Skip to content

Commit 45e8036

Browse files
authored
Merge pull request #172 from runcom/export-types
Export types
2 parents 274680c + 4267a18 commit 45e8036

File tree

7 files changed

+310
-0
lines changed

7 files changed

+310
-0
lines changed

specs-go/descriptor.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2016 The Linux Foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package specs
16+
17+
// Descriptor describes the disposition of targeted content.
18+
type Descriptor struct {
19+
// MediaType contains the MIME type of the referenced object.
20+
MediaType string `json:"mediaType"`
21+
22+
// Digests is the digest of the targeted content.
23+
Digest string `json:"digest"`
24+
25+
// Size specifies the size in bytes of the blob
26+
Size int64 `json:"size"`
27+
}

specs-go/v1/config.go

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Copyright 2016 The Linux Foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package v1
16+
17+
// ImageConfig defines the execution parameters which should be used as a base when running a container using an image.
18+
type ImageConfig struct {
19+
// User defines the username or UID which the process in the container should run as.
20+
User string `json:"User"`
21+
22+
// Memory defines the memory limit.
23+
Memory int64 `json:"Memory"`
24+
25+
// MemorySwap defines the total memory usage limit (memory + swap).
26+
MemorySwap int64 `json:"MemorySwap"`
27+
28+
// CPUShares is the CPU shares (relative weight vs. other containers).
29+
CPUShares int64 `json:"CpuShares"`
30+
31+
// ExposedPorts a set of ports to expose from a container running this image.
32+
ExposedPorts map[string]struct{} `json:"ExposedPorts"`
33+
34+
// Env is a list of environment variables to be used in a container.
35+
Env []string `json:"Env"`
36+
37+
// Entrypoint defines a list of arguments to use as the command to execute when the container starts.
38+
EntryPoint []string `json:"EntryPoint"`
39+
40+
// Cmd defines the default arguments to the entry point of the container.
41+
Cmd []string `json:"Cmd"`
42+
43+
// Volumes is a set of directories which should be created as data volumes in a container running this image.
44+
Volumes map[string]struct{} `json:"Volumes"`
45+
46+
// WorkingDir sets the current working directory of the entry point process in the container.
47+
WorkingDir string `json:"WorkingDir"`
48+
}
49+
50+
// RootFS describes a layer content addresses
51+
type RootFS struct {
52+
// Type is the type of the rootfs.
53+
Type string `json:"type"`
54+
55+
// DiffIDs is an array of layer content hashes (DiffIDs), in order from bottom-most to top-most.
56+
DiffIDs []string `json:"diff_ids"`
57+
}
58+
59+
// History describes the history of a layer.
60+
type History struct {
61+
// Created is the creation time.
62+
Created string `json:"created"`
63+
64+
// CreatedBy is the command which created the layer.
65+
CreatedBy string `json:"created_by"`
66+
67+
// Author is the author of the build point.
68+
Author string `json:"author"`
69+
70+
// Comment is a custom message set when creating the layer.
71+
Comment string `json:"comment"`
72+
73+
// EmptyLayer is used to mark if the history item created a filesystem diff.
74+
EmptyLayer bool `json:"empty_layer"`
75+
}
76+
77+
// Image is the JSON structure which describes some basic information about the image.
78+
type Image struct {
79+
// Created defines an ISO-8601 formatted combined date and time at which the image was created.
80+
Created string `json:"created"`
81+
82+
// Author defines the name and/or email address of the person or entity which created and is responsible for maintaining the image.
83+
Author string `json:"author"`
84+
85+
// Architecture is the CPU architecture which the binaries in this image are built to run on.
86+
Architecture string `json:"architecture"`
87+
88+
// OS is the name of the operating system which the image is built to run on.
89+
OS string `json:"os"`
90+
91+
// Config defines the execution parameters which should be used as a base when running a container using the image.
92+
Config ImageConfig `json:"config"`
93+
94+
// RootFS references the layer content addresses used by the image.
95+
RootFS RootFS `json:"rootfs"`
96+
97+
// History describes the history of each layer.
98+
History []History `json:"history"`
99+
}

specs-go/v1/manifest.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2016 The Linux Foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package v1
16+
17+
import "github.com/opencontainers/image-spec/specs-go"
18+
19+
// Manifest defines a schema2 manifest
20+
type Manifest struct {
21+
specs.Versioned
22+
23+
// Config references a configuration object for a container, by digest.
24+
// The referenced configuration object is a JSON blob that the runtime uses to set up the container.
25+
Config specs.Descriptor `json:"config"`
26+
27+
// Layers is an indexed list of layers referenced by the manifest.
28+
Layers []specs.Descriptor `json:"layers"`
29+
30+
// Annotations contains arbitrary metadata for the manifest list.
31+
Annotations map[string]string `json:"annotations"`
32+
}

specs-go/v1/manifest_list.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright 2016 The Linux Foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package v1
16+
17+
import "github.com/opencontainers/image-spec/specs-go"
18+
19+
// Platform describes the platform which the image in the manifest runs on.
20+
type Platform struct {
21+
// Architecture field specifies the CPU architecture, for example
22+
// `amd64` or `ppc64`.
23+
Architecture string `json:"architecture"`
24+
25+
// OS specifies the operating system, for example `linux` or `windows`.
26+
OS string `json:"os"`
27+
28+
// OSVersion is an optional field specifying the operating system
29+
// version, for example `10.0.10586`.
30+
OSVersion string `json:"os.version,omitempty"`
31+
32+
// OSFeatures is an optional field specifying an array of strings,
33+
// each listing a required OS feature (for example on Windows `win32k`).
34+
OSFeatures []string `json:"os.features,omitempty"`
35+
36+
// Variant is an optional field specifying a variant of the CPU, for
37+
// example `ppc64le` to specify a little-endian version of a PowerPC CPU.
38+
Variant string `json:"variant,omitempty"`
39+
40+
// Features is an optional field specifying an array of strings, each
41+
// listing a required CPU feature (for example `sse4` or `aes`).
42+
Features []string `json:"features,omitempty"`
43+
}
44+
45+
// ManifestDescriptor describes a platform specific manifest.
46+
type ManifestDescriptor struct {
47+
specs.Descriptor
48+
49+
// Platform describes the platform which the image in the manifest runs on.
50+
Platform Platform `json:"platform"`
51+
}
52+
53+
// ManifestList references manifests for various platforms.
54+
type ManifestList struct {
55+
specs.Versioned
56+
57+
// Manifests references platform specific manifests.
58+
Manifests []ManifestDescriptor `json:"manifests"`
59+
60+
// Annotations contains arbitrary metadata for the manifest list.
61+
Annotations map[string]string `json:"annotations"`
62+
}

specs-go/v1/mediatype.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2016 The Linux Foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package v1
16+
17+
const (
18+
// MediaTypeDescriptor specifies the mediaType for a content descriptor.
19+
MediaTypeDescriptor = "application/vnd.oci.descriptor.v1+json"
20+
21+
// MediaTypeImageManifest specifies the mediaType for an image manifest.
22+
MediaTypeImageManifest = "application/vnd.oci.image.manifest.v1+json"
23+
24+
// MediaTypeImageManifestList specifies the mediaType for an image manifest list.
25+
MediaTypeImageManifestList = "application/vnd.oci.image.manifest.list.v1+json"
26+
27+
// MediaTypeImageSerialization is the mediaType used for layers referenced by the manifest.
28+
MediaTypeImageSerialization = "application/vnd.oci.image.serialization.rootfs.tar.gzip"
29+
30+
// MediaTypeImageSerializationConfig specifies the mediaType for the image configuration.
31+
MediaTypeImageSerializationConfig = "application/vnd.oci.image.serialization.config.v1+json"
32+
)

specs-go/version.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2016 The Linux Foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package specs
16+
17+
import "fmt"
18+
19+
const (
20+
// VersionMajor is for an API incompatible changes
21+
VersionMajor = 0
22+
// VersionMinor is for functionality in a backwards-compatible manner
23+
VersionMinor = 3
24+
// VersionPatch is for backwards-compatible bug fixes
25+
VersionPatch = 0
26+
27+
// VersionDev indicates development branch. Releases will be empty string.
28+
VersionDev = "-dev"
29+
)
30+
31+
// Version is the specification version that the package types support.
32+
var Version = fmt.Sprintf("%d.%d.%d%s", VersionMajor, VersionMinor, VersionPatch, VersionDev)

specs-go/versioned.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2016 The Linux Foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package specs
16+
17+
// Versioned provides a struct with the manifest schemaVersion and mediaType.
18+
// Incoming content with unknown schema version can be decoded against this
19+
// struct to check the version.
20+
type Versioned struct {
21+
// SchemaVersion is the image manifest schema that this image follows
22+
SchemaVersion int `json:"schemaVersion"`
23+
24+
// MediaType is the media type of this schema.
25+
MediaType string `json:"mediaType,omitempty"`
26+
}

0 commit comments

Comments
 (0)