osbuild2: support for subscription-manager option in org.osbuild.rhsm
Add support for the newly added `subscription-manager` option in the `org.osbuild.rhsm` osbuild stage [1]. The option allows one to create configure subset of subscription-manager options in its configuration file `/etc/rhsm/rhsm.conf`. Add unit test cases for the added functionality. [1] https://github.com/osbuild/osbuild/pull/659 Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
parent
29ade764ce
commit
8367542f25
2 changed files with 34 additions and 7 deletions
|
|
@ -7,10 +7,19 @@ package osbuild2
|
|||
// state of DNF plugins used by the Subscription Manager.
|
||||
type RHSMStageOptions struct {
|
||||
DnfPlugins *RHSMStageOptionsDnfPlugins `json:"dnf-plugins,omitempty"`
|
||||
SubMan *RHSMStageOptionsSubMan `json:"subscription-manager,omitempty"`
|
||||
}
|
||||
|
||||
func (RHSMStageOptions) isStageOptions() {}
|
||||
|
||||
// NewRHSMStage creates a new RHSM stage
|
||||
func NewRHSMStage(options *RHSMStageOptions) *Stage {
|
||||
return &Stage{
|
||||
Type: "org.osbuild.rhsm",
|
||||
Options: options,
|
||||
}
|
||||
}
|
||||
|
||||
// RHSMStageOptionsDnfPlugins describes configuration of all RHSM DNF plugins
|
||||
type RHSMStageOptionsDnfPlugins struct {
|
||||
ProductID *RHSMStageOptionsDnfPlugin `json:"product-id,omitempty"`
|
||||
|
|
@ -25,10 +34,20 @@ type RHSMStageOptionsDnfPlugin struct {
|
|||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
// NewRHSMStage creates a new RHSM stage
|
||||
func NewRHSMStage(options *RHSMStageOptions) *Stage {
|
||||
return &Stage{
|
||||
Type: "org.osbuild.rhsm",
|
||||
Options: options,
|
||||
}
|
||||
// Subscription-manager configuration (/etc/rhsm/rhsm.conf)
|
||||
type RHSMStageOptionsSubMan struct {
|
||||
Rhsm *SubManConfigRHSMSection `json:"rhsm,omitempty"`
|
||||
Rhsmcertd *SubManConfigRHSMCERTDSection `json:"rhsmcertd,omitempty"`
|
||||
}
|
||||
|
||||
// RHSM configuration section of /etc/rhsm/rhsm.conf
|
||||
type SubManConfigRHSMSection struct {
|
||||
// Whether subscription-manager should manage DNF repos file
|
||||
ManageRepos *bool `json:"manage_repos,omitempty"`
|
||||
}
|
||||
|
||||
// RHSMCERTD configuration section of /etc/rhsm/rhsm.conf
|
||||
type SubManConfigRHSMCERTDSection struct {
|
||||
// Automatic system registration
|
||||
AutoRegistration *bool `json:"auto_registration,omitempty"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -311,10 +311,18 @@ func TestStage_UnmarshalJSON(t *testing.T) {
|
|||
Enabled: false,
|
||||
},
|
||||
},
|
||||
SubMan: &RHSMStageOptionsSubMan{
|
||||
Rhsm: &SubManConfigRHSMSection{
|
||||
ManageRepos: common.BoolToPtr(false),
|
||||
},
|
||||
Rhsmcertd: &SubManConfigRHSMCERTDSection{
|
||||
AutoRegistration: common.BoolToPtr(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
data: []byte(`{"type":"org.osbuild.rhsm","options":{"dnf-plugins":{"product-id":{"enabled":false},"subscription-manager":{"enabled":false}}}}`),
|
||||
data: []byte(`{"type":"org.osbuild.rhsm","options":{"dnf-plugins":{"product-id":{"enabled":false},"subscription-manager":{"enabled":false}},"subscription-manager":{"rhsm":{"manage_repos":false},"rhsmcertd":{"auto_registration":true}}}}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue