Skip to content

Commit

Permalink
blueprint: add cacert customization
Browse files Browse the repository at this point in the history
  • Loading branch information
lzap committed Nov 29, 2024
1 parent 1372be3 commit e307d8d
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 186 deletions.
7 changes: 7 additions & 0 deletions internal/blueprint/blueprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,13 @@ func Convert(bp Blueprint) iblueprint.Blueprint {

customizations.RHSM = &irhsm
}

if ca := c.CACerts; ca != nil {
ica := iblueprint.CACustomization{
PEMCerts: ca.PEMCerts,
}
customizations.CACerts = &ica
}
}

ibp := iblueprint.Blueprint{
Expand Down
6 changes: 6 additions & 0 deletions internal/blueprint/blueprint_convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ func TestConvert(t *testing.T) {
},
},
},
CACerts: &CACustomization{
PEMCerts: []string{"pem-cert"},
},
},
Distro: "distro",
},
Expand Down Expand Up @@ -401,6 +404,9 @@ func TestConvert(t *testing.T) {
},
},
},
CACerts: &iblueprint.CACustomization{
PEMCerts: []string{"pem-cert"},
},
},
Distro: "distro",
},
Expand Down
5 changes: 5 additions & 0 deletions internal/blueprint/customizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Customizations struct {
Installer *InstallerCustomization `json:"installer,omitempty" toml:"installer,omitempty"`
RPM *RPMCustomization `json:"rpm,omitempty" toml:"rpm,omitempty"`
RHSM *RHSMCustomization `json:"rhsm,omitempty" toml:"rhsm,omitempty"`
CACerts *CACustomization `json:"cacerts,omitempty" toml:"cacerts,omitempty"`
}

type IgnitionCustomization struct {
Expand Down Expand Up @@ -135,6 +136,10 @@ type OpenSCAPJSONTailoringCustomizations struct {
Filepath string `json:"filepath,omitempty" toml:"filepath,omitempty"`
}

type CACustomization struct {
PEMCerts []string `json:"pem_certs,omitempty" toml:"pem_certs,omitempty"`
}

type CustomizationError struct {
Message string
}
Expand Down
6 changes: 6 additions & 0 deletions internal/cloudapi/v2/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,12 @@ func (request *ComposeRequest) GetBlueprintFromCustomizations() (blueprint.Bluep
bp.Customizations.RHSM = bpRhsm
}

if cacerts := request.Customizations.Cacerts; cacerts != nil {
bp.Customizations.CACerts = &blueprint.CACustomization{
PEMCerts: cacerts.PemCerts,
}
}

// Did bp.Customizations get set at all? If not, set it back to nil
if reflect.DeepEqual(*bp.Customizations, blueprint.Customizations{}) {
bp.Customizations = nil
Expand Down
Loading

0 comments on commit e307d8d

Please sign in to comment.