Documentation
¶
Index ¶
- Constants
- func AddDockerComposeLabel(project *types.Project)
- func CompareProjectImage(old, new *types.Project) (onlyInOld, addedInNew []string)
- func DisableProfiles(p *types.Project, profiles []string)
- func EnableAllService(p *types.Project)
- func FindServicesByLabels(p *types.Project, labels []string) []types.ServiceConfig
- func InitializeDockerCli(clientOpt *flags.ClientOptions, ops ...command.DockerCliOption) (cli *command.DockerCli, err error)
- func PreloadConfigDetails(conf types.ConfigDetails) (types.ConfigDetails, error)
- func Reverse(src, dst *types.Project) error
- type ComposeOutput
- type ComposeOutputLine
- type ComposeProjectLoader
- type ComposeService
- func (s *ComposeService) Create(ctx context.Context, options api.CreateOptions) (ComposeOutput, error)
- func (s *ComposeService) Down(ctx context.Context, options api.DownOptions) (ComposeOutput, error)
- func (s *ComposeService) DryRunMode(ctx context.Context, dryRun bool) (context.Context, error)
- func (s *ComposeService) Kill(ctx context.Context, options api.KillOptions) (ComposeOutput, error)
- func (s *ComposeService) Ps(ctx context.Context, options api.PsOptions) ([]api.ContainerSummary, error)
- func (s *ComposeService) Remove(ctx context.Context, options api.RemoveOptions) (ComposeOutput, error)
- func (s *ComposeService) Restart(ctx context.Context, options api.RestartOptions) (ComposeOutput, error)
- func (s *ComposeService) Start(ctx context.Context, options api.StartOptions) (ComposeOutput, error)
- func (s *ComposeService) Stop(ctx context.Context, options api.StopOptions) (ComposeOutput, error)
- type ComposeServiceLoader
- type Loader
- type LoaderProxy
- func (p *LoaderProxy) ConfigDetails() types.ConfigDetails
- func (p *LoaderProxy) DockerCli() *command.DockerCli
- func (p *LoaderProxy) Load(ctx context.Context) (*types.Project, error)
- func (p *LoaderProxy) LoadComposeService(ctx context.Context, ops ...func(p *types.Project) error) (*ComposeService, error)
- func (p *LoaderProxy) Options() []func(*loader.Options)
- func (p *LoaderProxy) PreloadConfigDetails() error
- func (p *LoaderProxy) ProjectName() string
- func (p *LoaderProxy) UpdateConfigDetails(configDetails types.ConfigDetails)
- func (p *LoaderProxy) UpdateDockerCli(dockerCli *command.DockerCli)
- func (p *LoaderProxy) UpdateOptions(options []func(*loader.Options))
- func (p *LoaderProxy) UpdateProjectName(projectName string)
- type ResourceType
- type StateType
Constants ¶
const (
DryRunModePrefix = "DRY-RUN MODE - "
)
Variables ¶
This section is empty.
Functions ¶
func AddDockerComposeLabel ¶
AddDockerComposeLabel changes service.CustomLabels so that is can be found by docker compose v2.
func CompareProjectImage ¶
CompareProjectImage compares 2 projects and return image names which only exists in old, new respectively.
If any of image is not tagged, it will resolve by adding `:latest`.
func DisableProfiles ¶
DisableProfiles disables service which does match selected profiles. Unlike (*types.Project).ApplyProfiles, DisableProfiles ignores already disabled services, or services which has no profile set.
func EnableAllService ¶
EnableAllService sets p.Profile every possible profile in p.Services and p.DisabledServices, and call p.EnableServices with all service names.
func FindServicesByLabels ¶
func FindServicesByLabels(p *types.Project, labels []string) []types.ServiceConfig
FindServicesByLabels selects services in p by given labels.
func InitializeDockerCli ¶
func InitializeDockerCli( clientOpt *flags.ClientOptions, ops ...command.DockerCliOption, ) (cli *command.DockerCli, err error)
InitializeDockerCli initializes DockerCli.
If clientOpt is nil, cli will be initialized with &flags.ClientOptions{Context: "default"}.
ops will be applied twice, therefore all ops must be idempotent and/or must be aware of it. This is to encounter the case where passing malformed *flag.ClientOptions may cause it to exit by calling os.Exit(1). To prevent it from silently dying, this function sets err output stream to os.Stderr if it is not set. After initialization, it re-applies ops to ensure err output stream is what the caller wants to be.
func PreloadConfigDetails ¶
func PreloadConfigDetails(conf types.ConfigDetails) (types.ConfigDetails, error)
PreloadConfigDetails loads content and parse content if each corresponding field is not present in given conf.
Types ¶
type ComposeOutput ¶
type ComposeOutput struct { Resource map[string]ComposeOutputLine Out, Err string }
func (*ComposeOutput) ParseOutput ¶
type ComposeOutputLine ¶
type ComposeOutputLine struct { Name string Num int ResourceType ResourceType StateType StateType Desc string DryRunMode bool }
func DecodeComposeOutputLine ¶
type ComposeProjectLoader ¶
type ComposeService ¶
type ComposeService struct {
// contains filtered or unexported fields
}
func NewComposeService ¶
func NewComposeService( projectName string, project *types.Project, dockerCli command.Cli, ) *ComposeService
NewComposeService returns a new wrapped compose service proxy. NewComposeService is not goroutine safe. It mutates given project.
func (*ComposeService) Create ¶
func (s *ComposeService) Create(ctx context.Context, options api.CreateOptions) (ComposeOutput, error)
Create executes the equivalent to a `compose create`
func (*ComposeService) Down ¶
func (s *ComposeService) Down(ctx context.Context, options api.DownOptions) (ComposeOutput, error)
Down executes the equivalent to a `compose down`
func (*ComposeService) DryRunMode ¶
DryRunMode switches c to dry run mode if dryRun is true. Implementations might not change back to normal mode even if dryRun is false. User must call this only once and only when the user whishes to use dry run client.
func (*ComposeService) Kill ¶
func (s *ComposeService) Kill(ctx context.Context, options api.KillOptions) (ComposeOutput, error)
Kill executes the equivalent to a `compose kill`
func (*ComposeService) Ps ¶
func (s *ComposeService) Ps(ctx context.Context, options api.PsOptions) ([]api.ContainerSummary, error)
Ps executes the equivalent to a `compose ps`
func (*ComposeService) Remove ¶
func (s *ComposeService) Remove(ctx context.Context, options api.RemoveOptions) (ComposeOutput, error)
Remove executes the equivalent to a `compose rm`
func (*ComposeService) Restart ¶
func (s *ComposeService) Restart(ctx context.Context, options api.RestartOptions) (ComposeOutput, error)
Restart restarts containers
func (*ComposeService) Start ¶
func (s *ComposeService) Start(ctx context.Context, options api.StartOptions) (ComposeOutput, error)
Start executes the equivalent to a `compose start`
func (*ComposeService) Stop ¶
func (s *ComposeService) Stop(ctx context.Context, options api.StopOptions) (ComposeOutput, error)
Stop executes the equivalent to a `compose stop`
type ComposeServiceLoader ¶
type Loader ¶
type Loader struct { DockerCli *command.DockerCli ProjectName string ConfigDetails types.ConfigDetails Options []func(*loader.Options) }
func NewLoader ¶
func NewLoader( projectName string, configDetails types.ConfigDetails, options []func(*loader.Options), clientOpt *flags.ClientOptions, ops ...command.DockerCliOption, ) (*Loader, error)
func (*Loader) LoadComposeService ¶
type LoaderProxy ¶
type LoaderProxy struct {
// contains filtered or unexported fields
}
func NewLoaderProxy ¶
func NewLoaderProxy( projectName string, configDetails types.ConfigDetails, options []func(*loader.Options), clientOpt *flags.ClientOptions, ops ...command.DockerCliOption, ) (*LoaderProxy, error)
func (*LoaderProxy) ConfigDetails ¶
func (p *LoaderProxy) ConfigDetails() types.ConfigDetails
func (*LoaderProxy) DockerCli ¶
func (p *LoaderProxy) DockerCli() *command.DockerCli
func (*LoaderProxy) LoadComposeService ¶
func (p *LoaderProxy) LoadComposeService(ctx context.Context, ops ...func(p *types.Project) error) (*ComposeService, error)
func (*LoaderProxy) Options ¶
func (p *LoaderProxy) Options() []func(*loader.Options)
func (*LoaderProxy) PreloadConfigDetails ¶
func (p *LoaderProxy) PreloadConfigDetails() error
func (*LoaderProxy) ProjectName ¶
func (p *LoaderProxy) ProjectName() string
func (*LoaderProxy) UpdateConfigDetails ¶
func (p *LoaderProxy) UpdateConfigDetails(configDetails types.ConfigDetails)
func (*LoaderProxy) UpdateDockerCli ¶
func (p *LoaderProxy) UpdateDockerCli(dockerCli *command.DockerCli)
func (*LoaderProxy) UpdateOptions ¶
func (p *LoaderProxy) UpdateOptions(options []func(*loader.Options))
func (*LoaderProxy) UpdateProjectName ¶
func (p *LoaderProxy) UpdateProjectName(projectName string)
type ResourceType ¶
type ResourceType string
const ( Container ResourceType = "Container" Volume ResourceType = "Volume" Network ResourceType = "Network" )
type StateType ¶
type StateType string
Copied from https://github.com/docker/compose/blob/19bbb12fac83e19f3ef888722cbb32825b4088e6/pkg/progress/event.go
const ( Error StateType = "Error" Creating StateType = "Creating" Starting StateType = "Starting" Started StateType = "Started" Waiting StateType = "Waiting" Healthy StateType = "Healthy" Exited StateType = "Exited" Restarting StateType = "Restarting" Restarted StateType = "Restarted" Running StateType = "Running" Created StateType = "Created" Stopping StateType = "Stopping" Stopped StateType = "Stopped" Killing StateType = "Killing" Killed StateType = "Killed" Removing StateType = "Removing" Removed StateType = "Removed" Skipped StateType = "Skipped" // depends_on is set, required is false and dependency service is not running nor present. Recreate StateType = "Recreate" Recreated StateType = "Recreated" )