resource

package
v0.0.0-...-22a4003 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: Apache-2.0, MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SubstituteExamplePaths

func SubstituteExamplePaths(config string) string

func SubstituteTestPaths

func SubstituteTestPaths(config string) string

Types

type CustomCode

type CustomCode struct {

	// All custom code attributes are string-typed.  The string should
	// be the name of a template file which will be compiled in the
	// specified / described place.
	//
	// ======================
	// schema.Resource stuff
	// ======================
	// Extra Schema Entries go below all other schema entries in the
	// resource's Resource.Schema map.  They should be formatted as
	// entries in the map, e.g. `"foo": &schema.Schema{ ... },`.
	ExtraSchemaEntry string `yaml:"extra_schema_entry"`

	// ====================
	// Encoders & Decoders
	// ====================
	// The encoders are functions which take the `obj` map after it
	// has been assembled in either "Create" or "Update" and mutate it
	// before it is sent to the server.  There are lots of reasons you
	// might want to use these - any differences between local schema
	// and remote schema will be placed here.
	// Because the call signature of this function cannot be changed,
	// the template will place the function header and closing } for
	// you, and your custom code template should *not* include them.
	Encoder string

	// The update encoder is the encoder used in Update - if one is
	// not provided, the regular encoder is used.  If neither is
	// provided, of course, neither is used.  Similarly, the custom
	// code should *not* include the function header or closing }.
	// Update encoders are only used if object.input is false,
	// because when object.input is true, only individual fields
	// can be updated - in that case, use a custom expander.
	UpdateEncoder string `yaml:"update_encoder"`

	// The decoder is the opposite of the encoder - it's called
	// after the Read succeeds, rather than before Create / Update
	// are called.  Like with encoders, the decoder should not
	// include the function header or closing }.
	Decoder string

	// =====================
	// Simple customizations
	// =====================
	// Constants go above everything else in the file, and include
	// things like methods that will be referred to by name elsewhere
	// (e.g. "fooBarDiffSuppress") and regexes that are necessarily
	// exported (e.g. "fooBarValidationRegex").
	Constants string

	// This code is run before the Create call happens.  It's placed
	// in the Create function, just before the Create call is made.
	PreCreate string `yaml:"pre_create"`

	// This code is run after the Create call succeeds.  It's placed
	// in the Create function directly without modification.
	PostCreate string `yaml:"post_create"`

	// This code is run after the Create call fails before the error is
	// returned. It's placed in the Create function directly without
	// modification.
	PostCreateFailure string `yaml:"post_create_failure"`

	// This code replaces the entire contents of the Create call. It
	// should be used for resources that don't have normal creation
	// semantics that cannot be supported well by other MM features.
	CustomCreate string `yaml:"custom_create"`

	// This code is run before the Read call happens.  It's placed
	// in the Read function.
	PreRead string `yaml:"pre_read"`

	// This code is run after Read calls happen.  It's placed in the
	// Read function and also after the nested_query read call.
	PostRead string `yaml:"post_read"`

	// This code is run before the Update call happens.  It's placed
	// in the Update function, just after the encoder call, before
	// the Update call.  Just like the encoder, it is only used if
	// object.input is false.
	PreUpdate string `yaml:"pre_update"`

	// This code is run after the Update call happens.  It's placed
	// in the Update function, just after the call succeeds.
	// Just like the encoder, it is only used if object.input is
	// false.
	PostUpdate string `yaml:"post_update"`

	// This code replaces the entire contents of the Update call. It
	// should be used for resources that don't have normal update
	// semantics that cannot be supported well by other MM features.
	CustomUpdate string `yaml:"custom_update"`

	// This code is run just before the Delete call happens.  It's
	// useful to prepare an object for deletion, e.g. by detaching
	// a disk before deleting it.
	PreDelete string `yaml:"pre_delete"`

	// This code is run just after the Delete call happens.
	PostDelete string `yaml:"post_delete"`

	// This code replaces the entire delete method.  Since the delete
	// method's function header can't be changed, the template
	// inserts that for you - do not include it in your custom code.
	CustomDelete string `yaml:"custom_delete"`

	// This code replaces the entire import method.  Since the import
	// method's function header can't be changed, the template
	// inserts that for you - do not include it in your custom code.
	CustomImport string `yaml:"custom_import"`

	// This code is run just after the import method succeeds - it
	// is useful for parsing attributes that are necessary for
	// the Read() method to succeed.
	PostImport string `yaml:"post_import"`

	// This code is run in the generated test file to check that the
	// resource was successfully deleted. Use this if the API responds
	// with a success HTTP code for deleted resources
	TestCheckDestroy string `yaml:"test_check_destroy"`

	ValidateRawResourceConfigFuncs string `yaml:"raw_resource_config_validation"`

	// ====================
	// TGC Encoders & Decoders
	// ====================
	TgcEncoder string `yaml:"tgc_encoder"`

	TgcDecoder string `yaml:"tgc_decoder"`
}

Inserts custom code into terraform resources.

type Datasource

type Datasource struct {
	// boolean to determine whether the datasource file should be generated
	Generate bool `yaml:"generate"`
}

type Docs

type Docs struct {
	// All these values should be strings, which will be inserted
	// directly into the terraform resource documentation.  The
	// strings should _not_ be the names of template files
	// (This should be reconsidered if we find ourselves repeating
	// any string more than ones), but rather the actual text
	// (including markdown) which needs to be injected into the
	// template.
	// The text will be injected at the bottom of the specified
	// section.
	Warning string

	Note string

	RequiredProperties string `yaml:"required_properties"`

	OptionalProperties string `yaml:"optional_properties"`

	WriteOnlyProperties string `yaml:"write_only_properties"`

	Attributes string
}

Inserts custom strings into terraform resource docs.

type EnsureValue

type EnsureValue struct {
	// Field is the API field name that needs to be updated before deletion.
	// Can include dot notation for nested fields (e.g., "settings.deletionProtectionEnabled").
	Field string `yaml:"field,omitempty"`

	// Value is the required value that Field must be set to before deletion.
	// For boolean fields use "true" or "false", for integers use string representation,
	// for string fields use the exact string value required. The template automatically
	// converts this string to the appropriate type in the API request.
	// Example values: "false", "0", "DISABLED".
	Value string `yaml:"value,omitempty"`

	// IncludeFullResource determines whether to send the entire resource object
	// with the updated field (true) or to send just the field that needs updating (false)
	// in the update request payload. Some APIs require the full resource to be sent
	// in update operations. Defaults to false if not specified.
	IncludeFullResource bool `yaml:"include_full_resource,omitempty"`
}

EnsureValue specifies a field and value that must be set before a resource can be deleted. Used for resources that have fields like 'deletionProtectionEnabled' that must be explicitly disabled before the resource can be deleted.

type Examples

type Examples struct {
	// The name of the example in lower snake_case.
	// Generally takes the form of the resource name followed by some detail
	// about the specific test. For example, "address_with_subnetwork".
	Name string

	// The id of the "primary" resource in an example. Used in import tests.
	// This is the value that will appear in the Terraform config url. For
	// example:
	// resource "google_compute_address" {{primary_resource_id}} {
	//   ...
	// }
	PrimaryResourceId string `yaml:"primary_resource_id"`

	// Optional resource type of the "primary" resource. Used in import tests.
	// If set, this will override the default resource type implied from the
	// object parent
	PrimaryResourceType string `yaml:"primary_resource_type,omitempty"`

	// BootstrapIam will automatically bootstrap the given member/role pairs.
	// This should be used in cases where specific IAM permissions must be
	// present on the default test project, to avoid race conditions between
	// tests. Permissions attached to resources created in a test should instead
	// be provisioned with standard terraform resources.
	BootstrapIam []IamMember `yaml:"bootstrap_iam,omitempty"`

	// Vars is a Hash from template variable names to output variable names.
	// It will use the provided value as a prefix for generated tests, and
	// insert it into the docs verbatim.
	Vars map[string]string

	// Some variables need to hold special values during tests, and cannot
	// be inferred by Open in Cloud Shell.  For instance, org_id
	// needs to be the correct value during integration tests, or else
	// org tests cannot pass. Other examples include an existing project_id,
	// a zone, a service account name, etc.
	//
	// test_env_vars is a Hash from template variable names to one of the
	// following symbols:
	//  - PROJECT_NAME
	//  - CREDENTIALS
	//  - REGION
	//  - ORG_ID
	//  - ORG_TARGET
	//  - BILLING_ACCT
	//  - MASTER_BILLING_ACCT
	//  - SERVICE_ACCT
	//  - CUST_ID
	//  - IDENTITY_USER
	//  - CHRONICLE_ID
	//  - VMWAREENGINE_PROJECT
	// This list corresponds to the `get*FromEnv` methods in provider_test.go.
	TestEnvVars map[string]string `yaml:"test_env_vars,omitempty"`

	// Hash to provider custom override values for generating test config
	// If field my-var is set in this hash, it will replace vars[my-var] in
	// tests. i.e. if vars["network"] = "my-vpc", without override:
	//   - doc config will have `network = "my-vpc"`
	//   - tests config will have `"network = my-vpc%{random_suffix}"`
	//     with context
	//       map[string]interface{}{
	//         "random_suffix": acctest.RandString()
	//       }
	//
	// If test_vars_overrides["network"] = "nameOfVpc()"
	//   - doc config will have `network = "my-vpc"`
	//   - tests will replace with `"network = %{network}"` with context
	//       map[string]interface{}{
	//         "network": nameOfVpc
	//         ...
	//       }
	TestVarsOverrides map[string]string `yaml:"test_vars_overrides,omitempty"`

	// Hash to provider custom override values for generating oics config
	// See test_vars_overrides for more details
	OicsVarsOverrides map[string]string `yaml:"oics_vars_overrides,omitempty"`

	// The version name of of the example's version if it's different than the
	// resource version, eg. `beta`
	//
	// This should be the highest version of all the features used in the
	// example; if there's a single beta field in an example, the example's
	// min_version is beta. This is only needed if an example uses features
	// with a different version than the resource; a beta resource's examples
	// are all automatically versioned at beta.
	//
	// When an example has a version of beta, each resource must use the
	// `google-beta` provider in the config. If the `google` provider is
	// implicitly used, the test will fail.
	//
	// NOTE: Until Terraform 0.12 is released and is used in the OiCS tests, an
	// explicit provider block should be defined. While the tests @ 0.12 will
	// use `google-beta` automatically, past Terraform versions required an
	// explicit block.
	MinVersion string `yaml:"min_version,omitempty"`

	// Extra properties to ignore read on during import.
	// These properties will likely be custom code.
	IgnoreReadExtra []string `yaml:"ignore_read_extra,omitempty"`

	// Whether to skip generating tests for this resource
	ExcludeTest bool `yaml:"exclude_test,omitempty"`

	// Whether to skip generating docs for this example
	ExcludeDocs bool `yaml:"exclude_docs,omitempty"`

	// Whether to skip import tests for this example
	ExcludeImportTest bool `yaml:"exclude_import_test,omitempty"`

	// The name of the primary resource for use in IAM tests. IAM tests need
	// a reference to the primary resource to create IAM policies for
	PrimaryResourceName string `yaml:"primary_resource_name,omitempty"`

	// The name of the location/region override for use in IAM tests. IAM
	// tests may need this if the location is not inherited on the resource
	// for one reason or another
	RegionOverride string `yaml:"region_override,omitempty"`

	// The path to this example's Terraform config.
	// Defaults to `templates/terraform/examples/{{name}}.tf.erb`
	ConfigPath string `yaml:"config_path,omitempty"`

	// If the example should be skipped during VCR testing.
	// This is the case when something about the resource or config causes VCR to fail for example
	// a resource with a unique identifier generated within the resource via id.UniqueId()
	// Or a config with two fine grained resources that have a race condition during create
	SkipVcr bool `yaml:"skip_vcr,omitempty"`

	// The reason to skip a test. For example, a link to a ticket explaining the issue that needs to be resolved before
	// unskipping the test. If this is not empty, the test will be skipped.
	SkipTest string `yaml:"skip_test,omitempty"`

	// Specify which external providers are needed for the testcase.
	// Think before adding as there is latency and adds an external dependency to
	// your test so avoid if you can.
	ExternalProviders []string `yaml:"external_providers,omitempty"`

	DocumentationHCLText string `yaml:"-"`
	TestHCLText          string `yaml:"-"`
	OicsHCLText          string `yaml:"-"`

	// ====================
	// TGC
	// ====================
	// Extra properties to ignore test.
	// These properties are present in Terraform resources schema, but not in CAI assets.
	// Virtual Fields and url parameters are already ignored by default and do not need to be duplicated here.
	TGCTestIgnoreExtra []string `yaml:"tgc_test_ignore_extra,omitempty"`
	// The properties ignored in CAI assets. It is rarely used and only used
	// when the nested field has sent_empty_value: true.
	// But its parent field is C + O and not specified in raw_config.
	// Example: ['RESOURCE.cdnPolicy.signedUrlCacheMaxAgeSec'].
	// "RESOURCE" means that the property is for resource data in CAI asset.
	TGCTestIgnoreInAsset []string `yaml:"tgc_test_ignore_in_asset,omitempty"`
	// The reason to skip a test. For example, a link to a ticket explaining the issue that needs to be resolved before
	// unskipping the test. If this is not empty, the test will be skipped.
	TGCSkipTest string `yaml:"tgc_skip_test,omitempty"`
}

Generates configs to be shown as examples in docs and outputted as tests from a shared template

func (*Examples) ExecuteTemplate

func (e *Examples) ExecuteTemplate() string
func (e *Examples) OiCSLink() string

func (*Examples) ResourceType

func (e *Examples) ResourceType(terraformName string) string

func (*Examples) SetHCLText

func (e *Examples) SetHCLText()

Executes example templates for documentation and tests

func (*Examples) SetOiCSHCLText

func (e *Examples) SetOiCSHCLText()

Executes example templates for documentation and tests

func (*Examples) TestSlug

func (e *Examples) TestSlug(productName, resourceName string) string

func (*Examples) UnmarshalYAML

func (e *Examples) UnmarshalYAML(unmarshal func(any) error) error

Set default value for fields

func (*Examples) Validate

func (e *Examples) Validate(rName string)

func (*Examples) ValidateExternalProviders

func (e *Examples) ValidateExternalProviders()

type IamMember

type IamMember struct {
	Member, Role string
}

type IamPolicy

type IamPolicy struct {
	// boolean of if this binding should be generated
	Exclude bool

	// boolean of if this binding should be generated
	ExcludeTgc bool `yaml:"exclude_tgc"`

	// Boolean of if tests for IAM resources should exclude import test steps
	// Used to handle situations where typical generated IAM tests cannot import
	// due to the parent resource having an API-generated id
	ExcludeImportTest bool `yaml:"exclude_import_test"`

	// Character that separates resource identifier from method call in URL
	// For example, PubSub subscription uses {resource}:getIamPolicy
	// While Compute subnetwork uses {resource}/getIamPolicy
	MethodNameSeparator string `yaml:"method_name_separator"`

	// The terraform type (e.g. 'google_endpoints_service') of the parent resource
	// if it is not the same as the IAM resource. The IAP product needs these
	// as its IAM policies refer to compute resources.
	ParentResourceType string `yaml:"parent_resource_type"`

	// Some resources allow retrieving the IAM policy with GET requests,
	// others expect POST requests
	FetchIamPolicyVerb string `yaml:"fetch_iam_policy_verb"`

	// Last part of URL for fetching IAM policy.
	FetchIamPolicyMethod string `yaml:"fetch_iam_policy_method"`

	// Some resources allow setting the IAM policy with POST requests,
	// others expect PUT requests
	SetIamPolicyVerb string `yaml:"set_iam_policy_verb"`

	// Last part of URL for setting IAM policy.
	SetIamPolicyMethod string `yaml:"set_iam_policy_method"`

	// Whether the policy JSON is contained inside of a 'policy' object.
	WrappedPolicyObj bool `yaml:"wrapped_policy_obj"`

	// Certain resources allow different sets of roles to be set with IAM policies
	// This is a role that is acceptable for the given IAM policy resource for use in tests
	AllowedIamRole string `yaml:"allowed_iam_role"`

	// This is a role that grants create/read/delete for the parent resource for use in tests.
	// If set, the test runner will receive a binding to this role in _policy tests in order to
	// avoid getting locked out of the resource.
	AdminIamRole string `yaml:"admin_iam_role"`

	// Certain resources need an attribute other than "id" from their parent resource
	// Especially when a parent is not the same type as the IAM resource
	ParentResourceAttribute string `yaml:"parent_resource_attribute"`

	// If the IAM resource test needs a new project to be created, this is the name of the project
	TestProjectName string `yaml:"test_project_name"`

	// Resource name may need a custom diff suppress function. Default is to use
	// CompareSelfLinkOrResourceName
	CustomDiffSuppress *string `yaml:"custom_diff_suppress"`

	// Some resources (IAP) use fields named differently from the parent resource.
	// We need to use the parent's attributes to create an IAM policy, but they may not be
	// named as the IAM resource expects.
	// This allows us to specify a file (relative to MM root) containing a partial terraform
	// config with the test/example attributes of the IAM resource.
	ExampleConfigBody string `yaml:"example_config_body"`

	// How the API supports IAM conditions
	IamConditionsRequestType string `yaml:"iam_conditions_request_type"`

	// Allows us to override the base_url of the resource. This is required for Cloud Run as the
	// IAM resources use an entirely different base URL from the actual resource
	BaseUrl string `yaml:"base_url"`

	// Allows us to override the import format of the resource. Useful for Cloud Run where we need
	// variables that are outside of the base_url qualifiers.
	ImportFormat []string `yaml:"import_format"`

	// Allows us to override the self_link of the resource. This is required for Artifact Registry
	// to prevent breaking changes
	SelfLink string `yaml:"self_link"`

	// [Optional] Version number in the request payload.
	// if set, it overrides the default IamPolicyVersion
	IamPolicyVersion string `yaml:"iam_policy_version"`

	// [Optional] Min version to make IAM resources available at
	// If unset, defaults to 'ga'
	MinVersion string `yaml:"min_version"`

	// [Optional] Check to see if zone value should be replaced with GOOGLE_ZONE in iam tests
	// Defaults to true
	SubstituteZoneValue bool `yaml:"substitute_zone_value"`

	// Add a deprecation message for a resource that's been deprecated in the API.
	DeprecationMessage string `yaml:"deprecation_message,omitempty"`
}

Information about the IAM policy for this resource Several GCP resources have IAM policies that are scoped to and accessed via their parent resource See: https://cloud.google.com/iam/docs/overview

func (*IamPolicy) UnmarshalYAML

func (p *IamPolicy) UnmarshalYAML(unmarshal func(any) error) error

func (*IamPolicy) Validate

func (p *IamPolicy) Validate(rName string)

type NestedQuery

type NestedQuery struct {
	// A list of keys to traverse in order.
	// i.e. backendBucket --> cdnPolicy.signedUrlKeyNames
	// should be ["cdnPolicy", "signedUrlKeyNames"]
	Keys []string

	// If true, we expect the the nested list to be
	// a list of IDs for the nested resource, rather
	// than a list of nested resource objects
	// i.e. backendBucket.cdnPolicy.signedUrlKeyNames is a list of key names
	// rather than a list of the actual key objects
	IsListOfIds bool `yaml:"is_list_of_ids"`

	// If true, the resource is created/updated/deleted by patching
	// the parent resource and appropriate encoders/update_encoders/pre_delete
	// custom code will be included automatically. Only use if parent resource
	// does not have a separate endpoint (set as create/delete/update_urls)
	// for updating this resource.
	// The resulting encoded data will be mapped as
	// {
	//  keys[-1] : list_of_objects
	// }
	ModifyByPatch bool `yaml:"modify_by_patch"`
}

Metadata for resources that are nested within a parent resource, as a list of resources or single object within the parent. e.g. Fine-grained resources

func (*NestedQuery) Validate

func (q *NestedQuery) Validate(rName string)

type ParentResource

type ParentResource struct {
	// ResourceType is the type name of the parent resource (e.g., "google_container_cluster")
	// used to find the corresponding parent sweeper logic.
	ResourceType string `yaml:"resource_type"`

	// ParentField specifies which field to extract from the parent resource object.
	// This value is then used either directly as the parent identifier or as input
	// for the Template. Example: "name" or "id".
	// Required unless Template is provided.
	ParentField string `yaml:"parent_field"`

	// ParentFieldRegex is a regex pattern with at least one capture group used to
	// extract a specific portion of the ParentField value. The first capture group's
	// match will be used as the final value for substitution in the Template's
	// {{value}} placeholder or as the parent identifier if Template is not used.
	ParentFieldRegex string `yaml:"parent_field_regex"`

	// ParentFieldExtractName, when true, indicates the ParentField contains a self_link
	// URL (e.g., "projects/p/zones/z/instances/i"). It extracts just the final
	// resource name component ("i") from the URL path. This extracted name is then used
	// for substitution in the Template's {{value}} placeholder or as the parent
	// identifier if Template is not used.
	ParentFieldExtractName bool `yaml:"parent_field_extract_name"`

	// ChildField is the field name within the *child* resource's API list/get URL
	// (defined in base_url/self_link) that needs to be populated with the identifier
	// derived from the parent resource (via ParentField/Template).
	// Example: "cluster", "instance".
	ChildField string `yaml:"child_field"`

	// Template provides a format string to construct the parent reference identifier
	// needed in the child resource's URL. Variables in {{curly_braces}} are replaced
	// with values from the parent resource object (e.g., {{project}}, {{location}}).
	// The special placeholder {{value}} is populated with the processed parent field
	// value (obtained from ParentField, potentially modified by ParentFieldRegex or
	// ParentFieldExtractName).
	// Example: "projects/{{project}}/locations/{{location}}/clusters/{{value}}"
	// If specified, Template takes precedence over using the raw ParentField value.
	// At least one of ParentField or Template is required.
	Template string `yaml:"template"`
}

ParentResource specifies how to handle parent-child resource dependencies during sweeping. It defines how to identify and reference the parent resource when listing or processing child resources.

type ReferenceLinks struct {
	// guides containing
	//    name: The title of the link
	//    value: The URL to navigate on click
	Guides map[string]string

	// the url of the API guider
	Api string
}

Represents a list of documentation links.

type Sweeper

type Sweeper struct {
	// IdentifierField specifies which field in the resource object should be used
	// to identify resources for deletion. If not specified, defaults to "name"
	// if present in the resource, otherwise falls back to "id".
	IdentifierField string `yaml:"identifier_field"`

	// Regions (deprecated - use url_substitutions) defines which regions to run
	// the sweeper in. If empty, defaults to just us-central1. Note that
	// URLSubstitutions provides more granular control over list request parameters,
	// including regions.
	Regions []string `yaml:"regions,omitempty"`

	// Prefixes specifies name prefixes that identify resources eligible for sweeping.
	// Resources whose names start with any of these prefixes will be deleted.
	// By default, resources with the "tf-test-" prefix are automatically eligible
	// for sweeping even if no prefixes are specified here.
	Prefixes []string `yaml:"prefixes,omitempty"`

	// URLSubstitutions allows customizing URL parameters when listing resources.
	// Each map entry represents a set of key-value pairs to substitute in the
	// base_url template when listing resources. This is commonly used to specify
	// regions or other parameters required for the list API call. If not specified,
	// the sweeper will typically only run in the default region (us-central1) and
	// zone (us-central1-a), depending on the resource's base_url structure.
	URLSubstitutions []map[string]string `yaml:"url_substitutions,omitempty"`

	// Dependencies lists other resource types (e.g., "google_compute_instance")
	// that must be swept *before* this resource type. This ensures proper cleanup
	// order for resources with dependencies. If not specified, no dependencies
	// are assumed.
	Dependencies []string `yaml:"dependencies,omitempty"`

	// Parent configures sweeping for resources that depend on parent resources
	// (like a nodepool that belongs to a cluster). When specified, the sweeper
	// will first collect parent resources before listing and deleting child resources.
	// See the ParentResource struct for configuration details.
	Parent *ParentResource `yaml:"parent,omitempty"`

	// QueryString allows appending additional query parameters to the resource's
	// delete URL when performing delete operations. Format should include the
	// starting character, e.g., "?force=true" or "&verbose=true". If not specified,
	// no additional query parameters are added to the delete request.
	QueryString string `yaml:"query_string,omitempty"`

	// EnsureValue specifies a field that must be set to a specific value before
	// deletion can occur. This is used for resources that have fields like
	// 'deletionProtection' that must be explicitly disabled before the API allows
	// deletion. The sweeper automatically handles checking the current value and
	// updating it if necessary before attempting deletion. See the EnsureValue
	// struct for configuration details.
	EnsureValue *EnsureValue `yaml:"ensure_value,omitempty"`
}

Sweeper provides configuration for the test sweeper to clean up test resources. Sweepers are a testing infrastructure mechanism that automatically clean up resources created during tests. They run before tests start and can be run manually to clean up dangling resources. Sweepers help prevent test failures due to resource quota limits and reduce cloud infrastructure costs by removing test resources that were not properly cleaned up.

Sweeper generation is enabled by default, except for resources with custom deletion code, parent-child relationships (unless configured via Parent), or complex URL parameters. Defining the sweeper block overrides these exclusions.

func (Sweeper) EnvVarInterpolate

func (s Sweeper) EnvVarInterpolate(value string) string

EnvVarInterpolate takes a string and replaces any environment variable patterns with their corresponding function calls, returning a valid Go expression.

type Validation

type Validation struct {
	// Ensures the value matches this regex
	Regex    string
	Function string
}

Support for schema ValidateFunc functionality.

Jump to

Keyboard shortcuts

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