Skip to content

chore: remove usage of organization_id #674

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

Merged
merged 1 commit into from
Nov 2, 2020
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
5 changes: 2 additions & 3 deletions scaleway/data_source_account_ssh_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ func dataSourceScalewayAccountSSHKeyRead(ctx context.Context, d *schema.Resource
sshKey = res
} else {
res, err := accountAPI.ListSSHKeys(&account.ListSSHKeysRequest{
Name: expandStringPtr(d.Get("name")),
OrganizationID: expandStringPtr(d.Get("organization_id")),
ProjectID: expandStringPtr(d.Get("project_id")),
Name: expandStringPtr(d.Get("name")),
ProjectID: expandStringPtr(d.Get("project_id")),
}, scw.WithContext(ctx))
if err != nil {
return diag.FromErr(err)
Expand Down
9 changes: 4 additions & 5 deletions scaleway/data_source_instance_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,10 @@ func dataSourceScalewayInstanceImageRead(ctx context.Context, d *schema.Resource
imageID, ok := d.GetOk("image_id")
if !ok { // Get instance by name, zone, and arch.
res, err := instanceAPI.ListImages(&instance.ListImagesRequest{
Zone: zone,
Name: expandStringPtr(d.Get("name")),
Arch: expandStringPtr(d.Get("architecture")),
Organization: expandStringPtr(d.Get("organization_id")),
Project: expandStringPtr(d.Get("project_id")),
Zone: zone,
Name: expandStringPtr(d.Get("name")),
Arch: expandStringPtr(d.Get("architecture")),
Project: expandStringPtr(d.Get("project_id")),
}, scw.WithAllPages(), scw.WithContext(ctx))
if err != nil {
return diag.FromErr(err)
Expand Down
7 changes: 3 additions & 4 deletions scaleway/data_source_instance_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ func dataSourceScalewayInstanceSecurityGroupRead(ctx context.Context, d *schema.
securityGroupID, ok := d.GetOk("security_group_id")
if !ok {
res, err := instanceAPI.ListSecurityGroups(&instance.ListSecurityGroupsRequest{
Zone: zone,
Name: expandStringPtr(d.Get("name")),
Organization: expandStringPtr(d.Get("organization_id")),
Project: expandStringPtr(d.Get("project_id")),
Zone: zone,
Name: expandStringPtr(d.Get("name")),
Project: expandStringPtr(d.Get("project_id")),
}, scw.WithAllPages(), scw.WithContext(ctx))
if err != nil {
return diag.FromErr(err)
Expand Down
7 changes: 3 additions & 4 deletions scaleway/data_source_instance_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ func dataSourceScalewayInstanceServerRead(ctx context.Context, d *schema.Resourc
serverID, ok := d.GetOk("server_id")
if !ok {
res, err := instanceAPI.ListServers(&instance.ListServersRequest{
Zone: zone,
Name: expandStringPtr(d.Get("name")),
Organization: expandStringPtr(d.Get("organization_id")),
Project: expandStringPtr(d.Get("project_id")),
Zone: zone,
Name: expandStringPtr(d.Get("name")),
Project: expandStringPtr(d.Get("project_id")),
}, scw.WithContext(ctx))
if err != nil {
return diag.FromErr(err)
Expand Down
7 changes: 3 additions & 4 deletions scaleway/data_source_instance_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ func dataSourceScalewayInstanceVolumeRead(ctx context.Context, d *schema.Resourc
volumeID, ok := d.GetOk("volume_id")
if !ok { // Get volumes by zone and name.
res, err := instanceAPI.ListVolumes(&instance.ListVolumesRequest{
Zone: zone,
Name: expandStringPtr(d.Get("name")),
Organization: expandStringPtr(d.Get("organization_id")),
Project: expandStringPtr(d.Get("project_id")),
Zone: zone,
Name: expandStringPtr(d.Get("name")),
Project: expandStringPtr(d.Get("project_id")),
}, scw.WithContext(ctx))
if err != nil {
return diag.FromErr(err)
Expand Down
7 changes: 3 additions & 4 deletions scaleway/data_source_lb_ip_beta.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ func dataSourceScalewayLbIPBetaRead(ctx context.Context, d *schema.ResourceData,
ipID, ok := d.GetOk("ip_id")
if !ok { // Get IP by region and IP address.
res, err := api.ListIPs(&lb.ListIPsRequest{
Region: region,
IPAddress: expandStringPtr(d.Get("ip_address")),
OrganizationID: expandStringPtr(d.Get("organization_id")),
ProjectID: expandStringPtr(d.Get("project_id")),
Region: region,
IPAddress: expandStringPtr(d.Get("ip_address")),
ProjectID: expandStringPtr(d.Get("project_id")),
}, scw.WithContext(ctx))
if err != nil {
return diag.FromErr(err)
Expand Down
7 changes: 3 additions & 4 deletions scaleway/resource_account_ssh_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ func resourceScalewayAccountSSHKeyCreate(ctx context.Context, d *schema.Resource
accountAPI := accountAPI(m)

res, err := accountAPI.CreateSSHKey(&account.CreateSSHKeyRequest{
Name: d.Get("name").(string),
PublicKey: strings.Trim(d.Get("public_key").(string), "\n"),
OrganizationID: expandStringPtr(d.Get("organization_id")),
ProjectID: expandStringPtr(d.Get("project_id")),
Name: d.Get("name").(string),
PublicKey: strings.Trim(d.Get("public_key").(string), "\n"),
ProjectID: expandStringPtr(d.Get("project_id")),
}, scw.WithContext(ctx))
if err != nil {
return diag.FromErr(err)
Expand Down
13 changes: 6 additions & 7 deletions scaleway/resource_baremetal_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,12 @@ func resourceScalewayBaremetalServerCreate(ctx context.Context, d *schema.Resour
}

server, err := baremetalAPI.CreateServer(&baremetal.CreateServerRequest{
Zone: zone,
Name: expandOrGenerateString(d.Get("name"), "bm"),
OrganizationID: expandStringPtr(d.Get("organization_id")),
ProjectID: expandStringPtr(d.Get("project_id")),
Description: d.Get("description").(string),
OfferID: offerID.ID,
Tags: expandStrings(d.Get("tags")),
Zone: zone,
Name: expandOrGenerateString(d.Get("name"), "bm"),
ProjectID: expandStringPtr(d.Get("project_id")),
Description: d.Get("description").(string),
OfferID: offerID.ID,
Tags: expandStrings(d.Get("tags")),
}, scw.WithContext(ctx))
if err != nil {
return diag.FromErr(err)
Expand Down
5 changes: 2 additions & 3 deletions scaleway/resource_instance_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ func resourceScalewayInstanceIPCreate(ctx context.Context, d *schema.ResourceDat
}

res, err := instanceAPI.CreateIP(&instance.CreateIPRequest{
Zone: zone,
Organization: expandStringPtr(d.Get("organization_id")),
Project: expandStringPtr(d.Get("project_id")),
Zone: zone,
Project: expandStringPtr(d.Get("project_id")),
}, scw.WithContext(ctx))
if err != nil {
return diag.FromErr(err)
Expand Down
11 changes: 5 additions & 6 deletions scaleway/resource_instance_placement_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,11 @@ func resourceScalewayInstancePlacementGroupCreate(ctx context.Context, d *schema
}

res, err := instanceAPI.CreatePlacementGroup(&instance.CreatePlacementGroupRequest{
Zone: zone,
Name: expandOrGenerateString(d.Get("name"), "pg"),
Organization: expandStringPtr(d.Get("organization_id")),
Project: expandStringPtr(d.Get("project_id")),
PolicyMode: instance.PlacementGroupPolicyMode(d.Get("policy_mode").(string)),
PolicyType: instance.PlacementGroupPolicyType(d.Get("policy_type").(string)),
Zone: zone,
Name: expandOrGenerateString(d.Get("name"), "pg"),
Project: expandStringPtr(d.Get("project_id")),
PolicyMode: instance.PlacementGroupPolicyMode(d.Get("policy_mode").(string)),
PolicyType: instance.PlacementGroupPolicyType(d.Get("policy_type").(string)),
}, scw.WithContext(ctx))
if err != nil {
return diag.FromErr(err)
Expand Down
1 change: 0 additions & 1 deletion scaleway/resource_instance_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ func resourceScalewayInstanceSecurityGroupCreate(ctx context.Context, d *schema.
res, err := instanceAPI.CreateSecurityGroup(&instance.CreateSecurityGroupRequest{
Name: expandOrGenerateString(d.Get("name"), "sg"),
Zone: zone,
Organization: expandStringPtr(d.Get("organization_id")),
Project: expandStringPtr(d.Get("project_id")),
Description: d.Get("description").(string),
Stateful: d.Get("stateful").(bool),
Expand Down
1 change: 0 additions & 1 deletion scaleway/resource_instance_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ func resourceScalewayInstanceServerCreate(ctx context.Context, d *schema.Resourc
req := &instance.CreateServerRequest{
Zone: zone,
Name: expandOrGenerateString(d.Get("name"), "srv"),
Organization: expandStringPtr(d.Get("organization_id")),
Project: expandStringPtr(d.Get("project_id")),
Image: image.ID,
CommercialType: commercialType,
Expand Down
9 changes: 4 additions & 5 deletions scaleway/resource_instance_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,10 @@ func resourceScalewayInstanceVolumeCreate(ctx context.Context, d *schema.Resourc
}

createVolumeRequest := &instance.CreateVolumeRequest{
Zone: zone,
Name: expandOrGenerateString(d.Get("name"), "vol"),
VolumeType: instance.VolumeVolumeType(d.Get("type").(string)),
Organization: expandStringPtr(d.Get("organization_id")),
Project: expandStringPtr(d.Get("project_id")),
Zone: zone,
Name: expandOrGenerateString(d.Get("name"), "vol"),
VolumeType: instance.VolumeVolumeType(d.Get("type").(string)),
Project: expandStringPtr(d.Get("project_id")),
}

if size, ok := d.GetOk("size_in_gb"); ok {
Expand Down
1 change: 0 additions & 1 deletion scaleway/resource_k8s_cluster_beta.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ func resourceScalewayK8SClusterBetaCreate(ctx context.Context, d *schema.Resourc

req := &k8s.CreateClusterRequest{
Region: region,
OrganizationID: expandStringPtr(d.Get("organization_id")),
ProjectID: expandStringPtr(d.Get("project_id")),
Name: expandOrGenerateString(d.Get("name"), "cluster"),
Description: description.(string),
Expand Down
11 changes: 5 additions & 6 deletions scaleway/resource_lb_beta.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,11 @@ func resourceScalewayLbBetaCreate(ctx context.Context, d *schema.ResourceData, m
}

createReq := &lb.CreateLBRequest{
Region: region,
IPID: expandStringPtr(expandID(d.Get("ip_id"))),
OrganizationID: expandStringPtr(d.Get("organization_id")),
ProjectID: expandStringPtr(d.Get("project_id")),
Name: expandOrGenerateString(d.Get("name"), "lb"),
Type: d.Get("type").(string),
Region: region,
IPID: expandStringPtr(expandID(d.Get("ip_id"))),
ProjectID: expandStringPtr(d.Get("project_id")),
Name: expandOrGenerateString(d.Get("name"), "lb"),
Type: d.Get("type").(string),
}

if raw, ok := d.GetOk("tags"); ok {
Expand Down
7 changes: 3 additions & 4 deletions scaleway/resource_lb_ip_beta.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ func resourceScalewayLbIPBetaCreate(ctx context.Context, d *schema.ResourceData,
}

createReq := &lb.CreateIPRequest{
Region: region,
OrganizationID: expandStringPtr(d.Get("organization_id")),
ProjectID: expandStringPtr(d.Get("project_id")),
Reverse: expandStringPtr(d.Get("reverse")),
Region: region,
ProjectID: expandStringPtr(d.Get("project_id")),
Reverse: expandStringPtr(d.Get("reverse")),
}

res, err := lbAPI.CreateIP(createReq, scw.WithContext(ctx))
Expand Down
21 changes: 10 additions & 11 deletions scaleway/resource_rdb_instance_beta.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,16 @@ func resourceScalewayRdbInstanceBetaCreate(ctx context.Context, d *schema.Resour
}

createReq := &rdb.CreateInstanceRequest{
Region: region,
OrganizationID: expandStringPtr(d.Get("organization_id")),
ProjectID: expandStringPtr(d.Get("project_id")),
Name: expandOrGenerateString(d.Get("name"), "rdb"),
NodeType: d.Get("node_type").(string),
Engine: d.Get("engine").(string),
IsHaCluster: d.Get("is_ha_cluster").(bool),
DisableBackup: d.Get("disable_backup").(bool),
UserName: d.Get("user_name").(string),
Password: d.Get("password").(string),
Tags: expandStrings(d.Get("tags")),
Region: region,
ProjectID: expandStringPtr(d.Get("project_id")),
Name: expandOrGenerateString(d.Get("name"), "rdb"),
NodeType: d.Get("node_type").(string),
Engine: d.Get("engine").(string),
IsHaCluster: d.Get("is_ha_cluster").(bool),
DisableBackup: d.Get("disable_backup").(bool),
UserName: d.Get("user_name").(string),
Password: d.Get("password").(string),
Tags: expandStrings(d.Get("tags")),
}

res, err := rdbAPI.CreateInstance(createReq, scw.WithContext(ctx))
Expand Down
11 changes: 8 additions & 3 deletions scaleway/resource_registry_namespace_beta.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func resourceScalewayRegistryNamespaceBeta() *schema.Resource {
},
"region": regionSchema(),
"organization_id": organizationIDSchema(),
"project_id": projectIDSchema(),
},
}
}
Expand All @@ -54,8 +55,10 @@ func resourceScalewayRegistryNamespaceBetaCreate(ctx context.Context, d *schema.
}

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

_ = d.Set("name", ns.Name)
_ = d.Set("description", ns.Description)
_ = d.Set("organization_id", ns.OrganizationID)
// Registry does not support yet project id.
// Once it does, use ProjectID instead or OrganizationID
_ = d.Set("project_id", ns.OrganizationID)
_ = d.Set("is_public", ns.IsPublic)
_ = d.Set("endpoint", ns.Endpoint)
_ = d.Set("region", ns.Region)
Expand Down