Skip to content

Commit

Permalink
fix issues reported by github action
Browse files Browse the repository at this point in the history
  • Loading branch information
localvar committed Jun 14, 2022
1 parent ba8ffec commit 84fc70a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pkg/api/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (s *Server) _listStatusObjects() map[string]map[string]interface{} {
}

func (s *Server) _getStatusObjectFromDefaultNamespace(name string) map[string]string {
key := s.cluster.Layout().StatusNamespaceFormat(rawconfigtrafficcontroller.DefaultNamespace, name)
key := s.cluster.Layout().FullObjectName(rawconfigtrafficcontroller.DefaultNamespace, name)
prefix := s.cluster.Layout().StatusObjectPrefix(key)
kvs, err := s.cluster.GetPrefix(prefix)
if err != nil {
Expand Down
13 changes: 7 additions & 6 deletions pkg/cluster/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ const (
statusMemberPrefix = "/status/members/"
statusMemberFormat = "/status/members/%s" // +memberName
statusObjectPrefix = "/status/objects/"
statusObjectNameFormat = "%s-%s"
statusNamespaceFormat = "%s/%s"
statusObjectNameFormat = "%s-%s" // +kind + name
statusObjectPrefixFormat = "/status/objects/%s/" // +objectName
statusObjectFormat = "/status/objects/%s/%s" // +objectName +memberName
configObjectPrefix = "/config/objects/"
Expand All @@ -38,6 +37,7 @@ const (
wasmDataPrefixFormat = "/wasm/data/%s/%s/" // + pipelineName + filterName
customDataKindPrefix = "/custom-data-kinds/"
customDataPrefix = "/custom-data/"
fullObjectNameFormat = "%s/%s" // +namespace + name

// the cluster name of this eg group will be registered under this path in etcd
// any new member(primary or secondary ) will be rejected if it is configured a different cluster name
Expand Down Expand Up @@ -103,12 +103,13 @@ func (l *Layout) StatusObjectPrefix(name string) string {
}

// StatusObjectName returns the name of the status object.
func (l *Layout) StatusObjectName(kind string, specName string) string {
return fmt.Sprintf(statusObjectNameFormat, kind, specName)
func (l *Layout) StatusObjectName(kind string, name string) string {
return fmt.Sprintf(statusObjectNameFormat, kind, name)
}

func (l *Layout) StatusNamespaceFormat(namespace string, specName string) string {
return fmt.Sprintf(statusNamespaceFormat, namespace, specName)
// FullObjectName returns the full object name.
func (l *Layout) FullObjectName(namespace string, name string) string {
return fmt.Sprintf(fullObjectNameFormat, namespace, name)
}

// StatusObjectKey returns the key of object status.
Expand Down
6 changes: 3 additions & 3 deletions pkg/cluster/layout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ func TestLayout(t *testing.T) {
assert.True(strings.Contains(statusObjectName, "test-kind"))
assert.True(strings.Contains(statusObjectName, "test-name"))

statusNamespaceFormat := l.StatusNamespaceFormat("test-ns", "test-name")
assert.True(strings.Contains(statusNamespaceFormat, "test-ns"))
assert.True(strings.Contains(statusNamespaceFormat, "test-name"))
fullName := l.FullObjectName("test-ns", "test-name")
assert.True(strings.Contains(fullName, "test-ns"))
assert.True(strings.Contains(fullName, "test-name"))

assert.Equal(customDataPrefix, l.CustomDataPrefix())
assert.Equal(customDataKindPrefix, l.CustomDataKindPrefix())
Expand Down
2 changes: 1 addition & 1 deletion pkg/filters/proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ compression:

// direct set fnSendRequest to different function will cause data race since we use goroutine
// for mirror.
var fnKind int32 = 0
var fnKind int32
fnSendRequest = func(r *http.Request, client *http.Client) (*http.Response, error) {
kind := atomic.LoadInt32(&fnKind)
switch kind {
Expand Down
6 changes: 2 additions & 4 deletions pkg/object/httpserver/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,6 @@ func (mp *MuxPath) matchHeaders(r *httpprot.Request) bool {
return false
}
}

return true
} else {
for _, h := range mp.headers {
v := r.HTTPHeader().Get(h.Key)
Expand All @@ -311,9 +309,9 @@ func (mp *MuxPath) matchHeaders(r *httpprot.Request) bool {
return true
}
}

return false
}

return mp.mathAllHeader
}

func newMux(httpStat *httpstat.HTTPStat, topN *httpstat.TopN, mapper context.MuxMapper) *mux {
Expand Down
2 changes: 1 addition & 1 deletion pkg/object/statussynccontroller/statussynccontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (ssc *StatusSyncController) splitNamespaceStatus(status *trafficcontroller.
targetStatuses map[string]string, targetStatusesRecord *StatusesRecord) bool {

for key, value := range status.ToSyncStatus() {
name := ssc.superSpec.Super().Cluster().Layout().StatusNamespaceFormat(status.Namespace, key)
name := ssc.superSpec.Super().Cluster().Layout().FullObjectName(status.Namespace, key)
targetStatusesRecord.Statuses[name] = value

marshalledValue, ok := safeMarshal(value)
Expand Down
5 changes: 0 additions & 5 deletions pkg/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package registry

import (

// Filters
_ "github.com/megaease/easegress/pkg/filters/builder"
_ "github.com/megaease/easegress/pkg/filters/certextractor"
Expand All @@ -27,19 +26,16 @@ import (
_ "github.com/megaease/easegress/pkg/filters/fallback"
_ "github.com/megaease/easegress/pkg/filters/headerlookup"
_ "github.com/megaease/easegress/pkg/filters/headertojson"

_ "github.com/megaease/easegress/pkg/filters/kafka"
_ "github.com/megaease/easegress/pkg/filters/kafkabackend"
_ "github.com/megaease/easegress/pkg/filters/meshadaptor"
_ "github.com/megaease/easegress/pkg/filters/mock"

_ "github.com/megaease/easegress/pkg/filters/mqttclientauth"
_ "github.com/megaease/easegress/pkg/filters/proxy"
_ "github.com/megaease/easegress/pkg/filters/ratelimiter"
_ "github.com/megaease/easegress/pkg/filters/remotefilter"
_ "github.com/megaease/easegress/pkg/filters/requestadaptor"
_ "github.com/megaease/easegress/pkg/filters/responseadaptor"

_ "github.com/megaease/easegress/pkg/filters/topicmapper"
_ "github.com/megaease/easegress/pkg/filters/validator"
_ "github.com/megaease/easegress/pkg/filters/wasmhost"
Expand All @@ -55,7 +51,6 @@ import (
_ "github.com/megaease/easegress/pkg/object/httpserver"
_ "github.com/megaease/easegress/pkg/object/ingresscontroller"
_ "github.com/megaease/easegress/pkg/object/meshcontroller"

_ "github.com/megaease/easegress/pkg/object/mqttproxy"
_ "github.com/megaease/easegress/pkg/object/nacosserviceregistry"
_ "github.com/megaease/easegress/pkg/object/pipeline"
Expand Down
1 change: 1 addition & 0 deletions pkg/supervisor/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func ObjectKinds() []string {
return kinds
}

// TrafficObjectKinds is a map that contains all kinds of TrafficObject.
var TrafficObjectKinds = make(map[string]struct{})

// Register registers object.
Expand Down

0 comments on commit 84fc70a

Please sign in to comment.