diff --git a/config/openshift/v4_16/translate.go b/config/openshift/v4_16/translate.go index edcffd9a..b66b2a3f 100644 --- a/config/openshift/v4_16/translate.go +++ b/config/openshift/v4_16/translate.go @@ -117,7 +117,6 @@ func (c Config) ToMachineConfig4_16Unvalidated(options common.TranslateOptions) if r.IsFatal() { return result.MachineConfig{}, ts, r } - ts = translateUserGrubCfg(&cfg, &ts) // wrap ts = ts.PrefixPaths(path.New("yaml"), path.New("json", "spec", "config")) @@ -302,26 +301,3 @@ func validateMCOSupport(mc result.MachineConfig) report.Report { } return r } - -// fcos config generates a user.cfg file using append; however, OpenShift config -// does not support append (since MCO does not support it). Let change the file to use contents -func translateUserGrubCfg(config *types.Config, ts *translate.TranslationSet) translate.TranslationSet { - newMappings := translate.NewTranslationSet("json", "json") - for i, file := range config.Storage.Files { - if file.Path == "/boot/grub2/user.cfg" { - if len(file.Append) != 1 { - // The number of append objects was different from expected, this file - // was created by the user and not via butane GRUB sugar - return *ts - } - fromPath := path.New("json", "storage", "files", i, "append", 0) - translatedPath := path.New("json", "storage", "files", i, "contents") - config.Storage.Files[i].FileEmbedded1.Contents = file.Append[0] - config.Storage.Files[i].FileEmbedded1.Append = nil - newMappings.AddFromCommonObject(fromPath, translatedPath, config.Storage.Files[i].FileEmbedded1.Contents) - - return ts.Map(newMappings) - } - } - return *ts -} diff --git a/config/openshift/v4_16/translate_test.go b/config/openshift/v4_16/translate_test.go index eed71140..496eb06c 100644 --- a/config/openshift/v4_16/translate_test.go +++ b/config/openshift/v4_16/translate_test.go @@ -272,89 +272,6 @@ func TestTranslateConfig(t *testing.T) { {From: path.New("yaml", "openshift", "fips"), To: path.New("json", "spec", "fips")}, }, }, - // Test Grub config - { - Config{ - Metadata: Metadata{ - Name: "z", - Labels: map[string]string{ - ROLE_LABEL_KEY: "z", - }, - }, - Config: fcos.Config{ - Grub: fcos.Grub{ - Users: []fcos.GrubUser{ - { - Name: "root", - PasswordHash: util.StrToPtr("grub.pbkdf2.sha512.10000.874A958E526409..."), - }, - }, - }, - }, - }, - result.MachineConfig{ - ApiVersion: result.MC_API_VERSION, - Kind: result.MC_KIND, - Metadata: result.Metadata{ - Name: "z", - Labels: map[string]string{ - ROLE_LABEL_KEY: "z", - }, - }, - Spec: result.Spec{ - Config: types.Config{ - Ignition: types.Ignition{ - Version: "3.4.0", - }, - Storage: types.Storage{ - Filesystems: []types.Filesystem{ - { - Device: "/dev/disk/by-label/boot", - Format: util.StrToPtr("ext4"), - Path: util.StrToPtr("/boot"), - }, - }, - Files: []types.File{ - { - Node: types.Node{ - Path: "/boot/grub2/user.cfg", - }, - FileEmbedded1: types.FileEmbedded1{ - Contents: types.Resource{ - Source: util.StrToPtr("data:,%23%20Generated%20by%20Butane%0A%0Aset%20superusers%3D%22root%22%0Apassword_pbkdf2%20root%20grub.pbkdf2.sha512.10000.874A958E526409...%0A"), - Compression: util.StrToPtr(""), - }, - }, - }, - }, - }, - }, - }, - }, - []translate.Translation{ - {From: path.New("yaml", "version"), To: path.New("json", "apiVersion")}, - {From: path.New("yaml", "version"), To: path.New("json", "kind")}, - {From: path.New("yaml", "version"), To: path.New("json", "spec")}, - {From: path.New("yaml"), To: path.New("json", "spec", "config")}, - {From: path.New("yaml", "ignition"), To: path.New("json", "spec", "config", "ignition")}, - {From: path.New("yaml", "version"), To: path.New("json", "spec", "config", "ignition", "version")}, - {From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage")}, - {From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "filesystems")}, - {From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "filesystems", 0)}, - {From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "filesystems", 0, "path")}, - {From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "filesystems", 0, "device")}, - {From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "filesystems", 0, "format")}, - {From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "files")}, - {From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "files", 0)}, - {From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "files", 0, "path")}, - // "append" field is a remnant of translations performed in fcos config - // TODO: add a delete function to translation.TranslationSet and delete "append" translation - {From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "files", 0, "append")}, - {From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "files", 0, "contents")}, - {From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "files", 0, "contents", "source")}, - {From: path.New("yaml", "grub", "users"), To: path.New("json", "spec", "config", "storage", "files", 0, "contents", "compression")}, - }, - }, } for i, test := range tests {