Files
docker-cli/cli/command/container
Sebastiaan van Stijn b5d0d179e7 Add back validation for invalid label values on containers
This adds validation to `docker container run` / `docker container create`;

Validation of labels provided through flags was removed in 31dc5c0a9a,
after the validation was changed to fix labels without values, and to prevent
labels from being expanded with environment variables in 2b17f4c8a8

However, now empty label names from _files_ (`--label-file`) followed different
validation rules than labels passed through `--label`.

This patch adds back minimal validation for labels passed through the command-line

Before this patch:

```bash
docker container create \
  --name label \
  --label==with-leading-equal-sign \
  --label=without-value \
  --label=somelabel=somevalue \
  --label "  =  " \
  --label=with-quotes-in-value='{"foo"}' \
  --label='with"quotes"in-key=test' \
  busybox

docker container inspect --format '{{json .Config.Labels}}' label
```

```json
{
  "": "with-leading-equal-sign",
  "  ": "  ",
  "somelabel": "somevalue",
  "with\"quotes\"in-key": "test",
  "with-quotes-in-value": "{\"foo\"}",
  "without-value": ""
}
```

After this patch:

```bash
docker container create \
  --name label \
  --label==with-leading-equal-sign \
  --label=without-value \
  --label=somelabel=somevalue \
  --label "  =  " \
  --label=with-quotes-in-value='{"foo"}' \
  --label='with"quotes"in-key=test' \
  busybox

invalid argument "=with-leading-equal-sign" for "-l, --label" flag: invalid label format: "=with-leading-equal-sign"
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-19 03:02:06 +01:00
..
2018-06-08 18:24:26 +02:00
2018-05-11 16:49:43 -07:00
2019-02-12 09:14:50 +08:00
2017-10-26 12:21:02 -04:00
2018-05-11 16:49:43 -07:00
2019-02-04 08:32:47 -08:00
2018-10-23 17:05:44 +02:00
2018-06-08 18:24:26 +02:00
2018-05-11 16:49:43 -07:00
2018-05-11 16:49:43 -07:00
2018-05-11 16:49:43 -07:00
2018-06-08 18:24:26 +02:00
2018-05-11 16:49:43 -07:00
2018-06-08 18:24:26 +02:00
2019-02-04 08:32:47 -08:00
2018-05-11 16:49:43 -07:00
2018-05-11 16:49:43 -07:00
2018-09-05 00:01:16 +00:00
2018-06-08 18:24:26 +02:00
2018-05-11 16:49:43 -07:00
2018-05-11 16:49:43 -07:00
2019-02-04 08:32:47 -08:00
2018-10-23 17:05:44 +02:00
2018-05-11 16:49:43 -07:00
2018-05-11 16:49:43 -07:00
2019-02-12 09:14:50 +08:00
2019-02-12 09:14:50 +08:00
2018-05-11 16:49:43 -07:00
2018-06-08 18:24:26 +02:00
2018-05-11 16:49:43 -07:00
2018-05-11 16:49:43 -07:00