Created
January 24, 2021 21:29
-
-
Save rogerwelin/c33aaa3cdf79e187186cdeb8f650b4d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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