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 15package v1 16 17import ( 18 "time" 19 20 digest "github.com/opencontainers/go-digest" 21) 22 23// ImageConfig defines the execution parameters which should be used as a base when running a container using an image. 24type ImageConfig struct { 25 // User defines the username or UID which the process in the container should run as. 26 User string `json:"User,omitempty"` 27 28 // ExposedPorts a set of ports to expose from a container running this image. 29 ExposedPorts map[string]struct{} `json:"ExposedPorts,omitempty"` 30 31 // Env is a list of environment variables to be used in a container. 32 Env []string `json:"Env,omitempty"` 33 34 // Entrypoint defines a list of arguments to use as the command to execute when the container starts. 35 Entrypoint []string `json:"Entrypoint,omitempty"` 36 37 // Cmd defines the default arguments to the entrypoint of the container. 38 Cmd []string `json:"Cmd,omitempty"` 39 40 // Volumes is a set of directories describing where the process is likely write data specific to a container instance. 41 Volumes map[string]struct{} `json:"Volumes,omitempty"` 42 43 // WorkingDir sets the current working directory of the entrypoint process in the container. 44 WorkingDir string `json:"WorkingDir,omitempty"` 45 46 // Labels contains arbitrary metadata for the container. 47 Labels map[string]string `json:"Labels,omitempty"` 48 49 // StopSignal contains the system call signal that will be sent to the container to exit. 50 StopSignal string `json:"StopSignal,omitempty"` 51} 52 53// RootFS describes a layer content addresses 54type RootFS struct { 55 // Type is the type of the rootfs. 56 Type string `json:"type"` 57 58 // DiffIDs is an array of layer content hashes (DiffIDs), in order from bottom-most to top-most. 59 DiffIDs []digest.Digest `json:"diff_ids"` 60} 61 62// History describes the history of a layer. 63type History struct { 64 // Created is the combined date and time at which the layer was created, formatted as defined by RFC 3339, section 5.6. 65 Created *time.Time `json:"created,omitempty"` 66 67 // CreatedBy is the command which created the layer. 68 CreatedBy string `json:"created_by,omitempty"` 69 70 // Author is the author of the build point. 71 Author string `json:"author,omitempty"` 72 73 // Comment is a custom message set when creating the layer. 74 Comment string `json:"comment,omitempty"` 75 76 // EmptyLayer is used to mark if the history item created a filesystem diff. 77 EmptyLayer bool `json:"empty_layer,omitempty"` 78} 79 80// Image is the JSON structure which describes some basic information about the image. 81// This provides the `application/vnd.oci.image.config.v1+json` mediatype when marshalled to JSON. 82type Image struct { 83 // Created is the combined date and time at which the image was created, formatted as defined by RFC 3339, section 5.6. 84 Created *time.Time `json:"created,omitempty"` 85 86 // Author defines the name and/or email address of the person or entity which created and is responsible for maintaining the image. 87 Author string `json:"author,omitempty"` 88 89 // Architecture is the CPU architecture which the binaries in this image are built to run on. 90 Architecture string `json:"architecture"` 91 92 // OS is the name of the operating system which the image is built to run on. 93 OS string `json:"os"` 94 95 // Config defines the execution parameters which should be used as a base when running a container using the image. 96 Config ImageConfig `json:"config,omitempty"` 97 98 // RootFS references the layer content addresses used by the image. 99 RootFS RootFS `json:"rootfs"` 100 101 // History describes the history of each layer. 102 History []History `json:"history,omitempty"` 103} 104