summaryrefslogtreecommitdiffstats
path: root/vendor/github.com
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-04-24 20:11:36 -0400
committerJoram Wilander <jwawilander@gmail.com>2017-04-24 20:11:36 -0400
commitf5437632f486b7d0a0a181c58f113c86d032b02c (patch)
tree407388e3003a210a89f4b2128d7ad656f8b79d26 /vendor/github.com
parent7f68a60f8c228d5604e0566bf84cabb145d16c37 (diff)
downloadchat-f5437632f486b7d0a0a181c58f113c86d032b02c.tar.gz
chat-f5437632f486b7d0a0a181c58f113c86d032b02c.tar.bz2
chat-f5437632f486b7d0a0a181c58f113c86d032b02c.zip
Upgrading server dependancies (#6215)
Diffstat (limited to 'vendor/github.com')
-rw-r--r--vendor/github.com/NYTimes/gziphandler/.travis.yml1
-rw-r--r--vendor/github.com/NYTimes/gziphandler/README.md4
-rw-r--r--vendor/github.com/NYTimes/gziphandler/gzip.go127
-rw-r--r--vendor/github.com/NYTimes/gziphandler/gzip_go18.go43
-rw-r--r--vendor/github.com/NYTimes/gziphandler/gzip_go18_test.go70
-rw-r--r--vendor/github.com/NYTimes/gziphandler/gzip_test.go69
-rw-r--r--vendor/github.com/cpanato/html2text/.gitignore (renamed from vendor/github.com/jaytaylor/html2text/.gitignore)0
-rw-r--r--vendor/github.com/cpanato/html2text/.travis.yml (renamed from vendor/github.com/jaytaylor/html2text/.travis.yml)0
-rw-r--r--vendor/github.com/cpanato/html2text/LICENSE (renamed from vendor/github.com/jaytaylor/html2text/LICENSE)0
-rw-r--r--vendor/github.com/cpanato/html2text/README.md (renamed from vendor/github.com/jaytaylor/html2text/README.md)34
-rw-r--r--vendor/github.com/cpanato/html2text/html2text.go (renamed from vendor/github.com/jaytaylor/html2text/html2text.go)14
-rw-r--r--vendor/github.com/cpanato/html2text/html2text_test.go (renamed from vendor/github.com/jaytaylor/html2text/html2text_test.go)0
-rwxr-xr-xvendor/github.com/cpanato/html2text/testdata/utf8.html (renamed from vendor/github.com/jaytaylor/html2text/testdata/utf8.html)0
-rwxr-xr-xvendor/github.com/cpanato/html2text/testdata/utf8_with_bom.xhtml (renamed from vendor/github.com/jaytaylor/html2text/testdata/utf8_with_bom.xhtml)0
-rw-r--r--vendor/github.com/disintegration/imaging/.travis.yml1
-rw-r--r--vendor/github.com/disintegration/imaging/LICENSE2
-rw-r--r--vendor/github.com/disintegration/imaging/README.md191
-rw-r--r--vendor/github.com/disintegration/imaging/adjust_test.go60
-rw-r--r--vendor/github.com/disintegration/imaging/convolution.go148
-rw-r--r--vendor/github.com/disintegration/imaging/convolution_test.go275
-rw-r--r--vendor/github.com/disintegration/imaging/effects.go36
-rw-r--r--vendor/github.com/disintegration/imaging/effects_test.go64
-rw-r--r--vendor/github.com/disintegration/imaging/example_test.go58
-rw-r--r--vendor/github.com/disintegration/imaging/helpers.go44
-rw-r--r--vendor/github.com/disintegration/imaging/histogram.go2
-rw-r--r--vendor/github.com/disintegration/imaging/histogram_test.go2
-rw-r--r--vendor/github.com/disintegration/imaging/resize.go132
-rw-r--r--vendor/github.com/disintegration/imaging/resize_test.go68
-rw-r--r--vendor/github.com/disintegration/imaging/testdata/lena_128.pngbin0 -> 50383 bytes
-rw-r--r--vendor/github.com/disintegration/imaging/testdata/lena_512.pngbin0 -> 476195 bytes
-rw-r--r--vendor/github.com/disintegration/imaging/testdata/out_blur_0.5.pngbin0 -> 29110 bytes
-rw-r--r--vendor/github.com/disintegration/imaging/testdata/out_blur_1.5.pngbin0 -> 21067 bytes
-rw-r--r--vendor/github.com/disintegration/imaging/testdata/out_brightness_m10.pngbin0 -> 31562 bytes
-rw-r--r--vendor/github.com/disintegration/imaging/testdata/out_brightness_p10.pngbin0 -> 31532 bytes
-rw-r--r--vendor/github.com/disintegration/imaging/testdata/out_contrast_m10.pngbin0 -> 30812 bytes
-rw-r--r--vendor/github.com/disintegration/imaging/testdata/out_contrast_p10.pngbin0 -> 32615 bytes
-rw-r--r--vendor/github.com/disintegration/imaging/testdata/out_example.jpgbin0 -> 137574 bytes
-rw-r--r--vendor/github.com/disintegration/imaging/testdata/out_gamma_0.75.pngbin0 -> 31901 bytes
-rw-r--r--vendor/github.com/disintegration/imaging/testdata/out_gamma_1.25.pngbin0 -> 31295 bytes
-rw-r--r--vendor/github.com/disintegration/imaging/testdata/out_resize_catrom.pngbin0 -> 31179 bytes
-rw-r--r--vendor/github.com/disintegration/imaging/testdata/out_resize_lanczos.pngbin0 -> 32070 bytes
-rw-r--r--vendor/github.com/disintegration/imaging/testdata/out_resize_linear.pngbin0 -> 29475 bytes
-rw-r--r--vendor/github.com/disintegration/imaging/testdata/out_resize_nearest.pngbin0 -> 35790 bytes
-rw-r--r--vendor/github.com/disintegration/imaging/testdata/out_sharpen_0.5.pngbin0 -> 33936 bytes
-rw-r--r--vendor/github.com/disintegration/imaging/testdata/out_sharpen_1.5.pngbin0 -> 36632 bytes
-rw-r--r--vendor/github.com/disintegration/imaging/tools.go1
-rw-r--r--vendor/github.com/disintegration/imaging/tools_test.go2
-rw-r--r--vendor/github.com/disintegration/imaging/utils.go42
-rw-r--r--vendor/github.com/disintegration/imaging/utils_test.go24
-rw-r--r--vendor/github.com/golang/freetype/truetype/truetype.go13
-rw-r--r--vendor/github.com/hashicorp/hcl/json/parser/parser.go2
-rw-r--r--vendor/github.com/lib/pq/conn.go6
-rw-r--r--vendor/github.com/miekg/dns/README.md2
-rw-r--r--vendor/github.com/miekg/dns/dnssec.go2
-rw-r--r--vendor/github.com/miekg/dns/labels.go3
-rw-r--r--vendor/github.com/miekg/dns/labels_test.go3
-rw-r--r--vendor/github.com/miekg/dns/msg.go20
-rw-r--r--vendor/github.com/miekg/dns/msg_test.go124
-rw-r--r--vendor/github.com/miekg/dns/nsecx.go74
-rw-r--r--vendor/github.com/miekg/dns/nsecx_test.go126
-rw-r--r--vendor/github.com/miekg/dns/parse_test.go18
-rw-r--r--vendor/github.com/miekg/dns/scan_rr.go13
-rw-r--r--vendor/github.com/miekg/dns/types.go8
-rw-r--r--vendor/github.com/miekg/dns/zcompress.go122
-rw-r--r--vendor/github.com/miekg/dns/zmsg.go32
-rw-r--r--vendor/github.com/miekg/dns/ztypes.go15
-rw-r--r--vendor/github.com/minio/minio-go/README.md3
-rw-r--r--vendor/github.com/minio/minio-go/api-error-response.go10
-rw-r--r--vendor/github.com/minio/minio-go/api-get-object.go37
-rw-r--r--vendor/github.com/minio/minio-go/api.go43
-rw-r--r--vendor/github.com/minio/minio-go/api_functional_v2_test.go2
-rw-r--r--vendor/github.com/minio/minio-go/api_functional_v4_test.go153
-rw-r--r--vendor/github.com/minio/minio-go/bucket-cache.go7
-rw-r--r--vendor/github.com/minio/minio-go/copy-conditions.go10
-rw-r--r--vendor/github.com/minio/minio-go/docs/API.md89
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/copyobject.go2
-rw-r--r--vendor/github.com/minio/minio-go/examples/s3/putobject-s3-accelerate.go56
-rw-r--r--vendor/github.com/minio/minio-go/pkg/s3utils/utils.go12
-rw-r--r--vendor/github.com/minio/minio-go/pkg/set/stringset.go8
-rw-r--r--vendor/github.com/minio/minio-go/pkg/set/stringset_test.go25
-rw-r--r--vendor/github.com/mitchellh/mapstructure/.travis.yml2
-rw-r--r--vendor/github.com/mitchellh/mapstructure/decode_hooks.go8
-rw-r--r--vendor/github.com/mitchellh/mapstructure/mapstructure.go11
-rw-r--r--vendor/github.com/mitchellh/mapstructure/mapstructure_test.go2
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/.travis.yml1
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/README.md66
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/constants_command.go1
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command.go95
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command_flat_test.go36
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command_test.go3
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.json34
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.toml25
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.yaml25
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/ar-ar.all.json43
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/ar-ar.untranslated.json32
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.all.json27
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.untranslated.json1
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.untranslated.json.json0
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/fr-fr.all.json27
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/fr-fr.untranslated.json27
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/ar-ar.one.toml37
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/ar-ar.two.json45
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.constants.json34
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.one.yaml16
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.two.json19
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/fr-fr.json0
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/i18n/bundle/bundle.go101
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/i18n/translation/plural_translation.go4
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/i18n/translation/single_translation.go4
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/i18n/translation/template.go4
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/i18n/translation/translation.go1
-rw-r--r--vendor/github.com/nicksnyder/go-i18n/i18n/translations_test.go89
-rw-r--r--vendor/github.com/pelletier/go-toml/marshal.go22
-rw-r--r--vendor/github.com/pelletier/go-toml/marshal_test.go48
-rw-r--r--vendor/github.com/pelletier/go-toml/tomltree_write.go3
-rw-r--r--vendor/github.com/prometheus/common/.travis.yml3
-rw-r--r--vendor/github.com/prometheus/common/route/route.go50
-rw-r--r--vendor/github.com/prometheus/common/route/route_test.go45
-rw-r--r--vendor/github.com/prometheus/procfs/sysfs/doc.go16
-rw-r--r--vendor/github.com/prometheus/procfs/sysfs/fixtures/fs/xfs/sda1/stats/stats1
-rw-r--r--vendor/github.com/prometheus/procfs/sysfs/fixtures/fs/xfs/sdb1/stats/stats1
-rw-r--r--vendor/github.com/prometheus/procfs/sysfs/fs.go82
-rw-r--r--vendor/github.com/prometheus/procfs/sysfs/fs_test.go66
-rw-r--r--vendor/github.com/prometheus/procfs/xfs/parse.go2
-rw-r--r--vendor/github.com/prometheus/procfs/xfs/parse_test.go6
-rw-r--r--vendor/github.com/prometheus/procfs/xfs/xfs.go5
-rw-r--r--vendor/github.com/spf13/cast/cast.go6
-rw-r--r--vendor/github.com/spf13/cast/cast_test.go32
-rw-r--r--vendor/github.com/spf13/cast/caste.go29
-rw-r--r--vendor/github.com/spf13/cobra/README.md14
-rw-r--r--vendor/github.com/spf13/cobra/bash_completions.go4
-rw-r--r--vendor/github.com/spf13/cobra/cobra.go2
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/init.go4
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/license_apache_2.go238
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_2.go71
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_3.go79
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_2.go318
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_3.go661
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/license_mit.go63
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/licenses.go1321
-rw-r--r--vendor/github.com/spf13/cobra/cobra/cmd/root.go6
-rw-r--r--vendor/github.com/spf13/cobra/cobra_test.go51
-rw-r--r--vendor/github.com/spf13/cobra/command.go272
-rw-r--r--vendor/github.com/spf13/cobra/command_test.go46
-rw-r--r--vendor/github.com/spf13/cobra/doc/man_docs.go4
-rw-r--r--vendor/github.com/spf13/cobra/doc/man_docs.md7
-rw-r--r--vendor/github.com/spf13/cobra/doc/man_docs_test.go5
-rw-r--r--vendor/github.com/spf13/cobra/doc/man_examples_test.go4
-rw-r--r--vendor/github.com/spf13/cobra/doc/md_docs.go8
-rw-r--r--vendor/github.com/spf13/cobra/doc/md_docs.md18
-rw-r--r--vendor/github.com/spf13/cobra/doc/md_docs_test.go27
-rw-r--r--vendor/github.com/spf13/cobra/doc/yaml_docs.go10
-rw-r--r--vendor/github.com/spf13/cobra/doc/yaml_docs.md13
-rw-r--r--vendor/github.com/spf13/cobra/doc/yaml_docs_test.go28
-rw-r--r--vendor/github.com/spf13/pflag/README.md6
-rw-r--r--vendor/github.com/spf13/pflag/flag.go83
-rw-r--r--vendor/github.com/spf13/pflag/flag_test.go44
-rw-r--r--vendor/github.com/spf13/viper/viper.go28
-rw-r--r--vendor/github.com/spf13/viper/viper_test.go67
-rw-r--r--vendor/github.com/tylerb/graceful/README.md5
-rw-r--r--vendor/github.com/xenolf/lego/acme/client.go5
-rw-r--r--vendor/github.com/xenolf/lego/acme/http.go33
-rw-r--r--vendor/github.com/xenolf/lego/acme/jws.go16
-rw-r--r--vendor/github.com/xenolf/lego/cli.go2
-rw-r--r--vendor/github.com/xenolf/lego/providers/dns/azure/azure.go5
-rw-r--r--vendor/github.com/xenolf/lego/providers/dns/dnsimple/dnsimple.go4
-rw-r--r--vendor/github.com/xenolf/lego/providers/dns/dnsimple/dnsimple_test.go4
167 files changed, 4983 insertions, 2384 deletions
diff --git a/vendor/github.com/NYTimes/gziphandler/.travis.yml b/vendor/github.com/NYTimes/gziphandler/.travis.yml
index f918f8d76..d2b67f69c 100644
--- a/vendor/github.com/NYTimes/gziphandler/.travis.yml
+++ b/vendor/github.com/NYTimes/gziphandler/.travis.yml
@@ -2,4 +2,5 @@ language: go
go:
- 1.7
+ - 1.8
- tip
diff --git a/vendor/github.com/NYTimes/gziphandler/README.md b/vendor/github.com/NYTimes/gziphandler/README.md
index b1d55e26e..6d7246070 100644
--- a/vendor/github.com/NYTimes/gziphandler/README.md
+++ b/vendor/github.com/NYTimes/gziphandler/README.md
@@ -38,12 +38,12 @@ func main() {
## Documentation
-The docs can be found at [godoc.org] [docs], as usual.
+The docs can be found at [godoc.org][docs], as usual.
## License
-[Apache 2.0] [license].
+[Apache 2.0][license].
diff --git a/vendor/github.com/NYTimes/gziphandler/gzip.go b/vendor/github.com/NYTimes/gziphandler/gzip.go
index 23efacc45..cccf79de7 100644
--- a/vendor/github.com/NYTimes/gziphandler/gzip.go
+++ b/vendor/github.com/NYTimes/gziphandler/gzip.go
@@ -4,6 +4,7 @@ import (
"bufio"
"compress/gzip"
"fmt"
+ "io"
"net"
"net/http"
"strconv"
@@ -21,10 +22,16 @@ const (
type codings map[string]float64
-// The default qvalue to assign to an encoding if no explicit qvalue is set.
-// This is actually kind of ambiguous in RFC 2616, so hopefully it's correct.
-// The examples seem to indicate that it is.
-const DEFAULT_QVALUE = 1.0
+const (
+ // DefaultQValue is the default qvalue to assign to an encoding if no explicit qvalue is set.
+ // This is actually kind of ambiguous in RFC 2616, so hopefully it's correct.
+ // The examples seem to indicate that it is.
+ DefaultQValue = 1.0
+
+ // DefaultMinSize defines the minimum size to reach to enable compression.
+ // It's 512 bytes.
+ DefaultMinSize = 512
+)
// gzipWriterPools stores a sync.Pool for each compression level for reuse of
// gzip.Writers. Use poolIndex to covert a compression level to an index into
@@ -63,35 +70,88 @@ func addLevelPool(level int) {
// GzipResponseWriter provides an http.ResponseWriter interface, which gzips
// bytes before writing them to the underlying response. This doesn't close the
// writers, so don't forget to do that.
+// It can be configured to skip response smaller than minSize.
type GzipResponseWriter struct {
http.ResponseWriter
index int // Index for gzipWriterPools.
gw *gzip.Writer
+
+ code int // Saves the WriteHeader value.
+
+ minSize int // Specifed the minimum response size to gzip. If the response length is bigger than this value, it is compressed.
+ buf []byte // Holds the first part of the write before reaching the minSize or the end of the write.
}
// Write appends data to the gzip writer.
func (w *GzipResponseWriter) Write(b []byte) (int, error) {
- // Lazily create the gzip.Writer, this allows empty bodies to be actually
- // empty, for example in the case of status code 204 (no content).
- if w.gw == nil {
- w.init()
- }
-
+ // If content type is not set.
if _, ok := w.Header()[contentType]; !ok {
- // If content type is not set, infer it from the uncompressed body.
+ // It infer it from the uncompressed body.
w.Header().Set(contentType, http.DetectContentType(b))
}
- return w.gw.Write(b)
+
+ // GZIP responseWriter is initialized. Use the GZIP responseWriter.
+ if w.gw != nil {
+ n, err := w.gw.Write(b)
+ return n, err
+ }
+
+ // Save the write into a buffer for later use in GZIP responseWriter (if content is long enough) or at close with regular responseWriter.
+ w.buf = append(w.buf, b...)
+
+ // If the global writes are bigger than the minSize, compression is enable.
+ if len(w.buf) >= w.minSize {
+ err := w.startGzip()
+ if err != nil {
+ return 0, err
+ }
+ }
+
+ return len(b), nil
+}
+
+// startGzip initialize any GZIP specific informations.
+func (w *GzipResponseWriter) startGzip() error {
+
+ // Set the GZIP header.
+ w.Header().Set(contentEncoding, "gzip")
+
+ // if the Content-Length is already set, then calls to Write on gzip
+ // will fail to set the Content-Length header since its already set
+ // See: https://github.com/golang/go/issues/14975.
+ w.Header().Del(contentLength)
+
+ // Write the header to gzip response.
+ w.writeHeader()
+
+ // Initialize the GZIP response.
+ w.init()
+
+ // Flush the buffer into the gzip reponse.
+ n, err := w.gw.Write(w.buf)
+
+ // This should never happen (per io.Writer docs), but if the write didn't
+ // accept the entire buffer but returned no specific error, we have no clue
+ // what's going on, so abort just to be safe.
+ if err == nil && n < len(w.buf) {
+ return io.ErrShortWrite
+ }
+
+ w.buf = nil
+ return err
}
-// WriteHeader will check if the gzip writer needs to be lazily initiated and
-// then pass the code along to the underlying ResponseWriter.
+// WriteHeader just saves the response code until close or GZIP effective writes.
func (w *GzipResponseWriter) WriteHeader(code int) {
- if w.gw == nil &&
- code != http.StatusNotModified && code != http.StatusNoContent {
- w.init()
+ w.code = code
+}
+
+// writeHeader uses the saved code to send it to the ResponseWriter.
+func (w *GzipResponseWriter) writeHeader() {
+ if w.code == 0 {
+ w.code = http.StatusOK
}
- w.ResponseWriter.WriteHeader(code)
+ w.ResponseWriter.WriteHeader(w.code)
}
// init graps a new gzip writer from the gzipWriterPool and writes the correct
@@ -102,15 +162,22 @@ func (w *GzipResponseWriter) init() {
gzw := gzipWriterPools[w.index].Get().(*gzip.Writer)
gzw.Reset(w.ResponseWriter)
w.gw = gzw
- w.ResponseWriter.Header().Set(contentEncoding, "gzip")
- // if the Content-Length is already set, then calls to Write on gzip
- // will fail to set the Content-Length header since its already set
- // See: https://github.com/golang/go/issues/14975
- w.ResponseWriter.Header().Del(contentLength)
}
// Close will close the gzip.Writer and will put it back in the gzipWriterPool.
func (w *GzipResponseWriter) Close() error {
+ // Buffer not nil means the regular response must be returned.
+ if w.buf != nil {
+ w.writeHeader()
+ // Make the write into the regular response.
+ _, writeErr := w.ResponseWriter.Write(w.buf)
+ // Returns the error if any at write.
+ if writeErr != nil {
+ return fmt.Errorf("gziphandler: write to regular responseWriter at close gets error: %q", writeErr.Error())
+ }
+ }
+
+ // If the GZIP responseWriter is not set no needs to close it.
if w.gw == nil {
return nil
}
@@ -163,9 +230,18 @@ func MustNewGzipLevelHandler(level int) func(http.Handler) http.Handler {
// if an invalid gzip compression level is given, so if one can ensure the level
// is valid, the returned error can be safely ignored.
func NewGzipLevelHandler(level int) (func(http.Handler) http.Handler, error) {
+ return NewGzipLevelAndMinSize(level, DefaultMinSize)
+}
+
+// NewGzipLevelAndMinSize behave as NewGzipLevelHandler except it let the caller
+// specify the minimum size before compression.
+func NewGzipLevelAndMinSize(level, minSize int) (func(http.Handler) http.Handler, error) {
if level != gzip.DefaultCompression && (level < gzip.BestSpeed || level > gzip.BestCompression) {
return nil, fmt.Errorf("invalid compression level requested: %d", level)
}
+ if minSize < 0 {
+ return nil, fmt.Errorf("minimum size must be more than zero")
+ }
return func(h http.Handler) http.Handler {
index := poolIndex(level)
@@ -176,6 +252,9 @@ func NewGzipLevelHandler(level int) (func(http.Handler) http.Handler, error) {
gw := &GzipResponseWriter{
ResponseWriter: w,
index: index,
+ minSize: minSize,
+
+ buf: []byte{},
}
defer gw.Close()
@@ -238,7 +317,7 @@ func parseEncodings(s string) (codings, error) {
func parseCoding(s string) (coding string, qvalue float64, err error) {
for n, part := range strings.Split(s, ";") {
part = strings.TrimSpace(part)
- qvalue = DEFAULT_QVALUE
+ qvalue = DefaultQValue
if n == 0 {
coding = strings.ToLower(part)
diff --git a/vendor/github.com/NYTimes/gziphandler/gzip_go18.go b/vendor/github.com/NYTimes/gziphandler/gzip_go18.go
new file mode 100644
index 000000000..fa9665b7e
--- /dev/null
+++ b/vendor/github.com/NYTimes/gziphandler/gzip_go18.go
@@ -0,0 +1,43 @@
+// +build go1.8
+
+package gziphandler
+
+import "net/http"
+
+// Push initiates an HTTP/2 server push.
+// Push returns ErrNotSupported if the client has disabled push or if push
+// is not supported on the underlying connection.
+func (w *GzipResponseWriter) Push(target string, opts *http.PushOptions) error {
+ pusher, ok := w.ResponseWriter.(http.Pusher)
+ if ok && pusher != nil {
+ return pusher.Push(target, setAcceptEncodingForPushOptions(opts))
+ }
+ return http.ErrNotSupported
+}
+
+// setAcceptEncodingForPushOptions sets "Accept-Encoding" : "gzip" for PushOptions without overriding existing headers.
+func setAcceptEncodingForPushOptions(opts *http.PushOptions) *http.PushOptions {
+
+ if opts == nil {
+ opts = &http.PushOptions{
+ Header: http.Header{
+ acceptEncoding: []string{"gzip"},
+ },
+ }
+ return opts
+ }
+
+ if opts.Header == nil {
+ opts.Header = http.Header{
+ acceptEncoding: []string{"gzip"},
+ }
+ return opts
+ }
+
+ if encoding := opts.Header.Get(acceptEncoding); encoding == "" {
+ opts.Header.Add(acceptEncoding, "gzip")
+ return opts
+ }
+
+ return opts
+}
diff --git a/vendor/github.com/NYTimes/gziphandler/gzip_go18_test.go b/vendor/github.com/NYTimes/gziphandler/gzip_go18_test.go
new file mode 100644
index 000000000..412b2918e
--- /dev/null
+++ b/vendor/github.com/NYTimes/gziphandler/gzip_go18_test.go
@@ -0,0 +1,70 @@
+// +build go1.8
+
+package gziphandler
+
+import (
+ "net/http"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestSetAcceptEncodingForPushOptionsWithoutHeaders(t *testing.T) {
+ var opts *http.PushOptions
+ opts = setAcceptEncodingForPushOptions(opts)
+
+ assert.NotNil(t, opts)
+ assert.NotNil(t, opts.Header)
+
+ for k, v := range opts.Header {
+ assert.Equal(t, "Accept-Encoding", k)
+ assert.Len(t, v, 1)
+ assert.Equal(t, "gzip", v[0])
+ }
+
+ opts = &http.PushOptions{}
+ opts = setAcceptEncodingForPushOptions(opts)
+
+ assert.NotNil(t, opts)
+ assert.NotNil(t, opts.Header)
+
+ for k, v := range opts.Header {
+ assert.Equal(t, "Accept-Encoding", k)
+ assert.Len(t, v, 1)
+ assert.Equal(t, "gzip", v[0])
+ }
+}
+
+func TestSetAcceptEncodingForPushOptionsWithHeaders(t *testing.T) {
+ opts := &http.PushOptions{
+ Header: http.Header{
+ "User-Agent": []string{"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36"},
+ },
+ }
+ opts = setAcceptEncodingForPushOptions(opts)
+
+ assert.NotNil(t, opts)
+ assert.NotNil(t, opts.Header)
+
+ assert.Equal(t, "gzip", opts.Header.Get("Accept-Encoding"))
+ assert.Equal(t, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36", opts.Header.Get("User-Agent"))
+
+ opts = &http.PushOptions{
+ Header: http.Header{
+ "User-Agent": []string{"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36"},
+ acceptEncoding: []string{"deflate"},
+ },
+ }
+ opts = setAcceptEncodingForPushOptions(opts)
+
+ assert.NotNil(t, opts)
+ assert.NotNil(t, opts.Header)
+
+ e, found := opts.Header["Accept-Encoding"]
+ if !found {
+ assert.Fail(t, "Missing Accept-Encoding header value")
+ }
+ assert.Len(t, e, 1)
+ assert.Equal(t, "deflate", e[0])
+ assert.Equal(t, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36", opts.Header.Get("User-Agent"))
+}
diff --git a/vendor/github.com/NYTimes/gziphandler/gzip_test.go b/vendor/github.com/NYTimes/gziphandler/gzip_test.go
index 80f54c77d..b9e687c8e 100644
--- a/vendor/github.com/NYTimes/gziphandler/gzip_test.go
+++ b/vendor/github.com/NYTimes/gziphandler/gzip_test.go
@@ -16,8 +16,12 @@ import (
"github.com/stretchr/testify/assert"
)
-func TestParseEncodings(t *testing.T) {
+const (
+ smallTestBody = "aaabbcaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbccc"
+ testBody = "aaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbcccaaabbbccc"
+)
+func TestParseEncodings(t *testing.T) {
examples := map[string]codings{
// Examples from RFC 2616
@@ -39,8 +43,6 @@ func TestParseEncodings(t *testing.T) {
}
func TestGzipHandler(t *testing.T) {
- testBody := "aaabbbccc"
-
// This just exists to provide something for GzipHandler to wrap.
handler := newTestHandler(testBody)
@@ -80,7 +82,6 @@ func TestGzipHandler(t *testing.T) {
}
func TestNewGzipLevelHandler(t *testing.T) {
- testBody := "aaabbbccc"
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
io.WriteString(w, testBody)
@@ -102,7 +103,6 @@ func TestNewGzipLevelHandler(t *testing.T) {
assert.Equal(t, "gzip", res.Header.Get("Content-Encoding"))
assert.Equal(t, "Accept-Encoding", res.Header.Get("Vary"))
assert.Equal(t, gzipStrLevel(testBody, lvl), resp.Body.Bytes())
-
}
}
@@ -135,7 +135,7 @@ func TestGzipHandlerNoBody(t *testing.T) {
{http.StatusNoContent, "", 0},
{http.StatusNotModified, "", 0},
// Body is going to get gzip'd no matter what.
- {http.StatusOK, "gzip", 23},
+ {http.StatusOK, "", 0},
}
for num, test := range tests {
@@ -170,7 +170,7 @@ func TestGzipHandlerNoBody(t *testing.T) {
}
func TestGzipHandlerContentLength(t *testing.T) {
- b := []byte("testtesttesttesttesttesttesttesttesttesttesttesttest")
+ b := []byte(testBody)
handler := GzipHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Length", strconv.Itoa(len(b)))
w.Write(b)
@@ -215,6 +215,48 @@ func TestGzipHandlerContentLength(t *testing.T) {
assert.NotEqual(t, b, body)
}
+func TestGzipHandlerMinSizeMustBePositive(t *testing.T) {
+ _, err := NewGzipLevelAndMinSize(gzip.DefaultCompression, -1)
+ assert.Error(t, err)
+}
+
+func TestGzipHandlerMinSize(t *testing.T) {
+ responseLength := 0
+ b := []byte{'x'}
+
+ wrapper, _ := NewGzipLevelAndMinSize(gzip.DefaultCompression, 128)
+ handler := wrapper(http.HandlerFunc(
+ func(w http.ResponseWriter, r *http.Request) {
+ // Write responses one byte at a time to ensure that the flush
+ // mechanism, if used, is working properly.
+ for i := 0; i < responseLength; i++ {
+ n, err := w.Write(b)
+ assert.Equal(t, 1, n)
+ assert.Nil(t, err)
+ }
+ },
+ ))
+
+ r, _ := http.NewRequest("GET", "/whatever", &bytes.Buffer{})
+ r.Header.Add("Accept-Encoding", "gzip")
+
+ // Short response is not compressed
+ responseLength = 127
+ w := httptest.NewRecorder()
+ handler.ServeHTTP(w, r)
+ if w.Result().Header.Get(contentEncoding) == "gzip" {
+ t.Error("Expected uncompressed response, got compressed")
+ }
+
+ // Long response is not compressed
+ responseLength = 128
+ w = httptest.NewRecorder()
+ handler.ServeHTTP(w, r)
+ if w.Result().Header.Get(contentEncoding) != "gzip" {
+ t.Error("Expected compressed response, got uncompressed")
+ }
+}
+
func TestGzipDoubleClose(t *testing.T) {
// reset the pool for the default compression so we can make sure duplicates
// aren't added back by double close
@@ -240,6 +282,19 @@ func TestGzipDoubleClose(t *testing.T) {
assert.False(t, w1 == w2)
}
+func TestStatusCodes(t *testing.T) {
+ handler := GzipHandler(http.NotFoundHandler())
+ r := httptest.NewRequest("GET", "/", nil)
+ r.Header.Set("Accept-Encoding", "gzip")
+ w := httptest.NewRecorder()
+ handler.ServeHTTP(w, r)
+
+ result := w.Result()
+ if result.StatusCode != 404 {
+ t.Errorf("StatusCode should have been 404 but was %d", result.StatusCode)
+ }
+}
+
// --------------------------------------------------------------------
func BenchmarkGzipHandler_S2k(b *testing.B) { benchmark(b, false, 2048) }
diff --git a/vendor/github.com/jaytaylor/html2text/.gitignore b/vendor/github.com/cpanato/html2text/.gitignore
index daf913b1b..daf913b1b 100644
--- a/vendor/github.com/jaytaylor/html2text/.gitignore
+++ b/vendor/github.com/cpanato/html2text/.gitignore
diff --git a/vendor/github.com/jaytaylor/html2text/.travis.yml b/vendor/github.com/cpanato/html2text/.travis.yml
index 6c7f48efd..6c7f48efd 100644
--- a/vendor/github.com/jaytaylor/html2text/.travis.yml
+++ b/vendor/github.com/cpanato/html2text/.travis.yml
diff --git a/vendor/github.com/jaytaylor/html2text/LICENSE b/vendor/github.com/cpanato/html2text/LICENSE
index 24dc4abec..24dc4abec 100644
--- a/vendor/github.com/jaytaylor/html2text/LICENSE
+++ b/vendor/github.com/cpanato/html2text/LICENSE
diff --git a/vendor/github.com/jaytaylor/html2text/README.md b/vendor/github.com/cpanato/html2text/README.md
index ac1124739..57abf3ff3 100644
--- a/vendor/github.com/jaytaylor/html2text/README.md
+++ b/vendor/github.com/cpanato/html2text/README.md
@@ -1,8 +1,12 @@
# html2text
-[![Documentation](https://godoc.org/github.com/jaytaylor/html2text?status.svg)](https://godoc.org/github.com/jaytaylor/html2text)
-[![Build Status](https://travis-ci.org/jaytaylor/html2text.svg?branch=master)](https://travis-ci.org/jaytaylor/html2text)
-[![Report Card](https://goreportcard.com/badge/github.com/jaytaylor/html2text)](https://goreportcard.com/report/github.com/jaytaylor/html2text)
+[![Documentation](https://godoc.org/github.com/cpanato/html2text?status.svg)](https://godoc.org/github.com/cpanato/html2text)
+[![Build Status](https://travis-ci.org/cpanato/html2text.svg?branch=master)](https://travis-ci.org/cpanato/html2text)
+[![Report Card](https://goreportcard.com/badge/github.com/jaytaylor/html2text)](https://goreportcard.com/report/github.com/cpanato/html2text)
+
+### Initial information
+ This project was forked from [github.com/jaytaylor/html2text](https://github.com/jaytaylor/html2text) in order to use another clean bom library due the original one has no license.
+
### Converts HTML into text
@@ -23,7 +27,7 @@ It requires go 1.x or newer ;)
## Download the package
```bash
-go get github.com/jaytaylor/html2text
+go get github.com/cpanato/html2text
```
## Example usage
@@ -34,7 +38,7 @@ package main
import (
"fmt"
- "github.com/jaytaylor/html2text"
+ "github.com/cpanato/html2text"
)
func main() {
@@ -45,17 +49,17 @@ func main() {
<link rel=\"stylesheet\" href=\"main.css\">
<style type=\"text/css\">body { color: #fff; }</style>
</head>
-
+
<body>
<div class="logo">
<a href="http://mymegaservice.com/"><img src="/logo-image.jpg" alt="Mega Service"/></a>
</div>
-
+
<h1>Welcome to your new account on my service!</h1>
-
+
<p>
Here is some more information:
-
+
<ul>
<li>Link 1: <a href="https://example.com">Example.com</a></li>
<li>Link 2: <a href="https://example2.com">Example2.com</a></li>
@@ -102,15 +106,3 @@ go test
# License
Permissive MIT license.
-
-
-## Contact
-
-You are more than welcome to open issues and send pull requests if you find a bug or want a new feature.
-
-If you appreciate this library please feel free to drop me a line and tell me! It's always nice to hear from people who have benefitted from my work.
-
-Email: jay at (my github username).com
-
-Twitter: [@jtaylor](https://twitter.com/jtaylor)
-
diff --git a/vendor/github.com/jaytaylor/html2text/html2text.go b/vendor/github.com/cpanato/html2text/html2text.go
index 2a013a039..61774e8a0 100644
--- a/vendor/github.com/jaytaylor/html2text/html2text.go
+++ b/vendor/github.com/cpanato/html2text/html2text.go
@@ -3,11 +3,12 @@ package html2text
import (
"bytes"
"io"
+ "io/ioutil"
"regexp"
"strings"
"unicode"
- "github.com/ssor/bom"
+ "github.com/dimchansky/utfbom"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
@@ -291,10 +292,9 @@ func FromHtmlNode(doc *html.Node) (string, error) {
}
func FromReader(reader io.Reader) (string, error) {
- newReader, err := bom.NewReaderWithoutBom(reader)
- if err != nil {
- return "", err
- }
+ bs, err := ioutil.ReadAll(reader)
+ newReader, _ := utfbom.Skip(bytes.NewReader(bs))
+
doc, err := html.Parse(newReader)
if err != nil {
return "", err
@@ -303,8 +303,8 @@ func FromReader(reader io.Reader) (string, error) {
}
func FromString(input string) (string, error) {
- bs := bom.CleanBom([]byte(input))
- text, err := FromReader(bytes.NewReader(bs))
+ bs := utfbom.SkipOnly(bytes.NewReader([]byte(input)))
+ text, err := FromReader(bs)
if err != nil {
return "", err
}
diff --git a/vendor/github.com/jaytaylor/html2text/html2text_test.go b/vendor/github.com/cpanato/html2text/html2text_test.go
index b30d68ac9..b30d68ac9 100644
--- a/vendor/github.com/jaytaylor/html2text/html2text_test.go
+++ b/vendor/github.com/cpanato/html2text/html2text_test.go
diff --git a/vendor/github.com/jaytaylor/html2text/testdata/utf8.html b/vendor/github.com/cpanato/html2text/testdata/utf8.html
index 53d401ce9..53d401ce9 100755
--- a/vendor/github.com/jaytaylor/html2text/testdata/utf8.html
+++ b/vendor/github.com/cpanato/html2text/testdata/utf8.html
diff --git a/vendor/github.com/jaytaylor/html2text/testdata/utf8_with_bom.xhtml b/vendor/github.com/cpanato/html2text/testdata/utf8_with_bom.xhtml
index 68f0ee707..68f0ee707 100755
--- a/vendor/github.com/jaytaylor/html2text/testdata/utf8_with_bom.xhtml
+++ b/vendor/github.com/cpanato/html2text/testdata/utf8_with_bom.xhtml
diff --git a/vendor/github.com/disintegration/imaging/.travis.yml b/vendor/github.com/disintegration/imaging/.travis.yml
index 0e214c00d..110437d6a 100644
--- a/vendor/github.com/disintegration/imaging/.travis.yml
+++ b/vendor/github.com/disintegration/imaging/.travis.yml
@@ -9,6 +9,7 @@ go:
- 1.5
- 1.6
- 1.7
+ - 1.8
before_install:
- go get golang.org/x/tools/cmd/cover
diff --git a/vendor/github.com/disintegration/imaging/LICENSE b/vendor/github.com/disintegration/imaging/LICENSE
index 95ae410c3..72a26f0e8 100644
--- a/vendor/github.com/disintegration/imaging/LICENSE
+++ b/vendor/github.com/disintegration/imaging/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2012-2014 Grigory Dryapak
+Copyright (c) 2012-2017 Grigory Dryapak
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/vendor/github.com/disintegration/imaging/README.md b/vendor/github.com/disintegration/imaging/README.md
index 3dcea2000..f957c3e79 100644
--- a/vendor/github.com/disintegration/imaging/README.md
+++ b/vendor/github.com/disintegration/imaging/README.md
@@ -26,17 +26,18 @@ http://godoc.org/github.com/disintegration/imaging
A few usage examples can be found below. See the documentation for the full list of supported functions.
### Image resizing
+
```go
-// resize srcImage to size = 128x128px using the Lanczos filter
+// Resize srcImage to size = 128x128px using the Lanczos filter.
dstImage128 := imaging.Resize(srcImage, 128, 128, imaging.Lanczos)
-// resize srcImage to width = 800px preserving the aspect ratio
+// Resize srcImage to width = 800px preserving the aspect ratio.
dstImage800 := imaging.Resize(srcImage, 800, 0, imaging.Lanczos)
-// scale down srcImage to fit the 800x600px bounding box
+// Scale down srcImage to fit the 800x600px bounding box.
dstImageFit := imaging.Fit(srcImage, 800, 600, imaging.Lanczos)
-// resize and crop the srcImage to fill the 100x100px area
+// Resize and crop the srcImage to fill the 100x100px area.
dstImageFill := imaging.Fill(srcImage, 100, 100, imaging.Center, imaging.Lanczos)
```
@@ -53,146 +54,138 @@ The full list of supported filters: NearestNeighbor, Box, Linear, Hermite, Mitc
**Resampling filters comparison**
-Original image. Will be resized from 512x512px to 128x128px.
-
-![srcImage](http://disintegration.github.io/imaging/in_lena_bw_512.png)
-
-Filter | Resize result
----|---
-`imaging.NearestNeighbor` | ![dstImage](http://disintegration.github.io/imaging/out_resize_down_nearest.png)
-`imaging.Box` | ![dstImage](http://disintegration.github.io/imaging/out_resize_down_box.png)
-`imaging.Linear` | ![dstImage](http://disintegration.github.io/imaging/out_resize_down_linear.png)
-`imaging.MitchellNetravali` | ![dstImage](http://disintegration.github.io/imaging/out_resize_down_mitchell.png)
-`imaging.CatmullRom` | ![dstImage](http://disintegration.github.io/imaging/out_resize_down_catrom.png)
-`imaging.Gaussian` | ![dstImage](http://disintegration.github.io/imaging/out_resize_down_gaussian.png)
-`imaging.Lanczos` | ![dstImage](http://disintegration.github.io/imaging/out_resize_down_lanczos.png)
-
-**Resize functions comparison**
+The original image.
-Original image:
+![srcImage](testdata/lena_512.png)
-![srcImage](http://disintegration.github.io/imaging/in.jpg)
-
-Resize the image to width=100px and height=100px:
-
-```go
-dstImage := imaging.Resize(srcImage, 100, 100, imaging.Lanczos)
-```
-![dstImage](http://disintegration.github.io/imaging/out-comp-resize.jpg)
+The same image resized from 512x512px to 128x128px using different resampling filters.
+From faster (lower quality) to slower (higher quality):
-Resize the image to width=100px preserving the aspect ratio:
-
-```go
-dstImage := imaging.Resize(srcImage, 100, 0, imaging.Lanczos)
-```
-![dstImage](http://disintegration.github.io/imaging/out-comp-fit.jpg)
-
-Resize the image to fit the 100x100px boundng box preserving the aspect ratio:
-
-```go
-dstImage := imaging.Fit(srcImage, 100, 100, imaging.Lanczos)
-```
-![dstImage](http://disintegration.github.io/imaging/out-comp-fit.jpg)
+Filter | Resize result
+--------------------------|---------------------------------------------
+`imaging.NearestNeighbor` | ![dstImage](testdata/out_resize_nearest.png)
+`imaging.Linear` | ![dstImage](testdata/out_resize_linear.png)
+`imaging.CatmullRom` | ![dstImage](testdata/out_resize_catrom.png)
+`imaging.Lanczos` | ![dstImage](testdata/out_resize_lanczos.png)
-Resize and crop the image with a center anchor point to fill the 100x100px area:
-
-```go
-dstImage := imaging.Fill(srcImage, 100, 100, imaging.Center, imaging.Lanczos)
-```
-![dstImage](http://disintegration.github.io/imaging/out-comp-fill.jpg)
### Gaussian Blur
+
```go
dstImage := imaging.Blur(srcImage, 0.5)
```
Sigma parameter allows to control the strength of the blurring effect.
-Original image | Sigma = 0.5 | Sigma = 1.5
----|---|---
-![srcImage](http://disintegration.github.io/imaging/in_lena_bw_128.png) | ![dstImage](http://disintegration.github.io/imaging/out_blur_0.5.png) | ![dstImage](http://disintegration.github.io/imaging/out_blur_1.5.png)
+Original image | Sigma = 0.5 | Sigma = 1.5
+-----------------------------------|----------------------------------------|---------------------------------------
+![srcImage](testdata/lena_128.png) | ![dstImage](testdata/out_blur_0.5.png) | ![dstImage](testdata/out_blur_1.5.png)
### Sharpening
+
```go
dstImage := imaging.Sharpen(srcImage, 0.5)
```
-Uses gaussian function internally. Sigma parameter allows to control the strength of the sharpening effect.
+`Sharpen` uses gaussian function internally. Sigma parameter allows to control the strength of the sharpening effect.
-Original image | Sigma = 0.5 | Sigma = 1.5
----|---|---
-![srcImage](http://disintegration.github.io/imaging/in_lena_bw_128.png) | ![dstImage](http://disintegration.github.io/imaging/out_sharpen_0.5.png) | ![dstImage](http://disintegration.github.io/imaging/out_sharpen_1.5.png)
+Original image | Sigma = 0.5 | Sigma = 1.5
+-----------------------------------|-------------------------------------------|------------------------------------------
+![srcImage](testdata/lena_128.png) | ![dstImage](testdata/out_sharpen_0.5.png) | ![dstImage](testdata/out_sharpen_1.5.png)
### Gamma correction
+
```go
dstImage := imaging.AdjustGamma(srcImage, 0.75)
```
-Original image | Gamma = 0.75 | Gamma = 1.25
----|---|---
-![srcImage](http://disintegration.github.io/imaging/in_lena_bw_128.png) | ![dstImage](http://disintegration.github.io/imaging/out_gamma_0.75.png) | ![dstImage](http://disintegration.github.io/imaging/out_gamma_1.25.png)
+Original image | Gamma = 0.75 | Gamma = 1.25
+-----------------------------------|------------------------------------------|-----------------------------------------
+![srcImage](testdata/lena_128.png) | ![dstImage](testdata/out_gamma_0.75.png) | ![dstImage](testdata/out_gamma_1.25.png)
### Contrast adjustment
+
```go
dstImage := imaging.AdjustContrast(srcImage, 20)
```
-Original image | Contrast = 20 | Contrast = -20
----|---|---
-![srcImage](http://disintegration.github.io/imaging/in_lena_bw_128.png) | ![dstImage](http://disintegration.github.io/imaging/out_contrast_p20.png) | ![dstImage](http://disintegration.github.io/imaging/out_contrast_m20.png)
+Original image | Contrast = 10 | Contrast = -10
+-----------------------------------|--------------------------------------------|-------------------------------------------
+![srcImage](testdata/lena_128.png) | ![dstImage](testdata/out_contrast_p10.png) | ![dstImage](testdata/out_contrast_m10.png)
### Brightness adjustment
+
```go
dstImage := imaging.AdjustBrightness(srcImage, 20)
```
-Original image | Brightness = 20 | Brightness = -20
----|---|---
-![srcImage](http://disintegration.github.io/imaging/in_lena_bw_128.png) | ![dstImage](http://disintegration.github.io/imaging/out_brightness_p20.png) | ![dstImage](http://disintegration.github.io/imaging/out_brightness_m20.png)
-
+Original image | Brightness = 10 | Brightness = -10
+-----------------------------------|----------------------------------------------|---------------------------------------------
+![srcImage](testdata/lena_128.png) | ![dstImage](testdata/out_brightness_p10.png) | ![dstImage](testdata/out_brightness_m10.png)
-### Complete code example
-Here is the code example that loads several images, makes thumbnails of them
-and combines them together side-by-side.
+## Example code
```go
package main
import (
- "image"
- "image/color"
-
- "github.com/disintegration/imaging"
+ "image"
+ "image/color"
+ "log"
+
+ "github.com/disintegration/imaging"
)
func main() {
-
- // input files
- files := []string{"01.jpg", "02.jpg", "03.jpg"}
-
- // load images and make 100x100 thumbnails of them
- var thumbnails []image.Image
- for _, file := range files {
- img, err := imaging.Open(file)
- if err != nil {
- panic(err)
- }
- thumb := imaging.Thumbnail(img, 100, 100, imaging.CatmullRom)
- thumbnails = append(thumbnails, thumb)
- }
-
- // create a new blank image
- dst := imaging.New(100*len(thumbnails), 100, color.NRGBA{0, 0, 0, 0})
-
- // paste thumbnails into the new image side by side
- for i, thumb := range thumbnails {
- dst = imaging.Paste(dst, thumb, image.Pt(i*100, 0))
- }
-
- // save the combined image to file
- err := imaging.Save(dst, "dst.jpg")
- if err != nil {
- panic(err)
- }
+ // Open the test image.
+ src, err := imaging.Open("testdata/lena_512.png")
+ if err != nil {
+ log.Fatalf("Open failed: %v", err)
+ }
+
+ // Crop the original image to 350x350px size using the center anchor.
+ src = imaging.CropAnchor(src, 350, 350, imaging.Center)
+
+ // Resize the cropped image to width = 256px preserving the aspect ratio.
+ src = imaging.Resize(src, 256, 0, imaging.Lanczos)
+
+ // Create a blurred version of the image.
+ img1 := imaging.Blur(src, 2)
+
+ // Create a grayscale version of the image with higher contrast and sharpness.
+ img2 := imaging.Grayscale(src)
+ img2 = imaging.AdjustContrast(img2, 20)
+ img2 = imaging.Sharpen(img2, 2)
+
+ // Create an inverted version of the image.
+ img3 := imaging.Invert(src)
+
+ // Create an embossed version of the image using a convolution filter.
+ img4 := imaging.Convolve3x3(
+ src,
+ [9]float64{
+ -1, -1, 0,
+ -1, 1, 1,
+ 0, 1, 1,
+ },
+ nil,
+ )
+
+ // Create a new image and paste the four produced images into it.
+ dst := imaging.New(512, 512, color.NRGBA{0, 0, 0, 0})
+ dst = imaging.Paste(dst, img1, image.Pt(0, 0))
+ dst = imaging.Paste(dst, img2, image.Pt(0, 256))
+ dst = imaging.Paste(dst, img3, image.Pt(256, 0))
+ dst = imaging.Paste(dst, img4, image.Pt(256, 256))
+
+ // Save the resulting image using JPEG format.
+ err = imaging.Save(dst, "testdata/out_example.jpg")
+ if err != nil {
+ log.Fatalf("Save failed: %v", err)
+ }
}
```
+
+Output:
+
+![dstImage](testdata/out_example.jpg) \ No newline at end of file
diff --git a/vendor/github.com/disintegration/imaging/adjust_test.go b/vendor/github.com/disintegration/imaging/adjust_test.go
index 99898b0dc..60183d6ea 100644
--- a/vendor/github.com/disintegration/imaging/adjust_test.go
+++ b/vendor/github.com/disintegration/imaging/adjust_test.go
@@ -206,6 +206,26 @@ func TestAdjustContrast(t *testing.T) {
}
}
+func TestAdjustContrastGolden(t *testing.T) {
+ src, err := Open("testdata/lena_128.png")
+ if err != nil {
+ t.Errorf("Open: %v", err)
+ }
+ for name, p := range map[string]float64{
+ "out_contrast_m10.png": -10,
+ "out_contrast_p10.png": 10,
+ } {
+ got := AdjustContrast(src, p)
+ want, err := Open("testdata/" + name)
+ if err != nil {
+ t.Errorf("Open: %v", err)
+ }
+ if !compareNRGBA(got, toNRGBA(want), 0) {
+ t.Errorf("resulting image differs from golden: %s", name)
+ }
+ }
+}
+
func TestAdjustBrightness(t *testing.T) {
td := []struct {
desc string
@@ -333,6 +353,26 @@ func TestAdjustBrightness(t *testing.T) {
}
}
+func TestAdjustBrightnessGolden(t *testing.T) {
+ src, err := Open("testdata/lena_128.png")
+ if err != nil {
+ t.Errorf("Open: %v", err)
+ }
+ for name, p := range map[string]float64{
+ "out_brightness_m10.png": -10,
+ "out_brightness_p10.png": 10,
+ } {
+ got := AdjustBrightness(src, p)
+ want, err := Open("testdata/" + name)
+ if err != nil {
+ t.Errorf("Open: %v", err)
+ }
+ if !compareNRGBA(got, toNRGBA(want), 0) {
+ t.Errorf("resulting image differs from golden: %s", name)
+ }
+ }
+}
+
func TestAdjustGamma(t *testing.T) {
td := []struct {
desc string
@@ -416,6 +456,26 @@ func TestAdjustGamma(t *testing.T) {
}
}
+func TestAdjustGammaGolden(t *testing.T) {
+ src, err := Open("testdata/lena_128.png")
+ if err != nil {
+ t.Errorf("Open: %v", err)
+ }
+ for name, g := range map[string]float64{
+ "out_gamma_0.75.png": 0.75,
+ "out_gamma_1.25.png": 1.25,
+ } {
+ got := AdjustGamma(src, g)
+ want, err := Open("testdata/" + name)
+ if err != nil {
+ t.Errorf("Open: %v", err)
+ }
+ if !compareNRGBA(got, toNRGBA(want), 0) {
+ t.Errorf("resulting image differs from golden: %s", name)
+ }
+ }
+}
+
func TestAdjustSigmoid(t *testing.T) {
td := []struct {
desc string
diff --git a/vendor/github.com/disintegration/imaging/convolution.go b/vendor/github.com/disintegration/imaging/convolution.go
new file mode 100644
index 000000000..ed7540f05
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/convolution.go
@@ -0,0 +1,148 @@
+package imaging
+
+import (
+ "image"
+)
+
+// ConvolveOptions are convolution parameters.
+type ConvolveOptions struct {
+ // If Normalize is true the kernel is normalized before convolution.
+ Normalize bool
+
+ // If Abs is true the absolute value of each color channel is taken after convolution.
+ Abs bool
+
+ // Bias is added to each color channel value after convolution.
+ Bias int
+}
+
+// Convolve3x3 convolves the image with the specified 3x3 convolution kernel.
+// Default parameters are used if a nil *ConvolveOptions is passed.
+func Convolve3x3(img image.Image, kernel [9]float64, options *ConvolveOptions) *image.NRGBA {
+ return convolve(img, kernel[:], options)
+}
+
+// Convolve5x5 convolves the image with the specified 5x5 convolution kernel.
+// Default parameters are used if a nil *ConvolveOptions is passed.
+func Convolve5x5(img image.Image, kernel [25]float64, options *ConvolveOptions) *image.NRGBA {
+ return convolve(img, kernel[:], options)
+}
+
+func convolve(img image.Image, kernel []float64, options *ConvolveOptions) *image.NRGBA {
+ src := toNRGBA(img)
+ w := src.Bounds().Max.X
+ h := src.Bounds().Max.Y
+ dst := image.NewNRGBA(image.Rect(0, 0, w, h))
+
+ if w < 1 || h < 1 {
+ return dst
+ }
+
+ if options == nil {
+ options = &ConvolveOptions{}
+ }
+
+ if options.Normalize {
+ normalizeKernel(kernel)
+ }
+
+ type coef struct {
+ x, y int
+ k float64
+ }
+ var coefs []coef
+ var m int
+
+ switch len(kernel) {
+ case 9:
+ m = 1
+ case 25:
+ m = 2
+ default:
+ return dst
+ }
+
+ i := 0
+ for y := -m; y <= m; y++ {
+ for x := -m; x <= m; x++ {
+ if kernel[i] != 0 {
+ coefs = append(coefs, coef{x: x, y: y, k: kernel[i]})
+ }
+ i++
+ }
+ }
+
+ parallel(h, func(partStart, partEnd int) {
+ for y := partStart; y < partEnd; y++ {
+ for x := 0; x < w; x++ {
+ var r, g, b float64
+ for _, c := range coefs {
+ ix := x + c.x
+ if ix < 0 {
+ ix = 0
+ } else if ix >= w {
+ ix = w - 1
+ }
+
+ iy := y + c.y
+ if iy < 0 {
+ iy = 0
+ } else if iy >= h {
+ iy = h - 1
+ }
+
+ off := iy*src.Stride + ix*4
+ r += float64(src.Pix[off+0]) * c.k
+ g += float64(src.Pix[off+1]) * c.k
+ b += float64(src.Pix[off+2]) * c.k
+ }
+
+ if options.Abs {
+ if r < 0 {
+ r = -r
+ }
+ if g < 0 {
+ g = -g
+ }
+ if b < 0 {
+ b = -b
+ }
+ }
+
+ if options.Bias != 0 {
+ r += float64(options.Bias)
+ g += float64(options.Bias)
+ b += float64(options.Bias)
+ }
+
+ srcOff := y*src.Stride + x*4
+ dstOff := y*dst.Stride + x*4
+ dst.Pix[dstOff+0] = clamp(r)
+ dst.Pix[dstOff+1] = clamp(g)
+ dst.Pix[dstOff+2] = clamp(b)
+ dst.Pix[dstOff+3] = src.Pix[srcOff+3]
+ }
+ }
+ })
+
+ return dst
+}
+
+func normalizeKernel(kernel []float64) {
+ var sum, sumpos float64
+ for i := range kernel {
+ sum += kernel[i]
+ if kernel[i] > 0 {
+ sumpos += kernel[i]
+ }
+ }
+ if sum != 0 {
+ for i := range kernel {
+ kernel[i] /= sum
+ }
+ } else if sumpos != 0 {
+ for i := range kernel {
+ kernel[i] /= sumpos
+ }
+ }
+}
diff --git a/vendor/github.com/disintegration/imaging/convolution_test.go b/vendor/github.com/disintegration/imaging/convolution_test.go
new file mode 100644
index 000000000..5a824ead9
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/convolution_test.go
@@ -0,0 +1,275 @@
+package imaging
+
+import (
+ "image"
+ "testing"
+)
+
+func TestConvolve3x3(t *testing.T) {
+ testCases := []struct {
+ desc string
+ src image.Image
+ kernel [9]float64
+ options *ConvolveOptions
+ want *image.NRGBA
+ }{
+ {
+ "Convolve3x3 0x0",
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 0, 0),
+ Stride: 0,
+ Pix: []uint8{},
+ },
+ [9]float64{
+ 0, 0, 0,
+ 0, 1, 0,
+ 0, 0, 0,
+ },
+ nil,
+ &image.NRGBA{Rect: image.Rect(0, 0, 0, 0)},
+ },
+ {
+ "Convolve3x3 4x4 identity",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ [9]float64{
+ 0, 0, 0,
+ 0, 1, 0,
+ 0, 0, 0,
+ },
+ nil,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 4, 4),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ },
+ {
+ "Convolve3x3 4x4 abs",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ [9]float64{
+ 0, 0, 0,
+ 0, -1, 0,
+ 0, 0, 0,
+ },
+ &ConvolveOptions{Abs: true},
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 4, 4),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ },
+ {
+ "Convolve3x3 4x4 bias",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ [9]float64{
+ 0, 0, 0,
+ 0, 1, 0,
+ 0, 0, 0,
+ },
+ &ConvolveOptions{Bias: 0x10},
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 4, 4),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x10, 0x11, 0x12, 0x03, 0x14, 0x15, 0x16, 0x07, 0x18, 0x19, 0x1a, 0x0b, 0x1c, 0x1d, 0x1e, 0x0f,
+ 0x20, 0x21, 0x22, 0x13, 0x24, 0x25, 0x26, 0x17, 0x28, 0x29, 0x2a, 0x1b, 0x2c, 0x2d, 0x2e, 0x1f,
+ 0x30, 0x31, 0x32, 0x23, 0x34, 0x35, 0x36, 0x27, 0x38, 0x39, 0x3a, 0x2b, 0x3c, 0x3d, 0x3e, 0x2f,
+ 0x40, 0x41, 0x42, 0x33, 0x44, 0x45, 0x46, 0x37, 0x48, 0x49, 0x4a, 0x3b, 0x4c, 0x4d, 0x4e, 0x3f,
+ },
+ },
+ },
+ {
+ "Convolve3x3 4x4 norm",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ [9]float64{
+ 1, 1, 1,
+ 1, 1, 1,
+ 1, 1, 1,
+ },
+ &ConvolveOptions{Normalize: true},
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 4, 4),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x07, 0x08, 0x09, 0x03, 0x09, 0x0a, 0x0b, 0x07, 0x0d, 0x0e, 0x0f, 0x0b, 0x10, 0x11, 0x12, 0x0f,
+ 0x11, 0x12, 0x13, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1b, 0x1c, 0x1d, 0x1f,
+ 0x21, 0x22, 0x23, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2b, 0x2c, 0x2d, 0x2f,
+ 0x2c, 0x2d, 0x2e, 0x33, 0x2f, 0x30, 0x31, 0x37, 0x33, 0x34, 0x35, 0x3b, 0x35, 0x36, 0x37, 0x3f,
+ },
+ },
+ },
+ {
+ "Convolve3x3 3x3 laplacian",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 2, 2),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x01, 0xff, 0x00, 0x01, 0x02, 0xff, 0x00, 0x01, 0x03, 0xff,
+ 0x00, 0x01, 0x04, 0xff, 0x10, 0x10, 0x10, 0xff, 0x00, 0x01, 0x05, 0xff,
+ 0x00, 0x01, 0x06, 0xff, 0x00, 0x01, 0x07, 0xff, 0x00, 0x01, 0x08, 0xff,
+ },
+ },
+ [9]float64{
+ -1, -1, -1,
+ -1, 8, -1,
+ -1, -1, -1,
+ },
+ nil,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 3, 3),
+ Stride: 3 * 4,
+ Pix: []uint8{
+ 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x80, 0x78, 0x5c, 0xff, 0x00, 0x00, 0x00, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
+ },
+ },
+ },
+ }
+
+ for _, tc := range testCases {
+ got := Convolve3x3(tc.src, tc.kernel, tc.options)
+ want := tc.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: want %#v got %#v", tc.desc, want, got)
+ }
+ }
+}
+
+func TestConvolve5x5(t *testing.T) {
+ testCases := []struct {
+ desc string
+ src image.Image
+ kernel [25]float64
+ options *ConvolveOptions
+ want *image.NRGBA
+ }{
+ {
+ "Convolve5x5 4x4 translate",
+ &image.NRGBA{
+ Rect: image.Rect(-1, -1, 3, 3),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ [25]float64{
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1,
+ },
+ nil,
+ &image.NRGBA{
+ Rect: image.Rect(0, 0, 4, 4),
+ Stride: 4 * 4,
+ Pix: []uint8{
+ 0x28, 0x29, 0x2a, 0x03, 0x2c, 0x2d, 0x2e, 0x07, 0x2c, 0x2d, 0x2e, 0x0b, 0x2c, 0x2d, 0x2e, 0x0f,
+ 0x38, 0x39, 0x3a, 0x13, 0x3c, 0x3d, 0x3e, 0x17, 0x3c, 0x3d, 0x3e, 0x1b, 0x3c, 0x3d, 0x3e, 0x1f,
+ 0x38, 0x39, 0x3a, 0x23, 0x3c, 0x3d, 0x3e, 0x27, 0x3c, 0x3d, 0x3e, 0x2b, 0x3c, 0x3d, 0x3e, 0x2f,
+ 0x38, 0x39, 0x3a, 0x33, 0x3c, 0x3d, 0x3e, 0x37, 0x3c, 0x3d, 0x3e, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ },
+ },
+ },
+ }
+
+ for _, tc := range testCases {
+ got := Convolve5x5(tc.src, tc.kernel, tc.options)
+ want := tc.want
+ if !compareNRGBA(got, want, 0) {
+ t.Errorf("test [%s] failed: want %#v got %#v", tc.desc, want, got)
+ }
+ }
+}
+
+func BenchmarkConvolve3x3(b *testing.B) {
+ b.StopTimer()
+ img, err := Open("testdata/lena_512.png")
+ if err != nil {
+ b.Fatalf("Open: %v", err)
+ }
+ b.StartTimer()
+ for i := 0; i < b.N; i++ {
+ Convolve3x3(
+ img,
+ [9]float64{
+ -1, -1, 0,
+ -1, 0, 1,
+ 0, 1, 1,
+ },
+ nil,
+ )
+ }
+}
+
+func BenchmarkConvolve5x5(b *testing.B) {
+ b.StopTimer()
+ img, err := Open("testdata/lena_512.png")
+ if err != nil {
+ b.Fatalf("Open: %v", err)
+ }
+ b.StartTimer()
+ for i := 0; i < b.N; i++ {
+ Convolve5x5(
+ img,
+ [25]float64{
+ -1, -1, -1, -1, 0,
+ -1, -1, -1, 0, 1,
+ -1, -1, 0, 1, 1,
+ -1, 0, 1, 1, 1,
+ 0, 1, 1, 1, 1,
+ },
+ nil,
+ )
+ }
+}
diff --git a/vendor/github.com/disintegration/imaging/effects.go b/vendor/github.com/disintegration/imaging/effects.go
index 19d6e405e..25c940381 100644
--- a/vendor/github.com/disintegration/imaging/effects.go
+++ b/vendor/github.com/disintegration/imaging/effects.go
@@ -62,8 +62,7 @@ func blurHorizontal(src *image.NRGBA, kernel []float64) *image.NRGBA {
}
for y := 0; y < height; y++ {
-
- r, g, b, a := 0.0, 0.0, 0.0, 0.0
+ var r, g, b, a float64
for ix := start; ix <= end; ix++ {
weight := kernel[absint(x-ix)]
i := y*src.Stride + ix*4
@@ -74,17 +73,11 @@ func blurHorizontal(src *image.NRGBA, kernel []float64) *image.NRGBA {
a += wa
}
- r = math.Min(math.Max(r/a, 0.0), 255.0)
- g = math.Min(math.Max(g/a, 0.0), 255.0)
- b = math.Min(math.Max(b/a, 0.0), 255.0)
- a = math.Min(math.Max(a/weightSum, 0.0), 255.0)
-
j := y*dst.Stride + x*4
- dst.Pix[j+0] = uint8(r + 0.5)
- dst.Pix[j+1] = uint8(g + 0.5)
- dst.Pix[j+2] = uint8(b + 0.5)
- dst.Pix[j+3] = uint8(a + 0.5)
-
+ dst.Pix[j+0] = clamp(r / a)
+ dst.Pix[j+1] = clamp(g / a)
+ dst.Pix[j+2] = clamp(b / a)
+ dst.Pix[j+3] = clamp(a / weightSum)
}
}
})
@@ -117,8 +110,7 @@ func blurVertical(src *image.NRGBA, kernel []float64) *image.NRGBA {
}
for x := 0; x < width; x++ {
-
- r, g, b, a := 0.0, 0.0, 0.0, 0.0
+ var r, g, b, a float64
for iy := start; iy <= end; iy++ {
weight := kernel[absint(y-iy)]
i := iy*src.Stride + x*4
@@ -129,17 +121,11 @@ func blurVertical(src *image.NRGBA, kernel []float64) *image.NRGBA {
a += wa
}
- r = math.Min(math.Max(r/a, 0.0), 255.0)
- g = math.Min(math.Max(g/a, 0.0), 255.0)
- b = math.Min(math.Max(b/a, 0.0), 255.0)
- a = math.Min(math.Max(a/weightSum, 0.0), 255.0)
-
j := y*dst.Stride + x*4
- dst.Pix[j+0] = uint8(r + 0.5)
- dst.Pix[j+1] = uint8(g + 0.5)
- dst.Pix[j+2] = uint8(b + 0.5)
- dst.Pix[j+3] = uint8(a + 0.5)
-
+ dst.Pix[j+0] = clamp(r / a)
+ dst.Pix[j+1] = clamp(g / a)
+ dst.Pix[j+2] = clamp(b / a)
+ dst.Pix[j+3] = clamp(a / weightSum)
}
}
})
@@ -173,7 +159,7 @@ func Sharpen(img image.Image, sigma float64) *image.NRGBA {
i := y*src.Stride + x*4
for j := 0; j < 4; j++ {
k := i + j
- val := int(src.Pix[k]) + (int(src.Pix[k]) - int(blurred.Pix[k]))
+ val := int(src.Pix[k])<<1 - int(blurred.Pix[k])
if val < 0 {
val = 0
} else if val > 255 {
diff --git a/vendor/github.com/disintegration/imaging/effects_test.go b/vendor/github.com/disintegration/imaging/effects_test.go
index 998ffe399..9c787cb49 100644
--- a/vendor/github.com/disintegration/imaging/effects_test.go
+++ b/vendor/github.com/disintegration/imaging/effects_test.go
@@ -88,6 +88,38 @@ func TestBlur(t *testing.T) {
}
}
+func TestBlurGolden(t *testing.T) {
+ src, err := Open("testdata/lena_128.png")
+ if err != nil {
+ t.Errorf("Open: %v", err)
+ }
+ for name, sigma := range map[string]float64{
+ "out_blur_0.5.png": 0.5,
+ "out_blur_1.5.png": 1.5,
+ } {
+ got := Blur(src, sigma)
+ want, err := Open("testdata/" + name)
+ if err != nil {
+ t.Errorf("Open: %v", err)
+ }
+ if !compareNRGBA(got, toNRGBA(want), 0) {
+ t.Errorf("resulting image differs from golden: %s", name)
+ }
+ }
+}
+
+func BenchmarkBlur(b *testing.B) {
+ b.StopTimer()
+ img, err := Open("testdata/lena_512.png")
+ if err != nil {
+ b.Fatalf("Open: %v", err)
+ }
+ b.StartTimer()
+ for i := 0; i < b.N; i++ {
+ Blur(img, 3)
+ }
+}
+
func TestSharpen(t *testing.T) {
td := []struct {
desc string
@@ -188,3 +220,35 @@ func TestSharpen(t *testing.T) {
}
}
}
+
+func TestSharpenGolden(t *testing.T) {
+ src, err := Open("testdata/lena_128.png")
+ if err != nil {
+ t.Errorf("Open: %v", err)
+ }
+ for name, sigma := range map[string]float64{
+ "out_sharpen_0.5.png": 0.5,
+ "out_sharpen_1.5.png": 1.5,
+ } {
+ got := Sharpen(src, sigma)
+ want, err := Open("testdata/" + name)
+ if err != nil {
+ t.Errorf("Open: %v", err)
+ }
+ if !compareNRGBA(got, toNRGBA(want), 0) {
+ t.Errorf("resulting image differs from golden: %s", name)
+ }
+ }
+}
+
+func BenchmarkSharpen(b *testing.B) {
+ b.StopTimer()
+ img, err := Open("testdata/lena_512.png")
+ if err != nil {
+ b.Fatalf("Open: %v", err)
+ }
+ b.StartTimer()
+ for i := 0; i < b.N; i++ {
+ Sharpen(img, 3)
+ }
+}
diff --git a/vendor/github.com/disintegration/imaging/example_test.go b/vendor/github.com/disintegration/imaging/example_test.go
new file mode 100644
index 000000000..d79451f03
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/example_test.go
@@ -0,0 +1,58 @@
+package imaging_test
+
+import (
+ "image"
+ "image/color"
+ "log"
+
+ "github.com/disintegration/imaging"
+)
+
+func Example() {
+ // Open the test image.
+ src, err := imaging.Open("testdata/lena_512.png")
+ if err != nil {
+ log.Fatalf("Open failed: %v", err)
+ }
+
+ // Crop the original image to 350x350px size using the center anchor.
+ src = imaging.CropAnchor(src, 350, 350, imaging.Center)
+
+ // Resize the cropped image to width = 256px preserving the aspect ratio.
+ src = imaging.Resize(src, 256, 0, imaging.Lanczos)
+
+ // Create a blurred version of the image.
+ img1 := imaging.Blur(src, 2)
+
+ // Create a grayscale version of the image with higher contrast and sharpness.
+ img2 := imaging.Grayscale(src)
+ img2 = imaging.AdjustContrast(img2, 20)
+ img2 = imaging.Sharpen(img2, 2)
+
+ // Create an inverted version of the image.
+ img3 := imaging.Invert(src)
+
+ // Create an embossed version of the image using a convolution filter.
+ img4 := imaging.Convolve3x3(
+ src,
+ [9]float64{
+ -1, -1, 0,
+ -1, 1, 1,
+ 0, 1, 1,
+ },
+ nil,
+ )
+
+ // Create a new image and paste the four produced images into it.
+ dst := imaging.New(512, 512, color.NRGBA{0, 0, 0, 0})
+ dst = imaging.Paste(dst, img1, image.Pt(0, 0))
+ dst = imaging.Paste(dst, img2, image.Pt(0, 256))
+ dst = imaging.Paste(dst, img3, image.Pt(256, 0))
+ dst = imaging.Paste(dst, img4, image.Pt(256, 256))
+
+ // Save the resulting image using JPEG format.
+ err = imaging.Save(dst, "testdata/out_example.jpg")
+ if err != nil {
+ log.Fatalf("Save failed: %v", err)
+ }
+}
diff --git a/vendor/github.com/disintegration/imaging/helpers.go b/vendor/github.com/disintegration/imaging/helpers.go
index 79967ae44..3a4cbde80 100644
--- a/vendor/github.com/disintegration/imaging/helpers.go
+++ b/vendor/github.com/disintegration/imaging/helpers.go
@@ -1,11 +1,9 @@
-/*
-Package imaging provides basic image manipulation functions (resize, rotate, flip, crop, etc.).
-This package is based on the standard Go image package and works best along with it.
-
-Image manipulation functions provided by the package take any image type
-that implements `image.Image` interface as an input, and return a new image of
-`*image.NRGBA` type (32bit RGBA colors, not premultiplied by alpha).
-*/
+// Package imaging provides basic image manipulation functions (resize, rotate, flip, crop, etc.).
+// This package is based on the standard Go image package and works best along with it.
+//
+// Image manipulation functions provided by the package take any image type
+// that implements `image.Image` interface as an input, and return a new image of
+// `*image.NRGBA` type (32bit RGBA colors, not premultiplied by alpha).
package imaging
import (
@@ -24,8 +22,10 @@ import (
"golang.org/x/image/tiff"
)
+// Format is an image file format.
type Format int
+// Image file formats.
const (
JPEG Format = iota
PNG
@@ -52,6 +52,7 @@ func (f Format) String() string {
}
var (
+ // ErrUnsupportedFormat means the given image format (or file extension) is unsupported.
ErrUnsupportedFormat = errors.New("imaging: unsupported image format")
)
@@ -194,15 +195,12 @@ func Clone(img image.Image) *image.NRGBA {
di := dst.PixOffset(0, dstY)
si := src.PixOffset(srcMinX, srcMinY+dstY)
for dstX := 0; dstX < dstW; dstX++ {
-
dst.Pix[di+0] = src.Pix[si+0]
dst.Pix[di+1] = src.Pix[si+2]
dst.Pix[di+2] = src.Pix[si+4]
dst.Pix[di+3] = src.Pix[si+6]
-
di += 4
si += 8
-
}
}
})
@@ -213,9 +211,9 @@ func Clone(img image.Image) *image.NRGBA {
di := dst.PixOffset(0, dstY)
si := src.PixOffset(srcMinX, srcMinY+dstY)
for dstX := 0; dstX < dstW; dstX++ {
-
a := src.Pix[si+3]
dst.Pix[di+3] = a
+
switch a {
case 0:
dst.Pix[di+0] = 0
@@ -237,7 +235,6 @@ func Clone(img image.Image) *image.NRGBA {
di += 4
si += 4
-
}
}
})
@@ -248,9 +245,9 @@ func Clone(img image.Image) *image.NRGBA {
di := dst.PixOffset(0, dstY)
si := src.PixOffset(srcMinX, srcMinY+dstY)
for dstX := 0; dstX < dstW; dstX++ {
-
a := src.Pix[si+6]
dst.Pix[di+3] = a
+
switch a {
case 0:
dst.Pix[di+0] = 0
@@ -272,7 +269,6 @@ func Clone(img image.Image) *image.NRGBA {
di += 4
si += 8
-
}
}
})
@@ -283,16 +279,13 @@ func Clone(img image.Image) *image.NRGBA {
di := dst.PixOffset(0, dstY)
si := src.PixOffset(srcMinX, srcMinY+dstY)
for dstX := 0; dstX < dstW; dstX++ {
-
c := src.Pix[si]
dst.Pix[di+0] = c
dst.Pix[di+1] = c
dst.Pix[di+2] = c
dst.Pix[di+3] = 0xff
-
di += 4
si += 1
-
}
}
})
@@ -303,16 +296,13 @@ func Clone(img image.Image) *image.NRGBA {
di := dst.PixOffset(0, dstY)
si := src.PixOffset(srcMinX, srcMinY+dstY)
for dstX := 0; dstX < dstW; dstX++ {
-
c := src.Pix[si]
dst.Pix[di+0] = c
dst.Pix[di+1] = c
dst.Pix[di+2] = c
dst.Pix[di+3] = 0xff
-
di += 4
si += 2
-
}
}
})
@@ -322,7 +312,6 @@ func Clone(img image.Image) *image.NRGBA {
for dstY := partStart; dstY < partEnd; dstY++ {
di := dst.PixOffset(0, dstY)
for dstX := 0; dstX < dstW; dstX++ {
-
srcX := srcMinX + dstX
srcY := srcMinY + dstY
siy := src.YOffset(srcX, srcY)
@@ -332,9 +321,7 @@ func Clone(img image.Image) *image.NRGBA {
dst.Pix[di+1] = g
dst.Pix[di+2] = b
dst.Pix[di+3] = 0xff
-
di += 4
-
}
}
})
@@ -345,22 +332,18 @@ func Clone(img image.Image) *image.NRGBA {
for i := 0; i < plen; i++ {
pnew[i] = color.NRGBAModel.Convert(src.Palette[i]).(color.NRGBA)
}
-
parallel(dstH, func(partStart, partEnd int) {
for dstY := partStart; dstY < partEnd; dstY++ {
di := dst.PixOffset(0, dstY)
si := src.PixOffset(srcMinX, srcMinY+dstY)
for dstX := 0; dstX < dstW; dstX++ {
-
c := pnew[src.Pix[si]]
dst.Pix[di+0] = c.R
dst.Pix[di+1] = c.G
dst.Pix[di+2] = c.B
dst.Pix[di+3] = c.A
-
di += 4
si += 1
-
}
}
})
@@ -370,15 +353,12 @@ func Clone(img image.Image) *image.NRGBA {
for dstY := partStart; dstY < partEnd; dstY++ {
di := dst.PixOffset(0, dstY)
for dstX := 0; dstX < dstW; dstX++ {
-
c := color.NRGBAModel.Convert(img.At(srcMinX+dstX, srcMinY+dstY)).(color.NRGBA)
dst.Pix[di+0] = c.R
dst.Pix[di+1] = c.G
dst.Pix[di+2] = c.B
dst.Pix[di+3] = c.A
-
di += 4
-
}
}
})
@@ -388,7 +368,7 @@ func Clone(img image.Image) *image.NRGBA {
return dst
}
-// This function used internally to convert any image type to NRGBA if needed.
+// toNRGBA converts any image type to *image.NRGBA with min-point at (0, 0).
func toNRGBA(img image.Image) *image.NRGBA {
srcBounds := img.Bounds()
if srcBounds.Min.X == 0 && srcBounds.Min.Y == 0 {
diff --git a/vendor/github.com/disintegration/imaging/histogram.go b/vendor/github.com/disintegration/imaging/histogram.go
index aef333822..3afcb7ae2 100644
--- a/vendor/github.com/disintegration/imaging/histogram.go
+++ b/vendor/github.com/disintegration/imaging/histogram.go
@@ -17,7 +17,7 @@ func Histogram(img image.Image) [256]float64 {
var total float64
if width == 0 || height == 0 {
- return histogram
+ return histogram
}
for y := 0; y < height; y++ {
diff --git a/vendor/github.com/disintegration/imaging/histogram_test.go b/vendor/github.com/disintegration/imaging/histogram_test.go
index 0bcf82588..10f4c3fef 100644
--- a/vendor/github.com/disintegration/imaging/histogram_test.go
+++ b/vendor/github.com/disintegration/imaging/histogram_test.go
@@ -36,7 +36,7 @@ func TestHistogram(t *testing.T) {
for _, val := range h {
if val != 0 {
t.Errorf("Histogram for an empty image should be a zero histogram.")
- return
+ return
}
}
}
diff --git a/vendor/github.com/disintegration/imaging/resize.go b/vendor/github.com/disintegration/imaging/resize.go
index b21eed544..937f63fe9 100644
--- a/vendor/github.com/disintegration/imaging/resize.go
+++ b/vendor/github.com/disintegration/imaging/resize.go
@@ -5,17 +5,12 @@ import (
"math"
)
-type iwpair struct {
- i int
- w int32
+type indexWeight struct {
+ index int
+ weight float64
}
-type pweights struct {
- iwpairs []iwpair
- wsum int32
-}
-
-func precomputeWeights(dstSize, srcSize int, filter ResampleFilter) []pweights {
+func precomputeWeights(dstSize, srcSize int, filter ResampleFilter) [][]indexWeight {
du := float64(srcSize) / float64(dstSize)
scale := du
if scale < 1.0 {
@@ -23,7 +18,7 @@ func precomputeWeights(dstSize, srcSize int, filter ResampleFilter) []pweights {
}
ru := math.Ceil(scale * filter.Support)
- out := make([]pweights, dstSize)
+ out := make([][]indexWeight, dstSize)
for v := 0; v < dstSize; v++ {
fu := (float64(v)+0.5)*du - 0.5
@@ -37,15 +32,19 @@ func precomputeWeights(dstSize, srcSize int, filter ResampleFilter) []pweights {
endu = srcSize - 1
}
- wsum := int32(0)
+ var sum float64
for u := startu; u <= endu; u++ {
- w := int32(0xff * filter.Kernel((float64(u)-fu)/scale))
+ w := filter.Kernel((float64(u) - fu) / scale)
if w != 0 {
- wsum += w
- out[v].iwpairs = append(out[v].iwpairs, iwpair{u, w})
+ sum += w
+ out[v] = append(out[v], indexWeight{index: u, weight: w})
+ }
+ }
+ if sum != 0 {
+ for i := range out[v] {
+ out[v][i].weight /= sum
}
}
- out[v].wsum = wsum
}
return out
@@ -127,22 +126,26 @@ func resizeHorizontal(src *image.NRGBA, width int, filter ResampleFilter) *image
parallel(dstH, func(partStart, partEnd int) {
for dstY := partStart; dstY < partEnd; dstY++ {
+ i0 := dstY * src.Stride
+ j0 := dstY * dst.Stride
for dstX := 0; dstX < dstW; dstX++ {
- var c [4]int64
- for _, iw := range weights[dstX].iwpairs {
- i := dstY*src.Stride + iw.i*4
- a := int64(src.Pix[i+3]) * int64(iw.w)
- c[0] += int64(src.Pix[i+0]) * a
- c[1] += int64(src.Pix[i+1]) * a
- c[2] += int64(src.Pix[i+2]) * a
- c[3] += a
+ var r, g, b, a float64
+ for _, w := range weights[dstX] {
+ i := i0 + w.index*4
+ aw := float64(src.Pix[i+3]) * w.weight
+ r += float64(src.Pix[i+0]) * aw
+ g += float64(src.Pix[i+1]) * aw
+ b += float64(src.Pix[i+2]) * aw
+ a += aw
+ }
+ if a != 0 {
+ aInv := 1 / a
+ j := j0 + dstX*4
+ dst.Pix[j+0] = clamp(r * aInv)
+ dst.Pix[j+1] = clamp(g * aInv)
+ dst.Pix[j+2] = clamp(b * aInv)
+ dst.Pix[j+3] = clamp(a)
}
- j := dstY*dst.Stride + dstX*4
- sum := weights[dstX].wsum
- dst.Pix[j+0] = clampint32(int32(float64(c[0])/float64(c[3]) + 0.5))
- dst.Pix[j+1] = clampint32(int32(float64(c[1])/float64(c[3]) + 0.5))
- dst.Pix[j+2] = clampint32(int32(float64(c[2])/float64(c[3]) + 0.5))
- dst.Pix[j+3] = clampint32(int32(float64(c[3])/float64(sum) + 0.5))
}
}
})
@@ -163,33 +166,33 @@ func resizeVertical(src *image.NRGBA, height int, filter ResampleFilter) *image.
weights := precomputeWeights(dstH, srcH, filter)
parallel(dstW, func(partStart, partEnd int) {
-
for dstX := partStart; dstX < partEnd; dstX++ {
for dstY := 0; dstY < dstH; dstY++ {
- var c [4]int64
- for _, iw := range weights[dstY].iwpairs {
- i := iw.i*src.Stride + dstX*4
- a := int64(src.Pix[i+3]) * int64(iw.w)
- c[0] += int64(src.Pix[i+0]) * a
- c[1] += int64(src.Pix[i+1]) * a
- c[2] += int64(src.Pix[i+2]) * a
- c[3] += a
+ var r, g, b, a float64
+ for _, w := range weights[dstY] {
+ i := w.index*src.Stride + dstX*4
+ aw := float64(src.Pix[i+3]) * w.weight
+ r += float64(src.Pix[i+0]) * aw
+ g += float64(src.Pix[i+1]) * aw
+ b += float64(src.Pix[i+2]) * aw
+ a += aw
+ }
+ if a != 0 {
+ aInv := 1 / a
+ j := dstY*dst.Stride + dstX*4
+ dst.Pix[j+0] = clamp(r * aInv)
+ dst.Pix[j+1] = clamp(g * aInv)
+ dst.Pix[j+2] = clamp(b * aInv)
+ dst.Pix[j+3] = clamp(a)
}
- j := dstY*dst.Stride + dstX*4
- sum := weights[dstY].wsum
- dst.Pix[j+0] = clampint32(int32(float64(c[0])/float64(c[3]) + 0.5))
- dst.Pix[j+1] = clampint32(int32(float64(c[1])/float64(c[3]) + 0.5))
- dst.Pix[j+2] = clampint32(int32(float64(c[2])/float64(c[3]) + 0.5))
- dst.Pix[j+3] = clampint32(int32(float64(c[3])/float64(sum) + 0.5))
}
}
-
})
return dst
}
-// fast nearest-neighbor resize, no filtering
+// resizeNearest is a fast nearest-neighbor resize, no filtering.
func resizeNearest(src *image.NRGBA, width, height int) *image.NRGBA {
dstW, dstH := width, height
@@ -205,13 +208,16 @@ func resizeNearest(src *image.NRGBA, width, height int) *image.NRGBA {
parallel(dstH, func(partStart, partEnd int) {
for dstY := partStart; dstY < partEnd; dstY++ {
- fy := (float64(dstY)+0.5)*dy - 0.5
+ srcY := int((float64(dstY) + 0.5) * dy)
+ if srcY > srcH-1 {
+ srcY = srcH - 1
+ }
for dstX := 0; dstX < dstW; dstX++ {
- fx := (float64(dstX)+0.5)*dx - 0.5
-
- srcX := int(math.Min(math.Max(math.Floor(fx+0.5), 0.0), float64(srcW)))
- srcY := int(math.Min(math.Max(math.Floor(fy+0.5), 0.0), float64(srcH)))
+ srcX := int((float64(dstX) + 0.5) * dx)
+ if srcX > srcW-1 {
+ srcX = srcW - 1
+ }
srcOff := srcY*src.Stride + srcX*4
dstOff := dstY*dst.Stride + dstX*4
@@ -326,7 +332,7 @@ func Thumbnail(img image.Image, width, height int, filter ResampleFilter) *image
return Fill(img, width, height, Center, filter)
}
-// Resample filter struct. It can be used to make custom filters.
+// ResampleFilter is a resampling filter struct. It can be used to define custom filters.
//
// Supported resample filters: NearestNeighbor, Box, Linear, Hermite, MitchellNetravali,
// CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, Cosine.
@@ -361,7 +367,7 @@ type ResampleFilter struct {
Kernel func(float64) float64
}
-// Nearest-neighbor filter, no anti-aliasing.
+// NearestNeighbor is a nearest-neighbor filter (no anti-aliasing).
var NearestNeighbor ResampleFilter
// Box filter (averaging pixels).
@@ -373,37 +379,37 @@ var Linear ResampleFilter
// Hermite cubic spline filter (BC-spline; B=0; C=0).
var Hermite ResampleFilter
-// Mitchell-Netravali cubic filter (BC-spline; B=1/3; C=1/3).
+// MitchellNetravali is Mitchell-Netravali cubic filter (BC-spline; B=1/3; C=1/3).
var MitchellNetravali ResampleFilter
-// Catmull-Rom - sharp cubic filter (BC-spline; B=0; C=0.5).
+// CatmullRom is a Catmull-Rom - sharp cubic filter (BC-spline; B=0; C=0.5).
var CatmullRom ResampleFilter
-// Cubic B-spline - smooth cubic filter (BC-spline; B=1; C=0).
+// BSpline is a smooth cubic filter (BC-spline; B=1; C=0).
var BSpline ResampleFilter
-// Gaussian Blurring Filter.
+// Gaussian is a Gaussian blurring Filter.
var Gaussian ResampleFilter
-// Bartlett-windowed sinc filter (3 lobes).
+// Bartlett is a Bartlett-windowed sinc filter (3 lobes).
var Bartlett ResampleFilter
// Lanczos filter (3 lobes).
var Lanczos ResampleFilter
-// Hann-windowed sinc filter (3 lobes).
+// Hann is a Hann-windowed sinc filter (3 lobes).
var Hann ResampleFilter
-// Hamming-windowed sinc filter (3 lobes).
+// Hamming is a Hamming-windowed sinc filter (3 lobes).
var Hamming ResampleFilter
-// Blackman-windowed sinc filter (3 lobes).
+// Blackman is a Blackman-windowed sinc filter (3 lobes).
var Blackman ResampleFilter
-// Welch-windowed sinc filter (parabolic window, 3 lobes).
+// Welch is a Welch-windowed sinc filter (parabolic window, 3 lobes).
var Welch ResampleFilter
-// Cosine-windowed sinc filter (3 lobes).
+// Cosine is a Cosine-windowed sinc filter (3 lobes).
var Cosine ResampleFilter
func bcspline(x, b, c float64) float64 {
diff --git a/vendor/github.com/disintegration/imaging/resize_test.go b/vendor/github.com/disintegration/imaging/resize_test.go
index 927f92512..72701e093 100644
--- a/vendor/github.com/disintegration/imaging/resize_test.go
+++ b/vendor/github.com/disintegration/imaging/resize_test.go
@@ -108,10 +108,10 @@ func TestResize(t *testing.T) {
Rect: image.Rect(0, 0, 4, 4),
Stride: 4 * 4,
Pix: []uint8{
- 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x3f, 0xff, 0x00, 0x00, 0xc0, 0xff, 0x00, 0x00, 0xff,
- 0x00, 0xff, 0x00, 0x3f, 0x6d, 0x6e, 0x24, 0x6f, 0xb1, 0x13, 0x3a, 0xd0, 0xc0, 0x00, 0x3f, 0xff,
- 0x00, 0xff, 0x00, 0xc0, 0x13, 0xb2, 0x3a, 0xcf, 0x33, 0x32, 0x9a, 0xef, 0x3f, 0x00, 0xc0, 0xff,
- 0x00, 0xff, 0x00, 0xff, 0x00, 0xc0, 0x3f, 0xff, 0x00, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x40, 0xff, 0x00, 0x00, 0xbf, 0xff, 0x00, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0x40, 0x6e, 0x6d, 0x25, 0x70, 0xb0, 0x14, 0x3b, 0xcf, 0xbf, 0x00, 0x40, 0xff,
+ 0x00, 0xff, 0x00, 0xbf, 0x14, 0xb0, 0x3b, 0xcf, 0x33, 0x33, 0x99, 0xef, 0x40, 0x00, 0xbf, 0xff,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0xbf, 0x40, 0xff, 0x00, 0x40, 0xbf, 0xff, 0x00, 0x00, 0xff, 0xff,
},
},
},
@@ -158,7 +158,7 @@ func TestResize(t *testing.T) {
for _, d := range td {
got := Resize(d.src, d.w, d.h, d.f)
want := d.want
- if !compareNRGBA(got, want, 1) {
+ if !compareNRGBA(got, want, 0) {
t.Errorf("test [%s] failed: %#v", d.desc, got)
}
}
@@ -201,6 +201,28 @@ func TestResize(t *testing.T) {
}
}
+func TestResizeGolden(t *testing.T) {
+ src, err := Open("testdata/lena_512.png")
+ if err != nil {
+ t.Errorf("Open: %v", err)
+ }
+ for name, filter := range map[string]ResampleFilter{
+ "out_resize_nearest.png": NearestNeighbor,
+ "out_resize_linear.png": Linear,
+ "out_resize_catrom.png": CatmullRom,
+ "out_resize_lanczos.png": Lanczos,
+ } {
+ got := Resize(src, 128, 0, filter)
+ want, err := Open("testdata/" + name)
+ if err != nil {
+ t.Errorf("Open: %v", err)
+ }
+ if !compareNRGBA(got, toNRGBA(want), 0) {
+ t.Errorf("resulting image differs from golden: %s", name)
+ }
+ }
+}
+
func TestFit(t *testing.T) {
td := []struct {
desc string
@@ -568,3 +590,39 @@ func TestThumbnail(t *testing.T) {
}
}
}
+
+func BenchmarkResizeLanczosUp(b *testing.B) {
+ benchmarkResize(b, "testdata/lena_128.png", 512, Lanczos)
+}
+
+func BenchmarkResizeLinearUp(b *testing.B) {
+ benchmarkResize(b, "testdata/lena_128.png", 512, Linear)
+}
+
+func BenchmarkResizeNearestNeighborUp(b *testing.B) {
+ benchmarkResize(b, "testdata/lena_128.png", 512, NearestNeighbor)
+}
+
+func BenchmarkResizeLanczosDown(b *testing.B) {
+ benchmarkResize(b, "testdata/lena_512.png", 128, Lanczos)
+}
+
+func BenchmarkResizeLinearDown(b *testing.B) {
+ benchmarkResize(b, "testdata/lena_512.png", 128, Linear)
+}
+
+func BenchmarkResizeNearestNeighborDown(b *testing.B) {
+ benchmarkResize(b, "testdata/lena_512.png", 128, NearestNeighbor)
+}
+
+func benchmarkResize(b *testing.B, filename string, size int, f ResampleFilter) {
+ b.StopTimer()
+ img, err := Open(filename)
+ if err != nil {
+ b.Fatalf("Open: %v", err)
+ }
+ b.StartTimer()
+ for i := 0; i < b.N; i++ {
+ Resize(img, size, size, f)
+ }
+}
diff --git a/vendor/github.com/disintegration/imaging/testdata/lena_128.png b/vendor/github.com/disintegration/imaging/testdata/lena_128.png
new file mode 100644
index 000000000..43eb8e7c6
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/testdata/lena_128.png
Binary files differ
diff --git a/vendor/github.com/disintegration/imaging/testdata/lena_512.png b/vendor/github.com/disintegration/imaging/testdata/lena_512.png
new file mode 100644
index 000000000..0e0f9e6bc
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/testdata/lena_512.png
Binary files differ
diff --git a/vendor/github.com/disintegration/imaging/testdata/out_blur_0.5.png b/vendor/github.com/disintegration/imaging/testdata/out_blur_0.5.png
new file mode 100644
index 000000000..90d19347e
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/testdata/out_blur_0.5.png
Binary files differ
diff --git a/vendor/github.com/disintegration/imaging/testdata/out_blur_1.5.png b/vendor/github.com/disintegration/imaging/testdata/out_blur_1.5.png
new file mode 100644
index 000000000..3df019c33
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/testdata/out_blur_1.5.png
Binary files differ
diff --git a/vendor/github.com/disintegration/imaging/testdata/out_brightness_m10.png b/vendor/github.com/disintegration/imaging/testdata/out_brightness_m10.png
new file mode 100644
index 000000000..a59191e9d
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/testdata/out_brightness_m10.png
Binary files differ
diff --git a/vendor/github.com/disintegration/imaging/testdata/out_brightness_p10.png b/vendor/github.com/disintegration/imaging/testdata/out_brightness_p10.png
new file mode 100644
index 000000000..0b8bb3e10
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/testdata/out_brightness_p10.png
Binary files differ
diff --git a/vendor/github.com/disintegration/imaging/testdata/out_contrast_m10.png b/vendor/github.com/disintegration/imaging/testdata/out_contrast_m10.png
new file mode 100644
index 000000000..8b8e0b8e0
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/testdata/out_contrast_m10.png
Binary files differ
diff --git a/vendor/github.com/disintegration/imaging/testdata/out_contrast_p10.png b/vendor/github.com/disintegration/imaging/testdata/out_contrast_p10.png
new file mode 100644
index 000000000..dbfd40eea
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/testdata/out_contrast_p10.png
Binary files differ
diff --git a/vendor/github.com/disintegration/imaging/testdata/out_example.jpg b/vendor/github.com/disintegration/imaging/testdata/out_example.jpg
new file mode 100644
index 000000000..5f225b58f
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/testdata/out_example.jpg
Binary files differ
diff --git a/vendor/github.com/disintegration/imaging/testdata/out_gamma_0.75.png b/vendor/github.com/disintegration/imaging/testdata/out_gamma_0.75.png
new file mode 100644
index 000000000..89d28735b
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/testdata/out_gamma_0.75.png
Binary files differ
diff --git a/vendor/github.com/disintegration/imaging/testdata/out_gamma_1.25.png b/vendor/github.com/disintegration/imaging/testdata/out_gamma_1.25.png
new file mode 100644
index 000000000..915e6d53d
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/testdata/out_gamma_1.25.png
Binary files differ
diff --git a/vendor/github.com/disintegration/imaging/testdata/out_resize_catrom.png b/vendor/github.com/disintegration/imaging/testdata/out_resize_catrom.png
new file mode 100644
index 000000000..628272f97
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/testdata/out_resize_catrom.png
Binary files differ
diff --git a/vendor/github.com/disintegration/imaging/testdata/out_resize_lanczos.png b/vendor/github.com/disintegration/imaging/testdata/out_resize_lanczos.png
new file mode 100644
index 000000000..6d168f70e
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/testdata/out_resize_lanczos.png
Binary files differ
diff --git a/vendor/github.com/disintegration/imaging/testdata/out_resize_linear.png b/vendor/github.com/disintegration/imaging/testdata/out_resize_linear.png
new file mode 100644
index 000000000..0a74e5e5f
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/testdata/out_resize_linear.png
Binary files differ
diff --git a/vendor/github.com/disintegration/imaging/testdata/out_resize_nearest.png b/vendor/github.com/disintegration/imaging/testdata/out_resize_nearest.png
new file mode 100644
index 000000000..108cb6601
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/testdata/out_resize_nearest.png
Binary files differ
diff --git a/vendor/github.com/disintegration/imaging/testdata/out_sharpen_0.5.png b/vendor/github.com/disintegration/imaging/testdata/out_sharpen_0.5.png
new file mode 100644
index 000000000..056ba59b2
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/testdata/out_sharpen_0.5.png
Binary files differ
diff --git a/vendor/github.com/disintegration/imaging/testdata/out_sharpen_1.5.png b/vendor/github.com/disintegration/imaging/testdata/out_sharpen_1.5.png
new file mode 100644
index 000000000..a47dc6040
--- /dev/null
+++ b/vendor/github.com/disintegration/imaging/testdata/out_sharpen_1.5.png
Binary files differ
diff --git a/vendor/github.com/disintegration/imaging/tools.go b/vendor/github.com/disintegration/imaging/tools.go
index 76f14447b..2c6d68eea 100644
--- a/vendor/github.com/disintegration/imaging/tools.go
+++ b/vendor/github.com/disintegration/imaging/tools.go
@@ -8,6 +8,7 @@ import (
// Anchor is the anchor point for image alignment.
type Anchor int
+// Anchor point positions.
const (
Center Anchor = iota
TopLeft
diff --git a/vendor/github.com/disintegration/imaging/tools_test.go b/vendor/github.com/disintegration/imaging/tools_test.go
index 2ac7b31d3..83a258c26 100644
--- a/vendor/github.com/disintegration/imaging/tools_test.go
+++ b/vendor/github.com/disintegration/imaging/tools_test.go
@@ -598,7 +598,7 @@ func TestOverlay(t *testing.T) {
for _, d := range td {
got := Overlay(d.src1, d.src2, d.p, d.a)
want := d.want
- if !compareNRGBA(got, want, 1) {
+ if !compareNRGBA(got, want, 0) {
t.Errorf("test [%s] failed: %#v", d.desc, got)
}
}
diff --git a/vendor/github.com/disintegration/imaging/utils.go b/vendor/github.com/disintegration/imaging/utils.go
index 8b1ab8adb..9f5926aaa 100644
--- a/vendor/github.com/disintegration/imaging/utils.go
+++ b/vendor/github.com/disintegration/imaging/utils.go
@@ -1,28 +1,24 @@
package imaging
import (
- "math"
"runtime"
"sync"
"sync/atomic"
)
-var parallelizationEnabled = true
-
-// if GOMAXPROCS = 1: no goroutines used
-// if GOMAXPROCS > 1: spawn N=GOMAXPROCS workers in separate goroutines
+// parallel starts parallel image processing based on the current GOMAXPROCS value.
+// If GOMAXPROCS = 1 it uses no parallelization.
+// If GOMAXPROCS > 1 it spawns N=GOMAXPROCS workers in separate goroutines.
func parallel(dataSize int, fn func(partStart, partEnd int)) {
numGoroutines := 1
partSize := dataSize
- if parallelizationEnabled {
- numProcs := runtime.GOMAXPROCS(0)
- if numProcs > 1 {
- numGoroutines = numProcs
- partSize = dataSize / (numGoroutines * 10)
- if partSize < 1 {
- partSize = 1
- }
+ numProcs := runtime.GOMAXPROCS(0)
+ if numProcs > 1 {
+ numGoroutines = numProcs
+ partSize = dataSize / (numGoroutines * 10)
+ if partSize < 1 {
+ partSize = 1
}
}
@@ -54,6 +50,7 @@ func parallel(dataSize int, fn func(partStart, partEnd int)) {
}
}
+// absint returns the absolute value of i.
func absint(i int) int {
if i < 0 {
return -i
@@ -61,17 +58,14 @@ func absint(i int) int {
return i
}
-// clamp & round float64 to uint8 (0..255)
-func clamp(v float64) uint8 {
- return uint8(math.Min(math.Max(v, 0.0), 255.0) + 0.5)
-}
-
-// clamp int32 to uint8 (0..255)
-func clampint32(v int32) uint8 {
- if v < 0 {
- return 0
- } else if v > 255 {
+// clamp rounds and clamps float64 value to fit into uint8.
+func clamp(x float64) uint8 {
+ v := int64(x + 0.5)
+ if v > 255 {
return 255
}
- return uint8(v)
+ if v > 0 {
+ return uint8(v)
+ }
+ return 0
}
diff --git a/vendor/github.com/disintegration/imaging/utils_test.go b/vendor/github.com/disintegration/imaging/utils_test.go
index 99aa8c82f..44cc75102 100644
--- a/vendor/github.com/disintegration/imaging/utils_test.go
+++ b/vendor/github.com/disintegration/imaging/utils_test.go
@@ -15,7 +15,7 @@ func testParallelN(enabled bool, n, procs int) bool {
}
})
for i := 0; i < n; i++ {
- if data[i] != true {
+ if !data[i] {
return false
}
}
@@ -27,7 +27,7 @@ func TestParallel(t *testing.T) {
for _, e := range []bool{true, false} {
for _, n := range []int{1, 10, 100, 1000} {
for _, p := range []int{1, 2, 4, 8, 16, 100} {
- if testParallelN(e, n, p) != true {
+ if !testParallelN(e, n, p) {
t.Errorf("test [parallel %v %d %d] failed", e, n, p)
}
}
@@ -59,23 +59,3 @@ func TestClamp(t *testing.T) {
}
}
}
-
-func TestClampint32(t *testing.T) {
- td := []struct {
- i int32
- u uint8
- }{
- {0, 0},
- {255, 255},
- {128, 128},
- {256, 255},
- {2500, 255},
- {-10, 0},
- }
-
- for _, d := range td {
- if clampint32(d.i) != d.u {
- t.Errorf("test [clampint32 %v %v] failed: %v", d.i, d.u, clampint32(d.i))
- }
- }
-}
diff --git a/vendor/github.com/golang/freetype/truetype/truetype.go b/vendor/github.com/golang/freetype/truetype/truetype.go
index 613fc17e2..7a17d8e86 100644
--- a/vendor/github.com/golang/freetype/truetype/truetype.go
+++ b/vendor/github.com/golang/freetype/truetype/truetype.go
@@ -57,7 +57,8 @@ const (
// A 32-bit encoding consists of a most-significant 16-bit Platform ID and a
// least-significant 16-bit Platform Specific ID. The magic numbers are
// specified at https://www.microsoft.com/typography/otspec/name.htm
- unicodeEncoding = 0x00000003 // PID = 0 (Unicode), PSID = 3 (Unicode 2.0)
+ unicodeEncodingBMPOnly = 0x00000003 // PID = 0 (Unicode), PSID = 3 (Unicode 2.0 BMP Only)
+ unicodeEncodingFull = 0x00000004 // PID = 0 (Unicode), PSID = 4 (Unicode 2.0 Full Repertoire)
microsoftSymbolEncoding = 0x00030000 // PID = 3 (Microsoft), PSID = 0 (Symbol)
microsoftUCS2Encoding = 0x00030001 // PID = 3 (Microsoft), PSID = 1 (UCS-2)
microsoftUCS4Encoding = 0x0003000a // PID = 3 (Microsoft), PSID = 10 (UCS-4)
@@ -142,7 +143,7 @@ func parseSubtables(table []byte, name string, offset, size int, pred func([]byt
pidPsid := u32(table, offset)
// We prefer the Unicode cmap encoding. Failing to find that, we fall
// back onto the Microsoft cmap encoding.
- if pidPsid == unicodeEncoding {
+ if pidPsid == unicodeEncodingBMPOnly || pidPsid == unicodeEncodingFull {
bestOffset, bestPID, ok = offset, pidPsid>>16, true
break
@@ -550,8 +551,7 @@ func parse(ttf []byte, offset int) (font *Font, err error) {
return
}
ttcVersion, offset := u32(ttf, offset), offset+4
- if ttcVersion != 0x00010000 {
- // TODO: support TTC version 2.0, once I have such a .ttc file to test with.
+ if ttcVersion != 0x00010000 && ttcVersion != 0x00020000 {
err = FormatError("bad TTC version")
return
}
@@ -578,14 +578,15 @@ func parse(ttf []byte, offset int) (font *Font, err error) {
return
}
n, offset := int(u16(ttf, offset)), offset+2
- if len(ttf) < 16*n+12 {
+ offset += 6 // Skip the searchRange, entrySelector and rangeShift.
+ if len(ttf) < 16*n+offset {
err = FormatError("TTF data is too short")
return
}
f := new(Font)
// Assign the table slices.
for i := 0; i < n; i++ {
- x := 16*i + 12
+ x := 16*i + offset
switch string(ttf[x : x+4]) {
case "cmap":
f.cmap, err = readTable(ttf, ttf[x+8:x+16])
diff --git a/vendor/github.com/hashicorp/hcl/json/parser/parser.go b/vendor/github.com/hashicorp/hcl/json/parser/parser.go
index 6f4608530..125a5f072 100644
--- a/vendor/github.com/hashicorp/hcl/json/parser/parser.go
+++ b/vendor/github.com/hashicorp/hcl/json/parser/parser.go
@@ -147,7 +147,7 @@ func (p *Parser) objectKey() ([]*ast.ObjectKey, error) {
// Done
return keys, nil
case token.ILLEGAL:
- fmt.Println("illegal")
+ return nil, errors.New("illegal")
default:
return nil, fmt.Errorf("expected: STRING got: %s", p.tok.Type)
}
diff --git a/vendor/github.com/lib/pq/conn.go b/vendor/github.com/lib/pq/conn.go
index c005cf9c4..3e3a5cabc 100644
--- a/vendor/github.com/lib/pq/conn.go
+++ b/vendor/github.com/lib/pq/conn.go
@@ -35,14 +35,14 @@ var (
errNoLastInsertId = errors.New("no LastInsertId available after the empty statement")
)
-type drv struct{}
+type Driver struct{}
-func (d *drv) Open(name string) (driver.Conn, error) {
+func (d *Driver) Open(name string) (driver.Conn, error) {
return Open(name)
}
func init() {
- sql.Register("postgres", &drv{})
+ sql.Register("postgres", &Driver{})
}
type parameterStatus struct {
diff --git a/vendor/github.com/miekg/dns/README.md b/vendor/github.com/miekg/dns/README.md
index e8b0ec6a5..cd5c1948e 100644
--- a/vendor/github.com/miekg/dns/README.md
+++ b/vendor/github.com/miekg/dns/README.md
@@ -19,7 +19,7 @@ two versions of Go, currently: 1.6 and 1.7.
* KISS;
* Fast;
-* Small API, if its easy to code in Go, don't make a function for it.
+* Small API. If it's easy to code in Go, don't make a function for it.
# Users
diff --git a/vendor/github.com/miekg/dns/dnssec.go b/vendor/github.com/miekg/dns/dnssec.go
index 07262011e..3bd55388d 100644
--- a/vendor/github.com/miekg/dns/dnssec.go
+++ b/vendor/github.com/miekg/dns/dnssec.go
@@ -515,7 +515,7 @@ func (k *DNSKEY) publicKeyRSA() *rsa.PublicKey {
}
// Remainder
expo += uint64(keybuf[keyoff])
- if expo > 2<<31 {
+ if expo > (2<<31)+1 {
// Larger expo than supported.
// println("dns: F5 primes (or larger) are not supported")
return nil
diff --git a/vendor/github.com/miekg/dns/labels.go b/vendor/github.com/miekg/dns/labels.go
index fca5c7dd2..9538d9c3a 100644
--- a/vendor/github.com/miekg/dns/labels.go
+++ b/vendor/github.com/miekg/dns/labels.go
@@ -1,5 +1,7 @@
package dns
+import "strings"
+
// Holds a bunch of helper functions for dealing with labels.
// SplitDomainName splits a name string into it's labels.
@@ -50,6 +52,7 @@ func SplitDomainName(s string) (labels []string) {
//
// s1 and s2 must be syntactically valid domain names.
func CompareDomainName(s1, s2 string) (n int) {
+ s1, s2 = strings.ToLower(s1), strings.ToLower(s2)
s1 = Fqdn(s1)
s2 = Fqdn(s2)
l1 := Split(s1)
diff --git a/vendor/github.com/miekg/dns/labels_test.go b/vendor/github.com/miekg/dns/labels_test.go
index 536757d52..9875d6cd9 100644
--- a/vendor/github.com/miekg/dns/labels_test.go
+++ b/vendor/github.com/miekg/dns/labels_test.go
@@ -33,6 +33,9 @@ func TestCompareDomainName(t *testing.T) {
if CompareDomainName(".", ".") != 0 {
t.Errorf("%s with %s should be %d", ".", ".", 0)
}
+ if CompareDomainName("test.com.", "TEST.COM.") != 2 {
+ t.Errorf("test.com. and TEST.COM. should be an exact match")
+ }
}
func TestSplit(t *testing.T) {
diff --git a/vendor/github.com/miekg/dns/msg.go b/vendor/github.com/miekg/dns/msg.go
index 57262a10c..a348f7c9d 100644
--- a/vendor/github.com/miekg/dns/msg.go
+++ b/vendor/github.com/miekg/dns/msg.go
@@ -14,13 +14,17 @@ package dns
import (
crand "crypto/rand"
"encoding/binary"
+ "fmt"
"math/big"
"math/rand"
"strconv"
"sync"
)
-const maxCompressionOffset = 2 << 13 // We have 14 bits for the compression pointer
+const (
+ maxCompressionOffset = 2 << 13 // We have 14 bits for the compression pointer
+ maxDomainNameWireOctets = 255 // See RFC 1035 section 2.3.4
+)
var (
ErrAlg error = &Error{err: "bad algorithm"} // ErrAlg indicates an error with the (DNSSEC) algorithm.
@@ -33,6 +37,7 @@ var (
ErrKeyAlg error = &Error{err: "bad key algorithm"} // ErrKeyAlg indicates that the algorithm in the key is not valid.
ErrKey error = &Error{err: "bad key"}
ErrKeySize error = &Error{err: "bad key size"}
+ ErrLongDomain error = &Error{err: fmt.Sprintf("domain name exceeded %d wire-format octets", maxDomainNameWireOctets)}
ErrNoSig error = &Error{err: "no signature found"}
ErrPrivKey error = &Error{err: "bad private key"}
ErrRcode error = &Error{err: "bad rcode"}
@@ -329,6 +334,7 @@ func UnpackDomainName(msg []byte, off int) (string, int, error) {
s := make([]byte, 0, 64)
off1 := 0
lenmsg := len(msg)
+ maxLen := maxDomainNameWireOctets
ptr := 0 // number of pointers followed
Loop:
for {
@@ -353,8 +359,10 @@ Loop:
fallthrough
case '"', '\\':
s = append(s, '\\', b)
+ // presentation-format \X escapes add an extra byte
+ maxLen += 1
default:
- if b < 32 || b >= 127 { // unprintable use \DDD
+ if b < 32 || b >= 127 { // unprintable, use \DDD
var buf [3]byte
bufs := strconv.AppendInt(buf[:0], int64(b), 10)
s = append(s, '\\')
@@ -364,6 +372,8 @@ Loop:
for _, r := range bufs {
s = append(s, r)
}
+ // presentation-format \DDD escapes add 3 extra bytes
+ maxLen += 3
} else {
s = append(s, b)
}
@@ -388,6 +398,9 @@ Loop:
if ptr++; ptr > 10 {
return "", lenmsg, &Error{err: "too many compression pointers"}
}
+ // pointer should guarantee that it advances and points forwards at least
+ // but the condition on previous three lines guarantees that it's
+ // at least loop-free
off = (c^0xC0)<<8 | int(c1)
default:
// 0x80 and 0x40 are reserved
@@ -399,6 +412,9 @@ Loop:
}
if len(s) == 0 {
s = []byte(".")
+ } else if len(s) >= maxLen {
+ // error if the name is too long, but don't throw it away
+ return string(s), lenmsg, ErrLongDomain
}
return string(s), off1, nil
}
diff --git a/vendor/github.com/miekg/dns/msg_test.go b/vendor/github.com/miekg/dns/msg_test.go
new file mode 100644
index 000000000..2dbef6260
--- /dev/null
+++ b/vendor/github.com/miekg/dns/msg_test.go
@@ -0,0 +1,124 @@
+package dns
+
+import (
+ "fmt"
+ "regexp"
+ "strconv"
+ "strings"
+ "testing"
+)
+
+const (
+ maxPrintableLabel = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789x"
+ tooLongLabel = maxPrintableLabel + "x"
+)
+
+var (
+ longDomain = maxPrintableLabel[:53] + strings.TrimSuffix(
+ strings.Join([]string{".", ".", ".", ".", "."}, maxPrintableLabel[:49]), ".")
+ reChar = regexp.MustCompile(`.`)
+ i = -1
+ maxUnprintableLabel = reChar.ReplaceAllStringFunc(maxPrintableLabel, func(ch string) string {
+ if i++; i >= 32 {
+ i = 0
+ }
+ return fmt.Sprintf("\\%03d", i)
+ })
+)
+
+func TestUnpackDomainName(t *testing.T) {
+ var cases = []struct {
+ label string
+ input string
+ expectedOutput string
+ expectedError string
+ }{
+ {"empty domain",
+ "\x00",
+ ".",
+ ""},
+ {"long label",
+ string(63) + maxPrintableLabel + "\x00",
+ maxPrintableLabel + ".",
+ ""},
+ {"unprintable label",
+ string(63) + regexp.MustCompile(`\\[0-9]+`).ReplaceAllStringFunc(maxUnprintableLabel,
+ func(escape string) string {
+ n, _ := strconv.ParseInt(escape[1:], 10, 8)
+ return string(n)
+ }) + "\x00",
+ maxUnprintableLabel + ".",
+ ""},
+ {"long domain",
+ string(53) + strings.Replace(longDomain, ".", string(49), -1) + "\x00",
+ longDomain + ".",
+ ""},
+ {"compression pointer",
+ // an unrealistic but functional test referencing an offset _inside_ a label
+ "\x03foo" + "\x05\x03com\x00" + "\x07example" + "\xC0\x05",
+ "foo.\\003com\\000.example.com.",
+ ""},
+
+ {"too long domain",
+ string(54) + "x" + strings.Replace(longDomain, ".", string(49), -1) + "\x00",
+ "x" + longDomain + ".",
+ ErrLongDomain.Error()},
+ {"too long by pointer",
+ // a matryoshka doll name to get over 255 octets after expansion via internal pointers
+ string([]byte{
+ // 11 length values, first to last
+ 40, 37, 34, 31, 28, 25, 22, 19, 16, 13, 0,
+ // 12 filler values
+ 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120,
+ // 10 pointers, last to first
+ 192, 10, 192, 9, 192, 8, 192, 7, 192, 6, 192, 5, 192, 4, 192, 3, 192, 2, 192, 1,
+ }),
+ "",
+ ErrLongDomain.Error()},
+ {"long by pointer",
+ // a matryoshka doll name _not_ exceeding 255 octets after expansion
+ string([]byte{
+ // 11 length values, first to last
+ 37, 34, 31, 28, 25, 22, 19, 16, 13, 10, 0,
+ // 9 filler values
+ 120, 120, 120, 120, 120, 120, 120, 120, 120,
+ // 10 pointers, last to first
+ 192, 10, 192, 9, 192, 8, 192, 7, 192, 6, 192, 5, 192, 4, 192, 3, 192, 2, 192, 1,
+ }),
+ "" +
+ (`\"\031\028\025\022\019\016\013\010\000xxxxxxxxx` +
+ `\192\010\192\009\192\008\192\007\192\006\192\005\192\004\192\003\192\002.`) +
+ (`\031\028\025\022\019\016\013\010\000xxxxxxxxx` +
+ `\192\010\192\009\192\008\192\007\192\006\192\005\192\004\192\003.`) +
+ (`\028\025\022\019\016\013\010\000xxxxxxxxx` +
+ `\192\010\192\009\192\008\192\007\192\006\192\005\192\004.`) +
+ (`\025\022\019\016\013\010\000xxxxxxxxx` +
+ `\192\010\192\009\192\008\192\007\192\006\192\005.`) +
+ `\022\019\016\013\010\000xxxxxxxxx\192\010\192\009\192\008\192\007\192\006.` +
+ `\019\016\013\010\000xxxxxxxxx\192\010\192\009\192\008\192\007.` +
+ `\016\013\010\000xxxxxxxxx\192\010\192\009\192\008.` +
+ `\013\010\000xxxxxxxxx\192\010\192\009.` +
+ `\010\000xxxxxxxxx\192\010.` +
+ `\000xxxxxxxxx.`,
+ ""},
+ {"truncated name", "\x07example\x03", "", "dns: buffer size too small"},
+ {"non-absolute name", "\x07example\x03com", "", "dns: buffer size too small"},
+ {"compression pointer cycle",
+ "\x03foo" + "\x03bar" + "\x07example" + "\xC0\x04",
+ "",
+ "dns: too many compression pointers"},
+ {"reserved compression pointer 0b10", "\x07example\x80", "", "dns: bad rdata"},
+ {"reserved compression pointer 0b01", "\x07example\x40", "", "dns: bad rdata"},
+ }
+ for _, test := range cases {
+ output, idx, err := UnpackDomainName([]byte(test.input), 0)
+ if test.expectedOutput != "" && output != test.expectedOutput {
+ t.Errorf("%s: expected %s, got %s", test.label, test.expectedOutput, output)
+ }
+ if test.expectedError == "" && err != nil {
+ t.Errorf("%s: expected no error, got %d %v", test.label, idx, err)
+ } else if test.expectedError != "" && (err == nil || err.Error() != test.expectedError) {
+ t.Errorf("%s: expected error %s, got %d %v", test.label, test.expectedError, idx, err)
+ }
+ }
+}
diff --git a/vendor/github.com/miekg/dns/nsecx.go b/vendor/github.com/miekg/dns/nsecx.go
index 51ce7f8b1..9b908c447 100644
--- a/vendor/github.com/miekg/dns/nsecx.go
+++ b/vendor/github.com/miekg/dns/nsecx.go
@@ -48,62 +48,50 @@ func HashName(label string, ha uint8, iter uint16, salt string) string {
return toBase32(nsec3)
}
-// Denialer is an interface that should be implemented by types that are used to denial
-// answers in DNSSEC.
-type Denialer interface {
- // Cover will check if the (unhashed) name is being covered by this NSEC or NSEC3.
- Cover(name string) bool
- // Match will check if the ownername matches the (unhashed) name for this NSEC3 or NSEC3.
- Match(name string) bool
-}
-
-// Cover implements the Denialer interface.
-func (rr *NSEC) Cover(name string) bool {
- return true
-}
-
-// Match implements the Denialer interface.
-func (rr *NSEC) Match(name string) bool {
- return true
-}
-
-// Cover implements the Denialer interface.
+// Cover returns true if a name is covered by the NSEC3 record
func (rr *NSEC3) Cover(name string) bool {
- // FIXME(miek): check if the zones match
- // FIXME(miek): check if we're not dealing with parent nsec3
- hname := HashName(name, rr.Hash, rr.Iterations, rr.Salt)
- labels := Split(rr.Hdr.Name)
- if len(labels) < 2 {
+ nameHash := HashName(name, rr.Hash, rr.Iterations, rr.Salt)
+ owner := strings.ToUpper(rr.Hdr.Name)
+ labelIndices := Split(owner)
+ if len(labelIndices) < 2 {
return false
}
- hash := strings.ToUpper(rr.Hdr.Name[labels[0] : labels[1]-1]) // -1 to remove the dot
- if hash == rr.NextDomain {
- return false // empty interval
- }
- if hash > rr.NextDomain { // last name, points to apex
- // hname > hash
- // hname > rr.NextDomain
- // TODO(miek)
+ ownerHash := owner[:labelIndices[1]-1]
+ ownerZone := owner[labelIndices[1]:]
+ if !IsSubDomain(ownerZone, strings.ToUpper(name)) { // name is outside owner zone
+ return false
}
- if hname <= hash {
+
+ nextHash := rr.NextDomain
+ if ownerHash == nextHash { // empty interval
return false
}
- if hname >= rr.NextDomain {
+ if ownerHash > nextHash { // end of zone
+ if nameHash > ownerHash { // covered since there is nothing after ownerHash
+ return true
+ }
+ return nameHash < nextHash // if nameHash is before beginning of zone it is covered
+ }
+ if nameHash < ownerHash { // nameHash is before ownerHash, not covered
return false
}
- return true
+ return nameHash < nextHash // if nameHash is before nextHash is it covered (between ownerHash and nextHash)
}
-// Match implements the Denialer interface.
+// Match returns true if a name matches the NSEC3 record
func (rr *NSEC3) Match(name string) bool {
- // FIXME(miek): Check if we are in the same zone
- hname := HashName(name, rr.Hash, rr.Iterations, rr.Salt)
- labels := Split(rr.Hdr.Name)
- if len(labels) < 2 {
+ nameHash := HashName(name, rr.Hash, rr.Iterations, rr.Salt)
+ owner := strings.ToUpper(rr.Hdr.Name)
+ labelIndices := Split(owner)
+ if len(labelIndices) < 2 {
+ return false
+ }
+ ownerHash := owner[:labelIndices[1]-1]
+ ownerZone := owner[labelIndices[1]:]
+ if !IsSubDomain(ownerZone, strings.ToUpper(name)) { // name is outside owner zone
return false
}
- hash := strings.ToUpper(rr.Hdr.Name[labels[0] : labels[1]-1]) // -1 to remove the .
- if hash == hname {
+ if ownerHash == nameHash {
return true
}
return false
diff --git a/vendor/github.com/miekg/dns/nsecx_test.go b/vendor/github.com/miekg/dns/nsecx_test.go
index 93e0c63fc..8d5f71797 100644
--- a/vendor/github.com/miekg/dns/nsecx_test.go
+++ b/vendor/github.com/miekg/dns/nsecx_test.go
@@ -1,8 +1,6 @@
package dns
-import (
- "testing"
-)
+import "testing"
func TestPackNsec3(t *testing.T) {
nsec3 := HashName("dnsex.nl.", SHA1, 0, "DEAD")
@@ -17,13 +15,119 @@ func TestPackNsec3(t *testing.T) {
}
func TestNsec3(t *testing.T) {
- // examples taken from .nl
- nsec3, _ := NewRR("39p91242oslggest5e6a7cci4iaeqvnk.nl. IN NSEC3 1 1 5 F10E9F7EA83FC8F3 39P99DCGG0MDLARTCRMCF6OFLLUL7PR6 NS DS RRSIG")
- if !nsec3.(*NSEC3).Cover("snasajsksasasa.nl.") { // 39p94jrinub66hnpem8qdpstrec86pg3
- t.Error("39p94jrinub66hnpem8qdpstrec86pg3. should be covered by 39p91242oslggest5e6a7cci4iaeqvnk.nl. - 39P99DCGG0MDLARTCRMCF6OFLLUL7PR6")
- }
- nsec3, _ = NewRR("sk4e8fj94u78smusb40o1n0oltbblu2r.nl. IN NSEC3 1 1 5 F10E9F7EA83FC8F3 SK4F38CQ0ATIEI8MH3RGD0P5I4II6QAN NS SOA TXT RRSIG DNSKEY NSEC3PARAM")
- if !nsec3.(*NSEC3).Match("nl.") { // sk4e8fj94u78smusb40o1n0oltbblu2r.nl.
- t.Error("sk4e8fj94u78smusb40o1n0oltbblu2r.nl. should match sk4e8fj94u78smusb40o1n0oltbblu2r.nl.")
+ nsec3, _ := NewRR("sk4e8fj94u78smusb40o1n0oltbblu2r.nl. IN NSEC3 1 1 5 F10E9F7EA83FC8F3 SK4F38CQ0ATIEI8MH3RGD0P5I4II6QAN NS SOA TXT RRSIG DNSKEY NSEC3PARAM")
+ if !nsec3.(*NSEC3).Match("nl.") { // name hash = sk4e8fj94u78smusb40o1n0oltbblu2r
+ t.Fatal("sk4e8fj94u78smusb40o1n0oltbblu2r.nl. should match sk4e8fj94u78smusb40o1n0oltbblu2r.nl.")
+ }
+ if !nsec3.(*NSEC3).Match("NL.") { // name hash = sk4e8fj94u78smusb40o1n0oltbblu2r
+ t.Fatal("sk4e8fj94u78smusb40o1n0oltbblu2r.NL. should match sk4e8fj94u78smusb40o1n0oltbblu2r.nl.")
+ }
+ if nsec3.(*NSEC3).Match("com.") { //
+ t.Fatal("com. is not in the zone nl.")
+ }
+ if nsec3.(*NSEC3).Match("test.nl.") { // name hash = gd0ptr5bnfpimpu2d3v6gd4n0bai7s0q
+ t.Fatal("gd0ptr5bnfpimpu2d3v6gd4n0bai7s0q.nl. should not match sk4e8fj94u78smusb40o1n0oltbblu2r.nl.")
+ }
+ nsec3, _ = NewRR("nl. IN NSEC3 1 1 5 F10E9F7EA83FC8F3 SK4F38CQ0ATIEI8MH3RGD0P5I4II6QAN NS SOA TXT RRSIG DNSKEY NSEC3PARAM")
+ if nsec3.(*NSEC3).Match("nl.") {
+ t.Fatal("sk4e8fj94u78smusb40o1n0oltbblu2r.nl. should not match a record without a owner hash")
+ }
+
+ for _, tc := range []struct {
+ rr *NSEC3
+ name string
+ covers bool
+ }{
+ // positive tests
+ { // name hash between owner hash and next hash
+ rr: &NSEC3{
+ Hdr: RR_Header{Name: "2N1TB3VAIRUOBL6RKDVII42N9TFMIALP.com."},
+ Hash: 1,
+ Flags: 1,
+ Iterations: 5,
+ Salt: "F10E9F7EA83FC8F3",
+ NextDomain: "PT3RON8N7PM3A0OE989IB84OOSADP7O8",
+ },
+ name: "bsd.com.",
+ covers: true,
+ },
+ { // end of zone, name hash is after owner hash
+ rr: &NSEC3{
+ Hdr: RR_Header{Name: "3v62ulr0nre83v0rja2vjgtlif9v6rab.com."},
+ Hash: 1,
+ Flags: 1,
+ Iterations: 5,
+ Salt: "F10E9F7EA83FC8F3",
+ NextDomain: "2N1TB3VAIRUOBL6RKDVII42N9TFMIALP",
+ },
+ name: "csd.com.",
+ covers: true,
+ },
+ { // end of zone, name hash is before beginning of zone
+ rr: &NSEC3{
+ Hdr: RR_Header{Name: "PT3RON8N7PM3A0OE989IB84OOSADP7O8.com."},
+ Hash: 1,
+ Flags: 1,
+ Iterations: 5,
+ Salt: "F10E9F7EA83FC8F3",
+ NextDomain: "3V62ULR0NRE83V0RJA2VJGTLIF9V6RAB",
+ },
+ name: "asd.com.",
+ covers: true,
+ },
+ // negative tests
+ { // too short owner name
+ rr: &NSEC3{
+ Hdr: RR_Header{Name: "nl."},
+ Hash: 1,
+ Flags: 1,
+ Iterations: 5,
+ Salt: "F10E9F7EA83FC8F3",
+ NextDomain: "39P99DCGG0MDLARTCRMCF6OFLLUL7PR6",
+ },
+ name: "asd.com.",
+ covers: false,
+ },
+ { // outside of zone
+ rr: &NSEC3{
+ Hdr: RR_Header{Name: "39p91242oslggest5e6a7cci4iaeqvnk.nl."},
+ Hash: 1,
+ Flags: 1,
+ Iterations: 5,
+ Salt: "F10E9F7EA83FC8F3",
+ NextDomain: "39P99DCGG0MDLARTCRMCF6OFLLUL7PR6",
+ },
+ name: "asd.com.",
+ covers: false,
+ },
+ { // empty interval
+ rr: &NSEC3{
+ Hdr: RR_Header{Name: "2n1tb3vairuobl6rkdvii42n9tfmialp.com."},
+ Hash: 1,
+ Flags: 1,
+ Iterations: 5,
+ Salt: "F10E9F7EA83FC8F3",
+ NextDomain: "2N1TB3VAIRUOBL6RKDVII42N9TFMIALP",
+ },
+ name: "asd.com.",
+ covers: false,
+ },
+ { // name hash is before owner hash, not covered
+ rr: &NSEC3{
+ Hdr: RR_Header{Name: "3V62ULR0NRE83V0RJA2VJGTLIF9V6RAB.com."},
+ Hash: 1,
+ Flags: 1,
+ Iterations: 5,
+ Salt: "F10E9F7EA83FC8F3",
+ NextDomain: "PT3RON8N7PM3A0OE989IB84OOSADP7O8",
+ },
+ name: "asd.com.",
+ covers: false,
+ },
+ } {
+ covers := tc.rr.Cover(tc.name)
+ if tc.covers != covers {
+ t.Fatalf("Cover failed for %s: expected %t, got %t [record: %s]", tc.name, tc.covers, covers, tc.rr)
+ }
}
}
diff --git a/vendor/github.com/miekg/dns/parse_test.go b/vendor/github.com/miekg/dns/parse_test.go
index c727c1301..2622318df 100644
--- a/vendor/github.com/miekg/dns/parse_test.go
+++ b/vendor/github.com/miekg/dns/parse_test.go
@@ -1509,3 +1509,21 @@ func TestParseURI(t *testing.T) {
}
}
}
+
+func TestParseAVC(t *testing.T) {
+ avcs := map[string]string{
+ `example.org. IN AVC "app-name:WOLFGANG|app-class:OAM|business=yes"`: `example.org. 3600 IN AVC "app-name:WOLFGANG|app-class:OAM|business=yes"`,
+ }
+ for avc, o := range avcs {
+ rr, err := NewRR(avc)
+ if err != nil {
+ t.Error("failed to parse RR: ", err)
+ continue
+ }
+ if rr.String() != o {
+ t.Errorf("`%s' should be equal to\n`%s', but is `%s'", avc, o, rr.String())
+ } else {
+ t.Logf("RR is OK: `%s'", rr.String())
+ }
+ }
+}
diff --git a/vendor/github.com/miekg/dns/scan_rr.go b/vendor/github.com/miekg/dns/scan_rr.go
index f4c0d3767..b8b18fd77 100644
--- a/vendor/github.com/miekg/dns/scan_rr.go
+++ b/vendor/github.com/miekg/dns/scan_rr.go
@@ -1807,6 +1807,18 @@ func setSPF(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
return rr, nil, c1
}
+func setAVC(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
+ rr := new(AVC)
+ rr.Hdr = h
+
+ s, e, c1 := endingToTxtSlice(c, "bad AVC Txt", f)
+ if e != nil {
+ return nil, e, ""
+ }
+ rr.Txt = s
+ return rr, nil, c1
+}
+
func setTXT(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
rr := new(TXT)
rr.Hdr = h
@@ -2158,6 +2170,7 @@ var typeToparserFunc = map[uint16]parserFunc{
TypeSMIMEA: {setSMIMEA, true},
TypeSOA: {setSOA, false},
TypeSPF: {setSPF, true},
+ TypeAVC: {setAVC, true},
TypeSRV: {setSRV, false},
TypeSSHFP: {setSSHFP, true},
TypeTALINK: {setTALINK, false},
diff --git a/vendor/github.com/miekg/dns/types.go b/vendor/github.com/miekg/dns/types.go
index c17251cb6..53da4755c 100644
--- a/vendor/github.com/miekg/dns/types.go
+++ b/vendor/github.com/miekg/dns/types.go
@@ -91,6 +91,7 @@ const (
TypeEUI64 uint16 = 109
TypeURI uint16 = 256
TypeCAA uint16 = 257
+ TypeAVC uint16 = 258
TypeTKEY uint16 = 249
TypeTSIG uint16 = 250
@@ -530,6 +531,13 @@ type SPF struct {
func (rr *SPF) String() string { return rr.Hdr.String() + sprintTxt(rr.Txt) }
+type AVC struct {
+ Hdr RR_Header
+ Txt []string `dns:"txt"`
+}
+
+func (rr *AVC) String() string { return rr.Hdr.String() + sprintTxt(rr.Txt) }
+
type SRV struct {
Hdr RR_Header
Priority uint16
diff --git a/vendor/github.com/miekg/dns/zcompress.go b/vendor/github.com/miekg/dns/zcompress.go
index 86a31a916..b277978b9 100644
--- a/vendor/github.com/miekg/dns/zcompress.go
+++ b/vendor/github.com/miekg/dns/zcompress.go
@@ -5,99 +5,95 @@ package dns
func compressionLenHelperType(c map[string]int, r RR) {
switch x := r.(type) {
- case *KX:
- compressionLenHelper(c, x.Exchanger)
- case *MX:
- compressionLenHelper(c, x.Mx)
- case *NSEC:
- compressionLenHelper(c, x.NextDomain)
- case *DNAME:
- compressionLenHelper(c, x.Target)
+ case *PTR:
+ compressionLenHelper(c, x.Ptr)
+ case *SOA:
+ compressionLenHelper(c, x.Ns)
+ compressionLenHelper(c, x.Mbox)
+ case *AFSDB:
+ compressionLenHelper(c, x.Hostname)
case *HIP:
for i := range x.RendezvousServers {
compressionLenHelper(c, x.RendezvousServers[i])
}
- case *CNAME:
- compressionLenHelper(c, x.Target)
- case *MR:
- compressionLenHelper(c, x.Mr)
- case *PX:
- compressionLenHelper(c, x.Map822)
- compressionLenHelper(c, x.Mapx400)
- case *SIG:
- compressionLenHelper(c, x.SignerName)
- case *SRV:
- compressionLenHelper(c, x.Target)
- case *TALINK:
- compressionLenHelper(c, x.PreviousName)
- compressionLenHelper(c, x.NextName)
case *LP:
compressionLenHelper(c, x.Fqdn)
- case *NAPTR:
- compressionLenHelper(c, x.Replacement)
- case *NS:
- compressionLenHelper(c, x.Ns)
+ case *CNAME:
+ compressionLenHelper(c, x.Target)
+ case *MB:
+ compressionLenHelper(c, x.Mb)
case *RP:
compressionLenHelper(c, x.Mbox)
compressionLenHelper(c, x.Txt)
case *RRSIG:
compressionLenHelper(c, x.SignerName)
- case *TKEY:
- compressionLenHelper(c, x.Algorithm)
- case *TSIG:
- compressionLenHelper(c, x.Algorithm)
- case *AFSDB:
- compressionLenHelper(c, x.Hostname)
case *MF:
compressionLenHelper(c, x.Mf)
- case *RT:
- compressionLenHelper(c, x.Host)
case *MINFO:
compressionLenHelper(c, x.Rmail)
compressionLenHelper(c, x.Email)
- case *PTR:
+ case *SIG:
+ compressionLenHelper(c, x.SignerName)
+ case *SRV:
+ compressionLenHelper(c, x.Target)
+ case *TSIG:
+ compressionLenHelper(c, x.Algorithm)
+ case *KX:
+ compressionLenHelper(c, x.Exchanger)
+ case *MG:
+ compressionLenHelper(c, x.Mg)
+ case *NSAPPTR:
compressionLenHelper(c, x.Ptr)
- case *SOA:
- compressionLenHelper(c, x.Ns)
- compressionLenHelper(c, x.Mbox)
+ case *PX:
+ compressionLenHelper(c, x.Map822)
+ compressionLenHelper(c, x.Mapx400)
+ case *DNAME:
+ compressionLenHelper(c, x.Target)
+ case *MR:
+ compressionLenHelper(c, x.Mr)
+ case *MX:
+ compressionLenHelper(c, x.Mx)
+ case *TKEY:
+ compressionLenHelper(c, x.Algorithm)
+ case *NSEC:
+ compressionLenHelper(c, x.NextDomain)
+ case *TALINK:
+ compressionLenHelper(c, x.PreviousName)
+ compressionLenHelper(c, x.NextName)
case *MD:
compressionLenHelper(c, x.Md)
- case *NSAPPTR:
- compressionLenHelper(c, x.Ptr)
- case *MG:
- compressionLenHelper(c, x.Mg)
- case *MB:
- compressionLenHelper(c, x.Mb)
+ case *NAPTR:
+ compressionLenHelper(c, x.Replacement)
+ case *NS:
+ compressionLenHelper(c, x.Ns)
+ case *RT:
+ compressionLenHelper(c, x.Host)
}
}
func compressionLenSearchType(c map[string]int, r RR) (int, bool) {
switch x := r.(type) {
- case *MF:
- k1, ok1 := compressionLenSearch(c, x.Mf)
- return k1, ok1
case *MG:
k1, ok1 := compressionLenSearch(c, x.Mg)
return k1, ok1
- case *MINFO:
- k1, ok1 := compressionLenSearch(c, x.Rmail)
- k2, ok2 := compressionLenSearch(c, x.Email)
- return k1 + k2, ok1 && ok2
- case *MR:
- k1, ok1 := compressionLenSearch(c, x.Mr)
- return k1, ok1
case *PTR:
k1, ok1 := compressionLenSearch(c, x.Ptr)
return k1, ok1
case *AFSDB:
k1, ok1 := compressionLenSearch(c, x.Hostname)
return k1, ok1
- case *CNAME:
- k1, ok1 := compressionLenSearch(c, x.Target)
+ case *MB:
+ k1, ok1 := compressionLenSearch(c, x.Mb)
return k1, ok1
case *MD:
k1, ok1 := compressionLenSearch(c, x.Md)
return k1, ok1
+ case *MF:
+ k1, ok1 := compressionLenSearch(c, x.Mf)
+ return k1, ok1
+ case *NS:
+ k1, ok1 := compressionLenSearch(c, x.Ns)
+ return k1, ok1
case *RT:
k1, ok1 := compressionLenSearch(c, x.Host)
return k1, ok1
@@ -105,15 +101,19 @@ func compressionLenSearchType(c map[string]int, r RR) (int, bool) {
k1, ok1 := compressionLenSearch(c, x.Ns)
k2, ok2 := compressionLenSearch(c, x.Mbox)
return k1 + k2, ok1 && ok2
- case *MB:
- k1, ok1 := compressionLenSearch(c, x.Mb)
+ case *CNAME:
+ k1, ok1 := compressionLenSearch(c, x.Target)
+ return k1, ok1
+ case *MINFO:
+ k1, ok1 := compressionLenSearch(c, x.Rmail)
+ k2, ok2 := compressionLenSearch(c, x.Email)
+ return k1 + k2, ok1 && ok2
+ case *MR:
+ k1, ok1 := compressionLenSearch(c, x.Mr)
return k1, ok1
case *MX:
k1, ok1 := compressionLenSearch(c, x.Mx)
return k1, ok1
- case *NS:
- k1, ok1 := compressionLenSearch(c, x.Ns)
- return k1, ok1
}
return 0, false
}
diff --git a/vendor/github.com/miekg/dns/zmsg.go b/vendor/github.com/miekg/dns/zmsg.go
index 9b98e1bb2..418fb1fe3 100644
--- a/vendor/github.com/miekg/dns/zmsg.go
+++ b/vendor/github.com/miekg/dns/zmsg.go
@@ -61,6 +61,20 @@ func (rr *ANY) pack(msg []byte, off int, compression map[string]int, compress bo
return off, nil
}
+func (rr *AVC) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
+ off, err := rr.Hdr.pack(msg, off, compression, compress)
+ if err != nil {
+ return off, err
+ }
+ headerEnd := off
+ off, err = packStringTxt(rr.Txt, msg, off)
+ if err != nil {
+ return off, err
+ }
+ rr.Header().Rdlength = uint16(off - headerEnd)
+ return off, nil
+}
+
func (rr *CAA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
@@ -1528,6 +1542,23 @@ func unpackANY(h RR_Header, msg []byte, off int) (RR, int, error) {
return rr, off, err
}
+func unpackAVC(h RR_Header, msg []byte, off int) (RR, int, error) {
+ rr := new(AVC)
+ rr.Hdr = h
+ if noRdata(h) {
+ return rr, off, nil
+ }
+ var err error
+ rdStart := off
+ _ = rdStart
+
+ rr.Txt, off, err = unpackStringTxt(msg, off)
+ if err != nil {
+ return rr, off, err
+ }
+ return rr, off, err
+}
+
func unpackCAA(h RR_Header, msg []byte, off int) (RR, int, error) {
rr := new(CAA)
rr.Hdr = h
@@ -3467,6 +3498,7 @@ var typeToUnpack = map[uint16]func(RR_Header, []byte, int) (RR, int, error){
TypeAAAA: unpackAAAA,
TypeAFSDB: unpackAFSDB,
TypeANY: unpackANY,
+ TypeAVC: unpackAVC,
TypeCAA: unpackCAA,
TypeCDNSKEY: unpackCDNSKEY,
TypeCDS: unpackCDS,
diff --git a/vendor/github.com/miekg/dns/ztypes.go b/vendor/github.com/miekg/dns/ztypes.go
index 311b8243b..3e534f12e 100644
--- a/vendor/github.com/miekg/dns/ztypes.go
+++ b/vendor/github.com/miekg/dns/ztypes.go
@@ -14,6 +14,7 @@ var TypeToRR = map[uint16]func() RR{
TypeAAAA: func() RR { return new(AAAA) },
TypeAFSDB: func() RR { return new(AFSDB) },
TypeANY: func() RR { return new(ANY) },
+ TypeAVC: func() RR { return new(AVC) },
TypeCAA: func() RR { return new(CAA) },
TypeCDNSKEY: func() RR { return new(CDNSKEY) },
TypeCDS: func() RR { return new(CDS) },
@@ -86,6 +87,7 @@ var TypeToString = map[uint16]string{
TypeAFSDB: "AFSDB",
TypeANY: "ANY",
TypeATMA: "ATMA",
+ TypeAVC: "AVC",
TypeAXFR: "AXFR",
TypeCAA: "CAA",
TypeCDNSKEY: "CDNSKEY",
@@ -166,6 +168,7 @@ func (rr *A) Header() *RR_Header { return &rr.Hdr }
func (rr *AAAA) Header() *RR_Header { return &rr.Hdr }
func (rr *AFSDB) Header() *RR_Header { return &rr.Hdr }
func (rr *ANY) Header() *RR_Header { return &rr.Hdr }
+func (rr *AVC) Header() *RR_Header { return &rr.Hdr }
func (rr *CAA) Header() *RR_Header { return &rr.Hdr }
func (rr *CDNSKEY) Header() *RR_Header { return &rr.Hdr }
func (rr *CDS) Header() *RR_Header { return &rr.Hdr }
@@ -252,6 +255,13 @@ func (rr *ANY) len() int {
l := rr.Hdr.len()
return l
}
+func (rr *AVC) len() int {
+ l := rr.Hdr.len()
+ for _, x := range rr.Txt {
+ l += len(x) + 1
+ }
+ return l
+}
func (rr *CAA) len() int {
l := rr.Hdr.len()
l++ // Flag
@@ -649,6 +659,11 @@ func (rr *AFSDB) copy() RR {
func (rr *ANY) copy() RR {
return &ANY{*rr.Hdr.copyHeader()}
}
+func (rr *AVC) copy() RR {
+ Txt := make([]string, len(rr.Txt))
+ copy(Txt, rr.Txt)
+ return &AVC{*rr.Hdr.copyHeader(), Txt}
+}
func (rr *CAA) copy() RR {
return &CAA{*rr.Hdr.copyHeader(), rr.Flag, rr.Tag, rr.Value}
}
diff --git a/vendor/github.com/minio/minio-go/README.md b/vendor/github.com/minio/minio-go/README.md
index f0d880b1e..fb94f8010 100644
--- a/vendor/github.com/minio/minio-go/README.md
+++ b/vendor/github.com/minio/minio-go/README.md
@@ -1,4 +1,5 @@
-# Minio Go Client SDK for Amazon S3 Compatible Cloud Storage [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Minio/minio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+# Minio Go Client SDK for Amazon S3 Compatible Cloud Storage [![Slack](https://slack.minio.io/slack?type=svg)](https://slack.minio.io)
+
The Minio Go Client SDK provides simple APIs to access any Amazon S3 compatible object storage.
**Supported cloud storage providers:**
diff --git a/vendor/github.com/minio/minio-go/api-error-response.go b/vendor/github.com/minio/minio-go/api-error-response.go
index bcfad3761..fee3c7d53 100644
--- a/vendor/github.com/minio/minio-go/api-error-response.go
+++ b/vendor/github.com/minio/minio-go/api-error-response.go
@@ -149,6 +149,16 @@ func httpRespToErrorResponse(resp *http.Response, bucketName, objectName string)
return errResp
}
+// ErrTransferAccelerationBucket - bucket name is invalid to be used with transfer acceleration.
+func ErrTransferAccelerationBucket(bucketName string) error {
+ msg := fmt.Sprintf("The name of the bucket used for Transfer Acceleration must be DNS-compliant and must not contain periods (\".\").")
+ return ErrorResponse{
+ Code: "InvalidArgument",
+ Message: msg,
+ BucketName: bucketName,
+ }
+}
+
// ErrEntityTooLarge - Input size is larger than supported maximum.
func ErrEntityTooLarge(totalSize, maxObjectSize int64, bucketName, objectName string) error {
msg := fmt.Sprintf("Your proposed upload size ‘%d’ exceeds the maximum allowed object size ‘%d’ for single PUT operation.", totalSize, maxObjectSize)
diff --git a/vendor/github.com/minio/minio-go/api-get-object.go b/vendor/github.com/minio/minio-go/api-get-object.go
index c9b4dcedd..48ee947ff 100644
--- a/vendor/github.com/minio/minio-go/api-get-object.go
+++ b/vendor/github.com/minio/minio-go/api-get-object.go
@@ -212,10 +212,12 @@ type Object struct {
reqCh chan<- getRequest
resCh <-chan getResponse
doneCh chan<- struct{}
- prevOffset int64
currOffset int64
objectInfo ObjectInfo
+ // Ask lower level to initiate data fetching based on currOffset
+ seekData bool
+
// Keeps track of closed call.
isClosed bool
@@ -258,6 +260,10 @@ func (o *Object) doGetRequest(request getRequest) (getResponse, error) {
if response.Error != nil {
return response, response.Error
}
+
+ // Data are ready on the wire, no need to reinitiate connection in lower level
+ o.seekData = false
+
return response, nil
}
@@ -266,8 +272,6 @@ func (o *Object) doGetRequest(request getRequest) (getResponse, error) {
func (o *Object) setOffset(bytesRead int64) error {
// Update the currentOffset.
o.currOffset += bytesRead
- // Save the current offset as previous offset.
- o.prevOffset = o.currOffset
if o.currOffset >= o.objectInfo.Size {
return io.EOF
@@ -303,22 +307,9 @@ func (o *Object) Read(b []byte) (n int, err error) {
readReq.isFirstReq = true
}
- // Verify if offset has changed and currOffset is greater than
- // previous offset. Perhaps due to Seek().
- offsetChange := o.prevOffset - o.currOffset
- if offsetChange < 0 {
- offsetChange = -offsetChange
- }
- if offsetChange > 0 {
- // Fetch the new reader at the current offset again.
- readReq.Offset = o.currOffset
- readReq.DidOffsetChange = true
- } else {
- // No offset changes no need to fetch new reader, continue
- // reading.
- readReq.DidOffsetChange = false
- readReq.Offset = 0
- }
+ // Ask to establish a new data fetch routine based on seekData flag
+ readReq.DidOffsetChange = o.seekData
+ readReq.Offset = o.currOffset
// Send and receive from the first request.
response, err := o.doGetRequest(readReq)
@@ -430,8 +421,6 @@ func (o *Object) ReadAt(b []byte, offset int64) (n int, err error) {
if !o.objectInfoSet {
// Update the currentOffset.
o.currOffset += bytesRead
- // Save the current offset as previous offset.
- o.prevOffset = o.currOffset
} else {
// If this was not the first request update
// the offsets and compare against objectInfo
@@ -492,8 +481,6 @@ func (o *Object) Seek(offset int64, whence int) (n int64, err error) {
return 0, err
}
}
- // Save current offset as previous offset.
- o.prevOffset = o.currOffset
// Switch through whence.
switch whence {
@@ -527,6 +514,10 @@ func (o *Object) Seek(offset int64, whence int) (n int64, err error) {
if o.prevErr == io.EOF {
o.prevErr = nil
}
+
+ // Ask lower level to fetch again from source
+ o.seekData = true
+
// Return the effective offset.
return o.currOffset, nil
}
diff --git a/vendor/github.com/minio/minio-go/api.go b/vendor/github.com/minio/minio-go/api.go
index 98829cd2c..a21c40e80 100644
--- a/vendor/github.com/minio/minio-go/api.go
+++ b/vendor/github.com/minio/minio-go/api.go
@@ -71,6 +71,9 @@ type Client struct {
isTraceEnabled bool
traceOutput io.Writer
+ // S3 specific accelerated endpoint.
+ s3AccelerateEndpoint string
+
// Random seed.
random *rand.Rand
}
@@ -78,7 +81,7 @@ type Client struct {
// Global constants.
const (
libraryName = "minio-go"
- libraryVersion = "2.0.3"
+ libraryVersion = "2.0.4"
)
// User Agent should always following the below style.
@@ -206,8 +209,7 @@ func privateNew(endpoint, accessKeyID, secretAccessKey string, secure bool) (*Cl
// SetAppInfo - add application details to user agent.
func (c *Client) SetAppInfo(appName string, appVersion string) {
- // if app name and version is not set, we do not a new user
- // agent.
+ // if app name and version not set, we do not set a new user agent.
if appName != "" && appVersion != "" {
c.appInfo = struct {
appName string
@@ -258,8 +260,18 @@ func (c *Client) TraceOff() {
c.isTraceEnabled = false
}
-// requestMetadata - is container for all the values to make a
-// request.
+// SetS3TransferAccelerate - turns s3 accelerated endpoint on or off for all your
+// requests. This feature is only specific to S3 for all other endpoints this
+// function does nothing. To read further details on s3 transfer acceleration
+// please vist -
+// http://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html
+func (c *Client) SetS3TransferAccelerate(accelerateEndpoint string) {
+ if s3utils.IsAmazonEndpoint(c.endpointURL) {
+ c.s3AccelerateEndpoint = accelerateEndpoint
+ }
+}
+
+// requestMetadata - is container for all the values to make a request.
type requestMetadata struct {
// If set newRequest presigns the URL.
presignURL bool
@@ -601,10 +613,10 @@ func (c Client) newRequest(method string, metadata requestMetadata) (req *http.R
req.Body = ioutil.NopCloser(metadata.contentBody)
}
- // FIXEM: Enable this when Google Cloud Storage properly supports 100-continue.
+ // FIXME: Enable this when Google Cloud Storage properly supports 100-continue.
// Skip setting 'expect' header for Google Cloud Storage, there
// are some known issues - https://github.com/restic/restic/issues/520
- if !s3utils.IsGoogleEndpoint(c.endpointURL) {
+ if !s3utils.IsGoogleEndpoint(c.endpointURL) && c.s3AccelerateEndpoint == "" {
// Set 'Expect' header for the request.
req.Header.Set("Expect", "100-continue")
}
@@ -672,9 +684,22 @@ func (c Client) makeTargetURL(bucketName, objectName, bucketLocation string, que
host := c.endpointURL.Host
// For Amazon S3 endpoint, try to fetch location based endpoint.
if s3utils.IsAmazonEndpoint(c.endpointURL) {
- // Fetch new host based on the bucket location.
- host = getS3Endpoint(bucketLocation)
+ if c.s3AccelerateEndpoint != "" && bucketName != "" {
+ // http://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html
+ // Disable transfer acceleration for non-compliant bucket names.
+ if strings.Contains(bucketName, ".") {
+ return nil, ErrTransferAccelerationBucket(bucketName)
+ }
+ // If transfer acceleration is requested set new host.
+ // For more details about enabling transfer acceleration read here.
+ // http://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html
+ host = c.s3AccelerateEndpoint
+ } else {
+ // Fetch new host based on the bucket location.
+ host = getS3Endpoint(bucketLocation)
+ }
}
+
// Save scheme.
scheme := c.endpointURL.Scheme
diff --git a/vendor/github.com/minio/minio-go/api_functional_v2_test.go b/vendor/github.com/minio/minio-go/api_functional_v2_test.go
index 23713732a..f41cc0ff4 100644
--- a/vendor/github.com/minio/minio-go/api_functional_v2_test.go
+++ b/vendor/github.com/minio/minio-go/api_functional_v2_test.go
@@ -943,7 +943,7 @@ func TestCopyObjectV2(t *testing.T) {
}
// Set copy conditions.
- copyConds := NewCopyConditions()
+ copyConds := CopyConditions{}
err = copyConds.SetModified(time.Date(2014, time.April, 0, 0, 0, 0, 0, time.UTC))
if err != nil {
t.Fatal("Error:", err)
diff --git a/vendor/github.com/minio/minio-go/api_functional_v4_test.go b/vendor/github.com/minio/minio-go/api_functional_v4_test.go
index d19d3e1ae..426d2ddcc 100644
--- a/vendor/github.com/minio/minio-go/api_functional_v4_test.go
+++ b/vendor/github.com/minio/minio-go/api_functional_v4_test.go
@@ -1255,6 +1255,7 @@ func TestGetObjectReadSeekFunctional(t *testing.T) {
// Generate data more than 32K
buf := bytes.Repeat([]byte("2"), rand.Intn(1<<20)+32*1024)
+ bufSize := len(buf)
// Save the data
objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "")
@@ -1263,10 +1264,21 @@ func TestGetObjectReadSeekFunctional(t *testing.T) {
t.Fatal("Error:", err, bucketName, objectName)
}
- if n != int64(len(buf)) {
+ if n != int64(bufSize) {
t.Fatalf("Error: number of bytes does not match, want %v, got %v\n", len(buf), n)
}
+ defer func() {
+ err = c.RemoveObject(bucketName, objectName)
+ if err != nil {
+ t.Fatal("Error: ", err)
+ }
+ err = c.RemoveBucket(bucketName)
+ if err != nil {
+ t.Fatal("Error:", err)
+ }
+ }()
+
// Read the data back
r, err := c.GetObject(bucketName, objectName)
if err != nil {
@@ -1277,77 +1289,86 @@ func TestGetObjectReadSeekFunctional(t *testing.T) {
if err != nil {
t.Fatal("Error:", err, bucketName, objectName)
}
- if st.Size != int64(len(buf)) {
+ if st.Size != int64(bufSize) {
t.Fatalf("Error: number of bytes in stat does not match, want %v, got %v\n",
len(buf), st.Size)
}
- offset := int64(2048)
- n, err = r.Seek(offset, 0)
- if err != nil {
- t.Fatal("Error:", err, offset)
- }
- if n != offset {
- t.Fatalf("Error: number of bytes seeked does not match, want %v, got %v\n",
- offset, n)
- }
- n, err = r.Seek(0, 1)
- if err != nil {
- t.Fatal("Error:", err)
- }
- if n != offset {
- t.Fatalf("Error: number of current seek does not match, want %v, got %v\n",
- offset, n)
- }
- _, err = r.Seek(offset, 2)
- if err == nil {
- t.Fatal("Error: seek on positive offset for whence '2' should error out")
- }
- n, err = r.Seek(-offset, 2)
- if err != nil {
- t.Fatal("Error:", err)
- }
- if n != st.Size-offset {
- t.Fatalf("Error: number of bytes seeked back does not match, want %d, got %v\n", st.Size-offset, n)
- }
-
- var buffer1 bytes.Buffer
- if _, err = io.CopyN(&buffer1, r, st.Size); err != nil {
- if err != io.EOF {
- t.Fatal("Error:", err)
+ // This following function helps us to compare data from the reader after seek
+ // with the data from the original buffer
+ cmpData := func(r io.Reader, start, end int) {
+ if end-start == 0 {
+ return
}
- }
- if !bytes.Equal(buf[len(buf)-int(offset):], buffer1.Bytes()) {
- t.Fatal("Error: Incorrect read bytes v/s original buffer.")
- }
-
- // Seek again and read again.
- n, err = r.Seek(offset-1, 0)
- if err != nil {
- t.Fatal("Error:", err)
- }
- if n != (offset - 1) {
- t.Fatalf("Error: number of bytes seeked back does not match, want %v, got %v\n", offset-1, n)
- }
-
- var buffer2 bytes.Buffer
- if _, err = io.CopyN(&buffer2, r, st.Size); err != nil {
- if err != io.EOF {
- t.Fatal("Error:", err)
+ buffer := bytes.NewBuffer([]byte{})
+ if _, err := io.CopyN(buffer, r, int64(bufSize)); err != nil {
+ if err != io.EOF {
+ t.Fatal("Error:", err)
+ }
+ }
+ if !bytes.Equal(buf[start:end], buffer.Bytes()) {
+ t.Fatal("Error: Incorrect read bytes v/s original buffer.")
}
- }
- // Verify now lesser bytes.
- if !bytes.Equal(buf[2047:], buffer2.Bytes()) {
- t.Fatal("Error: Incorrect read bytes v/s original buffer.")
}
- err = c.RemoveObject(bucketName, objectName)
- if err != nil {
- t.Fatal("Error: ", err)
- }
- err = c.RemoveBucket(bucketName)
- if err != nil {
- t.Fatal("Error:", err)
+ // Generic seek error for errors other than io.EOF
+ seekErr := errors.New("seek error")
+
+ testCases := []struct {
+ offset int64
+ whence int
+ pos int64
+ err error
+ shouldCmp bool
+ start int
+ end int
+ }{
+ // Start from offset 0, fetch data and compare
+ {0, 0, 0, nil, true, 0, 0},
+ // Start from offset 2048, fetch data and compare
+ {2048, 0, 2048, nil, true, 2048, bufSize},
+ // Start from offset larger than possible
+ {int64(bufSize) + 1024, 0, 0, seekErr, false, 0, 0},
+ // Move to offset 0 without comparing
+ {0, 0, 0, nil, false, 0, 0},
+ // Move one step forward and compare
+ {1, 1, 1, nil, true, 1, bufSize},
+ // Move larger than possible
+ {int64(bufSize), 1, 0, seekErr, false, 0, 0},
+ // Provide negative offset with CUR_SEEK
+ {int64(-1), 1, 0, seekErr, false, 0, 0},
+ // Test with whence SEEK_END and with positive offset
+ {1024, 2, int64(bufSize) - 1024, io.EOF, true, 0, 0},
+ // Test with whence SEEK_END and with negative offset
+ {-1024, 2, int64(bufSize) - 1024, nil, true, bufSize - 1024, bufSize},
+ // Test with whence SEEK_END and with large negative offset
+ {-int64(bufSize) * 2, 2, 0, seekErr, true, 0, 0},
+ }
+
+ for i, testCase := range testCases {
+ // Perform seek operation
+ n, err := r.Seek(testCase.offset, testCase.whence)
+ // We expect an error
+ if testCase.err == seekErr && err == nil {
+ t.Fatalf("Test %d, unexpected err value: expected: %v, found: %v", i+1, testCase.err, err)
+ }
+ // We expect a specific error
+ if testCase.err != seekErr && testCase.err != err {
+ t.Fatalf("Test %d, unexpected err value: expected: %v, found: %v", i+1, testCase.err, err)
+ }
+ // If we expect an error go to the next loop
+ if testCase.err != nil {
+ continue
+ }
+ // Check the returned seek pos
+ if n != testCase.pos {
+ t.Fatalf("Test %d, error: number of bytes seeked does not match, want %v, got %v\n", i+1,
+ testCase.pos, n)
+ }
+ // Compare only if shouldCmp is activated
+ if testCase.shouldCmp {
+ cmpData(r, testCase.start, testCase.end)
+ }
}
}
@@ -1662,7 +1683,7 @@ func TestCopyObject(t *testing.T) {
}
// Set copy conditions.
- copyConds := NewCopyConditions()
+ copyConds := CopyConditions{}
// Start by setting wrong conditions
err = copyConds.SetModified(time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC))
@@ -1725,7 +1746,7 @@ func TestCopyObject(t *testing.T) {
}
// CopyObject again but with wrong conditions
- copyConds = NewCopyConditions()
+ copyConds = CopyConditions{}
err = copyConds.SetUnmodified(time.Date(2014, time.April, 0, 0, 0, 0, 0, time.UTC))
if err != nil {
t.Fatal("Error:", err)
diff --git a/vendor/github.com/minio/minio-go/bucket-cache.go b/vendor/github.com/minio/minio-go/bucket-cache.go
index 46dfe9348..c35e26b7c 100644
--- a/vendor/github.com/minio/minio-go/bucket-cache.go
+++ b/vendor/github.com/minio/minio-go/bucket-cache.go
@@ -164,13 +164,6 @@ func (c Client) getBucketLocationRequest(bucketName string) (*http.Request, erro
// Set get bucket location always as path style.
targetURL := c.endpointURL
-
- // Requesting a bucket location from an accelerate endpoint returns a 400,
- // so default to us-east-1 for the lookup
- if s3utils.IsAmazonS3AccelerateEndpoint(c.endpointURL) {
- targetURL.Host = getS3Endpoint("us-east-1")
- }
-
targetURL.Path = path.Join(bucketName, "") + "/"
targetURL.RawQuery = urlValues.Encode()
diff --git a/vendor/github.com/minio/minio-go/copy-conditions.go b/vendor/github.com/minio/minio-go/copy-conditions.go
index 5dcdfaef0..65018aa09 100644
--- a/vendor/github.com/minio/minio-go/copy-conditions.go
+++ b/vendor/github.com/minio/minio-go/copy-conditions.go
@@ -41,11 +41,13 @@ type CopyConditions struct {
conditions []copyCondition
}
-// NewCopyConditions - Instantiate new list of conditions.
+// NewCopyConditions - Instantiate new list of conditions. This
+// function is left behind for backward compatibility. The idiomatic
+// way to set an empty set of copy conditions is,
+// ``copyConditions := CopyConditions{}``.
+//
func NewCopyConditions() CopyConditions {
- return CopyConditions{
- conditions: make([]copyCondition, 0),
- }
+ return CopyConditions{}
}
// SetMatchETag - set match etag.
diff --git a/vendor/github.com/minio/minio-go/docs/API.md b/vendor/github.com/minio/minio-go/docs/API.md
index 0365c7fad..dfb90b5f2 100644
--- a/vendor/github.com/minio/minio-go/docs/API.md
+++ b/vendor/github.com/minio/minio-go/docs/API.md
@@ -1,4 +1,4 @@
-# Golang Client API Reference [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Minio/minio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+# Minio Go Client API Reference [![Slack](https://slack.minio.io/slack?type=svg)](https://slack.minio.io)
## Initialize Minio Client object.
@@ -60,7 +60,7 @@ func main() {
|[`ListBuckets`](#ListBuckets) |[`PutObject`](#PutObject) |[`PresignedPutObject`](#PresignedPutObject) | [`GetBucketPolicy`](#GetBucketPolicy) | [`SetCustomTransport`](#SetCustomTransport) |
|[`BucketExists`](#BucketExists) |[`CopyObject`](#CopyObject) |[`PresignedPostPolicy`](#PresignedPostPolicy) | [`ListBucketPolicies`](#ListBucketPolicies) | [`TraceOn`](#TraceOn) |
| [`RemoveBucket`](#RemoveBucket) |[`StatObject`](#StatObject) | | [`SetBucketNotification`](#SetBucketNotification) | [`TraceOff`](#TraceOff) |
-|[`ListObjects`](#ListObjects) |[`RemoveObject`](#RemoveObject) | | [`GetBucketNotification`](#GetBucketNotification) |
+|[`ListObjects`](#ListObjects) |[`RemoveObject`](#RemoveObject) | | [`GetBucketNotification`](#GetBucketNotification) | [`SetS3TransferAccelerate`](#SetS3TransferAccelerate) |
|[`ListObjectsV2`](#ListObjectsV2) | [`RemoveObjects`](#RemoveObjects) | | [`RemoveAllBucketNotification`](#RemoveAllBucketNotification) |
|[`ListIncompleteUploads`](#ListIncompleteUploads) | [`RemoveIncompleteUpload`](#RemoveIncompleteUpload) | | [`ListenBucketNotification`](#ListenBucketNotification) |
| | [`FPutObject`](#FPutObject) | | |
@@ -69,7 +69,7 @@ func main() {
## 1. Constructor
<a name="Minio"></a>
-### New(endpoint string, accessKeyID string, secretAccessKey string, ssl bool) (*Client, error)
+### New(endpoint, accessKeyID, secretAccessKey string, ssl bool) (*Client, error)
Initializes a new client object.
__Parameters__
@@ -86,7 +86,7 @@ __Parameters__
## 2. Bucket operations
<a name="MakeBucket"></a>
-### MakeBucket(bucketName string, location string) error
+### MakeBucket(bucketName, location string) error
Creates a new bucket.
@@ -216,7 +216,7 @@ if err != nil {
```
<a name="ListObjects"></a>
-### ListObjects(bucketName string, prefix string, recursive bool, doneCh chan struct{}) <-chan ObjectInfo
+### ListObjects(bucketName, prefix string, recursive bool, doneCh chan struct{}) <-chan ObjectInfo
Lists objects in a bucket.
@@ -267,7 +267,7 @@ for object := range objectCh {
<a name="ListObjectsV2"></a>
-### ListObjectsV2(bucketName string, prefix string, recursive bool, doneCh chan struct{}) <-chan ObjectInfo
+### ListObjectsV2(bucketName, prefix string, recursive bool, doneCh chan struct{}) <-chan ObjectInfo
Lists objects in a bucket using the recommended listing API v2
@@ -317,7 +317,7 @@ for object := range objectCh {
```
<a name="ListIncompleteUploads"></a>
-### ListIncompleteUploads(bucketName string, prefix string, recursive bool, doneCh chan struct{}) <- chan ObjectMultipartInfo
+### ListIncompleteUploads(bucketName, prefix string, recursive bool, doneCh chan struct{}) <- chan ObjectMultipartInfo
Lists partially uploaded objects in a bucket.
@@ -373,7 +373,7 @@ for multiPartObject := range multiPartObjectCh {
## 3. Object operations
<a name="GetObject"></a>
-### GetObject(bucketName string, objectName string) (*Object, error)
+### GetObject(bucketName, objectName string) (*Object, error)
Downloads an object.
@@ -392,7 +392,7 @@ __Return Value__
|Param |Type |Description |
|:---|:---| :---|
-|`object` | _*minio.Object_ |_minio.Object_ represents object reader |
+|`object` | _*minio.Object_ |_minio.Object_ represents object reader. It implements io.Reader, io.Seeker, io.ReaderAt and io.Closer interfaces. |
__Example__
@@ -418,7 +418,7 @@ if _, err = io.Copy(localFile, object); err != nil {
```
<a name="FGetObject"></a>
-### FGetObject(bucketName string, objectName string, filePath string) error
+### FGetObject(bucketName, objectName, filePath string) error
Downloads and saves the object as a file in the local filesystem.
@@ -446,7 +446,7 @@ if err != nil {
```
<a name="PutObject"></a>
-### PutObject(bucketName string, objectName string, reader io.Reader, contentType string) (n int, err error)
+### PutObject(bucketName, objectName string, reader io.Reader, contentType string) (n int, err error)
Uploads an object.
@@ -489,7 +489,7 @@ if err != nil {
<a name="CopyObject"></a>
-### CopyObject(bucketName string, objectName string, objectSource string, conditions CopyConditions) error
+### CopyObject(bucketName, objectName, objectSource string, conditions CopyConditions) error
Copy a source object into a new object with the provided name in the provided bucket.
@@ -509,24 +509,34 @@ __Example__
```go
+// Use-case-1
+// To copy an existing object to a new object with _no_ copy conditions.
+copyConditions := minio.CopyConditions{}
+err := minioClient.CopyObject("mybucket", "myobject", "my-sourcebucketname/my-sourceobjectname", copyConds)
+if err != nil {
+ fmt.Println(err)
+ return
+}
-// All following conditions are allowed and can be combined together.
+// Use-case-2
+// To copy an existing object to a new object with the following copy conditions
+// 1. that matches a given ETag
+// 2. and modified after 1st April 2014
+// 3. but unmodified since 23rd April 2014
-// Set copy conditions.
-var copyConds = minio.NewCopyConditions()
-// Set modified condition, copy object modified since 2014 April.
-copyConds.SetModified(time.Date(2014, time.April, 0, 0, 0, 0, 0, time.UTC))
+// Initialize empty copy conditions.
+var copyConds = minio.CopyConditions{}
-// Set unmodified condition, copy object unmodified since 2014 April.
-// copyConds.SetUnmodified(time.Date(2014, time.April, 0, 0, 0, 0, 0, time.UTC))
+// copy object that matches the given ETag.
+copyConds.SetMatchETag("31624deb84149d2f8ef9c385918b653a")
-// Set matching ETag condition, copy object which matches the following ETag.
-// copyConds.SetMatchETag("31624deb84149d2f8ef9c385918b653a")
+// and modified after 1st April 2014
+copyConds.SetModified(time.Date(2014, time.April, 1, 0, 0, 0, 0, time.UTC))
-// Set matching ETag except condition, copy object which does not match the following ETag.
-// copyConds.SetMatchETagExcept("31624deb84149d2f8ef9c385918b653a")
+// but unmodified since 23rd April 2014
+copyConds.SetUnmodified(time.Date(2014, time.April, 23, 0, 0, 0, 0, time.UTC))
-err := minioClient.CopyObject("mybucket", "myobject", "/my-sourcebucketname/my-sourceobjectname", copyConds)
+err := minioClient.CopyObject("mybucket", "myobject", "my-sourcebucketname/my-sourceobjectname", copyConds)
if err != nil {
fmt.Println(err)
return
@@ -535,7 +545,7 @@ if err != nil {
```
<a name="FPutObject"></a>
-### FPutObject(bucketName string, objectName string, filePath string, contentType string) error
+### FPutObject(bucketName, objectName, filePath, contentType string) error
Uploads contents from a file to objectName.
@@ -569,7 +579,7 @@ if err != nil {
```
<a name="StatObject"></a>
-### StatObject(bucketName string, objectName string) (ObjectInfo, error)
+### StatObject(bucketName, objectName string) (ObjectInfo, error)
Gets metadata of an object.
@@ -613,7 +623,7 @@ fmt.Println(objInfo)
```
<a name="RemoveObject"></a>
-### RemoveObject(bucketName string, objectName string) error
+### RemoveObject(bucketName, objectName string) error
Removes an object.
@@ -670,7 +680,7 @@ for e := range errorCh {
<a name="RemoveIncompleteUpload"></a>
-### RemoveIncompleteUpload(bucketName string, objectName string) error
+### RemoveIncompleteUpload(bucketName, objectName string) error
Removes a partially uploaded object.
@@ -699,7 +709,7 @@ if err != nil {
<a name="PresignedGetObject"></a>
-### PresignedGetObject(bucketName string, objectName string, expiry time.Duration, reqParams url.Values) (*url.URL, error)
+### PresignedGetObject(bucketName, objectName string, expiry time.Duration, reqParams url.Values) (*url.URL, error)
Generates a presigned URL for HTTP GET operations. Browsers/Mobile clients may point to this URL to directly download objects even if the bucket is private. This presigned URL can have an associated expiration time in seconds after which it is no longer operational. The default expiry is set to 7 days.
@@ -733,7 +743,7 @@ if err != nil {
```
<a name="PresignedPutObject"></a>
-### PresignedPutObject(bucketName string, objectName string, expiry time.Duration) (*url.URL, error)
+### PresignedPutObject(bucketName, objectName string, expiry time.Duration) (*url.URL, error)
Generates a presigned URL for HTTP PUT operations. Browsers/Mobile clients may point to this URL to upload objects directly to a bucket even if it is private. This presigned URL can have an associated expiration time in seconds after which it is no longer operational. The default expiry is set to 7 days.
@@ -822,7 +832,7 @@ fmt.Printf("%s\n", url)
## 5. Bucket policy/notification operations
<a name="SetBucketPolicy"></a>
-### SetBucketPolicy(bucketname string, objectPrefix string, policy policy.BucketPolicy) error
+### SetBucketPolicy(bucketname, objectPrefix string, policy policy.BucketPolicy) error
Set access permissions on bucket or an object prefix.
@@ -864,7 +874,7 @@ if err != nil {
```
<a name="GetBucketPolicy"></a>
-### GetBucketPolicy(bucketName string, objectPrefix string) (policy.BucketPolicy, error)
+### GetBucketPolicy(bucketName, objectPrefix string) (policy.BucketPolicy, error)
Get access permissions on a bucket or a prefix.
@@ -901,7 +911,7 @@ fmt.Println("Access permissions for mybucket is", bucketPolicy)
```
<a name="ListBucketPolicies"></a>
-### ListBucketPolicies(bucketName string, objectPrefix string) (map[string]BucketPolicy, error)
+### ListBucketPolicies(bucketName, objectPrefix string) (map[string]BucketPolicy, error)
Get access permissions rules associated to the specified bucket and prefix.
@@ -1099,7 +1109,7 @@ for notificationInfo := range minioClient.ListenBucketNotification("YOUR-BUCKET"
## 6. Client custom settings
<a name="SetAppInfo"></a>
-### SetAppInfo(appName string, appVersion string)
+### SetAppInfo(appName, appVersion string)
Adds application details to User-Agent.
__Parameters__
@@ -1148,6 +1158,17 @@ __Parameters__
### TraceOff()
Disables HTTP tracing.
+<a name="SetS3TransferAccelerate"></a>
+### SetS3TransferAccelerate(acceleratedEndpoint string)
+Set AWS S3 transfer acceleration endpoint for all API requests hereafter.
+NOTE: This API applies only to AWS S3 and ignored with other S3 compatible object storage services.
+
+__Parameters__
+
+| Param | Type | Description |
+|---|---|---|
+|`acceleratedEndpoint` | _string_ | Set to new S3 transfer acceleration endpoint.|
+
## 7. Explore Further
diff --git a/vendor/github.com/minio/minio-go/examples/s3/copyobject.go b/vendor/github.com/minio/minio-go/examples/s3/copyobject.go
index 9f9e5bc4f..a9ec78fee 100644
--- a/vendor/github.com/minio/minio-go/examples/s3/copyobject.go
+++ b/vendor/github.com/minio/minio-go/examples/s3/copyobject.go
@@ -45,7 +45,7 @@ func main() {
// All following conditions are allowed and can be combined together.
// Set copy conditions.
- var copyConds = minio.NewCopyConditions()
+ var copyConds = minio.CopyConditions{}
// Set modified condition, copy object modified since 2014 April.
copyConds.SetModified(time.Date(2014, time.April, 0, 0, 0, 0, 0, time.UTC))
diff --git a/vendor/github.com/minio/minio-go/examples/s3/putobject-s3-accelerate.go b/vendor/github.com/minio/minio-go/examples/s3/putobject-s3-accelerate.go
new file mode 100644
index 000000000..e47976f2e
--- /dev/null
+++ b/vendor/github.com/minio/minio-go/examples/s3/putobject-s3-accelerate.go
@@ -0,0 +1,56 @@
+// +build ignore
+
+/*
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2016 Minio, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "log"
+ "os"
+
+ "github.com/minio/minio-go"
+)
+
+func main() {
+ // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-testfile, my-bucketname and
+ // my-objectname are dummy values, please replace them with original values.
+
+ // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
+ // This boolean value is the last argument for New().
+
+ // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
+ // determined based on the Endpoint value.
+ s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
+ if err != nil {
+ log.Fatalln(err)
+ }
+
+ // Enable S3 transfer accelerate endpoint.
+ s3Client.S3TransferAccelerate("s3-accelerate.amazonaws.com")
+
+ object, err := os.Open("my-testfile")
+ if err != nil {
+ log.Fatalln(err)
+ }
+ defer object.Close()
+
+ n, err := s3Client.PutObject("my-bucketname", "my-objectname", object, "application/octet-stream")
+ if err != nil {
+ log.Fatalln(err)
+ }
+ log.Println("Uploaded", "my-objectname", " of size: ", n, "Successfully.")
+}
diff --git a/vendor/github.com/minio/minio-go/pkg/s3utils/utils.go b/vendor/github.com/minio/minio-go/pkg/s3utils/utils.go
index ae1cea337..a3b6ed845 100644
--- a/vendor/github.com/minio/minio-go/pkg/s3utils/utils.go
+++ b/vendor/github.com/minio/minio-go/pkg/s3utils/utils.go
@@ -85,10 +85,6 @@ func IsAmazonEndpoint(endpointURL url.URL) bool {
return true
}
- if IsAmazonS3AccelerateEndpoint(endpointURL) {
- return true
- }
-
return endpointURL.Host == "s3.amazonaws.com"
}
@@ -105,14 +101,6 @@ func IsAmazonChinaEndpoint(endpointURL url.URL) bool {
return endpointURL.Host == "s3.cn-north-1.amazonaws.com.cn"
}
-// IsAmazonS3AccelerateEndpoint - Match if it is an Amazon S3 Accelerate
-func IsAmazonS3AccelerateEndpoint(endpointURL url.URL) bool {
- if endpointURL == sentinelURL {
- return false
- }
- return endpointURL.Host == "s3-accelerate.amazonaws.com"
-}
-
// IsGoogleEndpoint - Match if it is exactly Google cloud storage endpoint.
func IsGoogleEndpoint(endpointURL url.URL) bool {
if endpointURL == sentinelURL {
diff --git a/vendor/github.com/minio/minio-go/pkg/set/stringset.go b/vendor/github.com/minio/minio-go/pkg/set/stringset.go
index 55084d461..9f33488e0 100644
--- a/vendor/github.com/minio/minio-go/pkg/set/stringset.go
+++ b/vendor/github.com/minio/minio-go/pkg/set/stringset.go
@@ -25,8 +25,8 @@ import (
// StringSet - uses map as set of strings.
type StringSet map[string]struct{}
-// keys - returns StringSet keys.
-func (set StringSet) keys() []string {
+// ToSlice - returns StringSet as string slice.
+func (set StringSet) ToSlice() []string {
keys := make([]string, 0, len(set))
for k := range set {
keys = append(keys, k)
@@ -141,7 +141,7 @@ func (set StringSet) Union(sset StringSet) StringSet {
// MarshalJSON - converts to JSON data.
func (set StringSet) MarshalJSON() ([]byte, error) {
- return json.Marshal(set.keys())
+ return json.Marshal(set.ToSlice())
}
// UnmarshalJSON - parses JSON data and creates new set with it.
@@ -169,7 +169,7 @@ func (set *StringSet) UnmarshalJSON(data []byte) error {
// String - returns printable string of the set.
func (set StringSet) String() string {
- return fmt.Sprintf("%s", set.keys())
+ return fmt.Sprintf("%s", set.ToSlice())
}
// NewStringSet - creates new string set.
diff --git a/vendor/github.com/minio/minio-go/pkg/set/stringset_test.go b/vendor/github.com/minio/minio-go/pkg/set/stringset_test.go
index 4b74e7065..e276fec5a 100644
--- a/vendor/github.com/minio/minio-go/pkg/set/stringset_test.go
+++ b/vendor/github.com/minio/minio-go/pkg/set/stringset_test.go
@@ -17,6 +17,7 @@
package set
import (
+ "fmt"
"strings"
"testing"
)
@@ -320,3 +321,27 @@ func TestStringSetString(t *testing.T) {
}
}
}
+
+// StringSet.ToSlice() is called with series of cases for valid and erroneous inputs and the result is validated.
+func TestStringSetToSlice(t *testing.T) {
+ testCases := []struct {
+ set StringSet
+ expectedResult string
+ }{
+ // Test empty set.
+ {NewStringSet(), `[]`},
+ // Test set with empty value.
+ {CreateStringSet(""), `[]`},
+ // Test set with value.
+ {CreateStringSet("foo"), `[foo]`},
+ // Test set with value.
+ {CreateStringSet("foo", "bar"), `[bar foo]`},
+ }
+
+ for _, testCase := range testCases {
+ sslice := testCase.set.ToSlice()
+ if str := fmt.Sprintf("%s", sslice); str != testCase.expectedResult {
+ t.Fatalf("expected: %s, got: %s", testCase.expectedResult, str)
+ }
+ }
+}
diff --git a/vendor/github.com/mitchellh/mapstructure/.travis.yml b/vendor/github.com/mitchellh/mapstructure/.travis.yml
index 7f3fe9a96..5c14c1339 100644
--- a/vendor/github.com/mitchellh/mapstructure/.travis.yml
+++ b/vendor/github.com/mitchellh/mapstructure/.travis.yml
@@ -1,7 +1,7 @@
language: go
go:
- - 1.4
+ - 1.8.1
script:
- go test
diff --git a/vendor/github.com/mitchellh/mapstructure/decode_hooks.go b/vendor/github.com/mitchellh/mapstructure/decode_hooks.go
index 115ae67c1..acdaadefe 100644
--- a/vendor/github.com/mitchellh/mapstructure/decode_hooks.go
+++ b/vendor/github.com/mitchellh/mapstructure/decode_hooks.go
@@ -121,6 +121,11 @@ func StringToTimeDurationHookFunc() DecodeHookFunc {
}
}
+// WeaklyTypedHook is a DecodeHookFunc which adds support for weak typing to
+// the decoder.
+//
+// Note that this is significantly different from the WeaklyTypedInput option
+// of the DecoderConfig.
func WeaklyTypedHook(
f reflect.Kind,
t reflect.Kind,
@@ -132,9 +137,8 @@ func WeaklyTypedHook(
case reflect.Bool:
if dataVal.Bool() {
return "1", nil
- } else {
- return "0", nil
}
+ return "0", nil
case reflect.Float32:
return strconv.FormatFloat(dataVal.Float(), 'f', -1, 64), nil
case reflect.Int:
diff --git a/vendor/github.com/mitchellh/mapstructure/mapstructure.go b/vendor/github.com/mitchellh/mapstructure/mapstructure.go
index 6dee0ef0a..6ec5c3335 100644
--- a/vendor/github.com/mitchellh/mapstructure/mapstructure.go
+++ b/vendor/github.com/mitchellh/mapstructure/mapstructure.go
@@ -1,5 +1,5 @@
-// The mapstructure package exposes functionality to convert an
-// arbitrary map[string]interface{} into a native Go structure.
+// Package mapstructure exposes functionality to convert an arbitrary
+// map[string]interface{} into a native Go structure.
//
// The Go structure can be arbitrarily complex, containing slices,
// other structs, etc. and the decoder will properly decode nested
@@ -32,7 +32,12 @@ import (
// both.
type DecodeHookFunc interface{}
+// DecodeHookFuncType is a DecodeHookFunc which has complete information about
+// the source and target types.
type DecodeHookFuncType func(reflect.Type, reflect.Type, interface{}) (interface{}, error)
+
+// DecodeHookFuncKind is a DecodeHookFunc which knows only the Kinds of the
+// source and target types.
type DecodeHookFuncKind func(reflect.Kind, reflect.Kind, interface{}) (interface{}, error)
// DecoderConfig is the configuration that is used to create a new decoder
@@ -436,7 +441,7 @@ func (d *Decoder) decodeFloat(name string, data interface{}, val reflect.Value)
case dataKind == reflect.Uint:
val.SetFloat(float64(dataVal.Uint()))
case dataKind == reflect.Float32:
- val.SetFloat(float64(dataVal.Float()))
+ val.SetFloat(dataVal.Float())
case dataKind == reflect.Bool && d.config.WeaklyTypedInput:
if dataVal.Bool() {
val.SetFloat(1)
diff --git a/vendor/github.com/mitchellh/mapstructure/mapstructure_test.go b/vendor/github.com/mitchellh/mapstructure/mapstructure_test.go
index 932779d93..547af7331 100644
--- a/vendor/github.com/mitchellh/mapstructure/mapstructure_test.go
+++ b/vendor/github.com/mitchellh/mapstructure/mapstructure_test.go
@@ -437,7 +437,7 @@ func TestDecode_DecodeHookType(t *testing.T) {
func TestDecode_Nil(t *testing.T) {
t.Parallel()
- var input interface{} = nil
+ var input interface{}
result := Basic{
Vstring: "foo",
}
diff --git a/vendor/github.com/nicksnyder/go-i18n/.travis.yml b/vendor/github.com/nicksnyder/go-i18n/.travis.yml
index 1202d43d6..527eb6475 100644
--- a/vendor/github.com/nicksnyder/go-i18n/.travis.yml
+++ b/vendor/github.com/nicksnyder/go-i18n/.travis.yml
@@ -7,4 +7,5 @@ go:
- 1.5
- 1.6
- 1.7
+ - 1.8
- tip
diff --git a/vendor/github.com/nicksnyder/go-i18n/README.md b/vendor/github.com/nicksnyder/go-i18n/README.md
index 5aef540b3..7136dc823 100644
--- a/vendor/github.com/nicksnyder/go-i18n/README.md
+++ b/vendor/github.com/nicksnyder/go-i18n/README.md
@@ -1,19 +1,19 @@
-go-i18n [![Build Status](https://secure.travis-ci.org/nicksnyder/go-i18n.png?branch=master)](http://travis-ci.org/nicksnyder/go-i18n)
+go-i18n [![Build Status](https://travis-ci.org/nicksnyder/go-i18n.svg?branch=master)](http://travis-ci.org/nicksnyder/go-i18n) [![Sourcegraph](https://sourcegraph.com/github.com/nicksnyder/go-i18n/-/badge.svg)](https://sourcegraph.com/github.com/nicksnyder/go-i18n?badge)
=======
go-i18n is a Go [package](#i18n-package) and a [command](#goi18n-command) that helps you translate Go programs into multiple languages.
* Supports [pluralized strings](http://cldr.unicode.org/index/cldr-spec/plural-rules) for all 200+ languages in the [Unicode Common Locale Data Repository (CLDR)](http://www.unicode.org/cldr/charts/28/supplemental/language_plural_rules.html).
* Code and tests are [automatically generated](https://github.com/nicksnyder/go-i18n/tree/master/i18n/language/codegen) from [CLDR data](http://cldr.unicode.org/index/downloads)
* Supports strings with named variables using [text/template](http://golang.org/pkg/text/template/) syntax.
-* Translation files are simple JSON or YAML.
+* Translation files are simple JSON, TOML or YAML.
* [Documented](http://godoc.org/github.com/nicksnyder/go-i18n) and [tested](https://travis-ci.org/nicksnyder/go-i18n)!
-Package i18n [![GoDoc](http://godoc.org/github.com/nicksnyder/go-i18n?status.png)](http://godoc.org/github.com/nicksnyder/go-i18n/i18n)
+Package i18n [![GoDoc](http://godoc.org/github.com/nicksnyder/go-i18n?status.svg)](http://godoc.org/github.com/nicksnyder/go-i18n/i18n)
------------
The i18n package provides runtime APIs for fetching translated strings.
-Command goi18n [![GoDoc](http://godoc.org/github.com/nicksnyder/go-i18n?status.png)](http://godoc.org/github.com/nicksnyder/go-i18n/goi18n)
+Command goi18n [![GoDoc](http://godoc.org/github.com/nicksnyder/go-i18n?status.svg)](http://godoc.org/github.com/nicksnyder/go-i18n/goi18n)
--------------
The goi18n command provides functionality for managing the translation process.
@@ -66,7 +66,7 @@ Translation files
A translation file stores translated and untranslated strings.
-Example:
+Here is an example of the default file format that go-i18n supports:
```json
[
@@ -116,6 +116,62 @@ Example:
]
```
+To use a different file format, write a parser for the format and add the parsed translations using [AddTranslation](https://godoc.org/github.com/nicksnyder/go-i18n/i18n#AddTranslation).
+
+Note that TOML only supports the flat format, which is described below.
+
+More examples of translation files: [JSON](https://github.com/nicksnyder/go-i18n/tree/master/goi18n/testdata/input), [TOML](https://github.com/nicksnyder/go-i18n/blob/master/goi18n/testdata/input/flat/ar-ar.one.toml), [YAML](https://github.com/nicksnyder/go-i18n/blob/master/goi18n/testdata/input/yaml/en-us.one.yaml).
+
+Flat Format
+-------------
+
+You can also write shorter translation files with flat format.
+E.g the example above can be written in this way:
+
+```json
+{
+ "d_days": {
+ "one": "{{.Count}} day.",
+ "other": "{{.Count}} days."
+ },
+
+ "my_height_in_meters": {
+ "one": "I am {{.Count}} meter tall.",
+ "other": "I am {{.Count}} meters tall."
+ },
+
+ "person_greeting": {
+ "other": "Hello {{.Person}}"
+ },
+
+ "person_unread_email_count": {
+ "one": "{{.Person}} has {{.Count}} unread email.",
+ "other": "{{.Person}} has {{.Count}} unread emails."
+ },
+
+ "person_unread_email_count_timeframe": {
+ "one": "{{.Person}} has {{.Count}} unread email in the past {{.Timeframe}}.",
+ "other": "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
+ },
+
+ "program_greeting": {
+ "other": "Hello world"
+ },
+
+ "your_unread_email_count": {
+ "one": "You have {{.Count}} unread email.",
+ "other": "You have {{.Count}} unread emails."
+ }
+}
+```
+
+The logic of flat format is, what it is structure of structures
+and name of substructures (ids) should be always a string.
+If there is only one key in substructure and it is "other", then it's non-plural
+translation, else plural.
+
+More examples of flat format translation files can be found in [goi18n/testdata/input/flat](https://github.com/nicksnyder/go-i18n/tree/master/goi18n/testdata/input/flat).
+
Contributions
-------------
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/constants_command.go b/vendor/github.com/nicksnyder/go-i18n/goi18n/constants_command.go
index 85b1ac18e..d877add32 100644
--- a/vendor/github.com/nicksnyder/go-i18n/goi18n/constants_command.go
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/constants_command.go
@@ -139,7 +139,6 @@ Options:
Default: .
`)
- os.Exit(1)
}
// commonInitialisms is a set of common initialisms.
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command.go b/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command.go
index 1d34ac438..1b9d04fd3 100644
--- a/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command.go
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command.go
@@ -5,7 +5,6 @@ import (
"flag"
"fmt"
"io/ioutil"
- "os"
"path/filepath"
"reflect"
"sort"
@@ -15,6 +14,7 @@ import (
"github.com/nicksnyder/go-i18n/i18n/bundle"
"github.com/nicksnyder/go-i18n/i18n/language"
"github.com/nicksnyder/go-i18n/i18n/translation"
+ toml "github.com/pelletier/go-toml"
)
type mergeCommand struct {
@@ -22,6 +22,7 @@ type mergeCommand struct {
sourceLanguage string
outdir string
format string
+ flat bool
}
func (mc *mergeCommand) execute() error {
@@ -33,15 +34,10 @@ func (mc *mergeCommand) execute() error {
return fmt.Errorf("invalid source locale: %s", mc.sourceLanguage)
}
- marshal, err := newMarshalFunc(mc.format)
- if err != nil {
- return err
- }
-
bundle := bundle.New()
for _, tf := range mc.translationFiles {
if err := bundle.LoadTranslationFile(tf); err != nil {
- return fmt.Errorf("failed to load translation file %s because %s\n", tf, err)
+ return fmt.Errorf("failed to load translation file %s: %s\n", tf, err)
}
}
@@ -64,7 +60,7 @@ func (mc *mergeCommand) execute() error {
all := filter(localeTranslations, func(t translation.Translation) translation.Translation {
return t.Normalize(lang)
})
- if err := mc.writeFile("all", all, localeID, marshal); err != nil {
+ if err := mc.writeFile("all", all, localeID); err != nil {
return err
}
@@ -74,7 +70,7 @@ func (mc *mergeCommand) execute() error {
}
return nil
})
- if err := mc.writeFile("untranslated", untranslated, localeID, marshal); err != nil {
+ if err := mc.writeFile("untranslated", untranslated, localeID); err != nil {
return err
}
}
@@ -88,6 +84,7 @@ func (mc *mergeCommand) parse(arguments []string) {
sourceLanguage := flags.String("sourceLanguage", "en-us", "")
outdir := flags.String("outdir", ".", "")
format := flags.String("format", "json", "")
+ flat := flags.Bool("flat", true, "")
flags.Parse(arguments)
@@ -95,31 +92,44 @@ func (mc *mergeCommand) parse(arguments []string) {
mc.sourceLanguage = *sourceLanguage
mc.outdir = *outdir
mc.format = *format
+ if *format == "toml" {
+ mc.flat = true
+ } else {
+ mc.flat = *flat
+ }
}
func (mc *mergeCommand) SetArgs(args []string) {
mc.translationFiles = args
}
-type marshalFunc func(interface{}) ([]byte, error)
-
-func (mc *mergeCommand) writeFile(label string, translations []translation.Translation, localeID string, marshal marshalFunc) error {
+func (mc *mergeCommand) writeFile(label string, translations []translation.Translation, localeID string) error {
sort.Sort(translation.SortableByID(translations))
- buf, err := marshal(marshalInterface(translations))
+
+ var convert func([]translation.Translation) interface{}
+ if mc.flat {
+ convert = marshalFlatInterface
+ } else {
+ convert = marshalInterface
+ }
+
+ buf, err := mc.marshal(convert(translations))
if err != nil {
- return fmt.Errorf("failed to marshal %s strings to %s because %s", localeID, mc.format, err)
+ return fmt.Errorf("failed to marshal %s strings to %s: %s", localeID, mc.format, err)
}
+
filename := filepath.Join(mc.outdir, fmt.Sprintf("%s.%s.%s", localeID, label, mc.format))
+
if err := ioutil.WriteFile(filename, buf, 0666); err != nil {
- return fmt.Errorf("failed to write %s because %s", filename, err)
+ return fmt.Errorf("failed to write %s: %s", filename, err)
}
return nil
}
-func filter(translations map[string]translation.Translation, filter func(translation.Translation) translation.Translation) []translation.Translation {
+func filter(translations map[string]translation.Translation, f func(translation.Translation) translation.Translation) []translation.Translation {
filtered := make([]translation.Translation, 0, len(translations))
for _, translation := range translations {
- if t := filter(translation); t != nil {
+ if t := f(translation); t != nil {
filtered = append(filtered, t)
}
}
@@ -127,21 +137,15 @@ func filter(translations map[string]translation.Translation, filter func(transla
}
-func newMarshalFunc(format string) (marshalFunc, error) {
- switch format {
- case "json":
- return func(v interface{}) ([]byte, error) {
- return json.MarshalIndent(v, "", " ")
- }, nil
- case "yaml":
- return func(v interface{}) ([]byte, error) {
- return yaml.Marshal(v)
- }, nil
+func marshalFlatInterface(translations []translation.Translation) interface{} {
+ mi := make(map[string]interface{}, len(translations))
+ for _, translation := range translations {
+ mi[translation.ID()] = translation.MarshalFlatInterface()
}
- return nil, fmt.Errorf("unsupported format: %s\n", format)
+ return mi
}
-func marshalInterface(translations []translation.Translation) []interface{} {
+func marshalInterface(translations []translation.Translation) interface{} {
mi := make([]interface{}, len(translations))
for i, translation := range translations {
mi[i] = translation.MarshalInterface()
@@ -149,6 +153,31 @@ func marshalInterface(translations []translation.Translation) []interface{} {
return mi
}
+func (mc mergeCommand) marshal(v interface{}) ([]byte, error) {
+ switch mc.format {
+ case "json":
+ return json.MarshalIndent(v, "", " ")
+ case "toml":
+ return marshalTOML(v)
+ case "yaml":
+ return yaml.Marshal(v)
+ }
+ return nil, fmt.Errorf("unsupported format: %s\n", mc.format)
+}
+
+func marshalTOML(v interface{}) ([]byte, error) {
+ m, ok := v.(map[string]interface{})
+ if !ok {
+ return nil, fmt.Errorf("invalid format for marshaling to TOML")
+ }
+ tree, err := toml.TreeFromMap(m)
+ if err != nil {
+ return nil, err
+ }
+ s, err := tree.ToTomlString()
+ return []byte(s), err
+}
+
func usageMerge() {
fmt.Printf(`Merge translation files.
@@ -198,9 +227,13 @@ Options:
-format format
goi18n encodes the output translation files in this format.
- Supported formats: json, yaml
+ Supported formats: json, toml, yaml
Default: json
+ -flat
+ goi18n writes the output translation files in flat format.
+ Usage of '-format toml' automitically sets this flag.
+ Default: true
+
`)
- os.Exit(1)
}
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command_flat_test.go b/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command_flat_test.go
new file mode 100644
index 000000000..caa892d29
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command_flat_test.go
@@ -0,0 +1,36 @@
+package main
+
+import "testing"
+
+func TestMergeExecuteFlat(t *testing.T) {
+ files := []string{
+ "testdata/input/flat/en-us.one.yaml",
+ "testdata/input/flat/en-us.two.json",
+ "testdata/input/flat/fr-fr.json",
+ "testdata/input/flat/ar-ar.one.toml",
+ "testdata/input/flat/ar-ar.two.json",
+ }
+ testFlatMergeExecute(t, files)
+}
+
+func testFlatMergeExecute(t *testing.T, files []string) {
+ resetDir(t, "testdata/output/flat")
+
+ mc := &mergeCommand{
+ translationFiles: files,
+ sourceLanguage: "en-us",
+ outdir: "testdata/output/flat",
+ format: "json",
+ flat: true,
+ }
+ if err := mc.execute(); err != nil {
+ t.Fatal(err)
+ }
+
+ expectEqualFiles(t, "testdata/output/flat/en-us.all.json", "testdata/expected/flat/en-us.all.json")
+ expectEqualFiles(t, "testdata/output/flat/ar-ar.all.json", "testdata/expected/flat/ar-ar.all.json")
+ expectEqualFiles(t, "testdata/output/flat/fr-fr.all.json", "testdata/expected/flat/fr-fr.all.json")
+ expectEqualFiles(t, "testdata/output/flat/en-us.untranslated.json", "testdata/expected/flat/en-us.untranslated.json")
+ expectEqualFiles(t, "testdata/output/flat/ar-ar.untranslated.json", "testdata/expected/flat/ar-ar.untranslated.json")
+ expectEqualFiles(t, "testdata/output/flat/fr-fr.untranslated.json", "testdata/expected/flat/fr-fr.untranslated.json")
+}
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command_test.go b/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command_test.go
index 37e46518b..425a6b62d 100644
--- a/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command_test.go
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/merge_command_test.go
@@ -37,6 +37,7 @@ func testMergeExecute(t *testing.T, files []string) {
sourceLanguage: "en-us",
outdir: "testdata/output",
format: "json",
+ flat: false,
}
if err := mc.execute(); err != nil {
t.Fatal(err)
@@ -69,6 +70,6 @@ func expectEqualFiles(t *testing.T, expectedName, actualName string) {
t.Fatal(err)
}
if !bytes.Equal(actual, expected) {
- t.Fatalf("contents of files did not match: %s, %s", expectedName, actualName)
+ t.Errorf("contents of files did not match: %s, %s", expectedName, actualName)
}
}
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.json
new file mode 100644
index 000000000..f67d21cac
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.json
@@ -0,0 +1,34 @@
+{
+ "program_greeting": {
+ "other": "Hello world"
+ },
+
+ "person_greeting": {
+ "other": "Hello {{.Person}}"
+ },
+
+ "my_height_in_meters": {
+ "one": "I am {{.Count}} meter tall.",
+ "other": "I am {{.Count}} meters tall."
+ },
+
+ "your_unread_email_count": {
+ "one": "You have {{.Count}} unread email.",
+ "other": "You have {{.Count}} unread emails."
+ },
+
+ "person_unread_email_count": {
+ "one": "{{.Person}} has {{.Count}} unread email.",
+ "other": "{{.Person}} has {{.Count}} unread emails."
+ },
+
+ "person_unread_email_count_timeframe": {
+ "one": "{{.Person}} has {{.Count}} unread email in the past {{.Timeframe}}.",
+ "other": "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
+ },
+
+ "d_days": {
+ "one": "{{.Count}} day.",
+ "other": "{{.Count}} days."
+ }
+}
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.toml b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.toml
new file mode 100644
index 000000000..5623a6c2e
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.toml
@@ -0,0 +1,25 @@
+[program_greeting]
+other = "Hello world"
+
+[person_greeting]
+other = "Hello {{.Person}}"
+
+[my_height_in_meters]
+one = "I am {{.Count}} meter tall."
+other = "I am {{.Count}} meters tall."
+
+[your_unread_email_count]
+one = "You have {{.Count}} unread email."
+other = "You have {{.Count}} unread emails."
+
+[person_unread_email_count]
+one = "{{.Person}} has {{.Count}} unread email."
+other = "{{.Person}} has {{.Count}} unread emails."
+
+[person_unread_email_count_timeframe]
+one = "{{.Person}} has {{.Count}} unread email in the past {{.Timeframe}}."
+other = "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
+
+[d_days]
+one = "{{.Count}} day"
+other = "{{.Count}} days"
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.yaml b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.yaml
new file mode 100644
index 000000000..316ac6b20
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/en-us.flat.yaml
@@ -0,0 +1,25 @@
+program_greeting:
+ other: "Hello world"
+
+person_greeting:
+ other: "Hello {{.Person}}"
+
+my_height_in_meters:
+ one: "I am {{.Count}} meter tall."
+ other: "I am {{.Count}} meters tall."
+
+your_unread_email_count:
+ one: "You have {{.Count}} unread email."
+ other: "You have {{.Count}} unread emails."
+
+person_unread_email_count:
+ one: "{{.Person}} has {{.Count}} unread email."
+ other: "{{.Person}} has {{.Count}} unread emails."
+
+person_unread_email_count_timeframe:
+ one: "{{.Person}} has {{.Count}} unread email in the past {{.Timeframe}}."
+ other: "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
+
+d_days:
+ one: "{{.Count}} day"
+ other: "{{.Count}} days"
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/ar-ar.all.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/ar-ar.all.json
new file mode 100644
index 000000000..1adb99ca9
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/ar-ar.all.json
@@ -0,0 +1,43 @@
+{
+ "d_days": {
+ "few": "new arabic few translation of d_days",
+ "many": "arabic many translation of d_days",
+ "one": "arabic one translation of d_days",
+ "other": "",
+ "two": "",
+ "zero": ""
+ },
+ "my_height_in_meters": {
+ "few": "",
+ "many": "",
+ "one": "",
+ "other": "",
+ "two": "",
+ "zero": ""
+ },
+ "person_greeting": {
+ "other": "new arabic translation of person_greeting"
+ },
+ "person_unread_email_count": {
+ "few": "arabic few translation of person_unread_email_count",
+ "many": "arabic many translation of person_unread_email_count",
+ "one": "arabic one translation of person_unread_email_count",
+ "other": "arabic other translation of person_unread_email_count",
+ "two": "arabic two translation of person_unread_email_count",
+ "zero": "arabic zero translation of person_unread_email_count"
+ },
+ "person_unread_email_count_timeframe": {
+ "other": ""
+ },
+ "program_greeting": {
+ "other": ""
+ },
+ "your_unread_email_count": {
+ "few": "",
+ "many": "",
+ "one": "",
+ "other": "",
+ "two": "",
+ "zero": ""
+ }
+} \ No newline at end of file
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/ar-ar.untranslated.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/ar-ar.untranslated.json
new file mode 100644
index 000000000..ea7aa7d19
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/ar-ar.untranslated.json
@@ -0,0 +1,32 @@
+{
+ "d_days": {
+ "few": "new arabic few translation of d_days",
+ "many": "arabic many translation of d_days",
+ "one": "arabic one translation of d_days",
+ "other": "{{.Count}} days",
+ "two": "{{.Count}} days",
+ "zero": "{{.Count}} days"
+ },
+ "my_height_in_meters": {
+ "few": "I am {{.Count}} meters tall.",
+ "many": "I am {{.Count}} meters tall.",
+ "one": "I am {{.Count}} meters tall.",
+ "other": "I am {{.Count}} meters tall.",
+ "two": "I am {{.Count}} meters tall.",
+ "zero": "I am {{.Count}} meters tall."
+ },
+ "person_unread_email_count_timeframe": {
+ "other": "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
+ },
+ "program_greeting": {
+ "other": "Hello world"
+ },
+ "your_unread_email_count": {
+ "few": "You have {{.Count}} unread emails.",
+ "many": "You have {{.Count}} unread emails.",
+ "one": "You have {{.Count}} unread emails.",
+ "other": "You have {{.Count}} unread emails.",
+ "two": "You have {{.Count}} unread emails.",
+ "zero": "You have {{.Count}} unread emails."
+ }
+} \ No newline at end of file
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.all.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.all.json
new file mode 100644
index 000000000..766b2a77c
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.all.json
@@ -0,0 +1,27 @@
+{
+ "d_days": {
+ "one": "{{.Count}} day",
+ "other": "{{.Count}} days"
+ },
+ "my_height_in_meters": {
+ "one": "I am {{.Count}} meter tall.",
+ "other": "I am {{.Count}} meters tall."
+ },
+ "person_greeting": {
+ "other": "Hello {{.Person}}"
+ },
+ "person_unread_email_count": {
+ "one": "{{.Person}} has {{.Count}} unread email.",
+ "other": "{{.Person}} has {{.Count}} unread emails."
+ },
+ "person_unread_email_count_timeframe": {
+ "other": "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
+ },
+ "program_greeting": {
+ "other": "Hello world"
+ },
+ "your_unread_email_count": {
+ "one": "You have {{.Count}} unread email.",
+ "other": "You have {{.Count}} unread emails."
+ }
+} \ No newline at end of file
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.untranslated.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.untranslated.json
new file mode 100644
index 000000000..9e26dfeeb
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.untranslated.json
@@ -0,0 +1 @@
+{} \ No newline at end of file
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.untranslated.json.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.untranslated.json.json
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/en-us.untranslated.json.json
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/fr-fr.all.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/fr-fr.all.json
new file mode 100644
index 000000000..b0ee0311f
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/fr-fr.all.json
@@ -0,0 +1,27 @@
+{
+ "d_days": {
+ "one": "",
+ "other": ""
+ },
+ "my_height_in_meters": {
+ "one": "",
+ "other": ""
+ },
+ "person_greeting": {
+ "other": ""
+ },
+ "person_unread_email_count": {
+ "one": "",
+ "other": ""
+ },
+ "person_unread_email_count_timeframe": {
+ "other": ""
+ },
+ "program_greeting": {
+ "other": ""
+ },
+ "your_unread_email_count": {
+ "one": "",
+ "other": ""
+ }
+} \ No newline at end of file
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/fr-fr.untranslated.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/fr-fr.untranslated.json
new file mode 100644
index 000000000..e6d5c4fb6
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/expected/flat/fr-fr.untranslated.json
@@ -0,0 +1,27 @@
+{
+ "d_days": {
+ "one": "{{.Count}} days",
+ "other": "{{.Count}} days"
+ },
+ "my_height_in_meters": {
+ "one": "I am {{.Count}} meters tall.",
+ "other": "I am {{.Count}} meters tall."
+ },
+ "person_greeting": {
+ "other": "Hello {{.Person}}"
+ },
+ "person_unread_email_count": {
+ "one": "{{.Person}} has {{.Count}} unread emails.",
+ "other": "{{.Person}} has {{.Count}} unread emails."
+ },
+ "person_unread_email_count_timeframe": {
+ "other": "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
+ },
+ "program_greeting": {
+ "other": "Hello world"
+ },
+ "your_unread_email_count": {
+ "one": "You have {{.Count}} unread emails.",
+ "other": "You have {{.Count}} unread emails."
+ }
+} \ No newline at end of file
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/ar-ar.one.toml b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/ar-ar.one.toml
new file mode 100644
index 000000000..364a62cfe
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/ar-ar.one.toml
@@ -0,0 +1,37 @@
+[d_days]
+few = "arabic few translation of d_days"
+many = "arabic many translation of d_days"
+one = ""
+other = ""
+two = ""
+zero = ""
+
+[person_greeting]
+other = "arabic translation of person_greeting"
+
+[person_unread_email_count]
+few = "arabic few translation of person_unread_email_count"
+many = "arabic many translation of person_unread_email_count"
+one = "arabic one translation of person_unread_email_count"
+other = ""
+two = ""
+zero = ""
+
+[person_unread_email_count_timeframe]
+few = ""
+many = ""
+one = ""
+other = ""
+two = ""
+zero = ""
+
+[program_greeting]
+other = ""
+
+[your_unread_email_count]
+few = ""
+many = ""
+one = ""
+other = ""
+two = ""
+zero = ""
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/ar-ar.two.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/ar-ar.two.json
new file mode 100644
index 000000000..5e6fba41b
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/ar-ar.two.json
@@ -0,0 +1,45 @@
+{
+ "d_days": {
+ "few": "new arabic few translation of d_days",
+ "many": "",
+ "one": "arabic one translation of d_days",
+ "other": "",
+ "two": "",
+ "zero": ""
+ },
+
+ "person_greeting": {
+ "other": "new arabic translation of person_greeting"
+ },
+
+ "person_unread_email_count": {
+ "few": "",
+ "many": "",
+ "one": "",
+ "other": "arabic other translation of person_unread_email_count",
+ "two": "arabic two translation of person_unread_email_count",
+ "zero": "arabic zero translation of person_unread_email_count"
+ },
+
+ "person_unread_email_count_timeframe": {
+ "few": "",
+ "many": "",
+ "one": "",
+ "other": "",
+ "two": "",
+ "zero": ""
+ },
+
+ "program_greeting": {
+ "other": ""
+ },
+
+ "your_unread_email_count": {
+ "few": "",
+ "many": "",
+ "one": "",
+ "other": "",
+ "two": "",
+ "zero": ""
+ }
+}
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.constants.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.constants.json
new file mode 100644
index 000000000..c41b2b97f
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.constants.json
@@ -0,0 +1,34 @@
+{
+ "d_days": {
+ "one": "{{.Count}} day",
+ "other": "{{.Count}} days"
+ },
+
+ "my_height_in_meters": {
+ "one": "I am {{.Count}} meter tall.",
+ "other": "I am {{.Count}} meters tall."
+ },
+
+ "person_greeting": {
+ "other": "Hello {{.Person}}"
+ },
+
+ "person_unread_email_count": {
+ "one": "{{.Person}} has {{.Count}} unread email.",
+ "other": "{{.Person}} has {{.Count}} unread emails."
+ },
+
+ "person_unread_email_count_timeframe": {
+ "one": "{{.Person}} has {{.Count}} unread email in the past {{.Timeframe}}.",
+ "other": "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
+ },
+
+ "program_greeting": {
+ "other": "Hello world"
+ },
+
+ "your_unread_email_count": {
+ "one": "You have {{.Count}} unread email.",
+ "other": "You have {{.Count}} unread emails."
+ }
+}
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.one.yaml b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.one.yaml
new file mode 100644
index 000000000..02ae0011b
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.one.yaml
@@ -0,0 +1,16 @@
+program_greeting:
+ other: "Hello world"
+
+your_unread_email_count:
+ one: "You have {{.Count}} unread email."
+ other: "You have {{.Count}} unread emails."
+
+my_height_in_meters:
+ one: "I am {{.Count}} meter tall."
+ other: "I am {{.Count}} meters tall."
+
+person_unread_email_count_timeframe:
+ other: "{{.Person}} has {{.Count}} unread email in the past {{.Timeframe}}."
+
+d_days:
+ other: "this should get overwritten"
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.two.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.two.json
new file mode 100644
index 000000000..06bd28dcd
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/en-us.two.json
@@ -0,0 +1,19 @@
+{
+ "person_greeting": {
+ "other": "Hello {{.Person}}"
+ },
+
+ "person_unread_email_count": {
+ "one": "{{.Person}} has {{.Count}} unread email.",
+ "other": "{{.Person}} has {{.Count}} unread emails."
+ },
+
+ "person_unread_email_count_timeframe": {
+ "other": "{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."
+ },
+
+ "d_days": {
+ "one": "{{.Count}} day",
+ "other": "{{.Count}} days"
+ }
+}
diff --git a/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/fr-fr.json b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/fr-fr.json
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/goi18n/testdata/input/flat/fr-fr.json
diff --git a/vendor/github.com/nicksnyder/go-i18n/i18n/bundle/bundle.go b/vendor/github.com/nicksnyder/go-i18n/i18n/bundle/bundle.go
index 155543bda..2ad1d7cc3 100644
--- a/vendor/github.com/nicksnyder/go-i18n/i18n/bundle/bundle.go
+++ b/vendor/github.com/nicksnyder/go-i18n/i18n/bundle/bundle.go
@@ -2,6 +2,7 @@
package bundle
import (
+ "bytes"
"encoding/json"
"fmt"
"io/ioutil"
@@ -11,6 +12,7 @@ import (
"github.com/nicksnyder/go-i18n/i18n/language"
"github.com/nicksnyder/go-i18n/i18n/translation"
+ toml "github.com/pelletier/go-toml"
"gopkg.in/yaml.v2"
)
@@ -78,34 +80,103 @@ func (b *Bundle) ParseTranslationFileBytes(filename string, buf []byte) error {
}
func parseTranslations(filename string, buf []byte) ([]translation.Translation, error) {
- var unmarshalFunc func([]byte, interface{}) error
- switch format := filepath.Ext(filename); format {
- case ".json":
- unmarshalFunc = json.Unmarshal
- case ".yaml":
- unmarshalFunc = yaml.Unmarshal
- default:
- return nil, fmt.Errorf("unsupported file extension %s", format)
+ if len(buf) == 0 {
+ return []translation.Translation{}, nil
}
- var translationsData []map[string]interface{}
- if len(buf) > 0 {
- if err := unmarshalFunc(buf, &translationsData); err != nil {
- return nil, fmt.Errorf("failed to load %s because %s", filename, err)
+ ext := filepath.Ext(filename)
+
+ // `github.com/pelletier/go-toml` has an Unmarshal function,
+ // that can't unmarshal to maps, so we should parse TOML format separately.
+ if ext == ".toml" {
+ tree, err := toml.LoadReader(bytes.NewReader(buf))
+ if err != nil {
+ return nil, err
}
+
+ m := make(map[string]map[string]interface{})
+ for k, v := range tree.ToMap() {
+ m[k] = v.(map[string]interface{})
+ }
+
+ return parseFlatFormat(m)
}
- translations := make([]translation.Translation, 0, len(translationsData))
- for i, translationData := range translationsData {
+ // Then parse other formats.
+ if isStandardFormat(ext, buf) {
+ var standardFormat []map[string]interface{}
+ if err := unmarshal(ext, buf, &standardFormat); err != nil {
+ return nil, fmt.Errorf("failed to unmarshal %v: %v", filename, err)
+ }
+ return parseStandardFormat(standardFormat)
+ } else {
+ var flatFormat map[string]map[string]interface{}
+ if err := unmarshal(ext, buf, &flatFormat); err != nil {
+ return nil, fmt.Errorf("failed to unmarshal %v: %v", filename, err)
+ }
+ return parseFlatFormat(flatFormat)
+ }
+}
+
+func isStandardFormat(ext string, buf []byte) bool {
+ firstRune := rune(buf[0])
+ if (ext == ".json" && firstRune == '[') || (ext == ".yaml" && firstRune == '-') {
+ return true
+ }
+ return false
+}
+
+// unmarshal finds an appropriate unmarshal function for ext
+// (extension of filename) and unmarshals buf to out. out must be a pointer.
+func unmarshal(ext string, buf []byte, out interface{}) error {
+ switch ext {
+ case ".json":
+ return json.Unmarshal(buf, out)
+ case ".yaml":
+ return yaml.Unmarshal(buf, out)
+ }
+
+ return fmt.Errorf("unsupported file extension %v", ext)
+}
+
+func parseStandardFormat(data []map[string]interface{}) ([]translation.Translation, error) {
+ translations := make([]translation.Translation, 0, len(data))
+ for i, translationData := range data {
t, err := translation.NewTranslation(translationData)
if err != nil {
- return nil, fmt.Errorf("unable to parse translation #%d in %s because %s\n%v", i, filename, err, translationData)
+ return nil, fmt.Errorf("unable to parse translation #%d because %s\n%v", i, err, translationData)
}
translations = append(translations, t)
}
return translations, nil
}
+// parseFlatFormat just converts data from flat format to standard format
+// and passes it to parseStandardFormat.
+//
+// Flat format logic:
+// key of data must be a string and data[key] must be always map[string]interface{},
+// but if there is only "other" key in it then it is non-plural, else plural.
+func parseFlatFormat(data map[string]map[string]interface{}) ([]translation.Translation, error) {
+ var standardFormatData []map[string]interface{}
+ for id, translationData := range data {
+ dataObject := make(map[string]interface{})
+ dataObject["id"] = id
+ if len(translationData) == 1 { // non-plural form
+ _, otherExists := translationData["other"]
+ if otherExists {
+ dataObject["translation"] = translationData["other"]
+ }
+ } else { // plural form
+ dataObject["translation"] = translationData
+ }
+
+ standardFormatData = append(standardFormatData, dataObject)
+ }
+
+ return parseStandardFormat(standardFormatData)
+}
+
// AddTranslation adds translations for a language.
//
// It is useful if your translations are in a format not supported by LoadTranslationFile.
diff --git a/vendor/github.com/nicksnyder/go-i18n/i18n/translation/plural_translation.go b/vendor/github.com/nicksnyder/go-i18n/i18n/translation/plural_translation.go
index 4f579d16a..5dd74b2f5 100644
--- a/vendor/github.com/nicksnyder/go-i18n/i18n/translation/plural_translation.go
+++ b/vendor/github.com/nicksnyder/go-i18n/i18n/translation/plural_translation.go
@@ -16,6 +16,10 @@ func (pt *pluralTranslation) MarshalInterface() interface{} {
}
}
+func (pt *pluralTranslation) MarshalFlatInterface() interface{} {
+ return pt.templates
+}
+
func (pt *pluralTranslation) ID() string {
return pt.id
}
diff --git a/vendor/github.com/nicksnyder/go-i18n/i18n/translation/single_translation.go b/vendor/github.com/nicksnyder/go-i18n/i18n/translation/single_translation.go
index 1010e5947..9fcba5a18 100644
--- a/vendor/github.com/nicksnyder/go-i18n/i18n/translation/single_translation.go
+++ b/vendor/github.com/nicksnyder/go-i18n/i18n/translation/single_translation.go
@@ -16,6 +16,10 @@ func (st *singleTranslation) MarshalInterface() interface{} {
}
}
+func (st *singleTranslation) MarshalFlatInterface() interface{} {
+ return map[string]interface{}{"other": st.template}
+}
+
func (st *singleTranslation) ID() string {
return st.id
}
diff --git a/vendor/github.com/nicksnyder/go-i18n/i18n/translation/template.go b/vendor/github.com/nicksnyder/go-i18n/i18n/translation/template.go
index c8756fa4e..3310150c0 100644
--- a/vendor/github.com/nicksnyder/go-i18n/i18n/translation/template.go
+++ b/vendor/github.com/nicksnyder/go-i18n/i18n/translation/template.go
@@ -13,6 +13,10 @@ type template struct {
}
func newTemplate(src string) (*template, error) {
+ if src == "" {
+ return new(template), nil
+ }
+
var tmpl template
err := tmpl.parseTemplate(src)
return &tmpl, err
diff --git a/vendor/github.com/nicksnyder/go-i18n/i18n/translation/translation.go b/vendor/github.com/nicksnyder/go-i18n/i18n/translation/translation.go
index fa93180b8..197514623 100644
--- a/vendor/github.com/nicksnyder/go-i18n/i18n/translation/translation.go
+++ b/vendor/github.com/nicksnyder/go-i18n/i18n/translation/translation.go
@@ -12,6 +12,7 @@ type Translation interface {
// MarshalInterface returns the object that should be used
// to serialize the translation.
MarshalInterface() interface{}
+ MarshalFlatInterface() interface{}
ID() string
Template(language.Plural) *template
UntranslatedCopy() Translation
diff --git a/vendor/github.com/nicksnyder/go-i18n/i18n/translations_test.go b/vendor/github.com/nicksnyder/go-i18n/i18n/translations_test.go
new file mode 100644
index 000000000..86c580833
--- /dev/null
+++ b/vendor/github.com/nicksnyder/go-i18n/i18n/translations_test.go
@@ -0,0 +1,89 @@
+package i18n
+
+import (
+ "testing"
+
+ "github.com/nicksnyder/go-i18n/i18n/bundle"
+)
+
+var bobMap = map[string]interface{}{"Person": "Bob"}
+var bobStruct = struct{ Person string }{Person: "Bob"}
+
+var testCases = []struct {
+ id string
+ arg interface{}
+ want string
+}{
+ {"program_greeting", nil, "Hello world"},
+ {"person_greeting", bobMap, "Hello Bob"},
+ {"person_greeting", bobStruct, "Hello Bob"},
+
+ {"your_unread_email_count", 0, "You have 0 unread emails."},
+ {"your_unread_email_count", 1, "You have 1 unread email."},
+ {"your_unread_email_count", 2, "You have 2 unread emails."},
+ {"my_height_in_meters", "1.7", "I am 1.7 meters tall."},
+
+ {"person_unread_email_count", []interface{}{0, bobMap}, "Bob has 0 unread emails."},
+ {"person_unread_email_count", []interface{}{1, bobMap}, "Bob has 1 unread email."},
+ {"person_unread_email_count", []interface{}{2, bobMap}, "Bob has 2 unread emails."},
+ {"person_unread_email_count", []interface{}{0, bobStruct}, "Bob has 0 unread emails."},
+ {"person_unread_email_count", []interface{}{1, bobStruct}, "Bob has 1 unread email."},
+ {"person_unread_email_count", []interface{}{2, bobStruct}, "Bob has 2 unread emails."},
+
+ {"person_unread_email_count_timeframe", []interface{}{3, map[string]interface{}{
+ "Person": "Bob",
+ "Timeframe": "0 days",
+ }}, "Bob has 3 unread emails in the past 0 days."},
+ {"person_unread_email_count_timeframe", []interface{}{3, map[string]interface{}{
+ "Person": "Bob",
+ "Timeframe": "1 day",
+ }}, "Bob has 3 unread emails in the past 1 day."},
+ {"person_unread_email_count_timeframe", []interface{}{3, map[string]interface{}{
+ "Person": "Bob",
+ "Timeframe": "2 days",
+ }}, "Bob has 3 unread emails in the past 2 days."},
+}
+
+func testFile(t *testing.T, path string) {
+ b := bundle.New()
+ b.MustLoadTranslationFile(path)
+
+ T, err := b.Tfunc("en-US")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ for _, tc := range testCases {
+ var args []interface{}
+ if _, ok := tc.arg.([]interface{}); ok {
+ args = tc.arg.([]interface{})
+ } else {
+ args = []interface{}{tc.arg}
+ }
+
+ got := T(tc.id, args...)
+ if got != tc.want {
+ t.Error("got: %v; want: %v", got, tc.want)
+ }
+ }
+}
+
+func TestJSONParse(t *testing.T) {
+ testFile(t, "../goi18n/testdata/expected/en-us.all.json")
+}
+
+func TestYAMLParse(t *testing.T) {
+ testFile(t, "../goi18n/testdata/en-us.yaml")
+}
+
+func TestJSONFlatParse(t *testing.T) {
+ testFile(t, "../goi18n/testdata/en-us.flat.json")
+}
+
+func TestYAMLFlatParse(t *testing.T) {
+ testFile(t, "../goi18n/testdata/en-us.flat.yaml")
+}
+
+func TestTOMLFlatParse(t *testing.T) {
+ testFile(t, "../goi18n/testdata/en-us.flat.toml")
+}
diff --git a/vendor/github.com/pelletier/go-toml/marshal.go b/vendor/github.com/pelletier/go-toml/marshal.go
index 4301a4513..a1d701046 100644
--- a/vendor/github.com/pelletier/go-toml/marshal.go
+++ b/vendor/github.com/pelletier/go-toml/marshal.go
@@ -33,6 +33,7 @@ type tomlOpts struct {
}
var timeType = reflect.TypeOf(time.Time{})
+var marshalerType = reflect.TypeOf(new(Marshaler)).Elem()
// Check if the given marshall type maps to a TomlTree primitive
func isPrimitive(mtype reflect.Type) bool {
@@ -50,7 +51,7 @@ func isPrimitive(mtype reflect.Type) bool {
case reflect.String:
return true
case reflect.Struct:
- return mtype == timeType
+ return mtype == timeType || isCustomMarshaler(mtype)
default:
return false
}
@@ -90,6 +91,20 @@ func isTree(mtype reflect.Type) bool {
}
}
+func isCustomMarshaler(mtype reflect.Type) bool {
+ return mtype.Implements(marshalerType)
+}
+
+func callCustomMarshaler(mval reflect.Value) ([]byte, error) {
+ return mval.Interface().(Marshaler).MarshalTOML()
+}
+
+// Marshaler is the interface implemented by types that
+// can marshal themselves into valid TOML.
+type Marshaler interface {
+ MarshalTOML() ([]byte, error)
+}
+
/*
Marshal returns the TOML encoding of v. Behavior is similar to the Go json
encoder, except that there is no concept of a Marshaler interface or MarshalTOML
@@ -106,6 +121,9 @@ func Marshal(v interface{}) ([]byte, error) {
return []byte{}, errors.New("Only a struct can be marshaled to TOML")
}
sval := reflect.ValueOf(v)
+ if isCustomMarshaler(mtype) {
+ return callCustomMarshaler(sval)
+ }
t, err := valueToTree(mtype, sval)
if err != nil {
return []byte{}, err
@@ -178,6 +196,8 @@ func valueToToml(mtype reflect.Type, mval reflect.Value) (interface{}, error) {
return valueToToml(mtype.Elem(), mval.Elem())
}
switch {
+ case isCustomMarshaler(mtype):
+ return callCustomMarshaler(mval)
case isTree(mtype):
return valueToTree(mtype, mval)
case isTreeSlice(mtype):
diff --git a/vendor/github.com/pelletier/go-toml/marshal_test.go b/vendor/github.com/pelletier/go-toml/marshal_test.go
index c8dee94de..891222e9b 100644
--- a/vendor/github.com/pelletier/go-toml/marshal_test.go
+++ b/vendor/github.com/pelletier/go-toml/marshal_test.go
@@ -3,6 +3,7 @@ package toml
import (
"bytes"
"encoding/json"
+ "fmt"
"io/ioutil"
"reflect"
"testing"
@@ -533,3 +534,50 @@ func TestNestedUnmarshal(t *testing.T) {
t.Errorf("Bad nested unmarshal: expected %v, got %v", expected, result)
}
}
+
+type customMarshalerParent struct {
+ Self customMarshaler `toml:"me"`
+ Friends []customMarshaler `toml:"friends"`
+}
+
+type customMarshaler struct {
+ FirsName string
+ LastName string
+}
+
+func (c customMarshaler) MarshalTOML() ([]byte, error) {
+ fullName := fmt.Sprintf("%s %s", c.FirsName, c.LastName)
+ return []byte(fullName), nil
+}
+
+var customMarshalerData = customMarshaler{FirsName: "Sally", LastName: "Fields"}
+var customMarshalerToml = []byte(`Sally Fields`)
+var nestedCustomMarshalerData = customMarshalerParent{
+ Self: customMarshaler{FirsName: "Maiku", LastName: "Suteda"},
+ Friends: []customMarshaler{customMarshalerData},
+}
+var nestedCustomMarshalerToml = []byte(`friends = ["Sally Fields"]
+me = "Maiku Suteda"
+`)
+
+func TestCustomMarshaler(t *testing.T) {
+ result, err := Marshal(customMarshalerData)
+ if err != nil {
+ t.Fatal(err)
+ }
+ expected := customMarshalerToml
+ if !bytes.Equal(result, expected) {
+ t.Errorf("Bad custom marshaler: expected\n-----\n%s\n-----\ngot\n-----\n%s\n-----\n", expected, result)
+ }
+}
+
+func TestNestedCustomMarshaler(t *testing.T) {
+ result, err := Marshal(nestedCustomMarshalerData)
+ if err != nil {
+ t.Fatal(err)
+ }
+ expected := nestedCustomMarshalerToml
+ if !bytes.Equal(result, expected) {
+ t.Errorf("Bad nested custom marshaler: expected\n-----\n%s\n-----\ngot\n-----\n%s\n-----\n", expected, result)
+ }
+}
diff --git a/vendor/github.com/pelletier/go-toml/tomltree_write.go b/vendor/github.com/pelletier/go-toml/tomltree_write.go
index 89c3c4229..6a7fa1745 100644
--- a/vendor/github.com/pelletier/go-toml/tomltree_write.go
+++ b/vendor/github.com/pelletier/go-toml/tomltree_write.go
@@ -52,6 +52,9 @@ func tomlValueStringRepresentation(v interface{}) (string, error) {
return strconv.FormatFloat(value, 'f', -1, 32), nil
case string:
return "\"" + encodeTomlString(value) + "\"", nil
+ case []byte:
+ b, _ := v.([]byte)
+ return tomlValueStringRepresentation(string(b))
case bool:
if value {
return "true", nil
diff --git a/vendor/github.com/prometheus/common/.travis.yml b/vendor/github.com/prometheus/common/.travis.yml
index 69b2431c8..2fe8e9ad7 100644
--- a/vendor/github.com/prometheus/common/.travis.yml
+++ b/vendor/github.com/prometheus/common/.travis.yml
@@ -2,6 +2,5 @@ sudo: false
language: go
go:
- - 1.5.4
- - 1.6.2
+ - 1.7.5
- tip
diff --git a/vendor/github.com/prometheus/common/route/route.go b/vendor/github.com/prometheus/common/route/route.go
index 1e5638ed9..bb4688173 100644
--- a/vendor/github.com/prometheus/common/route/route.go
+++ b/vendor/github.com/prometheus/common/route/route.go
@@ -1,26 +1,12 @@
package route
import (
- "fmt"
"net/http"
- "sync"
"github.com/julienschmidt/httprouter"
"golang.org/x/net/context"
)
-var (
- mtx = sync.RWMutex{}
- ctxts = map[*http.Request]context.Context{}
-)
-
-// Context returns the context for the request.
-func Context(r *http.Request) context.Context {
- mtx.RLock()
- defer mtx.RUnlock()
- return ctxts[r]
-}
-
type param string
// Param returns param p for the context.
@@ -33,59 +19,35 @@ func WithParam(ctx context.Context, p, v string) context.Context {
return context.WithValue(ctx, param(p), v)
}
-// ContextFunc returns a new context for a request.
-type ContextFunc func(r *http.Request) (context.Context, error)
-
// Router wraps httprouter.Router and adds support for prefixed sub-routers
// and per-request context injections.
type Router struct {
rtr *httprouter.Router
prefix string
- ctxFn ContextFunc
}
// New returns a new Router.
-func New(ctxFn ContextFunc) *Router {
- if ctxFn == nil {
- ctxFn = func(r *http.Request) (context.Context, error) {
- return context.Background(), nil
- }
- }
+func New() *Router {
return &Router{
- rtr: httprouter.New(),
- ctxFn: ctxFn,
+ rtr: httprouter.New(),
}
}
// WithPrefix returns a router that prefixes all registered routes with prefix.
func (r *Router) WithPrefix(prefix string) *Router {
- return &Router{rtr: r.rtr, prefix: r.prefix + prefix, ctxFn: r.ctxFn}
+ return &Router{rtr: r.rtr, prefix: r.prefix + prefix}
}
// handle turns a HandlerFunc into an httprouter.Handle.
func (r *Router) handle(h http.HandlerFunc) httprouter.Handle {
return func(w http.ResponseWriter, req *http.Request, params httprouter.Params) {
- reqCtx, err := r.ctxFn(req)
- if err != nil {
- http.Error(w, fmt.Sprintf("Error creating request context: %v", err), http.StatusBadRequest)
- return
- }
- ctx, cancel := context.WithCancel(reqCtx)
+ ctx, cancel := context.WithCancel(req.Context())
defer cancel()
for _, p := range params {
ctx = context.WithValue(ctx, param(p.Key), p.Value)
}
-
- mtx.Lock()
- ctxts[req] = ctx
- mtx.Unlock()
-
- h(w, req)
-
- mtx.Lock()
- delete(ctxts, req)
- mtx.Unlock()
+ h(w, req.WithContext(ctx))
}
}
@@ -132,7 +94,7 @@ func FileServe(dir string) http.HandlerFunc {
fs := http.FileServer(http.Dir(dir))
return func(w http.ResponseWriter, r *http.Request) {
- r.URL.Path = Param(Context(r), "filepath")
+ r.URL.Path = Param(r.Context(), "filepath")
fs.ServeHTTP(w, r)
}
}
diff --git a/vendor/github.com/prometheus/common/route/route_test.go b/vendor/github.com/prometheus/common/route/route_test.go
index e7b1cba33..a9bb20996 100644
--- a/vendor/github.com/prometheus/common/route/route_test.go
+++ b/vendor/github.com/prometheus/common/route/route_test.go
@@ -1,16 +1,13 @@
package route
import (
- "fmt"
"net/http"
"net/http/httptest"
"testing"
-
- "golang.org/x/net/context"
)
func TestRedirect(t *testing.T) {
- router := New(nil).WithPrefix("/test/prefix")
+ router := New().WithPrefix("/test/prefix")
w := httptest.NewRecorder()
r, err := http.NewRequest("GET", "http://localhost:9090/foo", nil)
if err != nil {
@@ -29,47 +26,19 @@ func TestRedirect(t *testing.T) {
}
}
-func TestContextFunc(t *testing.T) {
- router := New(func(r *http.Request) (context.Context, error) {
- return context.WithValue(context.Background(), "testkey", "testvalue"), nil
- })
-
- router.Get("/test", func(w http.ResponseWriter, r *http.Request) {
- want := "testvalue"
- got := Context(r).Value("testkey")
+func TestContext(t *testing.T) {
+ router := New()
+ router.Get("/test/:foo/", func(w http.ResponseWriter, r *http.Request) {
+ want := "bar"
+ got := Param(r.Context(), "foo")
if want != got {
t.Fatalf("Unexpected context value: want %q, got %q", want, got)
}
})
- r, err := http.NewRequest("GET", "http://localhost:9090/test", nil)
+ r, err := http.NewRequest("GET", "http://localhost:9090/test/bar/", nil)
if err != nil {
t.Fatalf("Error building test request: %s", err)
}
router.ServeHTTP(nil, r)
}
-
-func TestContextFnError(t *testing.T) {
- router := New(func(r *http.Request) (context.Context, error) {
- return context.Background(), fmt.Errorf("test error")
- })
-
- router.Get("/test", func(w http.ResponseWriter, r *http.Request) {})
-
- r, err := http.NewRequest("GET", "http://localhost:9090/test", nil)
- if err != nil {
- t.Fatalf("Error building test request: %s", err)
- }
- w := httptest.NewRecorder()
- router.ServeHTTP(w, r)
-
- if w.Code != http.StatusBadRequest {
- t.Fatalf("Unexpected response status: got %q, want %q", w.Code, http.StatusBadRequest)
- }
-
- want := "Error creating request context: test error\n"
- got := w.Body.String()
- if want != got {
- t.Fatalf("Unexpected response body: got %q, want %q", got, want)
- }
-}
diff --git a/vendor/github.com/prometheus/procfs/sysfs/doc.go b/vendor/github.com/prometheus/procfs/sysfs/doc.go
new file mode 100644
index 000000000..9a6c244e9
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/sysfs/doc.go
@@ -0,0 +1,16 @@
+// Copyright 2017 The Prometheus Authors
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Package sysfs provides functions to retrieve system and kernel metrics
+// from the pseudo-filesystem sys.
+package sysfs
diff --git a/vendor/github.com/prometheus/procfs/sysfs/fixtures/fs/xfs/sda1/stats/stats b/vendor/github.com/prometheus/procfs/sysfs/fixtures/fs/xfs/sda1/stats/stats
new file mode 100644
index 000000000..0db7520bf
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/sysfs/fixtures/fs/xfs/sda1/stats/stats
@@ -0,0 +1 @@
+extent_alloc 1 0 0 0
diff --git a/vendor/github.com/prometheus/procfs/sysfs/fixtures/fs/xfs/sdb1/stats/stats b/vendor/github.com/prometheus/procfs/sysfs/fixtures/fs/xfs/sdb1/stats/stats
new file mode 100644
index 000000000..85a038402
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/sysfs/fixtures/fs/xfs/sdb1/stats/stats
@@ -0,0 +1 @@
+extent_alloc 2 0 0 0
diff --git a/vendor/github.com/prometheus/procfs/sysfs/fs.go b/vendor/github.com/prometheus/procfs/sysfs/fs.go
new file mode 100644
index 000000000..8e8380083
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/sysfs/fs.go
@@ -0,0 +1,82 @@
+// Copyright 2017 The Prometheus Authors
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package sysfs
+
+import (
+ "fmt"
+ "os"
+ "path/filepath"
+
+ "github.com/prometheus/procfs/xfs"
+)
+
+// FS represents the pseudo-filesystem sys, which provides an interface to
+// kernel data structures.
+type FS string
+
+// DefaultMountPoint is the common mount point of the sys filesystem.
+const DefaultMountPoint = "/sys"
+
+// NewFS returns a new FS mounted under the given mountPoint. It will error
+// if the mount point can't be read.
+func NewFS(mountPoint string) (FS, error) {
+ info, err := os.Stat(mountPoint)
+ if err != nil {
+ return "", fmt.Errorf("could not read %s: %s", mountPoint, err)
+ }
+ if !info.IsDir() {
+ return "", fmt.Errorf("mount point %s is not a directory", mountPoint)
+ }
+
+ return FS(mountPoint), nil
+}
+
+// Path returns the path of the given subsystem relative to the sys root.
+func (fs FS) Path(p ...string) string {
+ return filepath.Join(append([]string{string(fs)}, p...)...)
+}
+
+// XFSStats retrieves XFS filesystem runtime statistics for each mounted XFS
+// filesystem. Only available on kernel 4.4+. On older kernels, an empty
+// slice of *xfs.Stats will be returned.
+func (fs FS) XFSStats() ([]*xfs.Stats, error) {
+ matches, err := filepath.Glob(fs.Path("fs/xfs/*/stats/stats"))
+ if err != nil {
+ return nil, err
+ }
+
+ stats := make([]*xfs.Stats, 0, len(matches))
+ for _, m := range matches {
+ f, err := os.Open(m)
+ if err != nil {
+ return nil, err
+ }
+
+ // "*" used in glob above indicates the name of the filesystem.
+ name := filepath.Base(filepath.Dir(filepath.Dir(m)))
+
+ // File must be closed after parsing, regardless of success or
+ // failure. Defer is not used because of the loop.
+ s, err := xfs.ParseStats(f)
+ _ = f.Close()
+ if err != nil {
+ return nil, err
+ }
+
+ s.Name = name
+ stats = append(stats, s)
+ }
+
+ return stats, nil
+}
diff --git a/vendor/github.com/prometheus/procfs/sysfs/fs_test.go b/vendor/github.com/prometheus/procfs/sysfs/fs_test.go
new file mode 100644
index 000000000..d7f2b736b
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/sysfs/fs_test.go
@@ -0,0 +1,66 @@
+// Copyright 2017 The Prometheus Authors
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package sysfs
+
+import "testing"
+
+func TestNewFS(t *testing.T) {
+ if _, err := NewFS("foobar"); err == nil {
+ t.Error("want NewFS to fail for non-existing mount point")
+ }
+
+ if _, err := NewFS("doc.go"); err == nil {
+ t.Error("want NewFS to fail if mount point is not a directory")
+ }
+}
+
+func TestFSXFSStats(t *testing.T) {
+ stats, err := FS("fixtures").XFSStats()
+ if err != nil {
+ t.Fatalf("failed to parse XFS stats: %v", err)
+ }
+
+ tests := []struct {
+ name string
+ allocated uint32
+ }{
+ {
+ name: "sda1",
+ allocated: 1,
+ },
+ {
+ name: "sdb1",
+ allocated: 2,
+ },
+ }
+
+ const expect = 2
+
+ if l := len(stats); l != expect {
+ t.Fatalf("unexpected number of XFS stats: %d", l)
+ }
+ if l := len(tests); l != expect {
+ t.Fatalf("unexpected number of tests: %d", l)
+ }
+
+ for i, tt := range tests {
+ if want, got := tt.name, stats[i].Name; want != got {
+ t.Errorf("unexpected stats name:\nwant: %q\nhave: %q", want, got)
+ }
+
+ if want, got := tt.allocated, stats[i].ExtentAllocation.ExtentsAllocated; want != got {
+ t.Errorf("unexpected extents allocated:\nwant: %d\nhave: %d", want, got)
+ }
+ }
+}
diff --git a/vendor/github.com/prometheus/procfs/xfs/parse.go b/vendor/github.com/prometheus/procfs/xfs/parse.go
index d1285fa6c..c8f6279f3 100644
--- a/vendor/github.com/prometheus/procfs/xfs/parse.go
+++ b/vendor/github.com/prometheus/procfs/xfs/parse.go
@@ -17,7 +17,6 @@ import (
"bufio"
"fmt"
"io"
- "log"
"strconv"
"strings"
)
@@ -273,7 +272,6 @@ func vnodeStats(us []uint32) (VnodeStats, error) {
// stats versions. Therefore, 7 or 8 elements may appear in
// this slice.
l := len(us)
- log.Println(l)
if l != 7 && l != 8 {
return VnodeStats{}, fmt.Errorf("incorrect number of values for XFS vnode stats: %d", l)
}
diff --git a/vendor/github.com/prometheus/procfs/xfs/parse_test.go b/vendor/github.com/prometheus/procfs/xfs/parse_test.go
index 11ddb7425..2e946c2c5 100644
--- a/vendor/github.com/prometheus/procfs/xfs/parse_test.go
+++ b/vendor/github.com/prometheus/procfs/xfs/parse_test.go
@@ -14,7 +14,6 @@
package xfs_test
import (
- "log"
"reflect"
"strings"
"testing"
@@ -416,9 +415,7 @@ func TestParseStats(t *testing.T) {
},
}
- for i, tt := range tests {
- t.Logf("[%02d] test %q", i, tt.name)
-
+ for _, tt := range tests {
var (
stats *xfs.Stats
err error
@@ -439,7 +436,6 @@ func TestParseStats(t *testing.T) {
}
if want, have := tt.stats, stats; !reflect.DeepEqual(want, have) {
- log.Printf("stats: %#v", have)
t.Errorf("unexpected XFS stats:\nwant:\n%v\nhave:\n%v", want, have)
}
}
diff --git a/vendor/github.com/prometheus/procfs/xfs/xfs.go b/vendor/github.com/prometheus/procfs/xfs/xfs.go
index ed77d907a..d86794b7c 100644
--- a/vendor/github.com/prometheus/procfs/xfs/xfs.go
+++ b/vendor/github.com/prometheus/procfs/xfs/xfs.go
@@ -22,6 +22,11 @@ package xfs
// kernel source. Most counters are uint32s (same data types used in
// xfs_stats.h), but some of the "extended precision stats" are uint64s.
type Stats struct {
+ // The name of the filesystem used to source these statistics.
+ // If empty, this indicates aggregated statistics for all XFS
+ // filesystems on the host.
+ Name string
+
ExtentAllocation ExtentAllocationStats
AllocationBTree BTreeStats
BlockMapping BlockMappingStats
diff --git a/vendor/github.com/spf13/cast/cast.go b/vendor/github.com/spf13/cast/cast.go
index dc504b432..8b8c208be 100644
--- a/vendor/github.com/spf13/cast/cast.go
+++ b/vendor/github.com/spf13/cast/cast.go
@@ -151,3 +151,9 @@ func ToIntSlice(i interface{}) []int {
v, _ := ToIntSliceE(i)
return v
}
+
+// ToDurationSlice casts an interface to a []time.Duration type.
+func ToDurationSlice(i interface{}) []time.Duration {
+ v, _ := ToDurationSliceE(i)
+ return v
+}
diff --git a/vendor/github.com/spf13/cast/cast_test.go b/vendor/github.com/spf13/cast/cast_test.go
index 2bb8c5f54..404fe7680 100644
--- a/vendor/github.com/spf13/cast/cast_test.go
+++ b/vendor/github.com/spf13/cast/cast_test.go
@@ -975,6 +975,38 @@ func TestToStringSliceE(t *testing.T) {
}
}
+func TestToDurationSliceE(t *testing.T) {
+ tests := []struct {
+ input interface{}
+ expect []time.Duration
+ iserr bool
+ }{
+ {[]string{"1s", "1m"}, []time.Duration{time.Second, time.Minute}, false},
+ {[]int{1, 2}, []time.Duration{1, 2}, false},
+ {[]interface{}{1, 3}, []time.Duration{1, 3}, false},
+ // errors
+ {nil, nil, true},
+ {testing.T{}, nil, true},
+ }
+
+ for i, test := range tests {
+ errmsg := fmt.Sprintf("i = %d", i) // assert helper message
+
+ v, err := ToDurationSliceE(test.input)
+ if test.iserr {
+ assert.Error(t, err, errmsg)
+ continue
+ }
+
+ assert.NoError(t, err, errmsg)
+ assert.Equal(t, test.expect, v, errmsg)
+
+ // Non-E test
+ v = ToDurationSlice(test.input)
+ assert.Equal(t, test.expect, v, errmsg)
+ }
+}
+
func TestToBoolE(t *testing.T) {
tests := []struct {
input interface{}
diff --git a/vendor/github.com/spf13/cast/caste.go b/vendor/github.com/spf13/cast/caste.go
index 4e75f64ba..81511fe52 100644
--- a/vendor/github.com/spf13/cast/caste.go
+++ b/vendor/github.com/spf13/cast/caste.go
@@ -1077,6 +1077,35 @@ func ToIntSliceE(i interface{}) ([]int, error) {
}
}
+// ToDurationSliceE casts an interface to a []time.Duration type.
+func ToDurationSliceE(i interface{}) ([]time.Duration, error) {
+ if i == nil {
+ return []time.Duration{}, fmt.Errorf("unable to cast %#v of type %T to []time.Duration", i, i)
+ }
+
+ switch v := i.(type) {
+ case []time.Duration:
+ return v, nil
+ }
+
+ kind := reflect.TypeOf(i).Kind()
+ switch kind {
+ case reflect.Slice, reflect.Array:
+ s := reflect.ValueOf(i)
+ a := make([]time.Duration, s.Len())
+ for j := 0; j < s.Len(); j++ {
+ val, err := ToDurationE(s.Index(j).Interface())
+ if err != nil {
+ return []time.Duration{}, fmt.Errorf("unable to cast %#v of type %T to []time.Duration", i, i)
+ }
+ a[j] = val
+ }
+ return a, nil
+ default:
+ return []time.Duration{}, fmt.Errorf("unable to cast %#v of type %T to []time.Duration", i, i)
+ }
+}
+
// StringToDate attempts to parse a string into a time.Time type using a
// predefined list of formats. If no suitable format is found, an error is
// returned.
diff --git a/vendor/github.com/spf13/cobra/README.md b/vendor/github.com/spf13/cobra/README.md
index 2de984012..7d4d68b50 100644
--- a/vendor/github.com/spf13/cobra/README.md
+++ b/vendor/github.com/spf13/cobra/README.md
@@ -16,14 +16,14 @@ Many of the most widely used Go projects are built using Cobra including:
* [CockroachDB](http://www.cockroachlabs.com/)
* [Bleve](http://www.blevesearch.com/)
* [ProjectAtomic (enterprise)](http://www.projectatomic.io/)
-* [Parse (CLI)](https://parse.com/)
* [GiantSwarm's swarm](https://github.com/giantswarm/cli)
* [Nanobox](https://github.com/nanobox-io/nanobox)/[Nanopack](https://github.com/nanopack)
+* [rclone](http://rclone.org/)
[![Build Status](https://travis-ci.org/spf13/cobra.svg "Travis CI status")](https://travis-ci.org/spf13/cobra)
[![CircleCI status](https://circleci.com/gh/spf13/cobra.png?circle-token=:circle-token "CircleCI status")](https://circleci.com/gh/spf13/cobra)
-[![GoDoc](https://godoc.org/github.com/spf13/cobra?status.svg)](https://godoc.org/github.com/spf13/cobra)
+[![GoDoc](https://godoc.org/github.com/spf13/cobra?status.svg)](https://godoc.org/github.com/spf13/cobra)
![cobra](https://cloud.githubusercontent.com/assets/173412/10911369/84832a8e-8212-11e5-9f82-cc96660a4794.gif)
@@ -168,7 +168,7 @@ import (
func main() {
if err := cmd.RootCmd.Execute(); err != nil {
fmt.Println(err)
- os.Exit(-1)
+ os.Exit(1)
}
}
```
@@ -180,9 +180,9 @@ commands you want. It's the easiest way to incorporate Cobra into your applicati
In order to use the cobra command, compile it using the following command:
- > go install github.com/spf13/cobra/cobra
+ > go get github.com/spf13/cobra/cobra
-This will create the cobra executable under your go path bin directory!
+This will create the cobra executable under your `$GOPATH/bin` directory.
### cobra init
@@ -257,7 +257,7 @@ license:
This is my license. There are many like it, but this one is mine.
My license is my best friend. It is my life. I must master it as I must
- master my life.
+ master my life.
```
## Manually implementing Cobra
@@ -329,7 +329,7 @@ import (
func main() {
if err := cmd.RootCmd.Execute(); err != nil {
fmt.Println(err)
- os.Exit(-1)
+ os.Exit(1)
}
}
```
diff --git a/vendor/github.com/spf13/cobra/bash_completions.go b/vendor/github.com/spf13/cobra/bash_completions.go
index 8820ba8fc..a0d040279 100644
--- a/vendor/github.com/spf13/cobra/bash_completions.go
+++ b/vendor/github.com/spf13/cobra/bash_completions.go
@@ -88,8 +88,8 @@ __handle_reply()
local index flag
flag="${cur%%=*}"
__index_of_word "${flag}" "${flags_with_completion[@]}"
+ COMPREPLY=()
if [[ ${index} -ge 0 ]]; then
- COMPREPLY=()
PREFIX=""
cur="${cur#*=}"
${flags_completion[${index}]}
@@ -225,7 +225,7 @@ __handle_command()
fi
c=$((c+1))
__debug "${FUNCNAME[0]}: looking for ${next_command}"
- declare -F $next_command >/dev/null && $next_command
+ declare -F "$next_command" >/dev/null && $next_command
}
__handle_word()
diff --git a/vendor/github.com/spf13/cobra/cobra.go b/vendor/github.com/spf13/cobra/cobra.go
index 9605b984c..25473a706 100644
--- a/vendor/github.com/spf13/cobra/cobra.go
+++ b/vendor/github.com/spf13/cobra/cobra.go
@@ -52,7 +52,7 @@ func AddTemplateFunc(name string, tmplFunc interface{}) {
templateFuncs[name] = tmplFunc
}
-// AddTemplateFuncs adds multiple template functions availalble to Usage and
+// AddTemplateFuncs adds multiple template functions that are available to Usage and
// Help template generation.
func AddTemplateFuncs(tmplFuncs template.FuncMap) {
for k, v := range tmplFuncs {
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/init.go b/vendor/github.com/spf13/cobra/cobra/cmd/init.go
index 13792f12f..b77c98645 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/init.go
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/init.go
@@ -210,8 +210,8 @@ func initConfig() {
}
viper.SetConfigName(".{{ .appName }}") // name of config file (without extension)
- viper.AddConfigPath("$HOME") // adding home directory as first search path
- viper.AutomaticEnv() // read in environment variables that match
+ viper.AddConfigPath(os.Getenv("HOME")) // adding home directory as first search path
+ viper.AutomaticEnv() // read in environment variables that match
// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_apache_2.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_apache_2.go
new file mode 100644
index 000000000..878e1d936
--- /dev/null
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/license_apache_2.go
@@ -0,0 +1,238 @@
+// Copyright © 2015 Steve Francia <spf@spf13.com>.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Parts inspired by https://github.com/ryanuber/go-license
+
+package cmd
+
+func initApache2() {
+ Licenses["apache"] = License{
+ Name: "Apache 2.0",
+ PossibleMatches: []string{"apache", "apache20", "apache 2.0", "apache2.0", "apache-2.0"},
+ Header: `
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.`,
+ Text: `
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+`,
+ }
+}
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_2.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_2.go
new file mode 100644
index 000000000..26bc775a9
--- /dev/null
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_2.go
@@ -0,0 +1,71 @@
+// Copyright © 2015 Steve Francia <spf@spf13.com>.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Parts inspired by https://github.com/ryanuber/go-license
+
+package cmd
+
+func initBsdClause2() {
+ Licenses["freebsd"] = License{
+ Name: "Simplified BSD License",
+ PossibleMatches: []string{"freebsd", "simpbsd", "simple bsd", "2 clause bsd"},
+ Header: `
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.`,
+ Text: `{{ .copyright }}
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+`,
+ }
+}
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_3.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_3.go
new file mode 100644
index 000000000..062c11528
--- /dev/null
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/license_bsd_clause_3.go
@@ -0,0 +1,79 @@
+// Copyright © 2015 Steve Francia <spf@spf13.com>.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Parts inspired by https://github.com/ryanuber/go-license
+
+package cmd
+
+func initBsdClause3() {
+ Licenses["bsd"] = License{
+ Name: "NewBSD",
+ PossibleMatches: []string{"bsd", "newbsd", "3 clause bsd"},
+ Header: `
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.`,
+ Text: `{{ .copyright }}
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+`,
+ }
+}
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_2.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_2.go
new file mode 100644
index 000000000..b361dd734
--- /dev/null
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_2.go
@@ -0,0 +1,318 @@
+// Copyright © 2015 Steve Francia <spf@spf13.com>.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Parts inspired by https://github.com/ryanuber/go-license
+
+package cmd
+
+func initGpl2() {
+ Licenses["gpl2"] = License{
+ Name: "GNU General Public License 2.0",
+ PossibleMatches: []string{"gpl2", "gnu gpl2"},
+ Header: `{{ .copyright }}
+
+ {{ .appName }} is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ {{ .appName }} is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with {{ .appName }}. If not, see <http://www.gnu.org/licenses/>.`,
+ Text: ` GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+`,
+ }
+}
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_3.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_3.go
new file mode 100644
index 000000000..5810276b2
--- /dev/null
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/license_gpl_3.go
@@ -0,0 +1,661 @@
+// Copyright © 2015 Steve Francia <spf@spf13.com>.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Parts inspired by https://github.com/ryanuber/go-license
+
+package cmd
+
+func initGpl3() {
+ Licenses["gpl3"] = License{
+ Name: "GNU General Public License 3.0",
+ PossibleMatches: []string{"gpl3", "gpl", "gnu gpl3", "gnu gpl"},
+ Header: `
+This file is part of {{ .appName }}.
+
+{{ .appName }} is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+{{ .appName }} is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with {{ .appName }}. If not, see <http://www.gnu.org/licenses/>.
+ `,
+ Text: ` GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+`,
+ }
+}
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/license_mit.go b/vendor/github.com/spf13/cobra/cobra/cmd/license_mit.go
new file mode 100644
index 000000000..4ff5a4cdf
--- /dev/null
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/license_mit.go
@@ -0,0 +1,63 @@
+// Copyright © 2015 Steve Francia <spf@spf13.com>.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Parts inspired by https://github.com/ryanuber/go-license
+
+package cmd
+
+func initMit() {
+ Licenses["mit"] = License{
+ Name: "Mit",
+ PossibleMatches: []string{"mit"},
+ Header: `
+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.`,
+ Text: `The MIT License (MIT)
+
+{{ .copyright }}
+
+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/spf13/cobra/cobra/cmd/licenses.go b/vendor/github.com/spf13/cobra/cobra/cmd/licenses.go
index b4c742c37..5b3cb7293 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/licenses.go
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/licenses.go
@@ -52,1326 +52,17 @@ func init() {
// Allows a user to use config for a custom license.
Licenses["custom"] = License{"Custom", []string{}, "", ""}
- Licenses["apache"] = License{
- Name: "Apache 2.0",
- PossibleMatches: []string{"apache", "apache20", "apache 2.0", "apache2.0", "apache-2.0"},
- Header: `
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.`,
- Text: `
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-`,
- }
-
- Licenses["mit"] = License{
- Name: "Mit",
- PossibleMatches: []string{"mit"},
- Header: `
-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.`,
- Text: `The MIT License (MIT)
-
-{{ .copyright }}
-
-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.
-`,
- }
-
- Licenses["bsd"] = License{
- Name: "NewBSD",
- PossibleMatches: []string{"bsd", "newbsd", "3 clause bsd"},
- Header: `
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.`,
- Text: `{{ .copyright }}
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-`,
- }
-
- Licenses["freebsd"] = License{
- Name: "Simplified BSD License",
- PossibleMatches: []string{"freebsd", "simpbsd", "simple bsd", "2 clause bsd"},
- Header: `
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.`,
- Text: `{{ .copyright }}
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-`,
- }
-
- Licenses["gpl2"] = License{
- Name: "GNU General Public License 2.0",
- PossibleMatches: []string{"gpl2", "gnu gpl2"},
- Header: `{{ .copyright }}
-
- {{ .appName }} is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- {{ .appName }} is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with {{ .appName }}. If not, see <http://www.gnu.org/licenses/>.`,
- Text: ` GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
+ initApache2()
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
+ initMit()
- NO WARRANTY
+ initBsdClause3()
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
+ initBsdClause2()
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
+ initGpl2()
- END OF TERMS AND CONDITIONS
-`,
- }
- Licenses["gpl3"] = License{
- Name: "GNU General Public License 3.0",
- PossibleMatches: []string{"gpl3", "gpl", "gnu gpl3", "gnu gpl"},
- Header: `
-This file is part of {{ .appName }}.
-
-{{ .appName }} is free software: you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-{{ .appName }} is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License
-along with {{ .appName }}. If not, see <http://www.gnu.org/licenses/>.
- `,
- Text: ` GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-`,
- }
+ initGpl3()
// Licenses["apache20"] = License{
// Name: "Apache 2.0",
diff --git a/vendor/github.com/spf13/cobra/cobra/cmd/root.go b/vendor/github.com/spf13/cobra/cobra/cmd/root.go
index 065c8bf40..32386ace4 100644
--- a/vendor/github.com/spf13/cobra/cobra/cmd/root.go
+++ b/vendor/github.com/spf13/cobra/cobra/cmd/root.go
@@ -61,9 +61,9 @@ func initConfig() {
viper.SetConfigFile(cfgFile)
}
- viper.SetConfigName(".cobra") // name of config file (without extension)
- viper.AddConfigPath("$HOME") // adding home directory as first search path
- viper.AutomaticEnv() // read in environment variables that match
+ viper.SetConfigName(".cobra") // name of config file (without extension)
+ viper.AddConfigPath(os.Getenv("HOME")) // adding home directory as first search path
+ viper.AutomaticEnv() // read in environment variables that match
// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {
diff --git a/vendor/github.com/spf13/cobra/cobra_test.go b/vendor/github.com/spf13/cobra/cobra_test.go
index 46887fd7d..d6593a539 100644
--- a/vendor/github.com/spf13/cobra/cobra_test.go
+++ b/vendor/github.com/spf13/cobra/cobra_test.go
@@ -3,7 +3,6 @@ package cobra
import (
"bytes"
"fmt"
- "os"
"reflect"
"runtime"
"strings"
@@ -13,9 +12,6 @@ import (
"github.com/spf13/pflag"
)
-var _ = fmt.Println
-var _ = os.Stderr
-
var tp, te, tt, t1, tr []string
var rootPersPre, echoPre, echoPersPre, timesPersPre []string
var flagb1, flagb2, flagb3, flagbr, flagbp bool
@@ -166,20 +162,22 @@ func flagInit() {
cmdRootWithRun.ResetFlags()
cmdSubNoRun.ResetFlags()
cmdCustomFlags.ResetFlags()
+ cmdVersion1.ResetFlags()
+ cmdVersion2.ResetFlags()
+
cmdRootNoRun.PersistentFlags().StringVarP(&flags2a, "strtwo", "t", "two", strtwoParentHelp)
- cmdEcho.Flags().IntVarP(&flagi1, "intone", "i", 123, "help message for flag intone")
- cmdTimes.Flags().IntVarP(&flagi2, "inttwo", "j", 234, "help message for flag inttwo")
- cmdPrint.Flags().IntVarP(&flagi3, "intthree", "i", 345, "help message for flag intthree")
cmdCustomFlags.Flags().IntVar(&flagi4, "intfour", 456, "help message for flag intfour")
- cmdEcho.PersistentFlags().StringVarP(&flags1, "strone", "s", "one", "help message for flag strone")
- cmdEcho.PersistentFlags().BoolVarP(&flagbp, "persistentbool", "p", false, "help message for flag persistentbool")
- cmdTimes.PersistentFlags().StringVarP(&flags2b, "strtwo", "t", "2", strtwoChildHelp)
- cmdPrint.PersistentFlags().StringVarP(&flags3, "strthree", "s", "three", "help message for flag strthree")
cmdEcho.Flags().BoolVarP(&flagb1, "boolone", "b", true, "help message for flag boolone")
+ cmdEcho.Flags().IntVarP(&flagi1, "intone", "i", 123, "help message for flag intone")
+ cmdEcho.PersistentFlags().BoolVarP(&flagbp, "persistentbool", "p", false, "help message for flag persistentbool")
+ cmdEcho.PersistentFlags().StringVarP(&flags1, "strone", "s", "one", "help message for flag strone")
+ cmdPrint.Flags().IntVarP(&flagi3, "intthree", "i", 345, "help message for flag intthree")
cmdTimes.Flags().BoolVarP(&flagb2, "booltwo", "c", false, "help message for flag booltwo")
+ cmdTimes.Flags().IntVarP(&flagi2, "inttwo", "j", 234, "help message for flag inttwo")
+ cmdTimes.Flags().StringVarP(&flags2b, "strtwo", "t", "2", strtwoChildHelp)
+ cmdTimes.PersistentFlags().StringVarP(&flags2b, "strtwo", "t", "2", strtwoChildHelp)
cmdPrint.Flags().BoolVarP(&flagb3, "boolthree", "b", true, "help message for flag boolthree")
- cmdVersion1.ResetFlags()
- cmdVersion2.ResetFlags()
+ cmdPrint.PersistentFlags().StringVarP(&flags3, "strthree", "s", "three", "help message for flag strthree")
}
func commandInit() {
@@ -571,7 +569,7 @@ func TestChildCommandFlags(t *testing.T) {
if r.Error == nil {
t.Errorf("invalid input should generate error")
}
- if !strings.Contains(r.Error.Error(), "invalid argument \"10E\" for i10E") {
+ if !strings.Contains(r.Error.Error(), "invalid syntax") {
t.Errorf("Wrong error message displayed, \n %s", r.Error)
}
}
@@ -677,7 +675,7 @@ func TestPersistentFlags(t *testing.T) {
fullSetupTest("echo times -s again -c -p test here")
if strings.Join(tt, " ") != "test here" {
- t.Errorf("flags didn't leave proper args remaining..%s given", tt)
+ t.Errorf("flags didn't leave proper args remaining. %s given", tt)
}
if flags1 != "again" {
@@ -858,7 +856,6 @@ func TestFlagAccess(t *testing.T) {
}
if inherited.Lookup("strtwo") != nil {
t.Errorf("InheritedFlags shouldn not contain overwritten flag strtwo")
-
}
}
@@ -990,7 +987,7 @@ func TestFlagsBeforeCommand(t *testing.T) {
// With parsing error properly reported
x = fullSetupTest("-i10E echo")
- if !strings.Contains(x.Error.Error(), "invalid argument \"10E\" for i10E") {
+ if !strings.Contains(x.Error.Error(), "invalid syntax") {
t.Errorf("Wrong error message displayed, \n %s", x.Error)
}
@@ -1185,3 +1182,23 @@ func TestUsageIsNotPrintedTwice(t *testing.T) {
t.Error("Usage output is not printed exactly once")
}
}
+
+func BenchmarkInheritedFlags(b *testing.B) {
+ initialize()
+ cmdEcho.AddCommand(cmdTimes)
+ b.ResetTimer()
+
+ for i := 0; i < b.N; i++ {
+ cmdTimes.InheritedFlags()
+ }
+}
+
+func BenchmarkLocalFlags(b *testing.B) {
+ initialize()
+ cmdEcho.AddCommand(cmdTimes)
+ b.ResetTimer()
+
+ for i := 0; i < b.N; i++ {
+ cmdTimes.LocalFlags()
+ }
+}
diff --git a/vendor/github.com/spf13/cobra/command.go b/vendor/github.com/spf13/cobra/command.go
index 664bf5aa5..f4705f970 100644
--- a/vendor/github.com/spf13/cobra/command.go
+++ b/vendor/github.com/spf13/cobra/command.go
@@ -66,6 +66,10 @@ type Command struct {
pflags *flag.FlagSet
// Flags that are declared specifically by this command (not inherited).
lflags *flag.FlagSet
+ // Inherited flags.
+ iflags *flag.FlagSet
+ // All persistent flags of cmd's parents.
+ parentsPflags *flag.FlagSet
// SilenceErrors is an option to quiet errors down stream
SilenceErrors bool
// Silence Usage is an option to silence usage when an error occurs.
@@ -110,10 +114,8 @@ type Command struct {
// is commands slice are sorted or not
commandsAreSorted bool
- flagErrorBuf *bytes.Buffer
-
args []string // actual args parsed from flags
- output *io.Writer // out writer if set in SetOutput(w)
+ output io.Writer // out writer if set in SetOutput(w)
usageFunc func(*Command) error // Usage can be defined by application
usageTemplate string // Can be defined by Application
flagErrorFunc func(*Command, error) error
@@ -141,7 +143,7 @@ func (c *Command) SetArgs(a []string) {
// SetOutput sets the destination for usage and error messages.
// If output is nil, os.Stderr is used.
func (c *Command) SetOutput(output io.Writer) {
- c.output = &output
+ c.output = output
}
// SetUsageFunc sets usage function. Usage can be defined by application.
@@ -199,7 +201,7 @@ func (c *Command) OutOrStderr() io.Writer {
func (c *Command) getOut(def io.Writer) io.Writer {
if c.output != nil {
- return *c.output
+ return c.output
}
if c.HasParent() {
return c.parent.getOut(def)
@@ -213,9 +215,8 @@ func (c *Command) UsageFunc() (f func(*Command) error) {
if c.usageFunc != nil {
return c.usageFunc
}
-
if c.HasParent() {
- return c.parent.UsageFunc()
+ return c.Parent().UsageFunc()
}
return func(c *Command) error {
c.mergePersistentFlags()
@@ -237,10 +238,13 @@ func (c *Command) Usage() error {
// HelpFunc returns either the function set by SetHelpFunc for this command
// or a parent, or it returns a function with default help behavior.
func (c *Command) HelpFunc() func(*Command, []string) {
- if helpFunc := c.checkHelpFunc(); helpFunc != nil {
- return helpFunc
+ if c.helpFunc != nil {
+ return c.helpFunc
+ }
+ if c.HasParent() {
+ return c.Parent().HelpFunc()
}
- return func(*Command, []string) {
+ return func(c *Command, a []string) {
c.mergePersistentFlags()
err := tmpl(c.OutOrStdout(), c.HelpTemplate(), c)
if err != nil {
@@ -249,20 +253,6 @@ func (c *Command) HelpFunc() func(*Command, []string) {
}
}
-// checkHelpFunc checks if there is helpFunc in ancestors of c.
-func (c *Command) checkHelpFunc() func(*Command, []string) {
- if c == nil {
- return nil
- }
- if c.helpFunc != nil {
- return c.helpFunc
- }
- if c.HasParent() {
- return c.parent.checkHelpFunc()
- }
- return nil
-}
-
// Help puts out the help for the command.
// Used when a user calls help [command].
// Can be defined by user by overriding HelpFunc.
@@ -341,8 +331,7 @@ func (c *Command) UsageTemplate() string {
{{ .CommandPath}} [command]{{end}}{{if gt .Aliases 0}}
Aliases:
- {{.NameAndAliases}}
-{{end}}{{if .HasExample}}
+ {{.NameAndAliases}}{{end}}{{if .HasExample}}
Examples:
{{ .Example }}{{end}}{{if .HasAvailableSubCommands}}
@@ -377,64 +366,62 @@ func (c *Command) HelpTemplate() string {
{{end}}{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}`
}
-// Really only used when casting a command to a commander.
-func (c *Command) resetChildrensParents() {
- for _, x := range c.commands {
- x.parent = c
- }
-}
-
func hasNoOptDefVal(name string, f *flag.FlagSet) bool {
flag := f.Lookup(name)
if flag == nil {
return false
}
- return len(flag.NoOptDefVal) > 0
+ return flag.NoOptDefVal != ""
}
func shortHasNoOptDefVal(name string, fs *flag.FlagSet) bool {
result := false
fs.VisitAll(func(flag *flag.Flag) {
- if flag.Shorthand == name && len(flag.NoOptDefVal) > 0 {
+ if flag.Shorthand == name && flag.NoOptDefVal != "" {
result = true
+ return
}
})
return result
}
func stripFlags(args []string, c *Command) []string {
- if len(args) < 1 {
+ if len(args) == 0 {
return args
}
c.mergePersistentFlags()
commands := []string{}
-
inQuote := false
- inFlag := false
- for _, y := range args {
+ flags := c.Flags()
+
+Loop:
+ for len(args) > 0 {
+ s := args[0]
+ args = args[1:]
if !inQuote {
switch {
- case strings.HasPrefix(y, "\""):
- inQuote = true
- case strings.Contains(y, "=\""):
+ case strings.HasPrefix(s, "\"") || strings.Contains(s, "=\""):
inQuote = true
- case strings.HasPrefix(y, "--") && !strings.Contains(y, "="):
- // TODO: this isn't quite right, we should really check ahead for 'true' or 'false'
- inFlag = !hasNoOptDefVal(y[2:], c.Flags())
- case strings.HasPrefix(y, "-") && !strings.Contains(y, "=") && len(y) == 2 && !shortHasNoOptDefVal(y[1:], c.Flags()):
- inFlag = true
- case inFlag:
- inFlag = false
- case y == "":
- // strip empty commands, as the go tests expect this to be ok....
- case !strings.HasPrefix(y, "-"):
- commands = append(commands, y)
- inFlag = false
+ case strings.HasPrefix(s, "--") && !strings.Contains(s, "=") && !hasNoOptDefVal(s[2:], flags):
+ // If '--flag arg' then
+ // delete arg from args.
+ fallthrough // (do the same as below)
+ case strings.HasPrefix(s, "-") && !strings.Contains(s, "=") && len(s) == 2 && !shortHasNoOptDefVal(s[1:], flags):
+ // If '-f arg' then
+ // delete 'arg' from args or break the loop if len(args) <= 1.
+ if len(args) <= 1 {
+ break Loop
+ } else {
+ args = args[1:]
+ continue
+ }
+ case s != "" && !strings.HasPrefix(s, "-"):
+ commands = append(commands, s)
}
}
- if strings.HasSuffix(y, "\"") && !strings.HasSuffix(y, "\\\"") {
+ if strings.HasSuffix(s, "\"") && !strings.HasSuffix(s, "\\\"") {
inQuote = false
}
}
@@ -547,32 +534,18 @@ func (c *Command) SuggestionsFor(typedName string) []string {
// VisitParents visits all parents of the command and invokes fn on each parent.
func (c *Command) VisitParents(fn func(*Command)) {
- var traverse func(*Command) *Command
-
- traverse = func(x *Command) *Command {
- if x != c {
- fn(x)
- }
- if x.HasParent() {
- return traverse(x.parent)
- }
- return x
+ if c.HasParent() {
+ fn(c.Parent())
+ c.Parent().VisitParents(fn)
}
- traverse(c)
}
// Root finds root command.
func (c *Command) Root() *Command {
- var findRoot func(*Command) *Command
-
- findRoot = func(x *Command) *Command {
- if x.HasParent() {
- return findRoot(x.parent)
- }
- return x
+ if c.HasParent() {
+ return c.Parent().Root()
}
-
- return findRoot(c)
+ return c
}
// ArgsLenAtDash will return the length of f.Args at the moment when a -- was
@@ -675,17 +648,6 @@ func (c *Command) preRun() {
}
}
-func (c *Command) errorMsgFromParse() string {
- s := c.flagErrorBuf.String()
-
- x := strings.Split(s, "\n")
-
- if len(x) > 0 {
- return x[0]
- }
- return ""
-}
-
// Execute Call execute to use the args (os.Args[1:] by default)
// and run through the command tree finding appropriate matches
// for commands and then corresponding flags.
@@ -796,6 +758,7 @@ func (c *Command) initHelpCmd() {
func (c *Command) ResetCommands() {
c.commands = nil
c.helpCommand = nil
+ c.parentsPflags = nil
}
// Sorts commands by their names.
@@ -927,12 +890,8 @@ func (c *Command) DebugFlags() {
}
if x.HasFlags() {
x.flags.VisitAll(func(f *flag.Flag) {
- if x.HasPersistentFlags() {
- if x.persistentFlag(f.Name) == nil {
- c.Println(" -"+f.Shorthand+",", "--"+f.Name, "["+f.DefValue+"]", "", f.Value, " [L]")
- } else {
- c.Println(" -"+f.Shorthand+",", "--"+f.Name, "["+f.DefValue+"]", "", f.Value, " [LP]")
- }
+ if x.HasPersistentFlags() && x.persistentFlag(f.Name) != nil {
+ c.Println(" -"+f.Shorthand+",", "--"+f.Name, "["+f.DefValue+"]", "", f.Value, " [LP]")
} else {
c.Println(" -"+f.Shorthand+",", "--"+f.Name, "["+f.DefValue+"]", "", f.Value, " [L]")
}
@@ -949,7 +908,6 @@ func (c *Command) DebugFlags() {
}
})
}
- c.Println(x.flagErrorBuf)
if x.HasSubCommands() {
for _, y := range x.commands {
debugflags(y)
@@ -1090,11 +1048,9 @@ func (c *Command) GlobalNormalizationFunc() func(f *flag.FlagSet, name string) f
func (c *Command) Flags() *flag.FlagSet {
if c.flags == nil {
c.flags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- if c.flagErrorBuf == nil {
- c.flagErrorBuf = new(bytes.Buffer)
- }
- c.flags.SetOutput(c.flagErrorBuf)
+ c.flags.SetOutput(c.OutOrStderr())
}
+
return c.flags
}
@@ -1115,47 +1071,37 @@ func (c *Command) LocalNonPersistentFlags() *flag.FlagSet {
func (c *Command) LocalFlags() *flag.FlagSet {
c.mergePersistentFlags()
- local := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- c.lflags.VisitAll(func(f *flag.Flag) {
- local.AddFlag(f)
- })
- if !c.HasParent() {
- flag.CommandLine.VisitAll(func(f *flag.Flag) {
- if local.Lookup(f.Name) == nil {
- local.AddFlag(f)
- }
- })
+ if c.lflags == nil {
+ c.lflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)
+ c.lflags.SetOutput(c.OutOrStderr())
}
- return local
+ c.lflags.SortFlags = c.Flags().SortFlags
+
+ addToLocal := func(f *flag.Flag) {
+ if c.lflags.Lookup(f.Name) == nil && c.parentsPflags.Lookup(f.Name) == nil {
+ c.lflags.AddFlag(f)
+ }
+ }
+ c.Flags().VisitAll(addToLocal)
+ c.PersistentFlags().VisitAll(addToLocal)
+ return c.lflags
}
// InheritedFlags returns all flags which were inherited from parents commands.
func (c *Command) InheritedFlags() *flag.FlagSet {
c.mergePersistentFlags()
- inherited := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- local := c.LocalFlags()
-
- var rmerge func(x *Command)
-
- rmerge = func(x *Command) {
- if x.HasPersistentFlags() {
- x.PersistentFlags().VisitAll(func(f *flag.Flag) {
- if inherited.Lookup(f.Name) == nil && local.Lookup(f.Name) == nil {
- inherited.AddFlag(f)
- }
- })
- }
- if x.HasParent() {
- rmerge(x.parent)
- }
+ if c.iflags == nil {
+ c.iflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)
}
- if c.HasParent() {
- rmerge(c.parent)
- }
-
- return inherited
+ local := c.LocalFlags()
+ c.parentsPflags.VisitAll(func(f *flag.Flag) {
+ if c.iflags.Lookup(f.Name) == nil && local.Lookup(f.Name) == nil {
+ c.iflags.AddFlag(f)
+ }
+ })
+ return c.iflags
}
// NonInheritedFlags returns all flags which were not inherited from parent commands.
@@ -1167,22 +1113,17 @@ func (c *Command) NonInheritedFlags() *flag.FlagSet {
func (c *Command) PersistentFlags() *flag.FlagSet {
if c.pflags == nil {
c.pflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- if c.flagErrorBuf == nil {
- c.flagErrorBuf = new(bytes.Buffer)
- }
- c.pflags.SetOutput(c.flagErrorBuf)
+ c.pflags.SetOutput(c.OutOrStderr())
}
return c.pflags
}
// ResetFlags is used in testing.
func (c *Command) ResetFlags() {
- c.flagErrorBuf = new(bytes.Buffer)
- c.flagErrorBuf.Reset()
c.flags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- c.flags.SetOutput(c.flagErrorBuf)
+ c.flags.SetOutput(c.OutOrStderr())
c.pflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- c.pflags.SetOutput(c.flagErrorBuf)
+ c.pflags.SetOutput(c.OutOrStderr())
}
// HasFlags checks if the command contains any flags (local plus persistent from the entire structure).
@@ -1245,8 +1186,9 @@ func (c *Command) persistentFlag(name string) (flag *flag.Flag) {
flag = c.PersistentFlags().Lookup(name)
}
- if flag == nil && c.HasParent() {
- flag = c.parent.persistentFlag(name)
+ if flag == nil {
+ c.updateParentsPflags()
+ flag = c.parentsPflags.Lookup(name)
}
return
}
@@ -1266,41 +1208,27 @@ func (c *Command) Parent() *Command {
return c.parent
}
+// mergePersistentFlags merges c.PersistentFlags() to c.Flags()
+// and adds missing persistent flags of all parents.
func (c *Command) mergePersistentFlags() {
- var rmerge func(x *Command)
+ c.Flags().AddFlagSet(c.PersistentFlags())
+ c.updateParentsPflags()
+ c.Flags().AddFlagSet(c.parentsPflags)
+}
- // Save the set of local flags
- if c.lflags == nil {
- c.lflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- if c.flagErrorBuf == nil {
- c.flagErrorBuf = new(bytes.Buffer)
- }
- c.lflags.SetOutput(c.flagErrorBuf)
- addtolocal := func(f *flag.Flag) {
- c.lflags.AddFlag(f)
- }
- c.Flags().VisitAll(addtolocal)
- c.PersistentFlags().VisitAll(addtolocal)
- }
- rmerge = func(x *Command) {
- if !x.HasParent() {
- flag.CommandLine.VisitAll(func(f *flag.Flag) {
- if x.PersistentFlags().Lookup(f.Name) == nil {
- x.PersistentFlags().AddFlag(f)
- }
- })
- }
- if x.HasPersistentFlags() {
- x.PersistentFlags().VisitAll(func(f *flag.Flag) {
- if c.Flags().Lookup(f.Name) == nil {
- c.Flags().AddFlag(f)
- }
- })
- }
- if x.HasParent() {
- rmerge(x.parent)
- }
+// updateParentsPflags updates c.parentsPflags by adding
+// new persistent flags of all parents.
+// If c.parentsPflags == nil, it makes new.
+func (c *Command) updateParentsPflags() {
+ if c.parentsPflags == nil {
+ c.parentsPflags = flag.NewFlagSet(c.Name(), flag.ContinueOnError)
+ c.parentsPflags.SetOutput(c.OutOrStderr())
+ c.parentsPflags.SortFlags = false
}
- rmerge(c)
+ c.Root().PersistentFlags().AddFlagSet(flag.CommandLine)
+
+ c.VisitParents(func(parent *Command) {
+ c.parentsPflags.AddFlagSet(parent.PersistentFlags())
+ })
}
diff --git a/vendor/github.com/spf13/cobra/command_test.go b/vendor/github.com/spf13/cobra/command_test.go
index 7947f6c4a..3921a0be7 100644
--- a/vendor/github.com/spf13/cobra/command_test.go
+++ b/vendor/github.com/spf13/cobra/command_test.go
@@ -6,6 +6,8 @@ import (
"os"
"reflect"
"testing"
+
+ "github.com/spf13/pflag"
)
// test to ensure hidden commands run as intended
@@ -191,8 +193,15 @@ func TestEnableCommandSortingIsDisabled(t *testing.T) {
EnableCommandSorting = true
}
-func TestFlagErrorFunc(t *testing.T) {
+func TestSetOutput(t *testing.T) {
+ cmd := &Command{}
+ cmd.SetOutput(nil)
+ if out := cmd.OutOrStdout(); out != os.Stdout {
+ t.Fatalf("expected setting output to nil to revert back to stdout, got %v", out)
+ }
+}
+func TestFlagErrorFunc(t *testing.T) {
cmd := &Command{
Use: "print",
RunE: func(cmd *Command, args []string) error {
@@ -214,3 +223,38 @@ func TestFlagErrorFunc(t *testing.T) {
t.Errorf("expected %v, got %v", expected, err.Error())
}
}
+
+// TestSortedFlags checks,
+// if cmd.LocalFlags() is unsorted when cmd.Flags().SortFlags set to false.
+// https://github.com/spf13/cobra/issues/404
+func TestSortedFlags(t *testing.T) {
+ cmd := &Command{}
+ cmd.Flags().SortFlags = false
+ names := []string{"C", "B", "A", "D"}
+ for _, name := range names {
+ cmd.Flags().Bool(name, false, "")
+ }
+
+ i := 0
+ cmd.LocalFlags().VisitAll(func(f *pflag.Flag) {
+ if i == len(names) {
+ return
+ }
+ if contains(f.Name, names) {
+ if names[i] != f.Name {
+ t.Errorf("Incorrect order. Expected %v, got %v", names[i], f.Name)
+ }
+ i++
+ }
+ })
+}
+
+// contains checks, if s is in ss.
+func contains(s string, ss []string) bool {
+ for _, v := range ss {
+ if v == s {
+ return true
+ }
+ }
+ return false
+}
diff --git a/vendor/github.com/spf13/cobra/doc/man_docs.go b/vendor/github.com/spf13/cobra/doc/man_docs.go
index b9266c367..1f90c44f1 100644
--- a/vendor/github.com/spf13/cobra/doc/man_docs.go
+++ b/vendor/github.com/spf13/cobra/doc/man_docs.go
@@ -30,8 +30,8 @@ import (
// GenManTree will generate a man page for this command and all descendants
// in the directory given. The header may be nil. This function may not work
-// correctly if your command names have - in them. If you have `cmd` with two
-// subcmds, `sub` and `sub-third`. And `sub` has a subcommand called `third`
+// correctly if your command names have `-` in them. If you have `cmd` with two
+// subcmds, `sub` and `sub-third`, and `sub` has a subcommand called `third`
// it is undefined which help output will be in the file `cmd-sub-third.1`.
func GenManTree(cmd *cobra.Command, header *GenManHeader, dir string) error {
return GenManTreeFromOpts(cmd, GenManTreeOptions{
diff --git a/vendor/github.com/spf13/cobra/doc/man_docs.md b/vendor/github.com/spf13/cobra/doc/man_docs.md
index d568d9a03..3709160f3 100644
--- a/vendor/github.com/spf13/cobra/doc/man_docs.md
+++ b/vendor/github.com/spf13/cobra/doc/man_docs.md
@@ -6,6 +6,8 @@ Generating man pages from a cobra command is incredibly easy. An example is as f
package main
import (
+ "log"
+
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)
@@ -19,7 +21,10 @@ func main() {
Title: "MINE",
Section: "3",
}
- doc.GenManTree(cmd, header, "/tmp")
+ err := doc.GenManTree(cmd, header, "/tmp")
+ if err != nil {
+ log.Fatal(err)
+ }
}
```
diff --git a/vendor/github.com/spf13/cobra/doc/man_docs_test.go b/vendor/github.com/spf13/cobra/doc/man_docs_test.go
index 26b8fcc60..9b272917d 100644
--- a/vendor/github.com/spf13/cobra/doc/man_docs_test.go
+++ b/vendor/github.com/spf13/cobra/doc/man_docs_test.go
@@ -13,9 +13,6 @@ import (
"github.com/spf13/cobra"
)
-var _ = fmt.Println
-var _ = os.Stderr
-
func translate(in string) string {
return strings.Replace(in, "-", "\\-", -1)
}
@@ -153,7 +150,7 @@ func TestGenManTree(t *testing.T) {
header := &GenManHeader{Section: "2"}
tmpdir, err := ioutil.TempDir("", "test-gen-man-tree")
if err != nil {
- t.Fatalf("Failed to create tempdir: %s", err.Error())
+ t.Fatalf("Failed to create tmpdir: %s", err.Error())
}
defer os.RemoveAll(tmpdir)
diff --git a/vendor/github.com/spf13/cobra/doc/man_examples_test.go b/vendor/github.com/spf13/cobra/doc/man_examples_test.go
index 3593853b0..db6604268 100644
--- a/vendor/github.com/spf13/cobra/doc/man_examples_test.go
+++ b/vendor/github.com/spf13/cobra/doc/man_examples_test.go
@@ -8,7 +8,7 @@ import (
"github.com/spf13/cobra/doc"
)
-func ExampleCommand_GenManTree() {
+func ExampleGenManTree() {
cmd := &cobra.Command{
Use: "test",
Short: "my test program",
@@ -20,7 +20,7 @@ func ExampleCommand_GenManTree() {
doc.GenManTree(cmd, header, "/tmp")
}
-func ExampleCommand_GenMan() {
+func ExampleGenMan() {
cmd := &cobra.Command{
Use: "test",
Short: "my test program",
diff --git a/vendor/github.com/spf13/cobra/doc/md_docs.go b/vendor/github.com/spf13/cobra/doc/md_docs.go
index 8d159c1d7..408d2f74b 100644
--- a/vendor/github.com/spf13/cobra/doc/md_docs.go
+++ b/vendor/github.com/spf13/cobra/doc/md_docs.go
@@ -52,10 +52,12 @@ func printOptions(w io.Writer, cmd *cobra.Command, name string) error {
return nil
}
+// GenMarkdown creates markdown output.
func GenMarkdown(cmd *cobra.Command, w io.Writer) error {
return GenMarkdownCustom(cmd, w, func(s string) string { return s })
}
+// GenMarkdownCustom creates custom markdown output.
func GenMarkdownCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string) string) error {
name := cmd.CommandPath()
@@ -141,6 +143,12 @@ func GenMarkdownCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string)
return nil
}
+// GenMarkdownTree will generate a markdown page for this command and all
+// descendants in the directory given. The header may be nil.
+// This function may not work correctly if your command names have `-` in them.
+// If you have `cmd` with two subcmds, `sub` and `sub-third`,
+// and `sub` has a subcommand called `third`, it is undefined which
+// help output will be in the file `cmd-sub-third.1`.
func GenMarkdownTree(cmd *cobra.Command, dir string) error {
identity := func(s string) string { return s }
emptyStr := func(s string) string { return "" }
diff --git a/vendor/github.com/spf13/cobra/doc/md_docs.md b/vendor/github.com/spf13/cobra/doc/md_docs.md
index beec3e0e8..56ce9fe81 100644
--- a/vendor/github.com/spf13/cobra/doc/md_docs.md
+++ b/vendor/github.com/spf13/cobra/doc/md_docs.md
@@ -6,6 +6,8 @@ Generating man pages from a cobra command is incredibly easy. An example is as f
package main
import (
+ "log"
+
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)
@@ -15,7 +17,10 @@ func main() {
Use: "test",
Short: "my test program",
}
- doc.GenMarkdownTree(cmd, "/tmp")
+ err := doc.GenMarkdownTree(cmd, "/tmp")
+ if err != nil {
+ log.Fatal(err)
+ }
}
```
@@ -29,6 +34,7 @@ This program can actually generate docs for the kubectl command in the kubernete
package main
import (
+ "log"
"io/ioutil"
"os"
@@ -40,7 +46,10 @@ import (
func main() {
kubectl := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, ioutil.Discard, ioutil.Discard)
- doc.GenMarkdownTree(kubectl, "./")
+ err := doc.GenMarkdownTree(kubectl, "./")
+ if err != nil {
+ log.Fatal(err)
+ }
}
```
@@ -52,7 +61,10 @@ You may wish to have more control over the output, or only generate for a single
```go
out := new(bytes.Buffer)
- doc.GenMarkdown(cmd, out)
+ err := doc.GenMarkdown(cmd, out)
+ if err != nil {
+ log.Fatal(err)
+ }
```
This will write the markdown doc for ONLY "cmd" into the out, buffer.
diff --git a/vendor/github.com/spf13/cobra/doc/md_docs_test.go b/vendor/github.com/spf13/cobra/doc/md_docs_test.go
index 86ee02930..f4f3bc149 100644
--- a/vendor/github.com/spf13/cobra/doc/md_docs_test.go
+++ b/vendor/github.com/spf13/cobra/doc/md_docs_test.go
@@ -2,14 +2,14 @@ package doc
import (
"bytes"
- "fmt"
+ "io/ioutil"
"os"
+ "path/filepath"
"strings"
"testing"
-)
-var _ = fmt.Println
-var _ = os.Stderr
+ "github.com/spf13/cobra"
+)
func TestGenMdDoc(t *testing.T) {
c := initializeWithRootCmd()
@@ -86,3 +86,22 @@ func TestGenMdNoTag(t *testing.T) {
checkStringOmits(t, found, unexpected)
}
+
+func TestGenMdTree(t *testing.T) {
+ cmd := &cobra.Command{
+ Use: "do [OPTIONS] arg1 arg2",
+ }
+ tmpdir, err := ioutil.TempDir("", "test-gen-md-tree")
+ if err != nil {
+ t.Fatalf("Failed to create tmpdir: %s", err.Error())
+ }
+ defer os.RemoveAll(tmpdir)
+
+ if err := GenMarkdownTree(cmd, tmpdir); err != nil {
+ t.Fatalf("GenMarkdownTree failed: %s", err.Error())
+ }
+
+ if _, err := os.Stat(filepath.Join(tmpdir, "do.md")); err != nil {
+ t.Fatalf("Expected file 'do.md' to exist")
+ }
+}
diff --git a/vendor/github.com/spf13/cobra/doc/yaml_docs.go b/vendor/github.com/spf13/cobra/doc/yaml_docs.go
index ac8db89eb..f5cd5a329 100644
--- a/vendor/github.com/spf13/cobra/doc/yaml_docs.go
+++ b/vendor/github.com/spf13/cobra/doc/yaml_docs.go
@@ -45,8 +45,8 @@ type cmdDoc struct {
// GenYamlTree creates yaml structured ref files for this command and all descendants
// in the directory given. This function may not work
-// correctly if your command names have - in them. If you have `cmd` with two
-// subcmds, `sub` and `sub-third`. And `sub` has a subcommand called `third`
+// correctly if your command names have `-` in them. If you have `cmd` with two
+// subcmds, `sub` and `sub-third`, and `sub` has a subcommand called `third`
// it is undefined which help output will be in the file `cmd-sub-third.1`.
func GenYamlTree(cmd *cobra.Command, dir string) error {
identity := func(s string) string { return s }
@@ -54,7 +54,7 @@ func GenYamlTree(cmd *cobra.Command, dir string) error {
return GenYamlTreeCustom(cmd, dir, emptyStr, identity)
}
-// GenYamlTreeCustom creates yaml structured ref files
+// GenYamlTreeCustom creates yaml structured ref files.
func GenYamlTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string) error {
for _, c := range cmd.Commands() {
if !c.IsAvailableCommand() || c.IsAdditionalHelpTopicCommand() {
@@ -82,12 +82,12 @@ func GenYamlTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHandle
return nil
}
-// GenYaml creates yaml output
+// GenYaml creates yaml output.
func GenYaml(cmd *cobra.Command, w io.Writer) error {
return GenYamlCustom(cmd, w, func(s string) string { return s })
}
-// GenYamlCustom creates custom yaml output
+// GenYamlCustom creates custom yaml output.
func GenYamlCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string) string) error {
yamlDoc := cmdDoc{}
yamlDoc.Name = cmd.CommandPath()
diff --git a/vendor/github.com/spf13/cobra/doc/yaml_docs.md b/vendor/github.com/spf13/cobra/doc/yaml_docs.md
index 4d0c75a12..1a9b7c6a3 100644
--- a/vendor/github.com/spf13/cobra/doc/yaml_docs.md
+++ b/vendor/github.com/spf13/cobra/doc/yaml_docs.md
@@ -6,6 +6,8 @@ Generating yaml files from a cobra command is incredibly easy. An example is as
package main
import (
+ "log"
+
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)
@@ -15,7 +17,10 @@ func main() {
Use: "test",
Short: "my test program",
}
- doc.GenYamlTree(cmd, "/tmp")
+ err := doc.GenYamlTree(cmd, "/tmp")
+ if err != nil {
+ log.Fatal(err)
+ }
}
```
@@ -30,6 +35,7 @@ package main
import (
"io/ioutil"
+ "log"
"os"
"k8s.io/kubernetes/pkg/kubectl/cmd"
@@ -40,7 +46,10 @@ import (
func main() {
kubectl := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, ioutil.Discard, ioutil.Discard)
- doc.GenYamlTree(kubectl, "./")
+ err := doc.GenYamlTree(kubectl, "./")
+ if err != nil {
+ log.Fatal(err)
+ }
}
```
diff --git a/vendor/github.com/spf13/cobra/doc/yaml_docs_test.go b/vendor/github.com/spf13/cobra/doc/yaml_docs_test.go
index a41499e1f..fb969da22 100644
--- a/vendor/github.com/spf13/cobra/doc/yaml_docs_test.go
+++ b/vendor/github.com/spf13/cobra/doc/yaml_docs_test.go
@@ -2,14 +2,14 @@ package doc
import (
"bytes"
- "fmt"
+ "io/ioutil"
"os"
+ "path/filepath"
"strings"
"testing"
-)
-var _ = fmt.Println
-var _ = os.Stderr
+ "github.com/spf13/cobra"
+)
func TestGenYamlDoc(t *testing.T) {
c := initializeWithRootCmd()
@@ -86,3 +86,23 @@ func TestGenYamlNoTag(t *testing.T) {
checkStringOmits(t, found, unexpected)
}
+
+func TestGenYamlTree(t *testing.T) {
+ cmd := &cobra.Command{
+ Use: "do [OPTIONS] arg1 arg2",
+ }
+
+ tmpdir, err := ioutil.TempDir("", "test-gen-yaml-tree")
+ if err != nil {
+ t.Fatalf("Failed to create tmpdir: %s", err.Error())
+ }
+ defer os.RemoveAll(tmpdir)
+
+ if err := GenYamlTree(cmd, tmpdir); err != nil {
+ t.Fatalf("GenYamlTree failed: %s", err.Error())
+ }
+
+ if _, err := os.Stat(filepath.Join(tmpdir, "do.yaml")); err != nil {
+ t.Fatalf("Expected file 'do.yaml' to exist")
+ }
+}
diff --git a/vendor/github.com/spf13/pflag/README.md b/vendor/github.com/spf13/pflag/README.md
index eefb46dec..3001fcd2b 100644
--- a/vendor/github.com/spf13/pflag/README.md
+++ b/vendor/github.com/spf13/pflag/README.md
@@ -270,8 +270,8 @@ func main() {
You can see the full reference documentation of the pflag package
[at godoc.org][3], or through go's standard documentation system by
running `godoc -http=:6060` and browsing to
-[http://localhost:6060/pkg/github.com/ogier/pflag][2] after
+[http://localhost:6060/pkg/github.com/spf13/pflag][2] after
installation.
-[2]: http://localhost:6060/pkg/github.com/ogier/pflag
-[3]: http://godoc.org/github.com/ogier/pflag
+[2]: http://localhost:6060/pkg/github.com/spf13/pflag
+[3]: http://godoc.org/github.com/spf13/pflag
diff --git a/vendor/github.com/spf13/pflag/flag.go b/vendor/github.com/spf13/pflag/flag.go
index 746af6327..0730bd637 100644
--- a/vendor/github.com/spf13/pflag/flag.go
+++ b/vendor/github.com/spf13/pflag/flag.go
@@ -16,9 +16,9 @@ pflag is a drop-in replacement of Go's native flag package. If you import
pflag under the name "flag" then all code should continue to function
with no changes.
- import flag "github.com/ogier/pflag"
+ import flag "github.com/spf13/pflag"
- There is one exception to this: if you directly instantiate the Flag struct
+There is one exception to this: if you directly instantiate the Flag struct
there is one more field "Shorthand" that you will need to set.
Most code never instantiates this struct directly, and instead uses
functions such as String(), BoolVar(), and Var(), and is therefore
@@ -134,14 +134,21 @@ type FlagSet struct {
// a custom error handler.
Usage func()
+ // SortFlags is used to indicate, if user wants to have sorted flags in
+ // help/usage messages.
+ SortFlags bool
+
name string
parsed bool
actual map[NormalizedName]*Flag
+ orderedActual []*Flag
+ sortedActual []*Flag
formal map[NormalizedName]*Flag
+ orderedFormal []*Flag
+ sortedFormal []*Flag
shorthands map[byte]*Flag
args []string // arguments after flags
argsLenAtDash int // len(args) when a '--' was located when parsing, or -1 if no --
- exitOnError bool // does the program exit if there's an error?
errorHandling ErrorHandling
output io.Writer // nil means stderr; use out() accessor
interspersed bool // allow interspersed option/non-option args
@@ -156,7 +163,7 @@ type Flag struct {
Value Value // value as set
DefValue string // default value (as text); for usage message
Changed bool // If the user set the value (or if left to default)
- NoOptDefVal string //default value (as text); if the flag is on the command line without any options
+ NoOptDefVal string // default value (as text); if the flag is on the command line without any options
Deprecated string // If this flag is deprecated, this string is the new or now thing to use
Hidden bool // used by cobra.Command to allow flags to be hidden from help/usage text
ShorthandDeprecated string // If the shorthand of this flag is deprecated, this string is the new or now thing to use
@@ -194,11 +201,13 @@ func sortFlags(flags map[NormalizedName]*Flag) []*Flag {
// "--getUrl" which may also be translated to "geturl" and everything will work.
func (f *FlagSet) SetNormalizeFunc(n func(f *FlagSet, name string) NormalizedName) {
f.normalizeNameFunc = n
- for k, v := range f.formal {
- delete(f.formal, k)
- nname := f.normalizeFlagName(string(k))
- f.formal[nname] = v
+ f.sortedFormal = f.sortedFormal[:0]
+ for k, v := range f.orderedFormal {
+ delete(f.formal, NormalizedName(v.Name))
+ nname := f.normalizeFlagName(v.Name)
v.Name = string(nname)
+ f.formal[nname] = v
+ f.orderedFormal[k] = v
}
}
@@ -229,10 +238,25 @@ func (f *FlagSet) SetOutput(output io.Writer) {
f.output = output
}
-// VisitAll visits the flags in lexicographical order, calling fn for each.
+// VisitAll visits the flags in lexicographical order or
+// in primordial order if f.SortFlags is false, calling fn for each.
// It visits all flags, even those not set.
func (f *FlagSet) VisitAll(fn func(*Flag)) {
- for _, flag := range sortFlags(f.formal) {
+ if len(f.formal) == 0 {
+ return
+ }
+
+ var flags []*Flag
+ if f.SortFlags {
+ if len(f.formal) != len(f.sortedFormal) {
+ f.sortedFormal = sortFlags(f.formal)
+ }
+ flags = f.sortedFormal
+ } else {
+ flags = f.orderedFormal
+ }
+
+ for _, flag := range flags {
fn(flag)
}
}
@@ -253,22 +277,39 @@ func (f *FlagSet) HasAvailableFlags() bool {
return false
}
-// VisitAll visits the command-line flags in lexicographical order, calling
-// fn for each. It visits all flags, even those not set.
+// VisitAll visits the command-line flags in lexicographical order or
+// in primordial order if f.SortFlags is false, calling fn for each.
+// It visits all flags, even those not set.
func VisitAll(fn func(*Flag)) {
CommandLine.VisitAll(fn)
}
-// Visit visits the flags in lexicographical order, calling fn for each.
+// Visit visits the flags in lexicographical order or
+// in primordial order if f.SortFlags is false, calling fn for each.
// It visits only those flags that have been set.
func (f *FlagSet) Visit(fn func(*Flag)) {
- for _, flag := range sortFlags(f.actual) {
+ if len(f.actual) == 0 {
+ return
+ }
+
+ var flags []*Flag
+ if f.SortFlags {
+ if len(f.actual) != len(f.sortedActual) {
+ f.sortedActual = sortFlags(f.actual)
+ }
+ flags = f.sortedActual
+ } else {
+ flags = f.orderedActual
+ }
+
+ for _, flag := range flags {
fn(flag)
}
}
-// Visit visits the command-line flags in lexicographical order, calling fn
-// for each. It visits only those flags that have been set.
+// Visit visits the command-line flags in lexicographical order or
+// in primordial order if f.SortFlags is false, calling fn for each.
+// It visits only those flags that have been set.
func Visit(fn func(*Flag)) {
CommandLine.Visit(fn)
}
@@ -373,6 +414,7 @@ func (f *FlagSet) Set(name, value string) error {
f.actual = make(map[NormalizedName]*Flag)
}
f.actual[normalName] = flag
+ f.orderedActual = append(f.orderedActual, flag)
flag.Changed = true
if len(flag.Deprecated) > 0 {
fmt.Fprintf(os.Stderr, "Flag --%s has been deprecated, %s\n", flag.Name, flag.Deprecated)
@@ -601,7 +643,7 @@ func (f *FlagSet) FlagUsagesWrapped(cols int) string {
line += usage
if !flag.defaultIsZeroValue() {
if flag.Value.Type() == "string" {
- line += fmt.Sprintf(" (default \"%s\")", flag.DefValue)
+ line += fmt.Sprintf(" (default %q)", flag.DefValue)
} else {
line += fmt.Sprintf(" (default %s)", flag.DefValue)
}
@@ -729,6 +771,7 @@ func (f *FlagSet) AddFlag(flag *Flag) {
flag.Name = string(normalizedFlagName)
f.formal[normalizedFlagName] = flag
+ f.orderedFormal = append(f.orderedFormal, flag)
if len(flag.Shorthand) == 0 {
return
@@ -807,6 +850,7 @@ func (f *FlagSet) setFlag(flag *Flag, value string, origArg string) error {
f.actual = make(map[NormalizedName]*Flag)
}
f.actual[f.normalizeFlagName(flag.Name)] = flag
+ f.orderedActual = append(f.orderedActual, flag)
flag.Changed = true
if len(flag.Deprecated) > 0 {
fmt.Fprintf(os.Stderr, "Flag --%s has been deprecated, %s\n", flag.Name, flag.Deprecated)
@@ -1036,14 +1080,15 @@ func Parsed() bool {
// CommandLine is the default set of command-line flags, parsed from os.Args.
var CommandLine = NewFlagSet(os.Args[0], ExitOnError)
-// NewFlagSet returns a new, empty flag set with the specified name and
-// error handling property.
+// NewFlagSet returns a new, empty flag set with the specified name,
+// error handling property and SortFlags set to true.
func NewFlagSet(name string, errorHandling ErrorHandling) *FlagSet {
f := &FlagSet{
name: name,
errorHandling: errorHandling,
argsLenAtDash: -1,
interspersed: true,
+ SortFlags: true,
}
return f
}
diff --git a/vendor/github.com/spf13/pflag/flag_test.go b/vendor/github.com/spf13/pflag/flag_test.go
index b83a0ed6a..172d49fc2 100644
--- a/vendor/github.com/spf13/pflag/flag_test.go
+++ b/vendor/github.com/spf13/pflag/flag_test.go
@@ -335,7 +335,7 @@ func testParse(f *FlagSet, t *testing.T) {
func testParseAll(f *FlagSet, t *testing.T) {
if f.Parsed() {
- fmt.Errorf("f.Parse() = true before Parse")
+ t.Error("f.Parse() = true before Parse")
}
f.BoolP("boola", "a", false, "bool value")
f.BoolP("boolb", "b", false, "bool2 value")
@@ -374,7 +374,7 @@ func testParseAll(f *FlagSet, t *testing.T) {
return nil
}
if err := f.ParseAll(args, store); err != nil {
- t.Errorf("expected no error, got ", err)
+ t.Errorf("expected no error, got %s", err)
}
if !f.Parsed() {
t.Errorf("f.Parse() = false after Parse")
@@ -1004,3 +1004,43 @@ func TestPrintDefaults(t *testing.T) {
t.Errorf("got %q want %q\n", got, defaultOutput)
}
}
+
+func TestVisitAllFlagOrder(t *testing.T) {
+ fs := NewFlagSet("TestVisitAllFlagOrder", ContinueOnError)
+ fs.SortFlags = false
+ // https://github.com/spf13/pflag/issues/120
+ fs.SetNormalizeFunc(func(f *FlagSet, name string) NormalizedName {
+ return NormalizedName(name)
+ })
+
+ names := []string{"C", "B", "A", "D"}
+ for _, name := range names {
+ fs.Bool(name, false, "")
+ }
+
+ i := 0
+ fs.VisitAll(func(f *Flag) {
+ if names[i] != f.Name {
+ t.Errorf("Incorrect order. Expected %v, got %v", names[i], f.Name)
+ }
+ i++
+ })
+}
+
+func TestVisitFlagOrder(t *testing.T) {
+ fs := NewFlagSet("TestVisitFlagOrder", ContinueOnError)
+ fs.SortFlags = false
+ names := []string{"C", "B", "A", "D"}
+ for _, name := range names {
+ fs.Bool(name, false, "")
+ fs.Set(name, "true")
+ }
+
+ i := 0
+ fs.Visit(func(f *Flag) {
+ if names[i] != f.Name {
+ t.Errorf("Incorrect order. Expected %v, got %v", names[i], f.Name)
+ }
+ i++
+ })
+}
diff --git a/vendor/github.com/spf13/viper/viper.go b/vendor/github.com/spf13/viper/viper.go
index 22a2ed8ad..31b41a6b2 100644
--- a/vendor/github.com/spf13/viper/viper.go
+++ b/vendor/github.com/spf13/viper/viper.go
@@ -21,6 +21,7 @@ package viper
import (
"bytes"
+ "encoding/csv"
"fmt"
"io"
"log"
@@ -719,7 +720,15 @@ func (v *Viper) GetSizeInBytes(key string) uint {
// UnmarshalKey takes a single key and unmarshals it into a Struct.
func UnmarshalKey(key string, rawVal interface{}) error { return v.UnmarshalKey(key, rawVal) }
func (v *Viper) UnmarshalKey(key string, rawVal interface{}) error {
- return mapstructure.Decode(v.Get(key), rawVal)
+ err := decode(v.Get(key), defaultDecoderConfig(rawVal))
+
+ if err != nil {
+ return err
+ }
+
+ v.insensitiviseMaps()
+
+ return nil
}
// Unmarshal unmarshals the config into a Struct. Make sure that the tags
@@ -886,7 +895,9 @@ func (v *Viper) find(lcaseKey string) interface{} {
return cast.ToBool(flag.ValueString())
case "stringSlice":
s := strings.TrimPrefix(flag.ValueString(), "[")
- return strings.TrimSuffix(s, "]")
+ s = strings.TrimSuffix(s, "]")
+ res, _ := readAsCSV(s)
+ return res
default:
return flag.ValueString()
}
@@ -953,7 +964,9 @@ func (v *Viper) find(lcaseKey string) interface{} {
return cast.ToBool(flag.ValueString())
case "stringSlice":
s := strings.TrimPrefix(flag.ValueString(), "[")
- return strings.TrimSuffix(s, "]")
+ s = strings.TrimSuffix(s, "]")
+ res, _ := readAsCSV(s)
+ return res
default:
return flag.ValueString()
}
@@ -963,6 +976,15 @@ func (v *Viper) find(lcaseKey string) interface{} {
return nil
}
+func readAsCSV(val string) ([]string, error) {
+ if val == "" {
+ return []string{}, nil
+ }
+ stringReader := strings.NewReader(val)
+ csvReader := csv.NewReader(stringReader)
+ return csvReader.Read()
+}
+
// IsSet checks to see if the key has been set in any of the data locations.
// IsSet is case-insensitive for a key.
func IsSet(key string) bool { return v.IsSet(key) }
diff --git a/vendor/github.com/spf13/viper/viper_test.go b/vendor/github.com/spf13/viper/viper_test.go
index cd7b65cbd..774ca1168 100644
--- a/vendor/github.com/spf13/viper/viper_test.go
+++ b/vendor/github.com/spf13/viper/viper_test.go
@@ -538,6 +538,44 @@ func TestBindPFlags(t *testing.T) {
}
+func TestBindPFlagsStringSlice(t *testing.T) {
+ for _, testValue := range []struct {
+ Expected []string
+ Value string
+ }{
+ {[]string{}, ""},
+ {[]string{"jeden"}, "jeden"},
+ {[]string{"dwa", "trzy"}, "dwa,trzy"},
+ {[]string{"cztery", "piec , szesc"}, "cztery,\"piec , szesc\""}} {
+
+ for _, changed := range []bool{true, false} {
+ v := New() // create independent Viper object
+ flagSet := pflag.NewFlagSet("test", pflag.ContinueOnError)
+ flagSet.StringSlice("stringslice", testValue.Expected, "test")
+ flagSet.Visit(func(f *pflag.Flag) {
+ if len(testValue.Value) > 0 {
+ f.Value.Set(testValue.Value)
+ f.Changed = changed
+ }
+ })
+
+ err := v.BindPFlags(flagSet)
+ if err != nil {
+ t.Fatalf("error binding flag set, %v", err)
+ }
+
+ type TestStr struct {
+ StringSlice []string
+ }
+ val := &TestStr{}
+ if err := v.Unmarshal(val); err != nil {
+ t.Fatalf("%+#v cannot unmarshal: %s", testValue.Value, err)
+ }
+ assert.Equal(t, testValue.Expected, val.StringSlice)
+ }
+ }
+}
+
func TestBindPFlag(t *testing.T) {
var testString = "testing"
var testValue = newStringValue(testString, &testString)
@@ -1102,6 +1140,35 @@ func TestCaseInsensitiveSet(t *testing.T) {
}
}
+func TestParseNested(t *testing.T) {
+ type duration struct {
+ Delay time.Duration
+ }
+
+ type item struct {
+ Name string
+ Delay time.Duration
+ Nested duration
+ }
+
+ config := `[[parent]]
+ delay="100ms"
+ [parent.nested]
+ delay="200ms"
+`
+ initConfig("toml", config)
+
+ var items []item
+ err := v.UnmarshalKey("parent", &items)
+ if err != nil {
+ t.Fatalf("unable to decode into struct, %v", err)
+ }
+
+ assert.Equal(t, 1, len(items))
+ assert.Equal(t, 100*time.Millisecond, items[0].Delay)
+ assert.Equal(t, 200*time.Millisecond, items[0].Nested.Delay)
+}
+
func doTestCaseInsensitive(t *testing.T, typ, config string) {
initConfig(typ, config)
Set("RfD", true)
diff --git a/vendor/github.com/tylerb/graceful/README.md b/vendor/github.com/tylerb/graceful/README.md
index c641b6e78..328c3acf8 100644
--- a/vendor/github.com/tylerb/graceful/README.md
+++ b/vendor/github.com/tylerb/graceful/README.md
@@ -3,11 +3,6 @@ graceful [![GoDoc](https://godoc.org/github.com/tylerb/graceful?status.png)](htt
Graceful is a Go 1.3+ package enabling graceful shutdown of http.Handler servers.
-## Using Go 1.8?
-
-If you are using Go 1.8, you may not need to use this library! Consider using `http.Server`'s built-in [Shutdown()](https://golang.org/pkg/net/http/#Server.Shutdown)
-method for graceful shutdowns.
-
## Installation
To install, simply execute:
diff --git a/vendor/github.com/xenolf/lego/acme/client.go b/vendor/github.com/xenolf/lego/acme/client.go
index ee519f2e2..ef0f80b7f 100644
--- a/vendor/github.com/xenolf/lego/acme/client.go
+++ b/vendor/github.com/xenolf/lego/acme/client.go
@@ -529,10 +529,7 @@ func (c *Client) chooseSolvers(auth authorization, domain string) map[int]solver
func (c *Client) getChallenges(domains []string) ([]authorizationResource, map[string]error) {
resc, errc := make(chan authorizationResource), make(chan domainError)
- var delay time.Duration
- if len(domains) > overallRequestLimit {
- delay = time.Second / overallRequestLimit
- }
+ delay := time.Second / overallRequestLimit
for _, domain := range domains {
time.Sleep(delay)
diff --git a/vendor/github.com/xenolf/lego/acme/http.go b/vendor/github.com/xenolf/lego/acme/http.go
index dc958046a..a858b5a75 100644
--- a/vendor/github.com/xenolf/lego/acme/http.go
+++ b/vendor/github.com/xenolf/lego/acme/http.go
@@ -97,10 +97,41 @@ func postJSON(j *jws, uri string, reqBody, respBody interface{}) (http.Header, e
if err != nil {
return nil, fmt.Errorf("Failed to post JWS message. -> %v", err)
}
+
defer resp.Body.Close()
if resp.StatusCode >= http.StatusBadRequest {
- return resp.Header, handleHTTPError(resp)
+
+ err := handleHTTPError(resp)
+
+ switch err.(type) {
+
+ case NonceError:
+
+ // Retry once if the nonce was invalidated
+
+ retryResp, err := j.post(uri, jsonBytes)
+ if err != nil {
+ return nil, fmt.Errorf("Failed to post JWS message. -> %v", err)
+ }
+
+ defer retryResp.Body.Close()
+
+ if retryResp.StatusCode >= http.StatusBadRequest {
+ return retryResp.Header, handleHTTPError(retryResp)
+ }
+
+ if respBody == nil {
+ return retryResp.Header, nil
+ }
+
+ return retryResp.Header, json.NewDecoder(retryResp.Body).Decode(respBody)
+
+ default:
+ return resp.Header, err
+
+ }
+
}
if respBody == nil {
diff --git a/vendor/github.com/xenolf/lego/acme/jws.go b/vendor/github.com/xenolf/lego/acme/jws.go
index 3b77cd491..a39434342 100644
--- a/vendor/github.com/xenolf/lego/acme/jws.go
+++ b/vendor/github.com/xenolf/lego/acme/jws.go
@@ -44,26 +44,12 @@ func (j *jws) post(url string, content []byte) (*http.Response, error) {
if err != nil {
return nil, fmt.Errorf("Failed to HTTP POST to %s -> %s", url, err.Error())
}
-
- // Even in case of an error, the response should still contain a nonce.
+
nonce, nonceErr := getNonceFromResponse(resp)
if nonceErr == nil {
j.nonces.Push(nonce)
}
- if err != nil {
- switch err.(type) {
- case NonceError:
- // In case of a nonce error - retry once
- resp, err = httpPost(url, "application/jose+json", bytes.NewBuffer([]byte(signedContent.FullSerialize())))
- if err != nil {
- return nil, fmt.Errorf("Failed to HTTP POST to %s -> %s", url, err.Error())
- }
- default:
- return nil, fmt.Errorf("Failed to HTTP POST to %s -> %s", url, err.Error())
- }
- }
-
return resp, nil
}
diff --git a/vendor/github.com/xenolf/lego/cli.go b/vendor/github.com/xenolf/lego/cli.go
index 61c08d455..03589a233 100644
--- a/vendor/github.com/xenolf/lego/cli.go
+++ b/vendor/github.com/xenolf/lego/cli.go
@@ -205,7 +205,7 @@ Here is an example bash command using the CloudFlare DNS provider:
fmt.Fprintln(w, "\tauroradns:\tAURORA_USER_ID, AURORA_KEY, AURORA_ENDPOINT")
fmt.Fprintln(w, "\tcloudflare:\tCLOUDFLARE_EMAIL, CLOUDFLARE_API_KEY")
fmt.Fprintln(w, "\tdigitalocean:\tDO_AUTH_TOKEN")
- fmt.Fprintln(w, "\tdnsimple:\tDNSIMPLE_EMAIL, DNSIMPLE_API_KEY")
+ fmt.Fprintln(w, "\tdnsimple:\tDNSIMPLE_EMAIL, DNSIMPLE_OAUTH_TOKEN")
fmt.Fprintln(w, "\tdnsmadeeasy:\tDNSMADEEASY_API_KEY, DNSMADEEASY_API_SECRET")
fmt.Fprintln(w, "\texoscale:\tEXOSCALE_API_KEY, EXOSCALE_API_SECRET, EXOSCALE_ENDPOINT")
fmt.Fprintln(w, "\tgandi:\tGANDI_API_KEY")
diff --git a/vendor/github.com/xenolf/lego/providers/dns/azure/azure.go b/vendor/github.com/xenolf/lego/providers/dns/azure/azure.go
index 9d281cd69..d079d5e13 100644
--- a/vendor/github.com/xenolf/lego/providers/dns/azure/azure.go
+++ b/vendor/github.com/xenolf/lego/providers/dns/azure/azure.go
@@ -10,10 +10,11 @@ import (
"github.com/Azure/azure-sdk-for-go/arm/dns"
+ "strings"
+
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/to"
"github.com/xenolf/lego/acme"
- "strings"
)
// DNSProvider is an implementation of the acme.ChallengeProvider interface
@@ -74,7 +75,7 @@ func (c *DNSProvider) Present(domain, token, keyAuth string) error {
Name: &relative,
RecordSetProperties: &dns.RecordSetProperties{
TTL: to.Int64Ptr(60),
- TXTRecords: &[]dns.TxtRecord{dns.TxtRecord{Value: &[]string{value}}},
+ TxtRecords: &[]dns.TxtRecord{dns.TxtRecord{Value: &[]string{value}}},
},
}
_, err = rsc.CreateOrUpdate(c.resourceGroup, zone, relative, dns.TXT, rec, "", "")
diff --git a/vendor/github.com/xenolf/lego/providers/dns/dnsimple/dnsimple.go b/vendor/github.com/xenolf/lego/providers/dns/dnsimple/dnsimple.go
index 155cacd25..e3fea79ec 100644
--- a/vendor/github.com/xenolf/lego/providers/dns/dnsimple/dnsimple.go
+++ b/vendor/github.com/xenolf/lego/providers/dns/dnsimple/dnsimple.go
@@ -32,7 +32,7 @@ func NewDNSProvider() (*DNSProvider, error) {
// DNSProvider instance configured for dnsimple.
func NewDNSProviderCredentials(accessToken, baseUrl string) (*DNSProvider, error) {
if accessToken == "" {
- return nil, fmt.Errorf("DNSimple OAuth token missing")
+ return nil, fmt.Errorf("DNSimple OAuth token is missing")
}
client := dnsimple.NewClient(dnsimple.NewOauthTokenCredentials(accessToken))
@@ -173,7 +173,7 @@ func (c *DNSProvider) getAccountID() (string, error) {
}
if whoamiResponse.Data.Account == nil {
- return "", fmt.Errorf("DNSimple API returned empty account ID")
+ return "", fmt.Errorf("DNSimple user tokens are not supported, please use an account token.")
}
return strconv.Itoa(whoamiResponse.Data.Account.ID), nil
diff --git a/vendor/github.com/xenolf/lego/providers/dns/dnsimple/dnsimple_test.go b/vendor/github.com/xenolf/lego/providers/dns/dnsimple/dnsimple_test.go
index ee65dd42b..bd35790d7 100644
--- a/vendor/github.com/xenolf/lego/providers/dns/dnsimple/dnsimple_test.go
+++ b/vendor/github.com/xenolf/lego/providers/dns/dnsimple/dnsimple_test.go
@@ -74,7 +74,7 @@ func TestNewDNSProviderInvalidWithMissingOauthToken(t *testing.T) {
provider, err := NewDNSProvider()
assert.Nil(t, provider)
- assert.EqualError(t, err, "DNSimple OAuth token missing")
+ assert.EqualError(t, err, "DNSimple OAuth token is missing")
}
//
@@ -102,7 +102,7 @@ func TestNewDNSProviderCredentialsInvalidWithMissingOauthToken(t *testing.T) {
provider, err := NewDNSProviderCredentials("", "")
assert.Nil(t, provider)
- assert.EqualError(t, err, "DNSimple OAuth token missing")
+ assert.EqualError(t, err, "DNSimple OAuth token is missing")
}
//