Commit graph

58 commits

Author SHA1 Message Date
Radek Simko
0fe906fa8c make copyrightfix 2026-02-17 13:56:34 +00:00
stephybun
c9d024062a
Generate Resource Config: set state in proto req (#37895)
Some checks are pending
build / Build for windows_amd64 (push) Blocked by required conditions
build / Build for freebsd_arm (push) Blocked by required conditions
build / Build for linux_arm (push) Blocked by required conditions
build / Build for darwin_arm64 (push) Blocked by required conditions
build / Build for linux_arm64 (push) Blocked by required conditions
build / Build for windows_arm64 (push) Blocked by required conditions
build / Build Docker image for linux_386 (push) Blocked by required conditions
build / Build Docker image for linux_amd64 (push) Blocked by required conditions
build / Build Docker image for linux_arm (push) Blocked by required conditions
build / Build Docker image for linux_arm64 (push) Blocked by required conditions
build / Build e2etest for linux_386 (push) Blocked by required conditions
build / Build e2etest for windows_386 (push) Blocked by required conditions
build / Build e2etest for darwin_amd64 (push) Blocked by required conditions
build / Build e2etest for linux_amd64 (push) Blocked by required conditions
build / Build e2etest for windows_amd64 (push) Blocked by required conditions
build / Build e2etest for linux_arm (push) Blocked by required conditions
build / Build e2etest for darwin_arm64 (push) Blocked by required conditions
build / Build e2etest for linux_arm64 (push) Blocked by required conditions
build / Run e2e test for linux_386 (push) Blocked by required conditions
build / Run e2e test for windows_386 (push) Blocked by required conditions
build / Run e2e test for darwin_amd64 (push) Blocked by required conditions
build / Run e2e test for linux_amd64 (push) Blocked by required conditions
build / Run e2e test for windows_amd64 (push) Blocked by required conditions
build / Run e2e test for linux_arm (push) Blocked by required conditions
build / Run e2e test for linux_arm64 (push) Blocked by required conditions
build / Run terraform-exec test for linux amd64 (push) Blocked by required conditions
Quick Checks / Unit Tests (push) Waiting to run
Quick Checks / Race Tests (push) Waiting to run
Quick Checks / End-to-end Tests (push) Waiting to run
Quick Checks / Code Consistency Checks (push) Waiting to run
* marshal state and set in the proto req for generate resource config

* changelog

* set state in the proto req for generate resource config in plugin6

* add GRPC tests for GenerateResourceConfig

* remove changelog entry since this fix is backported to 1.14
2025-12-10 15:19:29 +01:00
Daniel Banck
6b038754f0
Fix list resource diagnostics check (#37863)
* Fix list resource diagnostics check

* Improve error message on missing identity schema

* Add test case for list response diagnostics

* Add changelog
2025-11-04 13:43:19 +01:00
Radek Simko
922fdb2382
Implement LockState & UnlockState provider methods (#37711) 2025-10-03 10:02:02 +01:00
Radek Simko
51fc4c161f
PSS: Implement ReadStateBytes + WriteStateBytes (#37440)
* Implement ReadStateBytes + WriteStateBytes

* [WIP] -  Testing ReadStateBytes and WriteStateBytes (#37464)

* Fix nil pointer error

* Add WIP test for ReadStateBytes

* Move test mock to separate testing file

* Update mock to send unexpected EOF when there's a problem returning data and it's not a true EOF

* Add test case for when length != expected length

* Add test for when trying to read state from a store type that doesn't exist

* Change symbol names to lowercase

* Add ability to force a diagnostic to be returned from `mockReadStateBytesClient`'s `Recv` method

* Add test showing error diagnostics raised by the ReadStateBytes client are returned

* Add missing header

* Simplify mock by using an embedded type

* Rename `mockOpts` to `mockReadStateBytesOpts`

* Update existing tests to assert what arguments are passed to the RPC method call

* Add mock WriteStateBytesClient which uses `go.uber.org/mock/gomock` to enable assertions about calls to Send

* Add a test for WriteStateBytes that makes assertions about calls to the Send method

* Update test case to explicitly test writing data smaller than the chunk size

* Implement chunking in WriteStateBytes, add test case to assert expected chunking behaviour

* Add generated mock for Provider_WriteStateBytesClient in protocol v6

* Update tests to use new `MockProvider_WriteStateBytesClient`, remove handwritten mock

* Update code comments in test

* Add tests for diagnostics and errors returned during WriteStateBytes

* Add generated mock for Provider_ReadStateBytesClient in protocol v6, replace old mock

* Add test case for grpc errors in ReadStateBytes, fix how error is returned

* Typo in comment

* Add missing warning test, rename some test cases

* Update proto file definition of Read/WriteStateBytes RPCs (#37529)

* Update Read/WriteStateBytes RPCs to match https://github.com/hashicorp/terraform-plugin-go/pull/531

* Run `make protobuf`

* Run `make generate`

* Update use of `proto.ReadStateBytes_ResponseChunk` in tests

* Fix how diagnostics are handled alongside EOF error, update ReadStateBytes test

* More fixes - test setup was incorrect

I think? I assume that a response would be returned full of zero-values when EOF is encountered.

* WIP - avoid crash if chunk is nil

* Sarah's updates to radek/pss-read-write (#37642)

* Update code to not expect a chunk when EOF encountered

* Return early if any grpc errors are encountered during ReadStateBytes

* Close the stream with CloseSend once everything's read without error. Add test case about handling grpc errors from CloseSend.

* Fix test case about warnings: We would expect to receive a chunk with data alongside the warning and have a normal closing of the stream after EOF

* Add log line, remove unneeded type info

* Implement configurable state chunk size

* handle metadata in WriteStateBytes correctly

* validate chunk sizes received from provider

* ReadStateBytes: avoid early return on warnings

---------

Co-authored-by: Sarah French <15078782+SarahFrench@users.noreply.github.com>
2025-09-26 17:03:02 +01:00
Samsondeen
a7504719ef
list: send non-null "config" object to provider when not present in the list block (#37620) 2025-09-24 09:30:59 +02:00
Daniel Schmidt
871451122f actions: move schema to single action type and remove linked resources
we want to leave the door open to evolve the design in the future based on feedback
2025-09-15 17:09:22 +02:00
James Bardin
4e8717295e grpc method impl 2025-08-29 15:00:30 -04:00
Daniel Banck
2563b07813
Allow list events with only warnings (#37415)
This updates the event processing logic. Terraform now allows error and
warning diagnostics for list events with all other fields set to null.
The combination of a warning with a valid result is still possible.
2025-08-08 11:24:05 +02:00
Daniel Schmidt
17e7338b0f add client capabilites across the board 2025-08-05 15:34:13 +02:00
Kristin Laemmert
0374f04424
Add ValidateActionConfig to provider interface, protocol & internal implementations (#37345)
* Add ValidateActionConfig to provider interface and protocol

* Update internal/provider-simple-v6/provider.go

Co-authored-by: Daniel Schmidt <danielmschmidt92@gmail.com>

---------

Co-authored-by: Daniel Schmidt <danielmschmidt92@gmail.com>
2025-07-18 14:14:44 -04:00
Daniel Schmidt
24773cf86e improve allocation 2025-07-10 16:06:44 +02:00
Daniel Schmidt
ac132d1b15 add provider implementation for actions 2025-07-10 16:06:44 +02:00
Sarah French
0f8e77a50f
PSS: Add GetStates and DeleteState RPCs to plugin protocol v6 (#37288)
* Add GetStates RPC method to Plugin Protocol v6

* Add DeleteState RPC method to Plugin Protocol v6

* Add methods to provider-simple

* Fix error messages

* Apply suggestions from code review

Co-authored-by: Radek Simko <radeksimko@users.noreply.github.com>

* Change how GetStates RPC returns the list of state names

* Change GetStates implementation to use new data type

* `make protobuf` to accommodate new code comments

---------

Co-authored-by: Radek Simko <radeksimko@users.noreply.github.com>
2025-07-07 10:40:45 +01:00
Samsondeen
3d3439e00e
Testing list blocks with the gRPC Provider (#37236) 2025-06-18 11:16:29 +02:00
Daniel Banck
540512e27b
Add config to List response (#37237) 2025-06-13 17:06:51 +02:00
Samsondeen
e178088a5b
unwrap nested config (#37235) 2025-06-13 13:28:19 +02:00
Samsondeen
cacd7861e5
add nested config block to list block (#37229) 2025-06-11 15:37:45 +02:00
Samsondeen
685ff9f192
Schema representation of list block config and results (#37209) 2025-06-10 20:08:54 +02:00
Daniel Banck
cb58a15f3d
Implement ListResource RPC (TF-25509) (#37092)
* Implement ListResource RPC via callbacks

* Implement ListResource with iterators

* Change `ListResourceResponse` to slice

* Turn ListResourceResponse into a struct

* Add a limit for ListResource

* explicitly cancel stream when listing resources

---------

Co-authored-by: Samsondeen Dare <samsondeen.dare@hashicorp.com>
2025-06-04 09:40:10 +02:00
Radek Simko
643266dc90
Add initial state store protocol skeleton (#37197)
* Add initial state store protocol skeleton

Introduce ValidateStateStoreConfig + ConfigureStateStore
Update GetProviderSchema + GetMetadata (for mux)

* address PR feedback
2025-06-03 13:52:35 +00:00
Daniel Banck
44ae7da18e
Update Plugin Protocol for List and Implement ValidateListResourceConfig (#37007)
* Minor auto-formatting changes

* Add list RPC and schema protobuf definitions

* make protobuf

* make generate

* Add ValidateListResourceConfig implementation
2025-05-19 10:20:52 +02:00
Daniel Banck
421fe3580f
Check GetResourceIdentitySchemas diagnostics and return early (#36999) 2025-05-16 13:55:12 +02:00
Austin Valle
5c4c669882
Fix ImportResourceState RPC response decoding for identity data (#36806)
* Fix `ImportResourceState` RPC response decoding for identity data

* add tests for importy by identity

* re-run action for flakey UI test
2025-04-01 18:03:06 +02:00
Austin Valle
31f1ef37a1 update log 2025-03-24 17:34:03 -04:00
Daniel Schmidt
fec6e4b552 send resource identities to provider calls 2025-03-12 09:18:55 +01:00
Daniel Banck
b2b42c0fb4
Store resource identities in state (TF-23255) (#36464)
* Persist resource identity in Terraform state

* make syncdeps

* Move identity schema merging closer to the protocol

* mock GetResourceIdentitySchemas

* Fix identity refresh tests

* Add more tests

* Change grcpwrap upgrade identity

* Review feedback

* Remove unnecessary version conversion

* Check if GetResourceIdentitySchemas RPC call is implemented

* Update function signature docs

* Adapt protocol changes

* Check unimplemented error for identities in GetSchema
2025-03-11 20:58:44 +01:00
Daniel Banck
10c9b64007
Rename schema.Block to Body (#36629) 2025-03-04 16:33:43 +01:00
Radek Simko
289a3568da
Address go vet 1.24 failures (#36485)
* address go vet failures

* avoid unnecessary .Error()
2025-02-12 16:51:53 +00:00
Daniel Schmidt
e29708c4d9
ephemeral: add WriteOnlyAttributesAllowed client capability to validate resource 2024-12-18 09:30:32 +01:00
James Bardin
94687676a3 add basic grpc wrapper implemenation 2024-09-30 10:51:04 -04:00
James Bardin
9c3dc8f73a ephemeral protocol rename
Add `Resource` to all the ephemeral protocol symbols to make them
consistent with existing naming conventions.
2024-09-20 11:08:53 -04:00
James Bardin
03e1a9835d add ephemeral validation to existing implementations 2024-09-19 10:10:20 -04:00
James Bardin
95124dbe5a update provider impls for ephemeral
Add ephemeral methods to provider implementations so they still satisfy
the provider interface
2024-09-13 08:55:48 -04:00
Daniel Schmidt
ce721b8e9c
stacks: add deferred to grpc calls 2024-04-26 13:27:56 +02:00
Liam Cervante
055dd27e53
deferred actions: implement latest provider protocol changes (#35063) 2024-04-24 14:10:08 +02:00
Daniel Schmidt
a26fd2e81f
stacks: add deferrals to PlanResourceChange
Co-authored-by: Mutahhir Hayat <mutahhir.hayat@hashicorp.com>
2024-04-16 10:18:44 +02:00
Mark DeCrane
e6f4ffa8a3
stacks: adding deferred action to datasource reads 2024-04-11 14:26:05 +02:00
Daniel Schmidt
5b8f77d2a4
stacks: add deferred actions to plugin protocol
We are moving the deferred reason from plans/deferring to providers
to have a single representation of deferred reason to be used from
providers to the plan. Using the plan's representation causes circular
dependencies.

Co-authored-by: Matej Risek <matej.risek@hashicorp.com>
2024-04-08 13:32:41 +02:00
James Bardin
300f66b71d
Merge pull request #34603 from hashicorp/jbardin/remove-provider-funtion-warnings
provider functions can only return an error
2024-02-27 09:53:48 -05:00
Martin Atkins
a77d351ea2 plugin+plugin6: Don't panic if ProviderMeta not populated
"ProviderMeta" is a niche feature that's used by only two providers, but
this code was written under the assumption that the caller would always
provide it for any provider that has a schema for it, and unfortunately
the Terraform SDK seems to always provide a meta schema even for providers
that don't use it, and thus it's empty.

The current phase of the "unknown_instances" language experiment is not
fully wired in to the main logic as a way to reduce the risk of it
impacting behavior for those not participating in the experiment, but
that means that right now it doesn't actually have a resolved ProviderMeta
value to present, and so was just omitting it on the assumption that it
is always optional to provide anyway.

As a pragmatic stopgap to resolve that conflict, this makes the gRPC
provider dispatching logic tolerate an absent ProviderMeta value and
synthesize a null value to use in that case. This makes that logic slightly
more robust and also means we can defer doing all of the work to weave
ProviderMeta into this experimental codepath. The new TODO comment in that
codepath is intended to remind us to consider this again should we decide
to stablize the experiment later; when we do that, we'll hopefully do it
by refactoring to share more code between the two codepaths, at which
point ProviderMeta will be easier to support.
2024-02-13 16:40:07 -08:00
James Bardin
a8701f6ddd provider functions return an error
The call site for language functions doesn't currently have a way to
handle complex diagnostics, so rather than appear to support them in the
protocol we remove the concepts of diagnostics for now. We do however
retain the argument index fields, which we can wrap in a
function.ArgError and get a little more precise hcl diagnostic from
expression.
2024-02-01 09:26:51 -05:00
Brian Flad
c7a44bfc9a
Support Private State with MoveResourceState (#34575)
This change ensures that providers receive the source private state and can store potentially differing private state as part of a move, rather than always copying the source private state to the target. This functionality has not yet been released and therefore there are no compatibility concerns.
2024-01-26 07:46:31 -05:00
Liam Cervante
7d143388f3
Add support for the cross resource type move operation in the proto schema (#34480)
* Update proto schema and provider interfaces with support for moved across resource type RPCs

* address comments

* remove unused functions

* remove support for flatmap format
2024-01-11 10:08:50 +01:00
James Bardin
9abaf2f3b0 update provider code to match new rpc methods
Add the types, methods, and basic framework to use provider defined
functions.
2023-12-08 15:38:30 -05:00
Martin Atkins
2cc94b4e89 core: terraform.Context with preloaded provider schemas
Loading schemas from some providers can be particularly expensive, since
providers for large remote platforms tend to have very large schemas.

Since provider schemas are needed for many operations in Terraform,
callers sometimes end up loading schemas themselves anyway. Earlier work
tried to mitigate this by introducing a global schema cache for all
plugin-based providers, but that's problematic because it forces only a
single implementation of each distinct provider source address across the
entire lifetime of a process importing package providers.

This does not remove that global cache yet, but does add a new capability
that will hopefully eventually supplant it: callers of
terraform.NewContext can provide a set of preloaded provider schemas which
they must ensure would match what Terraform Core would find if it loaded
the schemas from an instance of the same provider instantiated through
the corresponding factory function given alongside.

A caller that wishes to avoid the potential cost of multiple schema
lookups can now therefore go look up the schemas itself before calling
terraform.NewContext, and provide frozen schemas that we'll use instead
of fetching from the associated plugins.

As of this commit no callers are actually using this mechanism. The first
caller will be the "stackeval" package, which already loads provider
schemas in order to evaluate provider configuration blocks anyway and so
should always be able to provide a full complement of preloaded schemas
to avoid Terraform Core needing to do any further lookups itself.
2023-11-14 13:01:56 -08:00
James Bardin
f907df8a6f correctly check for GetProviderSchemaOptional
A typo put the check for `GetProviderSchemaOptional` into the wrong `if`
expression, and was missed partly because of the named return which we
also remove here.
2023-09-05 17:20:26 -04:00
hashicorp-copywrite[bot]
53c34ff49c
Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
James Bardin
e14b03f7b0 always set schema caches from provider clients
Allow core to always use the global schema cache, so that providers
without GetProviderSchemaOptional are not spun up repeatedly. Rather
than conditionally setting the cache, we just conditionally use the
cache in the client to work around providers without
GetProviderSchemaOptional.
2023-07-18 13:52:41 -04:00
James Bardin
642904204a enable global schema cache 2023-07-10 11:01:19 -04:00