From 995bac6d25ab646fe7b87256ea6325472995e431 Mon Sep 17 00:00:00 2001 From: odubajDT Date: Thu, 18 Jan 2024 07:46:18 +0100 Subject: [PATCH] pr review Signed-off-by: odubajDT --- CONTRIBUTING.md | 3 ++- chart/open-feature-operator/README.md | 7 +++-- common/flagdproxy/flagdproxy.go | 37 ++++++++++++++------------- config/manager/kustomization.yaml | 4 +-- docs/installation.md | 7 +++-- docs/quick_start.md | 4 +-- docs/v1beta_migration.md | 4 +-- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7136e757d..8c633a522 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,7 +29,8 @@ make build-deploy-operator TAG=myTag RELEASE_REGISTRY=docker.io/user1 RELEASE_NA Which will result in building the operator image `docker.io/user1/myImgName:myTag`, uploading it to your image registry and deploying to your cluster. Please be aware that it is using the cluster your current kube-context is pointing to. -**Note:** All bash variables are optional, the default values are set and will result in an image `ghcr.io/openfeature/operator:latest` +> [!NOTE] +> All bash variables are optional, the default values are set and will result in an image `ghcr.io/openfeature/operator:latest` ### Autogenerated Documentation diff --git a/chart/open-feature-operator/README.md b/chart/open-feature-operator/README.md index 4de15405b..39c4345a4 100644 --- a/chart/open-feature-operator/README.md +++ b/chart/open-feature-operator/README.md @@ -45,12 +45,11 @@ helm repo update helm upgrade --install open-feature-operator openfeature/open-feature-operator ``` -**Note:** -If you have used `flagd-proxy` provider and upgrading to OFO version `v0.5.4` or higher, -`flagd-proxy` will be automatically upgraded to the lastest supported version by the `open-feature-operator`. +> [!NOTE] +> If you have used `flagd-proxy` provider and upgrading to OFO version `v0.5.4` or higher, +`flagd-proxy` will be automatically upgraded to the latest supported version by the `open-feature-operator`. This upgrade will also consider your current `FeatureFlagSource` configuration and adapt the `flagd-proxy` Deployment accordingly. - If you are upgrading OFO to `v0.5.3` or lower, `flagd-proxy` (if present) won't be upgraded automatically. #### Upgrade CRDs diff --git a/common/flagdproxy/flagdproxy.go b/common/flagdproxy/flagdproxy.go index 0e2a73922..39eda8552 100644 --- a/common/flagdproxy/flagdproxy.go +++ b/common/flagdproxy/flagdproxy.go @@ -64,11 +64,11 @@ func (f *FlagdProxyHandler) Config() *FlagdProxyConfiguration { return f.config } -func (f *FlagdProxyHandler) CreateObject(ctx context.Context, obj client.Object) error { +func (f *FlagdProxyHandler) createObject(ctx context.Context, obj client.Object) error { return f.Client.Create(ctx, obj) } -func (f *FlagdProxyHandler) UpdateObject(ctx context.Context, obj client.Object) error { +func (f *FlagdProxyHandler) updateObject(ctx context.Context, obj client.Object) error { return f.Client.Update(ctx, obj) } @@ -84,12 +84,12 @@ func (f *FlagdProxyHandler) HandleFlagdProxy(ctx context.Context) error { if !exists { f.Log.Info("flagd-proxy Deployment does not exist, creating") - return f.deployFlagdProxy(ctx, f.CreateObject, newDeployment, newService) + return f.deployFlagdProxy(ctx, f.createObject, newDeployment, newService) } // flagd-proxy exists, need to check if it's the right version if !f.isFlagdProxyUpToDate(deployment, newDeployment) { f.Log.Info("flagd-proxy Deployment changed, updating") - return f.deployFlagdProxy(ctx, f.UpdateObject, newDeployment, newService) + return f.deployFlagdProxy(ctx, f.updateObject, newDeployment, newService) } f.Log.Info("flagd-proxy Deployment up-to-date") return nil @@ -210,27 +210,28 @@ func (f *FlagdProxyHandler) isFlagdProxyUpToDate(old, new *appsV1.Deployment) bo return reflect.DeepEqual(old.Spec, new.Spec) } -func (f *FlagdProxyHandler) getOwnerReference(ctx context.Context) (metav1.OwnerReference, error) { +func (f *FlagdProxyHandler) getOperatorDeployment(ctx context.Context) (*appsV1.Deployment, error) { d := &appsV1.Deployment{} if err := f.Client.Get(ctx, client.ObjectKey{Name: f.config.OperatorDeploymentName, Namespace: f.config.Namespace}, d); err != nil { - return metav1.OwnerReference{}, fmt.Errorf("unable to fetch operator deployment to create owner reference: %w", err) + return nil, fmt.Errorf("unable to fetch operator deployment to create owner reference: %w", err) } - return metav1.OwnerReference{ - UID: d.GetUID(), - Name: d.GetName(), - APIVersion: d.APIVersion, - Kind: d.Kind, - }, nil + return d, nil } func (f *FlagdProxyHandler) getOwnerReferences(ctx context.Context) []metav1.OwnerReference { - ownerReferences := []metav1.OwnerReference{} - ownerReference, err := f.getOwnerReference(ctx) + operatorDeployment, err := f.getOperatorDeployment(ctx) if err != nil { - f.Log.Error(err, "unable to create owner reference for open-feature-operator, not appending") - } else { - ownerReferences = append(ownerReferences, ownerReference) + f.Log.Error(err, "unable to create owner reference for open-feature-operator") + return []metav1.OwnerReference{} + } + + return []metav1.OwnerReference{ + { + UID: operatorDeployment.GetUID(), + Name: operatorDeployment.GetName(), + APIVersion: operatorDeployment.APIVersion, + Kind: operatorDeployment.Kind, + }, } - return ownerReferences } diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 5679bb554..98e3a9c65 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -10,5 +10,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: - name: controller - newName: controller - newTag: latest + newName: docker.io/odubajdt/operator + newTag: proxy-update diff --git a/docs/installation.md b/docs/installation.md index 7af84ce41..7180f7970 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -28,12 +28,11 @@ helm upgrade --install openfeature openfeature/open-feature-operator helm upgrade --install openfeature openfeature/open-feature-operator ``` -**Note:** -If you have used `flagd-proxy` provider and upgrading to OFO version `v0.5.4` or higher, -`flagd-proxy` will be automatically upgraded to the lastest supported version by the `open-feature-operator`. +> [!NOTE] +> If you have used `flagd-proxy` provider and upgrading to OFO version `v0.5.4` or higher, +`flagd-proxy` will be automatically upgraded to the latest supported version by the `open-feature-operator`. This upgrade will also consider your current `FeatureFlagSource` configuration and adapt the `flagd-proxy` Deployment accordingly. - If you are upgrading OFO to `v0.5.3` or lower, `flagd-proxy` (if present) won't be upgraded automatically. #### Upgrading CRDs diff --git a/docs/quick_start.md b/docs/quick_start.md index 2dedfa004..f412946d6 100644 --- a/docs/quick_start.md +++ b/docs/quick_start.md @@ -22,7 +22,7 @@ kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/ kubectl wait --for=condition=Available=True deploy --all -n 'cert-manager' ``` -> **Note** +> [!NOTE] > Requirement of this dependency is explained in the [installation](./installation.md) guide. #### 3. Install OpenFeature Operator @@ -52,7 +52,7 @@ Next steps focus on adding feature flags, flag source configuration and a worklo kubectl create ns flags ``` -> **Note** +> [!NOTE] > We use the namespace `flags` for flag related custom resources #### 5. Install feature flags definition diff --git a/docs/v1beta_migration.md b/docs/v1beta_migration.md index e063c29cb..7ea6f2263 100644 --- a/docs/v1beta_migration.md +++ b/docs/v1beta_migration.md @@ -79,7 +79,7 @@ We recommend following migration steps, If you have used `flagd-proxy` provider, then you have to upgrade the image used by the `flagd-proxy` deployment. For this, please edit the deployment of `flagd-proxy` to version [v0.3.1](https://github.com/open-feature/flagd/pkgs/container/flagd-proxy/152333134?tag=v0.3.1) or above. -**Note:** -Since OFO version `v0.5.4`, `flagd-proxy` pod (if present) will be upgraded automatically to the +> [!NOTE] +> Since OFO version `v0.5.4`, `flagd-proxy` pod (if present) will be upgraded automatically to the to the latest supported version by `open-feature-operator`. For more information see the [upgrade section](./installation.md#upgrading).