Skip to content

Commit 37ce5e9

Browse files
authored
Fix adding finalizer and update pkgs (#21)
* Fix adding finalizer and update pkgs * Bump k8s deployment to v0.7.1 * Remove apiextensions from RBAC
1 parent 0489778 commit 37ce5e9

File tree

12 files changed

+118
-111
lines changed

12 files changed

+118
-111
lines changed

cmd/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"syscall"
2626

2727
"github.com/golang/glog"
28-
blended "github.com/inwinstack/blended/client/clientset/versioned"
28+
blended "github.com/inwinstack/blended/generated/clientset/versioned"
2929
"github.com/inwinstack/pa-svc-syncker/pkg/config"
3030
"github.com/inwinstack/pa-svc-syncker/pkg/operator"
3131
"github.com/inwinstack/pa-svc-syncker/pkg/version"
@@ -63,7 +63,7 @@ func parserFlags() {
6363

6464
func restConfig(kubeconfig string) (*rest.Config, error) {
6565
if kubeconfig != "" {
66-
cfg, err := clientcmd.BuildConfigFromFlags("master", kubeconfig)
66+
cfg, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
6767
if err != nil {
6868
return nil, err
6969
}

deploy/deployment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ spec:
2222
serviceAccountName: pa-svc-syncker
2323
containers:
2424
- name: pa-svc-syncker
25-
image: inwinstack/pa-svc-syncker:v0.7.0
25+
image: inwinstack/pa-svc-syncker:v0.7.1
2626
args:
2727
- --v=2
2828
- --logtostderr=true

deploy/rbac.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,6 @@ rules:
1616
- namespaces
1717
verbs:
1818
- "*"
19-
- apiGroups:
20-
- apiextensions.k8s.io
21-
resources:
22-
- customresourcedefinitions
23-
verbs:
24-
- get
25-
- list
26-
- watch
27-
- update
28-
- create
29-
- delete
3019
- apiGroups:
3120
- inwinstack.com
3221
resources:

go.mod

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,18 @@ module github.com/inwinstack/pa-svc-syncker
33
go 1.12
44

55
require (
6-
github.com/davecgh/go-spew v1.1.1 // indirect
7-
github.com/ghodss/yaml v1.0.0 // indirect
8-
github.com/gogo/protobuf v1.2.0 // indirect
96
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
10-
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 // indirect
11-
github.com/google/btree v1.0.0 // indirect
12-
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect
13-
github.com/googleapis/gnostic v0.2.0 // indirect
14-
github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f // indirect
15-
github.com/hashicorp/golang-lru v0.5.0 // indirect
16-
github.com/imdario/mergo v0.3.6 // indirect
17-
github.com/inwinstack/blended v0.6.0
18-
github.com/json-iterator/go v1.1.5 // indirect
19-
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
20-
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 // indirect
21-
github.com/onsi/ginkgo v1.8.0 // indirect
22-
github.com/onsi/gomega v1.5.0 // indirect
23-
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
24-
github.com/spf13/pflag v1.0.3
25-
github.com/stretchr/testify v1.3.0
26-
github.com/thoas/go-funk v0.0.0-20181015191849-9132db0aefe2
27-
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b // indirect
28-
golang.org/x/net v0.0.0-20190119204137-ed066c81e75e // indirect
29-
golang.org/x/sync v0.0.0-20190423024810-112230192c58 // indirect
30-
golang.org/x/sys v0.0.0-20190123074212-c6b37f3e9285 // indirect
31-
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c // indirect
32-
gopkg.in/inf.v0 v0.9.1 // indirect
33-
gopkg.in/yaml.v2 v2.2.2 // indirect
34-
k8s.io/api v0.0.0-20180628040859-072894a440bd
35-
k8s.io/apimachinery v0.0.0-20180621070125-103fd098999d
36-
k8s.io/client-go v8.0.0+incompatible
37-
k8s.io/kube-openapi v0.0.0-20190115222348-ced9eb3070a5 // indirect
7+
github.com/inwinstack/blended v0.7.0
8+
github.com/spf13/pflag v1.0.1
9+
github.com/stretchr/testify v1.2.2
10+
github.com/thoas/go-funk v0.4.0
11+
k8s.io/api v0.0.0-20190620084959-7cf5895f2711
12+
k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719
13+
k8s.io/client-go v0.0.0-20190620085101-78d2af792bab
14+
)
15+
16+
replace (
17+
k8s.io/api => k8s.io/api v0.0.0-20190620084959-7cf5895f2711
18+
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719
19+
k8s.io/client-go => k8s.io/client-go v0.0.0-20190620085101-78d2af792bab
3820
)

go.sum

Lines changed: 91 additions & 52 deletions
Large diffs are not rendered by default.

pkg/constants/constants.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ package constants
3333

3434
const Finalizer = "kubernetes"
3535

36-
const CustomFinalizer = "finalizer.inwinstack.com"
37-
3836
const PolicyPrefix = "k8s"
3937

4038
// Annotation Keys

pkg/operator/namespace/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"time"
2323

2424
"github.com/golang/glog"
25-
blended "github.com/inwinstack/blended/client/clientset/versioned"
25+
blended "github.com/inwinstack/blended/generated/clientset/versioned"
2626
"github.com/inwinstack/pa-svc-syncker/pkg/config"
2727
"github.com/inwinstack/pa-svc-syncker/pkg/operator/service"
2828
"github.com/thoas/go-funk"

pkg/operator/namespace/controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"time"
2424

2525
blendedv1 "github.com/inwinstack/blended/apis/inwinstack/v1"
26-
blendedfake "github.com/inwinstack/blended/client/clientset/versioned/fake"
26+
blendedfake "github.com/inwinstack/blended/generated/clientset/versioned/fake"
2727
"github.com/inwinstack/pa-svc-syncker/pkg/config"
2828
"github.com/inwinstack/pa-svc-syncker/pkg/constants"
2929
"github.com/stretchr/testify/assert"

pkg/operator/operator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"fmt"
2222
"time"
2323

24-
blended "github.com/inwinstack/blended/client/clientset/versioned"
24+
blended "github.com/inwinstack/blended/generated/clientset/versioned"
2525
"github.com/inwinstack/pa-svc-syncker/pkg/config"
2626
"github.com/inwinstack/pa-svc-syncker/pkg/operator/namespace"
2727
"github.com/inwinstack/pa-svc-syncker/pkg/operator/service"

pkg/operator/service/controller.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ import (
2323
"time"
2424

2525
"github.com/golang/glog"
26-
blended "github.com/inwinstack/blended/client/clientset/versioned"
26+
blended "github.com/inwinstack/blended/generated/clientset/versioned"
27+
"github.com/inwinstack/blended/k8sutil"
2728
"github.com/inwinstack/pa-svc-syncker/pkg/config"
2829
"github.com/inwinstack/pa-svc-syncker/pkg/constants"
2930
"github.com/thoas/go-funk"
@@ -222,6 +223,10 @@ func (c *Controller) reconcile(key string) error {
222223
}
223224

224225
svcCopy := service.DeepCopy()
226+
if !funk.ContainsString(svcCopy.Finalizers, constants.Finalizer) {
227+
k8sutil.AddFinalizer(&svcCopy.ObjectMeta, constants.Finalizer)
228+
}
229+
225230
if _, err := c.clientset.CoreV1().Services(svcCopy.Namespace).Update(svcCopy); err != nil {
226231
return err
227232
}
@@ -284,9 +289,7 @@ func (c *Controller) cleanup(svc *v1.Service) error {
284289
}
285290

286291
func (c *Controller) removeFinalizer(svc *v1.Service) error {
287-
svc.ObjectMeta.Finalizers = funk.FilterString(svc.ObjectMeta.Finalizers, func(s string) bool {
288-
return s != constants.Finalizer
289-
})
292+
k8sutil.RemoveFinalizer(&svc.ObjectMeta, constants.Finalizer)
290293
if _, err := c.clientset.CoreV1().Services(svc.Namespace).Update(svc); err != nil {
291294
return err
292295
}

0 commit comments

Comments
 (0)