Skip to content

Commit

Permalink
Merge branch 'master' into object_bucket_policy_doc_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
remyleone authored Dec 12, 2023
2 parents b2e77ed + 1cf9b7b commit 3b8655e
Show file tree
Hide file tree
Showing 37 changed files with 15,645 additions and 17,168 deletions.
5 changes: 2 additions & 3 deletions docs/resources/apple_silicon.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ In addition to all above arguments, the following attributes are exported:

~> **Important:** Apple Silicon servers' IDs are [zoned](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{zone}/{id}`, e.g. `fr-par-1/11111111-1111-1111-1111-111111111111`

- `state` - The state of the server. Check the possible values on
our [sdk](https://github.com/scaleway/scaleway-sdk-go/blob/master/api/applesilicon/v1alpha1/applesilicon_sdk.go#L103).
- `state` - The state of the server.
- `ip` - IPv4 address of the server (IPv4 address).
- `vnc_url` - URL of the VNC.
- `created_at` - The date and time of the creation of the Apple Silicon server.
Expand All @@ -57,5 +56,5 @@ In addition to all above arguments, the following attributes are exported:
Instance servers can be imported using the `{zone}/{id}`, e.g.

```bash
$ terraform import scaleway_apple_silicon.server fr-par-1/11111111-1111-1111-1111-111111111111
$ terraform import scaleway_apple_silicon_server.main fr-par-1/11111111-1111-1111-1111-111111111111
```
6 changes: 3 additions & 3 deletions docs/resources/object.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ resource "scaleway_object_bucket" "some_bucket" {
}
resource scaleway_object "some_file" {
bucket = scaleway_object_bucket.some_bucket.name
bucket = scaleway_object_bucket.some_bucket.id
key = "object_path"
file = "myfile"
Expand All @@ -29,7 +29,7 @@ resource scaleway_object "some_file" {

The following arguments are supported:

* `bucket` - (Required) The name of the bucket.
* `bucket` - (Required) The name of the bucket, or its Terraform ID.
* `key` - (Required) The path of the object.
* `file` - (Optional) The name of the file to upload, defaults to an empty file. Only one of `file`, `content` or `content_base64` can be defined.
* `content` - (Optional) The content of the file to upload. Only one of `file`, `content` or `content_base64` can be defined.
Expand All @@ -39,7 +39,7 @@ The following arguments are supported:
* `visibility` - (Optional) Visibility of the object, `public-read` or `private`
* `metadata` - (Optional) Map of metadata used for the object, keys must be lowercase
* `tags` - (Optional) Map of tags
* `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the bucket is associated with.
* `project_id` - (Defaults to [provider](../index.md#arguments-reference) `project_id`) The ID of the project the bucket is associated with.

## Attributes Reference

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/webhosting.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
subcategory: "Webhosting"
subcategory: "Web hosting"
page_title: "Scaleway: scaleway_webhosting"
---

Expand Down
4 changes: 0 additions & 4 deletions scaleway/helpers_apple_silicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ const (
defaultAppleSiliconServerRetryInterval = 5 * time.Second
)

const (
AppleSiliconM1Type = "M1-M"
)

// asAPIWithZone returns a new apple silicon API and the zone
func asAPIWithZone(d *schema.ResourceData, m interface{}) (*applesilicon.API, scw.Zone, error) {
meta := m.(*Meta)
Expand Down
5 changes: 4 additions & 1 deletion scaleway/helpers_k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ func waitK8SClusterDeleted(ctx context.Context, k8sAPI *k8s.API, region scw.Regi
return err
}

return fmt.Errorf("cluster %s has state %s, wants %s", clusterID, cluster.Status, k8s.ClusterStatusDeleted)
if cluster.Status != k8s.ClusterStatusDeleted {
return fmt.Errorf("cluster %s has state %s, wants %s", clusterID, cluster.Status, k8s.ClusterStatusDeleted)
}
return nil
}

func waitK8SPoolReady(ctx context.Context, k8sAPI *k8s.API, region scw.Region, poolID string, timeout time.Duration) (*k8s.Pool, error) {
Expand Down
4 changes: 0 additions & 4 deletions scaleway/resource_apple_silicon_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
applesilicon "github.com/scaleway/scaleway-sdk-go/api/applesilicon/v1alpha1"
"github.com/scaleway/scaleway-sdk-go/scw"
)
Expand Down Expand Up @@ -37,9 +36,6 @@ func resourceScalewayAppleSiliconServer() *schema.Resource {
Description: "Type of the server",
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
AppleSiliconM1Type,
}, false),
},
// Computed
"ip": {
Expand Down
2 changes: 1 addition & 1 deletion scaleway/resource_apple_silicon_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestAccScalewayAppleSiliconServer_Basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckScalewayAppleSiliconExists(tt, "scaleway_apple_silicon_server.main"),
resource.TestCheckResourceAttr("scaleway_apple_silicon_server.main", "name", "test-m1"),
resource.TestCheckResourceAttr("scaleway_apple_silicon_server.main", "type", AppleSiliconM1Type),
resource.TestCheckResourceAttr("scaleway_apple_silicon_server.main", "type", "M1-M"),
// Computed
resource.TestCheckResourceAttrSet("scaleway_apple_silicon_server.main", "ip"),
resource.TestCheckResourceAttrSet("scaleway_apple_silicon_server.main", "vnc_url"),
Expand Down
7 changes: 7 additions & 0 deletions scaleway/resource_k8s_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func resourceScalewayK8SPool() *schema.Resource {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Computed: true,
Description: "System volume type of the nodes composing the pool",
ValidateFunc: validation.StringInSlice([]string{
k8s.PoolVolumeTypeBSSD.String(),
Expand All @@ -154,6 +155,7 @@ func resourceScalewayK8SPool() *schema.Resource {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Computed: true,
Description: "The size of the system volume of the nodes in gigabyte",
},
"public_ip_disabled": {
Expand Down Expand Up @@ -378,13 +380,18 @@ func resourceScalewayK8SPoolRead(ctx context.Context, d *schema.ResourceData, me
_ = d.Set("version", pool.Version)
_ = d.Set("min_size", int(pool.MinSize))
_ = d.Set("max_size", int(pool.MaxSize))
_ = d.Set("root_volume_type", pool.RootVolumeType)
if pool.RootVolumeSize != nil {
_ = d.Set("root_volume_size_in_gb", int(*pool.RootVolumeSize)/1e9)
}
_ = d.Set("tags", pool.Tags)
_ = d.Set("container_runtime", pool.ContainerRuntime)
_ = d.Set("created_at", pool.CreatedAt.Format(time.RFC3339))
_ = d.Set("updated_at", pool.UpdatedAt.Format(time.RFC3339))
_ = d.Set("nodes", nodes)
_ = d.Set("status", pool.Status)
_ = d.Set("kubelet_args", flattenKubeletArgs(pool.KubeletArgs))
_ = d.Set("region", region)
_ = d.Set("zone", pool.Zone)
_ = d.Set("upgrade_policy", poolUpgradePolicyFlatten(pool))
_ = d.Set("public_ip_disabled", pool.PublicIPDisabled)
Expand Down
37 changes: 26 additions & 11 deletions scaleway/resource_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ func resourceScalewayObject() *schema.Resource {
},
Schema: map[string]*schema.Schema{
"bucket": {
Type: schema.TypeString,
Required: true,
Description: "The name of the bucket",
Type: schema.TypeString,
Required: true,
Description: "The bucket's name or regional ID.",
DiffSuppressFunc: diffSuppressFuncLocality,
},
"key": {
Type: schema.TypeString,
Expand Down Expand Up @@ -113,7 +114,18 @@ func resourceScalewayObjectCreate(ctx context.Context, d *schema.ResourceData, m
ctx, cancel := context.WithTimeout(ctx, d.Timeout(schema.TimeoutCreate))
defer cancel()

bucket := d.Get("bucket").(string)
regionalID := expandRegionalID(d.Get("bucket"))
bucket := regionalID.ID
bucketRegion := regionalID.Region

if bucketRegion != "" && bucketRegion != region {
s3Client, err = s3ClientForceRegion(d, meta, bucketRegion.String())
if err != nil {
return diag.FromErr(err)
}
region = bucketRegion
}

key := d.Get("key").(string)

req := &s3.PutObjectInput{
Expand Down Expand Up @@ -177,10 +189,13 @@ func resourceScalewayObjectUpdate(ctx context.Context, d *schema.ResourceData, m
ctx, cancel := context.WithTimeout(ctx, d.Timeout(schema.TimeoutUpdate))
defer cancel()

bucketUpdated := expandRegionalID(d.Get("bucket")).ID
keyUpdated := d.Get("key").(string)

if d.HasChanges("file", "hash") {
req := &s3.PutObjectInput{
Bucket: expandStringPtr(d.Get("bucket")),
Key: expandStringPtr(d.Get("key")),
Bucket: expandStringPtr(bucketUpdated),
Key: expandStringPtr(keyUpdated),
StorageClass: expandStringPtr(d.Get("storage_class")),
Metadata: expandMapStringStringPtr(d.Get("metadata")),
ACL: expandStringPtr(d.Get("visibility").(string)),
Expand All @@ -198,8 +213,8 @@ func resourceScalewayObjectUpdate(ctx context.Context, d *schema.ResourceData, m
_, err = s3Client.PutObjectWithContext(ctx, req)
} else {
_, err = s3Client.CopyObjectWithContext(ctx, &s3.CopyObjectInput{
Bucket: expandStringPtr(d.Get("bucket")),
Key: expandStringPtr(d.Get("key")),
Bucket: expandStringPtr(bucketUpdated),
Key: expandStringPtr(keyUpdated),
StorageClass: expandStringPtr(d.Get("storage_class")),
CopySource: scw.StringPtr(fmt.Sprintf("%s/%s", bucket, key)),
Metadata: expandMapStringStringPtr(d.Get("metadata")),
Expand All @@ -222,7 +237,7 @@ func resourceScalewayObjectUpdate(ctx context.Context, d *schema.ResourceData, m

if d.HasChange("tags") {
_, err := s3Client.PutObjectTaggingWithContext(ctx, &s3.PutObjectTaggingInput{
Bucket: expandStringPtr(d.Get("bucket")),
Bucket: expandStringPtr(bucketUpdated),
Key: expandStringPtr(key),
Tagging: &s3.Tagging{
TagSet: expandObjectBucketTags(d.Get("tags")),
Expand All @@ -233,7 +248,7 @@ func resourceScalewayObjectUpdate(ctx context.Context, d *schema.ResourceData, m
}
}

d.SetId(newRegionalIDString(region, objectID(d.Get("bucket").(string), d.Get("key").(string))))
d.SetId(newRegionalIDString(region, objectID(bucketUpdated, keyUpdated)))

return resourceScalewayObjectCreate(ctx, d, meta)
}
Expand All @@ -256,7 +271,7 @@ func resourceScalewayObjectRead(ctx context.Context, d *schema.ResourceData, met
}

_ = d.Set("region", region)
_ = d.Set("bucket", bucket)
_ = d.Set("bucket", newRegionalIDString(region, bucket))
_ = d.Set("key", key)

for k, v := range obj.Metadata {
Expand Down
Loading

0 comments on commit 3b8655e

Please sign in to comment.