|
| 1 | +// SPDX-FileCopyrightText: The RamenDR authors |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +// This package is a workaround to not depend on argoCD go.mod, as that brings in the entire k8s as a dependency |
| 5 | +// causing several valid and invalid security warnings, and in general polluting the ramen module dependencies |
| 6 | +// as well. The issue this workaround package overcomes is: https://github.com/argoproj/argo-cd/issues/4055 |
| 7 | + |
| 8 | +// This version of the API is as per ArgoCD version: |
| 9 | +// https://github.com/argoproj/argo-cd/blob/release-2.10/pkg/apis/application/v1alpha1/applicationset_types.go |
| 10 | + |
| 11 | +package argocdv1alpha1hack |
| 12 | + |
| 13 | +import ( |
| 14 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 15 | + "k8s.io/apimachinery/pkg/runtime" |
| 16 | + "k8s.io/apimachinery/pkg/runtime/schema" |
| 17 | +) |
| 18 | + |
| 19 | +// Below are just the bare minimum required fields that ramen uses for an ApplicationSet resource |
| 20 | + |
| 21 | +type ApplicationSetList struct { |
| 22 | + metav1.TypeMeta `json:",inline"` |
| 23 | + metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 24 | + Items []ApplicationSet `json:"items" protobuf:"bytes,2,rep,name=items"` |
| 25 | +} |
| 26 | + |
| 27 | +//nolint:maligned |
| 28 | +type ApplicationSet struct { |
| 29 | + metav1.TypeMeta `json:",inline"` |
| 30 | + metav1.ObjectMeta `json:"metadata" protobuf:"bytes,1,opt,name=metadata"` |
| 31 | + Spec ApplicationSetSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` |
| 32 | + Status ApplicationSetStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` |
| 33 | +} |
| 34 | + |
| 35 | +type ApplicationSetSpec struct { |
| 36 | + Generators []ApplicationSetGenerator `json:"generators" protobuf:"bytes,2,name=generators"` |
| 37 | + Template ApplicationSetTemplate `json:"template" protobuf:"bytes,3,name=template"` |
| 38 | +} |
| 39 | + |
| 40 | +type ApplicationSetGenerator struct { |
| 41 | + //nolint:lll |
| 42 | + ClusterDecisionResource *DuckTypeGenerator `json:"clusterDecisionResource,omitempty" protobuf:"bytes,5,name=clusterDecisionResource"` |
| 43 | +} |
| 44 | + |
| 45 | +type DuckTypeGenerator struct { |
| 46 | + ConfigMapRef string `json:"configMapRef" protobuf:"bytes,1,name=configMapRef"` |
| 47 | + LabelSelector metav1.LabelSelector `json:"labelSelector,omitempty" protobuf:"bytes,4,name=labelSelector"` |
| 48 | +} |
| 49 | + |
| 50 | +type ApplicationSetTemplate struct { |
| 51 | + ApplicationSetTemplateMeta `json:"metadata" protobuf:"bytes,1,name=metadata"` |
| 52 | + Spec ApplicationSpec `json:"spec" protobuf:"bytes,2,name=spec"` |
| 53 | +} |
| 54 | + |
| 55 | +type ApplicationSetTemplateMeta struct{} |
| 56 | + |
| 57 | +type ApplicationSpec struct { |
| 58 | + Destination ApplicationDestination `json:"destination" protobuf:"bytes,2,name=destination"` |
| 59 | + Project string `json:"project" protobuf:"bytes,3,name=project"` |
| 60 | +} |
| 61 | + |
| 62 | +type ApplicationDestination struct { |
| 63 | + Namespace string `json:"namespace,omitempty" protobuf:"bytes,2,opt,name=namespace"` |
| 64 | +} |
| 65 | + |
| 66 | +type ApplicationSetStatus struct{} |
| 67 | + |
| 68 | +// DeepCopy### interfaces required to use ApplicationSet as a runtime.Object |
| 69 | +// Lifted from generated deep copy file for other resources |
| 70 | + |
| 71 | +func (in *ApplicationSet) DeepCopyObject() runtime.Object { |
| 72 | + return in.DeepCopy() |
| 73 | +} |
| 74 | + |
| 75 | +func (in *ApplicationSet) DeepCopy() *ApplicationSet { |
| 76 | + if in == nil { |
| 77 | + return nil |
| 78 | + } |
| 79 | + |
| 80 | + out := new(ApplicationSet) |
| 81 | + |
| 82 | + in.DeepCopyInto(out) |
| 83 | + |
| 84 | + return out |
| 85 | +} |
| 86 | + |
| 87 | +func (in *ApplicationSet) DeepCopyInto(out *ApplicationSet) { |
| 88 | + *out = *in |
| 89 | + out.TypeMeta = in.TypeMeta |
| 90 | + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) |
| 91 | + out.Spec = in.Spec |
| 92 | + out.Status = in.Status |
| 93 | +} |
| 94 | + |
| 95 | +// DeepCopy### interfaces required to use ApplicationSetList as a runtime.Object |
| 96 | +// Lifted from generated deep copy file for other resources |
| 97 | +func (in *ApplicationSetList) DeepCopyInto(out *ApplicationSetList) { |
| 98 | + *out = *in |
| 99 | + out.TypeMeta = in.TypeMeta |
| 100 | + |
| 101 | + in.ListMeta.DeepCopyInto(&out.ListMeta) |
| 102 | + |
| 103 | + if in.Items != nil { |
| 104 | + in, out := &in.Items, &out.Items |
| 105 | + *out = make([]ApplicationSet, len(*in)) |
| 106 | + |
| 107 | + for i := range *in { |
| 108 | + (*in)[i].DeepCopyInto(&(*out)[i]) |
| 109 | + } |
| 110 | + } |
| 111 | +} |
| 112 | + |
| 113 | +func (in *ApplicationSetList) DeepCopy() *ApplicationSetList { |
| 114 | + if in == nil { |
| 115 | + return nil |
| 116 | + } |
| 117 | + |
| 118 | + out := new(ApplicationSetList) |
| 119 | + in.DeepCopyInto(out) |
| 120 | + |
| 121 | + return out |
| 122 | +} |
| 123 | + |
| 124 | +func (in *ApplicationSetList) DeepCopyObject() runtime.Object { |
| 125 | + c := in.DeepCopy() |
| 126 | + |
| 127 | + return c |
| 128 | +} |
| 129 | + |
| 130 | +// Schema registration helpers, with appropriate Group/Version/Kind values from the ArgoCD project |
| 131 | + |
| 132 | +var ( |
| 133 | + SchemeGroupVersion = schema.GroupVersion{Group: "argoproj.io", Version: "v1alpha1"} |
| 134 | + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) |
| 135 | + AddToScheme = SchemeBuilder.AddToScheme |
| 136 | +) |
| 137 | + |
| 138 | +func addKnownTypes(scheme *runtime.Scheme) error { |
| 139 | + scheme.AddKnownTypes(SchemeGroupVersion, |
| 140 | + &ApplicationSet{}, |
| 141 | + &ApplicationSetList{}, |
| 142 | + ) |
| 143 | + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) |
| 144 | + |
| 145 | + return nil |
| 146 | +} |
0 commit comments