Skip to content

[hold] make connection ref with namespce #294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions api/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
}
}
2 changes: 1 addition & 1 deletion api/v1alpha1/computeflinkdeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions api/v1alpha1/computeworkspace_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions api/v1alpha1/pulsarfunction_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions api/v1alpha1/pulsargeoreplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -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
Expand Down Expand Up @@ -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"`
}
2 changes: 1 addition & 1 deletion api/v1alpha1/pulsarnamespace_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions api/v1alpha1/pulsarnsisolationpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions api/v1alpha1/pulsarpackage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -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"`
Expand Down
3 changes: 1 addition & 2 deletions api/v1alpha1/pulsarpermission_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions api/v1alpha1/pulsarsink_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions api/v1alpha1/pulsarsource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/pulsartenant_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions api/v1alpha1/pulsartopic_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/secret_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 32 additions & 2 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading