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

Global only APIs need URL overwritten on each call #20

Open
pmalek opened this issue Nov 8, 2024 · 3 comments
Open

Global only APIs need URL overwritten on each call #20

pmalek opened this issue Nov 8, 2024 · 3 comments
Assignees

Comments

@pmalek
Copy link
Member

pmalek commented Nov 8, 2024

Problem statement

Up until now, this SDK worked around the global URLs for calls that were not targeted for the default API (prod) with the following work around:

switch hookCtx.OperationID {
case "get-organizations-me":
// NOTE(pmalek): This is because we merge OpenAPI specs and /organizations/me
// is only served by the global API.
// @mheap mentioned that we can add operation specific URLs to do away with this.
if strings.HasSuffix(req.URL.Host, "api.konghq.tech") {
req.URL.Host = "global.api.konghq.tech"
} else {
req.URL.Host = "global.api.konghq.com"
}
}
return req, nil
}

This doesn't scale.

Recently, working on KIC's user roles cleanup code (https://github.com/Kong/kubernetes-ingress-controller/blob/main/hack/cleanup/konnect_control_planes.go) I've noticed that listing user roles has the same problem and that would require adding yet another operation ID to to above linked workaround.

This issue tracks the effort to provide a proper solution for this problem.

@pmalek pmalek self-assigned this Nov 8, 2024
@mheap
Copy link
Member

mheap commented Nov 9, 2024

We solve this in Terraform with per operation server blocks. When you’re tackling this, please let me know and we can brainstorm

@pmalek
Copy link
Member Author

pmalek commented Nov 13, 2024

I've opened a thread at https://kongstrong.slack.com/archives/C05MLAA216D/p1731523197026319.

Not sure yet but perhaps this has to do with the fact that other (non global) APIs have other geo based URLs "to choose from", whereas there's only 1 global URL which is "hardcoded" in generated sdk, example:

sdk-konnect-go/roles.go

Lines 1671 to 1672 in 2361947

baseURL := utils.ReplaceParameters(operations.UsersRemoveRoleServerList[0], map[string]string{})

@pmalek
Copy link
Member Author

pmalek commented Nov 19, 2024

As of 0.1.7 this has a workaround by using KONG_CUSTOM_DOMAIN env: 4f50eb7.

Proper solution might need to wait for https://speakeasy.productlane.com/roadmap/caefbf9e-36f3-40a0-8de3-252d2f4ec600

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

No branches or pull requests

2 participants