From 87c71ed2ddbb11fd1e7b6296644758e43c5ab504 Mon Sep 17 00:00:00 2001 From: LiHui Date: Thu, 11 Mar 2021 17:10:06 +0800 Subject: [PATCH 1/2] Fix: handle openpititx config Signed-off-by: LiHui --- cmd/controller-manager/app/server.go | 2 +- pkg/apiserver/config/config.go | 11 +++++------ pkg/simple/client/openpitrix/options.go | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cmd/controller-manager/app/server.go b/cmd/controller-manager/app/server.go index 233dc6bb8..da93bf131 100644 --- a/cmd/controller-manager/app/server.go +++ b/cmd/controller-manager/app/server.go @@ -228,7 +228,7 @@ func run(s *options.KubeSphereControllerManagerOptions, stopCh <-chan struct{}) klog.Fatal("Unable to create helm category controller") } - if !s.OpenPitrixOptions.IsEmpty() { + if !s.OpenPitrixOptions.AppStoreConfIsEmpty() { storageClient, err := s3.NewS3Client(s.OpenPitrixOptions.S3Options) if err != nil { klog.Fatalf("failed to connect to s3, please check openpitrix s3 service status, error: %v", err) diff --git a/pkg/apiserver/config/config.go b/pkg/apiserver/config/config.go index 4ec842b42..4954270c6 100644 --- a/pkg/apiserver/config/config.go +++ b/pkg/apiserver/config/config.go @@ -200,11 +200,14 @@ func (conf *Config) ToMap() map[string]bool { } if name == "openpitrix" { - if conf.OpenPitrixOptions.IsEmpty() { + // openpitrix is always true + result[name] = true + if conf.OpenPitrixOptions == nil { result["openpitrix.appstore"] = false } else { - result["openpitrix.appstore"] = true + result["openpitrix.appstore"] = conf.OpenPitrixOptions.AppStoreConfIsEmpty() } + continue } if c.Field(i).IsNil() { @@ -240,10 +243,6 @@ func (conf *Config) stripEmptyOptions() { conf.LdapOptions = nil } - if conf.OpenPitrixOptions != nil && conf.OpenPitrixOptions.IsEmpty() { - conf.OpenPitrixOptions = nil - } - if conf.NetworkOptions != nil && conf.NetworkOptions.IsEmpty() { conf.NetworkOptions = nil } diff --git a/pkg/simple/client/openpitrix/options.go b/pkg/simple/client/openpitrix/options.go index f6d09681f..132fc33d8 100644 --- a/pkg/simple/client/openpitrix/options.go +++ b/pkg/simple/client/openpitrix/options.go @@ -39,7 +39,7 @@ func (s *Options) Validate() []error { return errors } -func (s *Options) IsEmpty() bool { +func (s *Options) AppStoreConfIsEmpty() bool { return s.S3Options == nil || s.S3Options.Endpoint == "" } From 263f07fe3012b7b899d7820c339676774d3b6592 Mon Sep 17 00:00:00 2001 From: LiHui Date: Thu, 11 Mar 2021 17:41:23 +0800 Subject: [PATCH 2/2] Fix: add router Signed-off-by: LiHui --- pkg/kapis/openpitrix/v1/register.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/pkg/kapis/openpitrix/v1/register.go b/pkg/kapis/openpitrix/v1/register.go index 2c15a39db..80ddc5e9e 100644 --- a/pkg/kapis/openpitrix/v1/register.go +++ b/pkg/kapis/openpitrix/v1/register.go @@ -455,6 +455,21 @@ func AddToContainer(c *restful.Container, ksInfomrers informers.InformerFactory, DataFormat("limit=%d,page=%d"). DefaultValue("limit=10,page=1"))) + webservice.Route(webservice.GET("/workspaces/{workspace}/applications"). + To(handler.ListApplications). + Returns(http.StatusOK, api.StatusOK, models.PageableResponse{}). + Metadata(restfulspec.KeyOpenAPITags, []string{constants.NamespaceResourcesTag}). + Doc("List all applications within the specified workspace"). + 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.PathParameter("workspace", "the workspace 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("/workspaces/{workspace}/clusters/{cluster}/applications"). To(handler.ListApplications). Returns(http.StatusOK, api.StatusOK, models.PageableResponse{}). @@ -464,7 +479,8 @@ func AddToContainer(c *restful.Container, ksInfomrers informers.InformerFactory, Required(false). DataFormat("key=value,key~value"). DefaultValue("")). - Param(webservice.PathParameter("namespace", "the name of the project.").Required(true)). + Param(webservice.PathParameter("workspace", "the workspace of the project.").Required(true)). + Param(webservice.PathParameter("cluster", "the cluster 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"). @@ -479,7 +495,7 @@ func AddToContainer(c *restful.Container, ksInfomrers informers.InformerFactory, Required(false). DataFormat("key=value,key~value"). DefaultValue("")). - Param(webservice.PathParameter("namespace", "the name of the project.").Required(true)). + Param(webservice.PathParameter("cluster", "the cluster 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"). @@ -494,6 +510,7 @@ func AddToContainer(c *restful.Container, ksInfomrers informers.InformerFactory, Required(false). DataFormat("key=value,key~value"). DefaultValue("")). + Param(webservice.PathParameter("workspace", "the workspace of the project.").Required(true)). 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").