Skip to content

Commit

Permalink
Embedded other platform fields in image spec
Browse files Browse the repository at this point in the history
This makes sure that an index can be generated from an image spec.

`OSVersion` in particular is fairly important for Windows since Windows
can only run containers for the OS version it was built for, and
currently the only way to reliably get this is from the index.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
  • Loading branch information
cpuguy83 committed Jul 9, 2021
1 parent 0e20f8a commit 1dc8bba
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 34 deletions.
23 changes: 18 additions & 5 deletions config.md
Expand Up @@ -105,16 +105,29 @@ Note: Any OPTIONAL field MAY also be set to null, which is equivalent to being a
The CPU architecture which the binaries in this image are built to run on.
Configurations SHOULD use, and implementations SHOULD understand, values listed in the Go Language document for [`GOARCH`][go-environment].

- **variant** *string*, OPTIONAL

The variant of the specified CPU architecture.
Configurations SHOULD use, and implementations SHOULD understand, `variant` values listed in the [Platform Variants](image-index.md#platform-variants) table.

- **os** *string*, REQUIRED

The name of the operating system which the image is built to run on.
Configurations SHOULD use, and implementations SHOULD understand, values listed in the Go Language document for [`GOOS`][go-environment].

- **os.version** *string*, OPTIONAL

This OPTIONAL property specifies the version of the operating system targeted by the referenced blob.
Implementations MAY refuse to use manifests where `os.version` is not known to work with the host OS version.
Valid values are implementation-defined. e.g. `10.0.14393.1066` on `windows`.

- **os.features** *array of strings*, OPTIONAL

This OPTIONAL property specifies an array of strings, each specifying a mandatory OS feature.
When `os` is `windows`, image indexes SHOULD use, and implementations SHOULD understand the following values:

- `win32k`: image requires `win32k.sys` on the host (Note: `win32k.sys` is missing on Nano Server)

- **variant** *string*, OPTIONAL

The variant of the specified CPU architecture.
Configurations SHOULD use, and implementations SHOULD understand, `variant` values listed in the [Platform Variants](image-index.md#platform-variants) table.

- **config** *object*, OPTIONAL

The execution parameters which SHOULD be used as a base when running a container using the image.
Expand Down
16 changes: 10 additions & 6 deletions conversion.md
Expand Up @@ -47,18 +47,22 @@ These fields all affect the `annotations` of the runtime configuration, and are
| `os` | `annotations` | 1,2 |
| `architecture` | `annotations` | 1,3 |
| `variant` | `annotations` | 1,4 |
| `author` | `annotations` | 1,5 |
| `created` | `annotations` | 1,6 |
| `os.version` | `annotations` | 1,5 |
| `os.features` | `annotations` | 1,6 |
| `author` | `annotations` | 1,7 |
| `created` | `annotations` | 1,8 |
| `Config.Labels` | `annotations` | |
| `Config.StopSignal` | `annotations` | 1,7 |
| `Config.StopSignal` | `annotations` | 1,9 |

1. If a user has explicitly specified this annotation with `Config.Labels`, then the value specified in this field takes lower [precedence](#annotations) and the converter MUST instead use the value from `Config.Labels`.
2. The value of this field MUST be set as the value of `org.opencontainers.image.os` in `annotations`.
3. The value of this field MUST be set as the value of `org.opencontainers.image.architecture` in `annotations`.
4. The value of this field MUST be set as the value of `org.opencontainers.image.variant` in `annotations`.
5. The value of this field MUST be set as the value of `org.opencontainers.image.author` in `annotations`.
6. The value of this field MUST be set as the value of `org.opencontainers.image.created` in `annotations`.
7. The value of this field MUST be set as the value of `org.opencontainers.image.stopSignal` in `annotations`.
5. The value of this field MUST be set as the value of `org.opencontainers.image.os.version` in `annotations`.
6. The value of this field MUST be set as the value of `org.opencontainers.image.os.features` in `annotations`.
7. The value of this field MUST be set as the value of `org.opencontainers.image.author` in `annotations`.
8. The value of this field MUST be set as the value of `org.opencontainers.image.created` in `annotations`.
9. The value of this field MUST be set as the value of `org.opencontainers.image.stopSignal` in `annotations`.

## Parsed Fields

Expand Down
1 change: 1 addition & 0 deletions image-index.md
Expand Up @@ -90,6 +90,7 @@ For the media type(s) that this document is compatible with, see the [matrix][ma
See [Pre-Defined Annotation Keys](annotations.md#pre-defined-annotation-keys).

## Platform Variants

When the variant of the CPU is not listed in the table, values are implementation-defined and SHOULD be submitted to this specification for standardization.

| ISA/ABI | `architecture` | `variant` |
Expand Down
11 changes: 10 additions & 1 deletion schema/config-schema.json
Expand Up @@ -15,11 +15,20 @@
"type": "string"
},
"variant": {
"type": "string"
"type": "string"
},
"os": {
"type": "string"
},
"os.version": {
"type": "string"
},
"os.features": {
"type": "array",
"items": {
"type": "string"
}
},
"config": {
"type": "object",
"properties": {
Expand Down
36 changes: 18 additions & 18 deletions schema/fs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions schema/validator.go
Expand Up @@ -22,8 +22,8 @@ import (
"io/ioutil"
"regexp"

v1 "github.com/opencontainerd/image-spec/specs-go/v1"
digest "github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/xeipuuv/gojsonschema"
)
Expand Down Expand Up @@ -204,8 +204,8 @@ func validateConfig(r io.Reader) error {

func checkArchitecture(Architecture string, Variant string) {
validCombins := map[string][]string{
"arm": {"v6", "v7", "v8"},
"arm64": {"v8"},
"arm": {"", "v6", "v7", "v8"},
"arm64": {"", "v8"},
"386": {""},
"amd64": {""},
"ppc64": {""},
Expand Down Expand Up @@ -246,7 +246,7 @@ func checkPlatform(OS string, Architecture string) {
return
}
}
fmt.Printf("warning: combination of OS %q and architecture %q is invalid.\n", OS, Architecture)
fmt.Printf("warning: combination of os %q and architecture %q is invalid.\n", OS, Architecture)
}
}
fmt.Printf("warning: operating system %q of the bundle is not supported yet.\n", OS)
Expand Down
8 changes: 8 additions & 0 deletions specs-go/v1/config.go
Expand Up @@ -95,6 +95,14 @@ type Image struct {
// OS is the name of the operating system which the image is built to run on.
OS string `json:"os"`

// OSVersion is an optional field specifying the operating system
// version, for example on Windows `10.0.14393.1066`.
OSVersion string `json:"os.version,omitempty"`

// OSFeatures is an optional field specifying an array of strings,
// each listing a required OS feature (for example on Windows `win32k`).
OSFeatures []string `json:"os.features,omitempty"`

// Config defines the execution parameters which should be used as a base when running a container using the image.
Config ImageConfig `json:"config,omitempty"`

Expand Down

0 comments on commit 1dc8bba

Please sign in to comment.