Skip to content

Feat: Kubectl get implementation #1251

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

Merged
merged 1 commit into from
Sep 15, 2020

Conversation

yue9944882
Copy link
Member

ideally i think this can be a replacement for GenericKubernetesApi

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 10, 2020
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 10, 2020
return !StringUtils.isEmpty(namespace);
}

public class KubectlGetSingle implements Kubectl.Executable<ApiType> {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is going to get messy/confusing to people because:

Kubectl.get().namespace(foo).name(bar).execute() will work, but Kubectl.get().name(bar).namespace(foo) won't.

I think we should either get rid of this class and merge the execute methods, or make this class extend from KubectlGet

Copy link
Member Author

Choose a reason for hiding this comment

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

Kubectl.get().namespace(foo).name(bar).execute() will work, but Kubectl.get().name(bar).namespace(foo) won't.

yeah i agree this can be confusing to the users. while the point here is that we're returning single object upon specifying resource name, and return a list of objects if the name absent. java doesn't support multi-return or overriding return type for the execute method so merging or overriding the execute methods won't work..

in a word, if we're to make both namespace(foo).name(bar) and name(bar).namespace(foo) work, the execute method will have to return a list of object even when getting one object, which can be even more confusing i suppose?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hrm, why not just have, and then you can do:

return new KubectlGetSingle().namespace(namespace).name(name) in the function that adds the name, then it will work either way.

public KubectlGetSingle<ApiType> extends ResourceBuilder<...>, implements Kubectl.Executable<ApiType>

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@brendandburns
Copy link
Contributor

Generally looks good, one comment about the interface.

@brendandburns
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 15, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, yue9944882

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [brendandburns,yue9944882]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 2c2acf5 into kubernetes-client:master Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants