mirror of https://github.com/docker/compose.git
update projectOptions to be public by renaming it to ProjectOptions
Signed-off-by: Tiger Wang <tigerwang@outlook.com>
This commit is contained in:
parent
b8bbdcd872
commit
89ef8198f3
|
@ -34,7 +34,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type buildOptions struct {
|
type buildOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
composeOptions
|
composeOptions
|
||||||
quiet bool
|
quiet bool
|
||||||
pull bool
|
pull bool
|
||||||
|
@ -73,9 +73,9 @@ var printerModes = []string{
|
||||||
buildx.PrinterModeQuiet,
|
buildx.PrinterModeQuiet,
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func buildCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := buildOptions{
|
opts := buildOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "build [OPTIONS] [SERVICE...]",
|
Use: "build [OPTIONS] [SERVICE...]",
|
||||||
|
@ -129,7 +129,7 @@ func buildCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runBuild(ctx context.Context, backend api.Service, opts buildOptions, services []string) error {
|
func runBuild(ctx context.Context, backend api.Service, opts buildOptions, services []string) error {
|
||||||
project, err := opts.toProject(services, cli.WithResolvedPaths(true))
|
project, err := opts.ToProject(services, cli.WithResolvedPaths(true))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,9 @@ func noCompletion() validArgsFn {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func completeServiceNames(p *projectOptions) validArgsFn {
|
func completeServiceNames(p *ProjectOptions) validArgsFn {
|
||||||
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||||
project, err := p.toProject(nil)
|
project, err := p.ToProject(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ func Adapt(fn Command) func(cmd *cobra.Command, args []string) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type projectOptions struct {
|
type ProjectOptions struct {
|
||||||
ProjectName string
|
ProjectName string
|
||||||
Profiles []string
|
Profiles []string
|
||||||
ConfigPaths []string
|
ConfigPaths []string
|
||||||
|
@ -108,16 +108,16 @@ type ProjectFunc func(ctx context.Context, project *types.Project) error
|
||||||
type ProjectServicesFunc func(ctx context.Context, project *types.Project, services []string) error
|
type ProjectServicesFunc func(ctx context.Context, project *types.Project, services []string) error
|
||||||
|
|
||||||
// WithProject creates a cobra run command from a ProjectFunc based on configured project options and selected services
|
// WithProject creates a cobra run command from a ProjectFunc based on configured project options and selected services
|
||||||
func (o *projectOptions) WithProject(fn ProjectFunc) func(cmd *cobra.Command, args []string) error {
|
func (o *ProjectOptions) WithProject(fn ProjectFunc) func(cmd *cobra.Command, args []string) error {
|
||||||
return o.WithServices(func(ctx context.Context, project *types.Project, services []string) error {
|
return o.WithServices(func(ctx context.Context, project *types.Project, services []string) error {
|
||||||
return fn(ctx, project)
|
return fn(ctx, project)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithServices creates a cobra run command from a ProjectFunc based on configured project options and selected services
|
// WithServices creates a cobra run command from a ProjectFunc based on configured project options and selected services
|
||||||
func (o *projectOptions) WithServices(fn ProjectServicesFunc) func(cmd *cobra.Command, args []string) error {
|
func (o *ProjectOptions) WithServices(fn ProjectServicesFunc) func(cmd *cobra.Command, args []string) error {
|
||||||
return Adapt(func(ctx context.Context, args []string) error {
|
return Adapt(func(ctx context.Context, args []string) error {
|
||||||
project, err := o.toProject(args, cli.WithResolvedPaths(true))
|
project, err := o.ToProject(args, cli.WithResolvedPaths(true))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ func (o *projectOptions) WithServices(fn ProjectServicesFunc) func(cmd *cobra.Co
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *projectOptions) addProjectFlags(f *pflag.FlagSet) {
|
func (o *ProjectOptions) addProjectFlags(f *pflag.FlagSet) {
|
||||||
f.StringArrayVar(&o.Profiles, "profile", []string{}, "Specify a profile to enable")
|
f.StringArrayVar(&o.Profiles, "profile", []string{}, "Specify a profile to enable")
|
||||||
f.StringVarP(&o.ProjectName, "project-name", "p", "", "Project name")
|
f.StringVarP(&o.ProjectName, "project-name", "p", "", "Project name")
|
||||||
f.StringArrayVarP(&o.ConfigPaths, "file", "f", []string{}, "Compose configuration files")
|
f.StringArrayVarP(&o.ConfigPaths, "file", "f", []string{}, "Compose configuration files")
|
||||||
|
@ -137,11 +137,11 @@ func (o *projectOptions) addProjectFlags(f *pflag.FlagSet) {
|
||||||
_ = f.MarkHidden("workdir")
|
_ = f.MarkHidden("workdir")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *projectOptions) projectOrName(services ...string) (*types.Project, string, error) {
|
func (o *ProjectOptions) projectOrName(services ...string) (*types.Project, string, error) {
|
||||||
name := o.ProjectName
|
name := o.ProjectName
|
||||||
var project *types.Project
|
var project *types.Project
|
||||||
if len(o.ConfigPaths) > 0 || o.ProjectName == "" {
|
if len(o.ConfigPaths) > 0 || o.ProjectName == "" {
|
||||||
p, err := o.toProject(services)
|
p, err := o.ToProject(services)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
envProjectName := os.Getenv("COMPOSE_PROJECT_NAME")
|
envProjectName := os.Getenv("COMPOSE_PROJECT_NAME")
|
||||||
if envProjectName != "" {
|
if envProjectName != "" {
|
||||||
|
@ -155,7 +155,7 @@ func (o *projectOptions) projectOrName(services ...string) (*types.Project, stri
|
||||||
return project, name, nil
|
return project, name, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *projectOptions) toProjectName() (string, error) {
|
func (o *ProjectOptions) toProjectName() (string, error) {
|
||||||
if o.ProjectName != "" {
|
if o.ProjectName != "" {
|
||||||
return o.ProjectName, nil
|
return o.ProjectName, nil
|
||||||
}
|
}
|
||||||
|
@ -165,14 +165,14 @@ func (o *projectOptions) toProjectName() (string, error) {
|
||||||
return envProjectName, nil
|
return envProjectName, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
project, err := o.toProject(nil)
|
project, err := o.ToProject(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return project.Name, nil
|
return project.Name, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *projectOptions) toProject(services []string, po ...cli.ProjectOptionsFn) (*types.Project, error) {
|
func (o *ProjectOptions) ToProject(services []string, po ...cli.ProjectOptionsFn) (*types.Project, error) {
|
||||||
options, err := o.toProjectOptions(po...)
|
options, err := o.toProjectOptions(po...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, compose.WrapComposeError(err)
|
return nil, compose.WrapComposeError(err)
|
||||||
|
@ -222,7 +222,7 @@ func (o *projectOptions) toProject(services []string, po ...cli.ProjectOptionsFn
|
||||||
return project, err
|
return project, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *projectOptions) toProjectOptions(po ...cli.ProjectOptionsFn) (*cli.ProjectOptions, error) {
|
func (o *ProjectOptions) toProjectOptions(po ...cli.ProjectOptionsFn) (*cli.ProjectOptions, error) {
|
||||||
return cli.NewProjectOptions(o.ConfigPaths,
|
return cli.NewProjectOptions(o.ConfigPaths,
|
||||||
append(po,
|
append(po,
|
||||||
cli.WithWorkingDirectory(o.ProjectDir),
|
cli.WithWorkingDirectory(o.ProjectDir),
|
||||||
|
@ -254,7 +254,7 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command { //
|
||||||
"commandConn.CloseRead:",
|
"commandConn.CloseRead:",
|
||||||
))
|
))
|
||||||
|
|
||||||
opts := projectOptions{}
|
opts := ProjectOptions{}
|
||||||
var (
|
var (
|
||||||
ansi string
|
ansi string
|
||||||
noAnsi bool
|
noAnsi bool
|
||||||
|
@ -383,7 +383,7 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command { //
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
func setEnvWithDotEnv(prjOpts *projectOptions) error {
|
func setEnvWithDotEnv(prjOpts *ProjectOptions) error {
|
||||||
options, err := prjOpts.toProjectOptions()
|
options, err := prjOpts.toProjectOptions()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return compose.WrapComposeError(err)
|
return compose.WrapComposeError(err)
|
||||||
|
|
|
@ -35,7 +35,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type convertOptions struct {
|
type convertOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
Format string
|
Format string
|
||||||
Output string
|
Output string
|
||||||
quiet bool
|
quiet bool
|
||||||
|
@ -50,9 +50,9 @@ type convertOptions struct {
|
||||||
noConsistency bool
|
noConsistency bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func convertCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func convertCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := convertOptions{
|
opts := convertOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Aliases: []string{"config"},
|
Aliases: []string{"config"},
|
||||||
|
@ -112,13 +112,12 @@ func convertCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||||
|
|
||||||
func runConvert(ctx context.Context, backend api.Service, opts convertOptions, services []string) error {
|
func runConvert(ctx context.Context, backend api.Service, opts convertOptions, services []string) error {
|
||||||
var content []byte
|
var content []byte
|
||||||
project, err := opts.toProject(services,
|
project, err := opts.ToProject(services,
|
||||||
cli.WithInterpolation(!opts.noInterpolate),
|
cli.WithInterpolation(!opts.noInterpolate),
|
||||||
cli.WithResolvedPaths(true),
|
cli.WithResolvedPaths(true),
|
||||||
cli.WithNormalization(!opts.noNormalize),
|
cli.WithNormalization(!opts.noNormalize),
|
||||||
cli.WithConsistency(!opts.noConsistency),
|
cli.WithConsistency(!opts.noConsistency),
|
||||||
cli.WithDiscardEnvFile)
|
cli.WithDiscardEnvFile)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -153,7 +152,7 @@ func runConvert(ctx context.Context, backend api.Service, opts convertOptions, s
|
||||||
}
|
}
|
||||||
|
|
||||||
func runServices(opts convertOptions) error {
|
func runServices(opts convertOptions) error {
|
||||||
project, err := opts.toProject(nil)
|
project, err := opts.ToProject(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -164,7 +163,7 @@ func runServices(opts convertOptions) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runVolumes(opts convertOptions) error {
|
func runVolumes(opts convertOptions) error {
|
||||||
project, err := opts.toProject(nil)
|
project, err := opts.ToProject(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -179,7 +178,7 @@ func runHash(opts convertOptions) error {
|
||||||
if opts.hash != "*" {
|
if opts.hash != "*" {
|
||||||
services = append(services, strings.Split(opts.hash, ",")...)
|
services = append(services, strings.Split(opts.hash, ",")...)
|
||||||
}
|
}
|
||||||
project, err := opts.toProject(services)
|
project, err := opts.ToProject(services)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -195,7 +194,7 @@ func runHash(opts convertOptions) error {
|
||||||
|
|
||||||
func runProfiles(opts convertOptions, services []string) error {
|
func runProfiles(opts convertOptions, services []string) error {
|
||||||
set := map[string]struct{}{}
|
set := map[string]struct{}{}
|
||||||
project, err := opts.toProject(services)
|
project, err := opts.ToProject(services)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -216,7 +215,7 @@ func runProfiles(opts convertOptions, services []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runConfigImages(opts convertOptions, services []string) error {
|
func runConfigImages(opts convertOptions, services []string) error {
|
||||||
project, err := opts.toProject(services)
|
project, err := opts.ToProject(services)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type copyOptions struct {
|
type copyOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
|
|
||||||
source string
|
source string
|
||||||
destination string
|
destination string
|
||||||
|
@ -37,9 +37,9 @@ type copyOptions struct {
|
||||||
copyUIDGID bool
|
copyUIDGID bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func copyCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := copyOptions{
|
opts := copyOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
copyCmd := &cobra.Command{
|
copyCmd := &cobra.Command{
|
||||||
Use: `cp [OPTIONS] SERVICE:SRC_PATH DEST_PATH|-
|
Use: `cp [OPTIONS] SERVICE:SRC_PATH DEST_PATH|-
|
||||||
|
|
|
@ -43,7 +43,7 @@ type createOptions struct {
|
||||||
quietPull bool
|
quietPull bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func createCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func createCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := createOptions{}
|
opts := createOptions{}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "create [OPTIONS] [SERVICE...]",
|
Use: "create [OPTIONS] [SERVICE...]",
|
||||||
|
|
|
@ -31,7 +31,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type downOptions struct {
|
type downOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
removeOrphans bool
|
removeOrphans bool
|
||||||
timeChanged bool
|
timeChanged bool
|
||||||
timeout int
|
timeout int
|
||||||
|
@ -39,9 +39,9 @@ type downOptions struct {
|
||||||
images string
|
images string
|
||||||
}
|
}
|
||||||
|
|
||||||
func downCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func downCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := downOptions{
|
opts := downOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
downCmd := &cobra.Command{
|
downCmd := &cobra.Command{
|
||||||
Use: "down [OPTIONS]",
|
Use: "down [OPTIONS]",
|
||||||
|
|
|
@ -31,10 +31,10 @@ type eventsOpts struct {
|
||||||
json bool
|
json bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func eventsCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func eventsCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := eventsOpts{
|
opts := eventsOpts{
|
||||||
composeOptions: &composeOptions{
|
composeOptions: &composeOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
|
@ -43,10 +43,10 @@ type execOpts struct {
|
||||||
interactive bool
|
interactive bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func execCommand(p *projectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
|
func execCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
|
||||||
opts := execOpts{
|
opts := execOpts{
|
||||||
composeOptions: &composeOptions{
|
composeOptions: &composeOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
runCmd := &cobra.Command{
|
runCmd := &cobra.Command{
|
||||||
|
|
|
@ -34,14 +34,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type imageOptions struct {
|
type imageOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
Quiet bool
|
Quiet bool
|
||||||
Format string
|
Format string
|
||||||
}
|
}
|
||||||
|
|
||||||
func imagesCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func imagesCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := imageOptions{
|
opts := imageOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
imgCmd := &cobra.Command{
|
imgCmd := &cobra.Command{
|
||||||
Use: "images [OPTIONS] [SERVICE...]",
|
Use: "images [OPTIONS] [SERVICE...]",
|
||||||
|
|
|
@ -27,14 +27,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type killOptions struct {
|
type killOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
removeOrphans bool
|
removeOrphans bool
|
||||||
signal string
|
signal string
|
||||||
}
|
}
|
||||||
|
|
||||||
func killCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func killCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := killOptions{
|
opts := killOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "kill [OPTIONS] [SERVICE...]",
|
Use: "kill [OPTIONS] [SERVICE...]",
|
||||||
|
@ -65,5 +65,4 @@ func runKill(ctx context.Context, backend api.Service, opts killOptions, service
|
||||||
Services: services,
|
Services: services,
|
||||||
Signal: opts.signal,
|
Signal: opts.signal,
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type logsOptions struct {
|
type logsOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
composeOptions
|
composeOptions
|
||||||
follow bool
|
follow bool
|
||||||
tail string
|
tail string
|
||||||
|
@ -38,9 +38,9 @@ type logsOptions struct {
|
||||||
timestamps bool
|
timestamps bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func logsCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func logsCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := logsOptions{
|
opts := logsOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
logsCmd := &cobra.Command{
|
logsCmd := &cobra.Command{
|
||||||
Use: "logs [OPTIONS] [SERVICE...]",
|
Use: "logs [OPTIONS] [SERVICE...]",
|
||||||
|
|
|
@ -25,12 +25,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type pauseOptions struct {
|
type pauseOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
func pauseCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func pauseCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := pauseOptions{
|
opts := pauseOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "pause [SERVICE...]",
|
Use: "pause [SERVICE...]",
|
||||||
|
@ -56,12 +56,12 @@ func runPause(ctx context.Context, backend api.Service, opts pauseOptions, servi
|
||||||
}
|
}
|
||||||
|
|
||||||
type unpauseOptions struct {
|
type unpauseOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
func unpauseCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func unpauseCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := unpauseOptions{
|
opts := unpauseOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "unpause [SERVICE...]",
|
Use: "unpause [SERVICE...]",
|
||||||
|
|
|
@ -28,15 +28,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type portOptions struct {
|
type portOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
port uint16
|
port uint16
|
||||||
protocol string
|
protocol string
|
||||||
index int
|
index int
|
||||||
}
|
}
|
||||||
|
|
||||||
func portCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func portCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := portOptions{
|
opts := portOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "port [OPTIONS] SERVICE PRIVATE_PORT",
|
Use: "port [OPTIONS] SERVICE PRIVATE_PORT",
|
||||||
|
|
|
@ -39,7 +39,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type psOptions struct {
|
type psOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
Format string
|
Format string
|
||||||
All bool
|
All bool
|
||||||
Quiet bool
|
Quiet bool
|
||||||
|
@ -67,9 +67,9 @@ func (p *psOptions) parseFilter() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func psCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func psCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := psOptions{
|
opts := psOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
psCmd := &cobra.Command{
|
psCmd := &cobra.Command{
|
||||||
Use: "ps [OPTIONS] [SERVICE...]",
|
Use: "ps [OPTIONS] [SERVICE...]",
|
||||||
|
|
|
@ -71,7 +71,7 @@ func TestPsTable(t *testing.T) {
|
||||||
}, nil
|
}, nil
|
||||||
}).AnyTimes()
|
}).AnyTimes()
|
||||||
|
|
||||||
opts := psOptions{projectOptions: &projectOptions{ProjectName: "test"}}
|
opts := psOptions{ProjectOptions: &ProjectOptions{ProjectName: "test"}}
|
||||||
err = runPs(ctx, backend, nil, opts)
|
err = runPs(ctx, backend, nil, opts)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type pullOptions struct {
|
type pullOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
composeOptions
|
composeOptions
|
||||||
quiet bool
|
quiet bool
|
||||||
parallel bool
|
parallel bool
|
||||||
|
@ -39,9 +39,9 @@ type pullOptions struct {
|
||||||
ignorePullFailures bool
|
ignorePullFailures bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func pullCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func pullCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := pullOptions{
|
opts := pullOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "pull [OPTIONS] [SERVICE...]",
|
Use: "pull [OPTIONS] [SERVICE...]",
|
||||||
|
@ -84,7 +84,7 @@ func withSelectedServicesOnly(project *types.Project, services []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runPull(ctx context.Context, backend api.Service, opts pullOptions, services []string) error {
|
func runPull(ctx context.Context, backend api.Service, opts pullOptions, services []string) error {
|
||||||
project, err := opts.toProject(services)
|
project, err := opts.ToProject(services)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,16 +25,16 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type pushOptions struct {
|
type pushOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
composeOptions
|
composeOptions
|
||||||
IncludeDeps bool
|
IncludeDeps bool
|
||||||
Ignorefailures bool
|
Ignorefailures bool
|
||||||
Quiet bool
|
Quiet bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func pushCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func pushCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := pushOptions{
|
opts := pushOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
pushCmd := &cobra.Command{
|
pushCmd := &cobra.Command{
|
||||||
Use: "push [OPTIONS] [SERVICE...]",
|
Use: "push [OPTIONS] [SERVICE...]",
|
||||||
|
@ -52,7 +52,7 @@ func pushCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runPush(ctx context.Context, backend api.Service, opts pushOptions, services []string) error {
|
func runPush(ctx context.Context, backend api.Service, opts pushOptions, services []string) error {
|
||||||
project, err := opts.toProject(services)
|
project, err := opts.ToProject(services)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,15 +24,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type removeOptions struct {
|
type removeOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
force bool
|
force bool
|
||||||
stop bool
|
stop bool
|
||||||
volumes bool
|
volumes bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func removeCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := removeOptions{
|
opts := removeOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "rm [OPTIONS] [SERVICE...]",
|
Use: "rm [OPTIONS] [SERVICE...]",
|
||||||
|
|
|
@ -26,13 +26,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type restartOptions struct {
|
type restartOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
timeout int
|
timeout int
|
||||||
}
|
}
|
||||||
|
|
||||||
func restartCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func restartCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := restartOptions{
|
opts := restartOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
restartCmd := &cobra.Command{
|
restartCmd := &cobra.Command{
|
||||||
Use: "restart [OPTIONS] [SERVICE...]",
|
Use: "restart [OPTIONS] [SERVICE...]",
|
||||||
|
|
|
@ -108,10 +108,10 @@ func (opts runOptions) apply(project *types.Project) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func runCommand(p *projectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
|
func runCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
|
||||||
opts := runOptions{
|
opts := runOptions{
|
||||||
composeOptions: &composeOptions{
|
composeOptions: &composeOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
createOpts := createOptions{}
|
createOpts := createOptions{}
|
||||||
|
@ -137,7 +137,7 @@ func runCommand(p *projectOptions, dockerCli command.Cli, backend api.Service) *
|
||||||
return nil
|
return nil
|
||||||
}),
|
}),
|
||||||
RunE: Adapt(func(ctx context.Context, args []string) error {
|
RunE: Adapt(func(ctx context.Context, args []string) error {
|
||||||
project, err := p.toProject([]string{opts.Service}, cgo.WithResolvedPaths(true))
|
project, err := p.ToProject([]string{opts.Service}, cgo.WithResolvedPaths(true))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type startOptions struct {
|
type startOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
func startCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func startCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := startOptions{
|
opts := startOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
startCmd := &cobra.Command{
|
startCmd := &cobra.Command{
|
||||||
Use: "start [SERVICE...]",
|
Use: "start [SERVICE...]",
|
||||||
|
|
|
@ -26,14 +26,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type stopOptions struct {
|
type stopOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
timeChanged bool
|
timeChanged bool
|
||||||
timeout int
|
timeout int
|
||||||
}
|
}
|
||||||
|
|
||||||
func stopCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func stopCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := stopOptions{
|
opts := stopOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "stop [OPTIONS] [SERVICE...]",
|
Use: "stop [OPTIONS] [SERVICE...]",
|
||||||
|
|
|
@ -31,12 +31,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type topOptions struct {
|
type topOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
func topCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func topCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
opts := topOptions{
|
opts := topOptions{
|
||||||
projectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
topCmd := &cobra.Command{
|
topCmd := &cobra.Command{
|
||||||
Use: "top [SERVICES...]",
|
Use: "top [SERVICES...]",
|
||||||
|
|
|
@ -34,7 +34,7 @@ import (
|
||||||
|
|
||||||
// composeOptions hold options common to `up` and `run` to run compose project
|
// composeOptions hold options common to `up` and `run` to run compose project
|
||||||
type composeOptions struct {
|
type composeOptions struct {
|
||||||
*projectOptions
|
*ProjectOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
type upOptions struct {
|
type upOptions struct {
|
||||||
|
@ -87,7 +87,7 @@ func (opts upOptions) apply(project *types.Project, services []string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func upCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func upCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
|
||||||
up := upOptions{}
|
up := upOptions{}
|
||||||
create := createOptions{}
|
create := createOptions{}
|
||||||
upCmd := &cobra.Command{
|
upCmd := &cobra.Command{
|
||||||
|
|
Loading…
Reference in New Issue