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 OPA support for Policy Set API's #575

Merged
merged 7 commits into from Nov 2, 2022
Merged

Add OPA support for Policy Set API's #575

merged 7 commits into from Nov 2, 2022

Conversation

mrinalirao
Copy link
Contributor

@mrinalirao mrinalirao commented Nov 1, 2022

Description

Add OPA support to the go-tfe client for policy sets. OPA is still in beta phase.
This PR only contains changes to the policy set API's.

For a complete list of API's that will be updated in subsequent PRs see : https://github.com/hashicorp/terraform-docs-common/pull/141/files

Api's updated:

  • Policy set creation (Adds kind + overridable attribute)
  • List Policy sets (Adds filter by kind support)

Testing plan

Integration tests added

External links

Output from tests

Needs the following env vars:
TFE_ADDRESS
TFE_TOKEN
OAUTH_CLIENT_GITHUB_TOKEN
GITHUB_POLICY_SET_IDENTIFIER
Set ENABLE_BETA=1

envchain local go test -run TestPolicySetsCreate_Beta -v ./... -tags=integration
=== RUN   TestPolicySetsCreate_Beta
=== RUN   TestPolicySetsCreate_Beta/with_valid_attributes
=== RUN   TestPolicySetsCreate_Beta/with_kind_missing
=== RUN   TestPolicySetsCreate_Beta/with_all_attributes_provided_-_sentinel
=== RUN   TestPolicySetsCreate_Beta/with_all_attributes_provided_-_OPA
=== RUN   TestPolicySetsCreate_Beta/with_missing_overridable_attribute
=== RUN   TestPolicySetsCreate_Beta/with_policies_and_workspaces_provided
=== RUN   TestPolicySetsCreate_Beta/with_vcs_policy_set
=== RUN   TestPolicySetsCreate_Beta/with_vcs_policy_updated
=== RUN   TestPolicySetsCreate_Beta/without_a_name_provided
=== RUN   TestPolicySetsCreate_Beta/with_an_invalid_name_provided
=== RUN   TestPolicySetsCreate_Beta/without_a_valid_organization
--- PASS: TestPolicySetsCreate_Beta (22.10s)
    --- PASS: TestPolicySetsCreate_Beta/with_valid_attributes (0.59s)
    --- PASS: TestPolicySetsCreate_Beta/with_kind_missing (0.59s)
    --- PASS: TestPolicySetsCreate_Beta/with_all_attributes_provided_-_sentinel (1.04s)
    --- PASS: TestPolicySetsCreate_Beta/with_all_attributes_provided_-_OPA (0.57s)
    --- PASS: TestPolicySetsCreate_Beta/with_missing_overridable_attribute (0.56s)
    --- PASS: TestPolicySetsCreate_Beta/with_policies_and_workspaces_provided (3.13s)
    --- PASS: TestPolicySetsCreate_Beta/with_vcs_policy_set (4.98s)
    --- PASS: TestPolicySetsCreate_Beta/with_vcs_policy_updated (5.02s)
    --- PASS: TestPolicySetsCreate_Beta/without_a_name_provided (0.00s)
    --- PASS: TestPolicySetsCreate_Beta/with_an_invalid_name_provided (0.00s)
    --- PASS: TestPolicySetsCreate_Beta/without_a_valid_organization (0.00s)
PASS
ok      github.com/hashicorp/go-tfe     23.067s
?       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]

  envchain local go test -run TestPolicySetsList_Beta -v ./... -tags=integration
=== RUN   TestPolicySetsList_Beta
=== RUN   TestPolicySetsList_Beta/without_list_options
=== RUN   TestPolicySetsList_Beta/with_pagination
=== RUN   TestPolicySetsList_Beta/with_search
=== RUN   TestPolicySetsList_Beta/with_include_param
=== RUN   TestPolicySetsList_Beta/filter_by_kind
=== RUN   TestPolicySetsList_Beta/without_a_valid_organization
--- PASS: TestPolicySetsList_Beta (13.14s)
    --- PASS: TestPolicySetsList_Beta/without_list_options (0.64s)
    --- PASS: TestPolicySetsList_Beta/with_pagination (0.57s)
    --- PASS: TestPolicySetsList_Beta/with_search (0.61s)
    --- PASS: TestPolicySetsList_Beta/with_include_param (1.06s)
    --- PASS: TestPolicySetsList_Beta/filter_by_kind (0.65s)
    --- PASS: TestPolicySetsList_Beta/without_a_valid_organization (0.00s)
PASS
ok      github.com/hashicorp/go-tfe     13.306s
?       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]

@mrinalirao mrinalirao changed the title Add OPA support to the client (WIP) Add OPA support for Policy Set API's Nov 1, 2022
@mrinalirao mrinalirao marked this pull request as ready for review November 1, 2022 22:25
@mrinalirao mrinalirao requested a review from a team as a code owner November 1, 2022 22:25
@annawinkler
Copy link
Contributor

👋 Hi @mrinalirao ! Thank you for your contribution! It looks like this PR might be targeting a feature that is in beta. We have guidance in our docs about how to add tests for beta features, plus how to comment when a feature is in beta. Could you please update the PR based on that guidance? 💖

I'll take a more detailed look and add more thoughts ✨

brandonc
brandonc previously approved these changes Nov 1, 2022
policy_set.go Outdated Show resolved Hide resolved
glennsarti
glennsarti previously approved these changes Nov 2, 2022
Copy link
Contributor

@glennsarti glennsarti left a comment

Choose a reason for hiding this comment

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

One typo change but should not block this PR.

policy_set.go Outdated Show resolved Hide resolved
@glennsarti
Copy link
Contributor

Almost forgot. You'll need a Changelog entry for this.

# Conflicts:
#	CHANGELOG.md
@mrinalirao mrinalirao merged commit af0a606 into main Nov 2, 2022
@mrinalirao mrinalirao deleted the TF-1450 branch November 2, 2022 22:32
@github-actions
Copy link

github-actions bot commented Nov 2, 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

4 participants