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

Remove TypeMeta declaration from the implementation of the objects #1462

Merged
merged 1 commit into from
May 27, 2019

Conversation

camilamacedo86
Copy link
Contributor

@camilamacedo86 camilamacedo86 commented May 21, 2019

Description of the change:

  • Remove TypeMeta declaration from the implementation of the objects

Note that the TypeMeta struct and its values are automatically filled when an object is initialized in this way is unnecessary to add this values and indeed shows a not good practice at all since the dev can add wrong values which will cause issues as for example not allow the client GET the object.

Following an example which could cause error just to example this scenario.

    ...
    route := &routev1.Route{
        TypeMeta: v1.TypeMeta{  // TODO (user): Remove the TypeMeta declared
            APIVersion: "v1",   // the correct value should be `"route.openshift.io/v1"`
            Kind:       "Route",
        },
        ObjectMeta: v1.ObjectMeta{
            Name:      name,
            Namespace: namespace,
            Labels:    ls,
        },
    }
    ...

Following an example of the issue faced, it is because of the TypeMeta.APIVersion informed is invalid for the resource object schema. It is not recommended declared the TypeMeta since it will be implicitly generated.

get route: (no kind "Route" is registered for version "v1" in scheme "k8s.io/client-go/kubernetes/scheme/register.go:61")

Motivation for the change:

Face issues like the above example because of this unnecessary declaration.

@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 21, 2019
@openshift-ci-robot
Copy link

Hi @camilamacedo86. Thanks for your PR.

I'm waiting for a operator-framework or openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 21, 2019
@camilamacedo86 camilamacedo86 changed the title Remove impl for TypeMeta since this object/values are inject automatically when the object is initialized Remove TypeMeta declaration from the implementation of the objects May 21, 2019
@camilamacedo86
Copy link
Contributor Author

c/c @lilic @shawn-hurley

@camilamacedo86 camilamacedo86 force-pushed the DOC-TypeMeta branch 2 times, most recently from 003b5f2 to 3a2201b Compare May 22, 2019 06:44
@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 22, 2019
@camilamacedo86 camilamacedo86 force-pushed the DOC-TypeMeta branch 2 times, most recently from a57e1d5 to ec9079c Compare May 22, 2019 07:14
@shawn-hurley
Copy link
Member

/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 22, 2019
Copy link
Member

@shawn-hurley shawn-hurley left a comment

Choose a reason for hiding this comment

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

I think it makes sense to clean this up, Thanks!

doc/design/milestone-0.0.2/query-api.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@hasbro17 hasbro17 left a comment

Choose a reason for hiding this comment

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

LGTM

@lilic
Copy link
Member

lilic commented May 27, 2019

Thanks for all your contributions @camilamacedo86! 🎉

@lilic lilic merged commit ffc1bf5 into operator-framework:master May 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants