chore(terraform): refactor region overrides in mapping funcs (#872)
This commit is contained in:
parent
0272a86292
commit
5e5404b459
31 changed files with 185 additions and 194 deletions
|
|
@ -174,12 +174,7 @@ func (r *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
var region string
|
||||
if utils.IsUndefined(model.Region) {
|
||||
region = r.providerData.GetRegion()
|
||||
} else {
|
||||
region = model.Region.ValueString()
|
||||
}
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "instance_id", instanceId)
|
||||
ctx = tflog.SetField(ctx, "region", region)
|
||||
|
|
|
|||
|
|
@ -441,10 +441,7 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
if region == "" {
|
||||
region = r.providerData.GetRegion()
|
||||
}
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "instance_id", instanceId)
|
||||
|
|
|
|||
|
|
@ -150,12 +150,7 @@ func (r *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
|
|||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
userId := model.UserId.ValueString()
|
||||
var region string
|
||||
if utils.IsUndefined(model.Region) {
|
||||
region = r.providerData.GetRegion()
|
||||
} else {
|
||||
region = model.Region.ValueString()
|
||||
}
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "instance_id", instanceId)
|
||||
ctx = tflog.SetField(ctx, "user_id", userId)
|
||||
|
|
|
|||
|
|
@ -277,14 +277,11 @@ func (r *userResource) Read(ctx context.Context, req resource.ReadRequest, resp
|
|||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
userId := model.UserId.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "instance_id", instanceId)
|
||||
ctx = tflog.SetField(ctx, "user_id", userId)
|
||||
ctx = tflog.SetField(ctx, "region", region)
|
||||
if region == "" {
|
||||
region = r.providerData.GetRegion()
|
||||
}
|
||||
|
||||
recordSetResp, err := r.client.GetUser(ctx, projectId, instanceId, userId, region).Execute()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue