Skip to content

Commit

Permalink
MTL-2000 Handle both formats (#334)
Browse files Browse the repository at this point in the history
Handle `cloud-init.yaml` with or without a root `zypper` key.
  • Loading branch information
rustydb authored Aug 18, 2023
1 parent fdf99cb commit 78867e4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions cmd/patch/patch-packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,19 @@ func loadPackagesConfig(filePath string) (UserData, error) {
return data, err
}

if err := yaml.Unmarshal(config, &configData); err != nil {
// Handle config files with or without the ``zypper`` root key.
if err := yaml.Unmarshal(config, &data); err != nil {
return data, err
}

data.Zypper = Zypper{
Repos: configData.Repos,
if data.Zypper.Repos == nil {
if err := yaml.Unmarshal(config, &configData); err != nil {
return data, err
}
data.Zypper = Zypper{
Repos: configData.Repos,
}
data.Packages = configData.Packages
}
data.Packages = configData.Packages

return data, err
}

Expand Down

0 comments on commit 78867e4

Please sign in to comment.