Skip to content

Commit f2390e9

Browse files
[CLOUDGA-24196] Put DB audit log feature under FF (#121)
Put DB audit log feature under FF
1 parent 3026563 commit f2390e9

File tree

8 files changed

+25
-177
lines changed

8 files changed

+25
-177
lines changed

docs/data-sources/associate_db_audit_export_config_cluster.md

Lines changed: 0 additions & 54 deletions
This file was deleted.

docs/resources/associate_db_audit_export_config_cluster.md

Lines changed: 0 additions & 70 deletions
This file was deleted.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/hashicorp/terraform-plugin-framework-validators v0.4.0
99
github.com/hashicorp/terraform-plugin-log v0.9.0
1010
github.com/sethvargo/go-retry v0.2.3
11-
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241005174727-b357e4b80b13
11+
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241018110715-ae57a1f1fb73
1212
)
1313

1414
require (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9
159159
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
160160
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
161161
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
162-
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241005174727-b357e4b80b13 h1:X5ElhDvBDzXcg14eObrBoaD6Di13n2137DgUHzc0FcQ=
163-
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241005174727-b357e4b80b13/go.mod h1:5vW0xIzIZw+1djkiWKx0qqNmqbRBSf4mjc4qw8lIMik=
162+
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241018110715-ae57a1f1fb73 h1:ZKr+fauJieZ4tYqoGJqSFhgNxFNYUgjnVED18iqQEKc=
163+
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241018110715-ae57a1f1fb73/go.mod h1:5vW0xIzIZw+1djkiWKx0qqNmqbRBSf4mjc4qw8lIMik=
164164
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
165165
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
166166
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

managed/fflags/feature_flags.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ type FeatureFlag string
1414

1515
const (
1616
GOOGLECLOUD_INTEGRATION_ENABLED FeatureFlag = "GOOGLECLOUD_INTEGRATION_ENABLED"
17+
DB_AUDIT_LOGGING FeatureFlag = "DB_AUDIT_LOGGING"
1718
)
1819

1920
var flagEnabled = map[FeatureFlag]bool{
2021
GOOGLECLOUD_INTEGRATION_ENABLED: false,
22+
DB_AUDIT_LOGGING: false,
2123
}
2224

2325
func (f FeatureFlag) String() string {

managed/provider.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/hashicorp/terraform-plugin-framework/diag"
1212
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
1313
"github.com/hashicorp/terraform-plugin-framework/types"
14+
"github.com/yugabyte/terraform-provider-ybm/managed/fflags"
1415
openapiclient "github.com/yugabyte/yugabytedb-managed-go-client-internal"
1516
)
1617

@@ -142,7 +143,7 @@ func (p *provider) Configure(ctx context.Context, req tfsdk.ConfigureProviderReq
142143
}
143144

144145
func (p *provider) GetResources(_ context.Context) (map[string]tfsdk.ResourceType, diag.Diagnostics) {
145-
return map[string]tfsdk.ResourceType{
146+
resources := map[string]tfsdk.ResourceType{
146147
"ybm_cluster": resourceClusterType{},
147148
"ybm_allow_list": resourceAllowListType{},
148149
"ybm_backup": resourceBackupType{},
@@ -155,18 +156,30 @@ func (p *provider) GetResources(_ context.Context) (map[string]tfsdk.ResourceTyp
155156
"ybm_api_key": resourceApiKeyType{},
156157
"ybm_metrics_exporter": resourceMetricsExporterType{},
157158
"ybm_associate_metrics_exporter_cluster": resourceAssociateMetricsExporterClusterType{},
158-
"ybm_associate_db_audit_export_config_cluster": resourceAssociateDbAuditExportConfigClusterType{},
159-
"ybm_integration": resourceIntegrationType{},
160-
}, nil
159+
"ybm_integration": resourceIntegrationType{},
160+
}
161+
162+
// Add DB Audit logging resource only if the feature flag is enabled
163+
if fflags.IsFeatureFlagEnabled(fflags.DB_AUDIT_LOGGING) {
164+
resources["ybm_associate_db_audit_export_config_cluster"] = resourceAssociateDbAuditExportConfigClusterType{}
165+
}
166+
167+
return resources, nil
161168
}
162169

163170
func (p *provider) GetDataSources(_ context.Context) (map[string]tfsdk.DataSourceType, diag.Diagnostics) {
164-
return map[string]tfsdk.DataSourceType{
171+
dataSources := map[string]tfsdk.DataSourceType{
165172
"ybm_backup": dataSourceBackupType{},
166173
"ybm_cluster": dataClusterNameType{},
167174
"ybm_vpc": dataSourceVPCType{},
168175
"ybm_allow_list": dataSourceAllowListType{},
169176
"ybm_integration": dataSourceIntegrationType{},
170-
"ybm_associate_db_audit_export_config_cluster": dataSourceAssociateDbAuditExportConfigClusterType{},
171-
}, nil
177+
}
178+
179+
// Add DB Audit logging data source only if the feature flag is enabled
180+
if fflags.IsFeatureFlagEnabled(fflags.DB_AUDIT_LOGGING) {
181+
dataSources["ybm_associate_db_audit_export_config_cluster"] = dataSourceAssociateDbAuditExportConfigClusterType{}
182+
}
183+
184+
return dataSources, nil
172185
}

templates/data-sources/associate_db_audit_export_config_cluster.md.tmpl

Lines changed: 0 additions & 16 deletions
This file was deleted.

templates/resources/associate_db_audit_export_config_cluster.md.tmpl

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)