Skip to content

⚠️ Clusterctlv2 add interfaces for the low-level Repository library #1842

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

Conversation

fabriziopandini
Copy link
Member

@fabriziopandini fabriziopandini commented Dec 5, 2019

What this PR does / why we need it:
This PR adds a clusterctl interfaces low-level api for managing Repository config objects, and more specifically the interfaces for managing two types of YAML files:

  • YAML files defining the provider components (CRD, Controller, RBAC etc.)
  • YAML files defining the cluster templates (Cluster, Machines)

By adding those interfaces, with this PR, then it will be possible to parallelize the work of adding the concrete implementation of each interface.

Which issue(s) this PR fixes
Rif #1729

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 5, 2019
@fabriziopandini fabriziopandini force-pushed the clusterctlv2-Irepository branch from 3dd5835 to 1882b01 Compare December 10, 2019 11:29
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 10, 2019
@fabriziopandini fabriziopandini changed the title [WIP] ⚠️ Clusterctlv2 add interfaces for the low-level Repository library ⚠️ Clusterctlv2 add interfaces for the low-level Repository library Dec 10, 2019
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 10, 2019
@fabriziopandini
Copy link
Member Author

@ncdc @vincepri @detiber this is ready for review now

Copy link
Contributor

@chuckha chuckha left a comment

Choose a reason for hiding this comment

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

My general concern here is that this is perpetuating a Go anti-pattern where the library is defining the interfaces when the consumer should be defining the interfaces.

General wisdom (and personal experience) says functions should accept interfaces and return structs. It is pretty annoying to use a library that only returns interfaces and explicitly tells me, the consumer, how i need to use the library.

I think some of these interfaces will be fine as this library will be the only thing consuming the interfaces, but the pattern of exposing the interface and having a private implementation can be quite annoying to work with.

In general, interfaces are designed by the consumer as the consumer knows how it wants to use a struct.

These blogs cover the topic fairly well

If there is a good reason for this pattern can you please outline why we choose to go against general go best practices?

@fabriziopandini
Copy link
Member Author

fabriziopandini commented Dec 11, 2019

@chuckha many thanks for the detailed feedback. the articles you linked are really interesting.

I see both pros and cons approach you are proposing and in the current approach that mimics what is implemented in the Kubernetes API package; nevertheless, I will be happy to address your concerns - including also re-working of the code already merged - if the consensus goes in that direction.

Said that my major concern is to keep the clusterctl work going, so, I this will be ok for you/for the team, I would prefer to experiment on an alternative approach for the API surface in a separated PR, and use the current approach for unblocking works on the clusterctl federated repository

@ncdc @vincepri @detiber opinions?

@chuckha
Copy link
Contributor

chuckha commented Dec 11, 2019

that's fine. all of kubernetes does this anyway and it's not a huge deal, it's just annoying to work with from time to time.

@vincepri
Copy link
Member

@chuckha Are you ok to approve this PR as-is given the comments above?

We merged some other PRs that follow this pattern (or anti-pattern as you mentioned 😄). Given that the tight timeline, and that the code can always be improved in future iterations, I'd like to get these merged asap

@chuckha
Copy link
Contributor

chuckha commented Dec 11, 2019

yep, it's fine to merge

Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini, vincepri

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 Dec 11, 2019
@k8s-ci-robot k8s-ci-robot merged commit ad39e36 into kubernetes-sigs:master Dec 11, 2019
@fabriziopandini fabriziopandini deleted the clusterctlv2-Irepository branch December 14, 2019 13:58
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.

4 participants