Skip to content

Commit 4c616cc

Browse files
Merge branch 'main' into zhiwei/collections-length-func
2 parents b34d0f0 + 0dfd722 commit 4c616cc

File tree

109 files changed

+4688
-234
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+4688
-234
lines changed

.changes/1.15.1.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## 1.15.1 (July 31, 2025)
2+
3+
BUG FIXES:
4+
5+
* all: Fixed bug with `UseStateForUnknown` where known null state values were not preserved during update plans. ([#1117](https://github.com/hashicorp/terraform-plugin-framework/issues/1117))
6+

.changes/1.16.0-alpha.1.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## 1.16.0-alpha.1 (July 22, 2025)
2+
3+
NOTES:
4+
5+
* This alpha pre-release contains the initial implementation for list resource that returns a list of resource identities for a single managed resource type. ([#1157](https://github.com/hashicorp/terraform-plugin-framework/issues/1157))
6+
* The ListResource and ValidateListResourceConfig RPCs are considered experimental and may change up until general availability ([#1178](https://github.com/hashicorp/terraform-plugin-framework/issues/1178))
7+
8+
BUG FIXES:
9+
10+
* all: Fixed bug with `UseStateForUnknown` where known null state values were not preserved during update plans. ([#1117](https://github.com/hashicorp/terraform-plugin-framework/issues/1117))
11+

.changes/1.16.0-beta.1.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## 1.16.0-beta.1 (July 31, 2025)
2+
3+
FEATURES:
4+
5+
* actions: Initial package implementation and new Actions RPC support ([#1181](https://github.com/hashicorp/terraform-plugin-framework/issues/1181))
6+
7+
ENHANCEMENTS:
8+
9+
* list: add `limit` field to `ListResult` ([#1182](https://github.com/hashicorp/terraform-plugin-framework/issues/1182))
10+
* list: add primitives, list and map types to schema ([#1177](https://github.com/hashicorp/terraform-plugin-framework/issues/1177))
11+
* actions: add schema interface and unlinked schema ([#1183](https://github.com/hashicorp/terraform-plugin-framework/issues/1183))
12+
* actions: add standard validation methods and interfaces for `ValidateActionConfig` RPCs ([#1188](https://github.com/hashicorp/terraform-plugin-framework/issues/1188))
13+
* actions: add attributes and nested blocks to schema package ([#1186](https://github.com/hashicorp/terraform-plugin-framework/issues/1186))
14+
15+
BUG FIXES:
16+
17+
* list: call `Configure` in `ListResource` RPC and remove the `ListResource` call in `ValidateListResourceConfig` ([#1192](https://github.com/hashicorp/terraform-plugin-framework/issues/1192))
18+

.changes/unreleased/BUG FIXES-20250612-115411.yaml

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

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
## 1.16.0-beta.1 (July 31, 2025)
2+
3+
FEATURES:
4+
5+
* actions: Initial package implementation and new Actions RPC support ([#1181](https://github.com/hashicorp/terraform-plugin-framework/issues/1181))
6+
7+
ENHANCEMENTS:
8+
9+
* list: add `limit` field to `ListResult` ([#1182](https://github.com/hashicorp/terraform-plugin-framework/issues/1182))
10+
* list: add primitives, list and map types to schema ([#1177](https://github.com/hashicorp/terraform-plugin-framework/issues/1177))
11+
* actions: add schema interface and unlinked schema ([#1183](https://github.com/hashicorp/terraform-plugin-framework/issues/1183))
12+
* actions: add standard validation methods and interfaces for `ValidateActionConfig` RPCs ([#1188](https://github.com/hashicorp/terraform-plugin-framework/issues/1188))
13+
* actions: add attributes and nested blocks to schema package ([#1186](https://github.com/hashicorp/terraform-plugin-framework/issues/1186))
14+
15+
BUG FIXES:
16+
17+
* list: call `Configure` in `ListResource` RPC and remove the `ListResource` call in `ValidateListResourceConfig` ([#1192](https://github.com/hashicorp/terraform-plugin-framework/issues/1192))
18+
19+
## 1.16.0-alpha.1 (July 22, 2025)
20+
21+
NOTES:
22+
23+
* This alpha pre-release contains the initial implementation for list resource that returns a list of resource identities for a single managed resource type. ([#1157](https://github.com/hashicorp/terraform-plugin-framework/issues/1157))
24+
* The ListResource and ValidateListResourceConfig RPCs are considered experimental and may change up until general availability ([#1178](https://github.com/hashicorp/terraform-plugin-framework/issues/1178))
25+
26+
BUG FIXES:
27+
28+
* all: Fixed bug with `UseStateForUnknown` where known null state values were not preserved during update plans. ([#1117](https://github.com/hashicorp/terraform-plugin-framework/issues/1117))
29+
30+
## 1.15.1 (July 31, 2025)
31+
32+
BUG FIXES:
33+
34+
* all: Fixed bug with `UseStateForUnknown` where known null state values were not preserved during update plans. ([#1117](https://github.com/hashicorp/terraform-plugin-framework/issues/1117))
35+
136
## 1.15.0 (May 16, 2025)
237

338
NOTES:

action/action.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,33 @@ type ActionWithModifyPlan interface {
4949
// diagnostics to practitioners, such as validation errors.
5050
ModifyPlan(context.Context, ModifyPlanRequest, *ModifyPlanResponse)
5151
}
52+
53+
// ActionWithConfigValidators is an interface type that extends Action to include declarative validations.
54+
//
55+
// Declaring validation using this methodology simplifies implementation of
56+
// reusable functionality. These also include descriptions, which can be used
57+
// for automating documentation.
58+
//
59+
// Validation will include ConfigValidators and ValidateConfig, if both are
60+
// implemented, in addition to any Attribute or Type validation.
61+
type ActionWithConfigValidators interface {
62+
Action
63+
64+
// ConfigValidators returns a list of functions which will all be performed during validation.
65+
ConfigValidators(context.Context) []ConfigValidator
66+
}
67+
68+
// ActionWithValidateConfig is an interface type that extends Action to include imperative validation.
69+
//
70+
// Declaring validation using this methodology simplifies one-off
71+
// functionality that typically applies to a single action. Any documentation
72+
// of this functionality must be manually added into schema descriptions.
73+
//
74+
// Validation will include ConfigValidators and ValidateConfig, if both are
75+
// implemented, in addition to any Attribute or Type validation.
76+
type ActionWithValidateConfig interface {
77+
Action
78+
79+
// ValidateConfig performs the validation.
80+
ValidateConfig(context.Context, ValidateConfigRequest, *ValidateConfigResponse)
81+
}

action/config_validator.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
package action
5+
6+
import "context"
7+
8+
// ConfigValidator describes reusable Action configuration validation functionality.
9+
type ConfigValidator interface {
10+
// Description describes the validation in plain text formatting.
11+
//
12+
// This information may be automatically added to action plain text
13+
// descriptions by external tooling.
14+
Description(context.Context) string
15+
16+
// MarkdownDescription describes the validation in Markdown formatting.
17+
//
18+
// This information may be automatically added to action Markdown
19+
// descriptions by external tooling.
20+
MarkdownDescription(context.Context) string
21+
22+
// ValidateAction performs the validation.
23+
//
24+
// This method name is separate from ConfigValidators in resource and other packages in
25+
// order to allow generic validators.
26+
ValidateAction(context.Context, ValidateConfigRequest, *ValidateConfigResponse)
27+
}

action/schema/bool_attribute.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ import (
88

99
"github.com/hashicorp/terraform-plugin-framework/attr"
1010
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
11+
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema/fwxschema"
12+
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1113
"github.com/hashicorp/terraform-plugin-framework/types"
1214
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
1315
)
1416

1517
// Ensure the implementation satisfies the desired interfaces.
1618
var (
17-
_ Attribute = BoolAttribute{}
19+
_ Attribute = BoolAttribute{}
20+
_ fwxschema.AttributeWithBoolValidators = BoolAttribute{}
1821
)
1922

2023
// BoolAttribute represents a schema attribute that is a boolean. When
@@ -89,6 +92,18 @@ type BoolAttribute struct {
8992
// - https://github.com/hashicorp/terraform/issues/7569
9093
//
9194
DeprecationMessage string
95+
96+
// Validators define value validation functionality for the attribute. All
97+
// elements of the slice of AttributeValidator are run, regardless of any
98+
// previous error diagnostics.
99+
//
100+
// Many common use case validators can be found in the
101+
// github.com/hashicorp/terraform-plugin-framework-validators Go module.
102+
//
103+
// If the Type field points to a custom type that implements the
104+
// xattr.TypeWithValidate interface, the validators defined in this field
105+
// are run in addition to the validation defined by the type.
106+
Validators []validator.Bool
92107
}
93108

94109
// ApplyTerraform5AttributePathStep always returns an error as it is not
@@ -167,3 +182,8 @@ func (a BoolAttribute) IsRequiredForImport() bool {
167182
func (a BoolAttribute) IsOptionalForImport() bool {
168183
return false
169184
}
185+
186+
// BoolValidators returns the Validators field value.
187+
func (a BoolAttribute) BoolValidators() []validator.Bool {
188+
return a.Validators
189+
}

action/schema/bool_attribute_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
1717
"github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema"
1818
"github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes"
19+
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1920
"github.com/hashicorp/terraform-plugin-framework/types"
2021
)
2122

@@ -435,3 +436,35 @@ func TestBoolAttributeIsOptionalForImport(t *testing.T) {
435436
})
436437
}
437438
}
439+
440+
func TestBoolAttributeBoolValidators(t *testing.T) {
441+
t.Parallel()
442+
443+
testCases := map[string]struct {
444+
attribute schema.BoolAttribute
445+
expected []validator.Bool
446+
}{
447+
"no-validators": {
448+
attribute: schema.BoolAttribute{},
449+
expected: nil,
450+
},
451+
"validators": {
452+
attribute: schema.BoolAttribute{
453+
Validators: []validator.Bool{},
454+
},
455+
expected: []validator.Bool{},
456+
},
457+
}
458+
459+
for name, testCase := range testCases {
460+
t.Run(name, func(t *testing.T) {
461+
t.Parallel()
462+
463+
got := testCase.attribute.BoolValidators()
464+
465+
if diff := cmp.Diff(got, testCase.expected); diff != "" {
466+
t.Errorf("unexpected difference: %s", diff)
467+
}
468+
})
469+
}
470+
}

action/schema/dynamic_attribute.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ import (
88

99
"github.com/hashicorp/terraform-plugin-framework/attr"
1010
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
11+
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema/fwxschema"
12+
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1113
"github.com/hashicorp/terraform-plugin-framework/types"
1214
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
1315
)
1416

1517
// Ensure the implementation satisifies the desired interfaces.
1618
var (
17-
_ Attribute = DynamicAttribute{}
19+
_ Attribute = DynamicAttribute{}
20+
_ fwxschema.AttributeWithDynamicValidators = DynamicAttribute{}
1821
)
1922

2023
// DynamicAttribute represents a schema attribute that is a dynamic, rather
@@ -90,6 +93,18 @@ type DynamicAttribute struct {
9093
// - https://github.com/hashicorp/terraform/issues/7569
9194
//
9295
DeprecationMessage string
96+
97+
// Validators define value validation functionality for the attribute. All
98+
// elements of the slice of AttributeValidator are run, regardless of any
99+
// previous error diagnostics.
100+
//
101+
// Many common use case validators can be found in the
102+
// github.com/hashicorp/terraform-plugin-framework-validators Go module.
103+
//
104+
// If the Type field points to a custom type that implements the
105+
// xattr.TypeWithValidate interface, the validators defined in this field
106+
// are run in addition to the validation defined by the type.
107+
Validators []validator.Dynamic
93108
}
94109

95110
// ApplyTerraform5AttributePathStep always returns an error as it is not
@@ -168,3 +183,8 @@ func (a DynamicAttribute) IsRequiredForImport() bool {
168183
func (a DynamicAttribute) IsOptionalForImport() bool {
169184
return false
170185
}
186+
187+
// DynamicValidators returns the Validators field value.
188+
func (a DynamicAttribute) DynamicValidators() []validator.Dynamic {
189+
return a.Validators
190+
}

0 commit comments

Comments
 (0)