Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing dependency parameters on command line #3013

Merged
merged 4 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
}
Loading