Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
Merge pull request #427 from colhom/release-channel
Browse files Browse the repository at this point in the history
kube-aws: configurable release channel
  • Loading branch information
colhom committed Apr 22, 2016
2 parents 26244de + 418614a commit 69871dc
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
12 changes: 12 additions & 0 deletions multi-node/aws/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
56 changes: 56 additions & 0 deletions multi-node/aws/pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

}
6 changes: 5 additions & 1 deletion multi-node/aws/pkg/config/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
Expand Down

0 comments on commit 69871dc

Please sign in to comment.