osbuild2: update rhsm stage
The stage now allows for customizations specific to YUM or DNF. So far it is just an alias to the same definition, meaning that composer can use exactly the same structures for both. Ref: https://github.com/osbuild/osbuild/pull/876
This commit is contained in:
parent
0b4261b4da
commit
f4412ff07f
2 changed files with 57 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ package osbuild2
|
|||
// related components. Currently it allows only configuration of the enablement
|
||||
// state of DNF plugins used by the Subscription Manager.
|
||||
type RHSMStageOptions struct {
|
||||
YumPlugins *RHSMStageOptionsDnfPlugins `json:"yum-plugins,omitempty"`
|
||||
DnfPlugins *RHSMStageOptionsDnfPlugins `json:"dnf-plugins,omitempty"`
|
||||
SubMan *RHSMStageOptionsSubMan `json:"subscription-manager,omitempty"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
package osbuild2
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestNewRhsmStage(t *testing.T) {
|
||||
|
|
@ -14,3 +17,56 @@ func TestNewRhsmStage(t *testing.T) {
|
|||
actualStage := NewRHSMStage(&RHSMStageOptions{})
|
||||
assert.Equal(t, expectedStage, actualStage)
|
||||
}
|
||||
|
||||
func TestRhsmStageJson(t *testing.T) {
|
||||
tests := []struct {
|
||||
Options RHSMStageOptions
|
||||
JsonString string
|
||||
}{
|
||||
{
|
||||
Options: RHSMStageOptions{
|
||||
YumPlugins: &RHSMStageOptionsDnfPlugins{
|
||||
ProductID: &RHSMStageOptionsDnfPlugin{
|
||||
Enabled: true,
|
||||
},
|
||||
SubscriptionManager: &RHSMStageOptionsDnfPlugin{
|
||||
Enabled: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
JsonString: `{"yum-plugins":{"product-id":{"enabled":true},"subscription-manager":{"enabled":false}}}`,
|
||||
},
|
||||
{
|
||||
Options: RHSMStageOptions{
|
||||
DnfPlugins: &RHSMStageOptionsDnfPlugins{
|
||||
ProductID: &RHSMStageOptionsDnfPlugin{
|
||||
Enabled: true,
|
||||
},
|
||||
SubscriptionManager: &RHSMStageOptionsDnfPlugin{
|
||||
Enabled: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
JsonString: `{"dnf-plugins":{"product-id":{"enabled":true},"subscription-manager":{"enabled":false}}}`,
|
||||
},
|
||||
{
|
||||
Options: RHSMStageOptions{
|
||||
SubMan: &RHSMStageOptionsSubMan{
|
||||
Rhsm: &SubManConfigRHSMSection{},
|
||||
Rhsmcertd: &SubManConfigRHSMCERTDSection{},
|
||||
},
|
||||
},
|
||||
JsonString: `{"subscription-manager":{"rhsm":{},"rhsmcertd":{}}}`,
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
marshaledJson, err := json.Marshal(test.Options)
|
||||
require.NoError(t, err, "failed to marshal JSON")
|
||||
require.Equal(t, string(marshaledJson), test.JsonString)
|
||||
|
||||
var jsonOptions RHSMStageOptions
|
||||
err = json.Unmarshal([]byte(test.JsonString), &jsonOptions)
|
||||
require.NoError(t, err, "failed to parse JSON")
|
||||
require.True(t, reflect.DeepEqual(test.Options, jsonOptions))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue