forked from buildpacks/imgutil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage.go
64 lines (57 loc) · 1.68 KB
/
image.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package imgutil
import (
"fmt"
"io"
"strings"
"time"
)
var NormalizedDateTime = time.Date(1980, time.January, 1, 0, 0, 1, 0, time.UTC)
type SaveDiagnostic struct {
ImageName string
Cause error
}
type SaveError struct {
Errors []SaveDiagnostic
}
func (e SaveError) Error() string {
var errors []string
for _, d := range e.Errors {
errors = append(errors, fmt.Sprintf("[%s: %s]", d.ImageName, d.Cause.Error()))
}
return fmt.Sprintf("failed to write image to the following tags: %s", strings.Join(errors, ","))
}
type Image interface {
Name() string
Rename(name string)
Label(string) (string, error)
Labels() (map[string]string, error)
SetLabel(string, string) error
RemoveLabel(string) error
Env(key string) (string, error)
SetEnv(string, string) error
SetEntrypoint(...string) error
SetWorkingDir(string) error
SetCmd(...string) error
SetOS(string) error
SetOSVersion(string) error
SetArchitecture(string) error
Rebase(string, Image) error
AddLayer(path string) error
AddLayerWithDiffID(path, diffID string) error
ReuseLayer(diffID string) error
// TopLayer returns the diff id for the top layer
TopLayer() (string, error)
// Save saves the image as `Name()` and any additional names provided to this method.
Save(additionalNames ...string) error
// Found tells whether the image exists in the repository by `Name()`.
Found() bool
// GetLayer retrieves layer by diff id. Returns a reader of the uncompressed contents of the layer.
GetLayer(diffID string) (io.ReadCloser, error)
Delete() error
CreatedAt() (time.Time, error)
Identifier() (Identifier, error)
OS() (string, error)
OSVersion() (string, error)
Architecture() (string, error)
}
type Identifier fmt.Stringer