summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Gopkg.lock13
-rw-r--r--data/datasource.go15
-rw-r--r--data/datasource_file.go8
-rw-r--r--data/datasource_file_test.go14
-rw-r--r--data/datasource_merge_test.go14
-rw-r--r--data/datasource_test.go31
-rw-r--r--env/env.go18
-rw-r--r--env/env_test.go76
-rw-r--r--vault/auth.go7
-rw-r--r--vendor/github.com/blang/vfs/LICENSE22
-rw-r--r--vendor/github.com/blang/vfs/doc.go2
-rw-r--r--vendor/github.com/blang/vfs/dummy.go158
-rw-r--r--vendor/github.com/blang/vfs/filesystem.go139
-rw-r--r--vendor/github.com/blang/vfs/ioutil.go83
-rw-r--r--vendor/github.com/blang/vfs/memfs/buffer.go177
-rw-r--r--vendor/github.com/blang/vfs/memfs/doc.go2
-rw-r--r--vendor/github.com/blang/vfs/memfs/memfile.go89
-rw-r--r--vendor/github.com/blang/vfs/memfs/memfs.go380
-rw-r--r--vendor/github.com/blang/vfs/os.go54
-rw-r--r--vendor/github.com/blang/vfs/path.go29
-rw-r--r--vendor/github.com/blang/vfs/readonly.go78
21 files changed, 83 insertions, 1326 deletions
diff --git a/Gopkg.lock b/Gopkg.lock
index 74d1697f..80ac724c 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -73,17 +73,6 @@
version = "v1.17.9"
[[projects]]
- digest = "1:27c31c51caa806074eca1038cbdc6a9c5b2eb202264b6bfb359eb441e2594268"
- name = "github.com/blang/vfs"
- packages = [
- ".",
- "memfs",
- ]
- pruneopts = "NUT"
- revision = "2c3e2278e174a74f31ff8bf6f47b43ecb358a870"
- version = "v1.0.0"
-
-[[projects]]
digest = "1:a12d94258c5298ead75e142e8001224bf029f302fed9e96cd39c0eaf90f3954d"
name = "github.com/boltdb/bolt"
packages = ["."]
@@ -557,8 +546,6 @@
"github.com/aws/aws-sdk-go/aws/session",
"github.com/aws/aws-sdk-go/service/ec2",
"github.com/aws/aws-sdk-go/service/ssm",
- "github.com/blang/vfs",
- "github.com/blang/vfs/memfs",
"github.com/boltdb/bolt",
"github.com/docker/libkv",
"github.com/docker/libkv/store",
diff --git a/data/datasource.go b/data/datasource.go
index b723aea8..9236a88a 100644
--- a/data/datasource.go
+++ b/data/datasource.go
@@ -13,9 +13,10 @@ import (
"regexp"
"strings"
+ "github.com/spf13/afero"
+
"github.com/pkg/errors"
- "github.com/blang/vfs"
"github.com/hairyhenderson/gomplate/libkv"
"github.com/hairyhenderson/gomplate/vault"
)
@@ -122,12 +123,12 @@ type Source struct {
Alias string
URL *url.URL
mediaType string
- fs vfs.Filesystem // used for file: URLs, nil otherwise
- hc *http.Client // used for http[s]: URLs, nil otherwise
- vc *vault.Vault // used for vault: URLs, nil otherwise
- kv *libkv.LibKV // used for consul:, etcd:, zookeeper: & boltdb: URLs, nil otherwise
- asmpg awssmpGetter // used for aws+smp:, nil otherwise
- header http.Header // used for http[s]: URLs, nil otherwise
+ fs afero.Fs // used for file: URLs, nil otherwise
+ hc *http.Client // used for http[s]: URLs, nil otherwise
+ vc *vault.Vault // used for vault: URLs, nil otherwise
+ kv *libkv.LibKV // used for consul:, etcd:, zookeeper: & boltdb: URLs, nil otherwise
+ asmpg awssmpGetter // used for aws+smp:, nil otherwise
+ header http.Header // used for http[s]: URLs, nil otherwise
}
func (s *Source) inherit(parent *Source) {
diff --git a/data/datasource_file.go b/data/datasource_file.go
index 93367cc5..a94944cd 100644
--- a/data/datasource_file.go
+++ b/data/datasource_file.go
@@ -9,14 +9,14 @@ import (
"path/filepath"
"strings"
- "github.com/pkg/errors"
+ "github.com/spf13/afero"
- "github.com/blang/vfs"
+ "github.com/pkg/errors"
)
func readFile(source *Source, args ...string) ([]byte, error) {
if source.fs == nil {
- source.fs = vfs.OS()
+ source.fs = afero.NewOsFs()
}
p := filepath.FromSlash(source.URL.Path)
@@ -59,7 +59,7 @@ func readFile(source *Source, args ...string) ([]byte, error) {
}
func readFileDir(source *Source, p string) ([]byte, error) {
- names, err := source.fs.ReadDir(p)
+ names, err := afero.ReadDir(source.fs, p)
if err != nil {
return nil, err
}
diff --git a/data/datasource_file_test.go b/data/datasource_file_test.go
index 3a402b3b..665173a0 100644
--- a/data/datasource_file_test.go
+++ b/data/datasource_file_test.go
@@ -5,24 +5,24 @@ package data
import (
"testing"
- "github.com/blang/vfs"
- "github.com/blang/vfs/memfs"
+ "github.com/spf13/afero"
+
"github.com/stretchr/testify/assert"
)
func TestReadFile(t *testing.T) {
content := []byte(`hello world`)
- fs := memfs.Create()
+ fs := afero.NewMemMapFs()
_ = fs.Mkdir("/tmp", 0777)
- f, _ := vfs.Create(fs, "/tmp/foo")
+ f, _ := fs.Create("/tmp/foo")
_, _ = f.Write(content)
_ = fs.Mkdir("/tmp/partial", 0777)
- f, _ = vfs.Create(fs, "/tmp/partial/foo.txt")
+ f, _ = fs.Create("/tmp/partial/foo.txt")
_, _ = f.Write(content)
- _, _ = vfs.Create(fs, "/tmp/partial/bar.txt")
- _, _ = vfs.Create(fs, "/tmp/partial/baz.txt")
+ _, _ = fs.Create("/tmp/partial/bar.txt")
+ _, _ = fs.Create("/tmp/partial/baz.txt")
source := &Source{Alias: "foo", URL: mustParseURL("file:///tmp/foo")}
source.fs = fs
diff --git a/data/datasource_merge_test.go b/data/datasource_merge_test.go
index b4ad7768..586d4dff 100644
--- a/data/datasource_merge_test.go
+++ b/data/datasource_merge_test.go
@@ -6,8 +6,8 @@ import (
"net/url"
"testing"
- "github.com/blang/vfs"
- "github.com/blang/vfs/memfs"
+ "github.com/spf13/afero"
+
"github.com/stretchr/testify/assert"
)
@@ -18,16 +18,16 @@ func TestReadMerge(t *testing.T) {
mergedContent := []byte("goodnight: moon\nhello: world\n")
- fs := memfs.Create()
+ fs := afero.NewMemMapFs()
_ = fs.Mkdir("/tmp", 0777)
- f, _ := vfs.Create(fs, "/tmp/jsonfile.json")
+ f, _ := fs.Create("/tmp/jsonfile.json")
_, _ = f.Write(jsonContent)
- f, _ = vfs.Create(fs, "/tmp/array.json")
+ f, _ = fs.Create("/tmp/array.json")
_, _ = f.Write(arrayContent)
- f, _ = vfs.Create(fs, "/tmp/yamlfile.yaml")
+ f, _ = fs.Create("/tmp/yamlfile.yaml")
_, _ = f.Write(yamlContent)
- f, _ = vfs.Create(fs, "/tmp/textfile.txt")
+ f, _ = fs.Create("/tmp/textfile.txt")
_, _ = f.Write([]byte(`plain text...`))
source := &Source{Alias: "foo", URL: mustParseURL("merge:file:///tmp/jsonfile.json|file:///tmp/yamlfile.yaml")}
diff --git a/data/datasource_test.go b/data/datasource_test.go
index ea0eb719..ee6c6acf 100644
--- a/data/datasource_test.go
+++ b/data/datasource_test.go
@@ -7,8 +7,8 @@ import (
"strings"
"testing"
- "github.com/blang/vfs"
- "github.com/blang/vfs/memfs"
+ "github.com/spf13/afero"
+
"github.com/stretchr/testify/assert"
)
@@ -97,17 +97,17 @@ func TestParseSourceWithAlias(t *testing.T) {
func TestDatasource(t *testing.T) {
setup := func(ext, mime string, contents []byte) *Data {
fname := "foo." + ext
- fs := memfs.Create()
+ fs := afero.NewMemMapFs()
var uPath string
- var f vfs.File
+ var f afero.File
if runtime.GOOS == "windows" {
_ = fs.Mkdir("C:\\tmp", 0777)
- f, _ = vfs.Create(fs, "C:\\tmp\\"+fname)
+ f, _ = fs.Create("C:\\tmp\\" + fname)
_, _ = f.Write(contents)
uPath = "C:/tmp/" + fname
} else {
_ = fs.Mkdir("/tmp", 0777)
- f, _ = vfs.Create(fs, "/tmp/"+fname)
+ f, _ = fs.Create("/tmp/" + fname)
uPath = "/tmp/" + fname
}
_, _ = f.Write(contents)
@@ -144,16 +144,16 @@ func TestDatasource(t *testing.T) {
func TestDatasourceReachable(t *testing.T) {
fname := "foo.json"
- fs := memfs.Create()
+ fs := afero.NewMemMapFs()
var uPath string
- var f vfs.File
+ var f afero.File
if runtime.GOOS == "windows" {
_ = fs.Mkdir("C:\\tmp", 0777)
- f, _ = vfs.Create(fs, "C:\\tmp\\"+fname)
+ f, _ = fs.Create("C:\\tmp\\" + fname)
uPath = "C:/tmp/" + fname
} else {
_ = fs.Mkdir("/tmp", 0777)
- f, _ = vfs.Create(fs, "/tmp/"+fname)
+ f, _ = fs.Create("/tmp/" + fname)
uPath = "/tmp/" + fname
}
_, _ = f.Write([]byte("{}"))
@@ -190,20 +190,17 @@ func TestInclude(t *testing.T) {
ext := "txt"
contents := "hello world"
fname := "foo." + ext
- fs := memfs.Create()
- // _ = fs.Mkdir("/tmp", 0777)
- // f, _ := vfs.Create(fs, "/tmp/"+fname)
- // _, _ = f.Write([]byte(contents))
+ fs := afero.NewMemMapFs()
var uPath string
- var f vfs.File
+ var f afero.File
if runtime.GOOS == "windows" {
_ = fs.Mkdir("C:\\tmp", 0777)
- f, _ = vfs.Create(fs, "C:\\tmp\\"+fname)
+ f, _ = fs.Create("C:\\tmp\\" + fname)
uPath = "C:/tmp/" + fname
} else {
_ = fs.Mkdir("/tmp", 0777)
- f, _ = vfs.Create(fs, "/tmp/"+fname)
+ f, _ = fs.Create("/tmp/" + fname)
uPath = "/tmp/" + fname
}
_, _ = f.Write([]byte(contents))
diff --git a/env/env.go b/env/env.go
index 37941569..5b955479 100644
--- a/env/env.go
+++ b/env/env.go
@@ -5,7 +5,7 @@ import (
"os"
"strings"
- "github.com/blang/vfs"
+ "github.com/spf13/afero"
)
// Getenv - retrieves the value of the environment variable named by the key.
@@ -13,23 +13,23 @@ import (
// referenced file will be read into the value.
// Otherwise the provided default (or an emptry string) is returned.
func Getenv(key string, def ...string) string {
- return GetenvVFS(vfs.OS(), key, def...)
+ return getenvVFS(afero.NewOsFs(), key, def...)
}
// ExpandEnv - like os.ExpandEnv, except supports `_FILE` vars as well
func ExpandEnv(s string) string {
- return expandEnvVFS(vfs.OS(), s)
+ return expandEnvVFS(afero.NewOsFs(), s)
}
// expandEnvVFS -
-func expandEnvVFS(fs vfs.Filesystem, s string) string {
+func expandEnvVFS(fs afero.Fs, s string) string {
return os.Expand(s, func(s string) string {
- return GetenvVFS(fs, s)
+ return getenvVFS(fs, s)
})
}
-// GetenvVFS - a convenience function intended for internal use only!
-func GetenvVFS(fs vfs.Filesystem, key string, def ...string) string {
+// getenvVFS - a convenience function intended for internal use only!
+func getenvVFS(fs afero.Fs, key string, def ...string) string {
val := getenvFile(fs, key)
if val == "" && len(def) > 0 {
return def[0]
@@ -38,7 +38,7 @@ func GetenvVFS(fs vfs.Filesystem, key string, def ...string) string {
return val
}
-func getenvFile(fs vfs.Filesystem, key string) string {
+func getenvFile(fs afero.Fs, key string) string {
val := os.Getenv(key)
if val != "" {
return val
@@ -56,7 +56,7 @@ func getenvFile(fs vfs.Filesystem, key string) string {
return ""
}
-func readFile(fs vfs.Filesystem, p string) (string, error) {
+func readFile(fs afero.Fs, p string) (string, error) {
f, err := fs.OpenFile(p, os.O_RDONLY, 0)
if err != nil {
return "", err
diff --git a/env/env_test.go b/env/env_test.go
index a00e77ce..0ed5f593 100644
--- a/env/env_test.go
+++ b/env/env_test.go
@@ -5,8 +5,8 @@ import (
"os"
"testing"
- "github.com/blang/vfs"
- "github.com/blang/vfs/memfs"
+ "github.com/spf13/afero"
+
"github.com/stretchr/testify/assert"
)
@@ -17,22 +17,22 @@ func TestGetenv(t *testing.T) {
}
func TestGetenvFile(t *testing.T) {
- fs := newMemFS()
+ fs := afero.NewMemMapFs()
_ = fs.Mkdir("/tmp", 0777)
- f, _ := vfs.Create(fs, "/tmp/foo")
+ f, _ := fs.Create("/tmp/foo")
_, _ = f.Write([]byte("foo"))
defer os.Unsetenv("FOO_FILE")
os.Setenv("FOO_FILE", "/tmp/foo")
- assert.Equal(t, "foo", GetenvVFS(fs, "FOO", "bar"))
+ assert.Equal(t, "foo", getenvVFS(fs, "FOO", "bar"))
os.Setenv("FOO_FILE", "/tmp/missing")
- assert.Equal(t, "bar", GetenvVFS(fs, "FOO", "bar"))
+ assert.Equal(t, "bar", getenvVFS(fs, "FOO", "bar"))
- _, _ = vfs.Create(fs, "/tmp/unreadable")
- fs = WriteOnly(fs)
+ _, _ = fs.Create("/tmp/unreadable")
+ fs = writeOnly(fs)
os.Setenv("FOO_FILE", "/tmp/unreadable")
- assert.Equal(t, "bar", GetenvVFS(fs, "FOO", "bar"))
+ assert.Equal(t, "bar", getenvVFS(fs, "FOO", "bar"))
}
func TestExpandEnv(t *testing.T) {
@@ -44,9 +44,9 @@ func TestExpandEnv(t *testing.T) {
}
func TestExpandEnvFile(t *testing.T) {
- fs := newMemFS()
+ fs := afero.NewMemMapFs()
_ = fs.Mkdir("/tmp", 0777)
- f, _ := vfs.Create(fs, "/tmp/foo")
+ f, _ := fs.Create("/tmp/foo")
_, _ = f.Write([]byte("foo"))
defer os.Unsetenv("FOO_FILE")
@@ -56,68 +56,56 @@ func TestExpandEnvFile(t *testing.T) {
os.Setenv("FOO_FILE", "/tmp/missing")
assert.Equal(t, "empty", expandEnvVFS(fs, "${FOO}empty"))
- _, _ = vfs.Create(fs, "/tmp/unreadable")
- fs = WriteOnly(fs)
+ _, _ = fs.Create("/tmp/unreadable")
+ fs = writeOnly(fs)
os.Setenv("FOO_FILE", "/tmp/unreadable")
assert.Equal(t, "", expandEnvVFS(fs, "${FOO}"))
}
// Maybe extract this into a separate package sometime...
-// WriteOnly - represents a filesystem that's writeable, but read operations fail
-func WriteOnly(fs vfs.Filesystem) vfs.Filesystem {
- return &WoFS{fs}
-}
-
-func newMemFS() vfs.Filesystem {
- return memfs.Create()
+// writeOnly - represents a filesystem that's writeable, but read operations fail
+func writeOnly(fs afero.Fs) afero.Fs {
+ return &woFS{fs}
}
-type WoFS struct {
- vfs.Filesystem
+type woFS struct {
+ afero.Fs
}
-func (fs WoFS) Remove(name string) error {
- return fs.Filesystem.Remove(name)
+func (fs woFS) Remove(name string) error {
+ return fs.Fs.Remove(name)
}
-func (fs WoFS) Rename(oldpath, newpath string) error {
- return fs.Filesystem.Rename(oldpath, newpath)
+func (fs woFS) Rename(oldpath, newpath string) error {
+ return fs.Fs.Rename(oldpath, newpath)
}
-func (fs WoFS) Mkdir(name string, perm os.FileMode) error {
- return fs.Filesystem.Mkdir(name, perm)
+func (fs woFS) Mkdir(name string, perm os.FileMode) error {
+ return fs.Fs.Mkdir(name, perm)
}
-func (fs WoFS) OpenFile(name string, flag int, perm os.FileMode) (vfs.File, error) {
- f, err := fs.Filesystem.OpenFile(name, flag, perm)
+func (fs woFS) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error) {
+ f, err := fs.Fs.OpenFile(name, flag, perm)
if err != nil {
- return WriteOnlyFile(f), err
+ return writeOnlyFile(f), err
}
- return WriteOnlyFile(f), nil
-}
-
-func (fs WoFS) Lstat(name string) (os.FileInfo, error) {
- return fs.Filesystem.Lstat(name)
-}
-
-func (fs WoFS) PathSeparator() uint8 {
- return fs.Filesystem.PathSeparator()
+ return writeOnlyFile(f), nil
}
-func (fs WoFS) ReadDir(path string) ([]os.FileInfo, error) {
+func (fs woFS) ReadDir(path string) ([]os.FileInfo, error) {
return nil, ErrWriteOnly
}
-func (fs WoFS) Stat(name string) (os.FileInfo, error) {
+func (fs woFS) Stat(name string) (os.FileInfo, error) {
return nil, ErrWriteOnly
}
-func WriteOnlyFile(f vfs.File) vfs.File {
+func writeOnlyFile(f afero.File) afero.File {
return &woFile{f}
}
type woFile struct {
- vfs.File
+ afero.File
}
// Write is disabled and returns ErrWriteOnly
diff --git a/vault/auth.go b/vault/auth.go
index d3a610f4..b3b909e6 100644
--- a/vault/auth.go
+++ b/vault/auth.go
@@ -8,7 +8,6 @@ import (
"strings"
"time"
- "github.com/blang/vfs"
"github.com/hairyhenderson/gomplate/aws"
"github.com/hairyhenderson/gomplate/conv"
"github.com/hairyhenderson/gomplate/env"
@@ -170,8 +169,7 @@ func (v *Vault) EC2Login() (string, error) {
if val, ok := secret.Auth.Metadata["nonce"]; ok {
nonce = val
}
- fs := vfs.OS()
- f, err := fs.OpenFile(output, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.FileMode(0600))
+ f, err := os.OpenFile(output, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.FileMode(0600))
if err != nil {
return "", errors.Wrapf(err, "Error opening nonce output file")
}
@@ -219,12 +217,11 @@ func (v *Vault) TokenLogin() (string, error) {
if token := env.Getenv("VAULT_TOKEN"); token != "" {
return token, nil
}
- fs := vfs.OS()
homeDir, err := homeDir()
if err != nil {
return "", err
}
- f, err := fs.OpenFile(path.Join(homeDir, ".vault-token"), os.O_RDONLY, 0)
+ f, err := os.OpenFile(path.Join(homeDir, ".vault-token"), os.O_RDONLY, 0)
if err != nil {
return "", nil
}
diff --git a/vendor/github.com/blang/vfs/LICENSE b/vendor/github.com/blang/vfs/LICENSE
deleted file mode 100644
index 4910a62b..00000000
--- a/vendor/github.com/blang/vfs/LICENSE
+++ /dev/null
@@ -1,22 +0,0 @@
-The MIT License
-
-Copyright (c) 2015 Benedikt Lang <github at blang.io>
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
diff --git a/vendor/github.com/blang/vfs/doc.go b/vendor/github.com/blang/vfs/doc.go
deleted file mode 100644
index 7f60ebbd..00000000
--- a/vendor/github.com/blang/vfs/doc.go
+++ /dev/null
@@ -1,2 +0,0 @@
-// Package vfs defines an abstract file system and various implementations.
-package vfs
diff --git a/vendor/github.com/blang/vfs/dummy.go b/vendor/github.com/blang/vfs/dummy.go
deleted file mode 100644
index a0359cde..00000000
--- a/vendor/github.com/blang/vfs/dummy.go
+++ /dev/null
@@ -1,158 +0,0 @@
-package vfs
-
-import (
- "os"
- "time"
-)
-
-// Dummy creates a new dummy filesystem which returns the given error on every operation.
-func Dummy(err error) *DummyFS {
- return &DummyFS{err}
-}
-
-// DummyFS is dummy filesystem which returns an error on every operation.
-// It can be used to mock a full filesystem for testing or fs creation.
-type DummyFS struct {
- err error
-}
-
-// PathSeparator returns the path separator
-func (fs DummyFS) PathSeparator() uint8 {
- return '/'
-}
-
-// OpenFile returns dummy error
-func (fs DummyFS) OpenFile(name string, flag int, perm os.FileMode) (File, error) {
- return nil, fs.err
-}
-
-// Remove returns dummy error
-func (fs DummyFS) Remove(name string) error {
- return fs.err
-}
-
-// Rename returns dummy error
-func (fs DummyFS) Rename(oldpath, newpath string) error {
- return fs.err
-}
-
-// Mkdir returns dummy error
-func (fs DummyFS) Mkdir(name string, perm os.FileMode) error {
- return fs.err
-}
-
-// Stat returns dummy error
-func (fs DummyFS) Stat(name string) (os.FileInfo, error) {
- return nil, fs.err
-}
-
-// Lstat returns dummy error
-func (fs DummyFS) Lstat(name string) (os.FileInfo, error) {
- return nil, fs.err
-}
-
-// ReadDir returns dummy error
-func (fs DummyFS) ReadDir(path string) ([]os.FileInfo, error) {
- return nil, fs.err
-}
-
-// DummyFile mocks a File returning an error on every operation
-// To create a DummyFS returning a dummyFile instead of an error
-// you can your own DummyFS:
-//
-// type writeDummyFS struct {
-// Filesystem
-// }
-//
-// func (fs writeDummyFS) OpenFile(name string, flag int, perm os.FileMode) (File, error) {
-// return DummyFile(dummyError), nil
-// }
-func DummyFile(err error) *DumFile {
- return &DumFile{err}
-}
-
-// DumFile represents a dummy File
-type DumFile struct {
- err error
-}
-
-// Name returns "dummy"
-func (f DumFile) Name() string {
- return "dummy"
-}
-
-// Sync returns dummy error
-func (f DumFile) Sync() error {
- return f.err
-}
-
-// Truncate returns dummy error
-func (f DumFile) Truncate(size int64) error {
- return f.err
-}
-
-// Close returns dummy error
-func (f DumFile) Close() error {
- return f.err
-}
-
-// Write returns dummy error
-func (f DumFile) Write(p []byte) (n int, err error) {
- return 0, f.err
-}
-
-// Read returns dummy error
-func (f DumFile) Read(p []byte) (n int, err error) {
- return 0, f.err
-}
-
-// ReadAt returns dummy error
-func (f DumFile) ReadAt(p []byte, off int64) (n int, err error) {
- return 0, f.err
-}
-
-// Seek returns dummy error
-func (f DumFile) Seek(offset int64, whence int) (int64, error) {
- return 0, f.err
-}
-
-// DumFileInfo mocks a os.FileInfo returning default values on every operation
-// Struct fields can be set.
-type DumFileInfo struct {
- IName string
- ISize int64
- IMode os.FileMode
- IModTime time.Time
- IDir bool
- ISys interface{}
-}
-
-// Name returns the field IName
-func (fi DumFileInfo) Name() string {
- return fi.IName
-}
-
-// Size returns the field ISize
-func (fi DumFileInfo) Size() int64 {
- return fi.ISize
-}
-
-// Mode returns the field IMode
-func (fi DumFileInfo) Mode() os.FileMode {
- return fi.IMode
-}
-
-// ModTime returns the field IModTime
-func (fi DumFileInfo) ModTime() time.Time {
- return fi.IModTime
-}
-
-// IsDir returns the field IDir
-func (fi DumFileInfo) IsDir() bool {
- return fi.IDir
-}
-
-// Sys returns the field ISys
-func (fi DumFileInfo) Sys() interface{} {
- return fi.ISys
-}
diff --git a/vendor/github.com/blang/vfs/filesystem.go b/vendor/github.com/blang/vfs/filesystem.go
deleted file mode 100644
index 7271206d..00000000
--- a/vendor/github.com/blang/vfs/filesystem.go
+++ /dev/null
@@ -1,139 +0,0 @@
-package vfs
-
-import (
- "errors"
- "io"
- "os"
- "strings"
-)
-
-var (
- // ErrIsDirectory is returned if a file is a directory
- ErrIsDirectory = errors.New("Is directory")
- // ErrNotDirectory is returned if a file is not a directory
- ErrNotDirectory = errors.New("Is not a directory")
-)
-
-// Filesystem represents an abstract filesystem
-type Filesystem interface {
- PathSeparator() uint8
- OpenFile(name string, flag int, perm os.FileMode) (File, error)
- Remove(name string) error
- // RemoveAll(path string) error
- Rename(oldpath, newpath string) error
- Mkdir(name string, perm os.FileMode) error
- // Symlink(oldname, newname string) error
- // TempDir() string
- // Chmod(name string, mode FileMode) error
- // Chown(name string, uid, gid int) error
- Stat(name string) (os.FileInfo, error)
- Lstat(name string) (os.FileInfo, error)
- ReadDir(path string) ([]os.FileInfo, error)
-}
-
-// File represents a File with common operations.
-// It differs from os.File so e.g. Stat() needs to be called from the Filesystem instead.
-// osfile.Stat() -> filesystem.Stat(file.Name())
-type File interface {
- Name() string
- Sync() error
- // Truncate shrinks or extends the size of the File to the specified size.
- Truncate(int64) error
- io.Reader
- io.ReaderAt
- io.Writer
- io.Seeker
- io.Closer
-}
-
-// Create creates the named file mode 0666 (before umask) on the given Filesystem,
-// truncating it if it already exists.
-// The associated file descriptor has mode os.O_RDWR.
-// If there is an error, it will be of type *os.PathError.
-func Create(fs Filesystem, name string) (File, error) {
- return fs.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666)
-}
-
-// Open opens the named file on the given Filesystem for reading.
-// If successful, methods on the returned file can be used for reading.
-// The associated file descriptor has mode os.O_RDONLY.
-// If there is an error, it will be of type *PathError.
-func Open(fs Filesystem, name string) (File, error) {
- return fs.OpenFile(name, os.O_RDONLY, 0)
-}
-
-// MkdirAll creates a directory named path on the given Filesystem,
-// along with any necessary parents, and returns nil,
-// or else returns an error.
-// The permission bits perm are used for all
-// directories that MkdirAll creates.
-// If path is already a directory, MkdirAll does nothing
-// and returns nil.
-func MkdirAll(fs Filesystem, path string, perm os.FileMode) error {
- if dir, err := fs.Stat(path); err == nil {
- if dir.IsDir() {
- return nil
- }
- return &os.PathError{"mkdir", path, ErrNotDirectory}
- }
-
- parts := SplitPath(path, string(fs.PathSeparator()))
- if len(parts) > 1 {
- // Create parent
- err := MkdirAll(fs, strings.Join(parts[0:len(parts)-1], string(fs.PathSeparator())), perm)
- if err != nil {
- return err
- }
- }
-
- // Parent now exists; invoke Mkdir and use its result.
- err := fs.Mkdir(path, perm)
- if err != nil {
- // Handle arguments like "foo/." by
- // double-checking that directory doesn't exist.
- dir, err1 := fs.Lstat(path)
- if err1 == nil && dir.IsDir() {
- return nil
- }
- return err
- }
- return nil
-}
-
-// RemoveAll removes path and any children it contains.
-// It removes everything it can but returns the first error
-// it encounters. If the path does not exist, RemoveAll
-// returns nil.
-func RemoveAll(fs Filesystem, path string) error {
- if err := fs.Remove(path); err == nil || os.IsNotExist(err) {
- return nil
- }
-
- // We could not delete it, so might be a directory
- fis, err := fs.ReadDir(path)
- if err != nil {
- if os.IsNotExist(err) {
- return nil
- }
- return err
- }
-
- // Remove contents & return first error.
- err = nil
- for _, fi := range fis {
- err1 := RemoveAll(fs, path+string(fs.PathSeparator())+fi.Name())
- if err == nil {
- err = err1
- }
- }
-
- // Remove directory itself.
- err1 := fs.Remove(path)
- if err1 == nil || os.IsNotExist(err1) {
- return nil
- }
- if err == nil {
- err = err1
- }
- return err
-}
diff --git a/vendor/github.com/blang/vfs/ioutil.go b/vendor/github.com/blang/vfs/ioutil.go
deleted file mode 100644
index 04c69824..00000000
--- a/vendor/github.com/blang/vfs/ioutil.go
+++ /dev/null
@@ -1,83 +0,0 @@
-package vfs
-
-import (
- "bytes"
- "io"
- "os"
-)
-
-// WriteFile writes data to a file named by filename on the given Filesystem. If
-// the file does not exist, WriteFile creates it with permissions perm;
-// otherwise WriteFile truncates it before writing.
-//
-// This is a port of the stdlib ioutil.WriteFile function.
-func WriteFile(fs Filesystem, filename string, data []byte, perm os.FileMode) error {
- f, err := fs.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm)
- if err != nil {
- return err
- }
- n, err := f.Write(data)
- if err == nil && n < len(data) {
- err = io.ErrShortWrite
- }
- if err1 := f.Close(); err == nil {
- err = err1
- }
- return err
-}
-
-// ReadFile reads the file named by filename and returns the contents. A
-// successful call returns err == nil, not err == EOF. Because ReadFile reads
-// the whole file, it does not treat an EOF from Read as an error to be
-// reported.
-//
-// This is a port of the stdlib ioutil.ReadFile function.
-func ReadFile(fs Filesystem, filename string) ([]byte, error) {
- f, err := fs.OpenFile(filename, os.O_RDONLY, 0)
- if err != nil {
- return nil, err
- }
- defer f.Close()
-
- // It's a good but not certain bet that FileInfo will tell us exactly how
- // much to read, so let's try it but be prepared for the answer to be wrong.
- var n int64
- if fi, err := fs.Stat(filename); err == nil {
- if size := fi.Size(); size < 1e9 {
- n = size
- }
- }
-
- // As initial capacity for readAll, use n + a little extra in case Size is
- // zero, and to avoid another allocation after Read has filled the buffer.
- // The readAll call will read into its allocated internal buffer cheaply. If
- // the size was wrong, we'll either waste some space off the end or
- // reallocate as needed, but in the overwhelmingly common case we'll get it
- // just right.
- return readAll(f, n+bytes.MinRead)
-}
-
-// readAll reads from r until an error or EOF and returns the data it read from
-// the internal buffer allocated with a specified capacity.
-//
-// This is a paste of the stdlib ioutil.readAll function.
-func readAll(r io.Reader, capacity int64) (b []byte, err error) {
- buf := bytes.NewBuffer(make([]byte, 0, capacity))
-
- // If the buffer overflows, we will get bytes.ErrTooLarge.
- // Return that as an error. Any other panic remains.
- defer func() {
- e := recover()
- if e == nil {
- return
- }
- if panicErr, ok := e.(error); ok && panicErr == bytes.ErrTooLarge {
- err = panicErr
- } else {
- panic(e)
- }
- }()
-
- _, err = buf.ReadFrom(r)
- return buf.Bytes(), err
-}
diff --git a/vendor/github.com/blang/vfs/memfs/buffer.go b/vendor/github.com/blang/vfs/memfs/buffer.go
deleted file mode 100644
index a0a78c5b..00000000
--- a/vendor/github.com/blang/vfs/memfs/buffer.go
+++ /dev/null
@@ -1,177 +0,0 @@
-package memfs
-
-import (
- "errors"
- "io"
- "os"
-)
-
-// Buffer is a usable block of data similar to a file
-type Buffer interface {
- io.Reader
- io.ReaderAt
- io.Writer
- io.Seeker
- io.Closer
- // Truncate shrinks or extends the size of the Buffer to the specified size.
- Truncate(int64) error
-}
-
-// MinBufferSize is the minimal initial allocated buffer size
-const MinBufferSize = 512
-
-// ErrTooLarge is thrown if it was not possible to enough memory
-var ErrTooLarge = errors.New("Volume too large")
-
-// Buf is a Buffer working on a slice of bytes.
-type Buf struct {
- buf *[]byte
- ptr int64
-}
-
-// NewBuffer creates a new data volume based on a buffer
-func NewBuffer(buf *[]byte) *Buf {
- return &Buf{
- buf: buf,
- }
-}
-
-// Seek sets the offset for the next Read or Write on the buffer to offset,
-// interpreted according to whence:
-// 0 (os.SEEK_SET) means relative to the origin of the file
-// 1 (os.SEEK_CUR) means relative to the current offset
-// 2 (os.SEEK_END) means relative to the end of the file
-// It returns the new offset and an error, if any.
-func (v *Buf) Seek(offset int64, whence int) (int64, error) {
- var abs int64
- switch whence {
- case os.SEEK_SET: // Relative to the origin of the file
- abs = offset
- case os.SEEK_CUR: // Relative to the current offset
- abs = int64(v.ptr) + offset
- case os.SEEK_END: // Relative to the end
- abs = int64(len(*v.buf)) + offset
- default:
- return 0, errors.New("Seek: invalid whence")
- }
- if abs < 0 {
- return 0, errors.New("Seek: negative position")
- }
- if abs > int64(len(*v.buf)) {
- return 0, errors.New("Seek: too far")
- }
- v.ptr = abs
- return abs, nil
-}
-
-// Write writes len(p) byte to the Buffer.
-// It returns the number of bytes written and an error if any.
-// Write returns non-nil error when n!=len(p).
-func (v *Buf) Write(p []byte) (int, error) {
- l := len(p)
- writeEnd := int(v.ptr) + l - len(*v.buf)
- if writeEnd > 0 {
- err := v.grow(writeEnd)
- if err != nil {
- return 0, err
- }
- }
- copy((*v.buf)[v.ptr:], p)
- v.ptr += int64(l)
- return l, nil
-}
-
-// Close the buffer. Currently no effect.
-func (v *Buf) Close() error {
- return nil
-}
-
-// Read reads len(p) byte from the Buffer starting at the current offset.
-// It returns the number of bytes read and an error if any.
-// Returns io.EOF error if pointer is at the end of the Buffer.
-func (v *Buf) Read(p []byte) (n int, err error) {
- if len(p) == 0 {
- return 0, nil
- }
- if v.ptr >= int64(len(*v.buf)) {
- return 0, io.EOF
- }
-
- n = copy(p, (*v.buf)[v.ptr:])
- v.ptr += int64(n)
- return
-}
-
-// ReadAt reads len(b) bytes from the Buffer starting at byte offset off.
-// It returns the number of bytes read and the error, if any.
-// ReadAt always returns a non-nil error when n < len(b).
-// At end of file, that error is io.EOF.
-func (v *Buf) ReadAt(p []byte, off int64) (n int, err error) {
- if len(p) == 0 {
- return 0, nil
- }
- if off >= int64(len(*v.buf)) {
- return 0, io.EOF
- }
-
- n = copy(p, (*v.buf)[off:])
- if n < len(p) {
- err = io.EOF
- }
- return
-}
-
-// Truncate truncates the Buffer to a given size.
-// It returns an error if the given size is negative.
-// If the Buffer is larger than the specified size, the extra data is lost.
-// If the Buffer is smaller, it is extended and the extended part (hole)
-// reads as zero bytes.
-func (v *Buf) Truncate(size int64) (err error) {
- if size < 0 {
- return errors.New("Truncate: size must be non-negative")
- }
- if bufSize := int64(len(*v.buf)); size == bufSize {
- return nil
- } else if size < bufSize {
- *v.buf = (*v.buf)[:size]
- } else /* size > bufSize */ {
- growSize := int(size - bufSize)
- if err = v.grow(growSize); err != nil {
- return err
- }
- }
- return nil
-}
-
-func (v *Buf) grow(n int) error {
- m := len(*v.buf)
- if (m + n) > cap(*v.buf) {
- size := 2*cap(*v.buf) + MinBufferSize
- if size < m+n {
- size = m + n + MinBufferSize
- }
- buf, err := makeSlice(size)
- if err != nil {
- return err
- }
- copy(buf, *v.buf)
- *v.buf = buf
- }
- *v.buf = (*v.buf)[0 : m+n]
- return nil
-}
-
-// makeSlice allocates a slice of size n. If the allocation fails, it panics
-// with ErrTooLarge.
-func makeSlice(n int) (b []byte, err error) {
- // If the make fails, give a known error.
- defer func() {
- if recover() != nil {
- b = nil
- err = ErrTooLarge
- return
- }
- }()
- b = make([]byte, n)
- return
-}
diff --git a/vendor/github.com/blang/vfs/memfs/doc.go b/vendor/github.com/blang/vfs/memfs/doc.go
deleted file mode 100644
index 2cf9fce0..00000000
--- a/vendor/github.com/blang/vfs/memfs/doc.go
+++ /dev/null
@@ -1,2 +0,0 @@
-// Package memfs defines an in-memory filesystem
-package memfs
diff --git a/vendor/github.com/blang/vfs/memfs/memfile.go b/vendor/github.com/blang/vfs/memfs/memfile.go
deleted file mode 100644
index a44d27c0..00000000
--- a/vendor/github.com/blang/vfs/memfs/memfile.go
+++ /dev/null
@@ -1,89 +0,0 @@
-package memfs
-
-import (
- "sync"
-)
-
-// MemFile represents a file backed by a Buffer which is secured from concurrent access.
-type MemFile struct {
- Buffer
- mutex *sync.RWMutex
- name string
-}
-
-// NewMemFile creates a Buffer which byte slice is safe from concurrent access,
-// the file itself is not thread-safe.
-//
-// This means multiple files can work safely on the same byte slice,
-// but multiple go routines working on the same file may corrupt the internal pointer structure.
-func NewMemFile(name string, rwMutex *sync.RWMutex, buf *[]byte) *MemFile {
- return &MemFile{
- Buffer: NewBuffer(buf),
- mutex: rwMutex,
- name: name,
- }
-}
-
-// Name of the file
-func (b MemFile) Name() string {
- return b.name
-}
-
-// Sync has no effect
-func (b MemFile) Sync() error {
- return nil
-}
-
-// Truncate changes the size of the file
-func (b MemFile) Truncate(size int64) (err error) {
- b.mutex.Lock()
- err = b.Buffer.Truncate(size)
- b.mutex.Unlock()
- return
-}
-
-// Read reads len(p) byte from the underlying buffer starting at the current offset.
-// It returns the number of bytes read and an error if any.
-// Returns io.EOF error if pointer is at the end of the Buffer.
-// See Buf.Read()
-func (b *MemFile) Read(p []byte) (n int, err error) {
- b.mutex.RLock()
- n, err = b.Buffer.Read(p)
- b.mutex.RUnlock()
- return
-}
-
-// ReadAt reads len(b) bytes from the Buffer starting at byte offset off.
-// It returns the number of bytes read and the error, if any.
-// ReadAt always returns a non-nil error when n < len(b).
-// At end of file, that error is io.EOF.
-// See Buf.ReadAt()
-func (b *MemFile) ReadAt(p []byte, off int64) (n int, err error) {
- b.mutex.RLock()
- n, err = b.Buffer.ReadAt(p, off)
- b.mutex.RUnlock()
- return
-}
-
-// Write writes len(p) byte to the Buffer.
-// It returns the number of bytes written and an error if any.
-// Write returns non-nil error when n!=len(p).
-func (b *MemFile) Write(p []byte) (n int, err error) {
- b.mutex.Lock()
- n, err = b.Buffer.Write(p)
- b.mutex.Unlock()
- return
-}
-
-// Seek sets the offset for the next Read or Write on the buffer to offset,
-// interpreted according to whence:
-// 0 (os.SEEK_SET) means relative to the origin of the file
-// 1 (os.SEEK_CUR) means relative to the current offset
-// 2 (os.SEEK_END) means relative to the end of the file
-// It returns the new offset and an error, if any.
-func (b *MemFile) Seek(offset int64, whence int) (n int64, err error) {
- b.mutex.RLock()
- n, err = b.Buffer.Seek(offset, whence)
- b.mutex.RUnlock()
- return
-}
diff --git a/vendor/github.com/blang/vfs/memfs/memfs.go b/vendor/github.com/blang/vfs/memfs/memfs.go
deleted file mode 100644
index 6be44bd1..00000000
--- a/vendor/github.com/blang/vfs/memfs/memfs.go
+++ /dev/null
@@ -1,380 +0,0 @@
-package memfs
-
-import (
- "errors"
- "fmt"
- "os"
- filepath "path"
- "sort"
- "sync"
- "time"
-
- "github.com/blang/vfs"
-)
-
-var (
- // ErrReadOnly is returned if the file is read-only and write operations are disabled.
- ErrReadOnly = errors.New("File is read-only")
- // ErrWriteOnly is returned if the file is write-only and read operations are disabled.
- ErrWriteOnly = errors.New("File is write-only")
- // ErrIsDirectory is returned if the file under operation is not a regular file but a directory.
- ErrIsDirectory = errors.New("Is directory")
-)
-
-// PathSeparator used to separate path segments
-const PathSeparator = "/"
-
-// MemFS is a in-memory filesystem
-type MemFS struct {
- root *fileInfo
- wd *fileInfo
- lock *sync.RWMutex
-}
-
-// Create a new MemFS filesystem which entirely resides in memory
-func Create() *MemFS {
- root := &fileInfo{
- name: "/",
- dir: true,
- }
- return &MemFS{
- root: root,
- wd: root,
- lock: &sync.RWMutex{},
- }
-}
-
-type fileInfo struct {
- name string
- dir bool
- mode os.FileMode
- parent *fileInfo
- size int64
- modTime time.Time
- fs vfs.Filesystem
- childs map[string]*fileInfo
- buf *[]byte
- mutex *sync.RWMutex
-}
-
-func (fi fileInfo) Sys() interface{} {
- return fi.fs
-}
-
-func (fi fileInfo) Size() int64 {
- if fi.dir {
- return 0
- }
- fi.mutex.RLock()
- l := len(*(fi.buf))
- fi.mutex.RUnlock()
- return int64(l)
-}
-
-func (fi fileInfo) IsDir() bool {
- return fi.dir
-}
-
-// ModTime returns the modification time.
-// Modification time is updated on:
-// - Creation
-// - Rename
-// - Open (except with O_RDONLY)
-func (fi fileInfo) ModTime() time.Time {
- return fi.modTime
-}
-
-func (fi fileInfo) Mode() os.FileMode {
- return fi.mode
-}
-
-func (fi fileInfo) Name() string {
- return fi.name
-}
-
-func (fi fileInfo) AbsPath() string {
- if fi.parent != nil {
- return filepath.Join(fi.parent.AbsPath(), fi.name)
- }
- return "/"
-}
-
-// PathSeparator returns the path separator
-func (fs *MemFS) PathSeparator() uint8 {
- return '/'
-}
-
-// Mkdir creates a new directory with given permissions
-func (fs *MemFS) Mkdir(name string, perm os.FileMode) error {
- fs.lock.Lock()
- defer fs.lock.Unlock()
- name = filepath.Clean(name)
- base := filepath.Base(name)
- parent, fi, err := fs.fileInfo(name)
- if err != nil {
- return &os.PathError{"mkdir", name, err}
- }
- if fi != nil {
- return &os.PathError{"mkdir", name, fmt.Errorf("Directory %q already exists", name)}
- }
-
- fi = &fileInfo{
- name: base,
- dir: true,
- mode: perm,
- parent: parent,
- modTime: time.Now(),
- fs: fs,
- }
- parent.childs[base] = fi
- return nil
-}
-
-// byName implements sort.Interface
-type byName []os.FileInfo
-
-// Len returns the length of the slice
-func (f byName) Len() int { return len(f) }
-
-// Less sorts slice by Name
-func (f byName) Less(i, j int) bool { return f[i].Name() < f[j].Name() }
-
-// Swap two elements by index
-func (f byName) Swap(i, j int) { f[i], f[j] = f[j], f[i] }
-
-// ReadDir reads the directory named by path and returns a list of sorted directory entries.
-func (fs *MemFS) ReadDir(path string) ([]os.FileInfo, error) {
- fs.lock.RLock()
- defer fs.lock.RUnlock()
-
- path = filepath.Clean(path)
- _, fi, err := fs.fileInfo(path)
- if err != nil {
- return nil, &os.PathError{"readdir", path, err}
- }
- if fi == nil || !fi.dir {
- return nil, &os.PathError{"readdir", path, vfs.ErrNotDirectory}
- }
-
- fis := make([]os.FileInfo, 0, len(fi.childs))
- for _, e := range fi.childs {
- fis = append(fis, e)
- }
- sort.Sort(byName(fis))
- return fis, nil
-}
-
-func (fs *MemFS) fileInfo(path string) (parent *fileInfo, node *fileInfo, err error) {
- path = filepath.Clean(path)
- segments := vfs.SplitPath(path, PathSeparator)
-
- // Shortcut for working directory and root
- if len(segments) == 1 {
- if segments[0] == "" {
- return nil, fs.root, nil
- } else if segments[0] == "." {
- return fs.wd.parent, fs.wd, nil
- }
- }
-
- // Determine root to traverse
- parent = fs.root
- if segments[0] == "." {
- parent = fs.wd
- }
- segments = segments[1:]
-
- // Further directories
- if len(segments) > 1 {
- for _, seg := range segments[:len(segments)-1] {
-
- if parent.childs == nil {
- return nil, nil, os.ErrNotExist
- }
- if entry, ok := parent.childs[seg]; ok && entry.dir {
- parent = entry
- } else {
- return nil, nil, os.ErrNotExist
- }
- }
- }
-
- lastSeg := segments[len(segments)-1]
- if parent.childs != nil {
- if node, ok := parent.childs[lastSeg]; ok {
- return parent, node, nil
- }
- } else {
- parent.childs = make(map[string]*fileInfo)
- }
-
- return parent, nil, nil
-}
-
-func hasFlag(flag int, flags int) bool {
- return flags&flag == flag
-}
-
-// OpenFile opens a file handle with a specified flag (os.O_RDONLY etc.) and perm (e.g. 0666).
-// If success the returned File can be used for I/O. Otherwise an error is returned, which
-// is a *os.PathError and can be extracted for further information.
-func (fs *MemFS) OpenFile(name string, flag int, perm os.FileMode) (vfs.File, error) {
- fs.lock.Lock()
- defer fs.lock.Unlock()
-
- name = filepath.Clean(name)
- base := filepath.Base(name)
- fiParent, fiNode, err := fs.fileInfo(name)
- if err != nil {
- return nil, &os.PathError{"open", name, err}
- }
-
- if fiNode == nil {
- if !hasFlag(os.O_CREATE, flag) {
- return nil, &os.PathError{"open", name, os.ErrNotExist}
- }
- fiNode = &fileInfo{
- name: base,
- dir: false,
- mode: perm,
- parent: fiParent,
- modTime: time.Now(),
- fs: fs,
- }
- fiParent.childs[base] = fiNode
- } else { // file exists
- if hasFlag(os.O_CREATE|os.O_EXCL, flag) {
- return nil, &os.PathError{"open", name, os.ErrExist}
- }
- if fiNode.dir {
- return nil, &os.PathError{"open", name, ErrIsDirectory}
- }
- }
-
- if !hasFlag(os.O_RDONLY, flag) {
- fiNode.modTime = time.Now()
- }
- return fiNode.file(flag)
-}
-
-func (fi *fileInfo) file(flag int) (vfs.File, error) {
- if fi.buf == nil || hasFlag(os.O_TRUNC, flag) {
- buf := make([]byte, 0, MinBufferSize)
- fi.buf = &buf
- fi.mutex = &sync.RWMutex{}
- }
- var f vfs.File = NewMemFile(fi.AbsPath(), fi.mutex, fi.buf)
- if hasFlag(os.O_APPEND, flag) {
- f.Seek(0, os.SEEK_END)
- }
- if hasFlag(os.O_RDWR, flag) {
- return f, nil
- } else if hasFlag(os.O_WRONLY, flag) {
- f = &woFile{f}
- } else {
- f = &roFile{f}
- }
-
- return f, nil
-}
-
-// roFile wraps the given file and disables Write(..) operation.
-type roFile struct {
- vfs.File
-}
-
-// Write is disabled and returns ErrorReadOnly
-func (f *roFile) Write(p []byte) (n int, err error) {
- return 0, ErrReadOnly
-}
-
-// woFile wraps the given file and disables Read(..) operation.
-type woFile struct {
- vfs.File
-}
-
-// Read is disabled and returns ErrorWroteOnly
-func (f *woFile) Read(p []byte) (n int, err error) {
- return 0, ErrWriteOnly
-}
-
-// Remove removes the named file or directory.
-// If there is an error, it will be of type *PathError.
-func (fs *MemFS) Remove(name string) error {
- fs.lock.Lock()
- defer fs.lock.Unlock()
-
- name = filepath.Clean(name)
- fiParent, fiNode, err := fs.fileInfo(name)
- if err != nil {
- return &os.PathError{"remove", name, err}
- }
- if fiNode == nil {
- return &os.PathError{"remove", name, os.ErrNotExist}
- }
-
- delete(fiParent.childs, fiNode.name)
- return nil
-}
-
-// Rename renames (moves) a file.
-// Handles to the oldpath persist but might return oldpath if Name() is called.
-func (fs *MemFS) Rename(oldpath, newpath string) error {
- fs.lock.Lock()
- defer fs.lock.Unlock()
-
- // OldPath
- oldpath = filepath.Clean(oldpath)
- fiOldParent, fiOld, err := fs.fileInfo(oldpath)
- if err != nil {
- return &os.PathError{"rename", oldpath, err}
- }
- if fiOld == nil {
- return &os.PathError{"rename", oldpath, os.ErrNotExist}
- }
-
- newpath = filepath.Clean(newpath)
- fiNewParent, fiNew, err := fs.fileInfo(newpath)
- if err != nil {
- return &os.PathError{"rename", newpath, err}
- }
-
- if fiNew != nil {
- return &os.PathError{"rename", newpath, os.ErrExist}
- }
-
- newBase := filepath.Base(newpath)
-
- // Relink
- delete(fiOldParent.childs, fiOld.name)
- fiOld.parent = fiNewParent
- fiOld.name = newBase
- fiOld.modTime = time.Now()
- fiNewParent.childs[fiOld.name] = fiOld
- return nil
-}
-
-// Stat returns the FileInfo structure describing the named file.
-// If there is an error, it will be of type *PathError.
-func (fs *MemFS) Stat(name string) (os.FileInfo, error) {
- fs.lock.RLock()
- defer fs.lock.RUnlock()
-
- name = filepath.Clean(name)
- // dir, base := filepath.Split(name)
- _, fi, err := fs.fileInfo(name)
- if err != nil {
- return nil, &os.PathError{"stat", name, err}
- }
- if fi == nil {
- return nil, &os.PathError{"stat", name, os.ErrNotExist}
- }
- return fi, nil
-}
-
-// Lstat returns a FileInfo describing the named file.
-// MemFS does not support symbolic links.
-// Alias for fs.Stat(name)
-func (fs *MemFS) Lstat(name string) (os.FileInfo, error) {
- return fs.Stat(name)
-}
diff --git a/vendor/github.com/blang/vfs/os.go b/vendor/github.com/blang/vfs/os.go
deleted file mode 100644
index feb33bb8..00000000
--- a/vendor/github.com/blang/vfs/os.go
+++ /dev/null
@@ -1,54 +0,0 @@
-package vfs
-
-import (
- "io/ioutil"
- "os"
-)
-
-// OsFS represents a filesystem backed by the filesystem of the underlying OS.
-type OsFS struct{}
-
-// OS returns a filesystem backed by the filesystem of the os. It wraps os.* stdlib operations.
-func OS() *OsFS {
- return &OsFS{}
-}
-
-// PathSeparator returns the path separator
-func (fs OsFS) PathSeparator() uint8 {
- return os.PathSeparator
-}
-
-// OpenFile wraps os.OpenFile
-func (fs OsFS) OpenFile(name string, flag int, perm os.FileMode) (File, error) {
- return os.OpenFile(name, flag, perm)
-}
-
-// Remove wraps os.Remove
-func (fs OsFS) Remove(name string) error {
- return os.Remove(name)
-}
-
-// Mkdir wraps os.Mkdir
-func (fs OsFS) Mkdir(name string, perm os.FileMode) error {
- return os.Mkdir(name, perm)
-}
-
-// Rename wraps os.Rename
-func (fs OsFS) Rename(oldpath, newpath string) error {
- return os.Rename(oldpath, newpath)
-}
-
-// Stat wraps os.Stat
-func (fs OsFS) Stat(name string) (os.FileInfo, error) {
- return os.Stat(name)
-}
-
-// Lstat wraps os.Lstat
-func (fs OsFS) Lstat(name string) (os.FileInfo, error) {
- return os.Lstat(name)
-}
-
-// ReadDir wraps ioutil.ReadDir
-func (fs OsFS) ReadDir(path string) ([]os.FileInfo, error) {
- return ioutil.ReadDir(path)
-}
diff --git a/vendor/github.com/blang/vfs/path.go b/vendor/github.com/blang/vfs/path.go
deleted file mode 100644
index 722e2497..00000000
--- a/vendor/github.com/blang/vfs/path.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package vfs
-
-import (
- "strings"
-)
-
-// SplitPath splits the given path in segments:
-// "/" -> []string{""}
-// "./file" -> []string{".", "file"}
-// "file" -> []string{".", "file"}
-// "/usr/src/linux/" -> []string{"", "usr", "src", "linux"}
-// The returned slice of path segments consists of one more more segments.
-func SplitPath(path string, sep string) []string {
- path = strings.TrimSpace(path)
- path = strings.TrimSuffix(path, sep)
- if path == "" { // was "/"
- return []string{""}
- }
- if path == "." {
- return []string{"."}
- }
-
- if len(path) > 0 && !strings.HasPrefix(path, sep) && !strings.HasPrefix(path, "."+sep) {
- path = "./" + path
- }
- parts := strings.Split(path, sep)
-
- return parts
-}
diff --git a/vendor/github.com/blang/vfs/readonly.go b/vendor/github.com/blang/vfs/readonly.go
deleted file mode 100644
index 406cd84f..00000000
--- a/vendor/github.com/blang/vfs/readonly.go
+++ /dev/null
@@ -1,78 +0,0 @@
-package vfs
-
-import (
- "errors"
- "os"
-)
-
-// ReadOnly creates a readonly wrapper around the given filesystem.
-// It disables the following operations:
-//
-// - Create
-// - Remove
-// - Rename
-// - Mkdir
-//
-// And disables OpenFile flags: os.O_CREATE, os.O_APPEND, os.O_WRONLY
-//
-// OpenFile returns a File with disabled Write() method otherwise.
-func ReadOnly(fs Filesystem) *RoFS {
- return &RoFS{Filesystem: fs}
-}
-
-// RoFS represents a read-only filesystem and
-// works as a wrapper around existing filesystems.
-type RoFS struct {
- Filesystem
-}
-
-// ErrorReadOnly is returned on every disabled operation.
-var ErrReadOnly = errors.New("Filesystem is read-only")
-
-// Remove is disabled and returns ErrorReadOnly
-func (fs RoFS) Remove(name string) error {
- return ErrReadOnly
-}
-
-// Rename is disabled and returns ErrorReadOnly
-func (fs RoFS) Rename(oldpath, newpath string) error {
- return ErrReadOnly
-}
-
-// Mkdir is disabled and returns ErrorReadOnly
-func (fs RoFS) Mkdir(name string, perm os.FileMode) error {
- return ErrReadOnly
-}
-
-// OpenFile returns ErrorReadOnly if flag contains os.O_CREATE, os.O_APPEND, os.O_WRONLY.
-// Otherwise it returns a read-only File with disabled Write(..) operation.
-func (fs RoFS) OpenFile(name string, flag int, perm os.FileMode) (File, error) {
- if flag&os.O_CREATE == os.O_CREATE {
- return nil, ErrReadOnly
- }
- if flag&os.O_APPEND == os.O_APPEND {
- return nil, ErrReadOnly
- }
- if flag&os.O_WRONLY == os.O_WRONLY {
- return nil, ErrReadOnly
- }
- f, err := fs.Filesystem.OpenFile(name, flag, perm)
- if err != nil {
- return ReadOnlyFile(f), err
- }
- return ReadOnlyFile(f), nil
-}
-
-// ReadOnlyFile wraps the given file and disables Write(..) operation.
-func ReadOnlyFile(f File) File {
- return &roFile{f}
-}
-
-type roFile struct {
- File
-}
-
-// Write is disabled and returns ErrorReadOnly
-func (f roFile) Write(p []byte) (n int, err error) {
- return 0, ErrReadOnly
-}