aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/nsheridan
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/nsheridan')
-rw-r--r--vendor/github.com/nsheridan/autocert-wkfs-cache/License.txt21
-rw-r--r--vendor/github.com/nsheridan/autocert-wkfs-cache/cache.go85
-rw-r--r--vendor/github.com/nsheridan/wkfs/License.txt21
-rw-r--r--vendor/github.com/nsheridan/wkfs/s3/README.md41
-rw-r--r--vendor/github.com/nsheridan/wkfs/s3/s3.go201
-rw-r--r--vendor/github.com/nsheridan/wkfs/s3/s3_file.go59
6 files changed, 0 insertions, 428 deletions
diff --git a/vendor/github.com/nsheridan/autocert-wkfs-cache/License.txt b/vendor/github.com/nsheridan/autocert-wkfs-cache/License.txt
deleted file mode 100644
index 09dc147..0000000
--- a/vendor/github.com/nsheridan/autocert-wkfs-cache/License.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2017 Niall Sheridan
-
-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/nsheridan/autocert-wkfs-cache/cache.go b/vendor/github.com/nsheridan/autocert-wkfs-cache/cache.go
deleted file mode 100644
index 3b3fd47..0000000
--- a/vendor/github.com/nsheridan/autocert-wkfs-cache/cache.go
+++ /dev/null
@@ -1,85 +0,0 @@
-package wkfscache
-
-import (
- "context"
- "os"
- "path/filepath"
-
- "go4.org/wkfs"
-
- "golang.org/x/crypto/acme/autocert"
-)
-
-type Cache string
-
-// Get reads a certificate data from the specified file name.
-func (d Cache) Get(ctx context.Context, name string) ([]byte, error) {
- name = filepath.Join(string(d), name)
- var (
- data []byte
- err error
- done = make(chan struct{})
- )
- go func() {
- data, err = wkfs.ReadFile(name)
- close(done)
- }()
- select {
- case <-ctx.Done():
- return nil, ctx.Err()
- case <-done:
- }
- if os.IsNotExist(err) {
- return nil, autocert.ErrCacheMiss
- }
- return data, err
-}
-
-// Put writes the certificate data to the specified file name.
-// The file will be created with 0600 permissions.
-func (d Cache) Put(ctx context.Context, name string, data []byte) error {
- if err := wkfs.MkdirAll(string(d), 0700); err != nil {
- return err
- }
-
- done := make(chan struct{})
- var err error
- go func() {
- defer close(done)
- if err := wkfs.WriteFile(filepath.Join(string(d), name), data, 0600); err != nil {
- return
- }
- // prevent overwriting the file if the context was cancelled
- if ctx.Err() != nil {
- return // no need to set err
- }
- }()
- select {
- case <-ctx.Done():
- return ctx.Err()
- case <-done:
- }
- return err
-}
-
-// Delete removes the specified file name.
-func (d Cache) Delete(ctx context.Context, name string) error {
- name = filepath.Join(string(d), name)
- var (
- err error
- done = make(chan struct{})
- )
- go func() {
- err = wkfs.Remove(name)
- close(done)
- }()
- select {
- case <-ctx.Done():
- return ctx.Err()
- case <-done:
- }
- if err != nil && !os.IsNotExist(err) {
- return err
- }
- return nil
-}
diff --git a/vendor/github.com/nsheridan/wkfs/License.txt b/vendor/github.com/nsheridan/wkfs/License.txt
deleted file mode 100644
index 09dc147..0000000
--- a/vendor/github.com/nsheridan/wkfs/License.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2017 Niall Sheridan
-
-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/nsheridan/wkfs/s3/README.md b/vendor/github.com/nsheridan/wkfs/s3/README.md
deleted file mode 100644
index 177f738..0000000
--- a/vendor/github.com/nsheridan/wkfs/s3/README.md
+++ /dev/null
@@ -1,41 +0,0 @@
-## S3 plugin for WKFS
-
-
-
-Package `s3` registers an AWS S3 filesystem at the well-known `/s3/` filesystem path.
-
-Sample usage:
-
-```go
-package main
-
-import (
- "fmt"
- "io"
- "log"
-
- "github.com/nsheridan/wkfs/s3"
- "go4.org/wkfs"
-)
-
-func main() {
- opts := &s3.Options{
- Region: "us-east-1"
- AccessKey: "abcdef"
- SecretKey: "secret"
- }
- s3.Register(opts)
- f, err := wkfs.Create("/s3/some-bucket/hello.txt")
- if err != nil {
- log.Fatal(err)
- }
- _, err := io.WriteString(f, "hello, world")
- if err != nil {
- log.Fatal(err)
- }
-}
-```
-
-
-
-`Options` are completely optional as the AWS SDK will attempt to obtain credentials from a number of locations - see [the documentation for details](http://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html) - e.g. if you're using environment variables you can register the filesystem with `s3.Register(nil)`.
diff --git a/vendor/github.com/nsheridan/wkfs/s3/s3.go b/vendor/github.com/nsheridan/wkfs/s3/s3.go
deleted file mode 100644
index de44f93..0000000
--- a/vendor/github.com/nsheridan/wkfs/s3/s3.go
+++ /dev/null
@@ -1,201 +0,0 @@
-package s3
-
-import (
- "bytes"
- "errors"
- "fmt"
- "io/ioutil"
- "os"
- "path"
- "path/filepath"
- "strings"
- "time"
-
- "go4.org/wkfs"
-
- "github.com/aws/aws-sdk-go/aws"
- "github.com/aws/aws-sdk-go/aws/awserr"
- "github.com/aws/aws-sdk-go/aws/credentials"
- "github.com/aws/aws-sdk-go/aws/session"
- "github.com/aws/aws-sdk-go/service/s3"
-)
-
-// Options for registering the S3 wkfs.
-// None of these are required and can be supplied to the aws client by other means.
-type Options struct {
- Region string
- AccessKey string
- SecretKey string
-}
-
-var _ wkfs.FileSystem = (*s3FS)(nil)
-
-// Register the /s3/ filesystem as a well-known filesystem.
-func Register(opts *Options) {
- if opts == nil {
- opts = &Options{}
- }
- config := &aws.Config{}
- // If region is unset the SDK will attempt to read the region from the environment.
- if opts.Region != "" {
- config.Region = aws.String(opts.Region)
- }
- // Attempt to use supplied credentials, otherwise fall back to the SDK.
- if opts.AccessKey != "" && opts.SecretKey != "" {
- config.Credentials = credentials.NewStaticCredentials(opts.AccessKey, opts.SecretKey, "")
- }
- s, err := session.NewSession(config)
- if err != nil {
- registerBrokenFS(err)
- return
- }
- sc := s3.New(s)
- if aws.StringValue(sc.Config.Region) == "" {
- registerBrokenFS(errors.New("could not find region configuration"))
- return
- }
- wkfs.RegisterFS("/s3/", &s3FS{
- sc: sc,
- })
-}
-
-func registerBrokenFS(err error) {
- wkfs.RegisterFS("/s3/", &s3FS{
- err: err,
- })
-}
-
-type s3FS struct {
- sc *s3.S3
- err error
-}
-
-func (fs *s3FS) parseName(name string) (bucket, fileName string, err error) {
- if fs.err != nil {
- return "", "", fs.err
- }
- name = strings.TrimPrefix(name, "/s3/")
- i := strings.Index(name, "/")
- if i < 0 {
- return name, "", nil
- }
- return name[:i], name[i+1:], nil
-}
-
-// Open opens the named file for reading.
-func (fs *s3FS) Open(name string) (wkfs.File, error) {
- bucket, fileName, err := fs.parseName(name)
- if err != nil {
- return nil, err
- }
- obj, err := fs.sc.GetObject(&s3.GetObjectInput{
- Bucket: &bucket,
- Key: &fileName,
- })
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case "NoSuchKey", "NoSuchBucket":
- return nil, os.ErrNotExist
- }
- }
- return nil, err
- }
- defer obj.Body.Close()
- slurp, err := ioutil.ReadAll(obj.Body)
- if err != nil {
- return nil, err
- }
- return &file{
- name: name,
- Reader: bytes.NewReader(slurp),
- }, nil
-}
-
-func (fs *s3FS) Stat(name string) (os.FileInfo, error) { return fs.Lstat(name) }
-func (fs *s3FS) Lstat(name string) (os.FileInfo, error) {
- bucket, fileName, err := fs.parseName(name)
- if err != nil {
- return nil, err
- }
- obj, err := fs.sc.GetObject(&s3.GetObjectInput{
- Bucket: &bucket,
- Key: &fileName,
- })
- if err != nil {
- if awsErr, ok := err.(awserr.Error); ok {
- if awsErr.Code() == "NoSuchKey" {
- return nil, os.ErrNotExist
- }
- }
- }
- if err != nil {
- return nil, err
- }
- return &statInfo{
- name: path.Base(fileName),
- size: *obj.ContentLength,
- }, nil
-}
-
-func (fs *s3FS) MkdirAll(path string, perm os.FileMode) error {
- _, err := fs.OpenFile(fmt.Sprintf("%s/", filepath.Clean(path)), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm)
- return err
-}
-
-func (fs *s3FS) OpenFile(name string, flag int, perm os.FileMode) (wkfs.FileWriter, error) {
- bucket, filename, err := fs.parseName(name)
- if err != nil {
- return nil, err
- }
- switch flag {
- case os.O_WRONLY | os.O_CREATE | os.O_EXCL:
- case os.O_WRONLY | os.O_CREATE | os.O_TRUNC:
- default:
- return nil, fmt.Errorf("Unsupported OpenFlag flag mode %d on S3", flag)
- }
- if flag&os.O_EXCL != 0 {
- if _, err := fs.Stat(name); err == nil {
- return nil, os.ErrExist
- }
- }
- return NewS3file(bucket, filename, fs.sc)
-}
-
-func (fs *s3FS) Remove(name string) error {
- var err error
- bucket, filename, err := fs.parseName(name)
- if err != nil {
- return err
- }
- _, err = fs.sc.DeleteObject(&s3.DeleteObjectInput{
- Bucket: aws.String(bucket),
- Key: aws.String(filename),
- })
- return err
-}
-
-type statInfo struct {
- name string
- size int64
- isDir bool
- modtime time.Time
-}
-
-func (si *statInfo) IsDir() bool { return si.isDir }
-func (si *statInfo) ModTime() time.Time { return si.modtime }
-func (si *statInfo) Mode() os.FileMode { return 0644 }
-func (si *statInfo) Name() string { return path.Base(si.name) }
-func (si *statInfo) Size() int64 { return si.size }
-func (si *statInfo) Sys() interface{} { return nil }
-
-type file struct {
- name string
- *bytes.Reader
-}
-
-func (*file) Close() error { return nil }
-func (f *file) Name() string { return path.Base(f.name) }
-func (f *file) Stat() (os.FileInfo, error) {
- panic("Stat not implemented on /s3/ files yet")
-}
diff --git a/vendor/github.com/nsheridan/wkfs/s3/s3_file.go b/vendor/github.com/nsheridan/wkfs/s3/s3_file.go
deleted file mode 100644
index c04597e..0000000
--- a/vendor/github.com/nsheridan/wkfs/s3/s3_file.go
+++ /dev/null
@@ -1,59 +0,0 @@
-package s3
-
-import (
- "bytes"
- "errors"
-
- "github.com/aws/aws-sdk-go/aws"
- "github.com/aws/aws-sdk-go/service/s3"
-)
-
-// S3file represents a file in S3.
-type S3file struct {
- bucket string
- name string
- offset int
- closed bool
-
- s3api *s3.S3
-}
-
-// NewS3file initializes an S3file.
-func NewS3file(bucket, name string, s3api *s3.S3) (*S3file, error) {
- return &S3file{
- bucket: bucket,
- name: name,
- offset: 0,
- closed: false,
- s3api: s3api,
- }, nil
-}
-
-// Write len(p) bytes to the file in S3.
-// It returns the number of bytes written and an error, if any.
-func (f *S3file) Write(p []byte) (n int, err error) {
- if f.closed {
- panic("read after close")
- }
- if f.offset != 0 {
- return 0, errors.New("Offset cannot be > 0")
- }
- readSeeker := bytes.NewReader(p)
- size := int(readSeeker.Size())
- obj := &s3.PutObjectInput{
- Bucket: aws.String(f.bucket),
- Key: aws.String(f.name),
- Body: readSeeker,
- }
- if _, err := f.s3api.PutObject(obj); err != nil {
- return 0, err
- }
- f.offset += size
- return size, nil
-}
-
-// Close the file, rendering it unusable.
-func (f *S3file) Close() error {
- f.closed = true
- return nil
-}