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

Conversation

nfnt
Copy link
Member

@nfnt nfnt commented Jul 21, 2020

What this PR does / why we need it:
Parameters can be used to only trigger plans without being used in any templates. In this case no warning should be printed when verifying a package.

Fixes #1617

Parameters can be used to only trigger plans without being used in any templates. In this case no warning should be printed when verifying a package.

Signed-off-by: Jan Schlicht <jan@d2iq.com>
Copy link
Contributor

@alenkacz alenkacz left a comment

Choose a reason for hiding this comment

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

👍

Signed-off-by: Jan Schlicht <jan@d2iq.com>
Copy link
Member

@kensipe kensipe left a comment

Choose a reason for hiding this comment

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

this approach is incrementally better but leaves open the param.trigger to be nonsensical or assigned to a plan that was removed or has never been added yet.

It should be better to check that the Trigger

  1. is in the set of plans ✅
  2. if not in the set of plans, is warned that has plan assignment that is not in the set of plans

We should add a verify for checking that triggers are in the set of plans (covering the case of "used" params that are also triggers for plans that do not exist. I'll create an issue for that.

For this PR, I have slight preference that we check that the trigger is in the set of plans... If you choose to move forward with the current solution please create an issue for this enhancement.

@@ -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

@kensipe
Copy link
Member

kensipe commented Jul 21, 2020

My leaning has changed :), The more I think about it... there should be a verifier for triggers / plan names (which is performed irrespective of use). This should be captured as an error and would cover this situation. I'm not sure if that needs to be duplicated here. This seems 👌 the way it is but we need additional logic which I will capture in an issue.

@nfnt nfnt merged commit 42881d5 into main Jul 22, 2020
@nfnt nfnt deleted the nfnt/fix-warnings-trigger-parameters branch July 22, 2020 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'kubectl kudo package verify' falsely warns if a parameter is only used to trigger plans
3 participants