Documentation ¶
Index ¶
- Constants
- func AddOptionalFieldsToSchema(schema map[string]*schema.Schema, keys ...string)
- func AddRequiredFieldsToSchema(schema map[string]*schema.Schema, keys ...string)
- func BuildReplacementFunc(re *regexp.Regexp, d TerraformResourceData, config *transport_tpg.Config, ...) (func(string) string, error)
- func CalcAddRemove(from []string, to []string) (add, remove []string)
- func CanonicalizeServiceScope(scope string) string
- func CanonicalizeServiceScopes(scopes []string) []string
- func ChangeFieldSchemaToForceNew(sch *schema.Schema)
- func CheckGCSName(name string) error
- func CheckGoogleIamPolicy(value string) error
- func CheckStringMap(v interface{}) map[string]string
- func CommonRefreshFunc(w Waiter) resource.StateRefreshFunc
- func CompareResourceNames(_, old, new string, _ *schema.ResourceData) bool
- func CompareSelfLinkOrResourceName(_, old, new string, _ *schema.ResourceData) bool
- func CompareSelfLinkRelativePaths(_, old, new string, _ *schema.ResourceData) bool
- func Convert(item, out interface{}) error
- func ConvertAndMapStringArr(ifaceArr []interface{}, f func(string) string) []string
- func ConvertSelfLinkToV1(link string) string
- func ConvertStringArr(ifaceArr []interface{}) []string
- func ConvertStringArrToInterface(strs []string) []interface{}
- func ConvertStringMap(v map[string]interface{}) map[string]string
- func ConvertStringSet(set *schema.Set) []string
- func ConvertToMap(item interface{}) (map[string]interface{}, error)
- func DatasourceSchemaFromResourceSchema(rs map[string]*schema.Schema) map[string]*schema.Schema
- func DefaultProviderProject(_ context.Context, diff *schema.ResourceDiff, meta interface{}) error
- func DefaultProviderRegion(_ context.Context, diff *schema.ResourceDiff, meta interface{}) error
- func DefaultProviderZone(_ context.Context, diff *schema.ResourceDiff, meta interface{}) error
- func ExpandBuildEnvironmentVariables(d *schema.ResourceData) map[string]string
- func ExpandEffectiveLabels(d TerraformResourceData) map[string]string
- func ExpandEnvironmentVariables(d *schema.ResourceData) map[string]string
- func ExpandLabels(d TerraformResourceData) map[string]string
- func ExpandString(v interface{}, d TerraformResourceData, config *transport_tpg.Config) (string, error)
- func ExpandStringMap(d TerraformResourceData, key string) map[string]string
- func ExtractFieldByPattern(fieldName, fieldValue, parentFieldValue, pattern string) (string, error)
- func ExtractFirstMapConfig(m []interface{}) map[string]interface{}
- func Fake404(reasonResourceType, resourceName string) *googleapi.Error
- func FixDatasourceSchemaFlags(schema map[string]*schema.Schema, required bool, keys ...string)
- func FrameworkDiagsToSdkDiags(fwD fwDiags.Diagnostics) *diag.Diagnostics
- func GenerateUserAgentString(d TerraformResourceData, currentUserAgent string) (string, error)
- func GetBillingProject(d TerraformResourceData, config *transport_tpg.Config) (string, error)
- func GetBillingProjectFromSchema(billingProjectSchemaField string, d TerraformResourceData, ...) (string, error)
- func GetContentMd5Hash(content []byte) string
- func GetFileMd5Hash(filename string) string
- func GetImportIdQualifiers(idRegexes []string, d TerraformResourceData, config *transport_tpg.Config, ...) (map[string]string, error)
- func GetInterconnectAttachmentLink(config *transport_tpg.Config, project, region, ic, userAgent string) (string, error)
- func GetLocation(d TerraformResourceData, config *transport_tpg.Config) (string, error)
- func GetLocationalResourcePropertiesFromSelfLinkString(selfLink string) (string, string, string, error)
- func GetProject(d TerraformResourceData, config *transport_tpg.Config) (string, error)
- func GetProjectFromDiff(d *schema.ResourceDiff, config *transport_tpg.Config) (string, error)
- func GetProjectFromSchema(projectSchemaField string, d TerraformResourceData, ...) (string, error)
- func GetRegion(d TerraformResourceData, config *transport_tpg.Config) (string, error)
- func GetRegionFromDiff(d *schema.ResourceDiff, config *transport_tpg.Config) (string, error)
- func GetRegionFromRegionalSelfLink(selfLink string) string
- func GetRegionFromSchema(regionSchemaField, zoneSchemaField string, d TerraformResourceData, ...) (string, error)
- func GetRegionFromZone(zone string) string
- func GetRegionalResourcePropertiesFromSelfLinkOrSchema(d *schema.ResourceData, config *transport_tpg.Config) (string, string, string, error)
- func GetRelativePath(selfLink string) (string, error)
- func GetResourceAttributes(n string, s *terraform.State) (map[string]string, error)
- func GetResourceNameFromSelfLink(link string) string
- func GetRouterLockName(region string, router string) string
- func GetUniverseDomain(d TerraformResourceData, config *transport_tpg.Config) (string, error)
- func GetUniverseDomainFromSchema(universeSchemaField string, d TerraformResourceData, ...) (string, error)
- func GetZonalResourcePropertiesFromSelfLinkOrSchema(d *schema.ResourceData, config *transport_tpg.Config) (string, string, string, error)
- func GetZone(d TerraformResourceData, config *transport_tpg.Config) (string, error)
- func GetZoneFromDiff(d *schema.ResourceDiff, config *transport_tpg.Config) (string, error)
- func GolangSetFromStringSlice(strings []string) map[string]struct{}
- func Hashcode(s string) int
- func IsConflictError(err error) bool
- func IsEmptyValue(v reflect.Value) bool
- func IsFailedPreconditionError(err error) bool
- func IsNotFoundGrpcError(err error) bool
- func IsQuotaError(err error) bool
- func IsZone(location string) bool
- func LabelsStateUpgrade(rawState map[string]interface{}, labesPrefix string) (map[string]interface{}, error)
- func MapStringArr(original []string, f func(string) string) []string
- func MergeSchemas(a, b map[string]*schema.Schema) map[string]*schema.Schema
- func MergeStringMaps(a, b map[string]string) map[string]string
- func MigrateStateNoop(v int, is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error)
- func NameFromSelfLinkStateFunc(v interface{}) string
- func OperationDone(w Waiter) bool
- func OperationWait(w Waiter, activity string, timeout time.Duration, pollInterval time.Duration) error
- func PaginatedListRequest(project, baseUrl, userAgent string, config *transport_tpg.Config, ...) ([]interface{}, error)
- func ParseImportId(idRegexes []string, d TerraformResourceData, config *transport_tpg.Config) error
- func ReplaceVars(d TerraformResourceData, config *transport_tpg.Config, linkTmpl string) (string, error)
- func ReplaceVarsForId(d TerraformResourceData, config *transport_tpg.Config, linkTmpl string) (string, error)
- func ReplaceVarsForTest(config *transport_tpg.Config, rs *terraform.ResourceState, linkTmpl string) (string, error)
- func ReplaceVarsRecursive(d TerraformResourceData, config *transport_tpg.Config, linkTmpl string, ...) (string, error)
- func ReverseStringMap(m map[string]string) map[string]string
- func SelfLinkNameHash(selfLink interface{}) int
- func SelfLinkRelativePathHash(selfLink interface{}) int
- func ServiceAccountFQN(serviceAccount string, d TerraformResourceData, config *transport_tpg.Config) (string, error)
- func SetAnnotationsDiff(_ context.Context, d *schema.ResourceDiff, meta interface{}) error
- func SetDataSourceAnnotations(d *schema.ResourceData) error
- func SetDataSourceLabels(d *schema.ResourceData) error
- func SetLabels(labels map[string]string, d *schema.ResourceData, lineage string) error
- func SetLabelsDiff(_ context.Context, d *schema.ResourceDiff, meta interface{}) error
- func SetMetadataAnnotationsDiff(_ context.Context, d *schema.ResourceDiff, meta interface{}) error
- func SetMetadataLabelsDiff(_ context.Context, d *schema.ResourceDiff, meta interface{}) error
- func SetupTestResourceDataFromConfigMap(t *testing.T, s map[string]*schema.Schema, configValues map[string]interface{}) *schema.ResourceData
- func SnakeToPascalCase(s string) string
- func StoreResourceName(resourceLink interface{}) string
- func StringInSlice(arr []string, str string) bool
- func StringScopeHashcode(v interface{}) int
- func StringSliceFromGolangSet(sset map[string]struct{}) []string
- func StringToFixed64(v string) (int64, error)
- func TerraformLabelsStateUpgrade(rawState map[string]interface{}) (map[string]interface{}, error)
- type CommonOpError
- type CommonOperation
- type CommonOperationWaiter
- func (w *CommonOperationWaiter) Error() error
- func (w *CommonOperationWaiter) IsRetryable(error) bool
- func (w *CommonOperationWaiter) OpName() string
- func (w *CommonOperationWaiter) PendingStates() []string
- func (w *CommonOperationWaiter) SetOp(op interface{}) error
- func (w *CommonOperationWaiter) State() string
- func (w *CommonOperationWaiter) TargetStates() []string
- type GlobalFieldValue
- func ParseGlobalFieldValue(resourceType, fieldValue, projectSchemaField string, d TerraformResourceData, ...) (*GlobalFieldValue, error)
- func ParseHttpHealthCheckFieldValue(healthCheck string, d TerraformResourceData, config *transport_tpg.Config) (*GlobalFieldValue, error)
- func ParseInstanceTemplateFieldValue(instanceTemplate string, d TerraformResourceData, config *transport_tpg.Config) (*GlobalFieldValue, error)
- func ParseMachineImageFieldValue(machineImage string, d TerraformResourceData, config *transport_tpg.Config) (*GlobalFieldValue, error)
- func ParseNetworkFieldValue(network string, d TerraformResourceData, config *transport_tpg.Config) (*GlobalFieldValue, error)
- func ParseSecurityPolicyFieldValue(securityPolicy string, d TerraformResourceData, config *transport_tpg.Config) (*GlobalFieldValue, error)
- func ParseSslCertificateFieldValue(sslCertificate string, d TerraformResourceData, config *transport_tpg.Config) (*GlobalFieldValue, error)
- type LocationType
- type OrganizationFieldValue
- type ProjectFieldValue
- type RegionalFieldValue
- func ParseNetworkEndpointGroupRegionalFieldValue(networkEndpointGroup string, d TerraformResourceData, ...) (*RegionalFieldValue, error)
- func ParseRegionDiskFieldValue(disk string, d TerraformResourceData, config *transport_tpg.Config) (*RegionalFieldValue, error)
- func ParseRegionalFieldValue(resourceType, fieldValue, projectSchemaField, regionSchemaField, ... string, ...) (*RegionalFieldValue, error)
- func ParseSecurityPolicyRegionalFieldValue(securityPolicy string, d TerraformResourceData, config *transport_tpg.Config) (*RegionalFieldValue, error)
- func ParseSubnetworkFieldValue(subnetwork string, d TerraformResourceData, config *transport_tpg.Config) (*RegionalFieldValue, error)
- func ParseSubnetworkFieldValueWithProjectField(subnetwork, projectField string, d TerraformResourceData, ...) (*RegionalFieldValue, error)
- type ResourceDataMock
- func (d *ResourceDataMock) Get(key string) interface{}
- func (d *ResourceDataMock) GetOk(key string) (interface{}, bool)
- func (d *ResourceDataMock) GetOkExists(key string) (interface{}, bool)
- func (d *ResourceDataMock) GetProviderMeta(dst interface{}) error
- func (d *ResourceDataMock) HasChange(key string) bool
- func (d *ResourceDataMock) Id() string
- func (d *ResourceDataMock) Set(key string, value interface{}) error
- func (d *ResourceDataMock) SetId(v string)
- func (d *ResourceDataMock) Timeout(key string) time.Duration
- type ResourceDiffMock
- func (d *ResourceDiffMock) Clear(key string) error
- func (d *ResourceDiffMock) ForceNew(key string) error
- func (d *ResourceDiffMock) Get(key string) interface{}
- func (d *ResourceDiffMock) GetChange(key string) (interface{}, interface{})
- func (d *ResourceDiffMock) GetOk(key string) (interface{}, bool)
- func (d *ResourceDiffMock) HasChange(key string) bool
- type TerraformResourceData
- type TerraformResourceDataChange
- type TerraformResourceDiff
- type Waiter
- type ZonalFieldValue
- func ParseAcceleratorFieldValue(accelerator string, d TerraformResourceData, config *transport_tpg.Config) (*ZonalFieldValue, error)
- func ParseDiskFieldValue(disk string, d TerraformResourceData, config *transport_tpg.Config) (*ZonalFieldValue, error)
- func ParseInstanceFieldValue(instance string, d TerraformResourceData, config *transport_tpg.Config) (*ZonalFieldValue, error)
- func ParseInstanceGroupFieldValue(instanceGroup string, d TerraformResourceData, config *transport_tpg.Config) (*ZonalFieldValue, error)
- func ParseMachineTypesFieldValue(machineType string, d TerraformResourceData, config *transport_tpg.Config) (*ZonalFieldValue, error)
- func ParseNetworkEndpointGroupFieldValue(networkEndpointGroup string, d TerraformResourceData, ...) (*ZonalFieldValue, error)
- func ParseZonalFieldValue(resourceType, fieldValue, projectSchemaField, zoneSchemaField string, ...) (*ZonalFieldValue, error)
- func ParseZonalFieldValueDiff(resourceType, fieldValue, projectSchemaField, zoneSchemaField string, ...) (*ZonalFieldValue, error)
Constants ¶
const ( GlobalLinkTemplate = "projects/%s/global/%s/%s" GlobalLinkBasePattern = "projects/(.+)/global/%s/(.+)" ZonalLinkTemplate = "projects/%s/zones/%s/%s/%s" ZonalLinkBasePattern = "projects/(.+)/zones/(.+)/%s/(.+)" ZonalPartialLinkBasePattern = "zones/(.+)/%s/(.+)" RegionalLinkTemplate = "projects/%s/regions/%s/%s/%s" RegionalLinkBasePattern = "projects/(.+)/regions/(.+)/%s/(.+)" RegionalPartialLinkBasePattern = "regions/(.+)/%s/(.+)" ProjectLinkTemplate = "projects/%s/%s/%s" ProjectBasePattern = "projects/(.+)/%s/(.+)" OrganizationLinkTemplate = "organizations/%s/%s/%s" OrganizationBasePattern = "organizations/(.+)/%s/(.+)" )
Variables ¶
This section is empty.
Functions ¶
func BuildReplacementFunc ¶
func BuildReplacementFunc(re *regexp.Regexp, d TerraformResourceData, config *transport_tpg.Config, linkTmpl string, shorten bool) (func(string) string, error)
This function replaces references to Terraform properties (in the form of {{var}}) with their value in Terraform It also replaces {{project}}, {{project_id_or_project}}, {{region}}, and {{zone}} with their appropriate values This function supports URL-encoding the result by prepending '%' to the field name e.g. {{%var}}
func CalcAddRemove ¶
Given two sets of references (with "from" values in self link form), determine which need to be added or removed // during an update using addX/removeX APIs.
func CheckGCSName ¶
validate name of the gcs bucket. Guidelines are located at https://cloud.google.com/storage/docs/naming-buckets this does not attempt to check for IP addresses or close misspellings of "google"
func CheckGoogleIamPolicy ¶
CheckGoogleIamPolicy makes assertions about the contents of a google_iam_policy data source's policy_data attribute
func CheckStringMap ¶
func CommonRefreshFunc ¶
func CommonRefreshFunc(w Waiter) resource.StateRefreshFunc
func CompareResourceNames ¶
func CompareResourceNames(_, old, new string, _ *schema.ResourceData) bool
Compare only the resource name of two self links/paths.
func CompareSelfLinkOrResourceName ¶
func CompareSelfLinkOrResourceName(_, old, new string, _ *schema.ResourceData) bool
CompareSelfLinkOrResourceName checks if two resources are the same resource
Use this method when the field accepts either a name or a self_link referencing a resource. The value we store (i.e. `old` in this method), must be a self_link.
func CompareSelfLinkRelativePaths ¶
func CompareSelfLinkRelativePaths(_, old, new string, _ *schema.ResourceData) bool
Compare only the relative path of two self links.
func Convert ¶
func Convert(item, out interface{}) error
Convert between two types by converting to/from JSON. Intended to switch between multiple API versions, as they are strict supersets of one another. item and out are pointers to structs
func ConvertAndMapStringArr ¶
func ConvertSelfLinkToV1 ¶
func ConvertStringArr ¶
func ConvertStringArr(ifaceArr []interface{}) []string
func ConvertStringArrToInterface ¶
func ConvertStringArrToInterface(strs []string) []interface{}
func ConvertStringMap ¶
func ConvertStringSet ¶
func ConvertToMap ¶
When converting to a map, we can't use setOmittedFields because FieldByName fails. Luckily, we don't use the omitted fields anymore with generated resources, and this function is used to bridge from handwritten -> generated. Since this is a known type, we can create it inline instead of needing to pass an object in.
func DatasourceSchemaFromResourceSchema ¶
DatasourceSchemaFromResourceSchema is a recursive func that converts an existing Resource schema to a Datasource schema. All schema elements are copied, but certain attributes are ignored or changed: - all attributes have Computed = true - all attributes have ForceNew, Required = false - Validation funcs and attributes (e.g. MaxItems) are not copied
func DefaultProviderProject ¶
func DefaultProviderProject(_ context.Context, diff *schema.ResourceDiff, meta interface{}) error
func DefaultProviderRegion ¶
func DefaultProviderRegion(_ context.Context, diff *schema.ResourceDiff, meta interface{}) error
func DefaultProviderZone ¶
func DefaultProviderZone(_ context.Context, diff *schema.ResourceDiff, meta interface{}) error
func ExpandBuildEnvironmentVariables ¶
func ExpandBuildEnvironmentVariables(d *schema.ResourceData) map[string]string
ExpandBuildEnvironmentVariables pulls the value of "build_environment_variables" out of a schema.ResourceData as a map[string]string.
func ExpandEffectiveLabels ¶
func ExpandEffectiveLabels(d TerraformResourceData) map[string]string
ExpandEffectiveLabels pulls the value of "effective_labels" out of a TerraformResourceData as a map[string]string.
func ExpandEnvironmentVariables ¶
func ExpandEnvironmentVariables(d *schema.ResourceData) map[string]string
ExpandEnvironmentVariables pulls the value of "environment_variables" out of a schema.ResourceData as a map[string]string.
func ExpandLabels ¶
func ExpandLabels(d TerraformResourceData) map[string]string
ExpandLabels pulls the value of "labels" out of a TerraformResourceData as a map[string]string.
func ExpandString ¶
func ExpandString(v interface{}, d TerraformResourceData, config *transport_tpg.Config) (string, error)
func ExpandStringMap ¶
func ExpandStringMap(d TerraformResourceData, key string) map[string]string
ExpandStringMap pulls the value of key out of a TerraformResourceData as a map[string]string.
func ExtractFieldByPattern ¶
ExtractFieldByPattern returns the value of a field extracted from a parent field according to the given regular expression pattern. An error is returned if the field already has a value different than the value extracted.
func ExtractFirstMapConfig ¶
func ExtractFirstMapConfig(m []interface{}) map[string]interface{}
func FixDatasourceSchemaFlags ¶
fixDatasourceSchemaFlags is a convenience func that toggles the Computed, Optional + Required flags on a schema element. This is useful when the schema has been generated (using `DatasourceSchemaFromResourceSchema` above for example) and therefore the attribute flags were not set appropriately when first added to the schema definition. Currently only supports top-level schema elements.
func FrameworkDiagsToSdkDiags ¶
func FrameworkDiagsToSdkDiags(fwD fwDiags.Diagnostics) *diag.Diagnostics
func GenerateUserAgentString ¶
func GenerateUserAgentString(d TerraformResourceData, currentUserAgent string) (string, error)
func GetBillingProject ¶
func GetBillingProject(d TerraformResourceData, config *transport_tpg.Config) (string, error)
GetBillingProject reads the "billing_project" field from the given resource data and falls back to the provider's value if not given. If no value is found, an error is returned.
func GetBillingProjectFromSchema ¶
func GetBillingProjectFromSchema(billingProjectSchemaField string, d TerraformResourceData, config *transport_tpg.Config) (string, error)
func GetContentMd5Hash ¶
func GetFileMd5Hash ¶
func GetImportIdQualifiers ¶
func GetImportIdQualifiers(idRegexes []string, d TerraformResourceData, config *transport_tpg.Config, id string) (map[string]string, error)
Parse an import id extracting field values using the given list of regexes. They are applied in order. The first in the list is tried first. This does not mutate any of the parameters, returning a map of matches Similar to ParseImportId in import.go, but less import specific
e.g: - projects/(?P<project>[^/]+)/regions/(?P<region>[^/]+)/subnetworks/(?P<name>[^/]+) (applied first) - (?P<project>[^/]+)/(?P<region>[^/]+)/(?P<name>[^/]+), - (?P<name>[^/]+) (applied last)
func GetInterconnectAttachmentLink ¶
func GetInterconnectAttachmentLink(config *transport_tpg.Config, project, region, ic, userAgent string) (string, error)
func GetLocation ¶
func GetLocation(d TerraformResourceData, config *transport_tpg.Config) (string, error)
GetLocation attempts to get values in this order (if they exist): - location argument in the resource config - region argument in the resource config - zone argument in the resource config - region argument in the provider config - zone argument set in the provider config
func GetLocationalResourcePropertiesFromSelfLinkString ¶
func GetLocationalResourcePropertiesFromSelfLinkString(selfLink string) (string, string, string, error)
given a full locational (non-global) self link, returns the project + region/zone + name or an error
func GetProject ¶
func GetProject(d TerraformResourceData, config *transport_tpg.Config) (string, error)
GetProject reads the "project" field from the given resource data and falls back to the provider's value if not given. If the provider's value is not given, an error is returned.
func GetProjectFromDiff ¶
func GetProjectFromDiff(d *schema.ResourceDiff, config *transport_tpg.Config) (string, error)
GetProjectFromDiff reads the "project" field from the given diff and falls back to the provider's value if not given. If the provider's value is not given, an error is returned.
func GetProjectFromSchema ¶
func GetProjectFromSchema(projectSchemaField string, d TerraformResourceData, config *transport_tpg.Config) (string, error)
func GetRegion ¶
func GetRegion(d TerraformResourceData, config *transport_tpg.Config) (string, error)
Infers the region based on the following (in order of priority): - `region` field in resource schema - region extracted from the `zone` field in resource schema - provider-level region - region extracted from the provider-level zone
func GetRegionFromDiff ¶
func GetRegionFromDiff(d *schema.ResourceDiff, config *transport_tpg.Config) (string, error)
getRegionFromDiff reads the "region" field from the given diff and falls back to the provider's value if not given. If the provider's value is not given, an error is returned.
func GetRegionFromRegionalSelfLink ¶
This function supports selflinks that have regions and locations in their paths
func GetRegionFromSchema ¶
func GetRegionFromSchema(regionSchemaField, zoneSchemaField string, d TerraformResourceData, config *transport_tpg.Config) (string, error)
Infers the region based on the following (in order of priority): - `regionSchemaField` in resource schema - region extracted from the `zoneSchemaField` in resource schema - provider-level region - region extracted from the provider-level zone
func GetRegionFromZone ¶
GetRegionFromZone returns the region from a zone for Google cloud. This is by removing the last two chars from the zone name to leave the region If there aren't enough characters in the input string, an empty string is returned e.g. southamerica-west1-a => southamerica-west1
func GetRegionalResourcePropertiesFromSelfLinkOrSchema ¶
func GetRegionalResourcePropertiesFromSelfLinkOrSchema(d *schema.ResourceData, config *transport_tpg.Config) (string, string, string, error)
func GetRelativePath ¶
func GetResourceAttributes ¶
func GetRouterLockName ¶
func GetUniverseDomain ¶
func GetUniverseDomain(d TerraformResourceData, config *transport_tpg.Config) (string, error)
GetUniverse reads the "universe_domain" field from the given resource data and falls back to the provider's value if not given. If the provider's value is not given, an error is returned.
func GetUniverseDomainFromSchema ¶
func GetUniverseDomainFromSchema(universeSchemaField string, d TerraformResourceData, config *transport_tpg.Config) (string, error)
func GetZonalResourcePropertiesFromSelfLinkOrSchema ¶
func GetZonalResourcePropertiesFromSelfLinkOrSchema(d *schema.ResourceData, config *transport_tpg.Config) (string, string, string, error)
func GetZone ¶
func GetZone(d TerraformResourceData, config *transport_tpg.Config) (string, error)
GetZone reads the "zone" value from the given resource data and falls back to provider's value if not given. If neither is provided, returns an error.
func GetZoneFromDiff ¶
func GetZoneFromDiff(d *schema.ResourceDiff, config *transport_tpg.Config) (string, error)
getZoneFromDiff reads the "zone" field from the given diff and falls back to the provider's value if not given. If the provider's value is not given, an error is returned.
func Hashcode ¶
Hashcode hashes a string to a unique hashcode.
crc32 returns a uint32, but for our use we need and non negative integer. Here we cast to an integer and invert it if the result is negative.
func IsConflictError ¶
func IsEmptyValue ¶
func IsNotFoundGrpcError ¶
gRPC does not return errors of type *googleapi.Error. Instead the errors returned are *status.Error. See the types of codes returned here (https://pkg.go.dev/google.golang.org/grpc/codes#Code).
func IsQuotaError ¶
func LabelsStateUpgrade ¶
func LabelsStateUpgrade(rawState map[string]interface{}, labesPrefix string) (map[string]interface{}, error)
Upgrade the field "labels" in the state to exclude the labels with the labels prefix and the field "effective_labels" to have all of labels, including the labels with the labels prefix
func MigrateStateNoop ¶
func MigrateStateNoop(v int, is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error)
func NameFromSelfLinkStateFunc ¶
func NameFromSelfLinkStateFunc(v interface{}) string
func OperationDone ¶
func OperationWait ¶
func PaginatedListRequest ¶
func PaginatedListRequest(project, baseUrl, userAgent string, config *transport_tpg.Config, flattener func(map[string]interface{}) []interface{}) ([]interface{}, error)
func ParseImportId ¶
func ParseImportId(idRegexes []string, d TerraformResourceData, config *transport_tpg.Config) error
Parse an import id extracting field values using the given list of regexes. They are applied in order. The first in the list is tried first.
e.g: - projects/(?P<project>[^/]+)/regions/(?P<region>[^/]+)/subnetworks/(?P<name>[^/]+) (applied first) - (?P<project>[^/]+)/(?P<region>[^/]+)/(?P<name>[^/]+), - (?P<name>[^/]+) (applied last)
func ReplaceVars ¶
func ReplaceVars(d TerraformResourceData, config *transport_tpg.Config, linkTmpl string) (string, error)
func ReplaceVarsForId ¶
func ReplaceVarsForId(d TerraformResourceData, config *transport_tpg.Config, linkTmpl string) (string, error)
relaceVarsForId shortens variables by running them through GetResourceNameFromSelfLink this allows us to use long forms of variables from configs without needing custom id formats. For instance: accessPolicies/{{access_policy}}/accessLevels/{{access_level}} with values: access_policy: accessPolicies/foo access_level: accessPolicies/foo/accessLevels/bar becomes accessPolicies/foo/accessLevels/bar
func ReplaceVarsForTest ¶
func ReplaceVarsForTest(config *transport_tpg.Config, rs *terraform.ResourceState, linkTmpl string) (string, error)
This function isn't a test of transport.go; instead, it is used as an alternative to ReplaceVars inside tests.
func ReplaceVarsRecursive ¶
func ReplaceVarsRecursive(d TerraformResourceData, config *transport_tpg.Config, linkTmpl string, shorten bool, depth int) (string, error)
ReplaceVars must be done recursively because there are baseUrls that can contain references to regions (eg cloudrun service) there aren't any cases known for 2+ recursion but we will track a run away substitution as 10+ calls to allow for future use cases.
func SelfLinkNameHash ¶
func SelfLinkNameHash(selfLink interface{}) int
Hash the name path of a self link.
func SelfLinkRelativePathHash ¶
func SelfLinkRelativePathHash(selfLink interface{}) int
Hash the relative path of a self link.
func ServiceAccountFQN ¶
func ServiceAccountFQN(serviceAccount string, d TerraformResourceData, config *transport_tpg.Config) (string, error)
ServiceAccountFQN will attempt to generate the fully qualified name in the format of:
"projects/(-|<project>)/serviceAccounts/<service_account_id>@<project>.iam.gserviceaccount.com" A project is required if we are trying to build the FQN from a service account id and and error will be returned in this case if no project is set in the resource or the provider-level config
func SetAnnotationsDiff ¶
func SetAnnotationsDiff(_ context.Context, d *schema.ResourceDiff, meta interface{}) error
func SetDataSourceAnnotations ¶
func SetDataSourceAnnotations(d *schema.ResourceData) error
Sets the "annotations" field with the value of the field "effective_annotations" for data sources. When reading data source, as the annotations field is unavailable in the configuration of the data source, the "annotations" field will be empty. With this funciton, the labels "annotations" will have all of annotations in the resource.
func SetDataSourceLabels ¶
func SetDataSourceLabels(d *schema.ResourceData) error
Sets the "labels" field and "terraform_labels" with the value of the field "effective_labels" for data sources. When reading data source, as the labels field is unavailable in the configuration of the data source, the "labels" field will be empty. With this funciton, the labels "field" will have all of labels in the resource.
func SetLabels ¶
SetLabels is called in the READ method of the resources to set the field "labels" and "terraform_labels" in the state based on the labels field in the configuration. So the field "labels" and "terraform_labels" in the state will only have the user defined labels. param "labels" is all of labels returned from API read reqeust. param "lineage" is the terraform lineage of the field and could be "labels" or "terraform_labels".
func SetLabelsDiff ¶
func SetLabelsDiff(_ context.Context, d *schema.ResourceDiff, meta interface{}) error
func SetMetadataAnnotationsDiff ¶
func SetMetadataAnnotationsDiff(_ context.Context, d *schema.ResourceDiff, meta interface{}) error
func SetMetadataLabelsDiff ¶
func SetMetadataLabelsDiff(_ context.Context, d *schema.ResourceDiff, meta interface{}) error
func SetupTestResourceDataFromConfigMap ¶
func SetupTestResourceDataFromConfigMap(t *testing.T, s map[string]*schema.Schema, configValues map[string]interface{}) *schema.ResourceData
Used to create populated schema.ResourceData structs in tests. Pass in a schema and a config map containing the fields and values you wish to set The returned schema.ResourceData can represent a configured resource, data source or provider.
func SnakeToPascalCase ¶
func StoreResourceName ¶
func StoreResourceName(resourceLink interface{}) string
func StringInSlice ¶
func StringScopeHashcode ¶
func StringScopeHashcode(v interface{}) int
func StringToFixed64 ¶
func TerraformLabelsStateUpgrade ¶
Upgrade the field "terraform_labels" in the state to have the value of filed "labels" when it is not set but "labels" field is set in the state
Types ¶
type CommonOpError ¶
type CommonOpError struct {
*cloudresourcemanager.Status
}
Wraps Op.Error in an implementation of built-in Error
func (*CommonOpError) Error ¶
func (e *CommonOpError) Error() string
type CommonOperation ¶
type CommonOperation cloudresourcemanager.Operation
The cloud resource manager API operation is an example of one of many interchangeable API operations. Choose it somewhat arbitrarily to represent the "common" operation.
type CommonOperationWaiter ¶
type CommonOperationWaiter struct {
Op CommonOperation
}
func (*CommonOperationWaiter) Error ¶
func (w *CommonOperationWaiter) Error() error
func (*CommonOperationWaiter) IsRetryable ¶
func (w *CommonOperationWaiter) IsRetryable(error) bool
func (*CommonOperationWaiter) OpName ¶
func (w *CommonOperationWaiter) OpName() string
func (*CommonOperationWaiter) PendingStates ¶
func (w *CommonOperationWaiter) PendingStates() []string
func (*CommonOperationWaiter) SetOp ¶
func (w *CommonOperationWaiter) SetOp(op interface{}) error
func (*CommonOperationWaiter) State ¶
func (w *CommonOperationWaiter) State() string
func (*CommonOperationWaiter) TargetStates ¶
func (w *CommonOperationWaiter) TargetStates() []string
type GlobalFieldValue ¶
type GlobalFieldValue struct { Project string Name string // contains filtered or unexported fields }
func ParseGlobalFieldValue ¶
func ParseGlobalFieldValue(resourceType, fieldValue, projectSchemaField string, d TerraformResourceData, config *transport_tpg.Config, isEmptyValid bool) (*GlobalFieldValue, error)
Parses a global field supporting 5 different formats: - https://www.googleapis.com/compute/ANY_VERSION/projects/{my_project}/global/{resource_type}/{resource_name} - projects/{my_project}/global/{resource_type}/{resource_name} - global/{resource_type}/{resource_name} - resource_name - "" (empty string). RelativeLink() returns empty if isEmptyValid is true.
If the project is not specified, it first tries to get the project from the `projectSchemaField` and then fallback on the default project.
func ParseHttpHealthCheckFieldValue ¶
func ParseHttpHealthCheckFieldValue(healthCheck string, d TerraformResourceData, config *transport_tpg.Config) (*GlobalFieldValue, error)
func ParseInstanceTemplateFieldValue ¶
func ParseInstanceTemplateFieldValue(instanceTemplate string, d TerraformResourceData, config *transport_tpg.Config) (*GlobalFieldValue, error)
func ParseMachineImageFieldValue ¶
func ParseMachineImageFieldValue(machineImage string, d TerraformResourceData, config *transport_tpg.Config) (*GlobalFieldValue, error)
func ParseNetworkFieldValue ¶
func ParseNetworkFieldValue(network string, d TerraformResourceData, config *transport_tpg.Config) (*GlobalFieldValue, error)
func ParseSecurityPolicyFieldValue ¶
func ParseSecurityPolicyFieldValue(securityPolicy string, d TerraformResourceData, config *transport_tpg.Config) (*GlobalFieldValue, error)
func ParseSslCertificateFieldValue ¶
func ParseSslCertificateFieldValue(sslCertificate string, d TerraformResourceData, config *transport_tpg.Config) (*GlobalFieldValue, error)
func (GlobalFieldValue) RelativeLink ¶
func (f GlobalFieldValue) RelativeLink() string
type OrganizationFieldValue ¶
type OrganizationFieldValue struct { OrgId string Name string // contains filtered or unexported fields }
func ParseOrganizationCustomRoleName ¶
func ParseOrganizationCustomRoleName(role string) (*OrganizationFieldValue, error)
func ParseOrganizationFieldValue ¶
func ParseOrganizationFieldValue(resourceType, fieldValue string, isEmptyValid bool) (*OrganizationFieldValue, error)
Parses an organization field with the following formats: - organizations/{my_organizations}/{resource_type}/{resource_name}
func (OrganizationFieldValue) RelativeLink ¶
func (f OrganizationFieldValue) RelativeLink() string
type ProjectFieldValue ¶
func ParseProjectFieldValue ¶
func ParseProjectFieldValue(resourceType, fieldValue, projectSchemaField string, d TerraformResourceData, config *transport_tpg.Config, isEmptyValid bool) (*ProjectFieldValue, error)
Parses a project field with the following formats: - projects/{my_projects}/{resource_type}/{resource_name}
func (ProjectFieldValue) RelativeLink ¶
func (f ProjectFieldValue) RelativeLink() string
type RegionalFieldValue ¶
type RegionalFieldValue struct { Project string Region string Name string // contains filtered or unexported fields }
func ParseNetworkEndpointGroupRegionalFieldValue ¶
func ParseNetworkEndpointGroupRegionalFieldValue(networkEndpointGroup string, d TerraformResourceData, config *transport_tpg.Config) (*RegionalFieldValue, error)
func ParseRegionDiskFieldValue ¶
func ParseRegionDiskFieldValue(disk string, d TerraformResourceData, config *transport_tpg.Config) (*RegionalFieldValue, error)
func ParseRegionalFieldValue ¶
func ParseRegionalFieldValue(resourceType, fieldValue, projectSchemaField, regionSchemaField, zoneSchemaField string, d TerraformResourceData, config *transport_tpg.Config, isEmptyValid bool) (*RegionalFieldValue, error)
Parses a regional field supporting 5 different formats: - https://www.googleapis.com/compute/ANY_VERSION/projects/{my_project}/regions/{region}/{resource_type}/{resource_name} - projects/{my_project}/regions/{region}/{resource_type}/{resource_name} - regions/{region}/{resource_type}/{resource_name} - resource_name - "" (empty string). RelativeLink() returns empty if isEmptyValid is true.
If the project is not specified, it first tries to get the project from the `projectSchemaField` and then fallback on the default project. If the region is not specified, see function documentation for `GetRegionFromSchema`.
func ParseSecurityPolicyRegionalFieldValue ¶
func ParseSecurityPolicyRegionalFieldValue(securityPolicy string, d TerraformResourceData, config *transport_tpg.Config) (*RegionalFieldValue, error)
func ParseSubnetworkFieldValue ¶
func ParseSubnetworkFieldValue(subnetwork string, d TerraformResourceData, config *transport_tpg.Config) (*RegionalFieldValue, error)
func ParseSubnetworkFieldValueWithProjectField ¶
func ParseSubnetworkFieldValueWithProjectField(subnetwork, projectField string, d TerraformResourceData, config *transport_tpg.Config) (*RegionalFieldValue, error)
func (RegionalFieldValue) RelativeLink ¶
func (f RegionalFieldValue) RelativeLink() string
type ResourceDataMock ¶
type ResourceDataMock struct { FieldsInSchema map[string]interface{} FieldsWithHasChange []string // contains filtered or unexported fields }
func (*ResourceDataMock) Get ¶
func (d *ResourceDataMock) Get(key string) interface{}
func (*ResourceDataMock) GetOk ¶
func (d *ResourceDataMock) GetOk(key string) (interface{}, bool)
func (*ResourceDataMock) GetOkExists ¶
func (d *ResourceDataMock) GetOkExists(key string) (interface{}, bool)
func (*ResourceDataMock) GetProviderMeta ¶
func (d *ResourceDataMock) GetProviderMeta(dst interface{}) error
func (*ResourceDataMock) HasChange ¶
func (d *ResourceDataMock) HasChange(key string) bool
func (*ResourceDataMock) Id ¶
func (d *ResourceDataMock) Id() string
func (*ResourceDataMock) Set ¶
func (d *ResourceDataMock) Set(key string, value interface{}) error
func (*ResourceDataMock) SetId ¶
func (d *ResourceDataMock) SetId(v string)
type ResourceDiffMock ¶
type ResourceDiffMock struct { Before map[string]interface{} After map[string]interface{} Cleared map[string]interface{} IsForceNew bool }
func (*ResourceDiffMock) Clear ¶
func (d *ResourceDiffMock) Clear(key string) error
func (*ResourceDiffMock) ForceNew ¶
func (d *ResourceDiffMock) ForceNew(key string) error
func (*ResourceDiffMock) Get ¶
func (d *ResourceDiffMock) Get(key string) interface{}
func (*ResourceDiffMock) GetChange ¶
func (d *ResourceDiffMock) GetChange(key string) (interface{}, interface{})
func (*ResourceDiffMock) GetOk ¶
func (d *ResourceDiffMock) GetOk(key string) (interface{}, bool)
func (*ResourceDiffMock) HasChange ¶
func (d *ResourceDiffMock) HasChange(key string) bool
type TerraformResourceData ¶
type TerraformResourceDataChange ¶
type TerraformResourceDataChange interface {
GetChange(string) (interface{}, interface{})
}
type TerraformResourceDiff ¶
type Waiter ¶
type Waiter interface { // State returns the current status of the operation. State() string // Error returns an error embedded in the operation we're waiting on, or nil // if the operation has no current error. Error() error // IsRetryable returns whether a given error should be retried. IsRetryable(error) bool // SetOp sets the operation we're waiting on in a Waiter struct so that it // can be used in other methods. SetOp(interface{}) error // QueryOp sends a request to the server to get the current status of the // operation. It's expected that QueryOp will return exactly one of an // operation or an error as non-nil, and that requests will be retried by // specific implementations of the method. QueryOp() (interface{}, error) // OpName is the name of the operation and is used to log its status. OpName() string // PendingStates contains the values of State() that cause us to continue // refreshing the operation. PendingStates() []string // TargetStates contain the values of State() that cause us to finish // refreshing the operation. TargetStates() []string }
type ZonalFieldValue ¶
func ParseAcceleratorFieldValue ¶
func ParseAcceleratorFieldValue(accelerator string, d TerraformResourceData, config *transport_tpg.Config) (*ZonalFieldValue, error)
func ParseDiskFieldValue ¶
func ParseDiskFieldValue(disk string, d TerraformResourceData, config *transport_tpg.Config) (*ZonalFieldValue, error)
func ParseInstanceFieldValue ¶
func ParseInstanceFieldValue(instance string, d TerraformResourceData, config *transport_tpg.Config) (*ZonalFieldValue, error)
func ParseInstanceGroupFieldValue ¶
func ParseInstanceGroupFieldValue(instanceGroup string, d TerraformResourceData, config *transport_tpg.Config) (*ZonalFieldValue, error)
func ParseMachineTypesFieldValue ¶
func ParseMachineTypesFieldValue(machineType string, d TerraformResourceData, config *transport_tpg.Config) (*ZonalFieldValue, error)
func ParseNetworkEndpointGroupFieldValue ¶
func ParseNetworkEndpointGroupFieldValue(networkEndpointGroup string, d TerraformResourceData, config *transport_tpg.Config) (*ZonalFieldValue, error)
func ParseZonalFieldValue ¶
func ParseZonalFieldValue(resourceType, fieldValue, projectSchemaField, zoneSchemaField string, d TerraformResourceData, config *transport_tpg.Config, isEmptyValid bool) (*ZonalFieldValue, error)
Parses a zonal field supporting 5 different formats: - https://www.googleapis.com/compute/ANY_VERSION/projects/{my_project}/zones/{zone}/{resource_type}/{resource_name} - projects/{my_project}/zones/{zone}/{resource_type}/{resource_name} - zones/{zone}/{resource_type}/{resource_name} - resource_name - "" (empty string). RelativeLink() returns empty if isEmptyValid is true.
If the project is not specified, it first tries to get the project from the `projectSchemaField` and then fallback on the default project. If the zone is not specified, it takes the value of `zoneSchemaField`.
func ParseZonalFieldValueDiff ¶
func ParseZonalFieldValueDiff(resourceType, fieldValue, projectSchemaField, zoneSchemaField string, d *schema.ResourceDiff, config *transport_tpg.Config, isEmptyValid bool) (*ZonalFieldValue, error)
Parses a zonal field supporting 5 different formats: - https://www.googleapis.com/compute/ANY_VERSION/projects/{my_project}/zones/{zone}/{resource_type}/{resource_name} - projects/{my_project}/zones/{zone}/{resource_type}/{resource_name} - zones/{zone}/{resource_type}/{resource_name} - resource_name - "" (empty string). RelativeLink() returns empty if isEmptyValid is true.
If the project is not specified, it first tries to get the project from the `projectSchemaField` and then fallback on the default project. If the zone is not specified, it takes the value of `zoneSchemaField`.
func (ZonalFieldValue) RelativeLink ¶
func (f ZonalFieldValue) RelativeLink() string