diff --git a/multi-node/aws/pkg/config/config.go b/multi-node/aws/pkg/config/config.go index 73f87c7fdc..073c28b87e 100644 --- a/multi-node/aws/pkg/config/config.go +++ b/multi-node/aws/pkg/config/config.go @@ -114,6 +114,12 @@ const ( vpcLogicalName = "VPC" ) +var supportedReleaseChannels = map[string]bool{ + "alpha": true, + "beta": true, + "stable": false, +} + func (c Cluster) Config() (*Config, error) { config := Config{Cluster: c} config.ETCDEndpoints = fmt.Sprintf("http://%s:2379", c.ControllerIP) @@ -329,6 +335,12 @@ func (cfg Cluster) valid() error { if cfg.ExternalDNSName == "" { return errors.New("externalDNSName must be set") } + + releaseChannelSupported := supportedReleaseChannels[cfg.ReleaseChannel] + if !releaseChannelSupported { + return fmt.Errorf("releaseChannel %s is not supported", cfg.ReleaseChannel) + } + if cfg.CreateRecordSet { if cfg.HostedZone == "" { return errors.New("hostedZone cannot be blank when createRecordSet is true") diff --git a/multi-node/aws/pkg/config/config_test.go b/multi-node/aws/pkg/config/config_test.go index 0241d47207..1503f7d559 100644 --- a/multi-node/aws/pkg/config/config_test.go +++ b/multi-node/aws/pkg/config/config_test.go @@ -253,3 +253,59 @@ func TestIsSubdomain(t *testing.T) { } } + +func TestReleaseChannel(t *testing.T) { + + validConfigs := []struct { + conf string + channel string + }{ + { + conf: ` +releaseChannel: alpha +`, + channel: "alpha", + }, + { + conf: ` +releaseChannel: beta +`, + channel: "beta", + }, + } + + invalidConfigs := []string{ + ` +#TODO(chom): move this to validConfigs when stable is supported +releaseChannel: stable # stable is not supported (yet). +`, + ` +releaseChannel: non-existant #this release channel will never exist +`, + } + + for _, conf := range validConfigs { + confBody := minimalConfigYaml + conf.conf + c, err := ClusterFromBytes([]byte(confBody)) + if err != nil { + t.Errorf("failed to parse config %s: %v", confBody, err) + continue + } + if c.ReleaseChannel != conf.channel { + t.Errorf( + "parsed release channel %s does not match config: %s", + c.ReleaseChannel, + confBody, + ) + } + } + + for _, conf := range invalidConfigs { + confBody := minimalConfigYaml + conf + _, err := ClusterFromBytes([]byte(confBody)) + if err == nil { + t.Errorf("expected error parsing invalid config: %s", confBody) + } + } + +} diff --git a/multi-node/aws/pkg/config/templates/cluster.yaml b/multi-node/aws/pkg/config/templates/cluster.yaml index 4705ec5273..9b69edebb5 100644 --- a/multi-node/aws/pkg/config/templates/cluster.yaml +++ b/multi-node/aws/pkg/config/templates/cluster.yaml @@ -9,13 +9,17 @@ clusterName: {{.ClusterName}} # for you. Otherwise the deployer is responsible for making this name routable externalDNSName: {{.ExternalDNSName}} +# CoreOS release channel to use. Currently supported options: [ alpha, beta ] +# See coreos.com/releases for more information +#releaseChannel: alpha + # Set to true if you want kube-aws to create a Route53 A Record for you. #createRecordSet: false # TTL in seconds for the Route53 RecordSet created if createRecordSet is set to true. #recordSetTTL: 300 -# The name of the hosted zone to add the externalDNSName to, +# The name of the hosted zone to add the externalDNSName to, # E.g: "google.com". This needs to already exist, kube-aws will not create # it for you. #hostedZone: ""