Skip to content

Commit

Permalink
feat: 新增内置标签podname
Browse files Browse the repository at this point in the history
  • Loading branch information
Ambition9186 committed Oct 30, 2024
1 parent a5ae47e commit ac5f891
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/bscp/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ func Pull(cmd *cobra.Command, args []string) {
os.Exit(1)
}

// 设置pod name
if version.CLIENTTYPE == string(sfs.Sidecar) {
conf.Labels["pod_name"] = os.Getenv("HOSTNAME")
}

bscp, err := client.New(
client.WithFeedAddrs(conf.FeedAddrs),
client.WithBizID(conf.Biz),
Expand Down Expand Up @@ -96,6 +101,7 @@ func Pull(cmd *cobra.Command, args []string) {
}

for _, app := range conf.Apps {
// app.Labels["podname"] = "dd"
opts := []client.AppOption{}
opts = append(opts, client.WithAppConfigMatch(app.ConfigMatches))
opts = append(opts, client.WithAppLabels(app.Labels))
Expand Down
5 changes: 5 additions & 0 deletions cmd/bscp/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ func Watch(cmd *cobra.Command, args []string) {
labels = r.mergeLabels
}

// 设置pod name
if version.CLIENTTYPE == string(sfs.Sidecar) {
conf.Labels["pod_name"] = os.Getenv("HOSTNAME")
}

bscp, err := newWatchClient(labels)
if err != nil {
logger.Error("init client", logger.ErrAttr(err))
Expand Down

0 comments on commit ac5f891

Please sign in to comment.