Skip to content

Commit

Permalink
Fix ResType error when using 'KEYPAIR'
Browse files Browse the repository at this point in the history
  • Loading branch information
powerkimhub committed Aug 20, 2024
1 parent b9d78fe commit 33c2ec7
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions api-runtime/common-runtime/TagManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func AddTag(connectionName string, resType cres.RSType, resName string, tag cres
return cres.KeyValue{}, err
}

// convert to lowercase
resType = cres.RSType(strings.ToLower(string(resType)))

// locking by resource type
if err := rLockResource(connectionName, resType, resName); err != nil {
cblog.Error(err)
Expand Down Expand Up @@ -70,6 +73,9 @@ func ListTag(connectionName string, resType cres.RSType, resName string) ([]cres
return nil, err
}

// convert to lowercase
resType = cres.RSType(strings.ToLower(string(resType)))

// locking by resource type
if err := rLockResource(connectionName, resType, resName); err != nil {
cblog.Error(err)
Expand Down Expand Up @@ -110,6 +116,9 @@ func GetTag(connectionName string, resType cres.RSType, resName string, key stri
return cres.KeyValue{}, err
}

// convert to lowercase
resType = cres.RSType(strings.ToLower(string(resType)))

// // locking by resource type
// if err := rLockResource(connectionName, resType, resName); err != nil {
// cblog.Error(err)
Expand Down Expand Up @@ -150,6 +159,9 @@ func RemoveTag(connectionName string, resType cres.RSType, resName string, key s
return false, err
}

// convert to lowercase
resType = cres.RSType(strings.ToLower(string(resType)))

// locking by resource type
if err := rLockResource(connectionName, resType, resName); err != nil {
cblog.Error(err)
Expand Down Expand Up @@ -190,6 +202,9 @@ func FindTag(connectionName string, resType cres.RSType, keyword string) ([]*cre
return nil, err
}

// convert to lowercase
resType = cres.RSType(strings.ToLower(string(resType)))

cldConn, err := ccm.GetCloudConnection(connectionName)
if err != nil {
cblog.Error(err)
Expand All @@ -207,7 +222,6 @@ func FindTag(connectionName string, resType cres.RSType, keyword string) ([]*cre

// rLockResource locks the resource based on its type.
func rLockResource(connectionName string, resType cres.RSType, resName string) error {
resType = cres.RSType(strings.ToLower(string(resType)))

switch resType {
case cres.VPC, cres.SUBNET:
Expand All @@ -234,7 +248,6 @@ func rLockResource(connectionName string, resType cres.RSType, resName string) e

// unlockResource unlocks the resource based on its type.
func rUnlockResource(connectionName string, resType cres.RSType, resName string) {
resType = cres.RSType(strings.ToLower(string(resType)))

switch resType {
case cres.VPC, cres.SUBNET:
Expand All @@ -258,7 +271,7 @@ func rUnlockResource(connectionName string, resType cres.RSType, resName string)

// getIIDInfoByResourceType gets the IID info for a given resource type and resource name.
func getIIDInfoByResourceType(connectionName string, resType cres.RSType, resName string) (string, string, error) {
resType = cres.RSType(strings.ToLower(string(resType)))

switch resType {
case cres.VPC:
var info VPCIIDInfo
Expand Down

0 comments on commit 33c2ec7

Please sign in to comment.