osbuild2: change cloud-init stage to match osbuild v30
The `org.osbuild.cloud-init` 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:
parent
1abd9a1192
commit
d4de95ab5a
3 changed files with 21 additions and 30 deletions
|
|
@ -6,7 +6,8 @@ import (
|
|||
)
|
||||
|
||||
type CloudInitStageOptions struct {
|
||||
ConfigFiles map[string]CloudInitConfigFile `json:"configuration_files,omitempty"`
|
||||
Filename string `json:"filename"`
|
||||
Config CloudInitConfigFile `json:"config"`
|
||||
}
|
||||
|
||||
func (CloudInitStageOptions) isStageOptions() {}
|
||||
|
|
|
|||
|
|
@ -21,32 +21,33 @@ func TestCloudInitStage_MarshalJSON_Invalid(t *testing.T) {
|
|||
name string
|
||||
options CloudInitStageOptions
|
||||
}{
|
||||
{
|
||||
name: "empty-options",
|
||||
options: CloudInitStageOptions{},
|
||||
},
|
||||
{
|
||||
name: "no-config-file-section",
|
||||
options: CloudInitStageOptions{
|
||||
ConfigFiles: map[string]CloudInitConfigFile{
|
||||
"00-default_user.cfg": {},
|
||||
},
|
||||
Filename: "00-default_user.cfg",
|
||||
Config: CloudInitConfigFile{},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "no-system-info-section-option",
|
||||
options: CloudInitStageOptions{
|
||||
ConfigFiles: map[string]CloudInitConfigFile{
|
||||
"00-default_user.cfg": {
|
||||
SystemInfo: &CloudInitConfigSystemInfo{},
|
||||
},
|
||||
Filename: "00-default_user.cfg",
|
||||
Config: CloudInitConfigFile{
|
||||
SystemInfo: &CloudInitConfigSystemInfo{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "no-default-user-section-option",
|
||||
options: CloudInitStageOptions{
|
||||
ConfigFiles: map[string]CloudInitConfigFile{
|
||||
"00-default_user.cfg": {
|
||||
SystemInfo: &CloudInitConfigSystemInfo{
|
||||
DefaultUser: &CloudInitConfigDefaultUser{},
|
||||
},
|
||||
Filename: "00-default_user.cfg",
|
||||
Config: CloudInitConfigFile{
|
||||
SystemInfo: &CloudInitConfigSystemInfo{
|
||||
DefaultUser: &CloudInitConfigDefaultUser{},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -80,32 +80,21 @@ func TestStage_UnmarshalJSON(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "cloud-init",
|
||||
fields: fields{
|
||||
Type: "org.osbuild.cloud-init",
|
||||
Options: &CloudInitStageOptions{},
|
||||
},
|
||||
args: args{
|
||||
data: []byte(`{"type":"org.osbuild.cloud-init","options":{}}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "cloud-init-data",
|
||||
fields: fields{
|
||||
Type: "org.osbuild.cloud-init",
|
||||
Options: &CloudInitStageOptions{
|
||||
ConfigFiles: map[string]CloudInitConfigFile{
|
||||
"00-default_user.cfg": {
|
||||
SystemInfo: &CloudInitConfigSystemInfo{
|
||||
DefaultUser: &CloudInitConfigDefaultUser{
|
||||
Name: "ec2-user",
|
||||
},
|
||||
Filename: "00-default_user.cfg",
|
||||
Config: CloudInitConfigFile{
|
||||
SystemInfo: &CloudInitConfigSystemInfo{
|
||||
DefaultUser: &CloudInitConfigDefaultUser{
|
||||
Name: "ec2-user",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
data: []byte(`{"type":"org.osbuild.cloud-init","options":{"configuration_files":{"00-default_user.cfg":{"system_info":{"default_user":{"name":"ec2-user"}}}}}}`),
|
||||
data: []byte(`{"type":"org.osbuild.cloud-init","options":{"filename":"00-default_user.cfg","config":{"system_info":{"default_user":{"name":"ec2-user"}}}}}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue