Skip to content

Commit

Permalink
feat(outputs): add porter bundle show command; misc review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
vdice committed Jul 9, 2019
1 parent f5d941f commit 8f10692
Show file tree
Hide file tree
Showing 19 changed files with 391 additions and 254 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ endif

install:
mkdir -p $(HOME)/.porter
cp -R bin/* $(HOME)/.porter/
cp -R bin/bundles $(HOME)/.porter/
cp -R bin/mixins $(HOME)/.porter/
cp bin/porter* $(HOME)/.porter/
ln -f -s $(HOME)/.porter/porter /usr/local/bin/porter

clean: clean-mixins clean-last-testrun
Expand Down
10 changes: 0 additions & 10 deletions build/testdata/bundles/mysql/porter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,3 @@ uninstall:
purge: true
releases:
- "{{ bundle.parameters.mysql-name }}"

outputs:
- name: mysql-root-password
description: "The root MySQL password"
type: string
- name: mysql-password
type: string
applyTo:
- install
- upgrade
3 changes: 2 additions & 1 deletion build/testdata/bundles/wordpress/porter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ outputs:
type: string
applyTo:
- "install"
- "upgrade"
- "upgrade"
sensitive: true
38 changes: 38 additions & 0 deletions cmd/porter/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func buildBundlesCommand(p *porter.Porter) *cobra.Command {
cmd.AddCommand(buildBundleInstallCommand(p))
cmd.AddCommand(buildBundleUpgradeCommand(p))
cmd.AddCommand(buildBundleUninstallCommand(p))
cmd.AddCommand(buildBundleShowCommand(p))

return cmd
}
Expand All @@ -37,6 +38,7 @@ func buildBundleAliasCommands(p *porter.Porter) []*cobra.Command {
buildUpgradeCommand(p),
buildUninstallCommand(p),
buildPublishCommand(p),
buildShowCommand(p),
}
}

Expand Down Expand Up @@ -326,3 +328,39 @@ func buildPublishCommand(p *porter.Porter) *cobra.Command {
}
return cmd
}

// TODO: test!
func buildBundleShowCommand(p *porter.Porter) *cobra.Command {
opts := porter.ShowOptions{}

cmd := cobra.Command{
Use: "show",
Short: "Show a bundle",
Long: "Displays info relating to a bundle claim, including status and a listing of outputs.",
Example: ` porter bundle show [CLAIM]
Optional output formats include json and yaml.
`,
PreRunE: func(cmd *cobra.Command, args []string) error {
return opts.Validate(args)
},
RunE: func(cmd *cobra.Command, args []string) error {
return p.ShowBundle(opts)
},
}

f := cmd.Flags()
f.StringVarP(&opts.RawFormat, "output", "o", "table",
"Specify an output format. Allowed values: table, json, yaml")

return &cmd
}

func buildShowCommand(p *porter.Porter) *cobra.Command {
cmd := buildBundleShowCommand(p)
cmd.Example = strings.Replace(cmd.Example, "porter bundle show", "porter show", -1)
cmd.Annotations = map[string]string{
"group": "alias",
}
return cmd
}
2 changes: 1 addition & 1 deletion cmd/porter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func buildRootCommand() *cobra.Command {
cmd.AddCommand(buildBundlesCommand(p))
cmd.AddCommand(buildMixinsCommand(p))
cmd.AddCommand(buildCredentialsCommand(p))
cmd.AddCommand(buildOutputsCommand(p))
// cmd.AddCommand(buildOutputsCommand(p))

for _, alias := range buildBundleAliasCommands(p) {
cmd.AddCommand(alias)
Expand Down
72 changes: 0 additions & 72 deletions cmd/porter/outputs.go

This file was deleted.

4 changes: 2 additions & 2 deletions pkg/cnab/provider/duffle.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewDuffle(c *config.Config) *Duffle {
}
}

func (d *Duffle) newDriver(driverName, bundleName string) (driver.Driver, error) {
func (d *Duffle) newDriver(driverName, claimName string) (driver.Driver, error) {
driverImpl, err := duffledriver.Lookup(driverName)
if err != nil {
return driverImpl, err
Expand All @@ -47,7 +47,7 @@ func (d *Duffle) newDriver(driverName, bundleName string) (driver.Driver, error)
}

// Create outputs sub-directory using the bundle name
bundleOutputsDir := filepath.Join(outputsDir, bundleName)
bundleOutputsDir := filepath.Join(outputsDir, claimName)
err = d.FileSystem.MkdirAll(bundleOutputsDir, 0755)
if err != nil {
return nil, errors.Wrapf(err, "could not create outputs directory %s for docker driver bind mount", bundleOutputsDir)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cnab/provider/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (d *Duffle) Install(args InstallArguments) error {
}
c.Parameters = params

driver, err := d.newDriver(args.Driver, b.Name)
driver, err := d.newDriver(args.Driver, c.Name)
if err != nil {
return errors.Wrap(err, "unable to instantiate driver")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cnab/provider/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (d *Duffle) Uninstall(args UninstallArguments) error {
}
}

driver, err := d.newDriver(args.Driver, claim.Bundle.Name)
driver, err := d.newDriver(args.Driver, claim.Name)
if err != nil {
return errors.Wrap(err, "unable to instantiate driver")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cnab/provider/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (d *Duffle) Upgrade(args UpgradeArguments) error {
}
}

driver, err := d.newDriver(args.Driver, claim.Bundle.Name)
driver, err := d.newDriver(args.Driver, claim.Name)
if err != nil {
return errors.Wrap(err, "unable to instantiate driver")
}
Expand Down
1 change: 1 addition & 0 deletions pkg/config/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ type OutputDefinition struct {
Name string `yaml:"name"`
ApplyTo []string `yaml:"applyTo,omitempty"`
Description string `yaml:"description,omitempty"`
Sensitive bool `yaml:"sensitive"`

Schema `yaml:",inline"`
}
Expand Down
Loading

0 comments on commit 8f10692

Please sign in to comment.