up --no-deps option

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2021-02-23 14:27:24 +01:00
parent 2858911c1c
commit 04edb78ab6
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
2 changed files with 22 additions and 0 deletions

View File

@ -45,6 +45,7 @@ type runOptions struct {
entrypoint string
labels []string
name string
noDeps bool
}
func runCommand(p *projectOptions) *cobra.Command {
@ -75,6 +76,7 @@ func runCommand(p *projectOptions) *cobra.Command {
flags.StringVarP(&opts.user, "user", "u", "", "Run as specified username or uid")
flags.StringVarP(&opts.workdir, "workdir", "w", "", "Working directory inside the container")
flags.StringVar(&opts.entrypoint, "entrypoint", "", "Override the entrypoint of the image")
flags.BoolVar(&opts.noDeps, "no-deps", false, "Don't start linked services.")
flags.SetInterspersed(false)
return cmd
@ -86,6 +88,15 @@ func runRun(ctx context.Context, opts runOptions) error {
return err
}
if opts.noDeps {
enabled, err := project.GetService(opts.Service)
if err != nil {
return err
}
project.DisabledServices = append(project.DisabledServices, project.Services...)
project.Services = types.Services{enabled}
}
_, err = progress.Run(ctx, func(ctx context.Context) (string, error) {
return "", startDependencies(ctx, c, *project, opts.Service)
})

View File

@ -63,6 +63,7 @@ type upOptions struct {
noPrefix bool
timeChanged bool
timeout int
noDeps bool
}
func (o upOptions) recreateStrategy() string {
@ -122,6 +123,7 @@ func upCommand(p *projectOptions, contextType string) *cobra.Command {
flags.BoolVar(&opts.cascadeStop, "abort-on-container-exit", false, "Stops all containers if any container was stopped. Incompatible with -d")
flags.StringVar(&opts.exitCodeFrom, "exit-code-from", "", "Return the exit code of the selected service container. Implies --abort-on-container-exit")
flags.IntVarP(&opts.timeout, "timeout", "t", 10, "Use this timeout in seconds for container shutdown when attached or when containers are already running.")
flags.BoolVar(&opts.noDeps, "no-deps", false, "Don't start linked services.")
}
return upCmd
@ -152,6 +154,15 @@ func runCreateStart(ctx context.Context, opts upOptions, services []string) erro
return err
}
if opts.noDeps {
enabled, err := project.GetServices(services)
if err != nil {
return err
}
project.DisabledServices = append(project.DisabledServices, project.Services...)
project.Services = enabled
}
err = applyScaleOpt(opts.scale, project)
if err != nil {
return err