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

🧹 Allow to override the API endpoint #12

Merged
merged 2 commits into from
Dec 5, 2023

Conversation

czunker
Copy link
Contributor

@czunker czunker commented Dec 5, 2023

Fixes #9

This comment has been minimized.

Fixes #9

Signed-off-by: Christian Zunker <[email protected]>
@czunker czunker force-pushed the christian/set_api_endpoint branch from 5b61056 to 015e1cb Compare December 5, 2023 11:21
gen/gen.go Outdated
@@ -176,10 +177,19 @@ fragment TypeRef on __Type {
}
}
`
apiEndpoint := "https://" + apiHost + "/query"
Copy link
Member

Choose a reason for hiding this comment

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

we should define apiHost := "us.api.mondoo.com" close to this code since its otherwise difficult to read

Copy link
Member

Choose a reason for hiding this comment

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

we should parse the url and prepend https if no schema is defined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

gen/gen.go Outdated
apiEndpoint := "https://" + apiHost + "/query"
endpoint, ok := os.LookupEnv("MONDOO_API_ENDPOINT")
if ok {
apiEndpoint, err = url.JoinPath(endpoint, "/query")
Copy link
Member

Choose a reason for hiding this comment

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

we should apply that logic to the default api host too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Signed-off-by: Christian Zunker <[email protected]>
Copy link
Member

@chris-rock chris-rock left a comment

Choose a reason for hiding this comment

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

Thank you @czunker

@chris-rock chris-rock merged commit 85d860c into main Dec 5, 2023
7 checks passed
@chris-rock chris-rock deleted the christian/set_api_endpoint branch December 5, 2023 13:54
@github-actions github-actions bot locked and limited conversation to collaborators Dec 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to override the endpoint in gen.go
2 participants