Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: CRD has been GAed after 1.16, upgrade client-go #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
language: go

go:
- "1.11.4"

env:
- GO111MODULE=on
- "1.22.2"

jobs:
include:
Expand Down
4 changes: 2 additions & 2 deletions charts/gravity-operator/templates/crd.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: apiextensions.k8s.io/v1beta1
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: clusters.gravity.mobike.io
Expand Down Expand Up @@ -33,7 +33,7 @@ spec:
JSONPath: .status.unavailablePipelines

---
apiVersion: apiextensions.k8s.io/v1beta1
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: pipelines.gravity.mobike.io
Expand Down
4 changes: 2 additions & 2 deletions cmd/gatekeeper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"k8s.io/client-go/dynamic"
"k8s.io/client-go/rest"

clusterclient "github.com/moiot/gravity-operator/pkg/client/cluster/clientset/versioned"
"github.com/moiot/gravity-operator/pkg/gatekeeper"
clusterclient "github.com/moiot/gravity-operator/pkg/generated/clientset/versioned"
"github.com/moiot/gravity-operator/pkg/signals"
)

Expand Down Expand Up @@ -65,7 +65,7 @@ func main() {
}
defer targetDB.Close()

repo := gatekeeper.NewRepository(casePath, operatorAddr, sourceDB, targetDB, clusterClient.GravityV1alpha1().Clusters(namespace))
repo := gatekeeper.NewRepository(casePath, operatorAddr, sourceDB, targetDB, clusterClient.ClusterV1alpha1().Clusters(namespace))
api := gatekeeper.NewApiServer(repo)
api.Start()

Expand Down
31 changes: 11 additions & 20 deletions cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ import (
"k8s.io/client-go/tools/clientcmd"

"github.com/moiot/gravity-operator/pkg/apiserver"
clusterclient "github.com/moiot/gravity-operator/pkg/client/cluster/clientset/versioned"
clusterinformer "github.com/moiot/gravity-operator/pkg/client/cluster/informers/externalversions"
pipeclient "github.com/moiot/gravity-operator/pkg/client/pipeline/clientset/versioned"
pipeinformer "github.com/moiot/gravity-operator/pkg/client/pipeline/informers/externalversions"
"github.com/moiot/gravity-operator/pkg/controller"
clientset "github.com/moiot/gravity-operator/pkg/generated/clientset/versioned"
informer "github.com/moiot/gravity-operator/pkg/generated/informers/externalversions"
"github.com/moiot/gravity-operator/pkg/signals"
)

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

clusterClient, err := clusterclient.NewForConfig(cfg)
client, err := clientset.NewForConfig(cfg)
if err != nil {
log.Fatalf("Error building cluster client: %s", err.Error())
log.Fatalf("Error building client: %s", err.Error())
}

pipelineClient, err := pipeclient.NewForConfig(cfg)
if err != nil {
log.Fatalf("Error building pipeline client: %s", err.Error())
}

clusterInformerFactory := clusterinformer.NewSharedInformerFactoryWithOptions(clusterClient, time.Second*30, clusterinformer.WithNamespace(namespace))
pipelinesInformerFactory := pipeinformer.NewSharedInformerFactoryWithOptions(pipelineClient, time.Second*30, pipeinformer.WithNamespace(namespace))
informerFactory := informer.NewSharedInformerFactoryWithOptions(client, time.Second*30, informer.WithNamespace(namespace))
kubeInformerFactory := kubeinformers.NewSharedInformerFactoryWithOptions(kubeClient, time.Second*30, kubeinformers.WithNamespace(namespace))

clusterController := controller.NewClusterController(
namespace,
kubeInformerFactory,
kubeClient,
clusterClient,
clusterInformerFactory.Gravity().V1alpha1().Clusters(),
pipelineClient,
pipelinesInformerFactory.Gravity().V1alpha1().Pipelines(),
client,
informerFactory.Cluster().V1alpha1().Clusters(),
client,
informerFactory.Pipeline().V1alpha1().Pipelines(),
)

go kubeInformerFactory.Start(stopCh)
go clusterInformerFactory.Start(stopCh)
go pipelinesInformerFactory.Start(stopCh)
go informerFactory.Start(stopCh)

log.Infof("running controllers")

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

apiServer := apiserver.NewApiServer(namespace, kubeClient, pipelineClient, clusterController, port)
apiServer := apiserver.NewApiServer(namespace, kubeClient, client, clusterController, port)
apiServer.Start()

<-stopCh
Expand Down
152 changes: 131 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,36 +1,146 @@
module github.com/moiot/gravity-operator

go 1.22.2

require (
github.com/gin-gonic/gin v1.9.1
github.com/go-sql-driver/mysql v1.4.1
github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5
github.com/moiot/gravity v0.9.62
github.com/prometheus/client_golang v1.19.0
github.com/sirupsen/logrus v1.2.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.30.0
k8s.io/apimachinery v0.30.0
k8s.io/client-go v0.30.0
)

require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/DataDog/zstd v1.3.5 // indirect
github.com/OneOfOne/xxhash v1.2.5 // indirect
github.com/Shopify/sarama v1.20.1 // indirect
github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7 // indirect
github.com/gin-gonic/gin v1.3.0
github.com/go-sql-driver/mysql v1.4.1
github.com/StackExchange/wmi v0.0.0-20180725035823-b12b22c5341f // indirect
github.com/aws/aws-sdk-go v1.16.11 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bytedance/sonic v1.11.5 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cloudwego/base64x v0.1.3 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/coreos/etcd v3.3.10+incompatible // indirect
github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/eapache/go-resiliency v1.1.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-ole/go-ole v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.19.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gofrs/uuid v3.2.0+incompatible // indirect
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect
github.com/googleapis/gnostic v0.2.0 // indirect
github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.6.3 // indirect
github.com/hashicorp/go-cleanhttp v0.5.0 // indirect
github.com/hashicorp/go-getter v0.0.0-20190112230949-c68364a1fae1 // indirect
github.com/hashicorp/go-hclog v0.7.0 // indirect
github.com/hashicorp/go-plugin v1.0.0 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.0.0 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/jinzhu/gorm v1.9.2 // indirect
github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a // indirect
github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/moiot/gravity v0.9.62
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/go-homedir v1.0.0 // indirect
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/mitchellh/hashstructure v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/olivere/elastic v6.2.17+incompatible // indirect
github.com/pelletier/go-toml/v2 v2.2.1 // indirect
github.com/pierrec/lz4 v2.0.5+incompatible // indirect
github.com/pingcap/errors v0.11.0 // indirect
github.com/pingcap/parser v0.0.0-20190118120648-5958b6fcdb2d // indirect
github.com/pingcap/tidb v0.0.0-20190118125846-54b6de0880f0 // indirect
github.com/pingcap/tipb v0.0.0-20181126132056-a7fd2aaa9719 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a // indirect
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446 // indirect
github.com/satori/go.uuid v1.2.0 // indirect
github.com/serialx/hashring v0.0.0-20180504054112-49a4782e9908 // indirect
github.com/sirupsen/logrus v1.2.0
github.com/spf13/pflag v1.0.3 // indirect
github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
github.com/shirou/gopsutil v2.18.12+incompatible // indirect
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 // indirect
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726 // indirect
github.com/siddontang/go-log v0.0.0-20180807004314-8d05993dda07 // indirect
github.com/siddontang/go-mysql v0.0.0-20190312052122-c6ab05a85eb8 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/ulikunitz/xz v0.5.5 // indirect
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect
github.com/xdg/stringprep v1.0.0 // indirect
go.mongodb.org/mongo-driver v1.0.1 // indirect
golang.org/x/arch v0.7.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.20.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107 // indirect
google.golang.org/grpc v1.19.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.2.2
k8s.io/api v0.0.0-20181216230433-16e3e9a3868f
k8s.io/apimachinery v0.0.0-20181203235515-3d8ee2261517
k8s.io/client-go v8.0.0+incompatible
k8s.io/kube-openapi v0.0.0-20181114233023-0317810137be // indirect
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/code-generator v0.30.0 // indirect
k8s.io/gengo v0.0.0-20240404160639-a0386bf69313 // indirect
k8s.io/gengo/v2 v2.0.0-20240404160639-a0386bf69313 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240423202451-8948a665c108 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading