Merge pull request #630 from tonistiigi/cleanup

golint and misspell cleanup
docker-18.09
Tibor Vass 2018-09-19 12:01:45 -07:00 committed by GitHub
commit cb0d51cca3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 35 additions and 44 deletions

27
cache/gc.go vendored
View File

@ -1,27 +0,0 @@
package cache
import (
"context"
"errors"
"time"
)
// GCPolicy defines policy for garbage collection
type GCPolicy struct {
MaxSize uint64
MaxKeepDuration time.Duration
}
// // CachePolicy defines policy for keeping a resource in cache
// type CachePolicy struct {
// Priority int
// LastUsed time.Time
// }
//
// func defaultCachePolicy() CachePolicy {
// return CachePolicy{Priority: 10, LastUsed: time.Now()}
// }
func (cm *cacheManager) GC(ctx context.Context) error {
return errors.New("GC not implemented")
}

2
cache/manager.go vendored
View File

@ -25,7 +25,6 @@ var (
type ManagerOpt struct {
Snapshotter snapshot.SnapshotterBase
GCPolicy GCPolicy
MetadataStore *metadata.Store
PruneRefChecker ExternalRefCheckerFunc
}
@ -40,7 +39,6 @@ type Accessor interface {
type Controller interface {
DiskUsage(ctx context.Context, info client.DiskUsageInfo) ([]*client.UsageInfo, error)
Prune(ctx context.Context, ch chan client.UsageInfo, info ...client.PruneInfo) error
GC(ctx context.Context) error
}
type Manager interface {

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

@ -26,7 +26,7 @@ type Builder interface {
// Solver provides a shared graph of all the vertexes currently being
// processed. Every vertex that is being solved needs to be loaded into job
// first. Vertex operations are invoked and progress tracking happends through
// first. Vertex operations are invoked and progress tracking happens through
// jobs.
type Solver struct {
mu sync.RWMutex

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

@ -18,7 +18,7 @@ import (
// DockerExporter implements containerd/images.Exporter to
// Docker Combined Image JSON + Filesystem Changeset Format v1.1
// https://github.com/moby/moby/blob/master/image/spec/v1.1.md#combined-image-json--filesystem-changeset-format
// The outputed tarball is also compatible wih OCI Image Format Specification
// The output tarball is also compatible with OCI Image Format Specification
type DockerExporter struct {
Name string
}

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
}

View File

@ -124,7 +124,7 @@ func (p *Puller) Pull(ctx context.Context) (*Pulled, error) {
childrenHandler := images.ChildrenHandler(p.ContentStore)
// Set any children labels for that content
childrenHandler = images.SetChildrenLabels(p.ContentStore, childrenHandler)
// Filter the childen by the platform
// Filter the children by the platform
childrenHandler = images.FilterPlatforms(childrenHandler, platform)
// Limit manifests pulled to the best match in an index
childrenHandler = images.LimitManifests(childrenHandler, platform, 1)