mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
This is part of a general effort to move all of Terraform's non-library package surface under internal in order to reinforce that these are for internal use within Terraform only. If you were previously importing packages under this prefix into an external codebase, you could pin to an earlier release tag as an interim solution until you've make a plan to achieve the same functionality some other way.
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package json
|
|
|
|
import (
|
|
"github.com/zclconf/go-cty/cty"
|
|
ctyjson "github.com/zclconf/go-cty/cty/json"
|
|
|
|
"github.com/hashicorp/terraform/internal/addrs"
|
|
)
|
|
|
|
type ResourceAddr struct {
|
|
Addr string `json:"addr"`
|
|
Module string `json:"module"`
|
|
Resource string `json:"resource"`
|
|
ImpliedProvider string `json:"implied_provider"`
|
|
ResourceType string `json:"resource_type"`
|
|
ResourceName string `json:"resource_name"`
|
|
ResourceKey ctyjson.SimpleJSONValue `json:"resource_key"`
|
|
}
|
|
|
|
func newResourceAddr(addr addrs.AbsResourceInstance) ResourceAddr {
|
|
resourceKey := ctyjson.SimpleJSONValue{Value: cty.NilVal}
|
|
if addr.Resource.Key != nil {
|
|
resourceKey.Value = addr.Resource.Key.Value()
|
|
}
|
|
return ResourceAddr{
|
|
Addr: addr.String(),
|
|
Module: addr.Module.String(),
|
|
Resource: addr.Resource.String(),
|
|
ImpliedProvider: addr.Resource.Resource.ImpliedProvider(),
|
|
ResourceType: addr.Resource.Resource.Type,
|
|
ResourceName: addr.Resource.Resource.Name,
|
|
ResourceKey: resourceKey,
|
|
}
|
|
}
|