Skip to content

Commit

Permalink
Allow passing dependency parameters on command line (#3013)
Browse files Browse the repository at this point in the history
The documentation states that dependency parameters can be passed on the
command line with the following format, DEP#PARAM=VALUE. Currently that
is not possible, this change makes it possible.

Signed-off-by: Kim Christensen <kimworking@gmail.com>
  • Loading branch information
kichristensen authored Mar 19, 2024
1 parent 9b088ab commit ed2b0de
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/porter/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,12 @@ func (p *Porter) applyActionOptionsToInstallation(ctx context.Context, ba Bundle
resolvedParams[k] = v
}

for name, value := range parsedOverrides {
if strings.Contains(name, "#") {
resolvedParams[name] = value
}
}

//
// 6. Separate out params for the root bundle from the ones intended for dependencies
// This only applies to the dep v1 implementation, in dep v2 you can't specify rando params for deps
Expand Down
27 changes: 27 additions & 0 deletions pkg/porter/parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,3 +917,30 @@ func TestParameterRemovedFromBundle(t *testing.T) {
err := p.applyActionOptionsToInstallation(ctx, opts, &installation)
require.NoError(t, err)
}

func Test_DependencyParameterOverride(t *testing.T) {
ctx := context.Background()
p := NewTestPorter(t)
p.TestConfig.TestContext.AddTestFile("testdata/porter.yaml", "porter.yaml")
opts := InstallOptions{
BundleExecutionOptions: &BundleExecutionOptions{
Params: []string{
"dep#first-param=1",
},
Driver: "docker",
BundleReferenceOptions: &BundleReferenceOptions{
installationOptions: installationOptions{
BundleDefinitionOptions: BundleDefinitionOptions{
File: config.Name,
},
Name: "MyInstallation",
},
},
},
}

installation := storage.NewInstallation(opts.Namespace, opts.Name)
err := p.applyActionOptionsToInstallation(ctx, opts, &installation)
require.NoError(t, err)
assert.Equal(t, opts.depParams["dep#first-param"], "1")
}

0 comments on commit ed2b0de

Please sign in to comment.