Add support for org.osbuild.rhsm stage
Add support to configure `org.osbuild.rhsm` osbuild stage. This stage allows the configuration of Red Hat Subscription Manager (RHSM) related components. Currently it is possible to configure only the enablement status of RHSM DNF plugins. Add `/docs/news/unreleased/osbuild-rhsm-stage.md` with information about the added support for `org.osbuild.rhsm` osbuild stage. Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
parent
f19e7a9c64
commit
1d48c92953
5 changed files with 87 additions and 0 deletions
6
docs/news/unreleased/osbuild-rhsm-stage.md
Normal file
6
docs/news/unreleased/osbuild-rhsm-stage.md
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# Add support for `org.osbuild.rhsm` osbuild stage
|
||||
|
||||
Add support for `org.osbuild.rhsm` osbuild stage. This stage is available in
|
||||
osbuild since version 24. The stage currently allows only configuring the
|
||||
enablement status of two RHSM DNF plugins, specifically of `product-id` and
|
||||
`subscription-manager` DNF plugins.
|
||||
34
internal/osbuild/rhsm_stage.go
Normal file
34
internal/osbuild/rhsm_stage.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package osbuild
|
||||
|
||||
// RHSMStageOptions describes configuration of the RHSM stage.
|
||||
//
|
||||
// The RHSM stage allows configuration of Red Hat Subscription Manager (RHSM)
|
||||
// related components. Currently it allows only configuration of the enablement
|
||||
// state of DNF plugins used by the Subscription Manager.
|
||||
type RHSMStageOptions struct {
|
||||
DnfPlugins *RHSMStageOptionsDnfPlugins `json:"dnf-plugins,omitempty"`
|
||||
}
|
||||
|
||||
func (RHSMStageOptions) isStageOptions() {}
|
||||
|
||||
// RHSMStageOptionsDnfPlugins describes configuration of all RHSM DNF plugins
|
||||
type RHSMStageOptionsDnfPlugins struct {
|
||||
ProductID *RHSMStageOptionsDnfPlugin `json:"product-id,omitempty"`
|
||||
SubscriptionManager *RHSMStageOptionsDnfPlugin `json:"subscription-manager,omitempty"`
|
||||
}
|
||||
|
||||
// RHSMStageOptionsDnfPlugin describes configuration of a specific RHSM DNF
|
||||
// plugin
|
||||
//
|
||||
// Only the enablement state of a DNF plugin can be currenlty set.
|
||||
type RHSMStageOptionsDnfPlugin struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
// NewRHSMStage creates a new RHSM stage
|
||||
func NewRHSMStage(options *RHSMStageOptions) *Stage {
|
||||
return &Stage{
|
||||
Name: "org.osbuild.rhsm",
|
||||
Options: options,
|
||||
}
|
||||
}
|
||||
16
internal/osbuild/rhsm_stage_test.go
Normal file
16
internal/osbuild/rhsm_stage_test.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package osbuild
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestNewRhsmStage(t *testing.T) {
|
||||
expectedStage := &Stage{
|
||||
Name: "org.osbuild.rhsm",
|
||||
Options: &RHSMStageOptions{},
|
||||
}
|
||||
actualStage := NewRHSMStage(&RHSMStageOptions{})
|
||||
assert.Equal(t, expectedStage, actualStage)
|
||||
}
|
||||
|
|
@ -60,6 +60,8 @@ func (stage *Stage) UnmarshalJSON(data []byte) error {
|
|||
options = new(KeymapStageOptions)
|
||||
case "org.osbuild.firewall":
|
||||
options = new(FirewallStageOptions)
|
||||
case "org.osbuild.rhsm":
|
||||
options = new(RHSMStageOptions)
|
||||
case "org.osbuild.rpm":
|
||||
options = new(RPMStageOptions)
|
||||
case "org.osbuild.rpm-ostree":
|
||||
|
|
|
|||
|
|
@ -172,6 +172,35 @@ func TestStage_UnmarshalJSON(t *testing.T) {
|
|||
data: []byte(`{"name":"org.osbuild.locale","options":{"language":""}}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "rhsm-empty",
|
||||
fields: fields{
|
||||
Name: "org.osbuild.rhsm",
|
||||
Options: &RHSMStageOptions{},
|
||||
},
|
||||
args: args{
|
||||
data: []byte(`{"name":"org.osbuild.rhsm","options":{}}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "rhsm",
|
||||
fields: fields{
|
||||
Name: "org.osbuild.rhsm",
|
||||
Options: &RHSMStageOptions{
|
||||
DnfPlugins: &RHSMStageOptionsDnfPlugins{
|
||||
ProductID: &RHSMStageOptionsDnfPlugin{
|
||||
Enabled: false,
|
||||
},
|
||||
SubscriptionManager: &RHSMStageOptionsDnfPlugin{
|
||||
Enabled: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
data: []byte(`{"name":"org.osbuild.rhsm","options":{"dnf-plugins":{"product-id":{"enabled":false},"subscription-manager":{"enabled":false}}}}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "rpm-empty",
|
||||
fields: fields{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue