Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #8 from flanksource/duck-typing-crd
Browse files Browse the repository at this point in the history
Duck typing crd
  • Loading branch information
moshloop authored Dec 7, 2020
2 parents 6aec15d + 2cf6d02 commit 8e6860e
Show file tree
Hide file tree
Showing 28 changed files with 2,037 additions and 3,600 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
on: [push]
name: Test
jobs:
test:
strategy:
matrix:
go-version: [1.13.x]
platform: [ubuntu-latest]
k8s:
- v1.16.9
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Test
env:
KUBERNETES_VERSION: ${{matrix.k8s}}
run: ./test/e2e.sh
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bin/
cover.out
.env
/.bin
/.certs
/karina*
553 changes: 276 additions & 277 deletions config/crd/bases/templating.flanksource.com_templates.yaml

Large diffs are not rendered by default.

46 changes: 3 additions & 43 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,8 @@ metadata:
name: manager-role
rules:
- apiGroups:
- ""
- '*'
resources:
- configmaps
- '*'
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- namespaces
verbs:
- get
- list
- watch
- apiGroups:
- extensions
resources:
- ingresses
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
- templating.flanksource.com
resources:
- templates
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- templating.flanksource.com
resources:
- templates/status
verbs:
- get
- patch
- update
- '*'
19 changes: 9 additions & 10 deletions controllers/template_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,26 @@ package controllers
import (
"context"

"github.com/flanksource/kommons"
templatev1 "github.com/flanksource/template-operator/api/v1"
"github.com/flanksource/template-operator/k8s"
"github.com/go-logr/logr"
kerrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

templatev1 "github.com/flanksource/template-operator/api/v1"
"github.com/flanksource/template-operator/k8s"
)

// TemplateReconciler reconciles a Template object
type TemplateReconciler struct {
ControllerClient client.Client
Client *k8s.Client
Client *kommons.Client
Log logr.Logger
Scheme *runtime.Scheme
}

// +kubebuilder:rbac:groups=templating.flanksource.com,resources=templates,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=templating.flanksource.com,resources=templates/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=extensions,resources=ingresses,verbs=get;list;watch;update;patch
// +kubebuilder:rbac:groups="",resources=namespaces,verbs=get;list;watch
// +kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch
// +kubebuilder:rbac:groups="*",resources="*",verbs="*"

func (r *TemplateReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
ctx := context.Background()
Expand All @@ -58,7 +54,10 @@ func (r *TemplateReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
return reconcile.Result{}, err
}

tm := k8s.NewTemplateManager(r.Client, log)
tm, err := k8s.NewTemplateManager(r.Client, log)
if err != nil {
return reconcile.Result{}, err
}
if err := tm.Run(ctx, template); err != nil {
return reconcile.Result{}, err
}
Expand Down
3 changes: 1 addition & 2 deletions examples/postgres-operator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ spec:
configMap:
name: postgres-exporter-config
allowedSourceRanges: null
clone: null
dockerImage: docker.io/flanksource/spilo:1.6-p2.flanksource
enableShmVolume: true
env:
Expand Down Expand Up @@ -133,6 +132,7 @@ spec:
value: "{{.spec.backup.bucket}}"
- name: CLONE_WAL_BUCKET_SCOPE_SUFFIX
value: /
numberOfInstances: "{{ .spec.replicas }}"
patroni:
initdb:
data-checksums: "true"
Expand Down Expand Up @@ -192,7 +192,6 @@ spec:
requests:
cpu: 10m
memory: 128Mi
standby: null
teamId: postgres
tls: null
users:
Expand Down
16 changes: 16 additions & 0 deletions examples/postgresqldb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: db.flanksource.com/v1
kind: PostgresqlDB
metadata:
name: test1
namespace: postgres-operator
spec:
replicas: 2
parameters:
max_connections: "1024"
shared_buffers: 4759MB
work_mem: 475MB
maintenance_work_mem: 634MB
storage:
storageClass: vsan
backup:
bucket: foo
34 changes: 19 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,33 @@ module github.com/flanksource/template-operator
go 1.13

require (
9fans.net/go v0.0.2 // indirect
github.com/AlekSi/pointer v1.1.0
github.com/flanksource/commons v1.4.0
github.com/ghodss/yaml v1.0.0
github.com/go-logr/logr v0.2.1
github.com/go-logr/zapr v0.2.0
github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31
github.com/flanksource/commons v1.4.3
github.com/flanksource/kommons v0.1.6
github.com/go-logr/logr v0.3.0
github.com/go-logr/zapr v0.3.0 // indirect
github.com/go-openapi/jsonpointer v0.19.3
github.com/go-openapi/spec v0.19.3
github.com/hairyhenderson/gomplate/v3 v3.6.0
github.com/mitchellh/mapstructure v1.1.2
github.com/onsi/ginkgo v1.12.1
github.com/onsi/gomega v1.10.1
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.4.2
github.com/sirupsen/logrus v1.7.0
github.com/tidwall/gjson v1.6.1
golang.org/x/tools v0.0.0-20200616195046-dc31b401abb5 // indirect
gopkg.in/flanksource/yaml.v3 v3.1.1
k8s.io/api v0.19.1
k8s.io/apimachinery v0.19.1
k8s.io/cli-runtime v0.19.1
k8s.io/client-go v11.0.0+incompatible
k8s.io/api v0.19.4
k8s.io/apiextensions-apiserver v0.19.4
k8s.io/apimachinery v0.19.4
k8s.io/cli-runtime v0.19.3
k8s.io/client-go v12.0.0+incompatible
sigs.k8s.io/controller-runtime v0.6.3
sigs.k8s.io/controller-tools v0.4.0 // indirect
sigs.k8s.io/kustomize v2.0.3+incompatible
sigs.k8s.io/yaml v1.2.0
)

replace k8s.io/client-go => k8s.io/client-go v0.19.1
replace (
github.com/Azure/go-autorest => github.com/Azure/go-autorest v13.0.0+incompatible
google.golang.org/genproto => google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb
google.golang.org/grpc => google.golang.org/grpc v1.26.0
k8s.io/client-go => k8s.io/client-go v0.19.4
)
Loading

0 comments on commit 8e6860e

Please sign in to comment.