Merge pull request #1415 from ulyssessouza/add-restart

Add restart command
This commit is contained in:
Guillaume Tardif 2021-03-19 15:04:57 +01:00 committed by GitHub
commit e0344ea7b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 281 additions and 0 deletions

View file

@ -48,6 +48,10 @@ func (c *composeService) Start(ctx context.Context, project *types.Project, opti
return errdefs.ErrNotImplemented
}
func (c *composeService) Restart(ctx context.Context, project *types.Project, options compose.RestartOptions) error {
return errdefs.ErrNotImplemented
}
func (c *composeService) Stop(ctx context.Context, project *types.Project, options compose.StopOptions) error {
return errdefs.ErrNotImplemented
}

View file

@ -38,6 +38,8 @@ type Service interface {
Create(ctx context.Context, project *types.Project, opts CreateOptions) error
// Start executes the equivalent to a `compose start`
Start(ctx context.Context, project *types.Project, options StartOptions) error
// Restart restarts containers
Restart(ctx context.Context, project *types.Project, options RestartOptions) error
// Stop executes the equivalent to a `compose stop`
Stop(ctx context.Context, project *types.Project, options StopOptions) error
// Up executes the equivalent to a `compose up`
@ -106,6 +108,12 @@ type StartOptions struct {
Services []string
}
// RestartOptions group options of the Restart API
type RestartOptions struct {
// Timeout override container restart timeout
Timeout *time.Duration
}
// StopOptions group options of the Stop API
type StopOptions struct {
// Timeout override container stop timeout

View file

@ -68,6 +68,16 @@ func StartedEvent(ID string) Event {
return NewEvent(ID, Done, "Started")
}
// RestartingEvent creates a new Restarting in progress Event
func RestartingEvent(ID string) Event {
return NewEvent(ID, Working, "Restarting")
}
// RestartedEvent creates a new Restarted in progress Event
func RestartedEvent(ID string) Event {
return NewEvent(ID, Done, "Restarted")
}
// RunningEvent creates a new Running in progress Event
func RunningEvent(ID string) Event {
return NewEvent(ID, Done, "Running")