Skip to content
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

issue-439, Support batch of users for OpenSearch cluster CRD #471

Merged
merged 1 commit into from
Jul 17, 2023
Merged
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
7 changes: 5 additions & 2 deletions apis/clusterresources/v1beta1/opensearchuser_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ type OpenSearchUserSpec struct {

// OpenSearchUserStatus defines the observed state of OpenSearchUser
type OpenSearchUserStatus struct {
State string `json:"state"`
ClusterID string `json:"clusterId"`
ClustersEvents map[string]string `json:"clustersEvents,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down Expand Up @@ -70,6 +69,10 @@ func (u *OpenSearchUser) NewPatch() client.Patch {
return client.MergeFrom(old)
}

func (u *OpenSearchUser) GetDeletionFinalizer() string {
return models.DeletionFinalizer + "_" + u.Namespace + "_" + u.Name
}

func init() {
SchemeBuilder.Register(&OpenSearchUser{}, &OpenSearchUserList{})
}
9 changes: 8 additions & 1 deletion apis/clusterresources/v1beta1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion apis/clusters/v1beta1/opensearch_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type OpenSearchSpec struct {
IndexManagementPlugin bool `json:"indexManagementPlugin,omitempty"`
AlertingPlugin bool `json:"alertingPlugin,omitempty"`
BundledUseOnly bool `json:"bundleUseOnly,omitempty"`
UserRef *UserReference `json:"userRef,omitempty"`
UserRefs []*UserReference `json:"userRefs,omitempty"`
}

type OpenSearchDataCentre struct {
Expand Down
14 changes: 10 additions & 4 deletions apis/clusters/v1beta1/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 @@ -51,13 +51,10 @@ spec:
status:
description: OpenSearchUserStatus defines the observed state of OpenSearchUser
properties:
clusterId:
type: string
state:
type: string
required:
- clusterId
- state
clustersEvents:
additionalProperties:
type: string
type: object
type: object
type: object
served: true
Expand Down
22 changes: 12 additions & 10 deletions config/crd/bases/clusters.instaclustr.com_opensearches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,18 @@ spec:
- email
type: object
type: array
userRef:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
userRefs:
items:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: array
version:
type: string
required:
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/clusters.instaclustr.com_redis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ spec:
- email
type: object
type: array
userRef:
userRefs:
items:
properties:
name:
Expand Down
19 changes: 18 additions & 1 deletion config/samples/clusterresources_v1beta1_opensearchuser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,21 @@ metadata:
spec:
secretRef:
name: "test-secret-1"
namespace: "default"
namespace: "default"
---
apiVersion: v1
kind: Secret
metadata:
name: test-secret-2
data:
username: dGVzdC11c2VyLTIK # test-user-2
password: VGVzdFBhc3MxMjMhCg== # TestPass123!
---
apiVersion: clusterresources.instaclustr.com/v1beta1
kind: OpenSearchUser
metadata:
name: test-user-2
spec:
secretRef:
name: "test-secret-2"
namespace: "default"
10 changes: 6 additions & 4 deletions config/samples/clusters_v1beta1_opensearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ spec:
alertingPlugin: false
anomalyDetectionPlugin: false
asynchronousSearchPlugin: false
# userRef:
# name: "test-user-1"
# namespace: "default"
# userRefs:
# - name: "test-user-1"
# namespace: "default"
# - name: "test-user-2"
# namespace: "default"
clusterManagerNodes:
- dedicatedManager: false
nodeSize: SRH-DEV-t4g.small-5
Expand All @@ -34,7 +36,7 @@ spec:
indexManagementPlugin: true
knnPlugin: false
loadBalancer: false
name: bohdan-test
name: OpenSearch-example
notificationsPlugin: false
# opensearchDashboards:
# - nodeSize: SRH-DEV-t4g.small-5
Expand Down
4 changes: 4 additions & 0 deletions controllers/clusterresources/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ func getUserCreds(secret *k8sCore.Secret) (username, password string, err error)

return username[:len(username)-1], password[:len(password)-1], nil
}

func getDeletionUserFinalizer(clusterID string) string {
return models.DeletionUserFinalizer + clusterID
}
Loading