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

✨Add templating interface to clusterctl #3115

Conversation

wfernandes
Copy link
Contributor

What this PR does / why we need it:

  • This PR creates an interface (YamlProcessor) to allow for future extensible templating processors.
  • Currently, there is no change in behavior which clusterctl commands or usage.
  • The existing templating behavior of variable substitution is encapsulated in the SimpleProcessor which is also the default if no yaml processor are defined.
  • This PR only exposes YAMLProcessor as part of the clusterctl.GetClusterTemplateOptions, that is, the yaml processor is exposed via the clusterctl client library for clusterctl.GetClusterTemplate(opts).
  • There are other minor changes and refactors.

Note
I'm happy to break this PR into smaller PRs. As of now, I kinda broke into separate commits.

Release Notes:
TODO

/area clusterctl

@k8s-ci-robot k8s-ci-robot added area/clusterctl Issues or PRs related to clusterctl do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels May 28, 2020
@k8s-ci-robot k8s-ci-robot added 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 May 28, 2020
@vincepri
Copy link
Member

/assign

@wfernandes wfernandes changed the title WIP: ✨Add templating interface to clusterctl ✨Add templating interface to clusterctl Jun 3, 2020
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Jun 3, 2020
@wfernandes wfernandes force-pushed the clusterctl-templating-default-yaml-processor branch from c65b79c to 6b5e144 Compare June 8, 2020 16:35
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 8, 2020
@ncdc
Copy link
Contributor

ncdc commented Jun 8, 2020

@fabriziopandini would you have time to review?

@vincepri
Copy link
Member

/hold

Holding to review/merge after we cut alpha.0 next week

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 11, 2020
@wfernandes wfernandes force-pushed the clusterctl-templating-default-yaml-processor branch from a93ff23 to 450e9e3 Compare June 18, 2020 18:11
@wfernandes
Copy link
Contributor Author

/retest

Copy link

@benmoss benmoss left a comment

Choose a reason for hiding this comment

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

Seems pretty good, just some small comments

@wfernandes
Copy link
Contributor Author

/test pull-cluster-api-e2e

@wfernandes
Copy link
Contributor Author

@vincepri Can we remove the hold on this PR now that alpha is cut?

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

I'm +1 to squash commits, remove the hold and take the latest steps to get this merged.
I have added a few comments, mostly nits.

cmd/clusterctl/client/client.go Show resolved Hide resolved
cmd/clusterctl/client/common.go Outdated Show resolved Hide resolved
cmd/clusterctl/client/repository/components.go Outdated Show resolved Hide resolved
cmd/clusterctl/client/repository/template_client_test.go Outdated Show resolved Hide resolved
cmd/clusterctl/client/repository/components_client_test.go Outdated Show resolved Hide resolved
cmd/clusterctl/client/yamlprocessor/processor.go Outdated Show resolved Hide resolved
@vincepri
Copy link
Member

I have some time today to review

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.

Code changes look good to me, this looks close to being shipped.

cmd/clusterctl/client/client_test.go Outdated Show resolved Hide resolved
cmd/clusterctl/client/client_test.go Outdated Show resolved Hide resolved
cmd/clusterctl/client/yamlprocessor/processor.go Outdated Show resolved Hide resolved
@vincepri
Copy link
Member

/milestone v0.3.7

@k8s-ci-robot k8s-ci-robot added this to the v0.3.7 milestone Jun 23, 2020
@wfernandes
Copy link
Contributor Author

wfernandes commented Jun 23, 2020

@fabriziopandini @vincepri I've addressed all of the comments. Thanks for the great feedback!

Whenever y'all get the chance please review the last commit that put I added.
455c4be

This one changes the function prototype of the Process method to not depend on config.VariablesClient.
See this feedback comment thread: #3115 (comment)

UPDATE: Since I squashed the commits you can reference the file simple_processor.go to see the changes to Process.

@wfernandes
Copy link
Contributor Author

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 23, 2020
@wfernandes wfernandes force-pushed the clusterctl-templating-default-yaml-processor branch from 455c4be to 4db9565 Compare June 24, 2020 20:05
The clusterctl.GetClusterTemplateOptions now includes a YamlProcessor
option to specify a YamlProcessor to use. By default it uses the
SimpleProcessor.

Other notes:
- Consolidate all the arguments into a single TemplateClientInput struct
- Use SimpleProcessor as default template processor
- Use SimpleProcessor for components provider
- Adds '$' to SimpleProcessor's variable regex because there was a test
case that defined that behavior
- Add TemplateInput struct to reduce the number of args
- Removes explicit sort.Strings
Since the sets.String.List returns a sorted list
- Consolidates all the arguments for NewCompoonents into ComponentsInput
@fabriziopandini
Copy link
Member

@wfernandes outstanding job!
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 25, 2020
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.

Leaving these here for documentation:

sigs.k8s.io/cluster-api/cmd/clusterctl/client
Incompatible changes:

  • ClusterClientFactory: changed from func(Kubeconfig) (sigs.k8s.io/cluster-api/cmd/clusterctl/client/cluster.Client, error) to func(ClusterClientFactoryInput) (sigs.k8s.io/cluster-api/cmd/clusterctl/client/cluster.Client, error)
  • RepositoryClientFactory: changed from func(sigs.k8s.io/cluster-api/cmd/clusterctl/client/config.Provider) (sigs.k8s.io/cluster-api/cmd/clusterctl/client/repository.Client, error) to func(RepositoryClientFactoryInput) (sigs.k8s.io/cluster-api/cmd/clusterctl/client/repository.Client, error)

sigs.k8s.io/cluster-api/cmd/clusterctl/client/repository
Incompatible changes:

  • NewComponents: changed from func(sigs.k8s.io/cluster-api/cmd/clusterctl/client/config.Provider, sigs.k8s.io/cluster-api/cmd/clusterctl/client/config.Client, []byte, ComponentsOptions) (*components, error) to func(ComponentsInput) (*components, error)

The PR looks good to go to me, leaving final approval to @ncdc

@ncdc
Copy link
Contributor

ncdc commented Jun 25, 2020

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ncdc

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 Jun 25, 2020
@vincepri
Copy link
Member

/test pull-cluster-api-test

@vincepri
Copy link
Member

We need to wait for #3253 to merge before tests here can pass

@ncdc
Copy link
Contributor

ncdc commented Jun 25, 2020

/retest

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Jun 25, 2020

@wfernandes: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-cluster-api-apidiff e87da61 link /test pull-cluster-api-apidiff

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot merged commit e874a89 into kubernetes-sigs:master Jun 25, 2020
@wfernandes wfernandes deleted the clusterctl-templating-default-yaml-processor branch June 25, 2020 16:20
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. area/clusterctl Issues or PRs related to clusterctl 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants