doitintl / kube-no-trouble

Easily check your clusters for use of deprecated APIs
MIT License
3.2k stars 157 forks source link

Warn and Fix Up Invalid Namespaces on Objects #594

Closed justdan96 closed 6 months ago

justdan96 commented 6 months ago

This is to avoid issues such as https://github.com/doitintl/kube-no-trouble/issues/505. I have been seeing this error myself, which manifests as:

10:53AM TRC parsing +map[ApiVersion:batch/v1beta1 Kind:CronJob Name:resource123 Namespace:<nil> ReplaceWith:batch/v1 RuleSet:Deprecated APIs removed in 1.25 Since:1.21]
panic: interface conversion: interface {} is nil, not string

This is a simple PR which just warns the user that the object's namespace was not collected correctly and then sets it to <undefined>. The message could also be amended to ask the user to report the issue to the developer. I figure this is a better outcome then a panic, and it also fixes the problem I (and presumably others) was having.

dark0dave commented 6 months ago

You couldn't run the pre-commit and sign this commit please?

dark0dave commented 6 months ago

Thanks for the contribution.

justdan96 commented 6 months ago

You couldn't run the pre-commit and sign this commit please?

Done and done.