Skip to content

Commit

Permalink
cloudapi: enable masked services
Browse files Browse the repository at this point in the history
Extend the cloudapi to accept masked systemd services as a
customization.
  • Loading branch information
kingsleyzissou authored and thozza committed Feb 29, 2024
1 parent f6b76cc commit c480d79
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 171 deletions.
8 changes: 8 additions & 0 deletions internal/cloudapi/v2/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ func (request *ComposeRequest) GetCustomizationsFromBlueprintRequest() (*bluepri
servicesCustomization.Disabled = make([]string, len(*rbpc.Services.Disabled))
copy(servicesCustomization.Disabled, *rbpc.Services.Disabled)
}
if rbpc.Services.Masked != nil {
servicesCustomization.Masked = make([]string, len(*rbpc.Services.Masked))
copy(servicesCustomization.Masked, *rbpc.Services.Masked)
}
c.Services = servicesCustomization
}

Expand Down Expand Up @@ -657,6 +661,10 @@ func (request *ComposeRequest) GetBlueprintFromCustomizations() (blueprint.Bluep
servicesCustomization.Disabled = make([]string, len(*request.Customizations.Services.Disabled))
copy(servicesCustomization.Disabled, *request.Customizations.Services.Disabled)
}
if request.Customizations.Services.Masked != nil {
servicesCustomization.Masked = make([]string, len(*request.Customizations.Services.Masked))
copy(servicesCustomization.Masked, *request.Customizations.Services.Masked)
}
bp.Customizations.Services = servicesCustomization
}

Expand Down
3 changes: 3 additions & 0 deletions internal/cloudapi/v2/compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func GetTestBlueprint() blueprint.Blueprint {
Services: &blueprint.ServicesCustomization{
Enabled: []string{"sshd"},
Disabled: []string{"cleanup"},
Masked: []string{"firewalld"},
},
OpenSCAP: &blueprint.OpenSCAPCustomization{
ProfileID: "B 263-59",
Expand Down Expand Up @@ -198,6 +199,7 @@ func TestGetBlueprintFromCustomizations(t *testing.T) {
Services: &Services{
Disabled: &[]string{"cleanup"},
Enabled: &[]string{"sshd"},
Masked: &[]string{"firewalld"},
},
Openscap: &OpenSCAP{ProfileId: "B 263-59"},
CustomRepositories: &[]CustomRepository{
Expand Down Expand Up @@ -320,6 +322,7 @@ func TestGetBlueprintFromCompose(t *testing.T) {
Services: &Services{
Disabled: &[]string{"cleanup"},
Enabled: &[]string{"sshd"},
Masked: &[]string{"firewalld"},
},
Openscap: &BlueprintOpenSCAP{ProfileId: "B 263-59"},
Repositories: &[]BlueprintRepository{
Expand Down
Loading

0 comments on commit c480d79

Please sign in to comment.