1 // Copyright 2018 Google LLC All Rights Reserved. 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 ( 18 "github.com/google/go-containerregistry/pkg/v1/types" 19 ) 20 21 // Image defines the interface for interacting with an OCI v1 image. 22 type Image interface { 23 // Layers returns the ordered collection of filesystem layers that comprise this image. 24 // The order of the list is oldest/base layer first, and most-recent/top layer last. 25 Layers() ([]Layer, error) 26 27 // MediaType of this image's manifest. 28 MediaType() (types.MediaType, error) 29 30 // Size returns the size of the manifest. 31 Size() (int64, error) 32 33 // ConfigName returns the hash of the image's config file, also known as 34 // the Image ID. 35 ConfigName() (Hash, error) 36 37 // ConfigFile returns this image's config file. 38 ConfigFile() (*ConfigFile, error) 39 40 // RawConfigFile returns the serialized bytes of ConfigFile(). 41 RawConfigFile() ([]byte, error) 42 43 // Digest returns the sha256 of this image's manifest. 44 Digest() (Hash, error) 45 46 // Manifest returns this image's Manifest object. 47 Manifest() (*Manifest, error) 48 49 // RawManifest returns the serialized bytes of Manifest() 50 RawManifest() ([]byte, error) 51 52 // LayerByDigest returns a Layer for interacting with a particular layer of 53 // the image, looking it up by "digest" (the compressed hash). 54 LayerByDigest(Hash) (Layer, error) 55 56 // LayerByDiffID is an analog to LayerByDigest, looking up by "diff id" 57 // (the uncompressed hash). 58 LayerByDiffID(Hash) (Layer, error) 59 } 60