compose up and other compose commands running on “Moby” context type.

Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
This commit is contained in:
Guillaume Tardif 2020-12-04 18:09:12 +01:00
parent 3190456101
commit ec5afcfd4d
12 changed files with 30 additions and 36 deletions

View file

@ -32,6 +32,15 @@ import (
// New returns a backend client associated with current context
func New(ctx context.Context) (*Client, error) {
return newWithDefaultBackend(ctx, "")
}
// NewWithDefaultLocalBackend returns a backend client associated with current context or local backend if on default context type
func NewWithDefaultLocalBackend(ctx context.Context) (*Client, error) {
return newWithDefaultBackend(ctx, store.LocalContextType)
}
func newWithDefaultBackend(ctx context.Context, defaultBackend string) (*Client, error) {
currentContext := apicontext.CurrentContext(ctx)
s := store.ContextStore(ctx)
@ -40,7 +49,12 @@ func New(ctx context.Context) (*Client, error) {
return nil, err
}
service, err := backend.Get(ctx, cc.Type())
backendName := cc.Type()
if backendName == store.DefaultContextType && defaultBackend != "" {
backendName = defaultBackend
}
service, err := backend.Get(ctx, backendName)
if err != nil {
return nil, err
}