Share PostHog region mapping and tidy pagination
The us/eu host strings lived in the driver and were duplicated in the connector-settings resolver. Expose drivers.PostHogRegionBaseURL as the single source and call it from the resolver. Also parse the base URL only inside the absolute-next branch of resolveNextURL, where it is actually used for the host check. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"go.probo.inc/probo/pkg/accessreview/drivers"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/server/api/console/v1/types"
|
||||
)
|
||||
@@ -98,7 +99,7 @@ func apiKeyConnectorSettings(input types.CreateAPIKeyConnectorInput) (json.RawMe
|
||||
return nil, fmt.Errorf("cannot create posthog connector: posthogRegion is required")
|
||||
}
|
||||
|
||||
baseURL, ok := posthogRegionBaseURL(*input.PosthogRegion)
|
||||
baseURL, ok := drivers.PostHogRegionBaseURL(*input.PosthogRegion)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cannot create posthog connector: posthogRegion must be US or EU")
|
||||
}
|
||||
@@ -120,20 +121,6 @@ func apiKeyConnectorSettings(input types.CreateAPIKeyConnectorInput) (json.RawMe
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// posthogRegionBaseURL maps a PostHog Cloud region selector to its data-API
|
||||
// base host. Only US and EU clouds exist; self-hosted instances use the
|
||||
// dedicated POSTHOG_SELF_HOSTED provider with a full instance URL instead.
|
||||
func posthogRegionBaseURL(region string) (string, bool) {
|
||||
switch region {
|
||||
case "US", "us":
|
||||
return "https://us.posthog.com", true
|
||||
case "EU", "eu":
|
||||
return "https://eu.posthog.com", true
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
}
|
||||
|
||||
// clientCredentialsConnectorSettings marshals the provider-specific
|
||||
// extra settings for a client-credentials connector. See
|
||||
// apiKeyConnectorSettings for the error contract.
|
||||
|
||||
Reference in New Issue
Block a user