Skip to content

Commit

Permalink
fix: allow for usage with self-hosted Prefect server (work_pools) (#127)
Browse files Browse the repository at this point in the history
* use client url builder where needed

* remove api key warning for oss server endpoint
  • Loading branch information
parkedwards authored Nov 30, 2023
1 parent 19f93c0 commit 70d1ca1
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 26 deletions.
2 changes: 1 addition & 1 deletion internal/client/account_memberships.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (c *Client) AccountMemberships(accountID uuid.UUID) (api.AccountMemberships
return &AccountMembershipsClient{
hc: c.hc,
apiKey: c.apiKey,
routePrefix: fmt.Sprintf("%s/accounts/%s/account_memberships", c.endpoint, accountID.String()),
routePrefix: getAccountScopedURL(c.endpoint, accountID, "account_memberships"),
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/client/account_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (c *Client) AccountRoles(accountID uuid.UUID) (api.AccountRolesClient, erro
return &AccountRolesClient{
hc: c.hc,
apiKey: c.apiKey,
routePrefix: fmt.Sprintf("%s/accounts/%s/account_roles", c.endpoint, accountID.String()),
routePrefix: getAccountScopedURL(c.endpoint, accountID, "account_roles"),
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/client/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (c *Client) Accounts(accountID uuid.UUID) (api.AccountsClient, error) {
return &AccountsClient{
hc: c.hc,
apiKey: c.apiKey,
routePrefix: fmt.Sprintf("%s/accounts/%s", c.endpoint, accountID.String()),
routePrefix: getAccountScopedURL(c.endpoint, accountID, ""),
}, nil
}

Expand Down
4 changes: 0 additions & 4 deletions internal/client/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ func (c *Client) Variables(accountID uuid.UUID, workspaceID uuid.UUID) (api.Vari
workspaceID = c.defaultWorkspaceID
}

if accountID == uuid.Nil || workspaceID == uuid.Nil {
return nil, fmt.Errorf("both accountID and workspaceID must be set: accountID is %q and workspaceID is %q", accountID, workspaceID)
}

return &VariablesClient{
hc: c.hc,
apiKey: c.apiKey,
Expand Down
4 changes: 0 additions & 4 deletions internal/client/work_pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ func (c *Client) WorkPools(accountID uuid.UUID, workspaceID uuid.UUID) (api.Work
workspaceID = c.defaultWorkspaceID
}

if accountID == uuid.Nil || workspaceID == uuid.Nil {
return nil, fmt.Errorf("both accountID and workspaceID must be set: accountID is %q and workspaceID is %q", accountID, workspaceID)
}

return &WorkPoolsClient{
hc: c.hc,
apiKey: c.apiKey,
Expand Down
2 changes: 1 addition & 1 deletion internal/client/workspace_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (c *Client) WorkspaceRoles(accountID uuid.UUID) (api.WorkspaceRolesClient,
return &WorkspaceRolesClient{
hc: c.hc,
apiKey: c.apiKey,
routePrefix: fmt.Sprintf("%s/accounts/%s/workspace_roles", c.endpoint, accountID.String()),
routePrefix: getAccountScopedURL(c.endpoint, accountID, "workspace_roles"),
}, nil
}

Expand Down
14 changes: 0 additions & 14 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,6 @@ func (p *PrefectProvider) Configure(ctx context.Context, req provider.ConfigureR
}
}

// If the endpoint is pointed to a self-hosted Prefect Server installation,
// we will warn the practitioner if an API Key is set, as it's possible that
// this is a user misconfiguration.
if !isPrefectCloudEndpoint {
if apiKey != "" {
resp.Diagnostics.AddAttributeWarning(
path.Root("api_key"),
"Prefect API Key ",
"The Prefect API Key is set, however, the Endpoint is set to a Prefect server installation. "+
"Potential resolutions: set the endpoint attribute or PREFECT_API_URL environment variable to a Prefect Cloud endpoint, unset the PREFECT_API_KEY environment variable, or remove the api_key attribute.",
)
}
}

if resp.Diagnostics.HasError() {
return
}
Expand Down

0 comments on commit 70d1ca1

Please sign in to comment.