Skip to content
This repository has been archived by the owner on Aug 14, 2020. It is now read-only.

spec: Define image format string #586

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion discovery/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ func NewAppFromString(app string) (*App, error) {
if err != nil {
return nil, err
}
labels[*labelName] = val[0]
labelValue, err := url.QueryUnescape(val[0])
if err != nil {
return nil, err
}
labels[*labelName] = labelValue
}
a, err := NewApp(name, labels)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions discovery/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ func TestNewAppFromString(t *testing.T) {
false,
},
{
"example.com/app:1.2.3,special=!*'();@&+$/?#[],channel=beta",
// URL escaped !*'();@&+$/?#[]
"example.com/app:1.2.3,special=%21%2A%27%28%29%3B%40%26%2B%24%2F%3F%23%5B%5D%C2%BC%C2%B5%C3%9F,channel=beta",

&App{
Name: "example.com/app",
Labels: map[types.ACIdentifier]string{
"version": "1.2.3",
"special": "!*'();@&+$/?#[]",
"special": "!*'();@&+$/?#[]¼µß",
"channel": "beta",
},
},
Expand Down
26 changes: 26 additions & 0 deletions spec/extras/imageformat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Image format string

This specification defines an image format string to use to reference an image. It can be used by discovery or by an ACI to let the user define the image to discovery, execute etc...

An image format string consists of an image name and a set of labels with this format:

```
name[:versionvalue][,labelname=labelvalue][,labelname=labelvalue]...
```

Where:
* name (string, required) a human-readable name for an App Container Image (string, restricted to the AC Identifier formatting)
* versionvalue (string, optional) is a shortcut to define a version label. Writing `name:versionvalue` is the same of writing `name,version=versionvalue`
* labelname=labelvalue (optional) A label definition, must have two key-value pairs: *labelname* is restricted to the AC Identifier formatting and *labelvalue* is an arbitrary string.

Since *labelvalue* (and *versionvalue*) can be an arbitrary string it MUST be URL escaped (percent encoded) (http://tools.ietf.org/html/rfc3986#section-2) with UTF-8 encoding.


### Examples

An image format string for an image with name "example.com/reduce-worker" with version "0.1.0+gitabcdef" will be:

`example.com/reduce-worker:0.1.0%2Bgitabcdef` or
`example.com/reduce-worker,version=0.1.0%2Bgitabcdef`

Note that the `+` in the *versionvalue* has been replace by `%2B` since the label value MUST be URL encoded.