Skip to content

Commit

Permalink
[CLI] fix org repo create
Browse files Browse the repository at this point in the history
  • Loading branch information
jin-xiaofeng committed May 23, 2024
1 parent d0c9575 commit 47f7432
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cli/ctl/agent_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,15 @@ func createRepoAgent(cmd *cobra.Command, arch, image, versionImage, k8sImage str

server := common.GetServerInfo(cmd)
url := fmt.Sprintf("http://%s:%d/v1/vtap-repo/", server.IP, server.Port)
resp, err := common.CURLPostFormData(url, contentType, bodyBuf, []common.HTTPOption{common.WithTimeout(common.GetTimeout(cmd)), common.WithORGID(common.GetORGID(cmd))}...)
orgID := common.GetORGID(cmd)
resp, err := common.CURLPostFormData(url, contentType, bodyBuf, []common.HTTPOption{common.WithTimeout(common.GetTimeout(cmd)), common.WithORGID(orgID)}...)
if err != nil {
return err
}
data := resp.Get("DATA")
fmt.Printf("created successfully, os: %s, branch: %s, rev_count: %s, commit_id: %s\n", data.Get("OS").MustString(),
data.Get("BRANCH").MustString(), data.Get("REV_COUNT").MustString(), data.Get("COMMIT_ID").MustString())
fmt.Printf("ORGID-%d: created successfully, os: %s, branch: %s, rev_count: %s, commit_id: %s\n",
orgID, data.Get("OS").MustString(), data.Get("BRANCH").MustString(),
data.Get("REV_COUNT").MustString(), data.Get("COMMIT_ID").MustString())
return nil
}

Expand Down
3 changes: 3 additions & 0 deletions cli/ctl/common/http_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ func CURLPostFormData(url, contentType string, body *bytes.Buffer, opts ...HTTPO
if err != nil {
return nil, err
}
if cfg.ORGID != 0 {
req.Header.Set(ctrlcommon.HEADER_KEY_X_ORG_ID, strconv.Itoa(cfg.ORGID))
}
req.Header.Set("Content-Type", contentType)
req.Header.Set("Accept", "application/json, text/plain")
req.Header.Set("X-User-Id", "1")
Expand Down

0 comments on commit 47f7432

Please sign in to comment.