Skip to content

Add proxy support for ImageRepository API#627

Merged
stefanprodan merged 1 commit intofluxcd:mainfrom
matheuscscp:imagerepo-proxy
Sep 11, 2024
Merged

Add proxy support for ImageRepository API#627
stefanprodan merged 1 commit intofluxcd:mainfrom
matheuscscp:imagerepo-proxy

Conversation

@matheuscscp
Copy link
Copy Markdown
Member

Fixes #612

@stefanprodan stefanprodan added enhancement New feature or request area/api API related issues and pull requests labels Aug 28, 2024
Copy link
Copy Markdown
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks @matheuscscp 🏅

Comment thread internal/controller/imagerepository_controller_test.go Outdated
Comment thread internal/controller/imagerepository_controller_test.go Outdated
Comment thread internal/controller/imagerepository_controller.go Outdated
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Comment on lines -360 to +382
auth, authErr = login.NewManager().Login(ctx, obj.Spec.Image, ref, opts)
var managerOpts []login.Option
if proxyURL != nil {
managerOpts = append(managerOpts, login.WithProxyURL(proxyURL))
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not login.NewManager(login.WithProxyURL(proxyURL)).Login(...), the nil check is done by the manager. This is how I did it in source-controller here: fluxcd/source-controller#1607

Copy link
Copy Markdown
Member Author

@matheuscscp matheuscscp Sep 10, 2024

Choose a reason for hiding this comment

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

I think login.NewManager(login.WithProxyURL(proxyURL)).Login(...) kinda suggests to the reader that there is always a proxy URL set in this case even though it may not be true (and this expression is also very long, and would read nicer if broken down, but that's unrelated to your specific suggestion, we could just break it in managerOpts := ...; manager := ...; manager.Login(...) and still do it as you say). This is how I did it for most of these optional parameters for Bucket: https://github.com/fluxcd/source-controller/blob/main/internal/controller/bucket_controller.go#L449-L537

Copy link
Copy Markdown
Contributor

@darkowlzz darkowlzz left a comment

Choose a reason for hiding this comment

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

LGTM!

@stefanprodan stefanprodan merged commit 5f8ca00 into fluxcd:main Sep 11, 2024
@matheuscscp matheuscscp deleted the imagerepo-proxy branch September 11, 2024 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api API related issues and pull requests enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add proxy support in ImageRepository

3 participants