Sebastiaan van Stijn
6aa76111d9
Merge ced6336804
into a5fb752ecf
2024-09-18 15:34:58 +01:00
plaurent
aa2c2cd906
Allow for OomScoreAdj
...
Signed-off-by: plaurent <patrick@saint-laurent.us>
2024-07-19 13:02:01 -04:00
Sebastiaan van Stijn
2088c5963b
vendor: github.com/docker/docker 1a1f3cff45ec (master, v27.0-dev)
...
Rewrite local code to use the new container.Ulimit alias to start
transitioning away from direct uses of go-units.Ulimit.
full diff: https://github.com/docker/docker/compare/v27.0.0-rc.2...1a1f3cff45ec5aba4a520fae88b4f929eab8b3e8
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-20 13:04:54 +02:00
Rob Murray
94f9de5928
Handle networks.driver_opts for a service
...
These are endpoint-specific driver options...
services:
myservice:
image: myimage
networks:
mynet:
driver_opts:
"option1": "value1"
The API has had support for a long time, it's only recently been
added to compose (unreleased right now).
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-07 08:20:43 +00:00
Casey Korver
d4491fc093
Correct typos in the cli/ folder
...
Signed-off-by: Casey Korver <casey@korver.dev>
2024-06-04 03:08:56 +00:00
Brian Goff
5400a48aaf
Plumb contexts through commands
...
This is to prepare for otel support.
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-12 22:30:16 +01:00
Sebastiaan van Stijn
539537ddf5
vendor: github.com/docker/docker cfdca8dc1d4c (v25.0.0-dev)
...
also added nolint:staticcheck to spec.Networks refs
full diff: https://github.com/docker/docker/compare/v25.0.0-beta.1...cfdca8dc1d4c84ee235f395a011ca62315c957a7
Co-authored-by: Albin Kerouanton <albinker@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-24 09:50:12 +01:00
Sebastiaan van Stijn
9c0c49a5f2
golangci-lint: revive: enable empty-lines
...
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-20 19:52:45 +01:00
Sebastiaan van Stijn
8e9aec6904
golangci-lint: revive: enable import-shadowing
...
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-20 19:52:41 +01:00
Sebastiaan van Stijn
888df09879
linting: address assorted issues found by gocritic
...
internal/test/builders/config.go:36:15: captLocal: `ID' should not be capitalized (gocritic)
func ConfigID(ID string) func(config *swarm.Config) {
^
internal/test/builders/secret.go:45:15: captLocal: `ID' should not be capitalized (gocritic)
func SecretID(ID string) func(secret *swarm.Secret) {
^
internal/test/builders/service.go:21:16: captLocal: `ID' should not be capitalized (gocritic)
func ServiceID(ID string) func(*swarm.Service) {
^
cli/command/image/formatter_history.go💯 15: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(c.h.CreatedBy, "\t", " ", -1)` (gocritic)
createdBy := strings.Replace(c.h.CreatedBy, "\t", " ", -1)
^
e2e/image/push_test.go:246:34: badCall: suspicious Join on 1 argument (gocritic)
assert.NilError(t, os.RemoveAll(filepath.Join(dir.Join("trust"))))
^
e2e/image/push_test.go:313:34: badCall: suspicious Join on 1 argument (gocritic)
assert.NilError(t, os.RemoveAll(filepath.Join(dir.Join("trust"))))
^
cli/config/configfile/file_test.go:185:2: assignOp: replace `c.GetAllCallCount = c.GetAllCallCount + 1` with `c.GetAllCallCount++` (gocritic)
c.GetAllCallCount = c.GetAllCallCount + 1
^
cli/command/context/inspect_test.go:20:58: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(si.MetadataPath, `\`, `\\`, -1)` (gocritic)
expected = strings.Replace(expected, "<METADATA_PATH>", strings.Replace(si.MetadataPath, `\`, `\\`, -1), 1)
^
cli/command/context/inspect_test.go:21:53: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(si.TLSPath, `\`, `\\`, -1)` (gocritic)
expected = strings.Replace(expected, "<TLS_PATH>", strings.Replace(si.TLSPath, `\`, `\\`, -1), 1)
^
cli/command/container/formatter_stats.go:119:46: captLocal: `Stats' should not be capitalized (gocritic)
func statsFormatWrite(ctx formatter.Context, Stats []StatsEntry, osType string, trunc bool) error {
^
cli/command/container/stats_helpers.go:209:4: assignOp: replace `blkRead = blkRead + bioEntry.Value` with `blkRead += bioEntry.Value` (gocritic)
blkRead = blkRead + bioEntry.Value
^
cli/command/container/stats_helpers.go:211:4: assignOp: replace `blkWrite = blkWrite + bioEntry.Value` with `blkWrite += bioEntry.Value` (gocritic)
blkWrite = blkWrite + bioEntry.Value
^
cli/command/registry/formatter_search.go:67:10: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(c.s.Description, "\n", " ", -1)` (gocritic)
desc := strings.Replace(c.s.Description, "\n", " ", -1)
^
cli/command/registry/formatter_search.go:68:9: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(desc, "\r", " ", -1)` (gocritic)
desc = strings.Replace(desc, "\r", " ", -1)
^
cli/command/service/list_test.go:164:5: assignOp: replace `tc.doc = tc.doc + " with quiet"` with `tc.doc += " with quiet"` (gocritic)
tc.doc = tc.doc + " with quiet"
^
cli/command/service/progress/progress.go:274:11: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(errMsg, "\n", " ", -1)` (gocritic)
errMsg = strings.Replace(errMsg, "\n", " ", -1)
^
cli/manifest/store/store.go:153:9: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(fileName, "/", "_", -1)` (gocritic)
return strings.Replace(fileName, "/", "_", -1)
^
cli/manifest/store/store.go:152:14: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(ref, ":", "-", -1)` (gocritic)
fileName := strings.Replace(ref, ":", "-", -1)
^
cli/command/plugin/formatter.go:79:10: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(c.p.Config.Description, "\n", "", -1)` (gocritic)
desc := strings.Replace(c.p.Config.Description, "\n", "", -1)
^
cli/command/plugin/formatter.go:80:9: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(desc, "\r", "", -1)` (gocritic)
desc = strings.Replace(desc, "\r", "", -1)
^
cli/compose/convert/service.go:642:23: captLocal: `DNS' should not be capitalized (gocritic)
func convertDNSConfig(DNS []string, DNSSearch []string) *swarm.DNSConfig {
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-20 16:02:16 +01:00
Sebastiaan van Stijn
d0dee3cebe
linting: Consider pre-allocating sliceVar (prealloc)
...
While updating, also addressed some redundant fmt.Sprintf()
opts/throttledevice.go:86:2: Consider pre-allocating `out` (prealloc)
var out []string
^
opts/ulimit.go:37:2: Consider pre-allocating `out` (prealloc)
var out []string
^
opts/ulimit.go:47:2: Consider pre-allocating `ulimits` (prealloc)
var ulimits []*units.Ulimit
^
opts/weightdevice.go:68:2: Consider pre-allocating `out` (prealloc)
var out []string
^
cli/context/store/metadatastore.go:96:2: Consider pre-allocating `res` (prealloc)
var res []Metadata
^
cli/context/store/store.go:127:2: Consider pre-allocating `names` (prealloc)
var names []string
^
cli/compose/loader/loader.go:223:2: Consider pre-allocating `keys` (prealloc)
var keys []string
^
cli/compose/loader/loader.go:397:2: Consider pre-allocating `services` (prealloc)
var services []types.ServiceConfig
^
cli/command/stack/loader/loader.go:63:2: Consider pre-allocating `msgs` (prealloc)
var msgs []string
^
cli/command/stack/loader/loader.go:118:2: Consider pre-allocating `configFiles` (prealloc)
var configFiles []composetypes.ConfigFile
^
cli/command/formatter/container.go:245:2: Consider pre-allocating `joinLabels` (prealloc)
var joinLabels []string
^
cli/command/formatter/container.go:265:2: Consider pre-allocating `mounts` (prealloc)
var mounts []string
^
cli/command/formatter/container.go:316:2: Consider pre-allocating `result` (prealloc)
var result []string
^
cli/command/formatter/displayutils.go:43:2: Consider pre-allocating `display` (prealloc)
var (
^
cli/command/formatter/volume.go:103:2: Consider pre-allocating `joinLabels` (prealloc)
var joinLabels []string
^
cli-plugins/manager/manager_test.go:49:2: Consider pre-allocating `dirs` (prealloc)
var dirs []string
^
cli/command/swarm/init.go:69:2: Consider pre-allocating `defaultAddrPool` (prealloc)
var defaultAddrPool []string
^
cli/command/manifest/push.go:195:2: Consider pre-allocating `blobReqs` (prealloc)
var blobReqs []manifestBlob
^
cli/command/secret/formatter.go:111:2: Consider pre-allocating `joinLabels` (prealloc)
var joinLabels []string
^
cli/command/network/formatter.go:104:2: Consider pre-allocating `joinLabels` (prealloc)
var joinLabels []string
^
cli/command/context/list.go:52:2: Consider pre-allocating `contexts` (prealloc)
var contexts []*formatter.ClientContext
^
cli/command/config/formatter.go:104:2: Consider pre-allocating `joinLabels` (prealloc)
var joinLabels []string
^
cli/command/trust/common_test.go:23:2: Consider pre-allocating `targetNames` (prealloc)
var targetNames []string
^
cli/command/service/generic_resource_opts.go:55:2: Consider pre-allocating `generic` (prealloc)
var generic []swarm.GenericResource
^
cli/command/service/generic_resource_opts.go:98:2: Consider pre-allocating `l` (prealloc)
var l []swarm.GenericResource
^
cli/command/service/opts.go:378:2: Consider pre-allocating `netAttach` (prealloc)
var netAttach []swarm.NetworkAttachmentConfig
^
cli/command/service/update.go:731:2: Consider pre-allocating `limits` (prealloc)
var limits []*units.Ulimit
^
cli/command/service/update.go:1315:2: Consider pre-allocating `newNetworks` (prealloc)
var newNetworks []swarm.NetworkAttachmentConfig
^
cli/command/service/update.go:1514:2: Consider pre-allocating `out` (prealloc)
var out []string
^
cli/compose/convert/service.go:713:2: Consider pre-allocating `ulimits` (prealloc)
var ulimits []*units.Ulimit
^
cli/compose/convert/volume.go:13:2: Consider pre-allocating `mounts` (prealloc)
var mounts []mount.Mount
^
cli/command/stack/swarm/list.go:39:2: Consider pre-allocating `stacks` (prealloc)
var stacks []*formatter.Stack
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-20 16:02:16 +01:00
Brian Goff
defa52b8c6
stacks: Add support for start interval
...
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-20 18:42:59 +02:00
Sebastiaan van Stijn
ced6336804
opts: ParseRestartPolicy: improve validation of max restart-counts
...
Use the new container.ValidateRestartPolicy utility to verify if a max-restart-count
is allowed for the given restart-policy.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-28 23:05:31 +02:00
Sebastiaan van Stijn
d68b361538
cli/compose/convert: convertEnvironment: sort results
...
All users of this function sorted the results afterwards, so let's
do it as part of the function itself.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-12 19:03:59 +02:00
Sebastiaan van Stijn
f4bde68694
replace some basic uses of fmt.Sprintf()
...
Really tiny gains here, and doesn't significantly impact readability:
BenchmarkSprintf
BenchmarkSprintf-10 11528700 91.59 ns/op 32 B/op 1 allocs/op
BenchmarkConcat
BenchmarkConcat-10 100000000 11.76 ns/op 0 B/op 0 allocs/op
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-12 19:03:49 +02:00
Sebastiaan van Stijn
3bed830a27
cli/compose: use strings.Cut
...
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-29 15:19:31 +01:00
Sebastiaan van Stijn
616124525e
format go with gofumpt (with -lang=1.19)
...
Looks like the linter uses an explicit -lang, which (for go1.19)
results in some additional formatting for octal values.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-30 19:14:36 +02:00
ollypom
3997f3431f
Added Swarm Job support to Stack Deploy
...
Added the support for both `global-job` and `replicated-job` to Docker
stack deploy.
Signed-off-by: ollypom <oppomeroy@gmail.com>
2022-05-17 22:30:22 +02:00
Albin Kerouanton
940907951b
Support ulimits in docker stack deploy
...
This is related to moby/moby 40639.
Signed-off-by: Albin Kerouanton <albin@akerouanton.name>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-09-10 14:59:02 +02:00
Sebastiaan van Stijn
190c64b415
Service cap-add/cap-drop: improve handling of combinations and special "ALL" value
...
When creating and updating services, we need to avoid unneeded service churn.
The interaction of separate lists to "add" and "drop" capabilities, a special
("ALL") capability, as well as a "relaxed" format for accepted capabilities
(case-insensitive, `CAP_` prefix optional) make this rather involved.
This patch updates how we handle `--cap-add` / `--cap-drop` when _creating_ as
well as _updating_, with the following rules/assumptions applied:
- both existing (service spec) and new (values passed through flags or in
the compose-file) are normalized and de-duplicated before use.
- the special "ALL" capability is equivalent to "all capabilities" and taken
into account when normalizing capabilities. Combining "ALL" capabilities
and other capabilities is therefore equivalent to just specifying "ALL".
- adding capabilities takes precedence over dropping, which means that if
a capability is both set to be "dropped" and to be "added", it is removed
from the list to "drop".
- the final lists should be sorted and normalized to reduce service churn
- no validation of capabilities is handled by the client. Validation is
delegated to the daemon/server.
When deploying a service using a docker-compose file, the docker-compose file
is *mostly* handled as being "declarative". However, many of the issues outlined
above also apply to compose-files, so similar handling is applied to compose
files as well to prevent service churn.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-09-08 14:38:35 +02:00
Olli Janatuinen
0db61ff6da
stack: Support cap_add and cap_drop on services
...
Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
Signed-off-by: Albin Kerouanton <albin@akerouanton.name>
2020-09-08 14:24:52 +02:00
Sebastiaan van Stijn
851eeb9639
Add support for pids limit in stacks (swarm)
...
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-06-18 21:25:08 +02:00
Sebastiaan van Stijn
0d57a400b3
vendor: docker/docker aaf470eca7b588aa19e6681bff8bf08d17be1bf2
...
full diff: 41ac6bef8d...aaf470eca7
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-06-15 13:32:53 +02:00
Silvin Lubecki
d640f44df3
cli/compose/convert: result 1 (error) is always nil (unparam)
...
cli/compose/convert/service.go:592:76: convertDNSConfig - result 1 (error) is always nil (unparam)
cli/compose/convert/service.go:538:110: convertEndpointSpec - result 1 (error) is always nil (unparam)
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-31 19:22:20 +01:00
Drew Erny
42ec51e1ae
add support for config credentialspecs to compose
...
Signed-off-by: Drew Erny <drew.erny@docker.com>
2019-04-12 11:17:34 -05:00
Sebastiaan van Stijn
6511da877f
Add support for using Configs as CredentialSpecs in services
...
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-04-12 11:17:29 -05:00
Sebastiaan van Stijn
f620349837
Add systctl support for services
...
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-19 13:33:32 +01:00
Olli Janatuinen
6347ab315b
Add maximum replicas per node support to stack version 3.8
...
Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
2019-02-19 11:25:12 +02:00
Joffrey F
e7788d6f9a
Allow marshalling of Compose config to JSON
...
Signed-off-by: Joffrey F <joffrey@docker.com>
2018-09-10 11:16:05 -07:00
Arash Deshmeh
71d650ee17
refactored cli/compose and cli/command/trust to use sort.Slice and removed custom types used for sorting
...
Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
2018-07-08 15:08:17 -04:00
Vincent Demeester
cc26da94ed
Add `init` support in 3.7 schema
...
> Run an init inside the container that forwards signals and reaps
processes
This is supported on `run` and now on Swarm services too, so it's also
possible to have in on a composefile :).
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-06-25 11:13:32 +02:00
Vincent Demeester
4e6e5d583c
Support for rollback config in compose 3.7
...
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-05-29 11:37:51 +02:00
Daniel Nephin
b4c108a385
Fix named network in compose file
...
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-12 15:15:27 -04:00
Daniel Nephin
9da2602f38
Fix external networks
...
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-12-11 11:29:49 -05:00
Renaud Gaubert
1ff73f867d
Added support of Generic resources in compose file
...
Signed-off-by: Renaud Gaubert <renaud.gaubert@gmail.com>
2017-11-28 21:52:09 +01:00
Ilya Sotkov
4f7f3d2f61
Add secret.name and config.name in compose.
...
Signed-off-by: Ilya Sotkov <ilya@sotkov.com>
2017-11-22 13:18:05 +02:00
Simon Ferquel
47cf2ea683
Add isolation mode on service update/create and compose files
...
Signed-off-by: Simon Ferquel <simon.ferquel@docker.com>
2017-11-17 15:31:13 +01:00
Daniel Nephin
a68c940f1a
Remove duplication in compose/convert
...
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-11-10 15:56:11 -05:00
Sebastiaan van Stijn
dbdf8f6468
Preserve sort-order of extra hosts, and allow duplicate entries
...
Extra hosts (`extra_hosts` in compose-file, or `--hosts` in services) adds
custom host/ip mappings to the container's `/etc/hosts`.
The current implementation used a `map[string]string{}` as intermediate
storage, and sorted the results alphabetically when converting to a service-spec.
As a result, duplicate hosts were removed, and order of host/ip mappings was not
preserved (in case the compose-file used a list instead of a map).
According to the **host.conf(5)** man page (http://man7.org/linux/man-pages/man5/host.conf.5.html )
multi Valid values are on and off. If set to on, the resolver
library will return all valid addresses for a host that
appears in the /etc/hosts file, instead of only the first.
This is off by default, as it may cause a substantial
performance loss at sites with large hosts files.
Multiple entries for a host are allowed, and even required for some situations,
for example, to add mappings for IPv4 and IPv6 addreses for a host, as illustrated
by the example hosts file in the **hosts(5)** man page (http://man7.org/linux/man-pages/man5/hosts.5.html ):
# The following lines are desirable for IPv4 capable hosts
127.0.0.1 localhost
# 127.0.1.1 is often used for the FQDN of the machine
127.0.1.1 thishost.mydomain.org thishost
192.168.1.10 foo.mydomain.org foo
192.168.1.13 bar.mydomain.org bar
146.82.138.7 master.debian.org master
209.237.226.90 www.opensource.org
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
This patch changes the intermediate storage format to use a `[]string`, and only
sorts entries if the input format in the compose file is a mapping. If the input
format is a list, the original sort-order is preserved.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-10-30 01:48:09 +01:00
pnagy
27e8bdf32b
sort secrets and configs to ensure idempotence
...
`docker stack deploy` keeps restarting services it doesn't need to (no changes)
because the entries' order gets randomized at some previous (de)serialization.
Maybe it would be worth looking into this at a higher level and ensure
all (de)serialization happens in an ordered collection.
This quick fix sorts secrets and configs (in place, mutably) which ensures the
same order for each run.
Based on
https://github.com/moby/moby/pull/30506
Fixes
https://github.com/moby/moby/issues/34746
Signed-off-by: Peter Nagy <xificurC@gmail.com>
2017-09-08 16:09:48 +02:00
Simon Ferquel
a0113c3a44
updated vendoring
...
Signed-off-by: Simon Ferquel <simon.ferquel@docker.com>
2017-09-01 19:41:06 -04:00
Li Yi
e02fcfd34e
Change the type of interval, timeout and start_period of healthcheck from string to * time.Duration
...
Signed-off-by: Li Yi <denverdino@gmail.com>
2017-08-30 23:39:12 +08:00
Sebastiaan van Stijn
1cd402b192
Merge pull request #360 from akalipetis/compose-update-order
...
Add support for update order in compose deployments
2017-08-01 22:24:48 +02:00
Antonis Kalipetis
2950667f07
Support the "order" key in "update_config" for compose
...
Signed-off-by: Antonis Kalipetis <akalipetis@gmail.com>
2017-07-28 22:50:55 +03:00
Christophe Robin
b129a70b5c
Add support for stop-signal in stack command
...
Signed-off-by: Christophe Robin <crobin@nekoo.com>
2017-07-27 13:18:05 +09:00
Daniel Nephin
3724fb7f37
Add gosimple lint
...
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-06-14 16:55:08 -07:00
Aaron Lehmann
4d980880f3
Merge pull request #121 from nishanttotla/digest-pinning-stack-deploy
...
Enable client side digest pinning for stack deploy
2017-06-08 23:20:02 +03:00
Vincent Demeester
96dc07a8cf
Update ConvertService for external usage 👼
...
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2017-06-08 10:44:05 +02:00
Nishant Totla
f790e839fc
Change --no-resolve-image flag to --resolve-image string flag
...
Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
2017-06-07 12:30:11 -07:00
Nishant Totla
9f1bea2657
Enable client side digest pinning for stack deploy
...
Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
2017-06-07 12:30:11 -07:00