parent
d1e12fcf64
commit
24b7387db9
140 changed files with 1597 additions and 7 deletions
|
|
@ -146,6 +146,8 @@ func (d *projectDataSource) Read(ctx context.Context, req datasource.ReadRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
||||
|
|
@ -181,6 +183,8 @@ func (d *projectDataSource) Read(ctx context.Context, req datasource.ReadRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapProjectFields(ctx, projectResp, &model, &resp.State)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading project", fmt.Sprintf("Processing API response: %v", err))
|
||||
|
|
|
|||
|
|
@ -196,6 +196,8 @@ func (r *projectResource) Create(ctx context.Context, req resource.CreateRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
containerId := model.ContainerId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_container_id", containerId)
|
||||
|
||||
|
|
@ -211,6 +213,9 @@ func (r *projectResource) Create(ctx context.Context, req resource.CreateRequest
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating project", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
respContainerId := *createResp.ContainerId
|
||||
|
||||
// If the request has not been processed yet and the containerId doesn't exist,
|
||||
|
|
@ -244,6 +249,9 @@ func (r *projectResource) Read(ctx context.Context, req resource.ReadRequest, re
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
containerId := model.ContainerId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "container_id", containerId)
|
||||
|
||||
|
|
@ -258,6 +266,8 @@ func (r *projectResource) Read(ctx context.Context, req resource.ReadRequest, re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapProjectFields(ctx, projectResp, &model.Model, &resp.State)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading project", fmt.Sprintf("Processing API response: %v", err))
|
||||
|
|
@ -282,6 +292,9 @@ func (r *projectResource) Update(ctx context.Context, req resource.UpdateRequest
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
containerId := model.ContainerId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "container_id", containerId)
|
||||
|
||||
|
|
@ -298,6 +311,8 @@ func (r *projectResource) Update(ctx context.Context, req resource.UpdateRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Fetch updated project
|
||||
projectResp, err := r.client.GetProject(ctx, containerId).Execute()
|
||||
if err != nil {
|
||||
|
|
@ -329,6 +344,8 @@ func (r *projectResource) Delete(ctx context.Context, req resource.DeleteRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
containerId := model.ContainerId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "container_id", containerId)
|
||||
|
||||
|
|
@ -339,6 +356,8 @@ func (r *projectResource) Delete(ctx context.Context, req resource.DeleteRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteProjectWaitHandler(ctx, r.client, containerId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting project", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue