Skip to content

Commit

Permalink
Stop relying on GVK being set on SCP object
Browse files Browse the repository at this point in the history
  • Loading branch information
thbkrkr committed Jan 29, 2024
1 parent 5a1c4a8 commit 2504e27
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pkg/controller/elasticsearch/filesettings/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func SetSoftOwner(settingsSecret *corev1.Secret, policy policyv1alpha1.StackConf
}
settingsSecret.Labels[reconciler.SoftOwnerNamespaceLabel] = policy.GetNamespace()
settingsSecret.Labels[reconciler.SoftOwnerNameLabel] = policy.GetName()
settingsSecret.Labels[reconciler.SoftOwnerKindLabel] = policy.GetObjectKind().GroupVersionKind().Kind
settingsSecret.Labels[reconciler.SoftOwnerKindLabel] = policyv1alpha1.Kind
}

// setSecureSettings stores the SecureSettings Secret sources referenced in the given StackConfigPolicy in the annotation of the Settings Secret.
Expand Down Expand Up @@ -163,7 +163,7 @@ func CanBeOwnedBy(settingsSecret corev1.Secret, policy policyv1alpha1.StackConfi
return reconciler.SoftOwnerRef{}, true
}
// or the owner is already the given policy
canBeOwned := currentOwner.Kind == policy.Kind && currentOwner.Namespace == policy.Namespace && currentOwner.Name == policy.Name
canBeOwned := currentOwner.Kind == policyv1alpha1.Kind && currentOwner.Namespace == policy.Namespace && currentOwner.Name == policy.Name
return currentOwner, canBeOwned
}

Expand Down
3 changes: 0 additions & 3 deletions pkg/controller/stackconfigpolicy/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ func TestReconcileStackConfigPolicy_Reconcile(t *testing.T) {
Name: "test-policy",
}
policyFixture := policyv1alpha1.StackConfigPolicy{
TypeMeta: metav1.TypeMeta{
Kind: "StackConfigPolicy",
},
ObjectMeta: metav1.ObjectMeta{
Namespace: "ns",
Name: "test-policy",
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/stackconfigpolicy/kibana_config_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func canBeOwned(ctx context.Context, c k8s.Client, policy policyv1alpha1.StackCo
return currentOwner, true, nil
}
// or the owner is already the given policy
canBeOwned := currentOwner.Kind == policy.Kind && currentOwner.Namespace == policy.Namespace && currentOwner.Name == policy.Name
canBeOwned := currentOwner.Kind == policyv1alpha1.Kind && currentOwner.Namespace == policy.Namespace && currentOwner.Name == policy.Name
return currentOwner, canBeOwned, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func Test_newKibanaConfigSecret(t *testing.T) {
"asset.policy.k8s.elastic.co/on-delete": "delete",
"kibana.k8s.elastic.co/name": "test-kb",
"common.k8s.elastic.co/type": "kibana",
"eck.k8s.elastic.co/owner-kind": "",
"eck.k8s.elastic.co/owner-kind": "StackConfigPolicy",
"eck.k8s.elastic.co/owner-name": "test-policy",
"eck.k8s.elastic.co/owner-namespace": "test-policy-ns",
},
Expand Down

0 comments on commit 2504e27

Please sign in to comment.