diff --git a/api/v1alpha1/common.go b/api/v1alpha1/common.go index 78f44829..dbbf5aed 100644 --- a/api/v1alpha1/common.go +++ b/api/v1alpha1/common.go @@ -18,6 +18,7 @@ import ( "reflect" corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -357,3 +358,45 @@ type VolumeSource struct { // +optional Secret *corev1.SecretVolumeSource `json:"secret,omitempty"` } + +// PulsarConnectionRef indicates the connection reference +type PulsarConnectionRef struct { + // +optional + Namespace string `json:"namespace,omitempty"` + + // +required + Name string `json:"name"` +} + +// StreamNativeCloudConnectionRef indicates the connection reference +type StreamNativeCloudConnectionRef struct { + // +optional + Namespace string `json:"namespace,omitempty"` + + // +required + Name string `json:"name"` +} + +// ToNamespacedName converts the connection reference to a namespaced name +func (r PulsarConnectionRef) ToNamespacedName(defaultNamespace string) types.NamespacedName { + ns := defaultNamespace + if r.Namespace != "" { + ns = r.Namespace + } + return types.NamespacedName{ + Namespace: ns, + Name: r.Name, + } +} + +// ToNamespacedName converts the connection reference to a namespaced name +func (r StreamNativeCloudConnectionRef) ToNamespacedName(defaultNamespace string) types.NamespacedName { + ns := defaultNamespace + if r.Namespace != "" { + ns = r.Namespace + } + return types.NamespacedName{ + Namespace: ns, + Name: r.Name, + } +} diff --git a/api/v1alpha1/computeflinkdeployment_types.go b/api/v1alpha1/computeflinkdeployment_types.go index e29c94a2..303d656a 100644 --- a/api/v1alpha1/computeflinkdeployment_types.go +++ b/api/v1alpha1/computeflinkdeployment_types.go @@ -28,7 +28,7 @@ type ComputeFlinkDeploymentSpec struct { // APIServerRef is the reference to the StreamNativeCloudConnection. // If not specified, the APIServerRef from the referenced ComputeWorkspace will be used. // +optional - APIServerRef corev1.LocalObjectReference `json:"apiServerRef,omitempty"` + APIServerRef StreamNativeCloudConnectionRef `json:"apiServerRef,omitempty"` // WorkspaceName is the reference to the workspace, and is required // +kubebuilder:validation:Required diff --git a/api/v1alpha1/computeworkspace_types.go b/api/v1alpha1/computeworkspace_types.go index d32e02f7..237404e2 100644 --- a/api/v1alpha1/computeworkspace_types.go +++ b/api/v1alpha1/computeworkspace_types.go @@ -15,7 +15,6 @@ package v1alpha1 import ( - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -26,7 +25,7 @@ import ( type ComputeWorkspaceSpec struct { // APIServerRef is the reference to the StreamNativeCloudConnection // +required - APIServerRef corev1.LocalObjectReference `json:"apiServerRef"` + APIServerRef StreamNativeCloudConnectionRef `json:"apiServerRef"` // PulsarClusterNames is the list of Pulsar clusters that the workspace will have access to. // +optional diff --git a/api/v1alpha1/pulsarfunction_types.go b/api/v1alpha1/pulsarfunction_types.go index 964d4889..fc0e615f 100644 --- a/api/v1alpha1/pulsarfunction_types.go +++ b/api/v1alpha1/pulsarfunction_types.go @@ -15,7 +15,6 @@ package v1alpha1 import ( - corev1 "k8s.io/api/core/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -197,7 +196,7 @@ type PulsarFunctionSpec struct { SubscriptionPosition string `json:"subscriptionPosition,omitempty"` // ConnectionRef is the reference to the PulsarConnection resource - ConnectionRef corev1.LocalObjectReference `json:"connectionRef"` + ConnectionRef PulsarConnectionRef `json:"connectionRef"` // +kubebuilder:validation:Enum=CleanUpAfterDeletion;KeepAfterDeletion // +optional diff --git a/api/v1alpha1/pulsargeoreplication_types.go b/api/v1alpha1/pulsargeoreplication_types.go index 1a487c4e..b1bbf08e 100644 --- a/api/v1alpha1/pulsargeoreplication_types.go +++ b/api/v1alpha1/pulsargeoreplication_types.go @@ -15,7 +15,6 @@ package v1alpha1 import ( - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -28,10 +27,10 @@ type PulsarGeoReplicationSpec struct { // Important: Run "make" to regenerate code after modifying this file // ConnectionRef is the reference to the source PulsarConnection - ConnectionRef corev1.LocalObjectReference `json:"connectionRef"` + ConnectionRef PulsarConnectionRef `json:"connectionRef"` // DestinationConnectionRef is the connection reference to the remote cluster - DestinationConnectionRef corev1.LocalObjectReference `json:"destinationConnectionRef"` + DestinationConnectionRef PulsarConnectionRef `json:"destinationConnectionRef"` // +kubebuilder:validation:Enum=CleanUpAfterDeletion;KeepAfterDeletion // +optional @@ -87,5 +86,5 @@ type ClusterInfo struct { // Name is the pulsar cluster name Name string `json:"name,omitempty"` // ConnectionRef is the connection reference that can connect to the pulsar cluster - ConnectionRef corev1.LocalObjectReference `json:"connectionRef"` + ConnectionRef PulsarConnectionRef `json:"connectionRef"` } diff --git a/api/v1alpha1/pulsarnamespace_types.go b/api/v1alpha1/pulsarnamespace_types.go index 688146a2..84751011 100644 --- a/api/v1alpha1/pulsarnamespace_types.go +++ b/api/v1alpha1/pulsarnamespace_types.go @@ -42,7 +42,7 @@ type PulsarNamespaceSpec struct { // ConnectionRef is the reference to the PulsarConnection resource // used to connect to the Pulsar cluster for this namespace. - ConnectionRef corev1.LocalObjectReference `json:"connectionRef"` + ConnectionRef PulsarConnectionRef `json:"connectionRef"` // LifecyclePolicy determines whether to keep or delete the Pulsar namespace // when the Kubernetes resource is deleted. diff --git a/api/v1alpha1/pulsarnsisolationpolicy_types.go b/api/v1alpha1/pulsarnsisolationpolicy_types.go index c691cc07..52e64560 100644 --- a/api/v1alpha1/pulsarnsisolationpolicy_types.go +++ b/api/v1alpha1/pulsarnsisolationpolicy_types.go @@ -15,7 +15,6 @@ package v1alpha1 import ( - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -38,7 +37,7 @@ type PulsarNSIsolationPolicySpec struct { // ConnectionRef is the reference to the PulsarConnection resource // used to connect to the Pulsar cluster for this ns-isolation-policy. - ConnectionRef corev1.LocalObjectReference `json:"connectionRef"` + ConnectionRef PulsarConnectionRef `json:"connectionRef"` // Namespaces namespaces-regex list // +kubebuilder:validation:Required diff --git a/api/v1alpha1/pulsarpackage_types.go b/api/v1alpha1/pulsarpackage_types.go index 0898bd33..449064c0 100644 --- a/api/v1alpha1/pulsarpackage_types.go +++ b/api/v1alpha1/pulsarpackage_types.go @@ -15,7 +15,6 @@ package v1alpha1 import ( - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -37,7 +36,7 @@ type PulsarPackageSpec struct { FileURL string `json:"fileURL"` // ConnectionRef is the reference to the PulsarConnection resource - ConnectionRef corev1.LocalObjectReference `json:"connectionRef"` + ConnectionRef PulsarConnectionRef `json:"connectionRef"` // +optional Description string `json:"description,omitempty"` diff --git a/api/v1alpha1/pulsarpermission_types.go b/api/v1alpha1/pulsarpermission_types.go index 2fbc2255..5e9373b8 100644 --- a/api/v1alpha1/pulsarpermission_types.go +++ b/api/v1alpha1/pulsarpermission_types.go @@ -15,7 +15,6 @@ package v1alpha1 import ( - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -27,7 +26,7 @@ type PulsarPermissionSpec struct { // ConnectionRef is the reference to the PulsarConnection resource // used to connect to the Pulsar cluster for this permission. - ConnectionRef corev1.LocalObjectReference `json:"connectionRef"` + ConnectionRef PulsarConnectionRef `json:"connectionRef"` // ResourceName is the name of the target resource (namespace or topic) // to which the permissions will be granted. diff --git a/api/v1alpha1/pulsarsink_types.go b/api/v1alpha1/pulsarsink_types.go index 17db5fc4..c170dd62 100644 --- a/api/v1alpha1/pulsarsink_types.go +++ b/api/v1alpha1/pulsarsink_types.go @@ -15,7 +15,6 @@ package v1alpha1 import ( - corev1 "k8s.io/api/core/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -157,7 +156,7 @@ type PulsarSinkSpec struct { TransformFunctionConfig string `json:"transformFunctionConfig,omitempty"` // ConnectionRef is the reference to the PulsarConnection resource - ConnectionRef corev1.LocalObjectReference `json:"connectionRef"` + ConnectionRef PulsarConnectionRef `json:"connectionRef"` // +kubebuilder:validation:Enum=CleanUpAfterDeletion;KeepAfterDeletion // +optional diff --git a/api/v1alpha1/pulsarsource_types.go b/api/v1alpha1/pulsarsource_types.go index 99fc2da8..96571ae8 100644 --- a/api/v1alpha1/pulsarsource_types.go +++ b/api/v1alpha1/pulsarsource_types.go @@ -15,7 +15,6 @@ package v1alpha1 import ( - corev1 "k8s.io/api/core/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -101,7 +100,7 @@ type PulsarSourceSpec struct { BatchBuilder string `json:"batchBuilder,omitempty"` // ConnectionRef is the reference to the PulsarConnection resource - ConnectionRef corev1.LocalObjectReference `json:"connectionRef"` + ConnectionRef PulsarConnectionRef `json:"connectionRef"` // +kubebuilder:validation:Enum=CleanUpAfterDeletion;KeepAfterDeletion // +optional diff --git a/api/v1alpha1/pulsartenant_types.go b/api/v1alpha1/pulsartenant_types.go index 10df0f82..f1314ab0 100644 --- a/api/v1alpha1/pulsartenant_types.go +++ b/api/v1alpha1/pulsartenant_types.go @@ -36,7 +36,7 @@ type PulsarTenantSpec struct { // ConnectionRef is the reference to the PulsarConnection resource // used to connect to the Pulsar cluster for this tenant. - ConnectionRef corev1.LocalObjectReference `json:"connectionRef"` + ConnectionRef PulsarConnectionRef `json:"connectionRef"` // AdminRoles is a list of roles that have administrative privileges for this tenant. // These roles can perform actions like creating namespaces, topics, and managing permissions. diff --git a/api/v1alpha1/pulsartopic_types.go b/api/v1alpha1/pulsartopic_types.go index 6dce1c40..2d38fccd 100644 --- a/api/v1alpha1/pulsartopic_types.go +++ b/api/v1alpha1/pulsartopic_types.go @@ -15,7 +15,6 @@ package v1alpha1 import ( - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -50,7 +49,7 @@ type PulsarTopicSpec struct { // ConnectionRef is the reference to the PulsarConnection resource // used to connect to the Pulsar cluster for this topic. - ConnectionRef corev1.LocalObjectReference `json:"connectionRef"` + ConnectionRef PulsarConnectionRef `json:"connectionRef"` // LifecyclePolicy determines whether to keep or delete the Pulsar topic // when the Kubernetes resource is deleted. @@ -119,7 +118,7 @@ type PulsarTopicSpec struct { // This is **ONLY** used when you are using PulsarGeoReplication for setting up geo-replication // between two Pulsar instances. // +optional - GeoReplicationRefs []*corev1.LocalObjectReference `json:"geoReplicationRefs,omitempty"` + GeoReplicationRefs []*PulsarConnectionRef `json:"geoReplicationRefs,omitempty"` // ReplicationClusters is the list of clusters to which the topic is replicated // This is **ONLY** used if you are replicating clusters within the same Pulsar instance. diff --git a/api/v1alpha1/secret_types.go b/api/v1alpha1/secret_types.go index a8f9932c..35936cf9 100644 --- a/api/v1alpha1/secret_types.go +++ b/api/v1alpha1/secret_types.go @@ -27,7 +27,7 @@ import ( type SecretSpec struct { // APIServerRef is the reference to the StreamNativeCloudConnection // +required - APIServerRef corev1.LocalObjectReference `json:"apiServerRef"` + APIServerRef StreamNativeCloudConnectionRef `json:"apiServerRef"` // InstanceName is the name of the instance this secret is for (e.g. pulsar-instance) // +optional diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 55f4d4c3..9119e0ca 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -1008,6 +1008,21 @@ func (in *PulsarConnectionList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PulsarConnectionRef) DeepCopyInto(out *PulsarConnectionRef) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PulsarConnectionRef. +func (in *PulsarConnectionRef) DeepCopy() *PulsarConnectionRef { + if in == nil { + return nil + } + out := new(PulsarConnectionRef) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PulsarConnectionSpec) DeepCopyInto(out *PulsarConnectionSpec) { *out = *in @@ -2412,11 +2427,11 @@ func (in *PulsarTopicSpec) DeepCopyInto(out *PulsarTopicSpec) { } if in.GeoReplicationRefs != nil { in, out := &in.GeoReplicationRefs, &out.GeoReplicationRefs - *out = make([]*v1.LocalObjectReference, len(*in)) + *out = make([]*PulsarConnectionRef, len(*in)) for i := range *in { if (*in)[i] != nil { in, out := &(*in)[i], &(*out)[i] - *out = new(v1.LocalObjectReference) + *out = new(PulsarConnectionRef) **out = **in } } @@ -2750,6 +2765,21 @@ func (in *StreamNativeCloudConnectionList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StreamNativeCloudConnectionRef) DeepCopyInto(out *StreamNativeCloudConnectionRef) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StreamNativeCloudConnectionRef. +func (in *StreamNativeCloudConnectionRef) DeepCopy() *StreamNativeCloudConnectionRef { + if in == nil { + return nil + } + out := new(StreamNativeCloudConnectionRef) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StreamNativeCloudConnectionSpec) DeepCopyInto(out *StreamNativeCloudConnectionSpec) { *out = *in diff --git a/charts/pulsar-resources-operator/crds/resource.streamnative.io_computeflinkdeployments.yaml b/charts/pulsar-resources-operator/crds/resource.streamnative.io_computeflinkdeployments.yaml index 68a7f205..fc0178a5 100644 --- a/charts/pulsar-resources-operator/crds/resource.streamnative.io_computeflinkdeployments.yaml +++ b/charts/pulsar-resources-operator/crds/resource.streamnative.io_computeflinkdeployments.yaml @@ -75,18 +75,12 @@ spec: If not specified, the APIServerRef from the referenced ComputeWorkspace will be used. properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic communityTemplate: description: CommunityTemplate is the community deployment template properties: diff --git a/charts/pulsar-resources-operator/crds/resource.streamnative.io_computeworkspaces.yaml b/charts/pulsar-resources-operator/crds/resource.streamnative.io_computeworkspaces.yaml index ad752f83..b08e6405 100644 --- a/charts/pulsar-resources-operator/crds/resource.streamnative.io_computeworkspaces.yaml +++ b/charts/pulsar-resources-operator/crds/resource.streamnative.io_computeworkspaces.yaml @@ -67,18 +67,12 @@ spec: description: APIServerRef is the reference to the StreamNativeCloudConnection properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic flinkBlobStorage: description: FlinkBlobStorage is the configuration for the Flink blob storage. diff --git a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarfunctions.yaml b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarfunctions.yaml index b901e657..cc699869 100644 --- a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarfunctions.yaml +++ b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarfunctions.yaml @@ -90,18 +90,12 @@ spec: resource properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic customRuntimeOptions: description: CustomRuntimeOptions is the custom runtime options of the function diff --git a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsargeoreplications.yaml b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsargeoreplications.yaml index 9caa28a5..b4fa26fb 100644 --- a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsargeoreplications.yaml +++ b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsargeoreplications.yaml @@ -58,35 +58,23 @@ spec: description: ConnectionRef is the reference to the source PulsarConnection properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic destinationConnectionRef: description: DestinationConnectionRef is the connection reference to the remote cluster properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic lifecyclePolicy: description: |- PulsarResourceLifeCyclePolicy defines the behavior for managing Pulsar resources diff --git a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarnamespaces.yaml b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarnamespaces.yaml index 7fc2ea5f..79fe6bc7 100644 --- a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarnamespaces.yaml +++ b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarnamespaces.yaml @@ -126,18 +126,12 @@ spec: used to connect to the Pulsar cluster for this namespace. properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic deduplication: description: Deduplication controls whether to enable message deduplication for the namespace. diff --git a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarnsisolationpolicies.yaml b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarnsisolationpolicies.yaml index b7890946..679b4d6c 100644 --- a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarnsisolationpolicies.yaml +++ b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarnsisolationpolicies.yaml @@ -96,18 +96,12 @@ spec: used to connect to the Pulsar cluster for this ns-isolation-policy. properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic name: description: Name is the policy name type: string diff --git a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarpackages.yaml b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarpackages.yaml index faa69c52..d59b450d 100644 --- a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarpackages.yaml +++ b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarpackages.yaml @@ -77,18 +77,12 @@ spec: resource properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic contact: type: string description: diff --git a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarpermissions.yaml b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarpermissions.yaml index be8d325e..1aab16ba 100644 --- a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarpermissions.yaml +++ b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarpermissions.yaml @@ -97,18 +97,12 @@ spec: used to connect to the Pulsar cluster for this permission. properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic lifecyclePolicy: description: |- LifecyclePolicy determines how to handle the Pulsar permissions diff --git a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarsinks.yaml b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarsinks.yaml index 1aff58a4..9120d255 100644 --- a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarsinks.yaml +++ b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarsinks.yaml @@ -95,18 +95,12 @@ spec: resource properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic customRuntimeOptions: description: CustomRuntimeOptions is the custom runtime options of the PulsarSink diff --git a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarsources.yaml b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarsources.yaml index dcdf054d..34c6ee40 100644 --- a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarsources.yaml +++ b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsarsources.yaml @@ -99,18 +99,12 @@ spec: resource properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic customRuntimeOptions: description: CustomRuntimeOptions is the custom runtime options of the PulsarSource diff --git a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsartenants.yaml b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsartenants.yaml index b2c6bc71..c23bbb57 100644 --- a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsartenants.yaml +++ b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsartenants.yaml @@ -95,18 +95,12 @@ spec: used to connect to the Pulsar cluster for this tenant. properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic geoReplicationRefs: description: |- GeoReplicationRefs is a list of references to PulsarGeoReplication resources, diff --git a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsartopics.yaml b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsartopics.yaml index 9bc1ed9c..50215ada 100644 --- a/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsartopics.yaml +++ b/charts/pulsar-resources-operator/crds/resource.streamnative.io_pulsartopics.yaml @@ -104,18 +104,12 @@ spec: used to connect to the Pulsar cluster for this topic. properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic deduplication: description: Deduplication controls whether to enable message deduplication for the topic. @@ -127,23 +121,15 @@ spec: This is **ONLY** used when you are using PulsarGeoReplication for setting up geo-replication between two Pulsar instances. items: - description: |- - LocalObjectReference contains enough information to let you locate the - referenced object inside the same namespace. + description: PulsarConnectionRef indicates the connection reference properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic type: array lifecyclePolicy: description: |- diff --git a/charts/pulsar-resources-operator/crds/resource.streamnative.io_secrets.yaml b/charts/pulsar-resources-operator/crds/resource.streamnative.io_secrets.yaml index 570048d6..d3efd1b6 100644 --- a/charts/pulsar-resources-operator/crds/resource.streamnative.io_secrets.yaml +++ b/charts/pulsar-resources-operator/crds/resource.streamnative.io_secrets.yaml @@ -68,18 +68,12 @@ spec: description: APIServerRef is the reference to the StreamNativeCloudConnection properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic data: additionalProperties: type: string diff --git a/config/crd/bases/resource.streamnative.io_computeflinkdeployments.yaml b/config/crd/bases/resource.streamnative.io_computeflinkdeployments.yaml index 68a7f205..fc0178a5 100644 --- a/config/crd/bases/resource.streamnative.io_computeflinkdeployments.yaml +++ b/config/crd/bases/resource.streamnative.io_computeflinkdeployments.yaml @@ -75,18 +75,12 @@ spec: If not specified, the APIServerRef from the referenced ComputeWorkspace will be used. properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic communityTemplate: description: CommunityTemplate is the community deployment template properties: diff --git a/config/crd/bases/resource.streamnative.io_computeworkspaces.yaml b/config/crd/bases/resource.streamnative.io_computeworkspaces.yaml index ad752f83..b08e6405 100644 --- a/config/crd/bases/resource.streamnative.io_computeworkspaces.yaml +++ b/config/crd/bases/resource.streamnative.io_computeworkspaces.yaml @@ -67,18 +67,12 @@ spec: description: APIServerRef is the reference to the StreamNativeCloudConnection properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic flinkBlobStorage: description: FlinkBlobStorage is the configuration for the Flink blob storage. diff --git a/config/crd/bases/resource.streamnative.io_pulsarfunctions.yaml b/config/crd/bases/resource.streamnative.io_pulsarfunctions.yaml index b901e657..cc699869 100644 --- a/config/crd/bases/resource.streamnative.io_pulsarfunctions.yaml +++ b/config/crd/bases/resource.streamnative.io_pulsarfunctions.yaml @@ -90,18 +90,12 @@ spec: resource properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic customRuntimeOptions: description: CustomRuntimeOptions is the custom runtime options of the function diff --git a/config/crd/bases/resource.streamnative.io_pulsargeoreplications.yaml b/config/crd/bases/resource.streamnative.io_pulsargeoreplications.yaml index 9caa28a5..b4fa26fb 100644 --- a/config/crd/bases/resource.streamnative.io_pulsargeoreplications.yaml +++ b/config/crd/bases/resource.streamnative.io_pulsargeoreplications.yaml @@ -58,35 +58,23 @@ spec: description: ConnectionRef is the reference to the source PulsarConnection properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic destinationConnectionRef: description: DestinationConnectionRef is the connection reference to the remote cluster properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic lifecyclePolicy: description: |- PulsarResourceLifeCyclePolicy defines the behavior for managing Pulsar resources diff --git a/config/crd/bases/resource.streamnative.io_pulsarnamespaces.yaml b/config/crd/bases/resource.streamnative.io_pulsarnamespaces.yaml index 7fc2ea5f..79fe6bc7 100644 --- a/config/crd/bases/resource.streamnative.io_pulsarnamespaces.yaml +++ b/config/crd/bases/resource.streamnative.io_pulsarnamespaces.yaml @@ -126,18 +126,12 @@ spec: used to connect to the Pulsar cluster for this namespace. properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic deduplication: description: Deduplication controls whether to enable message deduplication for the namespace. diff --git a/config/crd/bases/resource.streamnative.io_pulsarnsisolationpolicies.yaml b/config/crd/bases/resource.streamnative.io_pulsarnsisolationpolicies.yaml index b7890946..679b4d6c 100644 --- a/config/crd/bases/resource.streamnative.io_pulsarnsisolationpolicies.yaml +++ b/config/crd/bases/resource.streamnative.io_pulsarnsisolationpolicies.yaml @@ -96,18 +96,12 @@ spec: used to connect to the Pulsar cluster for this ns-isolation-policy. properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic name: description: Name is the policy name type: string diff --git a/config/crd/bases/resource.streamnative.io_pulsarpackages.yaml b/config/crd/bases/resource.streamnative.io_pulsarpackages.yaml index faa69c52..d59b450d 100644 --- a/config/crd/bases/resource.streamnative.io_pulsarpackages.yaml +++ b/config/crd/bases/resource.streamnative.io_pulsarpackages.yaml @@ -77,18 +77,12 @@ spec: resource properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic contact: type: string description: diff --git a/config/crd/bases/resource.streamnative.io_pulsarpermissions.yaml b/config/crd/bases/resource.streamnative.io_pulsarpermissions.yaml index be8d325e..1aab16ba 100644 --- a/config/crd/bases/resource.streamnative.io_pulsarpermissions.yaml +++ b/config/crd/bases/resource.streamnative.io_pulsarpermissions.yaml @@ -97,18 +97,12 @@ spec: used to connect to the Pulsar cluster for this permission. properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic lifecyclePolicy: description: |- LifecyclePolicy determines how to handle the Pulsar permissions diff --git a/config/crd/bases/resource.streamnative.io_pulsarsinks.yaml b/config/crd/bases/resource.streamnative.io_pulsarsinks.yaml index 1aff58a4..9120d255 100644 --- a/config/crd/bases/resource.streamnative.io_pulsarsinks.yaml +++ b/config/crd/bases/resource.streamnative.io_pulsarsinks.yaml @@ -95,18 +95,12 @@ spec: resource properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic customRuntimeOptions: description: CustomRuntimeOptions is the custom runtime options of the PulsarSink diff --git a/config/crd/bases/resource.streamnative.io_pulsarsources.yaml b/config/crd/bases/resource.streamnative.io_pulsarsources.yaml index dcdf054d..34c6ee40 100644 --- a/config/crd/bases/resource.streamnative.io_pulsarsources.yaml +++ b/config/crd/bases/resource.streamnative.io_pulsarsources.yaml @@ -99,18 +99,12 @@ spec: resource properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic customRuntimeOptions: description: CustomRuntimeOptions is the custom runtime options of the PulsarSource diff --git a/config/crd/bases/resource.streamnative.io_pulsartenants.yaml b/config/crd/bases/resource.streamnative.io_pulsartenants.yaml index b2c6bc71..c23bbb57 100644 --- a/config/crd/bases/resource.streamnative.io_pulsartenants.yaml +++ b/config/crd/bases/resource.streamnative.io_pulsartenants.yaml @@ -95,18 +95,12 @@ spec: used to connect to the Pulsar cluster for this tenant. properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic geoReplicationRefs: description: |- GeoReplicationRefs is a list of references to PulsarGeoReplication resources, diff --git a/config/crd/bases/resource.streamnative.io_pulsartopics.yaml b/config/crd/bases/resource.streamnative.io_pulsartopics.yaml index 9bc1ed9c..50215ada 100644 --- a/config/crd/bases/resource.streamnative.io_pulsartopics.yaml +++ b/config/crd/bases/resource.streamnative.io_pulsartopics.yaml @@ -104,18 +104,12 @@ spec: used to connect to the Pulsar cluster for this topic. properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic deduplication: description: Deduplication controls whether to enable message deduplication for the topic. @@ -127,23 +121,15 @@ spec: This is **ONLY** used when you are using PulsarGeoReplication for setting up geo-replication between two Pulsar instances. items: - description: |- - LocalObjectReference contains enough information to let you locate the - referenced object inside the same namespace. + description: PulsarConnectionRef indicates the connection reference properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic type: array lifecyclePolicy: description: |- diff --git a/config/crd/bases/resource.streamnative.io_secrets.yaml b/config/crd/bases/resource.streamnative.io_secrets.yaml index 570048d6..d3efd1b6 100644 --- a/config/crd/bases/resource.streamnative.io_secrets.yaml +++ b/config/crd/bases/resource.streamnative.io_secrets.yaml @@ -68,18 +68,12 @@ spec: description: APIServerRef is the reference to the StreamNativeCloudConnection properties: name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - TODO: Add other useful fields. apiVersion, kind, uid? - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Drop `kubebuilder:default` when controller-gen doesn't need it https://github.com/kubernetes-sigs/kubebuilder/issues/3896. type: string + namespace: + type: string + required: + - name type: object - x-kubernetes-map-type: atomic data: additionalProperties: type: string diff --git a/controllers/connection_ref_mapper.go b/controllers/connection_ref_mapper.go index d3c78770..66cea183 100644 --- a/controllers/connection_ref_mapper.go +++ b/controllers/connection_ref_mapper.go @@ -17,7 +17,6 @@ package controllers import ( "context" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" @@ -35,10 +34,14 @@ func (p *PulsarConnectionRefMapper) Map(object client.Object) []reconcile.Reques if ref == nil { return nil } + namespace := object.GetNamespace() + if ref.Namespace != "" { + namespace = ref.Namespace + } return []reconcile.Request{ { NamespacedName: types.NamespacedName{ - Namespace: object.GetNamespace(), + Namespace: namespace, Name: ref.Name, }, }, @@ -53,17 +56,21 @@ func ConnectionRefMapper(ctx context.Context, object client.Object) []reconcile. if ref == nil { return nil } + namespace := object.GetNamespace() + if ref.Namespace != "" { + namespace = ref.Namespace + } return []reconcile.Request{ { NamespacedName: types.NamespacedName{ - Namespace: object.GetNamespace(), + Namespace: namespace, Name: ref.Name, }, }, } } -func getConnectionRef(object client.Object) *corev1.LocalObjectReference { +func getConnectionRef(object client.Object) *pulsarv1alpha1.PulsarConnectionRef { switch v := object.(type) { case *pulsarv1alpha1.PulsarTenant: return &v.Spec.ConnectionRef diff --git a/controllers/flinkdeployment_controller.go b/controllers/flinkdeployment_controller.go index 21079e12..1f98654e 100644 --- a/controllers/flinkdeployment_controller.go +++ b/controllers/flinkdeployment_controller.go @@ -186,10 +186,7 @@ func (r *FlinkDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Requ // Get the APIServerConnection apiConn := &resourcev1alpha1.StreamNativeCloudConnection{} - if err := r.Get(ctx, types.NamespacedName{ - Namespace: req.Namespace, - Name: apiServerRef.Name, - }, apiConn); err != nil { + if err := r.Get(ctx, apiServerRef.ToNamespacedName(req.Namespace), apiConn); err != nil { r.updateDeploymentStatus(ctx, deployment, err, "GetAPIServerConnectionFailed", fmt.Sprintf("Failed to get APIServerConnection: %v", err)) return ctrl.Result{}, err diff --git a/controllers/pulsarconnection_controller.go b/controllers/pulsarconnection_controller.go index 0ae51fb4..4ea0ac05 100644 --- a/controllers/pulsarconnection_controller.go +++ b/controllers/pulsarconnection_controller.go @@ -128,95 +128,84 @@ func (r *PulsarConnectionReconciler) Reconcile(ctx context.Context, req ctrl.Req func (r *PulsarConnectionReconciler) SetupWithManager(mgr ctrl.Manager, options controller.Options) error { if err := mgr.GetCache().IndexField(context.TODO(), &resourcev1alpha1.PulsarTenant{}, ".spec.connectionRef.name", func(object client.Object) []string { - return []string{ - object.(*resourcev1alpha1.PulsarTenant).Spec.ConnectionRef.Name, - } + ref := object.(*resourcev1alpha1.PulsarTenant) + return []string{ref.Spec.ConnectionRef.ToNamespacedName(ref.Namespace).String()} }); err != nil { return err } if err := mgr.GetCache().IndexField(context.TODO(), &resourcev1alpha1.PulsarNamespace{}, ".spec.connectionRef.name", func(object client.Object) []string { - return []string{ - object.(*resourcev1alpha1.PulsarNamespace).Spec.ConnectionRef.Name, - } + ref := object.(*resourcev1alpha1.PulsarNamespace) + return []string{ref.Spec.ConnectionRef.ToNamespacedName(ref.Namespace).String()} }); err != nil { return err } if err := mgr.GetCache().IndexField(context.TODO(), &resourcev1alpha1.PulsarTopic{}, ".spec.connectionRef.name", func(object client.Object) []string { - return []string{ - object.(*resourcev1alpha1.PulsarTopic).Spec.ConnectionRef.Name, - } + ref := object.(*resourcev1alpha1.PulsarTopic) + return []string{ref.Spec.ConnectionRef.ToNamespacedName(ref.Namespace).String()} }); err != nil { return err } if err := mgr.GetCache().IndexField(context.TODO(), &resourcev1alpha1.PulsarPermission{}, ".spec.connectionRef.name", func(object client.Object) []string { - return []string{ - object.(*resourcev1alpha1.PulsarPermission).Spec.ConnectionRef.Name, - } + ref := object.(*resourcev1alpha1.PulsarPermission) + return []string{ref.Spec.ConnectionRef.ToNamespacedName(ref.Namespace).String()} }); err != nil { return err } if err := mgr.GetCache().IndexField(context.TODO(), &resourcev1alpha1.PulsarGeoReplication{}, ".spec.connectionRef.name", func(object client.Object) []string { - return []string{ - object.(*resourcev1alpha1.PulsarGeoReplication).Spec.ConnectionRef.Name, - } + ref := object.(*resourcev1alpha1.PulsarGeoReplication) + return []string{ref.Spec.ConnectionRef.ToNamespacedName(ref.Namespace).String()} }); err != nil { return err } if err := mgr.GetCache().IndexField(context.TODO(), &resourcev1alpha1.PulsarGeoReplication{}, ".spec.destinationConnectionRef.name", func(object client.Object) []string { - return []string{ - object.(*resourcev1alpha1.PulsarGeoReplication).Spec.DestinationConnectionRef.Name, - } + ref := object.(*resourcev1alpha1.PulsarGeoReplication) + return []string{ref.Spec.DestinationConnectionRef.ToNamespacedName(ref.Namespace).String()} }); err != nil { return err } if err := mgr.GetCache().IndexField(context.TODO(), &resourcev1alpha1.PulsarPackage{}, ".spec.connectionRef.name", func(object client.Object) []string { - return []string{ - object.(*resourcev1alpha1.PulsarPackage).Spec.ConnectionRef.Name, - } + ref := object.(*resourcev1alpha1.PulsarPackage) + return []string{ref.Spec.ConnectionRef.ToNamespacedName(ref.Namespace).String()} }); err != nil { return err } if err := mgr.GetCache().IndexField(context.TODO(), &resourcev1alpha1.PulsarFunction{}, ".spec.connectionRef.name", func(object client.Object) []string { - return []string{ - object.(*resourcev1alpha1.PulsarFunction).Spec.ConnectionRef.Name, - } + ref := object.(*resourcev1alpha1.PulsarFunction) + return []string{ref.Spec.ConnectionRef.ToNamespacedName(ref.Namespace).String()} }); err != nil { return err } if err := mgr.GetCache().IndexField(context.TODO(), &resourcev1alpha1.PulsarSink{}, ".spec.connectionRef.name", func(object client.Object) []string { - return []string{ - object.(*resourcev1alpha1.PulsarSink).Spec.ConnectionRef.Name, - } + ref := object.(*resourcev1alpha1.PulsarSink) + return []string{ref.Spec.ConnectionRef.ToNamespacedName(ref.Namespace).String()} }); err != nil { return err } if err := mgr.GetCache().IndexField(context.TODO(), &resourcev1alpha1.PulsarSource{}, ".spec.connectionRef.name", func(object client.Object) []string { - return []string{ - object.(*resourcev1alpha1.PulsarSource).Spec.ConnectionRef.Name, - } + ref := object.(*resourcev1alpha1.PulsarSource) + return []string{ref.Spec.ConnectionRef.ToNamespacedName(ref.Namespace).String()} }); err != nil { return err } if err := mgr.GetCache().IndexField(context.TODO(), &resourcev1alpha1.PulsarNSIsolationPolicy{}, ".spec.connectionRef.name", func(object client.Object) []string { - return []string{ - object.(*resourcev1alpha1.PulsarNSIsolationPolicy).Spec.ConnectionRef.Name, - } + ref := object.(*resourcev1alpha1.PulsarNSIsolationPolicy) + return []string{ref.Spec.ConnectionRef.ToNamespacedName(ref.Namespace).String()} }); err != nil { return err } diff --git a/controllers/secret_controller.go b/controllers/secret_controller.go index 908e4335..8835e678 100644 --- a/controllers/secret_controller.go +++ b/controllers/secret_controller.go @@ -180,10 +180,7 @@ func (r *SecretReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr // Get the APIServerConnection connection := &resourcev1alpha1.StreamNativeCloudConnection{} - if err := r.Get(ctx, types.NamespacedName{ - Namespace: req.Namespace, - Name: secret.Spec.APIServerRef.Name, - }, connection); err != nil { + if err := r.Get(ctx, secret.Spec.APIServerRef.ToNamespacedName(req.Namespace), connection); err != nil { r.updateSecretStatus(ctx, secret, err, "ConnectionNotFound", fmt.Sprintf("Failed to get APIServerConnection: %v", err)) return ctrl.Result{}, err diff --git a/controllers/workspace_controller.go b/controllers/workspace_controller.go index 4a3d9b67..86d8aeeb 100644 --- a/controllers/workspace_controller.go +++ b/controllers/workspace_controller.go @@ -152,10 +152,7 @@ func (r *WorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( // Get the APIServerConnection connection := &resourcev1alpha1.StreamNativeCloudConnection{} - if err := r.Get(ctx, types.NamespacedName{ - Namespace: req.Namespace, - Name: workspace.Spec.APIServerRef.Name, - }, connection); err != nil { + if err := r.Get(ctx, workspace.Spec.APIServerRef.ToNamespacedName(req.Namespace), connection); err != nil { r.updateWorkspaceStatus(ctx, workspace, err, "ConnectionNotFound", fmt.Sprintf("Failed to get APIServerConnection: %v", err)) return ctrl.Result{}, err diff --git a/pkg/connection/reconcile_geo_replication.go b/pkg/connection/reconcile_geo_replication.go index ca8192e6..d439ccd6 100644 --- a/pkg/connection/reconcile_geo_replication.go +++ b/pkg/connection/reconcile_geo_replication.go @@ -84,14 +84,11 @@ func (r *PulsarGeoReplicationReconciler) Reconcile(ctx context.Context) error { r.log.V(1).Info("Reconcile Geo") geoReplication := &r.conn.geoReplications[i] pulsarAdmin := r.conn.pulsarAdmin - if geoReplication.Spec.ConnectionRef.Name != r.conn.connection.Name { + geoReplicationNamespacedName := geoReplication.Spec.ConnectionRef.ToNamespacedName(geoReplication.Namespace) + if geoReplicationNamespacedName.Name != r.conn.connection.Name || geoReplicationNamespacedName.Namespace != r.conn.connection.Namespace { // If the connectionRef is the remote connection, we need to create a new pulsarAdmin for it localConnection := &resourcev1alpha1.PulsarConnection{} - namespacedName := types.NamespacedName{ - Name: geoReplication.Spec.ConnectionRef.Name, - Namespace: geoReplication.Namespace, - } - if err := r.conn.client.Get(ctx, namespacedName, localConnection); err != nil { + if err := r.conn.client.Get(ctx, geoReplicationNamespacedName, localConnection); err != nil { return fmt.Errorf("get local pulsarConnection [%w]", err) } cfg, err := MakePulsarAdminConfig(ctx, localConnection, r.conn.client) @@ -121,10 +118,7 @@ func (r *PulsarGeoReplicationReconciler) ReconcileGeoReplication(ctx context.Con log.Info("Start Reconcile") destConnection := &resourcev1alpha1.PulsarConnection{} - namespacedName := types.NamespacedName{ - Name: geoReplication.Spec.DestinationConnectionRef.Name, - Namespace: geoReplication.Namespace, - } + namespacedName := geoReplication.Spec.DestinationConnectionRef.ToNamespacedName(geoReplication.Namespace) if err := r.conn.client.Get(ctx, namespacedName, destConnection); err != nil { log.Error(err, "Failed to get destination connection for geo replication") return err diff --git a/pkg/connection/reconcile_namespace.go b/pkg/connection/reconcile_namespace.go index 705f549e..8a3d04a8 100644 --- a/pkg/connection/reconcile_namespace.go +++ b/pkg/connection/reconcile_namespace.go @@ -182,10 +182,7 @@ func (r *PulsarNamespaceReconciler) ReconcileNamespace(ctx context.Context, puls } log.V(1).Info("Found geo replication", "GEO Replication", geoReplication.Name) destConnection := &resourcev1alpha1.PulsarConnection{} - namespacedName = types.NamespacedName{ - Name: geoReplication.Spec.DestinationConnectionRef.Name, - Namespace: geoReplication.Namespace, - } + namespacedName = geoReplication.Spec.DestinationConnectionRef.ToNamespacedName(geoReplication.Namespace) if err := r.conn.client.Get(ctx, namespacedName, destConnection); err != nil { log.Error(err, "Failed to get destination connection for geo replication") return err diff --git a/pkg/connection/reconcile_tenant.go b/pkg/connection/reconcile_tenant.go index c866b623..c88f6084 100644 --- a/pkg/connection/reconcile_tenant.go +++ b/pkg/connection/reconcile_tenant.go @@ -147,10 +147,7 @@ func (r *PulsarTenantReconciler) ReconcileTenant(ctx context.Context, pulsarAdmi log.V(1).Info("Found geo replication", "GEO Replication", geoReplication.Name) destConnection := &resourcev1alpha1.PulsarConnection{} - namespacedName = types.NamespacedName{ - Name: geoReplication.Spec.DestinationConnectionRef.Name, - Namespace: geoReplication.Namespace, - } + namespacedName = geoReplication.Spec.DestinationConnectionRef.ToNamespacedName(geoReplication.Namespace) if err := r.conn.client.Get(ctx, namespacedName, destConnection); err != nil { log.Error(err, "Failed to get destination connection for geo replication") return err diff --git a/pkg/connection/reconcile_topic.go b/pkg/connection/reconcile_topic.go index 723dedd0..bb335f96 100644 --- a/pkg/connection/reconcile_topic.go +++ b/pkg/connection/reconcile_topic.go @@ -23,7 +23,6 @@ import ( "github.com/apache/pulsar-client-go/pulsaradmin/pkg/utils" "github.com/go-logr/logr" "github.com/streamnative/pulsar-resources-operator/pkg/feature" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -306,7 +305,7 @@ func (r *PulsarTopicReconciler) applyDefault(params *admin.TopicParams) { } func (r *PulsarTopicReconciler) applyGeo(ctx context.Context, params *admin.TopicParams, - ref *corev1.LocalObjectReference, topic *resourcev1alpha1.PulsarTopic) error { + ref *resourcev1alpha1.PulsarConnectionRef, topic *resourcev1alpha1.PulsarTopic) error { geoReplication := &resourcev1alpha1.PulsarGeoReplication{} if err := r.conn.client.Get(ctx, types.NamespacedName{ Namespace: topic.Namespace, @@ -316,10 +315,8 @@ func (r *PulsarTopicReconciler) applyGeo(ctx context.Context, params *admin.Topi } r.log.V(1).Info("Found geo replication", "GEO Replication", geoReplication.Name) destConnection := &resourcev1alpha1.PulsarConnection{} - if err := r.conn.client.Get(ctx, types.NamespacedName{ - Name: geoReplication.Spec.DestinationConnectionRef.Name, - Namespace: geoReplication.Namespace, - }, destConnection); err != nil { + namespacedName := geoReplication.Spec.DestinationConnectionRef.ToNamespacedName(geoReplication.Namespace) + if err := r.conn.client.Get(ctx, namespacedName, destConnection); err != nil { return err } diff --git a/tests/operator/resources_test.go b/tests/operator/resources_test.go index d6a971dc..45ced85a 100644 --- a/tests/operator/resources_test.go +++ b/tests/operator/resources_test.go @@ -23,7 +23,6 @@ import ( "github.com/onsi/gomega/format" "github.com/streamnative/pulsar-resources-operator/pkg/feature" v1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -69,7 +68,7 @@ var _ = Describe("Resources", func() { Spec: v1alphav1.PulsarTopicSpec{ Name: "persistent://cloud/stage/partitioned-topic", Partitions: pointer.Int32(1), - ConnectionRef: corev1.LocalObjectReference{ + ConnectionRef: v1alphav1.PulsarConnectionRef{ Name: pconnName, }, }, diff --git a/tests/utils/spec.go b/tests/utils/spec.go index e3746046..9e92d93e 100644 --- a/tests/utils/spec.go +++ b/tests/utils/spec.go @@ -17,7 +17,6 @@ package utils import ( "encoding/json" - corev1 "k8s.io/api/core/v1" v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -49,7 +48,7 @@ func MakePulsarTenant(namespace, name, tenantName, connectionName string, adminR }, Spec: v1alpha1.PulsarTenantSpec{ Name: tenantName, - ConnectionRef: corev1.LocalObjectReference{ + ConnectionRef: v1alpha1.PulsarConnectionRef{ Name: connectionName, }, AdminRoles: adminRoles, @@ -73,7 +72,7 @@ func MakePulsarNamespace(namespace, name, namespaceName, connectionName string, }, Spec: v1alpha1.PulsarNamespaceSpec{ Name: namespaceName, - ConnectionRef: corev1.LocalObjectReference{ + ConnectionRef: v1alpha1.PulsarConnectionRef{ Name: connectionName, }, BacklogQuotaLimitTime: limitTime, @@ -92,7 +91,7 @@ func MakePulsarTopic(namespace, name, topicName, connectionName string, policy v Name: name, }, Spec: v1alpha1.PulsarTopicSpec{ - ConnectionRef: corev1.LocalObjectReference{ + ConnectionRef: v1alpha1.PulsarConnectionRef{ Name: connectionName, }, Name: topicName, @@ -109,7 +108,7 @@ func MakePulsarPermission(namespace, name, resourceName, connectionName string, Name: name, }, Spec: v1alpha1.PulsarPermissionSpec{ - ConnectionRef: corev1.LocalObjectReference{ + ConnectionRef: v1alpha1.PulsarConnectionRef{ Name: connectionName, }, ResourceName: resourceName, @@ -128,7 +127,7 @@ func MakePulsarPackage(namespace, name, packageURL, connectionName string, polic Name: name, }, Spec: v1alpha1.PulsarPackageSpec{ - ConnectionRef: corev1.LocalObjectReference{ + ConnectionRef: v1alpha1.PulsarConnectionRef{ Name: connectionName, }, PackageURL: packageURL, @@ -147,7 +146,7 @@ func MakePulsarFunction(namespace, name, functionPackageUrl, connectionName stri Name: name, }, Spec: v1alpha1.PulsarFunctionSpec{ - ConnectionRef: corev1.LocalObjectReference{ + ConnectionRef: v1alpha1.PulsarConnectionRef{ Name: connectionName, }, LifecyclePolicy: policy, @@ -193,7 +192,7 @@ func MakePulsarSink(namespace, name, sinkPackageUrl, connectionName string, poli Name: name, }, Spec: v1alpha1.PulsarSinkSpec{ - ConnectionRef: corev1.LocalObjectReference{ + ConnectionRef: v1alpha1.PulsarConnectionRef{ Name: connectionName, }, LifecyclePolicy: policy, @@ -254,7 +253,7 @@ func MakePulsarSource(namespace, name, sourcePackageUrl, connectionName string, Name: name, }, Spec: v1alpha1.PulsarSourceSpec{ - ConnectionRef: corev1.LocalObjectReference{ + ConnectionRef: v1alpha1.PulsarConnectionRef{ Name: connectionName, }, LifecyclePolicy: policy, @@ -294,7 +293,7 @@ func MakeNSIsolationPolicy(namespace, name, clusterName, connectionName string, Name: name, }, Spec: v1alpha1.PulsarNSIsolationPolicySpec{ - ConnectionRef: corev1.LocalObjectReference{ + ConnectionRef: v1alpha1.PulsarConnectionRef{ Name: connectionName, }, Name: name,