Skip to content

Commit 7cc9ca4

Browse files
authored
fix(beta): remove caching of beta checks (#757)
beta checks caused issues when debugging relates to STACKITTPR-206
1 parent d6749b6 commit 7cc9ca4

File tree

6 files changed

+18
-66
lines changed

6 files changed

+18
-66
lines changed

stackit/internal/services/serverbackup/schedule/resource.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ import (
3030
"github.com/stackitcloud/stackit-sdk-go/services/serverbackup"
3131
)
3232

33-
// resourceBetaCheckDone is used to prevent multiple checks for beta resources.
34-
// This is a workaround for the lack of a global state in the provider and
35-
// needs to exist because the Configure method is called twice.
36-
var resourceBetaCheckDone bool
37-
3833
// Ensure the implementation satisfies the expected interfaces.
3934
var (
4035
_ resource.Resource = &scheduleResource{}
@@ -122,12 +117,9 @@ func (r *scheduleResource) Configure(ctx context.Context, req resource.Configure
122117
return
123118
}
124119

125-
if !resourceBetaCheckDone {
126-
features.CheckBetaResourcesEnabled(ctx, &r.providerData, &resp.Diagnostics, "stackit_server_backup_schedule", "resource")
127-
if resp.Diagnostics.HasError() {
128-
return
129-
}
130-
resourceBetaCheckDone = true
120+
features.CheckBetaResourcesEnabled(ctx, &r.providerData, &resp.Diagnostics, "stackit_server_backup_schedule", "resource")
121+
if resp.Diagnostics.HasError() {
122+
return
131123
}
132124

133125
var (

stackit/internal/services/serverupdate/schedule/resource.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ import (
3030
"github.com/stackitcloud/stackit-sdk-go/services/serverupdate"
3131
)
3232

33-
// resourceBetaCheckDone is used to prevent multiple checks for beta resources.
34-
// This is a workaround for the lack of a global state in the provider and
35-
// needs to exist because the Configure method is called twice.
36-
var resourceBetaCheckDone bool
37-
3833
// Ensure the implementation satisfies the expected interfaces.
3934
var (
4035
_ resource.Resource = &scheduleResource{}
@@ -115,12 +110,9 @@ func (r *scheduleResource) Configure(ctx context.Context, req resource.Configure
115110
return
116111
}
117112

118-
if !resourceBetaCheckDone {
119-
features.CheckBetaResourcesEnabled(ctx, &r.providerData, &resp.Diagnostics, "stackit_server_update_schedule", "resource")
120-
if resp.Diagnostics.HasError() {
121-
return
122-
}
123-
resourceBetaCheckDone = true
113+
features.CheckBetaResourcesEnabled(ctx, &r.providerData, &resp.Diagnostics, "stackit_server_update_schedule", "resource")
114+
if resp.Diagnostics.HasError() {
115+
return
124116
}
125117

126118
var apiClient *serverupdate.APIClient

stackit/internal/services/serviceaccount/account/datasource.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ import (
1717
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
1818
)
1919

20-
// dataSourceBetaCheckDone is used to prevent multiple checks for beta resources.
21-
// This is a workaround for the lack of a global state in the provider and
22-
// needs to exist because the Configure method is called twice.
23-
var dataSourceBetaCheckDone bool
24-
2520
// Ensure the implementation satisfies the expected interfaces.
2621
var (
2722
_ datasource.DataSource = &serviceAccountDataSource{}
@@ -50,12 +45,9 @@ func (r *serviceAccountDataSource) Configure(ctx context.Context, req datasource
5045
return
5146
}
5247

53-
if !dataSourceBetaCheckDone {
54-
features.CheckBetaResourcesEnabled(ctx, &providerData, &resp.Diagnostics, "stackit_service_account", "datasource")
55-
if resp.Diagnostics.HasError() {
56-
return
57-
}
58-
dataSourceBetaCheckDone = true
48+
features.CheckBetaResourcesEnabled(ctx, &providerData, &resp.Diagnostics, "stackit_service_account", "datasource")
49+
if resp.Diagnostics.HasError() {
50+
return
5951
}
6052

6153
var apiClient *serviceaccount.APIClient

stackit/internal/services/serviceaccount/account/resource.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ import (
2424
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
2525
)
2626

27-
// resourceBetaCheckDone is used to prevent multiple checks for beta resources.
28-
// This is a workaround for the lack of a global state in the provider and
29-
// needs to exist because the Configure method is called twice.
30-
var resourceBetaCheckDone bool
31-
3227
// Ensure the implementation satisfies the expected interfaces.
3328
var (
3429
_ resource.Resource = &serviceAccountResource{}
@@ -68,12 +63,9 @@ func (r *serviceAccountResource) Configure(ctx context.Context, req resource.Con
6863
return
6964
}
7065

71-
if !resourceBetaCheckDone {
72-
features.CheckBetaResourcesEnabled(ctx, &providerData, &resp.Diagnostics, "stackit_service_account", "resource")
73-
if resp.Diagnostics.HasError() {
74-
return
75-
}
76-
resourceBetaCheckDone = true
66+
features.CheckBetaResourcesEnabled(ctx, &providerData, &resp.Diagnostics, "stackit_service_account", "resource")
67+
if resp.Diagnostics.HasError() {
68+
return
7769
}
7870

7971
// Initialize the API client with the appropriate authentication and endpoint settings.

stackit/internal/services/serviceaccount/key/resource.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ import (
2929
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
3030
)
3131

32-
// resourceBetaCheckDone is used to prevent multiple checks for beta resources.
33-
// This is a workaround for the lack of a global state in the provider and
34-
// needs to exist because the Configure method is called twice.
35-
var resourceBetaCheckDone bool
36-
3732
// Ensure the implementation satisfies the expected interfaces.
3833
var (
3934
_ resource.Resource = &serviceAccountKeyResource{}
@@ -76,12 +71,9 @@ func (r *serviceAccountKeyResource) Configure(ctx context.Context, req resource.
7671
return
7772
}
7873

79-
if !resourceBetaCheckDone {
80-
features.CheckBetaResourcesEnabled(ctx, &providerData, &resp.Diagnostics, "stackit_service_account_key", "resource")
81-
if resp.Diagnostics.HasError() {
82-
return
83-
}
84-
resourceBetaCheckDone = true
74+
features.CheckBetaResourcesEnabled(ctx, &providerData, &resp.Diagnostics, "stackit_service_account_key", "resource")
75+
if resp.Diagnostics.HasError() {
76+
return
8577
}
8678

8779
// Initialize the API client with the appropriate authentication and endpoint settings.

stackit/internal/services/serviceaccount/token/resource.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ import (
2929
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate"
3030
)
3131

32-
// resourceBetaCheckDone is used to prevent multiple checks for beta resources.
33-
// This is a workaround for the lack of a global state in the provider and
34-
// needs to exist because the Configure method is called twice.
35-
var resourceBetaCheckDone bool
36-
3732
// Ensure the implementation satisfies the expected interfaces.
3833
var (
3934
_ resource.Resource = &serviceAccountTokenResource{}
@@ -78,12 +73,9 @@ func (r *serviceAccountTokenResource) Configure(ctx context.Context, req resourc
7873
return
7974
}
8075

81-
if !resourceBetaCheckDone {
82-
features.CheckBetaResourcesEnabled(ctx, &providerData, &resp.Diagnostics, "stackit_service_account_access_token", "resource")
83-
if resp.Diagnostics.HasError() {
84-
return
85-
}
86-
resourceBetaCheckDone = true
76+
features.CheckBetaResourcesEnabled(ctx, &providerData, &resp.Diagnostics, "stackit_service_account_access_token", "resource")
77+
if resp.Diagnostics.HasError() {
78+
return
8779
}
8880

8981
// Initialize the API client with the appropriate authentication and endpoint settings.

0 commit comments

Comments
 (0)