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 client for Connections API, some wiring up the client to the provider #1809

Merged
merged 21 commits into from
Sep 24, 2024

Conversation

fridgepoet
Copy link
Member

@fridgepoet fridgepoet commented Sep 19, 2024

This PR:

  • adds a client to reach the Connections API to create metrics endpoint scrape jobs, based on ongoing work from the Cloud Provider O11y squad on AWS scrape jobs
  • adds some wiring for the client to be initialized in the provider, provided an access token and url are provided
  • fixes up (housekeeping) some errors in the code that were added previously (e.g. value receiver instead of pointer receiver Scaffold metrics endpoint scrape job resource #1807)
  • adds to the resource's metrics endpoint scrape URL validation (it also must be https)

This contributes to #7670 and #7671

Special notes:

  • metrics endpoint scrape URL validation (must be https)

Alright, I found hashicorp/terraform-plugin-framework-validators#125, maybe they'll make a URL validator.

In the meantime, I added one in the latest commit:

Some examples with a terraform resource:

  1. resource has url = ""
Step 1/1 error: Error running pre-apply refresh: exit status 1
        
Error: value must be valid URL with HTTPS

  with grafana_connections_metrics_endpoint_scrape_job.test,
  on terraform_plugin_test.tf line 7, in resource "grafana_connections_metrics_endpoint_scrape_job" "test":
   7:   url = ""

A valid URL is required.

Given Value: ""
  1. resource does not have https: url="www.google.com"
Step 1/1 error: Error running pre-apply refresh: exit status 1
        
Error: value must be valid URL with HTTPS

  with grafana_connections_metrics_endpoint_scrape_job.test,
  on terraform_plugin_test.tf line 7, in resource "grafana_connections_metrics_endpoint_scrape_job" "test":
   7:   url = "www.google.com"

A URL was provided, protocol must be HTTPS.

Given Value: "www.google.com"

Copy link

In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically.
To do so, a Grafana Labs employee must trigger the cloud acceptance tests workflow manually.

@fridgepoet
Copy link
Member Author

fridgepoet commented Sep 19, 2024

@matthewnolf Do you have any idea about this lint error? https://github.com/grafana/terraform-provider-grafana/actions/runs/10942942082/job/30381152446?pr=1809#step:3:67

Edit: changed to pointer receivers as discussed, thanks Matt

@fridgepoet fridgepoet marked this pull request as ready for review September 19, 2024 14:53
@fridgepoet fridgepoet requested a review from a team as a code owner September 19, 2024 14:53
internal/common/client.go Outdated Show resolved Hide resolved
internal/common/connectionsapi/client.go Outdated Show resolved Hide resolved
internal/common/connectionsapi/client.go Outdated Show resolved Hide resolved
internal/common/connectionsapi/client.go Outdated Show resolved Hide resolved
internal/common/connectionsapi/client.go Outdated Show resolved Hide resolved
internal/common/connectionsapi/client_test.go Outdated Show resolved Hide resolved
internal/common/connectionsapi/client_test.go Outdated Show resolved Hide resolved
@fridgepoet fridgepoet changed the title Add client for Connections API Add client for Connections API, some wiring up the client to the provider Sep 23, 2024
internal/common/connectionsapi/client_test.go Outdated Show resolved Hide resolved
internal/common/connectionsapi/client_test.go Outdated Show resolved Hide resolved
@fridgepoet fridgepoet merged commit b8082de into metrics-endpoint Sep 24, 2024
19 of 26 checks passed
@fridgepoet fridgepoet deleted the shirley/connections-api-client branch September 24, 2024 16:13
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.

2 participants