mirror of
https://github.com/containers/podman.git
synced 2026-07-21 04:31:57 -04:00
* Support the `X-Registry-Auth` http-request header. * The content of the header is a base64 encoded JSON payload which can either be a single auth config or a map of auth configs (user+pw or token) with the corresponding registries being the keys. Vanilla Docker, projectatomic Docker and the bindings are transparantly supported. * Add a hidden `--registries-conf` flag. Buildah exposes the same flag, mostly for testing purposes. * Do all credential parsing in the client (i.e., `cmd/podman`) pass the username and password in the backend instead of unparsed credentials. * Add a `pkg/auth` which handles most of the heavy lifting. * Go through the authentication-handling code of most commands, bindings and endpoints. Migrate them to the new code and fix issues as seen. A final evaluation and more tests is still required *after* this change. * The manifest-push endpoint is missing certain parameters and should use the ABI function instead. Adding auth-support isn't really possible without these parts working. * The container commands and endpoints (i.e., create and run) have not been changed yet. The APIs don't yet account for the authfile. * Add authentication tests to `pkg/bindings`. Fixes: #6384 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
103 lines
2.6 KiB
Go
103 lines
2.6 KiB
Go
package mpb
|
|
|
|
import (
|
|
"io"
|
|
"io/ioutil"
|
|
"sync"
|
|
"time"
|
|
)
|
|
|
|
// ContainerOption is a function option which changes the default
|
|
// behavior of progress container, if passed to mpb.New(...ContainerOption).
|
|
type ContainerOption func(*pState)
|
|
|
|
// WithWaitGroup provides means to have a single joint point. If
|
|
// *sync.WaitGroup is provided, you can safely call just p.Wait()
|
|
// without calling Wait() on provided *sync.WaitGroup. Makes sense
|
|
// when there are more than one bar to render.
|
|
func WithWaitGroup(wg *sync.WaitGroup) ContainerOption {
|
|
return func(s *pState) {
|
|
s.uwg = wg
|
|
}
|
|
}
|
|
|
|
// WithWidth sets container width. If not set underlying bars will
|
|
// occupy whole term width.
|
|
func WithWidth(width int) ContainerOption {
|
|
return func(s *pState) {
|
|
s.reqWidth = width
|
|
}
|
|
}
|
|
|
|
// WithRefreshRate overrides default 120ms refresh rate.
|
|
func WithRefreshRate(d time.Duration) ContainerOption {
|
|
return func(s *pState) {
|
|
s.rr = d
|
|
}
|
|
}
|
|
|
|
// WithManualRefresh disables internal auto refresh time.Ticker.
|
|
// Refresh will occur upon receive value from provided ch.
|
|
func WithManualRefresh(ch <-chan time.Time) ContainerOption {
|
|
return func(s *pState) {
|
|
s.refreshSrc = ch
|
|
}
|
|
}
|
|
|
|
// WithRenderDelay delays rendering. By default rendering starts as
|
|
// soon as bar is added, with this option it's possible to delay
|
|
// rendering process by keeping provided chan unclosed. In other words
|
|
// rendering will start as soon as provided chan is closed.
|
|
func WithRenderDelay(ch <-chan struct{}) ContainerOption {
|
|
return func(s *pState) {
|
|
s.renderDelay = ch
|
|
}
|
|
}
|
|
|
|
// WithShutdownNotifier provided chanel will be closed, after all bars
|
|
// have been rendered.
|
|
func WithShutdownNotifier(ch chan struct{}) ContainerOption {
|
|
return func(s *pState) {
|
|
s.shutdownNotifier = ch
|
|
}
|
|
}
|
|
|
|
// WithOutput overrides default os.Stdout output. Setting it to nil
|
|
// will effectively disable auto refresh rate and discard any output,
|
|
// useful if you want to disable progress bars with little overhead.
|
|
func WithOutput(w io.Writer) ContainerOption {
|
|
return func(s *pState) {
|
|
if w == nil {
|
|
s.refreshSrc = make(chan time.Time)
|
|
s.output = ioutil.Discard
|
|
return
|
|
}
|
|
s.output = w
|
|
}
|
|
}
|
|
|
|
// WithDebugOutput sets debug output.
|
|
func WithDebugOutput(w io.Writer) ContainerOption {
|
|
if w == nil {
|
|
return nil
|
|
}
|
|
return func(s *pState) {
|
|
s.debugOut = w
|
|
}
|
|
}
|
|
|
|
// PopCompletedMode will pop and stop rendering completed bars.
|
|
func PopCompletedMode() ContainerOption {
|
|
return func(s *pState) {
|
|
s.popCompleted = true
|
|
}
|
|
}
|
|
|
|
// ContainerOptOn returns option when condition evaluates to true.
|
|
func ContainerOptOn(option ContainerOption, condition func() bool) ContainerOption {
|
|
if condition() {
|
|
return option
|
|
}
|
|
return nil
|
|
}
|