Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9ec6758
go mod
austinvalle Jul 9, 2025
5eeac4c
generate RPC methods
austinvalle Jul 9, 2025
bf10880
protov5 and fwserver impl
austinvalle Jul 9, 2025
3c21a45
protov6 copy
austinvalle Jul 9, 2025
61eadc9
add initial schema attributes and unlinked schema
austinvalle Jul 10, 2025
0e5df9c
implement unlinked schemas, some attributes, and the rpcs
austinvalle Jul 10, 2025
32b2083
the rest of the tests
austinvalle Jul 10, 2025
dcd6748
Merge branch 'main' into av/action-schema
austinvalle Jul 11, 2025
3a1048c
fix double import
austinvalle Jul 11, 2025
7e5fd9f
external interfaces for plan / configure
austinvalle Jul 11, 2025
95e7673
plan action impl and fwserver tests
austinvalle Jul 14, 2025
5d5960a
proto server tests
austinvalle Jul 14, 2025
7ec37c2
from/to plan tests
austinvalle Jul 14, 2025
e43f576
from invoke
austinvalle Jul 14, 2025
2f08b28
add invoke impl with just completed event
austinvalle Jul 14, 2025
261ef7d
fix map access in unit tests
austinvalle Jul 14, 2025
8fdf71d
Merge branch 'main' into av/unlinked-action-impl
austinvalle Jul 15, 2025
47f9631
implementation of sending progress events
austinvalle Jul 15, 2025
119f4c5
mention progress events
austinvalle Jul 15, 2025
98f7232
comments
austinvalle Jul 15, 2025
ea2deb8
all attributes (primitive, collection, nested)
austinvalle Jul 15, 2025
21ffee7
add blocks and docs
austinvalle Jul 15, 2025
1503be5
update all commented out custom type tests
austinvalle Jul 16, 2025
68a38e4
Merge branch 'main' into av/all-schemas-types
austinvalle Jul 16, 2025
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
2 changes: 0 additions & 2 deletions action/schema/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
)

// TODO:Actions: Add all of the attribute and nested attribute types listed below
//
// Attribute define a value field inside an action type schema. Implementations in this
// package include:
// - BoolAttribute
Expand Down
2 changes: 0 additions & 2 deletions action/schema/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
)

// TODO:Actions: Add all of the block and nested block types listed below
//
// Block defines a structural field inside an action type schema. Implementations in this
// package include:
// - ListNestedBlock
Expand Down
3 changes: 1 addition & 2 deletions action/schema/bool_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ type BoolAttribute struct {
CustomType basetypes.BoolTypable

// Required indicates whether the practitioner must enter a value for
// this attribute or not. Required and Optional cannot both be true,
// and Required and Computed cannot both be true.
// this attribute or not. Required and Optional cannot both be true.
Required bool

// Optional indicates whether the practitioner can choose to enter a value
Expand Down
13 changes: 13 additions & 0 deletions action/schema/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

// Package schema contains all available schema functionality for actions.
// Action schemas define the structure and value types for configuration data.
// Schemas are implemented via the action.Action type Schema method.
//
// There are three different types of action schemas, which define how a practitioner can trigger an action,
// as well as what effect the action can have on the state.
// - [UnlinkedSchema] actions are actions that cannot cause changes to resource states.
// - [LifecycleSchema] actions are actions that can cause changes to exactly one resource state.
// - [LinkedSchema] actions are actions that can cause changes to one or more resource states.
package schema
170 changes: 170 additions & 0 deletions action/schema/dynamic_attribute.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package schema

import (
"github.com/hashicorp/terraform-plugin-go/tftypes"

"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
)

// Ensure the implementation satisifies the desired interfaces.
var (
_ Attribute = DynamicAttribute{}
)

// DynamicAttribute represents a schema attribute that is a dynamic, rather
// than a single static type. Static types are always preferable over dynamic
// types in Terraform as practitioners will receive less helpful configuration
// assistance from validation error diagnostics and editor integrations. When
// retrieving the value for this attribute, use types.Dynamic as the value type
// unless the CustomType field is set.
//
// The concrete value type for a dynamic is determined at runtime in this order:
// 1. By Terraform, if defined in the configuration (if Required or Optional).
// 2. By the provider (if Computed).
//
// Once the concrete value type has been determined, it must remain consistent between
// plan and apply or Terraform will return an error.
type DynamicAttribute struct {
// CustomType enables the use of a custom attribute type in place of the
// default basetypes.DynamicType. When retrieving data, the basetypes.DynamicValuable
// associated with this custom type must be used in place of types.Dynamic.
CustomType basetypes.DynamicTypable

// Required indicates whether the practitioner must enter a value for
// this attribute or not. Required and Optional cannot both be true.
Required bool

// Optional indicates whether the practitioner can choose to enter a value
// for this attribute or not. Optional and Required cannot both be true.
Optional bool

// Description is used in various tooling, like the language server, to
// give practitioners more information about what this attribute is,
// what it's for, and how it should be used. It should be written as
// plain text, with no special formatting.
Description string

// MarkdownDescription is used in various tooling, like the
// documentation generator, to give practitioners more information
// about what this attribute is, what it's for, and how it should be
// used. It should be formatted using Markdown.
MarkdownDescription string

// DeprecationMessage defines warning diagnostic details to display when
// practitioner configurations use this Attribute. The warning diagnostic
// summary is automatically set to "Attribute Deprecated" along with
// configuration source file and line information.
//
// Set this field to a practitioner actionable message such as:
//
// - "Configure other_attribute instead. This attribute will be removed
// in the next major version of the provider."
// - "Remove this attribute's configuration as it no longer is used and
// the attribute will be removed in the next major version of the
// provider."
//
// In Terraform 1.2.7 and later, this warning diagnostic is displayed any
// time a practitioner attempts to configure a value for this attribute and
// certain scenarios where this attribute is referenced.
//
// In Terraform 1.2.6 and earlier, this warning diagnostic is only
// displayed when the Attribute is Required or Optional, and if the
// practitioner configuration sets the value to a known or unknown value
// (which may eventually be null).
//
// Across any Terraform version, there are no warnings raised for
// practitioner configuration values set directly to null, as there is no
// way for the framework to differentiate between an unset and null
// configuration due to how Terraform sends configuration information
// across the protocol.
//
// Additional information about deprecation enhancements for read-only
// attributes can be found in:
//
// - https://github.com/hashicorp/terraform/issues/7569
//
DeprecationMessage string
}

// ApplyTerraform5AttributePathStep always returns an error as it is not
// possible to step further into a DynamicAttribute.
func (a DynamicAttribute) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (interface{}, error) {
return a.GetType().ApplyTerraform5AttributePathStep(step)
}

// Equal returns true if the given Attribute is a DynamicAttribute
// and all fields are equal.
func (a DynamicAttribute) Equal(o fwschema.Attribute) bool {
if _, ok := o.(DynamicAttribute); !ok {
return false
}

return fwschema.AttributesEqual(a, o)
}

// GetDeprecationMessage returns the DeprecationMessage field value.
func (a DynamicAttribute) GetDeprecationMessage() string {
return a.DeprecationMessage
}

// GetDescription returns the Description field value.
func (a DynamicAttribute) GetDescription() string {
return a.Description
}

// GetMarkdownDescription returns the MarkdownDescription field value.
func (a DynamicAttribute) GetMarkdownDescription() string {
return a.MarkdownDescription
}

// GetType returns types.DynamicType or the CustomType field value if defined.
func (a DynamicAttribute) GetType() attr.Type {
if a.CustomType != nil {
return a.CustomType
}

return types.DynamicType
}

// IsComputed always returns false as action schema attributes cannot be Computed.
func (a DynamicAttribute) IsComputed() bool {
return false
}

// IsOptional returns the Optional field value.
func (a DynamicAttribute) IsOptional() bool {
return a.Optional
}

// IsRequired returns the Required field value.
func (a DynamicAttribute) IsRequired() bool {
return a.Required
}

// IsSensitive always returns false as action schema attributes cannot be Sensitive.
func (a DynamicAttribute) IsSensitive() bool {
return false
}

// IsWriteOnly always returns false as action schema attributes cannot be WriteOnly.
func (a DynamicAttribute) IsWriteOnly() bool {
return false
}

// IsRequiredForImport returns false as this behavior is only relevant
// for managed resource identity schema attributes.
func (a DynamicAttribute) IsRequiredForImport() bool {
return false
}

// IsOptionalForImport returns false as this behavior is only relevant
// for managed resource identity schema attributes.
func (a DynamicAttribute) IsOptionalForImport() bool {
return false
}
Loading
Loading