Skip to content

Merging hand-written code into one package #33

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 9 commits into from
Mar 12, 2019

Conversation

guoshimin
Copy link
Contributor

No description provided.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 28, 2019
@guoshimin
Copy link
Contributor Author

@jkachmar @jonschoning PTAL

@jkachmar
Copy link

Two comments:

  1. How do you feel about taking the restructuring as an opportunity to make the module naming a bit more consistent? For example:
    • Kubernetes.OpenAPI.ClientHelper -> Kubernetes.Client.Helper
    • Kubernetes.OpenAPI.Watch.Client -> Kubernetes.Client.Watch
    • Kubernetes.OpenAPI.KubeConfig -> Kubernetes.Client.KubeConfig

With this naming scheme, all of the hand-written functions are under the Kubernetes.Client namespace, and all of the generated functions are under the Kubernetes.OpenAPI namespace.

I haven't given this too much thought though, so there might be good reasons not to do it this way.

  1. Is there a better name for the ClientHelper module? I frequently see Helper or Util modules on Hackage and they can feel fairly vague. Perhaps it would be better to have something like:
    -Kubernetes.OpenAPI.KubeConfig -> Kubernetes.Client.KubeConfig
    • Kubernetes.OpenAPI.ClientHelper -> Kubernetes.Client.Config
      ...where the KubeConfig module holds functions/types concerned with Kubernetes kubeconfig functionality and the Config module holds functions/types concerned with the client configuration (i.e. the certificate and manager stuff that's currently in there).

@guoshimin
Copy link
Contributor Author

Yeah I'll make these changes.

@guoshimin
Copy link
Contributor Author

PTAL

Copy link

@jkachmar jkachmar left a comment

Choose a reason for hiding this comment

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

Looks awesome, thanks very much!

@guoshimin
Copy link
Contributor Author

@brendandburns can you approve? Thanks!


import Data.Function ((&))
import qualified Kubernetes.OpenAPI.API.CoreV1
import Kubernetes.OpenAPI.Client (dispatchMime)

Choose a reason for hiding this comment

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

@guoshimin I don't think the README example here reflects the lates module name changes.

@denibertovic
Copy link

denibertovic commented Mar 8, 2019

@guoshimin @jkachmar The way I usually approach module naming in this situation is to have "Kubernetes.Client." but then re-export whatever I need to "Kubernetes.Client" that way a user of the library only needs to do "import Kubernetes.Client" and they're set to go. Hoever, a more experienced user is free to pick and choose and import stuff from "Kubernetes.Client." one by one (for whatever reason).

I don't have an opinion on the names in "Kubernetes.Client.*" as long as the re-export in "Kubernetes.Client" give me as a user all I need.

Does this make sense?

@denibertovic
Copy link

denibertovic commented Mar 8, 2019

One more question/suggestion regarding the package names: Isn't it a little too much to name the 2 packages kubernetes-openapi-client-gen and kubernetes-openapi-client? Seems a bit of a mouthful. Wouldn't it make more sense to give them shorter (memorable names) like kubernetes-core and kubernetes-client (or event better just kubernetes? I understand the allure to suffix -gen so folks know it's generated code but 2 prominent examples of such code, amazonka and gogol, don't seem to use this scheme and it makes them much more memorable and more intuitive to use.

EDIT: Just to be clear this doesn't impact this PR it's just a suggestion. If however you would like to eventually make this change I have some free time this weekend and would be able to work on it.

@guoshimin
Copy link
Contributor Author

@denibertovic Thanks for the feedback! PTAL.

@denibertovic
Copy link

@guoshimin LGTM now.

Do you have any feedback on the package names in my second comment (for another PR of course).

@guoshimin
Copy link
Contributor Author

Oops, missed your second comment. @jonschoning first raised the point whether it was wise to take the name kubernetes on hackage and I agreed with him, so we made the package name more qualified. It's possible that we have gone too far. Now that I think about it more, it may be better to have just one package that includes both generated and hand-written code. That's how the other languages under kubernetes-client work, and more intuitive for the user. One complication is that we will have one .cabal file for both generated and hand-written code, and we will need to maintain it manually, but I think it's outweighed by the benefits. So @jonschoning @jkachmar what do you guys think of just having one package named kubernetes-client?

@denibertovic
Copy link

denibertovic commented Mar 10, 2019

@guoshimin why would it not be wise to use the name "kubernetes" if it's the official api bindings? Please point me to a discussion about this so you don't have to repeat yourself.

That said, I'm 👎 on the single package proposal. Having 2 packages seems perfectly reasonable and quite in spirit for these types of things in the ecosystem.

FWIW, if the "qualified" name must stay I would vote for keeping the kubernetes-openapi-client-gen name but renaming kubernetes-openapi-client to just kubernetes-client.

@jkachmar
Copy link

  • 👍 for shorter names (e.g. kubernetes-client and kubernetes-client-core/kubernetes-client-gen)
  • 👎 for a single package
    • I feel like if the generated stuff is separate, it's a little easier for someone to run the generator on their own (e.g. for a different version of the API) in a forked version

@jonschoning
Copy link
Contributor

  1. I'm good with kubernetes-client

    • Just to add some context, my reason for avoiding a root name like kubernetes is that although the code in this repo may be generated from the official swagger openapi spec, the openapi generator itself doesn't know anything about kubernetes at all and is constrained to generate to the lowest common denominator of "forall" OAS specs.
      Packages like gogol and amazonka have tailor-made generators, which have the advantage of being able to customize the codegen specifically for their own use case.
      So I was thinking to just allow some room on hackage, if someone in the future decides to implement tailor-made generator for kubernetes and really improve the UX.
      But I can live with kubernetes-client which I think is different enough
  2. I think I prefer keeping the generated code in a separate package as well, but am not super opinionated about this one.

@guoshimin
Copy link
Contributor Author

Thank you folks for your input. I'll change the package name to kubernetes-client/kubernetes-client-core.

@guoshimin
Copy link
Contributor Author

PTAL

name: kubernetes-client
version: 0.1.0.0
description: |
This package contains functions for working with kubeconfig files.

Choose a reason for hiding this comment

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

This description should get updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Done. And added a few more fields.

- x509-system
- x509-store
- x509-validation
executables:

Choose a reason for hiding this comment

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

I don't think when installing kubernetes-client that I should have to build this example binary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to test.

@@ -8,4 +8,4 @@ OpenAPI-Specification: https://github.com/OAI/OpenAPI-Specification/blob/master/

## Usage

Please refer to the README of the `kubernetes-client-helper` package.
Please refer to the README of the `kubernetes-openapi-client` package.

Choose a reason for hiding this comment

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

s/kubernetes-openapi-client/kubernetes-client/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

- data-default-class
- http-client >=0.5 && <0.6
- http-client-tls
- kubernetes-openapi-client-gen == 0.1.0.0

Choose a reason for hiding this comment

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

This should change to kubernetes-client-core right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will update it when I regen the code to use the new package name.

Choose a reason for hiding this comment

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

👍

@denibertovic
Copy link

LGTM. 👍

@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 Mar 12, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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:

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 12, 2019
@k8s-ci-robot k8s-ci-robot merged commit de91fe9 into kubernetes-client:master Mar 12, 2019
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.

7 participants