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

Add support for the save-plan run attr and save_plan operation filter #724

Merged
merged 7 commits into from
Jun 27, 2023

Conversation

nfagerlund
Copy link
Member

@nfagerlund nfagerlund commented Jun 21, 2023

Description

This feature is a work in progress, and is currently behind a feature flag in production. (It's not, however, a secret, as we're developing the Terraform core component of the feature in the open.)

Testing plan

  • With an organization that's been added to the saved-cloud-plans feature, use the client to create a run with SavePlan: true.
  • Examine the returned Run struct, and note that the SavePlan field is true.
  • If the run filter PR in atlas has been merged yet: List runs in the workspace and include Operation: RunOperationSavePlan in the list opts; note that your run is in the list, but normal runs aren't.

External links

As this feature is feature-flagged, there's no docs for it yet.

Output from tests

This is with tfc running in local dev with the un-merged filter PR applied.

=== RUN   TestRunsCreate
=== RUN   TestRunsCreate/without_a_configuration_version
=== RUN   TestRunsCreate/with_a_configuration_version
=== RUN   TestRunsCreate/with_allow_empty_apply
=== RUN   TestRunsCreate/with_save-plan
=== RUN   TestRunsCreate/with_terraform_version_and_plan_only
=== RUN   TestRunsCreate/refresh_defaults_to_true_if_not_set_as_a_create_option
=== RUN   TestRunsCreate/with_refresh-only_requested
    run_integration_test.go:253: Skipping this test until -refresh-only is released in the Terraform CLI
=== RUN   TestRunsCreate/with_auto-apply_requested
=== RUN   TestRunsCreate/without_auto-apply,_defaulting_to_workspace_autoapply
=== RUN   TestRunsCreate/without_a_workspace
=== RUN   TestRunsCreate/with_additional_attributes
=== RUN   TestRunsCreate/with_variables
--- PASS: TestRunsCreate (45.02s)
    --- PASS: TestRunsCreate/without_a_configuration_version (4.42s)
    --- PASS: TestRunsCreate/with_a_configuration_version (1.38s)
    --- PASS: TestRunsCreate/with_allow_empty_apply (1.31s)
    --- PASS: TestRunsCreate/with_save-plan (1.27s)
    --- PASS: TestRunsCreate/with_terraform_version_and_plan_only (1.54s)
    --- PASS: TestRunsCreate/refresh_defaults_to_true_if_not_set_as_a_create_option (2.60s)
    --- SKIP: TestRunsCreate/with_refresh-only_requested (0.00s)
    --- PASS: TestRunsCreate/with_auto-apply_requested (1.34s)
    --- PASS: TestRunsCreate/without_auto-apply,_defaulting_to_workspace_autoapply (1.10s)
    --- PASS: TestRunsCreate/without_a_workspace (0.00s)
    --- PASS: TestRunsCreate/with_additional_attributes (1.27s)
    --- PASS: TestRunsCreate/with_variables (1.33s)
PASS
ok  	github.com/hashicorp/go-tfe	45.568s

=== RUN   TestRunsListQueryParams
    helper_test.go:1154: Polling run "run-CDFMPP7eXrwJxLU4" for status included in ["cost_estimated" "errored"] with deadline of 2023-06-21 15:11:07.827564 -0700 PDT m=+123.692364525
    helper_test.go:1160: ...
    helper_test.go:1181: Reading run "run-CDFMPP7eXrwJxLU4"
    helper_test.go:1166: Run "run-CDFMPP7eXrwJxLU4" had status "planning"
    helper_test.go:1160: ...
    helper_test.go:1181: Reading run "run-CDFMPP7eXrwJxLU4"
    helper_test.go:1166: Run "run-CDFMPP7eXrwJxLU4" had status "planning"
    helper_test.go:1160: ...
    helper_test.go:1181: Reading run "run-CDFMPP7eXrwJxLU4"
    helper_test.go:1166: Run "run-CDFMPP7eXrwJxLU4" had status "planning"
    helper_test.go:1160: ...
    helper_test.go:1181: Reading run "run-CDFMPP7eXrwJxLU4"
    helper_test.go:1166: Run "run-CDFMPP7eXrwJxLU4" had status "planning"
    helper_test.go:1160: ...
    helper_test.go:1181: Reading run "run-CDFMPP7eXrwJxLU4"
    helper_test.go:1166: Run "run-CDFMPP7eXrwJxLU4" had status "planning"
    helper_test.go:1160: ...
    helper_test.go:1181: Reading run "run-CDFMPP7eXrwJxLU4"
    helper_test.go:1166: Run "run-CDFMPP7eXrwJxLU4" had status "planning"
    helper_test.go:1160: ...
    helper_test.go:1181: Reading run "run-CDFMPP7eXrwJxLU4"
    helper_test.go:1166: Run "run-CDFMPP7eXrwJxLU4" had status "cost_estimating"
    helper_test.go:1160: ...
    helper_test.go:1181: Reading run "run-CDFMPP7eXrwJxLU4"
    helper_test.go:1166: Run "run-CDFMPP7eXrwJxLU4" had status "cost_estimated"
=== RUN   TestRunsListQueryParams/with_status_query_parameter
=== RUN   TestRunsListQueryParams/with_source_query_parameter
=== RUN   TestRunsListQueryParams/with_operation_of_plan_only_parameter
=== RUN   TestRunsListQueryParams/with_operation_of_save_plan_parameter
=== RUN   TestRunsListQueryParams/with_mismatch_user_&_commit_parameter
--- PASS: TestRunsListQueryParams (26.41s)
    --- PASS: TestRunsListQueryParams/with_status_query_parameter (0.45s)
    --- PASS: TestRunsListQueryParams/with_source_query_parameter (0.53s)
    --- PASS: TestRunsListQueryParams/with_operation_of_plan_only_parameter (0.33s)
    --- PASS: TestRunsListQueryParams/with_operation_of_save_plan_parameter (0.35s)
    --- PASS: TestRunsListQueryParams/with_mismatch_user_&_commit_parameter (0.35s)
PASS
ok  	github.com/hashicorp/go-tfe	26.474s

Copy link
Collaborator

@brandonc brandonc left a comment

Choose a reason for hiding this comment

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

Looks fine. Can you add beta godocs, changelog, skipifbeta?

@@ -203,6 +211,17 @@ func TestRunsCreate(t *testing.T) {
assert.Equal(t, true, r.AllowEmptyApply)
})

t.Run("with save-plan", func(t *testing.T) {
options := RunCreateOptions{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably needs a SkipUnlessBeta(t) ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I knew I must be forgetting something 🤦

@nfagerlund
Copy link
Member Author

@brandonc Done! Thanks for the reminders. 💖

Uk1288
Uk1288 previously approved these changes Jun 27, 2023
Copy link
Contributor

@Uk1288 Uk1288 left a comment

Choose a reason for hiding this comment

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

Looking good!

Minor comment,

  • add planned_and_saved_at to RunStatusTimestamps

@nfagerlund
Copy link
Member Author

Oh dang good catch

Copy link
Contributor

@Uk1288 Uk1288 left a comment

Choose a reason for hiding this comment

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

🎉

@nfagerlund nfagerlund dismissed brandonc’s stale review June 27, 2023 17:44

Addressed it all!

@nfagerlund nfagerlund merged commit b09a59f into main Jun 27, 2023
@nfagerlund nfagerlund deleted the nf/jun23-save-plan-run-attr branch June 27, 2023 17:54
@github-actions
Copy link

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.

3 participants