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

Implement terraform Resource methods on resourceMetricsEndpointScrapeJob #1812

Open
wants to merge 12 commits into
base: metrics-endpoint
Choose a base branch
from

Conversation

fridgepoet
Copy link
Member

@fridgepoet fridgepoet commented Sep 23, 2024

This implements the methods for a terraform Resource on resourceMetricsEndpointScrapeJob.

Contributes to https://github.com/grafana/cloud-onboarding/issues/7670.

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.

Base automatically changed from shirley/connections-api-client to metrics-endpoint September 24, 2024 16:12
@fridgepoet fridgepoet force-pushed the shirley/terraform-resource-methods branch from 4fffc5a to 43a37f0 Compare September 25, 2024 15:00
@fridgepoet fridgepoet marked this pull request as ready for review September 25, 2024 15:14
@fridgepoet fridgepoet requested a review from a team as a code owner September 25, 2024 15:14
@fridgepoet fridgepoet marked this pull request as draft September 26, 2024 15:31
@fridgepoet fridgepoet force-pushed the shirley/terraform-resource-methods branch from 6fde641 to a70d7b0 Compare October 9, 2024 09:21
@@ -27,9 +27,6 @@ const (

func NewClient(authToken string, rawURL string, client *http.Client) (*Client, error) {
parsedURL, err := url.Parse(rawURL)
if parsedURL.Scheme != "https" {
Copy link
Member Author

Choose a reason for hiding this comment

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

Removing this check in order to mock with normal httptest server in acceptance tests.

@fridgepoet
Copy link
Member Author

The failing acceptance tests/cloudinstance seems to be from OnCall tests.. https://github.com/grafana/terraform-provider-grafana/actions/runs/11295196530/job/31417373511?pr=1812

@fridgepoet fridgepoet marked this pull request as ready for review October 11, 2024 15:58
Copy link
Contributor

@matthewnolf matthewnolf left a comment

Choose a reason for hiding this comment

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

One question about enabled - but otherwise looks good!

Comment on lines +185 to +189
resp.State.SetAttribute(ctx, path.Root("stack_id"), jobTF.StackID)
resp.State.SetAttribute(ctx, path.Root("name"), jobTF.Name)
resp.State.SetAttribute(ctx, path.Root("authentication_method"), jobTF.AuthenticationMethod)
resp.State.SetAttribute(ctx, path.Root("url"), jobTF.URL)
resp.State.SetAttribute(ctx, path.Root("scrape_interval_seconds"), jobTF.ScrapeIntervalSeconds)
Copy link
Member Author

Choose a reason for hiding this comment

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

Matt, since we talked about this:
I tested out the scenario where we set the entire object: As you pointed out before, this unintentionally detects drift because we're trying to set an empty username/password.
So we do indeed want to set only the non-sensitive attributes.

{
category: "Connections",
testCheck: func(t *testing.T, filename string) {
t.Skip() // TODO: Make all examples work
Copy link
Member Author

Choose a reason for hiding this comment

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

This is copied from the other implementations: this is re-running the acceptance tests here in TestAccExamples, but without the declaration of the mock httptest server, these tests fail. I'm not sure what the long-term solution plan is.

The acceptance tests still run and are passing elsewhere.

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