Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/github.com/hashicorp/t…
Browse files Browse the repository at this point in the history
…erraform-plugin-go-0.24.0
  • Loading branch information
davidfischer-ch authored Sep 20, 2024
2 parents 6a1f4b4 + faf58aa commit 05169d6
Show file tree
Hide file tree
Showing 2 changed files with 257 additions and 0 deletions.
251 changes: 251 additions & 0 deletions internal/provider/custom_resource_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,257 @@ resource "aria_abx_action" "restore" {
project_id = var.test_project_id
}
resource "aria_resource_action" "test_restore" {
name = "restore"
display_name = "Do restore"
description = "Restore the instance from latest snapshot (disks and memory)."
status = aria_custom_resource.test.status
resource_id = aria_custom_resource.test.id
resource_type = aria_custom_resource.test.resource_type
project_id = aria_custom_resource.test.project_id
runnable_item = {
id = aria_abx_action.restore.id
name = aria_abx_action.restore.name
project_id = aria_abx_action.restore.project_id
type = "abx.action"
input_parameters = []
output_parameters = []
}
}
`,
/*Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet("aria_abx_action.test", "id"),
resource.TestCheckResourceAttr("aria_abx_action.test", "name", "ARIA_PROVIDER_TEST_ACTION"),
resource.TestCheckResourceAttr("aria_abx_action.test", "description", "Temporary action generated by Aria provider's acceptance tests."),
resource.TestCheckResourceAttr("aria_abx_action.test", "faas_provider", "auto"),
resource.TestCheckResourceAttr("aria_abx_action.test", "type", "SCRIPT"),
resource.TestCheckResourceAttr("aria_abx_action.test", "runtime_name", "python"),
// resource.TestCheckResourceAttrSet("aria_abx_action.test", "runtime_version"),
resource.TestCheckResourceAttr("aria_abx_action.test", "cpu_shares", "1024"),
resource.TestCheckResourceAttr("aria_abx_action.test", "memory_in_mb", "128"),
resource.TestCheckResourceAttr("aria_abx_action.test", "timeout_seconds", "60"),
resource.TestCheckResourceAttr("aria_abx_action.test", "deployment_timeout_seconds", "900"),
resource.TestCheckResourceAttr("aria_abx_action.test", "entrypoint", "handler"),
resource.TestCheckResourceAttr("aria_abx_action.test", "shared", "true"),
resource.TestCheckResourceAttr("aria_abx_action.test", "system", "false"),
resource.TestCheckResourceAttr("aria_abx_action.test", "async_deployed", "false"),
resource.TestCheckResourceAttrSet("aria_abx_action.test", "org_id"),
),*/
},

// Rename Resource Type test
{
Config: `
variable "test_project_id" {
description = "Project where to generate test resources."
type = string
}
locals {
source = <<EOT
import os
def handler(*args, **kwargs):
print('Global symbols :', globals())
print('Environment variables :', os.environ)
print('Call Arguments: ', args, kwargs)
EOT
}
resource "aria_abx_action" "create" {
name = "Custom.AriaProviderTest.create"
description = "Temporary action generated by Aria provider's acceptance tests."
runtime_name = "python"
memory_in_mb = 128
timeout_seconds = 60
entrypoint = "handler"
dependencies = []
constants = []
secrets = []
source = local.source
shared = true
project_id = var.test_project_id
}
resource "aria_abx_action" "read" {
name = "Custom.AriaProviderTest.read"
description = "Temporary action generated by Aria provider's acceptance tests."
runtime_name = "python"
memory_in_mb = 128
timeout_seconds = 60
entrypoint = "handler"
dependencies = []
constants = []
secrets = []
source = local.source
shared = true
project_id = var.test_project_id
}
resource "aria_abx_action" "update" {
name = "Custom.AriaProviderTest.update"
description = "Temporary action generated by Aria provider's acceptance tests."
runtime_name = "python"
memory_in_mb = 128
timeout_seconds = 60
entrypoint = "handler"
dependencies = []
constants = []
secrets = []
source = local.source
shared = true
project_id = var.test_project_id
}
resource "aria_abx_action" "delete" {
name = "Custom.AriaProviderTest.delete"
description = "Temporary action generated by Aria provider's acceptance tests."
runtime_name = "python"
memory_in_mb = 128
timeout_seconds = 60
entrypoint = "handler"
dependencies = []
constants = []
secrets = []
source = local.source
shared = true
project_id = var.test_project_id
}
resource "aria_custom_resource" "test" {
display_name = "Aria Provider Test Custom Resource"
description = "Temporary custom resource generated by Aria provider's acceptance tests."
resource_type = "Custom.AriaProviderTestNew"
schema_type = "ABX_USER_DEFINED"
status = "DRAFT"
properties = {
some_text = {
name = "some_text"
title = "Some Text"
description = "Some text, more text."
type = "string"
encrypted = false
read_only = false
recreate_on_update = false
one_of = [
{ const = "a", title = "A", encrypted = false },
{ const = "b", title = "B", encrypted = false }
]
}
number = {
name = "number"
title = "Some Number"
description = <<EOT
Some number.
It can be an integer or a float.
EOT
type = "number"
default = "3.141592"
encrypted = false
read_only = false
recreate_on_update = false
minimum = 0
maximum = 5
}
super_secret = {
name = "super_secret"
title = "Super Secret"
description = ""
type = "string"
encrypted = true
read_only = false
recreate_on_update = false
min_length = 16
max_length = 64
}
}
create = {
id = aria_abx_action.create.id
name = aria_abx_action.create.name
project_id = aria_abx_action.create.project_id
type = "abx.action"
input_parameters = []
output_parameters = []
}
read = {
id = aria_abx_action.read.id
name = aria_abx_action.read.name
project_id = aria_abx_action.read.project_id
type = "abx.action"
input_parameters = []
output_parameters = []
}
update = {
id = aria_abx_action.update.id
name = aria_abx_action.update.name
project_id = aria_abx_action.update.project_id
type = "abx.action"
input_parameters = []
output_parameters = []
}
delete = {
id = aria_abx_action.delete.id
name = aria_abx_action.delete.name
project_id = aria_abx_action.delete.project_id
type = "abx.action"
input_parameters = []
output_parameters = []
}
}
resource "aria_abx_action" "snapshot" {
name = "Custom.AriaProviderTest.snapshot"
description = "Temporary action generated by Aria provider's acceptance tests."
runtime_name = "python"
memory_in_mb = 128
timeout_seconds = 60
entrypoint = "handler"
dependencies = []
constants = []
secrets = []
source = local.source
shared = true
project_id = var.test_project_id
}
resource "aria_resource_action" "test_snapshot" {
name = "snapshot"
display_name = "Do snapshot"
description = "Snapshot the instance (disks and memory)."
status = aria_custom_resource.test.status
resource_id = aria_custom_resource.test.id
resource_type = aria_custom_resource.test.resource_type
project_id = aria_custom_resource.test.project_id
runnable_item = {
id = aria_abx_action.snapshot.id
name = aria_abx_action.snapshot.name
project_id = aria_abx_action.snapshot.project_id
type = "abx.action"
input_parameters = []
output_parameters = []
}
}
resource "aria_abx_action" "restore" {
name = "Custom.AriaProviderTest.restore"
description = "Temporary action generated by Aria provider's acceptance tests."
runtime_name = "python"
memory_in_mb = 128
timeout_seconds = 60
entrypoint = "handler"
dependencies = []
constants = []
secrets = []
source = local.source
shared = true
project_id = var.test_project_id
}
resource "aria_resource_action" "test_restore" {
name = "restore"
display_name = "Do restore"
Expand Down
6 changes: 6 additions & 0 deletions internal/provider/custom_resource_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ package provider
import (
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
)

Expand All @@ -23,6 +25,10 @@ func CustomResourceSchema() schema.Schema {
"resource_type": schema.StringAttribute{
MarkdownDescription: "Define the type (must be unique, e.g. Custom.DB.PostgreSQL)",
Required: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
stringplanmodifier.UseStateForUnknown(),
},
},
"schema_type": schema.StringAttribute{
MarkdownDescription: "Type of resource, one of ABX_USER_DEFINED (and that's all, maybe)",
Expand Down

0 comments on commit 05169d6

Please sign in to comment.