Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions command/meta_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ func (m *Meta) backendFromConfig(opts *BackendOpts) (backend.Backend, tfdiags.Di
// settings in the configuration files are unchanged. (The only
// record we have of CLI overrides is in the settings cache in this
// case, so we have no other source to compare with.
if !opts.Init && cHash == s.Backend.Hash {
if !opts.Init && uint64(cHash) == s.Backend.Hash {
log.Printf("[TRACE] Meta.Backend: using already-initialized, unchanged %q backend configuration", c.Type)
return m.backend_C_r_S_unchanged(c, cHash, sMgr)
}
Expand Down Expand Up @@ -714,7 +714,7 @@ func (m *Meta) backend_C_r_s(c *configs.Backend, cHash int, sMgr *state.LocalSta
s.Backend = &terraform.BackendState{
Type: c.Type,
ConfigRaw: json.RawMessage(configJSON),
Hash: cHash,
Hash: uint64(cHash),
}

if err := sMgr.WriteState(s); err != nil {
Expand Down Expand Up @@ -857,7 +857,7 @@ func (m *Meta) backend_C_r_S_changed(c *configs.Backend, cHash int, sMgr *state.
s.Backend = &terraform.BackendState{
Type: c.Type,
ConfigRaw: json.RawMessage(configJSON),
Hash: cHash,
Hash: uint64(cHash),
}

if err := sMgr.WriteState(s); err != nil {
Expand Down Expand Up @@ -886,8 +886,8 @@ func (m *Meta) backend_C_r_S_unchanged(c *configs.Backend, cHash int, sMgr *stat
// it's possible for a backend to be unchanged, and the config itself to
// have changed by moving a parameter from the config to `-backend-config`
// In this case we only need to update the Hash.
if c != nil && s.Backend.Hash != cHash {
s.Backend.Hash = cHash
if c != nil && s.Backend.Hash != uint64(cHash) {
s.Backend.Hash = uint64(cHash)
if err := sMgr.WriteState(s); err != nil {
diags = diags.Append(err)
return nil, diags
Expand Down
2 changes: 1 addition & 1 deletion terraform/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ func (s *State) String() string {
type BackendState struct {
Type string `json:"type"` // Backend type
ConfigRaw json.RawMessage `json:"config"` // Backend raw config
Hash int `json:"hash"` // Hash of portion of configuration from config files
Hash uint64 `json:"hash"` // Hash of portion of configuration from config files
}

// Empty returns true if BackendState has no state.
Expand Down
14 changes: 14 additions & 0 deletions terraform/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,20 @@ func TestReadState_pruneDependencies(t *testing.T) {
}
}

func TestReadState_bigHash(t *testing.T) {
expected := uint64(14885267135666261723)
s := strings.NewReader(`{"version": 3, "backend":{"hash":14885267135666261723}}`)

actual, err := ReadState(s)
if err != nil {
t.Fatal(err)
}

if actual.Backend.Hash != expected {
t.Fatalf("expected backend hash %d, got %d", expected, actual.Backend.Hash)
}
}

func TestResourceNameSort(t *testing.T) {
names := []string{
"a",
Expand Down