Skip to content
This repository has been archived by the owner on Jul 12, 2018. It is now read-only.

Commit

Permalink
[#128032919] fix typo in required flag check
Browse files Browse the repository at this point in the history
Change go-agent-sha to go-agent-release-sha for consistency.

Signed-off-by: John Calabrese <jcalabrese@pivotal.io>
  • Loading branch information
zmb3 authored and xchapter7x committed Aug 9, 2016
1 parent ba666eb commit d6671ea
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
26 changes: 20 additions & 6 deletions plugins/products/bosh-init/bosh_cli_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func BoshFlags(defaults *BoshBase) []cli.Flag {
cli.StringFlag{Name: "bosh-release-url", Value: defaults.BoshReleaseURL, Usage: "url to bosh release"},
cli.StringFlag{Name: "bosh-cpi-release-sha", Value: defaults.CPIReleaseSHA, Usage: "sha1 of the cpi release being used (found on bosh.io)"},
cli.StringFlag{Name: "bosh-cpi-release-url", Value: defaults.CPIReleaseURL, Usage: "url to bosh cpi release"},
cli.StringFlag{Name: "go-agent-sha", Value: defaults.GOAgentSHA, Usage: "sha1 of the go agent being use (found on bosh.io)"},
cli.StringFlag{Name: "go-agent-release-sha", Value: defaults.GOAgentSHA, Usage: "sha1 of the go agent being use (found on bosh.io)"},
cli.StringFlag{Name: "go-agent-release-url", Value: defaults.GOAgentReleaseURL, Usage: "url to stemcell release"},
cli.StringFlag{Name: "director-name", Value: "enaml-bosh", Usage: "the name of your director"},
cli.StringFlag{Name: "uaa-release-sha", Value: "899f1e10f27e82ac524f1158a513392bbfabf2a0", Usage: "sha1 of the uaa release being used (found on bosh.io)"},
Expand All @@ -30,12 +30,26 @@ func BoshFlags(defaults *BoshBase) []cli.Flag {
}
}

var RequiredBoshFlags = []string{
"cidr",
"gateway",
"dns",
"bosh-private-ip",
"bosh-release-url",
"bosh-release-sha",
"bosh-cpi-release-url",
"bosh-cpi-release-sha",
"go-agent-release-url",
"go-agent-release-sha",
"director-name",
"uaa-release-url",
"uaa-release-sha",
"ntp-server",
}

func NewBoshBase(c *cli.Context) (base *BoshBase, err error) {

utils.CheckRequired(c, "cidr", "gateway", "dns", "bosh-private-ip",
"bosh-release-url", "bosh-release-sha", "bosh-cpi-release-url", "bosh-cpi-release-sha",
"go-agent-url", "go-agent-sha", "director-name", "uaa-release-url",
"uaa-release-sha", "ntp-server")
utils.CheckRequired(c, RequiredBoshFlags...)

base = &BoshBase{
Mode: c.String("mode"),
Expand All @@ -48,7 +62,7 @@ func NewBoshBase(c *cli.Context) (base *BoshBase, err error) {
BoshReleaseURL: c.String("bosh-release-url"),
CPIReleaseSHA: c.String("bosh-cpi-release-sha"),
CPIReleaseURL: c.String("bosh-cpi-release-url"),
GOAgentSHA: c.String("go-agent-sha"),
GOAgentSHA: c.String("go-agent-release-sha"),
GOAgentReleaseURL: c.String("go-agent-release-url"),
DirectorName: c.String("director-name"),
UAAReleaseSHA: c.String("uaa-release-sha"),
Expand Down
23 changes: 23 additions & 0 deletions plugins/products/bosh-init/bosh_cli_helper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package boshinit_test

import (
. "github.com/enaml-ops/omg-cli/plugins/products/bosh-init"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

var _ = Describe("BOSH CLI helpers", func() {
Describe("given a set of bosh required flags", func() {
Context("when used to check for use of required flags", func() {
It("then it should only allow fields to be defined when they are valid bosh flags", func() {
var validFlags []string
for _, f := range BoshFlags(NewPhotonBoshBase()) {
validFlags = append(validFlags, f.GetName())
}
for _, required := range RequiredBoshFlags {
Ω(validFlags).Should(ContainElement(required))
}
})
})
})
})

0 comments on commit d6671ea

Please sign in to comment.