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 the optional StateVersion field JSONState and changes to string for base64 encoding #514

Merged
merged 5 commits into from Aug 26, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions state_version.go
Expand Up @@ -145,6 +145,13 @@ type StateVersionCreateOptions struct {
// Optional: Specifies the run to associate the state with.
Run *Run `jsonapi:"relation,run,omitempty"`

// Optional: The external, json representation of state data, base64 encoded.
// https://www.terraform.io/internals/json-format#state-representation
// Supplying this state representation can provide more details to the platform
// about the current terraform state.
//
// **Note**: This field is in BETA, subject to change and not widely available yet.
JSONState *string `jsonapi:"attr,json-state,omitempty"`
// Optional: The external, json representation of state outputs, base64 encoded. Supplying this field
// will provide more detailed output type information to TFE.
// For more information on the contents of this field: https://www.terraform.io/internals/json-format#values-representation
Expand Down
6 changes: 6 additions & 0 deletions state_version_integration_test.go
Expand Up @@ -120,6 +120,11 @@ func TestStateVersionsCreate(t *testing.T) {
t.Fatal(err)
}

jsonState, err := ioutil.ReadFile("test-fixtures/ext-state-version/state.json")
brandonc marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
t.Fatal(err)
}

jsonStateOutputs, err := ioutil.ReadFile("test-fixtures/json-state-outputs/everything.json")
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -172,6 +177,7 @@ func TestStateVersionsCreate(t *testing.T) {
MD5: String(fmt.Sprintf("%x", md5.Sum(state))),
Serial: Int64(1),
State: String(base64.StdEncoding.EncodeToString(state)),
JSONState: String(base64.StdEncoding.EncodeToString(state)),
brandonc marked this conversation as resolved.
Show resolved Hide resolved
JSONStateOutputs: String(base64.StdEncoding.EncodeToString(jsonStateOutputs)),
})
require.NoError(t, err)
Expand Down