Skip to content

Commit

Permalink
Adding return statements (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
bendbennett committed Jan 22, 2024
1 parent c542a70 commit 518c94c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions statecheck/expect_known_output_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ func (e expectKnownOutputValue) CheckState(ctx context.Context, req CheckStateRe

if req.State == nil {
resp.Error = fmt.Errorf("state is nil")

return
}

if req.State.Values == nil {
resp.Error = fmt.Errorf("state does not contain any state values")

return
}

for address, oc := range req.State.Values.Outputs {
Expand Down
4 changes: 4 additions & 0 deletions statecheck/expect_known_output_value_at_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ func (e expectKnownOutputValueAtPath) CheckState(ctx context.Context, req CheckS

if req.State == nil {
resp.Error = fmt.Errorf("state is nil")

return
}

if req.State.Values == nil {
resp.Error = fmt.Errorf("state does not contain any state values")

return
}

for address, oc := range req.State.Values.Outputs {
Expand Down
8 changes: 8 additions & 0 deletions statecheck/expect_known_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,20 @@ func (e expectKnownValue) CheckState(ctx context.Context, req CheckStateRequest,

if req.State == nil {
resp.Error = fmt.Errorf("state is nil")

return
}

if req.State.Values == nil {
resp.Error = fmt.Errorf("state does not contain any state values")

return
}

if req.State.Values.RootModule == nil {
resp.Error = fmt.Errorf("state does not contain a root module")

return
}

for _, resourceChange := range req.State.Values.RootModule.Resources {
Expand All @@ -62,6 +68,8 @@ func (e expectKnownValue) CheckState(ctx context.Context, req CheckStateRequest,

if err := e.knownValue.CheckValue(result); err != nil {
resp.Error = fmt.Errorf("error checking value for attribute at path: %s.%s, err: %s", e.resourceAddress, e.attributePath.String(), err)

return
}
}

Expand Down
8 changes: 8 additions & 0 deletions statecheck/expect_sensitive_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ func (e expectSensitiveValue) CheckState(ctx context.Context, req CheckStateRequ

if req.State == nil {
resp.Error = fmt.Errorf("state is nil")

return
}

if req.State.Values == nil {
resp.Error = fmt.Errorf("state does not contain any state values")

return
}

if req.State.Values.RootModule == nil {
resp.Error = fmt.Errorf("state does not contain a root module")

return
}

for _, resourceChange := range req.State.Values.RootModule.Resources {
Expand Down Expand Up @@ -71,11 +77,13 @@ func (e expectSensitiveValue) CheckState(ctx context.Context, req CheckStateRequ
isSensitive, ok := result.(bool)
if !ok {
resp.Error = fmt.Errorf("invalid path: the path value cannot be asserted as bool")

return
}

if !isSensitive {
resp.Error = fmt.Errorf("attribute at path is not sensitive")

return
}
}
Expand Down

0 comments on commit 518c94c

Please sign in to comment.