-
Notifications
You must be signed in to change notification settings - Fork 101
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
Handle unknown types as unstructured #954
Conversation
I'll try to add integration test to confirm this |
@@ -52,6 +54,7 @@ func (drm *DynamicRESTMapper) reloadOnError(err error) bool { | |||
return false | |||
} | |||
err = drm.reload() | |||
fmt.Println("reload") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errant println?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functionally lgtm . I wouldn't stop a merge... but I do think it would be more readable with some package changes and it would be nice to keep "test" pkg from bleeding into the cli
@@ -23,6 +23,7 @@ import ( | |||
"github.com/kudobuilder/kudo/pkg/controller/instance" | |||
"github.com/kudobuilder/kudo/pkg/controller/operator" | |||
"github.com/kudobuilder/kudo/pkg/controller/operatorversion" | |||
util "github.com/kudobuilder/kudo/pkg/test/utils" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- IMO we should not import from the
pkg/test
packages. This could should move out to a common lib location used by kudo and test - it should not be in a
utils
package. IMO it looks like we have a code intest/utils/
which should be in our projectkube
orkubernetes
package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have a number of kube Clients like this in pkg/kubdoctl/kube/config.go
//ParseKubernetesObjects parses a list of runtime.Objects from the provided yaml | ||
// ParseKubernetesObjects parses a list of runtime.Objects from the provided yaml | ||
// If the type is not known in the scheme, it tries to parse it as Unstructured | ||
// TODO(av) could we use something else than a global scheme here? Should we somehow inject it? | ||
func ParseKubernetesObjects(yaml string) (objs []runtime.Object, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yaml string
seems unnecessarily limiting... wouldn't io.Reader
be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed the fact that there is a future controller-runtime feature that abstracts the client for unstructured... this looks good to go for me
**What this PR does / why we need it**: When scheme did not contain that type, we previously failed. Since we should be able to handle all types that people might have installed in their cluster, we should fallback to parsing a type as unstructured when not available. This PR has 3 parts: - update to `ParseKubernetesObjects` to process unknown types as Unstructured - use of dynamic restmapper in execution that ensures that we discover new types that were added during the lifetime of the controller - integration test NOTE: Right now we are using dynamic mapper from test harness. That is probably not as robust as the one introduced in the controller-runtime 0.3.0. I will port this code to the controller-runtime mapper when we bump the version of controller-runtime (that should happen prior to 0.8.0 anyway). Fixes #913
**What this PR does / why we need it**: When scheme did not contain that type, we previously failed. Since we should be able to handle all types that people might have installed in their cluster, we should fallback to parsing a type as unstructured when not available. This PR has 3 parts: - update to `ParseKubernetesObjects` to process unknown types as Unstructured - use of dynamic restmapper in execution that ensures that we discover new types that were added during the lifetime of the controller - integration test NOTE: Right now we are using dynamic mapper from test harness. That is probably not as robust as the one introduced in the controller-runtime 0.3.0. I will port this code to the controller-runtime mapper when we bump the version of controller-runtime (that should happen prior to 0.8.0 anyway). Fixes #913
What this PR does / why we need it:
When scheme did not contain that type, we previously failed. Since we should be able to handle all types that people might have installed in their cluster, we should fallback to parsing a type as unstructured when not available.
This PR has 3 parts:
ParseKubernetesObjects
to process unknown types as UnstructuredNOTE: Right now we are using dynamic mapper from test harness. That is probably not as robust as the one introduced in the controller-runtime 0.3.0. I will port this code to the controller-runtime mapper when we bump the version of controller-runtime (that should happen prior to 0.8.0 anyway).
Fixes #913