Skip to content

Commit b8c4f9f

Browse files
Bigtable: Mark GC policy legacy fields as not recommended (#6577) (#4919)
* Mark GC policy legacy fields deprecated * Mark fields as deprecated in comments * Revert back to really deprecating the fields. * Update doc to recommend gc_rules. Signed-off-by: Modular Magician <[email protected]> Signed-off-by: Modular Magician <[email protected]>
1 parent ca401b4 commit b8c4f9f

File tree

3 files changed

+48
-37
lines changed

3 files changed

+48
-37
lines changed

.changelog/6577.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:none
2+
3+
```

google-beta/resource_bigtable_gc_policy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func resourceBigtableGCPolicy() *schema.Resource {
103103
Type: schema.TypeString,
104104
Optional: true,
105105
ForceNew: true,
106-
Description: `If multiple policies are set, you should choose between UNION OR INTERSECTION.`,
106+
Description: `NOTE: 'gc_rules' is more flexible, and should be preferred over this field for new resources. This field may be deprecated in the future. If multiple policies are set, you should choose between UNION OR INTERSECTION.`,
107107
ValidateFunc: validation.StringInSlice([]string{GCPolicyModeIntersection, GCPolicyModeUnion}, false),
108108
ConflictsWith: []string{"gc_rules"},
109109
},
@@ -112,7 +112,7 @@ func resourceBigtableGCPolicy() *schema.Resource {
112112
Type: schema.TypeList,
113113
Optional: true,
114114
ForceNew: true,
115-
Description: `GC policy that applies to all cells older than the given age.`,
115+
Description: `NOTE: 'gc_rules' is more flexible, and should be preferred over this field for new resources. This field may be deprecated in the future. GC policy that applies to all cells older than the given age.`,
116116
MaxItems: 1,
117117
Elem: &schema.Resource{
118118
Schema: map[string]*schema.Schema{
@@ -143,7 +143,7 @@ func resourceBigtableGCPolicy() *schema.Resource {
143143
Type: schema.TypeList,
144144
Optional: true,
145145
ForceNew: true,
146-
Description: `GC policy that applies to all versions of a cell except for the most recent.`,
146+
Description: `NOTE: 'gc_rules' is more flexible, and should be preferred over this field for new resources. This field may be deprecated in the future. GC policy that applies to all versions of a cell except for the most recent.`,
147147
Elem: &schema.Resource{
148148
Schema: map[string]*schema.Schema{
149149
"number": {

website/docs/r/bigtable_gc_policy.html.markdown

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,16 @@ resource "google_bigtable_gc_policy" "policy" {
4747
column_family = "name"
4848
deletion_policy = "ABANDON"
4949
50-
max_age {
51-
duration = "168h"
50+
51+
gc_rules = <<EOF
52+
{
53+
"rules": [
54+
{
55+
"max_age": "168h"
56+
}
57+
]
5258
}
59+
EOF
5360
}
5461
```
5562

@@ -62,21 +69,23 @@ resource "google_bigtable_gc_policy" "policy" {
6269
column_family = "name"
6370
deletion_policy = "ABANDON"
6471
65-
mode = "UNION"
66-
67-
max_age {
68-
duration = "168h" # 7 days
69-
}
70-
71-
max_version {
72-
number = 10
72+
gc_rules = <<EOF
73+
{
74+
"mode": "union",
75+
"rules": [
76+
{
77+
"max_age": "168h"
78+
},
79+
{
80+
"max_version": 10
81+
}
82+
]
7383
}
84+
EOF
7485
}
7586
```
7687

77-
For complex, nested policies, an optional `gc_rules` field are supported. This field
78-
conflicts with `mode`, `max_age` and `max_version`. This field is a serialized JSON
79-
string. Example:
88+
An example of more complex GC policy:
8089
```hcl
8190
resource "google_bigtable_instance" "instance" {
8291
name = "instance_name"
@@ -106,27 +115,26 @@ resource "google_bigtable_gc_policy" "policy" {
106115
deletion_policy = "ABANDON"
107116
108117
gc_rules = <<EOF
109-
{
110-
"mode": "union",
111-
"rules": [
112-
{
113-
"max_age": "10h"
114-
},
115-
{
116-
"mode": "intersection",
117-
"rules": [
118-
{
119-
"max_age": "2h"
120-
},
121-
{
122-
"max_version": 2
123-
}
124-
]
125-
}
126-
]
127-
}
128-
EOF
129-
118+
{
119+
"mode": "union",
120+
"rules": [
121+
{
122+
"max_age": "10h"
123+
},
124+
{
125+
"mode": "intersection",
126+
"rules": [
127+
{
128+
"max_age": "2h"
129+
},
130+
{
131+
"max_version": 2
132+
}
133+
]
134+
}
135+
]
136+
}
137+
EOF
130138
}
131139
```
132140
This is equivalent to running the following `cbt` command:

0 commit comments

Comments
 (0)