Skip to content

Commit e563aff

Browse files
committed
feat(resource_ovh_cloud_project_region_storage_presign): add integration test & rename resource
Signed-off-by: Arnaud SINAYS <[email protected]>
1 parent 879199b commit e563aff

5 files changed

+70
-9
lines changed

Diff for: ovh/provider.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func Provider() *schema.Provider {
139139
"ovh_cloud_project_kube_iprestrictions": resourceCloudProjectKubeIpRestrictions(),
140140
"ovh_cloud_project_network_private": resourceCloudProjectNetworkPrivate(),
141141
"ovh_cloud_project_network_private_subnet": resourceCloudProjectNetworkPrivateSubnet(),
142-
"ovh_cloud_project_storage_s3_presign": resourceCloudProjectStorageS3Presign(),
142+
"ovh_cloud_project_region_storage_presign": resourceCloudProjectRegionStoragePresign(),
143143
"ovh_cloud_project_user": resourceCloudProjectUser(),
144144
"ovh_cloud_project_user_s3_credential": resourceCloudProjectUserS3Credential(),
145145
"ovh_cloud_project_user_s3_policy": resourceCloudProjectUserS3Policy(),

Diff for: ovh/resource_cloud_project_storage_s3_presign.go renamed to ovh/resource_cloud_project_region_storage_presign.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
"time"
1010
)
1111

12-
func resourceCloudProjectStorageS3Presign() *schema.Resource {
12+
func resourceCloudProjectRegionStoragePresign() *schema.Resource {
1313
return &schema.Resource{
14-
Create: resourceCloudProjectStorageS3PresignCreate,
14+
Create: resourceCloudProjectRegionStoragePresignCreate,
1515
Read: schema.Noop,
1616
Delete: schema.Noop,
1717

@@ -70,7 +70,7 @@ func resourceCloudProjectStorageS3Presign() *schema.Resource {
7070
}
7171
}
7272

73-
func resourceCloudProjectStorageS3PresignCreate(d *schema.ResourceData, meta interface{}) error {
73+
func resourceCloudProjectRegionStoragePresignCreate(d *schema.ResourceData, meta interface{}) error {
7474
config := meta.(*Config)
7575
serviceName := d.Get("service_name").(string)
7676
regionName := d.Get("region_name").(string)
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package ovh
2+
3+
import (
4+
"fmt"
5+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
6+
"os"
7+
"testing"
8+
)
9+
10+
const testCloudProjectRegionStoragePresign = `
11+
resource "ovh_cloud_project_region_storage_presign" "presign_url" {
12+
service_name = "%s"
13+
region_name = "%s"
14+
name = "%s"
15+
expire = 3600
16+
method = "GET"
17+
object = "%s"
18+
}
19+
`
20+
21+
func testAccCheckCloudRegionStorage(t *testing.T) {
22+
type cloudProjectRegionStorageResponse struct {
23+
Name string `json:"name"`
24+
Region string `json:"region"`
25+
}
26+
27+
r := cloudProjectRegionStorageResponse{}
28+
29+
endpoint := fmt.Sprintf("/cloud/project/%s/region/%s/storage/%s",
30+
os.Getenv("OVH_CLOUD_PROJECT_SERVICE_TEST"),
31+
os.Getenv("OVH_CLOUD_PROJECT_REGION_STORAGE_NAME_TEST"),
32+
os.Getenv("OVH_CLOUD_PROJECT_REGION_STORAGE_BUCKET_NAME_TEST"))
33+
34+
err := testAccOVHClient.Get(endpoint, &r)
35+
if err != nil {
36+
t.Fatalf("Error: %q\n", err)
37+
}
38+
t.Logf("Read Storage Container %s -> name: '%s', region: '%s'", endpoint, r.Name, r.Region)
39+
}
40+
41+
func TestCloudProjectRegionStoragePresign(t *testing.T) {
42+
serviceName := os.Getenv("OVH_CLOUD_PROJECT_SERVICE_TEST")
43+
regionName := os.Getenv("OVH_CLOUD_PROJECT_REGION_STORAGE_NAME_TEST")
44+
name := os.Getenv("OVH_CLOUD_PROJECT_REGION_STORAGE_BUCKET_NAME_TEST")
45+
object := os.Getenv("OVH_CLOUD_PROJECT_REGION_STORAGE_OBJECT_TEST")
46+
47+
config := fmt.Sprintf(testCloudProjectRegionStoragePresign, serviceName, regionName, name, object)
48+
49+
resource.Test(t, resource.TestCase{
50+
PreCheck: func() { testAccPreCheckCloud(t); testAccCheckCloudProjectExists(t); testAccCheckCloudRegionStorage(t) },
51+
Providers: testAccProviders,
52+
Steps: []resource.TestStep{
53+
{
54+
Config: config,
55+
Check: resource.ComposeTestCheckFunc(
56+
resource.TestCheckResourceAttrSet("ovh_cloud_project_region_storage_presign.presign_url", "url"),
57+
),
58+
},
59+
},
60+
})
61+
}

Diff for: website/docs/r/cloud_project_storage_s3_presign.html.markdown

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
---
22
layout: "ovh"
3-
page_title: "OVH: cloud_project_storage_s3_presign"
4-
sidebar_current: "docs-ovh-resource-cloud-project-storage-s3-presign"
3+
page_title: "OVH: cloud_project_region_storage_presign"
4+
sidebar_current: "docs-ovh-resource-cloud-project-region-storage-presign"
55
description: |-
66
Generates a temporary presigned S3 URLs to download or upload an object.
77
---
88

9-
# ovh_cloud_project_storage_s3_presign
9+
# ovh_cloud_project_region_storage_presign
1010

1111
Generates a temporary presigned S3 URLs to download or upload an object.
1212

1313
## Example Usage
1414

1515
```hcl
16-
resource "ovh_cloud_project_storage_s3_presign" "presigned_url" {
16+
resource "ovh_cloud_project_region_storage_presign" "presigned_url" {
1717
service_name = "xxxxxxxxxxxxxxxxx"
1818
region_name = "GRA"
1919
name = "s3-bucket-name"

Diff for: website/ovh.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
<a href="/docs/providers/ovh/r/cloud_project_network_private_subnet.html">ovh_cloud_project_network_private_subnet</a>
162162
</li>
163163
<li<%= sidebar_current("docs-ovh-resource-cloud-project-storage-s3-presign") %>>
164-
<a href="/docs/providers/ovh/r/cloud_project_storage_s3_presign.html">ovh_cloud_project_storage_s3_presign</a>
164+
<a href="/docs/providers/ovh/r/cloud_project_region_storage_presign.html">ovh_cloud_project_region_storage_presign</a>
165165
</li>
166166
<li<%= sidebar_current("docs-ovh-resource-cloud-project-user") %>>
167167
<a href="/docs/providers/ovh/r/cloud_project_user.html">ovh_cloud_project_user</a>

0 commit comments

Comments
 (0)