Merge pull request #1577 from crosbymichael/lint-1
Update files based on go lint
This commit is contained in:
		| @@ -522,9 +522,5 @@ func createTarFile(ctx context.Context, path, extractDir string, hdr *tar.Header | |||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if err := chtimes(path, boundTime(latestTime(hdr.AccessTime, hdr.ModTime)), boundTime(hdr.ModTime)); err != nil { | 	return chtimes(path, boundTime(latestTime(hdr.AccessTime, hdr.ModTime)), boundTime(hdr.ModTime)) | ||||||
| 		return err |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	return nil |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -167,7 +167,7 @@ func TestSymlinks(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestBreakouts(t *testing.T) { | func TestBreakouts(t *testing.T) { | ||||||
| 	tc := TarContext{}.WithUidGid(os.Getuid(), os.Getgid()).WithModTime(time.Now().UTC()) | 	tc := TarContext{}.WithUIDGID(os.Getuid(), os.Getgid()).WithModTime(time.Now().UTC()) | ||||||
| 	expected := "unbroken" | 	expected := "unbroken" | ||||||
| 	unbrokenCheck := func(root string) error { | 	unbrokenCheck := func(root string) error { | ||||||
| 		b, err := ioutil.ReadFile(filepath.Join(root, "etc", "unbroken")) | 		b, err := ioutil.ReadFile(filepath.Join(root, "etc", "unbroken")) | ||||||
| @@ -480,7 +480,7 @@ func TestDiffApply(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestApplyTar(t *testing.T) { | func TestApplyTar(t *testing.T) { | ||||||
| 	tc := TarContext{}.WithUidGid(os.Getuid(), os.Getgid()).WithModTime(time.Now().UTC()) | 	tc := TarContext{}.WithUIDGID(os.Getuid(), os.Getgid()).WithModTime(time.Now().UTC()) | ||||||
| 	directoriesExist := func(dirs ...string) func(string) error { | 	directoriesExist := func(dirs ...string) func(string) error { | ||||||
| 		return func(root string) error { | 		return func(root string) error { | ||||||
| 			for _, d := range dirs { | 			for _, d := range dirs { | ||||||
| @@ -767,8 +767,8 @@ func TarFromWriterTo(wt WriterToTar) io.ReadCloser { | |||||||
|  |  | ||||||
| // TarContext is used to create tar records | // TarContext is used to create tar records | ||||||
| type TarContext struct { | type TarContext struct { | ||||||
| 	Uid int | 	UID int | ||||||
| 	Gid int | 	GID int | ||||||
|  |  | ||||||
| 	// ModTime sets the modtimes for all files, if nil the current time | 	// ModTime sets the modtimes for all files, if nil the current time | ||||||
| 	// is used for each file when it was written | 	// is used for each file when it was written | ||||||
| @@ -784,8 +784,8 @@ func (tc TarContext) newHeader(mode os.FileMode, name, link string, size int64) | |||||||
| 		size: size, | 		size: size, | ||||||
| 		modt: tc.ModTime, | 		modt: tc.ModTime, | ||||||
| 		hdr: &tar.Header{ | 		hdr: &tar.Header{ | ||||||
| 			Uid:    tc.Uid, | 			Uid:    tc.UID, | ||||||
| 			Gid:    tc.Gid, | 			Gid:    tc.GID, | ||||||
| 			Xattrs: tc.Xattrs, | 			Xattrs: tc.Xattrs, | ||||||
| 		}, | 		}, | ||||||
| 	} | 	} | ||||||
| @@ -837,10 +837,10 @@ func (ti tarInfo) Sys() interface{} { | |||||||
| 	return ti.hdr | 	return ti.hdr | ||||||
| } | } | ||||||
|  |  | ||||||
| func (tc TarContext) WithUidGid(uid, gid int) TarContext { | func (tc TarContext) WithUIDGID(uid, gid int) TarContext { | ||||||
| 	ntc := tc | 	ntc := tc | ||||||
| 	ntc.Uid = uid | 	ntc.UID = uid | ||||||
| 	ntc.Gid = gid | 	ntc.GID = gid | ||||||
| 	return ntc | 	return ntc | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -42,6 +42,7 @@ type unixSocketCredentials struct { | |||||||
| 	serverName string | 	serverName string | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // NewUnixSocketCredentials returns TransportCredentials for a local unix socket | ||||||
| func NewUnixSocketCredentials(uid, gid int) credentials.TransportCredentials { | func NewUnixSocketCredentials(uid, gid int) credentials.TransportCredentials { | ||||||
| 	return &unixSocketCredentials{uid, gid, "locahost"} | 	return &unixSocketCredentials{uid, gid, "locahost"} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -44,12 +44,7 @@ var namespacesCreateCommand = cli.Command{ | |||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return err | 			return err | ||||||
| 		} | 		} | ||||||
|  | 		return namespaces.Create(ctx, namespace, labels) | ||||||
| 		if err := namespaces.Create(ctx, namespace, labels); err != nil { |  | ||||||
| 			return err |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		return nil |  | ||||||
| 	}, | 	}, | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -47,9 +47,6 @@ var taskPsCommand = cli.Command{ | |||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		if err := w.Flush(); err != nil { | 		return w.Flush() | ||||||
| 			return err |  | ||||||
| 		} |  | ||||||
| 		return nil |  | ||||||
| 	}, | 	}, | ||||||
| } | } | ||||||
|   | |||||||
| @@ -62,11 +62,13 @@ type Container struct { | |||||||
| 	Extensions map[string]types.Any | 	Extensions map[string]types.Any | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // RuntimeInfo holds runtime specific information | ||||||
| type RuntimeInfo struct { | type RuntimeInfo struct { | ||||||
| 	Name    string | 	Name    string | ||||||
| 	Options *types.Any | 	Options *types.Any | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Store interacts with the underlying container storage | ||||||
| type Store interface { | type Store interface { | ||||||
| 	Get(ctx context.Context, id string) (Container, error) | 	Get(ctx context.Context, id string) (Container, error) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -8,20 +8,25 @@ import ( | |||||||
| 	"github.com/opencontainers/go-digest" | 	"github.com/opencontainers/go-digest" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | // ReaderAt extends the standard io.ReaderAt interface with reporting of Size and io.Closer | ||||||
| type ReaderAt interface { | type ReaderAt interface { | ||||||
| 	io.ReaderAt | 	io.ReaderAt | ||||||
| 	io.Closer | 	io.Closer | ||||||
| 	Size() int64 | 	Size() int64 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Provider provides a reader interface for specific content | ||||||
| type Provider interface { | type Provider interface { | ||||||
| 	ReaderAt(ctx context.Context, dgst digest.Digest) (ReaderAt, error) | 	ReaderAt(ctx context.Context, dgst digest.Digest) (ReaderAt, error) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Ingester writes content | ||||||
| type Ingester interface { | type Ingester interface { | ||||||
| 	Writer(ctx context.Context, ref string, size int64, expected digest.Digest) (Writer, error) | 	Writer(ctx context.Context, ref string, size int64, expected digest.Digest) (Writer, error) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Info holds content specific information | ||||||
|  | // | ||||||
| // TODO(stevvooe): Consider a very different name for this struct. Info is way | // TODO(stevvooe): Consider a very different name for this struct. Info is way | ||||||
| // to general. It also reads very weird in certain context, like pluralization. | // to general. It also reads very weird in certain context, like pluralization. | ||||||
| type Info struct { | type Info struct { | ||||||
| @@ -32,6 +37,7 @@ type Info struct { | |||||||
| 	Labels    map[string]string | 	Labels    map[string]string | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Status of a content operation | ||||||
| type Status struct { | type Status struct { | ||||||
| 	Ref       string | 	Ref       string | ||||||
| 	Offset    int64 | 	Offset    int64 | ||||||
| @@ -81,6 +87,7 @@ type IngestManager interface { | |||||||
| 	Abort(ctx context.Context, ref string) error | 	Abort(ctx context.Context, ref string) error | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Writer handles the write of content into a content store | ||||||
| type Writer interface { | type Writer interface { | ||||||
| 	// Close is expected to be called after Commit() when commission is needed. | 	// Close is expected to be called after Commit() when commission is needed. | ||||||
| 	io.WriteCloser | 	io.WriteCloser | ||||||
| @@ -111,6 +118,7 @@ type Store interface { | |||||||
| // Opt is used to alter the mutable properties of content | // Opt is used to alter the mutable properties of content | ||||||
| type Opt func(*Info) error | type Opt func(*Info) error | ||||||
|  |  | ||||||
|  | // WithLabels allows labels to be set on content | ||||||
| func WithLabels(labels map[string]string) Opt { | func WithLabels(labels map[string]string) Opt { | ||||||
| 	return func(info *Info) error { | 	return func(info *Info) error { | ||||||
| 		info.Labels = labels | 		info.Labels = labels | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ var ( | |||||||
| 	} | 	} | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | // NewReader returns a io.Reader from a ReaderAt | ||||||
| func NewReader(ra ReaderAt) io.Reader { | func NewReader(ra ReaderAt) io.Reader { | ||||||
| 	rd := io.NewSectionReader(ra, 0, ra.Size()) | 	rd := io.NewSectionReader(ra, 0, ra.Size()) | ||||||
| 	return rd | 	return rd | ||||||
|   | |||||||
| @@ -36,6 +36,7 @@ type store struct { | |||||||
| 	root string | 	root string | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // NewServer returns a local content store | ||||||
| func NewStore(root string) (content.Store, error) { | func NewStore(root string) (content.Store, error) { | ||||||
| 	if err := os.MkdirAll(filepath.Join(root, "ingest"), 0777); err != nil && !os.IsExist(err) { | 	if err := os.MkdirAll(filepath.Join(root, "ingest"), 0777); err != nil && !os.IsExist(err) { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| @@ -97,8 +98,8 @@ func (s *store) ReaderAt(ctx context.Context, dgst digest.Digest) (content.Reade | |||||||
| // | // | ||||||
| // While this is safe to do concurrently, safe exist-removal logic must hold | // While this is safe to do concurrently, safe exist-removal logic must hold | ||||||
| // some global lock on the store. | // some global lock on the store. | ||||||
| func (cs *store) Delete(ctx context.Context, dgst digest.Digest) error { | func (s *store) Delete(ctx context.Context, dgst digest.Digest) error { | ||||||
| 	if err := os.RemoveAll(cs.blobPath(dgst)); err != nil { | 	if err := os.RemoveAll(s.blobPath(dgst)); err != nil { | ||||||
| 		if !os.IsNotExist(err) { | 		if !os.IsNotExist(err) { | ||||||
| 			return err | 			return err | ||||||
| 		} | 		} | ||||||
| @@ -109,14 +110,14 @@ func (cs *store) Delete(ctx context.Context, dgst digest.Digest) error { | |||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func (cs *store) Update(ctx context.Context, info content.Info, fieldpaths ...string) (content.Info, error) { | func (s *store) Update(ctx context.Context, info content.Info, fieldpaths ...string) (content.Info, error) { | ||||||
| 	// TODO: Support persisting and updating mutable content data | 	// TODO: Support persisting and updating mutable content data | ||||||
| 	return content.Info{}, errors.Wrapf(errdefs.ErrFailedPrecondition, "update not supported on immutable content store") | 	return content.Info{}, errors.Wrapf(errdefs.ErrFailedPrecondition, "update not supported on immutable content store") | ||||||
| } | } | ||||||
|  |  | ||||||
| func (cs *store) Walk(ctx context.Context, fn content.WalkFunc, filters ...string) error { | func (s *store) Walk(ctx context.Context, fn content.WalkFunc, filters ...string) error { | ||||||
| 	// TODO: Support filters | 	// TODO: Support filters | ||||||
| 	root := filepath.Join(cs.root, "blobs") | 	root := filepath.Join(s.root, "blobs") | ||||||
| 	var alg digest.Algorithm | 	var alg digest.Algorithm | ||||||
| 	return filepath.Walk(root, func(path string, fi os.FileInfo, err error) error { | 	return filepath.Walk(root, func(path string, fi os.FileInfo, err error) error { | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| @@ -153,7 +154,7 @@ func (cs *store) Walk(ctx context.Context, fn content.WalkFunc, filters ...strin | |||||||
| 			// store or extra paths not expected previously. | 			// store or extra paths not expected previously. | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		return fn(cs.info(dgst, fi)) | 		return fn(s.info(dgst, fi)) | ||||||
| 	}) | 	}) | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -29,6 +29,7 @@ var ( | |||||||
| 	ErrNotImplemented     = errors.New("not implemented") // represents not supported and unimplemented | 	ErrNotImplemented     = errors.New("not implemented") // represents not supported and unimplemented | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | // IsInvalidArgument returns true if the error is due to an invalid argument | ||||||
| func IsInvalidArgument(err error) bool { | func IsInvalidArgument(err error) bool { | ||||||
| 	return errors.Cause(err) == ErrInvalidArgument | 	return errors.Cause(err) == ErrInvalidArgument | ||||||
| } | } | ||||||
| @@ -45,15 +46,17 @@ func IsAlreadyExists(err error) bool { | |||||||
| } | } | ||||||
|  |  | ||||||
| // IsFailedPrecondition returns true if an operation could not proceed to the | // IsFailedPrecondition returns true if an operation could not proceed to the | ||||||
| // lack of a particular condition. | // lack of a particular condition | ||||||
| func IsFailedPrecondition(err error) bool { | func IsFailedPrecondition(err error) bool { | ||||||
| 	return errors.Cause(err) == ErrFailedPrecondition | 	return errors.Cause(err) == ErrFailedPrecondition | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // IsUnavailable returns true if the error is due to a resource being unavailable | ||||||
| func IsUnavailable(err error) bool { | func IsUnavailable(err error) bool { | ||||||
| 	return errors.Cause(err) == ErrUnavailable | 	return errors.Cause(err) == ErrUnavailable | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // IsNotImplemented returns true if the error is due to not being implemented | ||||||
| func IsNotImplemented(err error) bool { | func IsNotImplemented(err error) bool { | ||||||
| 	return errors.Cause(err) == ErrNotImplemented | 	return errors.Cause(err) == ErrNotImplemented | ||||||
| } | } | ||||||
|   | |||||||
| @@ -53,6 +53,7 @@ func ToGRPCf(err error, format string, args ...interface{}) error { | |||||||
| 	return ToGRPC(errors.Wrapf(err, format, args...)) | 	return ToGRPC(errors.Wrapf(err, format, args...)) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // FromGRPC returns the underlying error from a grpc service based on the grpc error code | ||||||
| func FromGRPC(err error) error { | func FromGRPC(err error) error { | ||||||
| 	if err == nil { | 	if err == nil { | ||||||
| 		return nil | 		return nil | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ import ( | |||||||
| 	events "github.com/containerd/containerd/api/services/events/v1" | 	events "github.com/containerd/containerd/api/services/events/v1" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | // Event is a generic interface for any type of event | ||||||
| type Event interface{} | type Event interface{} | ||||||
|  |  | ||||||
| // Publisher posts the event. | // Publisher posts the event. | ||||||
| @@ -13,6 +14,7 @@ type Publisher interface { | |||||||
| 	Publish(ctx context.Context, topic string, event Event) error | 	Publish(ctx context.Context, topic string, event Event) error | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Forwarder forwards an event to the underlying event bus | ||||||
| type Forwarder interface { | type Forwarder interface { | ||||||
| 	Forward(ctx context.Context, envelope *events.Envelope) error | 	Forward(ctx context.Context, envelope *events.Envelope) error | ||||||
| } | } | ||||||
| @@ -23,6 +25,7 @@ func (fn publisherFunc) Publish(ctx context.Context, topic string, event Event) | |||||||
| 	return fn(ctx, topic, event) | 	return fn(ctx, topic, event) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Subscriber allows callers to subscribe to events | ||||||
| type Subscriber interface { | type Subscriber interface { | ||||||
| 	Subscribe(ctx context.Context, filters ...string) (ch <-chan *events.Envelope, errs <-chan error) | 	Subscribe(ctx context.Context, filters ...string) (ch <-chan *events.Envelope, errs <-chan error) | ||||||
| } | } | ||||||
|   | |||||||
| @@ -18,10 +18,12 @@ import ( | |||||||
| 	"github.com/sirupsen/logrus" | 	"github.com/sirupsen/logrus" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | // Exchange broadcasts events | ||||||
| type Exchange struct { | type Exchange struct { | ||||||
| 	broadcaster *goevents.Broadcaster | 	broadcaster *goevents.Broadcaster | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // NewExchange returns a new event Exchange | ||||||
| func NewExchange() *Exchange { | func NewExchange() *Exchange { | ||||||
| 	return &Exchange{ | 	return &Exchange{ | ||||||
| 		broadcaster: goevents.NewBroadcaster(), | 		broadcaster: goevents.NewBroadcaster(), | ||||||
|   | |||||||
| @@ -8,8 +8,10 @@ type Adaptor interface { | |||||||
| 	Field(fieldpath []string) (value string, present bool) | 	Field(fieldpath []string) (value string, present bool) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // AdapterFunc allows implementation specific matching of fieldpaths | ||||||
| type AdapterFunc func(fieldpath []string) (string, bool) | type AdapterFunc func(fieldpath []string) (string, bool) | ||||||
|  |  | ||||||
|  | // Field returns the field name and true if it exists | ||||||
| func (fn AdapterFunc) Field(fieldpath []string) (string, bool) { | func (fn AdapterFunc) Field(fieldpath []string) (string, bool) { | ||||||
| 	return fn(fieldpath) | 	return fn(fieldpath) | ||||||
| } | } | ||||||
|   | |||||||
| @@ -58,22 +58,28 @@ import ( | |||||||
| 	"github.com/containerd/containerd/log" | 	"github.com/containerd/containerd/log" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | // Filter matches specific resources based the provided filter | ||||||
| type Filter interface { | type Filter interface { | ||||||
| 	Match(adaptor Adaptor) bool | 	Match(adaptor Adaptor) bool | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // FilterFunc is a function that handles matching with an adaptor | ||||||
| type FilterFunc func(Adaptor) bool | type FilterFunc func(Adaptor) bool | ||||||
|  |  | ||||||
|  | // Match matches the FilterFunc returning true if the object matches the filter | ||||||
| func (fn FilterFunc) Match(adaptor Adaptor) bool { | func (fn FilterFunc) Match(adaptor Adaptor) bool { | ||||||
| 	return fn(adaptor) | 	return fn(adaptor) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Always is a filter that always returns true for any type of object | ||||||
| var Always FilterFunc = func(adaptor Adaptor) bool { | var Always FilterFunc = func(adaptor Adaptor) bool { | ||||||
| 	return true | 	return true | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Any allows multiple filters to be matched aginst the object | ||||||
| type Any []Filter | type Any []Filter | ||||||
|  |  | ||||||
|  | // Match returns true if any of the provided filters are true | ||||||
| func (m Any) Match(adaptor Adaptor) bool { | func (m Any) Match(adaptor Adaptor) bool { | ||||||
| 	for _, m := range m { | 	for _, m := range m { | ||||||
| 		if m.Match(adaptor) { | 		if m.Match(adaptor) { | ||||||
| @@ -84,8 +90,10 @@ func (m Any) Match(adaptor Adaptor) bool { | |||||||
| 	return false | 	return false | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // All allows multiple filters to be matched aginst the object | ||||||
| type All []Filter | type All []Filter | ||||||
|  |  | ||||||
|  | // Match only returns true if all filters match the object | ||||||
| func (m All) Match(adaptor Adaptor) bool { | func (m All) Match(adaptor Adaptor) bool { | ||||||
| 	for _, m := range m { | 	for _, m := range m { | ||||||
| 		if !m.Match(adaptor) { | 		if !m.Match(adaptor) { | ||||||
|   | |||||||
| @@ -243,11 +243,10 @@ func TestFilters(t *testing.T) { | |||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				return | 				return | ||||||
| 			} else { | 			} | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				t.Fatal(err) | 				t.Fatal(err) | ||||||
| 			} | 			} | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			if filter == nil { | 			if filter == nil { | ||||||
| 				t.Fatal("filter should not be nil") | 				t.Fatal("filter should not be nil") | ||||||
|   | |||||||
| @@ -67,9 +67,8 @@ func (s *scanner) next() rune { | |||||||
| 	if r == utf8.RuneError { | 	if r == utf8.RuneError { | ||||||
| 		if w > 0 { | 		if w > 0 { | ||||||
| 			return tokenIllegal | 			return tokenIllegal | ||||||
| 		} else { |  | ||||||
| 			return tokenEOF |  | ||||||
| 		} | 		} | ||||||
|  | 		return tokenEOF | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if r == 0 { | 	if r == 0 { | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								fs/du.go
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								fs/du.go
									
									
									
									
									
								
							| @@ -1,5 +1,6 @@ | |||||||
| package fs | package fs | ||||||
|  |  | ||||||
|  | // Usage of disk information | ||||||
| type Usage struct { | type Usage struct { | ||||||
| 	Inodes int64 | 	Inodes int64 | ||||||
| 	Size   int64 | 	Size   int64 | ||||||
|   | |||||||
| @@ -26,12 +26,7 @@ func CreateFile(name string, content []byte, perm os.FileMode) Applier { | |||||||
| 		if err := ioutil.WriteFile(fullPath, content, perm); err != nil { | 		if err := ioutil.WriteFile(fullPath, content, perm); err != nil { | ||||||
| 			return err | 			return err | ||||||
| 		} | 		} | ||||||
|  | 		return os.Chmod(fullPath, perm) | ||||||
| 		if err := os.Chmod(fullPath, perm); err != nil { |  | ||||||
| 			return err |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		return nil |  | ||||||
| 	}) | 	}) | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -4,6 +4,7 @@ package fstest | |||||||
|  |  | ||||||
| import "github.com/containerd/continuity/sysx" | import "github.com/containerd/continuity/sysx" | ||||||
|  |  | ||||||
|  | // SetXAttr sets the xatter for the file | ||||||
| func SetXAttr(name, key, value string) Applier { | func SetXAttr(name, key, value string) Applier { | ||||||
| 	return applyFn(func(root string) error { | 	return applyFn(func(root string) error { | ||||||
| 		return sysx.LSetxattr(name, key, []byte(value), 0) | 		return sysx.LSetxattr(name, key, []byte(value), 0) | ||||||
|   | |||||||
| @@ -7,11 +7,13 @@ import ( | |||||||
| 	"testing" | 	"testing" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | // TestApplier applies the test context | ||||||
| type TestApplier interface { | type TestApplier interface { | ||||||
| 	TestContext(context.Context) (context.Context, func(), error) | 	TestContext(context.Context) (context.Context, func(), error) | ||||||
| 	Apply(context.Context, Applier) (string, func(), error) | 	Apply(context.Context, Applier) (string, func(), error) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // FSSuite runs the path test suite | ||||||
| func FSSuite(t *testing.T, a TestApplier) { | func FSSuite(t *testing.T, a TestApplier) { | ||||||
| 	t.Run("Basic", makeTest(t, a, basicTest)) | 	t.Run("Basic", makeTest(t, a, basicTest)) | ||||||
| 	t.Run("Deletion", makeTest(t, a, deletionTest)) | 	t.Run("Deletion", makeTest(t, a, deletionTest)) | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ package fs | |||||||
|  |  | ||||||
| import "os" | import "os" | ||||||
|  |  | ||||||
| // GetLinkID returns an identifier representing the node a hardlink is pointing | // GetLinkInfo returns an identifier representing the node a hardlink is pointing | ||||||
| // to. If the file is not hard linked then 0 will be returned. | // to. If the file is not hard linked then 0 will be returned. | ||||||
| func GetLinkInfo(fi os.FileInfo) (uint64, bool) { | func GetLinkInfo(fi os.FileInfo) (uint64, bool) { | ||||||
| 	return getLinkInfo(fi) | 	return getLinkInfo(fi) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Michael Crosby
					Michael Crosby