Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 2 additions & 5 deletions pkg/resources/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ import (
// its GroupVersionKind and ObjectMeta.
func ToKusionResourceID(gvk schema.GroupVersionKind, objectMeta metav1.ObjectMeta) string {
// resource id example: apps/v1:Deployment:nginx:nginx-deployment
if gvk.Group == "" {
gvk.Group = "core"
}

id := gvk.Group + resources.SegmentSeparator + gvk.Version + resources.SegmentSeparator + gvk.Kind
apiVersion, kind := gvk.ToAPIVersionAndKind()
id := apiVersion + resources.SegmentSeparator + kind
if objectMeta.Namespace != "" {
id += resources.SegmentSeparator + objectMeta.Namespace
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/terraform/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func ToKusionResourceID(p Provider, resourceType, resourceName string) (string,
return "", err
}

tfProviderStr := tfProvider.String()
return strings.Join([]string{tfProviderStr, resourceType, resourceName}, resources.SegmentSeparator), nil
tfProviderIDStr := tfProvider.IDString()
return strings.Join([]string{tfProviderIDStr, resourceType, resourceName}, resources.SegmentSeparator), nil
}

// NewKusionResource creates a Kusion Resource object with the given resourceType, resourceID, attributes.
Expand Down
5 changes: 5 additions & 0 deletions pkg/resources/terraform/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ type TFProvider struct {
func (tp TFProvider) String() string {
return tp.Hostname.ForDisplay() + resources.SegmentSeparator + tp.Namespace + resources.SegmentSeparator + tp.Type
}

// String returns an FQN string, intended for use in machine-readable output.
func (tp TFProvider) IDString() string {
return tp.Namespace + resources.SegmentSeparator + tp.Type
}