Skip to content

Commit

Permalink
use managed-by k8s annotation
Browse files Browse the repository at this point in the history
Signed-off-by: odubajDT <[email protected]>
  • Loading branch information
odubajDT committed Jan 22, 2024
1 parent 75974ab commit 76125b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
9 changes: 3 additions & 6 deletions common/flagdproxy/flagdproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"reflect"

"github.com/go-logr/logr"
"github.com/open-feature/open-feature-operator/common"
"github.com/open-feature/open-feature-operator/common/types"
appsV1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand All @@ -22,7 +21,6 @@ const (
FlagdProxyServiceAccountName = "open-feature-operator-flagd-proxy"
FlagdProxyServiceName = "flagd-proxy-svc"
operatorDeploymentName = "open-feature-operator-controller-manager"
ofoDeployed = "deployed"
)

type FlagdProxyHandler struct {
Expand Down Expand Up @@ -120,7 +118,7 @@ func (f *FlagdProxyHandler) newFlagdProxyServiceManifest(ownerReference *metav1.
Namespace: f.config.Namespace,
OwnerReferences: []metav1.OwnerReference{*ownerReference},
Labels: map[string]string{
fmt.Sprintf("%s/%s", common.OpenFeatureAnnotationPrefix, ofoDeployed): "true",
"app.kubernetes.io/managed-by": ManagedByAnnotationValue,
},
},
Spec: corev1.ServiceSpec{
Expand Down Expand Up @@ -157,7 +155,6 @@ func (f *FlagdProxyHandler) newFlagdProxyManifest(ownerReference *metav1.OwnerRe
"app": FlagdProxyDeploymentName,
"app.kubernetes.io/managed-by": ManagedByAnnotationValue,
"app.kubernetes.io/version": f.config.Tag,
fmt.Sprintf("%s/%s", common.OpenFeatureAnnotationPrefix, ofoDeployed): "true",
},
OwnerReferences: []metav1.OwnerReference{*ownerReference},
},
Expand Down Expand Up @@ -245,6 +242,6 @@ func (f *FlagdProxyHandler) getOwnerReference(ctx context.Context) (*metav1.Owne
}

func isDeployedByOFO(d *appsV1.Deployment) bool {
val, ok := d.Labels[fmt.Sprintf("%s/%s", common.OpenFeatureAnnotationPrefix, ofoDeployed)]
return ok && val == "true"
val, ok := d.Labels["app.kubernetes.io/managed-by"]
return ok && val == ManagedByAnnotationValue
}
6 changes: 2 additions & 4 deletions common/flagdproxy/flagdproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"testing"

"github.com/go-logr/logr/testr"
"github.com/open-feature/open-feature-operator/common"
"github.com/open-feature/open-feature-operator/common/types"
"github.com/stretchr/testify/require"
appsV1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -138,7 +137,7 @@ func TestFlagdProxyHandler_HandleFlagdProxy_ProxyExistsWithBadVersion(t *testing
Name: FlagdProxyDeploymentName,
OwnerReferences: []metav1.OwnerReference{*ownerRef},
Labels: map[string]string{
fmt.Sprintf("%s/%s", common.OpenFeatureAnnotationPrefix, ofoDeployed): "true",
"app.kubernetes.io/managed-by": ManagedByAnnotationValue,
},
},
Spec: v1.DeploymentSpec{
Expand Down Expand Up @@ -328,7 +327,6 @@ func TestFlagdProxyHandler_HandleFlagdProxy_CreateProxy(t *testing.T) {
"app": FlagdProxyDeploymentName,
"app.kubernetes.io/managed-by": ManagedByAnnotationValue,
"app.kubernetes.io/version": "tag",
fmt.Sprintf("%s/%s", common.OpenFeatureAnnotationPrefix, ofoDeployed): "true",
},
ResourceVersion: "1",
OwnerReferences: []metav1.OwnerReference{
Expand Down Expand Up @@ -407,7 +405,7 @@ func TestFlagdProxyHandler_HandleFlagdProxy_CreateProxy(t *testing.T) {
},
},
Labels: map[string]string{
fmt.Sprintf("%s/%s", common.OpenFeatureAnnotationPrefix, ofoDeployed): "true",
"app.kubernetes.io/managed-by": ManagedByAnnotationValue,
},
},
Spec: corev1.ServiceSpec{
Expand Down
4 changes: 2 additions & 2 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: docker.io/odubajdt/operator
newTag: proxy-update
newName: controller
newTag: latest

0 comments on commit 76125b9

Please sign in to comment.