fix(kubectl): prevent panic in IsMinikubeKubernetes on plain string extensions#3269
Open
AruneshDwivedi wants to merge 1 commit into
Open
fix(kubectl): prevent panic in IsMinikubeKubernetes on plain string extensions#3269AruneshDwivedi wants to merge 1 commit into
AruneshDwivedi wants to merge 1 commit into
Conversation
…xtensions
When kubeconfig extensions contain plain string values (e.g. from
Teleport), runtime.DefaultUnstructuredConverter.ToUnstructured returns a
string instead of map[string]interface{}. The subsequent map index
operation panics with 'reflect.Set: value of type string is not
assignable to type map[string]interface {}'.
Fix: check that the converted value is actually a map before accessing
it. Non-map extensions are skipped.
Fixes devspace-sh#3218
Signed-off-by: Arunesh Dwivedi <arunesh.devops@gmail.com>
✅ Deploy Preview for devspace-docs canceled.Built without sensitive environment variables
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
devspace buildpanics withreflect.Set: value of type string is not assignable to type map[string]interface {}when the kubeconfig contains extensions with plain string values (e.g. from Teleport).Root Cause
In
IsMinikubeKubernetes,runtime.DefaultUnstructuredConverter.ToUnstructured(extension)is called on each cluster extension. When an extension contains a plain string value (not a map),ToUnstructuredreturns astringinstead ofmap[string]interface{}. The subsequentext["provider"].(string)map index operation panics.Fix
Add a type assertion check: if the converted value is not a
map[string]interface{}, skip it withcontinue. Non-map extensions cannot contain aproviderfield anyway, so skipping is safe.Testing
Manually verified with a kubeconfig containing:
Previously panicked. Now correctly returns
false.Fixes #3218