Skip to content

Commit

Permalink
osbuild: add openscap profile and compliance policy id to facts
Browse files Browse the repository at this point in the history
  • Loading branch information
croissanne committed Sep 4, 2024
1 parent 398b06f commit 715c4ca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/osbuild/rhsm_facts_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ type RHSMFactsStageOptions struct {
}

type RHSMFacts struct {
ApiType string `json:"image-builder.osbuild-composer.api-type"`
ApiType string `json:"image-builder.osbuild-composer.api-type"`
OpenSCAPProfileID string `json:"image-builder.insights.openscap-profile-id,omitempty"`
CompliancePolicyID string `json:"image-builder.insights.compliance-policy-id,omitempty"`
}

func (RHSMFactsStageOptions) isStageOptions() {}
Expand Down
19 changes: 19 additions & 0 deletions pkg/osbuild/rhsm_facts_stage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@ func TestRHSMFactsStageJson(t *testing.T) {
},
JsonString: fmt.Sprintf(`{"facts":{"image-builder.osbuild-composer.api-type":"%s"}}`, "test-api"),
},
{
Options: RHSMFactsStageOptions{
Facts: RHSMFacts{
ApiType: "test-api",
OpenSCAPProfileID: "test-profile-id",
},
},
JsonString: fmt.Sprintf(`{"facts":{"image-builder.osbuild-composer.api-type":"%s","image-builder.insights.openscap-profile-id":"%s"}}`, "test-api", "test-profile-id"),
},
{
Options: RHSMFactsStageOptions{
Facts: RHSMFacts{
ApiType: "test-api",
OpenSCAPProfileID: "test-profile-id",
CompliancePolicyID: "test-compliance-policy-id",
},
},
JsonString: fmt.Sprintf(`{"facts":{"image-builder.osbuild-composer.api-type":"%s","image-builder.insights.openscap-profile-id":"%s","image-builder.insights.compliance-policy-id":"%s"}}`, "test-api", "test-profile-id", "test-compliance-policy-id"),
},
}
for _, test := range tests {
marshaledJson, err := json.Marshal(test.Options)
Expand Down

0 comments on commit 715c4ca

Please sign in to comment.