Skip to content

Commit

Permalink
doc: update diff section (#32)
Browse files Browse the repository at this point in the history
* chore: update operators name

* chore: add operator name in README

* chore: update operator-v2-with-tests dependency to match other operators dependencies

* chore: go mod tidy

* doc: update diff
  • Loading branch information
leovct authored Oct 19, 2023
1 parent 6bed3b5 commit fb45164
Show file tree
Hide file tree
Showing 48 changed files with 158 additions and 150 deletions.
90 changes: 49 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,23 @@ diff --color -r operator-v1/README.md operator-v2/README.md
---
> # operator-v2
diff --color -r operator-v1/api/v1/foo_types.go operator-v2/api/v1/foo_types.go
32a33,35
33a34,36
>
> // Foo's favorite colour
> Colour string `json:"colour,omitempty"`
Only in operator-v2: color
> // Foo's favorite colour
> Colour string `json:"colour,omitempty"`
Binary files operator-v1/bin/kustomize and operator-v2/bin/kustomize differ
Binary files operator-v1/bin/setup-envtest and operator-v2/bin/setup-envtest differ
diff --color -r operator-v1/config/crd/bases/tutorial.my.domain_foos.yaml operator-v2/config/crd/bases/tutorial.my.domain_foos.yaml
46a47,49
45a46,48
> colour:
> description: Foo's favorite colour
> type: string
diff --color -r operator-v1/controllers/foo_controller.go operator-v2/controllers/foo_controller.go
32a33
> color "my.domain/tutorial/color"
77a79
> foo.Status.Colour = color.ConvertStrToColor(foo.Name + foo.Namespace)
Only in operator-v2/internal: color
diff --color -r operator-v1/internal/controller/foo_controller.go operator-v2/internal/controller/foo_controller.go
31a32
> "my.domain/tutorial/internal/color"
75a77
> foo.Status.Colour = color.ConvertStrToColor(foo.Name + foo.Namespace)
```

### `v2` <> `v2-with-tests`
Expand All @@ -70,46 +72,52 @@ diff --color -r operator-v2/README.md operator-v2-with-tests/README.md
< # operator-v2
---
> # operator-v2-with-tests
Only in operator-v2-with-tests/color: color_test.go
Only in operator-v2-with-tests/controllers: foo_controller_test.go
diff --color -r operator-v2/controllers/suite_test.go operator-v2-with-tests/controllers/suite_test.go
Only in operator-v2-with-tests/bin: manager
diff --color -r operator-v2/go.mod operator-v2-with-tests/go.mod
7a8
> k8s.io/api v0.28.0
64d64
< k8s.io/api v0.28.0 // indirect
Only in operator-v2-with-tests/internal/color: color_test.go
Only in operator-v2-with-tests/internal/controller: foo_controller_test.go
diff --color -r operator-v2/internal/controller/suite_test.go operator-v2-with-tests/internal/controller/suite_test.go
19a20
> "context"
22a24,25
> ctrl "sigs.k8s.io/controller-runtime"
> "context"
24a26,27
> ctrl "sigs.k8s.io/controller-runtime"
>
40,42c43,49
42,44c45,51
< var cfg *rest.Config
< var k8sClient client.Client
< var testEnv *envtest.Environment
---
> var (
> cfg *rest.Config
> k8sClient client.Client
> testEnv *envtest.Environment
> ctx context.Context
> cancel context.CancelFunc
> cfg *rest.Config
> k8sClient client.Client
> testEnv *envtest.Environment
> ctx context.Context
> cancel context.CancelFunc
> )
53a61
> ctx, cancel = context.WithCancel(context.TODO())
75a84,100
> // Register and start the Foo controller
> k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{
> Scheme: scheme.Scheme,
> })
> Expect(err).ToNot(HaveOccurred())
> ctx, cancel = context.WithCancel(context.TODO())
83a92,108
> // Register and start the Foo controller
> k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{
> Scheme: scheme.Scheme,
> })
> Expect(err).ToNot(HaveOccurred())
>
> err = (&FooReconciler{
> Client: k8sManager.GetClient(),
> Scheme: k8sManager.GetScheme(),
> }).SetupWithManager(k8sManager)
> Expect(err).ToNot(HaveOccurred())
> err = (&FooReconciler{
> Client: k8sManager.GetClient(),
> Scheme: k8sManager.GetScheme(),
> }).SetupWithManager(k8sManager)
> Expect(err).ToNot(HaveOccurred())
>
> go func() {
> defer GinkgoRecover()
> err = k8sManager.Start(ctx)
> Expect(err).ToNot(HaveOccurred(), "failed to run manager")
> }()
78a104
> cancel()
> go func() {
> defer GinkgoRecover()
> err = k8sManager.Start(ctx)
> Expect(err).ToNot(HaveOccurred(), "failed to run manager")
> }()
86a112
> cancel()
```
4 changes: 2 additions & 2 deletions operator-v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ kubectl apply -k config/samples/
2. Build and push your image to the location specified by `IMG`:

```sh
make docker-build docker-push IMG=<some-registry>/operator-v1:tag
make docker-build docker-push IMG=<some-registry>/operator:tag
```

3. Deploy the controller to the cluster with the image specified by `IMG`:

```sh
make deploy IMG=<some-registry>/operator-v1:tag
make deploy IMG=<some-registry>/operator:tag
```

### Uninstall CRDs
Expand Down
4 changes: 2 additions & 2 deletions operator-v1/config/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Adds namespace to all resources.
namespace: operator-v1-system
namespace: operator-system

# Value of this field is prepended to the
# names of all resources, e.g. a deployment named
# "wordpress" becomes "alices-wordpress".
# Note that it should also match with the prefix (text before '-') of the namespace
# field above.
namePrefix: operator-v1-
namePrefix: operator-

# Labels to add to all resources and selectors.
#labels:
Expand Down
8 changes: 4 additions & 4 deletions operator-v1/config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ metadata:
app.kubernetes.io/name: namespace
app.kubernetes.io/instance: system
app.kubernetes.io/component: manager
app.kubernetes.io/created-by: operator-v1
app.kubernetes.io/part-of: operator-v1
app.kubernetes.io/created-by: operator
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
name: system
---
Expand All @@ -21,8 +21,8 @@ metadata:
app.kubernetes.io/name: deployment
app.kubernetes.io/instance: controller-manager
app.kubernetes.io/component: manager
app.kubernetes.io/created-by: operator-v1
app.kubernetes.io/part-of: operator-v1
app.kubernetes.io/created-by: operator
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
spec:
selector:
Expand Down
4 changes: 2 additions & 2 deletions operator-v1/config/prometheus/monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ metadata:
app.kubernetes.io/name: servicemonitor
app.kubernetes.io/instance: controller-manager-metrics-monitor
app.kubernetes.io/component: metrics
app.kubernetes.io/created-by: operator-v1
app.kubernetes.io/part-of: operator-v1
app.kubernetes.io/created-by: operator
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
name: controller-manager-metrics-monitor
namespace: system
Expand Down
4 changes: 2 additions & 2 deletions operator-v1/config/rbac/auth_proxy_client_clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ metadata:
app.kubernetes.io/name: clusterrole
app.kubernetes.io/instance: metrics-reader
app.kubernetes.io/component: kube-rbac-proxy
app.kubernetes.io/created-by: operator-v1
app.kubernetes.io/part-of: operator-v1
app.kubernetes.io/created-by: operator
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
name: metrics-reader
rules:
Expand Down
4 changes: 2 additions & 2 deletions operator-v1/config/rbac/auth_proxy_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ metadata:
app.kubernetes.io/name: clusterrole
app.kubernetes.io/instance: proxy-role
app.kubernetes.io/component: kube-rbac-proxy
app.kubernetes.io/created-by: operator-v1
app.kubernetes.io/part-of: operator-v1
app.kubernetes.io/created-by: operator
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
name: proxy-role
rules:
Expand Down
4 changes: 2 additions & 2 deletions operator-v1/config/rbac/auth_proxy_role_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ metadata:
app.kubernetes.io/name: clusterrolebinding
app.kubernetes.io/instance: proxy-rolebinding
app.kubernetes.io/component: kube-rbac-proxy
app.kubernetes.io/created-by: operator-v1
app.kubernetes.io/part-of: operator-v1
app.kubernetes.io/created-by: operator
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
name: proxy-rolebinding
roleRef:
Expand Down
4 changes: 2 additions & 2 deletions operator-v1/config/rbac/auth_proxy_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ metadata:
app.kubernetes.io/name: service
app.kubernetes.io/instance: controller-manager-metrics-service
app.kubernetes.io/component: kube-rbac-proxy
app.kubernetes.io/created-by: operator-v1
app.kubernetes.io/part-of: operator-v1
app.kubernetes.io/created-by: operator
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
name: controller-manager-metrics-service
namespace: system
Expand Down
4 changes: 2 additions & 2 deletions operator-v1/config/rbac/foo_editor_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ metadata:
app.kubernetes.io/name: clusterrole
app.kubernetes.io/instance: foo-editor-role
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: operator-v1
app.kubernetes.io/part-of: operator-v1
app.kubernetes.io/created-by: operator
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
name: foo-editor-role
rules:
Expand Down
4 changes: 2 additions & 2 deletions operator-v1/config/rbac/foo_viewer_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ metadata:
app.kubernetes.io/name: clusterrole
app.kubernetes.io/instance: foo-viewer-role
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: operator-v1
app.kubernetes.io/part-of: operator-v1
app.kubernetes.io/created-by: operator
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
name: foo-viewer-role
rules:
Expand Down
4 changes: 2 additions & 2 deletions operator-v1/config/rbac/leader_election_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ metadata:
app.kubernetes.io/name: role
app.kubernetes.io/instance: leader-election-role
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: operator-v1
app.kubernetes.io/part-of: operator-v1
app.kubernetes.io/created-by: operator
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
name: leader-election-role
rules:
Expand Down
4 changes: 2 additions & 2 deletions operator-v1/config/rbac/leader_election_role_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ metadata:
app.kubernetes.io/name: rolebinding
app.kubernetes.io/instance: leader-election-rolebinding
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: operator-v1
app.kubernetes.io/part-of: operator-v1
app.kubernetes.io/created-by: operator
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
name: leader-election-rolebinding
roleRef:
Expand Down
4 changes: 2 additions & 2 deletions operator-v1/config/rbac/role_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ metadata:
app.kubernetes.io/name: clusterrolebinding
app.kubernetes.io/instance: manager-rolebinding
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: operator-v1
app.kubernetes.io/part-of: operator-v1
app.kubernetes.io/created-by: operator
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
name: manager-rolebinding
roleRef:
Expand Down
4 changes: 2 additions & 2 deletions operator-v1/config/rbac/service_account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ metadata:
app.kubernetes.io/name: serviceaccount
app.kubernetes.io/instance: controller-manager-sa
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: operator-v1
app.kubernetes.io/part-of: operator-v1
app.kubernetes.io/created-by: operator
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
name: controller-manager
namespace: system
4 changes: 2 additions & 2 deletions operator-v1/config/samples/tutorial_v1_foo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ metadata:
labels:
app.kubernetes.io/name: foo
app.kubernetes.io/instance: foo-sample
app.kubernetes.io/part-of: operator-v1
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/created-by: operator-v1
app.kubernetes.io/created-by: operator
name: foo-sample
spec:
# TODO(user): Add fields here
6 changes: 3 additions & 3 deletions operator-v2-with-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# operator-v2
# operator-v2-with-tests
// TODO(user): Add simple overview of use/purpose

## Description
Expand All @@ -18,13 +18,13 @@ kubectl apply -k config/samples/
2. Build and push your image to the location specified by `IMG`:

```sh
make docker-build docker-push IMG=<some-registry>/operator-v2:tag
make docker-build docker-push IMG=<some-registry>/operator:tag
```

3. Deploy the controller to the cluster with the image specified by `IMG`:

```sh
make deploy IMG=<some-registry>/operator-v2:tag
make deploy IMG=<some-registry>/operator:tag
```

### Uninstall CRDs
Expand Down
4 changes: 2 additions & 2 deletions operator-v2-with-tests/config/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Adds namespace to all resources.
namespace: operator-v2-system
namespace: operator-system

# Value of this field is prepended to the
# names of all resources, e.g. a deployment named
# "wordpress" becomes "alices-wordpress".
# Note that it should also match with the prefix (text before '-') of the namespace
# field above.
namePrefix: operator-v2-
namePrefix: operator-

# Labels to add to all resources and selectors.
#labels:
Expand Down
8 changes: 4 additions & 4 deletions operator-v2-with-tests/config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ metadata:
app.kubernetes.io/name: namespace
app.kubernetes.io/instance: system
app.kubernetes.io/component: manager
app.kubernetes.io/created-by: operator-v2
app.kubernetes.io/part-of: operator-v2
app.kubernetes.io/created-by: operator
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
name: system
---
Expand All @@ -21,8 +21,8 @@ metadata:
app.kubernetes.io/name: deployment
app.kubernetes.io/instance: controller-manager
app.kubernetes.io/component: manager
app.kubernetes.io/created-by: operator-v2
app.kubernetes.io/part-of: operator-v2
app.kubernetes.io/created-by: operator
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
spec:
selector:
Expand Down
4 changes: 2 additions & 2 deletions operator-v2-with-tests/config/prometheus/monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ metadata:
app.kubernetes.io/name: servicemonitor
app.kubernetes.io/instance: controller-manager-metrics-monitor
app.kubernetes.io/component: metrics
app.kubernetes.io/created-by: operator-v2
app.kubernetes.io/part-of: operator-v2
app.kubernetes.io/created-by: operator
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
name: controller-manager-metrics-monitor
namespace: system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ metadata:
app.kubernetes.io/name: clusterrole
app.kubernetes.io/instance: metrics-reader
app.kubernetes.io/component: kube-rbac-proxy
app.kubernetes.io/created-by: operator-v2
app.kubernetes.io/part-of: operator-v2
app.kubernetes.io/created-by: operator
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
name: metrics-reader
rules:
Expand Down
4 changes: 2 additions & 2 deletions operator-v2-with-tests/config/rbac/auth_proxy_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ metadata:
app.kubernetes.io/name: clusterrole
app.kubernetes.io/instance: proxy-role
app.kubernetes.io/component: kube-rbac-proxy
app.kubernetes.io/created-by: operator-v2
app.kubernetes.io/part-of: operator-v2
app.kubernetes.io/created-by: operator
app.kubernetes.io/part-of: operator
app.kubernetes.io/managed-by: kustomize
name: proxy-role
rules:
Expand Down
Loading

0 comments on commit fb45164

Please sign in to comment.