update golint comments

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
docker-18.09
Tonis Tiigi 2018-09-18 10:49:25 -07:00
parent 301da72ce3
commit 0940cdc6fe
10 changed files with 32 additions and 12 deletions

View File

@ -7,12 +7,14 @@ import (
digest "github.com/opencontainers/go-digest"
)
// WithMetaResolver adds a metadata resolver to an image
func WithMetaResolver(mr ImageMetaResolver) ImageOption {
return imageOptionFunc(func(ii *ImageInfo) {
ii.metaResolver = mr
})
}
// ImageMetaResolver can resolve image config metadata from a reference
type ImageMetaResolver interface {
ResolveImageConfig(ctx context.Context, ref string, opt gw.ResolveImageConfigOpt) (digest.Digest, []byte, error)
}

View File

@ -11,6 +11,7 @@ import (
"github.com/pkg/errors"
)
// WorkerInfo contains information about a worker
type WorkerInfo struct {
ID string
Labels map[string]string
@ -18,6 +19,7 @@ type WorkerInfo struct {
GCPolicy []PruneInfo
}
// ListWorkers lists all active workers
func (c *Client) ListWorkers(ctx context.Context, opts ...ListWorkersOption) ([]*WorkerInfo, error) {
info := &ListWorkersInfo{}
for _, o := range opts {
@ -44,10 +46,12 @@ func (c *Client) ListWorkers(ctx context.Context, opts ...ListWorkersOption) ([]
return wi, nil
}
// ListWorkersOption is an option for a worker list query
type ListWorkersOption interface {
SetListWorkersOption(*ListWorkersInfo)
}
// ListWorkersInfo is a payload for worker list query
type ListWorkersInfo struct {
Filter []string
}

View File

@ -31,6 +31,7 @@ type containerdExecutor struct {
cgroupParent string
}
// New creates a new executor backed by connection to containerd API
func New(client *containerd.Client, root, cgroup string, networkProviders map[pb.NetMode]network.Provider) executor.Executor {
return containerdExecutor{
client: client,

View File

@ -29,6 +29,7 @@ type HealthConfig struct {
Retries int `json:",omitempty"`
}
// ImageConfig is a docker compatible config for an image
type ImageConfig struct {
specs.ImageConfig

View File

@ -7,6 +7,7 @@ import (
"google.golang.org/grpc/metadata"
)
// Hijack hijacks session to a connection.
func Hijack(stream controlapi.Control_SessionServer) (net.Conn, <-chan struct{}, map[string][]string) {
md, _ := metadata.FromIncomingContext(stream.Context())
c, closeCh := streamToConn(stream)

View File

@ -18,11 +18,13 @@ import (
"google.golang.org/grpc/metadata"
)
// AgentConfig is the config for a single exposed SSH agent
type AgentConfig struct {
ID string
Paths []string
}
// NewSSHAgentProvider creates a session provider that allows access to ssh agent
func NewSSHAgentProvider(confs []AgentConfig) (session.Attachable, error) {
m := map[string]source{}
for _, conf := range confs {

View File

@ -10,12 +10,12 @@ import (
"github.com/sirupsen/logrus"
)
type CacheID string
// NewInMemoryCacheManager creates a new in-memory cache manager
func NewInMemoryCacheManager() CacheManager {
return NewCacheManager(identity.NewID(), NewInMemoryCacheStorage(), NewInMemoryResultStorage())
}
// NewCacheManager creates a new cache manager with specific storage backend
func NewCacheManager(id string, storage CacheKeyStorage, results CacheResultStorage) CacheManager {
cm := &cacheManager{
id: id,

View File

@ -1,12 +1,25 @@
package pb
// InputIndex is incrementing index to the input vertex
type InputIndex int64
// OutputIndex is incrementing index that another vertex can depend on
type OutputIndex int64
// RootMount is a base mountpoint
const RootMount = "/"
// SkipOutput marks a disabled output index
const SkipOutput OutputIndex = -1
// Empty marks an input with no content
const Empty InputIndex = -1
// LLBBuilder is a special builder for BuildOp that directly builds LLB
const LLBBuilder InputIndex = -1
// LLBDefinitionInput marks an input that contains LLB definition for BuildOp
const LLBDefinitionInput = "buildkit.llb.definition"
// LLBDefaultDefinitionFile is a filename containing the definition in LLBBuilder
const LLBDefaultDefinitionFile = LLBDefinitionInput

View File

@ -11,6 +11,7 @@ import (
"github.com/pkg/errors"
)
// NewMultiProvider creates a new mutable provider with a base provider
func NewMultiProvider(base content.Provider) *MultiProvider {
return &MultiProvider{
base: base,
@ -18,12 +19,14 @@ func NewMultiProvider(base content.Provider) *MultiProvider {
}
}
// MultiProvider is a provider backed by a mutable map of providers
type MultiProvider struct {
mu sync.RWMutex
base content.Provider
sub map[digest.Digest]content.Provider
}
// ReaderAt returns a content.ReaderAt
func (mp *MultiProvider) ReaderAt(ctx context.Context, desc ocispec.Descriptor) (content.ReaderAt, error) {
mp.mu.RLock()
if p, ok := mp.sub[desc.Digest]; ok {
@ -37,6 +40,7 @@ func (mp *MultiProvider) ReaderAt(ctx context.Context, desc ocispec.Descriptor)
return mp.base.ReaderAt(ctx, desc)
}
// Add adds a new child provider for a specific digest
func (mp *MultiProvider) Add(dgst digest.Digest, p content.Provider) {
mp.mu.Lock()
defer mp.mu.Unlock()

View File

@ -21,11 +21,13 @@ type contextKeyT string
var contextKey = contextKeyT("buildkit/util/flightcontrol.progress")
// Group is a flightcontrol syncronization group
type Group struct {
mu sync.Mutex // protects m
m map[string]*call // lazily initialized
}
// Do executes a context function syncronized by the key
func (g *Group) Do(ctx context.Context, key string, fn func(ctx context.Context) (interface{}, error)) (v interface{}, err error) {
defer func() {
if errors.Cause(err) == errRetry {
@ -312,13 +314,3 @@ func (ps *progressState) close(pw progress.Writer) {
}
ps.mu.Unlock()
}
func WriteProgress(ctx context.Context, pw progress.Writer) error {
v := ctx.Value(contextKey)
p, ok := v.(*progressState)
if !ok {
return errors.Errorf("invalid context not from flightcontrol")
}
p.add(pw)
return nil
}