Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "field_manager" attribute #1831

Merged
merged 2 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/1831.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
Add "field_manager" attribute to kubernetes_labels, kubernetes_annotations, kubernetes_config_map_v1_data
```
8 changes: 7 additions & 1 deletion kubernetes/resource_kubernetes_annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ func resourceKubernetesAnnotations() *schema.Resource {
Description: "Force overwriting annotations that were created or edited outside of Terraform.",
Optional: true,
},
"field_manager": {
Type: schema.TypeString,
Description: "Set the name of the field manager for the specified labels.",
Optional: true,
Default: defaultFieldManagerName,
},
},
}
}
Expand Down Expand Up @@ -261,7 +267,7 @@ func resourceKubernetesAnnotationsUpdate(ctx context.Context, d *schema.Resource
types.ApplyPatchType,
patchbytes,
v1.PatchOptions{
FieldManager: defaultFieldManagerName,
FieldManager: d.Get("field_manager").(string),
jrhouston marked this conversation as resolved.
Show resolved Hide resolved
Force: ptrToBool(d.Get("force").(bool)),
},
)
Expand Down
7 changes: 7 additions & 0 deletions kubernetes/resource_kubernetes_annotations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func TestAccKubernetesAnnotations_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "kind", "ConfigMap"),
resource.TestCheckResourceAttr(resourceName, "metadata.0.name", name),
resource.TestCheckResourceAttr(resourceName, "annotations.%", "0"),
resource.TestCheckResourceAttr(resourceName, "field_manager", "tftest"),
jrhouston marked this conversation as resolved.
Show resolved Hide resolved
),
},
{
Expand All @@ -43,6 +44,7 @@ func TestAccKubernetesAnnotations_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "annotations.%", "2"),
resource.TestCheckResourceAttr(resourceName, "annotations.test1", "one"),
resource.TestCheckResourceAttr(resourceName, "annotations.test2", "two"),
resource.TestCheckResourceAttr(resourceName, "field_manager", "tftest"),
),
},
{
Expand All @@ -54,6 +56,7 @@ func TestAccKubernetesAnnotations_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "annotations.%", "2"),
resource.TestCheckResourceAttr(resourceName, "annotations.test1", "one"),
resource.TestCheckResourceAttr(resourceName, "annotations.test3", "three"),
resource.TestCheckResourceAttr(resourceName, "field_manager", "tftest"),
),
},
{
Expand All @@ -63,6 +66,7 @@ func TestAccKubernetesAnnotations_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "kind", "ConfigMap"),
resource.TestCheckResourceAttr(resourceName, "metadata.0.name", name),
resource.TestCheckResourceAttr(resourceName, "annotations.%", "0"),
resource.TestCheckResourceAttr(resourceName, "field_manager", "tftest"),
),
},
},
Expand All @@ -77,6 +81,7 @@ func testAccKubernetesAnnotations_empty(name string) string {
name = %q
}
annotations = {}
field_manager = "tftest"
}
`, name)
}
Expand All @@ -92,6 +97,7 @@ func testAccKubernetesAnnotations_basic(name string) string {
"test1" = "one"
"test2" = "two"
}
field_manager = "tftest"
}
`, name)
}
Expand All @@ -107,6 +113,7 @@ func testAccKubernetesAnnotations_modified(name string) string {
"test1" = "one"
"test3" = "three"
}
field_manager = "tftest"
}
`, name)
}
8 changes: 7 additions & 1 deletion kubernetes/resource_kubernetes_config_map_v1_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ func resourceKubernetesConfigMapV1Data() *schema.Resource {
Description: "Force overwriting data that is managed outside of Terraform.",
Optional: true,
},
"field_manager": {
Type: schema.TypeString,
Description: "Set the name of the field manager for the specified labels.",
Optional: true,
Default: defaultFieldManagerName,
},
},
}
}
Expand Down Expand Up @@ -179,7 +185,7 @@ func resourceKubernetesConfigMapV1DataUpdate(ctx context.Context, d *schema.Reso
types.ApplyPatchType,
patchbytes,
v1.PatchOptions{
FieldManager: defaultFieldManagerName,
FieldManager: d.Get("field_manager").(string),
Force: ptrToBool(d.Get("force").(bool)),
},
)
Expand Down
7 changes: 7 additions & 0 deletions kubernetes/resource_kubernetes_config_map_v1_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func TestAccKubernetesConfigMapV1Data_basic(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "metadata.0.name", name),
resource.TestCheckResourceAttr(resourceName, "data.%", "0"),
resource.TestCheckResourceAttr(resourceName, "field_manager", "tftest"),
),
},
{
Expand All @@ -39,6 +40,7 @@ func TestAccKubernetesConfigMapV1Data_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "data.%", "2"),
resource.TestCheckResourceAttr(resourceName, "data.test1", "one"),
resource.TestCheckResourceAttr(resourceName, "data.test2", "two"),
resource.TestCheckResourceAttr(resourceName, "field_manager", "tftest"),
),
},
{
Expand All @@ -48,13 +50,15 @@ func TestAccKubernetesConfigMapV1Data_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "data.%", "2"),
resource.TestCheckResourceAttr(resourceName, "data.test1", "one"),
resource.TestCheckResourceAttr(resourceName, "data.test3", "three"),
resource.TestCheckResourceAttr(resourceName, "field_manager", "tftest"),
),
},
{
Config: testAccKubernetesConfigMapV1Data_empty(name),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "metadata.0.name", name),
resource.TestCheckResourceAttr(resourceName, "data.%", "0"),
resource.TestCheckResourceAttr(resourceName, "field_manager", "tftest"),
),
},
},
Expand All @@ -67,6 +71,7 @@ func testAccKubernetesConfigMapV1Data_empty(name string) string {
name = %q
}
data = {}
field_manager = "tftest"
}
`, name)
}
Expand All @@ -80,6 +85,7 @@ func testAccKubernetesConfigMapV1Data_basic(name string) string {
"test1" = "one"
"test2" = "two"
}
field_manager = "tftest"
}
`, name)
}
Expand All @@ -93,6 +99,7 @@ func testAccKubernetesConfigMapV1Data_modified(name string) string {
"test1" = "one"
"test3" = "three"
}
field_manager = "tftest"
}
`, name)
}
8 changes: 7 additions & 1 deletion kubernetes/resource_kubernetes_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ func resourceKubernetesLabels() *schema.Resource {
Description: "Force overwriting labels that were created or edited outside of Terraform.",
Optional: true,
},
"field_manager": {
Type: schema.TypeString,
Description: "Set the name of the field manager for the specified labels.",
Optional: true,
Default: defaultFieldManagerName,
},
},
}
}
Expand Down Expand Up @@ -261,7 +267,7 @@ func resourceKubernetesLabelsUpdate(ctx context.Context, d *schema.ResourceData,
types.ApplyPatchType,
patchbytes,
v1.PatchOptions{
FieldManager: defaultFieldManagerName,
FieldManager: d.Get("field_manager").(string),
Force: ptrToBool(d.Get("force").(bool)),
},
)
Expand Down
7 changes: 7 additions & 0 deletions kubernetes/resource_kubernetes_labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func TestAccKubernetesLabels_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "kind", "ConfigMap"),
resource.TestCheckResourceAttr(resourceName, "metadata.0.name", name),
resource.TestCheckResourceAttr(resourceName, "labels.%", "0"),
resource.TestCheckResourceAttr(resourceName, "field_manager", "tftest"),
),
},
{
Expand All @@ -46,6 +47,7 @@ func TestAccKubernetesLabels_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "labels.%", "2"),
resource.TestCheckResourceAttr(resourceName, "labels.test1", "one"),
resource.TestCheckResourceAttr(resourceName, "labels.test2", "two"),
resource.TestCheckResourceAttr(resourceName, "field_manager", "tftest"),
),
},
{
Expand All @@ -57,6 +59,7 @@ func TestAccKubernetesLabels_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "labels.%", "2"),
resource.TestCheckResourceAttr(resourceName, "labels.test1", "one"),
resource.TestCheckResourceAttr(resourceName, "labels.test3", "three"),
resource.TestCheckResourceAttr(resourceName, "field_manager", "tftest"),
),
},
{
Expand All @@ -66,6 +69,7 @@ func TestAccKubernetesLabels_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "kind", "ConfigMap"),
resource.TestCheckResourceAttr(resourceName, "metadata.0.name", name),
resource.TestCheckResourceAttr(resourceName, "labels.%", "0"),
resource.TestCheckResourceAttr(resourceName, "field_manager", "tftest"),
),
},
},
Expand Down Expand Up @@ -103,6 +107,7 @@ func testAccKubernetesLabels_empty(name string) string {
name = %q
}
labels = {}
field_manager = "tftest"
}
`, name)
}
Expand All @@ -118,6 +123,7 @@ func testAccKubernetesLabels_basic(name string) string {
"test1" = "one"
"test2" = "two"
}
field_manager = "tftest"
}
`, name)
}
Expand All @@ -133,6 +139,7 @@ func testAccKubernetesLabels_modified(name string) string {
"test1" = "one"
"test3" = "three"
}
field_manager = "tftest"
}
`, name)
}
1 change: 1 addition & 0 deletions website/docs/r/annotations.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The following arguments are supported:
* `metadata` - (Required) Standard metadata of the resource to be annotated.
* `annotations` - (Required) A map of annotations to apply to the resource.
* `force` - (Optional) Force management of annotations if there is a conflict.
* `field_manager` - (Optional) The name of the [field manager](https://kubernetes.io/docs/reference/using-api/server-side-apply/#field-management). Defaults to `Terraform`.

## Nested Blocks

Expand Down
1 change: 1 addition & 0 deletions website/docs/r/config_map_v1_data.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ The following arguments are supported:
* `metadata` - (Required) Standard metadata of the ConfigMap.
* `data` - (Required) A map of data to apply to the ConfigMap.
* `force` - (Optional) Force management of the configured data if there is a conflict.
* `field_manager` - (Optional) The name of the [field manager](https://kubernetes.io/docs/reference/using-api/server-side-apply/#field-management). Defaults to `Terraform`.

## Nested Blocks

Expand Down
1 change: 1 addition & 0 deletions website/docs/r/labels.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The following arguments are supported:
* `metadata` - (Required) Standard metadata of the resource to be labelled.
* `labels` - (Required) A map of labels to apply to the resource.
* `force` - (Optional) Force management of labels if there is a conflict.
* `field_manager` - (Optional) The name of the [field manager](https://kubernetes.io/docs/reference/using-api/server-side-apply/#field-management). Defaults to `Terraform`.

## Nested Blocks

Expand Down