Make server backup schedule resources beta (#434)

* Make server backup schedule resources beta

* Adjust guide
This commit is contained in:
João Palet 2024-06-26 14:02:50 +01:00 committed by GitHub
parent b5eb8bd379
commit 5b617e0676
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 86 additions and 22 deletions

View file

@ -11,6 +11,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core"
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/features"
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
@ -19,6 +20,11 @@ import (
"github.com/stackitcloud/stackit-sdk-go/services/serverbackup"
)
// scheduleDataSourceBetaCheckDone is used to prevent multiple checks for beta resources.
// This is a workaround for the lack of a global state in the provider and
// needs to exist because the Configure method is called twice.
var schedulesDataSourceBetaCheckDone bool
// Ensure the implementation satisfies the expected interfaces.
var (
_ datasource.DataSource = &schedulesDataSource{}
@ -52,6 +58,14 @@ func (r *schedulesDataSource) Configure(ctx context.Context, req datasource.Conf
return
}
if !schedulesDataSourceBetaCheckDone {
features.CheckBetaResourcesEnabled(ctx, &providerData, &resp.Diagnostics, "stackit_server_backup_schedules", "data source")
if resp.Diagnostics.HasError() {
return
}
schedulesDataSourceBetaCheckDone = true
}
var apiClient *serverbackup.APIClient
var err error
if providerData.ServerBackupCustomEndpoint != "" {
@ -79,7 +93,8 @@ func (r *schedulesDataSource) Configure(ctx context.Context, req datasource.Conf
// Schema defines the schema for the data source.
func (r *schedulesDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
Description: "Server backup schedule data source schema.",
Description: "Server backup schedules datasource schema. Must have a `region` specified in the provider configuration.",
MarkdownDescription: features.AddBetaDescription("Server backup schedules datasource schema. Must have a `region` specified in the provider configuration."),
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
Description: "Terraform's internal data source identifier. It is structured as \"`project_id`,`server_id`\".",