Skip to content

Commit 4c5fbcc

Browse files
committed
review fix + remove deadcode and availibility + doc
1 parent f528c6f commit 4c5fbcc

18 files changed

+46
-281
lines changed

ovh/data_cloud_project_database.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func dataSourceCloudProjectDatabase() *schema.Resource {
100100
},
101101
"kafka_rest_api": {
102102
Type: schema.TypeBool,
103-
Description: "Defines whether the REST API is enabled on a kafka cluster",
103+
Description: "Defines whether the REST API is enabled on a Kafka cluster",
104104
Computed: true,
105105
},
106106
"maintenance_time": {
@@ -139,7 +139,7 @@ func dataSourceCloudProjectDatabase() *schema.Resource {
139139
},
140140
"opensearch_acls_enabled": {
141141
Type: schema.TypeBool,
142-
Description: "Defines whether the acls are enabled on an Opensearch cluster",
142+
Description: "Defines whether the ACLs are enabled on an Opensearch cluster",
143143
Computed: true,
144144
},
145145
"plan": {

ovh/data_cloud_project_database_capabilities.go

-106
Original file line numberDiff line numberDiff line change
@@ -128,100 +128,6 @@ func dataSourceCloudProjectDatabaseCapabilities() *schema.Resource {
128128
},
129129
},
130130
},
131-
"availability": {
132-
Type: schema.TypeSet,
133-
Description: "Availability of databases engines on cloud projects",
134-
Computed: true,
135-
Elem: &schema.Resource{
136-
Schema: map[string]*schema.Schema{
137-
"backup": {
138-
Type: schema.TypeString,
139-
Description: "Defines the type of backup",
140-
Computed: true,
141-
},
142-
"default": {
143-
Type: schema.TypeBool,
144-
Description: "Whether this availability can be used by default",
145-
Computed: true,
146-
},
147-
"end_of_life": {
148-
Type: schema.TypeString,
149-
Description: "End of life of the product",
150-
Computed: true,
151-
},
152-
"engine": {
153-
Type: schema.TypeString,
154-
Description: "Database engine name",
155-
Computed: true,
156-
},
157-
"flavor": {
158-
Type: schema.TypeString,
159-
Description: "Flavor name",
160-
Computed: true,
161-
},
162-
"max_disk_size": {
163-
Type: schema.TypeInt,
164-
Description: "Maximum possible disk size in GB",
165-
Computed: true,
166-
},
167-
"max_node_number": {
168-
Type: schema.TypeInt,
169-
Description: "Maximum nodes of the cluster",
170-
Computed: true,
171-
},
172-
"min_disk_size": {
173-
Type: schema.TypeInt,
174-
Description: "Minimum possible disk size in GB",
175-
Computed: true,
176-
},
177-
"min_node_number": {
178-
Type: schema.TypeInt,
179-
Description: "Minimum nodes of the cluster",
180-
Computed: true,
181-
},
182-
"network": {
183-
Type: schema.TypeString,
184-
Description: "Type of network",
185-
Computed: true,
186-
},
187-
"plan": {
188-
Type: schema.TypeString,
189-
Description: "Plan name",
190-
Computed: true,
191-
},
192-
"region": {
193-
Type: schema.TypeString,
194-
Description: "Region name",
195-
Computed: true,
196-
},
197-
"start_date": {
198-
Type: schema.TypeString,
199-
Description: "Date of the release of the product",
200-
Computed: true,
201-
},
202-
"status": {
203-
Type: schema.TypeString,
204-
Description: "Status of the availability",
205-
Computed: true,
206-
},
207-
"step_disk_size": {
208-
Type: schema.TypeInt,
209-
Description: "Flex disk size step in GB",
210-
Computed: true,
211-
},
212-
"upstream_end_of_life": {
213-
Type: schema.TypeString,
214-
Description: "End of life of the upstream product",
215-
Computed: true,
216-
},
217-
"version": {
218-
Type: schema.TypeString,
219-
Description: "Version name",
220-
Computed: true,
221-
},
222-
},
223-
},
224-
},
225131
},
226132
}
227133
}
@@ -240,18 +146,6 @@ func dataSourceCloudProjectDatabaseCapabilitiesRead(d *schema.ResourceData, meta
240146
return helpers.CheckDeleted(d, err, capabilitiesEndpoint)
241147
}
242148

243-
availabilityEndpoint := fmt.Sprintf("/cloud/project/%s/database/availability",
244-
url.PathEscape(serviceName),
245-
)
246-
availabilityRes := make([]CloudProjectDatabaseAvailability, 0)
247-
248-
log.Printf("[DEBUG] Will read availability from project %s", serviceName)
249-
if err := config.OVHClient.Get(availabilityEndpoint, &availabilityRes); err != nil {
250-
return helpers.CheckDeleted(d, err, availabilityEndpoint)
251-
}
252-
253-
capabilitiesRes.Availability = availabilityRes
254-
255149
d.SetId(serviceName)
256150
for k, v := range capabilitiesRes.ToMap() {
257151
d.Set(k, v)

ovh/data_cloud_project_database_capabilities_test.go

-64
Original file line numberDiff line numberDiff line change
@@ -101,70 +101,6 @@ func TestAccCloudProjectDatabaseCapabilitiesDataSource_basic(t *testing.T) {
101101
"data.ovh_cloud_project_database_capabilities.capabilities",
102102
"plans.0.name",
103103
),
104-
resource.TestCheckResourceAttrSet(
105-
"data.ovh_cloud_project_database_capabilities.capabilities",
106-
"availability.#",
107-
),
108-
resource.TestCheckResourceAttrSet(
109-
"data.ovh_cloud_project_database_capabilities.capabilities",
110-
"availability.0.backup",
111-
),
112-
resource.TestCheckResourceAttrSet(
113-
"data.ovh_cloud_project_database_capabilities.capabilities",
114-
"availability.0.default",
115-
),
116-
resource.TestCheckResourceAttrSet(
117-
"data.ovh_cloud_project_database_capabilities.capabilities",
118-
"availability.0.engine",
119-
),
120-
resource.TestCheckResourceAttrSet(
121-
"data.ovh_cloud_project_database_capabilities.capabilities",
122-
"availability.0.flavor",
123-
),
124-
resource.TestCheckResourceAttrSet(
125-
"data.ovh_cloud_project_database_capabilities.capabilities",
126-
"availability.0.max_disk_size",
127-
),
128-
resource.TestCheckResourceAttrSet(
129-
"data.ovh_cloud_project_database_capabilities.capabilities",
130-
"availability.0.max_node_number",
131-
),
132-
resource.TestCheckResourceAttrSet(
133-
"data.ovh_cloud_project_database_capabilities.capabilities",
134-
"availability.0.min_disk_size",
135-
),
136-
resource.TestCheckResourceAttrSet(
137-
"data.ovh_cloud_project_database_capabilities.capabilities",
138-
"availability.0.min_node_number",
139-
),
140-
resource.TestCheckResourceAttrSet(
141-
"data.ovh_cloud_project_database_capabilities.capabilities",
142-
"availability.0.network",
143-
),
144-
resource.TestCheckResourceAttrSet(
145-
"data.ovh_cloud_project_database_capabilities.capabilities",
146-
"availability.0.plan",
147-
),
148-
resource.TestCheckResourceAttrSet(
149-
"data.ovh_cloud_project_database_capabilities.capabilities",
150-
"availability.0.region",
151-
),
152-
resource.TestCheckResourceAttrSet(
153-
"data.ovh_cloud_project_database_capabilities.capabilities",
154-
"availability.0.start_date",
155-
),
156-
resource.TestCheckResourceAttrSet(
157-
"data.ovh_cloud_project_database_capabilities.capabilities",
158-
"availability.0.status",
159-
),
160-
resource.TestCheckResourceAttrSet(
161-
"data.ovh_cloud_project_database_capabilities.capabilities",
162-
"availability.0.step_disk_size",
163-
),
164-
resource.TestCheckResourceAttrSet(
165-
"data.ovh_cloud_project_database_capabilities.capabilities",
166-
"availability.0.version",
167-
),
168104
),
169105
},
170106
},

ovh/data_cloud_project_database_user.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func dataSourceCloudProjectDatabaseUser() *schema.Resource {
2222
Type: schema.TypeString,
2323
Description: "Name of the engine of the service",
2424
Required: true,
25-
ValidateFunc: helpers.ValidateEnum([]string{"cassandra", "mysql", "kafka", "kafkaConnect"}), //validateCloudProjectDatabaseUserEngineFunc,
25+
ValidateFunc: helpers.ValidateEnum([]string{"cassandra", "mysql", "kafka", "kafkaConnect"}),
2626
},
2727
"cluster_id": {
2828
Type: schema.TypeString,

ovh/resource_cloud_project_database.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func resourceCloudProjectDatabase() *schema.Resource {
5353
},
5454
"kafka_rest_api": {
5555
Type: schema.TypeBool,
56-
Description: "Defines whether the REST API is enabled on a kafka cluster",
56+
Description: "Defines whether the REST API is enabled on a Kafka cluster",
5757
Optional: true,
5858
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
5959
return d.Get("engine").(string) != "kafka" || new == old
@@ -88,7 +88,7 @@ func resourceCloudProjectDatabase() *schema.Resource {
8888
},
8989
"opensearch_acls_enabled": {
9090
Type: schema.TypeBool,
91-
Description: "Defines whether the acls are enabled on an Opensearch cluster",
91+
Description: "Defines whether the ACLs are enabled on an Opensearch cluster",
9292
Optional: true,
9393
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
9494
return d.Get("engine").(string) != "opensearch" || new == old

ovh/resource_cloud_project_database_user.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func resourceCloudProjectDatabaseUser() *schema.Resource {
3838
Description: "Name of the engine of the service",
3939
ForceNew: true,
4040
Required: true,
41-
ValidateFunc: helpers.ValidateEnum([]string{"cassandra", "mysql", "kafka", "kafkaConnect"}), //validateCloudProjectDatabaseUserEngineFunc,
41+
ValidateFunc: helpers.ValidateEnum([]string{"cassandra", "mysql", "kafka", "kafkaConnect"}),
4242
},
4343
"cluster_id": {
4444
Type: schema.TypeString,

ovh/types_cloud_project_database.go

+5-53
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func (opts *CloudProjectDatabaseUpdateOpts) FromResource(d *schema.ResourceData)
181181
opts.AclsEnabled = d.Get("opensearch_acls_enabled").(bool)
182182
}
183183
if engine == "kafka" {
184-
opts.AclsEnabled = d.Get("kafka_rest_api").(bool)
184+
opts.RestApi = d.Get("kafka_rest_api").(bool)
185185
}
186186

187187
opts.Description = d.Get("description").(string)
@@ -340,54 +340,11 @@ func (v CloudProjectDatabaseCapabilitiesPlan) ToMap() map[string]interface{} {
340340
return obj
341341
}
342342

343-
type CloudProjectDatabaseAvailability struct {
344-
Backup string `json:"backup"`
345-
Default bool `json:"default"`
346-
EndOfLife string `json:"endOfLife"`
347-
Engine string `json:"engine"`
348-
Flavor string `json:"flavor"`
349-
MaxDiskSize int `json:"maxDiskSize"`
350-
MaxNodeNumber int `json:"maxNodeNumber"`
351-
MinDiskSize int `json:"minDiskSize"`
352-
MinNodeNumber int `json:"minNodeNumber"`
353-
Network string `json:"network"`
354-
Plan string `json:"plan"`
355-
Region string `json:"region"`
356-
StartDate string `json:"startDate"`
357-
Status string `json:"status"`
358-
StepDiskSize int `json:"stepDiskSize"`
359-
UpstreamEndOfLife string `json:"upstreamEndOfLife"`
360-
Version string `json:"version"`
361-
}
362-
363-
func (v CloudProjectDatabaseAvailability) ToMap() map[string]interface{} {
364-
obj := make(map[string]interface{})
365-
obj["backup"] = v.Backup
366-
obj["default"] = v.Default
367-
obj["end_of_life"] = v.EndOfLife
368-
obj["engine"] = v.Engine
369-
obj["flavor"] = v.Flavor
370-
obj["max_disk_size"] = v.MaxDiskSize
371-
obj["max_node_number"] = v.MaxNodeNumber
372-
obj["min_disk_size"] = v.MinDiskSize
373-
obj["min_node_number"] = v.MinNodeNumber
374-
obj["network"] = v.Network
375-
obj["plan"] = v.Plan
376-
obj["region"] = v.Region
377-
obj["start_date"] = v.StartDate
378-
obj["status"] = v.Status
379-
obj["step_disk_size"] = v.StepDiskSize
380-
obj["upstream_end_of_life"] = v.UpstreamEndOfLife
381-
obj["version"] = v.Version
382-
return obj
383-
}
384-
385343
type CloudProjectDatabaseCapabilitiesResponse struct {
386-
Engines []CloudProjectDatabaseCapabilitiesEngine `json:"engines"`
387-
Flavors []CloudProjectDatabaseCapabilitiesFlavor `json:"flavors"`
388-
Options []CloudProjectDatabaseCapabilitiesOption `json:"options"`
389-
Plans []CloudProjectDatabaseCapabilitiesPlan `json:"plans"`
390-
Availability []CloudProjectDatabaseAvailability
344+
Engines []CloudProjectDatabaseCapabilitiesEngine `json:"engines"`
345+
Flavors []CloudProjectDatabaseCapabilitiesFlavor `json:"flavors"`
346+
Options []CloudProjectDatabaseCapabilitiesOption `json:"options"`
347+
Plans []CloudProjectDatabaseCapabilitiesPlan `json:"plans"`
391348
}
392349

393350
func (v CloudProjectDatabaseCapabilitiesResponse) ToMap() map[string]interface{} {
@@ -416,11 +373,6 @@ func (v CloudProjectDatabaseCapabilitiesResponse) ToMap() map[string]interface{}
416373
}
417374
obj["plans"] = plans
418375

419-
var availability []map[string]interface{}
420-
for _, e := range v.Availability {
421-
availability = append(availability, e.ToMap())
422-
}
423-
obj["availability"] = availability
424376
return obj
425377
}
426378

website/docs/d/cloud_project_database_capabilities.html.markdown

+2-20
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ data "ovh_cloud_project_database_capabilities" "capabilities" {
1818
}
1919
2020
output "capabilities_engine_name" {
21-
value = data.ovh_cloud_project_database_capabilities.capabilities.engine.0.name
21+
value = tolist(data.ovh_cloud_project_database_capabilities.capabilities[*].engines)[0]
2222
}
2323
```
2424

@@ -34,25 +34,7 @@ The following attributes are exported:
3434
`id` is set to `service_name` value. In addition,
3535
the following attributes are exported:
3636

37-
* `availability` - Availability of databases engines on cloud projects.
38-
* `backup` - Defines the type of backup.
39-
* `default` - Whether this availability can be used by default.
40-
* `end_of_life` - End of life of the product.
41-
* `engine` - Database engine name.
42-
* `flavor` - Flavor name.
43-
* `max_disk_size` - Maximum possible disk size in GB.
44-
* `max_node_number` - Maximum nodes of the cluster.
45-
* `min_disk_size` - Minimum possible disk size in GB.
46-
* `min_node_number` - Minimum nodes of the cluster.
47-
* `network` - Type of network.
48-
* `plan` - Plan name.
49-
* `region` - Region name.
50-
* `start_date` - Date of the release of the product.
51-
* `status` - Status of the availability.
52-
* `step_disk_size` - Flex disk size step in GB.
53-
* `upstream_end_of_life` - End of life of the upstream product.
54-
* `version` - Version name.
55-
* `engine` - Database engines available.
37+
* `engines` - Database engines available.
5638
* `default_version` - Default version used for the engine.
5739
* `description` - Description of the engine.
5840
* `name` - Engine name.

website/docs/d/cloud_project_database_database.html.markdown

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Use this data source to get information about a database of a database cluster a
1515
```hcl
1616
data "ovh_cloud_project_database_database" "database" {
1717
service_name = "XXX"
18-
engine = "YYY"
18+
engine = "YYY"
1919
cluster_id = "ZZZ"
2020
name = "UUU"
2121
}
@@ -30,7 +30,7 @@ output "database_name" {
3030
* `service_name` - (Required) The id of the public cloud project. If omitted,
3131
the `OVH_CLOUD_PROJECT_SERVICE` environment variable is used.
3232

33-
* `engine` - (Required) The engine of the database cluster you want database information. To get a full list of available engine visit :
33+
* `engine` - (Required) The engine of the database cluster you want database information. To get a full list of available engine visit.
3434
[public documentation](https://docs.ovh.com/gb/en/publiccloud/databases).\
3535
Available engines for this resource (other have specific resource):
3636
* `mysql`

website/docs/d/cloud_project_database_databases.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Use this data source to get the list of databases of a database cluster associat
1515
```hcl
1616
data "ovh_cloud_project_database_databases" "databases" {
1717
service_name = "XXXX"
18-
engine = "YYYY"
18+
engine = "YYYY"
1919
cluster_id = "ZZZ"
2020
}
2121

0 commit comments

Comments
 (0)