diff --git a/acceptance/create_vm_extension_test.go b/acceptance/create_vm_extension_test.go index 42c6876e6..176bea085 100644 --- a/acceptance/create_vm_extension_test.go +++ b/acceptance/create_vm_extension_test.go @@ -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"), @@ -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", @@ -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")) + }) }) diff --git a/cmd/loadConfigFile.go b/cmd/loadConfigFile.go index 0c20e11bf..a4a2b6e98 100644 --- a/cmd/loadConfigFile.go +++ b/cmd/loadConfigFile.go @@ -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", diff --git a/commands/assign_multi_stemcell.go b/commands/assign_multi_stemcell.go index 99d63cfb9..f2a6d7dcd 100644 --- a/commands/assign_multi_stemcell.go +++ b/commands/assign_multi_stemcell.go @@ -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"` } diff --git a/commands/assign_stemcell.go b/commands/assign_stemcell.go index 9d805a509..488a16457 100644 --- a/commands/assign_stemcell.go +++ b/commands/assign_stemcell.go @@ -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"` } diff --git a/commands/config_template.go b/commands/config_template.go index 6aae3652d..b827d5602 100644 --- a/commands/config_template.go +++ b/commands/config_template.go @@ -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"` diff --git a/commands/configure_authentication.go b/commands/configure_authentication.go index 2096e84d1..2994113e6 100644 --- a/commands/configure_authentication.go +++ b/commands/configure_authentication.go @@ -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"` diff --git a/commands/configure_ldap_authentication.go b/commands/configure_ldap_authentication.go index 247d0a2cd..f2be40c00 100644 --- a/commands/configure_ldap_authentication.go +++ b/commands/configure_ldap_authentication.go @@ -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"` diff --git a/commands/configure_saml_authentication.go b/commands/configure_saml_authentication.go index 2016861d6..1f755f4cd 100644 --- a/commands/configure_saml_authentication.go +++ b/commands/configure_saml_authentication.go @@ -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"` diff --git a/commands/disable_director_verfiers.go b/commands/disable_director_verfiers.go index a437eb2d8..32b98ab37 100644 --- a/commands/disable_director_verfiers.go +++ b/commands/disable_director_verfiers.go @@ -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"` } diff --git a/commands/download_product.go b/commands/download_product.go index 260b9c722..cff3ee959 100644 --- a/commands/download_product.go +++ b/commands/download_product.go @@ -78,7 +78,7 @@ type DownloadProductOptions struct { AzureOptions GCSOptions - interpolateConfigFileOptions + InterpolateOptions interpolateConfigFileOptions `group:"config file interpolation"` PivnetOptions S3Options StemcellOptions diff --git a/commands/import_installation.go b/commands/import_installation.go index 5bf77ee2b..201934e0e 100644 --- a/commands/import_installation.go +++ b/commands/import_installation.go @@ -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"` diff --git a/commands/interpolate.go b/commands/interpolate.go index a81065376..554405db6 100644 --- a/commands/interpolate.go +++ b/commands/interpolate.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/pivotal-cf/om/interpolate" "io/ioutil" + "log" "os" ) @@ -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 diff --git a/commands/upload_product.go b/commands/upload_product.go index 826f156bc..c62535bfe 100644 --- a/commands/upload_product.go +++ b/commands/upload_product.go @@ -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"` diff --git a/commands/upload_stemcell.go b/commands/upload_stemcell.go index acc24277f..2b9c31acc 100644 --- a/commands/upload_stemcell.go +++ b/commands/upload_stemcell.go @@ -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"`