Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/services/baremetal/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func ResourceServer() *schema.Resource {

return ok && newValue == offerName
},
ValidateDiagFunc: verify.IsUUIDOrNameOffer(),
},
"offer_id": {
Type: schema.TypeString,
Expand Down
25 changes: 25 additions & 0 deletions internal/verify/uuid.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,28 @@ func IsUUIDWithLocality() schema.SchemaValidateDiagFunc {
return IsUUID()(subUUID, path)
}
}

func IsUUIDOrNameOffer() schema.SchemaValidateDiagFunc {
return func(value interface{}, path cty.Path) diag.Diagnostics {
uuid, _ := value.(string)
if !validation.IsUUID(uuid) {
return diag.Diagnostics{diag.Diagnostic{
Severity: diag.Warning,
Summary: "Using a datasource for better consistency and reliability is recommended instead of directly using offer names.",
AttributePath: path,
Detail: `The offer name should be retrieved using a datasource to ensure reliable and consistent configuration.

Example:
data "scaleway_baremetal_offer" "my_offer_monthly" {
zone = "fr-par-2"
name = "EM-B112X-SSD"
subscription_period = "monthly"
}

Then, you can reference the datasource's attributes in your resources.`,
}}
}

return nil
}
}
Loading