Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Commit

Permalink
enable to specify app name
Browse files Browse the repository at this point in the history
  • Loading branch information
cappyzawa committed Apr 9, 2019
1 parent 9424173 commit f1b909b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)",
Expand Down
5 changes: 3 additions & 2 deletions plug/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions plug/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
Expand All @@ -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())
})
Expand Down

0 comments on commit f1b909b

Please sign in to comment.