Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/mongodb #73

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,7 @@ 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 app will be deployed
- `region` (String) Geographical region where the database will be deployed
miton18 marked this conversation as resolved.
Show resolved Hide resolved
- `smallest_flavor` (String) Smallest instance flavor

### Optional
Expand Down
1 change: 1 addition & 0 deletions docs/resources/materia_kv.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Manage Materia KV databases
### Required

- `name` (String) Name of the service
- `region` (String) Geographical region where the data will be stored

### Read-Only

Expand Down
1 change: 1 addition & 0 deletions docs/resources/mongodb.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ See [product specification](https://www.clever-cloud.com/fr/product/mongodb/).

- `name` (String) Name of the service
- `plan` (String) Database size and spec
- `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,7 @@ 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 app will be deployed
- `region` (String) Geographical region where the database will be deployed
- `smallest_flavor` (String) Smallest instance flavor

### Optional
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,7 @@ 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 app will be deployed
- `region` (String) Geographical region where the database will be deployed
- `smallest_flavor` (String) Smallest instance flavor

### Optional
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ resource "clevercloud_postgresql" "postgresql_database" {

- `name` (String) Name of the service
- `plan` (String) Database size and spec
- `region` (String) Geographical region where the database will be deployed
- `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,7 @@ 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 app will be deployed
- `region` (String) Geographical region where the database will be deployed
- `smallest_flavor` (String) Smallest instance flavor

### Optional
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,7 @@ 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 app will be deployed
- `region` (String) Geographical region where the database will be deployed
- `smallest_flavor` (String) Smallest instance flavor

### Optional
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,7 @@ 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 app will be deployed
- `region` (String) Geographical region where the database will be deployed
- `smallest_flavor` (String) Smallest instance flavor

### Optional
Expand Down
5 changes: 3 additions & 2 deletions pkg/attributes/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ var runtimeCommon = map[string]schema.Attribute{
MarkdownDescription: "Use dedicated instance with given flavor for build step",
},
"region": schema.StringAttribute{
Required: true,
MarkdownDescription: "Geographical region where the app will be deployed",
Required: true,
// Default: stringdefault.StaticString("par"), // TODO default value must be computed before apply
MarkdownDescription: "Geographical region where the database will be deployed",
},
"sticky_sessions": schema.BoolAttribute{
Optional: true,
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/addon/resource_addon_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (r ResourceAddon) Schema(_ context.Context, req resource.SchemaRequest, res
// 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)"},
"region": schema.StringAttribute{Required: true, MarkdownDescription: "Geographical region where the addon will be deployed (when relevant)"}, //TODO , Default: stringdefault.StaticString("par")},
"third_party_provider": schema.StringAttribute{Required: true, MarkdownDescription: "Provider ID"},

// provider
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/cellar/resource_cellar_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (r ResourceCellar) Schema(_ context.Context, req resource.SchemaRequest, re
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"},
"region": schema.StringAttribute{Required: true, MarkdownDescription: "Geographical region where the data will be stored"}, // TODO, Default: stringdefault.StaticString("par")},

// provider
"id": schema.StringAttribute{Computed: true, MarkdownDescription: "Generated unique identifier"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/materiakv/resource_materiakv_crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (r *ResourceMateriaKV) Create(ctx context.Context, req resource.CreateReque
Name: kv.Name.ValueString(),
Plan: plan.ID,
ProviderID: "kv",
Region: "par",
Region: kv.Region.ValueString(),
}

res := tmp.CreateAddon(ctx, r.cc, r.org, addonReq)
Expand Down
4 changes: 3 additions & 1 deletion pkg/resources/materiakv/resource_materiakv_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type MateriaKV struct {
CreationDate types.Int64 `tfsdk:"creation_date"`
Host types.String `tfsdk:"host"`
Port types.Int64 `tfsdk:"port"`
Region types.String `tfsdk:"region"`
Token types.String `tfsdk:"token"`
}

Expand All @@ -27,7 +28,8 @@ 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"},
"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")},
// provider
"id": schema.StringAttribute{Computed: true, MarkdownDescription: "Generated unique identifier"},
"creation_date": schema.Int64Attribute{Computed: true, MarkdownDescription: "Date of database creation"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/materiakv/resource_materiakv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestAccMateriaKV_basic(t *testing.T) {
cc := client.New(client.WithAutoOauthConfig())
org := os.Getenv("ORGANISATION")
providerBlock := helper.NewProvider("clevercloud").SetOrganisation(org).String()
materiakvBlock := helper.NewRessource("clevercloud_materia_kv", rName).SetOneValue("name", rName).String()
materiakvBlock := helper.NewRessource("clevercloud_materia_kv", rName, helper.SetKeyValues(map[string]any{"name": rName, "region": "par"})).String()

resource.Test(t, resource.TestCase{
PreCheck: func() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/mongodb/resource_mongodb_crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (r *ResourceMongoDB) Create(ctx context.Context, req resource.CreateRequest
Name: mg.Name.ValueString(),
Plan: plan.ID,
ProviderID: "mongodb-addon",
Region: "par",
Region: mg.Region.ValueString(),
}

res := tmp.CreateAddon(ctx, r.cc, r.org, addonReq)
Expand Down
6 changes: 4 additions & 2 deletions pkg/resources/mongodb/resource_mongodb_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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"`
Expand All @@ -29,8 +30,9 @@ 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"},
"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")},

// provider
"id": schema.StringAttribute{Computed: true, MarkdownDescription: "Generated unique identifier"},
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/mongodb/resource_mongodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestAccMongoDB_basic(t *testing.T) {
cc := client.New(client.WithAutoOauthConfig())
org := os.Getenv("ORGANISATION")
providerBlock := helper.NewProvider("clevercloud").SetOrganisation(org).String()
mongodbBlock := helper.NewRessource("clevercloud_mongodb", rName, helper.SetKeyValues(map[string]any{"name": rName, "plan": "dev"})).String()
mongodbBlock := helper.NewRessource("clevercloud_mongodb", rName, helper.SetKeyValues(map[string]any{"name": rName, "plan": "dev", "region": "par"})).String()

resource.Test(t, resource.TestCase{
PreCheck: func() {
Expand Down Expand Up @@ -71,7 +71,7 @@ func TestAccMongoDB_RefreshDeleted(t *testing.T) {
cc := client.New(client.WithAutoOauthConfig())
org := os.Getenv("ORGANISATION")
providerBlock := helper.NewProvider("clevercloud").SetOrganisation(org).String()
mongodbBlock2 := helper.NewRessource("clevercloud_mongodb", rName, helper.SetKeyValues(map[string]any{"name": rName, "plan": "dev"})).String()
mongodbBlock2 := helper.NewRessource("clevercloud_mongodb", rName, helper.SetKeyValues(map[string]any{"name": rName, "plan": "dev", "region": "par"})).String()

resource.Test(t, resource.TestCase{
PreCheck: func() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/postgresql/resource_postgresql_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (r ResourcePostgreSQL) Schema(_ context.Context, req resource.SchemaRequest
// 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 database will be deployed"},
"region": schema.StringAttribute{Required: true, MarkdownDescription: "Geographical region where the data will be stored"}, // TODO, Default: stringdefault.StaticString("par")},

// provider
"id": schema.StringAttribute{Computed: true, MarkdownDescription: "Generated unique identifier"},
Expand Down
Loading