mirror of https://github.com/docker/compose.git
format code with gofumpt
Format the code with gofumpt to prevent my IDE from reformatting every time I open a file. gofumpt provides a superset of gofmt, so should not impact users that are not using gofumpt. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
c01c9c29f4
commit
446e00520c
|
@ -60,5 +60,4 @@ func TestGetFlags(t *testing.T) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -348,7 +348,6 @@ func runHash(ctx context.Context, dockerCli command.Cli, opts configOptions) err
|
||||||
}
|
}
|
||||||
|
|
||||||
hash, err := compose.ServiceHash(s)
|
hash, err := compose.ServiceHash(s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,9 @@ func applyScaleOpts(project *types.Project, opts []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (opts createOptions) isPullPolicyValid() bool {
|
func (opts createOptions) isPullPolicyValid() bool {
|
||||||
pullPolicies := []string{types.PullPolicyAlways, types.PullPolicyNever, types.PullPolicyBuild,
|
pullPolicies := []string{
|
||||||
types.PullPolicyMissing, types.PullPolicyIfNotPresent}
|
types.PullPolicyAlways, types.PullPolicyNever, types.PullPolicyBuild,
|
||||||
|
types.PullPolicyMissing, types.PullPolicyIfNotPresent,
|
||||||
|
}
|
||||||
return slices.Contains(pullPolicies, opts.Pull)
|
return slices.Contains(pullPolicies, opts.Pull)
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,6 @@ func parseServicesReplicasArgs(args []string) (map[string]int, error) {
|
||||||
return nil, fmt.Errorf("invalid scale specifier: %s", arg)
|
return nil, fmt.Errorf("invalid scale specifier: %s", arg)
|
||||||
}
|
}
|
||||||
intValue, err := strconv.Atoi(val)
|
intValue, err := strconv.Atoi(val)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("invalid scale specifier: can't parse replica value as int: %v", arg)
|
return nil, fmt.Errorf("invalid scale specifier: can't parse replica value as int: %v", arg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,5 +47,4 @@ func TestApplyScaleOpt(t *testing.T) {
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Equal(t, *bar.Scale, 3)
|
assert.Equal(t, *bar.Scale, 3)
|
||||||
assert.Equal(t, *bar.Deploy.Replicas, 3)
|
assert.Equal(t, *bar.Deploy.Replicas, 3)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,42 +27,49 @@ var disableAnsi bool
|
||||||
func ansi(code string) string {
|
func ansi(code string) string {
|
||||||
return fmt.Sprintf("\033%s", code)
|
return fmt.Sprintf("\033%s", code)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SaveCursor() {
|
func SaveCursor() {
|
||||||
if disableAnsi {
|
if disableAnsi {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Print(ansi("7"))
|
fmt.Print(ansi("7"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func RestoreCursor() {
|
func RestoreCursor() {
|
||||||
if disableAnsi {
|
if disableAnsi {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Print(ansi("8"))
|
fmt.Print(ansi("8"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func HideCursor() {
|
func HideCursor() {
|
||||||
if disableAnsi {
|
if disableAnsi {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Print(ansi("[?25l"))
|
fmt.Print(ansi("[?25l"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func ShowCursor() {
|
func ShowCursor() {
|
||||||
if disableAnsi {
|
if disableAnsi {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Print(ansi("[?25h"))
|
fmt.Print(ansi("[?25h"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func MoveCursor(y, x int) {
|
func MoveCursor(y, x int) {
|
||||||
if disableAnsi {
|
if disableAnsi {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Print(ansi(fmt.Sprintf("[%d;%dH", y, x)))
|
fmt.Print(ansi(fmt.Sprintf("[%d;%dH", y, x)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func MoveCursorX(pos int) {
|
func MoveCursorX(pos int) {
|
||||||
if disableAnsi {
|
if disableAnsi {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Print(ansi(fmt.Sprintf("[%dG", pos)))
|
fmt.Print(ansi(fmt.Sprintf("[%dG", pos)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func ClearLine() {
|
func ClearLine() {
|
||||||
if disableAnsi {
|
if disableAnsi {
|
||||||
return
|
return
|
||||||
|
@ -70,6 +77,7 @@ func ClearLine() {
|
||||||
// Does not move cursor from its current position
|
// Does not move cursor from its current position
|
||||||
fmt.Print(ansi("[2K"))
|
fmt.Print(ansi("[2K"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func MoveCursorUp(lines int) {
|
func MoveCursorUp(lines int) {
|
||||||
if disableAnsi {
|
if disableAnsi {
|
||||||
return
|
return
|
||||||
|
@ -77,6 +85,7 @@ func MoveCursorUp(lines int) {
|
||||||
// Does not add new lines
|
// Does not add new lines
|
||||||
fmt.Print(ansi(fmt.Sprintf("[%dA", lines)))
|
fmt.Print(ansi(fmt.Sprintf("[%dA", lines)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func MoveCursorDown(lines int) {
|
func MoveCursorDown(lines int) {
|
||||||
if disableAnsi {
|
if disableAnsi {
|
||||||
return
|
return
|
||||||
|
@ -84,10 +93,12 @@ func MoveCursorDown(lines int) {
|
||||||
// Does not add new lines
|
// Does not add new lines
|
||||||
fmt.Print(ansi(fmt.Sprintf("[%dB", lines)))
|
fmt.Print(ansi(fmt.Sprintf("[%dB", lines)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLine() {
|
func NewLine() {
|
||||||
// Like \n
|
// Like \n
|
||||||
fmt.Print("\012")
|
fmt.Print("\012")
|
||||||
}
|
}
|
||||||
|
|
||||||
func lenAnsi(s string) int {
|
func lenAnsi(s string) int {
|
||||||
// len has into consideration ansi codes, if we want
|
// len has into consideration ansi codes, if we want
|
||||||
// the len of the actual len(string) we need to strip
|
// the len of the actual len(string) we need to strip
|
||||||
|
|
|
@ -104,10 +104,12 @@ func makeColorFunc(code string) colorFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var nextColor = rainbowColor
|
var (
|
||||||
var rainbow []colorFunc
|
nextColor = rainbowColor
|
||||||
var currentIndex = 0
|
rainbow []colorFunc
|
||||||
var mutex sync.Mutex
|
currentIndex = 0
|
||||||
|
mutex sync.Mutex
|
||||||
|
)
|
||||||
|
|
||||||
func rainbowColor() colorFunc {
|
func rainbowColor() colorFunc {
|
||||||
mutex.Lock()
|
mutex.Lock()
|
||||||
|
|
|
@ -110,8 +110,10 @@ type LogKeyboard struct {
|
||||||
signalChannel chan<- os.Signal
|
signalChannel chan<- os.Signal
|
||||||
}
|
}
|
||||||
|
|
||||||
var KeyboardManager *LogKeyboard
|
var (
|
||||||
var eg multierror.Group
|
KeyboardManager *LogKeyboard
|
||||||
|
eg multierror.Group
|
||||||
|
)
|
||||||
|
|
||||||
func NewKeyboardManager(ctx context.Context, isDockerDesktopActive, isWatchConfigured bool,
|
func NewKeyboardManager(ctx context.Context, isDockerDesktopActive, isWatchConfigured bool,
|
||||||
sc chan<- os.Signal,
|
sc chan<- os.Signal,
|
||||||
|
@ -206,7 +208,7 @@ func (lk *LogKeyboard) navigationMenu() string {
|
||||||
if openDDInfo != "" || openDDUI != "" {
|
if openDDInfo != "" || openDDUI != "" {
|
||||||
watchInfo = navColor(" ")
|
watchInfo = navColor(" ")
|
||||||
}
|
}
|
||||||
var isEnabled = " Enable"
|
isEnabled := " Enable"
|
||||||
if lk.Watch.Watching {
|
if lk.Watch.Watching {
|
||||||
isEnabled = " Disable"
|
isEnabled = " Disable"
|
||||||
}
|
}
|
||||||
|
@ -260,6 +262,7 @@ func (lk *LogKeyboard) openDDComposeUI(ctx context.Context, project *types.Proje
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lk *LogKeyboard) openDDWatchDocs(ctx context.Context, project *types.Project) {
|
func (lk *LogKeyboard) openDDWatchDocs(ctx context.Context, project *types.Project) {
|
||||||
eg.Go(tracing.EventWrapFuncForErrGroup(ctx, "menu/gui/watch", tracing.SpanOptions{},
|
eg.Go(tracing.EventWrapFuncForErrGroup(ctx, "menu/gui/watch", tracing.SpanOptions{},
|
||||||
func(ctx context.Context) error {
|
func(ctx context.Context) error {
|
||||||
|
|
|
@ -16,7 +16,5 @@
|
||||||
|
|
||||||
package internal
|
package internal
|
||||||
|
|
||||||
var (
|
// Version is the version of the CLI injected in compilation time
|
||||||
// Version is the version of the CLI injected in compilation time
|
var Version = "dev"
|
||||||
Version = "dev"
|
|
||||||
)
|
|
||||||
|
|
|
@ -431,7 +431,6 @@ func (e Event) String() string {
|
||||||
attr = append(attr, fmt.Sprintf("%s=%s", k, v))
|
attr = append(attr, fmt.Sprintf("%s=%s", k, v))
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s container %s %s (%s)\n", t, e.Status, e.Container, strings.Join(attr, ", "))
|
return fmt.Sprintf("%s container %s %s (%s)\n", t, e.Status, e.Container, strings.Join(attr, ", "))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListOptions group options of the ls API
|
// ListOptions group options of the ls API
|
||||||
|
|
|
@ -101,7 +101,8 @@ func (d *DryRunClient) ContainerAttach(ctx context.Context, container string, op
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DryRunClient) ContainerCreate(ctx context.Context, config *containerType.Config, hostConfig *containerType.HostConfig,
|
func (d *DryRunClient) ContainerCreate(ctx context.Context, config *containerType.Config, hostConfig *containerType.HostConfig,
|
||||||
networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (containerType.CreateResponse, error) {
|
networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string,
|
||||||
|
) (containerType.CreateResponse, error) {
|
||||||
d.containers = append(d.containers, moby.Container{
|
d.containers = append(d.containers, moby.Container{
|
||||||
ID: containerName,
|
ID: containerName,
|
||||||
Names: []string{containerName},
|
Names: []string{containerName},
|
||||||
|
@ -229,7 +230,6 @@ func (d *DryRunClient) ImageInspectWithRaw(ctx context.Context, imageName string
|
||||||
default:
|
default:
|
||||||
return d.apiClient.ImageInspectWithRaw(ctx, imageName)
|
return d.apiClient.ImageInspectWithRaw(ctx, imageName)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DryRunClient) ImagePull(ctx context.Context, ref string, options image.PullOptions) (io.ReadCloser, error) {
|
func (d *DryRunClient) ImagePull(ctx context.Context, ref string, options image.PullOptions) (io.ReadCloser, error) {
|
||||||
|
|
|
@ -134,7 +134,6 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
|
||||||
fmt.Sprintf("building with %q instance using %s driver", b.Name, b.Driver),
|
fmt.Sprintf("building with %q instance using %s driver", b.Name, b.Driver),
|
||||||
fmt.Sprintf("%s:%s", b.Driver, b.Name),
|
fmt.Sprintf("%s:%s", b.Driver, b.Name),
|
||||||
))
|
))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,7 +187,6 @@ func (s *composeService) projectFromName(containers Containers, projectName stri
|
||||||
Image: c.Image,
|
Image: c.Image,
|
||||||
Labels: c.Labels,
|
Labels: c.Labels,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
service.Scale = increment(service.Scale)
|
service.Scale = increment(service.Scale)
|
||||||
set[serviceLabel] = service
|
set[serviceLabel] = service
|
||||||
|
@ -321,7 +320,6 @@ func (s *composeService) RuntimeVersion(ctx context.Context) (string, error) {
|
||||||
runtimeVersion.val = version.APIVersion
|
runtimeVersion.val = version.APIVersion
|
||||||
})
|
})
|
||||||
return runtimeVersion.val, runtimeVersion.err
|
return runtimeVersion.val, runtimeVersion.err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *composeService) isDesktopIntegrationActive() bool {
|
func (s *composeService) isDesktopIntegrationActive() bool {
|
||||||
|
|
|
@ -581,11 +581,11 @@ func nextContainerNumber(containers []moby.Container) int {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return maxNumber + 1
|
return maxNumber + 1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *composeService) createContainer(ctx context.Context, project *types.Project, service types.ServiceConfig,
|
func (s *composeService) createContainer(ctx context.Context, project *types.Project, service types.ServiceConfig,
|
||||||
name string, number int, opts createOptions) (container moby.Container, err error) {
|
name string, number int, opts createOptions,
|
||||||
|
) (container moby.Container, err error) {
|
||||||
w := progress.ContextWriter(ctx)
|
w := progress.ContextWriter(ctx)
|
||||||
eventName := "Container " + name
|
eventName := "Container " + name
|
||||||
w.Event(progress.CreatingEvent(eventName))
|
w.Event(progress.CreatingEvent(eventName))
|
||||||
|
@ -598,7 +598,8 @@ func (s *composeService) createContainer(ctx context.Context, project *types.Pro
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *composeService) recreateContainer(ctx context.Context, project *types.Project, service types.ServiceConfig,
|
func (s *composeService) recreateContainer(ctx context.Context, project *types.Project, service types.ServiceConfig,
|
||||||
replaced moby.Container, inherit bool, timeout *time.Duration) (moby.Container, error) {
|
replaced moby.Container, inherit bool, timeout *time.Duration,
|
||||||
|
) (moby.Container, error) {
|
||||||
var created moby.Container
|
var created moby.Container
|
||||||
w := progress.ContextWriter(ctx)
|
w := progress.ContextWriter(ctx)
|
||||||
w.Event(progress.NewEvent(getContainerProgressName(replaced), progress.Working, "Recreate"))
|
w.Event(progress.NewEvent(getContainerProgressName(replaced), progress.Working, "Recreate"))
|
||||||
|
@ -667,7 +668,6 @@ func (s *composeService) createMobyContainer(ctx context.Context,
|
||||||
) (moby.Container, error) {
|
) (moby.Container, error) {
|
||||||
var created moby.Container
|
var created moby.Container
|
||||||
cfgs, err := s.getCreateConfigs(ctx, project, service, number, inherit, opts)
|
cfgs, err := s.getCreateConfigs(ctx, project, service, number, inherit, opts)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return created, err
|
return created, err
|
||||||
}
|
}
|
||||||
|
@ -850,7 +850,8 @@ func (s *composeService) isServiceCompleted(ctx context.Context, containers Cont
|
||||||
func (s *composeService) startService(ctx context.Context,
|
func (s *composeService) startService(ctx context.Context,
|
||||||
project *types.Project, service types.ServiceConfig,
|
project *types.Project, service types.ServiceConfig,
|
||||||
containers Containers, listener api.ContainerEventListener,
|
containers Containers, listener api.ContainerEventListener,
|
||||||
timeout time.Duration) error {
|
timeout time.Duration,
|
||||||
|
) error {
|
||||||
if service.Deploy != nil && service.Deploy.Replicas != nil && *service.Deploy.Replicas == 0 {
|
if service.Deploy != nil && service.Deploy.Replicas != nil && *service.Deploy.Replicas == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -432,5 +432,4 @@ func TestCreateMobyContainer(t *testing.T) {
|
||||||
}, progress.ContextWriter(context.TODO()))
|
}, progress.ContextWriter(context.TODO()))
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,6 @@ func (s *composeService) listContainersTargetedForCopy(ctx context.Context, proj
|
||||||
}
|
}
|
||||||
if direction == fromService {
|
if direction == fromService {
|
||||||
return containers[:1], err
|
return containers[:1], err
|
||||||
|
|
||||||
}
|
}
|
||||||
return containers, err
|
return containers, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,7 +205,6 @@ func (s *composeService) ensureProjectVolumes(ctx context.Context, project *type
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
progress.ContextWriter(ctx).TailMsgf("Failed to prepare Synchronized file shares: %v", err)
|
progress.ContextWriter(ctx).TailMsgf("Failed to prepare Synchronized file shares: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -259,7 +258,7 @@ func (s *composeService) getCreateConfigs(ctx context.Context,
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return createConfigs{}, err
|
return createConfigs{}, err
|
||||||
}
|
}
|
||||||
var containerConfig = container.Config{
|
containerConfig := container.Config{
|
||||||
Hostname: service.Hostname,
|
Hostname: service.Hostname,
|
||||||
Domainname: service.DomainName,
|
Domainname: service.DomainName,
|
||||||
User: service.User,
|
User: service.User,
|
||||||
|
@ -892,7 +891,7 @@ func requireMountAPI(bind *types.ServiceVolumeBind) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildContainerMountOptions(p types.Project, s types.ServiceConfig, img moby.ImageInspect, inherit *moby.Container) ([]mount.Mount, error) {
|
func buildContainerMountOptions(p types.Project, s types.ServiceConfig, img moby.ImageInspect, inherit *moby.Container) ([]mount.Mount, error) {
|
||||||
var mounts = map[string]mount.Mount{}
|
mounts := map[string]mount.Mount{}
|
||||||
if inherit != nil {
|
if inherit != nil {
|
||||||
for _, m := range inherit.Mounts {
|
for _, m := range inherit.Mounts {
|
||||||
if m.Type == "tmpfs" {
|
if m.Type == "tmpfs" {
|
||||||
|
@ -978,7 +977,7 @@ func fillBindMounts(p types.Project, s types.ServiceConfig, m map[string]mount.M
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildContainerConfigMounts(p types.Project, s types.ServiceConfig) ([]mount.Mount, error) {
|
func buildContainerConfigMounts(p types.Project, s types.ServiceConfig) ([]mount.Mount, error) {
|
||||||
var mounts = map[string]mount.Mount{}
|
mounts := map[string]mount.Mount{}
|
||||||
|
|
||||||
configsBaseDir := "/"
|
configsBaseDir := "/"
|
||||||
for _, config := range s.Configs {
|
for _, config := range s.Configs {
|
||||||
|
@ -1028,7 +1027,7 @@ func buildContainerConfigMounts(p types.Project, s types.ServiceConfig) ([]mount
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildContainerSecretMounts(p types.Project, s types.ServiceConfig) ([]mount.Mount, error) {
|
func buildContainerSecretMounts(p types.Project, s types.ServiceConfig) ([]mount.Mount, error) {
|
||||||
var mounts = map[string]mount.Mount{}
|
mounts := map[string]mount.Mount{}
|
||||||
|
|
||||||
secretsDir := "/run/secrets/"
|
secretsDir := "/run/secrets/"
|
||||||
for _, secret := range s.Secrets {
|
for _, secret := range s.Secrets {
|
||||||
|
@ -1392,7 +1391,6 @@ func (s *composeService) resolveExternalNetwork(ctx context.Context, n *types.Ne
|
||||||
networks, err := s.apiClient().NetworkList(ctx, network.ListOptions{
|
networks, err := s.apiClient().NetworkList(ctx, network.ListOptions{
|
||||||
Filters: filters.NewArgs(filters.Arg("name", n.Name)),
|
Filters: filters.NewArgs(filters.Arg("name", n.Name)),
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -1467,7 +1465,7 @@ func (s *composeService) ensureVolume(ctx context.Context, name string, volume t
|
||||||
}
|
}
|
||||||
actual, ok := inspected.Labels[api.ConfigHashLabel]
|
actual, ok := inspected.Labels[api.ConfigHashLabel]
|
||||||
if ok && actual != expected {
|
if ok && actual != expected {
|
||||||
var confirm = assumeYes
|
confirm := assumeYes
|
||||||
if !assumeYes {
|
if !assumeYes {
|
||||||
msg := fmt.Sprintf("Volume %q exists but doesn't match configuration in compose file. Recreate (data will be lost)?", volume.Name)
|
msg := fmt.Sprintf("Volume %q exists but doesn't match configuration in compose file. Recreate (data will be lost)?", volume.Name)
|
||||||
confirm, err = prompt.NewPrompt(s.stdin(), s.stdout()).Confirm(msg, false)
|
confirm, err = prompt.NewPrompt(s.stdin(), s.stdout()).Confirm(msg, false)
|
||||||
|
|
|
@ -438,7 +438,6 @@ func (g *Graph) HasCycles() (bool, error) {
|
||||||
if !utils.StringContains(discovered, vertex.Key) && !utils.StringContains(finished, vertex.Key) {
|
if !utils.StringContains(discovered, vertex.Key) && !utils.StringContains(finished, vertex.Key) {
|
||||||
var err error
|
var err error
|
||||||
discovered, finished, err = g.visit(vertex.Key, path, discovered, finished)
|
discovered, finished, err = g.visit(vertex.Key, path, discovered, finished)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return true, err
|
return true, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,8 @@ func TestDownRemoveOrphans(t *testing.T) {
|
||||||
{
|
{
|
||||||
Name: "myProject_default",
|
Name: "myProject_default",
|
||||||
Labels: map[string]string{compose.NetworkLabel: "default"},
|
Labels: map[string]string{compose.NetworkLabel: "default"},
|
||||||
}}, nil)
|
},
|
||||||
|
}, nil)
|
||||||
|
|
||||||
stopOptions := containerType.StopOptions{}
|
stopOptions := containerType.StopOptions{}
|
||||||
api.EXPECT().ContainerStop(gomock.Any(), "123", stopOptions).Return(nil)
|
api.EXPECT().ContainerStop(gomock.Any(), "123", stopOptions).Return(nil)
|
||||||
|
|
|
@ -21,10 +21,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
// isCaseInsensitiveEnvVars is true on platforms where environment variable names are treated case-insensitively.
|
||||||
// isCaseInsensitiveEnvVars is true on platforms where environment variable names are treated case-insensitively.
|
var isCaseInsensitiveEnvVars = (runtime.GOOS == "windows")
|
||||||
isCaseInsensitiveEnvVars = (runtime.GOOS == "windows")
|
|
||||||
)
|
|
||||||
|
|
||||||
// envResolver returns resolver for environment variables suitable for the current platform.
|
// envResolver returns resolver for environment variables suitable for the current platform.
|
||||||
// Expected to be used with `MappingWithEquals.Resolve`.
|
// Expected to be used with `MappingWithEquals.Resolve`.
|
||||||
|
|
|
@ -92,7 +92,6 @@ func (s *composeService) createProjectFromContainers(containers []moby.Container
|
||||||
Image: c.Image,
|
Image: c.Image,
|
||||||
Labels: c.Labels,
|
Labels: c.Labels,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
service.Scale = increment(service.Scale)
|
service.Scale = increment(service.Scale)
|
||||||
|
|
||||||
|
@ -172,7 +171,8 @@ func (s *composeService) toComposeHealthCheck(healthConfig *containerType.Health
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *composeService) toComposeVolumes(volumes []moby.MountPoint) (map[string]types.VolumeConfig,
|
func (s *composeService) toComposeVolumes(volumes []moby.MountPoint) (map[string]types.VolumeConfig,
|
||||||
[]types.ServiceVolumeConfig, map[string]types.SecretConfig, []types.ServiceSecretConfig) {
|
[]types.ServiceVolumeConfig, map[string]types.SecretConfig, []types.ServiceSecretConfig,
|
||||||
|
) {
|
||||||
volumeConfigs := make(map[string]types.VolumeConfig)
|
volumeConfigs := make(map[string]types.VolumeConfig)
|
||||||
secretConfigs := make(map[string]types.SecretConfig)
|
secretConfigs := make(map[string]types.SecretConfig)
|
||||||
var serviceVolumeConfigs []types.ServiceVolumeConfig
|
var serviceVolumeConfigs []types.ServiceVolumeConfig
|
||||||
|
@ -227,7 +227,6 @@ func (s *composeService) toComposeNetwork(networks map[string]*network.EndpointS
|
||||||
networkConfigs[name] = types.NetworkConfig{
|
networkConfigs[name] = types.NetworkConfig{
|
||||||
Internal: inspect.Internal,
|
Internal: inspect.Internal,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
serviceNetworkConfigs[name] = &types.ServiceNetworkConfig{
|
serviceNetworkConfigs[name] = &types.ServiceNetworkConfig{
|
||||||
Aliases: net.Aliases,
|
Aliases: net.Aliases,
|
||||||
|
|
|
@ -48,7 +48,6 @@ func (s *composeService) Images(ctx context.Context, projectName string, options
|
||||||
for _, c := range allContainers {
|
for _, c := range allContainers {
|
||||||
if utils.StringContains(options.Services, c.Labels[api.ServiceLabel]) {
|
if utils.StringContains(options.Services, c.Labels[api.ServiceLabel]) {
|
||||||
containers = append(containers, c)
|
containers = append(containers, c)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -123,7 +123,8 @@ func containerLabels(service string, oneOff bool) map[string]string {
|
||||||
compose.ServiceLabel: service,
|
compose.ServiceLabel: service,
|
||||||
compose.ConfigFilesLabel: composefile,
|
compose.ConfigFilesLabel: composefile,
|
||||||
compose.WorkingDirLabel: workingdir,
|
compose.WorkingDirLabel: workingdir,
|
||||||
compose.ProjectLabel: strings.ToLower(testProject)}
|
compose.ProjectLabel: strings.ToLower(testProject),
|
||||||
|
}
|
||||||
if oneOff {
|
if oneOff {
|
||||||
labels[compose.OneoffLabel] = "True"
|
labels[compose.OneoffLabel] = "True"
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ func (s *composeService) Logs(
|
||||||
consumer api.LogConsumer,
|
consumer api.LogConsumer,
|
||||||
options api.LogOptions,
|
options api.LogOptions,
|
||||||
) error {
|
) error {
|
||||||
|
|
||||||
var containers Containers
|
var containers Containers
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,6 @@ func (s *composeService) pause(ctx context.Context, projectName string, options
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
return eg.Wait()
|
return eg.Wait()
|
||||||
}
|
}
|
||||||
|
@ -86,7 +85,6 @@ func (s *composeService) unPause(ctx context.Context, projectName string, option
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
return eg.Wait()
|
return eg.Wait()
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,8 @@ func TestPs(t *testing.T) {
|
||||||
containers, err := tested.Ps(ctx, strings.ToLower(testProject), compose.PsOptions{})
|
containers, err := tested.Ps(ctx, strings.ToLower(testProject), compose.PsOptions{})
|
||||||
|
|
||||||
expected := []compose.ContainerSummary{
|
expected := []compose.ContainerSummary{
|
||||||
{ID: "123", Name: "123", Names: []string{"/123"}, Image: "foo", Project: strings.ToLower(testProject), Service: "service1",
|
{
|
||||||
|
ID: "123", Name: "123", Names: []string{"/123"}, Image: "foo", Project: strings.ToLower(testProject), Service: "service1",
|
||||||
State: "running", Health: "healthy", Publishers: []compose.PortPublisher{},
|
State: "running", Health: "healthy", Publishers: []compose.PortPublisher{},
|
||||||
Labels: map[string]string{
|
Labels: map[string]string{
|
||||||
compose.ProjectLabel: strings.ToLower(testProject),
|
compose.ProjectLabel: strings.ToLower(testProject),
|
||||||
|
@ -64,7 +65,8 @@ func TestPs(t *testing.T) {
|
||||||
compose.ServiceLabel: "service1",
|
compose.ServiceLabel: "service1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ID: "456", Name: "456", Names: []string{"/456"}, Image: "foo", Project: strings.ToLower(testProject), Service: "service1",
|
{
|
||||||
|
ID: "456", Name: "456", Names: []string{"/456"}, Image: "foo", Project: strings.ToLower(testProject), Service: "service1",
|
||||||
State: "running", Health: "",
|
State: "running", Health: "",
|
||||||
Publishers: []compose.PortPublisher{{URL: "localhost", TargetPort: 90, PublishedPort: 80}},
|
Publishers: []compose.PortPublisher{{URL: "localhost", TargetPort: 90, PublishedPort: 80}},
|
||||||
Labels: map[string]string{
|
Labels: map[string]string{
|
||||||
|
@ -74,7 +76,8 @@ func TestPs(t *testing.T) {
|
||||||
compose.ServiceLabel: "service1",
|
compose.ServiceLabel: "service1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ID: "789", Name: "789", Names: []string{"/789"}, Image: "foo", Project: strings.ToLower(testProject), Service: "service2",
|
{
|
||||||
|
ID: "789", Name: "789", Names: []string{"/789"}, Image: "foo", Project: strings.ToLower(testProject), Service: "service2",
|
||||||
State: "exited", Health: "", ExitCode: 130, Publishers: []compose.PortPublisher{},
|
State: "exited", Health: "", ExitCode: 130, Publishers: []compose.PortPublisher{},
|
||||||
Labels: map[string]string{
|
Labels: map[string]string{
|
||||||
compose.ProjectLabel: strings.ToLower(testProject),
|
compose.ProjectLabel: strings.ToLower(testProject),
|
||||||
|
|
|
@ -175,7 +175,8 @@ func getUnwrappedErrorMessage(err error) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *composeService) pullServiceImage(ctx context.Context, service types.ServiceConfig,
|
func (s *composeService) pullServiceImage(ctx context.Context, service types.ServiceConfig,
|
||||||
configFile driver.Auth, w progress.Writer, quietPull bool, defaultPlatform string) (string, error) {
|
configFile driver.Auth, w progress.Writer, quietPull bool, defaultPlatform string,
|
||||||
|
) (string, error) {
|
||||||
w.Event(progress.Event{
|
w.Event(progress.Event{
|
||||||
ID: service.Name,
|
ID: service.Name,
|
||||||
Status: progress.Working,
|
Status: progress.Working,
|
||||||
|
|
|
@ -31,6 +31,5 @@ func (s *composeService) Scale(ctx context.Context, project *types.Project, opti
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return s.start(ctx, project.Name, api.StartOptions{Project: project, Services: options.Services}, nil)
|
return s.start(ctx, project.Name, api.StartOptions{Project: project, Services: options.Services}, nil)
|
||||||
|
|
||||||
}), s.stdinfo())
|
}), s.stdinfo())
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,8 @@ type containerWatchFn func(container moby.Container, t time.Time) error
|
||||||
// watchContainers uses engine events to capture container start/die and notify ContainerEventListener
|
// watchContainers uses engine events to capture container start/die and notify ContainerEventListener
|
||||||
func (s *composeService) watchContainers(ctx context.Context, //nolint:gocyclo
|
func (s *composeService) watchContainers(ctx context.Context, //nolint:gocyclo
|
||||||
projectName string, services, required []string,
|
projectName string, services, required []string,
|
||||||
listener api.ContainerEventListener, containers Containers, onStart, onRecreate containerWatchFn) error {
|
listener api.ContainerEventListener, containers Containers, onStart, onRecreate containerWatchFn,
|
||||||
|
) error {
|
||||||
if len(containers) == 0 {
|
if len(containers) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@ func (s *composeService) getSyncImplementation(project *types.Project) (sync.Syn
|
||||||
|
|
||||||
return sync.NewTar(project.Name, tarDockerClient{s: s}), nil
|
return sync.NewTar(project.Name, tarDockerClient{s: s}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *composeService) shouldWatch(project *types.Project) bool {
|
func (s *composeService) shouldWatch(project *types.Project) bool {
|
||||||
var shouldWatch bool
|
var shouldWatch bool
|
||||||
for i := range project.Services {
|
for i := range project.Services {
|
||||||
|
@ -84,6 +85,7 @@ func (s *composeService) shouldWatch(project *types.Project) bool {
|
||||||
func (s *composeService) Watch(ctx context.Context, project *types.Project, services []string, options api.WatchOptions) error {
|
func (s *composeService) Watch(ctx context.Context, project *types.Project, services []string, options api.WatchOptions) error {
|
||||||
return s.watch(ctx, nil, project, services, options)
|
return s.watch(ctx, nil, project, services, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *composeService) watch(ctx context.Context, syncChannel chan bool, project *types.Project, services []string, options api.WatchOptions) error { //nolint: gocyclo
|
func (s *composeService) watch(ctx context.Context, syncChannel chan bool, project *types.Project, services []string, options api.WatchOptions) error { //nolint: gocyclo
|
||||||
var err error
|
var err error
|
||||||
if project, err = project.WithSelectedServices(services); err != nil {
|
if project, err = project.WithSelectedServices(services); err != nil {
|
||||||
|
@ -553,7 +555,6 @@ func (s *composeService) rebuild(ctx context.Context, project *types.Project, se
|
||||||
// restrict the build to ONLY this service, not any of its dependencies
|
// restrict the build to ONLY this service, not any of its dependencies
|
||||||
options.Build.Services = []string{serviceName}
|
options.Build.Services = []string{serviceName}
|
||||||
imageNameToIdMap, err := s.build(ctx, project, *options.Build, nil)
|
imageNameToIdMap, err := s.build(ctx, project, *options.Build, nil)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
options.LogTo.Log(api.WatchLogger, fmt.Sprintf("Build failed. Error: %v", err))
|
options.LogTo.Log(api.WatchLogger, fmt.Sprintf("Build failed. Error: %v", err))
|
||||||
return err
|
return err
|
||||||
|
@ -626,7 +627,6 @@ func (s *composeService) pruneDanglingImagesOnRebuild(ctx context.Context, proje
|
||||||
filters.Arg("label", api.ProjectLabel+"="+projectName),
|
filters.Arg("label", api.ProjectLabel+"="+projectName),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Debugf("Failed to list images: %v", err)
|
logrus.Debugf("Failed to list images: %v", err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -50,7 +50,7 @@ func TestDebounceBatching(t *testing.T) {
|
||||||
matcher := watch.EmptyMatcher{}
|
matcher := watch.EmptyMatcher{}
|
||||||
eventBatchCh := batchDebounceEvents(ctx, clock, quietPeriod, ch)
|
eventBatchCh := batchDebounceEvents(ctx, clock, quietPeriod, ch)
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
var path = "/a"
|
path := "/a"
|
||||||
if i%2 == 0 {
|
if i%2 == 0 {
|
||||||
path = "/b"
|
path = "/b"
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,6 @@ func (s stdLogger) Status(container, msg string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s stdLogger) Register(container string) {
|
func (s stdLogger) Register(container string) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWatch_Sync(t *testing.T) {
|
func TestWatch_Sync(t *testing.T) {
|
||||||
|
|
|
@ -32,7 +32,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLocalComposeBuild(t *testing.T) {
|
func TestLocalComposeBuild(t *testing.T) {
|
||||||
|
|
||||||
for _, env := range []string{"DOCKER_BUILDKIT=0", "DOCKER_BUILDKIT=1", "DOCKER_BUILDKIT=1,COMPOSE-BAKE=1"} {
|
for _, env := range []string{"DOCKER_BUILDKIT=0", "DOCKER_BUILDKIT=1", "DOCKER_BUILDKIT=1,COMPOSE-BAKE=1"} {
|
||||||
c := NewCLI(t, WithEnv(strings.Split(env, ",")...))
|
c := NewCLI(t, WithEnv(strings.Split(env, ",")...))
|
||||||
|
|
||||||
|
@ -135,7 +134,6 @@ func TestLocalComposeBuild(t *testing.T) {
|
||||||
c.RunDockerOrExitError(t, "rmi", "-f", "custom-nginx")
|
c.RunDockerOrExitError(t, "rmi", "-f", "custom-nginx")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildSSH(t *testing.T) {
|
func TestBuildSSH(t *testing.T) {
|
||||||
|
@ -150,7 +148,6 @@ func TestBuildSSH(t *testing.T) {
|
||||||
ExitCode: 1,
|
ExitCode: 1,
|
||||||
Err: "invalid empty ssh agent socket: make sure SSH_AUTH_SOCK is set",
|
Err: "invalid empty ssh agent socket: make sure SSH_AUTH_SOCK is set",
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("build succeed with ssh from Compose file", func(t *testing.T) {
|
t.Run("build succeed with ssh from Compose file", func(t *testing.T) {
|
||||||
|
@ -218,7 +215,6 @@ func TestBuildTags(t *testing.T) {
|
||||||
c := NewParallelCLI(t)
|
c := NewParallelCLI(t)
|
||||||
|
|
||||||
t.Run("build with tags", func(t *testing.T) {
|
t.Run("build with tags", func(t *testing.T) {
|
||||||
|
|
||||||
// ensure local test run does not reuse previously build image
|
// ensure local test run does not reuse previously build image
|
||||||
c.RunDockerOrExitError(t, "rmi", "build-test-tags")
|
c.RunDockerOrExitError(t, "rmi", "build-test-tags")
|
||||||
|
|
||||||
|
@ -318,7 +314,6 @@ func TestBuildPlatformsWithCorrectBuildxConfig(t *testing.T) {
|
||||||
assert.NilError(t, res.Error, res.Stderr())
|
assert.NilError(t, res.Error, res.Stderr())
|
||||||
res.Assert(t, icmd.Expected{Out: "I am building for linux/arm64"})
|
res.Assert(t, icmd.Expected{Out: "I am building for linux/arm64"})
|
||||||
res.Assert(t, icmd.Expected{Out: "I am building for linux/amd64"})
|
res.Assert(t, icmd.Expected{Out: "I am building for linux/amd64"})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("multi-arch multi service builds ok", func(t *testing.T) {
|
t.Run("multi-arch multi service builds ok", func(t *testing.T) {
|
||||||
|
@ -355,7 +350,6 @@ func TestBuildPlatformsWithCorrectBuildxConfig(t *testing.T) {
|
||||||
assert.NilError(t, res.Error, res.Stderr())
|
assert.NilError(t, res.Error, res.Stderr())
|
||||||
res.Assert(t, icmd.Expected{Out: "I am building for linux/386"})
|
res.Assert(t, icmd.Expected{Out: "I am building for linux/386"})
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildPrivileged(t *testing.T) {
|
func TestBuildPrivileged(t *testing.T) {
|
||||||
|
@ -445,7 +439,6 @@ Switch to a different driver, or turn on the containerd image store, and try aga
|
||||||
Err: "the classic builder doesn't support privileged mode, set DOCKER_BUILDKIT=1 to use BuildKit",
|
Err: "the classic builder doesn't support privileged mode, set DOCKER_BUILDKIT=1 to use BuildKit",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildBuilder(t *testing.T) {
|
func TestBuildBuilder(t *testing.T) {
|
||||||
|
@ -472,7 +465,6 @@ func TestBuildBuilder(t *testing.T) {
|
||||||
Err: fmt.Sprintf(`no builder %q found`, "unknown-builder"),
|
Err: fmt.Sprintf(`no builder %q found`, "unknown-builder"),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildEntitlements(t *testing.T) {
|
func TestBuildEntitlements(t *testing.T) {
|
||||||
|
|
|
@ -83,7 +83,6 @@ func TestLocalComposeUp(t *testing.T) {
|
||||||
t.Run("check user labels", func(t *testing.T) {
|
t.Run("check user labels", func(t *testing.T) {
|
||||||
res := c.RunDockerCmd(t, "inspect", projectName+"-web-1")
|
res := c.RunDockerCmd(t, "inspect", projectName+"-web-1")
|
||||||
res.Assert(t, icmd.Expected{Out: `"my-label": "test"`})
|
res.Assert(t, icmd.Expected{Out: `"my-label": "test"`})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("check healthcheck output", func(t *testing.T) {
|
t.Run("check healthcheck output", func(t *testing.T) {
|
||||||
|
@ -391,7 +390,6 @@ func TestNestedDotEnv(t *testing.T) {
|
||||||
ExitCode: 0,
|
ExitCode: 0,
|
||||||
Out: "root sub win=sub",
|
Out: "root sub win=sub",
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnnecessaryResources(t *testing.T) {
|
func TestUnnecessaryResources(t *testing.T) {
|
||||||
|
|
|
@ -133,7 +133,6 @@ func copyLocalConfig(t testing.TB, configDir string) {
|
||||||
// initializePlugins copies the necessary plugin files to the temporary config
|
// initializePlugins copies the necessary plugin files to the temporary config
|
||||||
// directory for the test.
|
// directory for the test.
|
||||||
func initializePlugins(t testing.TB, configDir string) {
|
func initializePlugins(t testing.TB, configDir string) {
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if t.Failed() {
|
if t.Failed() {
|
||||||
if conf, err := os.ReadFile(filepath.Join(configDir, "config.json")); err == nil {
|
if conf, err := os.ReadFile(filepath.Join(configDir, "config.json")); err == nil {
|
||||||
|
|
|
@ -128,6 +128,5 @@ func expectOutput(res *icmd.Result, expected string) func(t poll.LogT) poll.Resu
|
||||||
return poll.Success()
|
return poll.Success()
|
||||||
}
|
}
|
||||||
return poll.Continue("condition not met")
|
return poll.Continue("condition not met")
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,9 +142,7 @@ func TestNetworkModes(t *testing.T) {
|
||||||
t.Run("run with service mode dependency", func(t *testing.T) {
|
t.Run("run with service mode dependency", func(t *testing.T) {
|
||||||
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/network-test/compose.yaml", "--project-name", projectName, "run", "-T", "mydb", "echo", "success")
|
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/network-test/compose.yaml", "--project-name", projectName, "run", "-T", "mydb", "echo", "success")
|
||||||
res.Assert(t, icmd.Expected{Out: "success"})
|
res.Assert(t, icmd.Expected{Out: "success"})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNetworkConfigChanged(t *testing.T) {
|
func TestNetworkConfigChanged(t *testing.T) {
|
||||||
|
@ -182,5 +180,4 @@ func TestMacAddress(t *testing.T) {
|
||||||
})
|
})
|
||||||
res := c.RunDockerCmd(t, "inspect", fmt.Sprintf("%s-test-1", projectName), "-f", "{{ (index .NetworkSettings.Networks \"network_mac_address_default\" ).MacAddress }}")
|
res := c.RunDockerCmd(t, "inspect", fmt.Sprintf("%s-test-1", projectName), "-f", "{{ (index .NetworkSettings.Networks \"network_mac_address_default\" ).MacAddress }}")
|
||||||
res.Assert(t, icmd.Expected{Out: "00:e0:84:35:d0:e8"})
|
res.Assert(t, icmd.Expected{Out: "00:e0:84:35:d0:e8"})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,5 +89,4 @@ func TestComposePull(t *testing.T) {
|
||||||
res := c.RunDockerComposeCmd(t, "--project-directory", "fixtures/compose-pull/unknown-image", "pull", "--ignore-pull-failures")
|
res := c.RunDockerComposeCmd(t, "--project-directory", "fixtures/compose-pull/unknown-image", "pull", "--ignore-pull-failures")
|
||||||
res.Assert(t, icmd.Expected{Err: "Some service image(s) must be built from source by running:"})
|
res.Assert(t, icmd.Expected{Err: "Some service image(s) must be built from source by running:"})
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,6 @@ func TestScaleDoesntRecreate(t *testing.T) {
|
||||||
|
|
||||||
res := c.RunDockerComposeCmd(t, "-f", "fixtures/simple-composefile/compose.yaml", "--project-name", projectName, "up", "--scale", "simple=2", "-d")
|
res := c.RunDockerComposeCmd(t, "-f", "fixtures/simple-composefile/compose.yaml", "--project-name", projectName, "up", "--scale", "simple=2", "-d")
|
||||||
assert.Check(t, !strings.Contains(res.Combined(), "Recreated"))
|
assert.Check(t, !strings.Contains(res.Combined(), "Recreated"))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUpWithDependencyNotRequired(t *testing.T) {
|
func TestUpWithDependencyNotRequired(t *testing.T) {
|
||||||
|
|
|
@ -35,7 +35,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestWatch(t *testing.T) {
|
func TestWatch(t *testing.T) {
|
||||||
|
|
||||||
services := []string{"alpine", "busybox", "debian"}
|
services := []string{"alpine", "busybox", "debian"}
|
||||||
for _, svcName := range services {
|
for _, svcName := range services {
|
||||||
t.Run(svcName, func(t *testing.T) {
|
t.Run(svcName, func(t *testing.T) {
|
||||||
|
@ -133,7 +132,6 @@ func TestRebuildOnDotEnvWithExternalNetwork(t *testing.T) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
testComplete.Store(true)
|
testComplete.Store(true)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: these tests all share a single Compose file but are safe to run
|
// NOTE: these tests all share a single Compose file but are safe to run
|
||||||
|
|
|
@ -51,7 +51,7 @@ func (p *jsonWriter) Start(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *jsonWriter) Event(e Event) {
|
func (p *jsonWriter) Event(e Event) {
|
||||||
var message = &jsonMessage{
|
message := &jsonMessage{
|
||||||
DryRun: p.dryRun,
|
DryRun: p.dryRun,
|
||||||
Tail: false,
|
Tail: false,
|
||||||
ID: e.ID,
|
ID: e.ID,
|
||||||
|
@ -75,7 +75,7 @@ func (p *jsonWriter) Events(events []Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *jsonWriter) TailMsgf(msg string, args ...interface{}) {
|
func (p *jsonWriter) TailMsgf(msg string, args ...interface{}) {
|
||||||
var message = &jsonMessage{
|
message := &jsonMessage{
|
||||||
DryRun: p.dryRun,
|
DryRun: p.dryRun,
|
||||||
Tail: true,
|
Tail: true,
|
||||||
ID: "",
|
ID: "",
|
||||||
|
|
|
@ -20,8 +20,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
)
|
)
|
||||||
|
|
||||||
type noopWriter struct {
|
type noopWriter struct{}
|
||||||
}
|
|
||||||
|
|
||||||
func (p *noopWriter) Start(ctx context.Context) error {
|
func (p *noopWriter) Start(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -345,6 +345,4 @@ func lenAnsi(s string) int {
|
||||||
return length
|
return length
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var percentChars = strings.Split("⠀⡀⣀⣄⣤⣦⣶⣷⣿", "")
|
||||||
percentChars = strings.Split("⠀⡀⣀⣄⣤⣦⣶⣷⣿", "")
|
|
||||||
)
|
|
||||||
|
|
|
@ -36,5 +36,4 @@ func TestSplitWriter(t *testing.T) {
|
||||||
w.Write([]byte("\n"))
|
w.Write([]byte("\n"))
|
||||||
w.Write([]byte("world!\n"))
|
w.Write([]byte("world!\n"))
|
||||||
assert.DeepEqual(t, lines, []string{"hello", "world!"})
|
assert.DeepEqual(t, lines, []string{"hello", "world!"})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,7 @@ import (
|
||||||
"github.com/tilt-dev/fsnotify"
|
"github.com/tilt-dev/fsnotify"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var numberOfWatches = expvar.NewInt("watch.naive.numberOfWatches")
|
||||||
numberOfWatches = expvar.NewInt("watch.naive.numberOfWatches")
|
|
||||||
)
|
|
||||||
|
|
||||||
type FileEvent struct {
|
type FileEvent struct {
|
||||||
path string
|
path string
|
||||||
|
@ -76,8 +74,7 @@ type PathMatcher interface {
|
||||||
MatchesEntireDir(file string) (bool, error)
|
MatchesEntireDir(file string) (bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type EmptyMatcher struct {
|
type EmptyMatcher struct{}
|
||||||
}
|
|
||||||
|
|
||||||
func (EmptyMatcher) Matches(f string) (bool, error) { return false, nil }
|
func (EmptyMatcher) Matches(f string) (bool, error) { return false, nil }
|
||||||
func (EmptyMatcher) MatchesEntireDir(f string) (bool, error) { return false, nil }
|
func (EmptyMatcher) MatchesEntireDir(f string) (bool, error) { return false, nil }
|
||||||
|
|
Loading…
Reference in New Issue