Skip to content

Commit

Permalink
feat: set par as default regions
Browse files Browse the repository at this point in the history
  • Loading branch information
miton18 committed Jun 10, 2024
1 parent 5cd6764 commit 44be597
Show file tree
Hide file tree
Showing 19 changed files with 75 additions and 23 deletions.
5 changes: 4 additions & 1 deletion docs/resources/addon.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ List of available providers:

- `name` (String) Name of the addon
- `plan` (String) billing plan
- `region` (String) Geographical region where the addon will be deployed (when relevant)
- `third_party_provider` (String) Provider ID

### Optional

- `region` (String) Geographical region where the addon will be deployed (when relevant)

### Read-Only

- `configurations` (Map of String, Sensitive) Any configuration exposed by the addon
Expand Down
3 changes: 3 additions & 0 deletions docs/resources/cellar.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ See [product specification](https://www.clever-cloud.com/doc/deploy/addon/cellar
### Required

- `name` (String) Name of the Cellar

### Optional

- `region` (String) Geographical region where the data will be stored

### Read-Only
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/java_war.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ resource "clevercloud_java_war" "myapp" {
- `max_instance_count` (Number) Maximum instance count, if different from min value, enable autoscaling
- `min_instance_count` (Number) Minimum instance count
- `name` (String) Application name
- `region` (String) Geographical region where the database will be deployed
- `smallest_flavor` (String) Smallest instance flavor

### Optional
Expand All @@ -102,6 +101,7 @@ Can be either app_xxx or postgres_yyy ID format
- `hooks` (Block, Optional) (see [below for nested schema](#nestedblock--hooks))
- `java_version` (String) Choose the JVM version between 7 to 17 for OpenJDK or graalvm-ce for GraalVM 21.0.0.2 (based on OpenJDK 11.0).
- `redirect_https` (Boolean) Redirect client from plain to TLS port
- `region` (String) Geographical region where the database will be deployed
- `sticky_sessions` (Boolean) Enable sticky sessions, use it when your client sessions are instances scoped

### Read-Only
Expand Down
3 changes: 3 additions & 0 deletions docs/resources/materia_kv.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Manage Materia KV databases
### Required

- `name` (String) Name of the service

### Optional

- `region` (String) Geographical region where the data will be stored

### Read-Only
Expand Down
3 changes: 3 additions & 0 deletions docs/resources/mongodb.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ See [product specification](https://www.clever-cloud.com/fr/product/mongodb/).

- `name` (String) Name of the service
- `plan` (String) Database size and spec

### Optional

- `region` (String) Geographical region where the data will be stored

### Read-Only
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/nodejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ resource "clevercloud_nodejs" "myapp" {
- `max_instance_count` (Number) Maximum instance count, if different from min value, enable autoscaling
- `min_instance_count` (Number) Minimum instance count
- `name` (String) Application name
- `region` (String) Geographical region where the database will be deployed
- `smallest_flavor` (String) Smallest instance flavor

### Optional
Expand All @@ -103,6 +102,7 @@ Can be either app_xxx or postgres_yyy ID format
- `hooks` (Block, Optional) (see [below for nested schema](#nestedblock--hooks))
- `package_manager` (String) Either npm, npm-ci, yarn, yarn2 or custom
- `redirect_https` (Boolean) Redirect client from plain to TLS port
- `region` (String) Geographical region where the database will be deployed
- `registry` (String) The host of your private repository, available values: github or the registry host
- `registry_token` (String, Sensitive) Private repository token
- `start_script` (String) Set custom start script, instead of `npm start`
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/php.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ See [PHP product](https://www.clever-cloud.com/doc/getting-started/by-language/p
- `max_instance_count` (Number) Maximum instance count, if different from min value, enable autoscaling
- `min_instance_count` (Number) Minimum instance count
- `name` (String) Application name
- `region` (String) Geographical region where the database will be deployed
- `smallest_flavor` (String) Smallest instance flavor

### Optional
Expand All @@ -42,6 +41,7 @@ Can be either app_xxx or postgres_yyy ID format
- `php_version` (String) PHP version (Default: 8)
- `redirect_https` (Boolean) Redirect client from plain to TLS port
- `redis_sessions` (Boolean) Use a linked Redis instance to store sessions (Default: false)
- `region` (String) Geographical region where the database will be deployed
- `sticky_sessions` (Boolean) Enable sticky sessions, use it when your client sessions are instances scoped
- `webroot` (String) Define the DocumentRoot of your project (default: ".")

Expand Down
3 changes: 3 additions & 0 deletions docs/resources/postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ resource "clevercloud_postgresql" "postgresql_database" {

- `name` (String) Name of the service
- `plan` (String) Database size and spec

### Optional

- `region` (String) Geographical region where the data will be stored

### Read-Only
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ resource "clevercloud_python" "myapp" {
- `max_instance_count` (Number) Maximum instance count, if different from min value, enable autoscaling
- `min_instance_count` (Number) Minimum instance count
- `name` (String) Application name
- `region` (String) Geographical region where the database will be deployed
- `smallest_flavor` (String) Smallest instance flavor

### Optional
Expand All @@ -103,6 +102,7 @@ Can be either app_xxx or postgres_yyy ID format
- `pip_requirements` (String) Define a custom requirements.txt file (default: requirements.txt)
- `python_version` (String) Python version >= 2.7
- `redirect_https` (Boolean) Redirect client from plain to TLS port
- `region` (String) Geographical region where the database will be deployed
- `sticky_sessions` (Boolean) Enable sticky sessions, use it when your client sessions are instances scoped

### Read-Only
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/scala.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ resource "clevercloud_scala" "myapp" {
- `max_instance_count` (Number) Maximum instance count, if different from min value, enable autoscaling
- `min_instance_count` (Number) Minimum instance count
- `name` (String) Application name
- `region` (String) Geographical region where the database will be deployed
- `smallest_flavor` (String) Smallest instance flavor

### Optional
Expand All @@ -101,6 +100,7 @@ Can be either app_xxx or postgres_yyy ID format
- `environment` (Map of String, Sensitive) Environment variables injected into the application
- `hooks` (Block, Optional) (see [below for nested schema](#nestedblock--hooks))
- `redirect_https` (Boolean) Redirect client from plain to TLS port
- `region` (String) Geographical region where the database will be deployed
- `sticky_sessions` (Boolean) Enable sticky sessions, use it when your client sessions are instances scoped

### Read-Only
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/static.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ resource "clevercloud_static" "myapp" {
- `max_instance_count` (Number) Maximum instance count, if different from min value, enable autoscaling
- `min_instance_count` (Number) Minimum instance count
- `name` (String) Application name
- `region` (String) Geographical region where the database will be deployed
- `smallest_flavor` (String) Smallest instance flavor

### Optional
Expand All @@ -101,6 +100,7 @@ Can be either app_xxx or postgres_yyy ID format
- `environment` (Map of String, Sensitive) Environment variables injected into the application
- `hooks` (Block, Optional) (see [below for nested schema](#nestedblock--hooks))
- `redirect_https` (Boolean) Redirect client from plain to TLS port
- `region` (String) Geographical region where the database will be deployed
- `sticky_sessions` (Boolean) Enable sticky sessions, use it when your client sessions are instances scoped

### Read-Only
Expand Down
3 changes: 2 additions & 1 deletion pkg/application/creation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package application

import (
"context"
"fmt"

"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-log/tflog"
Expand Down Expand Up @@ -39,7 +40,7 @@ func CreateApp(ctx context.Context, req CreateReq) (*CreateRes, diag.Diagnostics
appRes := tmp.CreateApp(ctx, req.Client, req.Organization, req.Application)
if appRes.HasError() {
diags.AddError("failed to create application", appRes.Error().Error())
tflog.Error(ctx, "failed to create app", map[string]interface{}{"error": appRes.Error().Error()})
tflog.Error(ctx, "failed to create app", map[string]interface{}{"error": appRes.Error().Error(), "payload": fmt.Sprintf("%+v", req.Application)})
return nil, diags
}

Expand Down
7 changes: 5 additions & 2 deletions pkg/attributes/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (

"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"

"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
"github.com/hashicorp/terraform-plugin-framework/types"
"go.clever-cloud.com/terraform-provider/pkg"
)
Expand Down Expand Up @@ -44,8 +46,9 @@ var runtimeCommon = map[string]schema.Attribute{
MarkdownDescription: "Use dedicated instance with given flavor for build step",
},
"region": schema.StringAttribute{
Required: true,
// Default: stringdefault.StaticString("par"), // TODO default value must be computed before apply
Optional: true,
Computed: true,
Default: stringdefault.StaticString("par"),
MarkdownDescription: "Geographical region where the database will be deployed",
},
"sticky_sessions": schema.BoolAttribute{
Expand Down
12 changes: 9 additions & 3 deletions pkg/resources/addon/resource_addon_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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"
)

Expand All @@ -28,9 +29,14 @@ func (r ResourceAddon) Schema(_ context.Context, req resource.SchemaRequest, res
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{Required: true, MarkdownDescription: "Geographical region where the addon will be deployed (when relevant)"}, //TODO , Default: stringdefault.StaticString("par")},
"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)",
},
"third_party_provider": schema.StringAttribute{Required: true, MarkdownDescription: "Provider ID"},

// provider
Expand Down
10 changes: 8 additions & 2 deletions pkg/resources/cellar/resource_cellar_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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"
)

Expand All @@ -29,8 +30,13 @@ func (r ResourceCellar) Schema(_ context.Context, req resource.SchemaRequest, re
MarkdownDescription: resourceCellarDoc,
Attributes: map[string]schema.Attribute{
// customer provided
"name": schema.StringAttribute{Required: true, MarkdownDescription: "Name of the Cellar"},
"region": schema.StringAttribute{Required: true, MarkdownDescription: "Geographical region where the data will be stored"}, // TODO, Default: stringdefault.StaticString("par")},
"name": schema.StringAttribute{Required: true, MarkdownDescription: "Name of the Cellar"},
"region": schema.StringAttribute{
Optional: true,
Computed: true,
MarkdownDescription: "Geographical region where the data will be stored",
Default: stringdefault.StaticString("par"),
},

// provider
"id": schema.StringAttribute{Computed: true, MarkdownDescription: "Generated unique identifier"},
Expand Down
10 changes: 8 additions & 2 deletions pkg/resources/materiakv/resource_materiakv_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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"
)

Expand All @@ -28,8 +29,13 @@ func (r ResourceMateriaKV) Schema(_ context.Context, req resource.SchemaRequest,
MarkdownDescription: resourceMateriaKVDoc,
Attributes: map[string]schema.Attribute{
// customer provided
"name": schema.StringAttribute{Required: true, MarkdownDescription: "Name of the service"},
"region": schema.StringAttribute{Required: true, MarkdownDescription: "Geographical region where the data will be stored"}, // TODO, Default: stringdefault.StaticString("par")},
"name": schema.StringAttribute{Required: true, MarkdownDescription: "Name of the service"},
"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"},
Expand Down
12 changes: 9 additions & 3 deletions pkg/resources/mongodb/resource_mongodb_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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"
)

Expand All @@ -30,9 +31,14 @@ func (r ResourceMongoDB) Schema(_ context.Context, req resource.SchemaRequest, r
MarkdownDescription: resourceMongoDBDoc,
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{Required: true, MarkdownDescription: "Geographical region where the data will be stored"}, // TODO, Default: stringdefault.StaticString("par")},
"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"},
Expand Down
3 changes: 3 additions & 0 deletions pkg/resources/nodejs/resource_nodejs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ func TestAccNodejs_basic(t *testing.T) {
if !app.StickySessions {
return assertError("expect option to be set", "sticky_sessions", app.StickySessions)
}
if app.Zone != "par" {
return assertError("expect region to be 'par'", "region", app.Zone)
}

appEnvRes := tmp.GetAppEnv(ctx, cc, org, id)
if appEnvRes.HasError() {
Expand Down
12 changes: 9 additions & 3 deletions pkg/resources/postgresql/resource_postgresql_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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"
)

Expand All @@ -31,9 +32,14 @@ func (r ResourcePostgreSQL) Schema(_ context.Context, req resource.SchemaRequest
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{Required: true, MarkdownDescription: "Geographical region where the data will be stored"}, // TODO, Default: stringdefault.StaticString("par")},
"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"},
Expand Down

0 comments on commit 44be597

Please sign in to comment.