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

✨ Refactor template cloning for future use with kubeadmcontrolplane #1959

Merged
merged 1 commit into from
Dec 24, 2019

Conversation

detiber
Copy link
Member

@detiber detiber commented Dec 23, 2019

What this PR does / why we need it:

  • Use CloneTemplate through an interface for easier testing
  • Return an ObjectReference to the cloned resource rather than the resource itself
  • Add tests for template cloning

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 23, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: detiber

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 23, 2019
@detiber
Copy link
Member Author

detiber commented Dec 23, 2019

/assign @chuckha

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 23, 2019
@detiber detiber force-pushed the utilInjection branch 2 times, most recently from f035616 to 299d061 Compare December 23, 2019 20:29
- Use CloneTemplate through an interface for easier testing
- Return an ObjectReference to the cloned resource rather than the resource itself
- Add tests for template cloning
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.

oh this looks super nice!

/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 23, 2019
@k8s-ci-robot k8s-ci-robot merged commit 053db10 into kubernetes-sigs:master Dec 24, 2019
@@ -46,8 +49,10 @@ func Get(ctx context.Context, c client.Client, ref *corev1.ObjectReference, name
return obj, nil
}

type TemplateCloner struct{}
Copy link
Member

Choose a reason for hiding this comment

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

We need to add some documentation in the v1a2->v1a3 docs about this change, given that it might be used elsewhere

// CloneTemplate uses the client and the reference to create a new object from the template.
func CloneTemplate(ctx context.Context, c client.Client, ref *corev1.ObjectReference, namespace string) (*unstructured.Unstructured, error) {
func (tc *TemplateCloner) CloneTemplate(ctx context.Context, c client.Client, ref *corev1.ObjectReference, namespace, clusterName string, owner *metav1.OwnerReference) (*corev1.ObjectReference, error) {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if the list of arguments needs to be simplified in a struct in a future PR

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