forked from moby/moby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request moby#29609 from dnephin/add-compose-file-package
Replace the vendored aanand/compose-file with a local copy
- Loading branch information
Showing
41 changed files
with
4,362 additions
and
465 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package interpolation | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/docker/docker/cli/compose/types" | ||
) | ||
|
||
var defaults = map[string]string{ | ||
"USER": "jenny", | ||
"FOO": "bar", | ||
} | ||
|
||
func defaultMapping(name string) (string, bool) { | ||
val, ok := defaults[name] | ||
return val, ok | ||
} | ||
|
||
func TestInterpolate(t *testing.T) { | ||
services := types.Dict{ | ||
"servicea": types.Dict{ | ||
"image": "example:${USER}", | ||
"volumes": []interface{}{"$FOO:/target"}, | ||
"logging": types.Dict{ | ||
"driver": "${FOO}", | ||
"options": types.Dict{ | ||
"user": "$USER", | ||
}, | ||
}, | ||
}, | ||
} | ||
expected := types.Dict{ | ||
"servicea": types.Dict{ | ||
"image": "example:jenny", | ||
"volumes": []interface{}{"bar:/target"}, | ||
"logging": types.Dict{ | ||
"driver": "bar", | ||
"options": types.Dict{ | ||
"user": "jenny", | ||
}, | ||
}, | ||
}, | ||
} | ||
result, err := Interpolate(services, "service", defaultMapping) | ||
assert.NoError(t, err) | ||
assert.Equal(t, expected, result) | ||
} | ||
|
||
func TestInvalidInterpolation(t *testing.T) { | ||
services := types.Dict{ | ||
"servicea": types.Dict{ | ||
"image": "${", | ||
}, | ||
} | ||
_, err := Interpolate(services, "service", defaultMapping) | ||
assert.EqualError(t, err, `Invalid interpolation format for "image" option in service "servicea": "${"`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# passed through | ||
FOO=1 | ||
|
||
# overridden in example2.env | ||
BAR=1 | ||
|
||
# overridden in full-example.yml | ||
BAZ=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
BAR=2 |
Oops, something went wrong.