Documentation
¶
Index ¶
- Variables
- func CheckAttrHasPrefix(prefix string) resource.CheckResourceAttrWithFunc
- func CheckListAttr(resourceName, attrPrefix string, variable config.Variable, path ...any) resource.TestCheckFunc
- func CheckObjectAttr(resourceName, attrPrefix string, variable config.Variable, path ...any) resource.TestCheckFunc
- func ConvertConfigVariable(variable config.Variable, path ...any) string
- func CreateDefaultLocalFile() os.File
- func GetTestProjectServiceAccountToken(path string) string
- func ResourceNameWithDateTime(name string) string
- type ConfigBuilder
- func (b *ConfigBuilder) BuildClientOptions(service customEndpointConfig, setRegion bool) []sdkConf.ConfigurationOption
- func (b *ConfigBuilder) BuildProviderConfig() string
- func (b *ConfigBuilder) CustomEndpoint(endpoint customEndpointConfig, url string) *ConfigBuilder
- func (b *ConfigBuilder) EnableBetaResources(enable bool) *ConfigBuilder
- func (b *ConfigBuilder) Experiments(experiments ...Experiment) *ConfigBuilder
- func (b *ConfigBuilder) Region(region string) *ConfigBuilder
- func (b *ConfigBuilder) ServiceAccountToken(token string) *ConfigBuilder
- type Experiment
- type MockResponse
- type MockServer
Constants ¶
This section is empty.
Variables ¶
var ( // TestAccProtoV6ProviderFactories is used to instantiate a provider during // acceptance testing. The factory function will be invoked for every Terraform // CLI command executed to create a provider server to which the CLI can // reattach. TestAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){ "stackit": providerserver.NewProtocol6WithError(stackit.New("test-version")()), } // TestEphemeralAccProtoV6ProviderFactories is used to instantiate a provider during // acceptance testing. The factory function will be invoked for every Terraform // CLI command executed to create a provider server to which the CLI can // reattach. // // See the Terraform acceptance test documentation on ephemeral resources for more information: // https://developer.hashicorp.com/terraform/plugin/testing/acceptance-tests/ephemeral-resources TestEphemeralAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){ "stackit": providerserver.NewProtocol6WithError(stackit.New("test-version")()), "echo": echoprovider.NewProviderServer(), } // E2ETestsEnabled checks if end-to-end tests should be run. // It is enabled when the TF_ACC environment variable is set to "1". E2ETestsEnabled = os.Getenv("TF_ACC") == "1" // OrganizationId is the id of organization used for tests OrganizationId = os.Getenv("TF_ACC_ORGANIZATION_ID") // ProjectId is the id of project used for tests ProjectId = os.Getenv("TF_ACC_PROJECT_ID") Region = os.Getenv("TF_ACC_REGION") // TestProjectParentContainerID is the container id of the parent resource under which projects are created as part of the resource-manager acceptance tests TestProjectParentContainerID = os.Getenv("TF_ACC_TEST_PROJECT_PARENT_CONTAINER_ID") // TestProjectParentUUID is the uuid of the parent resource under which projects are created as part of the resource-manager acceptance tests TestProjectParentUUID = os.Getenv("TF_ACC_TEST_PROJECT_PARENT_UUID") // TestProjectServiceAccountEmail is the e-mail of a service account with admin permissions on the organization under which projects are created as part of the resource-manager acceptance tests TestProjectServiceAccountEmail = os.Getenv("TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL") // TestProjectUserEmail is the e-mail of a user for the project created as part of the resource-manager acceptance tests // Default email: acc-test@sa.stackit.cloud TestProjectUserEmail = getenv("TF_ACC_TEST_PROJECT_USER_EMAIL", "acc-test@sa.stackit.cloud") // TestImageLocalFilePath is the local path to an image file used for image acceptance tests TestImageLocalFilePath = getenv("TF_ACC_TEST_IMAGE_LOCAL_FILE_PATH", "default") ALBCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} ALBCertCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} AlbWafCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} CdnCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} DnsCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} DremioCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} EdgeCloudCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} GitCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} IaaSCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} KMSCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} LoadBalancerCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} LogMeCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} LogsCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} MariaDBCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} ModelServingCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} AuthorizationCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} MongoDBFlexCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} OpenSearchCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} ObservabilityCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} ObjectStorageCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} PostgresFlexCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} RabbitMQCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} RedisCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} ResourceManagerCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} ScfCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} SecretsManagerCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} SQLServerFlexCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} ServerBackupCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} ServerUpdateCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} SFSCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} ServiceAccountCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} TokenCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} VpnCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} SKECustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} IntakeCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} TelemetryRouterCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} TelemetryLinkCustomEndpoint = customEndpointConfig{/* contains filtered or unexported fields */} )
Functions ¶
func CheckAttrHasPrefix ¶ added in v0.92.0
func CheckAttrHasPrefix(prefix string) resource.CheckResourceAttrWithFunc
CheckAttrHasPrefix returns a CheckResourceAttrWithFunc that validates whether an attribute value starts with the given prefix.
func CheckListAttr ¶ added in v0.107.0
func CheckListAttr(resourceName, attrPrefix string, variable config.Variable, path ...any) resource.TestCheckFunc
CheckListAttr asserts a list's count ("<attrPrefix>.#") and all elements in one call. Accepts an optional path for nested variables and recursively flattens elements (scalars or objects) to match Terraform state format
func CheckObjectAttr ¶ added in v0.107.0
func CheckObjectAttr(resourceName, attrPrefix string, variable config.Variable, path ...any) resource.TestCheckFunc
CheckObjectAttr asserts all fields of an object variable in one call. Accepts an optional path for nested variables and recursively flattens fields (scalars, lists or nested objects) to match Terraform state format.
func ConvertConfigVariable ¶ added in v0.52.0
ConvertConfigVariable converts a config.Variable to a string for resource.TestCheckResourceAttr. For composite types, pass int indices or string keys to select a nested leaf. E.g., ConvertConfigVariable(list, 0) or ConvertConfigVariable(obj, "key").
func CreateDefaultLocalFile ¶ added in v0.43.1
CreateDefaultLocalFile is a helper for local_file_path. No real data is created
func GetTestProjectServiceAccountToken ¶ added in v0.57.0
Types ¶
type ConfigBuilder ¶ added in v0.90.0
type ConfigBuilder struct {
// contains filtered or unexported fields
}
func NewConfigBuilder ¶ added in v0.90.0
func NewConfigBuilder() *ConfigBuilder
NewConfigBuilder creates a new ConfigBuilder with region eu01 as default. All custom endpoints defined in TF_ACC_*_CUSTOM_ENDPOINT env vars are also set.
func (*ConfigBuilder) BuildClientOptions ¶ added in v0.90.0
func (b *ConfigBuilder) BuildClientOptions(service customEndpointConfig, setRegion bool) []sdkConf.ConfigurationOption
func (*ConfigBuilder) BuildProviderConfig ¶ added in v0.90.0
func (b *ConfigBuilder) BuildProviderConfig() string
func (*ConfigBuilder) CustomEndpoint ¶ added in v0.90.0
func (b *ConfigBuilder) CustomEndpoint(endpoint customEndpointConfig, url string) *ConfigBuilder
func (*ConfigBuilder) EnableBetaResources ¶ added in v0.90.0
func (b *ConfigBuilder) EnableBetaResources(enable bool) *ConfigBuilder
func (*ConfigBuilder) Experiments ¶ added in v0.90.0
func (b *ConfigBuilder) Experiments(experiments ...Experiment) *ConfigBuilder
func (*ConfigBuilder) Region ¶ added in v0.90.0
func (b *ConfigBuilder) Region(region string) *ConfigBuilder
func (*ConfigBuilder) ServiceAccountToken ¶ added in v0.90.0
func (b *ConfigBuilder) ServiceAccountToken(token string) *ConfigBuilder
type Experiment ¶ added in v0.90.0
type Experiment string
const ( ExperimentRoutingTables Experiment = "routing-tables" ExperimentNetwork Experiment = "network" ExperimentIAM Experiment = "iam" ExperimentDremio Experiment = "dremio" ExperimentVPC Experiment = "vpc" )
type MockResponse ¶ added in v0.83.0
type MockResponse struct {
StatusCode int
Description string
ToJsonBody any
Handler http.HandlerFunc
}
MockResponse represents a single response that the MockServer will return for a request. If `Handler` is set, it will be used to handle the request and the other fields will be ignored. If `ToJsonBody` is set, it will be marshaled to JSON and returned as the response body with content-type application/json. If `StatusCode` is set, it will be used as the response status code. Otherwise, http.StatusOK will be used.
type MockServer ¶ added in v0.83.0
func NewMockServer ¶ added in v0.83.0
func NewMockServer(t *testing.T, responses ...MockResponse) *MockServer
NewMockServer creates a new simple mock server that returns `responses` in order for each request. Use the `Reset` method to reset the response order and set new responses.
func (*MockServer) Reset ¶ added in v0.83.0
func (m *MockServer) Reset(responses ...MockResponse)
func (*MockServer) ServeHTTP ¶ added in v0.83.0
func (m *MockServer) ServeHTTP(w http.ResponseWriter, r *http.Request)