summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2023-01-23 10:24:00 +0100
committerLibravatar GitHub <noreply@github.com>2023-01-23 10:24:00 +0100
commit98a09b563318b751bb01d7cbc3af5cfc4601c9bd (patch)
tree63ed55523830a4c0a99d597b487cff22e0d20eff
parent[chore]: Bump github.com/abema/go-mp4 from 0.9.0 to 0.10.0 (#1374) (diff)
downloadgotosocial-98a09b563318b751bb01d7cbc3af5cfc4601c9bd.tar.xz
[chore]: Bump github.com/spf13/viper from 1.14.0 to 1.15.0 (#1375)
Bumps [github.com/spf13/viper](https://github.com/spf13/viper) from 1.14.0 to 1.15.0. - [Release notes](https://github.com/spf13/viper/releases) - [Commits](https://github.com/spf13/viper/compare/v1.14.0...v1.15.0) --- updated-dependencies: - dependency-name: github.com/spf13/viper dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
-rw-r--r--go.mod9
-rw-r--r--go.sum18
-rw-r--r--vendor/github.com/magiconair/properties/.travis.yml17
-rw-r--r--vendor/github.com/magiconair/properties/CHANGELOG.md45
-rw-r--r--vendor/github.com/magiconair/properties/decode.go66
-rw-r--r--vendor/github.com/magiconair/properties/doc.go127
-rw-r--r--vendor/github.com/magiconair/properties/integrate.go7
-rw-r--r--vendor/github.com/magiconair/properties/lex.go2
-rw-r--r--vendor/github.com/magiconair/properties/load.go2
-rw-r--r--vendor/github.com/magiconair/properties/parser.go2
-rw-r--r--vendor/github.com/magiconair/properties/properties.go17
-rw-r--r--vendor/github.com/magiconair/properties/rangecheck.go2
-rw-r--r--vendor/github.com/pelletier/go-toml/.dockerignore2
-rw-r--r--vendor/github.com/pelletier/go-toml/.gitignore5
-rw-r--r--vendor/github.com/pelletier/go-toml/CONTRIBUTING.md132
-rw-r--r--vendor/github.com/pelletier/go-toml/Dockerfile11
-rw-r--r--vendor/github.com/pelletier/go-toml/LICENSE247
-rw-r--r--vendor/github.com/pelletier/go-toml/Makefile29
-rw-r--r--vendor/github.com/pelletier/go-toml/PULL_REQUEST_TEMPLATE.md5
-rw-r--r--vendor/github.com/pelletier/go-toml/README.md176
-rw-r--r--vendor/github.com/pelletier/go-toml/SECURITY.md19
-rw-r--r--vendor/github.com/pelletier/go-toml/azure-pipelines.yml188
-rw-r--r--vendor/github.com/pelletier/go-toml/benchmark.sh35
-rw-r--r--vendor/github.com/pelletier/go-toml/doc.go23
-rw-r--r--vendor/github.com/pelletier/go-toml/example-crlf.toml30
-rw-r--r--vendor/github.com/pelletier/go-toml/example.toml30
-rw-r--r--vendor/github.com/pelletier/go-toml/fuzz.go31
-rw-r--r--vendor/github.com/pelletier/go-toml/fuzz.sh15
-rw-r--r--vendor/github.com/pelletier/go-toml/keysparsing.go112
-rw-r--r--vendor/github.com/pelletier/go-toml/lexer.go1031
-rw-r--r--vendor/github.com/pelletier/go-toml/localtime.go287
-rw-r--r--vendor/github.com/pelletier/go-toml/marshal.go1308
-rw-r--r--vendor/github.com/pelletier/go-toml/marshal_OrderPreserve_test.toml39
-rw-r--r--vendor/github.com/pelletier/go-toml/marshal_test.toml39
-rw-r--r--vendor/github.com/pelletier/go-toml/parser.go507
-rw-r--r--vendor/github.com/pelletier/go-toml/position.go29
-rw-r--r--vendor/github.com/pelletier/go-toml/token.go136
-rw-r--r--vendor/github.com/pelletier/go-toml/toml.go533
-rw-r--r--vendor/github.com/pelletier/go-toml/tomlpub.go71
-rw-r--r--vendor/github.com/pelletier/go-toml/tomltree_create.go155
-rw-r--r--vendor/github.com/pelletier/go-toml/tomltree_write.go552
-rw-r--r--vendor/github.com/pelletier/go-toml/tomltree_writepub.go6
-rw-r--r--vendor/github.com/spf13/afero/memmap.go5
-rw-r--r--vendor/github.com/spf13/viper/Makefile2
-rw-r--r--vendor/github.com/spf13/viper/README.md6
-rw-r--r--vendor/github.com/spf13/viper/internal/encoding/toml/codec.go29
-rw-r--r--vendor/github.com/spf13/viper/internal/encoding/toml/codec2.go19
-rw-r--r--vendor/github.com/spf13/viper/internal/encoding/yaml/codec.go2
-rw-r--r--vendor/github.com/spf13/viper/internal/encoding/yaml/yaml2.go14
-rw-r--r--vendor/github.com/spf13/viper/internal/encoding/yaml/yaml3.go14
-rw-r--r--vendor/github.com/spf13/viper/viper.go5
-rw-r--r--vendor/github.com/subosito/gotenv/gotenv.go44
-rw-r--r--vendor/modules.txt13
53 files changed, 218 insertions, 6032 deletions
diff --git a/go.mod b/go.mod
index 5afaa431e..47a826752 100644
--- a/go.mod
+++ b/go.mod
@@ -38,7 +38,7 @@ require (
github.com/oklog/ulid v1.3.1
github.com/robfig/cron/v3 v3.0.1
github.com/spf13/cobra v1.6.1
- github.com/spf13/viper v1.14.0
+ github.com/spf13/viper v1.15.0
github.com/stretchr/testify v1.8.1
github.com/superseriousbusiness/activity v1.2.1-gts
github.com/superseriousbusiness/exif-terminator v0.5.0
@@ -120,14 +120,13 @@ require (
github.com/klauspost/compress v1.15.9 // indirect
github.com/klauspost/cpuid/v2 v2.1.1 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
- github.com/magiconair/properties v1.8.6 // indirect
+ github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/opencontainers/runtime-spec v1.0.2 // indirect
- github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
@@ -135,11 +134,11 @@ require (
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/rs/xid v1.4.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
- github.com/spf13/afero v1.9.2 // indirect
+ github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
- github.com/subosito/gotenv v1.4.1 // indirect
+ github.com/subosito/gotenv v1.4.2 // indirect
github.com/superseriousbusiness/go-jpeg-image-structure/v2 v2.0.0-20220321154430-d89a106fdabe // indirect
github.com/tdewolff/parse/v2 v2.6.4 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
diff --git a/go.sum b/go.sum
index 9bb9d91ff..e46cd0a01 100644
--- a/go.sum
+++ b/go.sum
@@ -415,8 +415,8 @@ github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.3 h1:v9QZf2Sn6AmjXtQeFpdoq/eaNtYP6IN+7lcrygsIAtg=
-github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo=
-github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
+github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
+github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
@@ -460,8 +460,6 @@ github.com/opencontainers/runtime-spec v1.0.2 h1:UfAcuLBJB9Coz72x1hgl8O5RVzTdNia
github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/orcaman/writerseeker v0.0.0-20200621085525-1d3f536ff85e h1:s2RNOM/IGdY0Y6qfTeUKhDawdHDpK9RGBdx80qN4Ttw=
github.com/orcaman/writerseeker v0.0.0-20200621085525-1d3f536ff85e/go.mod h1:nBdnFKj15wFbf94Rwfq4m30eAcyY9V/IyKAGQFtqkW0=
-github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
-github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
@@ -506,8 +504,8 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykE
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
-github.com/spf13/afero v1.9.2 h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw=
-github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y=
+github.com/spf13/afero v1.9.3 h1:41FoI0fD7OR7mGcKE/aOiLkGreyf8ifIOQmJANWogMk=
+github.com/spf13/afero v1.9.3/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y=
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
@@ -516,8 +514,8 @@ github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmq
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
-github.com/spf13/viper v1.14.0 h1:Rg7d3Lo706X9tHsJMUjdiwMpHB7W8WnSVOssIY+JElU=
-github.com/spf13/viper v1.14.0/go.mod h1:WT//axPky3FdvXHzGw33dNdXXXfFQqmEalje+egj8As=
+github.com/spf13/viper v1.15.0 h1:js3yy885G8xwJa6iOISGFwd+qlUo5AvyXb7CiihdtiU=
+github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
@@ -533,8 +531,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
-github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs=
-github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
+github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
+github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
github.com/sunfish-shogi/bufseekio v0.0.0-20210207115823-a4185644b365/go.mod h1:dEzdXgvImkQ3WLI+0KQpmEx8T/C/ma9KeS3AfmU899I=
github.com/superseriousbusiness/activity v1.2.1-gts h1:wh7v0zYa1mJmqB35PSfvgl4cs51Dh5PyfKvcZLSxMQU=
github.com/superseriousbusiness/activity v1.2.1-gts/go.mod h1:AZw0Xb4Oju8rmaJCZ21gc5CPg47MmNgyac+Hx5jo8VM=
diff --git a/vendor/github.com/magiconair/properties/.travis.yml b/vendor/github.com/magiconair/properties/.travis.yml
deleted file mode 100644
index baf9031df..000000000
--- a/vendor/github.com/magiconair/properties/.travis.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-language: go
-go:
- - 1.3.x
- - 1.4.x
- - 1.5.x
- - 1.6.x
- - 1.7.x
- - 1.8.x
- - 1.9.x
- - "1.10.x"
- - "1.11.x"
- - "1.12.x"
- - "1.13.x"
- - "1.14.x"
- - "1.15.x"
- - "1.16.x"
- - tip
diff --git a/vendor/github.com/magiconair/properties/CHANGELOG.md b/vendor/github.com/magiconair/properties/CHANGELOG.md
index ff8d02535..842e8e24f 100644
--- a/vendor/github.com/magiconair/properties/CHANGELOG.md
+++ b/vendor/github.com/magiconair/properties/CHANGELOG.md
@@ -1,5 +1,50 @@
## Changelog
+### [1.8.7](https://github.com/magiconair/properties/tree/v1.8.7) - 08 Dec 2022
+
+ * [PR #65](https://github.com/magiconair/properties/pull/65): Speedup Merge
+
+ Thanks to [@AdityaVallabh](https://github.com/AdityaVallabh) for the patch.
+
+ * [PR #66](https://github.com/magiconair/properties/pull/66): use github actions
+
+### [1.8.6](https://github.com/magiconair/properties/tree/v1.8.6) - 23 Feb 2022
+
+ * [PR #57](https://github.com/magiconair/properties/pull/57):Fix "unreachable code" lint error
+
+ Thanks to [@ellie](https://github.com/ellie) for the patch.
+
+ * [PR #63](https://github.com/magiconair/properties/pull/63): Make TestMustGetParsedDuration backwards compatible
+
+ This patch ensures that the `TestMustGetParsedDuration` still works with `go1.3` to make the
+ author happy until it affects real users.
+
+ Thanks to [@maage](https://github.com/maage) for the patch.
+
+### [1.8.5](https://github.com/magiconair/properties/tree/v1.8.5) - 24 Mar 2021
+
+ * [PR #55](https://github.com/magiconair/properties/pull/55): Fix: Encoding Bug in Comments
+
+ When reading comments \ are loaded correctly, but when writing they are then
+ replaced by \\. This leads to wrong comments when writing and reading multiple times.
+
+ Thanks to [@doxsch](https://github.com/doxsch) for the patch.
+
+### [1.8.4](https://github.com/magiconair/properties/tree/v1.8.4) - 23 Sep 2020
+
+ * [PR #50](https://github.com/magiconair/properties/pull/50): enhance error message for circular references
+
+ Thanks to [@sriv](https://github.com/sriv) for the patch.
+
+### [1.8.3](https://github.com/magiconair/properties/tree/v1.8.3) - 14 Sep 2020
+
+ * [PR #49](https://github.com/magiconair/properties/pull/49): Include the key in error message causing the circular reference
+
+ The change is include the key in the error message which is causing the circular
+ reference when parsing/loading the properties files.
+
+ Thanks to [@haroon-sheikh](https://github.com/haroon-sheikh) for the patch.
+
### [1.8.2](https://github.com/magiconair/properties/tree/v1.8.2) - 25 Aug 2020
* [PR #36](https://github.com/magiconair/properties/pull/36): Escape backslash on write
diff --git a/vendor/github.com/magiconair/properties/decode.go b/vendor/github.com/magiconair/properties/decode.go
index 3ebf8049c..8e6aa441d 100644
--- a/vendor/github.com/magiconair/properties/decode.go
+++ b/vendor/github.com/magiconair/properties/decode.go
@@ -1,4 +1,4 @@
-// Copyright 2018 Frank Schroeder. All rights reserved.
+// Copyright 2013-2022 Frank Schroeder. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
@@ -48,49 +48,49 @@ import (
//
// Examples:
//
-// // Field is ignored.
-// Field int `properties:"-"`
+// // Field is ignored.
+// Field int `properties:"-"`
//
-// // Field is assigned value of 'Field'.
-// Field int
+// // Field is assigned value of 'Field'.
+// Field int
//
-// // Field is assigned value of 'myName'.
-// Field int `properties:"myName"`
+// // Field is assigned value of 'myName'.
+// Field int `properties:"myName"`
//
-// // Field is assigned value of key 'myName' and has a default
-// // value 15 if the key does not exist.
-// Field int `properties:"myName,default=15"`
+// // Field is assigned value of key 'myName' and has a default
+// // value 15 if the key does not exist.
+// Field int `properties:"myName,default=15"`
//
-// // Field is assigned value of key 'Field' and has a default
-// // value 15 if the key does not exist.
-// Field int `properties:",default=15"`
+// // Field is assigned value of key 'Field' and has a default
+// // value 15 if the key does not exist.
+// Field int `properties:",default=15"`
//
-// // Field is assigned value of key 'date' and the date
-// // is in format 2006-01-02
-// Field time.Time `properties:"date,layout=2006-01-02"`
+// // Field is assigned value of key 'date' and the date
+// // is in format 2006-01-02
+// Field time.Time `properties:"date,layout=2006-01-02"`
//
-// // Field is assigned the non-empty and whitespace trimmed
-// // values of key 'Field' split by commas.
-// Field []string
+// // Field is assigned the non-empty and whitespace trimmed
+// // values of key 'Field' split by commas.
+// Field []string
//
-// // Field is assigned the non-empty and whitespace trimmed
-// // values of key 'Field' split by commas and has a default
-// // value ["a", "b", "c"] if the key does not exist.
-// Field []string `properties:",default=a;b;c"`
+// // Field is assigned the non-empty and whitespace trimmed
+// // values of key 'Field' split by commas and has a default
+// // value ["a", "b", "c"] if the key does not exist.
+// Field []string `properties:",default=a;b;c"`
//
-// // Field is decoded recursively with "Field." as key prefix.
-// Field SomeStruct
+// // Field is decoded recursively with "Field." as key prefix.
+// Field SomeStruct
//
-// // Field is decoded recursively with "myName." as key prefix.
-// Field SomeStruct `properties:"myName"`
+// // Field is decoded recursively with "myName." as key prefix.
+// Field SomeStruct `properties:"myName"`
//
-// // Field is decoded recursively with "Field." as key prefix
-// // and the next dotted element of the key as map key.
-// Field map[string]string
+// // Field is decoded recursively with "Field." as key prefix
+// // and the next dotted element of the key as map key.
+// Field map[string]string
//
-// // Field is decoded recursively with "myName." as key prefix
-// // and the next dotted element of the key as map key.
-// Field map[string]string `properties:"myName"`
+// // Field is decoded recursively with "myName." as key prefix
+// // and the next dotted element of the key as map key.
+// Field map[string]string `properties:"myName"`
func (p *Properties) Decode(x interface{}) error {
t, v := reflect.TypeOf(x), reflect.ValueOf(x)
if t.Kind() != reflect.Ptr || v.Elem().Type().Kind() != reflect.Struct {
diff --git a/vendor/github.com/magiconair/properties/doc.go b/vendor/github.com/magiconair/properties/doc.go
index f8822da2b..7c7979315 100644
--- a/vendor/github.com/magiconair/properties/doc.go
+++ b/vendor/github.com/magiconair/properties/doc.go
@@ -1,4 +1,4 @@
-// Copyright 2018 Frank Schroeder. All rights reserved.
+// Copyright 2013-2022 Frank Schroeder. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
@@ -13,7 +13,7 @@
//
// To load a single properties file use MustLoadFile():
//
-// p := properties.MustLoadFile(filename, properties.UTF8)
+// p := properties.MustLoadFile(filename, properties.UTF8)
//
// To load multiple properties files use MustLoadFiles()
// which loads the files in the given order and merges the
@@ -23,25 +23,25 @@
// Filenames can contain environment variables which are expanded
// before loading.
//
-// f1 := "/etc/myapp/myapp.conf"
-// f2 := "/home/${USER}/myapp.conf"
-// p := MustLoadFiles([]string{f1, f2}, properties.UTF8, true)
+// f1 := "/etc/myapp/myapp.conf"
+// f2 := "/home/${USER}/myapp.conf"
+// p := MustLoadFiles([]string{f1, f2}, properties.UTF8, true)
//
// All of the different key/value delimiters ' ', ':' and '=' are
// supported as well as the comment characters '!' and '#' and
// multi-line values.
//
-// ! this is a comment
-// # and so is this
+// ! this is a comment
+// # and so is this
//
-// # the following expressions are equal
-// key value
-// key=value
-// key:value
-// key = value
-// key : value
-// key = val\
-// ue
+// # the following expressions are equal
+// key value
+// key=value
+// key:value
+// key = value
+// key : value
+// key = val\
+// ue
//
// Properties stores all comments preceding a key and provides
// GetComments() and SetComments() methods to retrieve and
@@ -55,62 +55,62 @@
// and malformed expressions are not allowed and cause an
// error. Expansion of environment variables is supported.
//
-// # standard property
-// key = value
+// # standard property
+// key = value
//
-// # property expansion: key2 = value
-// key2 = ${key}
+// # property expansion: key2 = value
+// key2 = ${key}
//
-// # recursive expansion: key3 = value
-// key3 = ${key2}
+// # recursive expansion: key3 = value
+// key3 = ${key2}
//
-// # circular reference (error)
-// key = ${key}
+// # circular reference (error)
+// key = ${key}
//
-// # malformed expression (error)
-// key = ${ke
+// # malformed expression (error)
+// key = ${ke
//
-// # refers to the users' home dir
-// home = ${HOME}
+// # refers to the users' home dir
+// home = ${HOME}
//
-// # local key takes precedence over env var: u = foo
-// USER = foo
-// u = ${USER}
+// # local key takes precedence over env var: u = foo
+// USER = foo
+// u = ${USER}
//
// The default property expansion format is ${key} but can be
// changed by setting different pre- and postfix values on the
// Properties object.
//
-// p := properties.NewProperties()
-// p.Prefix = "#["
-// p.Postfix = "]#"
+// p := properties.NewProperties()
+// p.Prefix = "#["
+// p.Postfix = "]#"
//
// Properties provides convenience functions for getting typed
// values with default values if the key does not exist or the
// type conversion failed.
//
-// # Returns true if the value is either "1", "on", "yes" or "true"
-// # Returns false for every other value and the default value if
-// # the key does not exist.
-// v = p.GetBool("key", false)
+// # Returns true if the value is either "1", "on", "yes" or "true"
+// # Returns false for every other value and the default value if
+// # the key does not exist.
+// v = p.GetBool("key", false)
//
-// # Returns the value if the key exists and the format conversion
-// # was successful. Otherwise, the default value is returned.
-// v = p.GetInt64("key", 999)
-// v = p.GetUint64("key", 999)
-// v = p.GetFloat64("key", 123.0)
-// v = p.GetString("key", "def")
-// v = p.GetDuration("key", 999)
+// # Returns the value if the key exists and the format conversion
+// # was successful. Otherwise, the default value is returned.
+// v = p.GetInt64("key", 999)
+// v = p.GetUint64("key", 999)
+// v = p.GetFloat64("key", 123.0)
+// v = p.GetString("key", "def")
+// v = p.GetDuration("key", 999)
//
// As an alternative properties may be applied with the standard
// library's flag implementation at any time.
//
-// # Standard configuration
-// v = flag.Int("key", 999, "help message")
-// flag.Parse()
+// # Standard configuration
+// v = flag.Int("key", 999, "help message")
+// flag.Parse()
//
-// # Merge p into the flag set
-// p.MustFlag(flag.CommandLine)
+// # Merge p into the flag set
+// p.MustFlag(flag.CommandLine)
//
// Properties provides several MustXXX() convenience functions
// which will terminate the app if an error occurs. The behavior
@@ -119,30 +119,30 @@
// of logging the error set a different ErrorHandler before
// you use the Properties package.
//
-// properties.ErrorHandler = properties.PanicHandler
+// properties.ErrorHandler = properties.PanicHandler
//
-// # Will panic instead of logging an error
-// p := properties.MustLoadFile("config.properties")
+// # Will panic instead of logging an error
+// p := properties.MustLoadFile("config.properties")
//
// You can also provide your own ErrorHandler function. The only requirement
// is that the error handler function must exit after handling the error.
//
-// properties.ErrorHandler = func(err error) {
-// fmt.Println(err)
-// os.Exit(1)
-// }
+// properties.ErrorHandler = func(err error) {
+// fmt.Println(err)
+// os.Exit(1)
+// }
//
-// # Will write to stdout and then exit
-// p := properties.MustLoadFile("config.properties")
+// # Will write to stdout and then exit
+// p := properties.MustLoadFile("config.properties")
//
// Properties can also be loaded into a struct via the `Decode`
// method, e.g.
//
-// type S struct {
-// A string `properties:"a,default=foo"`
-// D time.Duration `properties:"timeout,default=5s"`
-// E time.Time `properties:"expires,layout=2006-01-02,default=2015-01-01"`
-// }
+// type S struct {
+// A string `properties:"a,default=foo"`
+// D time.Duration `properties:"timeout,default=5s"`
+// E time.Time `properties:"expires,layout=2006-01-02,default=2015-01-01"`
+// }
//
// See `Decode()` method for the full documentation.
//
@@ -152,5 +152,4 @@
// http://en.wikipedia.org/wiki/.properties
//
// http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html#load%28java.io.Reader%29
-//
package properties
diff --git a/vendor/github.com/magiconair/properties/integrate.go b/vendor/github.com/magiconair/properties/integrate.go
index 74d38dc67..35d0ae97b 100644
--- a/vendor/github.com/magiconair/properties/integrate.go
+++ b/vendor/github.com/magiconair/properties/integrate.go
@@ -1,4 +1,4 @@
-// Copyright 2018 Frank Schroeder. All rights reserved.
+// Copyright 2013-2022 Frank Schroeder. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
@@ -10,8 +10,9 @@ import "flag"
// the respective key for flag.Flag.Name.
//
// It's use is recommended with command line arguments as in:
-// flag.Parse()
-// p.MustFlag(flag.CommandLine)
+//
+// flag.Parse()
+// p.MustFlag(flag.CommandLine)
func (p *Properties) MustFlag(dst *flag.FlagSet) {
m := make(map[string]*flag.Flag)
dst.VisitAll(func(f *flag.Flag) {
diff --git a/vendor/github.com/magiconair/properties/lex.go b/vendor/github.com/magiconair/properties/lex.go
index e1e9dd7b1..3d15a1f6e 100644
--- a/vendor/github.com/magiconair/properties/lex.go
+++ b/vendor/github.com/magiconair/properties/lex.go
@@ -1,4 +1,4 @@
-// Copyright 2018 Frank Schroeder. All rights reserved.
+// Copyright 2013-2022 Frank Schroeder. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
diff --git a/vendor/github.com/magiconair/properties/load.go b/vendor/github.com/magiconair/properties/load.go
index c83c2dadd..635368dc8 100644
--- a/vendor/github.com/magiconair/properties/load.go
+++ b/vendor/github.com/magiconair/properties/load.go
@@ -1,4 +1,4 @@
-// Copyright 2018 Frank Schroeder. All rights reserved.
+// Copyright 2013-2022 Frank Schroeder. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/vendor/github.com/magiconair/properties/parser.go b/vendor/github.com/magiconair/properties/parser.go
index 430e4fcd2..fccfd39f6 100644
--- a/vendor/github.com/magiconair/properties/parser.go
+++ b/vendor/github.com/magiconair/properties/parser.go
@@ -1,4 +1,4 @@
-// Copyright 2018 Frank Schroeder. All rights reserved.
+// Copyright 2013-2022 Frank Schroeder. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/vendor/github.com/magiconair/properties/properties.go b/vendor/github.com/magiconair/properties/properties.go
index 62ae2d67a..fb2f7b404 100644
--- a/vendor/github.com/magiconair/properties/properties.go
+++ b/vendor/github.com/magiconair/properties/properties.go
@@ -1,4 +1,4 @@
-// Copyright 2018 Frank Schroeder. All rights reserved.
+// Copyright 2013-2022 Frank Schroeder. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
@@ -700,22 +700,17 @@ func (p *Properties) Delete(key string) {
// Merge merges properties, comments and keys from other *Properties into p
func (p *Properties) Merge(other *Properties) {
+ for _, k := range other.k {
+ if _, ok := p.m[k]; !ok {
+ p.k = append(p.k, k)
+ }
+ }
for k, v := range other.m {
p.m[k] = v
}
for k, v := range other.c {
p.c[k] = v
}
-
-outer:
- for _, otherKey := range other.k {
- for _, key := range p.k {
- if otherKey == key {
- continue outer
- }
- }
- p.k = append(p.k, otherKey)
- }
}
// ----------------------------------------------------------------------------
diff --git a/vendor/github.com/magiconair/properties/rangecheck.go b/vendor/github.com/magiconair/properties/rangecheck.go
index b013a2e5e..dbd60b36e 100644
--- a/vendor/github.com/magiconair/properties/rangecheck.go
+++ b/vendor/github.com/magiconair/properties/rangecheck.go
@@ -1,4 +1,4 @@
-// Copyright 2018 Frank Schroeder. All rights reserved.
+// Copyright 2013-2022 Frank Schroeder. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/vendor/github.com/pelletier/go-toml/.dockerignore b/vendor/github.com/pelletier/go-toml/.dockerignore
deleted file mode 100644
index 7b5883475..000000000
--- a/vendor/github.com/pelletier/go-toml/.dockerignore
+++ /dev/null
@@ -1,2 +0,0 @@
-cmd/tomll/tomll
-cmd/tomljson/tomljson
diff --git a/vendor/github.com/pelletier/go-toml/.gitignore b/vendor/github.com/pelletier/go-toml/.gitignore
deleted file mode 100644
index e6ba63a5c..000000000
--- a/vendor/github.com/pelletier/go-toml/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-test_program/test_program_bin
-fuzz/
-cmd/tomll/tomll
-cmd/tomljson/tomljson
-cmd/tomltestgen/tomltestgen
diff --git a/vendor/github.com/pelletier/go-toml/CONTRIBUTING.md b/vendor/github.com/pelletier/go-toml/CONTRIBUTING.md
deleted file mode 100644
index 98b9893d3..000000000
--- a/vendor/github.com/pelletier/go-toml/CONTRIBUTING.md
+++ /dev/null
@@ -1,132 +0,0 @@
-## Contributing
-
-Thank you for your interest in go-toml! We appreciate you considering
-contributing to go-toml!
-
-The main goal is the project is to provide an easy-to-use TOML
-implementation for Go that gets the job done and gets out of your way –
-dealing with TOML is probably not the central piece of your project.
-
-As the single maintainer of go-toml, time is scarce. All help, big or
-small, is more than welcomed!
-
-### Ask questions
-
-Any question you may have, somebody else might have it too. Always feel
-free to ask them on the [issues tracker][issues-tracker]. We will try to
-answer them as clearly and quickly as possible, time permitting.
-
-Asking questions also helps us identify areas where the documentation needs
-improvement, or new features that weren't envisioned before. Sometimes, a
-seemingly innocent question leads to the fix of a bug. Don't hesitate and
-ask away!
-
-### Improve the documentation
-
-The best way to share your knowledge and experience with go-toml is to
-improve the documentation. Fix a typo, clarify an interface, add an
-example, anything goes!
-
-The documentation is present in the [README][readme] and thorough the
-source code. On release, it gets updated on [pkg.go.dev][pkg.go.dev]. To make a
-change to the documentation, create a pull request with your proposed
-changes. For simple changes like that, the easiest way to go is probably
-the "Fork this project and edit the file" button on Github, displayed at
-the top right of the file. Unless it's a trivial change (for example a
-typo), provide a little bit of context in your pull request description or
-commit message.
-
-### Report a bug
-
-Found a bug! Sorry to hear that :(. Help us and other track them down and
-fix by reporting it. [File a new bug report][bug-report] on the [issues
-tracker][issues-tracker]. The template should provide enough guidance on
-what to include. When in doubt: add more details! By reducing ambiguity and
-providing more information, it decreases back and forth and saves everyone
-time.
-
-### Code changes
-
-Want to contribute a patch? Very happy to hear that!
-
-First, some high-level rules:
-
-* A short proposal with some POC code is better than a lengthy piece of
- text with no code. Code speaks louder than words.
-* No backward-incompatible patch will be accepted unless discussed.
- Sometimes it's hard, and Go's lack of versioning by default does not
- help, but we try not to break people's programs unless we absolutely have
- to.
-* If you are writing a new feature or extending an existing one, make sure
- to write some documentation.
-* Bug fixes need to be accompanied with regression tests.
-* New code needs to be tested.
-* Your commit messages need to explain why the change is needed, even if
- already included in the PR description.
-
-It does sound like a lot, but those best practices are here to save time
-overall and continuously improve the quality of the project, which is
-something everyone benefits from.
-
-#### Get started
-
-The fairly standard code contribution process looks like that:
-
-1. [Fork the project][fork].
-2. Make your changes, commit on any branch you like.
-3. [Open up a pull request][pull-request]
-4. Review, potential ask for changes.
-5. Merge. You're in!
-
-Feel free to ask for help! You can create draft pull requests to gather
-some early feedback!
-
-#### Run the tests
-
-You can run tests for go-toml using Go's test tool: `go test ./...`.
-When creating a pull requests, all tests will be ran on Linux on a few Go
-versions (Travis CI), and on Windows using the latest Go version
-(AppVeyor).
-
-#### Style
-
-Try to look around and follow the same format and structure as the rest of
-the code. We enforce using `go fmt` on the whole code base.
-
----
-
-### Maintainers-only
-
-#### Merge pull request
-
-Checklist:
-
-* Passing CI.
-* Does not introduce backward-incompatible changes (unless discussed).
-* Has relevant doc changes.
-* Has relevant unit tests.
-
-1. Merge using "squash and merge".
-2. Make sure to edit the commit message to keep all the useful information
- nice and clean.
-3. Make sure the commit title is clear and contains the PR number (#123).
-
-#### New release
-
-1. Go to [releases][releases]. Click on "X commits to master since this
- release".
-2. Make note of all the changes. Look for backward incompatible changes,
- new features, and bug fixes.
-3. Pick the new version using the above and semver.
-4. Create a [new release][new-release].
-5. Follow the same format as [1.1.0][release-110].
-
-[issues-tracker]: https://github.com/pelletier/go-toml/issues
-[bug-report]: https://github.com/pelletier/go-toml/issues/new?template=bug_report.md
-[pkg.go.dev]: https://pkg.go.dev/github.com/pelletier/go-toml
-[readme]: ./README.md
-[fork]: https://help.github.com/articles/fork-a-repo
-[pull-request]: https://help.github.com/en/articles/creating-a-pull-request
-[releases]: https://github.com/pelletier/go-toml/releases
-[new-release]: https://github.com/pelletier/go-toml/releases/new
-[release-110]: https://github.com/pelletier/go-toml/releases/tag/v1.1.0
diff --git a/vendor/github.com/pelletier/go-toml/Dockerfile b/vendor/github.com/pelletier/go-toml/Dockerfile
deleted file mode 100644
index fffdb0166..000000000
--- a/vendor/github.com/pelletier/go-toml/Dockerfile
+++ /dev/null
@@ -1,11 +0,0 @@
-FROM golang:1.12-alpine3.9 as builder
-WORKDIR /go/src/github.com/pelletier/go-toml
-COPY . .
-ENV CGO_ENABLED=0
-ENV GOOS=linux
-RUN go install ./...
-
-FROM scratch
-COPY --from=builder /go/bin/tomll /usr/bin/tomll
-COPY --from=builder /go/bin/tomljson /usr/bin/tomljson
-COPY --from=builder /go/bin/jsontoml /usr/bin/jsontoml
diff --git a/vendor/github.com/pelletier/go-toml/LICENSE b/vendor/github.com/pelletier/go-toml/LICENSE
deleted file mode 100644
index f414553c2..000000000
--- a/vendor/github.com/pelletier/go-toml/LICENSE
+++ /dev/null
@@ -1,247 +0,0 @@
-The bulk of github.com/pelletier/go-toml is distributed under the MIT license
-(see below), with the exception of localtime.go and localtime.test.go.
-Those two files have been copied over from Google's civil library at revision
-ed46f5086358513cf8c25f8e3f022cb838a49d66, and are distributed under the Apache
-2.0 license (see below).
-
-
-github.com/pelletier/go-toml:
-
-
-The MIT License (MIT)
-
-Copyright (c) 2013 - 2021 Thomas Pelletier, Eric Anderton
-
-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.
-
-
-localtime.go, localtime_test.go:
-
-Originals:
- https://raw.githubusercontent.com/googleapis/google-cloud-go/ed46f5086358513cf8c25f8e3f022cb838a49d66/civil/civil.go
- https://raw.githubusercontent.com/googleapis/google-cloud-go/ed46f5086358513cf8c25f8e3f022cb838a49d66/civil/civil_test.go
-Changes:
- * Renamed files from civil* to localtime*.
- * Package changed from civil to toml.
- * 'Local' prefix added to all structs.
-License:
- https://raw.githubusercontent.com/googleapis/google-cloud-go/ed46f5086358513cf8c25f8e3f022cb838a49d66/LICENSE
-
-
- 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/pelletier/go-toml/Makefile b/vendor/github.com/pelletier/go-toml/Makefile
deleted file mode 100644
index 9e4503aea..000000000
--- a/vendor/github.com/pelletier/go-toml/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-export CGO_ENABLED=0
-go := go
-go.goos ?= $(shell echo `go version`|cut -f4 -d ' '|cut -d '/' -f1)
-go.goarch ?= $(shell echo `go version`|cut -f4 -d ' '|cut -d '/' -f2)
-
-out.tools := tomll tomljson jsontoml
-out.dist := $(out.tools:=_$(go.goos)_$(go.goarch).tar.xz)
-sources := $(wildcard **/*.go)
-
-
-.PHONY:
-tools: $(out.tools)
-
-$(out.tools): $(sources)
- GOOS=$(go.goos) GOARCH=$(go.goarch) $(go) build ./cmd/$@
-
-.PHONY:
-dist: $(out.dist)
-
-$(out.dist):%_$(go.goos)_$(go.goarch).tar.xz: %
- if [ "$(go.goos)" = "windows" ]; then \
- tar -cJf $@ $^.exe; \
- else \
- tar -cJf $@ $^; \
- fi
-
-.PHONY:
-clean:
- rm -rf $(out.tools) $(out.dist)
diff --git a/vendor/github.com/pelletier/go-toml/PULL_REQUEST_TEMPLATE.md b/vendor/github.com/pelletier/go-toml/PULL_REQUEST_TEMPLATE.md
deleted file mode 100644
index 041cdc4a2..000000000
--- a/vendor/github.com/pelletier/go-toml/PULL_REQUEST_TEMPLATE.md
+++ /dev/null
@@ -1,5 +0,0 @@
-**Issue:** add link to pelletier/go-toml issue here
-
-Explanation of what this pull request does.
-
-More detailed description of the decisions being made and the reasons why (if the patch is non-trivial).
diff --git a/vendor/github.com/pelletier/go-toml/README.md b/vendor/github.com/pelletier/go-toml/README.md
deleted file mode 100644
index 7399e04bf..000000000
--- a/vendor/github.com/pelletier/go-toml/README.md
+++ /dev/null
@@ -1,176 +0,0 @@
-# go-toml
-
-Go library for the [TOML](https://toml.io/) format.
-
-This library supports TOML version
-[v1.0.0-rc.3](https://toml.io/en/v1.0.0-rc.3)
-
-[![Go Reference](https://pkg.go.dev/badge/github.com/pelletier/go-toml.svg)](https://pkg.go.dev/github.com/pelletier/go-toml)
-[![license](https://img.shields.io/github/license/pelletier/go-toml.svg)](https://github.com/pelletier/go-toml/blob/master/LICENSE)
-[![Build Status](https://dev.azure.com/pelletierthomas/go-toml-ci/_apis/build/status/pelletier.go-toml?branchName=master)](https://dev.azure.com/pelletierthomas/go-toml-ci/_build/latest?definitionId=1&branchName=master)
-[![codecov](https://codecov.io/gh/pelletier/go-toml/branch/master/graph/badge.svg)](https://codecov.io/gh/pelletier/go-toml)
-[![Go Report Card](https://goreportcard.com/badge/github.com/pelletier/go-toml)](https://goreportcard.com/report/github.com/pelletier/go-toml)
-[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fpelletier%2Fgo-toml.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fpelletier%2Fgo-toml?ref=badge_shield)
-
-
-## Development status
-
-**ℹ️ Consider go-toml v2!**
-
-The next version of go-toml is in [active development][v2-dev], and
-[nearing completion][v2-map].
-
-Though technically in beta, v2 is already more tested, [fixes bugs][v1-bugs],
-and [much faster][v2-bench]. If you only need reading and writing TOML documents
-(majority of cases), those features are implemented and the API unlikely to
-change.
-
-The remaining features will be added shortly. While pull-requests are welcome on
-v1, no active development is expected on it. When v2.0.0 is released, v1 will be
-deprecated.
-
-👉 [go-toml v2][v2]
-
-[v2]: https://github.com/pelletier/go-toml/tree/v2
-[v2-map]: https://github.com/pelletier/go-toml/discussions/506
-[v2-dev]: https://github.com/pelletier/go-toml/tree/v2
-[v1-bugs]: https://github.com/pelletier/go-toml/issues?q=is%3Aissue+is%3Aopen+label%3Av2-fixed
-[v2-bench]: https://github.com/pelletier/go-toml/tree/v2#benchmarks
-
-## Features
-
-Go-toml provides the following features for using data parsed from TOML documents:
-
-* Load TOML documents from files and string data
-* Easily navigate TOML structure using Tree
-* Marshaling and unmarshaling to and from data structures
-* Line & column position data for all parsed elements
-* [Query support similar to JSON-Path](query/)
-* Syntax errors contain line and column numbers
-
-## Import
-
-```go
-import "github.com/pelletier/go-toml"
-```
-
-## Usage example
-
-Read a TOML document:
-
-```go
-config, _ := toml.Load(`
-[postgres]
-user = "pelletier"
-password = "mypassword"`)
-// retrieve data directly
-user := config.Get("postgres.user").(string)
-
-// or using an intermediate object
-postgresConfig := config.Get("postgres").(*toml.Tree)
-password := postgresConfig.Get("password").(string)
-```
-
-Or use Unmarshal:
-
-```go
-type Postgres struct {
- User string
- Password string
-}
-type Config struct {
- Postgres Postgres
-}
-
-doc := []byte(`
-[Postgres]
-User = "pelletier"
-Password = "mypassword"`)
-
-config := Config{}
-toml.Unmarshal(doc, &config)
-fmt.Println("user=", config.Postgres.User)
-```
-
-Or use a query:
-
-```go
-// use a query to gather elements without walking the tree
-q, _ := query.Compile("$..[user,password]")
-results := q.Execute(config)
-for ii, item := range results.Values() {
- fmt.Printf("Query result %d: %v\n", ii, item)
-}
-```
-
-## Documentation
-
-The documentation and additional examples are available at
-[pkg.go.dev](https://pkg.go.dev/github.com/pelletier/go-toml).
-
-## Tools
-
-Go-toml provides three handy command line tools:
-
-* `tomll`: Reads TOML files and lints them.
-
- ```
- go install github.com/pelletier/go-toml/cmd/tomll
- tomll --help
- ```
-* `tomljson`: Reads a TOML file and outputs its JSON representation.
-
- ```
- go install github.com/pelletier/go-toml/cmd/tomljson
- tomljson --help
- ```
-
- * `jsontoml`: Reads a JSON file and outputs a TOML representation.
-
- ```
- go install github.com/pelletier/go-toml/cmd/jsontoml
- jsontoml --help
- ```
-
-### Docker image
-
-Those tools are also available as a Docker image from
-[dockerhub](https://hub.docker.com/r/pelletier/go-toml). For example, to
-use `tomljson`:
-
-```
-docker run -v $PWD:/workdir pelletier/go-toml tomljson /workdir/example.toml
-```
-
-Only master (`latest`) and tagged versions are published to dockerhub. You
-can build your own image as usual:
-
-```
-docker build -t go-toml .
-```
-
-## Contribute
-
-Feel free to report bugs and patches using GitHub's pull requests system on
-[pelletier/go-toml](https://github.com/pelletier/go-toml). Any feedback would be
-much appreciated!
-
-### Run tests
-
-`go test ./...`
-
-### Fuzzing
-
-The script `./fuzz.sh` is available to
-run [go-fuzz](https://github.com/dvyukov/go-fuzz) on go-toml.
-
-## Versioning
-
-Go-toml follows [Semantic Versioning](http://semver.org/). The supported version
-of [TOML](https://github.com/toml-lang/toml) is indicated at the beginning of
-this document. The last two major versions of Go are supported
-(see [Go Release Policy](https://golang.org/doc/devel/release.html#policy)).
-
-## License
-
-The MIT License (MIT) + Apache 2.0. Read [LICENSE](LICENSE).
diff --git a/vendor/github.com/pelletier/go-toml/SECURITY.md b/vendor/github.com/pelletier/go-toml/SECURITY.md
deleted file mode 100644
index b2f21cfc9..000000000
--- a/vendor/github.com/pelletier/go-toml/SECURITY.md
+++ /dev/null
@@ -1,19 +0,0 @@
-# Security Policy
-
-## Supported Versions
-
-Use this section to tell people about which versions of your project are
-currently being supported with security updates.
-
-| Version | Supported |
-| ---------- | ------------------ |
-| Latest 2.x | :white_check_mark: |
-| All 1.x | :x: |
-| All 0.x | :x: |
-
-## Reporting a Vulnerability
-
-Email a vulnerability report to `security@pelletier.codes`. Make sure to include
-as many details as possible to reproduce the vulnerability. This is a
-side-project: I will try to get back to you as quickly as possible, time
-permitting in my personal life. Providing a working patch helps very much!
diff --git a/vendor/github.com/pelletier/go-toml/azure-pipelines.yml b/vendor/github.com/pelletier/go-toml/azure-pipelines.yml
deleted file mode 100644
index 4af198b4d..000000000
--- a/vendor/github.com/pelletier/go-toml/azure-pipelines.yml
+++ /dev/null
@@ -1,188 +0,0 @@
-trigger:
-- master
-
-stages:
-- stage: run_checks
- displayName: "Check"
- dependsOn: []
- jobs:
- - job: fmt
- displayName: "fmt"
- pool:
- vmImage: ubuntu-latest
- steps:
- - task: GoTool@0
- displayName: "Install Go 1.16"
- inputs:
- version: "1.16"
- - task: Go@0
- displayName: "go fmt ./..."
- inputs:
- command: 'custom'
- customCommand: 'fmt'
- arguments: './...'
- - job: coverage
- displayName: "coverage"
- pool:
- vmImage: ubuntu-latest
- steps:
- - task: GoTool@0
- displayName: "Install Go 1.16"
- inputs:
- version: "1.16"
- - task: Go@0
- displayName: "Generate coverage"
- inputs:
- command: 'test'
- arguments: "-race -coverprofile=coverage.txt -covermode=atomic"
- - task: Bash@3
- inputs:
- targetType: 'inline'
- script: 'bash <(curl -s https://codecov.io/bash) -t ${CODECOV_TOKEN}'
- env:
- CODECOV_TOKEN: $(CODECOV_TOKEN)
- - job: benchmark
- displayName: "benchmark"
- pool:
- vmImage: ubuntu-latest
- steps:
- - task: GoTool@0
- displayName: "Install Go 1.16"
- inputs:
- version: "1.16"
- - script: echo "##vso[task.setvariable variable=PATH]${PATH}:/home/vsts/go/bin/"
- - task: Bash@3
- inputs:
- filePath: './benchmark.sh'
- arguments: "master $(Build.Repository.Uri)"
-
- - job: go_unit_tests
- displayName: "unit tests"
- strategy:
- matrix:
- linux 1.16:
- goVersion: '1.16'
- imageName: 'ubuntu-latest'
- mac 1.16:
- goVersion: '1.16'
- imageName: 'macOS-latest'
- windows 1.16:
- goVersion: '1.16'
- imageName: 'windows-latest'
- linux 1.15:
- goVersion: '1.15'
- imageName: 'ubuntu-latest'
- mac 1.15:
- goVersion: '1.15'
- imageName: 'macOS-latest'
- windows 1.15:
- goVersion: '1.15'
- imageName: 'windows-latest'
- pool:
- vmImage: $(imageName)
- steps:
- - task: GoTool@0
- displayName: "Install Go $(goVersion)"
- inputs:
- version: $(goVersion)
- - task: Go@0
- displayName: "go test ./..."
- inputs:
- command: 'test'
- arguments: './...'
-- stage: build_binaries
- displayName: "Build binaries"
- dependsOn: run_checks
- jobs:
- - job: build_binary
- displayName: "Build binary"
- strategy:
- matrix:
- linux_amd64:
- GOOS: linux
- GOARCH: amd64
- darwin_amd64:
- GOOS: darwin
- GOARCH: amd64
- windows_amd64:
- GOOS: windows
- GOARCH: amd64
- pool:
- vmImage: ubuntu-latest
- steps:
- - task: GoTool@0
- displayName: "Install Go"
- inputs:
- version: 1.16
- - task: Bash@3
- inputs:
- targetType: inline
- script: "make dist"
- env:
- go.goos: $(GOOS)
- go.goarch: $(GOARCH)
- - task: CopyFiles@2
- inputs:
- sourceFolder: '$(Build.SourcesDirectory)'
- contents: '*.tar.xz'
- TargetFolder: '$(Build.ArtifactStagingDirectory)'
- - task: PublishBuildArtifacts@1
- inputs:
- pathtoPublish: '$(Build.ArtifactStagingDirectory)'
- artifactName: binaries
-- stage: build_binaries_manifest
- displayName: "Build binaries manifest"
- dependsOn: build_binaries
- jobs:
- - job: build_manifest
- displayName: "Build binaries manifest"
- steps:
- - task: DownloadBuildArtifacts@0
- inputs:
- buildType: 'current'
- downloadType: 'single'
- artifactName: 'binaries'
- downloadPath: '$(Build.SourcesDirectory)'
- - task: Bash@3
- inputs:
- targetType: inline
- script: "cd binaries && sha256sum --binary *.tar.xz | tee $(Build.ArtifactStagingDirectory)/sha256sums.txt"
- - task: PublishBuildArtifacts@1
- inputs:
- pathtoPublish: '$(Build.ArtifactStagingDirectory)'
- artifactName: manifest
-
-- stage: build_docker_image
- displayName: "Build Docker image"
- dependsOn: run_checks
- jobs:
- - job: build
- displayName: "Build"
- pool:
- vmImage: ubuntu-latest
- steps:
- - task: Docker@2
- inputs:
- command: 'build'
- Dockerfile: 'Dockerfile'
- buildContext: '.'
- addPipelineData: false
-
-- stage: publish_docker_image
- displayName: "Publish Docker image"
- dependsOn: build_docker_image
- condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'master'))
- jobs:
- - job: publish
- displayName: "Publish"
- pool:
- vmImage: ubuntu-latest
- steps:
- - task: Docker@2
- inputs:
- containerRegistry: 'DockerHub'
- repository: 'pelletier/go-toml'
- command: 'buildAndPush'
- Dockerfile: 'Dockerfile'
- buildContext: '.'
- tags: 'latest'
diff --git a/vendor/github.com/pelletier/go-toml/benchmark.sh b/vendor/github.com/pelletier/go-toml/benchmark.sh
deleted file mode 100644
index a69d3040f..000000000
--- a/vendor/github.com/pelletier/go-toml/benchmark.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/bash
-
-set -ex
-
-reference_ref=${1:-master}
-reference_git=${2:-.}
-
-if ! `hash benchstat 2>/dev/null`; then
- echo "Installing benchstat"
- go get golang.org/x/perf/cmd/benchstat
-fi
-
-tempdir=`mktemp -d /tmp/go-toml-benchmark-XXXXXX`
-ref_tempdir="${tempdir}/ref"
-ref_benchmark="${ref_tempdir}/benchmark-`echo -n ${reference_ref}|tr -s '/' '-'`.txt"
-local_benchmark="`pwd`/benchmark-local.txt"
-
-echo "=== ${reference_ref} (${ref_tempdir})"
-git clone ${reference_git} ${ref_tempdir} >/dev/null 2>/dev/null
-pushd ${ref_tempdir} >/dev/null
-git checkout ${reference_ref} >/dev/null 2>/dev/null
-go test -bench=. -benchmem | tee ${ref_benchmark}
-cd benchmark
-go test -bench=. -benchmem | tee -a ${ref_benchmark}
-popd >/dev/null
-
-echo ""
-echo "=== local"
-go test -bench=. -benchmem | tee ${local_benchmark}
-cd benchmark
-go test -bench=. -benchmem | tee -a ${local_benchmark}
-
-echo ""
-echo "=== diff"
-benchstat -delta-test=none ${ref_benchmark} ${local_benchmark}
diff --git a/vendor/github.com/pelletier/go-toml/doc.go b/vendor/github.com/pelletier/go-toml/doc.go
deleted file mode 100644
index a1406a32b..000000000
--- a/vendor/github.com/pelletier/go-toml/doc.go
+++ /dev/null
@@ -1,23 +0,0 @@
-// Package toml is a TOML parser and manipulation library.
-//
-// This version supports the specification as described in
-// https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.5.0.md
-//
-// Marshaling
-//
-// Go-toml can marshal and unmarshal TOML documents from and to data
-// structures.
-//
-// TOML document as a tree
-//
-// Go-toml can operate on a TOML document as a tree. Use one of the Load*
-// functions to parse TOML data and obtain a Tree instance, then one of its
-// methods to manipulate the tree.
-//
-// JSONPath-like queries
-//
-// The package github.com/pelletier/go-toml/query implements a system
-// similar to JSONPath to quickly retrieve elements of a TOML document using a
-// single expression. See the package documentation for more information.
-//
-package toml
diff --git a/vendor/github.com/pelletier/go-toml/example-crlf.toml b/vendor/github.com/pelletier/go-toml/example-crlf.toml
deleted file mode 100644
index 780d9c68f..000000000
--- a/vendor/github.com/pelletier/go-toml/example-crlf.toml
+++ /dev/null
@@ -1,30 +0,0 @@
-# This is a TOML document. Boom.
-
-title = "TOML Example"
-
-[owner]
-name = "Tom Preston-Werner"
-organization = "GitHub"
-bio = "GitHub Cofounder & CEO\nLikes tater tots and beer."
-dob = 1979-05-27T07:32:00Z # First class dates? Why not?
-
-[database]
-server = "192.168.1.1"
-ports = [ 8001, 8001, 8002 ]
-connection_max = 5000
-enabled = true
-
-[servers]
-
- # You can indent as you please. Tabs or spaces. TOML don't care.
- [servers.alpha]
- ip = "10.0.0.1"
- dc = "eqdc10"
-
- [servers.beta]
- ip = "10.0.0.2"
- dc = "eqdc10"
-
-[clients]
-data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it
-score = 4e-08 # to make sure leading zeroes in exponent parts of floats are supported \ No newline at end of file
diff --git a/vendor/github.com/pelletier/go-toml/example.toml b/vendor/github.com/pelletier/go-toml/example.toml
deleted file mode 100644
index f45bf88b8..000000000
--- a/vendor/github.com/pelletier/go-toml/example.toml
+++ /dev/null
@@ -1,30 +0,0 @@
-# This is a TOML document. Boom.
-
-title = "TOML Example"
-
-[owner]
-name = "Tom Preston-Werner"
-organization = "GitHub"
-bio = "GitHub Cofounder & CEO\nLikes tater tots and beer."
-dob = 1979-05-27T07:32:00Z # First class dates? Why not?
-
-[database]
-server = "192.168.1.1"
-ports = [ 8001, 8001, 8002 ]
-connection_max = 5000
-enabled = true
-
-[servers]
-
- # You can indent as you please. Tabs or spaces. TOML don't care.
- [servers.alpha]
- ip = "10.0.0.1"
- dc = "eqdc10"
-
- [servers.beta]
- ip = "10.0.0.2"
- dc = "eqdc10"
-
-[clients]
-data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it
-score = 4e-08 # to make sure leading zeroes in exponent parts of floats are supported \ No newline at end of file
diff --git a/vendor/github.com/pelletier/go-toml/fuzz.go b/vendor/github.com/pelletier/go-toml/fuzz.go
deleted file mode 100644
index 14570c8d3..000000000
--- a/vendor/github.com/pelletier/go-toml/fuzz.go
+++ /dev/null
@@ -1,31 +0,0 @@
-// +build gofuzz
-
-package toml
-
-func Fuzz(data []byte) int {
- tree, err := LoadBytes(data)
- if err != nil {
- if tree != nil {
- panic("tree must be nil if there is an error")
- }
- return 0
- }
-
- str, err := tree.ToTomlString()
- if err != nil {
- if str != "" {
- panic(`str must be "" if there is an error`)
- }
- panic(err)
- }
-
- tree, err = Load(str)
- if err != nil {
- if tree != nil {
- panic("tree must be nil if there is an error")
- }
- return 0
- }
-
- return 1
-}
diff --git a/vendor/github.com/pelletier/go-toml/fuzz.sh b/vendor/github.com/pelletier/go-toml/fuzz.sh
deleted file mode 100644
index 3204b4c44..000000000
--- a/vendor/github.com/pelletier/go-toml/fuzz.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#! /bin/sh
-set -eu
-
-go get github.com/dvyukov/go-fuzz/go-fuzz
-go get github.com/dvyukov/go-fuzz/go-fuzz-build
-
-if [ ! -e toml-fuzz.zip ]; then
- go-fuzz-build github.com/pelletier/go-toml
-fi
-
-rm -fr fuzz
-mkdir -p fuzz/corpus
-cp *.toml fuzz/corpus
-
-go-fuzz -bin=toml-fuzz.zip -workdir=fuzz
diff --git a/vendor/github.com/pelletier/go-toml/keysparsing.go b/vendor/github.com/pelletier/go-toml/keysparsing.go
deleted file mode 100644
index e091500b2..000000000
--- a/vendor/github.com/pelletier/go-toml/keysparsing.go
+++ /dev/null
@@ -1,112 +0,0 @@
-// Parsing keys handling both bare and quoted keys.
-
-package toml
-
-import (
- "errors"
- "fmt"
-)
-
-// Convert the bare key group string to an array.
-// The input supports double quotation and single quotation,
-// but escape sequences are not supported. Lexers must unescape them beforehand.
-func parseKey(key string) ([]string, error) {
- runes := []rune(key)
- var groups []string
-
- if len(key) == 0 {
- return nil, errors.New("empty key")
- }
-
- idx := 0
- for idx < len(runes) {
- for ; idx < len(runes) && isSpace(runes[idx]); idx++ {
- // skip leading whitespace
- }
- if idx >= len(runes) {
- break
- }
- r := runes[idx]
- if isValidBareChar(r) {
- // parse bare key
- startIdx := idx
- endIdx := -1
- idx++
- for idx < len(runes) {
- r = runes[idx]
- if isValidBareChar(r) {
- idx++
- } else if r == '.' {
- endIdx = idx
- break
- } else if isSpace(r) {
- endIdx = idx
- for ; idx < len(runes) && isSpace(runes[idx]); idx++ {
- // skip trailing whitespace
- }
- if idx < len(runes) && runes[idx] != '.' {
- return nil, fmt.Errorf("invalid key character after whitespace: %c", runes[idx])
- }
- break
- } else {
- return nil, fmt.Errorf("invalid bare key character: %c", r)
- }
- }
- if endIdx == -1 {
- endIdx = idx
- }
- groups = append(groups, string(runes[startIdx:endIdx]))
- } else if r == '\'' {
- // parse single quoted key
- idx++
- startIdx := idx
- for {
- if idx >= len(runes) {
- return nil, fmt.Errorf("unclosed single-quoted key")
- }
- r = runes[idx]
- if r == '\'' {
- groups = append(groups, string(runes[startIdx:idx]))
- idx++
- break
- }
- idx++
- }
- } else if r == '"' {
- // parse double quoted key
- idx++
- startIdx := idx
- for {
- if idx >= len(runes) {
- return nil, fmt.Errorf("unclosed double-quoted key")
- }
- r = runes[idx]
- if r == '"' {
- groups = append(groups, string(runes[startIdx:idx]))
- idx++
- break
- }
- idx++
- }
- } else if r == '.' {
- idx++
- if idx >= len(runes) {
- return nil, fmt.Errorf("unexpected end of key")
- }
- r = runes[idx]
- if !isValidBareChar(r) && r != '\'' && r != '"' && r != ' ' {
- return nil, fmt.Errorf("expecting key part after dot")
- }
- } else {
- return nil, fmt.Errorf("invalid key character: %c", r)
- }
- }
- if len(groups) == 0 {
- return nil, fmt.Errorf("empty key")
- }
- return groups, nil
-}
-
-func isValidBareChar(r rune) bool {
- return isAlphanumeric(r) || r == '-' || isDigit(r)
-}
diff --git a/vendor/github.com/pelletier/go-toml/lexer.go b/vendor/github.com/pelletier/go-toml/lexer.go
deleted file mode 100644
index 313908e3e..000000000
--- a/vendor/github.com/pelletier/go-toml/lexer.go
+++ /dev/null
@@ -1,1031 +0,0 @@
-// TOML lexer.
-//
-// Written using the principles developed by Rob Pike in
-// http://www.youtube.com/watch?v=HxaD_trXwRE
-
-package toml
-
-import (
- "bytes"
- "errors"
- "fmt"
- "strconv"
- "strings"
-)
-
-// Define state functions
-type tomlLexStateFn func() tomlLexStateFn
-
-// Define lexer
-type tomlLexer struct {
- inputIdx int
- input []rune // Textual source
- currentTokenStart int
- currentTokenStop int
- tokens []token
- brackets []rune
- line int
- col int
- endbufferLine int
- endbufferCol int
-}
-
-// Basic read operations on input
-
-func (l *tomlLexer) read() rune {
- r := l.peek()
- if r == '\n' {
- l.endbufferLine++
- l.endbufferCol = 1
- } else {
- l.endbufferCol++
- }
- l.inputIdx++
- return r
-}
-
-func (l *tomlLexer) next() rune {
- r := l.read()
-
- if r != eof {
- l.currentTokenStop++
- }
- return r
-}
-
-func (l *tomlLexer) ignore() {
- l.currentTokenStart = l.currentTokenStop
- l.line = l.endbufferLine
- l.col = l.endbufferCol
-}
-
-func (l *tomlLexer) skip() {
- l.next()
- l.ignore()
-}
-
-func (l *tomlLexer) fastForward(n int) {
- for i := 0; i < n; i++ {
- l.next()
- }
-}
-
-func (l *tomlLexer) emitWithValue(t tokenType, value string) {
- l.tokens = append(l.tokens, token{
- Position: Position{l.line, l.col},
- typ: t,
- val: value,
- })
- l.ignore()
-}
-
-func (l *tomlLexer) emit(t tokenType) {
- l.emitWithValue(t, string(l.input[l.currentTokenStart:l.currentTokenStop]))
-}
-
-func (l *tomlLexer) peek() rune {
- if l.inputIdx >= len(l.input) {
- return eof
- }
- return l.input[l.inputIdx]
-}
-
-func (l *tomlLexer) peekString(size int) string {
- maxIdx := len(l.input)
- upperIdx := l.inputIdx + size // FIXME: potential overflow
- if upperIdx > maxIdx {
- upperIdx = maxIdx
- }
- return string(l.input[l.inputIdx:upperIdx])
-}
-
-func (l *tomlLexer) follow(next string) bool {
- return next == l.peekString(len(next))
-}
-
-// Error management
-
-func (l *tomlLexer) errorf(format string, args ...interface{}) tomlLexStateFn {
- l.tokens = append(l.tokens, token{
- Position: Position{l.line, l.col},
- typ: tokenError,
- val: fmt.Sprintf(format, args...),
- })
- return nil
-}
-
-// State functions
-
-func (l *tomlLexer) lexVoid() tomlLexStateFn {
- for {
- next := l.peek()
- switch next {
- case '}': // after '{'
- return l.lexRightCurlyBrace
- case '[':
- return l.lexTableKey
- case '#':
- return l.lexComment(l.lexVoid)
- case '=':
- return l.lexEqual
- case '\r':
- fallthrough
- case '\n':
- l.skip()
- continue
- }
-
- if isSpace(next) {
- l.skip()
- }
-
- if isKeyStartChar(next) {
- return l.lexKey
- }
-
- if next == eof {
- l.next()
- break
- }
- }
-
- l.emit(tokenEOF)
- return nil
-}
-
-func (l *tomlLexer) lexRvalue() tomlLexStateFn {
- for {
- next := l.peek()
- switch next {
- case '.':
- return l.errorf("cannot start float with a dot")
- case '=':
- return l.lexEqual
- case '[':
- return l.lexLeftBracket
- case ']':
- return l.lexRightBracket
- case '{':
- return l.lexLeftCurlyBrace
- case '}':
- return l.lexRightCurlyBrace
- case '#':
- return l.lexComment(l.lexRvalue)
- case '"':
- return l.lexString
- case '\'':
- return l.lexLiteralString
- case ',':
- return l.lexComma
- case '\r':
- fallthrough
- case '\n':
- l.skip()
- if len(l.brackets) > 0 && l.brackets[len(l.brackets)-1] == '[' {
- return l.lexRvalue
- }
- return l.lexVoid
- }
-
- if l.follow("true") {
- return l.lexTrue
- }
-
- if l.follow("false") {
- return l.lexFalse
- }
-
- if l.follow("inf") {
- return l.lexInf
- }
-
- if l.follow("nan") {
- return l.lexNan
- }
-
- if isSpace(next) {
- l.skip()
- continue
- }
-
- if next == eof {
- l.next()
- break
- }
-
- if next == '+' || next == '-' {
- return l.lexNumber
- }
-
- if isDigit(next) {
- return l.lexDateTimeOrNumber
- }
-
- return l.errorf("no value can start with %c", next)
- }
-
- l.emit(tokenEOF)
- return nil
-}
-
-func (l *tomlLexer) lexDateTimeOrNumber() tomlLexStateFn {
- // Could be either a date/time, or a digit.
- // The options for date/times are:
- // YYYY-... => date or date-time
- // HH:... => time
- // Anything else should be a number.
-
- lookAhead := l.peekString(5)
- if len(lookAhead) < 3 {
- return l.lexNumber()
- }
-
- for idx, r := range lookAhead {
- if !isDigit(r) {
- if idx == 2 && r == ':' {
- return l.lexDateTimeOrTime()
- }
- if idx == 4 && r == '-' {
- return l.lexDateTimeOrTime()
- }
- return l.lexNumber()
- }
- }
- return l.lexNumber()
-}
-
-func (l *tomlLexer) lexLeftCurlyBrace() tomlLexStateFn {
- l.next()
- l.emit(tokenLeftCurlyBrace)
- l.brackets = append(l.brackets, '{')
- return l.lexVoid
-}
-
-func (l *tomlLexer) lexRightCurlyBrace() tomlLexStateFn {
- l.next()
- l.emit(tokenRightCurlyBrace)
- if len(l.brackets) == 0 || l.brackets[len(l.brackets)-1] != '{' {
- return l.errorf("cannot have '}' here")
- }
- l.brackets = l.brackets[:len(l.brackets)-1]
- return l.lexRvalue
-}
-
-func (l *tomlLexer) lexDateTimeOrTime() tomlLexStateFn {
- // Example matches:
- // 1979-05-27T07:32:00Z
- // 1979-05-27T00:32:00-07:00
- // 1979-05-27T00:32:00.999999-07:00
- // 1979-05-27 07:32:00Z
- // 1979-05-27 00:32:00-07:00
- // 1979-05-27 00:32:00.999999-07:00
- // 1979-05-27T07:32:00
- // 1979-05-27T00:32:00.999999
- // 1979-05-27 07:32:00
- // 1979-05-27 00:32:00.999999
- // 1979-05-27
- // 07:32:00
- // 00:32:00.999999
-
- // we already know those two are digits
- l.next()
- l.next()
-
- // Got 2 digits. At that point it could be either a time or a date(-time).
-
- r := l.next()
- if r == ':' {
- return l.lexTime()
- }
-
- return l.lexDateTime()
-}
-
-func (l *tomlLexer) lexDateTime() tomlLexStateFn {
- // This state accepts an offset date-time, a local date-time, or a local date.
- //
- // v--- cursor
- // 1979-05-27T07:32:00Z
- // 1979-05-27T00:32:00-07:00
- // 1979-05-27T00:32:00.999999-07:00
- // 1979-05-27 07:32:00Z
- // 1979-05-27 00:32:00-07:00
- // 1979-05-27 00:32:00.999999-07:00
- // 1979-05-27T07:32:00
- // 1979-05-27T00:32:00.999999
- // 1979-05-27 07:32:00
- // 1979-05-27 00:32:00.999999
- // 1979-05-27
-
- // date
-
- // already checked by lexRvalue
- l.next() // digit
- l.next() // -
-
- for i := 0; i < 2; i++ {
- r := l.next()
- if !isDigit(r) {
- return l.errorf("invalid month digit in date: %c", r)
- }
- }
-
- r := l.next()
- if r != '-' {
- return l.errorf("expected - to separate month of a date, not %c", r)
- }
-
- for i := 0; i < 2; i++ {
- r := l.next()
- if !isDigit(r) {
- return l.errorf("invalid day digit in date: %c", r)
- }
- }
-
- l.emit(tokenLocalDate)
-
- r = l.peek()
-
- if r == eof {
-
- return l.lexRvalue
- }
-
- if r != ' ' && r != 'T' {
- return l.errorf("incorrect date/time separation character: %c", r)
- }
-
- if r == ' ' {
- lookAhead := l.peekString(3)[1:]
- if len(lookAhead) < 2 {
- return l.lexRvalue
- }
- for _, r := range lookAhead {
- if !isDigit(r) {
- return l.lexRvalue
- }
- }
- }
-
- l.skip() // skip the T or ' '
-
- // time
-
- for i := 0; i < 2; i++ {
- r := l.next()
- if !isDigit(r) {
- return l.errorf("invalid hour digit in time: %c", r)
- }
- }
-
- r = l.next()
- if r != ':' {
- return l.errorf("time hour/minute separator should be :, not %c", r)
- }
-
- for i := 0; i < 2; i++ {
- r := l.next()
- if !isDigit(r) {
- return l.errorf("invalid minute digit in time: %c", r)
- }
- }
-
- r = l.next()
- if r != ':' {
- return l.errorf("time minute/second separator should be :, not %c", r)
- }
-
- for i := 0; i < 2; i++ {
- r := l.next()
- if !isDigit(r) {
- return l.errorf("invalid second digit in time: %c", r)
- }
- }
-
- r = l.peek()
- if r == '.' {
- l.next()
- r := l.next()
- if !isDigit(r) {
- return l.errorf("expected at least one digit in time's fraction, not %c", r)
- }
-
- for {
- r := l.peek()
- if !isDigit(r) {
- break
- }
- l.next()
- }
- }
-
- l.emit(tokenLocalTime)
-
- return l.lexTimeOffset
-
-}
-
-func (l *tomlLexer) lexTimeOffset() tomlLexStateFn {
- // potential offset
-
- // Z
- // -07:00
- // +07:00
- // nothing
-
- r := l.peek()
-
- if r == 'Z' {
- l.next()
- l.emit(tokenTimeOffset)
- } else if r == '+' || r == '-' {
- l.next()
-
- for i := 0; i < 2; i++ {
- r := l.next()
- if !isDigit(r) {
- return l.errorf("invalid hour digit in time offset: %c", r)
- }
- }
-
- r = l.next()
- if r != ':' {
- return l.errorf("time offset hour/minute separator should be :, not %c", r)
- }
-
- for i := 0; i < 2; i++ {
- r := l.next()
- if !isDigit(r) {
- return l.errorf("invalid minute digit in time offset: %c", r)
- }
- }
-
- l.emit(tokenTimeOffset)
- }
-
- return l.lexRvalue
-}
-
-func (l *tomlLexer) lexTime() tomlLexStateFn {
- // v--- cursor
- // 07:32:00
- // 00:32:00.999999
-
- for i := 0; i < 2; i++ {
- r := l.next()
- if !isDigit(r) {
- return l.errorf("invalid minute digit in time: %c", r)
- }
- }
-
- r := l.next()
- if r != ':' {
- return l.errorf("time minute/second separator should be :, not %c", r)
- }
-
- for i := 0; i < 2; i++ {
- r := l.next()
- if !isDigit(r) {
- return l.errorf("invalid second digit in time: %c", r)
- }
- }
-
- r = l.peek()
- if r == '.' {
- l.next()
- r := l.next()
- if !isDigit(r) {
- return l.errorf("expected at least one digit in time's fraction, not %c", r)
- }
-
- for {
- r := l.peek()
- if !isDigit(r) {
- break
- }
- l.next()
- }
- }
-
- l.emit(tokenLocalTime)
- return l.lexRvalue
-
-}
-
-func (l *tomlLexer) lexTrue() tomlLexStateFn {
- l.fastForward(4)
- l.emit(tokenTrue)
- return l.lexRvalue
-}
-
-func (l *tomlLexer) lexFalse() tomlLexStateFn {
- l.fastForward(5)
- l.emit(tokenFalse)
- return l.lexRvalue
-}
-
-func (l *tomlLexer) lexInf() tomlLexStateFn {
- l.fastForward(3)
- l.emit(tokenInf)
- return l.lexRvalue
-}
-
-func (l *tomlLexer) lexNan() tomlLexStateFn {
- l.fastForward(3)
- l.emit(tokenNan)
- return l.lexRvalue
-}
-
-func (l *tomlLexer) lexEqual() tomlLexStateFn {
- l.next()
- l.emit(tokenEqual)
- return l.lexRvalue
-}
-
-func (l *tomlLexer) lexComma() tomlLexStateFn {
- l.next()
- l.emit(tokenComma)
- if len(l.brackets) > 0 && l.brackets[len(l.brackets)-1] == '{' {
- return l.lexVoid
- }
- return l.lexRvalue
-}
-
-// Parse the key and emits its value without escape sequences.
-// bare keys, basic string keys and literal string keys are supported.
-func (l *tomlLexer) lexKey() tomlLexStateFn {
- var sb strings.Builder
-
- for r := l.peek(); isKeyChar(r) || r == '\n' || r == '\r'; r = l.peek() {
- if r == '"' {
- l.next()
- str, err := l.lexStringAsString(`"`, false, true)
- if err != nil {
- return l.errorf(err.Error())
- }
- sb.WriteString("\"")
- sb.WriteString(str)
- sb.WriteString("\"")
- l.next()
- continue
- } else if r == '\'' {
- l.next()
- str, err := l.lexLiteralStringAsString(`'`, false)
- if err != nil {
- return l.errorf(err.Error())
- }
- sb.WriteString("'")
- sb.WriteString(str)
- sb.WriteString("'")
- l.next()
- continue
- } else if r == '\n' {
- return l.errorf("keys cannot contain new lines")
- } else if isSpace(r) {
- var str strings.Builder
- str.WriteString(" ")
-
- // skip trailing whitespace
- l.next()
- for r = l.peek(); isSpace(r); r = l.peek() {
- str.WriteRune(r)
- l.next()
- }
- // break loop if not a dot
- if r != '.' {
- break
- }
- str.WriteString(".")
- // skip trailing whitespace after dot
- l.next()
- for r = l.peek(); isSpace(r); r = l.peek() {
- str.WriteRune(r)
- l.next()
- }
- sb.WriteString(str.String())
- continue
- } else if r == '.' {
- // skip
- } else if !isValidBareChar(r) {
- return l.errorf("keys cannot contain %c character", r)
- }
- sb.WriteRune(r)
- l.next()
- }
- l.emitWithValue(tokenKey, sb.String())
- return l.lexVoid
-}
-
-func (l *tomlLexer) lexComment(previousState tomlLexStateFn) tomlLexStateFn {
- return func() tomlLexStateFn {
- for next := l.peek(); next != '\n' && next != eof; next = l.peek() {
- if next == '\r' && l.follow("\r\n") {
- break
- }
- l.next()
- }
- l.ignore()
- return previousState
- }
-}
-
-func (l *tomlLexer) lexLeftBracket() tomlLexStateFn {
- l.next()
- l.emit(tokenLeftBracket)
- l.brackets = append(l.brackets, '[')
- return l.lexRvalue
-}
-
-func (l *tomlLexer) lexLiteralStringAsString(terminator string, discardLeadingNewLine bool) (string, error) {
- var sb strings.Builder
-
- if discardLeadingNewLine {
- if l.follow("\r\n") {
- l.skip()
- l.skip()
- } else if l.peek() == '\n' {
- l.skip()
- }
- }
-
- // find end of string
- for {
- if l.follow(terminator) {
- return sb.String(), nil
- }
-
- next := l.peek()
- if next == eof {
- break
- }
- sb.WriteRune(l.next())
- }
-
- return "", errors.New("unclosed string")
-}
-
-func (l *tomlLexer) lexLiteralString() tomlLexStateFn {
- l.skip()
-
- // handle special case for triple-quote
- terminator := "'"
- discardLeadingNewLine := false
- if l.follow("''") {
- l.skip()
- l.skip()
- terminator = "'''"
- discardLeadingNewLine = true
- }
-
- str, err := l.lexLiteralStringAsString(terminator, discardLeadingNewLine)
- if err != nil {
- return l.errorf(err.Error())
- }
-
- l.emitWithValue(tokenString, str)
- l.fastForward(len(terminator))
- l.ignore()
- return l.lexRvalue
-}
-
-// Lex a string and return the results as a string.
-// Terminator is the substring indicating the end of the token.
-// The resulting string does not include the terminator.
-func (l *tomlLexer) lexStringAsString(terminator string, discardLeadingNewLine, acceptNewLines bool) (string, error) {
- var sb strings.Builder
-
- if discardLeadingNewLine {
- if l.follow("\r\n") {
- l.skip()
- l.skip()
- } else if l.peek() == '\n' {
- l.skip()
- }
- }
-
- for {
- if l.follow(terminator) {
- return sb.String(), nil
- }
-
- if l.follow("\\") {
- l.next()
- switch l.peek() {
- case '\r':
- fallthrough
- case '\n':
- fallthrough
- case '\t':
- fallthrough
- case ' ':
- // skip all whitespace chars following backslash
- for strings.ContainsRune("\r\n\t ", l.peek()) {
- l.next()
- }
- case '"':
- sb.WriteString("\"")
- l.next()
- case 'n':
- sb.WriteString("\n")
- l.next()
- case 'b':
- sb.WriteString("\b")
- l.next()
- case 'f':
- sb.WriteString("\f")
- l.next()
- case '/':
- sb.WriteString("/")
- l.next()
- case 't':
- sb.WriteString("\t")
- l.next()
- case 'r':
- sb.WriteString("\r")
- l.next()
- case '\\':
- sb.WriteString("\\")
- l.next()
- case 'u':
- l.next()
- var code strings.Builder
- for i := 0; i < 4; i++ {
- c := l.peek()
- if !isHexDigit(c) {
- return "", errors.New("unfinished unicode escape")
- }
- l.next()
- code.WriteRune(c)
- }
- intcode, err := strconv.ParseInt(code.String(), 16, 32)
- if err != nil {
- return "", errors.New("invalid unicode escape: \\u" + code.String())
- }
- sb.WriteRune(rune(intcode))
- case 'U':
- l.next()
- var code strings.Builder
- for i := 0; i < 8; i++ {
- c := l.peek()
- if !isHexDigit(c) {
- return "", errors.New("unfinished unicode escape")
- }
- l.next()
- code.WriteRune(c)
- }
- intcode, err := strconv.ParseInt(code.String(), 16, 64)
- if err != nil {
- return "", errors.New("invalid unicode escape: \\U" + code.String())
- }
- sb.WriteRune(rune(intcode))
- default:
- return "", errors.New("invalid escape sequence: \\" + string(l.peek()))
- }
- } else {
- r := l.peek()
-
- if 0x00 <= r && r <= 0x1F && r != '\t' && !(acceptNewLines && (r == '\n' || r == '\r')) {
- return "", fmt.Errorf("unescaped control character %U", r)
- }
- l.next()
- sb.WriteRune(r)
- }
-
- if l.peek() == eof {
- break
- }
- }
-
- return "", errors.New("unclosed string")
-}
-
-func (l *tomlLexer) lexString() tomlLexStateFn {
- l.skip()
-
- // handle special case for triple-quote
- terminator := `"`
- discardLeadingNewLine := false
- acceptNewLines := false
- if l.follow(`""`) {
- l.skip()
- l.skip()
- terminator = `"""`
- discardLeadingNewLine = true
- acceptNewLines = true
- }
-
- str, err := l.lexStringAsString(terminator, discardLeadingNewLine, acceptNewLines)
- if err != nil {
- return l.errorf(err.Error())
- }
-
- l.emitWithValue(tokenString, str)
- l.fastForward(len(terminator))
- l.ignore()
- return l.lexRvalue
-}
-
-func (l *tomlLexer) lexTableKey() tomlLexStateFn {
- l.next()
-
- if l.peek() == '[' {
- // token '[[' signifies an array of tables
- l.next()
- l.emit(tokenDoubleLeftBracket)
- return l.lexInsideTableArrayKey
- }
- // vanilla table key
- l.emit(tokenLeftBracket)
- return l.lexInsideTableKey
-}
-
-// Parse the key till "]]", but only bare keys are supported
-func (l *tomlLexer) lexInsideTableArrayKey() tomlLexStateFn {
- for r := l.peek(); r != eof; r = l.peek() {
- switch r {
- case ']':
- if l.currentTokenStop > l.currentTokenStart {
- l.emit(tokenKeyGroupArray)
- }
- l.next()
- if l.peek() != ']' {
- break
- }
- l.next()
- l.emit(tokenDoubleRightBracket)
- return l.lexVoid
- case '[':
- return l.errorf("table array key cannot contain ']'")
- default:
- l.next()
- }
- }
- return l.errorf("unclosed table array key")
-}
-
-// Parse the key till "]" but only bare keys are supported
-func (l *tomlLexer) lexInsideTableKey() tomlLexStateFn {
- for r := l.peek(); r != eof; r = l.peek() {
- switch r {
- case ']':
- if l.currentTokenStop > l.currentTokenStart {
- l.emit(tokenKeyGroup)
- }
- l.next()
- l.emit(tokenRightBracket)
- return l.lexVoid
- case '[':
- return l.errorf("table key cannot contain ']'")
- default:
- l.next()
- }
- }
- return l.errorf("unclosed table key")
-}
-
-func (l *tomlLexer) lexRightBracket() tomlLexStateFn {
- l.next()
- l.emit(tokenRightBracket)
- if len(l.brackets) == 0 || l.brackets[len(l.brackets)-1] != '[' {
- return l.errorf("cannot have ']' here")
- }
- l.brackets = l.brackets[:len(l.brackets)-1]
- return l.lexRvalue
-}
-
-type validRuneFn func(r rune) bool
-
-func isValidHexRune(r rune) bool {
- return r >= 'a' && r <= 'f' ||
- r >= 'A' && r <= 'F' ||
- r >= '0' && r <= '9' ||
- r == '_'
-}
-
-func isValidOctalRune(r rune) bool {
- return r >= '0' && r <= '7' || r == '_'
-}
-
-func isValidBinaryRune(r rune) bool {
- return r == '0' || r == '1' || r == '_'
-}
-
-func (l *tomlLexer) lexNumber() tomlLexStateFn {
- r := l.peek()
-
- if r == '0' {
- follow := l.peekString(2)
- if len(follow) == 2 {
- var isValidRune validRuneFn
- switch follow[1] {
- case 'x':
- isValidRune = isValidHexRune
- case 'o':
- isValidRune = isValidOctalRune
- case 'b':
- isValidRune = isValidBinaryRune
- default:
- if follow[1] >= 'a' && follow[1] <= 'z' || follow[1] >= 'A' && follow[1] <= 'Z' {
- return l.errorf("unknown number base: %s. possible options are x (hex) o (octal) b (binary)", string(follow[1]))
- }
- }
-
- if isValidRune != nil {
- l.next()
- l.next()
- digitSeen := false
- for {
- next := l.peek()
- if !isValidRune(next) {
- break
- }
- digitSeen = true
- l.next()
- }
-
- if !digitSeen {
- return l.errorf("number needs at least one digit")
- }
-
- l.emit(tokenInteger)
-
- return l.lexRvalue
- }
- }
- }
-
- if r == '+' || r == '-' {
- l.next()
- if l.follow("inf") {
- return l.lexInf
- }
- if l.follow("nan") {
- return l.lexNan
- }
- }
-
- pointSeen := false
- expSeen := false
- digitSeen := false
- for {
- next := l.peek()
- if next == '.' {
- if pointSeen {
- return l.errorf("cannot have two dots in one float")
- }
- l.next()
- if !isDigit(l.peek()) {
- return l.errorf("float cannot end with a dot")
- }
- pointSeen = true
- } else if next == 'e' || next == 'E' {
- expSeen = true
- l.next()
- r := l.peek()
- if r == '+' || r == '-' {
- l.next()
- }
- } else if isDigit(next) {
- digitSeen = true
- l.next()
- } else if next == '_' {
- l.next()
- } else {
- break
- }
- if pointSeen && !digitSeen {
- return l.errorf("cannot start float with a dot")
- }
- }
-
- if !digitSeen {
- return l.errorf("no digit in that number")
- }
- if pointSeen || expSeen {
- l.emit(tokenFloat)
- } else {
- l.emit(tokenInteger)
- }
- return l.lexRvalue
-}
-
-func (l *tomlLexer) run() {
- for state := l.lexVoid; state != nil; {
- state = state()
- }
-}
-
-// Entry point
-func lexToml(inputBytes []byte) []token {
- runes := bytes.Runes(inputBytes)
- l := &tomlLexer{
- input: runes,
- tokens: make([]token, 0, 256),
- line: 1,
- col: 1,
- endbufferLine: 1,
- endbufferCol: 1,
- }
- l.run()
- return l.tokens
-}
diff --git a/vendor/github.com/pelletier/go-toml/localtime.go b/vendor/github.com/pelletier/go-toml/localtime.go
deleted file mode 100644
index 9dfe4b9e6..000000000
--- a/vendor/github.com/pelletier/go-toml/localtime.go
+++ /dev/null
@@ -1,287 +0,0 @@
-// Implementation of TOML's local date/time.
-//
-// Copied over from Google's civil to avoid pulling all the Google dependencies.
-// Originals:
-// https://raw.githubusercontent.com/googleapis/google-cloud-go/ed46f5086358513cf8c25f8e3f022cb838a49d66/civil/civil.go
-// Changes:
-// * Renamed files from civil* to localtime*.
-// * Package changed from civil to toml.
-// * 'Local' prefix added to all structs.
-//
-// Copyright 2016 Google LLC
-//
-// 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 civil implements types for civil time, a time-zone-independent
-// representation of time that follows the rules of the proleptic
-// Gregorian calendar with exactly 24-hour days, 60-minute hours, and 60-second
-// minutes.
-//
-// Because they lack location information, these types do not represent unique
-// moments or intervals of time. Use time.Time for that purpose.
-package toml
-
-import (
- "fmt"
- "time"
-)
-
-// A LocalDate represents a date (year, month, day).
-//
-// This type does not include location information, and therefore does not
-// describe a unique 24-hour timespan.
-type LocalDate struct {
- Year int // Year (e.g., 2014).
- Month time.Month // Month of the year (January = 1, ...).
- Day int // Day of the month, starting at 1.
-}
-
-// LocalDateOf returns the LocalDate in which a time occurs in that time's location.
-func LocalDateOf(t time.Time) LocalDate {
- var d LocalDate
- d.Year, d.Month, d.Day = t.Date()
- return d
-}
-
-// ParseLocalDate parses a string in RFC3339 full-date format and returns the date value it represents.
-func ParseLocalDate(s string) (LocalDate, error) {
- t, err := time.Parse("2006-01-02", s)
- if err != nil {
- return LocalDate{}, err
- }
- return LocalDateOf(t), nil
-}
-
-// String returns the date in RFC3339 full-date format.
-func (d LocalDate) String() string {
- return fmt.Sprintf("%04d-%02d-%02d", d.Year, d.Month, d.Day)
-}
-
-// IsValid reports whether the date is valid.
-func (d LocalDate) IsValid() bool {
- return LocalDateOf(d.In(time.UTC)) == d
-}
-
-// In returns the time corresponding to time 00:00:00 of the date in the location.
-//
-// In is always consistent with time.LocalDate, even when time.LocalDate returns a time
-// on a different day. For example, if loc is America/Indiana/Vincennes, then both
-// time.LocalDate(1955, time.May, 1, 0, 0, 0, 0, loc)
-// and
-// civil.LocalDate{Year: 1955, Month: time.May, Day: 1}.In(loc)
-// return 23:00:00 on April 30, 1955.
-//
-// In panics if loc is nil.
-func (d LocalDate) In(loc *time.Location) time.Time {
- return time.Date(d.Year, d.Month, d.Day, 0, 0, 0, 0, loc)
-}
-
-// AddDays returns the date that is n days in the future.
-// n can also be negative to go into the past.
-func (d LocalDate) AddDays(n int) LocalDate {
- return LocalDateOf(d.In(time.UTC).AddDate(0, 0, n))
-}
-
-// DaysSince returns the signed number of days between the date and s, not including the end day.
-// This is the inverse operation to AddDays.
-func (d LocalDate) DaysSince(s LocalDate) (days int) {
- // We convert to Unix time so we do not have to worry about leap seconds:
- // Unix time increases by exactly 86400 seconds per day.
- deltaUnix := d.In(time.UTC).Unix() - s.In(time.UTC).Unix()
- return int(deltaUnix / 86400)
-}
-
-// Before reports whether d1 occurs before d2.
-func (d1 LocalDate) Before(d2 LocalDate) bool {
- if d1.Year != d2.Year {
- return d1.Year < d2.Year
- }
- if d1.Month != d2.Month {
- return d1.Month < d2.Month
- }
- return d1.Day < d2.Day
-}
-
-// After reports whether d1 occurs after d2.
-func (d1 LocalDate) After(d2 LocalDate) bool {
- return d2.Before(d1)
-}
-
-// MarshalText implements the encoding.TextMarshaler interface.
-// The output is the result of d.String().
-func (d LocalDate) MarshalText() ([]byte, error) {
- return []byte(d.String()), nil
-}
-
-// UnmarshalText implements the encoding.TextUnmarshaler interface.
-// The date is expected to be a string in a format accepted by ParseLocalDate.
-func (d *LocalDate) UnmarshalText(data []byte) error {
- var err error
- *d, err = ParseLocalDate(string(data))
- return err
-}
-
-// A LocalTime represents a time with nanosecond precision.
-//
-// This type does not include location information, and therefore does not
-// describe a unique moment in time.
-//
-// This type exists to represent the TIME type in storage-based APIs like BigQuery.
-// Most operations on Times are unlikely to be meaningful. Prefer the LocalDateTime type.
-type LocalTime struct {
- Hour int // The hour of the day in 24-hour format; range [0-23]
- Minute int // The minute of the hour; range [0-59]
- Second int // The second of the minute; range [0-59]
- Nanosecond int // The nanosecond of the second; range [0-999999999]
-}
-
-// LocalTimeOf returns the LocalTime representing the time of day in which a time occurs
-// in that time's location. It ignores the date.
-func LocalTimeOf(t time.Time) LocalTime {
- var tm LocalTime
- tm.Hour, tm.Minute, tm.Second = t.Clock()
- tm.Nanosecond = t.Nanosecond()
- return tm
-}
-
-// ParseLocalTime parses a string and returns the time value it represents.
-// ParseLocalTime accepts an extended form of the RFC3339 partial-time format. After
-// the HH:MM:SS part of the string, an optional fractional part may appear,
-// consisting of a decimal point followed by one to nine decimal digits.
-// (RFC3339 admits only one digit after the decimal point).
-func ParseLocalTime(s string) (LocalTime, error) {
- t, err := time.Parse("15:04:05.999999999", s)
- if err != nil {
- return LocalTime{}, err
- }
- return LocalTimeOf(t), nil
-}
-
-// String returns the date in the format described in ParseLocalTime. If Nanoseconds
-// is zero, no fractional part will be generated. Otherwise, the result will
-// end with a fractional part consisting of a decimal point and nine digits.
-func (t LocalTime) String() string {
- s := fmt.Sprintf("%02d:%02d:%02d", t.Hour, t.Minute, t.Second)
- if t.Nanosecond == 0 {
- return s
- }
- return s + fmt.Sprintf(".%09d", t.Nanosecond)
-}
-
-// IsValid reports whether the time is valid.
-func (t LocalTime) IsValid() bool {
- // Construct a non-zero time.
- tm := time.Date(2, 2, 2, t.Hour, t.Minute, t.Second, t.Nanosecond, time.UTC)
- return LocalTimeOf(tm) == t
-}
-
-// MarshalText implements the encoding.TextMarshaler interface.
-// The output is the result of t.String().
-func (t LocalTime) MarshalText() ([]byte, error) {
- return []byte(t.String()), nil
-}
-
-// UnmarshalText implements the encoding.TextUnmarshaler interface.
-// The time is expected to be a string in a format accepted by ParseLocalTime.
-func (t *LocalTime) UnmarshalText(data []byte) error {
- var err error
- *t, err = ParseLocalTime(string(data))
- return err
-}
-
-// A LocalDateTime represents a date and time.
-//
-// This type does not include location information, and therefore does not
-// describe a unique moment in time.
-type LocalDateTime struct {
- Date LocalDate
- Time LocalTime
-}
-
-// Note: We deliberately do not embed LocalDate into LocalDateTime, to avoid promoting AddDays and Sub.
-
-// LocalDateTimeOf returns the LocalDateTime in which a time occurs in that time's location.
-func LocalDateTimeOf(t time.Time) LocalDateTime {
- return LocalDateTime{
- Date: LocalDateOf(t),
- Time: LocalTimeOf(t),
- }
-}
-
-// ParseLocalDateTime parses a string and returns the LocalDateTime it represents.
-// ParseLocalDateTime accepts a variant of the RFC3339 date-time format that omits
-// the time offset but includes an optional fractional time, as described in
-// ParseLocalTime. Informally, the accepted format is
-// YYYY-MM-DDTHH:MM:SS[.FFFFFFFFF]
-// where the 'T' may be a lower-case 't'.
-func ParseLocalDateTime(s string) (LocalDateTime, error) {
- t, err := time.Parse("2006-01-02T15:04:05.999999999", s)
- if err != nil {
- t, err = time.Parse("2006-01-02t15:04:05.999999999", s)
- if err != nil {
- return LocalDateTime{}, err
- }
- }
- return LocalDateTimeOf(t), nil
-}
-
-// String returns the date in the format described in ParseLocalDate.
-func (dt LocalDateTime) String() string {
- return dt.Date.String() + "T" + dt.Time.String()
-}
-
-// IsValid reports whether the datetime is valid.
-func (dt LocalDateTime) IsValid() bool {
- return dt.Date.IsValid() && dt.Time.IsValid()
-}
-
-// In returns the time corresponding to the LocalDateTime in the given location.
-//
-// If the time is missing or ambigous at the location, In returns the same
-// result as time.LocalDate. For example, if loc is America/Indiana/Vincennes, then
-// both
-// time.LocalDate(1955, time.May, 1, 0, 30, 0, 0, loc)
-// and
-// civil.LocalDateTime{
-// civil.LocalDate{Year: 1955, Month: time.May, Day: 1}},
-// civil.LocalTime{Minute: 30}}.In(loc)
-// return 23:30:00 on April 30, 1955.
-//
-// In panics if loc is nil.
-func (dt LocalDateTime) In(loc *time.Location) time.Time {
- return time.Date(dt.Date.Year, dt.Date.Month, dt.Date.Day, dt.Time.Hour, dt.Time.Minute, dt.Time.Second, dt.Time.Nanosecond, loc)
-}
-
-// Before reports whether dt1 occurs before dt2.
-func (dt1 LocalDateTime) Before(dt2 LocalDateTime) bool {
- return dt1.In(time.UTC).Before(dt2.In(time.UTC))
-}
-
-// After reports whether dt1 occurs after dt2.
-func (dt1 LocalDateTime) After(dt2 LocalDateTime) bool {
- return dt2.Before(dt1)
-}
-
-// MarshalText implements the encoding.TextMarshaler interface.
-// The output is the result of dt.String().
-func (dt LocalDateTime) MarshalText() ([]byte, error) {
- return []byte(dt.String()), nil
-}
-
-// UnmarshalText implements the encoding.TextUnmarshaler interface.
-// The datetime is expected to be a string in a format accepted by ParseLocalDateTime
-func (dt *LocalDateTime) UnmarshalText(data []byte) error {
- var err error
- *dt, err = ParseLocalDateTime(string(data))
- return err
-}
diff --git a/vendor/github.com/pelletier/go-toml/marshal.go b/vendor/github.com/pelletier/go-toml/marshal.go
deleted file mode 100644
index 571273049..000000000
--- a/vendor/github.com/pelletier/go-toml/marshal.go
+++ /dev/null
@@ -1,1308 +0,0 @@
-package toml
-
-import (
- "bytes"
- "encoding"
- "errors"
- "fmt"
- "io"
- "reflect"
- "sort"
- "strconv"
- "strings"
- "time"
-)
-
-const (
- tagFieldName = "toml"
- tagFieldComment = "comment"
- tagCommented = "commented"
- tagMultiline = "multiline"
- tagLiteral = "literal"
- tagDefault = "default"
-)
-
-type tomlOpts struct {
- name string
- nameFromTag bool
- comment string
- commented bool
- multiline bool
- literal bool
- include bool
- omitempty bool
- defaultValue string
-}
-
-type encOpts struct {
- quoteMapKeys bool
- arraysOneElementPerLine bool
-}
-
-var encOptsDefaults = encOpts{
- quoteMapKeys: false,
-}
-
-type annotation struct {
- tag string
- comment string
- commented string
- multiline string
- literal string
- defaultValue string
-}
-
-var annotationDefault = annotation{
- tag: tagFieldName,
- comment: tagFieldComment,
- commented: tagCommented,
- multiline: tagMultiline,
- literal: tagLiteral,
- defaultValue: tagDefault,
-}
-
-type MarshalOrder int
-
-// Orders the Encoder can write the fields to the output stream.
-const (
- // Sort fields alphabetically.
- OrderAlphabetical MarshalOrder = iota + 1
- // Preserve the order the fields are encountered. For example, the order of fields in
- // a struct.
- OrderPreserve
-)
-
-var timeType = reflect.TypeOf(time.Time{})
-var marshalerType = reflect.TypeOf(new(Marshaler)).Elem()
-var unmarshalerType = reflect.TypeOf(new(Unmarshaler)).Elem()
-var textMarshalerType = reflect.TypeOf(new(encoding.TextMarshaler)).Elem()
-var textUnmarshalerType = reflect.TypeOf(new(encoding.TextUnmarshaler)).Elem()
-var localDateType = reflect.TypeOf(LocalDate{})
-var localTimeType = reflect.TypeOf(LocalTime{})
-var localDateTimeType = reflect.TypeOf(LocalDateTime{})
-var mapStringInterfaceType = reflect.TypeOf(map[string]interface{}{})
-
-// Check if the given marshal type maps to a Tree primitive
-func isPrimitive(mtype reflect.Type) bool {
- switch mtype.Kind() {
- case reflect.Ptr:
- return isPrimitive(mtype.Elem())
- case reflect.Bool:
- return true
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- return true
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
- return true
- case reflect.Float32, reflect.Float64:
- return true
- case reflect.String:
- return true
- case reflect.Struct:
- return isTimeType(mtype)
- default:
- return false
- }
-}
-
-func isTimeType(mtype reflect.Type) bool {
- return mtype == timeType || mtype == localDateType || mtype == localDateTimeType || mtype == localTimeType
-}
-
-// Check if the given marshal type maps to a Tree slice or array
-func isTreeSequence(mtype reflect.Type) bool {
- switch mtype.Kind() {
- case reflect.Ptr:
- return isTreeSequence(mtype.Elem())
- case reflect.Slice, reflect.Array:
- return isTree(mtype.Elem())
- default:
- return false
- }
-}
-
-// Check if the given marshal type maps to a slice or array of a custom marshaler type
-func isCustomMarshalerSequence(mtype reflect.Type) bool {
- switch mtype.Kind() {
- case reflect.Ptr:
- return isCustomMarshalerSequence(mtype.Elem())
- case reflect.Slice, reflect.Array:
- return isCustomMarshaler(mtype.Elem()) || isCustomMarshaler(reflect.New(mtype.Elem()).Type())
- default:
- return false
- }
-}
-
-// Check if the given marshal type maps to a slice or array of a text marshaler type
-func isTextMarshalerSequence(mtype reflect.Type) bool {
- switch mtype.Kind() {
- case reflect.Ptr:
- return isTextMarshalerSequence(mtype.Elem())
- case reflect.Slice, reflect.Array:
- return isTextMarshaler(mtype.Elem()) || isTextMarshaler(reflect.New(mtype.Elem()).Type())
- default:
- return false
- }
-}
-
-// Check if the given marshal type maps to a non-Tree slice or array
-func isOtherSequence(mtype reflect.Type) bool {
- switch mtype.Kind() {
- case reflect.Ptr:
- return isOtherSequence(mtype.Elem())
- case reflect.Slice, reflect.Array:
- return !isTreeSequence(mtype)
- default:
- return false
- }
-}
-
-// Check if the given marshal type maps to a Tree
-func isTree(mtype reflect.Type) bool {
- switch mtype.Kind() {
- case reflect.Ptr:
- return isTree(mtype.Elem())
- case reflect.Map:
- return true
- case reflect.Struct:
- return !isPrimitive(mtype)
- default:
- return false
- }
-}
-
-func isCustomMarshaler(mtype reflect.Type) bool {
- return mtype.Implements(marshalerType)
-}
-
-func callCustomMarshaler(mval reflect.Value) ([]byte, error) {
- return mval.Interface().(Marshaler).MarshalTOML()
-}
-
-func isTextMarshaler(mtype reflect.Type) bool {
- return mtype.Implements(textMarshalerType) && !isTimeType(mtype)
-}
-
-func callTextMarshaler(mval reflect.Value) ([]byte, error) {
- return mval.Interface().(encoding.TextMarshaler).MarshalText()
-}
-
-func isCustomUnmarshaler(mtype reflect.Type) bool {
- return mtype.Implements(unmarshalerType)
-}
-
-func callCustomUnmarshaler(mval reflect.Value, tval interface{}) error {
- return mval.Interface().(Unmarshaler).UnmarshalTOML(tval)
-}
-
-func isTextUnmarshaler(mtype reflect.Type) bool {
- return mtype.Implements(textUnmarshalerType)
-}
-
-func callTextUnmarshaler(mval reflect.Value, text []byte) error {
- return mval.Interface().(encoding.TextUnmarshaler).UnmarshalText(text)
-}
-
-// Marshaler is the interface implemented by types that
-// can marshal themselves into valid TOML.
-type Marshaler interface {
- MarshalTOML() ([]byte, error)
-}
-
-// Unmarshaler is the interface implemented by types that
-// can unmarshal a TOML description of themselves.
-type Unmarshaler interface {
- UnmarshalTOML(interface{}) 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
-function for sub-structs, and currently only definite types can be marshaled
-(i.e. no `interface{}`).
-
-The following struct annotations are supported:
-
- toml:"Field" Overrides the field's name to output.
- omitempty When set, empty values and groups are not emitted.
- comment:"comment" Emits a # comment on the same line. This supports new lines.
- commented:"true" Emits the value as commented.
-
-Note that pointers are automatically assigned the "omitempty" option, as TOML
-explicitly does not handle null values (saying instead the label should be
-dropped).
-
-Tree structural types and corresponding marshal types:
-
- *Tree (*)struct, (*)map[string]interface{}
- []*Tree (*)[](*)struct, (*)[](*)map[string]interface{}
- []interface{} (as interface{}) (*)[]primitive, (*)[]([]interface{})
- interface{} (*)primitive
-
-Tree primitive types and corresponding marshal types:
-
- uint64 uint, uint8-uint64, pointers to same
- int64 int, int8-uint64, pointers to same
- float64 float32, float64, pointers to same
- string string, pointers to same
- bool bool, pointers to same
- time.LocalTime time.LocalTime{}, pointers to same
-
-For additional flexibility, use the Encoder API.
-*/
-func Marshal(v interface{}) ([]byte, error) {
- return NewEncoder(nil).marshal(v)
-}
-
-// Encoder writes TOML values to an output stream.
-type Encoder struct {
- w io.Writer
- encOpts
- annotation
- line int
- col int
- order MarshalOrder
- promoteAnon bool
- compactComments bool
- indentation string
-}
-
-// NewEncoder returns a new encoder that writes to w.
-func NewEncoder(w io.Writer) *Encoder {
- return &Encoder{
- w: w,
- encOpts: encOptsDefaults,
- annotation: annotationDefault,
- line: 0,
- col: 1,
- order: OrderAlphabetical,
- indentation: " ",
- }
-}
-
-// Encode writes the TOML encoding of v to the stream.
-//
-// See the documentation for Marshal for details.
-func (e *Encoder) Encode(v interface{}) error {
- b, err := e.marshal(v)
- if err != nil {
- return err
- }
- if _, err := e.w.Write(b); err != nil {
- return err
- }
- return nil
-}
-
-// QuoteMapKeys sets up the encoder to encode
-// maps with string type keys with quoted TOML keys.
-//
-// This relieves the character limitations on map keys.
-func (e *Encoder) QuoteMapKeys(v bool) *Encoder {
- e.quoteMapKeys = v
- return e
-}
-
-// ArraysWithOneElementPerLine sets up the encoder to encode arrays
-// with more than one element on multiple lines instead of one.
-//
-// For example:
-//
-// A = [1,2,3]
-//
-// Becomes
-//
-// A = [
-// 1,
-// 2,
-// 3,
-// ]
-func (e *Encoder) ArraysWithOneElementPerLine(v bool) *Encoder {
- e.arraysOneElementPerLine = v
- return e
-}
-
-// Order allows to change in which order fields will be written to the output stream.
-func (e *Encoder) Order(ord MarshalOrder) *Encoder {
- e.order = ord
- return e
-}
-
-// Indentation allows to change indentation when marshalling.
-func (e *Encoder) Indentation(indent string) *Encoder {
- e.indentation = indent
- return e
-}
-
-// SetTagName allows changing default tag "toml"
-func (e *Encoder) SetTagName(v string) *Encoder {
- e.tag = v
- return e
-}
-
-// SetTagComment allows changing default tag "comment"
-func (e *Encoder) SetTagComment(v string) *Encoder {
- e.comment = v
- return e
-}
-
-// SetTagCommented allows changing default tag "commented"
-func (e *Encoder) SetTagCommented(v string) *Encoder {
- e.commented = v
- return e
-}
-
-// SetTagMultiline allows changing default tag "multiline"
-func (e *Encoder) SetTagMultiline(v string) *Encoder {
- e.multiline = v
- return e
-}
-
-// PromoteAnonymous allows to change how anonymous struct fields are marshaled.
-// Usually, they are marshaled as if the inner exported fields were fields in
-// the outer struct. However, if an anonymous struct field is given a name in
-// its TOML tag, it is treated like a regular struct field with that name.
-// rather than being anonymous.
-//
-// In case anonymous promotion is enabled, all anonymous structs are promoted
-// and treated like regular struct fields.
-func (e *Encoder) PromoteAnonymous(promote bool) *Encoder {
- e.promoteAnon = promote
- return e
-}
-
-// CompactComments removes the new line before each comment in the tree.
-func (e *Encoder) CompactComments(cc bool) *Encoder {
- e.compactComments = cc
- return e
-}
-
-func (e *Encoder) marshal(v interface{}) ([]byte, error) {
- // Check if indentation is valid
- for _, char := range e.indentation {
- if !isSpace(char) {
- return []byte{}, fmt.Errorf("invalid indentation: must only contains space or tab characters")
- }
- }
-
- mtype := reflect.TypeOf(v)
- if mtype == nil {
- return []byte{}, errors.New("nil cannot be marshaled to TOML")
- }
-
- switch mtype.Kind() {
- case reflect.Struct, reflect.Map:
- case reflect.Ptr:
- if mtype.Elem().Kind() != reflect.Struct {
- return []byte{}, errors.New("Only pointer to struct can be marshaled to TOML")
- }
- if reflect.ValueOf(v).IsNil() {
- return []byte{}, errors.New("nil pointer cannot be marshaled to TOML")
- }
- default:
- return []byte{}, errors.New("Only a struct or map can be marshaled to TOML")
- }
-
- sval := reflect.ValueOf(v)
- if isCustomMarshaler(mtype) {
- return callCustomMarshaler(sval)
- }
- if isTextMarshaler(mtype) {
- return callTextMarshaler(sval)
- }
- t, err := e.valueToTree(mtype, sval)
- if err != nil {
- return []byte{}, err
- }
-
- var buf bytes.Buffer
- _, err = t.writeToOrdered(&buf, "", "", 0, e.arraysOneElementPerLine, e.order, e.indentation, e.compactComments, false)
-
- return buf.Bytes(), err
-}
-
-// Create next tree with a position based on Encoder.line
-func (e *Encoder) nextTree() *Tree {
- return newTreeWithPosition(Position{Line: e.line, Col: 1})
-}
-
-// Convert given marshal struct or map value to toml tree
-func (e *Encoder) valueToTree(mtype reflect.Type, mval reflect.Value) (*Tree, error) {
- if mtype.Kind() == reflect.Ptr {
- return e.valueToTree(mtype.Elem(), mval.Elem())
- }
- tval := e.nextTree()
- switch mtype.Kind() {
- case reflect.Struct:
- switch mval.Interface().(type) {
- case Tree:
- reflect.ValueOf(tval).Elem().Set(mval)
- default:
- for i := 0; i < mtype.NumField(); i++ {
- mtypef, mvalf := mtype.Field(i), mval.Field(i)
- opts := tomlOptions(mtypef, e.annotation)
- if opts.include && ((mtypef.Type.Kind() != reflect.Interface && !opts.omitempty) || !isZero(mvalf)) {
- val, err := e.valueToToml(mtypef.Type, mvalf)
- if err != nil {
- return nil, err
- }
- if tree, ok := val.(*Tree); ok && mtypef.Anonymous && !opts.nameFromTag && !e.promoteAnon {
- e.appendTree(tval, tree)
- } else {
- val = e.wrapTomlValue(val, tval)
- tval.SetPathWithOptions([]string{opts.name}, SetOptions{
- Comment: opts.comment,
- Commented: opts.commented,
- Multiline: opts.multiline,
- Literal: opts.literal,
- }, val)
- }
- }
- }
- }
- case reflect.Map:
- keys := mval.MapKeys()
- if e.order == OrderPreserve && len(keys) > 0 {
- // Sorting []reflect.Value is not straight forward.
- //
- // OrderPreserve will support deterministic results when string is used
- // as the key to maps.
- typ := keys[0].Type()
- kind := keys[0].Kind()
- if kind == reflect.String {
- ikeys := make([]string, len(keys))
- for i := range keys {
- ikeys[i] = keys[i].Interface().(string)
- }
- sort.Strings(ikeys)
- for i := range ikeys {
- keys[i] = reflect.ValueOf(ikeys[i]).Convert(typ)
- }
- }
- }
- for _, key := range keys {
- mvalf := mval.MapIndex(key)
- if (mtype.Elem().Kind() == reflect.Ptr || mtype.Elem().Kind() == reflect.Interface) && mvalf.IsNil() {
- continue
- }
- val, err := e.valueToToml(mtype.Elem(), mvalf)
- if err != nil {
- return nil, err
- }
- val = e.wrapTomlValue(val, tval)
- if e.quoteMapKeys {
- keyStr, err := tomlValueStringRepresentation(key.String(), "", "", e.order, e.arraysOneElementPerLine)
- if err != nil {
- return nil, err
- }
- tval.SetPath([]string{keyStr}, val)
- } else {
- tval.SetPath([]string{key.String()}, val)
- }
- }
- }
- return tval, nil
-}
-
-// Convert given marshal slice to slice of Toml trees
-func (e *Encoder) valueToTreeSlice(mtype reflect.Type, mval reflect.Value) ([]*Tree, error) {
- tval := make([]*Tree, mval.Len(), mval.Len())
- for i := 0; i < mval.Len(); i++ {
- val, err := e.valueToTree(mtype.Elem(), mval.Index(i))
- if err != nil {
- return nil, err
- }
- tval[i] = val
- }
- return tval, nil
-}
-
-// Convert given marshal slice to slice of toml values
-func (e *Encoder) valueToOtherSlice(mtype reflect.Type, mval reflect.Value) (interface{}, error) {
- tval := make([]interface{}, mval.Len(), mval.Len())
- for i := 0; i < mval.Len(); i++ {
- val, err := e.valueToToml(mtype.Elem(), mval.Index(i))
- if err != nil {
- return nil, err
- }
- tval[i] = val
- }
- return tval, nil
-}
-
-// Convert given marshal value to toml value
-func (e *Encoder) valueToToml(mtype reflect.Type, mval reflect.Value) (interface{}, error) {
- if mtype.Kind() == reflect.Ptr {
- switch {
- case isCustomMarshaler(mtype):
- return callCustomMarshaler(mval)
- case isTextMarshaler(mtype):
- b, err := callTextMarshaler(mval)
- return string(b), err
- default:
- return e.valueToToml(mtype.Elem(), mval.Elem())
- }
- }
- if mtype.Kind() == reflect.Interface {
- return e.valueToToml(mval.Elem().Type(), mval.Elem())
- }
- switch {
- case isCustomMarshaler(mtype):
- return callCustomMarshaler(mval)
- case isTextMarshaler(mtype):
- b, err := callTextMarshaler(mval)
- return string(b), err
- case isTree(mtype):
- return e.valueToTree(mtype, mval)
- case isOtherSequence(mtype), isCustomMarshalerSequence(mtype), isTextMarshalerSequence(mtype):
- return e.valueToOtherSlice(mtype, mval)
- case isTreeSequence(mtype):
- return e.valueToTreeSlice(mtype, mval)
- default:
- switch mtype.Kind() {
- case reflect.Bool:
- return mval.Bool(), nil
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- if mtype.Kind() == reflect.Int64 && mtype == reflect.TypeOf(time.Duration(1)) {
- return fmt.Sprint(mval), nil
- }
- return mval.Int(), nil
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
- return mval.Uint(), nil
- case reflect.Float32, reflect.Float64:
- return mval.Float(), nil
- case reflect.String:
- return mval.String(), nil
- case reflect.Struct:
- return mval.Interface(), nil
- default:
- return nil, fmt.Errorf("Marshal can't handle %v(%v)", mtype, mtype.Kind())
- }
- }
-}
-
-func (e *Encoder) appendTree(t, o *Tree) error {
- for key, value := range o.values {
- if _, ok := t.values[key]; ok {
- continue
- }
- if tomlValue, ok := value.(*tomlValue); ok {
- tomlValue.position.Col = t.position.Col
- }
- t.values[key] = value
- }
- return nil
-}
-
-// Create a toml value with the current line number as the position line
-func (e *Encoder) wrapTomlValue(val interface{}, parent *Tree) interface{} {
- _, isTree := val.(*Tree)
- _, isTreeS := val.([]*Tree)
- if isTree || isTreeS {
- e.line++
- return val
- }
-
- ret := &tomlValue{
- value: val,
- position: Position{
- e.line,
- parent.position.Col,
- },
- }
- e.line++
- return ret
-}
-
-// Unmarshal attempts to unmarshal the Tree into a Go struct pointed by v.
-// Neither Unmarshaler interfaces nor UnmarshalTOML functions are supported for
-// sub-structs, and only definite types can be unmarshaled.
-func (t *Tree) Unmarshal(v interface{}) error {
- d := Decoder{tval: t, tagName: tagFieldName}
- return d.unmarshal(v)
-}
-
-// Marshal returns the TOML encoding of Tree.
-// See Marshal() documentation for types mapping table.
-func (t *Tree) Marshal() ([]byte, error) {
- var buf bytes.Buffer
- _, err := t.WriteTo(&buf)
- if err != nil {
- return nil, err
- }
- return buf.Bytes(), nil
-}
-
-// Unmarshal parses the TOML-encoded data and stores the result in the value
-// pointed to by v. Behavior is similar to the Go json encoder, except that there
-// is no concept of an Unmarshaler interface or UnmarshalTOML function for
-// sub-structs, and currently only definite types can be unmarshaled to (i.e. no
-// `interface{}`).
-//
-// The following struct annotations are supported:
-//
-// toml:"Field" Overrides the field's name to map to.
-// default:"foo" Provides a default value.
-//
-// For default values, only fields of the following types are supported:
-// * string
-// * bool
-// * int
-// * int64
-// * float64
-//
-// See Marshal() documentation for types mapping table.
-func Unmarshal(data []byte, v interface{}) error {
- t, err := LoadReader(bytes.NewReader(data))
- if err != nil {
- return err
- }
- return t.Unmarshal(v)
-}
-
-// Decoder reads and decodes TOML values from an input stream.
-type Decoder struct {
- r io.Reader
- tval *Tree
- encOpts
- tagName string
- strict bool
- visitor visitorState
-}
-
-// NewDecoder returns a new decoder that reads from r.
-func NewDecoder(r io.Reader) *Decoder {
- return &Decoder{
- r: r,
- encOpts: encOptsDefaults,
- tagName: tagFieldName,
- }
-}
-
-// Decode reads a TOML-encoded value from it's input
-// and unmarshals it in the value pointed at by v.
-//
-// See the documentation for Marshal for details.
-func (d *Decoder) Decode(v interface{}) error {
- var err error
- d.tval, err = LoadReader(d.r)
- if err != nil {
- return err
- }
- return d.unmarshal(v)
-}
-
-// SetTagName allows changing default tag "toml"
-func (d *Decoder) SetTagName(v string) *Decoder {
- d.tagName = v
- return d
-}
-
-// Strict allows changing to strict decoding. Any fields that are found in the
-// input data and do not have a corresponding struct member cause an error.
-func (d *Decoder) Strict(strict bool) *Decoder {
- d.strict = strict
- return d
-}
-
-func (d *Decoder) unmarshal(v interface{}) error {
- mtype := reflect.TypeOf(v)
- if mtype == nil {
- return errors.New("nil cannot be unmarshaled from TOML")
- }
- if mtype.Kind() != reflect.Ptr {
- return errors.New("only a pointer to struct or map can be unmarshaled from TOML")
- }
-
- elem := mtype.Elem()
-
- switch elem.Kind() {
- case reflect.Struct, reflect.Map:
- case reflect.Interface:
- elem = mapStringInterfaceType
- default:
- return errors.New("only a pointer to struct or map can be unmarshaled from TOML")
- }
-
- if reflect.ValueOf(v).IsNil() {
- return errors.New("nil pointer cannot be unmarshaled from TOML")
- }
-
- vv := reflect.ValueOf(v).Elem()
-
- if d.strict {
- d.visitor = newVisitorState(d.tval)
- }
-
- sval, err := d.valueFromTree(elem, d.tval, &vv)
- if err != nil {
- return err
- }
- if err := d.visitor.validate(); err != nil {
- return err
- }
- reflect.ValueOf(v).Elem().Set(sval)
- return nil
-}
-
-// Convert toml tree to marshal struct or map, using marshal type. When mval1
-// is non-nil, merge fields into the given value instead of allocating a new one.
-func (d *Decoder) valueFromTree(mtype reflect.Type, tval *Tree, mval1 *reflect.Value) (reflect.Value, error) {
- if mtype.Kind() == reflect.Ptr {
- return d.unwrapPointer(mtype, tval, mval1)
- }
-
- // Check if pointer to value implements the Unmarshaler interface.
- if mvalPtr := reflect.New(mtype); isCustomUnmarshaler(mvalPtr.Type()) {
- d.visitor.visitAll()
-
- if tval == nil {
- return mvalPtr.Elem(), nil
- }
-
- if err := callCustomUnmarshaler(mvalPtr, tval.ToMap()); err != nil {
- return reflect.ValueOf(nil), fmt.Errorf("unmarshal toml: %v", err)
- }
- return mvalPtr.Elem(), nil
- }
-
- var mval reflect.Value
- switch mtype.Kind() {
- case reflect.Struct:
- if mval1 != nil {
- mval = *mval1
- } else {
- mval = reflect.New(mtype).Elem()
- }
-
- switch mval.Interface().(type) {
- case Tree:
- mval.Set(reflect.ValueOf(tval).Elem())
- default:
- for i := 0; i < mtype.NumField(); i++ {
- mtypef := mtype.Field(i)
- an := annotation{tag: d.tagName}
- opts := tomlOptions(mtypef, an)
- if !opts.include {
- continue
- }
- baseKey := opts.name
- keysToTry := []string{
- baseKey,
- strings.ToLower(baseKey),
- strings.ToTitle(baseKey),
- strings.ToLower(string(baseKey[0])) + baseKey[1:],
- }
-
- found := false
- if tval != nil {
- for _, key := range keysToTry {
- exists := tval.HasPath([]string{key})
- if !exists {
- continue
- }
-
- d.visitor.push(key)
- val := tval.GetPath([]string{key})
- fval := mval.Field(i)
- mvalf, err := d.valueFromToml(mtypef.Type, val, &fval)
- if err != nil {
- return mval, formatError(err, tval.GetPositionPath([]string{key}))
- }
- mval.Field(i).Set(mvalf)
- found = true
- d.visitor.pop()
- break
- }
- }
-
- if !found && opts.defaultValue != "" {
- mvalf := mval.Field(i)
- var val interface{}
- var err error
- switch mvalf.Kind() {
- case reflect.String:
- val = opts.defaultValue
- case reflect.Bool:
- val, err = strconv.ParseBool(opts.defaultValue)
- case reflect.Uint:
- val, err = strconv.ParseUint(opts.defaultValue, 10, 0)
- case reflect.Uint8:
- val, err = strconv.ParseUint(opts.defaultValue, 10, 8)
- case reflect.Uint16:
- val, err = strconv.ParseUint(opts.defaultValue, 10, 16)
- case reflect.Uint32:
- val, err = strconv.ParseUint(opts.defaultValue, 10, 32)
- case reflect.Uint64:
- val, err = strconv.ParseUint(opts.defaultValue, 10, 64)
- case reflect.Int:
- val, err = strconv.ParseInt(opts.defaultValue, 10, 0)
- case reflect.Int8:
- val, err = strconv.ParseInt(opts.defaultValue, 10, 8)
- case reflect.Int16:
- val, err = strconv.ParseInt(opts.defaultValue, 10, 16)
- case reflect.Int32:
- val, err = strconv.ParseInt(opts.defaultValue, 10, 32)
- case reflect.Int64:
- // Check if the provided number has a non-numeric extension.
- var hasExtension bool
- if len(opts.defaultValue) > 0 {
- lastChar := opts.defaultValue[len(opts.defaultValue)-1]
- if lastChar < '0' || lastChar > '9' {
- hasExtension = true
- }
- }
- // If the value is a time.Duration with extension, parse as duration.
- // If the value is an int64 or a time.Duration without extension, parse as number.
- if hasExtension && mvalf.Type().String() == "time.Duration" {
- val, err = time.ParseDuration(opts.defaultValue)
- } else {
- val, err = strconv.ParseInt(opts.defaultValue, 10, 64)
- }
- case reflect.Float32:
- val, err = strconv.ParseFloat(opts.defaultValue, 32)
- case reflect.Float64:
- val, err = strconv.ParseFloat(opts.defaultValue, 64)
- default:
- return mvalf, fmt.Errorf("unsupported field type for default option")
- }
-
- if err != nil {
- return mvalf, err
- }
- mvalf.Set(reflect.ValueOf(val).Convert(mvalf.Type()))
- }
-
- // save the old behavior above and try to check structs
- if !found && opts.defaultValue == "" && mtypef.Type.Kind() == reflect.Struct {
- tmpTval := tval
- if !mtypef.Anonymous {
- tmpTval = nil
- }
- fval := mval.Field(i)
- v, err := d.valueFromTree(mtypef.Type, tmpTval, &fval)
- if err != nil {
- return v, err
- }
- mval.Field(i).Set(v)
- }
- }
- }
- case reflect.Map:
- mval = reflect.MakeMap(mtype)
- for _, key := range tval.Keys() {
- d.visitor.push(key)
- // TODO: path splits key
- val := tval.GetPath([]string{key})
- mvalf, err := d.valueFromToml(mtype.Elem(), val, nil)
- if err != nil {
- return mval, formatError(err, tval.GetPositionPath([]string{key}))
- }
- mval.SetMapIndex(reflect.ValueOf(key).Convert(mtype.Key()), mvalf)
- d.visitor.pop()
- }
- }
- return mval, nil
-}
-
-// Convert toml value to marshal struct/map slice, using marshal type
-func (d *Decoder) valueFromTreeSlice(mtype reflect.Type, tval []*Tree) (reflect.Value, error) {
- mval, err := makeSliceOrArray(mtype, len(tval))
- if err != nil {
- return mval, err
- }
-
- for i := 0; i < len(tval); i++ {
- d.visitor.push(strconv.Itoa(i))
- val, err := d.valueFromTree(mtype.Elem(), tval[i], nil)
- if err != nil {
- return mval, err
- }
- mval.Index(i).Set(val)
- d.visitor.pop()
- }
- return mval, nil
-}
-
-// Convert toml value to marshal primitive slice, using marshal type
-func (d *Decoder) valueFromOtherSlice(mtype reflect.Type, tval []interface{}) (reflect.Value, error) {
- mval, err := makeSliceOrArray(mtype, len(tval))
- if err != nil {
- return mval, err
- }
-
- for i := 0; i < len(tval); i++ {
- val, err := d.valueFromToml(mtype.Elem(), tval[i], nil)
- if err != nil {
- return mval, err
- }
- mval.Index(i).Set(val)
- }
- return mval, nil
-}
-
-// Convert toml value to marshal primitive slice, using marshal type
-func (d *Decoder) valueFromOtherSliceI(mtype reflect.Type, tval interface{}) (reflect.Value, error) {
- val := reflect.ValueOf(tval)
- length := val.Len()
-
- mval, err := makeSliceOrArray(mtype, length)
- if err != nil {
- return mval, err
- }
-
- for i := 0; i < length; i++ {
- val, err := d.valueFromToml(mtype.Elem(), val.Index(i).Interface(), nil)
- if err != nil {
- return mval, err
- }
- mval.Index(i).Set(val)
- }
- return mval, nil
-}
-
-// Create a new slice or a new array with specified length
-func makeSliceOrArray(mtype reflect.Type, tLength int) (reflect.Value, error) {
- var mval reflect.Value
- switch mtype.Kind() {
- case reflect.Slice:
- mval = reflect.MakeSlice(mtype, tLength, tLength)
- case reflect.Array:
- mval = reflect.New(reflect.ArrayOf(mtype.Len(), mtype.Elem())).Elem()
- if tLength > mtype.Len() {
- return mval, fmt.Errorf("unmarshal: TOML array length (%v) exceeds destination array length (%v)", tLength, mtype.Len())
- }
- }
- return mval, nil
-}
-
-// Convert toml value to marshal value, using marshal type. When mval1 is non-nil
-// and the given type is a struct value, merge fields into it.
-func (d *Decoder) valueFromToml(mtype reflect.Type, tval interface{}, mval1 *reflect.Value) (reflect.Value, error) {
- if mtype.Kind() == reflect.Ptr {
- return d.unwrapPointer(mtype, tval, mval1)
- }
-
- switch t := tval.(type) {
- case *Tree:
- var mval11 *reflect.Value
- if mtype.Kind() == reflect.Struct {
- mval11 = mval1
- }
-
- if isTree(mtype) {
- return d.valueFromTree(mtype, t, mval11)
- }
-
- if mtype.Kind() == reflect.Interface {
- if mval1 == nil || mval1.IsNil() {
- return d.valueFromTree(reflect.TypeOf(map[string]interface{}{}), t, nil)
- } else {
- return d.valueFromToml(mval1.Elem().Type(), t, nil)
- }
- }
-
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to a tree", tval, tval)
- case []*Tree:
- if isTreeSequence(mtype) {
- return d.valueFromTreeSlice(mtype, t)
- }
- if mtype.Kind() == reflect.Interface {
- if mval1 == nil || mval1.IsNil() {
- return d.valueFromTreeSlice(reflect.TypeOf([]map[string]interface{}{}), t)
- } else {
- ival := mval1.Elem()
- return d.valueFromToml(mval1.Elem().Type(), t, &ival)
- }
- }
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to trees", tval, tval)
- case []interface{}:
- d.visitor.visit()
- if isOtherSequence(mtype) {
- return d.valueFromOtherSlice(mtype, t)
- }
- if mtype.Kind() == reflect.Interface {
- if mval1 == nil || mval1.IsNil() {
- return d.valueFromOtherSlice(reflect.TypeOf([]interface{}{}), t)
- } else {
- ival := mval1.Elem()
- return d.valueFromToml(mval1.Elem().Type(), t, &ival)
- }
- }
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to a slice", tval, tval)
- default:
- d.visitor.visit()
- mvalPtr := reflect.New(mtype)
-
- // Check if pointer to value implements the Unmarshaler interface.
- if isCustomUnmarshaler(mvalPtr.Type()) {
- if err := callCustomUnmarshaler(mvalPtr, tval); err != nil {
- return reflect.ValueOf(nil), fmt.Errorf("unmarshal toml: %v", err)
- }
- return mvalPtr.Elem(), nil
- }
-
- // Check if pointer to value implements the encoding.TextUnmarshaler.
- if isTextUnmarshaler(mvalPtr.Type()) && !isTimeType(mtype) {
- if err := d.unmarshalText(tval, mvalPtr); err != nil {
- return reflect.ValueOf(nil), fmt.Errorf("unmarshal text: %v", err)
- }
- return mvalPtr.Elem(), nil
- }
-
- switch mtype.Kind() {
- case reflect.Bool, reflect.Struct:
- val := reflect.ValueOf(tval)
-
- switch val.Type() {
- case localDateType:
- localDate := val.Interface().(LocalDate)
- switch mtype {
- case timeType:
- return reflect.ValueOf(time.Date(localDate.Year, localDate.Month, localDate.Day, 0, 0, 0, 0, time.Local)), nil
- }
- case localDateTimeType:
- localDateTime := val.Interface().(LocalDateTime)
- switch mtype {
- case timeType:
- return reflect.ValueOf(time.Date(
- localDateTime.Date.Year,
- localDateTime.Date.Month,
- localDateTime.Date.Day,
- localDateTime.Time.Hour,
- localDateTime.Time.Minute,
- localDateTime.Time.Second,
- localDateTime.Time.Nanosecond,
- time.Local)), nil
- }
- }
-
- // if this passes for when mtype is reflect.Struct, tval is a time.LocalTime
- if !val.Type().ConvertibleTo(mtype) {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String())
- }
-
- return val.Convert(mtype), nil
- case reflect.String:
- val := reflect.ValueOf(tval)
- // stupidly, int64 is convertible to string. So special case this.
- if !val.Type().ConvertibleTo(mtype) || val.Kind() == reflect.Int64 {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String())
- }
-
- return val.Convert(mtype), nil
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- val := reflect.ValueOf(tval)
- if mtype.Kind() == reflect.Int64 && mtype == reflect.TypeOf(time.Duration(1)) && val.Kind() == reflect.String {
- d, err := time.ParseDuration(val.String())
- if err != nil {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v. %s", tval, tval, mtype.String(), err)
- }
- return reflect.ValueOf(d), nil
- }
- if !val.Type().ConvertibleTo(mtype) || val.Kind() == reflect.Float64 {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String())
- }
- if reflect.Indirect(reflect.New(mtype)).OverflowInt(val.Convert(reflect.TypeOf(int64(0))).Int()) {
- return reflect.ValueOf(nil), fmt.Errorf("%v(%T) would overflow %v", tval, tval, mtype.String())
- }
-
- return val.Convert(mtype), nil
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- val := reflect.ValueOf(tval)
- if !val.Type().ConvertibleTo(mtype) || val.Kind() == reflect.Float64 {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String())
- }
-
- if val.Type().Kind() != reflect.Uint64 && val.Convert(reflect.TypeOf(int(1))).Int() < 0 {
- return reflect.ValueOf(nil), fmt.Errorf("%v(%T) is negative so does not fit in %v", tval, tval, mtype.String())
- }
- if reflect.Indirect(reflect.New(mtype)).OverflowUint(val.Convert(reflect.TypeOf(uint64(0))).Uint()) {
- return reflect.ValueOf(nil), fmt.Errorf("%v(%T) would overflow %v", tval, tval, mtype.String())
- }
-
- return val.Convert(mtype), nil
- case reflect.Float32, reflect.Float64:
- val := reflect.ValueOf(tval)
- if !val.Type().ConvertibleTo(mtype) || val.Kind() == reflect.Int64 {
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String())
- }
- if reflect.Indirect(reflect.New(mtype)).OverflowFloat(val.Convert(reflect.TypeOf(float64(0))).Float()) {
- return reflect.ValueOf(nil), fmt.Errorf("%v(%T) would overflow %v", tval, tval, mtype.String())
- }
-
- return val.Convert(mtype), nil
- case reflect.Interface:
- if mval1 == nil || mval1.IsNil() {
- return reflect.ValueOf(tval), nil
- } else {
- ival := mval1.Elem()
- return d.valueFromToml(mval1.Elem().Type(), t, &ival)
- }
- case reflect.Slice, reflect.Array:
- if isOtherSequence(mtype) && isOtherSequence(reflect.TypeOf(t)) {
- return d.valueFromOtherSliceI(mtype, t)
- }
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v(%v)", tval, tval, mtype, mtype.Kind())
- default:
- return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v(%v)", tval, tval, mtype, mtype.Kind())
- }
- }
-}
-
-func (d *Decoder) unwrapPointer(mtype reflect.Type, tval interface{}, mval1 *reflect.Value) (reflect.Value, error) {
- var melem *reflect.Value
-
- if mval1 != nil && !mval1.IsNil() && (mtype.Elem().Kind() == reflect.Struct || mtype.Elem().Kind() == reflect.Interface) {
- elem := mval1.Elem()
- melem = &elem
- }
-
- val, err := d.valueFromToml(mtype.Elem(), tval, melem)
- if err != nil {
- return reflect.ValueOf(nil), err
- }
- mval := reflect.New(mtype.Elem())
- mval.Elem().Set(val)
- return mval, nil
-}
-
-func (d *Decoder) unmarshalText(tval interface{}, mval reflect.Value) error {
- var buf bytes.Buffer
- fmt.Fprint(&buf, tval)
- return callTextUnmarshaler(mval, buf.Bytes())
-}
-
-func tomlOptions(vf reflect.StructField, an annotation) tomlOpts {
- tag := vf.Tag.Get(an.tag)
- parse := strings.Split(tag, ",")
- var comment string
- if c := vf.Tag.Get(an.comment); c != "" {
- comment = c
- }
- commented, _ := strconv.ParseBool(vf.Tag.Get(an.commented))
- multiline, _ := strconv.ParseBool(vf.Tag.Get(an.multiline))
- literal, _ := strconv.ParseBool(vf.Tag.Get(an.literal))
- defaultValue := vf.Tag.Get(tagDefault)
- result := tomlOpts{
- name: vf.Name,
- nameFromTag: false,
- comment: comment,
- commented: commented,
- multiline: multiline,
- literal: literal,
- include: true,
- omitempty: false,
- defaultValue: defaultValue,
- }
- if parse[0] != "" {
- if parse[0] == "-" && len(parse) == 1 {
- result.include = false
- } else {
- result.name = strings.Trim(parse[0], " ")
- result.nameFromTag = true
- }
- }
- if vf.PkgPath != "" {
- result.include = false
- }
- if len(parse) > 1 && strings.Trim(parse[1], " ") == "omitempty" {
- result.omitempty = true
- }
- if vf.Type.Kind() == reflect.Ptr {
- result.omitempty = true
- }
- return result
-}
-
-func isZero(val reflect.Value) bool {
- switch val.Type().Kind() {
- case reflect.Slice, reflect.Array, reflect.Map:
- return val.Len() == 0
- default:
- return reflect.DeepEqual(val.Interface(), reflect.Zero(val.Type()).Interface())
- }
-}
-
-func formatError(err error, pos Position) error {
- if err.Error()[0] == '(' { // Error already contains position information
- return err
- }
- return fmt.Errorf("%s: %s", pos, err)
-}
-
-// visitorState keeps track of which keys were unmarshaled.
-type visitorState struct {
- tree *Tree
- path []string
- keys map[string]struct{}
- active bool
-}
-
-func newVisitorState(tree *Tree) visitorState {
- path, result := []string{}, map[string]struct{}{}
- insertKeys(path, result, tree)
- return visitorState{
- tree: tree,
- path: path[:0],
- keys: result,
- active: true,
- }
-}
-
-func (s *visitorState) push(key string) {
- if s.active {
- s.path = append(s.path, key)
- }
-}
-
-func (s *visitorState) pop() {
- if s.active {
- s.path = s.path[:len(s.path)-1]
- }
-}
-
-func (s *visitorState) visit() {
- if s.active {
- delete(s.keys, strings.Join(s.path, "."))
- }
-}
-
-func (s *visitorState) visitAll() {
- if s.active {
- for k := range s.keys {
- if strings.HasPrefix(k, strings.Join(s.path, ".")) {
- delete(s.keys, k)
- }
- }
- }
-}
-
-func (s *visitorState) validate() error {
- if !s.active {
- return nil
- }
- undecoded := make([]string, 0, len(s.keys))
- for key := range s.keys {
- undecoded = append(undecoded, key)
- }
- sort.Strings(undecoded)
- if len(undecoded) > 0 {
- return fmt.Errorf("undecoded keys: %q", undecoded)
- }
- return nil
-}
-
-func insertKeys(path []string, m map[string]struct{}, tree *Tree) {
- for k, v := range tree.values {
- switch node := v.(type) {
- case []*Tree:
- for i, item := range node {
- insertKeys(append(path, k, strconv.Itoa(i)), m, item)
- }
- case *Tree:
- insertKeys(append(path, k), m, node)
- case *tomlValue:
- m[strings.Join(append(path, k), ".")] = struct{}{}
- }
- }
-}
diff --git a/vendor/github.com/pelletier/go-toml/marshal_OrderPreserve_test.toml b/vendor/github.com/pelletier/go-toml/marshal_OrderPreserve_test.toml
deleted file mode 100644
index 792b72ed7..000000000
--- a/vendor/github.com/pelletier/go-toml/marshal_OrderPreserve_test.toml
+++ /dev/null
@@ -1,39 +0,0 @@
-title = "TOML Marshal Testing"
-
-[basic_lists]
- floats = [12.3,45.6,78.9]
- bools = [true,false,true]
- dates = [1979-05-27T07:32:00Z,1980-05-27T07:32:00Z]
- ints = [8001,8001,8002]
- uints = [5002,5003]
- strings = ["One","Two","Three"]
-
-[[subdocptrs]]
- name = "Second"
-
-[basic_map]
- one = "one"
- two = "two"
-
-[subdoc]
-
- [subdoc.second]
- name = "Second"
-
- [subdoc.first]
- name = "First"
-
-[basic]
- uint = 5001
- bool = true
- float = 123.4
- float64 = 123.456782132399
- int = 5000
- string = "Bite me"
- date = 1979-05-27T07:32:00Z
-
-[[subdoclist]]
- name = "List.First"
-
-[[subdoclist]]
- name = "List.Second"
diff --git a/vendor/github.com/pelletier/go-toml/marshal_test.toml b/vendor/github.com/pelletier/go-toml/marshal_test.toml
deleted file mode 100644
index ba5e110bf..000000000
--- a/vendor/github.com/pelletier/go-toml/marshal_test.toml
+++ /dev/null
@@ -1,39 +0,0 @@
-title = "TOML Marshal Testing"
-
-[basic]
- bool = true
- date = 1979-05-27T07:32:00Z
- float = 123.4
- float64 = 123.456782132399
- int = 5000
- string = "Bite me"
- uint = 5001
-
-[basic_lists]
- bools = [true,false,true]
- dates = [1979-05-27T07:32:00Z,1980-05-27T07:32:00Z]
- floats = [12.3,45.6,78.9]
- ints = [8001,8001,8002]
- strings = ["One","Two","Three"]
- uints = [5002,5003]
-
-[basic_map]
- one = "one"
- two = "two"
-
-[subdoc]
-
- [subdoc.first]
- name = "First"
-
- [subdoc.second]
- name = "Second"
-
-[[subdoclist]]
- name = "List.First"
-
-[[subdoclist]]
- name = "List.Second"
-
-[[subdocptrs]]
- name = "Second"
diff --git a/vendor/github.com/pelletier/go-toml/parser.go b/vendor/github.com/pelletier/go-toml/parser.go
deleted file mode 100644
index b3726d0dd..000000000
--- a/vendor/github.com/pelletier/go-toml/parser.go
+++ /dev/null
@@ -1,507 +0,0 @@
-// TOML Parser.
-
-package toml
-
-import (
- "errors"
- "fmt"
- "math"
- "reflect"
- "strconv"
- "strings"
- "time"
-)
-
-type tomlParser struct {
- flowIdx int
- flow []token
- tree *Tree
- currentTable []string
- seenTableKeys []string
-}
-
-type tomlParserStateFn func() tomlParserStateFn
-
-// Formats and panics an error message based on a token
-func (p *tomlParser) raiseError(tok *token, msg string, args ...interface{}) {
- panic(tok.Position.String() + ": " + fmt.Sprintf(msg, args...))
-}
-
-func (p *tomlParser) run() {
- for state := p.parseStart; state != nil; {
- state = state()
- }
-}
-
-func (p *tomlParser) peek() *token {
- if p.flowIdx >= len(p.flow) {
- return nil
- }
- return &p.flow[p.flowIdx]
-}
-
-func (p *tomlParser) assume(typ tokenType) {
- tok := p.getToken()
- if tok == nil {
- p.raiseError(tok, "was expecting token %s, but token stream is empty", tok)
- }
- if tok.typ != typ {
- p.raiseError(tok, "was expecting token %s, but got %s instead", typ, tok)
- }
-}
-
-func (p *tomlParser) getToken() *token {
- tok := p.peek()
- if tok == nil {
- return nil
- }
- p.flowIdx++
- return tok
-}
-
-func (p *tomlParser) parseStart() tomlParserStateFn {
- tok := p.peek()
-
- // end of stream, parsing is finished
- if tok == nil {
- return nil
- }
-
- switch tok.typ {
- case tokenDoubleLeftBracket:
- return p.parseGroupArray
- case tokenLeftBracket:
- return p.parseGroup
- case tokenKey:
- return p.parseAssign
- case tokenEOF:
- return nil
- case tokenError:
- p.raiseError(tok, "parsing error: %s", tok.String())
- default:
- p.raiseError(tok, "unexpected token %s", tok.typ)
- }
- return nil
-}
-
-func (p *tomlParser) parseGroupArray() tomlParserStateFn {
- startToken := p.getToken() // discard the [[
- key := p.getToken()
- if key.typ != tokenKeyGroupArray {
- p.raiseError(key, "unexpected token %s, was expecting a table array key", key)
- }
-
- // get or create table array element at the indicated part in the path
- keys, err := parseKey(key.val)
- if err != nil {
- p.raiseError(key, "invalid table array key: %s", err)
- }
- p.tree.createSubTree(keys[:len(keys)-1], startToken.Position) // create parent entries
- destTree := p.tree.GetPath(keys)
- var array []*Tree
- if destTree == nil {
- array = make([]*Tree, 0)
- } else if target, ok := destTree.([]*Tree); ok && target != nil {
- array = destTree.([]*Tree)
- } else {
- p.raiseError(key, "key %s is already assigned and not of type table array", key)
- }
- p.currentTable = keys
-
- // add a new tree to the end of the table array
- newTree := newTree()
- newTree.position = startToken.Position
- array = append(array, newTree)
- p.tree.SetPath(p.currentTable, array)
-
- // remove all keys that were children of this table array
- prefix := key.val + "."
- found := false
- for ii := 0; ii < len(p.seenTableKeys); {
- tableKey := p.seenTableKeys[ii]
- if strings.HasPrefix(tableKey, prefix) {
- p.seenTableKeys = append(p.seenTableKeys[:ii], p.seenTableKeys[ii+1:]...)
- } else {
- found = (tableKey == key.val)
- ii++
- }
- }
-
- // keep this key name from use by other kinds of assignments
- if !found {
- p.seenTableKeys = append(p.seenTableKeys, key.val)
- }
-
- // move to next parser state
- p.assume(tokenDoubleRightBracket)
- return p.parseStart
-}
-
-func (p *tomlParser) parseGroup() tomlParserStateFn {
- startToken := p.getToken() // discard the [
- key := p.getToken()
- if key.typ != tokenKeyGroup {
- p.raiseError(key, "unexpected token %s, was expecting a table key", key)
- }
- for _, item := range p.seenTableKeys {
- if item == key.val {
- p.raiseError(key, "duplicated tables")
- }
- }
-
- p.seenTableKeys = append(p.seenTableKeys, key.val)
- keys, err := parseKey(key.val)
- if err != nil {
- p.raiseError(key, "invalid table array key: %s", err)
- }
- if err := p.tree.createSubTree(keys, startToken.Position); err != nil {
- p.raiseError(key, "%s", err)
- }
- destTree := p.tree.GetPath(keys)
- if target, ok := destTree.(*Tree); ok && target != nil && target.inline {
- p.raiseError(key, "could not re-define exist inline table or its sub-table : %s",
- strings.Join(keys, "."))
- }
- p.assume(tokenRightBracket)
- p.currentTable = keys
- return p.parseStart
-}
-
-func (p *tomlParser) parseAssign() tomlParserStateFn {
- key := p.getToken()
- p.assume(tokenEqual)
-
- parsedKey, err := parseKey(key.val)
- if err != nil {
- p.raiseError(key, "invalid key: %s", err.Error())
- }
-
- value := p.parseRvalue()
- var tableKey []string
- if len(p.currentTable) > 0 {
- tableKey = p.currentTable
- } else {
- tableKey = []string{}
- }
-
- prefixKey := parsedKey[0 : len(parsedKey)-1]
- tableKey = append(tableKey, prefixKey...)
-
- // find the table to assign, looking out for arrays of tables
- var targetNode *Tree
- switch node := p.tree.GetPath(tableKey).(type) {
- case []*Tree:
- targetNode = node[len(node)-1]
- case *Tree:
- targetNode = node
- case nil:
- // create intermediate
- if err := p.tree.createSubTree(tableKey, key.Position); err != nil {
- p.raiseError(key, "could not create intermediate group: %s", err)
- }
- targetNode = p.tree.GetPath(tableKey).(*Tree)
- default:
- p.raiseError(key, "Unknown table type for path: %s",
- strings.Join(tableKey, "."))
- }
-
- if targetNode.inline {
- p.raiseError(key, "could not add key or sub-table to exist inline table or its sub-table : %s",
- strings.Join(tableKey, "."))
- }
-
- // assign value to the found table
- keyVal := parsedKey[len(parsedKey)-1]
- localKey := []string{keyVal}
- finalKey := append(tableKey, keyVal)
- if targetNode.GetPath(localKey) != nil {
- p.raiseError(key, "The following key was defined twice: %s",
- strings.Join(finalKey, "."))
- }
- var toInsert interface{}
-
- switch value.(type) {
- case *Tree, []*Tree:
- toInsert = value
- default:
- toInsert = &tomlValue{value: value, position: key.Position}
- }
- targetNode.values[keyVal] = toInsert
- return p.parseStart
-}
-
-var errInvalidUnderscore = errors.New("invalid use of _ in number")
-
-func numberContainsInvalidUnderscore(value string) error {
- // For large numbers, you may use underscores between digits to enhance
- // readability. Each underscore must be surrounded by at least one digit on
- // each side.
-
- hasBefore := false
- for idx, r := range value {
- if r == '_' {
- if !hasBefore || idx+1 >= len(value) {
- // can't end with an underscore
- return errInvalidUnderscore
- }
- }
- hasBefore = isDigit(r)
- }
- return nil
-}
-
-var errInvalidUnderscoreHex = errors.New("invalid use of _ in hex number")
-
-func hexNumberContainsInvalidUnderscore(value string) error {
- hasBefore := false
- for idx, r := range value {
- if r == '_' {
- if !hasBefore || idx+1 >= len(value) {
- // can't end with an underscore
- return errInvalidUnderscoreHex
- }
- }
- hasBefore = isHexDigit(r)
- }
- return nil
-}
-
-func cleanupNumberToken(value string) string {
- cleanedVal := strings.Replace(value, "_", "", -1)
- return cleanedVal
-}
-
-func (p *tomlParser) parseRvalue() interface{} {
- tok := p.getToken()
- if tok == nil || tok.typ == tokenEOF {
- p.raiseError(tok, "expecting a value")
- }
-
- switch tok.typ {
- case tokenString:
- return tok.val
- case tokenTrue:
- return true
- case tokenFalse:
- return false
- case tokenInf:
- if tok.val[0] == '-' {
- return math.Inf(-1)
- }
- return math.Inf(1)
- case tokenNan:
- return math.NaN()
- case tokenInteger:
- cleanedVal := cleanupNumberToken(tok.val)
- base := 10
- s := cleanedVal
- checkInvalidUnderscore := numberContainsInvalidUnderscore
- if len(cleanedVal) >= 3 && cleanedVal[0] == '0' {
- switch cleanedVal[1] {
- case 'x':
- checkInvalidUnderscore = hexNumberContainsInvalidUnderscore
- base = 16
- case 'o':
- base = 8
- case 'b':
- base = 2
- default:
- panic("invalid base") // the lexer should catch this first
- }
- s = cleanedVal[2:]
- }
-
- err := checkInvalidUnderscore(tok.val)
- if err != nil {
- p.raiseError(tok, "%s", err)
- }
-
- var val interface{}
- val, err = strconv.ParseInt(s, base, 64)
- if err == nil {
- return val
- }
-
- if s[0] != '-' {
- if val, err = strconv.ParseUint(s, base, 64); err == nil {
- return val
- }
- }
- p.raiseError(tok, "%s", err)
- case tokenFloat:
- err := numberContainsInvalidUnderscore(tok.val)
- if err != nil {
- p.raiseError(tok, "%s", err)
- }
- cleanedVal := cleanupNumberToken(tok.val)
- val, err := strconv.ParseFloat(cleanedVal, 64)
- if err != nil {
- p.raiseError(tok, "%s", err)
- }
- return val
- case tokenLocalTime:
- val, err := ParseLocalTime(tok.val)
- if err != nil {
- p.raiseError(tok, "%s", err)
- }
- return val
- case tokenLocalDate:
- // a local date may be followed by:
- // * nothing: this is a local date
- // * a local time: this is a local date-time
-
- next := p.peek()
- if next == nil || next.typ != tokenLocalTime {
- val, err := ParseLocalDate(tok.val)
- if err != nil {
- p.raiseError(tok, "%s", err)
- }
- return val
- }
-
- localDate := tok
- localTime := p.getToken()
-
- next = p.peek()
- if next == nil || next.typ != tokenTimeOffset {
- v := localDate.val + "T" + localTime.val
- val, err := ParseLocalDateTime(v)
- if err != nil {
- p.raiseError(tok, "%s", err)
- }
- return val
- }
-
- offset := p.getToken()
-
- layout := time.RFC3339Nano
- v := localDate.val + "T" + localTime.val + offset.val
- val, err := time.ParseInLocation(layout, v, time.UTC)
- if err != nil {
- p.raiseError(tok, "%s", err)
- }
- return val
- case tokenLeftBracket:
- return p.parseArray()
- case tokenLeftCurlyBrace:
- return p.parseInlineTable()
- case tokenEqual:
- p.raiseError(tok, "cannot have multiple equals for the same key")
- case tokenError:
- p.raiseError(tok, "%s", tok)
- default:
- panic(fmt.Errorf("unhandled token: %v", tok))
- }
-
- return nil
-}
-
-func tokenIsComma(t *token) bool {
- return t != nil && t.typ == tokenComma
-}
-
-func (p *tomlParser) parseInlineTable() *Tree {
- tree := newTree()
- var previous *token
-Loop:
- for {
- follow := p.peek()
- if follow == nil || follow.typ == tokenEOF {
- p.raiseError(follow, "unterminated inline table")
- }
- switch follow.typ {
- case tokenRightCurlyBrace:
- p.getToken()
- break Loop
- case tokenKey, tokenInteger, tokenString:
- if !tokenIsComma(previous) && previous != nil {
- p.raiseError(follow, "comma expected between fields in inline table")
- }
- key := p.getToken()
- p.assume(tokenEqual)
-
- parsedKey, err := parseKey(key.val)
- if err != nil {
- p.raiseError(key, "invalid key: %s", err)
- }
-
- value := p.parseRvalue()
- tree.SetPath(parsedKey, value)
- case tokenComma:
- if tokenIsComma(previous) {
- p.raiseError(follow, "need field between two commas in inline table")
- }
- p.getToken()
- default:
- p.raiseError(follow, "unexpected token type in inline table: %s", follow.String())
- }
- previous = follow
- }
- if tokenIsComma(previous) {
- p.raiseError(previous, "trailing comma at the end of inline table")
- }
- tree.inline = true
- return tree
-}
-
-func (p *tomlParser) parseArray() interface{} {
- var array []interface{}
- arrayType := reflect.TypeOf(newTree())
- for {
- follow := p.peek()
- if follow == nil || follow.typ == tokenEOF {
- p.raiseError(follow, "unterminated array")
- }
- if follow.typ == tokenRightBracket {
- p.getToken()
- break
- }
- val := p.parseRvalue()
- if reflect.TypeOf(val) != arrayType {
- arrayType = nil
- }
- array = append(array, val)
- follow = p.peek()
- if follow == nil || follow.typ == tokenEOF {
- p.raiseError(follow, "unterminated array")
- }
- if follow.typ != tokenRightBracket && follow.typ != tokenComma {
- p.raiseError(follow, "missing comma")
- }
- if follow.typ == tokenComma {
- p.getToken()
- }
- }
-
- // if the array is a mixed-type array or its length is 0,
- // don't convert it to a table array
- if len(array) <= 0 {
- arrayType = nil
- }
- // An array of Trees is actually an array of inline
- // tables, which is a shorthand for a table array. If the
- // array was not converted from []interface{} to []*Tree,
- // the two notations would not be equivalent.
- if arrayType == reflect.TypeOf(newTree()) {
- tomlArray := make([]*Tree, len(array))
- for i, v := range array {
- tomlArray[i] = v.(*Tree)
- }
- return tomlArray
- }
- return array
-}
-
-func parseToml(flow []token) *Tree {
- result := newTree()
- result.position = Position{1, 1}
- parser := &tomlParser{
- flowIdx: 0,
- flow: flow,
- tree: result,
- currentTable: make([]string, 0),
- seenTableKeys: make([]string, 0),
- }
- parser.run()
- return result
-}
diff --git a/vendor/github.com/pelletier/go-toml/position.go b/vendor/github.com/pelletier/go-toml/position.go
deleted file mode 100644
index c17bff87b..000000000
--- a/vendor/github.com/pelletier/go-toml/position.go
+++ /dev/null
@@ -1,29 +0,0 @@
-// Position support for go-toml
-
-package toml
-
-import (
- "fmt"
-)
-
-// Position of a document element within a TOML document.
-//
-// Line and Col are both 1-indexed positions for the element's line number and
-// column number, respectively. Values of zero or less will cause Invalid(),
-// to return true.
-type Position struct {
- Line int // line within the document
- Col int // column within the line
-}
-
-// String representation of the position.
-// Displays 1-indexed line and column numbers.
-func (p Position) String() string {
- return fmt.Sprintf("(%d, %d)", p.Line, p.Col)
-}
-
-// Invalid returns whether or not the position is valid (i.e. with negative or
-// null values)
-func (p Position) Invalid() bool {
- return p.Line <= 0 || p.Col <= 0
-}
diff --git a/vendor/github.com/pelletier/go-toml/token.go b/vendor/github.com/pelletier/go-toml/token.go
deleted file mode 100644
index b437fdd3b..000000000
--- a/vendor/github.com/pelletier/go-toml/token.go
+++ /dev/null
@@ -1,136 +0,0 @@
-package toml
-
-import "fmt"
-
-// Define tokens
-type tokenType int
-
-const (
- eof = -(iota + 1)
-)
-
-const (
- tokenError tokenType = iota
- tokenEOF
- tokenComment
- tokenKey
- tokenString
- tokenInteger
- tokenTrue
- tokenFalse
- tokenFloat
- tokenInf
- tokenNan
- tokenEqual
- tokenLeftBracket
- tokenRightBracket
- tokenLeftCurlyBrace
- tokenRightCurlyBrace
- tokenLeftParen
- tokenRightParen
- tokenDoubleLeftBracket
- tokenDoubleRightBracket
- tokenLocalDate
- tokenLocalTime
- tokenTimeOffset
- tokenKeyGroup
- tokenKeyGroupArray
- tokenComma
- tokenColon
- tokenDollar
- tokenStar
- tokenQuestion
- tokenDot
- tokenDotDot
- tokenEOL
-)
-
-var tokenTypeNames = []string{
- "Error",
- "EOF",
- "Comment",
- "Key",
- "String",
- "Integer",
- "True",
- "False",
- "Float",
- "Inf",
- "NaN",
- "=",
- "[",
- "]",
- "{",
- "}",
- "(",
- ")",
- "]]",
- "[[",
- "LocalDate",
- "LocalTime",
- "TimeOffset",
- "KeyGroup",
- "KeyGroupArray",
- ",",
- ":",
- "$",
- "*",
- "?",
- ".",
- "..",
- "EOL",
-}
-
-type token struct {
- Position
- typ tokenType
- val string
-}
-
-func (tt tokenType) String() string {
- idx := int(tt)
- if idx < len(tokenTypeNames) {
- return tokenTypeNames[idx]
- }
- return "Unknown"
-}
-
-func (t token) String() string {
- switch t.typ {
- case tokenEOF:
- return "EOF"
- case tokenError:
- return t.val
- }
-
- return fmt.Sprintf("%q", t.val)
-}
-
-func isSpace(r rune) bool {
- return r == ' ' || r == '\t'
-}
-
-func isAlphanumeric(r rune) bool {
- return 'a' <= r && r <= 'z' || 'A' <= r && r <= 'Z' || r == '_'
-}
-
-func isKeyChar(r rune) bool {
- // Keys start with the first character that isn't whitespace or [ and end
- // with the last non-whitespace character before the equals sign. Keys
- // cannot contain a # character."
- return !(r == '\r' || r == '\n' || r == eof || r == '=')
-}
-
-func isKeyStartChar(r rune) bool {
- return !(isSpace(r) || r == '\r' || r == '\n' || r == eof || r == '[')
-}
-
-func isDigit(r rune) bool {
- return '0' <= r && r <= '9'
-}
-
-func isHexDigit(r rune) bool {
- return isDigit(r) ||
- (r >= 'a' && r <= 'f') ||
- (r >= 'A' && r <= 'F')
-}
diff --git a/vendor/github.com/pelletier/go-toml/toml.go b/vendor/github.com/pelletier/go-toml/toml.go
deleted file mode 100644
index 5541b941f..000000000
--- a/vendor/github.com/pelletier/go-toml/toml.go
+++ /dev/null
@@ -1,533 +0,0 @@
-package toml
-
-import (
- "errors"
- "fmt"
- "io"
- "io/ioutil"
- "os"
- "runtime"
- "strings"
-)
-
-type tomlValue struct {
- value interface{} // string, int64, uint64, float64, bool, time.Time, [] of any of this list
- comment string
- commented bool
- multiline bool
- literal bool
- position Position
-}
-
-// Tree is the result of the parsing of a TOML file.
-type Tree struct {
- values map[string]interface{} // string -> *tomlValue, *Tree, []*Tree
- comment string
- commented bool
- inline bool
- position Position
-}
-
-func newTree() *Tree {
- return newTreeWithPosition(Position{})
-}
-
-func newTreeWithPosition(pos Position) *Tree {
- return &Tree{
- values: make(map[string]interface{}),
- position: pos,
- }
-}
-
-// TreeFromMap initializes a new Tree object using the given map.
-func TreeFromMap(m map[string]interface{}) (*Tree, error) {
- result, err := toTree(m)
- if err != nil {
- return nil, err
- }
- return result.(*Tree), nil
-}
-
-// Position returns the position of the tree.
-func (t *Tree) Position() Position {
- return t.position
-}
-
-// Has returns a boolean indicating if the given key exists.
-func (t *Tree) Has(key string) bool {
- if key == "" {
- return false
- }
- return t.HasPath(strings.Split(key, "."))
-}
-
-// HasPath returns true if the given path of keys exists, false otherwise.
-func (t *Tree) HasPath(keys []string) bool {
- return t.GetPath(keys) != nil
-}
-
-// Keys returns the keys of the toplevel tree (does not recurse).
-func (t *Tree) Keys() []string {
- keys := make([]string, len(t.values))
- i := 0
- for k := range t.values {
- keys[i] = k
- i++
- }
- return keys
-}
-
-// Get the value at key in the Tree.
-// Key is a dot-separated path (e.g. a.b.c) without single/double quoted strings.
-// If you need to retrieve non-bare keys, use GetPath.
-// Returns nil if the path does not exist in the tree.
-// If keys is of length zero, the current tree is returned.
-func (t *Tree) Get(key string) interface{} {
- if key == "" {
- return t
- }
- return t.GetPath(strings.Split(key, "."))
-}
-
-// GetPath returns the element in the tree indicated by 'keys'.
-// If keys is of length zero, the current tree is returned.
-func (t *Tree) GetPath(keys []string) interface{} {
- if len(keys) == 0 {
- return t
- }
- subtree := t
- for _, intermediateKey := range keys[:len(keys)-1] {
- value, exists := subtree.values[intermediateKey]
- if !exists {
- return nil
- }
- switch node := value.(type) {
- case *Tree:
- subtree = node
- case []*Tree:
- // go to most recent element
- if len(node) == 0 {
- return nil
- }
- subtree = node[len(node)-1]
- default:
- return nil // cannot navigate through other node types
- }
- }
- // branch based on final node type
- switch node := subtree.values[keys[len(keys)-1]].(type) {
- case *tomlValue:
- return node.value
- default:
- return node
- }
-}
-
-// GetArray returns the value at key in the Tree.
-// It returns []string, []int64, etc type if key has homogeneous lists
-// Key is a dot-separated path (e.g. a.b.c) without single/double quoted strings.
-// Returns nil if the path does not exist in the tree.
-// If keys is of length zero, the current tree is returned.
-func (t *Tree) GetArray(key string) interface{} {
- if key == "" {
- return t
- }
- return t.GetArrayPath(strings.Split(key, "."))
-}
-
-// GetArrayPath returns the element in the tree indicated by 'keys'.
-// If keys is of length zero, the current tree is returned.
-func (t *Tree) GetArrayPath(keys []string) interface{} {
- if len(keys) == 0 {
- return t
- }
- subtree := t
- for _, intermediateKey := range keys[:len(keys)-1] {
- value, exists := subtree.values[intermediateKey]
- if !exists {
- return nil
- }
- switch node := value.(type) {
- case *Tree:
- subtree = node
- case []*Tree:
- // go to most recent element
- if len(node) == 0 {
- return nil
- }
- subtree = node[len(node)-1]
- default:
- return nil // cannot navigate through other node types
- }
- }
- // branch based on final node type
- switch node := subtree.values[keys[len(keys)-1]].(type) {
- case *tomlValue:
- switch n := node.value.(type) {
- case []interface{}:
- return getArray(n)
- default:
- return node.value
- }
- default:
- return node
- }
-}
-
-// if homogeneous array, then return slice type object over []interface{}
-func getArray(n []interface{}) interface{} {
- var s []string
- var i64 []int64
- var f64 []float64
- var bl []bool
- for _, value := range n {
- switch v := value.(type) {
- case string:
- s = append(s, v)
- case int64:
- i64 = append(i64, v)
- case float64:
- f64 = append(f64, v)
- case bool:
- bl = append(bl, v)
- default:
- return n
- }
- }
- if len(s) == len(n) {
- return s
- } else if len(i64) == len(n) {
- return i64
- } else if len(f64) == len(n) {
- return f64
- } else if len(bl) == len(n) {
- return bl
- }
- return n
-}
-
-// GetPosition returns the position of the given key.
-func (t *Tree) GetPosition(key string) Position {
- if key == "" {
- return t.position
- }
- return t.GetPositionPath(strings.Split(key, "."))
-}
-
-// SetPositionPath sets the position of element in the tree indicated by 'keys'.
-// If keys is of length zero, the current tree position is set.
-func (t *Tree) SetPositionPath(keys []string, pos Position) {
- if len(keys) == 0 {
- t.position = pos
- return
- }
- subtree := t
- for _, intermediateKey := range keys[:len(keys)-1] {
- value, exists := subtree.values[intermediateKey]
- if !exists {
- return
- }
- switch node := value.(type) {
- case *Tree:
- subtree = node
- case []*Tree:
- // go to most recent element
- if len(node) == 0 {
- return
- }
- subtree = node[len(node)-1]
- default:
- return
- }
- }
- // branch based on final node type
- switch node := subtree.values[keys[len(keys)-1]].(type) {
- case *tomlValue:
- node.position = pos
- return
- case *Tree:
- node.position = pos
- return
- case []*Tree:
- // go to most recent element
- if len(node) == 0 {
- return
- }
- node[len(node)-1].position = pos
- return
- }
-}
-
-// GetPositionPath returns the element in the tree indicated by 'keys'.
-// If keys is of length zero, the current tree is returned.
-func (t *Tree) GetPositionPath(keys []string) Position {
- if len(keys) == 0 {
- return t.position
- }
- subtree := t
- for _, intermediateKey := range keys[:len(keys)-1] {
- value, exists := subtree.values[intermediateKey]
- if !exists {
- return Position{0, 0}
- }
- switch node := value.(type) {
- case *Tree:
- subtree = node
- case []*Tree:
- // go to most recent element
- if len(node) == 0 {
- return Position{0, 0}
- }
- subtree = node[len(node)-1]
- default:
- return Position{0, 0}
- }
- }
- // branch based on final node type
- switch node := subtree.values[keys[len(keys)-1]].(type) {
- case *tomlValue:
- return node.position
- case *Tree:
- return node.position
- case []*Tree:
- // go to most recent element
- if len(node) == 0 {
- return Position{0, 0}
- }
- return node[len(node)-1].position
- default:
- return Position{0, 0}
- }
-}
-
-// GetDefault works like Get but with a default value
-func (t *Tree) GetDefault(key string, def interface{}) interface{} {
- val := t.Get(key)
- if val == nil {
- return def
- }
- return val
-}
-
-// SetOptions arguments are supplied to the SetWithOptions and SetPathWithOptions functions to modify marshalling behaviour.
-// The default values within the struct are valid default options.
-type SetOptions struct {
- Comment string
- Commented bool
- Multiline bool
- Literal bool
-}
-
-// SetWithOptions is the same as Set, but allows you to provide formatting
-// instructions to the key, that will be used by Marshal().
-func (t *Tree) SetWithOptions(key string, opts SetOptions, value interface{}) {
- t.SetPathWithOptions(strings.Split(key, "."), opts, value)
-}
-
-// SetPathWithOptions is the same as SetPath, but allows you to provide
-// formatting instructions to the key, that will be reused by Marshal().
-func (t *Tree) SetPathWithOptions(keys []string, opts SetOptions, value interface{}) {
- subtree := t
- for i, intermediateKey := range keys[:len(keys)-1] {
- nextTree, exists := subtree.values[intermediateKey]
- if !exists {
- nextTree = newTreeWithPosition(Position{Line: t.position.Line + i, Col: t.position.Col})
- subtree.values[intermediateKey] = nextTree // add new element here
- }
- switch node := nextTree.(type) {
- case *Tree:
- subtree = node
- case []*Tree:
- // go to most recent element
- if len(node) == 0 {
- // create element if it does not exist
- node = append(node, newTreeWithPosition(Position{Line: t.position.Line + i, Col: t.position.Col}))
- subtree.values[intermediateKey] = node
- }
- subtree = node[len(node)-1]
- }
- }
-
- var toInsert interface{}
-
- switch v := value.(type) {
- case *Tree:
- v.comment = opts.Comment
- v.commented = opts.Commented
- toInsert = value
- case []*Tree:
- for i := range v {
- v[i].commented = opts.Commented
- }
- toInsert = value
- case *tomlValue:
- v.comment = opts.Comment
- v.commented = opts.Commented
- v.multiline = opts.Multiline
- v.literal = opts.Literal
- toInsert = v
- default:
- toInsert = &tomlValue{value: value,
- comment: opts.Comment,
- commented: opts.Commented,
- multiline: opts.Multiline,
- literal: opts.Literal,
- position: Position{Line: subtree.position.Line + len(subtree.values) + 1, Col: subtree.position.Col}}
- }
-
- subtree.values[keys[len(keys)-1]] = toInsert
-}
-
-// Set an element in the tree.
-// Key is a dot-separated path (e.g. a.b.c).
-// Creates all necessary intermediate trees, if needed.
-func (t *Tree) Set(key string, value interface{}) {
- t.SetWithComment(key, "", false, value)
-}
-
-// SetWithComment is the same as Set, but allows you to provide comment
-// information to the key, that will be reused by Marshal().
-func (t *Tree) SetWithComment(key string, comment string, commented bool, value interface{}) {
- t.SetPathWithComment(strings.Split(key, "."), comment, commented, value)
-}
-
-// SetPath sets an element in the tree.
-// Keys is an array of path elements (e.g. {"a","b","c"}).
-// Creates all necessary intermediate trees, if needed.
-func (t *Tree) SetPath(keys []string, value interface{}) {
- t.SetPathWithComment(keys, "", false, value)
-}
-
-// SetPathWithComment is the same as SetPath, but allows you to provide comment
-// information to the key, that will be reused by Marshal().
-func (t *Tree) SetPathWithComment(keys []string, comment string, commented bool, value interface{}) {
- t.SetPathWithOptions(keys, SetOptions{Comment: comment, Commented: commented}, value)
-}
-
-// Delete removes a key from the tree.
-// Key is a dot-separated path (e.g. a.b.c).
-func (t *Tree) Delete(key string) error {
- keys, err := parseKey(key)
- if err != nil {
- return err
- }
- return t.DeletePath(keys)
-}
-
-// DeletePath removes a key from the tree.
-// Keys is an array of path elements (e.g. {"a","b","c"}).
-func (t *Tree) DeletePath(keys []string) error {
- keyLen := len(keys)
- if keyLen == 1 {
- delete(t.values, keys[0])
- return nil
- }
- tree := t.GetPath(keys[:keyLen-1])
- item := keys[keyLen-1]
- switch node := tree.(type) {
- case *Tree:
- delete(node.values, item)
- return nil
- }
- return errors.New("no such key to delete")
-}
-
-// createSubTree takes a tree and a key and create the necessary intermediate
-// subtrees to create a subtree at that point. In-place.
-//
-// e.g. passing a.b.c will create (assuming tree is empty) tree[a], tree[a][b]
-// and tree[a][b][c]
-//
-// Returns nil on success, error object on failure
-func (t *Tree) createSubTree(keys []string, pos Position) error {
- subtree := t
- for i, intermediateKey := range keys {
- nextTree, exists := subtree.values[intermediateKey]
- if !exists {
- tree := newTreeWithPosition(Position{Line: t.position.Line + i, Col: t.position.Col})
- tree.position = pos
- tree.inline = subtree.inline
- subtree.values[intermediateKey] = tree
- nextTree = tree
- }
-
- switch node := nextTree.(type) {
- case []*Tree:
- subtree = node[len(node)-1]
- case *Tree:
- subtree = node
- default:
- return fmt.Errorf("unknown type for path %s (%s): %T (%#v)",
- strings.Join(keys, "."), intermediateKey, nextTree, nextTree)
- }
- }
- return nil
-}
-
-// LoadBytes creates a Tree from a []byte.
-func LoadBytes(b []byte) (tree *Tree, err error) {
- defer func() {
- if r := recover(); r != nil {
- if _, ok := r.(runtime.Error); ok {
- panic(r)
- }
- err = fmt.Errorf("%s", r)
- }
- }()
-
- if len(b) >= 4 && (hasUTF32BigEndianBOM4(b) || hasUTF32LittleEndianBOM4(b)) {
- b = b[4:]
- } else if len(b) >= 3 && hasUTF8BOM3(b) {
- b = b[3:]
- } else if len(b) >= 2 && (hasUTF16BigEndianBOM2(b) || hasUTF16LittleEndianBOM2(b)) {
- b = b[2:]
- }
-
- tree = parseToml(lexToml(b))
- return
-}
-
-func hasUTF16BigEndianBOM2(b []byte) bool {
- return b[0] == 0xFE && b[1] == 0xFF
-}
-
-func hasUTF16LittleEndianBOM2(b []byte) bool {
- return b[0] == 0xFF && b[1] == 0xFE
-}
-
-func hasUTF8BOM3(b []byte) bool {
- return b[0] == 0xEF && b[1] == 0xBB && b[2] == 0xBF
-}
-
-func hasUTF32BigEndianBOM4(b []byte) bool {
- return b[0] == 0x00 && b[1] == 0x00 && b[2] == 0xFE && b[3] == 0xFF
-}
-
-func hasUTF32LittleEndianBOM4(b []byte) bool {
- return b[0] == 0xFF && b[1] == 0xFE && b[2] == 0x00 && b[3] == 0x00
-}
-
-// LoadReader creates a Tree from any io.Reader.
-func LoadReader(reader io.Reader) (tree *Tree, err error) {
- inputBytes, err := ioutil.ReadAll(reader)
- if err != nil {
- return
- }
- tree, err = LoadBytes(inputBytes)
- return
-}
-
-// Load creates a Tree from a string.
-func Load(content string) (tree *Tree, err error) {
- return LoadBytes([]byte(content))
-}
-
-// LoadFile creates a Tree from a file.
-func LoadFile(path string) (tree *Tree, err error) {
- file, err := os.Open(path)
- if err != nil {
- return nil, err
- }
- defer file.Close()
- return LoadReader(file)
-}
diff --git a/vendor/github.com/pelletier/go-toml/tomlpub.go b/vendor/github.com/pelletier/go-toml/tomlpub.go
deleted file mode 100644
index 4136b4625..000000000
--- a/vendor/github.com/pelletier/go-toml/tomlpub.go
+++ /dev/null
@@ -1,71 +0,0 @@
-package toml
-
-// PubTOMLValue wrapping tomlValue in order to access all properties from outside.
-type PubTOMLValue = tomlValue
-
-func (ptv *PubTOMLValue) Value() interface{} {
- return ptv.value
-}
-func (ptv *PubTOMLValue) Comment() string {
- return ptv.comment
-}
-func (ptv *PubTOMLValue) Commented() bool {
- return ptv.commented
-}
-func (ptv *PubTOMLValue) Multiline() bool {
- return ptv.multiline
-}
-func (ptv *PubTOMLValue) Position() Position {
- return ptv.position
-}
-
-func (ptv *PubTOMLValue) SetValue(v interface{}) {
- ptv.value = v
-}
-func (ptv *PubTOMLValue) SetComment(s string) {
- ptv.comment = s
-}
-func (ptv *PubTOMLValue) SetCommented(c bool) {
- ptv.commented = c
-}
-func (ptv *PubTOMLValue) SetMultiline(m bool) {
- ptv.multiline = m
-}
-func (ptv *PubTOMLValue) SetPosition(p Position) {
- ptv.position = p
-}
-
-// PubTree wrapping Tree in order to access all properties from outside.
-type PubTree = Tree
-
-func (pt *PubTree) Values() map[string]interface{} {
- return pt.values
-}
-
-func (pt *PubTree) Comment() string {
- return pt.comment
-}
-
-func (pt *PubTree) Commented() bool {
- return pt.commented
-}
-
-func (pt *PubTree) Inline() bool {
- return pt.inline
-}
-
-func (pt *PubTree) SetValues(v map[string]interface{}) {
- pt.values = v
-}
-
-func (pt *PubTree) SetComment(c string) {
- pt.comment = c
-}
-
-func (pt *PubTree) SetCommented(c bool) {
- pt.commented = c
-}
-
-func (pt *PubTree) SetInline(i bool) {
- pt.inline = i
-}
diff --git a/vendor/github.com/pelletier/go-toml/tomltree_create.go b/vendor/github.com/pelletier/go-toml/tomltree_create.go
deleted file mode 100644
index 80353500a..000000000
--- a/vendor/github.com/pelletier/go-toml/tomltree_create.go
+++ /dev/null
@@ -1,155 +0,0 @@
-package toml
-
-import (
- "fmt"
- "reflect"
- "time"
-)
-
-var kindToType = [reflect.String + 1]reflect.Type{
- reflect.Bool: reflect.TypeOf(true),
- reflect.String: reflect.TypeOf(""),
- reflect.Float32: reflect.TypeOf(float64(1)),
- reflect.Float64: reflect.TypeOf(float64(1)),
- reflect.Int: reflect.TypeOf(int64(1)),
- reflect.Int8: reflect.TypeOf(int64(1)),
- reflect.Int16: reflect.TypeOf(int64(1)),
- reflect.Int32: reflect.TypeOf(int64(1)),
- reflect.Int64: reflect.TypeOf(int64(1)),
- reflect.Uint: reflect.TypeOf(uint64(1)),
- reflect.Uint8: reflect.TypeOf(uint64(1)),
- reflect.Uint16: reflect.TypeOf(uint64(1)),
- reflect.Uint32: reflect.TypeOf(uint64(1)),
- reflect.Uint64: reflect.TypeOf(uint64(1)),
-}
-
-// typeFor returns a reflect.Type for a reflect.Kind, or nil if none is found.
-// supported values:
-// string, bool, int64, uint64, float64, time.Time, int, int8, int16, int32, uint, uint8, uint16, uint32, float32
-func typeFor(k reflect.Kind) reflect.Type {
- if k > 0 && int(k) < len(kindToType) {
- return kindToType[k]
- }
- return nil
-}
-
-func simpleValueCoercion(object interface{}) (interface{}, error) {
- switch original := object.(type) {
- case string, bool, int64, uint64, float64, time.Time:
- return original, nil
- case int:
- return int64(original), nil
- case int8:
- return int64(original), nil
- case int16:
- return int64(original), nil
- case int32:
- return int64(original), nil
- case uint:
- return uint64(original), nil
- case uint8:
- return uint64(original), nil
- case uint16:
- return uint64(original), nil
- case uint32:
- return uint64(original), nil
- case float32:
- return float64(original), nil
- case fmt.Stringer:
- return original.String(), nil
- case []interface{}:
- value := reflect.ValueOf(original)
- length := value.Len()
- arrayValue := reflect.MakeSlice(value.Type(), 0, length)
- for i := 0; i < length; i++ {
- val := value.Index(i).Interface()
- simpleValue, err := simpleValueCoercion(val)
- if err != nil {
- return nil, err
- }
- arrayValue = reflect.Append(arrayValue, reflect.ValueOf(simpleValue))
- }
- return arrayValue.Interface(), nil
- default:
- return nil, fmt.Errorf("cannot convert type %T to Tree", object)
- }
-}
-
-func sliceToTree(object interface{}) (interface{}, error) {
- // arrays are a bit tricky, since they can represent either a
- // collection of simple values, which is represented by one
- // *tomlValue, or an array of tables, which is represented by an
- // array of *Tree.
-
- // holding the assumption that this function is called from toTree only when value.Kind() is Array or Slice
- value := reflect.ValueOf(object)
- insideType := value.Type().Elem()
- length := value.Len()
- if length > 0 {
- insideType = reflect.ValueOf(value.Index(0).Interface()).Type()
- }
- if insideType.Kind() == reflect.Map {
- // this is considered as an array of tables
- tablesArray := make([]*Tree, 0, length)
- for i := 0; i < length; i++ {
- table := value.Index(i)
- tree, err := toTree(table.Interface())
- if err != nil {
- return nil, err
- }
- tablesArray = append(tablesArray, tree.(*Tree))
- }
- return tablesArray, nil
- }
-
- sliceType := typeFor(insideType.Kind())
- if sliceType == nil {
- sliceType = insideType
- }
-
- arrayValue := reflect.MakeSlice(reflect.SliceOf(sliceType), 0, length)
-
- for i := 0; i < length; i++ {
- val := value.Index(i).Interface()
- simpleValue, err := simpleValueCoercion(val)
- if err != nil {
- return nil, err
- }
- arrayValue = reflect.Append(arrayValue, reflect.ValueOf(simpleValue))
- }
- return &tomlValue{value: arrayValue.Interface(), position: Position{}}, nil
-}
-
-func toTree(object interface{}) (interface{}, error) {
- value := reflect.ValueOf(object)
-
- if value.Kind() == reflect.Map {
- values := map[string]interface{}{}
- keys := value.MapKeys()
- for _, key := range keys {
- if key.Kind() != reflect.String {
- if _, ok := key.Interface().(string); !ok {
- return nil, fmt.Errorf("map key needs to be a string, not %T (%v)", key.Interface(), key.Kind())
- }
- }
-
- v := value.MapIndex(key)
- newValue, err := toTree(v.Interface())
- if err != nil {
- return nil, err
- }
- values[key.String()] = newValue
- }
- return &Tree{values: values, position: Position{}}, nil
- }
-
- if value.Kind() == reflect.Array || value.Kind() == reflect.Slice {
- return sliceToTree(object)
- }
-
- simpleValue, err := simpleValueCoercion(object)
- if err != nil {
- return nil, err
- }
- return &tomlValue{value: simpleValue, position: Position{}}, nil
-}
diff --git a/vendor/github.com/pelletier/go-toml/tomltree_write.go b/vendor/github.com/pelletier/go-toml/tomltree_write.go
deleted file mode 100644
index c9afbdab7..000000000
--- a/vendor/github.com/pelletier/go-toml/tomltree_write.go
+++ /dev/null
@@ -1,552 +0,0 @@
-package toml
-
-import (
- "bytes"
- "fmt"
- "io"
- "math"
- "math/big"
- "reflect"
- "sort"
- "strconv"
- "strings"
- "time"
-)
-
-type valueComplexity int
-
-const (
- valueSimple valueComplexity = iota + 1
- valueComplex
-)
-
-type sortNode struct {
- key string
- complexity valueComplexity
-}
-
-// Encodes a string to a TOML-compliant multi-line string value
-// This function is a clone of the existing encodeTomlString function, except that whitespace characters
-// are preserved. Quotation marks and backslashes are also not escaped.
-func encodeMultilineTomlString(value string, commented string) string {
- var b bytes.Buffer
- adjacentQuoteCount := 0
-
- b.WriteString(commented)
- for i, rr := range value {
- if rr != '"' {
- adjacentQuoteCount = 0
- } else {
- adjacentQuoteCount++
- }
- switch rr {
- case '\b':
- b.WriteString(`\b`)
- case '\t':
- b.WriteString("\t")
- case '\n':
- b.WriteString("\n" + commented)
- case '\f':
- b.WriteString(`\f`)
- case '\r':
- b.WriteString("\r")
- case '"':
- if adjacentQuoteCount >= 3 || i == len(value)-1 {
- adjacentQuoteCount = 0
- b.WriteString(`\"`)
- } else {
- b.WriteString(`"`)
- }
- case '\\':
- b.WriteString(`\`)
- default:
- intRr := uint16(rr)
- if intRr < 0x001F {
- b.WriteString(fmt.Sprintf("\\u%0.4X", intRr))
- } else {
- b.WriteRune(rr)
- }
- }
- }
- return b.String()
-}
-
-// Encodes a string to a TOML-compliant string value
-func encodeTomlString(value string) string {
- var b bytes.Buffer
-
- for _, rr := range value {
- switch rr {
- case '\b':
- b.WriteString(`\b`)
- case '\t':
- b.WriteString(`\t`)
- case '\n':
- b.WriteString(`\n`)
- case '\f':
- b.WriteString(`\f`)
- case '\r':
- b.WriteString(`\r`)
- case '"':
- b.WriteString(`\"`)
- case '\\':
- b.WriteString(`\\`)
- default:
- intRr := uint16(rr)
- if intRr < 0x001F {
- b.WriteString(fmt.Sprintf("\\u%0.4X", intRr))
- } else {
- b.WriteRune(rr)
- }
- }
- }
- return b.String()
-}
-
-func tomlTreeStringRepresentation(t *Tree, ord MarshalOrder) (string, error) {
- var orderedVals []sortNode
- switch ord {
- case OrderPreserve:
- orderedVals = sortByLines(t)
- default:
- orderedVals = sortAlphabetical(t)
- }
-
- var values []string
- for _, node := range orderedVals {
- k := node.key
- v := t.values[k]
-
- repr, err := tomlValueStringRepresentation(v, "", "", ord, false)
- if err != nil {
- return "", err
- }
- values = append(values, quoteKeyIfNeeded(k)+" = "+repr)
- }
- return "{ " + strings.Join(values, ", ") + " }", nil
-}
-
-func tomlValueStringRepresentation(v interface{}, commented string, indent string, ord MarshalOrder, arraysOneElementPerLine bool) (string, error) {
- // this interface check is added to dereference the change made in the writeTo function.
- // That change was made to allow this function to see formatting options.
- tv, ok := v.(*tomlValue)
- if ok {
- v = tv.value
- } else {
- tv = &tomlValue{}
- }
-
- switch value := v.(type) {
- case uint64:
- return strconv.FormatUint(value, 10), nil
- case int64:
- return strconv.FormatInt(value, 10), nil
- case float64:
- // Default bit length is full 64
- bits := 64
- // Float panics if nan is used
- if !math.IsNaN(value) {
- // if 32 bit accuracy is enough to exactly show, use 32
- _, acc := big.NewFloat(value).Float32()
- if acc == big.Exact {
- bits = 32
- }
- }
- if math.Trunc(value) == value {
- return strings.ToLower(strconv.FormatFloat(value, 'f', 1, bits)), nil
- }
- return strings.ToLower(strconv.FormatFloat(value, 'f', -1, bits)), nil
- case string:
- if tv.multiline {
- if tv.literal {
- b := strings.Builder{}
- b.WriteString("'''\n")
- b.Write([]byte(value))
- b.WriteString("\n'''")
- return b.String(), nil
- } else {
- return "\"\"\"\n" + encodeMultilineTomlString(value, commented) + "\"\"\"", nil
- }
- }
- return "\"" + encodeTomlString(value) + "\"", nil
- case []byte:
- b, _ := v.([]byte)
- return string(b), nil
- case bool:
- if value {
- return "true", nil
- }
- return "false", nil
- case time.Time:
- return value.Format(time.RFC3339), nil
- case LocalDate:
- return value.String(), nil
- case LocalDateTime:
- return value.String(), nil
- case LocalTime:
- return value.String(), nil
- case *Tree:
- return tomlTreeStringRepresentation(value, ord)
- case nil:
- return "", nil
- }
-
- rv := reflect.ValueOf(v)
-
- if rv.Kind() == reflect.Slice {
- var values []string
- for i := 0; i < rv.Len(); i++ {
- item := rv.Index(i).Interface()
- itemRepr, err := tomlValueStringRepresentation(item, commented, indent, ord, arraysOneElementPerLine)
- if err != nil {
- return "", err
- }
- values = append(values, itemRepr)
- }
- if arraysOneElementPerLine && len(values) > 1 {
- stringBuffer := bytes.Buffer{}
- valueIndent := indent + ` ` // TODO: move that to a shared encoder state
-
- stringBuffer.WriteString("[\n")
-
- for _, value := range values {
- stringBuffer.WriteString(valueIndent)
- stringBuffer.WriteString(commented + value)
- stringBuffer.WriteString(`,`)
- stringBuffer.WriteString("\n")
- }
-
- stringBuffer.WriteString(indent + commented + "]")
-
- return stringBuffer.String(), nil
- }
- return "[" + strings.Join(values, ", ") + "]", nil
- }
- return "", fmt.Errorf("unsupported value type %T: %v", v, v)
-}
-
-func getTreeArrayLine(trees []*Tree) (line int) {
- // Prevent returning 0 for empty trees
- line = int(^uint(0) >> 1)
- // get lowest line number >= 0
- for _, tv := range trees {
- if tv.position.Line < line || line == 0 {
- line = tv.position.Line
- }
- }
- return
-}
-
-func sortByLines(t *Tree) (vals []sortNode) {
- var (
- line int
- lines []int
- tv *Tree
- tom *tomlValue
- node sortNode
- )
- vals = make([]sortNode, 0)
- m := make(map[int]sortNode)
-
- for k := range t.values {
- v := t.values[k]
- switch v.(type) {
- case *Tree:
- tv = v.(*Tree)
- line = tv.position.Line
- node = sortNode{key: k, complexity: valueComplex}
- case []*Tree:
- line = getTreeArrayLine(v.([]*Tree))
- node = sortNode{key: k, complexity: valueComplex}
- default:
- tom = v.(*tomlValue)
- line = tom.position.Line
- node = sortNode{key: k, complexity: valueSimple}
- }
- lines = append(lines, line)
- vals = append(vals, node)
- m[line] = node
- }
- sort.Ints(lines)
-
- for i, line := range lines {
- vals[i] = m[line]
- }
-
- return vals
-}
-
-func sortAlphabetical(t *Tree) (vals []sortNode) {
- var (
- node sortNode
- simpVals []string
- compVals []string
- )
- vals = make([]sortNode, 0)
- m := make(map[string]sortNode)
-
- for k := range t.values {
- v := t.values[k]
- switch v.(type) {
- case *Tree, []*Tree:
- node = sortNode{key: k, complexity: valueComplex}
- compVals = append(compVals, node.key)
- default:
- node = sortNode{key: k, complexity: valueSimple}
- simpVals = append(simpVals, node.key)
- }
- vals = append(vals, node)
- m[node.key] = node
- }
-
- // Simples first to match previous implementation
- sort.Strings(simpVals)
- i := 0
- for _, key := range simpVals {
- vals[i] = m[key]
- i++
- }
-
- sort.Strings(compVals)
- for _, key := range compVals {
- vals[i] = m[key]
- i++
- }
-
- return vals
-}
-
-func (t *Tree) writeTo(w io.Writer, indent, keyspace string, bytesCount int64, arraysOneElementPerLine bool) (int64, error) {
- return t.writeToOrdered(w, indent, keyspace, bytesCount, arraysOneElementPerLine, OrderAlphabetical, " ", false, false)
-}
-
-func (t *Tree) writeToOrdered(w io.Writer, indent, keyspace string, bytesCount int64, arraysOneElementPerLine bool, ord MarshalOrder, indentString string, compactComments, parentCommented bool) (int64, error) {
- var orderedVals []sortNode
-
- switch ord {
- case OrderPreserve:
- orderedVals = sortByLines(t)
- default:
- orderedVals = sortAlphabetical(t)
- }
-
- for _, node := range orderedVals {
- switch node.complexity {
- case valueComplex:
- k := node.key
- v := t.values[k]
-
- combinedKey := quoteKeyIfNeeded(k)
- if keyspace != "" {
- combinedKey = keyspace + "." + combinedKey
- }
-
- switch node := v.(type) {
- // node has to be of those two types given how keys are sorted above
- case *Tree:
- tv, ok := t.values[k].(*Tree)
- if !ok {
- return bytesCount, fmt.Errorf("invalid value type at %s: %T", k, t.values[k])
- }
- if tv.comment != "" {
- comment := strings.Replace(tv.comment, "\n", "\n"+indent+"#", -1)
- start := "# "
- if strings.HasPrefix(comment, "#") {
- start = ""
- }
- writtenBytesCountComment, errc := writeStrings(w, "\n", indent, start, comment)
- bytesCount += int64(writtenBytesCountComment)
- if errc != nil {
- return bytesCount, errc
- }
- }
-
- var commented string
- if parentCommented || t.commented || tv.commented {
- commented = "# "
- }
- writtenBytesCount, err := writeStrings(w, "\n", indent, commented, "[", combinedKey, "]\n")
- bytesCount += int64(writtenBytesCount)
- if err != nil {
- return bytesCount, err
- }
- bytesCount, err = node.writeToOrdered(w, indent+indentString, combinedKey, bytesCount, arraysOneElementPerLine, ord, indentString, compactComments, parentCommented || t.commented || tv.commented)
- if err != nil {
- return bytesCount, err
- }
- case []*Tree:
- for _, subTree := range node {
- var commented string
- if parentCommented || t.commented || subTree.commented {
- commented = "# "
- }
- writtenBytesCount, err := writeStrings(w, "\n", indent, commented, "[[", combinedKey, "]]\n")
- bytesCount += int64(writtenBytesCount)
- if err != nil {
- return bytesCount, err
- }
-
- bytesCount, err = subTree.writeToOrdered(w, indent+indentString, combinedKey, bytesCount, arraysOneElementPerLine, ord, indentString, compactComments, parentCommented || t.commented || subTree.commented)
- if err != nil {
- return bytesCount, err
- }
- }
- }
- default: // Simple
- k := node.key
- v, ok := t.values[k].(*tomlValue)
- if !ok {
- return bytesCount, fmt.Errorf("invalid value type at %s: %T", k, t.values[k])
- }
-
- var commented string
- if parentCommented || t.commented || v.commented {
- commented = "# "
- }
- repr, err := tomlValueStringRepresentation(v, commented, indent, ord, arraysOneElementPerLine)
- if err != nil {
- return bytesCount, err
- }
-
- if v.comment != "" {
- comment := strings.Replace(v.comment, "\n", "\n"+indent+"#", -1)
- start := "# "
- if strings.HasPrefix(comment, "#") {
- start = ""
- }
- if !compactComments {
- writtenBytesCountComment, errc := writeStrings(w, "\n")
- bytesCount += int64(writtenBytesCountComment)
- if errc != nil {
- return bytesCount, errc
- }
- }
- writtenBytesCountComment, errc := writeStrings(w, indent, start, comment, "\n")
- bytesCount += int64(writtenBytesCountComment)
- if errc != nil {
- return bytesCount, errc
- }
- }
-
- quotedKey := quoteKeyIfNeeded(k)
- writtenBytesCount, err := writeStrings(w, indent, commented, quotedKey, " = ", repr, "\n")
- bytesCount += int64(writtenBytesCount)
- if err != nil {
- return bytesCount, err
- }
- }
- }
-
- return bytesCount, nil
-}
-
-// quote a key if it does not fit the bare key format (A-Za-z0-9_-)
-// quoted keys use the same rules as strings
-func quoteKeyIfNeeded(k string) string {
- // when encoding a map with the 'quoteMapKeys' option enabled, the tree will contain
- // keys that have already been quoted.
- // not an ideal situation, but good enough of a stop gap.
- if len(k) >= 2 && k[0] == '"' && k[len(k)-1] == '"' {
- return k
- }
- isBare := true
- for _, r := range k {
- if !isValidBareChar(r) {
- isBare = false
- break
- }
- }
- if isBare {
- return k
- }
- return quoteKey(k)
-}
-
-func quoteKey(k string) string {
- return "\"" + encodeTomlString(k) + "\""
-}
-
-func writeStrings(w io.Writer, s ...string) (int, error) {
- var n int
- for i := range s {
- b, err := io.WriteString(w, s[i])
- n += b
- if err != nil {
- return n, err
- }
- }
- return n, nil
-}
-
-// WriteTo encode the Tree as Toml and writes it to the writer w.
-// Returns the number of bytes written in case of success, or an error if anything happened.
-func (t *Tree) WriteTo(w io.Writer) (int64, error) {
- return t.writeTo(w, "", "", 0, false)
-}
-
-// ToTomlString generates a human-readable representation of the current tree.
-// Output spans multiple lines, and is suitable for ingest by a TOML parser.
-// If the conversion cannot be performed, ToString returns a non-nil error.
-func (t *Tree) ToTomlString() (string, error) {
- b, err := t.Marshal()
- if err != nil {
- return "", err
- }
- return string(b), nil
-}
-
-// String generates a human-readable representation of the current tree.
-// Alias of ToString. Present to implement the fmt.Stringer interface.
-func (t *Tree) String() string {
- result, _ := t.ToTomlString()
- return result
-}
-
-// ToMap recursively generates a representation of the tree using Go built-in structures.
-// The following types are used:
-//
-// * bool
-// * float64
-// * int64
-// * string
-// * uint64
-// * time.Time
-// * map[string]interface{} (where interface{} is any of this list)
-// * []interface{} (where interface{} is any of this list)
-func (t *Tree) ToMap() map[string]interface{} {
- result := map[string]interface{}{}
-
- for k, v := range t.values {
- switch node := v.(type) {
- case []*Tree:
- var array []interface{}
- for _, item := range node {
- array = append(array, item.ToMap())
- }
- result[k] = array
- case *Tree:
- result[k] = node.ToMap()
- case *tomlValue:
- result[k] = tomlValueToGo(node.value)
- }
- }
- return result
-}
-
-func tomlValueToGo(v interface{}) interface{} {
- if tree, ok := v.(*Tree); ok {
- return tree.ToMap()
- }
-
- rv := reflect.ValueOf(v)
-
- if rv.Kind() != reflect.Slice {
- return v
- }
- values := make([]interface{}, rv.Len())
- for i := 0; i < rv.Len(); i++ {
- item := rv.Index(i).Interface()
- values[i] = tomlValueToGo(item)
- }
- return values
-}
diff --git a/vendor/github.com/pelletier/go-toml/tomltree_writepub.go b/vendor/github.com/pelletier/go-toml/tomltree_writepub.go
deleted file mode 100644
index fa326308c..000000000
--- a/vendor/github.com/pelletier/go-toml/tomltree_writepub.go
+++ /dev/null
@@ -1,6 +0,0 @@
-package toml
-
-// ValueStringRepresentation transforms an interface{} value into its toml string representation.
-func ValueStringRepresentation(v interface{}, commented string, indent string, ord MarshalOrder, arraysOneElementPerLine bool) (string, error) {
- return tomlValueStringRepresentation(v, commented, indent, ord, arraysOneElementPerLine)
-}
diff --git a/vendor/github.com/spf13/afero/memmap.go b/vendor/github.com/spf13/afero/memmap.go
index ea0798d87..d06975e71 100644
--- a/vendor/github.com/spf13/afero/memmap.go
+++ b/vendor/github.com/spf13/afero/memmap.go
@@ -142,6 +142,11 @@ func (m *MemMapFs) Mkdir(name string, perm os.FileMode) error {
}
m.mu.Lock()
+ // Dobule check that it doesn't exist.
+ if _, ok := m.getData()[name]; ok {
+ m.mu.Unlock()
+ return &os.PathError{Op: "mkdir", Path: name, Err: ErrFileExists}
+ }
item := mem.CreateDir(name)
mem.SetMode(item, os.ModeDir|perm)
m.getData()[name] = item
diff --git a/vendor/github.com/spf13/viper/Makefile b/vendor/github.com/spf13/viper/Makefile
index 130c427e8..3f4234d33 100644
--- a/vendor/github.com/spf13/viper/Makefile
+++ b/vendor/github.com/spf13/viper/Makefile
@@ -16,7 +16,7 @@ endif
# Dependency versions
GOTESTSUM_VERSION = 1.8.0
-GOLANGCI_VERSION = 1.49.0
+GOLANGCI_VERSION = 1.50.1
# Add the ability to override some variables
# Use with care
diff --git a/vendor/github.com/spf13/viper/README.md b/vendor/github.com/spf13/viper/README.md
index 63413a7dc..cd3929052 100644
--- a/vendor/github.com/spf13/viper/README.md
+++ b/vendor/github.com/spf13/viper/README.md
@@ -8,7 +8,7 @@
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge-flat.svg)](https://github.com/avelino/awesome-go#configuration)
[![run on repl.it](https://repl.it/badge/github/sagikazarmark/Viper-example)](https://repl.it/@sagikazarmark/Viper-example#main.go)
-[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/spf13/viper/CI?style=flat-square)](https://github.com/spf13/viper/actions?query=workflow%3ACI)
+[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/spf13/viper/ci.yaml?branch=master&style=flat-square)](https://github.com/spf13/viper/actions?query=workflow%3ACI)
[![Join the chat at https://gitter.im/spf13/viper](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/spf13/viper?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Go Report Card](https://goreportcard.com/badge/github.com/spf13/viper?style=flat-square)](https://goreportcard.com/report/github.com/spf13/viper)
![Go Version](https://img.shields.io/badge/go%20version-%3E=1.16-61CFDD.svg?style=flat-square)
@@ -40,8 +40,8 @@ go get github.com/spf13/viper
## What is Viper?
-Viper is a complete configuration solution for Go applications including 12-Factor apps. It is designed
-to work within an application, and can handle all types of configuration needs
+Viper is a complete configuration solution for Go applications including [12-Factor apps](https://12factor.net/#the_twelve_factors).
+It is designed to work within an application, and can handle all types of configuration needs
and formats. It supports:
* setting defaults
diff --git a/vendor/github.com/spf13/viper/internal/encoding/toml/codec.go b/vendor/github.com/spf13/viper/internal/encoding/toml/codec.go
index 45fddc8b5..a993c5994 100644
--- a/vendor/github.com/spf13/viper/internal/encoding/toml/codec.go
+++ b/vendor/github.com/spf13/viper/internal/encoding/toml/codec.go
@@ -1,39 +1,16 @@
-//go:build viper_toml1
-// +build viper_toml1
-
package toml
import (
- "github.com/pelletier/go-toml"
+ "github.com/pelletier/go-toml/v2"
)
// Codec implements the encoding.Encoder and encoding.Decoder interfaces for TOML encoding.
type Codec struct{}
func (Codec) Encode(v map[string]interface{}) ([]byte, error) {
- t, err := toml.TreeFromMap(v)
- if err != nil {
- return nil, err
- }
-
- s, err := t.ToTomlString()
- if err != nil {
- return nil, err
- }
-
- return []byte(s), nil
+ return toml.Marshal(v)
}
func (Codec) Decode(b []byte, v map[string]interface{}) error {
- tree, err := toml.LoadBytes(b)
- if err != nil {
- return err
- }
-
- tmap := tree.ToMap()
- for key, value := range tmap {
- v[key] = value
- }
-
- return nil
+ return toml.Unmarshal(b, &v)
}
diff --git a/vendor/github.com/spf13/viper/internal/encoding/toml/codec2.go b/vendor/github.com/spf13/viper/internal/encoding/toml/codec2.go
deleted file mode 100644
index 112c6d372..000000000
--- a/vendor/github.com/spf13/viper/internal/encoding/toml/codec2.go
+++ /dev/null
@@ -1,19 +0,0 @@
-//go:build !viper_toml1
-// +build !viper_toml1
-
-package toml
-
-import (
- "github.com/pelletier/go-toml/v2"
-)
-
-// Codec implements the encoding.Encoder and encoding.Decoder interfaces for TOML encoding.
-type Codec struct{}
-
-func (Codec) Encode(v map[string]interface{}) ([]byte, error) {
- return toml.Marshal(v)
-}
-
-func (Codec) Decode(b []byte, v map[string]interface{}) error {
- return toml.Unmarshal(b, &v)
-}
diff --git a/vendor/github.com/spf13/viper/internal/encoding/yaml/codec.go b/vendor/github.com/spf13/viper/internal/encoding/yaml/codec.go
index 24cc19dfc..82dc136a3 100644
--- a/vendor/github.com/spf13/viper/internal/encoding/yaml/codec.go
+++ b/vendor/github.com/spf13/viper/internal/encoding/yaml/codec.go
@@ -1,6 +1,6 @@
package yaml
-// import "gopkg.in/yaml.v2"
+import "gopkg.in/yaml.v3"
// Codec implements the encoding.Encoder and encoding.Decoder interfaces for YAML encoding.
type Codec struct{}
diff --git a/vendor/github.com/spf13/viper/internal/encoding/yaml/yaml2.go b/vendor/github.com/spf13/viper/internal/encoding/yaml/yaml2.go
deleted file mode 100644
index 4c398c2f4..000000000
--- a/vendor/github.com/spf13/viper/internal/encoding/yaml/yaml2.go
+++ /dev/null
@@ -1,14 +0,0 @@
-//go:build viper_yaml2
-// +build viper_yaml2
-
-package yaml
-
-import yamlv2 "gopkg.in/yaml.v2"
-
-var yaml = struct {
- Marshal func(in interface{}) (out []byte, err error)
- Unmarshal func(in []byte, out interface{}) (err error)
-}{
- Marshal: yamlv2.Marshal,
- Unmarshal: yamlv2.Unmarshal,
-}
diff --git a/vendor/github.com/spf13/viper/internal/encoding/yaml/yaml3.go b/vendor/github.com/spf13/viper/internal/encoding/yaml/yaml3.go
deleted file mode 100644
index 3a4775ced..000000000
--- a/vendor/github.com/spf13/viper/internal/encoding/yaml/yaml3.go
+++ /dev/null
@@ -1,14 +0,0 @@
-//go:build !viper_yaml2
-// +build !viper_yaml2
-
-package yaml
-
-import yamlv3 "gopkg.in/yaml.v3"
-
-var yaml = struct {
- Marshal func(in interface{}) (out []byte, err error)
- Unmarshal func(in []byte, out interface{}) (err error)
-}{
- Marshal: yamlv3.Marshal,
- Unmarshal: yamlv3.Unmarshal,
-}
diff --git a/vendor/github.com/spf13/viper/viper.go b/vendor/github.com/spf13/viper/viper.go
index 5c12529b4..06610fc5a 100644
--- a/vendor/github.com/spf13/viper/viper.go
+++ b/vendor/github.com/spf13/viper/viper.go
@@ -421,13 +421,18 @@ var SupportedExts = []string{"json", "toml", "yaml", "yml", "properties", "props
// SupportedRemoteProviders are universally supported remote providers.
var SupportedRemoteProviders = []string{"etcd", "etcd3", "consul", "firestore"}
+// OnConfigChange sets the event handler that is called when a config file changes.
func OnConfigChange(run func(in fsnotify.Event)) { v.OnConfigChange(run) }
+
+// OnConfigChange sets the event handler that is called when a config file changes.
func (v *Viper) OnConfigChange(run func(in fsnotify.Event)) {
v.onConfigChange = run
}
+// WatchConfig starts watching a config file for changes.
func WatchConfig() { v.WatchConfig() }
+// WatchConfig starts watching a config file for changes.
func (v *Viper) WatchConfig() {
initWG := sync.WaitGroup{}
initWG.Add(1)
diff --git a/vendor/github.com/subosito/gotenv/gotenv.go b/vendor/github.com/subosito/gotenv/gotenv.go
index 7b1186e1f..dc013e1e0 100644
--- a/vendor/github.com/subosito/gotenv/gotenv.go
+++ b/vendor/github.com/subosito/gotenv/gotenv.go
@@ -3,6 +3,7 @@ package gotenv
import (
"bufio"
+ "bytes"
"fmt"
"io"
"os"
@@ -174,9 +175,36 @@ func Write(env Env, filename string) error {
return file.Sync()
}
+// splitLines is a valid SplitFunc for a bufio.Scanner. It will split lines on CR ('\r'), LF ('\n') or CRLF (any of the three sequences).
+// If a CR is immediately followed by a LF, it is treated as a CRLF (one single line break).
+func splitLines(data []byte, atEOF bool) (advance int, token []byte, err error) {
+ if atEOF && len(data) == 0 {
+ return 0, nil, bufio.ErrFinalToken
+ }
+
+ idx := bytes.IndexAny(data, "\r\n")
+ switch {
+ case atEOF && idx < 0:
+ return len(data), data, bufio.ErrFinalToken
+
+ case idx < 0:
+ return 0, nil, nil
+ }
+
+ // consume CR or LF
+ eol := idx + 1
+ // detect CRLF
+ if len(data) > eol && data[eol-1] == '\r' && data[eol] == '\n' {
+ eol++
+ }
+
+ return eol, data[:idx], nil
+}
+
func strictParse(r io.Reader, override bool) (Env, error) {
env := make(Env)
scanner := bufio.NewScanner(r)
+ scanner.Split(splitLines)
firstLine := true
@@ -283,7 +311,6 @@ func parseLine(s string, env Env, override bool) error {
return varReplacement(s, hsq, env, override)
}
val = varRgx.ReplaceAllStringFunc(val, fv)
- val = parseVal(val, env, hdq, override)
}
env[key] = val
@@ -352,18 +379,3 @@ func checkFormat(s string, env Env) error {
return fmt.Errorf("line `%s` doesn't match format", s)
}
-
-func parseVal(val string, env Env, ignoreNewlines bool, override bool) string {
- if strings.Contains(val, "=") && !ignoreNewlines {
- kv := strings.Split(val, "\r")
-
- if len(kv) > 1 {
- val = kv[0]
- for _, l := range kv[1:] {
- _ = parseLine(l, env, override)
- }
- }
- }
-
- return val
-}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 91d7bee1b..8fe91068b 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -313,8 +313,8 @@ github.com/klauspost/cpuid/v2
# github.com/leodido/go-urn v1.2.1
## explicit; go 1.13
github.com/leodido/go-urn
-# github.com/magiconair/properties v1.8.6
-## explicit; go 1.13
+# github.com/magiconair/properties v1.8.7
+## explicit; go 1.19
github.com/magiconair/properties
# github.com/mattn/go-isatty v0.0.17
## explicit; go 1.15
@@ -360,9 +360,6 @@ github.com/oklog/ulid
# github.com/opencontainers/runtime-spec v1.0.2
## explicit
github.com/opencontainers/runtime-spec/specs-go
-# github.com/pelletier/go-toml v1.9.5
-## explicit; go 1.12
-github.com/pelletier/go-toml
# github.com/pelletier/go-toml/v2 v2.0.6
## explicit; go 1.16
github.com/pelletier/go-toml/v2
@@ -391,7 +388,7 @@ github.com/rs/xid
# github.com/sirupsen/logrus v1.9.0
## explicit; go 1.13
github.com/sirupsen/logrus
-# github.com/spf13/afero v1.9.2
+# github.com/spf13/afero v1.9.3
## explicit; go 1.16
github.com/spf13/afero
github.com/spf13/afero/internal/common
@@ -408,7 +405,7 @@ github.com/spf13/jwalterweatherman
# github.com/spf13/pflag v1.0.5
## explicit; go 1.12
github.com/spf13/pflag
-# github.com/spf13/viper v1.14.0
+# github.com/spf13/viper v1.15.0
## explicit; go 1.17
github.com/spf13/viper
github.com/spf13/viper/internal/encoding
@@ -424,7 +421,7 @@ github.com/spf13/viper/internal/encoding/yaml
github.com/stretchr/testify/assert
github.com/stretchr/testify/require
github.com/stretchr/testify/suite
-# github.com/subosito/gotenv v1.4.1
+# github.com/subosito/gotenv v1.4.2
## explicit; go 1.18
github.com/subosito/gotenv
# github.com/superseriousbusiness/activity v1.2.1-gts