Skip to content

Conversation

@Vafilor
Copy link
Contributor

@Vafilor Vafilor commented Nov 25, 2020

What this PR does:

Catches errors with params.yaml when the default namespace is blank, missing, or a reserved namespace.
Which issue(s) this PR fixes:

Fixes onepanelio/onepanel#748

Special notes for your reviewer:

…en running build or apply

Also moved loading params.yaml to the top of GenerateKustomizeResult so that we can do error checking before any file copying - which is slow.
@Vafilor Vafilor added the kind/bug Something isn't working label Nov 25, 2020
@Vafilor Vafilor added this to the v0.16.0 milestone Nov 25, 2020
@Vafilor Vafilor self-assigned this Nov 25, 2020
}

// HumanizeKustomizeError takes errors returned from GenerateKustomizeResult and returns them in a human friendly string
func HumanizeKustomizeError(err error) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be HumanizeKustomizeNamespaceError since the error messages are namespace specific?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could do that. I figured it could expand to other errors. This is specific to the GenerateKustomizeResult function. So maybe we should call it HumanizeKustomizeResultError?

switch paramsError.ErrorType {
case "missing":
return fmt.Sprintf("%s is missing in your params.yaml", paramsError.Key)
case "blank":
Copy link
Contributor

Choose a reason for hiding this comment

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

Or maybe these ErrorTypes should be namespaceBlank and namespaceReserved?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rushtehrani That might be best. Although, it is possible other params could be missing or blank when they should not be - the messages would be the same.


defaultNamespace := manifest.GetValue("application.defaultNamespace")
if defaultNamespace == nil {
return &ParamsError{Key: "application.defaultNamespace", ErrorType: "missing"}
Copy link
Contributor

@rushtehrani rushtehrani Nov 26, 2020

Choose a reason for hiding this comment

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

@rushtehrani That might be best. Although, it is possible other params could be missing or blank when they should not be - the messages would be the same.

Would it make sense to then have ErrorType and ResourceName and then provide a message based on the combination of those? And maybe have a catch all condition for each ErrorType if the ResourceName is not defined. We could also create a separate issue for this and expand later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rushtehrani

Yeah, let's expand on this separately.

I'm completely up for expanding/fleshing this out. The important parts to me are:

  • The key that caused the issue
  • The value (if applicable) that caused the issue.
  • What type of error it is - value missing, value blank, value invalid otherwise (how? reserved name, too many characters, etc)
  • Bonus: Line that caused the issue.

@rushtehrani rushtehrani merged commit 8b57bc6 into master Nov 26, 2020
@rushtehrani rushtehrani deleted the fix/onepanelio.core.748-namespace.error branch November 26, 2020 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI - error: don't allow application.defaultNamespace to be onepanel as this causes issues with the deployed yaml.

3 participants