Selaa lähdekoodia

daemon/graphdriver/vfs fix lint errors/warnings
Addresses #14756
Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>

Srini Brahmaroutu 10 vuotta sitten
vanhempi
commit
3e7f9c636a
2 muutettua tiedostoa jossa 15 lisäystä ja 0 poistoa
  1. 14 0
      daemon/graphdriver/vfs/driver.go
  2. 1 0
      hack/make/validate-lint

+ 14 - 0
daemon/graphdriver/vfs/driver.go

@@ -17,6 +17,8 @@ func init() {
 	graphdriver.Register("vfs", Init)
 	graphdriver.Register("vfs", Init)
 }
 }
 
 
+// Init returns a new VFS driver.
+// This sets the home directory for the driver and returns NaiveDiffDriver.
 func Init(home string, options []string) (graphdriver.Driver, error) {
 func Init(home string, options []string) (graphdriver.Driver, error) {
 	d := &Driver{
 	d := &Driver{
 		home: home,
 		home: home,
@@ -24,6 +26,10 @@ func Init(home string, options []string) (graphdriver.Driver, error) {
 	return graphdriver.NaiveDiffDriver(d), nil
 	return graphdriver.NaiveDiffDriver(d), nil
 }
 }
 
 
+// Driver holds information about the driver, home directory of the driver.
+// Driver implements graphdriver.ProtoDriver. It uses only basic vfs operations.
+// In order to support layering, files are copied from the parent layer into the new layer. There is no copy-on-write support.
+// Driver must be wrapped in NaiveDiffDriver to be used as a graphdriver.Driver
 type Driver struct {
 type Driver struct {
 	home string
 	home string
 }
 }
@@ -32,18 +38,22 @@ func (d *Driver) String() string {
 	return "vfs"
 	return "vfs"
 }
 }
 
 
+// Status is used for implementing the graphdriver.ProtoDriver interface. VFS does not currently have any status information.
 func (d *Driver) Status() [][2]string {
 func (d *Driver) Status() [][2]string {
 	return nil
 	return nil
 }
 }
 
 
+// GetMetadata is used for implementing the graphdriver.ProtoDriver interface. VFS does not currently have any meta data.
 func (d *Driver) GetMetadata(id string) (map[string]string, error) {
 func (d *Driver) GetMetadata(id string) (map[string]string, error) {
 	return nil, nil
 	return nil, nil
 }
 }
 
 
+// Cleanup is used to implement graphdriver.ProtoDriver. There is no cleanup required for this driver.
 func (d *Driver) Cleanup() error {
 func (d *Driver) Cleanup() error {
 	return nil
 	return nil
 }
 }
 
 
+// Create prepares the filesystem for the VFS driver and copies the directory for the given id under the parent.
 func (d *Driver) Create(id, parent string) error {
 func (d *Driver) Create(id, parent string) error {
 	dir := d.dir(id)
 	dir := d.dir(id)
 	if err := system.MkdirAll(filepath.Dir(dir), 0700); err != nil {
 	if err := system.MkdirAll(filepath.Dir(dir), 0700); err != nil {
@@ -73,6 +83,7 @@ func (d *Driver) dir(id string) string {
 	return filepath.Join(d.home, "dir", filepath.Base(id))
 	return filepath.Join(d.home, "dir", filepath.Base(id))
 }
 }
 
 
+// Remove deletes the content from the directory for a given id.
 func (d *Driver) Remove(id string) error {
 func (d *Driver) Remove(id string) error {
 	if _, err := os.Stat(d.dir(id)); err != nil {
 	if _, err := os.Stat(d.dir(id)); err != nil {
 		return err
 		return err
@@ -80,6 +91,7 @@ func (d *Driver) Remove(id string) error {
 	return os.RemoveAll(d.dir(id))
 	return os.RemoveAll(d.dir(id))
 }
 }
 
 
+// Get returns the directory for the given id.
 func (d *Driver) Get(id, mountLabel string) (string, error) {
 func (d *Driver) Get(id, mountLabel string) (string, error) {
 	dir := d.dir(id)
 	dir := d.dir(id)
 	if st, err := os.Stat(dir); err != nil {
 	if st, err := os.Stat(dir); err != nil {
@@ -90,12 +102,14 @@ func (d *Driver) Get(id, mountLabel string) (string, error) {
 	return dir, nil
 	return dir, nil
 }
 }
 
 
+// Put is a noop for vfs that return nil for the error, since this driver has no runtime resources to clean up.
 func (d *Driver) Put(id string) error {
 func (d *Driver) Put(id string) error {
 	// The vfs driver has no runtime resources (e.g. mounts)
 	// The vfs driver has no runtime resources (e.g. mounts)
 	// to clean up, so we don't need anything here
 	// to clean up, so we don't need anything here
 	return nil
 	return nil
 }
 }
 
 
+// Exists checks to see if the directory exists for the given id.
 func (d *Driver) Exists(id string) bool {
 func (d *Driver) Exists(id string) bool {
 	_, err := os.Stat(d.dir(id))
 	_, err := os.Stat(d.dir(id))
 	return err == nil
 	return err == nil

+ 1 - 0
hack/make/validate-lint

@@ -35,6 +35,7 @@ packages=(
 	docker
 	docker
 	dockerinit
 	dockerinit
 	graph
 	graph
+	daemon/graphdriver/vfs
 	image
 	image
 	integration-cli
 	integration-cli
 	pkg/broadcastwriter
 	pkg/broadcastwriter