Skip to content

Commit

Permalink
pr review
Browse files Browse the repository at this point in the history
Signed-off-by: odubajDT <[email protected]>
  • Loading branch information
odubajDT committed Jan 18, 2024
1 parent 779ae04 commit 995bac6
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 33 deletions.
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 3 additions & 4 deletions chart/open-feature-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 19 additions & 18 deletions common/flagdproxy/flagdproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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
Expand Down Expand Up @@ -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
}
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: controller
newTag: latest
newName: docker.io/odubajdt/operator
newTag: proxy-update
7 changes: 3 additions & 4 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/v1beta_migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

0 comments on commit 995bac6

Please sign in to comment.