Skip to content

Commit

Permalink
add some information about interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarchie committed Nov 16, 2020
1 parent 8fbc0a4 commit c607eff
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 18 deletions.
37 changes: 30 additions & 7 deletions acceptance/create_vm_extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ var _ = Describe("create VM extension", func() {

BeforeEach(func() {
server = createTLSServer()
})

AfterEach(func() {
server.Close()
})

It("creates a VM extension in OpsMan", func() {
server.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("PUT", "/api/v0/staged/vm_extensions/some-vm-extension"),
Expand All @@ -37,7 +30,13 @@ var _ = Describe("create VM extension", func() {
}`),
),
)
})

AfterEach(func() {
server.Close()
})

It("creates a VM extension in OpsMan", func() {
command := exec.Command(pathToMain,
"--target", server.URL(),
"--username", "some-username",
Expand All @@ -54,4 +53,28 @@ var _ = Describe("create VM extension", func() {
Eventually(session).Should(gexec.Exit(0))
Expect(string(session.Out.Contents())).To(Equal("VM Extension 'some-vm-extension' created/updated\n"))
})

It("supports config file", func() {
command := exec.Command(pathToMain,
"--target", server.URL(),
"--username", "some-username",
"--password", "some-password",
"--skip-ssl-validation",
"create-vm-extension",
"--name", "some-vm-extension",
"--config", writeFile(`---
vm-extension-config:
name: some-vm-extension
cloud_properties:
iam_instance_profile: "some-iam-profile"
elbs: ["some-elb"]
`),
)

session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).ToNot(HaveOccurred())

Eventually(session).Should(gexec.Exit(0))
Expect(string(session.Out.Contents())).To(Equal("VM Extension 'some-vm-extension' created/updated\n"))
})
})
1 change: 1 addition & 0 deletions cmd/loadConfigFile.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func loadConfigFile(args []string, envFunc func() []string) ([]string, error) {
"configure-opsman",
"configure-product",
"credentials",
"create-vm-extension",
"interpolate",
"stage-product",
"staged-config",
Expand Down
2 changes: 1 addition & 1 deletion commands/assign_multi_stemcell.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type AssignMultiStemcell struct {
logger logger
service assignMultiStemcellService
Options struct {
interpolateConfigFileOptions
InterpolateOptions interpolateConfigFileOptions `group:"config file interpolation"`
ProductName string `long:"product" short:"p" description:"name of Ops Manager tile to associate a stemcell to" required:"true"`
Stemcells []string `long:"stemcell" short:"s" description:"associate a particular stemcell version to a tile (ie 'ubuntu-trusty:123.4')" required:"true"`
}
Expand Down
2 changes: 1 addition & 1 deletion commands/assign_stemcell.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type AssignStemcell struct {
logger logger
service assignStemcellService
Options struct {
interpolateConfigFileOptions
InterpolateOptions interpolateConfigFileOptions `group:"config file interpolation"`
ProductName string `long:"product" short:"p" description:"name of Ops Manager tile to associate a stemcell to" required:"true"`
StemcellVersion string `long:"stemcell" short:"s" description:"associate a particular stemcell version to a tile." default:"latest"`
}
Expand Down
2 changes: 1 addition & 1 deletion commands/config_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type ConfigTemplate struct {
environFunc envProvider
buildProvider buildProvider
Options struct {
interpolateConfigFileOptions
InterpolateOptions interpolateConfigFileOptions `group:"config file interpolation"`

PivnetApiToken string `long:"pivnet-api-token"`
PivnetProductSlug string `long:"pivnet-product-slug" description:"the product name in pivnet"`
Expand Down
2 changes: 1 addition & 1 deletion commands/configure_authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type ConfigureAuthentication struct {
logger logger
environFunc func() []string
Options struct {
interpolateConfigFileOptions
InterpolateOptions interpolateConfigFileOptions `group:"config file interpolation"`

Username string `long:"username" short:"u" env:"OM_USERNAME" description:"admin username" required:"true"`
Password string `long:"password" short:"p" env:"OM_PASSWORD" description:"admin password" required:"true"`
Expand Down
2 changes: 1 addition & 1 deletion commands/configure_ldap_authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type ConfigureLDAPAuthentication struct {
logger logger
environFunc func() []string
Options struct {
interpolateConfigFileOptions
InterpolateOptions interpolateConfigFileOptions `group:"config file interpolation"`

DecryptionPassphrase string `long:"decryption-passphrase" short:"d" required:"true" description:"passphrase used to encrypt the installation"`
HTTPProxyURL string `long:"http-proxy-url" description:"proxy for outbound HTTP network traffic"`
Expand Down
2 changes: 1 addition & 1 deletion commands/configure_saml_authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type ConfigureSAMLAuthentication struct {
logger logger
environFunc func() []string
Options struct {
interpolateConfigFileOptions
InterpolateOptions interpolateConfigFileOptions `group:"config file interpolation"`

DecryptionPassphrase string `long:"decryption-passphrase" short:"d" required:"true" description:"passphrase used to encrypt the installation"`
HTTPProxyURL string `long:"http-proxy-url" description:"proxy for outbound HTTP network traffic"`
Expand Down
2 changes: 1 addition & 1 deletion commands/disable_director_verfiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type DisableDirectorVerifiers struct {
presenter presenters.FormattedPresenter
logger logger
Options struct {
interpolateConfigFileOptions
InterpolateOptions interpolateConfigFileOptions `group:"config file interpolation"`

VerifierTypes []string `long:"type" short:"t" description:"verifier types to disable" required:"true"`
}
Expand Down
2 changes: 1 addition & 1 deletion commands/download_product.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type DownloadProductOptions struct {

AzureOptions
GCSOptions
interpolateConfigFileOptions
InterpolateOptions interpolateConfigFileOptions `group:"config file interpolation"`
PivnetOptions
S3Options
StemcellOptions
Expand Down
2 changes: 1 addition & 1 deletion commands/import_installation.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type ImportInstallation struct {
service importInstallationService
passphrase string
Options struct {
interpolateConfigFileOptions
InterpolateOptions interpolateConfigFileOptions `group:"config file interpolation"`

Installation string `long:"installation" short:"i" required:"true" description:"path to installation."`
PollingInterval int `long:"polling-interval" short:"p" description:"interval (in seconds) to check OpsManager availability" default:"10"`
Expand Down
5 changes: 5 additions & 0 deletions commands/interpolate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/pivotal-cf/om/interpolate"
"io/ioutil"
"log"
"os"
)

Expand All @@ -20,6 +21,10 @@ type interpolateConfigFileOptions struct {
VarsFile []string `long:"vars-file" short:"l" description:"load variables from a YAML file"`
Vars []string `long:"var" short:"v" description:"load variable from the command line. Format: VAR=VAL"`
}
func (*interpolateConfigFileOptions) UnmarshalFlag(value string) error {
log.Print("We made it!")
return nil
}

type Interpolate struct {
environFunc func() []string
Expand Down
2 changes: 1 addition & 1 deletion commands/upload_product.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type UploadProduct struct {
logger logger
service uploadProductService
Options struct {
interpolateConfigFileOptions
InterpolateOptions interpolateConfigFileOptions `group:"config file interpolation"`

Product string `long:"product" short:"p" description:"path to product" required:"true"`
PollingInterval int `long:"polling-interval" short:"i" description:"interval (in seconds) at which to print status" default:"1"`
Expand Down
2 changes: 1 addition & 1 deletion commands/upload_stemcell.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type UploadStemcell struct {
logger logger
service uploadStemcellService
Options struct {
interpolateConfigFileOptions
InterpolateOptions interpolateConfigFileOptions `group:"config file interpolation"`

Stemcell string `long:"stemcell" short:"s" required:"true" description:"path to stemcell"`
Force bool `long:"force" short:"f" description:"upload stemcell even if it already exists on the target Ops Manager"`
Expand Down

0 comments on commit c607eff

Please sign in to comment.