mirror of
https://github.com/docker/compose.git
synced 2026-08-31 23:03:55 +00:00
Added tests to viz subcommand
Signed-off-by: Benjamín Guzmán <bg@benjaminguzman.dev>
This commit is contained in:
parent
3751c3074b
commit
7840a92c40
8 changed files with 478 additions and 108 deletions
|
|
@ -82,6 +82,19 @@ type Service interface {
|
|||
DryRunMode(ctx context.Context, dryRun bool) (context.Context, error)
|
||||
// Watch services' development context and sync/notify/rebuild/restart on changes
|
||||
Watch(ctx context.Context, project *types.Project, services []string, options WatchOptions) error
|
||||
// Viz generates a graphviz graph of the project services
|
||||
Viz(ctx context.Context, project *types.Project, options VizOptions) (string, error)
|
||||
}
|
||||
|
||||
type VizOptions struct {
|
||||
// IncludeNetworks if true, network names a container is attached to should appear in the graph node
|
||||
IncludeNetworks bool
|
||||
// IncludePorts if true, ports a container exposes should appear in the graph node
|
||||
IncludePorts bool
|
||||
// IncludeImageName if true, name of the image used to create a container should appear in the graph node
|
||||
IncludeImageName bool
|
||||
// Indentation string to be used to indent graphviz code, e.g. "\t", " "
|
||||
Indentation string
|
||||
}
|
||||
|
||||
// WatchOptions group options of the Watch API
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ type ServiceProxy struct {
|
|||
WatchFn func(ctx context.Context, project *types.Project, services []string, options WatchOptions) error
|
||||
MaxConcurrencyFn func(parallel int)
|
||||
DryRunModeFn func(ctx context.Context, dryRun bool) (context.Context, error)
|
||||
VizFn func(ctx context.Context, project *types.Project, options VizOptions) (string, error)
|
||||
interceptors []Interceptor
|
||||
}
|
||||
|
||||
|
|
@ -93,6 +94,7 @@ func (s *ServiceProxy) WithService(service Service) *ServiceProxy {
|
|||
s.WatchFn = service.Watch
|
||||
s.MaxConcurrencyFn = service.MaxConcurrency
|
||||
s.DryRunModeFn = service.DryRunMode
|
||||
s.VizFn = service.Viz
|
||||
return s
|
||||
}
|
||||
|
||||
|
|
@ -323,6 +325,14 @@ func (s *ServiceProxy) Watch(ctx context.Context, project *types.Project, servic
|
|||
return s.WatchFn(ctx, project, services, options)
|
||||
}
|
||||
|
||||
// Viz implements Viz interface
|
||||
func (s *ServiceProxy) Viz(ctx context.Context, project *types.Project, options VizOptions) (string, error) {
|
||||
if s.VizFn == nil {
|
||||
return "", ErrNotImplemented
|
||||
}
|
||||
return s.VizFn(ctx, project, options)
|
||||
}
|
||||
|
||||
func (s *ServiceProxy) MaxConcurrency(i int) {
|
||||
s.MaxConcurrencyFn(i)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue