Skip to content

Commit

Permalink
Refactor pkg/controller and fix typo on CRD name
Browse files Browse the repository at this point in the history
  • Loading branch information
mumoshu committed Oct 29, 2020
1 parent ca1e5e5 commit 56fd57e
Show file tree
Hide file tree
Showing 8 changed files with 297 additions and 242 deletions.
18 changes: 9 additions & 9 deletions examples/controller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,18 @@ EOS
Within a few seconds, the controller will reconcile your `Resource` by running `variant run apply --env preview --ref abc1234`.

You can verify that by tailing controller logs by `kubectl logs`, or browsing the `Reconcilation` object that is created by
the controller to record the reconcilation details:
the controller to record the reconciliation details:

```console
$ kubectl get reconcilation
$ kubectl get reconciliation
NAME AGE
myresource-2 12m
```

```console
$ kubectl get -o yaml reconcilation myresource-2
$ kubectl get -o yaml reconciliation myresource-2
apiVersion: core.variant.run/v1beta1
kind: Reconcilation
kind: Reconciliation
metadata:
creationTimestamp: "2020-10-28T12:05:55Z"
generation: 1
Expand Down Expand Up @@ -114,15 +114,15 @@ EOS
```

```console
$ kubectl get reconcilation
$ kubectl get reconciliation
NAME AGE
myresource-2 12m
myresource-3 12m
```

```cnosole
apiVersion: core.variant.run/v1beta1urce-3
kind: Reconcilation
kind: Reconciliation
metadata:
creationTimestamp: "2020-10-28T12:06:10Z"
generation: 1
Expand All @@ -146,17 +146,17 @@ Finally, deleting the `Resource` will let `variant` destroy the underlying resou
as you've configured:

```console
$ kubectl get reconcilation
$ kubectl get reconciliation
NAME AGE
myresource-2 19m
myresource-3 19m
myresource-4 9s
```

```console
$ kubectl get reconcilation -o yaml myresource-4
$ kubectl get reconciliation -o yaml myresource-4
apiVersion: core.variant.run/v1beta1
kind: Reconcilation
kind: Reconciliation
metadata:
creationTimestamp: "2020-10-28T12:25:32Z"
generation: 1
Expand Down
2 changes: 1 addition & 1 deletion examples/controller/reconcilation.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: core.variant.run/v1beta1
kind: Reconcilation
kind: Reconciliation
metadata:
name: myresource-abc
spec:
Expand Down
8 changes: 4 additions & 4 deletions examples/controller/variant.crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ spec:
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: reconcilations.core.variant.run
name: reconciliations.core.variant.run
spec:
group: core.variant.run
versions:
- name: v1beta1
served: true
storage: true
names:
kind: Reconcilation
plural: reconcilations
singular: reconcilation
kind: Reconciliation
plural: reconciliations
singular: reconciliation
scope: Namespaced
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/AlecAivazis/survey/v2 v2.0.5
github.com/PaesslerAG/jsonpath v0.1.1 // indirect
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/go-logr/logr v0.1.0
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/google/go-cmp v0.4.0
github.com/google/go-github/v27 v27.0.6 // indirect
Expand Down
27 changes: 27 additions & 0 deletions pkg/controller/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package controller

import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
)

const (
coreGroup = "core.variant.run"
coreVersion = "v1beta1"
)

var (
reconciliationGroupVersionKind = schema.GroupVersionKind{
Group: coreGroup,
Version: coreVersion,
Kind: "Reconciliation",
}
)

func newReconciliation() *unstructured.Unstructured {
obj := &unstructured.Unstructured{}

obj.SetGroupVersionKind(reconciliationGroupVersionKind)

return obj
}
Loading

0 comments on commit 56fd57e

Please sign in to comment.