Skip to content

Commit

Permalink
Merge branch 'kubesphere:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhouzi authored Nov 2, 2023
2 parents bf3040a + b4a9ee4 commit fd66d95
Show file tree
Hide file tree
Showing 38 changed files with 7,265 additions and 1,792 deletions.
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.13.0
github.com/stretchr/testify v1.8.1
golang.org/x/crypto v0.5.0
golang.org/x/crypto v0.14.0
golang.org/x/oauth2 v0.4.0
google.golang.org/grpc v1.53.0
gopkg.in/cas.v2 v2.2.0
Expand Down Expand Up @@ -273,11 +273,11 @@ require (
go.uber.org/zap v1.24.0 // indirect
golang.org/x/exp v0.0.0-20230124195608-d38c7dcee874 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.6.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
Expand Down Expand Up @@ -492,7 +492,7 @@ replace (
go.uber.org/atomic => go.uber.org/atomic v1.10.0
go.uber.org/goleak => go.uber.org/goleak v1.2.0
golang.org/x/crypto => golang.org/x/crypto v0.5.0
golang.org/x/net => golang.org/x/net v0.7.0
golang.org/x/net => golang.org/x/net v0.17.0
golang.org/x/oauth2 => golang.org/x/oauth2 v0.4.0
golang.org/x/sync => golang.org/x/sync v0.1.0
golang.org/x/sys => golang.org/x/sys v0.5.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1396,8 +1396,8 @@ golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI=
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M=
golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
Expand Down
10 changes: 10 additions & 0 deletions pkg/kapis/resources/v1alpha3/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1alpha3
import (
"fmt"
"net/http"
"sort"
"strings"

"github.com/emicklei/go-restful/v3"
Expand Down Expand Up @@ -251,6 +252,9 @@ func (h *Handler) handleGetRepositoryTags(request *restful.Request, response *re
secretName := request.QueryParameter("secret")
namespace := request.PathParameter("namespace")
repository := request.QueryParameter("repository")

q := query.ParseQueryParameter(request)

var secret *v1.Secret

if len(repository) == 0 {
Expand All @@ -272,6 +276,12 @@ func (h *Handler) handleGetRepositoryTags(request *restful.Request, response *re
return
}

if !q.Ascending {
sort.Sort(sort.Reverse(sort.StringSlice(tags.Tags)))
}
startIndex, endIndex := q.Pagination.GetValidPagination(len(tags.Tags))
tags.Tags = tags.Tags[startIndex:endIndex]

response.WriteHeaderAndJson(http.StatusOK, tags, restful.MIME_JSON)
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/kapis/resources/v1alpha3/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ func AddToContainer(c *restful.Container, informerFactory informers.InformerFact
Param(webservice.PathParameter("namespace", "Namespace of the image repository secret.").Required(true)).
Param(webservice.QueryParameter("repository", "Repository to query, e.g. calico/cni.").Required(true)).
Param(webservice.QueryParameter("secret", "Secret name of the image repository credential, left empty means anonymous fetch.").Required(false)).
Metadata(restfulspec.KeyOpenAPITags, []string{tagNamespacedResource}).
Param(webservice.QueryParameter(query.ParameterPage, "page").Required(false).DataFormat("page=%d").DefaultValue("page=1")).
Param(webservice.QueryParameter(query.ParameterLimit, "limit").Required(false)).
Param(webservice.QueryParameter(query.ParameterAscending, "sort parameters, e.g. reverse=true").Required(false).DefaultValue("ascending=false")).
Doc("List repository tags, this is an experimental API, use it by your own caution.").
Returns(http.StatusOK, ok, v2.RepositoryTags{}))

Expand Down
2 changes: 1 addition & 1 deletion pkg/models/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import (
)

const (
MasterLabel = "node-role.kubernetes.io/master"
MasterLabel = "node-role.kubernetes.io/control-plane"
SidecarInject = "sidecar.istio.io/inject"
gatewayPrefix = "kubesphere-router-"
workingNamespace = "kubesphere-controls-system"
Expand Down
7 changes: 7 additions & 0 deletions pkg/models/openpitrix/applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,12 @@ func (c *applicationOperator) ModifyApp(appId string, request *ModifyAppRequest)
return err
}

_, err = c.appClient.UpdateStatus(context.TODO(), appCopy, metav1.UpdateOptions{})
if err != nil {
klog.Errorf("update helm application status: %s failed, error: %s", appId, err)
return err
}

_, err = c.appClient.Patch(context.TODO(), appId, patch.Type(), data, metav1.PatchOptions{})
if err != nil {
klog.Errorf("patch helm application: %s failed, error: %s", appId, err)
Expand All @@ -478,6 +484,7 @@ func (c *applicationOperator) ModifyApp(appId string, request *ModifyAppRequest)
}
return err
}

return nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/models/registries/v2/registries.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (r *registryer) ListRepositoryTags(src string) (RepositoryTags, error) {
Registry: repo.RegistryStr(),
Repository: repo.RepositoryStr(),
Tags: tags,
Total: len(tags),
}, nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/models/registries/v2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type RepositoryTags struct {
Registry string `json:"registry"`
Repository string `json:"repository"`
Tags []string `json:"tags"`
Total int `json:"total"`
}

// ImageConfig wraps v1.ConfigFile to avoid direct dependency
Expand Down
20 changes: 6 additions & 14 deletions pkg/utils/clusterclient/clusterclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ type innerCluster struct {
}

type clusterClients struct {
sync.RWMutex
clusterLister clusterlister.ClusterLister

// build a in memory cluster cache to speed things up
innerClusters map[string]*innerCluster
// build an in memory cluster cache to speed things up
innerClusters sync.Map
}

type ClusterClients interface {
Expand All @@ -62,7 +61,6 @@ type ClusterClients interface {

func NewClusterClient(clusterInformer clusterinformer.ClusterInformer) ClusterClients {
c := &clusterClients{
innerClusters: make(map[string]*innerCluster),
clusterLister: clusterInformer.Lister(),
}

Expand All @@ -85,9 +83,7 @@ func NewClusterClient(clusterInformer clusterinformer.ClusterInformer) ClusterCl
func (c *clusterClients) removeCluster(obj interface{}) {
cluster := obj.(*clusterv1alpha1.Cluster)
klog.V(4).Infof("remove cluster %s", cluster.Name)
c.Lock()
delete(c.innerClusters, cluster.Name)
c.Unlock()
c.innerClusters.Delete(cluster.Name)
}

func newInnerCluster(cluster *clusterv1alpha1.Cluster) *innerCluster {
Expand Down Expand Up @@ -139,9 +135,7 @@ func (c *clusterClients) addCluster(obj interface{}) *innerCluster {
}

inner := newInnerCluster(cluster)
c.Lock()
c.innerClusters[cluster.Name] = inner
c.Unlock()
c.innerClusters.Store(cluster.Name, inner)
return inner
}

Expand All @@ -158,10 +152,8 @@ func (c *clusterClients) GetClusterKubeconfig(clusterName string) (string, error
}

func (c *clusterClients) GetInnerCluster(name string) *innerCluster {
c.RLock()
defer c.RUnlock()
if inner, ok := c.innerClusters[name]; ok {
return inner
if inner, ok := c.innerClusters.Load(name); ok {
return inner.(*innerCluster)
} else if cluster, err := c.clusterLister.Get(name); err == nil {
// double check if the cluster exists but is not cached
return c.addCluster(cluster)
Expand Down
13 changes: 8 additions & 5 deletions staging/src/kubesphere.io/api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/prometheus/common v0.39.0
github.com/prometheus/prometheus v0.42.0
github.com/robfig/cron/v3 v3.0.1
golang.org/x/net v0.7.0
golang.org/x/net v0.17.0
gopkg.in/yaml.v3 v3.0.1
istio.io/api v0.0.0-20201113182140-d4b7e3fc2b44
k8s.io/api v0.26.1
Expand Down Expand Up @@ -85,14 +85,13 @@ require (
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/goleak v1.2.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/exp v0.0.0-20230124195608-d38c7dcee874 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/oauth2 v0.4.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.6.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
Expand All @@ -113,5 +112,9 @@ require (
replace (
github.com/projectcalico/api => github.com/kubesphere/calico/api v0.0.0-20230227071013-a73515ddc939 // v3.25.0
github.com/projectcalico/calico => github.com/kubesphere/calico v0.0.0-20230227071013-a73515ddc939 // v3.25.0
golang.org/x/crypto => golang.org/x/crypto v0.5.0
golang.org/x/sys => golang.org/x/sys v0.5.0
golang.org/x/term => golang.org/x/term v0.5.0
golang.org/x/text => golang.org/x/text v0.7.0
kubesphere.io/api => ../api
)
Loading

0 comments on commit fd66d95

Please sign in to comment.