Skip to content
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

API Get unmarshaller doesn't respect the APIVersion when the Kind is the same #127

Closed
fanminshi opened this issue Mar 22, 2018 · 1 comment

Comments

@fanminshi
Copy link
Contributor

fanminshi commented Mar 22, 2018

For example, Get can retrieve a object at APIVersion apps/v1beta1 and still unmarshall the data into the object d with a different type apps/v1 as shown in d := &appsv1.Deployment{}.

       name := "memcached-operator"
	namespace := "default"
	d := &appsv1.Deployment{
		TypeMeta: metav1.TypeMeta{
			Kind:       "Deployment",
			APIVersion: "apps/v1beta1",
		},
		ObjectMeta: metav1.ObjectMeta{
			Name:      name,
			Namespace: namespace,
		},
	}
	err := query.Get(d)
	if err != nil {
		logrus.Infof("Failed to get Deployment via sdk %v : %v", name, err)
	}

Output:
None

@fanminshi fanminshi changed the title API Get unmarshalling mechanism doesn't are about APIVersion if the Kind is the same API Get unmarshaller doesn't respect the APIVersion when the Kind is the same Mar 22, 2018
@hasbro17
Copy link
Contributor

To expand on the underlying issue, when decoding from JSON data for apps/v1beta1 Deployment into the Go type for apps/v1 Deployment the decoder does not give an error because the json scheme for both apiversions objects is the same.
https://github.com/coreos/operator-sdk/blob/master/pkg/util/k8sutil/k8sutil.go#L96
https://github.com/kubernetes/apimachinery/blob/master/pkg/runtime/interfaces.go#L51-L58

@spahl spahl added the wontfix label Jun 5, 2018
@spahl spahl closed this as completed Jun 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants