未验证 提交 cf162559 编写于 作者: Z Zhengyi Lai

Refactor with OpenPitrix

Signed-off-by: Zhengyi Lai <zheng1@yunify.com> (+2 squashed commits)
上级 55354bf2
......@@ -69,6 +69,9 @@ deploy: manifests
generate:
go generate ./pkg/... ./cmd/...
mockgen:
mockgen -package=openpitrix -source=pkg/simple/client/openpitrix/openpitrix.go -destination=pkg/simple/client/openpitrix/mock.go
deepcopy:
GO111MODULE=on go install -mod=vendor k8s.io/code-generator/cmd/deepcopy-gen
${GOPATH}/bin/deepcopy-gen -i kubesphere.io/kubesphere/pkg/apis/... -h ./hack/boilerplate.go.txt -O zz_generated.deepcopy
......
......@@ -95,7 +95,7 @@ require (
k8s.io/klog v1.0.0
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a
k8s.io/kubectl v0.17.3
openpitrix.io/openpitrix v0.4.1-0.20190920134345-4d2be6e4965c
openpitrix.io/openpitrix v0.4.9-0.20200611125425-ae07f141e797
sigs.k8s.io/controller-runtime v0.5.0
sigs.k8s.io/controller-tools v0.2.4
sigs.k8s.io/kubefed v0.2.0-alpha.1
......@@ -114,13 +114,20 @@ replace (
github.com/Azure/go-autorest/tracing => github.com/Azure/go-autorest/tracing v0.5.0
github.com/BurntSushi/toml => github.com/BurntSushi/toml v0.3.1
github.com/MakeNowJust/heredoc => github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd
github.com/Masterminds/goutils => github.com/Masterminds/goutils v1.1.0
github.com/Masterminds/semver => github.com/Masterminds/semver v1.5.0
github.com/Masterminds/semver/v3 => github.com/Masterminds/semver/v3 v3.0.1
github.com/Masterminds/sprig/v3 => github.com/Masterminds/sprig/v3 v3.0.0
github.com/Masterminds/vcs => github.com/Masterminds/vcs v1.13.0
github.com/Microsoft/go-winio => github.com/Microsoft/go-winio v0.4.12
github.com/Microsoft/hcsshim => github.com/Microsoft/hcsshim v0.8.6
github.com/NYTimes/gziphandler => github.com/NYTimes/gziphandler v1.1.1
github.com/Nvveen/Gotty => github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5
github.com/OneOfOne/xxhash => github.com/OneOfOne/xxhash v1.2.2
github.com/PuerkitoBio/goquery => github.com/PuerkitoBio/goquery v1.5.0
github.com/PuerkitoBio/purell => github.com/PuerkitoBio/purell v1.1.1
github.com/PuerkitoBio/urlesc => github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578
github.com/Shopify/logrus-bugsnag => github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d
github.com/StackExchange/wmi => github.com/StackExchange/wmi v0.0.0-20170410192909-ea383cf3ba6e
github.com/alcortesm/tgz => github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7
github.com/alecthomas/template => github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc
......@@ -136,11 +143,17 @@ replace (
github.com/bitly/go-simplejson => github.com/bitly/go-simplejson v0.5.0
github.com/blang/semver => github.com/blang/semver v3.5.0+incompatible
github.com/bmizerany/assert => github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869
github.com/bshuster-repo/logrus-logstash-hook => github.com/bshuster-repo/logrus-logstash-hook v0.4.1
github.com/bugsnag/bugsnag-go => github.com/bugsnag/bugsnag-go v1.5.0
github.com/bugsnag/panicwrap => github.com/bugsnag/panicwrap v1.2.0
github.com/cespare/xxhash => github.com/cespare/xxhash v1.1.0
github.com/chai2010/gettext-go => github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5
github.com/chai2010/jsonmap => github.com/chai2010/jsonmap v1.0.0
github.com/client9/misspell => github.com/client9/misspell v0.3.4
github.com/cockroachdb/datadriven => github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa
github.com/container-storage-interface/spec => github.com/container-storage-interface/spec v1.2.0
github.com/containerd/containerd => github.com/containerd/containerd v1.3.0
github.com/containerd/continuity => github.com/containerd/continuity v0.0.0-20181203112020-004b46473808
github.com/coreos/bbolt => github.com/coreos/bbolt v1.3.3
github.com/coreos/etcd => github.com/coreos/etcd v3.3.17+incompatible
github.com/coreos/go-oidc => github.com/coreos/go-oidc v2.1.0+incompatible
......@@ -149,15 +162,22 @@ replace (
github.com/coreos/pkg => github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f
github.com/cpuguy83/go-md2man => github.com/cpuguy83/go-md2man v1.0.10
github.com/creack/pty => github.com/creack/pty v1.1.7
github.com/cyphar/filepath-securejoin => github.com/cyphar/filepath-securejoin v0.2.2
github.com/davecgh/go-spew => github.com/davecgh/go-spew v1.1.1
github.com/daviddengcn/go-colortext => github.com/daviddengcn/go-colortext v0.0.0-20160507010035-511bcaf42ccd
github.com/deckarep/golang-set => github.com/deckarep/golang-set v1.7.1
github.com/deislabs/oras => github.com/deislabs/oras v0.7.0
github.com/denisenkom/go-mssqldb => github.com/denisenkom/go-mssqldb v0.0.0-20190204142019-df6d76eb9289
github.com/dgrijalva/jwt-go => github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/disintegration/imaging => github.com/disintegration/imaging v1.6.1
github.com/docker/cli => github.com/docker/cli v0.0.0-20190506213505-d88565df0c2d
github.com/docker/distribution => github.com/docker/distribution v2.7.1+incompatible
github.com/docker/docker => github.com/docker/engine v1.4.2-0.20190822205725-ed20165a37b4
github.com/docker/docker-credential-helpers => github.com/docker/docker-credential-helpers v0.6.1
github.com/docker/go-connections => github.com/docker/go-connections v0.3.0
github.com/docker/go-metrics => github.com/docker/go-metrics v0.0.0-20181218153428-b84716841b82
github.com/docker/go-units => github.com/docker/go-units v0.3.3
github.com/docker/libtrust => github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7
github.com/docker/spdystream => github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c
github.com/docopt/docopt-go => github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
github.com/dustin/go-humanize => github.com/dustin/go-humanize v1.0.0
......@@ -177,7 +197,10 @@ replace (
github.com/fatih/structs => github.com/fatih/structs v1.1.0
github.com/flynn/go-shlex => github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568
github.com/fsnotify/fsnotify => github.com/fsnotify/fsnotify v1.4.7
github.com/garyburd/redigo => github.com/garyburd/redigo v1.6.0
github.com/ghodss/yaml => github.com/ghodss/yaml v1.0.0
github.com/gin-contrib/sse => github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.4.0
github.com/gliderlabs/ssh => github.com/gliderlabs/ssh v0.1.1
github.com/globalsign/mgo => github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8
github.com/go-kit/kit => github.com/go-kit/kit v0.8.0
......@@ -204,6 +227,7 @@ replace (
github.com/gobuffalo/flect => github.com/gobuffalo/flect v0.1.5
github.com/gobwas/glob => github.com/gobwas/glob v0.2.3
github.com/gocraft/dbr => github.com/gocraft/dbr v0.0.0-20180507214907-a0fd650918f6
github.com/gofrs/flock => github.com/gofrs/flock v0.7.1
github.com/gofrs/uuid => github.com/gofrs/uuid v3.2.0+incompatible
github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.0
github.com/golang/example => github.com/golang/example v0.0.0-20170904185048-46695d81d1fa
......@@ -226,8 +250,10 @@ replace (
github.com/googleapis/gax-go/v2 => github.com/googleapis/gax-go/v2 v2.0.4
github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.3.1
github.com/gophercloud/gophercloud => github.com/gophercloud/gophercloud v0.3.0
github.com/gorilla/handlers => github.com/gorilla/handlers v1.4.0
github.com/gorilla/mux => github.com/gorilla/mux v1.7.1
github.com/gorilla/websocket => github.com/gorilla/websocket v1.4.0
github.com/gosuri/uitable => github.com/gosuri/uitable v0.0.1
github.com/gregjones/httpcache => github.com/gregjones/httpcache v0.0.0-20170728041850-787624de3eb7
github.com/grpc-ecosystem/go-grpc-middleware => github.com/grpc-ecosystem/go-grpc-middleware v1.0.0
github.com/grpc-ecosystem/go-grpc-prometheus => github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
......@@ -236,6 +262,7 @@ replace (
github.com/hashicorp/golang-lru => github.com/hashicorp/golang-lru v0.5.3
github.com/hashicorp/hcl => github.com/hashicorp/hcl v1.0.0
github.com/hpcloud/tail => github.com/hpcloud/tail v1.0.0
github.com/huandu/xstrings => github.com/huandu/xstrings v1.2.0
github.com/imdario/mergo => github.com/imdario/mergo v0.3.7
github.com/inconshreveable/mousetrap => github.com/inconshreveable/mousetrap v1.0.0
github.com/jbenet/go-context => github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99
......@@ -275,11 +302,15 @@ replace (
github.com/mattn/go-colorable => github.com/mattn/go-colorable v0.1.2
github.com/mattn/go-isatty => github.com/mattn/go-isatty v0.0.8
github.com/mattn/go-runewidth => github.com/mattn/go-runewidth v0.0.0-20181025052659-b20a3daf6a39
github.com/mattn/go-shellwords => github.com/mattn/go-shellwords v1.0.5
github.com/mattn/go-sqlite3 => github.com/mattn/go-sqlite3 v1.11.0
github.com/matttproud/golang_protobuf_extensions => github.com/matttproud/golang_protobuf_extensions v1.0.1
github.com/miekg/dns => github.com/miekg/dns v0.0.0-20181005163659-0d29b283ac0f
github.com/mitchellh/copystructure => github.com/mitchellh/copystructure v1.0.0
github.com/mitchellh/go-homedir => github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/go-wordwrap => github.com/mitchellh/go-wordwrap v1.0.0
github.com/mitchellh/mapstructure => github.com/mitchellh/mapstructure v1.1.2
github.com/mitchellh/reflectwalk => github.com/mitchellh/reflectwalk v1.0.0
github.com/mna/pigeon => github.com/mna/pigeon v0.0.0-20180808201053-bb0192cfc2ae
github.com/modern-go/concurrent => github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
github.com/modern-go/reflect2 => github.com/modern-go/reflect2 v1.0.1
......@@ -293,6 +324,7 @@ replace (
github.com/open-policy-agent/opa => github.com/open-policy-agent/opa v0.18.0
github.com/opencontainers/go-digest => github.com/opencontainers/go-digest v1.0.0-rc1
github.com/opencontainers/image-spec => github.com/opencontainers/image-spec v1.0.1
github.com/opencontainers/runc => github.com/opencontainers/runc v0.1.1
github.com/openshift/api => github.com/openshift/api v0.0.0-20180801171038-322a19404e37
github.com/openshift/generic-admission-server => github.com/openshift/generic-admission-server v1.14.0
github.com/opentracing/opentracing-go => github.com/opentracing/opentracing-go v1.1.0
......@@ -302,6 +334,7 @@ replace (
github.com/pelletier/go-toml => github.com/pelletier/go-toml v1.2.0
github.com/peterbourgon/diskv => github.com/peterbourgon/diskv v2.0.1+incompatible
github.com/peterh/liner => github.com/peterh/liner v0.0.0-20170211195444-bf27d3ba8e1d
github.com/phayes/freeport => github.com/phayes/freeport v0.0.0-20171002181615-b8543db493a5
github.com/philhofer/fwd => github.com/philhofer/fwd v1.0.0
github.com/pkg/errors => github.com/pkg/errors v0.8.1
github.com/pmezard/go-difflib => github.com/pmezard/go-difflib v1.0.0
......@@ -319,6 +352,7 @@ replace (
github.com/prometheus/prometheus => github.com/prometheus/prometheus v1.8.2
github.com/rcrowley/go-metrics => github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a
github.com/remyoudompheng/bigfft => github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446
github.com/robfig/cron => github.com/robfig/cron v1.2.0
github.com/rogpeppe/fastuuid => github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af
github.com/rogpeppe/go-charset => github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4
github.com/russross/blackfriday => github.com/russross/blackfriday v1.5.2
......@@ -344,13 +378,21 @@ replace (
github.com/tinylib/msgp => github.com/tinylib/msgp v1.1.0
github.com/tmc/grpc-websocket-proxy => github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5
github.com/ugorji/go => github.com/ugorji/go v1.1.4
github.com/ugorji/go/codec => github.com/ugorji/go/codec v0.0.0-20190128213124-ee1426cffec0
github.com/urfave/cli => github.com/urfave/cli v1.20.0
github.com/xanzy/ssh-agent => github.com/xanzy/ssh-agent v0.2.1
github.com/xeipuuv/gojsonpointer => github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f
github.com/xeipuuv/gojsonreference => github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415
github.com/xeipuuv/gojsonschema => github.com/xeipuuv/gojsonschema v1.2.0
github.com/xenolf/lego => github.com/xenolf/lego v0.3.2-0.20160613233155-a9d8cec0e656
github.com/xiang90/probing => github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2
github.com/xlab/handysort => github.com/xlab/handysort v0.0.0-20150421192137-fb3537ed64a1
github.com/xlab/treeprint => github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6
github.com/xordataexchange/crypt => github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77
github.com/yashtewari/glob-intersection => github.com/yashtewari/glob-intersection v0.0.0-20180916065949-5c77d914dd0b
github.com/yvasiyarov/go-metrics => github.com/yvasiyarov/go-metrics v0.0.0-20150112132944-c25f46c4b940
github.com/yvasiyarov/gorelic => github.com/yvasiyarov/gorelic v0.0.6
github.com/yvasiyarov/newrelic_platform_go => github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f
go.etcd.io/bbolt => go.etcd.io/bbolt v1.3.3
go.etcd.io/etcd => go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738
go.opencensus.io => go.opencensus.io v0.21.0
......@@ -359,6 +401,7 @@ replace (
go.uber.org/zap => go.uber.org/zap v1.10.0
golang.org/x/crypto => golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
golang.org/x/exp => golang.org/x/exp v0.0.0-20190121172915-509febef88a4
golang.org/x/image => golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81
golang.org/x/lint => golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f
golang.org/x/net => golang.org/x/net v0.0.0-20190620200207-3b0461eec859
golang.org/x/oauth2 => golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a
......@@ -377,16 +420,21 @@ replace (
google.golang.org/grpc => google.golang.org/grpc v1.23.1
gopkg.in/airbrake/gobrake.v2 => gopkg.in/airbrake/gobrake.v2 v2.0.9
gopkg.in/alecthomas/kingpin.v2 => gopkg.in/alecthomas/kingpin.v2 v2.2.6
gopkg.in/alexcesaro/quotedprintable.v3 => gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc
gopkg.in/asn1-ber.v1 => gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d
gopkg.in/check.v1 => gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15
gopkg.in/cheggaaa/pb.v1 => gopkg.in/cheggaaa/pb.v1 v1.0.25
gopkg.in/fsnotify.v1 => gopkg.in/fsnotify.v1 v1.4.7
gopkg.in/gemnasium/logrus-airbrake-hook.v2 => gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2
gopkg.in/go-playground/assert.v1 => gopkg.in/go-playground/assert.v1 v1.2.1
gopkg.in/go-playground/validator.v8 => gopkg.in/go-playground/validator.v8 v8.18.2
gopkg.in/go-playground/validator.v9 => gopkg.in/go-playground/validator.v9 v9.29.1
gopkg.in/gomail.v2 => gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/inf.v0 => gopkg.in/inf.v0 v0.9.1
gopkg.in/mail.v2 => gopkg.in/mail.v2 v2.3.1
gopkg.in/natefinch/lumberjack.v2 => gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/resty.v1 => gopkg.in/resty.v1 v1.12.0
gopkg.in/square/go-jose.v1 => gopkg.in/square/go-jose.v1 v1.1.2
gopkg.in/square/go-jose.v2 => gopkg.in/square/go-jose.v2 v2.3.1
gopkg.in/src-d/go-billy.v4 => gopkg.in/src-d/go-billy.v4 v4.3.0
gopkg.in/src-d/go-git-fixtures.v3 => gopkg.in/src-d/go-git-fixtures.v3 v3.1.1
......@@ -398,6 +446,7 @@ replace (
gopkg.in/yaml.v2 => gopkg.in/yaml.v2 v2.2.8
gopkg.in/yaml.v3 => gopkg.in/yaml.v3 v3.0.0-20190905181640-827449938966
gotest.tools => gotest.tools v2.2.0+incompatible
helm.sh/helm/v3 => helm.sh/helm/v3 v3.0.1
honnef.co/go/tools => honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc
istio.io/api => istio.io/api v0.0.0-20191111210003-35e06ef8d838
istio.io/client-go => istio.io/client-go v0.0.0-20191113122552-9bd0ba57c3d2
......@@ -425,10 +474,12 @@ replace (
modernc.org/strutil => modernc.org/strutil v1.0.0
modernc.org/xc => modernc.org/xc v1.0.0
openpitrix.io/iam => openpitrix.io/iam v0.1.0
openpitrix.io/libqueue => openpitrix.io/libqueue v0.4.1
openpitrix.io/logger => openpitrix.io/logger v0.1.0
openpitrix.io/openpitrix => github.com/pengcong06/openpitrix v0.4.1-0.20200527062040-411ab8612348
openpitrix.io/openpitrix v0.4.1-0.20190920134345-4d2be6e4965c => openpitrix.io/openpitrix v0.4.9-0.20200610105301-68151bb90d21
openpitrix.io/notification => openpitrix.io/notification v0.2.2
openpitrix.io/openpitrix => openpitrix.io/openpitrix v0.4.9-0.20200611125425-ae07f141e797
rsc.io/goversion => rsc.io/goversion v1.0.0
rsc.io/letsencrypt => rsc.io/letsencrypt v0.0.1
sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.4.0
sigs.k8s.io/controller-tools => sigs.k8s.io/controller-tools v0.2.4
sigs.k8s.io/kubefed => sigs.k8s.io/kubefed v0.2.0-alpha.1
......
......@@ -72,7 +72,6 @@ github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa h1:OaNxuTZr
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
github.com/container-storage-interface/spec v1.2.0 h1:bD9KIVgaVKKkQ/UbVUY9kCaH/CJbhNxe0eeB4JeJV2s=
github.com/container-storage-interface/spec v1.2.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4=
github.com/containerd/containerd v1.3.0-beta.2.0.20190823190603-4a2f61c4f2b4/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/containerd/containerd v1.3.0/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/containerd/continuity v0.0.0-20181203112020-004b46473808/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/coreos/bbolt v1.3.3 h1:n6AiVyVRKQFNb6mJlwESEvvLoDyiTzXX7ORAUlkeBdY=
......@@ -148,9 +147,7 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
github.com/garyburd/redigo v1.6.0/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gin-contrib/sse v0.0.0-20190125020943-a7658810eb74/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
github.com/gin-gonic/gin v1.3.0/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y=
github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM=
github.com/gliderlabs/ssh v0.1.1 h1:j3L6gSLQalDETeEg/Jg0mGY0/y/N6zI2xX1978P0Uqw=
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
......@@ -448,9 +445,7 @@ github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.1.0/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
github.com/xenolf/lego v0.0.0-20160613233155-a9d8cec0e656/go.mod h1:fwiGnfsIjG7OHPfOvgK7Y/Qo6+2Ox0iozjNTkZICKbY=
github.com/xenolf/lego v0.3.2-0.20160613233155-a9d8cec0e656/go.mod h1:fwiGnfsIjG7OHPfOvgK7Y/Qo6+2Ox0iozjNTkZICKbY=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
......@@ -596,8 +591,8 @@ openpitrix.io/iam v0.1.0/go.mod h1:EcZE8CPBg+1fEKCDEhpsIZ8isWWO7javpu84mSqoVn4=
openpitrix.io/libqueue v0.4.1/go.mod h1:qUuS2viIR86Fm1rLfLRFMMAyltUeGxNt8zoCNkmf/Gk=
openpitrix.io/logger v0.1.0/go.mod h1:SV8Btt2cTSmeL9H/1XCkYmQ+WQ2upVY4e0wlr07RP28=
openpitrix.io/notification v0.2.2/go.mod h1:2YRxpnrFk2Z3fXpRXWzbDY9j6Sztrd860Vm8qh5hZzY=
openpitrix.io/openpitrix v0.4.9-0.20200610105301-68151bb90d21 h1:MUCblqyJK8dX7WYUAiyN7vzpchn+6GYS7pSYVbJHmJ4=
openpitrix.io/openpitrix v0.4.9-0.20200610105301-68151bb90d21/go.mod h1:sLaDrxic8mrYWWJop4GkBSRwQ0AqVIy7TZzbCOynr8o=
openpitrix.io/openpitrix v0.4.9-0.20200611125425-ae07f141e797 h1:zWzbsWTu2wKovmSXqFgsQTDN7Ckx9TBiD9SQ9qDWQpg=
openpitrix.io/openpitrix v0.4.9-0.20200611125425-ae07f141e797/go.mod h1:sLaDrxic8mrYWWJop4GkBSRwQ0AqVIy7TZzbCOynr8o=
rsc.io/goversion v1.0.0/go.mod h1:Eih9y/uIBS3ulggl7KNJ09xGSLcuNaLgmvvqa07sgfo=
rsc.io/letsencrypt v0.0.1/go.mod h1:buyQKZ6IXrRnB7TdkHP0RyEybLx18HHyOSoTyoOLqNY=
sigs.k8s.io/controller-runtime v0.4.0 h1:wATM6/m+3w8lj8FXNaO6Fs/rq/vqoOjO1Q116Z9NPsg=
......
......@@ -18,8 +18,6 @@ package namespace
import (
"context"
"fmt"
"github.com/golang/protobuf/ptypes/wrappers"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
......@@ -31,7 +29,6 @@ import (
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"openpitrix.io/openpitrix/pkg/pb"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
......@@ -130,11 +127,6 @@ func (r *ReconcileNamespace) Reconcile(request reconcile.Request) (reconcile.Res
return reconcile.Result{}, err
}
// delete runtime
if err = r.deleteRuntime(instance); err != nil {
return reconcile.Result{}, err
}
// remove our finalizer from the list and update it.
instance.ObjectMeta.Finalizers = sliceutil.RemoveString(instance.ObjectMeta.Finalizers, func(item string) bool {
return item == finalizer
......@@ -153,13 +145,6 @@ func (r *ReconcileNamespace) Reconcile(request reconcile.Request) (reconcile.Res
return reconcile.Result{}, err
}
// skip if openpitrix is not enabled
if r.openpitrixClient != nil {
if err := r.checkAndCreateRuntime(instance); err != nil {
return reconcile.Result{}, err
}
}
return reconcile.Result{}, nil
}
......@@ -175,88 +160,6 @@ func (r *ReconcileNamespace) isControlledByWorkspace(namespace *corev1.Namespace
return true, nil
}
// Create openpitrix runtime
func (r *ReconcileNamespace) checkAndCreateRuntime(namespace *corev1.Namespace) error {
if runtimeId := namespace.Annotations[constants.OpenPitrixRuntimeAnnotationKey]; runtimeId != "" {
return nil
}
adminKubeConfigName := fmt.Sprintf("kubeconfig-%s", constants.AdminUserName)
runtimeCredentials, err := r.openpitrixClient.DescribeRuntimeCredentials(openpitrix.SystemContext(), &pb.DescribeRuntimeCredentialsRequest{SearchWord: &wrappers.StringValue{Value: adminKubeConfigName}, Limit: 1})
if err != nil {
klog.Error(fmt.Sprintf("create runtime, namespace: %s, error: %s", namespace.Name, err))
return err
}
var kubesphereRuntimeCredentialId string
// runtime credential exist
if len(runtimeCredentials.GetRuntimeCredentialSet()) > 0 {
kubesphereRuntimeCredentialId = runtimeCredentials.GetRuntimeCredentialSet()[0].GetRuntimeCredentialId().GetValue()
} else {
adminKubeConfig := corev1.ConfigMap{}
err := r.Get(context.TODO(), types.NamespacedName{Namespace: constants.KubeSphereControlNamespace, Name: adminKubeConfigName}, &adminKubeConfig)
if err != nil {
klog.Error(fmt.Sprintf("create runtime, namespace: %s, error: %s", namespace.Name, err))
return err
}
resp, err := r.openpitrixClient.CreateRuntimeCredential(openpitrix.SystemContext(), &pb.CreateRuntimeCredentialRequest{
Name: &wrappers.StringValue{Value: adminKubeConfigName},
Provider: &wrappers.StringValue{Value: "kubernetes"},
Description: &wrappers.StringValue{Value: "kubeconfig"},
RuntimeUrl: &wrappers.StringValue{Value: "kubesphere"},
RuntimeCredentialContent: &wrappers.StringValue{Value: adminKubeConfig.Data["config"]},
})
if err != nil {
klog.Error(fmt.Sprintf("create runtime, namespace: %s, error: %s", namespace.Name, err))
return err
}
kubesphereRuntimeCredentialId = resp.GetRuntimeCredentialId().GetValue()
}
// TODO runtime id is invalid when recreate runtime
runtimeId, err := r.openpitrixClient.CreateRuntime(openpitrix.SystemContext(), &pb.CreateRuntimeRequest{
Name: &wrappers.StringValue{Value: namespace.Name},
RuntimeCredentialId: &wrappers.StringValue{Value: kubesphereRuntimeCredentialId},
Provider: &wrappers.StringValue{Value: openpitrix.KubernetesProvider},
Zone: &wrappers.StringValue{Value: namespace.Name},
})
if err != nil {
klog.Error(fmt.Sprintf("create runtime, namespace: %s, error: %s", namespace.Name, err))
return err
}
klog.V(4).Infof("runtime created successfully, namespace: %s, runtime id: %s", namespace.Name, runtimeId)
return nil
}
// Delete openpitrix runtime
func (r *ReconcileNamespace) deleteRuntime(namespace *corev1.Namespace) error {
if runtimeId := namespace.Annotations[constants.OpenPitrixRuntimeAnnotationKey]; runtimeId != "" {
_, err := r.openpitrixClient.DeleteRuntimes(openpitrix.SystemContext(), &pb.DeleteRuntimesRequest{RuntimeId: []string{runtimeId}, Force: &wrappers.BoolValue{Value: true}})
if err == nil || openpitrix.IsNotFound(err) || openpitrix.IsDeleted(err) {
return nil
} else {
klog.Errorf("delete openpitrix runtime: %s, error: %s", runtimeId, err)
return err
}
}
return nil
}
// Create openpitrix runtime
func (r *ReconcileNamespace) checkAndBindWorkspace(namespace *corev1.Namespace) error {
workspaceName := namespace.Labels[constants.WorkspaceLabelKey]
......
......@@ -44,39 +44,40 @@ func newOpenpitrixHandler(factory informers.InformerFactory, opClient op.Client)
}
}
func (h *openpitrixHandler) ListApplications(request *restful.Request, response *restful.Response) {
limit, offset := params.ParsePaging(request)
runtimeId := request.PathParameter("runtime")
namespace := request.PathParameter("namespace")
orderBy := params.GetStringValueWithDefault(request, params.OrderByParam, openpitrix.CreateTime)
reverse := params.GetBoolValueWithDefault(request, params.ReverseParam, false)
conditions, err := params.ParseConditions(request)
func (h *openpitrixHandler) ListApplications(req *restful.Request, resp *restful.Response) {
limit, offset := params.ParsePaging(req)
clusterName := req.PathParameter("cluster")
namespace := req.PathParameter("namespace")
orderBy := params.GetStringValueWithDefault(req, params.OrderByParam, openpitrix.CreateTime)
reverse := params.GetBoolValueWithDefault(req, params.ReverseParam, false)
conditions, err := params.ParseConditions(req)
if err != nil {
klog.V(4).Infoln(err)
api.HandleBadRequest(response, nil, err)
api.HandleBadRequest(resp, nil, err)
return
}
conditions.Match[openpitrix.Zone] = namespace
conditions.Match[openpitrix.RuntimeId] = runtimeId
// in openpitrix, runtime id is the cluster name
conditions.Match[openpitrix.RuntimeId] = clusterName
result, err := h.openpitrix.ListApplications(conditions, limit, offset, orderBy, reverse)
if err != nil {
klog.Errorln(err)
api.HandleInternalError(response, nil, err)
api.HandleInternalError(resp, nil, err)
return
}
response.WriteAsJson(result)
resp.WriteAsJson(result)
}
func (h *openpitrixHandler) DescribeApplication(req *restful.Request, resp *restful.Response) {
runtimeId := req.PathParameter("runtime")
clusterName := req.PathParameter("cluster")
namespace := req.PathParameter("namespace")
clusterId := req.PathParameter("application")
applicationId := req.PathParameter("application")
app, err := h.openpitrix.DescribeApplication(namespace, clusterId, runtimeId)
app, err := h.openpitrix.DescribeApplication(namespace, applicationId, clusterName)
if err != nil {
klog.Errorln(err)
......@@ -89,7 +90,7 @@ func (h *openpitrixHandler) DescribeApplication(req *restful.Request, resp *rest
}
func (h *openpitrixHandler) CreateApplication(req *restful.Request, resp *restful.Response) {
runtimeId := req.PathParameter("runtime")
clusterName := req.PathParameter("cluster")
namespace := req.PathParameter("namespace")
var createClusterRequest openpitrix.CreateClusterRequest
err := req.ReadEntity(&createClusterRequest)
......@@ -101,7 +102,7 @@ func (h *openpitrixHandler) CreateApplication(req *restful.Request, resp *restfu
createClusterRequest.Username = req.HeaderParameter(constants.UserNameHeader)
err = h.openpitrix.CreateApplication(runtimeId, namespace, createClusterRequest)
err = h.openpitrix.CreateApplication(clusterName, namespace, createClusterRequest)
if err != nil {
klog.Errorln(err)
......@@ -114,8 +115,8 @@ func (h *openpitrixHandler) CreateApplication(req *restful.Request, resp *restfu
func (h *openpitrixHandler) ModifyApplication(req *restful.Request, resp *restful.Response) {
var modifyClusterAttributesRequest openpitrix.ModifyClusterAttributesRequest
runtimeId := req.PathParameter("runtime")
clusterId := req.PathParameter("application")
clusterName := req.PathParameter("cluster")
applicationId := req.PathParameter("application")
namespace := req.PathParameter("namespace")
err := req.ReadEntity(&modifyClusterAttributesRequest)
if err != nil {
......@@ -124,7 +125,7 @@ func (h *openpitrixHandler) ModifyApplication(req *restful.Request, resp *restfu
return
}
app, err := h.openpitrix.DescribeApplication(namespace, clusterId, runtimeId)
app, err := h.openpitrix.DescribeApplication(namespace, applicationId, clusterName)
if err != nil {
klog.Errorln(err)
......@@ -132,8 +133,8 @@ func (h *openpitrixHandler) ModifyApplication(req *restful.Request, resp *restfu
return
}
if runtimeId != app.Cluster.RuntimeId {
err = fmt.Errorf("rumtime not match %s,%s", app.Cluster.RuntimeId, runtimeId)
if clusterName != app.Cluster.RuntimeId {
err = fmt.Errorf("runtime and cluster not match %s,%s", app.Cluster.RuntimeId, clusterName)
klog.V(4).Infoln(err)
api.HandleForbidden(resp, nil, err)
return
......@@ -151,10 +152,10 @@ func (h *openpitrixHandler) ModifyApplication(req *restful.Request, resp *restfu
}
func (h *openpitrixHandler) DeleteApplication(req *restful.Request, resp *restful.Response) {
runtimeId := req.PathParameter("runtime")
clusterId := req.PathParameter("application")
clusterName := req.PathParameter("cluster")
applicationId := req.PathParameter("application")
namespace := req.PathParameter("namespace")
app, err := h.openpitrix.DescribeApplication(namespace, clusterId, runtimeId)
app, err := h.openpitrix.DescribeApplication(namespace, applicationId, clusterName)
if err != nil {
klog.Errorln(err)
......@@ -162,14 +163,14 @@ func (h *openpitrixHandler) DeleteApplication(req *restful.Request, resp *restfu
return
}
if runtimeId != app.Cluster.RuntimeId {
err = fmt.Errorf("rumtime not match %s,%s", app.Cluster.RuntimeId, runtimeId)
if clusterName != app.Cluster.RuntimeId {
err = fmt.Errorf("runtime and cluster not match %s,%s", app.Cluster.RuntimeId, clusterName)
klog.V(4).Infoln(err)
api.HandleForbidden(resp, nil, err)
return
}
err = h.openpitrix.DeleteApplication(clusterId)
err = h.openpitrix.DeleteApplication(applicationId)
if err != nil {
klog.Errorln(err)
......@@ -181,9 +182,9 @@ func (h *openpitrixHandler) DeleteApplication(req *restful.Request, resp *restfu
}
func (h *openpitrixHandler) UpgradeApplication(req *restful.Request, resp *restful.Response) {
runtimeId := req.PathParameter("runtime")
clusterName := req.PathParameter("cluster")
namespace := req.PathParameter("namespace")
clusterId := req.PathParameter("application")
applicationId := req.PathParameter("application")
var upgradeClusterRequest openpitrix.UpgradeClusterRequest
err := req.ReadEntity(&upgradeClusterRequest)
if err != nil {
......@@ -194,7 +195,7 @@ func (h *openpitrixHandler) UpgradeApplication(req *restful.Request, resp *restf
upgradeClusterRequest.Username = req.HeaderParameter(constants.UserNameHeader)
app, err := h.openpitrix.DescribeApplication(namespace, clusterId, runtimeId)
app, err := h.openpitrix.DescribeApplication(namespace, applicationId, clusterName)
if err != nil {
klog.Errorln(err)
......@@ -202,8 +203,8 @@ func (h *openpitrixHandler) UpgradeApplication(req *restful.Request, resp *restf
return
}
if runtimeId != app.Cluster.RuntimeId {
err = fmt.Errorf("rumtime not match %s,%s", app.Cluster.RuntimeId, runtimeId)
if clusterName != app.Cluster.RuntimeId {
err = fmt.Errorf("runtime and cluster not match %s,%s", app.Cluster.RuntimeId, clusterName)
klog.V(4).Infoln(err)
api.HandleForbidden(resp, nil, err)
return
......
......@@ -43,7 +43,21 @@ func AddToContainer(c *restful.Container, factory informers.InformerFactory, op
webservice := runtime.NewWebService(GroupVersion)
handler := newOpenpitrixHandler(factory, op)
webservice.Route(webservice.GET("/runtimes/{runtime}/applications").
webservice.Route(webservice.GET("/applications").
To(handler.ListApplications).
Returns(http.StatusOK, api.StatusOK, models.PageableResponse{}).
Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Doc("List all applications").
Param(webservice.QueryParameter(params.ConditionsParam, "query conditions, connect multiple conditions with commas, equal symbol for exact query, wave symbol for fuzzy query e.g. name~a").
Required(false).
DataFormat("key=value,key~value").
DefaultValue("")).
Param(webservice.QueryParameter(params.PagingParam, "paging query, e.g. limit=100,page=1").
Required(false).
DataFormat("limit=%d,page=%d").
DefaultValue("limit=10,page=1")))
webservice.Route(webservice.GET("/clusters/{cluster}/applications").
To(handler.ListApplications).
Returns(http.StatusOK, api.StatusOK, models.PageableResponse{}).
Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
......@@ -52,13 +66,13 @@ func AddToContainer(c *restful.Container, factory informers.InformerFactory, op
Required(false).
DataFormat("key=value,key~value").
DefaultValue("")).
Param(webservice.PathParameter("runtime", "the id of runtime")).
Param(webservice.PathParameter("cluster", "the name of the cluster.").Required(true)).
Param(webservice.QueryParameter(params.PagingParam, "paging query, e.g. limit=100,page=1").
Required(false).
DataFormat("limit=%d,page=%d").
DefaultValue("limit=10,page=1")))
webservice.Route(webservice.GET("/runtimes/{runtime}/namespaces/{namespace}/applications").
webservice.Route(webservice.GET("/clusters/{cluster}/namespaces/{namespace}/applications").
To(handler.ListApplications).
Returns(http.StatusOK, api.StatusOK, models.PageableResponse{}).
Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
......@@ -67,61 +81,61 @@ func AddToContainer(c *restful.Container, factory informers.InformerFactory, op
Required(false).
DataFormat("key=value,key~value").
DefaultValue("")).
Param(webservice.PathParameter("runtime", "the id of runtime")).
Param(webservice.PathParameter("namespace", "the name of the project")).
Param(webservice.PathParameter("cluster", "the name of the cluster.").Required(true)).
Param(webservice.PathParameter("namespace", "the name of the project").Required(true)).
Param(webservice.QueryParameter(params.PagingParam, "paging query, e.g. limit=100,page=1").
Required(false).
DataFormat("limit=%d,page=%d").
DefaultValue("limit=10,page=1")))
webservice.Route(webservice.GET("/runtimes/{runtime}/namespaces/{namespace}/applications/{application}").
webservice.Route(webservice.GET("/clusters/{cluster}/namespaces/{namespace}/applications/{application}").
To(handler.DescribeApplication).
Returns(http.StatusOK, api.StatusOK, openpitrix2.Application{}).
Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Doc("Describe the specified application of the namespace").
Param(webservice.PathParameter("runtime", "the id of runtime")).
Param(webservice.PathParameter("namespace", "the name of the project")).
Param(webservice.PathParameter("application", "application ID")))
Param(webservice.PathParameter("cluster", "the name of the cluster.").Required(true)).
Param(webservice.PathParameter("namespace", "the name of the project").Required(true)).
Param(webservice.PathParameter("application", "the id of the application").Required(true)))
webservice.Route(webservice.POST("/runtimes/{runtime}/namespaces/{namespace}/applications").
webservice.Route(webservice.POST("/clusters/{cluster}/namespaces/{namespace}/applications").
To(handler.CreateApplication).
Doc("Deploy a new application").
Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Reads(openpitrix2.CreateClusterRequest{}).
Returns(http.StatusOK, api.StatusOK, errors.Error{}).
Param(webservice.PathParameter("runtime", "the id of runtime")).
Param(webservice.PathParameter("namespace", "the name of the project")))
Param(webservice.PathParameter("cluster", "the name of the cluster.").Required(true)).
Param(webservice.PathParameter("namespace", "the name of the project").Required(true)))
webservice.Route(webservice.PATCH("/runtimes/{runtime}/namespaces/{namespace}/applications/{application}").
webservice.Route(webservice.PATCH("/clusters/{cluster}/namespaces/{namespace}/applications/{application}").
Consumes(mimePatch...).
To(handler.ModifyApplication).
Doc("Modify application").
Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Reads(openpitrix2.ModifyClusterAttributesRequest{}).
Returns(http.StatusOK, api.StatusOK, errors.Error{}).
Param(webservice.PathParameter("runtime", "the id of runtime")).
Param(webservice.PathParameter("namespace", "the name of the project")).
Param(webservice.PathParameter("application", "the id of the application cluster")))
Param(webservice.PathParameter("cluster", "the name of the cluster.").Required(true)).
Param(webservice.PathParameter("namespace", "the name of the project").Required(true)).
Param(webservice.PathParameter("application", "the id of the application").Required(true)))
webservice.Route(webservice.DELETE("/runtimes/{runtime}/namespaces/{namespace}/applications/{application}").
webservice.Route(webservice.DELETE("/clusters/{cluster}/namespaces/{namespace}/applications/{application}").
To(handler.DeleteApplication).
Doc("Delete the specified application").
Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Returns(http.StatusOK, api.StatusOK, errors.Error{}).
Param(webservice.PathParameter("runtime", "the id of runtime")).
Param(webservice.PathParameter("namespace", "the name of the project")).
Param(webservice.PathParameter("application", "the id of the application cluster")))
Param(webservice.PathParameter("cluster", "the name of the cluster.").Required(true)).
Param(webservice.PathParameter("namespace", "the name of the project").Required(true)).
Param(webservice.PathParameter("application", "the id of the application").Required(true)))
webservice.Route(webservice.POST("/runtimes/{runtime}/namespaces/{namespace}/applications/{application}").
webservice.Route(webservice.POST("/clusters/{cluster}/namespaces/{namespace}/applications/{application}").
Consumes(mimePatch...).
To(handler.UpgradeApplication).
Doc("Upgrade application").
Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}).
Reads(openpitrix2.UpgradeClusterRequest{}).
Returns(http.StatusOK, api.StatusOK, errors.Error{}).
Param(webservice.PathParameter("runtime", "the id of runtime")).
Param(webservice.PathParameter("namespace", "the name of the project")).
Param(webservice.PathParameter("application", "the id of the application cluster")))
Param(webservice.PathParameter("cluster", "the name of the cluster.").Required(true)).
Param(webservice.PathParameter("namespace", "the name of the project").Required(true)).
Param(webservice.PathParameter("application", "the id of the application").Required(true)))
webservice.Route(webservice.POST("/apps/{app}/versions").
To(handler.CreateAppVersion).
......
......@@ -35,8 +35,8 @@ import (
type ApplicationInterface interface {
ListApplications(conditions *params.Conditions, limit, offset int, orderBy string, reverse bool) (*models.PageableResponse, error)
DescribeApplication(namespace, clusterId, runtimeId string) (*Application, error)
CreateApplication(runtimeId, namespace string, request CreateClusterRequest) error
DescribeApplication(namespace, applicationId, clusterName string) (*Application, error)
CreateApplication(clusterName, namespace string, request CreateClusterRequest) error
ModifyApplication(request ModifyClusterAttributesRequest) error
DeleteApplication(id string) error
UpgradeApplication(request UpgradeClusterRequest) error
......@@ -143,10 +143,10 @@ func (c *applicationOperator) describeApplication(cluster *pb.Cluster) (*Applica
return &app, nil
}
func (c *applicationOperator) DescribeApplication(namespace string, clusterId string, runtimeId string) (*Application, error) {
func (c *applicationOperator) DescribeApplication(namespace string, applicationId string, clusterName string) (*Application, error) {
describeClusterRequest := &pb.DescribeClustersRequest{
ClusterId: []string{clusterId},
RuntimeId: []string{runtimeId},
ClusterId: []string{applicationId},
RuntimeId: []string{clusterName},
Zone: []string{namespace},
WithDetail: pbutil.ToProtoBool(true),
Limit: 1,
......@@ -358,11 +358,11 @@ func (c *applicationOperator) getIng(namespace string, services []v1.Service) []
return ings
}
func (c *applicationOperator) CreateApplication(runtimeId, namespace string, request CreateClusterRequest) error {
func (c *applicationOperator) CreateApplication(clusterName, namespace string, request CreateClusterRequest) error {
_, err := c.opClient.CreateCluster(openpitrix.ContextWithUsername(request.Username), &pb.CreateClusterRequest{
AppId: &wrappers.StringValue{Value: request.AppId},
VersionId: &wrappers.StringValue{Value: request.VersionId},
RuntimeId: &wrappers.StringValue{Value: request.RuntimeId},
RuntimeId: &wrappers.StringValue{Value: clusterName},
Conf: &wrappers.StringValue{Value: request.Conf},
Zone: &wrappers.StringValue{Value: namespace},
})
......@@ -395,8 +395,8 @@ func (c *applicationOperator) ModifyApplication(request ModifyClusterAttributesR
return nil
}
func (c *applicationOperator) DeleteApplication(clusterId string) error {
_, err := c.opClient.DeleteClusters(openpitrix.SystemContext(), &pb.DeleteClustersRequest{ClusterId: []string{clusterId}, Force: &wrappers.BoolValue{Value: true}})
func (c *applicationOperator) DeleteApplication(applicationId string) error {
_, err := c.opClient.DeleteClusters(openpitrix.SystemContext(), &pb.DeleteClustersRequest{ClusterId: []string{applicationId}, Force: &wrappers.BoolValue{Value: true}})
if err != nil {
klog.Errorln(err)
......
/*
Copyright 2019 The KubeSphere Authors.
Copyright 2020 The KubeSphere Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......@@ -20,6 +20,7 @@ package openpitrix
import (
"context"
"fmt"
"github.com/golang/protobuf/ptypes/wrappers"
"k8s.io/klog"
"openpitrix.io/openpitrix/pkg/manager"
"openpitrix.io/openpitrix/pkg/pb"
......@@ -48,6 +49,12 @@ type Client interface {
pb.CategoryManagerClient
pb.AttachmentManagerClient
pb.RepoIndexerClient
// upsert the openpitrix runtime when cluster is updated or created
UpsertRuntime(cluster string, kubeConfig string) error
// clean up the openpitrix runtime when cluster is deleted
CleanupRuntime(cluster string) error
// migrate the openpitrix runtime when upgrade ks2.x to ks3.x
MigrateRuntime(runtimeId string, cluster string) error
}
type client struct {
......@@ -60,6 +67,47 @@ type client struct {
pb.RepoIndexerClient
}
func (c *client) UpsertRuntime(cluster string, kubeConfig string) error {
ctx := SystemContext()
req := &pb.CreateRuntimeCredentialRequest{
Name: &wrappers.StringValue{Value: fmt.Sprintf("kubeconfig-%s", cluster)},
Provider: &wrappers.StringValue{Value: "kubernetes"},
Description: &wrappers.StringValue{Value: "kubeconfig"},
RuntimeUrl: &wrappers.StringValue{Value: "kubesphere"},
RuntimeCredentialContent: &wrappers.StringValue{Value: kubeConfig},
RuntimeCredentialId: &wrappers.StringValue{Value: cluster},
}
_, err := c.CreateRuntimeCredential(ctx, req)
if err != nil {
return err
}
_, err = c.CreateRuntime(ctx, &pb.CreateRuntimeRequest{
Name: &wrappers.StringValue{Value: cluster},
RuntimeCredentialId: &wrappers.StringValue{Value: cluster},
Provider: &wrappers.StringValue{Value: KubernetesProvider},
Zone: &wrappers.StringValue{Value: cluster},
})
return err
}
func (c *client) CleanupRuntime(cluster string) error {
ctx := SystemContext()
_, err := c.DeleteClusterInRuntime(ctx, &pb.DeleteClusterInRuntimeRequest{
RuntimeId: []string{cluster},
})
return err
}
func (c *client) MigrateRuntime(runtimeId string, cluster string) error {
ctx := SystemContext()
_, err := c.MigrateClusterInRuntime(ctx, &pb.MigrateClusterInRuntimeRequest{
FromRuntimeId: runtimeId,
ToRuntimeId: cluster,
})
return err
}
func parseToHostPort(endpoint string) (string, int, error) {
args := strings.Split(endpoint, ":")
if len(args) != 2 {
......
......@@ -136,9 +136,9 @@ github.com/elastic/go-elasticsearch/v7/estransport
github.com/elastic/go-elasticsearch/v7/internal/version
# github.com/emicklei/go-restful v2.11.1+incompatible => github.com/emicklei/go-restful v2.9.5+incompatible
github.com/emicklei/go-restful
github.com/emicklei/go-restful/log
# github.com/emicklei/go-restful-openapi v1.0.0 => github.com/emicklei/go-restful-openapi v1.0.0
github.com/emicklei/go-restful-openapi
github.com/emicklei/go-restful/log
# github.com/emirpasic/gods v1.12.0 => github.com/emirpasic/gods v1.12.0
github.com/emirpasic/gods/containers
github.com/emirpasic/gods/lists
......@@ -1359,7 +1359,7 @@ k8s.io/utils/net
k8s.io/utils/path
k8s.io/utils/pointer
k8s.io/utils/trace
# openpitrix.io/openpitrix v0.4.1-0.20190920134345-4d2be6e4965c => openpitrix.io/openpitrix v0.4.9-0.20200610105301-68151bb90d21
# openpitrix.io/openpitrix v0.4.9-0.20200611125425-ae07f141e797 => openpitrix.io/openpitrix v0.4.9-0.20200611125425-ae07f141e797
openpitrix.io/openpitrix/pkg/config
openpitrix.io/openpitrix/pkg/constants
openpitrix.io/openpitrix/pkg/db
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册