mirror of
https://github.com/docker/compose.git
synced 2026-02-10 18:49:28 +08:00
Compare commits
21 Commits
v2.5.1
...
fix-bindmo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ba46049db | ||
|
|
6756732fe4 | ||
|
|
67c13cf821 | ||
|
|
dbafb02377 | ||
|
|
a1b3f95709 | ||
|
|
5b6b674da9 | ||
|
|
31d9490a0b | ||
|
|
6b71073ae2 | ||
|
|
e806acce88 | ||
|
|
71600a52bf | ||
|
|
285a9c94f7 | ||
|
|
22194f6ef7 | ||
|
|
e51fd0a844 | ||
|
|
b961d49859 | ||
|
|
9cae9eb0fe | ||
|
|
8d03e29994 | ||
|
|
7ee7becd01 | ||
|
|
97d46a14ef | ||
|
|
a5a1c5f2f1 | ||
|
|
a2770b66ff | ||
|
|
48b150beff |
4
.github/workflows/artifacts.yml
vendored
4
.github/workflows/artifacts.yml
vendored
@@ -7,10 +7,10 @@ jobs:
|
||||
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/generate-artifacts')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up Go 1.17
|
||||
- name: Set up Go 1.18
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17
|
||||
go-version: 1.18.2
|
||||
id: go
|
||||
|
||||
- name: Checkout code into the Go module directory
|
||||
|
||||
38
.github/workflows/ci.yml
vendored
38
.github/workflows/ci.yml
vendored
@@ -5,6 +5,12 @@ on:
|
||||
branches:
|
||||
- v2
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
debug_enabled:
|
||||
description: 'To run with tmate enter "debug_enabled"'
|
||||
required: false
|
||||
default: "false"
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
@@ -13,10 +19,10 @@ jobs:
|
||||
env:
|
||||
GO111MODULE: "on"
|
||||
steps:
|
||||
- name: Set up Go 1.17
|
||||
- name: Set up Go 1.18
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17
|
||||
go-version: 1.18.2
|
||||
id: go
|
||||
|
||||
- name: Checkout code into the Go module directory
|
||||
@@ -40,10 +46,10 @@ jobs:
|
||||
env:
|
||||
GO111MODULE: "on"
|
||||
steps:
|
||||
- name: Set up Go 1.17
|
||||
- name: Set up Go 1.18
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17
|
||||
go-version: 1.18.2
|
||||
id: go
|
||||
|
||||
- name: Checkout code into the Go module directory
|
||||
@@ -65,10 +71,10 @@ jobs:
|
||||
env:
|
||||
GO111MODULE: "on"
|
||||
steps:
|
||||
- name: Set up Go 1.17
|
||||
- name: Set up Go 1.18
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17
|
||||
go-version: 1.18.2
|
||||
id: go
|
||||
|
||||
- name: Setup docker CLI
|
||||
@@ -90,7 +96,7 @@ jobs:
|
||||
- name: Build for local E2E
|
||||
env:
|
||||
BUILD_TAGS: e2e
|
||||
run: make -f builder.Makefile compose-plugin
|
||||
run: make GIT_TAG=e2e-PR-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} -f builder.Makefile compose-plugin
|
||||
|
||||
- name: E2E Test in plugin mode
|
||||
run: make e2e-compose
|
||||
@@ -101,10 +107,10 @@ jobs:
|
||||
env:
|
||||
GO111MODULE: "on"
|
||||
steps:
|
||||
- name: Set up Go 1.17
|
||||
- name: Set up Go 1.18
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17
|
||||
go-version: 1.18.2
|
||||
id: go
|
||||
|
||||
- name: Setup docker CLI
|
||||
@@ -123,7 +129,17 @@ jobs:
|
||||
- name: Build for local E2E
|
||||
env:
|
||||
BUILD_TAGS: e2e
|
||||
run: make -f builder.Makefile compose-plugin
|
||||
run: make GIT_TAG=e2e-PR-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} -f builder.Makefile compose-plugin
|
||||
|
||||
- name: Setup tmate session
|
||||
uses: mxschmitt/action-tmate@v3
|
||||
with:
|
||||
limit-access-to-actor: true
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
|
||||
|
||||
- name: E2E Test in standalone mode
|
||||
run: make e2e-compose-standalone
|
||||
run: |
|
||||
rm -f /usr/local/bin/docker-compose
|
||||
cp bin/docker-compose /usr/local/bin
|
||||
make e2e-compose-standalone
|
||||
|
||||
4
.github/workflows/release.yaml
vendored
4
.github/workflows/release.yaml
vendored
@@ -11,10 +11,10 @@ jobs:
|
||||
upload-release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up Go 1.17
|
||||
- name: Set up Go 1.18
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17
|
||||
go-version: 1.18.2
|
||||
id: go
|
||||
|
||||
- name: Setup docker CLI
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
ARG GO_VERSION=1.17-alpine
|
||||
ARG GO_VERSION=1.18.2-alpine
|
||||
ARG GOLANGCI_LINT_VERSION=v1.40.1-alpine
|
||||
ARG PROTOC_GEN_GO_VERSION=v1.4.3
|
||||
|
||||
@@ -88,7 +88,7 @@ RUN --mount=target=. \
|
||||
make -f builder.Makefile test
|
||||
|
||||
FROM base AS check-license-headers
|
||||
RUN go get -u github.com/kunalkushwaha/ltag
|
||||
RUN go install github.com/kunalkushwaha/ltag@latest
|
||||
RUN --mount=target=. \
|
||||
make -f builder.Makefile check-license-headers
|
||||
|
||||
|
||||
4
Makefile
4
Makefile
@@ -43,11 +43,13 @@ compose-plugin: ## Compile the compose cli-plugin
|
||||
|
||||
.PHONY: e2e-compose
|
||||
e2e-compose: ## Run end to end local tests in plugin mode. Set E2E_TEST=TestName to run a single test
|
||||
docker compose version
|
||||
go test $(TEST_FLAGS) -count=1 ./pkg/e2e
|
||||
|
||||
.PHONY: e2e-compose-standalone
|
||||
e2e-compose-standalone: ## Run End to end local tests in standalone mode. Set E2E_TEST=TestName to run a single test
|
||||
go test $(TEST_FLAGS) -count=1 --tags=standalone ./pkg/e2e
|
||||
docker-compose version
|
||||
go test $(TEST_FLAGS) -v -count=1 -parallel=1 --tags=standalone ./pkg/e2e
|
||||
|
||||
.PHONY: mocks
|
||||
mocks:
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
|
||||
"github.com/compose-spec/compose-go/cli"
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
composegoutils "github.com/compose-spec/compose-go/utils"
|
||||
dockercli "github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli-plugins/manager"
|
||||
"github.com/docker/cli/cli/command"
|
||||
@@ -257,6 +258,10 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command {
|
||||
}
|
||||
},
|
||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
err := setEnvWithDotEnv(&opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
parent := cmd.Root()
|
||||
if parent != nil {
|
||||
parentPrerun := parent.PersistentPreRunE
|
||||
@@ -333,3 +338,27 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command {
|
||||
command.Flags().MarkHidden("verbose") //nolint:errcheck
|
||||
return command
|
||||
}
|
||||
|
||||
func setEnvWithDotEnv(prjOpts *projectOptions) error {
|
||||
options, err := prjOpts.toProjectOptions()
|
||||
if err != nil {
|
||||
return compose.WrapComposeError(err)
|
||||
}
|
||||
workingDir, err := options.GetWorkingDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
envFromFile, err := cli.GetEnvFromFile(composegoutils.GetAsEqualsMap(os.Environ()), workingDir, options.EnvFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for k, v := range envFromFile {
|
||||
if _, ok := os.LookupEnv(k); !ok {
|
||||
if err = os.Setenv(k, v); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -185,6 +185,9 @@ func runUp(ctx context.Context, backend api.Service, createOptions createOptions
|
||||
if upOptions.attachDependencies {
|
||||
attachTo = project.ServiceNames()
|
||||
}
|
||||
if len(attachTo) == 0 {
|
||||
attachTo = project.ServiceNames()
|
||||
}
|
||||
|
||||
create := api.CreateOptions{
|
||||
Services: services,
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
ARG GO_VERSION=1.17
|
||||
ARG GO_VERSION=1.18.2
|
||||
ARG FORMATS=md,yaml
|
||||
|
||||
FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION}-alpine AS docsgen
|
||||
|
||||
8
go.mod
8
go.mod
@@ -1,12 +1,12 @@
|
||||
module github.com/docker/compose/v2
|
||||
|
||||
go 1.17
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/AlecAivazis/survey/v2 v2.3.2
|
||||
github.com/buger/goterm v1.0.4
|
||||
github.com/cnabio/cnab-to-oci v0.3.1-beta1
|
||||
github.com/compose-spec/compose-go v1.2.5
|
||||
github.com/compose-spec/compose-go v1.2.7
|
||||
github.com/containerd/console v1.0.3
|
||||
github.com/containerd/containerd v1.6.2
|
||||
github.com/distribution/distribution/v3 v3.0.0-20210316161203-a01c71e2477e
|
||||
@@ -69,7 +69,7 @@ require (
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/imdario/mergo v0.3.12 // indirect
|
||||
github.com/imdario/mergo v0.3.13 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
|
||||
@@ -123,7 +123,7 @@ require (
|
||||
google.golang.org/protobuf v1.27.1 // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0 // indirect
|
||||
k8s.io/apimachinery v0.23.4 // indirect; see replace for the actual version used
|
||||
k8s.io/client-go v0.23.4 // indirect; see replace for the actual version used
|
||||
k8s.io/klog/v2 v2.30.0 // indirect
|
||||
|
||||
15
go.sum
15
go.sum
@@ -259,7 +259,6 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA
|
||||
github.com/certifi/gocertifi v0.0.0-20180118203423-deb3ae2ef261/go.mod h1:GJKEexRPVJrBSOjoqN5VNOIKJ5Q3RViH6eu3puDRwx4=
|
||||
github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
|
||||
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
|
||||
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/cespare/xxhash/v2 v2.1.0/go.mod h1:dgIUBU3pDso/gPgZ1osOZ0iQf77oPR28Tjxl5dIMyVM=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
@@ -302,8 +301,8 @@ github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoC
|
||||
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI=
|
||||
github.com/codahale/hdrhistogram v0.0.0-20160425231609-f8ad88b59a58/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
|
||||
github.com/compose-spec/compose-go v1.0.8/go.mod h1:REnCbBugoIdHB7S1sfkN/aJ7AJpNApGNjNiVjA9L8x4=
|
||||
github.com/compose-spec/compose-go v1.2.5 h1:yGaACRJrWTQMFW89/ck2o1qd3gIxAji4EQkgewH3hqc=
|
||||
github.com/compose-spec/compose-go v1.2.5/go.mod h1:a/H2RY5UejNRhzbNXHygSAxBARTpLmLlaCkh58xfStM=
|
||||
github.com/compose-spec/compose-go v1.2.7 h1:eqKGZhdOQEGKW/FmFDt4xyEPhCpbA5dr0PkcWD895aI=
|
||||
github.com/compose-spec/compose-go v1.2.7/go.mod h1:Jl9L8zJrt4aGY1XAz03DvHAu8V3/f00TK+uJL4BayDU=
|
||||
github.com/compose-spec/godotenv v1.1.1/go.mod h1:zF/3BOa18Z24tts5qnO/E9YURQanJTBUf7nlcCTNsyc=
|
||||
github.com/containerd/aufs v0.0.0-20200908144142-dab0cbea06f4/go.mod h1:nukgQABAEopAHvB6j7cnP5zJ+/3aVcE7hCYqvIwAHyE=
|
||||
github.com/containerd/aufs v0.0.0-20201003224125-76a6863f2989/go.mod h1:AkGGQs9NM2vtYHaUen+NljV0/baGCAPELGm2q9ZXpWU=
|
||||
@@ -871,8 +870,9 @@ github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ
|
||||
github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||
github.com/imdario/mergo v0.3.10/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
|
||||
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
|
||||
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
|
||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/intel/goresctrl v0.2.0/go.mod h1:+CZdzouYFn5EsxgqAQTEzMfwKwuc0fVdMrT9FCCAVRQ=
|
||||
@@ -1475,7 +1475,6 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
|
||||
go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=
|
||||
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
|
||||
go.opentelemetry.io/contrib v0.20.0 h1:ubFQUn0VCZ0gPwIoJfBJVpeBlyRMxu8Mm/huKWYd9p0=
|
||||
go.opentelemetry.io/contrib v0.20.0/go.mod h1:G/EtFaa6qaN7+LxqfIAT3GiZa7Wv5DTBUzl5H4LY0Kc=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.20.0/go.mod h1:oVGt1LRbBOBq1A5BQLlUg9UaU/54aiHw8cgjV3aWZ/E=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.28.0/go.mod h1:vEhqr0m4eTc+DWxfsXoXue2GBgV2uUwVznkGIHW/e5w=
|
||||
@@ -1492,7 +1491,6 @@ go.opentelemetry.io/otel v1.4.0/go.mod h1:jeAqMFKy2uLIxCtKxoFj0FAL5zAPKQagc3+GtB
|
||||
go.opentelemetry.io/otel v1.4.1 h1:QbINgGDDcoQUoMJa2mMaWno49lja9sHwp6aoa2n3a4g=
|
||||
go.opentelemetry.io/otel v1.4.1/go.mod h1:StM6F/0fSwpd8dKWDCdRr7uRvEPYdW0hBSlbdTiUde4=
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.4.1/go.mod h1:ZW7vkOu9nC1CxsD8bHNHCia5JUbwP39vxgd1q4Z5rCI=
|
||||
go.opentelemetry.io/otel/exporters/otlp v0.20.0 h1:PTNgq9MRmQqqJY0REVbZFvwkYOA85vbdQU/nVfxDyqg=
|
||||
go.opentelemetry.io/otel/exporters/otlp v0.20.0/go.mod h1:YIieizyaN77rtLJra0buKiNBOm9XQfkPEKBeuhoMwAM=
|
||||
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.3.0/go.mod h1:VpP4/RMn8bv8gNo9uK7/IMY4mtWLELsS+JIP0inH0h4=
|
||||
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.4.1/go.mod h1:VpP4/RMn8bv8gNo9uK7/IMY4mtWLELsS+JIP0inH0h4=
|
||||
@@ -2142,8 +2140,9 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA=
|
||||
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
|
||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
|
||||
@@ -2194,7 +2193,6 @@ k8s.io/gengo v0.0.0-20200428234225-8167cfdcfc14/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8
|
||||
k8s.io/gengo v0.0.0-20201113003025-83324d819ded/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
|
||||
k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
|
||||
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
|
||||
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
|
||||
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
@@ -2233,7 +2231,6 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.14/go.mod h1:LEScyz
|
||||
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
|
||||
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.22/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
|
||||
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
|
||||
sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06 h1:zD2IemQ4LmOcAumeiyDWXKUI2SO0NYDe3H6QGvPOVgU=
|
||||
sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06/go.mod h1:/ULNhyfzRopfcjskuui0cTITekDduZ7ycKN3oUT9R18=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
|
||||
|
||||
@@ -275,6 +275,10 @@ func (s *composeService) toBuildOptions(project *types.Project, service types.Se
|
||||
sessionConfig = append(sessionConfig, p)
|
||||
}
|
||||
|
||||
if len(service.Build.Tags) > 0 {
|
||||
tags = append(tags, service.Build.Tags...)
|
||||
}
|
||||
|
||||
return build.Options{
|
||||
Inputs: build.Inputs{
|
||||
ContextPath: service.Build.Context,
|
||||
|
||||
@@ -718,9 +718,15 @@ MOUNTS:
|
||||
// so `Bind` API is used here with raw volume string
|
||||
// see https://github.com/moby/moby/issues/43483
|
||||
for _, v := range service.Volumes {
|
||||
if v.Target == m.Target && v.Bind != nil && v.Bind.CreateHostPath {
|
||||
binds = append(binds, v.String())
|
||||
continue MOUNTS
|
||||
if v.Target == m.Target {
|
||||
switch {
|
||||
case string(m.Type) != v.Type:
|
||||
v.Source = m.Source
|
||||
fallthrough
|
||||
case v.Bind != nil && v.Bind.CreateHostPath:
|
||||
binds = append(binds, v.String())
|
||||
continue MOUNTS
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -911,10 +917,14 @@ func buildMount(project types.Project, volume types.ServiceVolumeConfig) (mount.
|
||||
}
|
||||
}
|
||||
|
||||
bind, vol, tmpfs := buildMountOptions(volume)
|
||||
bind, vol, tmpfs := buildMountOptions(project, volume)
|
||||
|
||||
volume.Target = path.Clean(volume.Target)
|
||||
|
||||
if bind != nil {
|
||||
volume.Type = types.VolumeTypeBind
|
||||
}
|
||||
|
||||
return mount.Mount{
|
||||
Type: mount.Type(volume.Type),
|
||||
Source: source,
|
||||
@@ -927,7 +937,7 @@ func buildMount(project types.Project, volume types.ServiceVolumeConfig) (mount.
|
||||
}, nil
|
||||
}
|
||||
|
||||
func buildMountOptions(volume types.ServiceVolumeConfig) (*mount.BindOptions, *mount.VolumeOptions, *mount.TmpfsOptions) {
|
||||
func buildMountOptions(project types.Project, volume types.ServiceVolumeConfig) (*mount.BindOptions, *mount.VolumeOptions, *mount.TmpfsOptions) {
|
||||
switch volume.Type {
|
||||
case "bind":
|
||||
if volume.Volume != nil {
|
||||
@@ -944,6 +954,11 @@ func buildMountOptions(volume types.ServiceVolumeConfig) (*mount.BindOptions, *m
|
||||
if volume.Tmpfs != nil {
|
||||
logrus.Warnf("mount of type `volume` should not define `tmpfs` option")
|
||||
}
|
||||
if v, ok := project.Volumes[volume.Source]; ok && v.DriverOpts["o"] == types.VolumeTypeBind {
|
||||
return buildBindOption(&types.ServiceVolumeBind{
|
||||
CreateHostPath: true,
|
||||
}), nil, nil
|
||||
}
|
||||
return nil, buildVolumeOptions(volume.Volume), nil
|
||||
case "tmpfs":
|
||||
if volume.Bind != nil {
|
||||
|
||||
@@ -116,6 +116,9 @@ func applyRunOptions(project *types.Project, service *types.ServiceConfig, opts
|
||||
if len(opts.Environment) > 0 {
|
||||
env := types.NewMappingWithEquals(opts.Environment)
|
||||
projectEnv := env.Resolve(func(s string) (string, bool) {
|
||||
if _, ok := service.Environment[s]; ok {
|
||||
return "", false
|
||||
}
|
||||
v, ok := project.Environment[s]
|
||||
return v, ok
|
||||
}).RemoveEmpty()
|
||||
|
||||
@@ -61,12 +61,12 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options
|
||||
go func() {
|
||||
<-signalChan
|
||||
s.Kill(ctx, project.Name, api.KillOptions{ // nolint:errcheck
|
||||
Services: options.Create.Services,
|
||||
Services: project.ServiceNames(),
|
||||
})
|
||||
}()
|
||||
|
||||
return s.Stop(ctx, project.Name, api.StopOptions{
|
||||
Services: options.Create.Services,
|
||||
Services: project.ServiceNames(),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -181,3 +181,24 @@ func TestBuildSecrets(t *testing.T) {
|
||||
res.Assert(t, icmd.Success)
|
||||
})
|
||||
}
|
||||
|
||||
func TestBuildTags(t *testing.T) {
|
||||
c := NewParallelE2eCLI(t, binDir)
|
||||
|
||||
t.Run("build with tags", func(t *testing.T) {
|
||||
|
||||
// ensure local test run does not reuse previously build image
|
||||
c.RunDockerOrExitError("rmi", "build-test-tags")
|
||||
|
||||
c.RunDockerComposeCmd("--project-directory", "./fixtures/build-test/tags", "build", "--no-cache")
|
||||
|
||||
res := c.RunDockerCmd("image", "inspect", "build-test-tags")
|
||||
expectedOutput := `"RepoTags": [
|
||||
"docker/build-test-tags:1.0.0",
|
||||
"build-test-tags:latest",
|
||||
"other-image-name:v1.0.0"
|
||||
],
|
||||
`
|
||||
res.Assert(t, icmd.Expected{Out: expectedOutput})
|
||||
})
|
||||
}
|
||||
|
||||
169
pkg/e2e/compose_environment_test.go
Normal file
169
pkg/e2e/compose_environment_test.go
Normal file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
Copyright 2020 Docker Compose CLI authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/icmd"
|
||||
)
|
||||
|
||||
func TestEnvPriority(t *testing.T) {
|
||||
c := NewParallelE2eCLI(t, binDir)
|
||||
|
||||
projectDir := "./fixtures/environment/env-priority"
|
||||
|
||||
t.Run("up", func(t *testing.T) {
|
||||
c.RunDockerOrExitError("rmi", "env-compose-priority")
|
||||
c.RunDockerComposeCmd("-f", "./fixtures/environment/env-priority/compose-with-env.yaml",
|
||||
"--project-directory", projectDir, "up", "-d", "--build")
|
||||
})
|
||||
|
||||
// Full options activated
|
||||
// 1. Compose file <-- Result expected
|
||||
// 2. Shell environment variables
|
||||
// 3. Environment file
|
||||
// 4. Dockerfile
|
||||
// 5. Variable is not defined
|
||||
t.Run("compose file priority", func(t *testing.T) {
|
||||
os.Setenv("WHEREAMI", "shell") //nolint:errcheck
|
||||
defer os.Unsetenv("WHEREAMI") //nolint:errcheck
|
||||
|
||||
res := c.RunDockerComposeCmd("-f", "./fixtures/environment/env-priority/compose-with-env.yaml",
|
||||
"--project-directory", projectDir, "--env-file", "./fixtures/environment/env-priority/.env.override",
|
||||
"run", "--rm", "-e", "WHEREAMI", "env-compose-priority")
|
||||
|
||||
assert.Equal(t, strings.TrimSpace(res.Stdout()), "Compose File")
|
||||
})
|
||||
|
||||
// No Compose file, all other options
|
||||
// 1. Compose file
|
||||
// 2. Shell environment variables <-- Result expected
|
||||
// 3. Environment file
|
||||
// 4. Dockerfile
|
||||
// 5. Variable is not defined
|
||||
t.Run("shell priority", func(t *testing.T) {
|
||||
os.Setenv("WHEREAMI", "shell") //nolint:errcheck
|
||||
defer os.Unsetenv("WHEREAMI") //nolint:errcheck
|
||||
|
||||
res := c.RunDockerComposeCmd("-f", "./fixtures/environment/env-priority/compose.yaml",
|
||||
"--project-directory", projectDir, "--env-file", "./fixtures/environment/env-priority/.env.override",
|
||||
"run", "--rm", "-e", "WHEREAMI", "env-compose-priority")
|
||||
assert.Equal(t, strings.TrimSpace(res.Stdout()), "shell")
|
||||
})
|
||||
|
||||
// No Compose file and env variable pass to the run command
|
||||
// 1. Compose file
|
||||
// 2. Shell environment variables <-- Result expected
|
||||
// 3. Environment file
|
||||
// 4. Dockerfile
|
||||
// 5. Variable is not defined
|
||||
t.Run("shell priority from run command", func(t *testing.T) {
|
||||
res := c.RunDockerComposeCmd("-f", "./fixtures/environment/env-priority/compose.yaml",
|
||||
"--project-directory", projectDir, "--env-file", "./fixtures/environment/env-priority/.env.override",
|
||||
"run", "--rm", "-e", "WHEREAMI=shell-run", "env-compose-priority")
|
||||
assert.Equal(t, strings.TrimSpace(res.Stdout()), "shell-run")
|
||||
})
|
||||
|
||||
// No Compose file & no env variable but override env file
|
||||
// 1. Compose file
|
||||
// 2. Shell environment variables
|
||||
// 3. Environment file <-- Result expected
|
||||
// 4. Dockerfile
|
||||
// 5. Variable is not defined
|
||||
t.Run("override env file", func(t *testing.T) {
|
||||
res := c.RunDockerComposeCmd("-f", "./fixtures/environment/env-priority/compose.yaml",
|
||||
"--project-directory", projectDir, "--env-file", "./fixtures/environment/env-priority/.env.override",
|
||||
"run", "--rm", "-e", "WHEREAMI", "env-compose-priority")
|
||||
assert.Equal(t, strings.TrimSpace(res.Stdout()), "override")
|
||||
})
|
||||
|
||||
// No Compose file & no env variable but override env file
|
||||
// 1. Compose file
|
||||
// 2. Shell environment variables
|
||||
// 3. Environment file <-- Result expected
|
||||
// 4. Dockerfile
|
||||
// 5. Variable is not defined
|
||||
t.Run("env file", func(t *testing.T) {
|
||||
res := c.RunDockerComposeCmd("-f", "./fixtures/environment/env-priority/compose.yaml",
|
||||
"--project-directory", projectDir, "run", "--rm", "-e", "WHEREAMI", "env-compose-priority")
|
||||
assert.Equal(t, strings.TrimSpace(res.Stdout()), "Env File")
|
||||
})
|
||||
|
||||
// No Compose file & no env variable, using an empty override env file
|
||||
// 1. Compose file
|
||||
// 2. Shell environment variables
|
||||
// 3. Environment file
|
||||
// 4. Dockerfile <-- Result expected
|
||||
// 5. Variable is not defined
|
||||
t.Run("use Dockerfile", func(t *testing.T) {
|
||||
res := c.RunDockerComposeCmd("-f", "./fixtures/environment/env-priority/compose.yaml",
|
||||
"--project-directory", projectDir, "--env-file", "./fixtures/environment/env-priority/.env.empty",
|
||||
"run", "--rm", "-e", "WHEREAMI", "env-compose-priority")
|
||||
assert.Equal(t, strings.TrimSpace(res.Stdout()), "Dockerfile")
|
||||
})
|
||||
|
||||
t.Run("down", func(t *testing.T) {
|
||||
c.RunDockerComposeCmd("--project-directory", projectDir, "down")
|
||||
})
|
||||
}
|
||||
|
||||
func TestEnvInterpolation(t *testing.T) {
|
||||
c := NewParallelE2eCLI(t, binDir)
|
||||
|
||||
projectDir := "./fixtures/environment/env-interpolation"
|
||||
|
||||
// No variable defined in the Compose file and env variable pass to the run command
|
||||
// 1. Compose file
|
||||
// 2. Shell environment variables <-- Result expected
|
||||
// 3. Environment file
|
||||
// 4. Dockerfile
|
||||
// 5. Variable is not defined
|
||||
t.Run("shell priority from run command", func(t *testing.T) {
|
||||
os.Setenv("WHEREAMI", "shell") //nolint:errcheck
|
||||
defer os.Unsetenv("WHEREAMI") //nolint:errcheck
|
||||
res := c.RunDockerComposeCmd("-f", "./fixtures/environment/env-interpolation/compose.yaml",
|
||||
"--project-directory", projectDir, "config")
|
||||
|
||||
res.Assert(t, icmd.Expected{Out: `IMAGE: default_env:shell`})
|
||||
})
|
||||
}
|
||||
|
||||
func TestCommentsInEnvFile(t *testing.T) {
|
||||
c := NewParallelE2eCLI(t, binDir)
|
||||
|
||||
projectDir := "./fixtures/environment/env-file-comments"
|
||||
|
||||
t.Run("comments in env files", func(t *testing.T) {
|
||||
c.RunDockerOrExitError("rmi", "env-file-comments")
|
||||
|
||||
c.RunDockerComposeCmd("-f", "./fixtures/environment/env-file-comments/compose.yaml",
|
||||
"--project-directory", projectDir, "up", "-d", "--build")
|
||||
|
||||
res := c.RunDockerComposeCmd("-f", "./fixtures/environment/env-file-comments/compose.yaml",
|
||||
"--project-directory", projectDir, "run", "--rm",
|
||||
"-e", "COMMENT", "-e", "NO_COMMENT", "env-file-comments")
|
||||
|
||||
res.Assert(t, icmd.Expected{Out: `COMMENT=1234`})
|
||||
res.Assert(t, icmd.Expected{Out: `NO_COMMENT=1234#5`})
|
||||
|
||||
c.RunDockerComposeCmd("--project-directory", projectDir, "down", "--rmi", "all")
|
||||
})
|
||||
}
|
||||
@@ -95,7 +95,7 @@ func TestLocalComposeUp(t *testing.T) {
|
||||
|
||||
res := c.RunDockerComposeCmd("-p", projectName, "ps")
|
||||
res.Assert(t, icmd.Expected{Out: `NAME COMMAND SERVICE STATUS PORTS`})
|
||||
res.Assert(t, icmd.Expected{Out: `compose-e2e-demo-web-1 "/dispatcher" web running (healthy) 0.0.0.0:90->80/tcp, :::90->80/tcp`})
|
||||
res.Assert(t, icmd.Expected{Out: `compose-e2e-demo-web-1 "/dispatcher" web running (healthy) 0.0.0.0:90->80/tcp`})
|
||||
res.Assert(t, icmd.Expected{Out: `compose-e2e-demo-db-1 "docker-entrypoint.s…" db running 5432/tcp`})
|
||||
})
|
||||
|
||||
|
||||
86
pkg/e2e/ddev_test.go
Normal file
86
pkg/e2e/ddev_test.go
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
Copyright 2020 Docker Compose CLI authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
const ddevVersion = "v1.19.1"
|
||||
|
||||
func TestComposeRunDdev(t *testing.T) {
|
||||
if !composeStandaloneMode {
|
||||
t.Skip("Not running on standalone mode.")
|
||||
}
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("Running on Windows. Skipping...")
|
||||
}
|
||||
_ = os.Setenv("DDEV_DEBUG", "true")
|
||||
|
||||
c := NewParallelE2eCLI(t, binDir)
|
||||
dir, err := os.MkdirTemp("", t.Name()+"-")
|
||||
assert.NilError(t, err)
|
||||
|
||||
// ddev needs to be able to find mkcert to figure out where certs are.
|
||||
_ = os.Setenv("PATH", fmt.Sprintf("%s:%s", os.Getenv("PATH"), dir))
|
||||
|
||||
siteName := filepath.Base(dir)
|
||||
|
||||
t.Cleanup(func() {
|
||||
_ = c.RunCmdInDir(dir, "./ddev", "delete", "-Oy")
|
||||
_ = c.RunCmdInDir(dir, "./ddev", "poweroff")
|
||||
_ = os.RemoveAll(dir)
|
||||
})
|
||||
|
||||
osName := "linux"
|
||||
if runtime.GOOS == "darwin" {
|
||||
osName = "macos"
|
||||
}
|
||||
|
||||
compressedFilename := fmt.Sprintf("ddev_%s-%s.%s.tar.gz", osName, runtime.GOARCH, ddevVersion)
|
||||
c.RunCmdInDir(dir, "curl", "-LO",
|
||||
fmt.Sprintf("https://github.com/drud/ddev/releases/download/%s/%s",
|
||||
ddevVersion,
|
||||
compressedFilename))
|
||||
|
||||
c.RunCmdInDir(dir, "tar", "-xzf", compressedFilename)
|
||||
|
||||
// Create a simple index.php we can test against.
|
||||
c.RunCmdInDir(dir, "sh", "-c", "echo '<?php\nprint \"ddev is working\";' >index.php")
|
||||
|
||||
c.RunCmdInDir(dir, "./ddev", "config", "--auto")
|
||||
c.RunCmdInDir(dir, "./ddev", "config", "global", "--use-docker-compose-from-path")
|
||||
vRes := c.RunCmdInDir(dir, "./ddev", "version")
|
||||
out := vRes.Stdout()
|
||||
fmt.Printf("ddev version: %s\n", out)
|
||||
|
||||
c.RunCmdInDir(dir, "./ddev", "poweroff")
|
||||
|
||||
c.RunCmdInDir(dir, "./ddev", "start", "-y")
|
||||
|
||||
curlRes := c.RunCmdInDir(dir, "curl", "-sSL", fmt.Sprintf("http://%s.ddev.site", siteName))
|
||||
out = curlRes.Stdout()
|
||||
fmt.Println(out)
|
||||
assert.Assert(c.test, strings.Contains(out, "ddev is working"), "Could not start project")
|
||||
}
|
||||
17
pkg/e2e/fixtures/build-test/tags/Dockerfile
Normal file
17
pkg/e2e/fixtures/build-test/tags/Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
||||
# Copyright 2020 Docker Compose CLI authors
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM nginx:alpine
|
||||
|
||||
RUN echo "SUCCESS"
|
||||
9
pkg/e2e/fixtures/build-test/tags/compose.yaml
Normal file
9
pkg/e2e/fixtures/build-test/tags/compose.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
services:
|
||||
nginx:
|
||||
image: build-test-tags
|
||||
build:
|
||||
context: .
|
||||
tags:
|
||||
- docker.io/docker/build-test-tags:1.0.0
|
||||
- other-image-name:v1.0.0
|
||||
|
||||
2
pkg/e2e/fixtures/environment/env-file-comments/.env
Normal file
2
pkg/e2e/fixtures/environment/env-file-comments/.env
Normal file
@@ -0,0 +1,2 @@
|
||||
COMMENT=1234#5
|
||||
NO_COMMENT="1234#5"
|
||||
18
pkg/e2e/fixtures/environment/env-file-comments/Dockerfile
Normal file
18
pkg/e2e/fixtures/environment/env-file-comments/Dockerfile
Normal file
@@ -0,0 +1,18 @@
|
||||
# Copyright 2020 Docker Compose CLI authors
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM alpine
|
||||
ENV COMMENT=Dockerfile
|
||||
ENV NO_COMMENT=Dockerfile
|
||||
CMD ["sh", "-c", "printenv", "|", "grep", "COMMENT"]
|
||||
@@ -0,0 +1,5 @@
|
||||
services:
|
||||
env-file-comments:
|
||||
build:
|
||||
context: .
|
||||
image: env-file-comments
|
||||
2
pkg/e2e/fixtures/environment/env-interpolation/.env
Normal file
2
pkg/e2e/fixtures/environment/env-interpolation/.env
Normal file
@@ -0,0 +1,2 @@
|
||||
WHEREAMI=Env File
|
||||
IMAGE=default_env:${WHEREAMI}
|
||||
@@ -0,0 +1,6 @@
|
||||
services:
|
||||
env-interpolation:
|
||||
image: bash
|
||||
environment:
|
||||
IMAGE: ${IMAGE}
|
||||
command: echo "$IMAGE"
|
||||
1
pkg/e2e/fixtures/environment/env-priority/.env
Normal file
1
pkg/e2e/fixtures/environment/env-priority/.env
Normal file
@@ -0,0 +1 @@
|
||||
WHEREAMI=Env File
|
||||
1
pkg/e2e/fixtures/environment/env-priority/.env.override
Normal file
1
pkg/e2e/fixtures/environment/env-priority/.env.override
Normal file
@@ -0,0 +1 @@
|
||||
WHEREAMI=override
|
||||
17
pkg/e2e/fixtures/environment/env-priority/Dockerfile
Normal file
17
pkg/e2e/fixtures/environment/env-priority/Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
||||
# Copyright 2020 Docker Compose CLI authors
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM alpine
|
||||
ENV WHEREAMI=Dockerfile
|
||||
CMD ["printenv", "WHEREAMI"]
|
||||
@@ -0,0 +1,7 @@
|
||||
services:
|
||||
env-compose-priority:
|
||||
image: env-compose-priority
|
||||
build:
|
||||
context: .
|
||||
environment:
|
||||
WHEREAMI: "Compose File"
|
||||
3
pkg/e2e/fixtures/environment/env-priority/compose.yaml
Normal file
3
pkg/e2e/fixtures/environment/env-priority/compose.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
services:
|
||||
env-compose-priority:
|
||||
image: env-compose-priority
|
||||
@@ -167,6 +167,19 @@ func (c *E2eCLI) NewCmd(command string, args ...string) icmd.Cmd {
|
||||
}
|
||||
}
|
||||
|
||||
// NewCmdWithEnv creates a cmd object configured with the test environment set with additional env vars
|
||||
func (c *E2eCLI) NewCmdWithEnv(envvars []string, command string, args ...string) icmd.Cmd {
|
||||
env := append(os.Environ(),
|
||||
append(envvars,
|
||||
"DOCKER_CONFIG="+c.ConfigDir,
|
||||
"KUBECONFIG=invalid")...
|
||||
)
|
||||
return icmd.Cmd{
|
||||
Command: append([]string{command}, args...),
|
||||
Env: env,
|
||||
}
|
||||
}
|
||||
|
||||
// MetricsSocket get the path where test metrics will be sent
|
||||
func (c *E2eCLI) MetricsSocket() string {
|
||||
return filepath.Join(c.ConfigDir, "./docker-cli.sock")
|
||||
@@ -192,6 +205,17 @@ func (c *E2eCLI) RunCmd(args ...string) *icmd.Result {
|
||||
return res
|
||||
}
|
||||
|
||||
// RunCmdInDir runs a command in a given dir, expects no error and returns a result
|
||||
func (c *E2eCLI) RunCmdInDir(dir string, args ...string) *icmd.Result {
|
||||
fmt.Printf("\t[%s] %s\n", c.test.Name(), strings.Join(args, " "))
|
||||
assert.Assert(c.test, len(args) >= 1, "require at least one command in parameters")
|
||||
cmd := c.NewCmd(args[0], args[1:]...)
|
||||
cmd.Dir = dir
|
||||
res := icmd.RunCmd(cmd)
|
||||
res.Assert(c.test, icmd.Success)
|
||||
return res
|
||||
}
|
||||
|
||||
// RunDockerCmd runs a docker command, expects no error and returns a result
|
||||
func (c *E2eCLI) RunDockerCmd(args ...string) *icmd.Result {
|
||||
if len(args) > 0 && args[0] == compose.PluginName {
|
||||
|
||||
@@ -18,11 +18,14 @@ package e2e
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/icmd"
|
||||
)
|
||||
|
||||
func TestLocalComposeVolume(t *testing.T) {
|
||||
@@ -88,3 +91,30 @@ func TestLocalComposeVolume(t *testing.T) {
|
||||
assert.Assert(t, !strings.Contains(ls, "myvolume"))
|
||||
})
|
||||
}
|
||||
|
||||
func TestProjectVolumeBind(t *testing.T) {
|
||||
if composeStandaloneMode {
|
||||
t.Skip()
|
||||
}
|
||||
c := NewParallelE2eCLI(t, binDir)
|
||||
const projectName = "compose-e2e-project-volume-bind"
|
||||
|
||||
t.Run("up with build and no image name, volume", func(t *testing.T) {
|
||||
tmpDir, err := os.MkdirTemp("", projectName)
|
||||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
c.RunDockerComposeCmd("--project-directory", "fixtures/project-volume-bind-test", "--project-name", projectName, "down")
|
||||
|
||||
c.RunDockerOrExitError("volume", "rm", "-f", projectName+"_project_data").Assert(t, icmd.Success)
|
||||
cmd := c.NewCmdWithEnv([]string{"TEST_DIR=" + tmpDir},
|
||||
"docker", "compose", "--project-directory", "fixtures/project-volume-bind-test", "--project-name", projectName, "up", "-d")
|
||||
icmd.RunCmd(cmd).Assert(t, icmd.Success)
|
||||
defer c.RunDockerComposeCmd("--project-directory", "fixtures/project-volume-bind-test", "--project-name", projectName, "down")
|
||||
|
||||
c.RunCmd("sh", "-c", "echo SUCCESS > "+filepath.Join(tmpDir, "resultfile")).Assert(t, icmd.Success)
|
||||
|
||||
ret := c.RunDockerOrExitError("exec", "frontend", "bash", "-c", "cat /data/resultfile").Assert(t, icmd.Success)
|
||||
assert.Assert(t, strings.Contains(ret.Stdout(), "SUCCESS"))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -83,7 +83,10 @@ func (w *ttyWriter) Event(e Event) {
|
||||
last.Status = e.Status
|
||||
last.Text = e.Text
|
||||
last.StatusText = e.StatusText
|
||||
last.ParentID = e.ParentID
|
||||
// allow set/unset of parent, but not swapping otherwise prompt is flickering
|
||||
if last.ParentID == "" || e.ParentID == "" {
|
||||
last.ParentID = e.ParentID
|
||||
}
|
||||
w.events[e.ID] = last
|
||||
} else {
|
||||
e.startTime = time.Now()
|
||||
|
||||
Reference in New Issue
Block a user