diff --git a/api/v1alpha1/export_types.go b/api/v1alpha1/export_types.go new file mode 100644 index 00000000..65403e78 --- /dev/null +++ b/api/v1alpha1/export_types.go @@ -0,0 +1,76 @@ +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + // ConditionReconciled is a status condition type that indicates whether the + // CR has been successfully reconciled + ConditionReconciled ConditionType = "Reconciled" + // ReconciledReasonComplete indicates the CR was successfully reconciled + ReconciledReasonComplete = "ReconcileComplete" + // ReconciledReasonError indicates an error was encountered while + // reconciling the CR + ReconciledReasonError = "ReconcileError" +) + +type ExportSpec struct { + // Method download or git. This defines which process + // to use for exporting objects from a cluster + Method string `json:"method"` + // Branch within the git repository + Branch string `json:"branch,omitempty"` + // Git repository which will be cloned and updated + Repo string `json:"repo,omitempty"` + // Email used to specify the user who performed the git commit + Email string `json:"email,omitempty"` + // Predefined secret that contains an SSH key that will + // be used for git cloning and pushing + Secret string `json:"secret,omitempty"` + // Set automatically by the webhook to dictate who will + // run the export process + User string `json:"user,omitempty"` + // Set automatically by the webhook to dictate the + // group + Group []string `json:"group,omitempty"` + // Filter Export by labels + LabelSelector string `json:"labelSelector,omitempty"` +} + +// ExportStatus defines the observed state of Export +type ExportStatus struct { + // Condition set by controller to signify the export completed + // successfully and the route is available + Completed bool `json:"completed,omitempty"` + Extracted bool `json:"extracted,omitempty"` + Conditions []Condition `json:"conditions,omitempty"` + // Route that is defined by the controller to specify the + // location of the zip file + Route string `json:"route,omitempty"` +} + +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status + +// Export is the Schema for the exports API +type Export struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec ExportSpec `json:"spec,omitempty"` + Status ExportStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// ExportList contains a list of Export +type ExportList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Export `json:"items"` +} + +func init() { + SchemeBuilder.Register(&Export{}, &ExportList{}) +} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 59792187..233e3ec5 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -414,6 +414,107 @@ func (in *DevSpaces) DeepCopy() *DevSpaces { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Export) DeepCopyInto(out *Export) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Export. +func (in *Export) DeepCopy() *Export { + if in == nil { + return nil + } + out := new(Export) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Export) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ExportList) DeepCopyInto(out *ExportList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Export, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExportList. +func (in *ExportList) DeepCopy() *ExportList { + if in == nil { + return nil + } + out := new(ExportList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ExportList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ExportSpec) DeepCopyInto(out *ExportSpec) { + *out = *in + if in.Group != nil { + in, out := &in.Group, &out.Group + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExportSpec. +func (in *ExportSpec) DeepCopy() *ExportSpec { + if in == nil { + return nil + } + out := new(ExportSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ExportStatus) DeepCopyInto(out *ExportStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExportStatus. +func (in *ExportStatus) DeepCopy() *ExportStatus { + if in == nil { + return nil + } + out := new(ExportStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GitHubSecret) DeepCopyInto(out *GitHubSecret) { *out = *in diff --git a/make/generate.mk b/make/generate.mk index b82b16e5..89dfcb23 100644 --- a/make/generate.mk +++ b/make/generate.mk @@ -6,7 +6,7 @@ API_VERSION:=v1alpha1 # how to dispatch the CRD files per repository (space-separated lists) # !!! IMPORTANT !!! - when there is a new CRD added or an existing one removed or renamed, don't forget to change it also here: https://github.com/codeready-toolchain/toolchain-cicd/blob/master/scripts/add-cluster.sh#L52-L73 HOST_CLUSTER_CRDS:=masteruserrecords nstemplatetiers usersignups bannedusers notifications spaces spacebindings socialevents tiertemplates toolchainstatuses toolchainclusters toolchainconfigs usertiers proxyplugins spacerequests -MEMBER_CLUSTER_CRDS:=useraccounts nstemplatesets memberstatuses idlers toolchainclusters memberoperatorconfigs spacerequests workspaces +MEMBER_CLUSTER_CRDS:=useraccounts nstemplatesets memberstatuses idlers toolchainclusters memberoperatorconfigs spacerequests workspaces exports PATH_TO_CRD_BASES=config/crd/bases