Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tencent] Resolve cluster tag issue #176

Merged
merged 3 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,18 @@ type GCPVMHandler struct {
func (vmHandler *GCPVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, error) {
// Set VM Create Information
// GCP 는 reqinfo에 ProjectID를 받아야 함.
cblogger.Debug(vmReqInfo)

//ctx := vmHandler.Ctx
vmName := vmReqInfo.IId.NameId
projectID := vmHandler.Credential.ProjectID
prefix := "https://www.googleapis.com/compute/v1/projects/" + projectID

region := vmHandler.Region.Region
zone := vmHandler.Region.Zone

if vmHandler.Region.TargetZone != "" {
zone = vmHandler.Region.TargetZone
}

// email을 어디다가 넣지? 이것또한 문제넹
clientEmail := vmHandler.Credential.ClientEmail

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,12 @@ func getClusterInfo(access_key string, access_secret string, region_id string, c
cblogger.Error(err)
panic(err)
}

jsonRes, err := json.MarshalIndent(res, "", " ")
if err != nil {
cblogger.Error(fmt.Sprintf("Failed to marshal res: %v", err))
} else {
cblogger.Info(fmt.Sprintf("res in JSON format: %s", string(jsonRes)))
}
// description에서 security group 이름 추출
security_group_id := ""
re := regexp.MustCompile(`\S*#CB-SPIDER:PMKS:SECURITYGROUP:ID:\S*`)
Expand Down Expand Up @@ -479,6 +484,20 @@ func getClusterInfo(access_key string, access_secret string, region_id string, c
// KeyValueList: []irs.KeyValue{}, // flatten data 입력하기
}

// Tags가 있는지 확인하고 추가
if res.Response.Clusters[0].TagSpecification != nil {
var tagList []irs.KeyValue
for _, tag := range res.Response.Clusters[0].TagSpecification {

for _, tag := range tag.Tags {
tagList = append(clusterInfo.KeyValueList, irs.KeyValue{
Key: *tag.Key,
Value: *tag.Value,
})
}
clusterInfo.TagList = tagList
}
}
// k,v 추출 & 추가
// KeyValueList: []irs.KeyValue{}, // flatten data 입력하기
temp, err := json.Marshal(*res.Response.Clusters[0])
Expand Down