diff --git a/mantle/cmd/kola/options.go b/mantle/cmd/kola/options.go index e54050627506a7b4287e27ba7299435dcbd06e65..9ba44f403bad5c8e9dd3dc4c3d979c98897356c9 100644 --- a/mantle/cmd/kola/options.go +++ b/mantle/cmd/kola/options.go @@ -69,6 +69,8 @@ func init() { sv(&kola.Options.CosaWorkdir, "workdir", "", "coreos-assembler working directory") sv(&kola.Options.CosaBuildId, "build", "", "coreos-assembler build ID") sv(&kola.Options.CosaBuildArch, "arch", coreosarch.CurrentRpmArch(), "The target architecture of the build") + sv(&kola.Options.AppendButane, "append-butane", "", "Path to Butane config which is merged with test code") + sv(&kola.Options.AppendIgnition, "append-ignition", "", "Path to Ignition config which is merged with test code") // we make this a percentage to avoid having to deal with floats root.PersistentFlags().UintVar(&kola.Options.ExtendTimeoutPercent, "extend-timeout-percentage", 0, "Extend all test timeouts by N percent") // rhcos-specific options diff --git a/mantle/platform/cluster.go b/mantle/platform/cluster.go index 7a9b283e807ff739fa175fb9f9de792a79c470b5..51e804a76211cfb321423c5e3dfe65802db951f8 100644 --- a/mantle/platform/cluster.go +++ b/mantle/platform/cluster.go @@ -196,10 +196,63 @@ func (bc *BaseCluster) RenderUserData(userdata *platformConf.UserData, ignitionV userdata = userdata.Subst(k, v) } - conf, err := userdata.Render(bc.rconf.WarningsAction) + confSources := []*platformConf.Conf{} + + // Gather the base config + baseConf, err := userdata.Render(bc.rconf.WarningsAction) if err != nil { return nil, err } + // We may have multiple config sources; create an array now + // with that sole element. + confSources = append(confSources, baseConf) + + // If butane is specified, parse and add that. + if bc.bf.baseopts.AppendButane != "" { + buf, err := os.ReadFile(bc.bf.baseopts.AppendButane) + if err != nil { + return nil, err + } + subData := platformConf.Butane(string(buf)) + subConf, err := subData.Render(platformConf.ReportWarnings) + if err != nil { + return nil, err + } + confSources = append(confSources, subConf) + } + + // If Ignition is specified, parse and add that. + if bc.bf.baseopts.AppendIgnition != "" { + buf, err := os.ReadFile(bc.bf.baseopts.AppendIgnition) + if err != nil { + return nil, err + } + subData := platformConf.Ignition(string(buf)) + subConf, err := subData.Render(platformConf.ReportWarnings) + if err != nil { + return nil, err + } + confSources = append(confSources, subConf) + } + + // Look at the array of configs we have so far; if there is exactly one, + // then we don't need to do any merging. + var conf *platformConf.Conf + if len(confSources) == 1 { + conf = confSources[0] + } else { + // There are multiple configs; we now default to merging + // them all into a new Ignition config. + userdata, err := platformConf.MergeAllConfigs(confSources) + if err != nil { + return nil, err + } + + conf, err = userdata.Render(platformConf.ReportWarnings) + if err != nil { + return nil, err + } + } for _, dropin := range bc.bf.baseopts.SystemdDropins { conf.AddSystemdUnitDropin(dropin.Unit, dropin.Name, dropin.Contents) diff --git a/mantle/platform/platform.go b/mantle/platform/platform.go index 7e038d55795d3738c014c4ca62a696c0d519dfc1..56e45f6da9a51ab9e00204eb3ac1da5bf12cf73a 100644 --- a/mantle/platform/platform.go +++ b/mantle/platform/platform.go @@ -184,6 +184,9 @@ type Options struct { UseWarnExitCode77 bool + AppendButane string + AppendIgnition string + // OSContainer is an image pull spec that can be given to the pivot service // in RHCOS machines to perform machine content upgrades. // When specified additional files & units will be automatically generated