fix: refactor tests
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 5s
CI Workflow / Test readiness for publishing provider (pull_request) Failing after 3m27s
CI Workflow / CI run tests (pull_request) Failing after 4m54s
CI Workflow / CI run build and linting (pull_request) Failing after 4m39s
CI Workflow / Code coverage report (pull_request) Has been skipped
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 5s
CI Workflow / Test readiness for publishing provider (pull_request) Failing after 3m27s
CI Workflow / CI run tests (pull_request) Failing after 4m54s
CI Workflow / CI run build and linting (pull_request) Failing after 4m39s
CI Workflow / Code coverage report (pull_request) Has been skipped
This commit is contained in:
parent
826bb5b36a
commit
c7260e04e2
19 changed files with 521 additions and 938 deletions
32
docs/data-sources/sqlserverflexalpha_database.md
Normal file
32
docs/data-sources/sqlserverflexalpha_database.md
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||||
|
page_title: "stackitprivatepreview_sqlserverflexalpha_database Data Source - stackitprivatepreview"
|
||||||
|
subcategory: ""
|
||||||
|
description: |-
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# stackitprivatepreview_sqlserverflexalpha_database (Data Source)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- schema generated by tfplugindocs -->
|
||||||
|
## Schema
|
||||||
|
|
||||||
|
### Required
|
||||||
|
|
||||||
|
- `database_name` (String) The name of the database.
|
||||||
|
- `instance_id` (String) The ID of the instance.
|
||||||
|
- `project_id` (String) The STACKIT project ID.
|
||||||
|
- `region` (String) The region which should be addressed
|
||||||
|
|
||||||
|
### Read-Only
|
||||||
|
|
||||||
|
- `collation_name` (String) The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.
|
||||||
|
- `compatibility_level` (Number) CompatibilityLevel of the Database.
|
||||||
|
- `id` (String) The terraform internal identifier.
|
||||||
|
- `name` (String) The name of the database.
|
||||||
|
- `owner` (String) The owner of the database.
|
||||||
|
- `tf_original_api_id` (Number) The id of the database.
|
||||||
77
docs/data-sources/sqlserverflexalpha_instance.md
Normal file
77
docs/data-sources/sqlserverflexalpha_instance.md
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
---
|
||||||
|
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||||
|
page_title: "stackitprivatepreview_sqlserverflexalpha_instance Data Source - stackitprivatepreview"
|
||||||
|
subcategory: ""
|
||||||
|
description: |-
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# stackitprivatepreview_sqlserverflexalpha_instance (Data Source)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Example Usage
|
||||||
|
|
||||||
|
```terraform
|
||||||
|
data "stackitprivatepreview_sqlserverflexalpha_instance" "example" {
|
||||||
|
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
|
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
<!-- schema generated by tfplugindocs -->
|
||||||
|
## Schema
|
||||||
|
|
||||||
|
### Required
|
||||||
|
|
||||||
|
- `instance_id` (String) The ID of the instance.
|
||||||
|
- `project_id` (String) The STACKIT project ID.
|
||||||
|
- `region` (String) The region which should be addressed
|
||||||
|
|
||||||
|
### Read-Only
|
||||||
|
|
||||||
|
- `backup_schedule` (String) The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.
|
||||||
|
- `edition` (String) Edition of the MSSQL server instance
|
||||||
|
- `encryption` (Attributes) this defines which key to use for storage encryption (see [below for nested schema](#nestedatt--encryption))
|
||||||
|
- `flavor_id` (String) The id of the instance flavor.
|
||||||
|
- `is_deletable` (Boolean) Whether the instance can be deleted or not.
|
||||||
|
- `name` (String) The name of the instance.
|
||||||
|
- `network` (Attributes) The access configuration of the instance (see [below for nested schema](#nestedatt--network))
|
||||||
|
- `replicas` (Number) How many replicas the instance should have.
|
||||||
|
- `retention_days` (Number) The days for how long the backup files should be stored before cleaned up. 30 to 365
|
||||||
|
- `status` (String)
|
||||||
|
- `storage` (Attributes) The object containing information about the storage size and class. (see [below for nested schema](#nestedatt--storage))
|
||||||
|
- `tf_original_api_id` (String) The ID of the instance.
|
||||||
|
- `version` (String) The sqlserver version used for the instance.
|
||||||
|
|
||||||
|
<a id="nestedatt--encryption"></a>
|
||||||
|
### Nested Schema for `encryption`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `kek_key_id` (String) The key identifier
|
||||||
|
- `kek_key_ring_id` (String) The keyring identifier
|
||||||
|
- `kek_key_version` (String) The key version
|
||||||
|
- `service_account` (String)
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedatt--network"></a>
|
||||||
|
### Nested Schema for `network`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `access_scope` (String) The network access scope of the instance
|
||||||
|
|
||||||
|
⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected.
|
||||||
|
- `acl` (List of String) List of IPV4 cidr.
|
||||||
|
- `instance_address` (String)
|
||||||
|
- `router_address` (String)
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedatt--storage"></a>
|
||||||
|
### Nested Schema for `storage`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `class` (String) The storage class for the storage.
|
||||||
|
- `size` (Number) The storage size in Gigabytes.
|
||||||
62
docs/data-sources/sqlserverflexalpha_user.md
Normal file
62
docs/data-sources/sqlserverflexalpha_user.md
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
---
|
||||||
|
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||||
|
page_title: "stackitprivatepreview_sqlserverflexalpha_user Data Source - stackitprivatepreview"
|
||||||
|
subcategory: ""
|
||||||
|
description: |-
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# stackitprivatepreview_sqlserverflexalpha_user (Data Source)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Example Usage
|
||||||
|
|
||||||
|
```terraform
|
||||||
|
data "stackitprivatepreview_sqlserverflexalpha_user" "example" {
|
||||||
|
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
|
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
|
user_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
<!-- schema generated by tfplugindocs -->
|
||||||
|
## Schema
|
||||||
|
|
||||||
|
### Required
|
||||||
|
|
||||||
|
- `instance_id` (String) The ID of the instance.
|
||||||
|
- `project_id` (String) The STACKIT project ID.
|
||||||
|
- `region` (String) The region which should be addressed
|
||||||
|
|
||||||
|
### Optional
|
||||||
|
|
||||||
|
- `page` (Number) Number of the page of items list to be returned.
|
||||||
|
- `size` (Number) Number of items to be returned on each page.
|
||||||
|
- `sort` (String) Sorting of the users to be returned on each page.
|
||||||
|
|
||||||
|
### Read-Only
|
||||||
|
|
||||||
|
- `pagination` (Attributes) (see [below for nested schema](#nestedatt--pagination))
|
||||||
|
- `users` (Attributes List) List of all users inside an instance (see [below for nested schema](#nestedatt--users))
|
||||||
|
|
||||||
|
<a id="nestedatt--pagination"></a>
|
||||||
|
### Nested Schema for `pagination`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `page` (Number)
|
||||||
|
- `size` (Number)
|
||||||
|
- `sort` (String)
|
||||||
|
- `total_pages` (Number)
|
||||||
|
- `total_rows` (Number)
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedatt--users"></a>
|
||||||
|
### Nested Schema for `users`
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `status` (String) The current status of the user.
|
||||||
|
- `tf_original_api_id` (Number) The ID of the user.
|
||||||
|
- `username` (String) The name of the user.
|
||||||
63
docs/resources/sqlserverflexalpha_database.md
Normal file
63
docs/resources/sqlserverflexalpha_database.md
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
---
|
||||||
|
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||||
|
page_title: "stackitprivatepreview_sqlserverflexalpha_database Resource - stackitprivatepreview"
|
||||||
|
subcategory: ""
|
||||||
|
description: |-
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# stackitprivatepreview_sqlserverflexalpha_database (Resource)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Example Usage
|
||||||
|
|
||||||
|
```terraform
|
||||||
|
resource "stackitprivatepreview_sqlserverflexalpha_database" "example" {
|
||||||
|
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
|
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
|
collation = ""
|
||||||
|
compatibility = "160"
|
||||||
|
name = ""
|
||||||
|
owner = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
# Only use the import statement, if you want to import a existing sqlserverflex database
|
||||||
|
import {
|
||||||
|
to = stackitprivatepreview_sqlserverflexalpha_database.import-example
|
||||||
|
id = "${var.project_id},${var.region},${var.sql_instance_id},${var.sql_user_id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
import {
|
||||||
|
to = stackitprivatepreview_sqlserverflexalpha_database.import-example
|
||||||
|
identity = {
|
||||||
|
project_id = "project.id"
|
||||||
|
region = "region"
|
||||||
|
instance_id = "instance.id"
|
||||||
|
database_id = "database.id"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
<!-- schema generated by tfplugindocs -->
|
||||||
|
## Schema
|
||||||
|
|
||||||
|
### Required
|
||||||
|
|
||||||
|
- `name` (String) The name of the database.
|
||||||
|
- `owner` (String) The owner of the database.
|
||||||
|
|
||||||
|
### Optional
|
||||||
|
|
||||||
|
- `collation` (String) The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.
|
||||||
|
- `compatibility` (Number) CompatibilityLevel of the Database.
|
||||||
|
- `database_name` (String) The name of the database.
|
||||||
|
- `instance_id` (String) The ID of the instance.
|
||||||
|
- `project_id` (String) The STACKIT project ID.
|
||||||
|
- `region` (String) The region which should be addressed
|
||||||
|
|
||||||
|
### Read-Only
|
||||||
|
|
||||||
|
- `collation_name` (String) The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint.
|
||||||
|
- `compatibility_level` (Number) CompatibilityLevel of the Database.
|
||||||
|
- `id` (Number) The id of the database.
|
||||||
103
docs/resources/sqlserverflexalpha_instance.md
Normal file
103
docs/resources/sqlserverflexalpha_instance.md
Normal file
|
|
@ -0,0 +1,103 @@
|
||||||
|
---
|
||||||
|
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||||
|
page_title: "stackitprivatepreview_sqlserverflexalpha_instance Resource - stackitprivatepreview"
|
||||||
|
subcategory: ""
|
||||||
|
description: |-
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# stackitprivatepreview_sqlserverflexalpha_instance (Resource)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Example Usage
|
||||||
|
|
||||||
|
```terraform
|
||||||
|
resource "stackitprivatepreview_sqlserverflexalpha_instance" "example" {
|
||||||
|
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
|
name = "example-instance"
|
||||||
|
acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"]
|
||||||
|
backup_schedule = "00 00 * * *"
|
||||||
|
flavor = {
|
||||||
|
cpu = 4
|
||||||
|
ram = 16
|
||||||
|
}
|
||||||
|
storage = {
|
||||||
|
class = "class"
|
||||||
|
size = 5
|
||||||
|
}
|
||||||
|
version = 2022
|
||||||
|
}
|
||||||
|
|
||||||
|
# Only use the import statement, if you want to import an existing sqlserverflex instance
|
||||||
|
import {
|
||||||
|
to = stackitprivatepreview_sqlserverflexalpha_instance.import-example
|
||||||
|
id = "${var.project_id},${var.region},${var.sql_instance_id}"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
<!-- schema generated by tfplugindocs -->
|
||||||
|
## Schema
|
||||||
|
|
||||||
|
### Required
|
||||||
|
|
||||||
|
- `backup_schedule` (String) The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.
|
||||||
|
- `flavor_id` (String) The id of the instance flavor.
|
||||||
|
- `name` (String) The name of the instance.
|
||||||
|
- `network` (Attributes) the network configuration of the instance. (see [below for nested schema](#nestedatt--network))
|
||||||
|
- `retention_days` (Number) The days for how long the backup files should be stored before cleaned up. 30 to 365
|
||||||
|
- `storage` (Attributes) The object containing information about the storage size and class. (see [below for nested schema](#nestedatt--storage))
|
||||||
|
- `version` (String) The sqlserver version used for the instance.
|
||||||
|
|
||||||
|
### Optional
|
||||||
|
|
||||||
|
- `encryption` (Attributes) this defines which key to use for storage encryption (see [below for nested schema](#nestedatt--encryption))
|
||||||
|
- `instance_id` (String) The ID of the instance.
|
||||||
|
- `project_id` (String) The STACKIT project ID.
|
||||||
|
- `region` (String) The region which should be addressed
|
||||||
|
|
||||||
|
### Read-Only
|
||||||
|
|
||||||
|
- `edition` (String) Edition of the MSSQL server instance
|
||||||
|
- `id` (String) The ID of the instance.
|
||||||
|
- `is_deletable` (Boolean) Whether the instance can be deleted or not.
|
||||||
|
- `replicas` (Number) How many replicas the instance should have.
|
||||||
|
- `status` (String)
|
||||||
|
|
||||||
|
<a id="nestedatt--network"></a>
|
||||||
|
### Nested Schema for `network`
|
||||||
|
|
||||||
|
Required:
|
||||||
|
|
||||||
|
- `acl` (List of String) List of IPV4 cidr.
|
||||||
|
|
||||||
|
Optional:
|
||||||
|
|
||||||
|
- `access_scope` (String) The network access scope of the instance
|
||||||
|
|
||||||
|
⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected.
|
||||||
|
|
||||||
|
Read-Only:
|
||||||
|
|
||||||
|
- `instance_address` (String)
|
||||||
|
- `router_address` (String)
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedatt--storage"></a>
|
||||||
|
### Nested Schema for `storage`
|
||||||
|
|
||||||
|
Required:
|
||||||
|
|
||||||
|
- `class` (String) The storage class for the storage.
|
||||||
|
- `size` (Number) The storage size in Gigabytes.
|
||||||
|
|
||||||
|
|
||||||
|
<a id="nestedatt--encryption"></a>
|
||||||
|
### Nested Schema for `encryption`
|
||||||
|
|
||||||
|
Required:
|
||||||
|
|
||||||
|
- `kek_key_id` (String) The key identifier
|
||||||
|
- `kek_key_ring_id` (String) The keyring identifier
|
||||||
|
- `kek_key_version` (String) The key version
|
||||||
|
- `service_account` (String)
|
||||||
53
docs/resources/sqlserverflexalpha_user.md
Normal file
53
docs/resources/sqlserverflexalpha_user.md
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
---
|
||||||
|
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||||
|
page_title: "stackitprivatepreview_sqlserverflexalpha_user Resource - stackitprivatepreview"
|
||||||
|
subcategory: ""
|
||||||
|
description: |-
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# stackitprivatepreview_sqlserverflexalpha_user (Resource)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Example Usage
|
||||||
|
|
||||||
|
```terraform
|
||||||
|
resource "stackitprivatepreview_sqlserverflexalpha_user" "example" {
|
||||||
|
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
|
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
|
username = "username"
|
||||||
|
roles = ["role"]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Only use the import statement, if you want to import an existing sqlserverflex user
|
||||||
|
import {
|
||||||
|
to = stackitprivatepreview_sqlserverflexalpha_user.import-example
|
||||||
|
id = "${var.project_id},${var.region},${var.sql_instance_id},${var.sql_user_id}"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
<!-- schema generated by tfplugindocs -->
|
||||||
|
## Schema
|
||||||
|
|
||||||
|
### Required
|
||||||
|
|
||||||
|
- `roles` (List of String) A list containing the user roles for the instance. A list with the valid user roles can be retrieved using the List Roles endpoint.
|
||||||
|
- `username` (String) The name of the user.
|
||||||
|
|
||||||
|
### Optional
|
||||||
|
|
||||||
|
- `default_database` (String) The default database for a user of the instance.
|
||||||
|
- `instance_id` (String) The ID of the instance.
|
||||||
|
- `project_id` (String) The STACKIT project ID.
|
||||||
|
- `region` (String) The region which should be addressed
|
||||||
|
- `user_id` (Number) The ID of the user.
|
||||||
|
|
||||||
|
### Read-Only
|
||||||
|
|
||||||
|
- `host` (String) The host of the instance in which the user belongs to.
|
||||||
|
- `id` (Number) The ID of the user.
|
||||||
|
- `password` (String) The password for the user.
|
||||||
|
- `port` (Number) The port of the instance in which the user belongs to.
|
||||||
|
- `status` (String) The current status of the user.
|
||||||
|
- `uri` (String) The connection string for the user to the instance.
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
package testutil
|
|
||||||
|
|
||||||
import "testing"
|
|
||||||
|
|
||||||
func Equal[V comparable](t *testing.T, got, expected V) {
|
|
||||||
t.Helper()
|
|
||||||
|
|
||||||
if expected != got {
|
|
||||||
t.Errorf("assert equal failed:\ngot: %v \nexpected: %v", got, expected)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,651 +0,0 @@
|
||||||
package testutil
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-framework/providerserver"
|
|
||||||
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
|
|
||||||
"github.com/hashicorp/terraform-plugin-testing/config"
|
|
||||||
"github.com/hashicorp/terraform-plugin-testing/echoprovider"
|
|
||||||
|
|
||||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// Default location of credentials JSON
|
|
||||||
// credentialsFilePath = ".stackit/credentials.json" //nolint:gosec // linter false positive
|
|
||||||
serviceAccountFilePath = ".stackit/service_account.json"
|
|
||||||
)
|
|
||||||
|
|
||||||
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){
|
|
||||||
"stackitprivatepreview": 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){
|
|
||||||
"stackitprivatepreview": 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")
|
|
||||||
// ServiceAccountFile is the json file of the service account
|
|
||||||
ServiceAccountFile = os.Getenv("TF_ACC_SERVICE_ACCOUNT_FILE")
|
|
||||||
// ServerId is the id of a server used for some tests
|
|
||||||
ServerId = getenv("TF_ACC_SERVER_ID", "")
|
|
||||||
// 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")
|
|
||||||
|
|
||||||
CdnCustomEndpoint = os.Getenv("TF_ACC_CDN_CUSTOM_ENDPOINT")
|
|
||||||
DnsCustomEndpoint = os.Getenv("TF_ACC_DNS_CUSTOM_ENDPOINT")
|
|
||||||
GitCustomEndpoint = os.Getenv("TF_ACC_GIT_CUSTOM_ENDPOINT")
|
|
||||||
IaaSCustomEndpoint = os.Getenv("TF_ACC_IAAS_CUSTOM_ENDPOINT")
|
|
||||||
KMSCustomEndpoint = os.Getenv("TF_ACC_KMS_CUSTOM_ENDPOINT")
|
|
||||||
LoadBalancerCustomEndpoint = os.Getenv("TF_ACC_LOADBALANCER_CUSTOM_ENDPOINT")
|
|
||||||
LogMeCustomEndpoint = os.Getenv("TF_ACC_LOGME_CUSTOM_ENDPOINT")
|
|
||||||
MariaDBCustomEndpoint = os.Getenv("TF_ACC_MARIADB_CUSTOM_ENDPOINT")
|
|
||||||
ModelServingCustomEndpoint = os.Getenv("TF_ACC_MODELSERVING_CUSTOM_ENDPOINT")
|
|
||||||
AuthorizationCustomEndpoint = os.Getenv("TF_ACC_authorization_custom_endpoint")
|
|
||||||
MongoDBFlexCustomEndpoint = os.Getenv("TF_ACC_MONGODBFLEX_CUSTOM_ENDPOINT")
|
|
||||||
OpenSearchCustomEndpoint = os.Getenv("TF_ACC_OPENSEARCH_CUSTOM_ENDPOINT")
|
|
||||||
ObservabilityCustomEndpoint = os.Getenv("TF_ACC_OBSERVABILITY_CUSTOM_ENDPOINT")
|
|
||||||
ObjectStorageCustomEndpoint = os.Getenv("TF_ACC_OBJECTSTORAGE_CUSTOM_ENDPOINT")
|
|
||||||
PostgresFlexCustomEndpoint = os.Getenv("TF_ACC_POSTGRESFLEX_CUSTOM_ENDPOINT")
|
|
||||||
RabbitMQCustomEndpoint = os.Getenv("TF_ACC_RABBITMQ_CUSTOM_ENDPOINT")
|
|
||||||
RedisCustomEndpoint = os.Getenv("TF_ACC_REDIS_CUSTOM_ENDPOINT")
|
|
||||||
ResourceManagerCustomEndpoint = os.Getenv("TF_ACC_RESOURCEMANAGER_CUSTOM_ENDPOINT")
|
|
||||||
ScfCustomEndpoint = os.Getenv("TF_ACC_SCF_CUSTOM_ENDPOINT")
|
|
||||||
SecretsManagerCustomEndpoint = os.Getenv("TF_ACC_SECRETSMANAGER_CUSTOM_ENDPOINT")
|
|
||||||
SQLServerFlexCustomEndpoint = os.Getenv("TF_ACC_SQLSERVERFLEX_CUSTOM_ENDPOINT")
|
|
||||||
ServerBackupCustomEndpoint = os.Getenv("TF_ACC_SERVER_BACKUP_CUSTOM_ENDPOINT")
|
|
||||||
ServerUpdateCustomEndpoint = os.Getenv("TF_ACC_SERVER_UPDATE_CUSTOM_ENDPOINT")
|
|
||||||
ServiceAccountCustomEndpoint = os.Getenv("TF_ACC_SERVICE_ACCOUNT_CUSTOM_ENDPOINT")
|
|
||||||
SKECustomEndpoint = os.Getenv("TF_ACC_SKE_CUSTOM_ENDPOINT")
|
|
||||||
)
|
|
||||||
|
|
||||||
// Provider config helper functions
|
|
||||||
|
|
||||||
func ObservabilityProviderConfig() string {
|
|
||||||
if ObservabilityCustomEndpoint == "" {
|
|
||||||
return `provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
observability_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
ObservabilityCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func CdnProviderConfig() string {
|
|
||||||
if CdnCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
enable_beta_resources = true
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
cdn_custom_endpoint = "%s"
|
|
||||||
enable_beta_resources = true
|
|
||||||
}`,
|
|
||||||
CdnCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func DnsProviderConfig() string {
|
|
||||||
if DnsCustomEndpoint == "" {
|
|
||||||
return `provider "stackitprivatepreview" {}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
dns_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
DnsCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func IaaSProviderConfig() string {
|
|
||||||
if IaaSCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
iaas_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
IaaSCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func IaaSProviderConfigWithBetaResourcesEnabled() string {
|
|
||||||
if IaaSCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
enable_beta_resources = true
|
|
||||||
default_region = "eu01"
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
enable_beta_resources = true
|
|
||||||
iaas_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
IaaSCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func IaaSProviderConfigWithExperiments() string {
|
|
||||||
if IaaSCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
experiments = [ "routing-tables", "network" ]
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
iaas_custom_endpoint = "%s"
|
|
||||||
experiments = [ "routing-tables", "network" ]
|
|
||||||
}`,
|
|
||||||
IaaSCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func KMSProviderConfig() string {
|
|
||||||
if KMSCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
kms_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
KMSCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func LoadBalancerProviderConfig() string {
|
|
||||||
if LoadBalancerCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
loadbalancer_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
LoadBalancerCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func LogMeProviderConfig() string {
|
|
||||||
if LogMeCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
logme_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
LogMeCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func MariaDBProviderConfig() string {
|
|
||||||
if MariaDBCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
mariadb_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
MariaDBCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ModelServingProviderConfig() string {
|
|
||||||
if ModelServingCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
modelserving_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
ModelServingCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func MongoDBFlexProviderConfig() string {
|
|
||||||
if MongoDBFlexCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
mongodbflex_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
MongoDBFlexCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ObjectStorageProviderConfig() string {
|
|
||||||
if ObjectStorageCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
objectstorage_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
ObjectStorageCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func OpenSearchProviderConfig() string {
|
|
||||||
if OpenSearchCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
opensearch_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
OpenSearchCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func PostgresFlexProviderConfig(saFile string) string {
|
|
||||||
if PostgresFlexCustomEndpoint == "" {
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
service_account_key_path = "%s"
|
|
||||||
}`, saFile)
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
service_account_key_path = "%s"
|
|
||||||
postgresflex_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
saFile,
|
|
||||||
PostgresFlexCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func RabbitMQProviderConfig() string {
|
|
||||||
if RabbitMQCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
rabbitmq_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
RabbitMQCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func RedisProviderConfig() string {
|
|
||||||
if RedisCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
redis_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
RedisCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ResourceManagerProviderConfig() string {
|
|
||||||
key := GetTestProjectServiceAccountJson("")
|
|
||||||
if ResourceManagerCustomEndpoint == "" || AuthorizationCustomEndpoint == "" {
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
service_account_key = "%s"
|
|
||||||
}`,
|
|
||||||
key,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
resourcemanager_custom_endpoint = "%s"
|
|
||||||
authorization_custom_endpoint = "%s"
|
|
||||||
service_account_token = "%s"
|
|
||||||
}`,
|
|
||||||
ResourceManagerCustomEndpoint,
|
|
||||||
AuthorizationCustomEndpoint,
|
|
||||||
key,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func SecretsManagerProviderConfig() string {
|
|
||||||
if SecretsManagerCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
secretsmanager_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
SecretsManagerCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func SQLServerFlexProviderConfig(saFile string) string {
|
|
||||||
if SQLServerFlexCustomEndpoint == "" {
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
service_account_key_path = "%s"
|
|
||||||
}`, saFile)
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
service_account_key_path = "%s"
|
|
||||||
sqlserverflex_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
saFile,
|
|
||||||
SQLServerFlexCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ServerBackupProviderConfig() string {
|
|
||||||
if ServerBackupCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
enable_beta_resources = true
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
server_backup_custom_endpoint = "%s"
|
|
||||||
enable_beta_resources = true
|
|
||||||
}`,
|
|
||||||
ServerBackupCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ServerUpdateProviderConfig() string {
|
|
||||||
if ServerUpdateCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
enable_beta_resources = true
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
server_update_custom_endpoint = "%s"
|
|
||||||
enable_beta_resources = true
|
|
||||||
}`,
|
|
||||||
ServerUpdateCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func SKEProviderConfig() string {
|
|
||||||
if SKECustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
ske_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
SKECustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func AuthorizationProviderConfig() string {
|
|
||||||
if AuthorizationCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
experiments = ["iam"]
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
authorization_custom_endpoint = "%s"
|
|
||||||
experiments = ["iam"]
|
|
||||||
}`,
|
|
||||||
AuthorizationCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ServiceAccountProviderConfig() string {
|
|
||||||
if ServiceAccountCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
enable_beta_resources = true
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
service_account_custom_endpoint = "%s"
|
|
||||||
enable_beta_resources = true
|
|
||||||
}`,
|
|
||||||
ServiceAccountCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GitProviderConfig() string {
|
|
||||||
if GitCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
enable_beta_resources = true
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
git_custom_endpoint = "%s"
|
|
||||||
enable_beta_resources = true
|
|
||||||
}`,
|
|
||||||
GitCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ScfProviderConfig() string {
|
|
||||||
if ScfCustomEndpoint == "" {
|
|
||||||
return `
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
return fmt.Sprintf(`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "eu01"
|
|
||||||
scf_custom_endpoint = "%s"
|
|
||||||
}`,
|
|
||||||
ScfCustomEndpoint,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ResourceNameWithDateTime(name string) string {
|
|
||||||
dateTime := time.Now().Format(time.RFC3339)
|
|
||||||
// Remove timezone to have a smaller datetime
|
|
||||||
dateTimeTrimmed, _, _ := strings.Cut(dateTime, "+")
|
|
||||||
return fmt.Sprintf("tf-acc-%s-%s", name, dateTimeTrimmed)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetTestProjectServiceAccountJson(path string) string {
|
|
||||||
var err error
|
|
||||||
token, tokenSet := os.LookupEnv("TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_JSON")
|
|
||||||
if !tokenSet || token == "" {
|
|
||||||
token, err = readTestServiceAccountJsonFromFile(path)
|
|
||||||
if err != nil {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return token
|
|
||||||
}
|
|
||||||
|
|
||||||
//func GetTestProjectServiceAccountToken(path string) string {
|
|
||||||
// var err error
|
|
||||||
// token, tokenSet := os.LookupEnv("TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN")
|
|
||||||
// if !tokenSet || token == "" {
|
|
||||||
// token, err = readTestTokenFromCredentialsFile(path)
|
|
||||||
// if err != nil {
|
|
||||||
// return ""
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return token
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//func readTestTokenFromCredentialsFile(path string) (string, error) {
|
|
||||||
// if path == "" {
|
|
||||||
// customPath, customPathSet := os.LookupEnv("STACKIT_CREDENTIALS_PATH")
|
|
||||||
// if !customPathSet || customPath == "" {
|
|
||||||
// path = credentialsFilePath
|
|
||||||
// home, err := os.UserHomeDir()
|
|
||||||
// if err != nil {
|
|
||||||
// return "", fmt.Errorf("getting home directory: %w", err)
|
|
||||||
// }
|
|
||||||
// path = filepath.Join(home, path)
|
|
||||||
// } else {
|
|
||||||
// path = customPath
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// credentialsRaw, err := os.ReadFile(path)
|
|
||||||
// if err != nil {
|
|
||||||
// return "", fmt.Errorf("opening file: %w", err)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// var credentials struct {
|
|
||||||
// TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN string `json:"TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN"`
|
|
||||||
// }
|
|
||||||
// err = json.Unmarshal(credentialsRaw, &credentials)
|
|
||||||
// if err != nil {
|
|
||||||
// return "", fmt.Errorf("unmarshalling credentials: %w", err)
|
|
||||||
// }
|
|
||||||
// return credentials.TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN, nil
|
|
||||||
//}
|
|
||||||
|
|
||||||
func readTestServiceAccountJsonFromFile(path string) (string, error) {
|
|
||||||
if path == "" {
|
|
||||||
customPath, customPathSet := os.LookupEnv("STACKIT_SERVICE_ACCOUNT_PATH")
|
|
||||||
if !customPathSet || customPath == "" {
|
|
||||||
path = serviceAccountFilePath
|
|
||||||
home, err := os.UserHomeDir()
|
|
||||||
if err != nil {
|
|
||||||
return "", fmt.Errorf("getting home directory: %w", err)
|
|
||||||
}
|
|
||||||
path = filepath.Join(home, path)
|
|
||||||
} else {
|
|
||||||
path = customPath
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
credentialsRaw, err := os.ReadFile(path)
|
|
||||||
if err != nil {
|
|
||||||
return "", fmt.Errorf("opening file: %w", err)
|
|
||||||
}
|
|
||||||
return string(credentialsRaw), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func getenv(key, defaultValue string) string {
|
|
||||||
val := os.Getenv(key)
|
|
||||||
if val == "" {
|
|
||||||
return defaultValue
|
|
||||||
}
|
|
||||||
return val
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateDefaultLocalFile is a helper for local_file_path. No real data is created
|
|
||||||
func CreateDefaultLocalFile() os.File {
|
|
||||||
// Define the file name and size
|
|
||||||
fileName := "test-512k.img"
|
|
||||||
size := 512 * 1024 // 512 KB
|
|
||||||
|
|
||||||
// Create the file
|
|
||||||
file, err := os.Create(fileName)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Seek to the desired position (512 KB)
|
|
||||||
_, err = file.Seek(int64(size), 0)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return *file
|
|
||||||
}
|
|
||||||
|
|
||||||
func ConvertConfigVariable(variable config.Variable) string {
|
|
||||||
tmpByteArray, _ := variable.MarshalJSON()
|
|
||||||
// In case the variable is a string, the quotes should be removed
|
|
||||||
if tmpByteArray[0] == '"' && tmpByteArray[len(tmpByteArray)-1] == '"' {
|
|
||||||
result := string(tmpByteArray[1 : len(tmpByteArray)-1])
|
|
||||||
// Replace escaped quotes which where added MarshalJSON
|
|
||||||
rawString := strings.ReplaceAll(result, `\"`, `"`)
|
|
||||||
return rawString
|
|
||||||
}
|
|
||||||
return string(tmpByteArray)
|
|
||||||
}
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
||||||
// Copyright (c) STACKIT
|
|
||||||
|
|
||||||
package testutil
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-testing/config"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestConvertConfigVariable(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
variable config.Variable
|
|
||||||
want string
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "string",
|
|
||||||
variable: config.StringVariable("test"),
|
|
||||||
want: "test",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "bool: true",
|
|
||||||
variable: config.BoolVariable(true),
|
|
||||||
want: "true",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "bool: false",
|
|
||||||
variable: config.BoolVariable(false),
|
|
||||||
want: "false",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "integer",
|
|
||||||
variable: config.IntegerVariable(10),
|
|
||||||
want: "10",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "quoted string",
|
|
||||||
variable: config.StringVariable(`instance =~ ".*"`),
|
|
||||||
want: `instance =~ ".*"`,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
if got := ConvertConfigVariable(tt.variable); got != tt.want {
|
|
||||||
t.Errorf("ConvertConfigVariable() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -171,7 +171,7 @@ func handleConnectionInfo(ctx context.Context, m *dataSourceModel, resp *postgre
|
||||||
postgresflexalphadatasource.WriteValue{}.AttributeTypes(ctx),
|
postgresflexalphadatasource.WriteValue{}.AttributeTypes(ctx),
|
||||||
map[string]attr.Value{
|
map[string]attr.Value{
|
||||||
"host": types.StringValue(resp.ConnectionInfo.Write.Host),
|
"host": types.StringValue(resp.ConnectionInfo.Write.Host),
|
||||||
"port": types.Int32Value(resp.ConnectionInfo.Write.Port),
|
"port": types.Int64Value(int64(resp.ConnectionInfo.Write.Port)),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -180,7 +180,7 @@ func handleConnectionInfo(ctx context.Context, m *dataSourceModel, resp *postgre
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleNetwork(ctx context.Context, m *dataSourceModel, resp *postgresflex.GetInstanceResponse) error {
|
func handleNetwork(ctx context.Context, m *dataSourceModel, resp *postgresflex.GetInstanceResponse) error {
|
||||||
netAcl, diags := types.ListValueFrom(ctx, types.StringType, resp.Network.GetAcl())
|
netACL, diags := types.ListValueFrom(ctx, types.StringType, resp.Network.GetAcl())
|
||||||
if diags.HasError() {
|
if diags.HasError() {
|
||||||
return fmt.Errorf("failed converting network acl from response")
|
return fmt.Errorf("failed converting network acl from response")
|
||||||
}
|
}
|
||||||
|
|
@ -199,7 +199,7 @@ func handleNetwork(ctx context.Context, m *dataSourceModel, resp *postgresflex.G
|
||||||
postgresflexalphadatasource.NetworkValue{}.AttributeTypes(ctx),
|
postgresflexalphadatasource.NetworkValue{}.AttributeTypes(ctx),
|
||||||
map[string]attr.Value{
|
map[string]attr.Value{
|
||||||
"access_scope": types.StringValue(string(resp.Network.GetAccessScope())),
|
"access_scope": types.StringValue(string(resp.Network.GetAccessScope())),
|
||||||
"acl": netAcl,
|
"acl": netACL,
|
||||||
"instance_address": types.StringValue(instAddr),
|
"instance_address": types.StringValue(instAddr),
|
||||||
"router_address": types.StringValue(rtrAddr),
|
"router_address": types.StringValue(rtrAddr),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ func Test_handleConnectionInfo(t *testing.T) {
|
||||||
ConnectionInfo: postgresflex.InstanceConnectionInfo{
|
ConnectionInfo: postgresflex.InstanceConnectionInfo{
|
||||||
Write: postgresflex.InstanceConnectionInfoWrite{
|
Write: postgresflex.InstanceConnectionInfoWrite{
|
||||||
Host: tt.args.hostName,
|
Host: tt.args.hostName,
|
||||||
Port: tt.args.port,
|
Port: int32(tt.args.port),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -93,7 +93,7 @@ func Test_handleConnectionInfo(t *testing.T) {
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Errorf("could not find a value for port in connection_info.write")
|
t.Errorf("could not find a value for port in connection_info.write")
|
||||||
}
|
}
|
||||||
if !gotPort.Equal(types.Int32Value(tt.args.port)) {
|
if !gotPort.Equal(types.Int64Value(int64(tt.args.port))) {
|
||||||
t.Errorf("port value incorrect: want: %d - got: %s", tt.args.port, gotPort.String())
|
t.Errorf("port value incorrect: want: %d - got: %s", tt.args.port, gotPort.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -102,6 +102,7 @@ func Test_handleConnectionInfo(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_handleEncryption(t *testing.T) {
|
func Test_handleEncryption(t *testing.T) {
|
||||||
|
t.Skipf("please implement")
|
||||||
type args struct {
|
type args struct {
|
||||||
m *dataSourceModel
|
m *dataSourceModel
|
||||||
resp *postgresflex.GetInstanceResponse
|
resp *postgresflex.GetInstanceResponse
|
||||||
|
|
@ -121,6 +122,7 @@ func Test_handleEncryption(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_handleNetwork(t *testing.T) {
|
func Test_handleNetwork(t *testing.T) {
|
||||||
|
t.Skipf("please implement")
|
||||||
type args struct {
|
type args struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
m *dataSourceModel
|
m *dataSourceModel
|
||||||
|
|
@ -143,6 +145,7 @@ func Test_handleNetwork(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_mapGetDataInstanceResponseToModel(t *testing.T) {
|
func Test_mapGetDataInstanceResponseToModel(t *testing.T) {
|
||||||
|
t.Skipf("please implement")
|
||||||
type args struct {
|
type args struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
m *dataSourceModel
|
m *dataSourceModel
|
||||||
|
|
@ -165,6 +168,7 @@ func Test_mapGetDataInstanceResponseToModel(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_mapGetInstanceResponseToModel(t *testing.T) {
|
func Test_mapGetInstanceResponseToModel(t *testing.T) {
|
||||||
|
t.Skipf("please implement")
|
||||||
type args struct {
|
type args struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
m *postgresflexalpharesource.InstanceModel
|
m *postgresflexalpharesource.InstanceModel
|
||||||
|
|
|
||||||
|
|
@ -169,11 +169,11 @@ func TestMapFieldsCreate(t *testing.T) {
|
||||||
UserId: types.Int64Value(1),
|
UserId: types.Int64Value(1),
|
||||||
InstanceId: types.StringValue("iid"),
|
InstanceId: types.StringValue("iid"),
|
||||||
ProjectId: types.StringValue("pid"),
|
ProjectId: types.StringValue("pid"),
|
||||||
Name: types.StringNull(),
|
Name: types.StringValue(""),
|
||||||
Roles: types.List(types.SetNull(types.StringType)),
|
Roles: types.List(types.SetNull(types.StringType)),
|
||||||
Password: types.StringNull(),
|
Password: types.StringNull(),
|
||||||
Region: types.StringValue(testRegion),
|
Region: types.StringValue(testRegion),
|
||||||
Status: types.StringNull(),
|
Status: types.StringValue(""),
|
||||||
//ConnectionString: types.StringNull(),
|
//ConnectionString: types.StringNull(),
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
|
|
@ -213,11 +213,11 @@ func TestMapFieldsCreate(t *testing.T) {
|
||||||
UserId: types.Int64Value(1),
|
UserId: types.Int64Value(1),
|
||||||
InstanceId: types.StringValue("iid"),
|
InstanceId: types.StringValue("iid"),
|
||||||
ProjectId: types.StringValue("pid"),
|
ProjectId: types.StringValue("pid"),
|
||||||
Name: types.StringNull(),
|
Name: types.StringValue(""),
|
||||||
Roles: types.List(types.SetNull(types.StringType)),
|
Roles: types.List(types.SetNull(types.StringType)),
|
||||||
Password: types.StringNull(),
|
Password: types.StringNull(),
|
||||||
Region: types.StringValue(testRegion),
|
Region: types.StringValue(testRegion),
|
||||||
Status: types.StringNull(),
|
Status: types.StringValue(""),
|
||||||
//ConnectionString: types.StringNull(),
|
//ConnectionString: types.StringNull(),
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
|
|
@ -260,7 +260,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
||||||
t.Fatalf("Should not have failed: %v", err)
|
t.Fatalf("Should not have failed: %v", err)
|
||||||
}
|
}
|
||||||
if tt.isValid {
|
if tt.isValid {
|
||||||
diff := cmp.Diff(state, &tt.expected)
|
diff := cmp.Diff(&tt.expected, state)
|
||||||
if diff != "" {
|
if diff != "" {
|
||||||
t.Fatalf("Data does not match: %s", diff)
|
t.Fatalf("Data does not match: %s", diff)
|
||||||
}
|
}
|
||||||
|
|
@ -290,10 +290,10 @@ func TestMapFields(t *testing.T) {
|
||||||
UserId: types.Int64Value(int64(1)),
|
UserId: types.Int64Value(int64(1)),
|
||||||
InstanceId: types.StringValue("iid"),
|
InstanceId: types.StringValue("iid"),
|
||||||
ProjectId: types.StringValue("pid"),
|
ProjectId: types.StringValue("pid"),
|
||||||
Name: types.StringNull(),
|
Name: types.StringValue(""),
|
||||||
Roles: types.List(types.SetNull(types.StringType)),
|
Roles: types.List(types.SetNull(types.StringType)),
|
||||||
Region: types.StringValue(testRegion),
|
Region: types.StringValue(testRegion),
|
||||||
Status: types.StringNull(),
|
Status: types.StringValue(""),
|
||||||
//ConnectionString: types.StringNull(),
|
//ConnectionString: types.StringNull(),
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
|
|
@ -326,7 +326,7 @@ func TestMapFields(t *testing.T) {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Region: types.StringValue(testRegion),
|
Region: types.StringValue(testRegion),
|
||||||
Status: types.StringNull(),
|
Status: types.StringValue(""),
|
||||||
//ConnectionString: types.StringNull(),
|
//ConnectionString: types.StringNull(),
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
|
|
@ -343,10 +343,10 @@ func TestMapFields(t *testing.T) {
|
||||||
UserId: types.Int64Value(1),
|
UserId: types.Int64Value(1),
|
||||||
InstanceId: types.StringValue("iid"),
|
InstanceId: types.StringValue("iid"),
|
||||||
ProjectId: types.StringValue("pid"),
|
ProjectId: types.StringValue("pid"),
|
||||||
Name: types.StringNull(),
|
Name: types.StringValue(""),
|
||||||
Roles: types.List(types.SetNull(types.StringType)),
|
Roles: types.List(types.SetNull(types.StringType)),
|
||||||
Region: types.StringValue(testRegion),
|
Region: types.StringValue(testRegion),
|
||||||
Status: types.StringNull(),
|
Status: types.StringValue(""),
|
||||||
//ConnectionString: types.StringNull(),
|
//ConnectionString: types.StringNull(),
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import (
|
||||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
|
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
|
||||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
|
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
|
||||||
|
|
||||||
"github.com/stackitcloud/stackit-sdk-go/services/postgresflex"
|
"github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v3alpha1api"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -38,7 +38,7 @@ func TestConfigureClient(t *testing.T) {
|
||||||
name string
|
name string
|
||||||
args args
|
args args
|
||||||
wantErr bool
|
wantErr bool
|
||||||
expected *postgresflex.APIClient
|
expected *v3alpha1api.APIClient
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "default endpoint",
|
name: "default endpoint",
|
||||||
|
|
@ -47,8 +47,8 @@ func TestConfigureClient(t *testing.T) {
|
||||||
Version: testVersion,
|
Version: testVersion,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: func() *postgresflex.APIClient {
|
expected: func() *v3alpha1api.APIClient {
|
||||||
apiClient, err := postgresflex.NewAPIClient(
|
apiClient, err := v3alpha1api.NewAPIClient(
|
||||||
config.WithRegion("eu01"),
|
config.WithRegion("eu01"),
|
||||||
utils.UserAgentConfigOption(testVersion),
|
utils.UserAgentConfigOption(testVersion),
|
||||||
)
|
)
|
||||||
|
|
@ -67,8 +67,8 @@ func TestConfigureClient(t *testing.T) {
|
||||||
PostgresFlexCustomEndpoint: testCustomEndpoint,
|
PostgresFlexCustomEndpoint: testCustomEndpoint,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: func() *postgresflex.APIClient {
|
expected: func() *v3alpha1api.APIClient {
|
||||||
apiClient, err := postgresflex.NewAPIClient(
|
apiClient, err := v3alpha1api.NewAPIClient(
|
||||||
utils.UserAgentConfigOption(testVersion),
|
utils.UserAgentConfigOption(testVersion),
|
||||||
config.WithEndpoint(testCustomEndpoint),
|
config.WithEndpoint(testCustomEndpoint),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import (
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||||
|
"github.com/stackitcloud/stackit-sdk-go/core/utils"
|
||||||
sqlserverflexalpha "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3alpha1api"
|
sqlserverflexalpha "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3alpha1api"
|
||||||
datasource "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database/datasources_gen"
|
datasource "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database/datasources_gen"
|
||||||
)
|
)
|
||||||
|
|
@ -200,8 +201,9 @@ func TestToCreatePayload(t *testing.T) {
|
||||||
},
|
},
|
||||||
expected: expected{
|
expected: expected{
|
||||||
payload: &sqlserverflexalpha.CreateDatabaseRequestPayload{
|
payload: &sqlserverflexalpha.CreateDatabaseRequestPayload{
|
||||||
Name: ("my-db"),
|
Name: "my-db",
|
||||||
Owner: ("my-owner"),
|
Owner: "my-owner",
|
||||||
|
Compatibility: utils.Ptr(int32(0)),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -28,13 +28,13 @@ func TestMapDataSourceFields(t *testing.T) {
|
||||||
UserId: types.Int64Value(1),
|
UserId: types.Int64Value(1),
|
||||||
InstanceId: types.StringValue("iid"),
|
InstanceId: types.StringValue("iid"),
|
||||||
ProjectId: types.StringValue("pid"),
|
ProjectId: types.StringValue("pid"),
|
||||||
Username: types.StringNull(),
|
Username: types.StringValue(""),
|
||||||
Roles: types.List(types.SetNull(types.StringType)),
|
Roles: types.List(types.SetNull(types.StringType)),
|
||||||
Host: types.StringNull(),
|
Host: types.StringValue(""),
|
||||||
Port: types.Int64Null(),
|
Port: types.Int64Value(0),
|
||||||
Region: types.StringValue(testRegion),
|
Region: types.StringValue(testRegion),
|
||||||
Status: types.StringNull(),
|
Status: types.StringValue(""),
|
||||||
DefaultDatabase: types.StringNull(),
|
DefaultDatabase: types.StringValue(""),
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
|
|
@ -93,15 +93,17 @@ func TestMapDataSourceFields(t *testing.T) {
|
||||||
},
|
},
|
||||||
testRegion,
|
testRegion,
|
||||||
dataSourceModel{
|
dataSourceModel{
|
||||||
Id: types.StringValue("pid,region,iid,1"),
|
Id: types.StringValue("pid,region,iid,1"),
|
||||||
UserId: types.Int64Value(1),
|
UserId: types.Int64Value(1),
|
||||||
InstanceId: types.StringValue("iid"),
|
InstanceId: types.StringValue("iid"),
|
||||||
ProjectId: types.StringValue("pid"),
|
ProjectId: types.StringValue("pid"),
|
||||||
Username: types.StringNull(),
|
Username: types.StringValue(""),
|
||||||
Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
|
Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
|
||||||
Host: types.StringNull(),
|
Host: types.StringValue(""),
|
||||||
Port: types.Int64Value(2123456789),
|
Port: types.Int64Value(2123456789),
|
||||||
Region: types.StringValue(testRegion),
|
Region: types.StringValue(testRegion),
|
||||||
|
DefaultDatabase: types.StringValue(""),
|
||||||
|
Status: types.StringValue(""),
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
|
|
@ -165,28 +167,31 @@ func TestMapFieldsCreate(t *testing.T) {
|
||||||
{
|
{
|
||||||
"default_values",
|
"default_values",
|
||||||
&v3alpha1api.CreateUserResponse{
|
&v3alpha1api.CreateUserResponse{
|
||||||
Id: (int64(1)),
|
Id: int64(1),
|
||||||
Password: (""),
|
Password: "xy",
|
||||||
},
|
},
|
||||||
testRegion,
|
testRegion,
|
||||||
resourceModel{
|
resourceModel{
|
||||||
Id: types.Int64Value(1),
|
Id: types.Int64Value(1),
|
||||||
UserId: types.Int64Value(1),
|
UserId: types.Int64Value(1),
|
||||||
InstanceId: types.StringValue("iid"),
|
InstanceId: types.StringValue("iid"),
|
||||||
ProjectId: types.StringValue("pid"),
|
ProjectId: types.StringValue("pid"),
|
||||||
Username: types.StringNull(),
|
Username: types.StringValue(""),
|
||||||
Roles: types.List(types.SetNull(types.StringType)),
|
Roles: types.List(types.SetNull(types.StringType)),
|
||||||
Password: types.StringValue(""),
|
Password: types.StringValue("xy"),
|
||||||
Host: types.StringNull(),
|
Host: types.StringValue(""),
|
||||||
Port: types.Int64Null(),
|
Port: types.Int64Value(0),
|
||||||
Region: types.StringValue(testRegion),
|
Region: types.StringValue(testRegion),
|
||||||
|
DefaultDatabase: types.StringValue(""),
|
||||||
|
Status: types.StringValue(""),
|
||||||
|
Uri: types.StringValue(""),
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"simple_values",
|
"simple_values",
|
||||||
&v3alpha1api.CreateUserResponse{
|
&v3alpha1api.CreateUserResponse{
|
||||||
Id: (int64(2)),
|
Id: int64(2),
|
||||||
Roles: []string{
|
Roles: []string{
|
||||||
"role_2",
|
"role_2",
|
||||||
"role_1",
|
"role_1",
|
||||||
|
|
@ -198,6 +203,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
||||||
Port: int32(1234),
|
Port: int32(1234),
|
||||||
Status: "status",
|
Status: "status",
|
||||||
DefaultDatabase: "default_db",
|
DefaultDatabase: "default_db",
|
||||||
|
Uri: "myURI",
|
||||||
},
|
},
|
||||||
testRegion,
|
testRegion,
|
||||||
resourceModel{
|
resourceModel{
|
||||||
|
|
@ -221,6 +227,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
||||||
Region: types.StringValue(testRegion),
|
Region: types.StringValue(testRegion),
|
||||||
Status: types.StringValue("status"),
|
Status: types.StringValue("status"),
|
||||||
DefaultDatabase: types.StringValue("default_db"),
|
DefaultDatabase: types.StringValue("default_db"),
|
||||||
|
Uri: types.StringValue("myURI"),
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
|
|
@ -230,7 +237,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
||||||
Id: int64(3),
|
Id: int64(3),
|
||||||
Roles: []string{},
|
Roles: []string{},
|
||||||
Username: "",
|
Username: "",
|
||||||
Password: "",
|
Password: "xy",
|
||||||
Host: "",
|
Host: "",
|
||||||
Port: int32(256789),
|
Port: int32(256789),
|
||||||
},
|
},
|
||||||
|
|
@ -240,14 +247,15 @@ func TestMapFieldsCreate(t *testing.T) {
|
||||||
UserId: types.Int64Value(3),
|
UserId: types.Int64Value(3),
|
||||||
InstanceId: types.StringValue("iid"),
|
InstanceId: types.StringValue("iid"),
|
||||||
ProjectId: types.StringValue("pid"),
|
ProjectId: types.StringValue("pid"),
|
||||||
Username: types.StringNull(),
|
Username: types.StringValue(""),
|
||||||
Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
|
Roles: types.ListNull(types.StringType),
|
||||||
Password: types.StringValue(""),
|
Password: types.StringValue("xy"),
|
||||||
Host: types.StringNull(),
|
Host: types.StringValue(""),
|
||||||
Port: types.Int64Value(2123456789),
|
Port: types.Int64Value(256789),
|
||||||
Region: types.StringValue(testRegion),
|
Region: types.StringValue(testRegion),
|
||||||
DefaultDatabase: types.StringNull(),
|
DefaultDatabase: types.StringValue(""),
|
||||||
Status: types.StringNull(),
|
Status: types.StringValue(""),
|
||||||
|
Uri: types.StringValue(""),
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
|
|
@ -325,10 +333,10 @@ func TestMapFields(t *testing.T) {
|
||||||
UserId: types.Int64Value(1),
|
UserId: types.Int64Value(1),
|
||||||
InstanceId: types.StringValue("iid"),
|
InstanceId: types.StringValue("iid"),
|
||||||
ProjectId: types.StringValue("pid"),
|
ProjectId: types.StringValue("pid"),
|
||||||
Username: types.StringNull(),
|
Username: types.StringValue(""),
|
||||||
Roles: types.List(types.SetNull(types.StringType)),
|
Roles: types.List(types.SetNull(types.StringType)),
|
||||||
Host: types.StringNull(),
|
Host: types.StringValue(""),
|
||||||
Port: types.Int64Null(),
|
Port: types.Int64Value(0),
|
||||||
Region: types.StringValue(testRegion),
|
Region: types.StringValue(testRegion),
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
|
|
@ -382,9 +390,9 @@ func TestMapFields(t *testing.T) {
|
||||||
UserId: types.Int64Value(1),
|
UserId: types.Int64Value(1),
|
||||||
InstanceId: types.StringValue("iid"),
|
InstanceId: types.StringValue("iid"),
|
||||||
ProjectId: types.StringValue("pid"),
|
ProjectId: types.StringValue("pid"),
|
||||||
Username: types.StringNull(),
|
Username: types.StringValue(""),
|
||||||
Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
|
Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})),
|
||||||
Host: types.StringNull(),
|
Host: types.StringValue(""),
|
||||||
Port: types.Int64Value(2123456789),
|
Port: types.Int64Value(2123456789),
|
||||||
Region: types.StringValue(testRegion),
|
Region: types.StringValue(testRegion),
|
||||||
},
|
},
|
||||||
|
|
@ -477,7 +485,7 @@ func TestToCreatePayload(t *testing.T) {
|
||||||
{
|
{
|
||||||
"null_fields_and_int_conversions",
|
"null_fields_and_int_conversions",
|
||||||
&resourceModel{
|
&resourceModel{
|
||||||
Username: types.StringNull(),
|
Username: types.StringValue(""),
|
||||||
},
|
},
|
||||||
[]string{
|
[]string{
|
||||||
"",
|
"",
|
||||||
|
|
|
||||||
|
|
@ -166,6 +166,7 @@ func mapFieldsCreate(userResp *v3beta1api.CreateUserResponse, model *resourceMod
|
||||||
model.Region = types.StringValue(region)
|
model.Region = types.StringValue(region)
|
||||||
model.Status = types.StringValue(user.Status)
|
model.Status = types.StringValue(user.Status)
|
||||||
model.DefaultDatabase = types.StringValue(user.DefaultDatabase)
|
model.DefaultDatabase = types.StringValue(user.DefaultDatabase)
|
||||||
|
model.Uri = types.StringValue(user.Uri)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,39 +161,43 @@ func TestMapFieldsCreate(t *testing.T) {
|
||||||
{
|
{
|
||||||
"default_values",
|
"default_values",
|
||||||
&sqlserverflexbeta.CreateUserResponse{
|
&sqlserverflexbeta.CreateUserResponse{
|
||||||
Id: (int64(1)),
|
Id: int64(1),
|
||||||
Password: (""),
|
Password: "",
|
||||||
},
|
},
|
||||||
testRegion,
|
testRegion,
|
||||||
resourceModel{
|
resourceModel{
|
||||||
Id: types.Int64Value(1),
|
Id: types.Int64Value(1),
|
||||||
UserId: types.Int64Value(1),
|
UserId: types.Int64Value(1),
|
||||||
InstanceId: types.StringValue("iid"),
|
InstanceId: types.StringValue("iid"),
|
||||||
ProjectId: types.StringValue("pid"),
|
ProjectId: types.StringValue("pid"),
|
||||||
Username: types.StringNull(),
|
Username: types.StringValue(""),
|
||||||
Roles: types.List(types.SetNull(types.StringType)),
|
Roles: types.List(types.SetNull(types.StringType)),
|
||||||
Password: types.StringValue(""),
|
Password: types.StringValue(""),
|
||||||
Host: types.StringNull(),
|
Host: types.StringValue(""),
|
||||||
Port: types.Int64Null(),
|
Port: types.Int64Value(0),
|
||||||
Region: types.StringValue(testRegion),
|
Region: types.StringValue(testRegion),
|
||||||
|
DefaultDatabase: types.StringValue(""),
|
||||||
|
Status: types.StringValue(""),
|
||||||
|
Uri: types.StringValue(""),
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"simple_values",
|
"simple_values",
|
||||||
&sqlserverflexbeta.CreateUserResponse{
|
&sqlserverflexbeta.CreateUserResponse{
|
||||||
Id: (int64(2)),
|
Id: int64(2),
|
||||||
Roles: []string{
|
Roles: []string{
|
||||||
"role_1",
|
"role_1",
|
||||||
"role_2",
|
"role_2",
|
||||||
"",
|
"",
|
||||||
},
|
},
|
||||||
Username: ("username"),
|
Username: "username",
|
||||||
Password: ("password"),
|
Password: "password",
|
||||||
Host: ("host"),
|
Host: "host",
|
||||||
Port: (int32(1234)),
|
Port: int32(1234),
|
||||||
Status: ("status"),
|
Status: "status",
|
||||||
DefaultDatabase: ("default_db"),
|
DefaultDatabase: "default_db",
|
||||||
|
Uri: "myURI",
|
||||||
},
|
},
|
||||||
testRegion,
|
testRegion,
|
||||||
resourceModel{
|
resourceModel{
|
||||||
|
|
@ -217,6 +221,7 @@ func TestMapFieldsCreate(t *testing.T) {
|
||||||
Region: types.StringValue(testRegion),
|
Region: types.StringValue(testRegion),
|
||||||
Status: types.StringValue("status"),
|
Status: types.StringValue("status"),
|
||||||
DefaultDatabase: types.StringValue("default_db"),
|
DefaultDatabase: types.StringValue("default_db"),
|
||||||
|
Uri: types.StringValue("myURI"),
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
sdkClients "github.com/stackitcloud/stackit-sdk-go/core/clients"
|
sdkClients "github.com/stackitcloud/stackit-sdk-go/core/clients"
|
||||||
"github.com/stackitcloud/stackit-sdk-go/core/config"
|
"github.com/stackitcloud/stackit-sdk-go/core/config"
|
||||||
|
|
||||||
sqlserverflex "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3beta1api"
|
"github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3beta1api"
|
||||||
|
|
||||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
|
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core"
|
||||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
|
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
|
||||||
|
|
@ -36,7 +36,7 @@ func TestConfigureClient(t *testing.T) {
|
||||||
name string
|
name string
|
||||||
args args
|
args args
|
||||||
wantErr bool
|
wantErr bool
|
||||||
expected *sqlserverflex.APIClient
|
expected *v3beta1api.APIClient
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "default endpoint",
|
name: "default endpoint",
|
||||||
|
|
@ -45,8 +45,8 @@ func TestConfigureClient(t *testing.T) {
|
||||||
Version: testVersion,
|
Version: testVersion,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: func() *sqlserverflex.APIClient {
|
expected: func() *v3beta1api.APIClient {
|
||||||
apiClient, err := sqlserverflex.NewAPIClient(
|
apiClient, err := v3beta1api.NewAPIClient(
|
||||||
config.WithRegion("eu01"),
|
config.WithRegion("eu01"),
|
||||||
utils.UserAgentConfigOption(testVersion),
|
utils.UserAgentConfigOption(testVersion),
|
||||||
)
|
)
|
||||||
|
|
@ -65,8 +65,8 @@ func TestConfigureClient(t *testing.T) {
|
||||||
SQLServerFlexCustomEndpoint: testCustomEndpoint,
|
SQLServerFlexCustomEndpoint: testCustomEndpoint,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: func() *sqlserverflex.APIClient {
|
expected: func() *v3beta1api.APIClient {
|
||||||
apiClient, err := sqlserverflex.NewAPIClient(
|
apiClient, err := v3beta1api.NewAPIClient(
|
||||||
utils.UserAgentConfigOption(testVersion),
|
utils.UserAgentConfigOption(testVersion),
|
||||||
config.WithEndpoint(testCustomEndpoint),
|
config.WithEndpoint(testCustomEndpoint),
|
||||||
)
|
)
|
||||||
|
|
@ -89,7 +89,7 @@ func TestConfigureClient(t *testing.T) {
|
||||||
t.Errorf("ConfigureClient() error = %v, want %v", diags.HasError(), tt.wantErr)
|
t.Errorf("ConfigureClient() error = %v, want %v", diags.HasError(), tt.wantErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(actual, tt.expected) {
|
if !reflect.DeepEqual(actual.GetConfig(), tt.expected.GetConfig()) {
|
||||||
t.Errorf("ConfigureClient() = %v, want %v", actual, tt.expected)
|
t.Errorf("ConfigureClient() = %v, want %v", actual, tt.expected)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -3,22 +3,14 @@ package stackit_test
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/golang-jwt/jwt/v5"
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
test "github.com/hashicorp/terraform-plugin-testing/helper/resource" //nolint:staticcheck // used for acceptance testing
|
sqlserverflexalphaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database"
|
||||||
"github.com/jarcoal/httpmock"
|
//nolint:staticcheck // used for acceptance testing
|
||||||
"github.com/stackitcloud/stackit-sdk-go/core/clients"
|
|
||||||
|
|
||||||
postgresflexalpha "github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v3alpha1api"
|
|
||||||
|
|
||||||
postgresFlexAlphaFlavor "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/flavor"
|
postgresFlexAlphaFlavor "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/flavor"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-framework/datasource"
|
"github.com/hashicorp/terraform-plugin-framework/datasource"
|
||||||
|
|
@ -29,14 +21,11 @@ import (
|
||||||
postgresflexalphaFlavors "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/flavors"
|
postgresflexalphaFlavors "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/flavors"
|
||||||
postgresFlexAlphaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance"
|
postgresFlexAlphaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance"
|
||||||
postgresFlexAlphaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/user"
|
postgresFlexAlphaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/user"
|
||||||
//sqlserverflexalphaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database"
|
sqlserverFlexAlphaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance"
|
||||||
//sqlserverFlexAlphaFlavor "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/flavor"
|
sqlserverFlexAlphaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/user"
|
||||||
//sqlserverFlexAlphaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance"
|
sqlserverflexBetaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/database"
|
||||||
//sqlserverFlexAlphaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/user"
|
sqlserverFlexBetaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/instance"
|
||||||
//sqlserverflexBetaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/database"
|
sqlserverFlexBetaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/user"
|
||||||
//sqlserverFlexBetaFlavor "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/flavor"
|
|
||||||
//sqlserverFlexBetaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/instance"
|
|
||||||
//sqlserverFlexBetaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/user"
|
|
||||||
|
|
||||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/internal/testutils"
|
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/internal/testutils"
|
||||||
|
|
||||||
|
|
@ -62,110 +51,6 @@ func TestMain(m *testing.M) {
|
||||||
os.Exit(code)
|
os.Exit(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMshTest(t *testing.T) {
|
|
||||||
httpmock.Activate()
|
|
||||||
defer httpmock.DeactivateAndReset()
|
|
||||||
|
|
||||||
testutils.ActivateEnvironmentHttpMocks()
|
|
||||||
|
|
||||||
httpmock.RegisterResponder(
|
|
||||||
"POST", `https://service-account.api.stackit.cloud/token`,
|
|
||||||
func(_ *http.Request) (*http.Response, error) {
|
|
||||||
token := jwt.NewWithClaims(
|
|
||||||
jwt.SigningMethodHS256, jwt.MapClaims{
|
|
||||||
"foo": "bar",
|
|
||||||
"nbf": time.Date(2015, 10, 10, 12, 0, 0, 0, time.UTC).Unix(),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
// Sign and get the complete encoded token as a string using the secret
|
|
||||||
tokenString, err := token.SignedString([]byte("mySecret"))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
tR := clients.TokenResponseBody{
|
|
||||||
AccessToken: tokenString,
|
|
||||||
ExpiresIn: 3600,
|
|
||||||
RefreshToken: "",
|
|
||||||
Scope: "",
|
|
||||||
TokenType: "",
|
|
||||||
}
|
|
||||||
|
|
||||||
return httpmock.NewJsonResponse(http.StatusOK, tR)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
httpmock.RegisterResponder(
|
|
||||||
"GET",
|
|
||||||
`https://postgres-flex-service.api.eu01.stackit.cloud/v3alpha1/projects/xyz-project-id/regions/eu01/flavors?page=1&size=25&sort=id.asc`,
|
|
||||||
func(_ *http.Request) (*http.Response, error) {
|
|
||||||
res := postgresflexalpha.GetFlavorsResponse{
|
|
||||||
Flavors: []postgresflexalpha.ListFlavors{
|
|
||||||
{
|
|
||||||
Cpu: 0,
|
|
||||||
Description: "",
|
|
||||||
Id: "",
|
|
||||||
MaxGB: 0,
|
|
||||||
Memory: 0,
|
|
||||||
MinGB: 0,
|
|
||||||
NodeType: "",
|
|
||||||
StorageClasses: nil,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Pagination: postgresflexalpha.Pagination{
|
|
||||||
Page: (int32(1)),
|
|
||||||
Size: (int32(25)),
|
|
||||||
Sort: "",
|
|
||||||
TotalPages: (int32(1)),
|
|
||||||
TotalRows: (int32(0)),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
return httpmock.NewJsonResponse(
|
|
||||||
http.StatusOK,
|
|
||||||
res,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
if _, ok := os.LookupEnv("TF_ACC_SERVICE_ACCOUNT_FILE"); !ok {
|
|
||||||
t.Skipf("TF_ACC_SERVICE_ACCOUNT_FILE is missing")
|
|
||||||
}
|
|
||||||
|
|
||||||
test.Test(
|
|
||||||
t, test.TestCase{
|
|
||||||
IsUnitTest: true,
|
|
||||||
ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories,
|
|
||||||
Steps: []test.TestStep{
|
|
||||||
{
|
|
||||||
ConfigVariables: map[string]config.Variable{
|
|
||||||
"project_id": config.StringVariable("xyz-project-id"),
|
|
||||||
},
|
|
||||||
Config: fmt.Sprintf(
|
|
||||||
`
|
|
||||||
provider "stackitprivatepreview" {
|
|
||||||
default_region = "%[1]s"
|
|
||||||
service_account_key_path = "%[2]s"
|
|
||||||
}
|
|
||||||
variable "project_id" {
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
data "stackitprivatepreview_postgresflexalpha_flavor" "all" {
|
|
||||||
project_id = var.project_id
|
|
||||||
region = "eu01"
|
|
||||||
cpu = 2
|
|
||||||
ram = 4
|
|
||||||
node_type = "Single"
|
|
||||||
storage_class = "premium-perf2-stackit"
|
|
||||||
}`,
|
|
||||||
os.Getenv("TF_ACC_REGION"),
|
|
||||||
os.Getenv("TF_ACC_SERVICE_ACCOUNT_FILE"),
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUnitProviderHasChildDataSources_Basic(t *testing.T) {
|
func TestUnitProviderHasChildDataSources_Basic(t *testing.T) {
|
||||||
expectedDataSources := []datasource.DataSource{
|
expectedDataSources := []datasource.DataSource{
|
||||||
postgresFlexAlphaFlavor.NewFlavorDataSource(),
|
postgresFlexAlphaFlavor.NewFlavorDataSource(),
|
||||||
|
|
@ -175,15 +60,15 @@ func TestUnitProviderHasChildDataSources_Basic(t *testing.T) {
|
||||||
postgresFlexAlphaUser.NewUserDataSource(),
|
postgresFlexAlphaUser.NewUserDataSource(),
|
||||||
postgresflexalphaFlavors.NewFlavorsDataSource(),
|
postgresflexalphaFlavors.NewFlavorsDataSource(),
|
||||||
|
|
||||||
//sqlserverFlexAlphaFlavor.NewFlavorDataSource(),
|
// sqlserverFlexAlphaFlavor.NewFlavorDataSource(),
|
||||||
//sqlserverFlexAlphaInstance.NewInstanceDataSource(),
|
sqlserverFlexAlphaInstance.NewInstanceDataSource(),
|
||||||
//sqlserverFlexAlphaUser.NewUserDataSource(),
|
sqlserverFlexAlphaUser.NewUserDataSource(),
|
||||||
//sqlserverflexalphaDatabase.NewDatabaseDataSource(),
|
sqlserverflexalphaDatabase.NewDatabaseDataSource(),
|
||||||
|
|
||||||
//sqlserverflexBetaDatabase.NewDatabaseDataSource(),
|
sqlserverflexBetaDatabase.NewDatabaseDataSource(),
|
||||||
//sqlserverFlexBetaInstance.NewInstanceDataSource(),
|
sqlserverFlexBetaInstance.NewInstanceDataSource(),
|
||||||
//sqlserverFlexBetaUser.NewUserDataSource(),
|
sqlserverFlexBetaUser.NewUserDataSource(),
|
||||||
//sqlserverFlexBetaFlavor.NewFlavorDataSource(),
|
// sqlserverFlexBetaFlavor.NewFlavorDataSource(),
|
||||||
}
|
}
|
||||||
provider, ok := stackit.New("testing")().(*stackit.Provider)
|
provider, ok := stackit.New("testing")().(*stackit.Provider)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
@ -212,13 +97,13 @@ func TestUnitProviderHasChildResources_Basic(t *testing.T) {
|
||||||
postgresFlexAlphaUser.NewUserResource(),
|
postgresFlexAlphaUser.NewUserResource(),
|
||||||
postgresFlexAlphaDatabase.NewDatabaseResource(),
|
postgresFlexAlphaDatabase.NewDatabaseResource(),
|
||||||
|
|
||||||
//sqlserverFlexAlphaInstance.NewInstanceResource(),
|
sqlserverFlexAlphaInstance.NewInstanceResource(),
|
||||||
//sqlserverFlexAlphaUser.NewUserResource(),
|
sqlserverFlexAlphaUser.NewUserResource(),
|
||||||
//sqlserverflexalphaDatabase.NewDatabaseResource(),
|
sqlserverflexalphaDatabase.NewDatabaseResource(),
|
||||||
|
|
||||||
//sqlserverFlexBetaInstance.NewInstanceResource(),
|
sqlserverFlexBetaInstance.NewInstanceResource(),
|
||||||
//sqlserverFlexBetaUser.NewUserResource(),
|
sqlserverFlexBetaUser.NewUserResource(),
|
||||||
//sqlserverflexBetaDatabase.NewDatabaseResource(),
|
sqlserverflexBetaDatabase.NewDatabaseResource(),
|
||||||
}
|
}
|
||||||
provider, ok := stackit.New("testing")().(*stackit.Provider)
|
provider, ok := stackit.New("testing")().(*stackit.Provider)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue