Skip to content

Commit 58e590f

Browse files
committed
feat: CRD has been GAed after 1.16, upgrade client-go
1 parent 625441b commit 58e590f

64 files changed

Lines changed: 1174 additions & 1319 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
language: go
22

33
go:
4-
- "1.11.4"
5-
6-
env:
7-
- GO111MODULE=on
4+
- "1.22.2"
85

96
jobs:
107
include:

charts/gravity-operator/templates/crd.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: apiextensions.k8s.io/v1beta1
1+
apiVersion: apiextensions.k8s.io/v1
22
kind: CustomResourceDefinition
33
metadata:
44
name: clusters.gravity.mobike.io
@@ -33,7 +33,7 @@ spec:
3333
JSONPath: .status.unavailablePipelines
3434

3535
---
36-
apiVersion: apiextensions.k8s.io/v1beta1
36+
apiVersion: apiextensions.k8s.io/v1
3737
kind: CustomResourceDefinition
3838
metadata:
3939
name: pipelines.gravity.mobike.io

cmd/gatekeeper/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
"k8s.io/client-go/dynamic"
1313
"k8s.io/client-go/rest"
1414

15-
clusterclient "github.com/moiot/gravity-operator/pkg/client/cluster/clientset/versioned"
1615
"github.com/moiot/gravity-operator/pkg/gatekeeper"
16+
clusterclient "github.com/moiot/gravity-operator/pkg/generated/clientset/versioned"
1717
"github.com/moiot/gravity-operator/pkg/signals"
1818
)
1919

@@ -65,7 +65,7 @@ func main() {
6565
}
6666
defer targetDB.Close()
6767

68-
repo := gatekeeper.NewRepository(casePath, operatorAddr, sourceDB, targetDB, clusterClient.GravityV1alpha1().Clusters(namespace))
68+
repo := gatekeeper.NewRepository(casePath, operatorAddr, sourceDB, targetDB, clusterClient.ClusterV1alpha1().Clusters(namespace))
6969
api := gatekeeper.NewApiServer(repo)
7070
api.Start()
7171

cmd/operator/main.go

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ import (
1212
"k8s.io/client-go/tools/clientcmd"
1313

1414
"github.com/moiot/gravity-operator/pkg/apiserver"
15-
clusterclient "github.com/moiot/gravity-operator/pkg/client/cluster/clientset/versioned"
16-
clusterinformer "github.com/moiot/gravity-operator/pkg/client/cluster/informers/externalversions"
17-
pipeclient "github.com/moiot/gravity-operator/pkg/client/pipeline/clientset/versioned"
18-
pipeinformer "github.com/moiot/gravity-operator/pkg/client/pipeline/informers/externalversions"
1915
"github.com/moiot/gravity-operator/pkg/controller"
16+
clientset "github.com/moiot/gravity-operator/pkg/generated/clientset/versioned"
17+
informer "github.com/moiot/gravity-operator/pkg/generated/informers/externalversions"
2018
"github.com/moiot/gravity-operator/pkg/signals"
2119
)
2220

@@ -46,41 +44,34 @@ func main() {
4644
log.Fatalf("Error building kubernetes clientset: %s", err.Error())
4745
}
4846

49-
clusterClient, err := clusterclient.NewForConfig(cfg)
47+
client, err := clientset.NewForConfig(cfg)
5048
if err != nil {
51-
log.Fatalf("Error building cluster client: %s", err.Error())
49+
log.Fatalf("Error building client: %s", err.Error())
5250
}
5351

54-
pipelineClient, err := pipeclient.NewForConfig(cfg)
55-
if err != nil {
56-
log.Fatalf("Error building pipeline client: %s", err.Error())
57-
}
58-
59-
clusterInformerFactory := clusterinformer.NewSharedInformerFactoryWithOptions(clusterClient, time.Second*30, clusterinformer.WithNamespace(namespace))
60-
pipelinesInformerFactory := pipeinformer.NewSharedInformerFactoryWithOptions(pipelineClient, time.Second*30, pipeinformer.WithNamespace(namespace))
52+
informerFactory := informer.NewSharedInformerFactoryWithOptions(client, time.Second*30, informer.WithNamespace(namespace))
6153
kubeInformerFactory := kubeinformers.NewSharedInformerFactoryWithOptions(kubeClient, time.Second*30, kubeinformers.WithNamespace(namespace))
6254

6355
clusterController := controller.NewClusterController(
6456
namespace,
6557
kubeInformerFactory,
6658
kubeClient,
67-
clusterClient,
68-
clusterInformerFactory.Gravity().V1alpha1().Clusters(),
69-
pipelineClient,
70-
pipelinesInformerFactory.Gravity().V1alpha1().Pipelines(),
59+
client,
60+
informerFactory.Cluster().V1alpha1().Clusters(),
61+
client,
62+
informerFactory.Pipeline().V1alpha1().Pipelines(),
7163
)
7264

7365
go kubeInformerFactory.Start(stopCh)
74-
go clusterInformerFactory.Start(stopCh)
75-
go pipelinesInformerFactory.Start(stopCh)
66+
go informerFactory.Start(stopCh)
7667

7768
log.Infof("running controllers")
7869

7970
if err := clusterController.Run(5, stopCh); err != nil {
8071
log.Fatalf("Error running clusterController: %v", err.Error())
8172
}
8273

83-
apiServer := apiserver.NewApiServer(namespace, kubeClient, pipelineClient, clusterController, port)
74+
apiServer := apiserver.NewApiServer(namespace, kubeClient, client, clusterController, port)
8475
apiServer.Start()
8576

8677
<-stopCh

go.mod

Lines changed: 131 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,146 @@
11
module github.com/moiot/gravity-operator
22

3+
go 1.22.2
4+
5+
require (
6+
github.com/gin-gonic/gin v1.9.1
7+
github.com/go-sql-driver/mysql v1.4.1
8+
github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5
9+
github.com/moiot/gravity v0.9.62
10+
github.com/prometheus/client_golang v1.19.0
11+
github.com/sirupsen/logrus v1.2.0
12+
gopkg.in/yaml.v2 v2.4.0
13+
k8s.io/api v0.30.0
14+
k8s.io/apimachinery v0.30.0
15+
k8s.io/client-go v0.30.0
16+
)
17+
318
require (
19+
github.com/BurntSushi/toml v0.3.1 // indirect
420
github.com/DataDog/zstd v1.3.5 // indirect
21+
github.com/OneOfOne/xxhash v1.2.5 // indirect
522
github.com/Shopify/sarama v1.20.1 // indirect
6-
github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7 // indirect
7-
github.com/gin-gonic/gin v1.3.0
8-
github.com/go-sql-driver/mysql v1.4.1
23+
github.com/StackExchange/wmi v0.0.0-20180725035823-b12b22c5341f // indirect
24+
github.com/aws/aws-sdk-go v1.16.11 // indirect
25+
github.com/beorn7/perks v1.0.1 // indirect
26+
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
27+
github.com/bytedance/sonic v1.11.5 // indirect
28+
github.com/bytedance/sonic/loader v0.1.1 // indirect
29+
github.com/cespare/xxhash/v2 v2.2.0 // indirect
30+
github.com/cloudwego/base64x v0.1.3 // indirect
31+
github.com/cloudwego/iasm v0.2.0 // indirect
32+
github.com/coreos/etcd v3.3.10+incompatible // indirect
33+
github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548 // indirect
34+
github.com/davecgh/go-spew v1.1.1 // indirect
35+
github.com/eapache/go-resiliency v1.1.0 // indirect
36+
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
37+
github.com/eapache/queue v1.1.0 // indirect
38+
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
39+
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
40+
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
41+
github.com/gin-contrib/sse v0.1.0 // indirect
42+
github.com/go-logr/logr v1.4.1 // indirect
43+
github.com/go-ole/go-ole v1.2.2 // indirect
44+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
45+
github.com/go-openapi/jsonreference v0.21.0 // indirect
46+
github.com/go-openapi/swag v0.23.0 // indirect
47+
github.com/go-playground/locales v0.14.1 // indirect
48+
github.com/go-playground/universal-translator v0.18.1 // indirect
49+
github.com/go-playground/validator/v10 v10.19.0 // indirect
50+
github.com/go-stack/stack v1.8.0 // indirect
51+
github.com/goccy/go-json v0.10.2 // indirect
952
github.com/gofrs/uuid v3.2.0+incompatible // indirect
10-
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect
11-
github.com/googleapis/gnostic v0.2.0 // indirect
12-
github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f // indirect
53+
github.com/gogo/protobuf v1.3.2 // indirect
54+
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
55+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
56+
github.com/golang/protobuf v1.5.4 // indirect
57+
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
58+
github.com/google/gnostic-models v0.6.8 // indirect
59+
github.com/google/go-cmp v0.6.0 // indirect
60+
github.com/google/gofuzz v1.2.0 // indirect
61+
github.com/google/uuid v1.3.0 // indirect
1362
github.com/grpc-ecosystem/grpc-gateway v1.6.3 // indirect
63+
github.com/hashicorp/go-cleanhttp v0.5.0 // indirect
1464
github.com/hashicorp/go-getter v0.0.0-20190112230949-c68364a1fae1 // indirect
65+
github.com/hashicorp/go-hclog v0.7.0 // indirect
1566
github.com/hashicorp/go-plugin v1.0.0 // indirect
67+
github.com/hashicorp/go-safetemp v1.0.0 // indirect
68+
github.com/hashicorp/go-version v1.0.0 // indirect
69+
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
1670
github.com/imdario/mergo v0.3.6 // indirect
1771
github.com/jinzhu/gorm v1.9.2 // indirect
1872
github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a // indirect
19-
github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5
20-
github.com/modern-go/reflect2 v1.0.1 // indirect
21-
github.com/moiot/gravity v0.9.62
22-
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
23-
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829
73+
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect
74+
github.com/josharian/intern v1.0.0 // indirect
75+
github.com/json-iterator/go v1.1.12 // indirect
76+
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
77+
github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect
78+
github.com/leodido/go-urn v1.4.0 // indirect
79+
github.com/mailru/easyjson v0.7.7 // indirect
80+
github.com/mattn/go-isatty v0.0.20 // indirect
81+
github.com/mitchellh/go-homedir v1.0.0 // indirect
82+
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
83+
github.com/mitchellh/hashstructure v1.0.0 // indirect
84+
github.com/mitchellh/mapstructure v1.1.2 // indirect
85+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
86+
github.com/modern-go/reflect2 v1.0.2 // indirect
87+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
88+
github.com/oklog/run v1.0.0 // indirect
89+
github.com/olivere/elastic v6.2.17+incompatible // indirect
90+
github.com/pelletier/go-toml/v2 v2.2.1 // indirect
91+
github.com/pierrec/lz4 v2.0.5+incompatible // indirect
92+
github.com/pingcap/errors v0.11.0 // indirect
93+
github.com/pingcap/parser v0.0.0-20190118120648-5958b6fcdb2d // indirect
94+
github.com/pingcap/tidb v0.0.0-20190118125846-54b6de0880f0 // indirect
95+
github.com/pingcap/tipb v0.0.0-20181126132056-a7fd2aaa9719 // indirect
96+
github.com/pkg/errors v0.9.1 // indirect
97+
github.com/pmezard/go-difflib v1.0.0 // indirect
98+
github.com/prometheus/client_model v0.5.0 // indirect
99+
github.com/prometheus/common v0.48.0 // indirect
100+
github.com/prometheus/procfs v0.12.0 // indirect
101+
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a // indirect
102+
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446 // indirect
103+
github.com/satori/go.uuid v1.2.0 // indirect
24104
github.com/serialx/hashring v0.0.0-20180504054112-49a4782e9908 // indirect
25-
github.com/sirupsen/logrus v1.2.0
26-
github.com/spf13/pflag v1.0.3 // indirect
27-
github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 // indirect
28-
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
29-
gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
105+
github.com/shirou/gopsutil v2.18.12+incompatible // indirect
106+
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 // indirect
107+
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726 // indirect
108+
github.com/siddontang/go-log v0.0.0-20180807004314-8d05993dda07 // indirect
109+
github.com/siddontang/go-mysql v0.0.0-20190312052122-c6ab05a85eb8 // indirect
110+
github.com/spf13/pflag v1.0.5 // indirect
111+
github.com/stretchr/testify v1.9.0 // indirect
112+
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
113+
github.com/ugorji/go/codec v1.2.12 // indirect
114+
github.com/ulikunitz/xz v0.5.5 // indirect
115+
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect
116+
github.com/xdg/stringprep v1.0.0 // indirect
117+
go.mongodb.org/mongo-driver v1.0.1 // indirect
118+
golang.org/x/arch v0.7.0 // indirect
119+
golang.org/x/crypto v0.22.0 // indirect
120+
golang.org/x/mod v0.17.0 // indirect
121+
golang.org/x/net v0.24.0 // indirect
122+
golang.org/x/oauth2 v0.16.0 // indirect
123+
golang.org/x/sync v0.7.0 // indirect
124+
golang.org/x/sys v0.19.0 // indirect
125+
golang.org/x/term v0.19.0 // indirect
126+
golang.org/x/text v0.14.0 // indirect
127+
golang.org/x/time v0.3.0 // indirect
128+
golang.org/x/tools v0.20.0 // indirect
129+
google.golang.org/appengine v1.6.7 // indirect
130+
google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107 // indirect
131+
google.golang.org/grpc v1.19.0 // indirect
132+
google.golang.org/protobuf v1.33.0 // indirect
30133
gopkg.in/inf.v0 v0.9.1 // indirect
31-
gopkg.in/yaml.v2 v2.2.2
32-
k8s.io/api v0.0.0-20181216230433-16e3e9a3868f
33-
k8s.io/apimachinery v0.0.0-20181203235515-3d8ee2261517
34-
k8s.io/client-go v8.0.0+incompatible
35-
k8s.io/kube-openapi v0.0.0-20181114233023-0317810137be // indirect
134+
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce // indirect
135+
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
136+
gopkg.in/yaml.v3 v3.0.1 // indirect
137+
k8s.io/code-generator v0.30.0 // indirect
138+
k8s.io/gengo v0.0.0-20240404160639-a0386bf69313 // indirect
139+
k8s.io/gengo/v2 v2.0.0-20240404160639-a0386bf69313 // indirect
140+
k8s.io/klog/v2 v2.120.1 // indirect
141+
k8s.io/kube-openapi v0.0.0-20240423202451-8948a665c108 // indirect
142+
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
143+
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
144+
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
145+
sigs.k8s.io/yaml v1.3.0 // indirect
36146
)

0 commit comments

Comments
 (0)