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

VAULT-31135: add new hcp_vault_radar_source_github_cloud resource. #1119

Merged
merged 3 commits into from
Oct 18, 2024

Conversation

trentdibacco
Copy link
Contributor

@trentdibacco trentdibacco commented Oct 15, 2024

🛠️ Description

Preview of managing a Vault Radar GitHub Cloud via the HCP Terraform Provider.

This introduces a new hcp_vault_radar_source_github_cloud resource.

This is similar to hcp_vault_radar_source_github_enterprise which already existed. I refactored out the commonality that manages Radar source TF resources. Both the new hcp_vault_radar_source_github_cloud and the existing hcp_vault_radar_source_github_enterprise share the same resource implementation, but still provide different schemas, validation, and resource names. This abstraction will allow use to introduce support for managing other radar source like GitLab and Bitbucket later on.

Note

This is a preview, and my intent is for this resource not to show up in the in the online documentations.
Therefore, I did not set the subcategory in the markup.

New Resource Checklist

  • Plugin Framework
  • Minimal LOC:
  • Acceptance Tests:
  • Documentation:
  • Well-formed Code: go fmt.

Schema

  • Uses Globally Unique ID: Uses GUID returned by server.
  • Validates Fields Where Possible:
  • Supports Optional Project ID Input:

CRUD Operations

  • Uses Context-Aware CRUD Functions:
  • Uses Context For API Calls:
  • Uses DRY API Calls:
  • Handles Existing Resource Prior To Create:
  • Refreshes Attributes During Read:
  • Handles Removed Resource During Read:
  • Handles Failed State During Read:
  • Handles Nonexistent Resource Prior To Delete:

Documentation

  • Includes Descriptions For Resource And Fields:
  • Includes Example:
  • Includes Generated Docs:

🏗️ Acceptance tests

Note

These acceptance tests works, but requires external environments not avail to CI/CD.
These tests are being skipped because of pre-existing conditions that would be require for the test to succeed.

  • Requires Project already setup with Radar.
  • Requires a Service Account with an Admin role on the Project.
  • Access to a GitHub Cloud Orginization
  • Requires the following environment variables to be set:
    • HCP_PROJECT_ID
    • RADAR_GITHUB_CLOUD_ORGANIZATION
    • RADAR_GITHUB_CLOUD_TOKEN

Note

A ticket exist to address this in the future.
https://hashicorp.atlassian.net/browse/VAULT-31712

  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Output from acceptance testing:

make testacc TESTARGS='-run=TestRadarSourceGitHubCloud'
...
=== RUN   TestRadarSourceGitHubCloud
--- PASS: TestRadarSourceGitHubCloud (26.90s)
...

@trentdibacco trentdibacco requested review from a team as code owners October 15, 2024 23:21
Copy link
Contributor Author

@trentdibacco trentdibacco Oct 15, 2024

Choose a reason for hiding this comment

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

This implementation for most part was taken from the previous implementation of resource_radar_source_github_enterprise but refactored out a few things to be shared with resource_radar_source_github_cloud.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of the red in this file moved to the abstraction in radar_source

Copy link

@kathytong-hashicorp kathytong-hashicorp left a comment

Choose a reason for hiding this comment

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

LGTM!

)

// radarSourceResource is an implementation for configuring specific types Radar data sources.
// Examples: hcp_vault_radar_source_github_cloud and hcp__vault_radar_source_github_enterprise make use of

Choose a reason for hiding this comment

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

nit: Should be one underscore instead of the two hcp__vault_radar_source_github_enterprise ?

@@ -0,0 +1,3 @@
```release-note:feature

Choose a reason for hiding this comment

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

Curious where 1119 comes from, I see 1116 from your last PR but don't see 1117 or 1118 on main, are they from other PRs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

1119 the PR number

@trentdibacco trentdibacco merged commit f92d07d into main Oct 18, 2024
6 checks passed
@trentdibacco trentdibacco deleted the vault_radar_source_github_cloud branch October 18, 2024 16:26
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.

4 participants