Skip to content

Commit

Permalink
chore(deps): bump github.com/docker/compose/v2 from 2.23.3 to 2.24.0 …
Browse files Browse the repository at this point in the history
…in /modules/compose (#2096)

* chore(deps): bump github.com/docker/compose/v2 in /modules/compose

Bumps [github.com/docker/compose/v2](https://github.com/docker/compose) from 2.23.3 to 2.24.0.
- [Release notes](https://github.com/docker/compose/releases)
- [Commits](docker/compose@v2.23.3...v2.24.0)

---
updated-dependencies:
- dependency-name: github.com/docker/compose/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: bump buildx to rc-2

* chore: use compose-go v2

* fix: resolve breaking changes using the right type

Compose's services is now a map from string to ServiceConfig, so we are
updating the code to lookup the services using the map instead of the string.

* fix: use non-deprecated list options

* chore: proper deprecation commands for LocalDockerCompose

* chore: use require for Up errors

* chore: fix validation for modern compose version

* chore: remove unused variable

* chore: remove named return

* chore: simplify

* chore: use non-deprecated options

* chore: resolve golangci lints

* fix: assert.Len

* fix: wrong replace

* chore: bump compose dependencies

* fix: honour compose unicity

* fix: lint applied reversely

* fix: length

* fix: wrong copy&paste

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Manuel de la Peña <mdelapenya@gmail.com>
  • Loading branch information
dependabot[bot] and mdelapenya authored Jan 24, 2024
1 parent 12ad0ab commit 0598eeb
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 185 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-test-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:

- name: golangci-lint
# TODO: Remove each example/module once it passes the golangci-lint
if: ${{ inputs.platform == 'ubuntu-latest' && inputs.go-version == '1.20.x' && !contains(fromJSON('["modules/compose"]'), inputs.project-directory) }}
if: ${{ inputs.platform == 'ubuntu-latest' && inputs.go-version == '1.20.x' }}
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
Expand Down
16 changes: 6 additions & 10 deletions modules/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (
"path/filepath"
"runtime"
"strings"
"sync"

"github.com/compose-spec/compose-go/types"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/flags"
"github.com/docker/compose/v2/pkg/api"
Expand All @@ -24,10 +23,7 @@ const (
envComposeFile = "COMPOSE_FILE"
)

var (
composeLogOnce sync.Once
ErrNoStackConfigured = errors.New("no stack files configured")
)
var ErrNoStackConfigured = errors.New("no stack files configured")

type composeStackOptions struct {
Identifier string
Expand Down Expand Up @@ -77,9 +73,9 @@ type ComposeStack interface {
ServiceContainer(ctx context.Context, svcName string) (*testcontainers.DockerContainer, error)
}

// DockerCompose defines the contract for running Docker Compose
// Deprecated: DockerCompose is the old shell escape based API
// use ComposeStack instead
// DockerCompose defines the contract for running Docker Compose
type DockerCompose interface {
Down() ExecError
Invoke() ExecError
Expand Down Expand Up @@ -138,16 +134,16 @@ func NewDockerComposeWith(opts ...ComposeStackOption) (*dockerCompose, error) {
return composeAPI, nil
}

// Deprecated: NewLocalDockerCompose returns a DockerCompose compatible instance which is superseded
// by ComposeStack use NewDockerCompose instead to get a ComposeStack compatible instance
//
// NewLocalDockerCompose returns an instance of the local Docker Compose, using an
// array of Docker Compose file paths and an identifier for the Compose execution.
//
// It will iterate through the array adding '-f compose-file-path' flags to the local
// Docker Compose execution. The identifier represents the name of the execution,
// which will define the name of the underlying Docker network and the name of the
// running Compose services.
//
// Deprecated: NewLocalDockerCompose returns a DockerCompose compatible instance which is superseded
// by ComposeStack use NewDockerCompose instead to get a ComposeStack compatible instance
func NewLocalDockerCompose(filePaths []string, identifier string, opts ...LocalDockerComposeOption) *LocalDockerCompose {
dc := &LocalDockerCompose{
LocalDockerComposeOptions: &LocalDockerComposeOptions{
Expand Down
20 changes: 11 additions & 9 deletions modules/compose/compose_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"strings"
"sync"

"github.com/compose-spec/compose-go/cli"
"github.com/compose-spec/compose-go/types"
"github.com/compose-spec/compose-go/v2/cli"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/pkg/api"
types2 "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/client"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -180,10 +180,12 @@ func (d *dockerCompose) Down(ctx context.Context, opts ...StackDownOption) error
return d.composeService.Down(ctx, d.name, options.DownOptions)
}

func (d *dockerCompose) Up(ctx context.Context, opts ...StackUpOption) (err error) {
func (d *dockerCompose) Up(ctx context.Context, opts ...StackUpOption) error {
d.lock.Lock()
defer d.lock.Unlock()

var err error

d.project, err = d.compileProject()
if err != nil {
return err
Expand All @@ -203,11 +205,11 @@ func (d *dockerCompose) Up(ctx context.Context, opts ...StackUpOption) (err erro
if len(upOptions.Services) != len(d.project.Services) {
sort.Strings(upOptions.Services)

filteredServices := make(types.Services, 0, len(d.project.Services))
filteredServices := types.Services{}

for i := range d.project.Services {
if idx := sort.SearchStrings(upOptions.Services, d.project.Services[i].Name); idx < len(upOptions.Services) && upOptions.Services[idx] == d.project.Services[i].Name {
filteredServices = append(filteredServices, d.project.Services[i])
for _, srv := range upOptions.Services {
if srvConfig, ok := d.project.Services[srv]; ok {
filteredServices[srv] = srvConfig
}
}

Expand Down Expand Up @@ -288,7 +290,7 @@ func (d *dockerCompose) lookupContainer(ctx context.Context, svcName string) (*t
return container, nil
}

listOptions := types2.ContainerListOptions{
listOptions := container.ListOptions{
All: true,
Filters: filters.NewArgs(
filters.Arg("label", fmt.Sprintf("%s=%s", api.ProjectLabel, d.name)),
Expand Down
Loading

0 comments on commit 0598eeb

Please sign in to comment.