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

Commit f1b909b

Browse files
author
cappyzawa
committed
enable to specify app name
1 parent 9424173 commit f1b909b

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (c *CfPushWithVault) Run(cliConnection plugin.CliConnection, args []string)
6060
Variables: variables,
6161
}
6262

63-
if err := command.Push(fc.String("file")); err != nil {
63+
if err := command.Push(fc.String("file"), fc.Args()[1:]); err != nil {
6464
fmt.Fprintf(os.Stdout, "failed to push with vault: %v", err)
6565
os.Exit(1)
6666
}
@@ -73,14 +73,14 @@ func (c *CfPushWithVault) GetMetadata() plugin.PluginMetadata {
7373
Version: plugin.VersionType{
7474
Major: 0,
7575
Minor: 0,
76-
Build: 1,
76+
Build: 2,
7777
},
7878
Commands: []plugin.Command{
7979
{
8080
Name: "push-with-vault",
8181
HelpText: "This enable to use (( )) place holders in manifest files. (( )) are evaluated by vault",
8282
UsageDetails: plugin.Usage{
83-
Usage: "$ cf push-with-vault",
83+
Usage: "$ cf push-with-vault [APP_NAME]",
8484
Options: map[string]string{
8585
"-file": "Path to manifest (default: ./manifest.yml)",
8686
"-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)",

plug/command.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Command struct {
1818
}
1919

2020
// Push pushes cf app based on manifest
21-
func (c *Command) Push(file string) error {
21+
func (c *Command) Push(file string, args []string) error {
2222
// read file
2323
absFile, err := filepath.Abs(file)
2424
if err != nil {
@@ -42,8 +42,9 @@ func (c *Command) Push(file string) error {
4242
return err
4343
}
4444

45+
args = append([]string{"push", "-f", tmpFile.Name()}, args...)
4546
// cf push
46-
if _, err := c.CliConnection.CliCommand("push", "-f", tmpFile.Name()); err != nil {
47+
if _, err := c.CliConnection.CliCommand(args...); err != nil {
4748
return err
4849
}
4950

plug/command_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ var _ = Describe("Command", func() {
2828
Describe("Push()", func() {
2929
Context("manifest file is missing", func() {
3030
It("an error is occurred", func() {
31-
err := command.Push("../testdata/missing.yml")
31+
err := command.Push("../testdata/missing.yml", []string{"testApp"})
3232
Expect(err).To(HaveOccurred())
3333
})
3434
})
3535
Context("manifest file does not contain parameters", func() {
3636
It("access to the vault does not occur", func() {
37-
err := command.Push("../testdata/no_contains_params.yml")
37+
err := command.Push("../testdata/no_contains_params.yml", []string{"testApp"})
3838
Expect(fakeVariables.GetCallCount()).To(BeZero())
3939
Expect(err).NotTo(HaveOccurred())
4040
})
@@ -45,7 +45,7 @@ var _ = Describe("Command", func() {
4545
fakeVariables.GetReturns(nil, true, nil)
4646
})
4747
It("access to the vault occurs multiple times", func() {
48-
err := command.Push("../testdata/multi_params.yml")
48+
err := command.Push("../testdata/multi_params.yml", []string{"testApp"})
4949
Expect(fakeVariables.GetCallCount()).To(Equal(2))
5050
Expect(err).NotTo(HaveOccurred())
5151
})

0 commit comments

Comments
 (0)