github.com/openshift/installer@v1.4.17/pkg/types/utils.go (about) 1 package types 2 3 import ( 4 "fmt" 5 "os" 6 7 "github.com/sirupsen/logrus" 8 9 configv1 "github.com/openshift/api/config/v1" 10 features "github.com/openshift/api/features" 11 ) 12 13 // StringsToIPs is used to convert list of strings to list of IP addresses. 14 func StringsToIPs(ips []string) []configv1.IP { 15 res := []configv1.IP{} 16 17 if ips == nil { 18 return res 19 } 20 21 for _, ip := range ips { 22 res = append(res, configv1.IP(ip)) 23 } 24 25 return res 26 } 27 28 // MachineNetworksToCIDRs is used to convert list of Machine Network Entries to 29 // list of CIDRs. 30 func MachineNetworksToCIDRs(nets []MachineNetworkEntry) []configv1.CIDR { 31 res := []configv1.CIDR{} 32 33 if nets == nil { 34 return res 35 } 36 37 for _, net := range nets { 38 res = append(res, configv1.CIDR(net.CIDR.String())) 39 } 40 41 return res 42 } 43 44 // GetClusterProfileName utility method to retrieve the cluster profile setting. This is used 45 // when dealing with openshift api to get FeatureSets. 46 func GetClusterProfileName() features.ClusterProfileName { 47 // Get cluster profile for new FeatureGate access. Blank is no longer an option, so default to 48 // SelfManaged. 49 clusterProfile := features.SelfManaged 50 if cp := os.Getenv("OPENSHIFT_INSTALL_EXPERIMENTAL_CLUSTER_PROFILE"); cp != "" { 51 logrus.Warnf("Found override for Cluster Profile: %q", cp) 52 // All profiles when getting FeatureSets need to have "include.release.openshift.io/" at the beginning. 53 // See vendor/openshift/api/config/v1/feature_gates.go for more info. 54 clusterProfile = features.ClusterProfileName(fmt.Sprintf("%s%s", "include.release.openshift.io/", cp)) 55 } 56 return clusterProfile 57 }