Skip to content

Commit

Permalink
Support CRUD operations for DR (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
posriniv authored Dec 10, 2024
1 parent 4086375 commit 79634ed
Show file tree
Hide file tree
Showing 7 changed files with 507 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/hashicorp/terraform-plugin-framework-validators v0.4.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/sethvargo/go-retry v0.2.3
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241111184456-64fb00419bec
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241121131757-c39c1074998a
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241111184456-64fb00419bec h1:VLtUGFreqNxI54GgSuwypYHl+MA8aqxl22bLWpxAP0w=
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241111184456-64fb00419bec/go.mod h1:5vW0xIzIZw+1djkiWKx0qqNmqbRBSf4mjc4qw8lIMik=
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241121131757-c39c1074998a h1:eXXFUXaaoOuuRKz++a5ndNsqFAscPC0fgQzEwiZ4C1o=
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241121131757-c39c1074998a/go.mod h1:5vW0xIzIZw+1djkiWKx0qqNmqbRBSf4mjc4qw8lIMik=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
2 changes: 2 additions & 0 deletions managed/fflags/feature_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ const (
GOOGLECLOUD_INTEGRATION_ENABLED FeatureFlag = "GOOGLECLOUD_INTEGRATION_ENABLED"
DB_AUDIT_LOGGING FeatureFlag = "DB_AUDIT_LOGGING"
CONNECTION_POOLING FeatureFlag = "CONNECTION_POOLING"
DR FeatureFlag = "DR"
)

var flagEnabled = map[FeatureFlag]bool{
GOOGLECLOUD_INTEGRATION_ENABLED: false,
DB_AUDIT_LOGGING: false,
CONNECTION_POOLING: false,
DR: false,
}

func (f FeatureFlag) String() string {
Expand Down
10 changes: 10 additions & 0 deletions managed/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,3 +391,13 @@ type DbQueryLoggingConfig struct {
ConfigID types.String `tfsdk:"config_id"`
LogConfig *LogConfig `tfsdk:"log_config"`
}

type DrConfig struct {
AccountId types.String `tfsdk:"account_id"`
ProjectId types.String `tfsdk:"project_id"`
DrConfigId types.String `tfsdk:"dr_config_id"`
Name types.String `tfsdk:"name"`
SourceClusterId types.String `tfsdk:"source_cluster_id"`
TargetClusterId types.String `tfsdk:"target_cluster_id"`
Databases []types.String `tfsdk:"databases"`
}
5 changes: 5 additions & 0 deletions managed/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ func (p *provider) GetResources(_ context.Context) (map[string]tfsdk.ResourceTyp
resources["ybm_db_audit_logging"] = resourceDbAuditLoggingType{}
}

// Add DR config resource only if the feature flag is enabled
if fflags.IsFeatureFlagEnabled(fflags.DR) {
resources["ybm_dr_config"] = resourceDrConfigType{}
}

return resources, nil
}

Expand Down
Loading

0 comments on commit 79634ed

Please sign in to comment.