Skip to content

Commit

Permalink
Bugfix for TagList missing in list() result value of KeyPair
Browse files Browse the repository at this point in the history
  • Loading branch information
dev4unet committed Aug 20, 2024
1 parent f750259 commit d942194
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ func handleKeyPair() {
keyPairReqInfo := irs.KeyPairReqInfo{
IId: irs.IID{NameId: keyPairName},
//Name: keyPairName,
//TagList: []irs.KeyValue{{Key: "Name1", Value: "Tag Name Value1"}, {Key: "Name2", Value: "Tag Name Value2"}, {Key: "Name", Value: keyPairName + "123"}},
TagList: []irs.KeyValue{{Key: "Name1", Value: "Tag Name Value1"}, {Key: "Name2", Value: "Tag Name Value2"}},
TagList: []irs.KeyValue{{Key: "Name1", Value: "Tag Name Value1"}, {Key: "Name2", Value: "Tag Name Value2"}, {Key: "Name", Value: keyPairName + "123"}},
//TagList: []irs.KeyValue{{Key: "Name1", Value: "Tag Name Value1"}, {Key: "Name2", Value: "Tag Name Value2"}},
}
result, err := KeyPairHandler.CreateKey(keyPairReqInfo)
if err != nil {
Expand All @@ -522,6 +522,7 @@ func handleKeyPair() {
cblogger.Infof(keyPairName, " KeyPair Lookup Failed : ", err)
} else {
cblogger.Infof("[%s] KeyPair Lookup Result : [%s]", keyPairName, result)
spew.Dump(result)
}
case 4:
cblogger.Infof("[%s] KeyPair Delete Test", keyPairName)
Expand Down Expand Up @@ -2257,13 +2258,13 @@ func readConfigFile() Config {
}

func main() {
handleMyImage()
//handleMyImage()
// myimage
//handleTag()
// handlePublicIP() // PublicIP 생성 후 conf
// handleDisk()

//handleKeyPair()
handleKeyPair()
//handleVPC()
//handleSecurity()
//handleVM()
Expand All @@ -2274,5 +2275,5 @@ func main() {
//handleCluster()
//handleRegionZone()
//handlePriceInfo()
handleTag()
//handleTag()
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ func (keyPairHandler *AwsKeyPairHandler) ListKey() ([]*irs.KeyPairInfo, error) {
keyPairInfo.Fingerprint = *pair.KeyFingerprint
*/
keyPairInfo, errKeyPair := ExtractKeyPairDescribeInfo(pair)
//keyPairInfo.TagList, _ = keyPairHandler.TagHandler.ListTag(irs.KEY, keyPairInfo.IId)
// Implemented direct logic instead of keyPairHandler.TagHandler.ListTag for speed.
for _, tag := range pair.Tags {
keyPairInfo.TagList = append(keyPairInfo.TagList, irs.KeyValue{
Key: aws.StringValue(tag.Key),
Value: aws.StringValue(tag.Value),
})
}

if errKeyPair != nil {
//cblogger.Infof("[%s] KeyPair는 Local에서 관리하는 대상이 아니기 때문에 Skip합니다.", *pair.KeyName)
cblogger.Error(errKeyPair.Error())
Expand Down Expand Up @@ -133,7 +142,7 @@ func (keyPairHandler *AwsKeyPairHandler) CreateKey(keyPairReqInfo irs.KeyPairReq
}
// Creates a new key pair with the given name
result, err := keyPairHandler.Client.CreateKeyPair(input)
// spew.Dump(result)
//spew.Dump(result)

callLogInfo.ElapsedTime = call.Elapsed(callLogStart)

Expand Down Expand Up @@ -252,7 +261,7 @@ func (keyPairHandler *AwsKeyPairHandler) GetKey(keyIID irs.IID) (irs.KeyPairInfo
callLogStart := call.Start()

result, err := keyPairHandler.Client.DescribeKeyPairs(input)
// spew.Dump(result)
//spew.Dump(result)
callLogInfo.ElapsedTime = call.Elapsed(callLogStart)
cblogger.Debug("result : ", result)
cblogger.Debug("err : ", err)
Expand Down Expand Up @@ -287,7 +296,7 @@ func (keyPairHandler *AwsKeyPairHandler) GetKey(keyIID irs.IID) (irs.KeyPairInfo
}

keyPairInfo.TagList, _ = keyPairHandler.TagHandler.ListTag(irs.KEY, keyPairInfo.IId)
// spew.Dump(keyPairInfo.TagList)
//spew.Dump(keyPairInfo.TagList)

cblogger.Debug(keyPairInfo)
return keyPairInfo, nil
Expand Down

0 comments on commit d942194

Please sign in to comment.