pass services list to projectOrName function to add profiles for targeted services

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
Guillaume Lours 2022-11-28 22:07:36 +01:00 committed by Nicolas De loof
parent ed38fe0da8
commit 24ec0b2d09
9 changed files with 11 additions and 11 deletions

View File

@ -137,11 +137,11 @@ func (o *projectOptions) addProjectFlags(f *pflag.FlagSet) {
_ = f.MarkHidden("workdir")
}
func (o *projectOptions) projectOrName() (*types.Project, string, error) {
func (o *projectOptions) projectOrName(services ...string) (*types.Project, string, error) {
name := o.ProjectName
var project *types.Project
if o.ProjectName == "" {
p, err := o.toProject(nil)
p, err := o.toProject(services)
if err != nil {
envProjectName := os.Getenv("COMPOSE_PROJECT_NAME")
if envProjectName != "" {

View File

@ -54,7 +54,7 @@ func killCommand(p *projectOptions, backend api.Service) *cobra.Command {
}
func runKill(ctx context.Context, backend api.Service, opts killOptions, services []string) error {
project, name, err := opts.projectOrName()
project, name, err := opts.projectOrName(services...)
if err != nil {
return err
}

View File

@ -63,7 +63,7 @@ func logsCommand(p *projectOptions, backend api.Service) *cobra.Command {
}
func runLogs(ctx context.Context, backend api.Service, opts logsOptions, services []string) error {
project, name, err := opts.projectOrName()
project, name, err := opts.projectOrName(services...)
if err != nil {
return err
}

View File

@ -44,7 +44,7 @@ func pauseCommand(p *projectOptions, backend api.Service) *cobra.Command {
}
func runPause(ctx context.Context, backend api.Service, opts pauseOptions, services []string) error {
project, name, err := opts.projectOrName()
project, name, err := opts.projectOrName(services...)
if err != nil {
return err
}
@ -75,7 +75,7 @@ func unpauseCommand(p *projectOptions, backend api.Service) *cobra.Command {
}
func runUnPause(ctx context.Context, backend api.Service, opts unpauseOptions, services []string) error {
project, name, err := opts.projectOrName()
project, name, err := opts.projectOrName(services...)
if err != nil {
return err
}

View File

@ -91,7 +91,7 @@ func psCommand(p *projectOptions, backend api.Service) *cobra.Command {
}
func runPs(ctx context.Context, backend api.Service, services []string, opts psOptions) error {
project, name, err := opts.projectOrName()
project, name, err := opts.projectOrName(services...)
if err != nil {
return err
}

View File

@ -59,7 +59,7 @@ Any data which is not in a volume will be lost.`,
}
func runRemove(ctx context.Context, backend api.Service, opts removeOptions, services []string) error {
project, name, err := opts.projectOrName()
project, name, err := opts.projectOrName(services...)
if err != nil {
return err
}

View File

@ -49,7 +49,7 @@ func restartCommand(p *projectOptions, backend api.Service) *cobra.Command {
}
func runRestart(ctx context.Context, backend api.Service, opts restartOptions, services []string) error {
project, name, err := opts.projectOrName()
project, name, err := opts.projectOrName(services...)
if err != nil {
return err
}

View File

@ -43,7 +43,7 @@ func startCommand(p *projectOptions, backend api.Service) *cobra.Command {
}
func runStart(ctx context.Context, backend api.Service, opts startOptions, services []string) error {
project, name, err := opts.projectOrName()
project, name, err := opts.projectOrName(services...)
if err != nil {
return err
}

View File

@ -53,7 +53,7 @@ func stopCommand(p *projectOptions, backend api.Service) *cobra.Command {
}
func runStop(ctx context.Context, backend api.Service, opts stopOptions, services []string) error {
project, name, err := opts.projectOrName()
project, name, err := opts.projectOrName(services...)
if err != nil {
return err
}