Skip to content

Commit

Permalink
release v0.1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
contabo committed Sep 8, 2023
1 parent ae27490 commit 3d7d813
Show file tree
Hide file tree
Showing 21 changed files with 60 additions and 219 deletions.
2 changes: 1 addition & 1 deletion contabo/data_source_object_storage_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceObjectStorageBucket() *schema.Resource {
"name": {
Type: schema.TypeString,
Description: "The name of your bucket, consider the naming restriction https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-s3-bucket-naming-requirements.html.",
Required: true,
Optional: true,
},
"object_storage_id": {
Type: schema.TypeString,
Expand Down
2 changes: 1 addition & 1 deletion contabo/data_source_private_networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func dataSourcePrivateNetwork() *schema.Resource {
},
"id": {
Type: schema.TypeString,
Computed: true,
Description: "The identifier of the Private Network. Use it to manage it!",
Required: true,
},
"name": {
Type: schema.TypeString,
Expand Down
8 changes: 4 additions & 4 deletions contabo/data_source_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ func dataSourceSecret() *schema.Resource {
},
"id": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Required: true,
Description: "The identifier of the secret. Use it to manage it!",
},
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "Name of the secret.",
Computed: true,
},
"value": &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "The value of the secret. It will be available only when retrieving a single secret.",
Computed: true,
},
"type": &schema.Schema{
Type: schema.TypeString,
Required: true,
Description: "The type of the secret. It will be available only when retrieving secrets, following types are allowed: `ssh`, `password`.",
Computed: true,
},
},
}
Expand Down
90 changes: 0 additions & 90 deletions contabo/resource_firewall_test.go

This file was deleted.

25 changes: 15 additions & 10 deletions contabo/resource_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import (
"fmt"
"testing"

"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

var creationDisplayName = (uuid.New()).String()
var updatedDisplayName = (uuid.New()).String()
var anotherUpdatedDisplayName = (uuid.New()).String()

func TestAccContaboInstanceBasic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -18,32 +23,32 @@ func TestAccContaboInstanceBasic(t *testing.T) {
Config: updateAndReinstallVPSCreation(),
Check: resource.ComposeTestCheckFunc(
testCheckContaboInstanceExists("contabo_instance.update_reinstall_test"),
resource.TestCheckResourceAttr("contabo_instance.update_reinstall_test", "display_name", "created_display_name"),
resource.TestCheckResourceAttr("contabo_instance.update_reinstall_test", "display_name", creationDisplayName),
),
PreventPostDestroyRefresh: true,
},
{
Config: updateAndReinstallInstallFedora(),
Check: resource.ComposeTestCheckFunc(
testCheckContaboInstanceExists("contabo_instance.update_reinstall_test"),
resource.TestCheckResourceAttr("contabo_instance.update_reinstall_test", "image_id", "1e1802ac-843c-42ed-9533-add37aaff46b"),
resource.TestCheckResourceAttr("contabo_instance.update_reinstall_test", "image_id", "66abf39a-ba8b-425e-a385-8eb347ceac10"),
),
PreventPostDestroyRefresh: true,
},
{
Config: updateAndReinstallDisplayNameUpdate(),
Check: resource.ComposeTestCheckFunc(
testCheckContaboInstanceExists("contabo_instance.update_reinstall_test"),
resource.TestCheckResourceAttr("contabo_instance.update_reinstall_test", "display_name", "first_updated_display_name"),
resource.TestCheckResourceAttr("contabo_instance.update_reinstall_test", "display_name", updatedDisplayName),
),
PreventPostDestroyRefresh: true,
},
{
Config: updateAndReinstallUpdateDisplayNameAndInstallArch(),
Check: resource.ComposeTestCheckFunc(
testCheckContaboInstanceExists("contabo_instance.update_reinstall_test"),
resource.TestCheckResourceAttr("contabo_instance.update_reinstall_test", "display_name", "secound_updated_display_name"),
resource.TestCheckResourceAttr("contabo_instance.update_reinstall_test", "image_id", "69b52ee3-2fda-4f44-b8de-69e480d87c7d"),
resource.TestCheckResourceAttr("contabo_instance.update_reinstall_test", "display_name", anotherUpdatedDisplayName),
resource.TestCheckResourceAttr("contabo_instance.update_reinstall_test", "image_id", "66abf39a-ba8b-425e-a385-8eb347ceac10"),
),
PreventPostDestroyRefresh: true,
},
Expand All @@ -56,7 +61,7 @@ func updateAndReinstallVPSCreation() string {
provider "contabo" {}
resource "contabo_instance" "update_reinstall_test" {
display_name = "created_display_name"
display_name = "` + creationDisplayName + `"
image_id = "66abf39a-ba8b-425e-a385-8eb347ceac10"
}
`
Expand All @@ -67,7 +72,7 @@ func updateAndReinstallDisplayNameUpdate() string {
provider "contabo" {}
resource "contabo_instance" "update_reinstall_test" {
display_name = "first_updated_display_name"
display_name = "` + updatedDisplayName + `"
}
`
}
Expand All @@ -77,7 +82,7 @@ func updateAndReinstallInstallFedora() string {
provider "contabo" {}
resource "contabo_instance" "update_reinstall_test" {
image_id = "1e1802ac-843c-42ed-9533-add37aaff46b"
image_id = "66abf39a-ba8b-425e-a385-8eb347ceac10"
}
`
}
Expand All @@ -87,8 +92,8 @@ func updateAndReinstallUpdateDisplayNameAndInstallArch() string {
provider "contabo" {}
resource "contabo_instance" "update_reinstall_test" {
image_id = "69b52ee3-2fda-4f44-b8de-69e480d87c7d"
display_name = "secound_updated_display_name"
image_id = "66abf39a-ba8b-425e-a385-8eb347ceac10"
display_name = "` + anotherUpdatedDisplayName + `"
}
`
}
Expand Down
7 changes: 5 additions & 2 deletions contabo/resource_object_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import (
"testing"
"time"

"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

var displayName = (uuid.New()).String()

func TestAccContaboObjectStorageBasic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -25,7 +28,7 @@ func TestAccContaboObjectStorageBasic(t *testing.T) {
),
resource.TestCheckResourceAttr(
"contabo_object_storage.object_storage_eu",
"display_name", "terraform_test_object_storage_eu",
"display_name", displayName,
),
),
ExpectNonEmptyPlan: true,
Expand All @@ -43,7 +46,7 @@ func testCheckContaboObjectStorageConfigBasic() string {
resource "contabo_object_storage" "object_storage_eu" {
region = "EU"
total_purchased_space_tb = 0.250
display_name = "terraform_test_object_storage_eu"
display_name = "` + displayName + `"
}
`
}
Expand Down
17 changes: 11 additions & 6 deletions contabo/resource_private_networking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ import (
"testing"

"contabo.com/openapi"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
uuid "github.com/satori/go.uuid"
)

var instanceDisplayName = (uuid.New()).String()
var anotherInstanceDisplayName = (uuid.New()).String()
var privateNetworkName = (uuid.New()).String()
var privateNetworkWithInstanceName = (uuid.New()).String()

func TestAccContaboPrivateNetworkBasic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() {
Expand Down Expand Up @@ -61,7 +66,7 @@ func testAccCheckPrivateNetworkDestroy(s *terraform.State) error {

_, _, err := client.PrivateNetworksApi.
RetrievePrivateNetwork(context.Background(), privateNetworktId).
XRequestId(uuid.NewV4().String()).
XRequestId((uuid.New()).String()).
Execute()
if err == nil {
fmt.Printf("Private Network %v Still Exists: %v", privateNetworktId, err.Error())
Expand All @@ -75,15 +80,15 @@ func testAccCheckPrivateNetworkDestroy(s *terraform.State) error {
func testAddInstance() string {
return `
resource "contabo_instance" "new" {
display_name = "custom terraform"
display_name = "` + instanceDisplayName + `"
}
`
}

func testCheckContaboPrivateNetworkConfigBasic() string {
return `
resource "contabo_private_network" "new" {
name = "terraform-test-private-network"
name = "` + privateNetworkName + `"
description = "terraform test private network"
region = "EU"
}
Expand All @@ -93,11 +98,11 @@ func testCheckContaboPrivateNetworkConfigBasic() string {
func testContaboPrivateNetworkConfigWithInstance() string {
return `
resource "contabo_instance" "new" {
display_name = "custom terraform"
display_name = "` + anotherInstanceDisplayName + `"
}
resource "contabo_private_network" "with_instance" {
name = "terraform-test-private-network-with-instance"
name = "` + privateNetworkWithInstanceName + `"
region = "EU"
instance_ids = [
contabo_instance.new.id
Expand Down
8 changes: 5 additions & 3 deletions contabo/resource_secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import (
"testing"

"contabo.com/openapi"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
uuid "github.com/satori/go.uuid"
)

var secretName = (uuid.New()).String()

func TestAccContaboSecretBasic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -45,7 +47,7 @@ func testAccCheckSecretDestroy(s *terraform.State) error {

_, _, err := client.SecretsApi.
RetrieveSecret(context.Background(), secretId).
XRequestId(uuid.NewV4().String()).
XRequestId((uuid.New()).String()).
Execute()
if err == nil {
fmt.Printf("SECRET %v Still Exists: %v", secretId, err.Error())
Expand All @@ -61,7 +63,7 @@ func testCheckContaboSecretConfigBasic() string {
provider "contabo" {}
resource "contabo_secret" "new" {
name = "my_secret"
name = "` + secretName + `"
type = "password"
value = "AllCombinationPassword123?#"
}
Expand Down
2 changes: 1 addition & 1 deletion contabo/resource_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func resourceSecret() *schema.Resource {
UpdateContext: resourceSecretUpdate,
DeleteContext: resourceSecretDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Schema: map[string]*schema.Schema{
"created_at": &schema.Schema{
Expand Down

0 comments on commit 3d7d813

Please sign in to comment.