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

feat(client): add GetEndpointHost utility getter #347

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

parkedwards
Copy link
Contributor

@parkedwards parkedwards commented Dec 24, 2024

resolves https://linear.app/prefect/issue/PLA-841/extract-path-suffix-less-api-endpoint-into-webhook-resource
resolves #333

this PR adds an endpointHost (host only, so no prefix) attribute to the PrefectClient, as well as a getter method on the interface. we use this to construct the full webhook endpoint, since the API only stashes the slug portion, and we'll want to expose a fully formed endpoint based on the API that the provider is initialized with

@parkedwards parkedwards changed the title add endpoint host and hook into webhooks feat(client): add GetEndpointHost utility getter Dec 24, 2024
@@ -6,6 +6,8 @@ import "github.com/google/uuid"
//
//nolint:interfacebloat // we'll accept a larger PrefectClient interface
type PrefectClient interface {
GetEndpointHost() string
Copy link
Contributor Author

Choose a reason for hiding this comment

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

todo: add a comment string that differentiates the client factories from a new category of methods like this one

@parkedwards parkedwards added the maintenance Maintenance work - won't show in release notes label Dec 24, 2024
@@ -131,6 +134,23 @@ func testAccCheckWebhookExists(webhookResourceName string, webhook *api.Webhook)
}
}

func testAccCheckWebhookEndpoint(webhookResourceName string, webhook *api.Webhook) resource.TestCheckFunc {
Copy link
Contributor Author

@parkedwards parkedwards Dec 26, 2024

Choose a reason for hiding this comment

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

it's worth calling out here, since i couldn't verify this behavior from their docs + only found it through testing the actual control flow

basically, there's a pattern in the testing docs where you can instantiate a pointer outside of the test steps, hydrate it with a custom test function, and then reference it again in the subsequent function

https://developer.hashicorp.com/terraform/plugin/testing/acceptance-tests/teststep#custom-check-functions

however, the nuance is that these custom functions seem to run well after any pre-built check function on the resource. object, eg. resource.TestCheckResourceAttr - so you can't run these resource checks against the hydrated value, because the pointer will still be a zero value

you can, however, perform this check with another custom test function because the value appears to be hydrated at execution time - so that's what we do here

this answers the issue raised here, so closing this PR will resolve #120

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs maintenance Maintenance work - won't show in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

extract path-suffix-less API endpoint into webhook resource
1 participant