tpgresource

package
v0.0.0-...-0d862b9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2024 License: Apache-2.0, MPL-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
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 AddOptionalFieldsToSchema

func AddOptionalFieldsToSchema(schema map[string]*schema.Schema, keys ...string)

func AddRequiredFieldsToSchema

func AddRequiredFieldsToSchema(schema map[string]*schema.Schema, keys ...string)

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

func CalcAddRemove(from []string, to []string) (add, remove []string)

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 CanonicalizeServiceScope

func CanonicalizeServiceScope(scope string) string

func CanonicalizeServiceScopes

func CanonicalizeServiceScopes(scopes []string) []string

func ChangeFieldSchemaToForceNew

func ChangeFieldSchemaToForceNew(sch *schema.Schema)

func CheckGCSName

func CheckGCSName(name string) error

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

func CheckGoogleIamPolicy(value string) error

CheckGoogleIamPolicy makes assertions about the contents of a google_iam_policy data source's policy_data attribute

func CheckStringMap

func CheckStringMap(v interface{}) map[string]string

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 ConvertAndMapStringArr(ifaceArr []interface{}, f func(string) string) []string

func ConvertSelfLinkToV1

func ConvertSelfLinkToV1(link string) string

func ConvertStringArr

func ConvertStringArr(ifaceArr []interface{}) []string

func ConvertStringArrToInterface

func ConvertStringArrToInterface(strs []string) []interface{}

func ConvertStringMap

func ConvertStringMap(v map[string]interface{}) map[string]string

func ConvertStringSet

func ConvertStringSet(set *schema.Set) []string

func ConvertToMap

func ConvertToMap(item interface{}) (map[string]interface{}, error)

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

func DatasourceSchemaFromResourceSchema(rs map[string]*schema.Schema) map[string]*schema.Schema

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

func ExtractFieldByPattern(fieldName, fieldValue, parentFieldValue, pattern string) (string, error)

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 Fake404

func Fake404(reasonResourceType, resourceName string) *googleapi.Error

return a fake 404 so requests get retried or nested objects are considered deleted

func FixDatasourceSchemaFlags

func FixDatasourceSchemaFlags(schema map[string]*schema.Schema, required bool, keys ...string)

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 GetContentMd5Hash(content []byte) string

func GetFileMd5Hash

func GetFileMd5Hash(filename string) string

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(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(selfLink string) string

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

func GetRegionFromZone(zone string) string

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 GetRelativePath(selfLink string) (string, error)

func GetResourceAttributes

func GetResourceAttributes(n string, s *terraform.State) (map[string]string, error)
func GetResourceNameFromSelfLink(link string) string

func GetRouterLockName

func GetRouterLockName(region string, router string) string

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 GolangSetFromStringSlice

func GolangSetFromStringSlice(strings []string) map[string]struct{}

func Hashcode

func Hashcode(s string) int

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 IsConflictError(err error) bool

func IsEmptyValue

func IsEmptyValue(v reflect.Value) bool

func IsFailedPreconditionError

func IsFailedPreconditionError(err error) bool

func IsNotFoundGrpcError

func IsNotFoundGrpcError(err error) bool

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 IsQuotaError(err error) bool

func IsZone

func IsZone(location string) bool

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 MapStringArr

func MapStringArr(original []string, f func(string) string) []string

func MergeSchemas

func MergeSchemas(a, b map[string]*schema.Schema) map[string]*schema.Schema

func MergeStringMaps

func MergeStringMaps(a, b map[string]string) map[string]string

func MigrateStateNoop

func MigrateStateNoop(v int, is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error)

func NameFromSelfLinkStateFunc

func NameFromSelfLinkStateFunc(v interface{}) string

func OperationDone

func OperationDone(w Waiter) bool

func OperationWait

func OperationWait(w Waiter, activity string, timeout time.Duration, pollInterval time.Duration) error

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 ReverseStringMap

func ReverseStringMap(m map[string]string) map[string]string

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

func SetLabels(labels map[string]string, d *schema.ResourceData, lineage string) error

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 SnakeToPascalCase(s string) string

func StoreResourceName

func StoreResourceName(resourceLink interface{}) string

func StringInSlice

func StringInSlice(arr []string, str string) bool

func StringScopeHashcode

func StringScopeHashcode(v interface{}) int

func StringSliceFromGolangSet

func StringSliceFromGolangSet(sset map[string]struct{}) []string

func StringToFixed64

func StringToFixed64(v string) (int64, error)

func TerraformLabelsStateUpgrade

func TerraformLabelsStateUpgrade(rawState map[string]interface{}) (map[string]interface{}, error)

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 (f GlobalFieldValue) RelativeLink() string

type LocationType

type LocationType int
const (
	Zonal LocationType = iota
	Regional
	Global
)

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 (f OrganizationFieldValue) RelativeLink() string

type ProjectFieldValue

type ProjectFieldValue struct {
	Project string
	Name    string

	ResourceType string
}

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 (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 (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)

func (*ResourceDataMock) Timeout

func (d *ResourceDataMock) Timeout(key string) time.Duration

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 TerraformResourceData interface {
	HasChange(string) bool
	GetOkExists(string) (interface{}, bool)
	GetOk(string) (interface{}, bool)
	Get(string) interface{}
	Set(string, interface{}) error
	SetId(string)
	Id() string
	GetProviderMeta(interface{}) error
	Timeout(key string) time.Duration
}

type TerraformResourceDataChange

type TerraformResourceDataChange interface {
	GetChange(string) (interface{}, interface{})
}

type TerraformResourceDiff

type TerraformResourceDiff interface {
	HasChange(string) bool
	GetChange(string) (interface{}, interface{})
	Get(string) interface{}
	GetOk(string) (interface{}, bool)
	Clear(string) error
	ForceNew(string) error
}

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

type ZonalFieldValue struct {
	Project string
	Zone    string
	Name    string

	ResourceType string
}

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 (f ZonalFieldValue) RelativeLink() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL