Skip to content

Commit 13f7c4a

Browse files
authored
Support CRUD operations for PITR configs, PITR restore, clone (#151)
Support CRUD operations for PITR configs, PITR restore and clone
1 parent 47202c4 commit 13f7c4a

File tree

9 files changed

+1123
-4
lines changed

9 files changed

+1123
-4
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ module github.com/yugabyte/terraform-provider-ybm
22

33
go 1.22.7
44

5-
toolchain go1.23.1
5+
toolchain go1.23.4
66

77
require (
88
github.com/golang/mock v1.6.0
99
github.com/hashicorp/terraform-plugin-framework v0.10.0
1010
github.com/hashicorp/terraform-plugin-framework-validators v0.4.0
1111
github.com/hashicorp/terraform-plugin-log v0.9.0
1212
github.com/sethvargo/go-retry v0.2.3
13-
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20250111091824-e051c979c3dd
13+
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20250204064923-ec656335987b
1414
)
1515

1616
require github.com/stretchr/testify v1.8.2 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9
169169
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
170170
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
171171
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
172-
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20250111091824-e051c979c3dd h1:vuMsPasq6Uzoy5fBJ0HJz7/jiCuLhKRj+LOyNVolqCk=
173-
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20250111091824-e051c979c3dd/go.mod h1:5vW0xIzIZw+1djkiWKx0qqNmqbRBSf4mjc4qw8lIMik=
172+
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20250204064923-ec656335987b h1:yvhcGfFhG06y3I6KOJBogTkCwZasKZiroRjpVbXYa1s=
173+
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20250204064923-ec656335987b/go.mod h1:5vW0xIzIZw+1djkiWKx0qqNmqbRBSf4mjc4qw8lIMik=
174174
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
175175
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
176176
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

managed/fflags/feature_flags.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ type FeatureFlag string
1515
const (
1616
CONNECTION_POOLING FeatureFlag = "CONNECTION_POOLING"
1717
DR FeatureFlag = "DR"
18+
PITR FeatureFlag = "PITR"
19+
PITR_RESTORE FeatureFlag = "PITR_RESTORE"
20+
PITR_CLONE FeatureFlag = "PITR_CLONE"
1821
)
1922

2023
var flagEnabled = map[FeatureFlag]bool{
2124
CONNECTION_POOLING: false,
2225
DR: false,
26+
PITR: false,
27+
PITR_RESTORE: false,
28+
PITR_CLONE: false,
2329
}
2430

2531
func (f FeatureFlag) String() string {

managed/models.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,3 +402,40 @@ type DrConfig struct {
402402
TargetClusterId types.String `tfsdk:"target_cluster_id"`
403403
Databases []types.String `tfsdk:"databases"`
404404
}
405+
406+
type PitrConfig struct {
407+
AccountId types.String `tfsdk:"account_id"`
408+
ProjectId types.String `tfsdk:"project_id"`
409+
ClusterId types.String `tfsdk:"cluster_id"`
410+
PitrConfigId types.String `tfsdk:"pitr_config_id"`
411+
NamespaceId types.String `tfsdk:"namespace_id"`
412+
NamespaceName types.String `tfsdk:"namespace_name"`
413+
NamespaceType types.String `tfsdk:"namespace_type"`
414+
RetentionPeriodInDays types.Int64 `tfsdk:"retention_period_in_days"`
415+
State types.String `tfsdk:"state"`
416+
EarliestRecoveryTimeMillis types.Int64 `tfsdk:"earliest_recovery_time_millis"`
417+
LatestRecoveryTimeMillis types.Int64 `tfsdk:"latest_recovery_time_millis"`
418+
}
419+
420+
type PitrRestore struct {
421+
AccountId types.String `tfsdk:"account_id"`
422+
ProjectId types.String `tfsdk:"project_id"`
423+
ClusterId types.String `tfsdk:"cluster_id"`
424+
PitrConfigId types.String `tfsdk:"pitr_config_id"`
425+
PitrRestoreId types.String `tfsdk:"pitr_restore_id"`
426+
RestoreAtMillis types.Int64 `tfsdk:"restore_at_millis"`
427+
State types.String `tfsdk:"state"`
428+
}
429+
430+
type PitrClone struct {
431+
AccountId types.String `tfsdk:"account_id"`
432+
ProjectId types.String `tfsdk:"project_id"`
433+
ClusterId types.String `tfsdk:"cluster_id"`
434+
CloneNamespaceId types.String `tfsdk:"clone_namespace_id"`
435+
CloneAs types.String `tfsdk:"clone_as"`
436+
SourceNamespaceId types.String `tfsdk:"source_namespace_id"`
437+
NamespaceName types.String `tfsdk:"namespace_name"`
438+
NamespaceType types.String `tfsdk:"namespace_type"`
439+
CloneAtMillis types.Int64 `tfsdk:"clone_at_millis"`
440+
State types.String `tfsdk:"state"`
441+
}

managed/provider.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,21 @@ func (p *provider) GetResources(_ context.Context) (map[string]tfsdk.ResourceTyp
166166
resources["ybm_dr_config"] = resourceDrConfigType{}
167167
}
168168

169+
// Add PITR config resource only if the feature flag is enabled
170+
if fflags.IsFeatureFlagEnabled(fflags.PITR) {
171+
resources["ybm_pitr_config"] = resourcePitrConfigType{}
172+
}
173+
174+
// Add PITR restore resource only if the feature flag is enabled
175+
if fflags.IsFeatureFlagEnabled(fflags.PITR_RESTORE) {
176+
resources["ybm_pitr_restore"] = resourcePitrRestoreType{}
177+
}
178+
179+
// Add PITR clone resource only if the feature flag is enabled
180+
if fflags.IsFeatureFlagEnabled(fflags.PITR_CLONE) {
181+
resources["ybm_pitr_clone"] = resourcePitrCloneType{}
182+
}
183+
169184
return resources, nil
170185
}
171186

0 commit comments

Comments
 (0)