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

⚠️ Removing CloneTemplate and CloneTemplateInput #7839

Merged
merged 1 commit into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 0 additions & 59 deletions controllers/external/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,65 +59,6 @@ func Delete(ctx context.Context, c client.Writer, ref *corev1.ObjectReference) e
return nil
}

// CloneTemplateInput is the input to CloneTemplate.
//
// Deprecated: use CreateFromTemplateInput instead. This type will be removed in a future release.
type CloneTemplateInput struct {
// Client is the controller runtime client.
Client client.Client

// TemplateRef is a reference to the template that needs to be cloned.
TemplateRef *corev1.ObjectReference

// Namespace is the Kubernetes namespace the cloned object should be created into.
Namespace string

// ClusterName is the cluster this object is linked to.
ClusterName string

// OwnerRef is an optional OwnerReference to attach to the cloned object.
// +optional
OwnerRef *metav1.OwnerReference

// Labels is an optional map of labels to be added to the object.
// +optional
Labels map[string]string

// Annotations is an optional map of annotations to be added to the object.
// +optional
Annotations map[string]string
}

// CloneTemplate uses the client and the reference to create a new object from the template.
//
// Deprecated: use CreateFromTemplate instead. This function will be removed in a future release.
func CloneTemplate(ctx context.Context, in *CloneTemplateInput) (*corev1.ObjectReference, error) {
from, err := Get(ctx, in.Client, in.TemplateRef, in.Namespace)
if err != nil {
return nil, err
}
generateTemplateInput := &GenerateTemplateInput{
Template: from,
TemplateRef: in.TemplateRef,
Namespace: in.Namespace,
ClusterName: in.ClusterName,
OwnerRef: in.OwnerRef,
Labels: in.Labels,
Annotations: in.Annotations,
}
to, err := GenerateTemplate(generateTemplateInput)
if err != nil {
return nil, err
}

// Create the external clone.
if err := in.Client.Create(ctx, to); err != nil {
return nil, err
}

return GetObjectReference(to), nil
}

// CreateFromTemplateInput is the input to CreateFromTemplate.
type CreateFromTemplateInput struct {
// Client is the controller runtime client.
Expand Down
1 change: 1 addition & 0 deletions docs/book/src/developer/providers/v1.3-to-v1.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ maintainers of providers and consumers of our Go API.

- `clusterctl backup` has been removed.
- `MachineHealthCheckSuccededCondition` condition type has been removed.
- `CloneTemplate` and `CloneTemplateInput` has been removed.

### API Changes

Expand Down