-
Notifications
You must be signed in to change notification settings - Fork 46
refactor: make use of generated clients for composer #1540
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the composer client instantiation to make use of the generated clients based on OAS3, along with renaming and updating method calls to match the new client interface. Key changes include:
- Replacing older client constructors with NewClientFromConfig in several modules.
- Updating type references from ComposerClient to Client and renaming method calls (e.g., Compose → PostCompose, OpenAPI → GetOpenapi).
- Enhancing the oauth2 package with new Doer and TokenerDoer interfaces and updating DummyToken and LazyToken implementations accordingly.
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
internal/v1/server_test.go | Updated client instantiation to use NewClientFromConfig. |
internal/v1/server.go | Changed client type from ComposerClient to Client in both struct and configuration. |
internal/v1/handler_compose_image.go | Replaced Compose with PostCompose method call. |
internal/v1/handler.go | Updated several composer method calls to their new naming conventions (GetOpenapi, GetComposeStatus, etc.). |
internal/oauth2/lazy_token.go | Introduced Doer and TokenerDoer interfaces and updated LazyToken to implement Do. |
internal/oauth2/dummy_token.go | Extended DummyToken to implement SetClient and Do methods. |
internal/oauth2/doer.go | Added a helper function to perform HTTP requests using tracing and token-based authentication. |
internal/clients/composer/client.go | Refactored client creation to use NewClientFromConfig and modified the configuration to use a TokenerDoer. |
internal/clients/composer/client.cfg.yaml | Enabled client generation for the composer client code. |
cmd/image-builder/main.go | Updated the composer client instantiation to use the new NewClientFromConfig. |
Comments suppressed due to low confidence (1)
internal/clients/composer/client.go:38
- [nitpick] The field name 'Client' in the client struct may be confusing since it overlaps with the package name and typical HTTP client terminology. Consider renaming it to something more descriptive, such as 'Tokener' or 'doer', to better convey its purpose.
client.Client = conf.Tokener
cb37c69
to
507518b
Compare
} | ||
|
||
return resp, err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actual token handling is now part of the Tokener itself. It implements Doer
interface to do that.
@@ -57,7 +57,7 @@ func (h *Handlers) GetVersion(ctx echo.Context) error { | |||
} | |||
|
|||
func (h *Handlers) GetReadiness(ctx echo.Context) error { | |||
resp, err := h.server.cClient.OpenAPI(ctx.Request().Context()) | |||
resp, err := h.server.cClient.GetOpenapi(ctx.Request().Context()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the intermediate client is gone, all generated methods can be used directly.
I have always wondered why client code is not generated, this fixes it. It should be pretty stragithforward change for all other OAS3 clients (not onese which are OpenAPI 3.1). Review with care, things can go wild here.