Skip to content

Commit

Permalink
support manage sn cloud secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
freeznet committed Feb 26, 2025
1 parent 878704d commit ae52064
Show file tree
Hide file tree
Showing 24 changed files with 1,024 additions and 108 deletions.
69 changes: 42 additions & 27 deletions api/v1alpha1/secret_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,40 @@ import (
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// SecretSpec defines the desired state of Workspace
// SecretSpec defines the desired state of StreamNative Cloud Secret
type SecretSpec struct {
// APIServerRef is the reference to the StreamNativeCloudConnection
// +required
APIServerRef corev1.LocalObjectReference `json:"apiServerRef"`

// InstanceName is the name of the instance this secret is for (e.g. pulsar-instance)
// +optional
InstanceName string `json:"instanceName"`

// Location is the location of the secret.
// +optional
Location string `json:"location"`

// the value should be base64 encoded
// +optional
Data map[string]string `json:"data,omitempty"`

// SecretRef is the reference to the kubernetes secret
// When SecretRef is set, it will be used to fetch the secret data.
// Data will be ignored.
// +optional
SecretRef *KubernetesSecretReference `json:"secretRef,omitempty"`

// PoolMemberName is the pool member to deploy the secret.
// +optional
PoolMemberName *string `json:"poolMemberName,omitempty"`

// +optional
// +listType=atomic
Tolerations []Toleration `json:"tolerations,omitempty"`
}

// SecretStatus defines the observed state of Workspace
// SecretStatus defines the observed state of StreamNative Cloud Secret
type SecretStatus struct {
// Conditions represent the latest available observations of an object's state
// +optional
Expand All @@ -40,10 +66,6 @@ type SecretStatus struct {
// ObservedGeneration is the last observed generation.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// WorkspaceID is the ID of the workspace in the API server
// +optional
WorkspaceID string `json:"workspaceId,omitempty"`
}

//+kubebuilder:object:root=true
Expand All @@ -52,33 +74,13 @@ type SecretStatus struct {
//+kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
//+kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status"

// Secret is the Schema for the workspaces API
// Secret is the Schema for the StreamNative Cloud Secret API
type Secret struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec SecretSpec `json:"spec,omitempty"`
Status SecretStatus `json:"status,omitempty"`

// InstanceName is the name of the instance this secret is for (e.g. pulsar-instance)
// +optional
InstanceName string `json:"instanceName"`

// Location is the location of the secret.
// +optional
Location string `json:"location"`

// the value should be base64 encoded
Data map[string]string `json:"data,omitempty"`

// PoolMemberRef is the pool member to deploy the secret.
// admission controller will infer this information automatically
// +optional
PoolMemberRef *PoolMemberReference `json:"poolMemberRef,omitempty"`

// +optional
// +listType=atomic
Tolerations []Toleration `json:"tolerations,omitempty"`
}

// PoolMemberReference is a reference to a pool member with a given name.
Expand All @@ -94,6 +96,19 @@ func (r PoolMemberReference) ToNamespacedName() types.NamespacedName {
}
}

// KubernetesSecretReference is a reference to a Kubernetes Secret with a given name.
type KubernetesSecretReference struct {
Namespace string `json:"namespace" protobuf:"bytes,1,opt,name=namespace"`
Name string `json:"name" protobuf:"bytes,2,opt,name=name"`
}

func (r KubernetesSecretReference) ToNamespacedName() types.NamespacedName {
return types.NamespacedName{
Namespace: r.Namespace,
Name: r.Name,
}
}

// The workload this Toleration is attached to tolerates any taint that matches

Check failure on line 112 in api/v1alpha1/secret_types.go

View workflow job for this annotation

GitHub Actions / lint

ST1021: comment on exported type Toleration should be of the form "Toleration ..." (with optional leading article) (stylecheck)
// the triple <key,value,effect> using the matching operator <operator>.
type Toleration struct {
Expand Down
70 changes: 52 additions & 18 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
@@ -1,3 +1,17 @@
# Copyright 2025 StreamNative
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
14 changes: 14 additions & 0 deletions config/crd/bases/resource.streamnative.io_computeworkspaces.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2025 StreamNative
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
14 changes: 14 additions & 0 deletions config/crd/bases/resource.streamnative.io_pulsarconnections.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2025 StreamNative
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
14 changes: 14 additions & 0 deletions config/crd/bases/resource.streamnative.io_pulsarfunctions.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2025 StreamNative
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2025 StreamNative
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
14 changes: 14 additions & 0 deletions config/crd/bases/resource.streamnative.io_pulsarnamespaces.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2025 StreamNative
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2025 StreamNative
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
14 changes: 14 additions & 0 deletions config/crd/bases/resource.streamnative.io_pulsarpackages.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2025 StreamNative
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
14 changes: 14 additions & 0 deletions config/crd/bases/resource.streamnative.io_pulsarpermissions.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2025 StreamNative
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
14 changes: 14 additions & 0 deletions config/crd/bases/resource.streamnative.io_pulsarsinks.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2025 StreamNative
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
Loading

0 comments on commit ae52064

Please sign in to comment.