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

Don't warn if parameter is only used as trigger #1618

Merged
merged 2 commits into from
Jul 22, 2020
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
5 changes: 2 additions & 3 deletions pkg/kudoctl/cmd/testdata/invalid-params.golden
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Warnings
parameter "Cpus" defined but not used.
parameter "comma," defined but not used.
Warnings
parameter "Cpus" defined but not used.
Errors
parameter "Cpus" has a duplicate
parameter "comma," contains invalid character ','
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ func paramsDefinedNotUsed(pf *packages.Files) verifier.Result {
}
for _, value := range pf.Params.Parameters {
if _, ok := tparams[value.Name]; !ok {
res.AddParamWarning(value.Name, "defined but not used.")
// A parameter could be use to trigger a plan while not being used in templates.
if value.Trigger == "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we warn if the plan does not exist?

Copy link
Member Author

@nfnt nfnt Jul 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do that already, but in a different validation check that returns an error if a trigger is set to a non-existing plan. See https://github.com/kudobuilder/kudo/blob/main/pkg/kudoctl/packages/verifier/plan/verify_references.go#L37

res.AddParamWarning(value.Name, "defined but not used.")
}
}
}
return res
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func TestTemplateParametersVerifier(t *testing.T) {
{Name: "UsedViaRoot"},
{Name: "BROKER_COUNT"},
{Name: "EXTERNAL_NODE_PORT"},
{Name: "TRIGGER_ONLY", Trigger: "foo"},
}
paramFile := packages.ParamsFile{Parameters: params}
templates := make(map[string]string)
Expand Down