From f1b909b9706e059a16e942cde28147a63727b88a Mon Sep 17 00:00:00 2001 From: cappyzawa Date: Wed, 10 Apr 2019 00:56:37 +0900 Subject: [PATCH] enable to specify app name --- main.go | 6 +++--- plug/command.go | 5 +++-- plug/command_test.go | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index a4ae8b0..7235ccc 100644 --- a/main.go +++ b/main.go @@ -60,7 +60,7 @@ func (c *CfPushWithVault) Run(cliConnection plugin.CliConnection, args []string) Variables: variables, } - if err := command.Push(fc.String("file")); err != nil { + if err := command.Push(fc.String("file"), fc.Args()[1:]); err != nil { fmt.Fprintf(os.Stdout, "failed to push with vault: %v", err) os.Exit(1) } @@ -73,14 +73,14 @@ func (c *CfPushWithVault) GetMetadata() plugin.PluginMetadata { Version: plugin.VersionType{ Major: 0, Minor: 0, - Build: 1, + Build: 2, }, Commands: []plugin.Command{ { Name: "push-with-vault", HelpText: "This enable to use (( )) place holders in manifest files. (( )) are evaluated by vault", UsageDetails: plugin.Usage{ - Usage: "$ cf push-with-vault", + Usage: "$ cf push-with-vault [APP_NAME]", Options: map[string]string{ "-file": "Path to manifest (default: ./manifest.yml)", "-vault-addr": "Address of the Vault server expressed as a URL and port, for example: https://127.0.0.1:8200/. (default: \"VAULT_ADDR\" env)", diff --git a/plug/command.go b/plug/command.go index 5f4d2d7..c52605f 100644 --- a/plug/command.go +++ b/plug/command.go @@ -18,7 +18,7 @@ type Command struct { } // Push pushes cf app based on manifest -func (c *Command) Push(file string) error { +func (c *Command) Push(file string, args []string) error { // read file absFile, err := filepath.Abs(file) if err != nil { @@ -42,8 +42,9 @@ func (c *Command) Push(file string) error { return err } + args = append([]string{"push", "-f", tmpFile.Name()}, args...) // cf push - if _, err := c.CliConnection.CliCommand("push", "-f", tmpFile.Name()); err != nil { + if _, err := c.CliConnection.CliCommand(args...); err != nil { return err } diff --git a/plug/command_test.go b/plug/command_test.go index 8d7f87c..55d651d 100644 --- a/plug/command_test.go +++ b/plug/command_test.go @@ -28,13 +28,13 @@ var _ = Describe("Command", func() { Describe("Push()", func() { Context("manifest file is missing", func() { It("an error is occurred", func() { - err := command.Push("../testdata/missing.yml") + err := command.Push("../testdata/missing.yml", []string{"testApp"}) Expect(err).To(HaveOccurred()) }) }) Context("manifest file does not contain parameters", func() { It("access to the vault does not occur", func() { - err := command.Push("../testdata/no_contains_params.yml") + err := command.Push("../testdata/no_contains_params.yml", []string{"testApp"}) Expect(fakeVariables.GetCallCount()).To(BeZero()) Expect(err).NotTo(HaveOccurred()) }) @@ -45,7 +45,7 @@ var _ = Describe("Command", func() { fakeVariables.GetReturns(nil, true, nil) }) It("access to the vault occurs multiple times", func() { - err := command.Push("../testdata/multi_params.yml") + err := command.Push("../testdata/multi_params.yml", []string{"testApp"}) Expect(fakeVariables.GetCallCount()).To(Equal(2)) Expect(err).NotTo(HaveOccurred()) })