-
Notifications
You must be signed in to change notification settings - Fork 1
/
cib.go
56 lines (50 loc) · 2.55 KB
/
cib.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
// Package cib contains the primitives for container image building.
package cib
import (
"context"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb"
"github.com/moby/buildkit/frontend/gateway/client"
"github.com/moby/buildkit/util/apicaps"
specs "github.com/opencontainers/image-spec/specs-go/v1"
)
//go:generate mockgen -package cib_mock -destination mock/cib.go . Service
//go:generate mockgen -package cib_mock -destination mock/client.go github.com/moby/buildkit/frontend/gateway/client Client,Reference
// Service that wraps low-level BuildKit actions and provides a simple
// interface for container image build.
type Service interface {
// GetOpts returns client options.
GetOpts() map[string]string
// GetCaps returns the capabilities of the service.
GetCaps() apicaps.CapSet
// GetMarshalOpts returns options for marshalling LLB.
GetMarshalOpts() []llb.ConstraintsOpt
// GetResolveMode returns the resolution mode for base images.
GetResolveMode() (llb.ResolveMode, error)
// GetMetadataFileName returns the name for the metadata file.
GetMetadataFileName() string
// GetMetadata returns the contents of the metadata file.
GetMetadata() ([]byte, error)
// GetExcludes returns the list of paths to exclude from the build context.
GetExcludes() ([]string, error)
// GetBuildArgs returns the list of build-time variables.
GetBuildArgs() map[string]string
// GetBuildPlatform returns the build platform for the client.
GetBuildPlatform() *specs.Platform
// GetTargetPlatforms returns the list of target platforms for the image(s) being built.
GetTargetPlatforms() ([]*specs.Platform, error)
// GetCacheImports returns the list of external cache sources to use in the build.
GetCacheImports() ([]client.CacheOptionsEntry, error)
// GetIgnoreCache indicates whether the cache should be ignored.
GetIgnoreCache() bool
// Src returns the reference to the source code (created lazily).
Src() (ref client.Reference, err error)
// SrcState returns the LLB state of the source code (created lazily).
SrcState() (state llb.State, err error)
// FetchImageConfig returns the configuration of the image for the given platform.
FetchImageConfig(name string, platform *specs.Platform) (dockerfile2llb.Image, error)
// From creates a new LLB state from the specified base image.
From(base string, platform *specs.Platform, comment string) (llb.State, *dockerfile2llb.Image, error)
// Solve the provided LLB state and return a single reference from it.
Solve(ctx context.Context, state llb.State) (client.Reference, error)
}