osbuild2: change modprobe stage to match osbuild v30

The `org.osbuild.modprobe` stage was reworked before the osbuild v30
release. Update the composer implementation to match the expected
schema.

Related to https://github.com/osbuild/osbuild/pull/739.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
Tomas Hozza 2021-07-26 14:47:28 +02:00 committed by Tomas Hozza
parent d4de95ab5a
commit b56642d6dd
3 changed files with 17 additions and 30 deletions

View file

@ -6,7 +6,8 @@ import (
)
type ModprobeStageOptions struct {
ConfigFiles map[string]ModprobeConfigCmdList `json:"configuration_files,omitempty"`
Filename string `json:"filename"`
Commands ModprobeConfigCmdList `json:"commands"`
}
func (ModprobeStageOptions) isStageOptions() {}

View file

@ -21,12 +21,15 @@ func TestModprobeStage_MarshalJSON_Invalid(t *testing.T) {
name string
options ModprobeStageOptions
}{
{
name: "empty-options",
options: ModprobeStageOptions{},
},
{
name: "no-commands",
options: ModprobeStageOptions{
ConfigFiles: map[string]ModprobeConfigCmdList{
"disallow-modules.conf": {},
},
Filename: "disallow-modules.conf",
Commands: ModprobeConfigCmdList{},
},
},
}

View file

@ -299,41 +299,24 @@ func TestStage_UnmarshalJSON(t *testing.T) {
},
{
name: "modprobe",
fields: fields{
Type: "org.osbuild.modprobe",
Options: &ModprobeStageOptions{},
},
args: args{
data: []byte(`{"type":"org.osbuild.modprobe","options":{}}`),
},
},
{
name: "modprobe-data",
fields: fields{
Type: "org.osbuild.modprobe",
Options: &ModprobeStageOptions{
ConfigFiles: map[string]ModprobeConfigCmdList{
"disallow-modules.conf": {
&ModprobeConfigCmdBlacklist{
Command: "blacklist",
Modulename: "nouveau",
},
&ModprobeConfigCmdBlacklist{
Command: "blacklist",
Modulename: "floppy",
},
Filename: "disallow-modules.conf",
Commands: ModprobeConfigCmdList{
&ModprobeConfigCmdBlacklist{
Command: "blacklist",
Modulename: "nouveau",
},
"disallow-additional-modules.conf": {
&ModprobeConfigCmdBlacklist{
Command: "blacklist",
Modulename: "my-module",
},
&ModprobeConfigCmdBlacklist{
Command: "blacklist",
Modulename: "floppy",
},
},
},
},
args: args{
data: []byte(`{"type":"org.osbuild.modprobe","options":{"configuration_files":{"disallow-additional-modules.conf":[{"command":"blacklist","modulename":"my-module"}],"disallow-modules.conf":[{"command":"blacklist","modulename":"nouveau"},{"command":"blacklist","modulename":"floppy"}]}}}`),
data: []byte(`{"type":"org.osbuild.modprobe","options":{"filename":"disallow-modules.conf","commands":[{"command":"blacklist","modulename":"nouveau"},{"command":"blacklist","modulename":"floppy"}]}}`),
},
},
{