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-698, Save default user ref for kafkaconnect #712

Merged
merged 1 commit into from
Feb 16, 2024
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
28 changes: 14 additions & 14 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -233,84 +233,84 @@
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "46fe9b29395041087f91b33bd8c5c6177cd42fd1",
"is_verified": false,
"line_number": 246
"line_number": 247
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "4b3af1508421e2fa591c5b260c36dd06fdd872a5",
"is_verified": false,
"line_number": 284
"line_number": 285
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "cf45830dd81b7e1a8b5ffbc2d95b112771524117",
"is_verified": false,
"line_number": 294
"line_number": 295
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "138905ac46675150bf790088ec56b2efc6a64697",
"is_verified": false,
"line_number": 305
"line_number": 306
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "3948059919ffeee8ecc42149cb386f43d2f06f74",
"is_verified": false,
"line_number": 310
"line_number": 311
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "87f1180476a944c4162d1af55efedc8f3e3b609c",
"is_verified": false,
"line_number": 519
"line_number": 520
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "f0f06c9167ce61a586749bb183ac6a3756dd6010",
"is_verified": false,
"line_number": 529
"line_number": 530
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "2042128e13ef5ede4af44271160c72f64564c632",
"is_verified": false,
"line_number": 540
"line_number": 541
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "82dc9ca8ba09262ce948227aeb5d9db8084eeb5d",
"is_verified": false,
"line_number": 545
"line_number": 546
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "5f915325aef923cdc945f639f14c2f854b4214d6",
"is_verified": false,
"line_number": 569
"line_number": 570
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "5ffe533b830f08a0326348a9160afafc8ada44db",
"is_verified": false,
"line_number": 602
"line_number": 603
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/kafkaconnect_types.go",
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
"is_verified": false,
"line_number": 607
"line_number": 608
}
],
"apis/clusters/v1beta1/postgresql_types.go": [
Expand Down Expand Up @@ -390,7 +390,7 @@
"filename": "apis/clusters/v1beta1/zz_generated.deepcopy.go",
"hashed_secret": "44e17306b837162269a410204daaa5ecee4ec22c",
"is_verified": false,
"line_number": 2290
"line_number": 1322
}
],
"apis/kafkamanagement/v1beta1/kafkauser_types.go": [
Expand Down Expand Up @@ -1130,5 +1130,5 @@
}
]
},
"generated_at": "2024-02-15T12:14:33Z"
"generated_at": "2024-02-16T12:41:16Z"
}
3 changes: 2 additions & 1 deletion apis/clusters/v1beta1/kafkaconnect_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ type KafkaConnectSpec struct {
// KafkaConnectStatus defines the observed state of KafkaConnect
type KafkaConnectStatus struct {
ClusterStatus `json:",inline"`
TargetKafkaClusterID string `json:"targetKafkaClusterId,omitempty"`
TargetKafkaClusterID string `json:"targetKafkaClusterId,omitempty"`
DefaultUserSecretRef *Reference `json:"defaultUserSecretRef,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
5 changes: 5 additions & 0 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.

11 changes: 11 additions & 0 deletions config/crd/bases/clusters.instaclustr.com_kafkaconnects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,17 @@ spec:
type: string
type: object
type: array
defaultUserSecretRef:
description: ObjectReference is namespaced reference to an object
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
id:
type: string
maintenanceEvents:
Expand Down
19 changes: 19 additions & 0 deletions controllers/clusters/kafkaconnect_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ func (r *KafkaConnectReconciler) createDefaultSecret(ctx context.Context, kc *v1
return err
}

patch := kc.NewPatch()
secret := kc.NewDefaultUserSecret(username, password)
err = r.Create(ctx, secret)
if err != nil {
Expand All @@ -455,6 +456,24 @@ func (r *KafkaConnectReconciler) createDefaultSecret(ctx context.Context, kc *v1
"secret namespace", secret.Namespace,
)

kc.Status.DefaultUserSecretRef = &v1beta1.Reference{
Name: secret.Name,
Namespace: secret.Namespace,
}

err = r.Status().Patch(ctx, kc, patch)
if err != nil {
l.Error(err, "Cannot patch Kafka Connect resource",
"cluster name", kc.Spec.Name,
"status", kc.Status)

r.EventRecorder.Eventf(
kc, models.Warning, models.PatchFailed,
"Cluster resource patch is failed. Reason: %v", err)

return err
}

return nil
}

Expand Down
Loading