github.com/openshift/installer@v1.4.17/pkg/asset/agent/common.go (about) 1 package agent 2 3 import ( 4 "github.com/sirupsen/logrus" 5 6 hiveext "github.com/openshift/assisted-service/api/hiveextension/v1beta1" 7 "github.com/openshift/installer/pkg/types" 8 "github.com/openshift/installer/pkg/types/baremetal" 9 "github.com/openshift/installer/pkg/types/external" 10 "github.com/openshift/installer/pkg/types/none" 11 "github.com/openshift/installer/pkg/types/vsphere" 12 ) 13 14 // SupportedInstallerPlatforms lists the supported platforms for agent installer. 15 func SupportedInstallerPlatforms() []string { 16 return []string{baremetal.Name, vsphere.Name, none.Name, external.Name} 17 } 18 19 var supportedHivePlatforms = []hiveext.PlatformType{ 20 hiveext.BareMetalPlatformType, 21 hiveext.VSpherePlatformType, 22 hiveext.NonePlatformType, 23 hiveext.ExternalPlatformType, 24 } 25 26 // SupportedHivePlatforms lists the supported platforms for AgentClusterInstall. 27 func SupportedHivePlatforms() []string { 28 platforms := []string{} 29 for _, p := range supportedHivePlatforms { 30 platforms = append(platforms, string(p)) 31 } 32 return platforms 33 } 34 35 // HivePlatformType returns the PlatformType for the ZTP Hive API corresponding 36 // to the given InstallConfig platform. 37 func HivePlatformType(platform types.Platform) hiveext.PlatformType { 38 switch platform.Name() { 39 case baremetal.Name: 40 return hiveext.BareMetalPlatformType 41 case external.Name: 42 return hiveext.ExternalPlatformType 43 case none.Name: 44 return hiveext.NonePlatformType 45 case vsphere.Name: 46 return hiveext.VSpherePlatformType 47 } 48 return "" 49 } 50 51 // IsSupportedPlatform returns true if provided platform is supported. 52 // Otherwise, returns false. 53 func IsSupportedPlatform(platform hiveext.PlatformType) bool { 54 for _, p := range supportedHivePlatforms { 55 if p == platform { 56 return true 57 } 58 } 59 return false 60 } 61 62 // DetermineReleaseImageArch returns the arch of the release image. 63 func DetermineReleaseImageArch(pullSecret, pullSpec string) (string, error) { 64 templateFilter := "-o=go-template={{if and .metadata.metadata (index . \"metadata\" \"metadata\" \"release.openshift.io/architecture\")}}{{index . \"metadata\" \"metadata\" \"release.openshift.io/architecture\"}}{{else}}{{.config.architecture}}{{end}}" 65 insecure := "--insecure=true" 66 var getReleaseArch = []string{ 67 "oc", 68 "adm", 69 "release", 70 "info", 71 pullSpec, 72 templateFilter, 73 insecure, 74 } 75 76 releaseArch, err := ExecuteOC(pullSecret, getReleaseArch) 77 if err != nil { 78 logrus.Errorf("Release Image arch could not be found: %s", err) 79 return "", err 80 } 81 logrus.Debugf("Release Image arch is: %s", releaseArch) 82 return releaseArch, nil 83 }