diff --git a/Makefile b/Makefile index e038ad6763..77543f3567 100644 --- a/Makefile +++ b/Makefile @@ -69,6 +69,8 @@ generate: $(protoc_bin) get-crds generate-stackgres-crds ## Generate code with c go version rm -rf apis/generated go run sigs.k8s.io/controller-tools/cmd/controller-gen paths="{./apis/v1/..., ./apis/vshn/..., ./apis/exoscale/...}" object crd:crdVersions=v1,allowDangerousTypes=true output:artifacts:config=./apis/generated + # Because controller-gen creates the files with the plural `forgejoes` but angryjet expects `forgejos` + mv apis/generated/vshn.appcat.vshn.io_vshnforgejoes.yaml apis/generated/vshn.appcat.vshn.io_vshnforgejos.yaml go generate ./... # Because yaml is such a fun and easy specification, we need to hack some things here. # Depending on the yaml parser implementation the equal sign (=) has special meaning, or not... @@ -193,7 +195,7 @@ clean: get-crds: ./hack/get_crds.sh https://github.com/crossplane-contrib/provider-helm provider-helm apis/release apis/helm ./hack/get_crds.sh https://github.com/crossplane-contrib/provider-kubernetes provider-kubernetes apis/object/v1alpha2 apis/kubernetes - + # provider-sql needs manual fixes... Running this every time would break them. # The crossplane code generator only works if the code is valid, but the code is not valid until the code generator has run... #./hack/get_crds.sh https://github.com/crossplane-contrib/provider-sql provider-sql apis/ apis/sql diff --git a/README.md b/README.md index 770bdae523..19e26ade99 100644 --- a/README.md +++ b/README.md @@ -196,4 +196,3 @@ go run github.com/crossplane/crossplane/cmd/crank beta render xr.yaml compositio Crank will return a list of all the objects this specific request would have produced, including the result messages. Please have a look at the `hack/` folder for an example. - diff --git a/apis/vshn/v1/dbaas_vshn_forgejo.go b/apis/vshn/v1/dbaas_vshn_forgejo.go new file mode 100644 index 0000000000..0c0f09422a --- /dev/null +++ b/apis/vshn/v1/dbaas_vshn_forgejo.go @@ -0,0 +1,262 @@ +package v1 + +import ( + "fmt" + + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + v1 "github.com/vshn/appcat/v4/apis/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// Workaround to make nested defaulting work. +// kubebuilder is unable to set a {} default +//go:generate yq -i e ../../generated/vshn.appcat.vshn.io_vshnforgejos.yaml --expression "with(.spec.versions[]; .schema.openAPIV3Schema.properties.spec.properties.parameters.default={})" +//go:generate yq -i e ../../generated/vshn.appcat.vshn.io_vshnforgejos.yaml --expression "with(.spec.versions[]; .schema.openAPIV3Schema.properties.spec.properties.parameters.properties.size.default={})" +//go:generate yq -i e ../../generated/vshn.appcat.vshn.io_vshnforgejos.yaml --expression "with(.spec.versions[]; .schema.openAPIV3Schema.properties.spec.properties.parameters.properties.service.default={})" +//go:generate yq -i e ../../generated/vshn.appcat.vshn.io_vshnforgejos.yaml --expression "with(.spec.versions[]; .schema.openAPIV3Schema.properties.spec.properties.parameters.properties.tls.default={})" +//go:generate yq -i e ../../generated/vshn.appcat.vshn.io_vshnforgejos.yaml --expression "with(.spec.versions[]; .schema.openAPIV3Schema.properties.spec.properties.parameters.properties.backup.default={})" + +// +kubebuilder:object:root=true + +// VSHNForgejo is the API for creating forgejo instances. +type VSHNForgejo struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the desired state of a VSHNForgejo. + Spec VSHNForgejoSpec `json:"spec"` + + // Status reflects the observed state of a VSHNForgejo. + Status VSHNForgejoStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:generate=true +// +kubebuilder:object:root=true +type VSHNForgejoList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []VSHNForgejo `json:"items,omitempty"` +} + +// VSHNForgejoSpec defines the desired state of a VSHNForgejo. +type VSHNForgejoSpec struct { + // Parameters are the configurable fields of a VSHNForgejo. + Parameters VSHNForgejoParameters `json:"parameters,omitempty"` + + // WriteConnectionSecretToRef references a secret to which the connection details will be written. + WriteConnectionSecretToRef v1.LocalObjectReference `json:"writeConnectionSecretToRef,omitempty"` +} + +// VSHNForgejoParameters are the configurable fields of a VSHNForgejo. +type VSHNForgejoParameters struct { + // Service contains forgejo DBaaS specific properties + Service VSHNForgejoServiceSpec `json:"service,omitempty"` + + // Size contains settings to control the sizing of a service. + Size VSHNSizeSpec `json:"size,omitempty"` + + // Scheduling contains settings to control the scheduling of an instance. + Scheduling VSHNDBaaSSchedulingSpec `json:"scheduling,omitempty"` + + // TLS contains settings to control tls traffic of a service. + TLS VSHNForgejoTLSSpec `json:"tls,omitempty"` + + // Backup contains settings to control how the instance should get backed up. + Backup K8upBackupSpec `json:"backup,omitempty"` + + // Restore contains settings to control the restore of an instance. + Restore K8upRestoreSpec `json:"restore,omitempty"` + + // Maintenance contains settings to control the maintenance of an instance. + Maintenance VSHNDBaaSMaintenanceScheduleSpec `json:"maintenance,omitempty"` + + // Security defines the security of a service + Security Security `json:"security,omitempty"` +} + +// VSHNForgejoServiceSpec contains forgejo DBaaS specific properties +type VSHNForgejoServiceSpec struct { + // +kubebuilder:validation:Enum= + // +kubebuilder:default= + + // Version contains supported version of forgejo. + // Multiple versions are supported. The latest version is the default version. + Version string `json:"version,omitempty"` + + // Forgejosettings contains additional forgejo settings. + Forgejosettings string `json:"forgejosettings,omitempty"` + + // +kubebuilder:validation:Enum="besteffort";"guaranteed" + // +kubebuilder:default="besteffort" + + // ServiceLevel defines the service level of this service. Either Best Effort or Guaranteed Availability is allowed. + ServiceLevel VSHNDBaaSServiceLevel `json:"serviceLevel,omitempty"` +} + +// VSHNForgejoSizeSpec contains settings to control the sizing of a service. +type VSHNForgejoSizeSpec struct { + + // CPURequests defines the requests amount of Kubernetes CPUs for an instance. + CPURequests string `json:"cpuRequests,omitempty"` + + // CPULimits defines the limits amount of Kubernetes CPUs for an instance. + CPULimits string `json:"cpuLimits,omitempty"` + + // MemoryRequests defines the requests amount of memory in units of bytes for an instance. + MemoryRequests string `json:"memoryRequests,omitempty"` + + // MemoryLimits defines the limits amount of memory in units of bytes for an instance. + MemoryLimits string `json:"memoryLimits,omitempty"` + + // Disk defines the amount of disk space for an instance. + Disk string `json:"disk,omitempty"` + + // Plan is the name of the resource plan that defines the compute resources. + Plan string `json:"plan,omitempty"` +} + +// VSHNForgejoTLSSpec contains settings to control tls traffic of a service. +type VSHNForgejoTLSSpec struct { + // +kubebuilder:default=true + + // TLSEnabled enables TLS traffic for the service + TLSEnabled bool `json:"enabled,omitempty"` + + // +kubebuilder:default=true + // TLSAuthClients enables client authentication requirement + TLSAuthClients bool `json:"authClients,omitempty"` +} + +// VSHNForgejoStatus reflects the observed state of a VSHNForgejo. +type VSHNForgejoStatus struct { + NamespaceConditions []v1.Condition `json:"namespaceConditions,omitempty"` + SelfSignedIssuerConditions []v1.Condition `json:"selfSignedIssuerConditions,omitempty"` + LocalCAConditions []v1.Condition `json:"localCAConditions,omitempty"` + CaCertificateConditions []v1.Condition `json:"caCertificateConditions,omitempty"` + ServerCertificateConditions []v1.Condition `json:"serverCertificateConditions,omitempty"` + ClientCertificateConditions []v1.Condition `json:"clientCertificateConditions,omitempty"` + // InstanceNamespace contains the name of the namespace where the instance resides + InstanceNamespace string `json:"instanceNamespace,omitempty"` + // Schedules keeps track of random generated schedules, is overwriten by + // schedules set in the service's spec. + Schedules VSHNScheduleStatus `json:"schedules,omitempty"` +} + +func (v *VSHNForgejo) GetClaimNamespace() string { + return v.GetLabels()["crossplane.io/claim-namespace"] +} + +func (v *VSHNForgejo) GetInstanceNamespace() string { + return fmt.Sprintf("vshn-forgejo-%s", v.GetName()) +} + +func (v *VSHNForgejo) SetInstanceNamespaceStatus() { + v.Status.InstanceNamespace = v.GetInstanceNamespace() +} + +// +kubebuilder:object:generate=true +// +kubebuilder:object:root=true + +// XVSHNForgejo represents the internal composite of this claim +type XVSHNForgejo struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec XVSHNForgejoSpec `json:"spec"` + Status XVSHNForgejoStatus `json:"status,omitempty"` +} + +// XVSHNForgejoSpec defines the desired state of a VSHNForgejo. +type XVSHNForgejoSpec struct { + // Parameters are the configurable fields of a VSHNForgejo. + Parameters VSHNForgejoParameters `json:"parameters,omitempty"` + + xpv1.ResourceSpec `json:",inline"` +} + +type XVSHNForgejoStatus struct { + VSHNForgejoStatus `json:",inline"` + xpv1.ResourceStatus `json:",inline"` +} + +// +kubebuilder:object:generate=true +// +kubebuilder:object:root=true + +// XVSHNForgejoList represents a list of composites +type XVSHNForgejoList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []XVSHNForgejo `json:"items"` +} + +// GetMaintenanceDayOfWeek returns the currently set day of week +func (v *VSHNForgejo) GetMaintenanceDayOfWeek() string { + if v.Spec.Parameters.Maintenance.DayOfWeek != "" { + return v.Spec.Parameters.Maintenance.DayOfWeek + } + return v.Status.Schedules.Maintenance.DayOfWeek +} + +// GetMaintenanceTimeOfDay returns the currently set time of day +func (v *VSHNForgejo) GetMaintenanceTimeOfDay() string { + if v.Spec.Parameters.Maintenance.TimeOfDay != "" { + return v.Spec.Parameters.Maintenance.TimeOfDay + } + return v.Status.Schedules.Maintenance.TimeOfDay +} + +// SetMaintenanceDayOfWeek sets the day of week to the given value +func (v *VSHNForgejo) SetMaintenanceDayOfWeek(dow string) { + v.Status.Schedules.Maintenance.DayOfWeek = dow +} + +// SetMaintenanceTimeOfDay sets the time of day to the given value +func (v *VSHNForgejo) SetMaintenanceTimeOfDay(tod string) { + v.Status.Schedules.Maintenance.TimeOfDay = tod +} + +// GetBackupSchedule returns the current backup schedule +func (v *VSHNForgejo) GetBackupSchedule() string { + if v.Spec.Parameters.Backup.Schedule != "" { + return v.Spec.Parameters.Backup.Schedule + } + return v.Status.Schedules.Backup +} + +// SetBackupSchedule overwrites the current backup schedule +func (v *VSHNForgejo) SetBackupSchedule(schedule string) { + v.Status.Schedules.Backup = schedule +} + +// GetBackupRetention returns the retention definition for this backup. +func (v *VSHNForgejo) GetBackupRetention() K8upRetentionPolicy { + return v.Spec.Parameters.Backup.Retention +} + +// GetServiceName returns the name of this service +func (v *VSHNForgejo) GetServiceName() string { + return "forgejo" +} + +// GetFullMaintenanceSchedule returns +func (v *VSHNForgejo) GetFullMaintenanceSchedule() VSHNDBaaSMaintenanceScheduleSpec { + schedule := v.Spec.Parameters.Maintenance + schedule.DayOfWeek = v.GetMaintenanceDayOfWeek() + schedule.TimeOfDay = v.GetMaintenanceTimeOfDay() + return schedule +} + +// GetAllowAllNamespaces returns the AllowAllNamespaces field of this service +func (v *VSHNForgejo) GetAllowAllNamespaces() bool { + return v.Spec.Parameters.Security.AllowAllNamespaces +} + +// GetAllowedNamespaces returns the AllowedNamespaces array of this service +func (v *VSHNForgejo) GetAllowedNamespaces() []string { + if v.Spec.Parameters.Security.AllowedNamespaces == nil { + v.Spec.Parameters.Security.AllowedNamespaces = []string{} + } + return append(v.Spec.Parameters.Security.AllowedNamespaces, v.GetClaimNamespace()) +} diff --git a/apis/vshn/v1/zz_generated.deepcopy.go b/apis/vshn/v1/zz_generated.deepcopy.go index b9f76b551d..67a130292e 100644 --- a/apis/vshn/v1/zz_generated.deepcopy.go +++ b/apis/vshn/v1/zz_generated.deepcopy.go @@ -200,6 +200,208 @@ func (in *VSHNDBaaSSizeRequestsSpec) DeepCopy() *VSHNDBaaSSizeRequestsSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VSHNForgejo) DeepCopyInto(out *VSHNForgejo) { + *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 VSHNForgejo. +func (in *VSHNForgejo) DeepCopy() *VSHNForgejo { + if in == nil { + return nil + } + out := new(VSHNForgejo) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VSHNForgejo) 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 *VSHNForgejoList) DeepCopyInto(out *VSHNForgejoList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]VSHNForgejo, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VSHNForgejoList. +func (in *VSHNForgejoList) DeepCopy() *VSHNForgejoList { + if in == nil { + return nil + } + out := new(VSHNForgejoList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VSHNForgejoList) 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 *VSHNForgejoParameters) DeepCopyInto(out *VSHNForgejoParameters) { + *out = *in + out.Service = in.Service + out.Size = in.Size + in.Scheduling.DeepCopyInto(&out.Scheduling) + out.TLS = in.TLS + out.Backup = in.Backup + out.Restore = in.Restore + out.Maintenance = in.Maintenance + in.Security.DeepCopyInto(&out.Security) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VSHNForgejoParameters. +func (in *VSHNForgejoParameters) DeepCopy() *VSHNForgejoParameters { + if in == nil { + return nil + } + out := new(VSHNForgejoParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VSHNForgejoServiceSpec) DeepCopyInto(out *VSHNForgejoServiceSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VSHNForgejoServiceSpec. +func (in *VSHNForgejoServiceSpec) DeepCopy() *VSHNForgejoServiceSpec { + if in == nil { + return nil + } + out := new(VSHNForgejoServiceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VSHNForgejoSizeSpec) DeepCopyInto(out *VSHNForgejoSizeSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VSHNForgejoSizeSpec. +func (in *VSHNForgejoSizeSpec) DeepCopy() *VSHNForgejoSizeSpec { + if in == nil { + return nil + } + out := new(VSHNForgejoSizeSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VSHNForgejoSpec) DeepCopyInto(out *VSHNForgejoSpec) { + *out = *in + in.Parameters.DeepCopyInto(&out.Parameters) + out.WriteConnectionSecretToRef = in.WriteConnectionSecretToRef +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VSHNForgejoSpec. +func (in *VSHNForgejoSpec) DeepCopy() *VSHNForgejoSpec { + if in == nil { + return nil + } + out := new(VSHNForgejoSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VSHNForgejoStatus) DeepCopyInto(out *VSHNForgejoStatus) { + *out = *in + if in.NamespaceConditions != nil { + in, out := &in.NamespaceConditions, &out.NamespaceConditions + *out = make([]apisv1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.SelfSignedIssuerConditions != nil { + in, out := &in.SelfSignedIssuerConditions, &out.SelfSignedIssuerConditions + *out = make([]apisv1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.LocalCAConditions != nil { + in, out := &in.LocalCAConditions, &out.LocalCAConditions + *out = make([]apisv1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.CaCertificateConditions != nil { + in, out := &in.CaCertificateConditions, &out.CaCertificateConditions + *out = make([]apisv1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ServerCertificateConditions != nil { + in, out := &in.ServerCertificateConditions, &out.ServerCertificateConditions + *out = make([]apisv1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ClientCertificateConditions != nil { + in, out := &in.ClientCertificateConditions, &out.ClientCertificateConditions + *out = make([]apisv1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + out.Schedules = in.Schedules +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VSHNForgejoStatus. +func (in *VSHNForgejoStatus) DeepCopy() *VSHNForgejoStatus { + if in == nil { + return nil + } + out := new(VSHNForgejoStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VSHNForgejoTLSSpec) DeepCopyInto(out *VSHNForgejoTLSSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VSHNForgejoTLSSpec. +func (in *VSHNForgejoTLSSpec) DeepCopy() *VSHNForgejoTLSSpec { + if in == nil { + return nil + } + out := new(VSHNForgejoTLSSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VSHNKeycloak) DeepCopyInto(out *VSHNKeycloak) { *out = *in @@ -1285,6 +1487,99 @@ func (in *VSHNSizeSpec) DeepCopy() *VSHNSizeSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *XVSHNForgejo) DeepCopyInto(out *XVSHNForgejo) { + *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 XVSHNForgejo. +func (in *XVSHNForgejo) DeepCopy() *XVSHNForgejo { + if in == nil { + return nil + } + out := new(XVSHNForgejo) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *XVSHNForgejo) 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 *XVSHNForgejoList) DeepCopyInto(out *XVSHNForgejoList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]XVSHNForgejo, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new XVSHNForgejoList. +func (in *XVSHNForgejoList) DeepCopy() *XVSHNForgejoList { + if in == nil { + return nil + } + out := new(XVSHNForgejoList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *XVSHNForgejoList) 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 *XVSHNForgejoSpec) DeepCopyInto(out *XVSHNForgejoSpec) { + *out = *in + in.Parameters.DeepCopyInto(&out.Parameters) + in.ResourceSpec.DeepCopyInto(&out.ResourceSpec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new XVSHNForgejoSpec. +func (in *XVSHNForgejoSpec) DeepCopy() *XVSHNForgejoSpec { + if in == nil { + return nil + } + out := new(XVSHNForgejoSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *XVSHNForgejoStatus) DeepCopyInto(out *XVSHNForgejoStatus) { + *out = *in + in.VSHNForgejoStatus.DeepCopyInto(&out.VSHNForgejoStatus) + in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new XVSHNForgejoStatus. +func (in *XVSHNForgejoStatus) DeepCopy() *XVSHNForgejoStatus { + if in == nil { + return nil + } + out := new(XVSHNForgejoStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *XVSHNKeycloak) DeepCopyInto(out *XVSHNKeycloak) { *out = *in diff --git a/apis/vshn/v1/zz_generated.managed.go b/apis/vshn/v1/zz_generated.managed.go index c2257719f9..fe4fc124b6 100644 --- a/apis/vshn/v1/zz_generated.managed.go +++ b/apis/vshn/v1/zz_generated.managed.go @@ -4,6 +4,66 @@ package v1 import xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" +// GetCondition of this XVSHNForgejo. +func (mg *XVSHNForgejo) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return mg.Status.GetCondition(ct) +} + +// GetDeletionPolicy of this XVSHNForgejo. +func (mg *XVSHNForgejo) GetDeletionPolicy() xpv1.DeletionPolicy { + return mg.Spec.DeletionPolicy +} + +// GetManagementPolicies of this XVSHNForgejo. +func (mg *XVSHNForgejo) GetManagementPolicies() xpv1.ManagementPolicies { + return mg.Spec.ManagementPolicies +} + +// GetProviderConfigReference of this XVSHNForgejo. +func (mg *XVSHNForgejo) GetProviderConfigReference() *xpv1.Reference { + return mg.Spec.ProviderConfigReference +} + +// GetPublishConnectionDetailsTo of this XVSHNForgejo. +func (mg *XVSHNForgejo) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { + return mg.Spec.PublishConnectionDetailsTo +} + +// GetWriteConnectionSecretToReference of this XVSHNForgejo. +func (mg *XVSHNForgejo) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + return mg.Spec.WriteConnectionSecretToReference +} + +// SetConditions of this XVSHNForgejo. +func (mg *XVSHNForgejo) SetConditions(c ...xpv1.Condition) { + mg.Status.SetConditions(c...) +} + +// SetDeletionPolicy of this XVSHNForgejo. +func (mg *XVSHNForgejo) SetDeletionPolicy(r xpv1.DeletionPolicy) { + mg.Spec.DeletionPolicy = r +} + +// SetManagementPolicies of this XVSHNForgejo. +func (mg *XVSHNForgejo) SetManagementPolicies(r xpv1.ManagementPolicies) { + mg.Spec.ManagementPolicies = r +} + +// SetProviderConfigReference of this XVSHNForgejo. +func (mg *XVSHNForgejo) SetProviderConfigReference(r *xpv1.Reference) { + mg.Spec.ProviderConfigReference = r +} + +// SetPublishConnectionDetailsTo of this XVSHNForgejo. +func (mg *XVSHNForgejo) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { + mg.Spec.PublishConnectionDetailsTo = r +} + +// SetWriteConnectionSecretToReference of this XVSHNForgejo. +func (mg *XVSHNForgejo) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { + mg.Spec.WriteConnectionSecretToReference = r +} + // GetCondition of this XVSHNKeycloak. func (mg *XVSHNKeycloak) GetCondition(ct xpv1.ConditionType) xpv1.Condition { return mg.Status.GetCondition(ct) diff --git a/apis/vshn/v1/zz_generated.managedlist.go b/apis/vshn/v1/zz_generated.managedlist.go index ef5dc90c3b..71950b8f7a 100644 --- a/apis/vshn/v1/zz_generated.managedlist.go +++ b/apis/vshn/v1/zz_generated.managedlist.go @@ -4,6 +4,15 @@ package v1 import resource "github.com/crossplane/crossplane-runtime/pkg/resource" +// GetItems of this XVSHNForgejoList. +func (l *XVSHNForgejoList) GetItems() []resource.Managed { + items := make([]resource.Managed, len(l.Items)) + for i := range l.Items { + items[i] = &l.Items[i] + } + return items +} + // GetItems of this XVSHNKeycloakList. func (l *XVSHNKeycloakList) GetItems() []resource.Managed { items := make([]resource.Managed, len(l.Items)) diff --git a/cmd/functions.go b/cmd/functions.go index b0378b0a52..4cbee89624 100644 --- a/cmd/functions.go +++ b/cmd/functions.go @@ -6,6 +6,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" _ "github.com/vshn/appcat/v4/pkg/comp-functions/functions/miniobucket" + _ "github.com/vshn/appcat/v4/pkg/comp-functions/functions/vshnforgejo" _ "github.com/vshn/appcat/v4/pkg/comp-functions/functions/vshnkeycloak" _ "github.com/vshn/appcat/v4/pkg/comp-functions/functions/vshnmariadb" _ "github.com/vshn/appcat/v4/pkg/comp-functions/functions/vshnminio" diff --git a/crds/vshn.appcat.vshn.io_vshnforgejos.yaml b/crds/vshn.appcat.vshn.io_vshnforgejos.yaml new file mode 100644 index 0000000000..d7f551b0dd --- /dev/null +++ b/crds/vshn.appcat.vshn.io_vshnforgejos.yaml @@ -0,0 +1,470 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.14.0 + name: vshnforgejoes.vshn.appcat.vshn.io +spec: + group: vshn.appcat.vshn.io + names: + kind: VSHNForgejo + listKind: VSHNForgejoList + plural: vshnforgejoes + singular: vshnforgejo + scope: Namespaced + versions: + - name: v1 + schema: + openAPIV3Schema: + description: VSHNForgejo is the API for creating forgejo instances. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: Spec defines the desired state of a VSHNForgejo. + properties: + parameters: + description: Parameters are the configurable fields of a VSHNForgejo. + properties: + backup: + description: Backup contains settings to control how the instance should get backed up. + properties: + retention: + description: K8upRetentionPolicy describes the retention configuration for a K8up backup. + properties: + keepDaily: + default: 6 + type: integer + keepHourly: + type: integer + keepLast: + type: integer + keepMonthly: + type: integer + keepWeekly: + type: integer + keepYearly: + type: integer + type: object + schedule: + pattern: ^(\*|([0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9])|\*\/([0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9])) (\*|([0-9]|1[0-9]|2[0-3])|\*\/([0-9]|1[0-9]|2[0-3])) (\*|([1-9]|1[0-9]|2[0-9]|3[0-1])|\*\/([1-9]|1[0-9]|2[0-9]|3[0-1])) (\*|([1-9]|1[0-2])|\*\/([1-9]|1[0-2])) (\*|([0-6])|\*\/([0-6]))$ + type: string + type: object + default: {} + maintenance: + description: Maintenance contains settings to control the maintenance of an instance. + properties: + dayOfWeek: + description: |- + DayOfWeek specifies at which weekday the maintenance is held place. + Allowed values are [monday, tuesday, wednesday, thursday, friday, saturday, sunday] + enum: + - monday + - tuesday + - wednesday + - thursday + - friday + - saturday + - sunday + type: string + timeOfDay: + description: |- + TimeOfDay for installing updates in UTC. + Format: "hh:mm:ss". + pattern: ^([0-1]?[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$ + type: string + type: object + restore: + description: Restore contains settings to control the restore of an instance. + properties: + backupName: + description: BackupName is the name of the specific backup you want to restore. + type: string + claimName: + description: |- + ClaimName specifies the name of the instance you want to restore from. + The claim has to be in the same namespace as this new instance. + type: string + type: object + scheduling: + description: Scheduling contains settings to control the scheduling of an instance. + properties: + nodeSelector: + additionalProperties: + type: string + description: NodeSelector is a selector which must match a node’s labels for the pod to be scheduled on that node + type: object + type: object + security: + description: Security defines the security of a service + properties: + allowAllNamespaces: + default: false + description: AllowAllNamespaces allows the service to be accessible from all namespaces, this supersedes the AllowedNamespaces field + type: boolean + allowedNamespaces: + description: AllowedNamespaces defines a list of namespaces from where the service can be reached in the claim namespace + items: + type: string + type: array + type: object + service: + description: Service contains forgejo DBaaS specific properties + properties: + forgejosettings: + description: Forgejosettings contains additional forgejo settings. + type: string + serviceLevel: + default: besteffort + description: ServiceLevel defines the service level of this service. Either Best Effort or Guaranteed Availability is allowed. + enum: + - besteffort + - guaranteed + type: string + version: + default: + description: |- + Version contains supported version of forgejo. + Multiple versions are supported. The latest version is the default version. + enum: + - + type: string + type: object + default: {} + size: + description: Size contains settings to control the sizing of a service. + properties: + cpu: + description: CPU defines the amount of Kubernetes CPUs for an instance. + type: string + disk: + description: Disk defines the amount of disk space for an instance. + type: string + memory: + description: Memory defines the amount of memory in units of bytes for an instance. + type: string + plan: + description: Plan is the name of the resource plan that defines the compute resources. + type: string + requests: + description: Requests defines CPU and memory requests for an instance + properties: + cpu: + description: CPU defines the amount of Kubernetes CPUs for an instance. + type: string + memory: + description: Memory defines the amount of memory in units of bytes for an instance. + type: string + type: object + type: object + default: {} + tls: + description: TLS contains settings to control tls traffic of a service. + properties: + authClients: + default: true + description: TLSAuthClients enables client authentication requirement + type: boolean + enabled: + default: true + description: TLSEnabled enables TLS traffic for the service + type: boolean + type: object + default: {} + type: object + default: {} + writeConnectionSecretToRef: + description: WriteConnectionSecretToRef references a secret to which the connection details will be written. + properties: + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + namespace: + type: string + type: object + x-kubernetes-map-type: atomic + type: object + status: + description: Status reflects the observed state of a VSHNForgejo. + properties: + caCertificateConditions: + items: + properties: + lastTransitionTime: + description: LastTransitionTime is the last time the condition transitioned from one status to another. + format: date-time + type: string + message: + description: Message is a human-readable message indicating details about the transition. + maxLength: 32768 + type: string + observedGeneration: + description: |- + ObservedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: Reason contains a programmatic identifier indicating the reason for the condition's last transition. + maxLength: 1024 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: Status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: Type of condition. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + type: object + type: array + clientCertificateConditions: + items: + properties: + lastTransitionTime: + description: LastTransitionTime is the last time the condition transitioned from one status to another. + format: date-time + type: string + message: + description: Message is a human-readable message indicating details about the transition. + maxLength: 32768 + type: string + observedGeneration: + description: |- + ObservedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: Reason contains a programmatic identifier indicating the reason for the condition's last transition. + maxLength: 1024 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: Status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: Type of condition. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + type: object + type: array + instanceNamespace: + description: InstanceNamespace contains the name of the namespace where the instance resides + type: string + localCAConditions: + items: + properties: + lastTransitionTime: + description: LastTransitionTime is the last time the condition transitioned from one status to another. + format: date-time + type: string + message: + description: Message is a human-readable message indicating details about the transition. + maxLength: 32768 + type: string + observedGeneration: + description: |- + ObservedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: Reason contains a programmatic identifier indicating the reason for the condition's last transition. + maxLength: 1024 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: Status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: Type of condition. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + type: object + type: array + namespaceConditions: + items: + properties: + lastTransitionTime: + description: LastTransitionTime is the last time the condition transitioned from one status to another. + format: date-time + type: string + message: + description: Message is a human-readable message indicating details about the transition. + maxLength: 32768 + type: string + observedGeneration: + description: |- + ObservedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: Reason contains a programmatic identifier indicating the reason for the condition's last transition. + maxLength: 1024 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: Status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: Type of condition. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + type: object + type: array + schedules: + description: |- + Schedules keeps track of random generated schedules, is overwriten by + schedules set in the service's spec. + properties: + backup: + description: Backup keeps track of the backup schedule. + type: string + maintenance: + description: Maintenance keeps track of the maintenance schedule. + properties: + dayOfWeek: + description: |- + DayOfWeek specifies at which weekday the maintenance is held place. + Allowed values are [monday, tuesday, wednesday, thursday, friday, saturday, sunday] + enum: + - monday + - tuesday + - wednesday + - thursday + - friday + - saturday + - sunday + type: string + timeOfDay: + description: |- + TimeOfDay for installing updates in UTC. + Format: "hh:mm:ss". + pattern: ^([0-1]?[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$ + type: string + type: object + type: object + selfSignedIssuerConditions: + items: + properties: + lastTransitionTime: + description: LastTransitionTime is the last time the condition transitioned from one status to another. + format: date-time + type: string + message: + description: Message is a human-readable message indicating details about the transition. + maxLength: 32768 + type: string + observedGeneration: + description: |- + ObservedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: Reason contains a programmatic identifier indicating the reason for the condition's last transition. + maxLength: 1024 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: Status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: Type of condition. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + type: object + type: array + serverCertificateConditions: + items: + properties: + lastTransitionTime: + description: LastTransitionTime is the last time the condition transitioned from one status to another. + format: date-time + type: string + message: + description: Message is a human-readable message indicating details about the transition. + maxLength: 32768 + type: string + observedGeneration: + description: |- + ObservedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: Reason contains a programmatic identifier indicating the reason for the condition's last transition. + maxLength: 1024 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: Status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: Type of condition. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + type: object + type: array + type: object + required: + - spec + type: object + served: true + storage: true diff --git a/crds/vshn.appcat.vshn.io_xvshnforgejoes.yaml b/crds/vshn.appcat.vshn.io_xvshnforgejoes.yaml new file mode 100644 index 0000000000..f554b225af --- /dev/null +++ b/crds/vshn.appcat.vshn.io_xvshnforgejoes.yaml @@ -0,0 +1,712 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.14.0 + name: xvshnforgejoes.vshn.appcat.vshn.io +spec: + group: vshn.appcat.vshn.io + names: + kind: XVSHNForgejo + listKind: XVSHNForgejoList + plural: xvshnforgejoes + singular: xvshnforgejo + scope: Namespaced + versions: + - name: v1 + schema: + openAPIV3Schema: + description: XVSHNForgejo represents the internal composite of this claim + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: XVSHNForgejoSpec defines the desired state of a VSHNForgejo. + properties: + deletionPolicy: + default: Delete + description: |- + DeletionPolicy specifies what will happen to the underlying external + when this managed resource is deleted - either "Delete" or "Orphan" the + external resource. + This field is planned to be deprecated in favor of the ManagementPolicies + field in a future release. Currently, both could be set independently and + non-default values would be honored if the feature flag is enabled. + See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + enum: + - Orphan + - Delete + type: string + managementPolicies: + default: + - '*' + description: |- + THIS IS A BETA FIELD. It is on by default but can be opted out + through a Crossplane feature flag. + ManagementPolicies specify the array of actions Crossplane is allowed to + take on the managed and external resources. + This field is planned to replace the DeletionPolicy field in a future + release. Currently, both could be set independently and non-default + values would be honored if the feature flag is enabled. If both are + custom, the DeletionPolicy field will be ignored. + See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md + items: + description: |- + A ManagementAction represents an action that the Crossplane controllers + can take on an external resource. + enum: + - Observe + - Create + - Update + - Delete + - LateInitialize + - '*' + type: string + type: array + parameters: + description: Parameters are the configurable fields of a VSHNForgejo. + properties: + backup: + description: Backup contains settings to control how the instance + should get backed up. + properties: + retention: + description: K8upRetentionPolicy describes the retention configuration + for a K8up backup. + properties: + keepDaily: + default: 6 + type: integer + keepHourly: + type: integer + keepLast: + type: integer + keepMonthly: + type: integer + keepWeekly: + type: integer + keepYearly: + type: integer + type: object + schedule: + pattern: ^(\*|([0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9])|\*\/([0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9])) + (\*|([0-9]|1[0-9]|2[0-3])|\*\/([0-9]|1[0-9]|2[0-3])) (\*|([1-9]|1[0-9]|2[0-9]|3[0-1])|\*\/([1-9]|1[0-9]|2[0-9]|3[0-1])) + (\*|([1-9]|1[0-2])|\*\/([1-9]|1[0-2])) (\*|([0-6])|\*\/([0-6]))$ + type: string + type: object + maintenance: + description: Maintenance contains settings to control the maintenance + of an instance. + properties: + dayOfWeek: + description: |- + DayOfWeek specifies at which weekday the maintenance is held place. + Allowed values are [monday, tuesday, wednesday, thursday, friday, saturday, sunday] + enum: + - monday + - tuesday + - wednesday + - thursday + - friday + - saturday + - sunday + type: string + timeOfDay: + description: |- + TimeOfDay for installing updates in UTC. + Format: "hh:mm:ss". + pattern: ^([0-1]?[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$ + type: string + type: object + restore: + description: Restore contains settings to control the restore + of an instance. + properties: + backupName: + description: BackupName is the name of the specific backup + you want to restore. + type: string + claimName: + description: |- + ClaimName specifies the name of the instance you want to restore from. + The claim has to be in the same namespace as this new instance. + type: string + type: object + scheduling: + description: Scheduling contains settings to control the scheduling + of an instance. + properties: + nodeSelector: + additionalProperties: + type: string + description: NodeSelector is a selector which must match a + node’s labels for the pod to be scheduled on that node + type: object + type: object + security: + description: Security defines the security of a service + properties: + allowAllNamespaces: + default: false + description: AllowAllNamespaces allows the service to be accessible + from all namespaces, this supersedes the AllowedNamespaces + field + type: boolean + allowedNamespaces: + description: AllowedNamespaces defines a list of namespaces + from where the service can be reached in the claim namespace + items: + type: string + type: array + type: object + service: + description: Service contains forgejo DBaaS specific properties + properties: + forgejosettings: + description: Forgejosettings contains additional forgejo settings. + type: string + serviceLevel: + default: besteffort + description: ServiceLevel defines the service level of this + service. Either Best Effort or Guaranteed Availability is + allowed. + enum: + - besteffort + - guaranteed + type: string + version: + default: + description: |- + Version contains supported version of forgejo. + Multiple versions are supported. The latest version is the default version. + enum: + - + type: string + type: object + size: + description: Size contains settings to control the sizing of a + service. + properties: + cpu: + description: CPU defines the amount of Kubernetes CPUs for + an instance. + type: string + disk: + description: Disk defines the amount of disk space for an + instance. + type: string + memory: + description: Memory defines the amount of memory in units + of bytes for an instance. + type: string + plan: + description: Plan is the name of the resource plan that defines + the compute resources. + type: string + requests: + description: Requests defines CPU and memory requests for + an instance + properties: + cpu: + description: CPU defines the amount of Kubernetes CPUs + for an instance. + type: string + memory: + description: Memory defines the amount of memory in units + of bytes for an instance. + type: string + type: object + type: object + tls: + description: TLS contains settings to control tls traffic of a + service. + properties: + authClients: + default: true + description: TLSAuthClients enables client authentication + requirement + type: boolean + enabled: + default: true + description: TLSEnabled enables TLS traffic for the service + type: boolean + type: object + type: object + providerConfigRef: + default: + name: default + description: |- + ProviderConfigReference specifies how the provider that will be used to + create, observe, update, and delete this managed resource should be + configured. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + publishConnectionDetailsTo: + description: |- + PublishConnectionDetailsTo specifies the connection secret config which + contains a name, metadata and a reference to secret store config to + which any connection details for this managed resource should be written. + Connection details frequently include the endpoint, username, + and password required to connect to the managed resource. + properties: + configRef: + default: + name: default + description: |- + SecretStoreConfigRef specifies which secret store config should be used + for this ConnectionSecret. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + metadata: + description: Metadata is the metadata for connection secret. + properties: + annotations: + additionalProperties: + type: string + description: |- + Annotations are the annotations to be added to connection secret. + - For Kubernetes secrets, this will be used as "metadata.annotations". + - It is up to Secret Store implementation for others store types. + type: object + labels: + additionalProperties: + type: string + description: |- + Labels are the labels/tags to be added to connection secret. + - For Kubernetes secrets, this will be used as "metadata.labels". + - It is up to Secret Store implementation for others store types. + type: object + type: + description: |- + Type is the SecretType for the connection secret. + - Only valid for Kubernetes Secret Stores. + type: string + type: object + name: + description: Name is the name of the connection secret. + type: string + required: + - name + type: object + writeConnectionSecretToRef: + description: |- + WriteConnectionSecretToReference specifies the namespace and name of a + Secret to which any connection details for this managed resource should + be written. Connection details frequently include the endpoint, username, + and password required to connect to the managed resource. + This field is planned to be replaced in a future release in favor of + PublishConnectionDetailsTo. Currently, both could be set independently + and connection details would be published to both without affecting + each other. + properties: + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - name + - namespace + type: object + type: object + status: + properties: + caCertificateConditions: + items: + properties: + lastTransitionTime: + description: LastTransitionTime is the last time the condition + transitioned from one status to another. + format: date-time + type: string + message: + description: Message is a human-readable message indicating + details about the transition. + maxLength: 32768 + type: string + observedGeneration: + description: |- + ObservedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: Reason contains a programmatic identifier indicating + the reason for the condition's last transition. + maxLength: 1024 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: Status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: Type of condition. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + type: object + type: array + clientCertificateConditions: + items: + properties: + lastTransitionTime: + description: LastTransitionTime is the last time the condition + transitioned from one status to another. + format: date-time + type: string + message: + description: Message is a human-readable message indicating + details about the transition. + maxLength: 32768 + type: string + observedGeneration: + description: |- + ObservedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: Reason contains a programmatic identifier indicating + the reason for the condition's last transition. + maxLength: 1024 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: Status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: Type of condition. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + type: object + type: array + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: |- + LastTransitionTime is the last time this condition transitioned from one + status to another. + format: date-time + type: string + message: + description: |- + A Message containing details about this condition's last transition from + one status to another, if any. + type: string + reason: + description: A Reason for this condition's last transition from + one status to another. + type: string + status: + description: Status of this condition; is it currently True, + False, or Unknown? + type: string + type: + description: |- + Type of this condition. At most one of each condition type may apply to + a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + instanceNamespace: + description: InstanceNamespace contains the name of the namespace + where the instance resides + type: string + localCAConditions: + items: + properties: + lastTransitionTime: + description: LastTransitionTime is the last time the condition + transitioned from one status to another. + format: date-time + type: string + message: + description: Message is a human-readable message indicating + details about the transition. + maxLength: 32768 + type: string + observedGeneration: + description: |- + ObservedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: Reason contains a programmatic identifier indicating + the reason for the condition's last transition. + maxLength: 1024 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: Status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: Type of condition. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + type: object + type: array + namespaceConditions: + items: + properties: + lastTransitionTime: + description: LastTransitionTime is the last time the condition + transitioned from one status to another. + format: date-time + type: string + message: + description: Message is a human-readable message indicating + details about the transition. + maxLength: 32768 + type: string + observedGeneration: + description: |- + ObservedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: Reason contains a programmatic identifier indicating + the reason for the condition's last transition. + maxLength: 1024 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: Status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: Type of condition. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + type: object + type: array + schedules: + description: |- + Schedules keeps track of random generated schedules, is overwriten by + schedules set in the service's spec. + properties: + backup: + description: Backup keeps track of the backup schedule. + type: string + maintenance: + description: Maintenance keeps track of the maintenance schedule. + properties: + dayOfWeek: + description: |- + DayOfWeek specifies at which weekday the maintenance is held place. + Allowed values are [monday, tuesday, wednesday, thursday, friday, saturday, sunday] + enum: + - monday + - tuesday + - wednesday + - thursday + - friday + - saturday + - sunday + type: string + timeOfDay: + description: |- + TimeOfDay for installing updates in UTC. + Format: "hh:mm:ss". + pattern: ^([0-1]?[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$ + type: string + type: object + type: object + selfSignedIssuerConditions: + items: + properties: + lastTransitionTime: + description: LastTransitionTime is the last time the condition + transitioned from one status to another. + format: date-time + type: string + message: + description: Message is a human-readable message indicating + details about the transition. + maxLength: 32768 + type: string + observedGeneration: + description: |- + ObservedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: Reason contains a programmatic identifier indicating + the reason for the condition's last transition. + maxLength: 1024 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: Status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: Type of condition. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + type: object + type: array + serverCertificateConditions: + items: + properties: + lastTransitionTime: + description: LastTransitionTime is the last time the condition + transitioned from one status to another. + format: date-time + type: string + message: + description: Message is a human-readable message indicating + details about the transition. + maxLength: 32768 + type: string + observedGeneration: + description: |- + ObservedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: Reason contains a programmatic identifier indicating + the reason for the condition's last transition. + maxLength: 1024 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: Status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: Type of condition. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + type: object + type: array + type: object + required: + - spec + type: object + served: true + storage: true diff --git a/forgejo.json b/forgejo.json new file mode 100644 index 0000000000..ed82947f7d --- /dev/null +++ b/forgejo.json @@ -0,0 +1,8 @@ +{ + "name": "VSHNForgejo", + "backup": true, + "restore": true, + "maintenance": true, + "tls": true, + "settingsKey": "forgejosettings" +} diff --git a/pkg/comp-functions/functions/vshnforgejo/deploy.go b/pkg/comp-functions/functions/vshnforgejo/deploy.go new file mode 100644 index 0000000000..ff0847e053 --- /dev/null +++ b/pkg/comp-functions/functions/vshnforgejo/deploy.go @@ -0,0 +1,174 @@ +package vshnforgejo + +import ( + "context" + "encoding/json" + "fmt" + + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + xfnproto "github.com/crossplane/function-sdk-go/proto/v1beta1" + sgv1 "github.com/vshn/appcat/v4/apis/stackgres/v1" + vshnv1 "github.com/vshn/appcat/v4/apis/vshn/v1" + "github.com/vshn/appcat/v4/pkg/comp-functions/functions/common" + "github.com/vshn/appcat/v4/pkg/comp-functions/runtime" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + k8sruntime "k8s.io/apimachinery/pkg/runtime" + "k8s.io/utils/ptr" +) + +const ( + pgInstanceNameSuffix = "-pg" + pgSecretName = "pg-creds" +) + +// DeployForgejo deploys a keycloak instance via the codecentric Helm Chart. +func DeployForgejo(ctx context.Context, svc *runtime.ServiceRuntime) *xfnproto.Result { + + comp := &vshnv1.VSHNForgejo{} + err := svc.GetObservedComposite(comp) + if err != nil { + return runtime.NewFatalResult(fmt.Errorf("cannot get composite: %w", err)) + } + + svc.Log.Info("Adding postgresql instance") + err = addPostgreSQL(svc, comp) + if err != nil { + return runtime.NewWarningResult(fmt.Sprintf("cannot create postgresql instance: %s", err)) + } + + svc.Log.Info("Bootstrapping instance namespace and rbac rules") + err = common.BootstrapInstanceNs(ctx, comp, comp.GetServiceName(), comp.GetName()+"-instanceNs", svc) + if err != nil { + return runtime.NewWarningResult(fmt.Sprintf("cannot bootstrap instance namespace: %s", err)) + } + + svc.Log.Info("Adding forgejo release") + err = addForgejo(ctx, svc, comp) + if err != nil { + return runtime.NewWarningResult(fmt.Sprintf("cannot add forgejo release: %s", err)) + } + + return nil +} + +// TODO: copied from keycloak, could probably go to common +func addPostgreSQL(svc *runtime.ServiceRuntime, comp *vshnv1.VSHNForgejo) error { + // Unfortunately k8up and stackgres backups don't match up very well... + // if no daily backup is set we just do the default. + retention := 6 + if comp.Spec.Parameters.Backup.Retention.KeepDaily != 0 { + retention = comp.Spec.Parameters.Backup.Retention.KeepDaily + } + + configs := map[string]string{ + "ignore_startup_parameters": "extra_float_digits, search_path", + } + + configBytes, err := json.Marshal(configs) + if err != nil { + return err + } + + params := &vshnv1.VSHNPostgreSQLParameters{ + Size: comp.Spec.Parameters.Size, + Maintenance: comp.GetFullMaintenanceSchedule(), + Backup: vshnv1.VSHNPostgreSQLBackup{ + Retention: retention, + DeletionProtection: ptr.To(true), + DeletionRetention: 7, + }, + Service: vshnv1.VSHNPostgreSQLServiceSpec{ + PgBouncerSettings: &sgv1.SGPoolingConfigSpecPgBouncerPgbouncerIni{ + Pgbouncer: k8sruntime.RawExtension{ + Raw: configBytes, + }, + }, + }, + } + + // if comp.Spec.Parameters.Service.PostgreSQLParameters != nil { + // err := mergo.Merge(params, comp.Spec.Parameters.Service.PostgreSQLParameters, mergo.WithOverride) + // if err != nil { + // return err + // } + + // // Mergo doesn't override non-default values with default values. So + // // changing true to false is not possible with a merge. + // // This is a small hack to fix this. + // // `mergo.WithOverwriteWithEmptyValue` opens a new can of worms, so it's + // // not used here. https://github.com/darccio/mergo/issues/249 + // if comp.Spec.Parameters.Service.PostgreSQLParameters.Backup.DeletionProtection != nil { + // params.Backup.DeletionProtection = comp.Spec.Parameters.Service.PostgreSQLParameters.Backup.DeletionProtection + // } + // } + // We need to set this after the merge, as the default instance count for PostgreSQL is always 1 + // and would therefore override any value we set before the merge. + params.Instances = 1 + + pg := &vshnv1.XVSHNPostgreSQL{ + ObjectMeta: metav1.ObjectMeta{ + Name: comp.GetName() + pgInstanceNameSuffix, + }, + Spec: vshnv1.XVSHNPostgreSQLSpec{ + Parameters: *params, + ResourceSpec: xpv1.ResourceSpec{ + WriteConnectionSecretToReference: &xpv1.SecretReference{ + Name: pgSecretName, + Namespace: comp.GetInstanceNamespace(), + }, + }, + }, + } + + err = common.CustomCreateNetworkPolicy([]string{comp.GetInstanceNamespace()}, pg.GetInstanceNamespace(), pg.GetName()+"-forgejo", false, svc) + if err != nil { + return err + } + + err = common.DisableBilling(pg.GetInstanceNamespace(), svc) + if err != nil { + return err + } + + return svc.SetDesiredComposedResource(pg) +} + +func addForgejo(ctx context.Context, svc *runtime.ServiceRuntime, comp *vshnv1.VSHNForgejo) error { + + cd, err := svc.GetObservedComposedResourceConnectionDetails(comp.GetName() + pgInstanceNameSuffix) + if err != nil { + return err + } + + values := map[string]any{ + "gitea": map[string]any{ + "config": map[string]any{ + "APP_NAME": "Yolo Forgejo", + "database": map[string]any{ + "DB_TYPE": "postgres", + "HOST": string(cd["POSTGRESQL_HOST"]), + "NAME": "postgres", + "USER": string(cd["POSTGRESQL_USER"]), + "PASSWD": string(cd["POSTGRESQL_PASSWORD"]), + "SCHEMA": "public", + }, + }, + }, + "postgresql": map[string]any{ + "enabled": false, + }, + "postgresql-ha": map[string]any{ + "enabled": false, + }, + "redis-cluster": map[string]any{ + "enabled": false, + }, + } + + release, err := common.NewRelease(ctx, svc, comp, values) + if err != nil { + return err + } + + return svc.SetDesiredComposedResource(release) +} diff --git a/pkg/comp-functions/functions/vshnforgejo/register.go b/pkg/comp-functions/functions/vshnforgejo/register.go new file mode 100644 index 0000000000..931e91923f --- /dev/null +++ b/pkg/comp-functions/functions/vshnforgejo/register.go @@ -0,0 +1,17 @@ +package vshnforgejo + +import ( + "github.com/vshn/appcat/v4/pkg/comp-functions/runtime" +) + +func init() { + runtime.RegisterService("forgejo", runtime.Service{ + Steps: []runtime.Step{ + + { + Name: "deploy", + Execute: DeployForgejo, + }, + }, + }) +} diff --git a/pkg/comp-functions/functions/vshnpostgres/connection_details.go b/pkg/comp-functions/functions/vshnpostgres/connection_details.go index 7c51848d64..7adaf40f78 100644 --- a/pkg/comp-functions/functions/vshnpostgres/connection_details.go +++ b/pkg/comp-functions/functions/vshnpostgres/connection_details.go @@ -11,6 +11,7 @@ import ( vshnv1 "github.com/vshn/appcat/v4/apis/vshn/v1" "github.com/vshn/appcat/v4/pkg/comp-functions/runtime" corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" controllerruntime "sigs.k8s.io/controller-runtime" ) @@ -145,8 +146,27 @@ func addConnectionDetailsToObject(obj *xkubev1.Object, comp *vshnv1.VSHNPostgreS obj.Spec.WriteConnectionSecretToReference = &commonv1.SecretReference{ Name: comp.GetName() + "-connection", - Namespace: comp.GetInstanceNamespace(), + Namespace: svc.Config.Data["crossplaneNamespace"], } - return svc.SetDesiredComposedResourceWithName(obj, "cluster") + err := svc.SetDesiredComposedResourceWithName(obj, "cluster") + if err != nil { + return err + } + + // TODO: should probably go somewhere else... + cd, err := svc.GetObservedComposedResourceConnectionDetails("pg-bucket") + if err != nil { + return err + } + + secret := &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: "pgbucket-" + comp.GetName(), + Namespace: comp.GetInstanceNamespace(), + }, + Data: cd, + } + + return svc.SetDesiredKubeObject(secret, comp.GetName()+"-bucket-credentials") } diff --git a/pkg/comp-functions/functions/vshnpostgres/pgqexporter_config.go b/pkg/comp-functions/functions/vshnpostgres/pgqexporter_config.go index 5301eda82a..62a1e8d6c5 100644 --- a/pkg/comp-functions/functions/vshnpostgres/pgqexporter_config.go +++ b/pkg/comp-functions/functions/vshnpostgres/pgqexporter_config.go @@ -45,10 +45,7 @@ func PgExporterConfig(ctx context.Context, svc *runtime.ServiceRuntime) *v1beta1 xRef := xkube.Reference{ DependsOn: &xkube.DependsOn{ - APIVersion: "stackgres.io/v1", - Kind: "SGCluster", - Name: comp.GetName(), - Namespace: comp.GetInstanceNamespace(), + Name: comp.GetName() + "-cluster", }, } diff --git a/pkg/comp-functions/functions/vshnpostgres/user_management.go b/pkg/comp-functions/functions/vshnpostgres/user_management.go index 3def0cce3e..82af7f4e1c 100644 --- a/pkg/comp-functions/functions/vshnpostgres/user_management.go +++ b/pkg/comp-functions/functions/vshnpostgres/user_management.go @@ -178,7 +178,7 @@ func addProviderConfig(comp *vshnv1.VSHNPostgreSQL, svc *runtime.ServiceRuntime) }, } - err = svc.SetDesiredKubeObject(config, comp.GetName()+"-providerconfig") + err = svc.SetDesiredComposedResource(config) if err != nil { svc.AddResult(runtime.NewWarningResult(fmt.Sprintf("cannot apply the provider config for provider sql: %s", err))) svc.Log.Error(err, "cannot apply the provider config for provider sql") diff --git a/pkg/comp-functions/runtime/function_mgr.go b/pkg/comp-functions/runtime/function_mgr.go index 16c12bf4c2..b6208dede9 100644 --- a/pkg/comp-functions/runtime/function_mgr.go +++ b/pkg/comp-functions/runtime/function_mgr.go @@ -95,7 +95,7 @@ type KubeObjectOption func(obj *xkube.Object) // ComposedResourceOption defines the type of functional parameters for Crossplane // managed resources -type ComposedResourceOption func(obj xpresource.Managed) +type ComposedResourceOption func(obj client.Object) // RegisterService will register a service to the map of all services. func RegisterService(name string, function Service) { @@ -322,7 +322,7 @@ func (s *ServiceRuntime) GetResponse() (*fnv1beta1.RunFunctionResponse, error) { // SetDesiredComposedResource adds the given object to the desired resources, it needs to be a proper // crossplane Managed Resource. -func (s *ServiceRuntime) SetDesiredComposedResource(obj xpresource.Managed, opts ...ComposedResourceOption) error { +func (s *ServiceRuntime) SetDesiredComposedResource(obj client.Object, opts ...ComposedResourceOption) error { return s.SetDesiredComposedResourceWithName(obj, obj.GetName(), opts...) } @@ -330,7 +330,7 @@ func (s *ServiceRuntime) SetDesiredComposedResource(obj xpresource.Managed, opts // crossplane Managed Resource. Additionally provide a name, if it's not derived from the object name. // Usually needed for objects that where migrated from P+T compositions with a static name. // Additionally it injects the claim-name, claim-namespace and the composite name as a label. -func (s *ServiceRuntime) SetDesiredComposedResourceWithName(obj xpresource.Managed, name string, opts ...ComposedResourceOption) error { +func (s *ServiceRuntime) SetDesiredComposedResourceWithName(obj client.Object, name string, opts ...ComposedResourceOption) error { s.addOwnerReferenceAnnotation(obj, true) @@ -351,7 +351,7 @@ func (s *ServiceRuntime) SetDesiredComposedResourceWithName(obj xpresource.Manag // as resName exists. // resName is the name of the resource in the desired map. func ComposedOptionProtectedBy(resName string) ComposedResourceOption { - return func(obj xpresource.Managed) { + return func(obj client.Object) { addProtectionAnnotation(resName, ProtectedByAnnotation, obj) } } @@ -359,7 +359,7 @@ func ComposedOptionProtectedBy(resName string) ComposedResourceOption { // ComposedOptionProtects is the inverse of ProtectedBy. The object with this annotation // protects the object with resName. func ComposedOptionProtects(resName string) ComposedResourceOption { - return func(obj xpresource.Managed) { + return func(obj client.Object) { addProtectionAnnotation(resName, ProtectsAnnotation, obj) } }