Skip to content
This repository was archived by the owner on Sep 30, 2020. It is now read-only.

Commit a5d83c3

Browse files
committed
Fix tests
1 parent 5850ca8 commit a5d83c3

File tree

6 files changed

+15
-6
lines changed

6 files changed

+15
-6
lines changed

cmd/ami.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"github.com/kubernetes-incubator/kube-aws/core/root"
77
"github.com/kubernetes-incubator/kube-aws/flatcar/amiregistry"
88
"github.com/kubernetes-incubator/kube-aws/logger"
9-
"github.com/kubernetes-incubator/kube-aws/model"
109
"github.com/spf13/cobra"
1110
)
1211

@@ -35,8 +34,7 @@ func runCmdAmi(_ *cobra.Command, _ []string) error {
3534
region := cluster.ControlPlane().Region.Name
3635
channel := string(cluster.ControlPlane().ReleaseChannel)
3736

38-
releaseChannel := model.ReleaseChannel(channel)
39-
amiID, err := amiregistry.GetAMI(region, releaseChannel)
37+
amiID, err := amiregistry.GetAMI(region, cluster.ControlPlane().ReleaseChannel)
4038
if err != nil {
4139
return fmt.Errorf("Impossible to retrieve FlatCar AMI for region %s, channel %s", region, channel)
4240
}

cmd/init.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/kubernetes-incubator/kube-aws/filegen"
99
"github.com/kubernetes-incubator/kube-aws/flatcar/amiregistry"
1010
"github.com/kubernetes-incubator/kube-aws/logger"
11+
"github.com/kubernetes-incubator/kube-aws/model"
1112
"github.com/spf13/cobra"
1213
)
1314

@@ -20,7 +21,8 @@ var (
2021
SilenceUsage: true,
2122
}
2223

23-
initOpts = config.InitialConfig{}
24+
initOpts = config.InitialConfig{}
25+
releaseChannel = ""
2426
)
2527

2628
const (
@@ -38,6 +40,7 @@ func init() {
3840
cmdInit.Flags().StringVar(&initOpts.KeyName, "key-name", "", "The AWS key-pair for ssh access to nodes")
3941
cmdInit.Flags().StringVar(&initOpts.KMSKeyARN, "kms-key-arn", "", "The ARN of the AWS KMS key for encrypting TLS assets")
4042
cmdInit.Flags().StringVar(&initOpts.AmiId, "ami-id", "", "The AMI ID of Flatcar. Last Flatcar Stable Channel selected by default if empty")
43+
cmdInit.Flags().StringVar(&releaseChannel, "release-channel", defaultReleaseChannel, "Flatcar release channel for AMI")
4144
cmdInit.Flags().BoolVar(&initOpts.NoRecordSet, "no-record-set", false, "Instruct kube-aws to not manage Route53 record sets for your K8S API endpoints")
4245
}
4346

@@ -55,12 +58,14 @@ func runCmdInit(_ *cobra.Command, _ []string) error {
5558

5659
if initOpts.AmiId == "" {
5760
amiID, err := amiregistry.GetAMI(initOpts.Region.Name, defaultReleaseChannel)
58-
initOpts.AmiId = amiID
5961
if err != nil {
6062
return fmt.Errorf("cannot retrieve Flatcar AMI for region %s, channel %s", initOpts.Region.Name, defaultReleaseChannel)
6163
}
64+
initOpts.AmiId = amiID
6265
}
6366

67+
initOpts.ReleaseChannel = model.ReleaseChannel(defaultReleaseChannel)
68+
6469
if !initOpts.NoRecordSet && initOpts.HostedZoneID == "" {
6570
return errors.New("missing required flags: either --hosted-zone-id or --no-record-set is required")
6671
}

core/controlplane/cluster/cluster_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func defaultConfigValues(t *testing.T, configYaml string) string {
2929
defaultYaml := `
3030
externalDNSName: test.staging.core-os.net
3131
keyName: test-key-name
32+
releaseChannel: stable
3233
s3URI: s3://mybucket/mydir
3334
region: us-west-1
3435
clusterName: test-cluster-name

core/controlplane/config/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ func NewDefaultCluster() *Cluster {
174174
K8sVer: k8sVer,
175175
ContainerRuntime: "docker",
176176
Subnets: []model.Subnet{},
177+
ReleaseChannel: model.DefaultReleaseChannel(),
177178
EIPAllocationIDs: []string{},
178179
Experimental: experimental,
179180
Kubelet: kubelet,

core/controlplane/config/config_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ releaseChannel: non-existent #this release channel will never exist
515515
t.Errorf("failed to parse config %s: %v", confBody, err)
516516
continue
517517
}
518-
if c.ReleaseChannel != conf.channel {
518+
if string(c.ReleaseChannel) != conf.channel {
519519
t.Errorf(
520520
"parsed release channel %s does not match config: %s",
521521
c.ReleaseChannel,

model/release_channel.go

+4
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ func (ch ReleaseChannel) IsValid() error {
1818
}
1919
return errors.New("Invalid Release Channel")
2020
}
21+
22+
func DefaultReleaseChannel() ReleaseChannel {
23+
return ReleaseChannel(stable)
24+
}

0 commit comments

Comments
 (0)