Skip to content

Commit 02773d8

Browse files
authored
fix: terraform empty resource name and type for hashicorp resources (#1391)
1 parent c294471 commit 02773d8

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

pkg/domain/constant/resource.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const (
88
AzureProviderType = "azure"
99
GoogleProviderType = "google"
1010
CustomProviderType = "custom"
11+
HashicorpProviderType = "hashicorp"
1112
StatusResourceApplied = "applied"
1213
StatusResourceDestroyed = "destroyed"
1314
StatusResourceFailed = "failed"

pkg/server/manager/stack/util.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -438,36 +438,33 @@ func convertV1ResourceToEntity(resource *v1.Resource) (*entity.Resource, error)
438438
if providerInfo, ok := resource.Extensions["provider"].(string); ok {
439439
resourceProvider = providerInfo
440440
}
441+
// idParts = [providerNamespace, providerName, resourceType, resourceName]
442+
resourceType = idParts[2]
443+
resourceName = idParts[3]
441444
// Look at second element of the id to determine the resource plane
442445
switch idParts[1] {
443446
case constant.AWSProviderType:
444447
resourcePlane = constant.AWSProviderType
445-
resourceType = idParts[2]
446-
resourceName = idParts[3]
447448
if arn, ok := resource.Attributes["arn"].(string); ok {
448449
cloudResourceID = arn
449450
}
450451
case constant.AzureProviderType:
451452
resourcePlane = constant.AzureProviderType
452-
resourceType = idParts[2]
453-
resourceName = idParts[3]
454453
if resID, ok := resource.Attributes["id"].(string); ok {
455454
cloudResourceID = resID
456455
}
457456
case constant.GoogleProviderType:
458457
resourcePlane = constant.GoogleProviderType
459-
resourceType = idParts[2]
460-
resourceName = idParts[3]
461458
if resID, ok := resource.Attributes["id"].(string); ok {
462459
cloudResourceID = resID
463460
}
464461
case constant.AliCloudProviderType:
465462
resourcePlane = constant.AliCloudProviderType
466-
resourceType = idParts[2]
467-
resourceName = idParts[3]
468463
if resID, ok := resource.Attributes["id"].(string); ok {
469464
cloudResourceID = resID
470465
}
466+
case constant.HashicorpProviderType:
467+
resourcePlane = constant.HashicorpProviderType
471468
default:
472469
if _, ok := resource.Extensions["provider"]; ok {
473470
resourcePlane = constant.CustomProviderType

0 commit comments

Comments
 (0)