parent
d1e12fcf64
commit
24b7387db9
140 changed files with 1597 additions and 7 deletions
|
|
@ -145,6 +145,8 @@ func (d *folderDataSource) Read(ctx context.Context, req datasource.ReadRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
containerId := model.ContainerId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "container_id", containerId)
|
||||
|
||||
|
|
@ -164,6 +166,8 @@ func (d *folderDataSource) Read(ctx context.Context, req datasource.ReadRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFolderFields(ctx, folderResp, &model, &resp.State)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading folder", fmt.Sprintf("Processing API response: %v", err))
|
||||
|
|
|
|||
|
|
@ -191,6 +191,8 @@ func (r *folderResource) Create(ctx context.Context, req resource.CreateRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
containerParentId := model.ContainerParentId.ValueString()
|
||||
folderName := model.Name.ValueString()
|
||||
ctx = tflog.SetField(ctx, "container_parent_id", containerParentId)
|
||||
|
|
@ -209,6 +211,8 @@ func (r *folderResource) Create(ctx context.Context, req resource.CreateRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if folderCreateResp.ContainerId == nil || *folderCreateResp.ContainerId == "" {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating folder", "Container ID is missing")
|
||||
return
|
||||
|
|
@ -242,6 +246,8 @@ func (r *folderResource) Read(ctx context.Context, req resource.ReadRequest, res
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
containerId := model.ContainerId.ValueString()
|
||||
folderName := model.Name.ValueString()
|
||||
ctx = tflog.SetField(ctx, "folder_name", folderName)
|
||||
|
|
@ -258,6 +264,8 @@ func (r *folderResource) Read(ctx context.Context, req resource.ReadRequest, res
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFolderFields(ctx, folderResp, &model.Model, &resp.State)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading folder", fmt.Sprintf("Processing API response: %v", err))
|
||||
|
|
@ -282,6 +290,9 @@ func (r *folderResource) 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 +309,8 @@ func (r *folderResource) Update(ctx context.Context, req resource.UpdateRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Fetch updated folder
|
||||
folderResp, err := r.client.GetFolderDetails(ctx, containerId).Execute()
|
||||
if err != nil {
|
||||
|
|
@ -329,6 +342,8 @@ func (r *folderResource) Delete(ctx context.Context, req resource.DeleteRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
containerId := model.ContainerId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "container_id", containerId)
|
||||
|
||||
|
|
@ -344,6 +359,8 @@ func (r *folderResource) Delete(ctx context.Context, req resource.DeleteRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "Resource Manager folder deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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