Skip to content

Commit

Permalink
Merge pull request #32 from whalecold/chore/meta
Browse files Browse the repository at this point in the history
chore(meta): add default meta info
  • Loading branch information
felix021 authored Jan 24, 2024
2 parents 7e572af + e2ab4ea commit 175a0b2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func main() {
| serverAddr | 127.0.0.1 | nacos server address |
| serverPort | 8848 | nacos server port |
| namespace | | the namespaceId of nacos |
| NACOS_ENV_TAGS | "" | support inject default tags|
| KITEX_NACOS_ENV_TAGS | "" | support inject default tags|

### More Info

Expand Down
6 changes: 4 additions & 2 deletions nacos/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ func init() {
}

func parseTags(tags string) map[string]string {
out := map[string]string{
"cloudwego.nacos.client": "kitex",
}
if len(tags) == 0 {
return nil
return out
}
out := map[string]string{}
parts := strings.Split(tags, ",")
for _, part := range parts {
tag := strings.Split(part, "=")
Expand Down
5 changes: 3 additions & 2 deletions nacos/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ func TestEnvFunc(t *testing.T) {

func TestParseTags(t *testing.T) {
assert.Equal(t, parseTags("k1=v1,k2=v2"), map[string]string{
"k1": "v1",
"k2": "v2",
"cloudwego.nacos.client": "kitex",
"k1": "v1",
"k2": "v2",
})
}

0 comments on commit 175a0b2

Please sign in to comment.