Skip to content

Commit

Permalink
Merge pull request #444 from hashicorp/aw/state-updates
Browse files Browse the repository at this point in the history
Rename ext-state to json-state & base64 encoding
  • Loading branch information
annawinkler committed Jun 28, 2022
2 parents 87a1eaa + c5ca643 commit 2de89fc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
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

0 comments on commit 2de89fc

Please sign in to comment.