Skip to content

Commit c58a281

Browse files
author
Eric Stroczynski
authored
docs/building-operators/golang: fix context.Context usage, imports, general formatting (#4475)
Signed-off-by: Eric Stroczynski <[email protected]>
1 parent 545eb37 commit c58a281

File tree

4 files changed

+112
-94
lines changed

4 files changed

+112
-94
lines changed

website/content/en/docs/building-operators/golang/migration.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ func main() {
182182
log.Error(err, "")
183183
os.Exit(1)
184184
}
185-
..
185+
...
186+
}
186187
```
187188

188189
In order to use the previous one ensure that you have the [operator-lib][operator-lib] as a dependency of your project.
@@ -202,6 +203,7 @@ func main() {
202203
LeaderElectionID: "f1c5ece8.example.com",
203204
})
204205
...
206+
}
205207
```
206208

207209
- Ensure that you copy all customizations made in `cmd/manager/main.go` to `main.go`. You’ll also need to ensure that all needed schemes have been registered, if you have been using third-party API's (i.e Route Api from OpenShift).
@@ -244,7 +246,7 @@ If not, you can install Prometheus via [kube-prometheus](https://github.com/core
244246
kubectl apply -f https://raw.githubusercontent.com/coreos/prometheus-operator/release-0.33/bundle.yaml
245247
```
246248
- Now uncomment the line `- ../prometheus` in the `config/default/kustomization.yaml` file. It creates the `ServiceMonitor` resource which enables exporting the metrics:
247-
```sh
249+
```yaml
248250
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
249251
- ../prometheus
250252
```
@@ -280,7 +282,7 @@ func (r *MemcachedReconciler) SetupWithManager(mgr ctrl.Manager) error {
280282

281283
In this way, the following metric with the resource info will be exported:
282284

283-
```shell
285+
```
284286
resource_created_at_seconds{"name", "namespace", "group", "version", "kind"}
285287
```
286288

@@ -294,15 +296,15 @@ The Dockerfile image also changes and now it is a `multi-stage`, `distroless` an
294296

295297
See that, you might need to port some customizations made in your old Dockerfile as well. Also, if you wish to still using the previous UBI image replace:
296298

297-
```sh
299+
```docker
298300
# Use distroless as minimal base image to package the manager binary
299301
# Refer to https://github.com/GoogleContainerTools/distroless for more details
300302
FROM gcr.io/distroless/static:nonroot
301303
```
302304

303305
With:
304306

305-
```sh
307+
```docker
306308
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
307309
```
308310

0 commit comments

Comments
 (0)