Commit graph

90 commits

Author SHA1 Message Date
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
Sarah French
cf047be4e4
PSS: Use interfaces to configure state stores (#37899)
Some checks failed
build / Build for freebsd_amd64 (push) Has been cancelled
build / Build for linux_amd64 (push) Has been cancelled
build / Build for openbsd_amd64 (push) Has been cancelled
build / Build for solaris_amd64 (push) Has been cancelled
build / Build for windows_amd64 (push) Has been cancelled
build / Build for freebsd_arm (push) Has been cancelled
build / Build for linux_arm (push) Has been cancelled
build / Build for darwin_arm64 (push) Has been cancelled
build / Build for linux_arm64 (push) Has been cancelled
build / Build for windows_arm64 (push) Has been cancelled
build / Build Docker image for linux_386 (push) Has been cancelled
build / Build Docker image for linux_amd64 (push) Has been cancelled
build / Build Docker image for linux_arm (push) Has been cancelled
build / Build Docker image for linux_arm64 (push) Has been cancelled
build / Build e2etest for linux_386 (push) Has been cancelled
build / Build e2etest for windows_386 (push) Has been cancelled
build / Build e2etest for darwin_amd64 (push) Has been cancelled
build / Build e2etest for linux_amd64 (push) Has been cancelled
build / Build e2etest for windows_amd64 (push) Has been cancelled
build / Build e2etest for linux_arm (push) Has been cancelled
build / Build e2etest for darwin_arm64 (push) Has been cancelled
build / Build e2etest for linux_arm64 (push) Has been cancelled
build / Run e2e test for linux_386 (push) Has been cancelled
build / Run e2e test for windows_386 (push) Has been cancelled
build / Run e2e test for darwin_amd64 (push) Has been cancelled
build / Run e2e test for linux_amd64 (push) Has been cancelled
build / Run e2e test for windows_amd64 (push) Has been cancelled
build / Run e2e test for linux_arm (push) Has been cancelled
build / Run e2e test for linux_arm64 (push) Has been cancelled
build / Run terraform-exec test for linux amd64 (push) Has been cancelled
* refactor: Move chunk size limit constants to new `chunks` package

* refactor: Make `NewPluggable` return a `Pluggable` concrete type, instead of an instance of the `backend.Backend` interface.

* refactor: Configure state stores through the backend.Backend interface, instead of directly using methods related to RPCs. This requires changing where we call `SetStateStoreChunkSize`.

* docs: Add godocs comment to `StateStoreChunkSizeSetter` interface

To summarize, we don't really need the `SetStateStoreChunkSize` method, and instead methods like `(*GRPCProvider).ConfigureStateStore` in the `plugin6` package can directly inspect the negotiation process that passes through that code and pull out the chunk size. However that means that that code would also need to implement validation. And that's just `(*GRPCProvider).ConfigureStateStore`; what about all the test mocks that are used in different types of test? They would all need to be implemented similarly to GRPCProvider to be good, useful mocks, and then a lot of things that fulfil the provider.Interface interface are coupled to each other. Instead, it's easier to have validation in the `grpcClient` struct's methods in the `remote` package, as that code is common to all scenarios. That code needs a method to 'reach into'  the provider.Interface value, so we use the `SetStateStoreChunkSize` method.

* chore: Make it clearer that the v6 GRPCProvider implements `SetStateStoreChunkSize`

* fix: Remove unnecessary assignment of chunk size

I'm surprised that removing this doesn't break E2E tests of PSS that use grpcwrap, but I think there's `plugin6` code that runs in that situation, so maybe chunking is handled elsewhere.

* chore: Add panic to try detect unexpected cases when setting chunk size.

* feat: Add `providers.StateStoreChunkSizeSetter` implementation to provider-simple-v6

* docs: Update code comments for NewPluggable describing its intended use
2025-11-26 13:34:22 +00:00
Sarah French
4420c4dcc0
PSS: Update the workspace new subcommand to work with PSS, add E2E and integration tests for using workspace commands with PSS. (#37855)
* feat: Update the `workspace new` subcommand to work with PSS, add E2E testing

* refactor: Replace instances of `ioutil` with `os` while looking at the workspace command

* docs: Update code comments in `workspace new` command

* test: Update E2E test using PSS with workspace commands to assert state files are created by given commands

* test: Include `workspace show` in happy path E2E test using PSS

* fix: Allow DeleteState RPC to include the id of the state to delete

* test: Include `workspace delete` in happy path E2E test using PSS

* fix: Avoid assignment to nil map in mock provider during WriteStateBytes

* test: Add integration test for workspace commands when using PSS

We still need an E2E test for this, to ensure that the GRPC-related packages pass all the expected data between core and the provider.

* test: Update test to reflect changes in the test fixture configuration

* docs: Fix code comment

* test: Change test to build its own Terraform binary with experiments enabled

* refactor: Replace use of `newMeta` with reuse of Meta that we re-set the UI value on
2025-11-19 12:50:43 +00: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
Sarah French
2e5b5dee5d
Upgrade protoc and protoc-gen-go-grpc versions to matching terraform-plugin-go (#37647)
Some checks failed
build / Build for freebsd_amd64 (push) Has been cancelled
build / Build for linux_amd64 (push) Has been cancelled
build / Build for openbsd_amd64 (push) Has been cancelled
build / Build for solaris_amd64 (push) Has been cancelled
build / Build for windows_amd64 (push) Has been cancelled
build / Build for freebsd_arm (push) Has been cancelled
build / Build for linux_arm (push) Has been cancelled
build / Build for darwin_arm64 (push) Has been cancelled
build / Build for linux_arm64 (push) Has been cancelled
build / Build for windows_arm64 (push) Has been cancelled
build / Build Docker image for linux_386 (push) Has been cancelled
build / Build Docker image for linux_amd64 (push) Has been cancelled
build / Build Docker image for linux_arm (push) Has been cancelled
build / Build Docker image for linux_arm64 (push) Has been cancelled
build / Build e2etest for linux_386 (push) Has been cancelled
build / Build e2etest for windows_386 (push) Has been cancelled
build / Build e2etest for darwin_amd64 (push) Has been cancelled
build / Build e2etest for linux_amd64 (push) Has been cancelled
build / Build e2etest for windows_amd64 (push) Has been cancelled
build / Build e2etest for linux_arm (push) Has been cancelled
build / Build e2etest for darwin_arm64 (push) Has been cancelled
build / Build e2etest for linux_arm64 (push) Has been cancelled
build / Run e2e test for linux_386 (push) Has been cancelled
build / Run e2e test for windows_386 (push) Has been cancelled
build / Run e2e test for darwin_amd64 (push) Has been cancelled
build / Run e2e test for linux_amd64 (push) Has been cancelled
build / Run e2e test for windows_amd64 (push) Has been cancelled
build / Run e2e test for linux_arm (push) Has been cancelled
build / Run e2e test for linux_arm64 (push) Has been cancelled
build / Run terraform-exec test for linux amd64 (push) Has been cancelled
* Update protoc version in downloader script

* go get google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1

This matched terraform-plugin-go

* make protobuf

* Run `make protobuf`

* Update generator to handle generic types from google.golang.org/grpc

Looks like this was added in v1.69.3 in https://github.com/grpc/grpc-go/pull/7057 ?

* Run `make generate`

* Fix "cannot infer Res" compile error - more usage of generics

* More fixing compile errors due to switching to use of a generic

* Make putting `google.golang.org/grpc` import into generated files conditional

* Run `make generate`

* Update more places where generics now need to be used

* Update generator to handle any types from google.golang.org/grpc in same switch case.
2025-10-22 14:46:18 +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
Kristin Laemmert
df113486a1
actions: remove references to action types, linked resources (#37616)
* action renaming
* actions: remove references to action types
* actions: remove references to linked_resources or action types from the plan proto
2025-09-16 08:46:22 -04: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
Daniel Banck
1ac8497994
Add support for Terraform Search in the cloud backend (TF-25935) (#37479) 2025-09-15 13:21:05 +02:00
James Bardin
4e8717295e grpc method impl 2025-08-29 15:00:30 -04:00
James Bardin
aa1babe5bb plugin6 mock 2025-08-29 15:00:30 -04:00
Daniel Schmidt
176263d936 actions: remove future action types
removing them for now, this gives us more flexibility in the future since the schema is not yet locked in
2025-08-29 16:25:41 +02:00
Sarah French
037ed81e9e
PSS: Implement first gRPC methods: config validation and usage, listing and deleting workspaces (#37418)
* Implement first grpc methods: config validation and use, listing and deleting workspaces

* Add a state store to the default provider schema used in protocol 6 GRPCProvider tests

* Add `ValidateStateStoreConfig` test that shows diagnostics are returned as expected

* Add `ValidateStateStoreConfig` test that shows schema-related errors are returned before the `ValidateStateStoreConfig` RPC takes place

* Add similar tests for `ConfigureStateStore` - check errors are returned and schema errors are caught early

* Refactor to avoid looping over cases

* Update `GetStates` to check the store type is implemented before retrieving states. Add tests.

* Fix defect in DeleteState, update it to check state store type is valid

* Add tests for `DeleteState` method

---------

Co-authored-by: Radek Simko <radek.simko@gmail.com>
2025-08-13 12:11:31 +01: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
Kristin Laemmert
9256074c43
Actions in plan/changes (#37320)
* Add actions to the plans and change
* jsonplan - ignoring LinkedResources for now, those are not in the MVP
* pausing here: we'll work on the plan rendering later
2025-07-17 08:19:57 -04:00
Daniel Schmidt
a2ce38ce12 use gomock generated mocks for the action invoke stream API 2025-07-10 16:06:44 +02:00
Daniel Schmidt
ac132d1b15 add provider implementation for actions 2025-07-10 16:06:44 +02:00
Daniel Schmidt
e6b848d5ab add actions protobuf definitions 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
2d08b5d0d1 match internal/plugin6 implementation to internal/plugin 2025-03-24 17:47:16 -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
James Bardin
3b3e4bf003 update the rest of the go:generate calls 2025-02-12 12:25:58 -05: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 Banck
857d188308
Add resource identity message to protocol (TF-23178) (#36451)
* protocol: create new 5.9 and 6.9 protocol versions

* protocol: add resource identity messages to 5.9 & 6.9

* make protobuf

* make generate

* grpcwrap: Add RPC calls skeleton
2025-02-10 16:31:50 +01:00
James Bardin
337bf8e11b
Merge pull request #36236 from hashicorp/jbardin/write-only-structural-attrs
convert write-only structural attrs to and from protobuf
2024-12-18 09:52:17 -05:00
James Bardin
345a931132 convert write-only structural attrs through proto
Nested structural attributes were missing write-only flags when
converted to and from the wire protocol.
2024-12-18 09:08:37 -05:00
Daniel Schmidt
e29708c4d9
ephemeral: add WriteOnlyAttributesAllowed client capability to validate resource 2024-12-18 09:30:32 +01:00
Daniel Schmidt
3a962e8e7e
ephemeral: add WriteOnlyAttributesAllowed client capability
we allow it for all requests
2024-12-12 10:56:40 +01:00
Daniel Schmidt
0222b97692
ephemeral: add write-only attribute to proto to schema conversion 2024-12-12 10:56:40 +01:00
Daniel Schmidt
50b3732f72
write-only attributes: add to provider schema 2024-11-12 16:42:05 +01:00
James Bardin
6f5007efe7 grpc mock tests 2024-09-30 10:51:04 -04: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