Skip to content

Commit

Permalink
Set AWS architecture based on default payload architecture
Browse files Browse the repository at this point in the history
(This should be squashed into the AWS architecture commit prior to
merging, as it undoes some of those changes.)
  • Loading branch information
yselkowitz authored and Prashanth684 committed May 14, 2021
1 parent 7006de2 commit c0b82c8
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 56 deletions.
5 changes: 3 additions & 2 deletions pkg/asset/installconfig/aws/platform.go
Expand Up @@ -10,12 +10,13 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"github.com/openshift/installer/pkg/types"
"github.com/openshift/installer/pkg/types/aws"
"github.com/openshift/installer/pkg/version"
)

// Platform collects AWS-specific configuration.
func Platform(architecture types.Architecture) (*aws.Platform, error) {
func Platform() (*aws.Platform, error) {
architecture := version.DefaultArch()
regions := knownRegions(architecture)
longRegions := make([]string, 0, len(regions))
shortRegions := make([]string, 0, len(regions))
Expand Down
9 changes: 0 additions & 9 deletions pkg/asset/installconfig/installconfig.go
Expand Up @@ -80,15 +80,6 @@ func (a *InstallConfig) Generate(parents asset.Parents) error {
Networking: &types.Networking{
MachineNetwork: networking.machineNetwork,
},
ControlPlane: &types.MachinePool{
Architecture: platform.Architecture,
},
Compute: []types.MachinePool{
{
Name: "worker",
Architecture: platform.Architecture,
},
},
}

a.Config.AWS = platform.AWS
Expand Down
3 changes: 1 addition & 2 deletions pkg/asset/installconfig/installconfig_test.go
Expand Up @@ -24,8 +24,7 @@ func TestInstallConfigGenerate_FillsInDefaults(t *testing.T) {
clusterName := &clusterName{"test-cluster"}
pullSecret := &pullSecret{`{"auths":{"example.com":{"auth":"authorization value"}}}`}
platform := &platform{
Platform: types.Platform{None: &none.Platform{}},
Architecture: types.ArchitectureAMD64,
Platform: types.Platform{None: &none.Platform{}},
}
installConfig := &InstallConfig{}
networking := &networking{}
Expand Down
43 changes: 1 addition & 42 deletions pkg/asset/installconfig/platform.go
Expand Up @@ -3,7 +3,6 @@ package installconfig
import (
"fmt"
"sort"
"unsafe"

survey "github.com/AlecAivazis/survey/v2"
"github.com/AlecAivazis/survey/v2/core"
Expand Down Expand Up @@ -36,7 +35,6 @@ import (
// the cluster.
type platform struct {
types.Platform
Architecture types.Architecture
}

var _ asset.Asset = (*platform)(nil)
Expand All @@ -53,15 +51,9 @@ func (a *platform) Generate(asset.Parents) error {
return err
}

a.Architecture = types.ArchitectureAMD64
switch platform {
case aws.Name:
a.Architecture, err = a.queryUserForArchitecture(*(*[]string)(unsafe.Pointer(&types.ArchitectureListAWS)))
if err != nil {
return err
}

a.AWS, err = awsconfig.Platform(a.Architecture)
a.AWS, err = awsconfig.Platform()
if err != nil {
return err
}
Expand All @@ -71,11 +63,6 @@ func (a *platform) Generate(asset.Parents) error {
return err
}
case baremetal.Name:
a.Architecture, err = a.queryUserForArchitecture(*(*[]string)(unsafe.Pointer(&types.ArchitectureList)))
if err != nil {
return err
}

a.BareMetal, err = baremetalconfig.Platform()
if err != nil {
return err
Expand All @@ -86,11 +73,6 @@ func (a *platform) Generate(asset.Parents) error {
return err
}
case libvirt.Name:
a.Architecture, err = a.queryUserForArchitecture(*(*[]string)(unsafe.Pointer(&types.ArchitectureList)))
if err != nil {
return err
}

a.Libvirt, err = libvirtconfig.Platform()
if err != nil {
return err
Expand Down Expand Up @@ -150,29 +132,6 @@ func (a *platform) queryUserForPlatform() (platform string, err error) {
return
}

func (a *platform) queryUserForArchitecture(archlist []string) (architecture types.Architecture, err error) {
var arch string
err = survey.Ask([]*survey.Question{
{
Prompt: &survey.Select{
Message: "Architecture",
Help: "The architecture of the control plane and the compute nodes. Heterogenous clusters are not supported",
Default: types.ArchitectureAMD64,
Options: archlist,
},
Validate: survey.ComposeValidators(survey.Required, func(ans interface{}) error {
choice := ans.(string)
i := sort.SearchStrings(archlist, choice)
if i == len(archlist) || archlist[i] != choice {
return errors.Errorf("invalid architecture %q", choice)
}
return nil
}),
},
}, &arch)
return types.Architecture(arch), nil
}

func (a *platform) CurrentName() string {
return a.Platform.Name()
}
1 change: 0 additions & 1 deletion pkg/asset/store/assetcreate_test.go
Expand Up @@ -25,7 +25,6 @@ const userProvidedAssets = `{
},
"*installconfig.platform": {
"none": {}
"architecture": "amd64"
},
"*installconfig.pullSecret": {
"PullSecret": "{\"auths\": {\"example.com\": {\"auth\": \"test-auth\"}}}\n"
Expand Down

0 comments on commit c0b82c8

Please sign in to comment.