github.com/openshift/installer@v1.4.17/hack/build-coreos-manifest.go (about) 1 // We want to keep the stream metadata stored "directly" 2 // in git so it's easy to read and validate. This build 3 // script is invoked as part of the container build to 4 // inject the data into a ConfigMap that will be installed 5 // via CVO manifests into the target cluster, and maintained 6 // across upgrades. 7 package main 8 9 import ( 10 "fmt" 11 "os" 12 "path/filepath" 13 "strings" 14 15 corev1 "k8s.io/api/core/v1" 16 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 17 "sigs.k8s.io/yaml" 18 ) 19 20 const ( 21 streamRHCOSJSON = "data/data/coreos/rhcos.json" 22 streamFCOSJSON = "data/data/coreos/fcos.json" 23 fcosTAG = "okd" 24 dest = "bin/manifests/coreos-bootimages.yaml" 25 ) 26 27 func run() error { 28 streamJSON := streamRHCOSJSON 29 if tags, _ := os.LookupEnv("TAGS"); strings.Contains(tags, fcosTAG) { 30 streamJSON = streamFCOSJSON 31 } 32 bootimages, err := os.ReadFile(streamJSON) 33 if err != nil { 34 return err 35 } 36 37 cm := &corev1.ConfigMap{ 38 TypeMeta: metav1.TypeMeta{ 39 APIVersion: corev1.SchemeGroupVersion.String(), 40 Kind: "ConfigMap", 41 }, 42 ObjectMeta: metav1.ObjectMeta{ 43 Namespace: "openshift-machine-config-operator", 44 Name: "coreos-bootimages", 45 Annotations: map[string]string{ 46 "include.release.openshift.io/ibm-cloud-managed": "true", 47 "include.release.openshift.io/self-managed-high-availability": "true", 48 "include.release.openshift.io/single-node-developer": "true", 49 }, 50 }, 51 Data: map[string]string{ 52 "releaseVersion": "0.0.1-snapshot", 53 "stream": string(bootimages), 54 }, 55 } 56 57 b, err := yaml.Marshal(cm) 58 if err != nil { 59 return err 60 } 61 62 if err := os.MkdirAll(filepath.Dir(dest), 0755); err != nil { 63 return err 64 } 65 66 err = os.WriteFile(dest, b, 0o644) 67 if err != nil { 68 return err 69 } 70 71 return nil 72 } 73 74 func main() { 75 if err := run(); err != nil { 76 fmt.Fprintf(os.Stderr, "%s\n", err) 77 os.Exit(1) 78 } 79 }