Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
Check parameter presence
Browse files Browse the repository at this point in the history
Older bundles don't have the inspect format parameter, we don't set it
for them, we set it only on bundles that define that parameter.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
  • Loading branch information
rumpl committed Oct 3, 2019
1 parent dbd0ee1 commit 3a2ac87
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
1 change: 0 additions & 1 deletion e2e/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ func TestInspectApp(t *testing.T) {
cmd.Command = dockerCli.Command("app", "inspect", "simple-app:1.0.0")
cmd.Dir = dir.Path()
output := icmd.RunCmd(cmd).Assert(t, icmd.Success).Combined()
fmt.Println(output)
golden.Assert(t, output, "app-inspect.golden")

}
Expand Down
9 changes: 6 additions & 3 deletions internal/commands/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ func runInspect(dockerCli command.Cli, appname string, opts inspectOptions) erro
if err != nil {
return err
}
bundle, ref, err := getLocalBundle(dockerCli, bundleStore, appname, false)
bndl, ref, err := getLocalBundle(dockerCli, bundleStore, appname, false)

if err != nil {
return err
}
installation, err := appstore.NewInstallation("custom-action", ref.String())
if err != nil {
return err
}
installation.Bundle = bundle
installation.Bundle = bndl

driverImpl, errBuf := prepareDriver(dockerCli, bindMount{}, nil)
a := &action.RunCustom{
Expand All @@ -62,7 +63,9 @@ func runInspect(dockerCli command.Cli, appname string, opts inspectOptions) erro
if opts.pretty {
format = "pretty"
}
installation.Parameters[internal.ParameterInspectFormatName] = format

installation.SetParameter(internal.ParameterInspectFormatName, format)

if err := a.Run(&installation.Claim, nil, nil); err != nil {
return fmt.Errorf("inspect failed: %s\n%s", err, errBuf)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func pushInvocationImage(dockerCli command.Cli, retag retagResult) error {
func pushBundle(dockerCli command.Cli, opts pushOptions, bndl *bundle.Bundle, retag retagResult) error {
insecureRegistries, err := insecureRegistriesFromEngine(dockerCli)
if err != nil {
return errors.Wrap(err, "could not retrive insecure registries")
return errors.Wrap(err, "could not retrieve insecure registries")
}
resolver := remotes.CreateResolver(dockerCli.ConfigFile(), insecureRegistries...)
var display fixupDisplay = &plainDisplay{out: os.Stdout}
Expand Down
8 changes: 8 additions & 0 deletions internal/store/installation.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ func NewInstallation(name string, reference string) (*Installation, error) {
}, nil
}

// SetParameters sets the parameter value if the installation bundle has
// a defined parameter with that name.
func (i Installation) SetParameter(name string, value string) {
if _, ok := i.Bundle.Parameters[name]; ok {
i.Parameters[name] = value
}
}

var _ InstallationStore = &installationStore{}

type installationStore struct {
Expand Down

0 comments on commit 3a2ac87

Please sign in to comment.