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 opa-versions and sentinel-versions admin Api #758

Merged
merged 5 commits into from
Jan 2, 2024

Conversation

mrinalirao
Copy link
Contributor

@mrinalirao mrinalirao commented Aug 18, 2023

Description

Add support for the new opa-versions and the sentinel-versions admin API which will be required for creating the opa-version and the sentinel-version providers

Testing plan

Integration tests (Results below)

Output from tests

  • opa-versions test :
envchain local go test -run TestAdminOpaVersions_List -v ./...

=== RUN   TestAdminOpaVersions_List
=== RUN   TestAdminOpaVersions_List/without_list_options
=== RUN   TestAdminOpaVersions_List/with_list_options
=== RUN   TestAdminOpaVersions_List/with_filter_query_string
=== RUN   TestAdminOpaVersions_List/with_search_version_query_string
=== RUN   TestAdminOpaVersions_List/with_search_version_query_string/ensure_each_version_matches_substring
--- PASS: TestAdminOpaVersions_List (4.75s)
    --- PASS: TestAdminOpaVersions_List/without_list_options (0.63s)
    --- PASS: TestAdminOpaVersions_List/with_list_options (1.25s)
    --- PASS: TestAdminOpaVersions_List/with_filter_query_string (1.34s)
    --- PASS: TestAdminOpaVersions_List/with_search_version_query_string (0.65s)
        --- PASS: TestAdminOpaVersions_List/with_search_version_query_string/ensure_each_version_matches_substring (0.00s)
PASS
ok      github.com/hashicorp/go-tfe     5.460s
 envchain local go test -run TestAdminOpaVersions_CreateDelete -v ./...

=== RUN   TestAdminOpaVersions_CreateDelete
=== RUN   TestAdminOpaVersions_CreateDelete/with_valid_options
=== RUN   TestAdminOpaVersions_CreateDelete/with_only_required_options
=== RUN   TestAdminOpaVersions_CreateDelete/with_empty_options
--- PASS: TestAdminOpaVersions_CreateDelete (3.87s)
    --- PASS: TestAdminOpaVersions_CreateDelete/with_valid_options (1.87s)
    --- PASS: TestAdminOpaVersions_CreateDelete/with_only_required_options (1.14s)
    --- PASS: TestAdminOpaVersions_CreateDelete/with_empty_options (0.00s)
PASS
ok      github.com/hashicorp/go-tfe     4.598s
envchain local go test -run TestAdminOpaVersions_ReadUpdate -v ./...

=== RUN   TestAdminOpaVersions_ReadUpdate
=== RUN   TestAdminOpaVersions_ReadUpdate/reads_and_updates
=== RUN   TestAdminOpaVersions_ReadUpdate/with_non-existent_OPA_version
--- PASS: TestAdminOpaVersions_ReadUpdate (4.23s)
    --- PASS: TestAdminOpaVersions_ReadUpdate/reads_and_updates (2.61s)
    --- PASS: TestAdminOpaVersions_ReadUpdate/with_non-existent_OPA_version (0.73s)
PASS
ok      github.com/hashicorp/go-tfe     4.982s
  • sentinel-versions test :
envchain local go test -run TestAdminSentinelVersions_List -v ./...

=== RUN   TestAdminSentinelVersions_List
=== RUN   TestAdminSentinelVersions_List/without_list_options
=== RUN   TestAdminSentinelVersions_List/with_list_options
=== RUN   TestAdminSentinelVersions_List/with_filter_query_string
=== RUN   TestAdminSentinelVersions_List/with_search_version_query_string
=== RUN   TestAdminSentinelVersions_List/with_search_version_query_string/ensure_each_version_matches_substring
--- PASS: TestAdminSentinelVersions_List (4.11s)
    --- PASS: TestAdminSentinelVersions_List/without_list_options (0.50s)
    --- PASS: TestAdminSentinelVersions_List/with_list_options (1.10s)
    --- PASS: TestAdminSentinelVersions_List/with_filter_query_string (1.09s)
    --- PASS: TestAdminSentinelVersions_List/with_search_version_query_string (0.60s)
        --- PASS: TestAdminSentinelVersions_List/with_search_version_query_string/ensure_each_version_matches_substring (0.00s)
PASS
ok      github.com/hashicorp/go-tfe     4.773s
envchain local go test -run TestAdminSentinelVersions_CreateDelete -v ./...

=== RUN   TestAdminSentinelVersions_CreateDelete
=== RUN   TestAdminSentinelVersions_CreateDelete/with_valid_options
=== RUN   TestAdminSentinelVersions_CreateDelete/with_only_required_options
=== RUN   TestAdminSentinelVersions_CreateDelete/with_empty_options
--- PASS: TestAdminSentinelVersions_CreateDelete (3.39s)
    --- PASS: TestAdminSentinelVersions_CreateDelete/with_valid_options (1.33s)
    --- PASS: TestAdminSentinelVersions_CreateDelete/with_only_required_options (1.20s)
    --- PASS: TestAdminSentinelVersions_CreateDelete/with_empty_options (0.00s)
PASS
ok      github.com/hashicorp/go-tfe     3.571s
envchain local go test -run TestAdminSentinelVersions_ReadUpdate -v ./...

=== RUN   TestAdminSentinelVersions_ReadUpdate
=== RUN   TestAdminSentinelVersions_ReadUpdate/reads_and_updates
=== RUN   TestAdminSentinelVersions_ReadUpdate/with_non-existent_Sentinel_version
--- PASS: TestAdminSentinelVersions_ReadUpdate (3.60s)
    --- PASS: TestAdminSentinelVersions_ReadUpdate/reads_and_updates (2.28s)
    --- PASS: TestAdminSentinelVersions_ReadUpdate/with_non-existent_Sentinel_version (0.47s)
PASS
ok      github.com/hashicorp/go-tfe     3.777s

@mrinalirao mrinalirao marked this pull request as ready for review August 18, 2023 07:10
@mrinalirao mrinalirao requested a review from a team as a code owner August 18, 2023 07:10
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.

Awesome work. There are a couple of blockers down below. Also when you create a new resource, make sure to generate the mocks by calling ./generate_mocks.sh.

admin_opa_version.go Outdated Show resolved Hide resolved
admin_opa_version.go Outdated Show resolved Hide resolved
oList, err := client.Admin.OpaVersions.List(ctx, nil)
require.NoError(t, err)

assert.NotEmpty(t, oList.Items)
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this assertion always be true for any instance? We create a fresh instance for our nightly TFE tests. Normally, for _List tests I like to create a few resources beforehand to ensure than something is returned by the List() call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please correct me if I am wrong, but I thought these tool versions are prepopulated in the test instances from this script here: https://github.com/hashicorp/atlas/blob/f016d274ae6bb7d4da54fdeede86a794125dbaac/lib/data/tool_versions.yml#L1028
Because it looks like admin_terraform _versions tests do the same thing.

admin_opa_version_integration_test.go Outdated Show resolved Hide resolved
admin_sentinel_version.go Show resolved Hide resolved
helper_test.go Outdated Show resolved Hide resolved
@mrinalirao
Copy link
Contributor Author

@sebasslash Thanks for the review 🙏 but I am going to convert this into a draft PR as we realised we cannot publish the docs until we have Pinned Policy Runtime Version released. I will move it into review when we have the docs in prod! :) Thanks again!

@mrinalirao mrinalirao marked this pull request as draft August 24, 2023 00:34
@mrinalirao mrinalirao marked this pull request as ready for review December 26, 2023 22:26
@mrinalirao
Copy link
Contributor Author

This is ready to be reviewed :)

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.

Can you also add these to generate_mocks.sh as well as to the "Admin" section of the API Coverage in the README?

admin_opa_version.go Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
brandonc
brandonc previously approved these changes Jan 2, 2024
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.

Ran tests without issue. go-tfe API looks good.

@brandonc brandonc dismissed sebasslash’s stale review January 2, 2024 18:24

Feedback addressed

@brandonc brandonc merged commit 966669f into main Jan 2, 2024
10 checks passed
@brandonc brandonc deleted the mr/pprv_policy_provider branch January 2, 2024 20:19
Copy link

github-actions bot commented Jan 2, 2024

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