// Module included in the following assemblies:
//
// * operators/operator_sdk/golang/osdk-golang-updating-projects.adoc
// * operators/operator_sdk/ansible/osdk-ansible-updating-projects.adoc
// * operators/operator_sdk/helm/osdk-helm-updating-projects.adoc
// * operators/operator_sdk/helm/osdk-hybrid-helm-updating-projects.adoc
// * operators/operator_sdk/java/osdk-java-updating-projects.adoc

ifeval::["{context}" == "osdk-golang-updating-projects"]
:golang:
:type: Go
endif::[]
ifeval::["{context}" == "osdk-ansible-updating-projects"]
:ansible:
:type: Ansible
endif::[]
ifeval::["{context}" == "osdk-helm-updating-projects"]
:helm:
:type: Helm
endif::[]
ifeval::["{context}" == "osdk-hybrid-helm-updating-projects"]
:hybrid:
:type: Hybrid Helm
endif::[]
ifeval::["{context}" == "osdk-java-updating-projects"]
:java:
:type: Java
endif::[]

:_mod-docs-content-type: PROCEDURE
[id="osdk-upgrading-projects_{context}"]
= Updating {type}-based Operator projects for Operator SDK {osdk_ver}

The following procedure updates an existing {type}-based Operator project for compatibility with {osdk_ver}.

.Prerequisites

* Operator SDK {osdk_ver} installed
* An Operator project created or maintained with Operator SDK {osdk_ver_n1}

.Procedure

ifdef::helm,hybrid,java[]
* Find the `ose-kube-rbac-proxy` pull spec in the following files, and update the image tag to `v4.14`:
endif::[]
ifdef::ansible,golang[]
. Find the `ose-kube-rbac-proxy` pull spec in the following files, and update the image tag to `v4.14`:
endif::[]
+
--
* `config/default/manager_auth_proxy_patch.yaml`
* `bundle/manifests/memcached-operator.clusterserviceversion.yaml`
--
+
[source,yaml]
----
…
      containers:
      - name: kube-rbac-proxy
        image: registry.redhat.io/openshift4/ose-kube-rbac-proxy:v4.14 <1>
…
----
<1> Update the tag version from `v4.13` to `v4.14`.

ifdef::ansible[]
. Update your Makefile's `run` target to the following:
+
[source,make]
----
.PHONY: run
ANSIBLE_ROLES_PATH?="$(shell pwd)/roles"
run: ansible-operator ## Run against the configured Kubernetes cluster in ~/.kube/config
    $(ANSIBLE_OPERATOR) run
----

. To upgrade the `kubernetes.core` collection to v2.4.0, replace the following in your project's `requirements.yaml` file:
+
[source,yaml]
----
  - name: kubernetes.core
    version: "2.3.1"
----
+
with:
+
[source,yaml]
----
  - name: kubernetes.core
    version: "2.4.0"
----
endif::[]

ifdef::golang[]
. Modify your `go.mod` file to include the following dependencies and updated versions:
+
[source,go]
----
k8s.io/api v0.26.2
k8s.io/apiextensions-apiserver v0.26.2
k8s.io/apimachinery v0.26.2
k8s.io/cli-runtime v0.26.2
k8s.io/client-go v0.26.2
k8s.io/kubectl v0.26.2
sigs.k8s.io/controller-runtime v0.14.5
sigs.k8s.io/controller-tools v0.11.3
sigs.k8s.io/kubebuilder/v3 v3.9.1
----

. Download the latest dependencies by running the following command:
+
[source,terminal]
----
$ go mod tidy
----

. Modify your Makefile with the following changes:

.. Change the `ENVTEST_K8S_VERSION` field from `1.26` to `1.27`.
.. Change the `build` target from `generate fmt vet` to `manifests generate fmt vet`:
+
[source,diff]
----
    - build: generate fmt vet ## Build manager binary.
    + build: manifests generate fmt vet ## Build manager binary.
----
endif::[]

ifeval::["{context}" == "osdk-golang-updating-projects"]
:!golang:
:!type:
endif::[]
ifeval::["{context}" == "osdk-ansible-updating-projects"]
:!ansible:
:!type:
endif::[]
ifeval::["{context}" == "osdk-helm-updating-projects"]
:!helm:
:!type:
endif::[]
ifeval::["{context}" == "osdk-hybrid-helm-updating-projects"]
:!hybrid:
:!type:
endif::[]
ifeval::["{context}" == "osdk-java-updating-projects"]
:!java:
:!type:
endif::[]
