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

Rename ext-state to json-state & base64 encoding #444

Merged
merged 1 commit into from Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -2,7 +2,7 @@

## Enhancements
* Adds `RetryServerErrors` field to the `Config` object by @sebasslash [#439](https://github.com/hashicorp/go-tfe/pull/439)

* [beta] Renames the optional StateVersion field `ExtState` to `JSONState` and changes to string for base64 encoding by @annawinkler [#444](https://github.com/hashicorp/go-tfe/pull/444)
# v1.3.0

## Enhancements
Expand Down
5 changes: 2 additions & 3 deletions state_version.go
Expand Up @@ -3,7 +3,6 @@ package tfe
import (
"bytes"
"context"
"encoding/json"
"fmt"
"net/url"
"time"
Expand Down Expand Up @@ -140,13 +139,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.
// 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.
ExtState json.RawMessage `jsonapi:"attr,ext-state,omitempty"`
JSONState *string `jsonapi:"attr,json-state,omitempty"`
}

// List all the state versions for a given workspace.
Expand Down
12 changes: 6 additions & 6 deletions state_version_integration_test.go
Expand Up @@ -121,7 +121,7 @@ func TestStateVersionsCreate(t *testing.T) {
t.Fatal(err)
}

extState, err := ioutil.ReadFile("test-fixtures/ext-state-version/state.json")
jsonState, err := ioutil.ReadFile("test-fixtures/ext-state-version/state.json")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -169,11 +169,11 @@ func TestStateVersionsCreate(t *testing.T) {
}

sv, err := client.StateVersions.Create(ctx, wTest.ID, StateVersionCreateOptions{
Lineage: String("741c4949-60b9-5bb1-5bf8-b14f4bb14af3"),
MD5: String(fmt.Sprintf("%x", md5.Sum(state))),
Serial: Int64(1),
State: String(base64.StdEncoding.EncodeToString(state)),
ExtState: extState,
Lineage: String("741c4949-60b9-5bb1-5bf8-b14f4bb14af3"),
MD5: String(fmt.Sprintf("%x", md5.Sum(state))),
Serial: Int64(1),
State: String(base64.StdEncoding.EncodeToString(state)),
JSONState: String(base64.StdEncoding.EncodeToString(jsonState)),
})
require.NoError(t, err)

Expand Down