Skip to content

Instantly share code, notes, and snippets.

@rogerwelin
Created January 24, 2021 21:29
Show Gist options
  • Save rogerwelin/c33aaa3cdf79e187186cdeb8f650b4d9 to your computer and use it in GitHub Desktop.
Save rogerwelin/c33aaa3cdf79e187186cdeb8f650b4d9 to your computer and use it in GitHub Desktop.
package main
import (
"io/ioutil"
"gopkg.in/yaml.v2"
)
type config struct {
APIVersion string `yaml:"apiVersion"`
Kind string `yaml:"kind"`
PatchesStrategicMerge []string `yaml:"patchesStrategicMerge"`
Images []Images `yaml:"images"`
Resources []string `yaml:"resources"`
}
type Images struct {
Name string `yaml:"name"`
NewName string `yaml:"newName"`
NewTag string `yaml:"newTag"`
}
func main() {
var apa config
f, err := ioutil.ReadFile("kustomize.yaml")
if err != nil {
panic(err)
}
err = yaml.Unmarshal(f, &apa)
if err != nil {
panic(err)
}
apa.Images[0].NewTag = "abc123"
newyaml, err := yaml.Marshal(apa)
if err != nil {
panic(err)
}
err = ioutil.WriteFile("kustomize.yaml", newyaml, 0644)
if err != nil {
panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment