Change the public ip resource conflict warning message order (#600)

* change the warning message order

* change the warning message

* Update stackit/internal/services/iaas/publicipassociate/resource.go

Co-authored-by: João Palet <joao.palet@outlook.com>

* adapt warning in schema and docs

---------

Co-authored-by: João Palet <joao.palet@outlook.com>
This commit is contained in:
GokceGK 2024-11-25 11:41:12 +01:00 committed by GitHub
parent 2a2d62a429
commit 1051995ad6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 6 deletions

View file

@ -99,6 +99,9 @@ func (r *publicIpAssociateResource) Configure(ctx context.Context, req resource.
return
}
core.LogAndAddWarning(ctx, &resp.Diagnostics, "The `stackit_public_ip_associate` resource should not be used together with the `stackit_public_ip` resource for the same public IP or for the same network interface.",
"Using both resources together for the same public IP or network interface WILL lead to conflicts, as they both have control of the public IP and network interface association.")
r.client = apiClient
tflog.Info(ctx, "iaas client configured")
}
@ -109,7 +112,8 @@ func (r *publicIpAssociateResource) Schema(_ context.Context, _ resource.SchemaR
"main": "Associates an existing public IP to a network interface. " +
"This is useful for situations where you have a pre-allocated public IP or unable to use the `stackit_public_ip` resource to create a new public IP. " +
"Must have a `region` specified in the provider configuration.",
"warning_message": "The `stackit_public_ip_associate` resource should not be used together with the `stackit_public_ip` resource for the same network interface, as they both have control of the network interface association and this will lead to conflicts.",
"warning_message": "The `stackit_public_ip_associate` resource should not be used together with the `stackit_public_ip` resource for the same public IP or for the same network interface. \n" +
"Using both resources together for the same public IP or network interface WILL lead to conflicts, as they both have control of the public IP and network interface association.",
}
resp.Schema = schema.Schema{
MarkdownDescription: features.AddBetaDescription(fmt.Sprintf("%s\n\n!> %s", descriptions["main"], descriptions["warning_message"])),
@ -185,9 +189,6 @@ func (r *publicIpAssociateResource) Create(ctx context.Context, req resource.Cre
ctx = tflog.SetField(ctx, "public_ip_id", publicIpId)
ctx = tflog.SetField(ctx, "network_interface_id", networkInterfaceId)
core.LogAndAddWarning(ctx, &resp.Diagnostics, "The `stackit_public_ip_associate` resource should not be used together with the `stackit_public_ip` resource for the same network interface.",
"The `stackit_public_ip_associate` resource should not be used together with the `stackit_public_ip` resource for the same network interface, as they both have control of the network interface association and this will lead to conflicts.")
// Generate API request body from model
payload, err := toCreatePayload(&model)
if err != nil {