Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Terraform
Commits
50d48c63
Unverified
Commit
50d48c63
authored
2 years ago
by
Brandon Croft
Browse files
Options
Download
Email Patches
Plain Diff
remove unused error and fix output authorization detection
parent
0139e75a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
internal/cloud/state.go
+10
-8
internal/cloud/state.go
with
10 additions
and
8 deletions
+10
-8
internal/cloud/state.go
+
10
-
8
View file @
50d48c63
...
...
@@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"log"
"strings"
"github.com/hashicorp/go-tfe"
...
...
@@ -25,12 +26,11 @@ type State struct {
delegate
remote
.
State
}
var
ErrNotEnoughOutputsTypeInformation
=
errors
.
New
(
"not enough type information to read outputs"
)
var
ErrStateVersionOutputsUpgradeState
=
errors
.
New
(
strings
.
TrimSpace
(
`
var
ErrStateVersionUnauthorizedUpgradeState
=
errors
.
New
(
strings
.
TrimSpace
(
`
You are not authorized to read the full state version containing outputs.
State versions created by terraform v1.3.0 and newer do not require this level
of authorization and therefore this error can be fixed by upgrading the
remote
state version.
of authorization and therefore this error can
usually
be fixed by upgrading the
remote
state version.
`
))
// Proof that cloud State is a statemgr.Persistent interface
...
...
@@ -74,16 +74,18 @@ func (s *State) WriteState(state *states.State) error {
}
func
(
s
*
State
)
fallbackReadOutputsFromFullState
()
(
map
[
string
]
*
states
.
OutputValue
,
error
)
{
log
.
Printf
(
"[DEBUG] falling back to reading full state"
)
if
err
:=
s
.
RefreshState
();
err
!=
nil
{
if
strings
.
HasSuffix
(
err
.
Error
(),
"failed to retrieve state: forbidden"
)
{
return
nil
,
ErrStateVersionOutputsUpgradeState
}
return
nil
,
fmt
.
Errorf
(
"failed to load state: %w"
,
err
)
}
state
:=
s
.
State
()
if
state
==
nil
{
state
=
states
.
NewState
()
// We know that there is supposed to be state (and this is not simply a new workspace
// without state) because the fallback is only invoked when outputs are present but
// detailed types are not available.
return
nil
,
ErrStateVersionUnauthorizedUpgradeState
}
return
state
.
RootModule
()
.
OutputValues
,
nil
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help