parent
d1e12fcf64
commit
24b7387db9
140 changed files with 1597 additions and 7 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue