github.com/openshift/installer@v1.4.17/pkg/infrastructure/clusterapi/helpers.go (about) 1 package clusterapi 2 3 import ( 4 "encoding/json" 5 "fmt" 6 "net" 7 8 igntypes "github.com/coreos/ignition/v2/config/v3_2/types" 9 10 "github.com/openshift/installer/pkg/asset/ignition" 11 "github.com/openshift/installer/pkg/asset/openshiftinstall" 12 "github.com/openshift/installer/pkg/types" 13 ) 14 15 // injectInstallInfo adds information about the installer and its invoker as a 16 // ConfigMap to the provided bootstrap Ignition config. 17 func injectInstallInfo(bootstrap []byte) ([]byte, error) { 18 config := &igntypes.Config{} 19 if err := json.Unmarshal(bootstrap, &config); err != nil { 20 return nil, fmt.Errorf("failed to unmarshal bootstrap Ignition config: %w", err) 21 } 22 23 cm, err := openshiftinstall.CreateInstallConfigMap("openshift-install") 24 if err != nil { 25 return nil, fmt.Errorf("failed to generate openshift-install config: %w", err) 26 } 27 28 config.Storage.Files = append(config.Storage.Files, ignition.FileFromString("/opt/openshift/manifests/openshift-install.yaml", "root", 0644, cm)) 29 30 ign, err := ignition.Marshal(config) 31 if err != nil { 32 return nil, fmt.Errorf("failed to marshal bootstrap Ignition config: %w", err) 33 } 34 35 return ign, nil 36 } 37 38 func prioritizeIPv4(config *types.InstallConfig, addresses []string) string { 39 if len(addresses) == 0 { 40 return "" 41 } 42 43 if config.Platform.Name() == "vsphere" { 44 for _, a := range addresses { 45 ip := net.ParseIP(a) 46 if ip.To4() != nil { 47 return a 48 } 49 } 50 } 51 52 return addresses[0] 53 }