parent
d1e12fcf64
commit
24b7387db9
140 changed files with 1597 additions and 7 deletions
|
|
@ -184,6 +184,8 @@ func (r *distributionDataSource) Read(ctx context.Context, req datasource.ReadRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
distributionId := model.DistributionId.ValueString()
|
||||
distributionResp, err := r.client.GetDistributionExecute(ctx, projectId, distributionId)
|
||||
|
|
@ -199,6 +201,9 @@ func (r *distributionDataSource) Read(ctx context.Context, req datasource.ReadRe
|
|||
resp.State.RemoveResource(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, distributionResp.Distribution, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading CDN distribution", fmt.Sprintf("Error processing API response: %v", err))
|
||||
|
|
|
|||
|
|
@ -334,6 +334,9 @@ func (r *distributionResource) Create(ctx context.Context, req resource.CreateRe
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
||||
|
|
@ -348,6 +351,9 @@ func (r *distributionResource) Create(ctx context.Context, req resource.CreateRe
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating CDN distribution", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
waitResp, err := wait.CreateDistributionPoolWaitHandler(ctx, r.client, projectId, *createResp.Distribution.Id).SetTimeout(5 * time.Minute).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating CDN distribution", fmt.Sprintf("Waiting for create: %v", err))
|
||||
|
|
@ -376,6 +382,8 @@ func (r *distributionResource) Read(ctx context.Context, req resource.ReadReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
distributionId := model.DistributionId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -394,6 +402,9 @@ func (r *distributionResource) Read(ctx context.Context, req resource.ReadReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading CDN distribution", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, cdnResp.Distribution, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading CDN ditribution", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
@ -416,6 +427,8 @@ func (r *distributionResource) Update(ctx context.Context, req resource.UpdateRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
distributionId := model.DistributionId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -516,6 +529,8 @@ func (r *distributionResource) Update(ctx context.Context, req resource.UpdateRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
waitResp, err := wait.UpdateDistributionWaitHandler(ctx, r.client, projectId, distributionId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Update CDN distribution", fmt.Sprintf("Waiting for update: %v", err))
|
||||
|
|
@ -543,6 +558,9 @@ func (r *distributionResource) Delete(ctx context.Context, req resource.DeleteRe
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
distributionId := model.DistributionId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -552,6 +570,9 @@ func (r *distributionResource) Delete(ctx context.Context, req resource.DeleteRe
|
|||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Delete CDN distribution", fmt.Sprintf("Delete distribution: %v", err))
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteDistributionWaitHandler(ctx, r.client, projectId, distributionId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Delete CDN distribution", fmt.Sprintf("Waiting for deletion: %v", err))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue