Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

validate if name is set #272

Merged
merged 2 commits into from Oct 24, 2019
Merged

Conversation

theSuess
Copy link
Contributor

This change simply checks if the name of the object is set. Without this check, the validation succeeds on typos like this:

    metadata: { labels+: {"foo":"bar"}}

but will panic while updating with the following error, making it especially hard to debug:

panic: interface conversion: runtime.Object is *unstructured.UnstructuredList, not *unstructured.Unstructured

@@ -82,6 +82,9 @@ func (c ValidateCmd) Run(apiObjects []*unstructured.Unstructured, out io.Writer)
for _, err := range schema.Validate(obj) {
allErrs = append(allErrs, err)
}
if obj.GetName() == "" {
Copy link

Choose a reason for hiding this comment

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

What about ObjectMeta.GenerateName? Can kubecfg accommodate its use?

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 generate a name ourselves using this field if it exists but server-side name generation would not work because of the way we fetch the existing resource before applying the config (it would also not support diffing).

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, generateName doesn't seem compatible with the workflow promoted by kubecfg

@mkmik mkmik merged commit c79d627 into vmware-archive:master Oct 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants