parent
d1e12fcf64
commit
24b7387db9
140 changed files with 1597 additions and 7 deletions
15
.github/docs/contribution-guide/resource.go
vendored
15
.github/docs/contribution-guide/resource.go
vendored
|
|
@ -184,6 +184,9 @@ func (r *barResource) Create(ctx context.Context, req resource.CreateRequest, re
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := model.Region.ValueString() // not needed for global APIs
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -203,6 +206,8 @@ func (r *barResource) Create(ctx context.Context, req resource.CreateRequest, re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// only in case the create bar API call is asynchronous (Make sure to include *ALL* fields which are part of the
|
||||
// internal terraform resource id! And please include the comment below in your code):
|
||||
// Write id attributes to state before polling via the wait handler - just in case anything goes wrong during the wait handler
|
||||
|
|
@ -244,6 +249,9 @@ func (r *barResource) Read(ctx context.Context, req resource.ReadRequest, resp *
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
barId := model.BarId.ValueString()
|
||||
|
|
@ -257,6 +265,8 @@ func (r *barResource) Read(ctx context.Context, req resource.ReadRequest, resp *
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(barResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -285,6 +295,9 @@ func (r *barResource) Delete(ctx context.Context, req resource.DeleteRequest, re
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
barId := model.BarId.ValueString()
|
||||
|
|
@ -298,6 +311,8 @@ func (r *barResource) Delete(ctx context.Context, req resource.DeleteRequest, re
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting bar", fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// only in case the bar delete API endpoint is asynchronous: use a wait handler to wait for the delete operation to complete
|
||||
_, err = wait.DeleteBarWaitHandler(ctx, r.client, projectId, region, barId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -11,7 +11,7 @@ require (
|
|||
github.com/hashicorp/terraform-plugin-go v0.29.0
|
||||
github.com/hashicorp/terraform-plugin-log v0.10.0
|
||||
github.com/hashicorp/terraform-plugin-testing v1.13.3
|
||||
github.com/stackitcloud/stackit-sdk-go/core v0.19.0
|
||||
github.com/stackitcloud/stackit-sdk-go/core v0.20.0
|
||||
github.com/stackitcloud/stackit-sdk-go/services/cdn v1.6.0
|
||||
github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.1
|
||||
github.com/stackitcloud/stackit-sdk-go/services/git v0.8.0
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -152,8 +152,8 @@ github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN
|
|||
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
|
||||
github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8=
|
||||
github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY=
|
||||
github.com/stackitcloud/stackit-sdk-go/core v0.19.0 h1:dtJcs6/TTCzzb2RKI7HJugDrbCkaFEDmn1pOeFe8qnI=
|
||||
github.com/stackitcloud/stackit-sdk-go/core v0.19.0/go.mod h1:fqto7M82ynGhEnpZU6VkQKYWYoFG5goC076JWXTUPRQ=
|
||||
github.com/stackitcloud/stackit-sdk-go/core v0.20.0 h1:4rrUk6uT1g4nOn5/g1uXukP07Tux/o5xbMz/f/qE1rY=
|
||||
github.com/stackitcloud/stackit-sdk-go/core v0.20.0/go.mod h1:fqto7M82ynGhEnpZU6VkQKYWYoFG5goC076JWXTUPRQ=
|
||||
github.com/stackitcloud/stackit-sdk-go/services/authorization v0.9.0 h1:7ZKd3b+E/R4TEVShLTXxx5FrsuDuJBOyuVOuKTMa4mo=
|
||||
github.com/stackitcloud/stackit-sdk-go/services/authorization v0.9.0/go.mod h1:/FoXa6hF77Gv8brrvLBCKa5ie1Xy9xn39yfHwaln9Tw=
|
||||
github.com/stackitcloud/stackit-sdk-go/services/cdn v1.6.0 h1:Q+qIdejeMsYMkbtVoI9BpGlKGdSVFRBhH/zj44SP8TM=
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
"github.com/stackitcloud/stackit-sdk-go/core/runtime"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/diag"
|
||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
|
|
@ -102,12 +103,20 @@ func DiagsToError(diags diag.Diagnostics) error {
|
|||
|
||||
// LogAndAddError Logs the error and adds it to the diags
|
||||
func LogAndAddError(ctx context.Context, diags *diag.Diagnostics, summary, detail string) {
|
||||
if traceId := runtime.GetTraceId(ctx); traceId != "" {
|
||||
detail = fmt.Sprintf("%s\nTrace ID: %q", detail, traceId)
|
||||
}
|
||||
|
||||
tflog.Error(ctx, fmt.Sprintf("%s | %s", summary, detail))
|
||||
diags.AddError(summary, detail)
|
||||
}
|
||||
|
||||
// LogAndAddWarning Logs the warning and adds it to the diags
|
||||
func LogAndAddWarning(ctx context.Context, diags *diag.Diagnostics, summary, detail string) {
|
||||
if traceId := runtime.GetTraceId(ctx); traceId != "" {
|
||||
detail = fmt.Sprintf("%s\nTrace ID: %q", detail, traceId)
|
||||
}
|
||||
|
||||
tflog.Warn(ctx, fmt.Sprintf("%s | %s", summary, detail))
|
||||
diags.AddWarning(summary, detail)
|
||||
}
|
||||
|
|
@ -125,3 +134,22 @@ func LogAndAddErrorBeta(ctx context.Context, diags *diag.Diagnostics, name strin
|
|||
tflog.Error(ctx, fmt.Sprintf("%s | %s", errTitle, errContent))
|
||||
diags.AddError(errTitle, errContent)
|
||||
}
|
||||
|
||||
// InitProviderContext extends the context to capture the http response
|
||||
func InitProviderContext(ctx context.Context) context.Context {
|
||||
// Capture http response to get trace-id
|
||||
var httpResp *http.Response
|
||||
return runtime.WithCaptureHTTPResponse(ctx, &httpResp)
|
||||
}
|
||||
|
||||
// LogResponse logs the trace-id of the last request
|
||||
func LogResponse(ctx context.Context) context.Context {
|
||||
// Logs the trace-id of the request
|
||||
traceId := runtime.GetTraceId(ctx)
|
||||
ctx = tflog.SetField(ctx, "x-trace-id", traceId)
|
||||
|
||||
tflog.Info(ctx, "response data", map[string]interface{}{
|
||||
"x-trace-id": traceId,
|
||||
})
|
||||
return ctx
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,6 +152,8 @@ func (r *roleAssignmentResource) Create(ctx context.Context, req resource.Create
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = r.annotateLogger(ctx, &model)
|
||||
|
||||
if err := r.checkDuplicate(ctx, model); err != nil {
|
||||
|
|
@ -171,6 +173,8 @@ func (r *roleAssignmentResource) Create(ctx context.Context, req resource.Create
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapMembersResponse(createResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -194,6 +198,8 @@ func (r *roleAssignmentResource) Read(ctx context.Context, req resource.ReadRequ
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = r.annotateLogger(ctx, &model)
|
||||
|
||||
listResp, err := r.authorizationClient.ListMembers(ctx, r.apiName, model.ResourceId.ValueString()).Subject(model.Subject.ValueString()).Execute()
|
||||
|
|
@ -202,6 +208,8 @@ func (r *roleAssignmentResource) Read(ctx context.Context, req resource.ReadRequ
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapListMembersResponse(listResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -232,6 +240,8 @@ func (r *roleAssignmentResource) Delete(ctx context.Context, req resource.Delete
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = r.annotateLogger(ctx, &model)
|
||||
|
||||
payload := authorization.RemoveMembersPayload{
|
||||
|
|
@ -247,6 +257,8 @@ func (r *roleAssignmentResource) Delete(ctx context.Context, req resource.Delete
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, fmt.Sprintf("Error deleting %s role assignment", r.apiName), fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, fmt.Sprintf("%s role assignment deleted", r.apiName))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,6 +126,8 @@ func (r *customDomainDataSource) Read(ctx context.Context, req datasource.ReadRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
distributionId := model.DistributionId.ValueString()
|
||||
|
|
@ -146,6 +148,8 @@ func (r *customDomainDataSource) Read(ctx context.Context, req datasource.ReadRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Call the new data source mapping function
|
||||
err = mapCustomDomainDataSourceFields(customDomainResp, &model, projectId, distributionId)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -186,6 +186,9 @@ func (r *customDomainResource) 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)
|
||||
distributionId := model.DistributionId.ValueString()
|
||||
|
|
@ -207,6 +210,9 @@ func (r *customDomainResource) Create(ctx context.Context, req resource.CreateRe
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating CDN custom domain", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.CreateCDNCustomDomainWaitHandler(ctx, r.client, projectId, distributionId, name).SetTimeout(5 * time.Minute).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating CDN custom domain", fmt.Sprintf("Waiting for create: %v", err))
|
||||
|
|
@ -240,6 +246,8 @@ func (r *customDomainResource) Read(ctx context.Context, req resource.ReadReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
distributionId := model.DistributionId.ValueString()
|
||||
|
|
@ -248,7 +256,6 @@ func (r *customDomainResource) Read(ctx context.Context, req resource.ReadReques
|
|||
ctx = tflog.SetField(ctx, "name", name)
|
||||
|
||||
customDomainResp, err := r.client.GetCustomDomain(ctx, projectId, distributionId, name).Execute()
|
||||
|
||||
if err != nil {
|
||||
var oapiErr *oapierror.GenericOpenAPIError
|
||||
// n.b. err is caught here if of type *oapierror.GenericOpenAPIError, which the stackit SDK client returns
|
||||
|
|
@ -261,6 +268,9 @@ func (r *customDomainResource) Read(ctx context.Context, req resource.ReadReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading CDN custom domain", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapCustomDomainResourceFields(customDomainResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading CDN custom domain", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
@ -283,6 +293,8 @@ func (r *customDomainResource) Update(ctx context.Context, req resource.UpdateRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
distributionId := model.DistributionId.ValueString()
|
||||
|
|
@ -306,6 +318,8 @@ func (r *customDomainResource) Update(ctx context.Context, req resource.UpdateRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.CreateCDNCustomDomainWaitHandler(ctx, r.client, projectId, distributionId, name).SetTimeout(5 * time.Minute).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating CDN custom domain certificate", fmt.Sprintf("Waiting for update: %v", err))
|
||||
|
|
@ -338,6 +352,8 @@ func (r *customDomainResource) Delete(ctx context.Context, req resource.DeleteRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
distributionId := model.DistributionId.ValueString()
|
||||
|
|
@ -349,6 +365,9 @@ func (r *customDomainResource) Delete(ctx context.Context, req resource.DeleteRe
|
|||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Delete CDN custom domain", fmt.Sprintf("Delete custom domain: %v", err))
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteCDNCustomDomainWaitHandler(ctx, r.client, projectId, distributionId, name).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Delete CDN custom domain", fmt.Sprintf("Waiting for deletion: %v", err))
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -136,6 +136,9 @@ func (d *recordSetDataSource) Read(ctx context.Context, req datasource.ReadReque
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
zoneId := model.ZoneId.ValueString()
|
||||
recordSetId := model.RecordSetId.ValueString()
|
||||
|
|
@ -157,6 +160,9 @@ func (d *recordSetDataSource) Read(ctx context.Context, req datasource.ReadReque
|
|||
resp.State.RemoveResource(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if recordSetResp != nil && recordSetResp.Rrset.State != nil && *recordSetResp.Rrset.State == dns.RECORDSETSTATE_DELETE_SUCCEEDED {
|
||||
resp.State.RemoveResource(ctx)
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading record set", "Record set was deleted successfully")
|
||||
|
|
|
|||
|
|
@ -200,6 +200,8 @@ func (r *recordSetResource) Create(ctx context.Context, req resource.CreateReque
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
zoneId := model.ZoneId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -218,6 +220,8 @@ func (r *recordSetResource) Create(ctx context.Context, req resource.CreateReque
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Write id attributes to state before polling via the wait handler - just in case anything goes wrong during the wait handler
|
||||
utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{
|
||||
"project_id": projectId,
|
||||
|
|
@ -257,6 +261,9 @@ func (r *recordSetResource) Read(ctx context.Context, req resource.ReadRequest,
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
zoneId := model.ZoneId.ValueString()
|
||||
recordSetId := model.RecordSetId.ValueString()
|
||||
|
|
@ -274,6 +281,8 @@ func (r *recordSetResource) Read(ctx context.Context, req resource.ReadRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, recordSetResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -300,6 +309,8 @@ func (r *recordSetResource) Update(ctx context.Context, req resource.UpdateReque
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
zoneId := model.ZoneId.ValueString()
|
||||
recordSetId := model.RecordSetId.ValueString()
|
||||
|
|
@ -319,6 +330,9 @@ func (r *recordSetResource) Update(ctx context.Context, req resource.UpdateReque
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating record set", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
waitResp, err := wait.PartialUpdateRecordSetWaitHandler(ctx, r.client, projectId, zoneId, recordSetId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating record set", fmt.Sprintf("Instance update waiting: %v", err))
|
||||
|
|
@ -348,6 +362,8 @@ func (r *recordSetResource) Delete(ctx context.Context, req resource.DeleteReque
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
zoneId := model.ZoneId.ValueString()
|
||||
recordSetId := model.RecordSetId.ValueString()
|
||||
|
|
@ -360,6 +376,9 @@ func (r *recordSetResource) Delete(ctx context.Context, req resource.DeleteReque
|
|||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting record set", fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteRecordSetWaitHandler(ctx, r.client, projectId, zoneId, recordSetId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting record set", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -179,6 +179,9 @@ func (d *zoneDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
zoneId := model.ZoneId.ValueString()
|
||||
dnsName := model.DnsName.ValueString()
|
||||
|
|
@ -205,6 +208,8 @@ func (d *zoneDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
|
|||
resp.State.RemoveResource(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
} else {
|
||||
listZoneResp, err := d.client.ListZones(ctx, projectId).
|
||||
DnsNameEq(dnsName).
|
||||
|
|
@ -224,6 +229,9 @@ func (d *zoneDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
|
|||
resp.State.RemoveResource(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if *listZoneResp.TotalItems != 1 {
|
||||
utils.LogError(
|
||||
ctx,
|
||||
|
|
|
|||
|
|
@ -284,6 +284,8 @@ func (r *zoneResource) Create(ctx context.Context, req resource.CreateRequest, r
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
||||
|
|
@ -300,6 +302,8 @@ func (r *zoneResource) Create(ctx context.Context, req resource.CreateRequest, r
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Write id attributes to state before polling via the wait handler - just in case anything goes wrong during the wait handler
|
||||
zoneId := *createResp.Zone.Id
|
||||
utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]interface{}{
|
||||
|
|
@ -338,6 +342,9 @@ func (r *zoneResource) Read(ctx context.Context, req resource.ReadRequest, resp
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
zoneId := model.ZoneId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -348,6 +355,9 @@ func (r *zoneResource) Read(ctx context.Context, req resource.ReadRequest, resp
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading zone", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if zoneResp != nil && zoneResp.Zone.State != nil && *zoneResp.Zone.State == dns.ZONESTATE_DELETE_SUCCEEDED {
|
||||
resp.State.RemoveResource(ctx)
|
||||
return
|
||||
|
|
@ -377,6 +387,9 @@ func (r *zoneResource) Update(ctx context.Context, req resource.UpdateRequest, r
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
zoneId := model.ZoneId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -394,6 +407,9 @@ func (r *zoneResource) Update(ctx context.Context, req resource.UpdateRequest, r
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating zone", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
waitResp, err := wait.PartialUpdateZoneWaitHandler(ctx, r.client, projectId, zoneId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating zone", fmt.Sprintf("Zone update waiting: %v", err))
|
||||
|
|
@ -423,6 +439,8 @@ func (r *zoneResource) Delete(ctx context.Context, req resource.DeleteRequest, r
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
zoneId := model.ZoneId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -434,6 +452,9 @@ func (r *zoneResource) Delete(ctx context.Context, req resource.DeleteRequest, r
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting zone", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteZoneWaitHandler(ctx, r.client, projectId, zoneId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting zone", fmt.Sprintf("Zone deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -132,6 +132,8 @@ func (g *gitDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
// Extract the project ID and instance id of the model
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
|
|
@ -149,6 +151,8 @@ func (g *gitDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, gitInstanceResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading git instance", fmt.Sprintf("Processing API response: %v", err))
|
||||
|
|
|
|||
|
|
@ -195,6 +195,8 @@ func (g *gitResource) Create(ctx context.Context, req resource.CreateRequest, re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
// Set logging context with the project ID and instance ID.
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceName := model.Name.ValueString()
|
||||
|
|
@ -216,6 +218,8 @@ func (g *gitResource) Create(ctx context.Context, req resource.CreateRequest, re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
gitInstanceId := *gitInstanceResp.Id
|
||||
_, err = wait.CreateGitInstanceWaitHandler(ctx, g.client, projectId, gitInstanceId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
|
|
@ -248,6 +252,8 @@ func (g *gitResource) Read(ctx context.Context, req resource.ReadRequest, resp *
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
// Extract the project ID and instance id of the model
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
|
|
@ -265,6 +271,8 @@ func (g *gitResource) Read(ctx context.Context, req resource.ReadRequest, resp *
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, gitInstanceResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading git instance", fmt.Sprintf("Processing API response: %v", err))
|
||||
|
|
@ -298,6 +306,8 @@ func (g *gitResource) Delete(ctx context.Context, req resource.DeleteRequest, re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -310,6 +320,8 @@ func (g *gitResource) Delete(ctx context.Context, req resource.DeleteRequest, re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteGitInstanceWaitHandler(ctx, g.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error waiting for instance deletion", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -118,6 +118,9 @@ func (d *affinityGroupDatasource) Read(ctx context.Context, req datasource.ReadR
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
affinityGroupId := model.AffinityGroupId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "affinity_group_id", affinityGroupId)
|
||||
|
||||
|
|
@ -137,6 +140,8 @@ func (d *affinityGroupDatasource) Read(ctx context.Context, req datasource.ReadR
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, affinityGroupResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading affinity group", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -154,6 +154,9 @@ func (r *affinityGroupResource) Create(ctx context.Context, req resource.CreateR
|
|||
return
|
||||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
||||
// Create new affinityGroup
|
||||
|
|
@ -167,6 +170,9 @@ func (r *affinityGroupResource) Create(ctx context.Context, req resource.CreateR
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating affinity group", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "affinity_group_id", affinityGroupResp.Id)
|
||||
|
||||
// Map response body to schema
|
||||
|
|
@ -194,6 +200,9 @@ func (r *affinityGroupResource) Read(ctx context.Context, req resource.ReadReque
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
affinityGroupId := model.AffinityGroupId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "affinity_group_id", affinityGroupId)
|
||||
|
||||
|
|
@ -208,6 +217,8 @@ func (r *affinityGroupResource) Read(ctx context.Context, req resource.ReadReque
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, affinityGroupResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading affinity group", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
@ -237,6 +248,9 @@ func (r *affinityGroupResource) Delete(ctx context.Context, req resource.DeleteR
|
|||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
affinityGroupId := model.AffinityGroupId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "affinity_group_id", affinityGroupId)
|
||||
|
||||
|
|
@ -247,6 +261,8 @@ func (r *affinityGroupResource) Delete(ctx context.Context, req resource.DeleteR
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "Affinity group deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -213,6 +213,9 @@ func (r *imageDataSource) Read(ctx context.Context, req datasource.ReadRequest,
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
imageId := model.ImageId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "image_id", imageId)
|
||||
|
||||
|
|
@ -232,6 +235,8 @@ func (r *imageDataSource) Read(ctx context.Context, req datasource.ReadRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapDataSourceFields(ctx, imageResp, &model)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -378,6 +378,9 @@ func (r *imageResource) Create(ctx context.Context, req resource.CreateRequest,
|
|||
}
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
||||
// Generate API request body from model
|
||||
|
|
@ -393,6 +396,9 @@ func (r *imageResource) Create(ctx context.Context, req resource.CreateRequest,
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating image", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "image_id", *imageCreateResp.Id)
|
||||
|
||||
// Get the image object, as the create response does not contain all fields
|
||||
|
|
@ -458,6 +464,9 @@ func (r *imageResource) Read(ctx context.Context, req resource.ReadRequest, resp
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
imageId := model.ImageId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "image_id", imageId)
|
||||
|
||||
|
|
@ -472,6 +481,8 @@ func (r *imageResource) Read(ctx context.Context, req resource.ReadRequest, resp
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, imageResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -498,6 +509,9 @@ func (r *imageResource) Update(ctx context.Context, req resource.UpdateRequest,
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
imageId := model.ImageId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "image_id", imageId)
|
||||
|
||||
|
|
@ -522,6 +536,8 @@ func (r *imageResource) Update(ctx context.Context, req resource.UpdateRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, updatedImage, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating image", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
@ -547,6 +563,9 @@ func (r *imageResource) Delete(ctx context.Context, req resource.DeleteRequest,
|
|||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
imageId := model.ImageId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "image_id", imageId)
|
||||
|
||||
|
|
@ -556,6 +575,9 @@ func (r *imageResource) Delete(ctx context.Context, req resource.DeleteRequest,
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting image", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteImageWaitHandler(ctx, r.client, projectId, imageId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting image", fmt.Sprintf("image deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -370,6 +370,8 @@ func (d *imageDataV2Source) Read(ctx context.Context, req datasource.ReadRequest
|
|||
}
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectID)
|
||||
ctx = tflog.SetField(ctx, "image_id", imageID)
|
||||
ctx = tflog.SetField(ctx, "name", name)
|
||||
|
|
@ -391,6 +393,8 @@ func (d *imageDataV2Source) Read(ctx context.Context, req datasource.ReadRequest
|
|||
resp.State.RemoveResource(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
} else {
|
||||
// Case 2: Lookup by name or name_regex
|
||||
|
||||
|
|
@ -411,6 +415,8 @@ func (d *imageDataV2Source) Read(ctx context.Context, req datasource.ReadRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Step 1: Match images by name or regular expression (name or name_regex, if provided)
|
||||
var matchedImages []*iaas.Image
|
||||
for i := range *imageList.Items {
|
||||
|
|
|
|||
|
|
@ -92,6 +92,9 @@ func (r *keyPairDataSource) Read(ctx context.Context, req datasource.ReadRequest
|
|||
return
|
||||
}
|
||||
name := model.Name.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "name", name)
|
||||
|
||||
keypairResp, err := r.client.GetKeyPair(ctx, name).Execute()
|
||||
|
|
@ -108,6 +111,8 @@ func (r *keyPairDataSource) Read(ctx context.Context, req datasource.ReadRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, keypairResp, &model)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -146,6 +146,9 @@ func (r *keyPairResource) Create(ctx context.Context, req resource.CreateRequest
|
|||
}
|
||||
|
||||
name := model.Name.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "name", name)
|
||||
|
||||
// Generate API request body from model
|
||||
|
|
@ -163,6 +166,8 @@ func (r *keyPairResource) Create(ctx context.Context, req resource.CreateRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, keyPair, &model)
|
||||
if err != nil {
|
||||
|
|
@ -187,6 +192,9 @@ func (r *keyPairResource) Read(ctx context.Context, req resource.ReadRequest, re
|
|||
return
|
||||
}
|
||||
name := model.Name.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "name", name)
|
||||
|
||||
keyPairResp, err := r.client.GetKeyPair(ctx, name).Execute()
|
||||
|
|
@ -200,6 +208,8 @@ func (r *keyPairResource) Read(ctx context.Context, req resource.ReadRequest, re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, keyPairResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -225,6 +235,9 @@ func (r *keyPairResource) Update(ctx context.Context, req resource.UpdateRequest
|
|||
return
|
||||
}
|
||||
name := model.Name.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "name", name)
|
||||
|
||||
// Retrieve values from state
|
||||
|
|
@ -248,6 +261,8 @@ func (r *keyPairResource) Update(ctx context.Context, req resource.UpdateRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, updatedKeyPair, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating key pair", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
@ -272,6 +287,9 @@ func (r *keyPairResource) Delete(ctx context.Context, req resource.DeleteRequest
|
|||
}
|
||||
|
||||
name := model.Name.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "name", name)
|
||||
|
||||
// Delete existing key pair
|
||||
|
|
@ -281,6 +299,8 @@ func (r *keyPairResource) Delete(ctx context.Context, req resource.DeleteRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "Key pair deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -144,6 +144,8 @@ func (d *machineTypeDataSource) Read(ctx context.Context, req datasource.ReadReq
|
|||
projectId := model.ProjectId.ValueString()
|
||||
sortAscending := model.SortAscending.ValueBool()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "filter_is_null", model.Filter.IsNull())
|
||||
ctx = tflog.SetField(ctx, "filter_is_unknown", model.Filter.IsUnknown())
|
||||
|
|
@ -166,6 +168,8 @@ func (d *machineTypeDataSource) Read(ctx context.Context, req datasource.ReadReq
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if apiResp.Items == nil || len(*apiResp.Items) == 0 {
|
||||
core.LogAndAddWarning(ctx, &resp.Diagnostics, "No machine types found", "No matching machine types.")
|
||||
return
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ func DatasourceRead(ctx context.Context, req datasource.ReadRequest, resp *datas
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
networkId := model.NetworkId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -44,6 +47,8 @@ func DatasourceRead(ctx context.Context, req datasource.ReadRequest, resp *datas
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapDataSourceFields(ctx, networkResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading network", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ func Create(ctx context.Context, req resource.CreateRequest, resp *resource.Crea
|
|||
}
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
||||
// Generate API request body from model
|
||||
|
|
@ -49,6 +52,8 @@ func Create(ctx context.Context, req resource.CreateRequest, resp *resource.Crea
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
networkId := *network.NetworkId
|
||||
network, err = wait.CreateNetworkWaitHandler(ctx, client, projectId, networkId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
|
|
@ -82,6 +87,9 @@ func Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResp
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
networkId := model.NetworkId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "network_id", networkId)
|
||||
|
||||
|
|
@ -96,6 +104,8 @@ func Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResp
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, networkResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -121,6 +131,9 @@ func Update(ctx context.Context, req resource.UpdateRequest, resp *resource.Upda
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
networkId := model.NetworkId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "network_id", networkId)
|
||||
|
||||
|
|
@ -144,6 +157,9 @@ func Update(ctx context.Context, req resource.UpdateRequest, resp *resource.Upda
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating network", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
waitResp, err := wait.UpdateNetworkWaitHandler(ctx, client, projectId, networkId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating network", fmt.Sprintf("Network update waiting: %v", err))
|
||||
|
|
@ -174,6 +190,9 @@ func Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.Dele
|
|||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
networkId := model.NetworkId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "network_id", networkId)
|
||||
|
||||
|
|
@ -183,6 +202,9 @@ func Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.Dele
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting network", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteNetworkWaitHandler(ctx, client, projectId, networkId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting network", fmt.Sprintf("Network deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ func DatasourceRead(ctx context.Context, req datasource.ReadRequest, resp *datas
|
|||
projectId := model.ProjectId.ValueString()
|
||||
networkId := model.NetworkId.ValueString()
|
||||
region := providerData.GetRegionWithOverride(model.Region)
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "network_id", networkId)
|
||||
|
||||
|
|
@ -45,6 +48,8 @@ func DatasourceRead(ctx context.Context, req datasource.ReadRequest, resp *datas
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapDataSourceFields(ctx, networkResp, &model, region)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading network", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ func Create(ctx context.Context, req resource.CreateRequest, resp *resource.Crea
|
|||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "region", region)
|
||||
|
||||
|
|
@ -51,6 +54,8 @@ func Create(ctx context.Context, req resource.CreateRequest, resp *resource.Crea
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
networkId := *network.Id
|
||||
network, err = wait.CreateNetworkWaitHandler(ctx, client, projectId, region, networkId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
|
|
@ -85,6 +90,9 @@ func Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResp
|
|||
projectId := model.ProjectId.ValueString()
|
||||
networkId := model.NetworkId.ValueString()
|
||||
region := providerData.GetRegionWithOverride(model.Region)
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "network_id", networkId)
|
||||
ctx = tflog.SetField(ctx, "region", region)
|
||||
|
|
@ -100,6 +108,8 @@ func Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResp
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, networkResp, &model, region)
|
||||
if err != nil {
|
||||
|
|
@ -126,6 +136,9 @@ func Update(ctx context.Context, req resource.UpdateRequest, resp *resource.Upda
|
|||
projectId := model.ProjectId.ValueString()
|
||||
networkId := model.NetworkId.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "network_id", networkId)
|
||||
ctx = tflog.SetField(ctx, "region", region)
|
||||
|
|
@ -150,6 +163,9 @@ func Update(ctx context.Context, req resource.UpdateRequest, resp *resource.Upda
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating network", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
waitResp, err := wait.UpdateNetworkWaitHandler(ctx, client, projectId, region, networkId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating network", fmt.Sprintf("Network update waiting: %v", err))
|
||||
|
|
@ -181,6 +197,9 @@ func Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.Dele
|
|||
projectId := model.ProjectId.ValueString()
|
||||
networkId := model.NetworkId.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "network_id", networkId)
|
||||
ctx = tflog.SetField(ctx, "region", region)
|
||||
|
|
@ -191,6 +210,9 @@ func Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.Dele
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting network", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteNetworkWaitHandler(ctx, client, projectId, region, networkId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting network", fmt.Sprintf("Network deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -172,6 +172,9 @@ func (d *networkAreaDataSource) Read(ctx context.Context, req datasource.ReadReq
|
|||
}
|
||||
organizationId := model.OrganizationId.ValueString()
|
||||
networkAreaId := model.NetworkAreaId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "organization_id", organizationId)
|
||||
ctx = tflog.SetField(ctx, "network_area_id", networkAreaId)
|
||||
|
||||
|
|
@ -191,6 +194,8 @@ func (d *networkAreaDataSource) Read(ctx context.Context, req datasource.ReadReq
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
networkAreaRanges := networkAreaResp.Ipv4.NetworkRanges
|
||||
|
||||
err = mapFields(ctx, networkAreaResp, networkAreaRanges, &model)
|
||||
|
|
|
|||
|
|
@ -240,6 +240,9 @@ func (r *networkAreaResource) Create(ctx context.Context, req resource.CreateReq
|
|||
}
|
||||
|
||||
organizationId := model.OrganizationId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "organization_id", organizationId)
|
||||
|
||||
// Generate API request body from model
|
||||
|
|
@ -256,6 +259,8 @@ func (r *networkAreaResource) Create(ctx context.Context, req resource.CreateReq
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
networkArea, err := wait.CreateNetworkAreaWaitHandler(ctx, r.client, organizationId, *area.AreaId).WaitWithContext(context.Background())
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating network area", fmt.Sprintf("Network area creation waiting: %v", err))
|
||||
|
|
@ -291,6 +296,9 @@ func (r *networkAreaResource) Read(ctx context.Context, req resource.ReadRequest
|
|||
}
|
||||
organizationId := model.OrganizationId.ValueString()
|
||||
networkAreaId := model.NetworkAreaId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "organization_id", organizationId)
|
||||
ctx = tflog.SetField(ctx, "network_area_id", networkAreaId)
|
||||
|
||||
|
|
@ -305,6 +313,8 @@ func (r *networkAreaResource) Read(ctx context.Context, req resource.ReadRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
networkAreaRanges := networkAreaResp.Ipv4.NetworkRanges
|
||||
|
||||
// Map response body to schema
|
||||
|
|
@ -333,6 +343,9 @@ func (r *networkAreaResource) Update(ctx context.Context, req resource.UpdateReq
|
|||
}
|
||||
organizationId := model.OrganizationId.ValueString()
|
||||
networkAreaId := model.NetworkAreaId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "organization_id", organizationId)
|
||||
ctx = tflog.SetField(ctx, "network_area_id", networkAreaId)
|
||||
|
||||
|
|
@ -365,6 +378,9 @@ func (r *networkAreaResource) Update(ctx context.Context, req resource.UpdateReq
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating network area", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
waitResp, err := wait.UpdateNetworkAreaWaitHandler(ctx, r.client, organizationId, networkAreaId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating network area", fmt.Sprintf("Network area update waiting: %v", err))
|
||||
|
|
@ -416,6 +432,9 @@ func (r *networkAreaResource) Delete(ctx context.Context, req resource.DeleteReq
|
|||
|
||||
organizationId := model.OrganizationId.ValueString()
|
||||
networkAreaId := model.NetworkAreaId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "organization_id", organizationId)
|
||||
ctx = tflog.SetField(ctx, "network_area_id", networkAreaId)
|
||||
|
||||
|
|
@ -431,6 +450,9 @@ func (r *networkAreaResource) Delete(ctx context.Context, req resource.DeleteReq
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting network area", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteNetworkAreaWaitHandler(ctx, r.client, organizationId, networkAreaId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting network area", fmt.Sprintf("Network area deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -116,6 +116,9 @@ func (d *networkAreaRouteDataSource) Read(ctx context.Context, req datasource.Re
|
|||
organizationId := model.OrganizationId.ValueString()
|
||||
networkAreaId := model.NetworkAreaId.ValueString()
|
||||
networkAreaRouteId := model.NetworkAreaRouteId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "organization_id", organizationId)
|
||||
ctx = tflog.SetField(ctx, "network_area_id", networkAreaId)
|
||||
ctx = tflog.SetField(ctx, "network_area_route_id", networkAreaRouteId)
|
||||
|
|
@ -136,6 +139,8 @@ func (d *networkAreaRouteDataSource) Read(ctx context.Context, req datasource.Re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, networkAreaRouteResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading network area route", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -160,6 +160,8 @@ func (r *networkAreaRouteResource) Create(ctx context.Context, req resource.Crea
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
organizationId := model.OrganizationId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "organization_id", organizationId)
|
||||
networkAreaId := model.NetworkAreaId.ValueString()
|
||||
|
|
@ -178,6 +180,9 @@ func (r *networkAreaRouteResource) Create(ctx context.Context, req resource.Crea
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating network area route", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if routes.Items == nil || len(*routes.Items) == 0 {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating network area route.", "Empty response from API")
|
||||
return
|
||||
|
|
@ -221,6 +226,9 @@ func (r *networkAreaRouteResource) Read(ctx context.Context, req resource.ReadRe
|
|||
organizationId := model.OrganizationId.ValueString()
|
||||
networkAreaId := model.NetworkAreaId.ValueString()
|
||||
networkAreaRouteId := model.NetworkAreaRouteId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "organization_id", organizationId)
|
||||
ctx = tflog.SetField(ctx, "network_area_id", networkAreaId)
|
||||
ctx = tflog.SetField(ctx, "network_area_route_id", networkAreaRouteId)
|
||||
|
|
@ -236,6 +244,8 @@ func (r *networkAreaRouteResource) Read(ctx context.Context, req resource.ReadRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, networkAreaRouteResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -264,6 +274,9 @@ func (r *networkAreaRouteResource) Delete(ctx context.Context, req resource.Dele
|
|||
organizationId := model.OrganizationId.ValueString()
|
||||
networkAreaId := model.NetworkAreaId.ValueString()
|
||||
networkAreaRouteId := model.NetworkAreaRouteId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "organization_id", organizationId)
|
||||
ctx = tflog.SetField(ctx, "network_area_id", networkAreaId)
|
||||
ctx = tflog.SetField(ctx, "network_area_route_id", networkAreaRouteId)
|
||||
|
|
@ -275,6 +288,8 @@ func (r *networkAreaRouteResource) Delete(ctx context.Context, req resource.Dele
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "Network area route deleted")
|
||||
}
|
||||
|
||||
|
|
@ -291,6 +306,9 @@ func (r *networkAreaRouteResource) Update(ctx context.Context, req resource.Upda
|
|||
organizationId := model.OrganizationId.ValueString()
|
||||
networkAreaId := model.NetworkAreaId.ValueString()
|
||||
networkAreaRouteId := model.NetworkAreaRouteId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "organization_id", organizationId)
|
||||
ctx = tflog.SetField(ctx, "network_area_id", networkAreaId)
|
||||
ctx = tflog.SetField(ctx, "network_area_route_id", networkAreaRouteId)
|
||||
|
|
@ -316,6 +334,8 @@ func (r *networkAreaRouteResource) Update(ctx context.Context, req resource.Upda
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, networkAreaRouteResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating network area route", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -144,6 +144,9 @@ func (d *networkInterfaceDataSource) Read(ctx context.Context, req datasource.Re
|
|||
projectId := model.ProjectId.ValueString()
|
||||
networkId := model.NetworkId.ValueString()
|
||||
networkInterfaceId := model.NetworkInterfaceId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "network_id", networkId)
|
||||
ctx = tflog.SetField(ctx, "network_interface_id", networkInterfaceId)
|
||||
|
|
@ -164,6 +167,8 @@ func (d *networkInterfaceDataSource) Read(ctx context.Context, req datasource.Re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, networkInterfaceResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading network interface", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -257,6 +257,8 @@ func (r *networkInterfaceResource) Create(ctx context.Context, req resource.Crea
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
networkId := model.NetworkId.ValueString()
|
||||
|
|
@ -276,6 +278,8 @@ func (r *networkInterfaceResource) Create(ctx context.Context, req resource.Crea
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
networkInterfaceId := *networkInterface.Id
|
||||
|
||||
ctx = tflog.SetField(ctx, "network_interface_id", networkInterfaceId)
|
||||
|
|
@ -306,6 +310,9 @@ func (r *networkInterfaceResource) Read(ctx context.Context, req resource.ReadRe
|
|||
projectId := model.ProjectId.ValueString()
|
||||
networkId := model.NetworkId.ValueString()
|
||||
networkInterfaceId := model.NetworkInterfaceId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "network_id", networkId)
|
||||
ctx = tflog.SetField(ctx, "network_interface_id", networkInterfaceId)
|
||||
|
|
@ -321,6 +328,8 @@ func (r *networkInterfaceResource) Read(ctx context.Context, req resource.ReadRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, networkInterfaceResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -348,6 +357,9 @@ func (r *networkInterfaceResource) Update(ctx context.Context, req resource.Upda
|
|||
projectId := model.ProjectId.ValueString()
|
||||
networkId := model.NetworkId.ValueString()
|
||||
networkInterfaceId := model.NetworkInterfaceId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "network_id", networkId)
|
||||
ctx = tflog.SetField(ctx, "network_interface_id", networkInterfaceId)
|
||||
|
|
@ -373,6 +385,8 @@ func (r *networkInterfaceResource) Update(ctx context.Context, req resource.Upda
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, nicResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating network interface", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
@ -399,6 +413,9 @@ func (r *networkInterfaceResource) Delete(ctx context.Context, req resource.Dele
|
|||
projectId := model.ProjectId.ValueString()
|
||||
networkId := model.NetworkId.ValueString()
|
||||
networkInterfaceId := model.NetworkInterfaceId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "network_id", networkId)
|
||||
ctx = tflog.SetField(ctx, "network_interface_id", networkInterfaceId)
|
||||
|
|
@ -410,6 +427,8 @@ func (r *networkInterfaceResource) Delete(ctx context.Context, req resource.Dele
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "Network interface deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -130,6 +130,8 @@ func (r *networkInterfaceAttachResource) Create(ctx context.Context, req resourc
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
serverId := model.ServerId.ValueString()
|
||||
|
|
@ -144,6 +146,8 @@ func (r *networkInterfaceAttachResource) Create(ctx context.Context, req resourc
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
model.Id = utils.BuildInternalTerraformId(projectId, serverId, networkInterfaceId)
|
||||
|
||||
// Set state to fully populated data
|
||||
|
|
@ -163,6 +167,9 @@ func (r *networkInterfaceAttachResource) Read(ctx context.Context, req resource.
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
serverId := model.ServerId.ValueString()
|
||||
|
|
@ -181,6 +188,8 @@ func (r *networkInterfaceAttachResource) Read(ctx context.Context, req resource.
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if nics == nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading network interface attachment", "List of network interfaces attached to the server is nil")
|
||||
return
|
||||
|
|
@ -221,6 +230,8 @@ func (r *networkInterfaceAttachResource) Delete(ctx context.Context, req resourc
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
serverId := model.ServerId.ValueString()
|
||||
|
|
@ -235,6 +246,8 @@ func (r *networkInterfaceAttachResource) Delete(ctx context.Context, req resourc
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "Network interface attachment deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -123,6 +123,9 @@ func (d *projectDataSource) Read(ctx context.Context, req datasource.ReadRequest
|
|||
return
|
||||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
||||
projectResp, err := d.client.GetProjectDetailsExecute(ctx, projectId)
|
||||
|
|
@ -139,6 +142,8 @@ func (d *projectDataSource) Read(ctx context.Context, req datasource.ReadRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapDataSourceFields(projectResp, &model)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -111,6 +111,9 @@ func (d *publicIpDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
publicIpId := model.PublicIpId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "public_ip_id", publicIpId)
|
||||
|
||||
|
|
@ -130,6 +133,8 @@ func (d *publicIpDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, publicIpResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading public IP", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -145,6 +145,8 @@ func (r *publicIpResource) Create(ctx context.Context, req resource.CreateReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
||||
|
|
@ -163,6 +165,8 @@ func (r *publicIpResource) Create(ctx context.Context, req resource.CreateReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "public_ip_id", *publicIp.Id)
|
||||
|
||||
// Map response body to schema
|
||||
|
|
@ -190,6 +194,9 @@ func (r *publicIpResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
publicIpId := model.PublicIpId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "public_ip_id", publicIpId)
|
||||
|
||||
|
|
@ -204,6 +211,8 @@ func (r *publicIpResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, publicIpResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -230,6 +239,9 @@ func (r *publicIpResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
publicIpId := model.PublicIpId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "public_ip_id", publicIpId)
|
||||
|
||||
|
|
@ -254,6 +266,8 @@ func (r *publicIpResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, updatedPublicIp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating public IP", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
@ -279,6 +293,9 @@ func (r *publicIpResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
publicIpId := model.PublicIpId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "public_ip_id", publicIpId)
|
||||
|
||||
|
|
@ -289,6 +306,8 @@ func (r *publicIpResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "public IP deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -153,6 +153,9 @@ func (r *publicIpAssociateResource) Create(ctx context.Context, req resource.Cre
|
|||
projectId := model.ProjectId.ValueString()
|
||||
publicIpId := model.PublicIpId.ValueString()
|
||||
networkInterfaceId := model.NetworkInterfaceId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "public_ip_id", publicIpId)
|
||||
ctx = tflog.SetField(ctx, "network_interface_id", networkInterfaceId)
|
||||
|
|
@ -170,6 +173,8 @@ func (r *publicIpAssociateResource) Create(ctx context.Context, req resource.Cre
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(updatedPublicIp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error associating public IP to network interface", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
@ -194,6 +199,9 @@ func (r *publicIpAssociateResource) Read(ctx context.Context, req resource.ReadR
|
|||
projectId := model.ProjectId.ValueString()
|
||||
publicIpId := model.PublicIpId.ValueString()
|
||||
networkInterfaceId := model.NetworkInterfaceId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "public_ip_id", publicIpId)
|
||||
ctx = tflog.SetField(ctx, "network_interface_id", networkInterfaceId)
|
||||
|
|
@ -209,6 +217,8 @@ func (r *publicIpAssociateResource) Read(ctx context.Context, req resource.ReadR
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(publicIpResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -242,6 +252,9 @@ func (r *publicIpAssociateResource) Delete(ctx context.Context, req resource.Del
|
|||
projectId := model.ProjectId.ValueString()
|
||||
publicIpId := model.PublicIpId.ValueString()
|
||||
networkInterfaceId := model.NetworkInterfaceId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "public_ip_id", publicIpId)
|
||||
ctx = tflog.SetField(ctx, "network_interface_id", networkInterfaceId)
|
||||
|
|
@ -256,6 +269,8 @@ func (r *publicIpAssociateResource) Delete(ctx context.Context, req resource.Del
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "public IP association deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,6 +115,9 @@ func (d *publicIpRangesDataSource) Read(ctx context.Context, req datasource.Read
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
publicIpRangeResp, err := d.client.ListPublicIPRangesExecute(ctx)
|
||||
if err != nil {
|
||||
utils.LogError(
|
||||
|
|
@ -131,6 +134,8 @@ func (d *publicIpRangesDataSource) Read(ctx context.Context, req datasource.Read
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, publicIpRangeResp, &model)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -111,6 +111,9 @@ func (d *securityGroupDataSource) Read(ctx context.Context, req datasource.ReadR
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
securityGroupId := model.SecurityGroupId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "security_group_id", securityGroupId)
|
||||
|
||||
|
|
@ -130,6 +133,8 @@ func (d *securityGroupDataSource) Read(ctx context.Context, req datasource.ReadR
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, securityGroupResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading security group", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -162,6 +162,8 @@ func (r *securityGroupResource) Create(ctx context.Context, req resource.CreateR
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
||||
|
|
@ -180,6 +182,8 @@ func (r *securityGroupResource) Create(ctx context.Context, req resource.CreateR
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
securityGroupId := *securityGroup.Id
|
||||
|
||||
ctx = tflog.SetField(ctx, "security_group_id", securityGroupId)
|
||||
|
|
@ -209,6 +213,9 @@ func (r *securityGroupResource) Read(ctx context.Context, req resource.ReadReque
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
securityGroupId := model.SecurityGroupId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "security_id", securityGroupId)
|
||||
|
||||
|
|
@ -223,6 +230,8 @@ func (r *securityGroupResource) Read(ctx context.Context, req resource.ReadReque
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, securityGroupResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -249,6 +258,9 @@ func (r *securityGroupResource) Update(ctx context.Context, req resource.UpdateR
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
securityGroupId := model.SecurityGroupId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "security_group_id", securityGroupId)
|
||||
|
||||
|
|
@ -273,6 +285,8 @@ func (r *securityGroupResource) Update(ctx context.Context, req resource.UpdateR
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, updatedSecurityGroup, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating security group", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
@ -298,6 +312,9 @@ func (r *securityGroupResource) Delete(ctx context.Context, req resource.DeleteR
|
|||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
securityGroupId := model.SecurityGroupId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "security_group_id", securityGroupId)
|
||||
|
||||
|
|
@ -308,6 +325,8 @@ func (r *securityGroupResource) Delete(ctx context.Context, req resource.DeleteR
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "security group deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -166,6 +166,9 @@ func (d *securityGroupRuleDataSource) Read(ctx context.Context, req datasource.R
|
|||
projectId := model.ProjectId.ValueString()
|
||||
securityGroupId := model.SecurityGroupId.ValueString()
|
||||
securityGroupRuleId := model.SecurityGroupRuleId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "security_group_id", securityGroupId)
|
||||
ctx = tflog.SetField(ctx, "security_group_rule_id", securityGroupRuleId)
|
||||
|
|
@ -186,6 +189,8 @@ func (d *securityGroupRuleDataSource) Read(ctx context.Context, req datasource.R
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(securityGroupRuleResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading security group rule", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -389,6 +389,8 @@ func (r *securityGroupRuleResource) Create(ctx context.Context, req resource.Cre
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
securityGroupId := model.SecurityGroupId.ValueString()
|
||||
|
|
@ -438,6 +440,8 @@ func (r *securityGroupRuleResource) Create(ctx context.Context, req resource.Cre
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "security_group_rule_id", *securityGroupRule.Id)
|
||||
|
||||
// Map response body to schema
|
||||
|
|
@ -466,6 +470,9 @@ func (r *securityGroupRuleResource) Read(ctx context.Context, req resource.ReadR
|
|||
projectId := model.ProjectId.ValueString()
|
||||
securityGroupId := model.SecurityGroupId.ValueString()
|
||||
securityGroupRuleId := model.SecurityGroupRuleId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "security_group_id", securityGroupId)
|
||||
ctx = tflog.SetField(ctx, "security_group_rule_id", securityGroupRuleId)
|
||||
|
|
@ -481,6 +488,8 @@ func (r *securityGroupRuleResource) Read(ctx context.Context, req resource.ReadR
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(securityGroupRuleResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -515,6 +524,9 @@ func (r *securityGroupRuleResource) Delete(ctx context.Context, req resource.Del
|
|||
projectId := model.ProjectId.ValueString()
|
||||
securityGroupId := model.SecurityGroupId.ValueString()
|
||||
securityGroupRuleId := model.SecurityGroupRuleId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "security_group_id", securityGroupId)
|
||||
ctx = tflog.SetField(ctx, "security_group_rule_id", securityGroupRuleId)
|
||||
|
|
@ -526,6 +538,8 @@ func (r *securityGroupRuleResource) Delete(ctx context.Context, req resource.Del
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "security group rule deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -185,6 +185,9 @@ func (r *serverDataSource) Read(ctx context.Context, req datasource.ReadRequest,
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
serverId := model.ServerId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "server_id", serverId)
|
||||
|
||||
|
|
@ -206,6 +209,8 @@ func (r *serverDataSource) Read(ctx context.Context, req datasource.ReadRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapDataSourceFields(ctx, serverResp, &model)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -428,6 +428,9 @@ func (r *serverResource) Create(ctx context.Context, req resource.CreateRequest,
|
|||
}
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
||||
// Generate API request body from model
|
||||
|
|
@ -445,6 +448,8 @@ func (r *serverResource) Create(ctx context.Context, req resource.CreateRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
serverId := *server.Id
|
||||
_, err = wait.CreateServerWaitHandler(ctx, r.client, projectId, serverId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
|
|
@ -603,6 +608,9 @@ func (r *serverResource) Read(ctx context.Context, req resource.ReadRequest, res
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
serverId := model.ServerId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "server_id", serverId)
|
||||
|
||||
|
|
@ -619,6 +627,8 @@ func (r *serverResource) Read(ctx context.Context, req resource.ReadRequest, res
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, serverResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -682,6 +692,9 @@ func (r *serverResource) Update(ctx context.Context, req resource.UpdateRequest,
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
serverId := model.ServerId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "server_id", serverId)
|
||||
|
||||
|
|
@ -710,6 +723,8 @@ func (r *serverResource) Update(ctx context.Context, req resource.UpdateRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if err := updateServerStatus(ctx, r.client, server.Status, &model); err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating server", err.Error())
|
||||
return
|
||||
|
|
@ -726,6 +741,8 @@ func (r *serverResource) Update(ctx context.Context, req resource.UpdateRequest,
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating server", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
}
|
||||
|
||||
// Re-fetch the server data, to get the details values.
|
||||
|
|
@ -763,6 +780,9 @@ func (r *serverResource) Delete(ctx context.Context, req resource.DeleteRequest,
|
|||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
serverId := model.ServerId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "server_id", serverId)
|
||||
|
||||
|
|
@ -772,6 +792,9 @@ func (r *serverResource) Delete(ctx context.Context, req resource.DeleteRequest,
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting server", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteServerWaitHandler(ctx, r.client, projectId, serverId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting server", fmt.Sprintf("server deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -126,6 +126,8 @@ func (r *networkInterfaceAttachResource) Create(ctx context.Context, req resourc
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
serverId := model.ServerId.ValueString()
|
||||
|
|
@ -140,6 +142,8 @@ func (r *networkInterfaceAttachResource) Create(ctx context.Context, req resourc
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
model.Id = utils.BuildInternalTerraformId(projectId, serverId, serviceAccountEmail)
|
||||
|
||||
// Set state to fully populated data
|
||||
|
|
@ -159,6 +163,9 @@ func (r *networkInterfaceAttachResource) Read(ctx context.Context, req resource.
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
serverId := model.ServerId.ValueString()
|
||||
|
|
@ -177,6 +184,8 @@ func (r *networkInterfaceAttachResource) Read(ctx context.Context, req resource.
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if serviceAccounts == nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading service account attachment", "List of service accounts attached to the server is nil")
|
||||
return
|
||||
|
|
@ -217,6 +226,8 @@ func (r *networkInterfaceAttachResource) Delete(ctx context.Context, req resourc
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
serverId := model.ServerId.ValueString()
|
||||
|
|
@ -231,6 +242,8 @@ func (r *networkInterfaceAttachResource) Delete(ctx context.Context, req resourc
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "Service account attachment deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -141,6 +141,9 @@ func (d *volumeDataSource) Read(ctx context.Context, req datasource.ReadRequest,
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
volumeId := model.VolumeId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "volume_id", volumeId)
|
||||
|
||||
|
|
@ -160,6 +163,8 @@ func (d *volumeDataSource) Read(ctx context.Context, req datasource.ReadRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, volumeResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading volume", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -287,6 +287,8 @@ func (r *volumeResource) Create(ctx context.Context, req resource.CreateRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
||||
|
|
@ -314,6 +316,8 @@ func (r *volumeResource) Create(ctx context.Context, req resource.CreateRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
volumeId := *volume.Id
|
||||
volume, err = wait.CreateVolumeWaitHandler(ctx, r.client, projectId, volumeId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
|
|
@ -348,6 +352,9 @@ func (r *volumeResource) Read(ctx context.Context, req resource.ReadRequest, res
|
|||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
volumeId := model.VolumeId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "volume_id", volumeId)
|
||||
|
||||
|
|
@ -362,6 +369,8 @@ func (r *volumeResource) Read(ctx context.Context, req resource.ReadRequest, res
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, volumeResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -386,6 +395,9 @@ func (r *volumeResource) Update(ctx context.Context, req resource.UpdateRequest,
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
volumeId := model.VolumeId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -412,6 +424,8 @@ func (r *volumeResource) Update(ctx context.Context, req resource.UpdateRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Resize existing volume
|
||||
modelSize := conversion.Int64ValueToPointer(model.Size)
|
||||
if modelSize != nil && updatedVolume.Size != nil {
|
||||
|
|
@ -455,6 +469,9 @@ func (r *volumeResource) Delete(ctx context.Context, req resource.DeleteRequest,
|
|||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
volumeId := model.VolumeId.ValueString()
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "volume_id", volumeId)
|
||||
|
||||
|
|
@ -464,6 +481,9 @@ func (r *volumeResource) Delete(ctx context.Context, req resource.DeleteRequest,
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting volume", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteVolumeWaitHandler(ctx, r.client, projectId, volumeId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting volume", fmt.Sprintf("volume deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -132,6 +132,8 @@ func (r *volumeAttachResource) Create(ctx context.Context, req resource.CreateRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
serverId := model.ServerId.ValueString()
|
||||
|
|
@ -150,6 +152,8 @@ func (r *volumeAttachResource) Create(ctx context.Context, req resource.CreateRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.AddVolumeToServerWaitHandler(ctx, r.client, projectId, serverId, volumeId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error attaching volume to server", fmt.Sprintf("volume attachment waiting: %v", err))
|
||||
|
|
@ -175,6 +179,9 @@ func (r *volumeAttachResource) Read(ctx context.Context, req resource.ReadReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
serverId := model.ServerId.ValueString()
|
||||
|
|
@ -193,6 +200,8 @@ func (r *volumeAttachResource) Read(ctx context.Context, req resource.ReadReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Set refreshed state
|
||||
diags = resp.State.Set(ctx, model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -217,6 +226,8 @@ func (r *volumeAttachResource) Delete(ctx context.Context, req resource.DeleteRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
serverId := model.ServerId.ValueString()
|
||||
|
|
@ -231,6 +242,8 @@ func (r *volumeAttachResource) Delete(ctx context.Context, req resource.DeleteRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.RemoveVolumeFromServerWaitHandler(ctx, r.client, projectId, serverId, volumeId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error removing volume from server", fmt.Sprintf("volume removal waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -78,6 +78,8 @@ func (d *routingTableRouteDataSource) Read(ctx context.Context, req datasource.R
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
organizationId := model.OrganizationId.ValueString()
|
||||
region := d.providerData.GetRegionWithOverride(model.Region)
|
||||
routingTableId := model.RoutingTableId.ValueString()
|
||||
|
|
@ -106,6 +108,8 @@ func (d *routingTableRouteDataSource) Read(ctx context.Context, req datasource.R
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = shared.MapRouteModel(ctx, routeResp, &model, region)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading routing table route", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -237,6 +237,8 @@ func (r *routeResource) Create(ctx context.Context, req resource.CreateRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
organizationId := model.OrganizationId.ValueString()
|
||||
routingTableId := model.RoutingTableId.ValueString()
|
||||
networkAreaId := model.NetworkAreaId.ValueString()
|
||||
|
|
@ -260,6 +262,8 @@ func (r *routeResource) Create(ctx context.Context, req resource.CreateRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFieldsFromList(ctx, routeResp, &model, region)
|
||||
if err != nil {
|
||||
|
|
@ -284,6 +288,9 @@ func (r *routeResource) Read(ctx context.Context, req resource.ReadRequest, resp
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
organizationId := model.OrganizationId.ValueString()
|
||||
routingTableId := model.RoutingTableId.ValueString()
|
||||
networkAreaId := model.NetworkAreaId.ValueString()
|
||||
|
|
@ -302,6 +309,8 @@ func (r *routeResource) Read(ctx context.Context, req resource.ReadRequest, resp
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = shared.MapRouteModel(ctx, routeResp, &model, region)
|
||||
if err != nil {
|
||||
|
|
@ -328,6 +337,8 @@ func (r *routeResource) Update(ctx context.Context, req resource.UpdateRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
organizationId := model.OrganizationId.ValueString()
|
||||
routingTableId := model.RoutingTableId.ValueString()
|
||||
networkAreaId := model.NetworkAreaId.ValueString()
|
||||
|
|
@ -361,6 +372,8 @@ func (r *routeResource) Update(ctx context.Context, req resource.UpdateRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = shared.MapRouteModel(ctx, route, &model, region)
|
||||
if err != nil {
|
||||
|
|
@ -385,6 +398,8 @@ func (r *routeResource) Delete(ctx context.Context, req resource.DeleteRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
organizationId := model.OrganizationId.ValueString()
|
||||
routingTableId := model.RoutingTableId.ValueString()
|
||||
networkAreaId := model.NetworkAreaId.ValueString()
|
||||
|
|
@ -403,6 +418,8 @@ func (r *routeResource) Delete(ctx context.Context, req resource.DeleteRequest,
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error routing table route", fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "Routing table route deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,6 +89,8 @@ func (d *routingTableRoutesDataSource) Read(ctx context.Context, req datasource.
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
organizationId := model.OrganizationId.ValueString()
|
||||
region := d.providerData.GetRegionWithOverride(model.Region)
|
||||
networkAreaId := model.NetworkAreaId.ValueString()
|
||||
|
|
@ -114,6 +116,8 @@ func (d *routingTableRoutesDataSource) Read(ctx context.Context, req datasource.
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapDataSourceRoutingTableRoutes(ctx, routesResp, &model, region)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading routing table routes", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -81,6 +81,8 @@ func (d *routingTableDataSource) Read(ctx context.Context, req datasource.ReadRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
organizationId := model.OrganizationId.ValueString()
|
||||
region := d.providerData.GetRegionWithOverride(model.Region)
|
||||
routingTableId := model.RoutingTableId.ValueString()
|
||||
|
|
@ -106,6 +108,8 @@ func (d *routingTableDataSource) Read(ctx context.Context, req datasource.ReadRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapDatasourceFields(ctx, routingTableResp, &model, region)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading routing table", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -228,6 +228,8 @@ func (r *routingTableResource) Create(ctx context.Context, req resource.CreateRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
organizationId := model.OrganizationId.ValueString()
|
||||
networkAreaId := model.NetworkAreaId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -249,6 +251,8 @@ func (r *routingTableResource) Create(ctx context.Context, req resource.CreateRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, routingTable, &model, region)
|
||||
if err != nil {
|
||||
|
|
@ -273,6 +277,8 @@ func (r *routingTableResource) Read(ctx context.Context, req resource.ReadReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
organizationId := model.OrganizationId.ValueString()
|
||||
routingTableId := model.RoutingTableId.ValueString()
|
||||
networkAreaId := model.NetworkAreaId.ValueString()
|
||||
|
|
@ -299,6 +305,8 @@ func (r *routingTableResource) Read(ctx context.Context, req resource.ReadReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, routingTableResp, &model, region)
|
||||
if err != nil {
|
||||
|
|
@ -324,6 +332,8 @@ func (r *routingTableResource) Update(ctx context.Context, req resource.UpdateRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
organizationId := model.OrganizationId.ValueString()
|
||||
routingTableId := model.RoutingTableId.ValueString()
|
||||
networkAreaId := model.NetworkAreaId.ValueString()
|
||||
|
|
@ -355,6 +365,8 @@ func (r *routingTableResource) Update(ctx context.Context, req resource.UpdateRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, routingTable, &model, region)
|
||||
if err != nil {
|
||||
|
|
@ -380,6 +392,8 @@ func (r *routingTableResource) Delete(ctx context.Context, req resource.DeleteRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
organizationId := model.OrganizationId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
routingTableId := model.RoutingTableId.ValueString()
|
||||
|
|
@ -396,6 +410,8 @@ func (r *routingTableResource) Delete(ctx context.Context, req resource.DeleteRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "Routing table deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -123,6 +123,8 @@ func (d *routingTablesDataSource) Read(ctx context.Context, req datasource.ReadR
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
organizationId := model.OrganizationId.ValueString()
|
||||
region := d.providerData.GetRegionWithOverride(model.Region)
|
||||
networkAreaId := model.NetworkAreaId.ValueString()
|
||||
|
|
@ -146,6 +148,8 @@ func (d *routingTablesDataSource) Read(ctx context.Context, req datasource.ReadR
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapDataSourceRoutingTables(ctx, routingTablesResp, &model, region)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading routing table", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -147,6 +147,8 @@ func (k *keyDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
keyRingId := model.KeyRingId.ValueString()
|
||||
region := k.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -173,6 +175,8 @@ func (k *keyDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(keyResponse, &model, region)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading key", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -243,6 +243,8 @@ func (r *keyResource) Create(ctx context.Context, req resource.CreateRequest, re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
keyRingId := model.KeyRingId.ValueString()
|
||||
|
|
@ -263,6 +265,8 @@ func (r *keyResource) Create(ctx context.Context, req resource.CreateRequest, re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if createResponse == nil || createResponse.Id == nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating key", "API returned empty response")
|
||||
return
|
||||
|
|
@ -305,6 +309,8 @@ func (r *keyResource) Read(ctx context.Context, req resource.ReadRequest, resp *
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
keyRingId := model.KeyRingId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -327,6 +333,8 @@ func (r *keyResource) Read(ctx context.Context, req resource.ReadRequest, resp *
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(keyResponse, &model, region)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading key", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
@ -353,6 +361,8 @@ func (r *keyResource) Delete(ctx context.Context, req resource.DeleteRequest, re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
keyRingId := model.KeyRingId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -363,6 +373,8 @@ func (r *keyResource) Delete(ctx context.Context, req resource.DeleteRequest, re
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting key", fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// The keys can't be deleted instantly by Terraform, they can only be scheduled for deletion via the API.
|
||||
core.LogAndAddWarning(ctx, &resp.Diagnostics, "Key scheduled for deletion on API side", deletionWarning)
|
||||
|
||||
|
|
|
|||
|
|
@ -100,6 +100,9 @@ func (k *keyRingDataSource) Read(ctx context.Context, request datasource.ReadReq
|
|||
if response.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
keyRingId := model.KeyRingId.ValueString()
|
||||
region := k.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -124,6 +127,8 @@ func (k *keyRingDataSource) Read(ctx context.Context, request datasource.ReadReq
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(keyRingResponse, &model, region)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &response.Diagnostics, "Error reading keyring", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -178,6 +178,8 @@ func (r *keyRingResource) Create(ctx context.Context, req resource.CreateRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
||||
|
|
@ -195,6 +197,8 @@ func (r *keyRingResource) Create(ctx context.Context, req resource.CreateRequest
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if createResponse == nil || createResponse.Id == nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating keyring", "API returned empty response")
|
||||
return
|
||||
|
|
@ -236,6 +240,8 @@ func (r *keyRingResource) Read(ctx context.Context, req resource.ReadRequest, re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
keyRingId := model.KeyRingId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -256,6 +262,8 @@ func (r *keyRingResource) Read(ctx context.Context, req resource.ReadRequest, re
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(keyRingResponse, &model, region)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading keyring", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -135,6 +135,8 @@ func (w *wrappingKeyDataSource) Read(ctx context.Context, request datasource.Rea
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
keyRingId := model.KeyRingId.ValueString()
|
||||
region := w.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -161,6 +163,8 @@ func (w *wrappingKeyDataSource) Read(ctx context.Context, request datasource.Rea
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(wrappingKeyResponse, &model, region)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &response.Diagnostics, "Error reading wrapping key", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -248,6 +248,8 @@ func (r *wrappingKeyResource) Create(ctx context.Context, req resource.CreateReq
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
keyRingId := model.KeyRingId.ValueString()
|
||||
|
|
@ -268,6 +270,8 @@ func (r *wrappingKeyResource) Create(ctx context.Context, req resource.CreateReq
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if createWrappingKeyResp == nil || createWrappingKeyResp.Id == nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating wrapping key", "API returned empty response")
|
||||
return
|
||||
|
|
@ -311,6 +315,8 @@ func (r *wrappingKeyResource) Read(ctx context.Context, request resource.ReadReq
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
keyRingId := model.KeyRingId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -333,6 +339,8 @@ func (r *wrappingKeyResource) Read(ctx context.Context, request resource.ReadReq
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(wrappingKeyResponse, &model, region)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &response.Diagnostics, "Error reading wrapping key", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
@ -359,6 +367,8 @@ func (r *wrappingKeyResource) Delete(ctx context.Context, request resource.Delet
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
keyRingId := model.KeyRingId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -369,6 +379,8 @@ func (r *wrappingKeyResource) Delete(ctx context.Context, request resource.Delet
|
|||
core.LogAndAddError(ctx, &response.Diagnostics, "Error deleting wrapping key", fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "wrapping key deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -385,6 +385,9 @@ func (r *loadBalancerDataSource) Read(ctx context.Context, req datasource.ReadRe
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
name := model.Name.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -408,6 +411,8 @@ func (r *loadBalancerDataSource) Read(ctx context.Context, req datasource.ReadRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, lbResp, &model, region)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
|
||||
|
||||
loadbalancerUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/loadbalancer/utils"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
|
@ -750,6 +749,9 @@ func (r *loadBalancerResource) Create(ctx context.Context, req resource.CreateRe
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -769,6 +771,8 @@ func (r *loadBalancerResource) Create(ctx context.Context, req resource.CreateRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
waitResp, err := wait.CreateLoadBalancerWaitHandler(ctx, r.client, projectId, region, *createResp.Name).SetTimeout(90 * time.Minute).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating load balancer", fmt.Sprintf("Load balancer creation waiting: %v", err))
|
||||
|
|
@ -800,6 +804,9 @@ func (r *loadBalancerResource) Read(ctx context.Context, req resource.ReadReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
name := model.Name.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -819,6 +826,8 @@ func (r *loadBalancerResource) Read(ctx context.Context, req resource.ReadReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, lbResp, &model, region)
|
||||
if err != nil {
|
||||
|
|
@ -844,6 +853,9 @@ func (r *loadBalancerResource) Update(ctx context.Context, req resource.UpdateRe
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
name := model.Name.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
|
|
@ -875,6 +887,8 @@ func (r *loadBalancerResource) Update(ctx context.Context, req resource.UpdateRe
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating load balancer", fmt.Sprintf("Calling API for target pool: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
}
|
||||
ctx = tflog.SetField(ctx, "target_pool_name", nil)
|
||||
|
||||
|
|
@ -910,6 +924,9 @@ func (r *loadBalancerResource) Delete(ctx context.Context, req resource.DeleteRe
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
name := model.Name.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
|
|
@ -924,6 +941,8 @@ func (r *loadBalancerResource) Delete(ctx context.Context, req resource.DeleteRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteLoadBalancerWaitHandler(ctx, r.client, projectId, region, name).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting load balancer", fmt.Sprintf("Load balancer deleting waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -188,6 +188,9 @@ func (r *observabilityCredentialResource) Create(ctx context.Context, req resour
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -206,6 +209,9 @@ func (r *observabilityCredentialResource) Create(ctx context.Context, req resour
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating observability credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
ctx = tflog.SetField(ctx, "credentials_ref", createResp.Credential.CredentialsRef)
|
||||
|
||||
// Map response body to schema
|
||||
|
|
@ -233,6 +239,9 @@ func (r *observabilityCredentialResource) Read(ctx context.Context, req resource
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
credentialsRef := model.CredentialsRef.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -252,6 +261,8 @@ func (r *observabilityCredentialResource) Read(ctx context.Context, req resource
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(credResp.Credential, &model, region)
|
||||
if err != nil {
|
||||
|
|
@ -281,6 +292,9 @@ func (r *observabilityCredentialResource) Delete(ctx context.Context, req resour
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
credentialsRef := model.CredentialsRef.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
|
|
@ -295,6 +309,8 @@ func (r *observabilityCredentialResource) Delete(ctx context.Context, req resour
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "Load balancer observability credential deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -124,6 +124,9 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
credentialId := model.CredentialId.ValueString()
|
||||
|
|
@ -147,6 +150,8 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(recordSetResp, &model)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -160,6 +160,9 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -171,6 +174,9 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if credentialsResp.Id == nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", "Got empty credential id")
|
||||
return
|
||||
|
|
@ -206,6 +212,9 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest,
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
credentialId := model.CredentialId.ValueString()
|
||||
|
|
@ -224,6 +233,8 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(recordSetResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -255,6 +266,8 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
credentialId := model.CredentialId.ValueString()
|
||||
|
|
@ -267,6 +280,9 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ
|
|||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -246,6 +246,9 @@ func (r *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -268,6 +271,8 @@ func (r *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(instanceResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -389,6 +389,9 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
||||
|
|
@ -420,6 +423,9 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
instanceId := *createResp.InstanceId
|
||||
ctx = tflog.SetField(ctx, "instance_id", instanceId)
|
||||
waitResp, err := wait.CreateInstanceWaitHandler(ctx, r.client, projectId, instanceId).SetTimeout(90 * time.Minute).WaitWithContext(ctx)
|
||||
|
|
@ -452,6 +458,9 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -468,6 +477,8 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(instanceResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -499,6 +510,9 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -532,6 +546,9 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
waitResp, err := wait.PartialUpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Instance update waiting: %v", err))
|
||||
|
|
@ -562,6 +579,9 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -573,6 +593,9 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -132,6 +132,9 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
credentialId := model.CredentialId.ValueString()
|
||||
|
|
@ -155,6 +158,8 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, recordSetResp, &model)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -168,6 +168,9 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -179,6 +182,9 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if credentialsResp.Id == nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", "Got empty credential id")
|
||||
return
|
||||
|
|
@ -214,6 +220,9 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest,
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
credentialId := model.CredentialId.ValueString()
|
||||
|
|
@ -232,6 +241,8 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, recordSetResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -263,6 +274,8 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
credentialId := model.CredentialId.ValueString()
|
||||
|
|
@ -275,6 +288,9 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ
|
|||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -182,6 +182,9 @@ func (r *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -204,6 +207,8 @@ func (r *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(instanceResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -282,6 +282,9 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
||||
|
|
@ -313,6 +316,9 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
instanceId := *createResp.InstanceId
|
||||
ctx = tflog.SetField(ctx, "instance_id", instanceId)
|
||||
waitResp, err := wait.CreateInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
|
|
@ -345,6 +351,9 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -361,6 +370,8 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(instanceResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -392,6 +403,9 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -425,6 +439,9 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
waitResp, err := wait.PartialUpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Instance update waiting: %v", err))
|
||||
|
|
@ -455,6 +472,9 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -466,6 +486,9 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -237,8 +237,9 @@ func (r *tokenResource) Create(ctx context.Context, req resource.CreateRequest,
|
|||
return
|
||||
}
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -299,6 +300,8 @@ func (r *tokenResource) Create(ctx context.Context, req resource.CreateRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
waitResp, err := wait.CreateModelServingWaitHandler(ctx, r.client, region, projectId, *createTokenResp.Token.Id).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating AI model serving auth token", fmt.Sprintf("Waiting for token to be active: %v", err))
|
||||
|
|
@ -331,6 +334,8 @@ func (r *tokenResource) Read(ctx context.Context, req resource.ReadRequest, resp
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
tokenId := model.TokenId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -355,6 +360,8 @@ func (r *tokenResource) Read(ctx context.Context, req resource.ReadRequest, resp
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if getTokenResp != nil && getTokenResp.Token.State != nil &&
|
||||
*getTokenResp.Token.State == inactiveState {
|
||||
resp.State.RemoveResource(ctx)
|
||||
|
|
@ -397,6 +404,8 @@ func (r *tokenResource) Update(ctx context.Context, req resource.UpdateRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := state.ProjectId.ValueString()
|
||||
tokenId := state.TokenId.ValueString()
|
||||
|
||||
|
|
@ -440,6 +449,8 @@ func (r *tokenResource) Update(ctx context.Context, req resource.UpdateRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if updateTokenResp != nil && updateTokenResp.Token.State != nil &&
|
||||
*updateTokenResp.Token.State == inactiveState {
|
||||
resp.State.RemoveResource(ctx)
|
||||
|
|
@ -480,6 +491,8 @@ func (r *tokenResource) Delete(ctx context.Context, req resource.DeleteRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
tokenId := model.TokenId.ValueString()
|
||||
|
||||
|
|
@ -504,6 +517,8 @@ func (r *tokenResource) Delete(ctx context.Context, req resource.DeleteRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteModelServingWaitHandler(ctx, r.client, region, projectId, tokenId).
|
||||
WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -197,6 +197,8 @@ func (d *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := d.providerData.GetRegionWithOverride(model.Region)
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
|
|
@ -219,6 +221,8 @@ func (d *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
var flavor = &flavorModel{}
|
||||
if !(model.Flavor.IsNull() || model.Flavor.IsUnknown()) {
|
||||
diags = model.Flavor.As(ctx, flavor, basetypes.ObjectAsOptions{})
|
||||
|
|
|
|||
|
|
@ -355,6 +355,9 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -411,6 +414,9 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if createResp == nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", "API response is empty")
|
||||
return
|
||||
|
|
@ -484,6 +490,9 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
|
|
@ -528,6 +537,8 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, instanceResp, &model, flavor, storage, options, region)
|
||||
if err != nil {
|
||||
|
|
@ -552,6 +563,9 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
|
|
@ -610,6 +624,9 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
waitResp, err := wait.UpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId, region).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Instance update waiting: %v", err))
|
||||
|
|
@ -657,6 +674,9 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
|
|
@ -670,6 +690,9 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteInstanceWaitHandler(ctx, r.client, projectId, instanceId, region).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -146,6 +146,9 @@ func (d *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := d.providerData.GetRegionWithOverride(model.Region)
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
|
|
@ -171,6 +174,8 @@ func (d *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema and populate Computed attribute values
|
||||
err = mapDataSourceFields(recordSetResp, &model, region)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -222,6 +222,9 @@ func (r *userResource) Create(ctx context.Context, req resource.CreateRequest, r
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
|
|
@ -250,6 +253,9 @@ func (r *userResource) Create(ctx context.Context, req resource.CreateRequest, r
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating user", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if userResp == nil || userResp.Item == nil || userResp.Item.Id == nil || *userResp.Item.Id == "" {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating user", "API didn't return user ID. A user might have been created")
|
||||
return
|
||||
|
|
@ -280,6 +286,9 @@ func (r *userResource) Read(ctx context.Context, req resource.ReadRequest, resp
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
|
|
@ -300,6 +309,8 @@ func (r *userResource) Read(ctx context.Context, req resource.ReadRequest, resp
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(recordSetResp, &model, region)
|
||||
if err != nil {
|
||||
|
|
@ -325,6 +336,9 @@ func (r *userResource) Update(ctx context.Context, req resource.UpdateRequest, r
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
|
|
@ -365,6 +379,8 @@ func (r *userResource) Update(ctx context.Context, req resource.UpdateRequest, r
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
userResp, err := r.client.GetUser(ctx, projectId, instanceId, userId, region).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating user", fmt.Sprintf("Calling API: %v", err))
|
||||
|
|
@ -397,6 +413,8 @@ func (r *userResource) Delete(ctx context.Context, req resource.DeleteRequest, r
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
|
|
@ -412,6 +430,9 @@ func (r *userResource) Delete(ctx context.Context, req resource.DeleteRequest, r
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting user", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "MongoDB Flex user deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,6 +113,9 @@ func (r *bucketDataSource) Read(ctx context.Context, req datasource.ReadRequest,
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
bucketName := model.Name.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -137,6 +140,8 @@ func (r *bucketDataSource) Read(ctx context.Context, req datasource.ReadRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(bucketResp, &model, region)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -178,6 +178,9 @@ func (r *bucketResource) Create(ctx context.Context, req resource.CreateRequest,
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
bucketName := model.Name.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
|
|
@ -200,6 +203,8 @@ func (r *bucketResource) Create(ctx context.Context, req resource.CreateRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
waitResp, err := wait.CreateBucketWaitHandler(ctx, r.client, projectId, region, bucketName).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating bucket", fmt.Sprintf("Bucket creation waiting: %v", err))
|
||||
|
|
@ -228,6 +233,9 @@ func (r *bucketResource) Read(ctx context.Context, req resource.ReadRequest, res
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
bucketName := model.Name.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -247,6 +255,8 @@ func (r *bucketResource) Read(ctx context.Context, req resource.ReadRequest, res
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(bucketResp, &model, region)
|
||||
if err != nil {
|
||||
|
|
@ -277,6 +287,9 @@ func (r *bucketResource) Delete(ctx context.Context, req resource.DeleteRequest,
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
bucketName := model.Name.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
|
|
@ -297,6 +310,9 @@ func (r *bucketResource) Delete(ctx context.Context, req resource.DeleteRequest,
|
|||
}
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting bucket", fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteBucketWaitHandler(ctx, r.client, projectId, region, bucketName).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting bucket", fmt.Sprintf("Bucket deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -120,6 +120,8 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
credentialsGroupId := model.CredentialsGroupId.ValueString()
|
||||
credentialId := model.CredentialId.ValueString()
|
||||
|
|
@ -145,6 +147,9 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ
|
|||
resp.State.RemoveResource(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if credentialsGroupResp == nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Reading credentials", fmt.Sprintf("Response is nil: %v", err))
|
||||
return
|
||||
|
|
|
|||
|
|
@ -248,6 +248,9 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
credentialsGroupId := model.CredentialsGroupId.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
|
|
@ -275,6 +278,9 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if credentialResp.KeyId == nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", "Got empty credential id")
|
||||
return
|
||||
|
|
@ -326,6 +332,8 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
credentialsGroupId := model.CredentialsGroupId.ValueString()
|
||||
credentialId := model.CredentialId.ValueString()
|
||||
|
|
@ -341,6 +349,9 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest,
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Finding credential: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if !found {
|
||||
resp.State.RemoveResource(ctx)
|
||||
return
|
||||
|
|
@ -399,6 +410,8 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
credentialsGroupId := model.CredentialsGroupId.ValueString()
|
||||
credentialId := model.CredentialId.ValueString()
|
||||
|
|
@ -415,6 +428,8 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "ObjectStorage credential deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,6 +111,9 @@ func (r *credentialsGroupDataSource) Read(ctx context.Context, req datasource.Re
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
credentialsGroupId := model.CredentialsGroupId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -124,6 +127,9 @@ func (r *credentialsGroupDataSource) Read(ctx context.Context, req datasource.Re
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials group", fmt.Sprintf("getting credential group from list of credentials groups: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if !found {
|
||||
resp.State.RemoveResource(ctx)
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials group", fmt.Sprintf("Credentials group with ID %q does not exists in project %q", credentialsGroupId, projectId))
|
||||
|
|
|
|||
|
|
@ -176,6 +176,9 @@ func (r *credentialsGroupResource) Create(ctx context.Context, req resource.Crea
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
credentialsGroupName := model.Name.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
|
|
@ -202,6 +205,8 @@ func (r *credentialsGroupResource) Create(ctx context.Context, req resource.Crea
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(got, &model, region)
|
||||
if err != nil {
|
||||
|
|
@ -224,6 +229,9 @@ func (r *credentialsGroupResource) Read(ctx context.Context, req resource.ReadRe
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
credentialsGroupId := model.CredentialsGroupId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -237,6 +245,9 @@ func (r *credentialsGroupResource) Read(ctx context.Context, req resource.ReadRe
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentialsGroup", fmt.Sprintf("getting credential group from list of credentials groups: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if !found {
|
||||
resp.State.RemoveResource(ctx)
|
||||
return
|
||||
|
|
@ -267,6 +278,9 @@ func (r *credentialsGroupResource) Delete(ctx context.Context, req resource.Dele
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
credentialsGroupId := model.CredentialsGroupId.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
|
|
@ -281,6 +295,8 @@ func (r *credentialsGroupResource) Delete(ctx context.Context, req resource.Dele
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials group", fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "ObjectStorage credentials group deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -138,6 +138,8 @@ func (a *alertGroupDataSource) Read(ctx context.Context, req datasource.ReadRequ
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
alertGroupName := model.Name.ValueString()
|
||||
|
|
@ -157,6 +159,8 @@ func (a *alertGroupDataSource) Read(ctx context.Context, req datasource.ReadRequ
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, readAlertGroupResp.Data, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading alert group", fmt.Sprintf("Error processing API response: %v", err))
|
||||
|
|
|
|||
|
|
@ -239,6 +239,8 @@ func (a *alertGroupResource) Create(ctx context.Context, req resource.CreateRequ
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
alertGroupName := model.Name.ValueString()
|
||||
|
|
@ -258,6 +260,8 @@ func (a *alertGroupResource) Create(ctx context.Context, req resource.CreateRequ
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// all alert groups are returned. We have to search the map for the one corresponding to our name
|
||||
for _, alertGroup := range *createAlertGroupResp.Data {
|
||||
if model.Name.ValueString() != *alertGroup.Name {
|
||||
|
|
@ -289,6 +293,8 @@ func (a *alertGroupResource) Read(ctx context.Context, req resource.ReadRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
alertGroupName := model.Name.ValueString()
|
||||
|
|
@ -308,6 +314,8 @@ func (a *alertGroupResource) Read(ctx context.Context, req resource.ReadRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, readAlertGroupResp.Data, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading alert group", fmt.Sprintf("Error processing API response: %v", err))
|
||||
|
|
@ -337,6 +345,8 @@ func (a *alertGroupResource) Delete(ctx context.Context, req resource.DeleteRequ
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
alertGroupName := model.Name.ValueString()
|
||||
|
|
@ -350,6 +360,8 @@ func (a *alertGroupResource) Delete(ctx context.Context, req resource.DeleteRequ
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "Alert group deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,6 +136,8 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
description := model.Description.ValueStringPointer()
|
||||
|
|
@ -149,6 +151,9 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(got.Credentials, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
@ -193,6 +198,9 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest,
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
userName := model.Username.ValueString()
|
||||
|
|
@ -211,6 +219,9 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest,
|
|||
resp.State.RemoveResource(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
diags = resp.State.Set(ctx, model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
|
|
@ -233,6 +244,9 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
userName := model.Username.ValueString()
|
||||
|
|
@ -241,5 +255,8 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "Observability credential deleted")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -381,6 +381,9 @@ func (d *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
instanceResp, err := d.client.GetInstance(ctx, instanceId, projectId).Execute()
|
||||
|
|
@ -398,6 +401,9 @@ func (d *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
resp.State.RemoveResource(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if instanceResp != nil && instanceResp.Status != nil && *instanceResp.Status == observability.GETINSTANCERESPONSESTATUS_DELETE_SUCCEEDED {
|
||||
resp.State.RemoveResource(ctx)
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", "Instance was deleted successfully")
|
||||
|
|
|
|||
|
|
@ -897,6 +897,8 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
acl := []string{}
|
||||
if !(model.ACL.IsNull() || model.ACL.IsUnknown()) {
|
||||
diags = model.ACL.ElementsAs(ctx, &acl, false)
|
||||
|
|
@ -934,6 +936,9 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
instanceId := createResp.InstanceId
|
||||
ctx = tflog.SetField(ctx, "instance_id", instanceId)
|
||||
waitResp, err := wait.CreateInstanceWaitHandler(ctx, r.client, *instanceId, projectId).WaitWithContext(ctx)
|
||||
|
|
@ -1064,6 +1069,9 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -1079,6 +1087,9 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if instanceResp != nil && instanceResp.Status != nil && *instanceResp.Status == observability.GETINSTANCERESPONSESTATUS_DELETE_SUCCEEDED {
|
||||
resp.State.RemoveResource(ctx)
|
||||
return
|
||||
|
|
@ -1215,6 +1226,9 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
|
||||
|
|
@ -1268,6 +1282,9 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
instance, err = wait.UpdateInstanceWaitHandler(ctx, r.client, instanceId, projectId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Instance update waiting: %v", err))
|
||||
|
|
@ -1401,6 +1418,8 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
|
||||
|
|
@ -1410,6 +1429,9 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteInstanceWaitHandler(ctx, r.client, instanceId, projectId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -138,6 +138,8 @@ func (l *logAlertGroupDataSource) Read(ctx context.Context, req datasource.ReadR
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
alertGroupName := model.Name.ValueString()
|
||||
|
|
@ -157,6 +159,8 @@ func (l *logAlertGroupDataSource) Read(ctx context.Context, req datasource.ReadR
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, readAlertGroupResp.Data, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading log alert group", fmt.Sprintf("Error processing API response: %v", err))
|
||||
|
|
|
|||
|
|
@ -239,6 +239,8 @@ func (l *logAlertGroupResource) Create(ctx context.Context, req resource.CreateR
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
alertGroupName := model.Name.ValueString()
|
||||
|
|
@ -258,6 +260,8 @@ func (l *logAlertGroupResource) Create(ctx context.Context, req resource.CreateR
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// all log alert groups are returned. We have to search the map for the one corresponding to our name
|
||||
for _, alertGroup := range *createAlertGroupResp.Data {
|
||||
if model.Name.ValueString() != *alertGroup.Name {
|
||||
|
|
@ -289,6 +293,8 @@ func (l *logAlertGroupResource) Read(ctx context.Context, req resource.ReadReque
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
alertGroupName := model.Name.ValueString()
|
||||
|
|
@ -308,6 +314,8 @@ func (l *logAlertGroupResource) Read(ctx context.Context, req resource.ReadReque
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, readAlertGroupResp.Data, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading log alert group", fmt.Sprintf("Error processing API response: %v", err))
|
||||
|
|
@ -337,6 +345,8 @@ func (l *logAlertGroupResource) Delete(ctx context.Context, req resource.DeleteR
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
alertGroupName := model.Name.ValueString()
|
||||
|
|
@ -350,6 +360,8 @@ func (l *logAlertGroupResource) Delete(ctx context.Context, req resource.DeleteR
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "log alert group deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -190,6 +190,9 @@ func (d *scrapeConfigDataSource) Read(ctx context.Context, req datasource.ReadRe
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
scName := model.Name.ValueString()
|
||||
|
|
@ -210,6 +213,8 @@ func (d *scrapeConfigDataSource) Read(ctx context.Context, req datasource.ReadRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(ctx, scResp.Data, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Mapping fields", err.Error())
|
||||
|
|
|
|||
|
|
@ -305,6 +305,8 @@ func (r *scrapeConfigResource) Create(ctx context.Context, req resource.CreateRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
scName := model.Name.ValueString()
|
||||
|
|
@ -347,6 +349,9 @@ func (r *scrapeConfigResource) Create(ctx context.Context, req resource.CreateRe
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating scrape config", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.CreateScrapeConfigWaitHandler(ctx, r.client, instanceId, scName, projectId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating scrape config", fmt.Sprintf("Scrape config creation waiting: %v", err))
|
||||
|
|
@ -379,6 +384,9 @@ func (r *scrapeConfigResource) Read(ctx context.Context, req resource.ReadReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
scName := model.Name.ValueString()
|
||||
|
|
@ -394,6 +402,8 @@ func (r *scrapeConfigResource) Read(ctx context.Context, req resource.ReadReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, scResp.Data, &model)
|
||||
if err != nil {
|
||||
|
|
@ -418,6 +428,9 @@ func (r *scrapeConfigResource) Update(ctx context.Context, req resource.UpdateRe
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
scName := model.Name.ValueString()
|
||||
|
|
@ -460,6 +473,9 @@ func (r *scrapeConfigResource) Update(ctx context.Context, req resource.UpdateRe
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating scrape config", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// We do not have an update status provided by the observability scrape config api, so we cannot use a waiter here, hence a simple sleep is used.
|
||||
time.Sleep(15 * time.Second)
|
||||
|
||||
|
|
@ -492,6 +508,8 @@ func (r *scrapeConfigResource) Delete(ctx context.Context, req resource.DeleteRe
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
scName := model.Name.ValueString()
|
||||
|
|
@ -502,6 +520,9 @@ func (r *scrapeConfigResource) Delete(ctx context.Context, req resource.DeleteRe
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting scrape config", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteScrapeConfigWaitHandler(ctx, r.client, instanceId, scName, projectId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting scrape config", fmt.Sprintf("Scrape config deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -132,6 +132,9 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
credentialId := model.CredentialId.ValueString()
|
||||
|
|
@ -155,6 +158,8 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, recordSetResp, &model)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -168,6 +168,9 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -179,6 +182,9 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if credentialsResp.Id == nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", "Got empty credential id")
|
||||
return
|
||||
|
|
@ -214,6 +220,9 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest,
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
credentialId := model.CredentialId.ValueString()
|
||||
|
|
@ -232,6 +241,8 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest,
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(ctx, recordSetResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -263,6 +274,8 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
credentialId := model.CredentialId.ValueString()
|
||||
|
|
@ -275,6 +288,9 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ
|
|||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -215,6 +215,9 @@ func (r *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -237,6 +240,8 @@ func (r *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
err = mapFields(instanceResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Processing API payload: %v", err))
|
||||
|
|
|
|||
|
|
@ -330,6 +330,9 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
||||
|
|
@ -361,6 +364,9 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
instanceId := *createResp.InstanceId
|
||||
ctx = tflog.SetField(ctx, "instance_id", instanceId)
|
||||
waitResp, err := wait.CreateInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
|
|
@ -393,6 +399,9 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -409,6 +418,8 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(instanceResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -440,6 +451,9 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -479,6 +493,8 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(waitResp, &model)
|
||||
if err != nil {
|
||||
|
|
@ -503,6 +519,9 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -514,6 +533,9 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteInstanceWaitHandler(ctx, r.client, projectId, instanceId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
|
|
|
|||
|
|
@ -124,6 +124,9 @@ func (r *databaseDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
databaseId := model.DatabaseId.ValueString()
|
||||
|
|
@ -149,6 +152,8 @@ func (r *databaseDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema and populate Computed attribute values
|
||||
err = mapFields(databaseResp, &model, region)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -198,6 +198,9 @@ func (r *databaseResource) Create(ctx context.Context, req resource.CreateReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
|
|
@ -217,6 +220,9 @@ func (r *databaseResource) Create(ctx context.Context, req resource.CreateReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating database", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if databaseResp == nil || databaseResp.Id == nil || *databaseResp.Id == "" {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating database", "API didn't return database Id. A database might have been created")
|
||||
return
|
||||
|
|
@ -253,6 +259,9 @@ func (r *databaseResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
databaseId := model.DatabaseId.ValueString()
|
||||
|
|
@ -273,6 +282,8 @@ func (r *databaseResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
// Map response body to schema
|
||||
err = mapFields(databaseResp, &model, region)
|
||||
if err != nil {
|
||||
|
|
@ -305,6 +316,8 @@ func (r *databaseResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
databaseId := model.DatabaseId.ValueString()
|
||||
|
|
@ -319,6 +332,9 @@ func (r *databaseResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting database", fmt.Sprintf("Calling API: %v", err))
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
tflog.Info(ctx, "Postgres Flex database deleted")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -158,6 +158,8 @@ func (r *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -179,6 +181,9 @@ func (r *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques
|
|||
resp.State.RemoveResource(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if instanceResp != nil && instanceResp.Item != nil && instanceResp.Item.Status != nil && *instanceResp.Item.Status == wait.InstanceStateDeleted {
|
||||
resp.State.RemoveResource(ctx)
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", "Instance was deleted successfully")
|
||||
|
|
|
|||
|
|
@ -273,6 +273,9 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
|
@ -320,6 +323,9 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
instanceId := *createResp.Id
|
||||
ctx = tflog.SetField(ctx, "instance_id", instanceId)
|
||||
waitResp, err := wait.CreateInstanceWaitHandler(ctx, r.client, projectId, region, instanceId).WaitWithContext(ctx)
|
||||
|
|
@ -351,6 +357,9 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
region := r.providerData.GetRegionWithOverride(model.Region)
|
||||
|
|
@ -385,6 +394,9 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
if instanceResp != nil && instanceResp.Item != nil && instanceResp.Item.Status != nil && *instanceResp.Item.Status == wait.InstanceStateDeleted {
|
||||
resp.State.RemoveResource(ctx)
|
||||
return
|
||||
|
|
@ -414,6 +426,9 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
|
|
@ -463,6 +478,9 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
waitResp, err := wait.PartialUpdateInstanceWaitHandler(ctx, r.client, projectId, region, instanceId).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Instance update waiting: %v", err))
|
||||
|
|
@ -492,6 +510,9 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
|
|
@ -505,6 +526,9 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
_, err = wait.DeleteInstanceWaitHandler(ctx, r.client, projectId, region, instanceId).SetTimeout(45 * time.Minute).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue