Skip to content

Commit 4602317

Browse files
authored
chore: remove usage of organization_id (#674)
1 parent 2908de7 commit 4602317

18 files changed

+64
-76
lines changed

scaleway/data_source_account_ssh_key.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ func dataSourceScalewayAccountSSHKeyRead(ctx context.Context, d *schema.Resource
5151
sshKey = res
5252
} else {
5353
res, err := accountAPI.ListSSHKeys(&account.ListSSHKeysRequest{
54-
Name: expandStringPtr(d.Get("name")),
55-
OrganizationID: expandStringPtr(d.Get("organization_id")),
56-
ProjectID: expandStringPtr(d.Get("project_id")),
54+
Name: expandStringPtr(d.Get("name")),
55+
ProjectID: expandStringPtr(d.Get("project_id")),
5756
}, scw.WithContext(ctx))
5857
if err != nil {
5958
return diag.FromErr(err)

scaleway/data_source_instance_image.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,10 @@ func dataSourceScalewayInstanceImageRead(ctx context.Context, d *schema.Resource
103103
imageID, ok := d.GetOk("image_id")
104104
if !ok { // Get instance by name, zone, and arch.
105105
res, err := instanceAPI.ListImages(&instance.ListImagesRequest{
106-
Zone: zone,
107-
Name: expandStringPtr(d.Get("name")),
108-
Arch: expandStringPtr(d.Get("architecture")),
109-
Organization: expandStringPtr(d.Get("organization_id")),
110-
Project: expandStringPtr(d.Get("project_id")),
106+
Zone: zone,
107+
Name: expandStringPtr(d.Get("name")),
108+
Arch: expandStringPtr(d.Get("architecture")),
109+
Project: expandStringPtr(d.Get("project_id")),
111110
}, scw.WithAllPages(), scw.WithContext(ctx))
112111
if err != nil {
113112
return diag.FromErr(err)

scaleway/data_source_instance_security_group.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ func dataSourceScalewayInstanceSecurityGroupRead(ctx context.Context, d *schema.
4343
securityGroupID, ok := d.GetOk("security_group_id")
4444
if !ok {
4545
res, err := instanceAPI.ListSecurityGroups(&instance.ListSecurityGroupsRequest{
46-
Zone: zone,
47-
Name: expandStringPtr(d.Get("name")),
48-
Organization: expandStringPtr(d.Get("organization_id")),
49-
Project: expandStringPtr(d.Get("project_id")),
46+
Zone: zone,
47+
Name: expandStringPtr(d.Get("name")),
48+
Project: expandStringPtr(d.Get("project_id")),
5049
}, scw.WithAllPages(), scw.WithContext(ctx))
5150
if err != nil {
5251
return diag.FromErr(err)

scaleway/data_source_instance_server.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ func dataSourceScalewayInstanceServerRead(ctx context.Context, d *schema.Resourc
4343
serverID, ok := d.GetOk("server_id")
4444
if !ok {
4545
res, err := instanceAPI.ListServers(&instance.ListServersRequest{
46-
Zone: zone,
47-
Name: expandStringPtr(d.Get("name")),
48-
Organization: expandStringPtr(d.Get("organization_id")),
49-
Project: expandStringPtr(d.Get("project_id")),
46+
Zone: zone,
47+
Name: expandStringPtr(d.Get("name")),
48+
Project: expandStringPtr(d.Get("project_id")),
5049
}, scw.WithContext(ctx))
5150
if err != nil {
5251
return diag.FromErr(err)

scaleway/data_source_instance_volume.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ func dataSourceScalewayInstanceVolumeRead(ctx context.Context, d *schema.Resourc
4242
volumeID, ok := d.GetOk("volume_id")
4343
if !ok { // Get volumes by zone and name.
4444
res, err := instanceAPI.ListVolumes(&instance.ListVolumesRequest{
45-
Zone: zone,
46-
Name: expandStringPtr(d.Get("name")),
47-
Organization: expandStringPtr(d.Get("organization_id")),
48-
Project: expandStringPtr(d.Get("project_id")),
45+
Zone: zone,
46+
Name: expandStringPtr(d.Get("name")),
47+
Project: expandStringPtr(d.Get("project_id")),
4948
}, scw.WithContext(ctx))
5049
if err != nil {
5150
return diag.FromErr(err)

scaleway/data_source_lb_ip_beta.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ func dataSourceScalewayLbIPBetaRead(ctx context.Context, d *schema.ResourceData,
4343
ipID, ok := d.GetOk("ip_id")
4444
if !ok { // Get IP by region and IP address.
4545
res, err := api.ListIPs(&lb.ListIPsRequest{
46-
Region: region,
47-
IPAddress: expandStringPtr(d.Get("ip_address")),
48-
OrganizationID: expandStringPtr(d.Get("organization_id")),
49-
ProjectID: expandStringPtr(d.Get("project_id")),
46+
Region: region,
47+
IPAddress: expandStringPtr(d.Get("ip_address")),
48+
ProjectID: expandStringPtr(d.Get("project_id")),
5049
}, scw.WithContext(ctx))
5150
if err != nil {
5251
return diag.FromErr(err)

scaleway/resource_account_ssh_key.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ func resourceScalewayAccountSSHKeyCreate(ctx context.Context, d *schema.Resource
4545
accountAPI := accountAPI(m)
4646

4747
res, err := accountAPI.CreateSSHKey(&account.CreateSSHKeyRequest{
48-
Name: d.Get("name").(string),
49-
PublicKey: strings.Trim(d.Get("public_key").(string), "\n"),
50-
OrganizationID: expandStringPtr(d.Get("organization_id")),
51-
ProjectID: expandStringPtr(d.Get("project_id")),
48+
Name: d.Get("name").(string),
49+
PublicKey: strings.Trim(d.Get("public_key").(string), "\n"),
50+
ProjectID: expandStringPtr(d.Get("project_id")),
5251
}, scw.WithContext(ctx))
5352
if err != nil {
5453
return diag.FromErr(err)

scaleway/resource_baremetal_server.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,12 @@ func resourceScalewayBaremetalServerCreate(ctx context.Context, d *schema.Resour
140140
}
141141

142142
server, err := baremetalAPI.CreateServer(&baremetal.CreateServerRequest{
143-
Zone: zone,
144-
Name: expandOrGenerateString(d.Get("name"), "bm"),
145-
OrganizationID: expandStringPtr(d.Get("organization_id")),
146-
ProjectID: expandStringPtr(d.Get("project_id")),
147-
Description: d.Get("description").(string),
148-
OfferID: offerID.ID,
149-
Tags: expandStrings(d.Get("tags")),
143+
Zone: zone,
144+
Name: expandOrGenerateString(d.Get("name"), "bm"),
145+
ProjectID: expandStringPtr(d.Get("project_id")),
146+
Description: d.Get("description").(string),
147+
OfferID: offerID.ID,
148+
Tags: expandStrings(d.Get("tags")),
150149
}, scw.WithContext(ctx))
151150
if err != nil {
152151
return diag.FromErr(err)

scaleway/resource_instance_ip.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ func resourceScalewayInstanceIPCreate(ctx context.Context, d *schema.ResourceDat
4848
}
4949

5050
res, err := instanceAPI.CreateIP(&instance.CreateIPRequest{
51-
Zone: zone,
52-
Organization: expandStringPtr(d.Get("organization_id")),
53-
Project: expandStringPtr(d.Get("project_id")),
51+
Zone: zone,
52+
Project: expandStringPtr(d.Get("project_id")),
5453
}, scw.WithContext(ctx))
5554
if err != nil {
5655
return diag.FromErr(err)

scaleway/resource_instance_placement_group.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,11 @@ func resourceScalewayInstancePlacementGroupCreate(ctx context.Context, d *schema
6666
}
6767

6868
res, err := instanceAPI.CreatePlacementGroup(&instance.CreatePlacementGroupRequest{
69-
Zone: zone,
70-
Name: expandOrGenerateString(d.Get("name"), "pg"),
71-
Organization: expandStringPtr(d.Get("organization_id")),
72-
Project: expandStringPtr(d.Get("project_id")),
73-
PolicyMode: instance.PlacementGroupPolicyMode(d.Get("policy_mode").(string)),
74-
PolicyType: instance.PlacementGroupPolicyType(d.Get("policy_type").(string)),
69+
Zone: zone,
70+
Name: expandOrGenerateString(d.Get("name"), "pg"),
71+
Project: expandStringPtr(d.Get("project_id")),
72+
PolicyMode: instance.PlacementGroupPolicyMode(d.Get("policy_mode").(string)),
73+
PolicyType: instance.PlacementGroupPolicyType(d.Get("policy_type").(string)),
7574
}, scw.WithContext(ctx))
7675
if err != nil {
7776
return diag.FromErr(err)

scaleway/resource_instance_security_group.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ func resourceScalewayInstanceSecurityGroupCreate(ctx context.Context, d *schema.
9797
res, err := instanceAPI.CreateSecurityGroup(&instance.CreateSecurityGroupRequest{
9898
Name: expandOrGenerateString(d.Get("name"), "sg"),
9999
Zone: zone,
100-
Organization: expandStringPtr(d.Get("organization_id")),
101100
Project: expandStringPtr(d.Get("project_id")),
102101
Description: d.Get("description").(string),
103102
Stateful: d.Get("stateful").(bool),

scaleway/resource_instance_server.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ func resourceScalewayInstanceServerCreate(ctx context.Context, d *schema.Resourc
254254
req := &instance.CreateServerRequest{
255255
Zone: zone,
256256
Name: expandOrGenerateString(d.Get("name"), "srv"),
257-
Organization: expandStringPtr(d.Get("organization_id")),
258257
Project: expandStringPtr(d.Get("project_id")),
259258
Image: image.ID,
260259
CommercialType: commercialType,

scaleway/resource_instance_volume.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,10 @@ func resourceScalewayInstanceVolumeCreate(ctx context.Context, d *schema.Resourc
8181
}
8282

8383
createVolumeRequest := &instance.CreateVolumeRequest{
84-
Zone: zone,
85-
Name: expandOrGenerateString(d.Get("name"), "vol"),
86-
VolumeType: instance.VolumeVolumeType(d.Get("type").(string)),
87-
Organization: expandStringPtr(d.Get("organization_id")),
88-
Project: expandStringPtr(d.Get("project_id")),
84+
Zone: zone,
85+
Name: expandOrGenerateString(d.Get("name"), "vol"),
86+
VolumeType: instance.VolumeVolumeType(d.Get("type").(string)),
87+
Project: expandStringPtr(d.Get("project_id")),
8988
}
9089

9190
if size, ok := d.GetOk("size_in_gb"); ok {

scaleway/resource_k8s_cluster_beta.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ func resourceScalewayK8SClusterBetaCreate(ctx context.Context, d *schema.Resourc
229229

230230
req := &k8s.CreateClusterRequest{
231231
Region: region,
232-
OrganizationID: expandStringPtr(d.Get("organization_id")),
233232
ProjectID: expandStringPtr(d.Get("project_id")),
234233
Name: expandOrGenerateString(d.Get("name"), "cluster"),
235234
Description: description.(string),

scaleway/resource_lb_beta.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,11 @@ func resourceScalewayLbBetaCreate(ctx context.Context, d *schema.ResourceData, m
6868
}
6969

7070
createReq := &lb.CreateLBRequest{
71-
Region: region,
72-
IPID: expandStringPtr(expandID(d.Get("ip_id"))),
73-
OrganizationID: expandStringPtr(d.Get("organization_id")),
74-
ProjectID: expandStringPtr(d.Get("project_id")),
75-
Name: expandOrGenerateString(d.Get("name"), "lb"),
76-
Type: d.Get("type").(string),
71+
Region: region,
72+
IPID: expandStringPtr(expandID(d.Get("ip_id"))),
73+
ProjectID: expandStringPtr(d.Get("project_id")),
74+
Name: expandOrGenerateString(d.Get("name"), "lb"),
75+
Type: d.Get("type").(string),
7776
}
7877

7978
if raw, ok := d.GetOk("tags"); ok {

scaleway/resource_lb_ip_beta.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ func resourceScalewayLbIPBetaCreate(ctx context.Context, d *schema.ResourceData,
5151
}
5252

5353
createReq := &lb.CreateIPRequest{
54-
Region: region,
55-
OrganizationID: expandStringPtr(d.Get("organization_id")),
56-
ProjectID: expandStringPtr(d.Get("project_id")),
57-
Reverse: expandStringPtr(d.Get("reverse")),
54+
Region: region,
55+
ProjectID: expandStringPtr(d.Get("project_id")),
56+
Reverse: expandStringPtr(d.Get("reverse")),
5857
}
5958

6059
res, err := lbAPI.CreateIP(createReq, scw.WithContext(ctx))

scaleway/resource_rdb_instance_beta.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,16 @@ func resourceScalewayRdbInstanceBetaCreate(ctx context.Context, d *schema.Resour
128128
}
129129

130130
createReq := &rdb.CreateInstanceRequest{
131-
Region: region,
132-
OrganizationID: expandStringPtr(d.Get("organization_id")),
133-
ProjectID: expandStringPtr(d.Get("project_id")),
134-
Name: expandOrGenerateString(d.Get("name"), "rdb"),
135-
NodeType: d.Get("node_type").(string),
136-
Engine: d.Get("engine").(string),
137-
IsHaCluster: d.Get("is_ha_cluster").(bool),
138-
DisableBackup: d.Get("disable_backup").(bool),
139-
UserName: d.Get("user_name").(string),
140-
Password: d.Get("password").(string),
141-
Tags: expandStrings(d.Get("tags")),
131+
Region: region,
132+
ProjectID: expandStringPtr(d.Get("project_id")),
133+
Name: expandOrGenerateString(d.Get("name"), "rdb"),
134+
NodeType: d.Get("node_type").(string),
135+
Engine: d.Get("engine").(string),
136+
IsHaCluster: d.Get("is_ha_cluster").(bool),
137+
DisableBackup: d.Get("disable_backup").(bool),
138+
UserName: d.Get("user_name").(string),
139+
Password: d.Get("password").(string),
140+
Tags: expandStrings(d.Get("tags")),
142141
}
143142

144143
res, err := rdbAPI.CreateInstance(createReq, scw.WithContext(ctx))

scaleway/resource_registry_namespace_beta.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func resourceScalewayRegistryNamespaceBeta() *schema.Resource {
4343
},
4444
"region": regionSchema(),
4545
"organization_id": organizationIDSchema(),
46+
"project_id": projectIDSchema(),
4647
},
4748
}
4849
}
@@ -54,8 +55,10 @@ func resourceScalewayRegistryNamespaceBetaCreate(ctx context.Context, d *schema.
5455
}
5556

5657
ns, err := api.CreateNamespace(&registry.CreateNamespaceRequest{
57-
Region: region,
58-
OrganizationID: expandStringPtr(d.Get("organization_id")),
58+
Region: region,
59+
// Registry does not support yet project id.
60+
// Once it does, use ProjectID instead or OrganizationID
61+
OrganizationID: expandStringPtr(d.Get("project_id")),
5962
Name: d.Get("name").(string),
6063
Description: d.Get("description").(string),
6164
IsPublic: d.Get("is_public").(bool),
@@ -90,7 +93,9 @@ func resourceScalewayRegistryNamespaceBetaRead(ctx context.Context, d *schema.Re
9093

9194
_ = d.Set("name", ns.Name)
9295
_ = d.Set("description", ns.Description)
93-
_ = d.Set("organization_id", ns.OrganizationID)
96+
// Registry does not support yet project id.
97+
// Once it does, use ProjectID instead or OrganizationID
98+
_ = d.Set("project_id", ns.OrganizationID)
9499
_ = d.Set("is_public", ns.IsPublic)
95100
_ = d.Set("endpoint", ns.Endpoint)
96101
_ = d.Set("region", ns.Region)

0 commit comments

Comments
 (0)