From e0d5cf0154bb5e27b36001f0643d781ae587d501 Mon Sep 17 00:00:00 2001 From: miton18 Date: Mon, 4 Nov 2024 11:56:33 +0100 Subject: [PATCH] chore: factorize apps schema --- .github/workflows/lint.yml | 2 +- docs/resources/addon.md | 6 +-- docs/resources/java_war.md | 18 ++++---- docs/resources/nodejs.md | 16 +++---- docs/resources/python.md | 16 +++---- docs/resources/scala.md | 18 ++++---- docs/resources/static.md | 16 +++---- pkg/attributes/addon.go | 33 ++++++++++++++ pkg/attributes/{common.go => runtime.go} | 36 ++++++++++----- pkg/resources/addon/schema.go | 24 ++-------- .../docker/resource_docker_schema.go | 24 +--------- pkg/resources/java/schema.go | 24 +--------- pkg/resources/mongodb/schema.go | 40 +++++------------ pkg/resources/nodejs/schema.go | 25 +---------- pkg/resources/php/schema.go | 24 +--------- pkg/resources/postgresql/schema.go | 45 ++++++------------- pkg/resources/python/schema.go | 25 +---------- pkg/resources/scala/schema.go | 24 +--------- pkg/resources/static/schema.go | 26 +---------- 19 files changed, 142 insertions(+), 300 deletions(-) create mode 100644 pkg/attributes/addon.go rename pkg/attributes/{common.go => runtime.go} (80%) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 305c9cd..3651259 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,5 +16,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.57 + version: v1.61 ... diff --git a/docs/resources/addon.md b/docs/resources/addon.md index 6cbfea4..72b346b 100644 --- a/docs/resources/addon.md +++ b/docs/resources/addon.md @@ -24,13 +24,13 @@ List of available providers: ### Required -- `name` (String) Name of the addon -- `plan` (String) billing plan +- `name` (String) Name of the service +- `plan` (String) Database size and spec - `third_party_provider` (String) Provider ID ### Optional -- `region` (String) Geographical region where the addon will be deployed (when relevant) +- `region` (String) Geographical region where the data will be stored ### Read-Only diff --git a/docs/resources/java_war.md b/docs/resources/java_war.md index 27f3064..64a9b78 100644 --- a/docs/resources/java_war.md +++ b/docs/resources/java_war.md @@ -3,22 +3,22 @@ page_title: "clevercloud_java_war Resource - terraform-provider-clevercloud" subcategory: "" description: |- - Manage Java https://www.java.com/en/ applications. + Manage Java applications. See Java product https://www.clever-cloud.com/doc/getting-started/by-language/java/ specification. Example usage Basic - terraform + resource "clevercloud_java_war" "myapp" { - name = "tf-myapp" - region = "par" - min_instance_count = 1 - max_instance_count = 2 - smallest_flavor = "XS" - biggest_flavor = "M" + name = "tf-myapp" + region = "par" + min_instance_count = 1 + max_instance_count = 2 + smallest_flavor = "XS" + biggest_flavor = "M" } Advanced - terraform + resource "clevercloud_java_war" "myapp" { name = "tf-myapp" region = "par" diff --git a/docs/resources/nodejs.md b/docs/resources/nodejs.md index 4354313..365a277 100644 --- a/docs/resources/nodejs.md +++ b/docs/resources/nodejs.md @@ -7,18 +7,18 @@ description: |- See NodeJS product https://www.clever-cloud.com/nodejs-hosting/ specification. Example usage Basic - terraform + resource "clevercloud_nodejs" "myapp" { - name = "tf-myapp" - region = "par" - min_instance_count = 1 - max_instance_count = 2 - smallest_flavor = "XS" - biggest_flavor = "M" + name = "tf-myapp" + region = "par" + min_instance_count = 1 + max_instance_count = 2 + smallest_flavor = "XS" + biggest_flavor = "M" } Advanced - terraform + resource "clevercloud_nodejs" "myapp" { name = "tf-myapp" region = "par" diff --git a/docs/resources/python.md b/docs/resources/python.md index 7d5055b..a538b0f 100644 --- a/docs/resources/python.md +++ b/docs/resources/python.md @@ -7,18 +7,18 @@ description: |- See Python product https://www.clever-cloud.com/python-hosting/ specification. Example usage Basic - terraform + resource "clevercloud_python" "myapp" { - name = "tf-myapp" - region = "par" - min_instance_count = 1 - max_instance_count = 2 - smallest_flavor = "XS" - biggest_flavor = "M" + name = "tf-myapp" + region = "par" + min_instance_count = 1 + max_instance_count = 2 + smallest_flavor = "XS" + biggest_flavor = "M" } Advanced - terraform + resource "clevercloud_python" "myapp" { name = "tf-myapp" region = "par" diff --git a/docs/resources/scala.md b/docs/resources/scala.md index 6020896..79843bf 100644 --- a/docs/resources/scala.md +++ b/docs/resources/scala.md @@ -3,22 +3,22 @@ page_title: "clevercloud_scala Resource - terraform-provider-clevercloud" subcategory: "" description: |- - Manage Scala https://www.scala-lang.org/ applications. + Manage Scala applications. See Scala product https://www.clever-cloud.com/scala-hosting/ specification. Example usage Basic - terraform + resource "clevercloud_scala" "myapp" { - name = "tf-myapp" - region = "par" - min_instance_count = 1 - max_instance_count = 2 - smallest_flavor = "XS" - biggest_flavor = "M" + name = "tf-myapp" + region = "par" + min_instance_count = 1 + max_instance_count = 2 + smallest_flavor = "XS" + biggest_flavor = "M" } Advanced - terraform + resource "clevercloud_scala" "myapp" { name = "tf-myapp" region = "par" diff --git a/docs/resources/static.md b/docs/resources/static.md index 3c26190..3b6b7b0 100644 --- a/docs/resources/static.md +++ b/docs/resources/static.md @@ -7,18 +7,18 @@ description: |- See Static product https://www.clever-cloud.com/doc/deploy/application/static/static/ specification. Example usage Basic - terraform + resource "clevercloud_static" "myapp" { - name = "tf-myapp" - region = "par" - min_instance_count = 1 - max_instance_count = 2 - smallest_flavor = "XS" - biggest_flavor = "M" + name = "tf-myapp" + region = "par" + min_instance_count = 1 + max_instance_count = 2 + smallest_flavor = "XS" + biggest_flavor = "M" } Advanced - terraform + resource "clevercloud_static" "myapp" { name = "tf-myapp" region = "par" diff --git a/pkg/attributes/addon.go b/pkg/attributes/addon.go new file mode 100644 index 0000000..0783e5e --- /dev/null +++ b/pkg/attributes/addon.go @@ -0,0 +1,33 @@ +package attributes + +import ( + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/types" + "go.clever-cloud.com/terraform-provider/pkg" +) + +type Addon struct { + ID types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` + Plan types.String `tfsdk:"plan"` + Region types.String `tfsdk:"region"` + CreationDate types.Int64 `tfsdk:"creation_date"` +} + +var addonCommon = map[string]schema.Attribute{ + "id": schema.StringAttribute{Computed: true, MarkdownDescription: "Generated unique identifier"}, + "name": schema.StringAttribute{Required: true, MarkdownDescription: "Name of the service"}, + "plan": schema.StringAttribute{Required: true, MarkdownDescription: "Database size and spec"}, + "region": schema.StringAttribute{ + Optional: true, + Computed: true, + Default: stringdefault.StaticString("par"), + MarkdownDescription: "Geographical region where the data will be stored", + }, + "creation_date": schema.Int64Attribute{Computed: true, MarkdownDescription: "Date of database creation"}, +} + +func WithAddonCommons(runtimeSpecifics map[string]schema.Attribute) map[string]schema.Attribute { + return pkg.Merge(addonCommon, runtimeSpecifics) +} diff --git a/pkg/attributes/common.go b/pkg/attributes/runtime.go similarity index 80% rename from pkg/attributes/common.go rename to pkg/attributes/runtime.go index 7584c09..0da76ce 100644 --- a/pkg/attributes/common.go +++ b/pkg/attributes/runtime.go @@ -12,6 +12,30 @@ import ( "go.clever-cloud.com/terraform-provider/pkg" ) +type Runtime struct { + ID types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` + Description types.String `tfsdk:"description"` + MinInstanceCount types.Int64 `tfsdk:"min_instance_count"` + MaxInstanceCount types.Int64 `tfsdk:"max_instance_count"` + SmallestFlavor types.String `tfsdk:"smallest_flavor"` + BiggestFlavor types.String `tfsdk:"biggest_flavor"` + BuildFlavor types.String `tfsdk:"build_flavor"` + Region types.String `tfsdk:"region"` + StickySessions types.Bool `tfsdk:"sticky_sessions"` + RedirectHTTPS types.Bool `tfsdk:"redirect_https"` + VHost types.String `tfsdk:"vhost"` + AdditionalVHosts types.List `tfsdk:"additional_vhosts"` + DeployURL types.String `tfsdk:"deploy_url"` + Dependencies types.Set `tfsdk:"dependencies"` + Deployment *Deployment `tfsdk:"deployment"` + Hooks *Hooks `tfsdk:"hooks"` + + // Env + AppFolder types.String `tfsdk:"app_folder"` + Environment types.Map `tfsdk:"environment"` +} + // This attributes are used on several runtimes var runtimeCommon = map[string]schema.Attribute{ // client provided @@ -124,15 +148,5 @@ var runtimeCommon = map[string]schema.Attribute{ } func WithRuntimeCommons(runtimeSpecifics map[string]schema.Attribute) map[string]schema.Attribute { - m := map[string]schema.Attribute{} - - for attrName, attr := range runtimeCommon { - m[attrName] = attr - } - - for attrName, attr := range runtimeSpecifics { - m[attrName] = attr - } - - return m + return pkg.Merge(runtimeCommon, runtimeSpecifics) } diff --git a/pkg/resources/addon/schema.go b/pkg/resources/addon/schema.go index 6260f1d..cc40a4e 100644 --- a/pkg/resources/addon/schema.go +++ b/pkg/resources/addon/schema.go @@ -6,17 +6,13 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" "github.com/hashicorp/terraform-plugin-framework/types" + "go.clever-cloud.com/terraform-provider/pkg/attributes" ) type Addon struct { - ID types.String `tfsdk:"id"` + attributes.Addon ThirdPartyProvider types.String `tfsdk:"third_party_provider"` - Name types.String `tfsdk:"name"` - CreationDate types.Int64 `tfsdk:"creation_date"` - Plan types.String `tfsdk:"plan"` - Region types.String `tfsdk:"region"` Configurations types.Map `tfsdk:"configurations"` } @@ -27,28 +23,16 @@ func (r ResourceAddon) Schema(_ context.Context, req resource.SchemaRequest, res resp.Schema = schema.Schema{ Version: 0, MarkdownDescription: resourcePostgresqlDoc, - Attributes: map[string]schema.Attribute{ - // customer provided - "name": schema.StringAttribute{Required: true, MarkdownDescription: "Name of the addon"}, - "plan": schema.StringAttribute{Required: true, MarkdownDescription: "billing plan"}, - "region": schema.StringAttribute{ - Optional: true, - Computed: true, - Default: stringdefault.StaticString("par"), - MarkdownDescription: "Geographical region where the addon will be deployed (when relevant)", - }, + Attributes: attributes.WithAddonCommons(map[string]schema.Attribute{ "third_party_provider": schema.StringAttribute{Required: true, MarkdownDescription: "Provider ID"}, - // provider - "id": schema.StringAttribute{Computed: true, MarkdownDescription: "Generated unique identifier"}, - "creation_date": schema.Int64Attribute{Computed: true, MarkdownDescription: "Date of database creation"}, "configurations": schema.MapAttribute{ Computed: true, Sensitive: true, MarkdownDescription: "Any configuration exposed by the addon", ElementType: types.StringType, }, - }, + }), } } diff --git a/pkg/resources/docker/resource_docker_schema.go b/pkg/resources/docker/resource_docker_schema.go index f12e601..939e67c 100644 --- a/pkg/resources/docker/resource_docker_schema.go +++ b/pkg/resources/docker/resource_docker_schema.go @@ -19,29 +19,7 @@ import ( ) type Docker struct { - ID types.String `tfsdk:"id"` - Name types.String `tfsdk:"name"` - Description types.String `tfsdk:"description"` - MinInstanceCount types.Int64 `tfsdk:"min_instance_count"` - MaxInstanceCount types.Int64 `tfsdk:"max_instance_count"` - SmallestFlavor types.String `tfsdk:"smallest_flavor"` - BiggestFlavor types.String `tfsdk:"biggest_flavor"` - BuildFlavor types.String `tfsdk:"build_flavor"` - Region types.String `tfsdk:"region"` - StickySessions types.Bool `tfsdk:"sticky_sessions"` - RedirectHTTPS types.Bool `tfsdk:"redirect_https"` - VHost types.String `tfsdk:"vhost"` - AdditionalVHosts types.List `tfsdk:"additional_vhosts"` - DeployURL types.String `tfsdk:"deploy_url"` - Deployment *attributes.Deployment `tfsdk:"deployment"` - Hooks *attributes.Hooks `tfsdk:"hooks"` - Dependencies types.Set `tfsdk:"dependencies"` - - // Env - AppFolder types.String `tfsdk:"app_folder"` - Environment types.Map `tfsdk:"environment"` - - // Docker related + attributes.Runtime Dockerfile types.String `tfsdk:"dockerfile"` ContainerPort types.Int64 `tfsdk:"container_port"` ContainerPortTCP types.Int64 `tfsdk:"container_port_tcp"` diff --git a/pkg/resources/java/schema.go b/pkg/resources/java/schema.go index d0ded3c..bc0c44e 100644 --- a/pkg/resources/java/schema.go +++ b/pkg/resources/java/schema.go @@ -14,29 +14,7 @@ import ( ) type Java struct { - ID types.String `tfsdk:"id"` - Name types.String `tfsdk:"name"` - Description types.String `tfsdk:"description"` - MinInstanceCount types.Int64 `tfsdk:"min_instance_count"` - MaxInstanceCount types.Int64 `tfsdk:"max_instance_count"` - SmallestFlavor types.String `tfsdk:"smallest_flavor"` - BiggestFlavor types.String `tfsdk:"biggest_flavor"` - BuildFlavor types.String `tfsdk:"build_flavor"` - Region types.String `tfsdk:"region"` - StickySessions types.Bool `tfsdk:"sticky_sessions"` - RedirectHTTPS types.Bool `tfsdk:"redirect_https"` - VHost types.String `tfsdk:"vhost"` - AdditionalVHosts types.List `tfsdk:"additional_vhosts"` - DeployURL types.String `tfsdk:"deploy_url"` - Deployment *attributes.Deployment `tfsdk:"deployment"` - Hooks *attributes.Hooks `tfsdk:"hooks"` - Dependencies types.Set `tfsdk:"dependencies"` - - // Env - AppFolder types.String `tfsdk:"app_folder"` - Environment types.Map `tfsdk:"environment"` - - // Java related + attributes.Runtime JavaVersion types.String `tfsdk:"java_version"` } diff --git a/pkg/resources/mongodb/schema.go b/pkg/resources/mongodb/schema.go index dce7e8a..f2bdee6 100644 --- a/pkg/resources/mongodb/schema.go +++ b/pkg/resources/mongodb/schema.go @@ -6,20 +6,16 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" "github.com/hashicorp/terraform-plugin-framework/types" + "go.clever-cloud.com/terraform-provider/pkg/attributes" ) type MongoDB struct { - ID types.String `tfsdk:"id"` - Name types.String `tfsdk:"name"` - Plan types.String `tfsdk:"plan"` - Region types.String `tfsdk:"region"` - CreationDate types.Int64 `tfsdk:"creation_date"` - Host types.String `tfsdk:"host"` - Port types.Int64 `tfsdk:"port"` - User types.String `tfsdk:"user"` - Password types.String `tfsdk:"password"` + attributes.Addon + Host types.String `tfsdk:"host"` + Port types.Int64 `tfsdk:"port"` + User types.String `tfsdk:"user"` + Password types.String `tfsdk:"password"` } //go:embed doc.md @@ -29,25 +25,13 @@ func (r ResourceMongoDB) Schema(_ context.Context, req resource.SchemaRequest, r resp.Schema = schema.Schema{ Version: 0, MarkdownDescription: resourceMongoDBDoc, - Attributes: map[string]schema.Attribute{ + Attributes: attributes.WithAddonCommons(map[string]schema.Attribute{ // customer provided - "name": schema.StringAttribute{Required: true, MarkdownDescription: "Name of the service"}, - "plan": schema.StringAttribute{Required: true, MarkdownDescription: "Database size and spec"}, - "region": schema.StringAttribute{ - Optional: true, - Computed: true, - Default: stringdefault.StaticString("par"), - MarkdownDescription: "Geographical region where the data will be stored", - }, - - // provider - "id": schema.StringAttribute{Computed: true, MarkdownDescription: "Generated unique identifier"}, - "creation_date": schema.Int64Attribute{Computed: true, MarkdownDescription: "Date of database creation"}, - "host": schema.StringAttribute{Computed: true, MarkdownDescription: "Database host, used to connect to"}, - "port": schema.Int64Attribute{Computed: true, MarkdownDescription: "Database port"}, - "user": schema.StringAttribute{Computed: true, MarkdownDescription: "Login username"}, - "password": schema.StringAttribute{Computed: true, MarkdownDescription: "Login password"}, - }, + "host": schema.StringAttribute{Computed: true, MarkdownDescription: "Database host, used to connect to"}, + "port": schema.Int64Attribute{Computed: true, MarkdownDescription: "Database port"}, + "user": schema.StringAttribute{Computed: true, MarkdownDescription: "Login username"}, + "password": schema.StringAttribute{Computed: true, MarkdownDescription: "Login password"}, + }), } } diff --git a/pkg/resources/nodejs/schema.go b/pkg/resources/nodejs/schema.go index 8f25a2b..97695b7 100644 --- a/pkg/resources/nodejs/schema.go +++ b/pkg/resources/nodejs/schema.go @@ -14,30 +14,7 @@ import ( ) type NodeJS struct { - // Common - ID types.String `tfsdk:"id"` - Name types.String `tfsdk:"name"` - Description types.String `tfsdk:"description"` - MinInstanceCount types.Int64 `tfsdk:"min_instance_count"` - MaxInstanceCount types.Int64 `tfsdk:"max_instance_count"` - SmallestFlavor types.String `tfsdk:"smallest_flavor"` - BiggestFlavor types.String `tfsdk:"biggest_flavor"` - BuildFlavor types.String `tfsdk:"build_flavor"` - Region types.String `tfsdk:"region"` - StickySessions types.Bool `tfsdk:"sticky_sessions"` - RedirectHTTPS types.Bool `tfsdk:"redirect_https"` - VHost types.String `tfsdk:"vhost"` - AdditionalVHosts types.List `tfsdk:"additional_vhosts"` - DeployURL types.String `tfsdk:"deploy_url"` - Deployment *attributes.Deployment `tfsdk:"deployment"` - Hooks *attributes.Hooks `tfsdk:"hooks"` - Dependencies types.Set `tfsdk:"dependencies"` - - // Env - AppFolder types.String `tfsdk:"app_folder"` - Environment types.Map `tfsdk:"environment"` - - // Node + attributes.Runtime DevDependencies types.Bool `tfsdk:"dev_dependencies"` StartScript types.String `tfsdk:"start_script"` PackageManager types.String `tfsdk:"package_manager"` diff --git a/pkg/resources/php/schema.go b/pkg/resources/php/schema.go index 3ce31f6..58e42ea 100644 --- a/pkg/resources/php/schema.go +++ b/pkg/resources/php/schema.go @@ -14,29 +14,7 @@ import ( ) type PHP struct { - ID types.String `tfsdk:"id"` - Name types.String `tfsdk:"name"` - Description types.String `tfsdk:"description"` - MinInstanceCount types.Int64 `tfsdk:"min_instance_count"` - MaxInstanceCount types.Int64 `tfsdk:"max_instance_count"` - SmallestFlavor types.String `tfsdk:"smallest_flavor"` - BiggestFlavor types.String `tfsdk:"biggest_flavor"` - BuildFlavor types.String `tfsdk:"build_flavor"` - Region types.String `tfsdk:"region"` - StickySessions types.Bool `tfsdk:"sticky_sessions"` - RedirectHTTPS types.Bool `tfsdk:"redirect_https"` - VHost types.String `tfsdk:"vhost"` - AdditionalVHosts types.List `tfsdk:"additional_vhosts"` - DeployURL types.String `tfsdk:"deploy_url"` - Deployment *attributes.Deployment `tfsdk:"deployment"` - Hooks *attributes.Hooks `tfsdk:"hooks"` - Dependencies types.Set `tfsdk:"dependencies"` - - // Env - AppFolder types.String `tfsdk:"app_folder"` - Environment types.Map `tfsdk:"environment"` - - // PHP related + attributes.Runtime PHPVersion types.String `tfsdk:"php_version"` WebRoot types.String `tfsdk:"webroot"` RedisSessions types.Bool `tfsdk:"redis_sessions"` diff --git a/pkg/resources/postgresql/schema.go b/pkg/resources/postgresql/schema.go index 4f8bc82..690e7fa 100644 --- a/pkg/resources/postgresql/schema.go +++ b/pkg/resources/postgresql/schema.go @@ -6,21 +6,17 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" "github.com/hashicorp/terraform-plugin-framework/types" + "go.clever-cloud.com/terraform-provider/pkg/attributes" ) type PostgreSQL struct { - ID types.String `tfsdk:"id"` - Name types.String `tfsdk:"name"` - Plan types.String `tfsdk:"plan"` - Region types.String `tfsdk:"region"` - CreationDate types.Int64 `tfsdk:"creation_date"` - Host types.String `tfsdk:"host"` - Port types.Int64 `tfsdk:"port"` - Database types.String `tfsdk:"database"` - User types.String `tfsdk:"user"` - Password types.String `tfsdk:"password"` + attributes.Addon + Host types.String `tfsdk:"host"` + Port types.Int64 `tfsdk:"port"` + Database types.String `tfsdk:"database"` + User types.String `tfsdk:"user"` + Password types.String `tfsdk:"password"` } //go:embed doc.md @@ -30,26 +26,13 @@ func (r ResourcePostgreSQL) Schema(_ context.Context, req resource.SchemaRequest resp.Schema = schema.Schema{ Version: 0, MarkdownDescription: resourcePostgresqlDoc, - Attributes: map[string]schema.Attribute{ - // customer provided - "name": schema.StringAttribute{Required: true, MarkdownDescription: "Name of the service"}, - "plan": schema.StringAttribute{Required: true, MarkdownDescription: "Database size and spec"}, - "region": schema.StringAttribute{ - Optional: true, - Computed: true, - Default: stringdefault.StaticString("par"), - MarkdownDescription: "Geographical region where the data will be stored", - }, - - // provider - "id": schema.StringAttribute{Computed: true, MarkdownDescription: "Generated unique identifier"}, - "creation_date": schema.Int64Attribute{Computed: true, MarkdownDescription: "Date of database creation"}, - "host": schema.StringAttribute{Computed: true, MarkdownDescription: "Database host, used to connect to"}, - "port": schema.Int64Attribute{Computed: true, MarkdownDescription: "Database port"}, - "database": schema.StringAttribute{Computed: true, MarkdownDescription: "Database name on the PostgreSQL server"}, - "user": schema.StringAttribute{Computed: true, MarkdownDescription: "Login username"}, - "password": schema.StringAttribute{Computed: true, MarkdownDescription: "Login password"}, - }, + Attributes: attributes.WithAddonCommons(map[string]schema.Attribute{ + "host": schema.StringAttribute{Computed: true, MarkdownDescription: "Database host, used to connect to"}, + "port": schema.Int64Attribute{Computed: true, MarkdownDescription: "Database port"}, + "database": schema.StringAttribute{Computed: true, MarkdownDescription: "Database name on the PostgreSQL server"}, + "user": schema.StringAttribute{Computed: true, MarkdownDescription: "Login username"}, + "password": schema.StringAttribute{Computed: true, MarkdownDescription: "Login password"}, + }), } } diff --git a/pkg/resources/python/schema.go b/pkg/resources/python/schema.go index 576ab68..f7151b7 100644 --- a/pkg/resources/python/schema.go +++ b/pkg/resources/python/schema.go @@ -14,30 +14,7 @@ import ( ) type Python struct { - // Common - ID types.String `tfsdk:"id"` - Name types.String `tfsdk:"name"` - Description types.String `tfsdk:"description"` - MinInstanceCount types.Int64 `tfsdk:"min_instance_count"` - MaxInstanceCount types.Int64 `tfsdk:"max_instance_count"` - SmallestFlavor types.String `tfsdk:"smallest_flavor"` - BiggestFlavor types.String `tfsdk:"biggest_flavor"` - BuildFlavor types.String `tfsdk:"build_flavor"` - Region types.String `tfsdk:"region"` - StickySessions types.Bool `tfsdk:"sticky_sessions"` - RedirectHTTPS types.Bool `tfsdk:"redirect_https"` - VHost types.String `tfsdk:"vhost"` - AdditionalVHosts types.List `tfsdk:"additional_vhosts"` - DeployURL types.String `tfsdk:"deploy_url"` - Deployment *attributes.Deployment `tfsdk:"deployment"` - Hooks *attributes.Hooks `tfsdk:"hooks"` - Dependencies types.Set `tfsdk:"dependencies"` - - // Env - AppFolder types.String `tfsdk:"app_folder"` - Environment types.Map `tfsdk:"environment"` - - // Python + attributes.Runtime PythonVersion types.String `tfsdk:"python_version"` PipRequirements types.String `tfsdk:"pip_requirements"` } diff --git a/pkg/resources/scala/schema.go b/pkg/resources/scala/schema.go index 604d62f..2115acd 100644 --- a/pkg/resources/scala/schema.go +++ b/pkg/resources/scala/schema.go @@ -7,35 +7,13 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" "go.clever-cloud.com/terraform-provider/pkg" "go.clever-cloud.com/terraform-provider/pkg/application" "go.clever-cloud.com/terraform-provider/pkg/attributes" ) type Scala struct { - ID types.String `tfsdk:"id"` - Name types.String `tfsdk:"name"` - Description types.String `tfsdk:"description"` - MinInstanceCount types.Int64 `tfsdk:"min_instance_count"` - MaxInstanceCount types.Int64 `tfsdk:"max_instance_count"` - SmallestFlavor types.String `tfsdk:"smallest_flavor"` - BiggestFlavor types.String `tfsdk:"biggest_flavor"` - BuildFlavor types.String `tfsdk:"build_flavor"` - Region types.String `tfsdk:"region"` - StickySessions types.Bool `tfsdk:"sticky_sessions"` - RedirectHTTPS types.Bool `tfsdk:"redirect_https"` - VHost types.String `tfsdk:"vhost"` - AdditionalVHosts types.List `tfsdk:"additional_vhosts"` - DeployURL types.String `tfsdk:"deploy_url"` - Deployment *attributes.Deployment `tfsdk:"deployment"` - Hooks *attributes.Hooks `tfsdk:"hooks"` - Dependencies types.Set `tfsdk:"dependencies"` - - // Env - AppFolder types.String `tfsdk:"app_folder"` - Environment types.Map `tfsdk:"environment"` - + attributes.Runtime // Scala related } diff --git a/pkg/resources/static/schema.go b/pkg/resources/static/schema.go index 7aabd10..8d35ca8 100644 --- a/pkg/resources/static/schema.go +++ b/pkg/resources/static/schema.go @@ -7,36 +7,14 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" "go.clever-cloud.com/terraform-provider/pkg" "go.clever-cloud.com/terraform-provider/pkg/application" "go.clever-cloud.com/terraform-provider/pkg/attributes" ) type Static struct { - ID types.String `tfsdk:"id"` - Name types.String `tfsdk:"name"` - Description types.String `tfsdk:"description"` - MinInstanceCount types.Int64 `tfsdk:"min_instance_count"` - MaxInstanceCount types.Int64 `tfsdk:"max_instance_count"` - SmallestFlavor types.String `tfsdk:"smallest_flavor"` - BiggestFlavor types.String `tfsdk:"biggest_flavor"` - BuildFlavor types.String `tfsdk:"build_flavor"` - Region types.String `tfsdk:"region"` - StickySessions types.Bool `tfsdk:"sticky_sessions"` - RedirectHTTPS types.Bool `tfsdk:"redirect_https"` - VHost types.String `tfsdk:"vhost"` - AdditionalVHosts types.List `tfsdk:"additional_vhosts"` - DeployURL types.String `tfsdk:"deploy_url"` - Deployment *attributes.Deployment `tfsdk:"deployment"` - Hooks *attributes.Hooks `tfsdk:"hooks"` - Dependencies types.Set `tfsdk:"dependencies"` - - // Env - AppFolder types.String `tfsdk:"app_folder"` - Environment types.Map `tfsdk:"environment"` - - // Scala related + attributes.Runtime + // Static related } //go:embed doc.md