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

Adds StateVersionOutputs ReadCurrent #370

Merged
merged 5 commits into from Apr 4, 2022

Conversation

brandonc
Copy link
Collaborator

@brandonc brandonc commented Mar 29, 2022

Description

I'd like to support the new current-state-version-outputs endpoint to unblock a bug fix within terraform

External links

Output from tests (HashiCorp employees only)

$ TF_ACC=1 go test ./... -v -tags integration -run TestStateVersionOutputsRead
=== RUN   TestStateVersionOutputsRead
=== RUN   TestStateVersionOutputsRead/Read_by_ID
=== RUN   TestStateVersionOutputsRead/Read_by_ID/when_a_state_output_exists
=== RUN   TestStateVersionOutputsRead/Read_by_ID/when_a_state_output_does_not_exist
=== RUN   TestStateVersionOutputsRead/Read_current_workspace_outputs
--- PASS: TestStateVersionOutputsRead (5.19s)
    --- PASS: TestStateVersionOutputsRead/Read_by_ID (0.64s)
        --- PASS: TestStateVersionOutputsRead/Read_by_ID/when_a_state_output_exists (0.23s)
        --- PASS: TestStateVersionOutputsRead/Read_by_ID/when_a_state_output_does_not_exist (0.42s)
    --- PASS: TestStateVersionOutputsRead/Read_current_workspace_outputs (0.29s)
PASS
ok  	github.com/hashicorp/go-tfe	5.809s
?   	github.com/hashicorp/go-tfe/examples/organizations	[no test files]
?   	github.com/hashicorp/go-tfe/examples/workspaces	[no test files]
?   	github.com/hashicorp/go-tfe/mocks	[no test files]

Copy link
Contributor

@sebasslash sebasslash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks GTM 👍

Copy link
Collaborator

@uturunku1 uturunku1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏁🐎

@@ -16,6 +16,7 @@ var _ StateVersionOutputs = (*stateVersionOutputs)(nil)
// TFE API docs: https://www.terraform.io/docs/cloud/api/state-version-outputs.html
type StateVersionOutputs interface {
Read(ctx context.Context, outputID string) (*StateVersionOutput, error)
ReadCurrent(ctx context.Context, workspaceID string) (*StateVersionOutputsList, error)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we have this precedence for ReadCurrent and ReadCurrentwithOptions: https://github.com/hashicorp/go-tfe/blob/main/state_version.go#L33-L36 But if this endpoint won't be adding options in the near future, then we are good.

// Read a State Version Output
func (s *stateVersionOutputs) Read(ctx context.Context, outputID string) (*StateVersionOutput, error) {
if !validStringID(&outputID) {
return nil, ErrInvalidRunID
return nil, ErrInvalidOutputID
Copy link
Collaborator

@uturunku1 uturunku1 Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

geeze, were we returning the incorrect error message all this time?

@@ -12,7 +12,7 @@ import (
"github.com/stretchr/testify/require"
)

const waitForStateVersionOutputs = 700 * time.Millisecond
const waitForStateVersionOutputs = 1000 * time.Millisecond
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 1000 instead of 700?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My tests didn't pass locally with the old timing.

@brandonc brandonc merged commit 14c362e into main Apr 4, 2022
@brandonc brandonc deleted the brandonc/current-state-version-outputs branch April 4, 2022 17:03
@github-actions
Copy link

github-actions bot commented Apr 4, 2022

Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants