auth: OpenID/OAUth2 middleware
2 configurations for the listeners are now possible: - enableJWT=false with client ssl auth - enableJWT=true with https Actual verification of the tokens is handled by https://github.com/openshift-online/ocm-sdk-go. An authentication handler is run as the top level handler, before any routing is done. Routes which do not require authentication should be listed as exceptions. Authentication can be restricted using an ACL file which allows filtering based on JWT claims. For more information see the inline comments in ocm-sdk/authentication. As an added quirk the `-v` flag for the osbuild-composer executable was changed to `-verbose` to avoid flag collision with glog which declares the `-v` flag in the package `init()` function. The ocm-sdk depends on glog and pulls it in.
This commit is contained in:
parent
58613788bc
commit
4a057bf3d5
192 changed files with 25042 additions and 110 deletions
1
Makefile
1
Makefile
|
|
@ -115,6 +115,7 @@ build:
|
||||||
go build -o bin/osbuild-upload-azure ./cmd/osbuild-upload-azure/
|
go build -o bin/osbuild-upload-azure ./cmd/osbuild-upload-azure/
|
||||||
go build -o bin/osbuild-upload-aws ./cmd/osbuild-upload-aws/
|
go build -o bin/osbuild-upload-aws ./cmd/osbuild-upload-aws/
|
||||||
go build -o bin/osbuild-upload-gcp ./cmd/osbuild-upload-gcp/
|
go build -o bin/osbuild-upload-gcp ./cmd/osbuild-upload-gcp/
|
||||||
|
go build -o bin/osbuild-mock-openid-provider ./cmd/osbuild-mock-openid-provider
|
||||||
go test -c -tags=integration -o bin/osbuild-composer-cli-tests ./cmd/osbuild-composer-cli-tests/main_test.go
|
go test -c -tags=integration -o bin/osbuild-composer-cli-tests ./cmd/osbuild-composer-cli-tests/main_test.go
|
||||||
go test -c -tags=integration -o bin/osbuild-weldr-tests ./internal/client/
|
go test -c -tags=integration -o bin/osbuild-weldr-tests ./internal/client/
|
||||||
go test -c -tags=integration -o bin/osbuild-dnf-json-tests ./cmd/osbuild-dnf-json-tests/main_test.go
|
go test -c -tags=integration -o bin/osbuild-dnf-json-tests ./cmd/osbuild-dnf-json-tests/main_test.go
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import (
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
|
|
||||||
|
"github.com/osbuild/osbuild-composer/internal/auth"
|
||||||
"github.com/osbuild/osbuild-composer/internal/cloudapi"
|
"github.com/osbuild/osbuild-composer/internal/cloudapi"
|
||||||
"github.com/osbuild/osbuild-composer/internal/distroregistry"
|
"github.com/osbuild/osbuild-composer/internal/distroregistry"
|
||||||
"github.com/osbuild/osbuild-composer/internal/jobqueue"
|
"github.com/osbuild/osbuild-composer/internal/jobqueue"
|
||||||
|
|
@ -101,22 +102,28 @@ func (c *Composer) InitWeldr(repoPaths []string, weldrListener net.Listener,
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Composer) InitAPI(cert, key string, l net.Listener) error {
|
func (c *Composer) InitAPI(cert, key string, enableJWT bool, l net.Listener) error {
|
||||||
c.api = cloudapi.NewServer(c.workers, c.rpm, c.distros)
|
c.api = cloudapi.NewServer(c.workers, c.rpm, c.distros)
|
||||||
c.koji = kojiapi.NewServer(c.logger, c.workers, c.rpm, c.distros)
|
c.koji = kojiapi.NewServer(c.logger, c.workers, c.rpm, c.distros)
|
||||||
|
|
||||||
|
clientAuth := tls.RequireAndVerifyClientCert
|
||||||
|
if enableJWT {
|
||||||
|
// jwt enabled => tls listener without client auth
|
||||||
|
clientAuth = tls.NoClientCert
|
||||||
|
}
|
||||||
|
|
||||||
tlsConfig, err := createTLSConfig(&connectionConfig{
|
tlsConfig, err := createTLSConfig(&connectionConfig{
|
||||||
CACertFile: c.config.Koji.CA,
|
CACertFile: c.config.Koji.CA,
|
||||||
ServerKeyFile: key,
|
ServerKeyFile: key,
|
||||||
ServerCertFile: cert,
|
ServerCertFile: cert,
|
||||||
AllowedDomains: c.config.Koji.AllowedDomains,
|
AllowedDomains: c.config.Koji.AllowedDomains,
|
||||||
|
ClientAuth: clientAuth,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating TLS configuration: %v", err)
|
return fmt.Errorf("Error creating TLS configuration: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.apiListener = tls.NewListener(l, tlsConfig)
|
c.apiListener = tls.NewListener(l, tlsConfig)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -124,17 +131,23 @@ func (c *Composer) InitLocalWorker(l net.Listener) {
|
||||||
c.localWorkerListener = l
|
c.localWorkerListener = l
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Composer) InitRemoteWorkers(cert, key string, l net.Listener) error {
|
func (c *Composer) InitRemoteWorkers(cert, key string, enableJWT bool, l net.Listener) error {
|
||||||
|
clientAuth := tls.RequireAndVerifyClientCert
|
||||||
|
if enableJWT {
|
||||||
|
// jwt enabled => tls listener without client auth
|
||||||
|
clientAuth = tls.NoClientCert
|
||||||
|
}
|
||||||
|
|
||||||
tlsConfig, err := createTLSConfig(&connectionConfig{
|
tlsConfig, err := createTLSConfig(&connectionConfig{
|
||||||
CACertFile: c.config.Worker.CA,
|
CACertFile: c.config.Worker.CA,
|
||||||
ServerKeyFile: key,
|
ServerKeyFile: key,
|
||||||
ServerCertFile: cert,
|
ServerCertFile: cert,
|
||||||
AllowedDomains: c.config.Worker.AllowedDomains,
|
AllowedDomains: c.config.Worker.AllowedDomains,
|
||||||
|
ClientAuth: clientAuth,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating TLS configuration for remote worker API: %v", err)
|
return fmt.Errorf("Error creating TLS configuration for remote worker API: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.workerListener = tls.NewListener(l, tlsConfig)
|
c.workerListener = tls.NewListener(l, tlsConfig)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -168,11 +181,26 @@ func (c *Composer) Start() error {
|
||||||
|
|
||||||
if c.workerListener != nil {
|
if c.workerListener != nil {
|
||||||
go func() {
|
go func() {
|
||||||
|
handler := c.workers.Handler()
|
||||||
|
var err error
|
||||||
|
if c.config.Worker.EnableJWT {
|
||||||
|
handler, err = auth.BuildJWTAuthHandler(
|
||||||
|
c.config.Worker.JWTKeysURL,
|
||||||
|
c.config.Worker.JWTKeysCA,
|
||||||
|
c.config.Worker.JWTACLFile,
|
||||||
|
[]string{},
|
||||||
|
handler,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
s := &http.Server{
|
s := &http.Server{
|
||||||
ErrorLog: c.logger,
|
ErrorLog: c.logger,
|
||||||
Handler: c.workers.Handler(),
|
Handler: handler,
|
||||||
}
|
}
|
||||||
err := s.Serve(c.workerListener)
|
err = s.Serve(c.workerListener)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
@ -193,12 +221,26 @@ func (c *Composer) Start() error {
|
||||||
mux.Handle(kojiRoute+"/", c.koji.Handler(kojiRoute))
|
mux.Handle(kojiRoute+"/", c.koji.Handler(kojiRoute))
|
||||||
mux.Handle("/metrics", promhttp.Handler().(http.HandlerFunc))
|
mux.Handle("/metrics", promhttp.Handler().(http.HandlerFunc))
|
||||||
|
|
||||||
s := &http.Server{
|
handler := http.Handler(mux)
|
||||||
ErrorLog: c.logger,
|
var err error
|
||||||
Handler: mux,
|
if c.config.ComposerAPI.EnableJWT {
|
||||||
|
handler, err = auth.BuildJWTAuthHandler(
|
||||||
|
c.config.ComposerAPI.JWTKeysURL,
|
||||||
|
c.config.ComposerAPI.JWTKeysCA,
|
||||||
|
c.config.ComposerAPI.JWTACLFile,
|
||||||
|
[]string{
|
||||||
|
"/metrics/?$",
|
||||||
|
}, mux)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err := s.Serve(c.apiListener)
|
s := &http.Server{
|
||||||
|
ErrorLog: c.logger,
|
||||||
|
Handler: handler,
|
||||||
|
}
|
||||||
|
err = s.Serve(c.apiListener)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
@ -237,6 +279,7 @@ type connectionConfig struct {
|
||||||
ServerKeyFile string
|
ServerKeyFile string
|
||||||
ServerCertFile string
|
ServerCertFile string
|
||||||
AllowedDomains []string
|
AllowedDomains []string
|
||||||
|
ClientAuth tls.ClientAuthType
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTLSConfig(c *connectionConfig) (*tls.Config, error) {
|
func createTLSConfig(c *connectionConfig) (*tls.Config, error) {
|
||||||
|
|
@ -261,7 +304,7 @@ func createTLSConfig(c *connectionConfig) (*tls.Config, error) {
|
||||||
}
|
}
|
||||||
return &tls.Config{
|
return &tls.Config{
|
||||||
Certificates: []tls.Certificate{cert},
|
Certificates: []tls.Certificate{cert},
|
||||||
ClientAuth: tls.RequireAndVerifyClientCert,
|
ClientAuth: c.ClientAuth,
|
||||||
ClientCAs: roots,
|
ClientCAs: roots,
|
||||||
VerifyPeerCertificate: func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {
|
VerifyPeerCertificate: func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {
|
||||||
for _, chain := range verifiedChains {
|
for _, chain := range verifiedChains {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,17 @@ type ComposerConfigFile struct {
|
||||||
PGUser string `toml:"pg_user" env:"PGUSER"`
|
PGUser string `toml:"pg_user" env:"PGUSER"`
|
||||||
PGPassword string `toml:"pg_password" env:"PGPASSWORD"`
|
PGPassword string `toml:"pg_password" env:"PGPASSWORD"`
|
||||||
PGSSLMode string `toml:"pg_ssl_mode" env:"PGSSLMODE"`
|
PGSSLMode string `toml:"pg_ssl_mode" env:"PGSSLMODE"`
|
||||||
|
EnableJWT bool `toml:"enable_jwt"`
|
||||||
|
JWTKeysURL string `toml:"jwt_keys_url"`
|
||||||
|
JWTKeysCA string `toml:"jwt_ca_file"`
|
||||||
|
JWTACLFile string `toml:"jwt_acl_file"`
|
||||||
} `toml:"worker"`
|
} `toml:"worker"`
|
||||||
|
ComposerAPI struct {
|
||||||
|
EnableJWT bool `toml:"enable_jwt"`
|
||||||
|
JWTKeysURL string `toml:"jwt_keys_url"`
|
||||||
|
JWTKeysCA string `toml:"jwt_ca_file"`
|
||||||
|
JWTACLFile string `toml:"jwt_acl_file"`
|
||||||
|
} `toml:"composer_api"`
|
||||||
WeldrAPI WeldrAPIConfig `toml:"weldr_api"`
|
WeldrAPI WeldrAPIConfig `toml:"weldr_api"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,6 +110,9 @@ func loadConfigFromEnv(intf interface{}) error {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fieldV.SetString(confV)
|
fieldV.SetString(confV)
|
||||||
|
case reflect.Bool:
|
||||||
|
// no-op
|
||||||
|
continue
|
||||||
case reflect.Slice:
|
case reflect.Slice:
|
||||||
// no-op
|
// no-op
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,10 @@ func TestDefaultConfig(t *testing.T) {
|
||||||
defaultConfig := GetDefaultConfig()
|
defaultConfig := GetDefaultConfig()
|
||||||
require.Empty(t, defaultConfig.Koji)
|
require.Empty(t, defaultConfig.Koji)
|
||||||
require.Empty(t, defaultConfig.Worker)
|
require.Empty(t, defaultConfig.Worker)
|
||||||
require.Empty(t, defaultConfig.ComposerAPI)
|
require.False(t, defaultConfig.ComposerAPI.EnableJWT)
|
||||||
|
require.Equal(t, "", defaultConfig.ComposerAPI.JWTKeysCA)
|
||||||
|
require.False(t, defaultConfig.Worker.EnableJWT)
|
||||||
|
require.Equal(t, "", defaultConfig.Worker.JWTKeysCA)
|
||||||
|
|
||||||
expectedWeldrAPIConfig := WeldrAPIConfig{
|
expectedWeldrAPIConfig := WeldrAPIConfig{
|
||||||
DistroConfigs: map[string]WeldrDistroConfig{
|
DistroConfigs: map[string]WeldrDistroConfig{
|
||||||
|
|
@ -62,6 +65,11 @@ func TestConfig(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, config)
|
require.NotNil(t, config)
|
||||||
require.Equal(t, "composer-db", config.Worker.PGDatabase)
|
require.Equal(t, "composer-db", config.Worker.PGDatabase)
|
||||||
|
|
||||||
|
require.True(t, config.ComposerAPI.EnableJWT)
|
||||||
|
require.Equal(t, "https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/certs", config.ComposerAPI.JWTKeysURL)
|
||||||
|
require.Equal(t, "", config.ComposerAPI.JWTKeysCA)
|
||||||
|
require.Equal(t, "/var/lib/osbuild-composer/acl", config.ComposerAPI.JWTACLFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWeldrDistrosImageTypeDenyList(t *testing.T) {
|
func TestWeldrDistrosImageTypeDenyList(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ var repositoryConfigs = []string{
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var verbose bool
|
var verbose bool
|
||||||
flag.BoolVar(&verbose, "v", false, "Print access log")
|
flag.BoolVar(&verbose, "verbose", false, "Print access log")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
var logger *log.Logger
|
var logger *log.Logger
|
||||||
|
|
@ -88,7 +88,7 @@ func main() {
|
||||||
log.Fatal("The osbuild-composer-api.socket unit is misconfigured. It should contain only one socket.")
|
log.Fatal("The osbuild-composer-api.socket unit is misconfigured. It should contain only one socket.")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = composer.InitAPI(ServerCertFile, ServerKeyFile, l[0])
|
err = composer.InitAPI(ServerCertFile, ServerKeyFile, config.ComposerAPI.EnableJWT, l[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error initializing koji API: %v", err)
|
log.Fatalf("Error initializing koji API: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -99,7 +99,7 @@ func main() {
|
||||||
log.Fatal("The osbuild-remote-worker.socket unit is misconfigured. It should contain only one socket.")
|
log.Fatal("The osbuild-remote-worker.socket unit is misconfigured. It should contain only one socket.")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = composer.InitRemoteWorkers(ServerCertFile, ServerKeyFile, l[0])
|
err = composer.InitRemoteWorkers(ServerCertFile, ServerKeyFile, config.Worker.EnableJWT, l[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error initializing worker API: %v", err)
|
log.Fatalf("Error initializing worker API: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
5
cmd/osbuild-composer/testdata/test.toml
vendored
5
cmd/osbuild-composer/testdata/test.toml
vendored
|
|
@ -15,3 +15,8 @@ image_type_denylist = [ "qcow2" ]
|
||||||
|
|
||||||
# overrides the default rhel-* configuration
|
# overrides the default rhel-* configuration
|
||||||
[weldr_api.distros."rhel-*"]
|
[weldr_api.distros."rhel-*"]
|
||||||
|
|
||||||
|
[composer_api]
|
||||||
|
enable_jwt = true
|
||||||
|
jwt_keys_url = "https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/certs"
|
||||||
|
jwt_acl_file = "/var/lib/osbuild-composer/acl"
|
||||||
|
|
|
||||||
123
cmd/osbuild-mock-openid-provider/main.go
Normal file
123
cmd/osbuild-mock-openid-provider/main.go
Normal file
|
|
@ -0,0 +1,123 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
"encoding/json"
|
||||||
|
"flag"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
"math/big"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/golang-jwt/jwt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Implements /certs and /token
|
||||||
|
func main() {
|
||||||
|
var addr string
|
||||||
|
var rsaPubPem string
|
||||||
|
var rsaPem string
|
||||||
|
var tlsCert string
|
||||||
|
var tlsKey string
|
||||||
|
flag.StringVar(&addr, "a", "localhost:8080", "Address to serve on")
|
||||||
|
flag.StringVar(&rsaPubPem, "rsaPubPem", "", "rsa pubkey in pem format (path)")
|
||||||
|
flag.StringVar(&rsaPem, "rsaPem", "", "rsa privkey in pem format (path)")
|
||||||
|
flag.StringVar(&tlsCert, "cert", "", "tls cert")
|
||||||
|
flag.StringVar(&tlsKey, "key", "", "tls key")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
if rsaPubPem == "" || rsaPem == "" {
|
||||||
|
panic("path to rsa keys needed")
|
||||||
|
}
|
||||||
|
|
||||||
|
mux := http.NewServeMux()
|
||||||
|
mux.HandleFunc("/certs", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
type key struct {
|
||||||
|
Kid string `json:"kid"`
|
||||||
|
Kty string `json:"kty"`
|
||||||
|
Alg string `json:"alg"`
|
||||||
|
N string `json:"n"`
|
||||||
|
E string `json:"e"`
|
||||||
|
}
|
||||||
|
|
||||||
|
rsaPubBytes, err := ioutil.ReadFile(rsaPubPem)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
pubKey, err := jwt.ParseRSAPublicKeyFromPEM(rsaPubBytes)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
k := key{
|
||||||
|
Kid: "key-id",
|
||||||
|
Kty: "RSA",
|
||||||
|
Alg: "RS256",
|
||||||
|
N: strings.TrimRight(base64.URLEncoding.EncodeToString(pubKey.N.Bytes()), "="),
|
||||||
|
E: strings.TrimRight(base64.URLEncoding.EncodeToString(big.NewInt(int64(pubKey.E)).Bytes()), "="),
|
||||||
|
}
|
||||||
|
|
||||||
|
type response struct {
|
||||||
|
Keys []key `json:"keys"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.NewEncoder(w).Encode(response{
|
||||||
|
Keys: []key{
|
||||||
|
k,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.HandleFunc("/token", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
type customClaims struct {
|
||||||
|
Type string `json:"typ"`
|
||||||
|
ExpiresAt int64 `json:"exp"`
|
||||||
|
IssuedAt int64 `json:"iat"`
|
||||||
|
jwt.Claims
|
||||||
|
}
|
||||||
|
|
||||||
|
cc := customClaims{
|
||||||
|
Type: "Bearer",
|
||||||
|
ExpiresAt: 0,
|
||||||
|
IssuedAt: time.Now().Unix(),
|
||||||
|
}
|
||||||
|
token := jwt.NewWithClaims(jwt.SigningMethodRS256, cc)
|
||||||
|
token.Header["kid"] = "key-id"
|
||||||
|
|
||||||
|
rsaPrivBytes, err := ioutil.ReadFile(rsaPem)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
privKey, err := jwt.ParseRSAPrivateKeyFromPEM(rsaPrivBytes)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
tokenStr, err := token.SignedString(privKey)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
type response struct {
|
||||||
|
AccessToken string `json:"access_token"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.NewEncoder(w).Encode(response{
|
||||||
|
AccessToken: tokenStr,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
})
|
||||||
|
|
||||||
|
if tlsCert != "" && tlsKey != "" {
|
||||||
|
log.Fatal(http.ListenAndServeTLS(addr, tlsCert, tlsKey, mux))
|
||||||
|
} else {
|
||||||
|
log.Fatal(http.ListenAndServe(addr, mux))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -148,32 +149,47 @@ func main() {
|
||||||
var client *worker.Client
|
var client *worker.Client
|
||||||
if unix {
|
if unix {
|
||||||
client = worker.NewClientUnix(address)
|
client = worker.NewClientUnix(address)
|
||||||
} else if config.Authentication != nil && config.Authentication.OfflineTokenPath != "" {
|
|
||||||
t, err := ioutil.ReadFile(config.Authentication.OfflineTokenPath)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Could not read offline token: %v", err)
|
|
||||||
}
|
|
||||||
token := strings.TrimSpace(string(t))
|
|
||||||
|
|
||||||
if config.Authentication.OAuthURL == "" {
|
|
||||||
log.Fatal("OAuth URL should be specified together with the offline token")
|
|
||||||
}
|
|
||||||
|
|
||||||
client, err = worker.NewClient("https://"+address, nil, &token, &config.Authentication.OAuthURL)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Error creating worker client: %v", err)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
conf, err := createTLSConfig(&connectionConfig{
|
var token *string
|
||||||
|
var oAuthURL *string
|
||||||
|
if config.Authentication != nil && config.Authentication.OfflineTokenPath != "" {
|
||||||
|
t, err := ioutil.ReadFile(config.Authentication.OfflineTokenPath)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Could not read offline token: %v", err)
|
||||||
|
}
|
||||||
|
t2 := strings.TrimSpace(string(t))
|
||||||
|
token = &t2
|
||||||
|
|
||||||
|
if config.Authentication.OAuthURL == "" {
|
||||||
|
log.Fatal("OAuth URL should be specified together with the offline token")
|
||||||
|
}
|
||||||
|
oAuthURL = &config.Authentication.OAuthURL
|
||||||
|
|
||||||
|
if strings.HasPrefix(address, "http") {
|
||||||
|
out, err := exec.Command("systemd-escape", "-u", address).Output()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Could not escape remote worker address: %v", err)
|
||||||
|
}
|
||||||
|
address = strings.TrimSpace(string(out))
|
||||||
|
} else {
|
||||||
|
address = fmt.Sprintf("https://%s", address)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var conf *tls.Config
|
||||||
|
conConf := &connectionConfig{
|
||||||
CACertFile: "/etc/osbuild-composer/ca-crt.pem",
|
CACertFile: "/etc/osbuild-composer/ca-crt.pem",
|
||||||
ClientKeyFile: "/etc/osbuild-composer/worker-key.pem",
|
ClientKeyFile: "/etc/osbuild-composer/worker-key.pem",
|
||||||
ClientCertFile: "/etc/osbuild-composer/worker-crt.pem",
|
ClientCertFile: "/etc/osbuild-composer/worker-crt.pem",
|
||||||
})
|
}
|
||||||
if err != nil {
|
if _, err = os.Stat(conConf.CACertFile); err == nil {
|
||||||
log.Fatalf("Error creating TLS config: %v", err)
|
conf, err = createTLSConfig(conConf)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Error creating TLS config: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err = worker.NewClient("https://"+address, conf, nil, nil)
|
client, err = worker.NewClient(address, conf, token, oAuthURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error creating worker client: %v", err)
|
log.Fatalf("Error creating worker client: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
49
docs/news/unreleased/api-oauth2-support.md
Normal file
49
docs/news/unreleased/api-oauth2-support.md
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
# Composer-api and worker-api: OAuth2 support
|
||||||
|
|
||||||
|
Adding OAuth2 support to composer means both the composer-api and worker-api are now able to authenticate clients using
|
||||||
|
the [JWT](https://jwt.io/) set in the "Authorization" HTTP header. This was added with Red Hat Single Sign-On in mind,
|
||||||
|
but would work for other OAuth2 providers as well (potentially with minor changes).
|
||||||
|
|
||||||
|
## Workflow
|
||||||
|
|
||||||
|
1. A client makes a request to https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token using
|
||||||
|
their offline token.
|
||||||
|
|
||||||
|
2. sso.redhat.com would respond with an `access_token` which is valid for a certain period.
|
||||||
|
|
||||||
|
3. This `access_token` can be set in the "Authorization" HTTP header: "Authorization: Bearer `access_token`".
|
||||||
|
|
||||||
|
4. Composer verifies the token against the certificates returned by
|
||||||
|
https://^Co.redhat.com/auth/realms/redhat-external/protocol/openid-connect/certs.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
Using [openshift-online/ocm-sdk](https://github.com/openshift-online/ocm-sdk-go) composer-api now supports oauth2
|
||||||
|
authentication. To this end there's 4 new config options for the Worker and Composer API:
|
||||||
|
|
||||||
|
- EnableJWT: Enable or disable OAuth2 authentication.
|
||||||
|
- JWTKeysURL: Location where the certs used to verify the JWT tokens are served.
|
||||||
|
- JWTKeysCA: Path to the CA which should be used when retrieving the certs (optional).
|
||||||
|
- JWTACLFile: Path to a yaml file containing a series of pattern match rules against the claims
|
||||||
|
contained within the JWT (optional).
|
||||||
|
|
||||||
|
### ACL claims pattern matching format
|
||||||
|
|
||||||
|
The ACLFile should contain a list of claims and their required pattern in yaml format. Note that a claim with a specific
|
||||||
|
name can only be specified once. So if for instance a required pattern for the `email` claim is listed twice, only one
|
||||||
|
will pattern will be applied.
|
||||||
|
|
||||||
|
The pattern is verified using the golang regexp package, and follows the [RE2
|
||||||
|
syntax](https://github.com/google/re2/wiki/Syntax).
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```
|
||||||
|
- claim: email
|
||||||
|
pattern: ^.*@redhat\.com$
|
||||||
|
- claim: sub
|
||||||
|
pattern: ^f:b3f7b485-7184-43c8-8169-37bd6d1fe4aa:myuser$
|
||||||
|
- claim: account_number
|
||||||
|
pattern: ^(1000|1001|1002)$
|
||||||
|
- claim: account_id
|
||||||
|
pattern: ^(5000|5005)$
|
||||||
|
```
|
||||||
2
go.mod
2
go.mod
|
|
@ -19,6 +19,7 @@ require (
|
||||||
github.com/deepmap/oapi-codegen v1.3.12
|
github.com/deepmap/oapi-codegen v1.3.12
|
||||||
github.com/getkin/kin-openapi v0.13.0
|
github.com/getkin/kin-openapi v0.13.0
|
||||||
github.com/gobwas/glob v0.2.3
|
github.com/gobwas/glob v0.2.3
|
||||||
|
github.com/golang-jwt/jwt v3.2.0+incompatible
|
||||||
github.com/golang/protobuf v1.5.2 // indirect
|
github.com/golang/protobuf v1.5.2 // indirect
|
||||||
github.com/google/go-cmp v0.5.5
|
github.com/google/go-cmp v0.5.5
|
||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
|
|
@ -28,6 +29,7 @@ require (
|
||||||
github.com/julienschmidt/httprouter v1.3.0
|
github.com/julienschmidt/httprouter v1.3.0
|
||||||
github.com/kolo/xmlrpc v0.0.0-20200310150728-e0350524596b
|
github.com/kolo/xmlrpc v0.0.0-20200310150728-e0350524596b
|
||||||
github.com/labstack/echo/v4 v4.1.11
|
github.com/labstack/echo/v4 v4.1.11
|
||||||
|
github.com/openshift-online/ocm-sdk-go v0.1.198
|
||||||
github.com/prometheus/client_golang v1.10.0
|
github.com/prometheus/client_golang v1.10.0
|
||||||
github.com/stretchr/testify v1.7.0
|
github.com/stretchr/testify v1.7.0
|
||||||
github.com/ubccr/kerby v0.0.0-20170626144437-201a958fc453
|
github.com/ubccr/kerby v0.0.0-20170626144437-201a958fc453
|
||||||
|
|
|
||||||
98
go.sum
98
go.sum
|
|
@ -82,6 +82,9 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
|
||||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||||
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
|
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
|
||||||
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
||||||
|
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
|
||||||
|
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||||
|
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
||||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||||
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
|
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
|
||||||
|
|
@ -107,7 +110,10 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||||
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
|
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
|
||||||
|
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
|
||||||
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
||||||
|
github.com/cenkalti/backoff/v4 v4.0.0 h1:6VeaLF9aI+MAUQ95106HwWzYZgJJpZ4stumjj6RFYAU=
|
||||||
|
github.com/cenkalti/backoff/v4 v4.0.0/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg=
|
||||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
|
|
@ -142,25 +148,31 @@ github.com/deepmap/oapi-codegen v1.3.12/go.mod h1:suMvK7+rKlx3+tpa8ByptmvoXbAV70
|
||||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||||
github.com/dimchansky/utfbom v1.1.0 h1:FcM3g+nofKgUteL8dm/UpdRXNC9KmADgTpLKsu0TRo4=
|
github.com/dimchansky/utfbom v1.1.0 h1:FcM3g+nofKgUteL8dm/UpdRXNC9KmADgTpLKsu0TRo4=
|
||||||
github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8=
|
github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8=
|
||||||
|
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
|
||||||
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||||
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
||||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
|
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
|
||||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||||
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
||||||
|
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
|
||||||
|
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||||
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
|
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po=
|
github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po=
|
||||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
|
github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||||
github.com/form3tech-oss/jwt-go v3.2.2+incompatible h1:TcekIExNqud5crz4xD2pavyTgWiPvpYe4Xau31I0PRk=
|
github.com/form3tech-oss/jwt-go v3.2.2+incompatible h1:TcekIExNqud5crz4xD2pavyTgWiPvpYe4Xau31I0PRk=
|
||||||
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
|
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
|
||||||
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
|
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
|
||||||
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
|
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
github.com/getkin/kin-openapi v0.13.0 h1:03fqBEEgivp4MVK2ElB140B56hjO9ZFvFTHBsvFsSro=
|
github.com/getkin/kin-openapi v0.13.0 h1:03fqBEEgivp4MVK2ElB140B56hjO9ZFvFTHBsvFsSro=
|
||||||
github.com/getkin/kin-openapi v0.13.0/go.mod h1:WGRs2ZMM1Q8LR1QBEwUxC6RJEfaBcD0s+pcEVXFuAjw=
|
github.com/getkin/kin-openapi v0.13.0/go.mod h1:WGRs2ZMM1Q8LR1QBEwUxC6RJEfaBcD0s+pcEVXFuAjw=
|
||||||
|
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||||
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
|
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
|
||||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||||
github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
|
github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
|
||||||
|
|
@ -174,16 +186,26 @@ github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vb
|
||||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||||
|
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
|
||||||
|
github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0=
|
||||||
|
github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg=
|
||||||
|
github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc=
|
||||||
|
github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
|
||||||
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||||
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
|
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
|
||||||
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
|
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
|
||||||
|
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||||
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
|
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
|
||||||
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||||
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
|
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
|
||||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||||
|
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
|
||||||
|
github.com/golang-jwt/jwt v3.2.0+incompatible h1:cy0jZQ1aewnxirUHoalEYhE2zxzE7JqR9YQPWhEKzXc=
|
||||||
|
github.com/golang-jwt/jwt v3.2.0+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||||
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
|
|
@ -197,6 +219,7 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt
|
||||||
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||||
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||||
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
||||||
|
github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
|
@ -231,6 +254,7 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
|
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=
|
github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=
|
||||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||||
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||||
|
|
@ -250,11 +274,14 @@ github.com/google/uuid v0.0.0-20170306145142-6a5e28554805/go.mod h1:TIyPZe4Mgqvf
|
||||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||||
github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM=
|
github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM=
|
||||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||||
|
github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
|
||||||
|
github.com/googleapis/gnostic v0.1.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
|
||||||
github.com/gophercloud/gophercloud v0.20.0 h1:1+4jrsjVhdX5omlAo4jkmFc6ftLbuXLzgFo4i6lH+Gk=
|
github.com/gophercloud/gophercloud v0.20.0 h1:1+4jrsjVhdX5omlAo4jkmFc6ftLbuXLzgFo4i6lH+Gk=
|
||||||
github.com/gophercloud/gophercloud v0.20.0/go.mod h1:wRtmUelyIIv3CSSDI47aUwbs075O6i+LY+pXsKCBsb4=
|
github.com/gophercloud/gophercloud v0.20.0/go.mod h1:wRtmUelyIIv3CSSDI47aUwbs075O6i+LY+pXsKCBsb4=
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||||
|
|
@ -263,6 +290,8 @@ github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51
|
||||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||||
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||||
|
github.com/grokify/html-strip-tags-go v0.0.0-20200322061010-ea0c1cf2f119 h1:h3iGUlU8HyW4baKd6D+h1mwOHnM2kwskSuG6Bv4tSbc=
|
||||||
|
github.com/grokify/html-strip-tags-go v0.0.0-20200322061010-ea0c1cf2f119/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78=
|
||||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||||
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||||
|
|
@ -286,6 +315,7 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO
|
||||||
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
|
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
|
||||||
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
|
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
|
||||||
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
||||||
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
|
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
|
||||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||||
|
|
@ -300,7 +330,11 @@ github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgO
|
||||||
github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA=
|
github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA=
|
||||||
github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE=
|
github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE=
|
||||||
github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s=
|
github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s=
|
||||||
|
github.com/jackc/pgconn v1.4.0/go.mod h1:Y2O3ZDF0q4mMacyWV3AstPJpeHXWGEetiFttmq5lahk=
|
||||||
|
github.com/jackc/pgconn v1.5.0/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI=
|
||||||
|
github.com/jackc/pgconn v1.5.1-0.20200601181101-fa742c524853/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI=
|
||||||
github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o=
|
github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o=
|
||||||
|
github.com/jackc/pgconn v1.8.1/go.mod h1:JV6m6b6jhjdmzchES0drzCcYcAHS1OPD5xu3OZ/lE2g=
|
||||||
github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY=
|
github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY=
|
||||||
github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530 h1:dUJ578zuPEsXjtzOfEF0q9zDAfljJ9oFnTHcQaNkccw=
|
github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530 h1:dUJ578zuPEsXjtzOfEF0q9zDAfljJ9oFnTHcQaNkccw=
|
||||||
github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
|
github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
|
||||||
|
|
@ -318,24 +352,38 @@ github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod
|
||||||
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg=
|
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg=
|
||||||
github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
|
github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
|
||||||
github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
|
github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
|
||||||
|
github.com/jackc/pgproto3/v2 v2.0.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||||
github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||||
github.com/jackc/pgproto3/v2 v2.1.1 h1:7PQ/4gLoqnl87ZxL7xjO0DR5gYuviDCZxQJsUlFW1eI=
|
github.com/jackc/pgproto3/v2 v2.1.1 h1:7PQ/4gLoqnl87ZxL7xjO0DR5gYuviDCZxQJsUlFW1eI=
|
||||||
github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||||
|
github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
|
||||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg=
|
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg=
|
||||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
|
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
|
||||||
github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg=
|
github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg=
|
||||||
github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
|
github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
|
||||||
github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw=
|
github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw=
|
||||||
|
github.com/jackc/pgtype v1.2.0/go.mod h1:5m2OfMh1wTK7x+Fk952IDmI4nw3nPrvtQdM0ZT4WpC0=
|
||||||
|
github.com/jackc/pgtype v1.3.1-0.20200510190516-8cd94a14c75a/go.mod h1:vaogEUkALtxZMCH411K+tKzNpwzCKU+AnPzBKZ+I+Po=
|
||||||
|
github.com/jackc/pgtype v1.3.1-0.20200606141011-f6355165a91c/go.mod h1:cvk9Bgu/VzJ9/lxTO5R5sf80p0DiucVtN7ZxvaC4GmQ=
|
||||||
|
github.com/jackc/pgtype v1.7.0/go.mod h1:ZnHF+rMePVqDKaOfJVI4Q8IVvAQMryDlDkZnKOI75BE=
|
||||||
|
github.com/jackc/pgtype v1.8.0/go.mod h1:PqDKcEBtllAtk/2p6z6SHdXW5UB+MhE75tUol2OKexE=
|
||||||
github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM=
|
github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM=
|
||||||
github.com/jackc/pgtype v1.8.1 h1:9k0IXtdJXHJbyAWQgbWr1lU+MEhPXZz6RIXxfR5oxXs=
|
github.com/jackc/pgtype v1.8.1 h1:9k0IXtdJXHJbyAWQgbWr1lU+MEhPXZz6RIXxfR5oxXs=
|
||||||
github.com/jackc/pgtype v1.8.1/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
|
github.com/jackc/pgtype v1.8.1/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
|
||||||
github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
|
github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
|
||||||
github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
|
github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
|
||||||
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
|
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
|
||||||
|
github.com/jackc/pgx/v4 v4.5.0/go.mod h1:EpAKPLdnTorwmPUUsqrPxy5fphV18j9q3wrfRXgo+kA=
|
||||||
|
github.com/jackc/pgx/v4 v4.6.1-0.20200510190926-94ba730bb1e9/go.mod h1:t3/cdRQl6fOLDxqtlyhe9UWgfIi9R8+8v8GKV5TRA/o=
|
||||||
|
github.com/jackc/pgx/v4 v4.6.1-0.20200606145419-4e5062306904/go.mod h1:ZDaNWkt9sW1JMiNn0kdYBaLelIhw7Pg4qd+Vk6tw7Hg=
|
||||||
|
github.com/jackc/pgx/v4 v4.11.0/go.mod h1:i62xJgdrtVDsnL3U8ekyrQXEwGNTRoG7/8r+CIdYfcc=
|
||||||
|
github.com/jackc/pgx/v4 v4.12.0/go.mod h1:fE547h6VulLPA3kySjfnSG/e2D861g/50JlVUa/ub60=
|
||||||
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c h1:Dznn52SgVIVst9UyOT9brctYUgxs+CvVfPaC3jKrA50=
|
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c h1:Dznn52SgVIVst9UyOT9brctYUgxs+CvVfPaC3jKrA50=
|
||||||
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs=
|
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs=
|
||||||
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||||
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||||
|
github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||||
|
github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||||
github.com/jackc/puddle v1.1.3 h1:JnPg/5Q9xVJGfjsO5CPUOjnJps1JaRUm8I9FXVCFK94=
|
github.com/jackc/puddle v1.1.3 h1:JnPg/5Q9xVJGfjsO5CPUOjnJps1JaRUm8I9FXVCFK94=
|
||||||
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
|
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
|
||||||
|
|
@ -345,6 +393,7 @@ github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX
|
||||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
|
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
|
||||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||||
github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o=
|
github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o=
|
||||||
|
|
@ -355,6 +404,7 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V
|
||||||
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
||||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||||
|
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/kolo/xmlrpc v0.0.0-20200310150728-e0350524596b h1:DzHy0GlWeF0KAglaTMY7Q+khIFoG8toHP+wLFBVBQJc=
|
github.com/kolo/xmlrpc v0.0.0-20200310150728-e0350524596b h1:DzHy0GlWeF0KAglaTMY7Q+khIFoG8toHP+wLFBVBQJc=
|
||||||
github.com/kolo/xmlrpc v0.0.0-20200310150728-e0350524596b/go.mod h1:o03bZfuBwAXHetKXuInt4S7omeXUu62/A845kiycsSQ=
|
github.com/kolo/xmlrpc v0.0.0-20200310150728-e0350524596b/go.mod h1:o03bZfuBwAXHetKXuInt4S7omeXUu62/A845kiycsSQ=
|
||||||
|
|
@ -375,11 +425,13 @@ github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL
|
||||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
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.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
|
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8=
|
github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8=
|
||||||
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
|
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
|
||||||
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
|
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
|
||||||
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
|
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
|
||||||
|
github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||||
github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ=
|
github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ=
|
||||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||||
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
||||||
|
|
@ -412,11 +464,15 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu
|
||||||
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
|
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
|
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
|
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
|
||||||
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
|
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
|
||||||
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
|
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
|
||||||
github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k=
|
github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k=
|
||||||
|
|
@ -429,10 +485,18 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA
|
||||||
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
|
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
|
||||||
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
|
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
|
||||||
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
|
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
|
||||||
|
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
|
github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw=
|
||||||
|
github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
|
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||||
|
github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
|
||||||
|
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||||
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
|
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
|
||||||
|
github.com/openshift-online/ocm-sdk-go v0.1.198 h1:C9W6zd+kVb7MdsGN9g9SccK0FAojPZb222afii0TS98=
|
||||||
|
github.com/openshift-online/ocm-sdk-go v0.1.198/go.mod h1:h/SNeA5mYUZ7doFJFojp0s+xfIbOXXzNWrjVk/liJAs=
|
||||||
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
|
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
|
||||||
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
|
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
|
||||||
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||||
|
|
@ -460,6 +524,7 @@ github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod
|
||||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||||
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
|
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
|
||||||
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||||
|
github.com/prometheus/client_golang v1.9.0/go.mod h1:FqZLKOZnGdFAhOK4nqGHa7D66IdsO+O441Eve7ptJDU=
|
||||||
github.com/prometheus/client_golang v1.10.0 h1:/o0BDeWzLWXNZ+4q5gXltUvaMpJqckTa+jTNoB+z4cg=
|
github.com/prometheus/client_golang v1.10.0 h1:/o0BDeWzLWXNZ+4q5gXltUvaMpJqckTa+jTNoB+z4cg=
|
||||||
github.com/prometheus/client_golang v1.10.0/go.mod h1:WJM3cc3yu7XKBKa/I8WeZm+V3eltZnBwfENSU7mdogU=
|
github.com/prometheus/client_golang v1.10.0/go.mod h1:WJM3cc3yu7XKBKa/I8WeZm+V3eltZnBwfENSU7mdogU=
|
||||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||||
|
|
@ -473,6 +538,7 @@ github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
|
||||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||||
github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
|
github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
|
||||||
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
||||||
|
github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s=
|
||||||
github.com/prometheus/common v0.18.0 h1:WCVKW7aL6LEe1uryfI9dnEc2ZqNB1Fn0ok930v0iL1Y=
|
github.com/prometheus/common v0.18.0 h1:WCVKW7aL6LEe1uryfI9dnEc2ZqNB1Fn0ok930v0iL1Y=
|
||||||
github.com/prometheus/common v0.18.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s=
|
github.com/prometheus/common v0.18.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s=
|
||||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||||
|
|
@ -480,6 +546,7 @@ github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R
|
||||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||||
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
||||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||||
|
github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||||
github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4=
|
github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4=
|
||||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||||
|
|
@ -494,6 +561,7 @@ github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0
|
||||||
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
||||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||||
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
|
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
|
||||||
|
github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||||
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
|
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
|
||||||
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||||
|
|
@ -508,7 +576,9 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9
|
||||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||||
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
|
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
|
||||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
||||||
|
github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
|
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||||
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||||
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
|
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
|
||||||
|
|
@ -540,6 +610,7 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
|
||||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
|
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
|
||||||
|
gitlab.com/c0b/go-ordered-json v0.0.0-20171130231205-49bbdab258c2/go.mod h1:NREvu3a57BaK0R1+ztrEzHWiZAihohNLQ6trPxlIqZI=
|
||||||
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||||
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
|
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
|
||||||
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
||||||
|
|
@ -570,13 +641,16 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U
|
||||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||||
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||||
|
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||||
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
|
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
|
||||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
|
@ -614,6 +688,7 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.4.0 h1:8pl+sMODzuvGJkmj2W4kZihvVb5mKm8pB/X44PIQHv8=
|
golang.org/x/mod v0.4.0 h1:8pl+sMODzuvGJkmj2W4kZihvVb5mKm8pB/X44PIQHv8=
|
||||||
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
|
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
|
@ -634,6 +709,7 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
|
||||||
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20191112182307-2180aed22343/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20191112182307-2180aed22343/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
|
@ -674,6 +750,7 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ
|
||||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
|
@ -697,6 +774,7 @@ golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||||
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191112214154-59a1497f0cea/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191112214154-59a1497f0cea/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
|
@ -725,6 +803,7 @@ golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
|
@ -732,6 +811,7 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
|
@ -747,6 +827,8 @@ golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxb
|
||||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
|
@ -910,12 +992,15 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8X
|
||||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
|
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
|
||||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||||
|
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
|
||||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
|
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
|
||||||
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
|
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
|
||||||
|
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||||
gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU=
|
gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU=
|
||||||
gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||||
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||||
|
|
@ -923,10 +1008,12 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
|
@ -935,8 +1022,17 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
|
||||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||||
|
k8s.io/api v0.18.5/go.mod h1:tN+e/2nbdGKOAH55NMV8oGrMG+3uRlA9GaRfvnCCSNk=
|
||||||
|
k8s.io/apimachinery v0.18.5/go.mod h1:OaXp26zu/5J7p0f92ASynJa1pZo06YlV9fG7BoWbCko=
|
||||||
|
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
|
||||||
|
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
|
||||||
|
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
|
||||||
|
k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E=
|
||||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||||
|
sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=
|
||||||
|
sigs.k8s.io/structured-merge-diff/v3 v3.0.0/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=
|
||||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||||
|
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||||
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
|
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
|
||||||
|
|
|
||||||
59
internal/auth/jwt_auth_handler.go
Normal file
59
internal/auth/jwt_auth_handler.go
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
package auth
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"crypto/x509"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/openshift-online/ocm-sdk-go/authentication"
|
||||||
|
"github.com/openshift-online/ocm-sdk-go/logging"
|
||||||
|
)
|
||||||
|
|
||||||
|
// When using this handler for auth, it should be run as high up as possible.
|
||||||
|
// Exceptions can be registered in the `exclude` slice
|
||||||
|
func BuildJWTAuthHandler(keysURL, caFile, aclFile string, exclude []string, next http.Handler) (handler http.Handler, err error) {
|
||||||
|
logBuilder := logging.NewGoLoggerBuilder()
|
||||||
|
if caFile != "" {
|
||||||
|
logBuilder = logBuilder.Debug(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
logger, err := logBuilder.Build()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Info(context.Background(), aclFile)
|
||||||
|
|
||||||
|
builder := authentication.NewHandler().
|
||||||
|
Logger(logger).
|
||||||
|
KeysURL(keysURL)
|
||||||
|
|
||||||
|
// Used during testing
|
||||||
|
if caFile != "" {
|
||||||
|
logger.Warn(context.Background(),
|
||||||
|
"A custom CA is specified to verify jwt tokens, this shouldn't be enabled in a production setting.")
|
||||||
|
caPEM, err := ioutil.ReadFile(caFile)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
pool := x509.NewCertPool()
|
||||||
|
ok := pool.AppendCertsFromPEM(caPEM)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("Unable to load jwt ca cert %s.", caFile)
|
||||||
|
}
|
||||||
|
builder = builder.KeysCAs(pool)
|
||||||
|
}
|
||||||
|
|
||||||
|
if aclFile != "" {
|
||||||
|
builder = builder.ACLFile(aclFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, e := range exclude {
|
||||||
|
builder = builder.Public(e)
|
||||||
|
}
|
||||||
|
handler, err = builder.Next(next).Build()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
@ -66,10 +66,6 @@ func NewClient(baseURL string, conf *tls.Config, offlineToken, oAuthURL *string)
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if conf != nil && offlineToken != nil {
|
|
||||||
return nil, fmt.Errorf("error creating client, both tls and oauth are enabled")
|
|
||||||
}
|
|
||||||
|
|
||||||
requester := &http.Client{}
|
requester := &http.Client{}
|
||||||
if conf != nil {
|
if conf != nil {
|
||||||
requester.Transport = &http.Transport{
|
requester.Transport = &http.Transport{
|
||||||
|
|
|
||||||
|
|
@ -258,10 +258,9 @@ func TestOAuth(t *testing.T) {
|
||||||
workSrv := httptest.NewServer(handler)
|
workSrv := httptest.NewServer(handler)
|
||||||
defer workSrv.Close()
|
defer workSrv.Close()
|
||||||
|
|
||||||
/* Start a server which will act as a proxy, adding a valid identity header */
|
/* Check that the worker supplies the access token */
|
||||||
proxySrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
proxySrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
require.Equal(t, "Bearer accessToken!", r.Header.Get("Authorization"))
|
require.Equal(t, "Bearer accessToken!", r.Header.Get("Authorization"))
|
||||||
r.Header.Set("x-rh-identity", "eyJlbnRpdGxlbWVudHMiOnsiaW5zaWdodHMiOnsiaXNfZW50aXRsZWQiOnRydWV9LCJzbWFydF9tYW5hZ2VtZW50Ijp7ImlzX2VudGl0bGVkIjp0cnVlfSwib3BlbnNoaWZ0Ijp7ImlzX2VudGl0bGVkIjp0cnVlfSwiaHlicmlkIjp7ImlzX2VudGl0bGVkIjp0cnVlfSwibWlncmF0aW9ucyI6eyJpc19lbnRpdGxlZCI6dHJ1ZX0sImFuc2libGUiOnsiaXNfZW50aXRsZWQiOnRydWV9fSwiaWRlbnRpdHkiOnsiYWNjb3VudF9udW1iZXIiOiIwMDAwMDAiLCJ0eXBlIjoiVXNlciIsInVzZXIiOnsidXNlcm5hbWUiOiJ1c2VyIiwiZW1haWwiOiJ1c2VyQHVzZXIudXNlciIsImZpcnN0X25hbWUiOiJ1c2VyIiwibGFzdF9uYW1lIjoidXNlciIsImlzX2FjdGl2ZSI6dHJ1ZSwiaXNfb3JnX2FkbWluIjp0cnVlLCJpc19pbnRlcm5hbCI6dHJ1ZSwibG9jYWxlIjoiZW4tVVMifSwiaW50ZXJuYWwiOnsib3JnX2lkIjoiMDAwMDAwIn19fQ==")
|
|
||||||
handler.ServeHTTP(w, r)
|
handler.ServeHTTP(w, r)
|
||||||
}))
|
}))
|
||||||
defer proxySrv.Close()
|
defer proxySrv.Close()
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ BuildRequires: golang(github.com/coreos/go-semver/semver)
|
||||||
BuildRequires: golang(github.com/coreos/go-systemd/activation)
|
BuildRequires: golang(github.com/coreos/go-systemd/activation)
|
||||||
BuildRequires: golang(github.com/deepmap/oapi-codegen/pkg/codegen)
|
BuildRequires: golang(github.com/deepmap/oapi-codegen/pkg/codegen)
|
||||||
BuildRequires: golang(github.com/go-chi/chi)
|
BuildRequires: golang(github.com/go-chi/chi)
|
||||||
|
BuildRequires: golang(github.com/golang-jwt/jwt)
|
||||||
BuildRequires: golang(github.com/google/uuid)
|
BuildRequires: golang(github.com/google/uuid)
|
||||||
BuildRequires: golang(github.com/jackc/pgx/v4)
|
BuildRequires: golang(github.com/jackc/pgx/v4)
|
||||||
BuildRequires: golang(github.com/julienschmidt/httprouter)
|
BuildRequires: golang(github.com/julienschmidt/httprouter)
|
||||||
|
|
@ -56,6 +57,7 @@ BuildRequires: golang(github.com/gobwas/glob)
|
||||||
BuildRequires: golang(github.com/google/go-cmp/cmp)
|
BuildRequires: golang(github.com/google/go-cmp/cmp)
|
||||||
BuildRequires: golang(github.com/gophercloud/gophercloud)
|
BuildRequires: golang(github.com/gophercloud/gophercloud)
|
||||||
BuildRequires: golang(github.com/prometheus/client_golang/prometheus/promhttp)
|
BuildRequires: golang(github.com/prometheus/client_golang/prometheus/promhttp)
|
||||||
|
BuildRequires: golang(github.com/openshift-online/ocm-sdk-go)
|
||||||
BuildRequires: golang(github.com/stretchr/testify/assert)
|
BuildRequires: golang(github.com/stretchr/testify/assert)
|
||||||
BuildRequires: golang(github.com/ubccr/kerby)
|
BuildRequires: golang(github.com/ubccr/kerby)
|
||||||
BuildRequires: golang(github.com/vmware/govmomi)
|
BuildRequires: golang(github.com/vmware/govmomi)
|
||||||
|
|
@ -146,6 +148,7 @@ go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-auth-tes
|
||||||
go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-koji-tests %{goipath}/cmd/osbuild-koji-tests
|
go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-koji-tests %{goipath}/cmd/osbuild-koji-tests
|
||||||
go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-composer-dbjobqueue-tests %{goipath}/cmd/osbuild-composer-dbjobqueue-tests
|
go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-composer-dbjobqueue-tests %{goipath}/cmd/osbuild-composer-dbjobqueue-tests
|
||||||
go build -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/cloud-cleaner %{goipath}/cmd/cloud-cleaner
|
go build -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/cloud-cleaner %{goipath}/cmd/cloud-cleaner
|
||||||
|
go build -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-mock-openid-provider %{goipath}/cmd/osbuild-mock-openid-provider
|
||||||
|
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
|
@ -180,6 +183,7 @@ install -m 0755 -vp _bin/osbuild-auth-tests %{buildroot}%{_l
|
||||||
install -m 0755 -vp _bin/osbuild-koji-tests %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
install -m 0755 -vp _bin/osbuild-koji-tests %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||||
install -m 0755 -vp _bin/osbuild-composer-dbjobqueue-tests %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
install -m 0755 -vp _bin/osbuild-composer-dbjobqueue-tests %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||||
install -m 0755 -vp _bin/cloud-cleaner %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
install -m 0755 -vp _bin/cloud-cleaner %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||||
|
install -m 0755 -vp _bin/osbuild-mock-openid-provider %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||||
install -m 0755 -vp tools/define-compose-url.sh %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
install -m 0755 -vp tools/define-compose-url.sh %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||||
install -m 0755 -vp tools/provision.sh %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
install -m 0755 -vp tools/provision.sh %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||||
install -m 0755 -vp tools/gen-certs.sh %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
install -m 0755 -vp tools/gen-certs.sh %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||||
|
|
|
||||||
|
|
@ -254,6 +254,7 @@ function cleanupAzure() {
|
||||||
}
|
}
|
||||||
|
|
||||||
WORKDIR=$(mktemp -d)
|
WORKDIR=$(mktemp -d)
|
||||||
|
KILL_PIDS=()
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
case $CLOUD_PROVIDER in
|
case $CLOUD_PROVIDER in
|
||||||
"$CLOUD_PROVIDER_AWS")
|
"$CLOUD_PROVIDER_AWS")
|
||||||
|
|
@ -271,6 +272,10 @@ function cleanup() {
|
||||||
esac
|
esac
|
||||||
|
|
||||||
sudo rm -rf "$WORKDIR"
|
sudo rm -rf "$WORKDIR"
|
||||||
|
|
||||||
|
for P in "${KILL_PIDS[@]}"; do
|
||||||
|
sudo pkill -P "$P"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
|
@ -1131,4 +1136,74 @@ EOF
|
||||||
|
|
||||||
sudo mv -f /usr/libexec/osbuild-composer/dnf-json.bak /usr/libexec/osbuild-composer/dnf-json
|
sudo mv -f /usr/libexec/osbuild-composer/dnf-json.bak /usr/libexec/osbuild-composer/dnf-json
|
||||||
|
|
||||||
|
#
|
||||||
|
# Verify oauth2
|
||||||
|
#
|
||||||
|
cat <<EOF | sudo tee "/etc/osbuild-composer/osbuild-composer.toml"
|
||||||
|
[koji]
|
||||||
|
allowed_domains = [ "localhost", "client.osbuild.org" ]
|
||||||
|
ca = "/etc/osbuild-composer/ca-crt.pem"
|
||||||
|
|
||||||
|
[worker]
|
||||||
|
allowed_domains = [ "localhost", "worker.osbuild.org" ]
|
||||||
|
ca = "/etc/osbuild-composer/ca-crt.pem"
|
||||||
|
pg_host = "localhost"
|
||||||
|
pg_port = "5432"
|
||||||
|
pg_database = "osbuildcomposer"
|
||||||
|
pg_user = "postgres"
|
||||||
|
pg_password = "foobar"
|
||||||
|
pg_ssl_mode = "disable"
|
||||||
|
enable_jwt = true
|
||||||
|
jwt_keys_url = "https://localhost:8080/certs"
|
||||||
|
jwt_ca_file = "/etc/osbuild-composer/ca-crt.pem"
|
||||||
|
[composer_api]
|
||||||
|
enable_jwt = true
|
||||||
|
jwt_keys_url = "https://localhost:8080/certs"
|
||||||
|
jwt_ca_file = "/etc/osbuild-composer/ca-crt.pem"
|
||||||
|
jwt_acl_file = ""
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat <<EOF | sudo tee "/etc/osbuild-worker/token"
|
||||||
|
offlineToken
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat <<EOF | sudo tee "/etc/osbuild-worker/osbuild-worker.toml"
|
||||||
|
[authentication]
|
||||||
|
oauth_url = http://localhost:8081/token
|
||||||
|
offline_token = "/etc/osbuild-worker/token"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Spin up an https instance for the composer-api and worker-api; the auth handler needs to hit an ssl `/certs` endpoint
|
||||||
|
sudo /usr/libexec/osbuild-composer-test/osbuild-mock-openid-provider -rsaPubPem /etc/osbuild-composer/client-crt.pem -rsaPem /etc/osbuild-composer/client-key.pem -cert /etc/osbuild-composer/composer-crt.pem -key /etc/osbuild-composer/composer-key.pem &
|
||||||
|
KILL_PIDS+=("$!")
|
||||||
|
# Spin up an http instance for the worker client to bypass the need to specify an extra CA
|
||||||
|
sudo /usr/libexec/osbuild-composer-test/osbuild-mock-openid-provider -a localhost:8081 -rsaPubPem /etc/osbuild-composer/client-crt.pem -rsaPem /etc/osbuild-composer/client-key.pem &
|
||||||
|
KILL_PIDS+=("$!")
|
||||||
|
|
||||||
|
sudo systemctl restart osbuild-composer
|
||||||
|
|
||||||
|
until curl --output /dev/null --silent --fail localhost:8081/token; do
|
||||||
|
sleep 0.5
|
||||||
|
done
|
||||||
|
TOKEN="$(curl localhost:8081/token | jq -r .access_token)"
|
||||||
|
|
||||||
|
[ "$(curl \
|
||||||
|
--silent \
|
||||||
|
--cacert /etc/osbuild-composer/ca-crt.pem \
|
||||||
|
--output /dev/null \
|
||||||
|
--write-out '%{http_code}' \
|
||||||
|
--header "Authorization: Bearer $TOKEN" \
|
||||||
|
https://localhost/api/composer/v1/version)" = "200" ]
|
||||||
|
|
||||||
|
[ "$(curl \
|
||||||
|
--silent \
|
||||||
|
--cacert /etc/osbuild-composer/ca-crt.pem \
|
||||||
|
--output /dev/null \
|
||||||
|
--write-out '%{http_code}' \
|
||||||
|
--header "Authorization: Bearer badtoken" \
|
||||||
|
https://localhost/api/composer/v1/version)" = "401" ]
|
||||||
|
|
||||||
|
sudo systemctl start osbuild-remote-worker@https:--localhost:8700.service
|
||||||
|
sudo systemctl is-active --quiet osbuild-remote-worker@https:--localhost:8700.service
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
||||||
22
vendor/github.com/cenkalti/backoff/v4/.gitignore
generated
vendored
Normal file
22
vendor/github.com/cenkalti/backoff/v4/.gitignore
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||||
|
*.o
|
||||||
|
*.a
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Folders
|
||||||
|
_obj
|
||||||
|
_test
|
||||||
|
|
||||||
|
# Architecture specific extensions/prefixes
|
||||||
|
*.[568vq]
|
||||||
|
[568vq].out
|
||||||
|
|
||||||
|
*.cgo1.go
|
||||||
|
*.cgo2.c
|
||||||
|
_cgo_defun.c
|
||||||
|
_cgo_gotypes.go
|
||||||
|
_cgo_export.*
|
||||||
|
|
||||||
|
_testmain.go
|
||||||
|
|
||||||
|
*.exe
|
||||||
10
vendor/github.com/cenkalti/backoff/v4/.travis.yml
generated
vendored
Normal file
10
vendor/github.com/cenkalti/backoff/v4/.travis.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
language: go
|
||||||
|
go:
|
||||||
|
- 1.12
|
||||||
|
- 1.x
|
||||||
|
- tip
|
||||||
|
before_install:
|
||||||
|
- go get github.com/mattn/goveralls
|
||||||
|
- go get golang.org/x/tools/cmd/cover
|
||||||
|
script:
|
||||||
|
- $HOME/gopath/bin/goveralls -service=travis-ci
|
||||||
20
vendor/github.com/cenkalti/backoff/v4/LICENSE
generated
vendored
Normal file
20
vendor/github.com/cenkalti/backoff/v4/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Cenk Altı
|
||||||
|
|
||||||
|
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.
|
||||||
33
vendor/github.com/cenkalti/backoff/v4/README.md
generated
vendored
Normal file
33
vendor/github.com/cenkalti/backoff/v4/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
# Exponential Backoff [![GoDoc][godoc image]][godoc] [![Build Status][travis image]][travis] [![Coverage Status][coveralls image]][coveralls]
|
||||||
|
|
||||||
|
This is a Go port of the exponential backoff algorithm from [Google's HTTP Client Library for Java][google-http-java-client].
|
||||||
|
|
||||||
|
[Exponential backoff][exponential backoff wiki]
|
||||||
|
is an algorithm that uses feedback to multiplicatively decrease the rate of some process,
|
||||||
|
in order to gradually find an acceptable rate.
|
||||||
|
The retries exponentially increase and stop increasing when a certain threshold is met.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Import path is `github.com/cenkalti/backoff/v4`. Please note the version part at the end.
|
||||||
|
|
||||||
|
godoc.org does not support modules yet,
|
||||||
|
so you can use https://godoc.org/gopkg.in/cenkalti/backoff.v4 to view the documentation.
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
* I would like to keep this library as small as possible.
|
||||||
|
* Please don't send a PR without opening an issue and discussing it first.
|
||||||
|
* If proposed change is not a common use case, I will probably not accept it.
|
||||||
|
|
||||||
|
[godoc]: https://godoc.org/github.com/cenkalti/backoff
|
||||||
|
[godoc image]: https://godoc.org/github.com/cenkalti/backoff?status.png
|
||||||
|
[travis]: https://travis-ci.org/cenkalti/backoff
|
||||||
|
[travis image]: https://travis-ci.org/cenkalti/backoff.png?branch=master
|
||||||
|
[coveralls]: https://coveralls.io/github/cenkalti/backoff?branch=master
|
||||||
|
[coveralls image]: https://coveralls.io/repos/github/cenkalti/backoff/badge.svg?branch=master
|
||||||
|
|
||||||
|
[google-http-java-client]: https://github.com/google/google-http-java-client/blob/da1aa993e90285ec18579f1553339b00e19b3ab5/google-http-client/src/main/java/com/google/api/client/util/ExponentialBackOff.java
|
||||||
|
[exponential backoff wiki]: http://en.wikipedia.org/wiki/Exponential_backoff
|
||||||
|
|
||||||
|
[advanced example]: https://godoc.org/github.com/cenkalti/backoff#example_
|
||||||
66
vendor/github.com/cenkalti/backoff/v4/backoff.go
generated
vendored
Normal file
66
vendor/github.com/cenkalti/backoff/v4/backoff.go
generated
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
// Package backoff implements backoff algorithms for retrying operations.
|
||||||
|
//
|
||||||
|
// Use Retry function for retrying operations that may fail.
|
||||||
|
// If Retry does not meet your needs,
|
||||||
|
// copy/paste the function into your project and modify as you wish.
|
||||||
|
//
|
||||||
|
// There is also Ticker type similar to time.Ticker.
|
||||||
|
// You can use it if you need to work with channels.
|
||||||
|
//
|
||||||
|
// See Examples section below for usage examples.
|
||||||
|
package backoff
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// BackOff is a backoff policy for retrying an operation.
|
||||||
|
type BackOff interface {
|
||||||
|
// NextBackOff returns the duration to wait before retrying the operation,
|
||||||
|
// or backoff. Stop to indicate that no more retries should be made.
|
||||||
|
//
|
||||||
|
// Example usage:
|
||||||
|
//
|
||||||
|
// duration := backoff.NextBackOff();
|
||||||
|
// if (duration == backoff.Stop) {
|
||||||
|
// // Do not retry operation.
|
||||||
|
// } else {
|
||||||
|
// // Sleep for duration and retry operation.
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
NextBackOff() time.Duration
|
||||||
|
|
||||||
|
// Reset to initial state.
|
||||||
|
Reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop indicates that no more retries should be made for use in NextBackOff().
|
||||||
|
const Stop time.Duration = -1
|
||||||
|
|
||||||
|
// ZeroBackOff is a fixed backoff policy whose backoff time is always zero,
|
||||||
|
// meaning that the operation is retried immediately without waiting, indefinitely.
|
||||||
|
type ZeroBackOff struct{}
|
||||||
|
|
||||||
|
func (b *ZeroBackOff) Reset() {}
|
||||||
|
|
||||||
|
func (b *ZeroBackOff) NextBackOff() time.Duration { return 0 }
|
||||||
|
|
||||||
|
// StopBackOff is a fixed backoff policy that always returns backoff.Stop for
|
||||||
|
// NextBackOff(), meaning that the operation should never be retried.
|
||||||
|
type StopBackOff struct{}
|
||||||
|
|
||||||
|
func (b *StopBackOff) Reset() {}
|
||||||
|
|
||||||
|
func (b *StopBackOff) NextBackOff() time.Duration { return Stop }
|
||||||
|
|
||||||
|
// ConstantBackOff is a backoff policy that always returns the same backoff delay.
|
||||||
|
// This is in contrast to an exponential backoff policy,
|
||||||
|
// which returns a delay that grows longer as you call NextBackOff() over and over again.
|
||||||
|
type ConstantBackOff struct {
|
||||||
|
Interval time.Duration
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *ConstantBackOff) Reset() {}
|
||||||
|
func (b *ConstantBackOff) NextBackOff() time.Duration { return b.Interval }
|
||||||
|
|
||||||
|
func NewConstantBackOff(d time.Duration) *ConstantBackOff {
|
||||||
|
return &ConstantBackOff{Interval: d}
|
||||||
|
}
|
||||||
66
vendor/github.com/cenkalti/backoff/v4/context.go
generated
vendored
Normal file
66
vendor/github.com/cenkalti/backoff/v4/context.go
generated
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
package backoff
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BackOffContext is a backoff policy that stops retrying after the context
|
||||||
|
// is canceled.
|
||||||
|
type BackOffContext interface { // nolint: golint
|
||||||
|
BackOff
|
||||||
|
Context() context.Context
|
||||||
|
}
|
||||||
|
|
||||||
|
type backOffContext struct {
|
||||||
|
BackOff
|
||||||
|
ctx context.Context
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithContext returns a BackOffContext with context ctx
|
||||||
|
//
|
||||||
|
// ctx must not be nil
|
||||||
|
func WithContext(b BackOff, ctx context.Context) BackOffContext { // nolint: golint
|
||||||
|
if ctx == nil {
|
||||||
|
panic("nil context")
|
||||||
|
}
|
||||||
|
|
||||||
|
if b, ok := b.(*backOffContext); ok {
|
||||||
|
return &backOffContext{
|
||||||
|
BackOff: b.BackOff,
|
||||||
|
ctx: ctx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return &backOffContext{
|
||||||
|
BackOff: b,
|
||||||
|
ctx: ctx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getContext(b BackOff) context.Context {
|
||||||
|
if cb, ok := b.(BackOffContext); ok {
|
||||||
|
return cb.Context()
|
||||||
|
}
|
||||||
|
if tb, ok := b.(*backOffTries); ok {
|
||||||
|
return getContext(tb.delegate)
|
||||||
|
}
|
||||||
|
return context.Background()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *backOffContext) Context() context.Context {
|
||||||
|
return b.ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *backOffContext) NextBackOff() time.Duration {
|
||||||
|
select {
|
||||||
|
case <-b.ctx.Done():
|
||||||
|
return Stop
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
next := b.BackOff.NextBackOff()
|
||||||
|
if deadline, ok := b.ctx.Deadline(); ok && deadline.Sub(time.Now()) < next { // nolint: gosimple
|
||||||
|
return Stop
|
||||||
|
}
|
||||||
|
return next
|
||||||
|
}
|
||||||
156
vendor/github.com/cenkalti/backoff/v4/exponential.go
generated
vendored
Normal file
156
vendor/github.com/cenkalti/backoff/v4/exponential.go
generated
vendored
Normal file
|
|
@ -0,0 +1,156 @@
|
||||||
|
package backoff
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math/rand"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
ExponentialBackOff is a backoff implementation that increases the backoff
|
||||||
|
period for each retry attempt using a randomization function that grows exponentially.
|
||||||
|
|
||||||
|
NextBackOff() is calculated using the following formula:
|
||||||
|
|
||||||
|
randomized interval =
|
||||||
|
RetryInterval * (random value in range [1 - RandomizationFactor, 1 + RandomizationFactor])
|
||||||
|
|
||||||
|
In other words NextBackOff() will range between the randomization factor
|
||||||
|
percentage below and above the retry interval.
|
||||||
|
|
||||||
|
For example, given the following parameters:
|
||||||
|
|
||||||
|
RetryInterval = 2
|
||||||
|
RandomizationFactor = 0.5
|
||||||
|
Multiplier = 2
|
||||||
|
|
||||||
|
the actual backoff period used in the next retry attempt will range between 1 and 3 seconds,
|
||||||
|
multiplied by the exponential, that is, between 2 and 6 seconds.
|
||||||
|
|
||||||
|
Note: MaxInterval caps the RetryInterval and not the randomized interval.
|
||||||
|
|
||||||
|
If the time elapsed since an ExponentialBackOff instance is created goes past the
|
||||||
|
MaxElapsedTime, then the method NextBackOff() starts returning backoff.Stop.
|
||||||
|
|
||||||
|
The elapsed time can be reset by calling Reset().
|
||||||
|
|
||||||
|
Example: Given the following default arguments, for 10 tries the sequence will be,
|
||||||
|
and assuming we go over the MaxElapsedTime on the 10th try:
|
||||||
|
|
||||||
|
Request # RetryInterval (seconds) Randomized Interval (seconds)
|
||||||
|
|
||||||
|
1 0.5 [0.25, 0.75]
|
||||||
|
2 0.75 [0.375, 1.125]
|
||||||
|
3 1.125 [0.562, 1.687]
|
||||||
|
4 1.687 [0.8435, 2.53]
|
||||||
|
5 2.53 [1.265, 3.795]
|
||||||
|
6 3.795 [1.897, 5.692]
|
||||||
|
7 5.692 [2.846, 8.538]
|
||||||
|
8 8.538 [4.269, 12.807]
|
||||||
|
9 12.807 [6.403, 19.210]
|
||||||
|
10 19.210 backoff.Stop
|
||||||
|
|
||||||
|
Note: Implementation is not thread-safe.
|
||||||
|
*/
|
||||||
|
type ExponentialBackOff struct {
|
||||||
|
InitialInterval time.Duration
|
||||||
|
RandomizationFactor float64
|
||||||
|
Multiplier float64
|
||||||
|
MaxInterval time.Duration
|
||||||
|
// After MaxElapsedTime the ExponentialBackOff returns Stop.
|
||||||
|
// It never stops if MaxElapsedTime == 0.
|
||||||
|
MaxElapsedTime time.Duration
|
||||||
|
Stop time.Duration
|
||||||
|
Clock Clock
|
||||||
|
|
||||||
|
currentInterval time.Duration
|
||||||
|
startTime time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clock is an interface that returns current time for BackOff.
|
||||||
|
type Clock interface {
|
||||||
|
Now() time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default values for ExponentialBackOff.
|
||||||
|
const (
|
||||||
|
DefaultInitialInterval = 500 * time.Millisecond
|
||||||
|
DefaultRandomizationFactor = 0.5
|
||||||
|
DefaultMultiplier = 1.5
|
||||||
|
DefaultMaxInterval = 60 * time.Second
|
||||||
|
DefaultMaxElapsedTime = 15 * time.Minute
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewExponentialBackOff creates an instance of ExponentialBackOff using default values.
|
||||||
|
func NewExponentialBackOff() *ExponentialBackOff {
|
||||||
|
b := &ExponentialBackOff{
|
||||||
|
InitialInterval: DefaultInitialInterval,
|
||||||
|
RandomizationFactor: DefaultRandomizationFactor,
|
||||||
|
Multiplier: DefaultMultiplier,
|
||||||
|
MaxInterval: DefaultMaxInterval,
|
||||||
|
MaxElapsedTime: DefaultMaxElapsedTime,
|
||||||
|
Stop: Stop,
|
||||||
|
Clock: SystemClock,
|
||||||
|
}
|
||||||
|
b.Reset()
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
type systemClock struct{}
|
||||||
|
|
||||||
|
func (t systemClock) Now() time.Time {
|
||||||
|
return time.Now()
|
||||||
|
}
|
||||||
|
|
||||||
|
// SystemClock implements Clock interface that uses time.Now().
|
||||||
|
var SystemClock = systemClock{}
|
||||||
|
|
||||||
|
// Reset the interval back to the initial retry interval and restarts the timer.
|
||||||
|
// Reset must be called before using b.
|
||||||
|
func (b *ExponentialBackOff) Reset() {
|
||||||
|
b.currentInterval = b.InitialInterval
|
||||||
|
b.startTime = b.Clock.Now()
|
||||||
|
}
|
||||||
|
|
||||||
|
// NextBackOff calculates the next backoff interval using the formula:
|
||||||
|
// Randomized interval = RetryInterval * (1 ± RandomizationFactor)
|
||||||
|
func (b *ExponentialBackOff) NextBackOff() time.Duration {
|
||||||
|
// Make sure we have not gone over the maximum elapsed time.
|
||||||
|
if b.MaxElapsedTime != 0 && b.GetElapsedTime() > b.MaxElapsedTime {
|
||||||
|
return b.Stop
|
||||||
|
}
|
||||||
|
defer b.incrementCurrentInterval()
|
||||||
|
return getRandomValueFromInterval(b.RandomizationFactor, rand.Float64(), b.currentInterval)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetElapsedTime returns the elapsed time since an ExponentialBackOff instance
|
||||||
|
// is created and is reset when Reset() is called.
|
||||||
|
//
|
||||||
|
// The elapsed time is computed using time.Now().UnixNano(). It is
|
||||||
|
// safe to call even while the backoff policy is used by a running
|
||||||
|
// ticker.
|
||||||
|
func (b *ExponentialBackOff) GetElapsedTime() time.Duration {
|
||||||
|
return b.Clock.Now().Sub(b.startTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Increments the current interval by multiplying it with the multiplier.
|
||||||
|
func (b *ExponentialBackOff) incrementCurrentInterval() {
|
||||||
|
// Check for overflow, if overflow is detected set the current interval to the max interval.
|
||||||
|
if float64(b.currentInterval) >= float64(b.MaxInterval)/b.Multiplier {
|
||||||
|
b.currentInterval = b.MaxInterval
|
||||||
|
} else {
|
||||||
|
b.currentInterval = time.Duration(float64(b.currentInterval) * b.Multiplier)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a random value from the following interval:
|
||||||
|
// [randomizationFactor * currentInterval, randomizationFactor * currentInterval].
|
||||||
|
func getRandomValueFromInterval(randomizationFactor, random float64, currentInterval time.Duration) time.Duration {
|
||||||
|
var delta = randomizationFactor * float64(currentInterval)
|
||||||
|
var minInterval = float64(currentInterval) - delta
|
||||||
|
var maxInterval = float64(currentInterval) + delta
|
||||||
|
|
||||||
|
// Get a random value from the range [minInterval, maxInterval].
|
||||||
|
// The formula used below has a +1 because if the minInterval is 1 and the maxInterval is 3 then
|
||||||
|
// we want a 33% chance for selecting either 1, 2 or 3.
|
||||||
|
return time.Duration(minInterval + (random * (maxInterval - minInterval + 1)))
|
||||||
|
}
|
||||||
3
vendor/github.com/cenkalti/backoff/v4/go.mod
generated
vendored
Normal file
3
vendor/github.com/cenkalti/backoff/v4/go.mod
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
module github.com/cenkalti/backoff/v4
|
||||||
|
|
||||||
|
go 1.12
|
||||||
96
vendor/github.com/cenkalti/backoff/v4/retry.go
generated
vendored
Normal file
96
vendor/github.com/cenkalti/backoff/v4/retry.go
generated
vendored
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
package backoff
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// An Operation is executing by Retry() or RetryNotify().
|
||||||
|
// The operation will be retried using a backoff policy if it returns an error.
|
||||||
|
type Operation func() error
|
||||||
|
|
||||||
|
// Notify is a notify-on-error function. It receives an operation error and
|
||||||
|
// backoff delay if the operation failed (with an error).
|
||||||
|
//
|
||||||
|
// NOTE that if the backoff policy stated to stop retrying,
|
||||||
|
// the notify function isn't called.
|
||||||
|
type Notify func(error, time.Duration)
|
||||||
|
|
||||||
|
// Retry the operation o until it does not return error or BackOff stops.
|
||||||
|
// o is guaranteed to be run at least once.
|
||||||
|
//
|
||||||
|
// If o returns a *PermanentError, the operation is not retried, and the
|
||||||
|
// wrapped error is returned.
|
||||||
|
//
|
||||||
|
// Retry sleeps the goroutine for the duration returned by BackOff after a
|
||||||
|
// failed operation returns.
|
||||||
|
func Retry(o Operation, b BackOff) error {
|
||||||
|
return RetryNotify(o, b, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RetryNotify calls notify function with the error and wait duration
|
||||||
|
// for each failed attempt before sleep.
|
||||||
|
func RetryNotify(operation Operation, b BackOff, notify Notify) error {
|
||||||
|
return RetryNotifyWithTimer(operation, b, notify, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RetryNotifyWithTimer calls notify function with the error and wait duration using the given Timer
|
||||||
|
// for each failed attempt before sleep.
|
||||||
|
// A default timer that uses system timer is used when nil is passed.
|
||||||
|
func RetryNotifyWithTimer(operation Operation, b BackOff, notify Notify, t Timer) error {
|
||||||
|
var err error
|
||||||
|
var next time.Duration
|
||||||
|
if t == nil {
|
||||||
|
t = &defaultTimer{}
|
||||||
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
t.Stop()
|
||||||
|
}()
|
||||||
|
|
||||||
|
ctx := getContext(b)
|
||||||
|
|
||||||
|
b.Reset()
|
||||||
|
for {
|
||||||
|
if err = operation(); err == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if permanent, ok := err.(*PermanentError); ok {
|
||||||
|
return permanent.Err
|
||||||
|
}
|
||||||
|
|
||||||
|
if next = b.NextBackOff(); next == Stop {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if notify != nil {
|
||||||
|
notify(err, next)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Start(next)
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return ctx.Err()
|
||||||
|
case <-t.C():
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PermanentError signals that the operation should not be retried.
|
||||||
|
type PermanentError struct {
|
||||||
|
Err error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *PermanentError) Error() string {
|
||||||
|
return e.Err.Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *PermanentError) Unwrap() error {
|
||||||
|
return e.Err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Permanent wraps the given err in a *PermanentError.
|
||||||
|
func Permanent(err error) *PermanentError {
|
||||||
|
return &PermanentError{
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
|
}
|
||||||
94
vendor/github.com/cenkalti/backoff/v4/ticker.go
generated
vendored
Normal file
94
vendor/github.com/cenkalti/backoff/v4/ticker.go
generated
vendored
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
package backoff
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Ticker holds a channel that delivers `ticks' of a clock at times reported by a BackOff.
|
||||||
|
//
|
||||||
|
// Ticks will continue to arrive when the previous operation is still running,
|
||||||
|
// so operations that take a while to fail could run in quick succession.
|
||||||
|
type Ticker struct {
|
||||||
|
C <-chan time.Time
|
||||||
|
c chan time.Time
|
||||||
|
b BackOff
|
||||||
|
ctx context.Context
|
||||||
|
timer Timer
|
||||||
|
stop chan struct{}
|
||||||
|
stopOnce sync.Once
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewTicker returns a new Ticker containing a channel that will send
|
||||||
|
// the time at times specified by the BackOff argument. Ticker is
|
||||||
|
// guaranteed to tick at least once. The channel is closed when Stop
|
||||||
|
// method is called or BackOff stops. It is not safe to manipulate the
|
||||||
|
// provided backoff policy (notably calling NextBackOff or Reset)
|
||||||
|
// while the ticker is running.
|
||||||
|
func NewTicker(b BackOff) *Ticker {
|
||||||
|
return NewTickerWithTimer(b, &defaultTimer{})
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewTickerWithTimer returns a new Ticker with a custom timer.
|
||||||
|
// A default timer that uses system timer is used when nil is passed.
|
||||||
|
func NewTickerWithTimer(b BackOff, timer Timer) *Ticker {
|
||||||
|
c := make(chan time.Time)
|
||||||
|
t := &Ticker{
|
||||||
|
C: c,
|
||||||
|
c: c,
|
||||||
|
b: b,
|
||||||
|
ctx: getContext(b),
|
||||||
|
timer: timer,
|
||||||
|
stop: make(chan struct{}),
|
||||||
|
}
|
||||||
|
t.b.Reset()
|
||||||
|
go t.run()
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop turns off a ticker. After Stop, no more ticks will be sent.
|
||||||
|
func (t *Ticker) Stop() {
|
||||||
|
t.stopOnce.Do(func() { close(t.stop) })
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Ticker) run() {
|
||||||
|
c := t.c
|
||||||
|
defer close(c)
|
||||||
|
|
||||||
|
// Ticker is guaranteed to tick at least once.
|
||||||
|
afterC := t.send(time.Now())
|
||||||
|
|
||||||
|
for {
|
||||||
|
if afterC == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
case tick := <-afterC:
|
||||||
|
afterC = t.send(tick)
|
||||||
|
case <-t.stop:
|
||||||
|
t.c = nil // Prevent future ticks from being sent to the channel.
|
||||||
|
return
|
||||||
|
case <-t.ctx.Done():
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Ticker) send(tick time.Time) <-chan time.Time {
|
||||||
|
select {
|
||||||
|
case t.c <- tick:
|
||||||
|
case <-t.stop:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
next := t.b.NextBackOff()
|
||||||
|
if next == Stop {
|
||||||
|
t.Stop()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
t.timer.Start(next)
|
||||||
|
return t.timer.C()
|
||||||
|
}
|
||||||
35
vendor/github.com/cenkalti/backoff/v4/timer.go
generated
vendored
Normal file
35
vendor/github.com/cenkalti/backoff/v4/timer.go
generated
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
package backoff
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
type Timer interface {
|
||||||
|
Start(duration time.Duration)
|
||||||
|
Stop()
|
||||||
|
C() <-chan time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaultTimer implements Timer interface using time.Timer
|
||||||
|
type defaultTimer struct {
|
||||||
|
timer *time.Timer
|
||||||
|
}
|
||||||
|
|
||||||
|
// C returns the timers channel which receives the current time when the timer fires.
|
||||||
|
func (t *defaultTimer) C() <-chan time.Time {
|
||||||
|
return t.timer.C
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start starts the timer to fire after the given duration
|
||||||
|
func (t *defaultTimer) Start(duration time.Duration) {
|
||||||
|
if t.timer == nil {
|
||||||
|
t.timer = time.NewTimer(duration)
|
||||||
|
} else {
|
||||||
|
t.timer.Reset(duration)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop is called when the timer is not used anymore and resources may be freed.
|
||||||
|
func (t *defaultTimer) Stop() {
|
||||||
|
if t.timer != nil {
|
||||||
|
t.timer.Stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
38
vendor/github.com/cenkalti/backoff/v4/tries.go
generated
vendored
Normal file
38
vendor/github.com/cenkalti/backoff/v4/tries.go
generated
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
package backoff
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
/*
|
||||||
|
WithMaxRetries creates a wrapper around another BackOff, which will
|
||||||
|
return Stop if NextBackOff() has been called too many times since
|
||||||
|
the last time Reset() was called
|
||||||
|
|
||||||
|
Note: Implementation is not thread-safe.
|
||||||
|
*/
|
||||||
|
func WithMaxRetries(b BackOff, max uint64) BackOff {
|
||||||
|
return &backOffTries{delegate: b, maxTries: max}
|
||||||
|
}
|
||||||
|
|
||||||
|
type backOffTries struct {
|
||||||
|
delegate BackOff
|
||||||
|
maxTries uint64
|
||||||
|
numTries uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *backOffTries) NextBackOff() time.Duration {
|
||||||
|
if b.maxTries == 0 {
|
||||||
|
return Stop
|
||||||
|
}
|
||||||
|
if b.maxTries > 0 {
|
||||||
|
if b.maxTries <= b.numTries {
|
||||||
|
return Stop
|
||||||
|
}
|
||||||
|
b.numTries++
|
||||||
|
}
|
||||||
|
return b.delegate.NextBackOff()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *backOffTries) Reset() {
|
||||||
|
b.numTries = 0
|
||||||
|
b.delegate.Reset()
|
||||||
|
}
|
||||||
4
vendor/github.com/golang-jwt/jwt/.gitignore
generated
vendored
Normal file
4
vendor/github.com/golang-jwt/jwt/.gitignore
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
.DS_Store
|
||||||
|
bin
|
||||||
|
|
||||||
|
|
||||||
13
vendor/github.com/golang-jwt/jwt/.travis.yml
generated
vendored
Normal file
13
vendor/github.com/golang-jwt/jwt/.travis.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
language: go
|
||||||
|
|
||||||
|
script:
|
||||||
|
- go vet ./...
|
||||||
|
- go test -v ./...
|
||||||
|
|
||||||
|
go:
|
||||||
|
- 1.3
|
||||||
|
- 1.4
|
||||||
|
- 1.5
|
||||||
|
- 1.6
|
||||||
|
- 1.7
|
||||||
|
- tip
|
||||||
8
vendor/github.com/golang-jwt/jwt/LICENSE
generated
vendored
Normal file
8
vendor/github.com/golang-jwt/jwt/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
Copyright (c) 2012 Dave Grijalva
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
97
vendor/github.com/golang-jwt/jwt/MIGRATION_GUIDE.md
generated
vendored
Normal file
97
vendor/github.com/golang-jwt/jwt/MIGRATION_GUIDE.md
generated
vendored
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
## Migration Guide from v2 -> v3
|
||||||
|
|
||||||
|
Version 3 adds several new, frequently requested features. To do so, it introduces a few breaking changes. We've worked to keep these as minimal as possible. This guide explains the breaking changes and how you can quickly update your code.
|
||||||
|
|
||||||
|
### `Token.Claims` is now an interface type
|
||||||
|
|
||||||
|
The most requested feature from the 2.0 verison of this library was the ability to provide a custom type to the JSON parser for claims. This was implemented by introducing a new interface, `Claims`, to replace `map[string]interface{}`. We also included two concrete implementations of `Claims`: `MapClaims` and `StandardClaims`.
|
||||||
|
|
||||||
|
`MapClaims` is an alias for `map[string]interface{}` with built in validation behavior. It is the default claims type when using `Parse`. The usage is unchanged except you must type cast the claims property.
|
||||||
|
|
||||||
|
The old example for parsing a token looked like this..
|
||||||
|
|
||||||
|
```go
|
||||||
|
if token, err := jwt.Parse(tokenString, keyLookupFunc); err == nil {
|
||||||
|
fmt.Printf("Token for user %v expires %v", token.Claims["user"], token.Claims["exp"])
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
is now directly mapped to...
|
||||||
|
|
||||||
|
```go
|
||||||
|
if token, err := jwt.Parse(tokenString, keyLookupFunc); err == nil {
|
||||||
|
claims := token.Claims.(jwt.MapClaims)
|
||||||
|
fmt.Printf("Token for user %v expires %v", claims["user"], claims["exp"])
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
`StandardClaims` is designed to be embedded in your custom type. You can supply a custom claims type with the new `ParseWithClaims` function. Here's an example of using a custom claims type.
|
||||||
|
|
||||||
|
```go
|
||||||
|
type MyCustomClaims struct {
|
||||||
|
User string
|
||||||
|
*StandardClaims
|
||||||
|
}
|
||||||
|
|
||||||
|
if token, err := jwt.ParseWithClaims(tokenString, &MyCustomClaims{}, keyLookupFunc); err == nil {
|
||||||
|
claims := token.Claims.(*MyCustomClaims)
|
||||||
|
fmt.Printf("Token for user %v expires %v", claims.User, claims.StandardClaims.ExpiresAt)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `ParseFromRequest` has been moved
|
||||||
|
|
||||||
|
To keep this library focused on the tokens without becoming overburdened with complex request processing logic, `ParseFromRequest` and its new companion `ParseFromRequestWithClaims` have been moved to a subpackage, `request`. The method signatues have also been augmented to receive a new argument: `Extractor`.
|
||||||
|
|
||||||
|
`Extractors` do the work of picking the token string out of a request. The interface is simple and composable.
|
||||||
|
|
||||||
|
This simple parsing example:
|
||||||
|
|
||||||
|
```go
|
||||||
|
if token, err := jwt.ParseFromRequest(tokenString, req, keyLookupFunc); err == nil {
|
||||||
|
fmt.Printf("Token for user %v expires %v", token.Claims["user"], token.Claims["exp"])
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
is directly mapped to:
|
||||||
|
|
||||||
|
```go
|
||||||
|
if token, err := request.ParseFromRequest(req, request.OAuth2Extractor, keyLookupFunc); err == nil {
|
||||||
|
claims := token.Claims.(jwt.MapClaims)
|
||||||
|
fmt.Printf("Token for user %v expires %v", claims["user"], claims["exp"])
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
There are several concrete `Extractor` types provided for your convenience:
|
||||||
|
|
||||||
|
* `HeaderExtractor` will search a list of headers until one contains content.
|
||||||
|
* `ArgumentExtractor` will search a list of keys in request query and form arguments until one contains content.
|
||||||
|
* `MultiExtractor` will try a list of `Extractors` in order until one returns content.
|
||||||
|
* `AuthorizationHeaderExtractor` will look in the `Authorization` header for a `Bearer` token.
|
||||||
|
* `OAuth2Extractor` searches the places an OAuth2 token would be specified (per the spec): `Authorization` header and `access_token` argument
|
||||||
|
* `PostExtractionFilter` wraps an `Extractor`, allowing you to process the content before it's parsed. A simple example is stripping the `Bearer ` text from a header
|
||||||
|
|
||||||
|
|
||||||
|
### RSA signing methods no longer accept `[]byte` keys
|
||||||
|
|
||||||
|
Due to a [critical vulnerability](https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/), we've decided the convenience of accepting `[]byte` instead of `rsa.PublicKey` or `rsa.PrivateKey` isn't worth the risk of misuse.
|
||||||
|
|
||||||
|
To replace this behavior, we've added two helper methods: `ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)` and `ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error)`. These are just simple helpers for unpacking PEM encoded PKCS1 and PKCS8 keys. If your keys are encoded any other way, all you need to do is convert them to the `crypto/rsa` package's types.
|
||||||
|
|
||||||
|
```go
|
||||||
|
func keyLookupFunc(*Token) (interface{}, error) {
|
||||||
|
// Don't forget to validate the alg is what you expect:
|
||||||
|
if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok {
|
||||||
|
return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"])
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look up key
|
||||||
|
key, err := lookupPublicKey(token.Header["kid"])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unpack key from PEM encoded PKCS8
|
||||||
|
return jwt.ParseRSAPublicKeyFromPEM(key)
|
||||||
|
}
|
||||||
|
```
|
||||||
100
vendor/github.com/golang-jwt/jwt/README.md
generated
vendored
Normal file
100
vendor/github.com/golang-jwt/jwt/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,100 @@
|
||||||
|
# jwt-go
|
||||||
|
|
||||||
|
[](https://travis-ci.org/dgrijalva/jwt-go)
|
||||||
|
[](https://godoc.org/github.com/dgrijalva/jwt-go)
|
||||||
|
|
||||||
|
A [go](http://www.golang.org) (or 'golang' for search engine friendliness) implementation of [JSON Web Tokens](http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html)
|
||||||
|
|
||||||
|
**NEW VERSION COMING:** There have been a lot of improvements suggested since the version 3.0.0 released in 2016. I'm working now on cutting two different releases: 3.2.0 will contain any non-breaking changes or enhancements. 4.0.0 will follow shortly which will include breaking changes. See the 4.0.0 milestone to get an idea of what's coming. If you have other ideas, or would like to participate in 4.0.0, now's the time. If you depend on this library and don't want to be interrupted, I recommend you use your dependency mangement tool to pin to version 3.
|
||||||
|
|
||||||
|
**SECURITY NOTICE:** Some older versions of Go have a security issue in the cryotp/elliptic. Recommendation is to upgrade to at least 1.8.3. See issue #216 for more detail.
|
||||||
|
|
||||||
|
**SECURITY NOTICE:** It's important that you [validate the `alg` presented is what you expect](https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/). This library attempts to make it easy to do the right thing by requiring key types match the expected alg, but you should take the extra step to verify it in your usage. See the examples provided.
|
||||||
|
|
||||||
|
## What the heck is a JWT?
|
||||||
|
|
||||||
|
JWT.io has [a great introduction](https://jwt.io/introduction) to JSON Web Tokens.
|
||||||
|
|
||||||
|
In short, it's a signed JSON object that does something useful (for example, authentication). It's commonly used for `Bearer` tokens in Oauth 2. A token is made of three parts, separated by `.`'s. The first two parts are JSON objects, that have been [base64url](http://tools.ietf.org/html/rfc4648) encoded. The last part is the signature, encoded the same way.
|
||||||
|
|
||||||
|
The first part is called the header. It contains the necessary information for verifying the last part, the signature. For example, which encryption method was used for signing and what key was used.
|
||||||
|
|
||||||
|
The part in the middle is the interesting bit. It's called the Claims and contains the actual stuff you care about. Refer to [the RFC](http://self-issued.info/docs/draft-jones-json-web-token.html) for information about reserved keys and the proper way to add your own.
|
||||||
|
|
||||||
|
## What's in the box?
|
||||||
|
|
||||||
|
This library supports the parsing and verification as well as the generation and signing of JWTs. Current supported signing algorithms are HMAC SHA, RSA, RSA-PSS, and ECDSA, though hooks are present for adding your own.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
See [the project documentation](https://godoc.org/github.com/dgrijalva/jwt-go) for examples of usage:
|
||||||
|
|
||||||
|
* [Simple example of parsing and validating a token](https://godoc.org/github.com/dgrijalva/jwt-go#example-Parse--Hmac)
|
||||||
|
* [Simple example of building and signing a token](https://godoc.org/github.com/dgrijalva/jwt-go#example-New--Hmac)
|
||||||
|
* [Directory of Examples](https://godoc.org/github.com/dgrijalva/jwt-go#pkg-examples)
|
||||||
|
|
||||||
|
## Extensions
|
||||||
|
|
||||||
|
This library publishes all the necessary components for adding your own signing methods. Simply implement the `SigningMethod` interface and register a factory method using `RegisterSigningMethod`.
|
||||||
|
|
||||||
|
Here's an example of an extension that integrates with the Google App Engine signing tools: https://github.com/someone1/gcp-jwt-go
|
||||||
|
|
||||||
|
## Compliance
|
||||||
|
|
||||||
|
This library was last reviewed to comply with [RTF 7519](http://www.rfc-editor.org/info/rfc7519) dated May 2015 with a few notable differences:
|
||||||
|
|
||||||
|
* In order to protect against accidental use of [Unsecured JWTs](http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html#UnsecuredJWT), tokens using `alg=none` will only be accepted if the constant `jwt.UnsafeAllowNoneSignatureType` is provided as the key.
|
||||||
|
|
||||||
|
## Project Status & Versioning
|
||||||
|
|
||||||
|
This library is considered production ready. Feedback and feature requests are appreciated. The API should be considered stable. There should be very few backwards-incompatible changes outside of major version updates (and only with good reason).
|
||||||
|
|
||||||
|
This project uses [Semantic Versioning 2.0.0](http://semver.org). Accepted pull requests will land on `master`. Periodically, versions will be tagged from `master`. You can find all the releases on [the project releases page](https://github.com/dgrijalva/jwt-go/releases).
|
||||||
|
|
||||||
|
While we try to make it obvious when we make breaking changes, there isn't a great mechanism for pushing announcements out to users. You may want to use this alternative package include: `gopkg.in/dgrijalva/jwt-go.v3`. It will do the right thing WRT semantic versioning.
|
||||||
|
|
||||||
|
**BREAKING CHANGES:***
|
||||||
|
* Version 3.0.0 includes _a lot_ of changes from the 2.x line, including a few that break the API. We've tried to break as few things as possible, so there should just be a few type signature changes. A full list of breaking changes is available in `VERSION_HISTORY.md`. See `MIGRATION_GUIDE.md` for more information on updating your code.
|
||||||
|
|
||||||
|
## Usage Tips
|
||||||
|
|
||||||
|
### Signing vs Encryption
|
||||||
|
|
||||||
|
A token is simply a JSON object that is signed by its author. this tells you exactly two things about the data:
|
||||||
|
|
||||||
|
* The author of the token was in the possession of the signing secret
|
||||||
|
* The data has not been modified since it was signed
|
||||||
|
|
||||||
|
It's important to know that JWT does not provide encryption, which means anyone who has access to the token can read its contents. If you need to protect (encrypt) the data, there is a companion spec, `JWE`, that provides this functionality. JWE is currently outside the scope of this library.
|
||||||
|
|
||||||
|
### Choosing a Signing Method
|
||||||
|
|
||||||
|
There are several signing methods available, and you should probably take the time to learn about the various options before choosing one. The principal design decision is most likely going to be symmetric vs asymmetric.
|
||||||
|
|
||||||
|
Symmetric signing methods, such as HSA, use only a single secret. This is probably the simplest signing method to use since any `[]byte` can be used as a valid secret. They are also slightly computationally faster to use, though this rarely is enough to matter. Symmetric signing methods work the best when both producers and consumers of tokens are trusted, or even the same system. Since the same secret is used to both sign and validate tokens, you can't easily distribute the key for validation.
|
||||||
|
|
||||||
|
Asymmetric signing methods, such as RSA, use different keys for signing and verifying tokens. This makes it possible to produce tokens with a private key, and allow any consumer to access the public key for verification.
|
||||||
|
|
||||||
|
### Signing Methods and Key Types
|
||||||
|
|
||||||
|
Each signing method expects a different object type for its signing keys. See the package documentation for details. Here are the most common ones:
|
||||||
|
|
||||||
|
* The [HMAC signing method](https://godoc.org/github.com/dgrijalva/jwt-go#SigningMethodHMAC) (`HS256`,`HS384`,`HS512`) expect `[]byte` values for signing and validation
|
||||||
|
* The [RSA signing method](https://godoc.org/github.com/dgrijalva/jwt-go#SigningMethodRSA) (`RS256`,`RS384`,`RS512`) expect `*rsa.PrivateKey` for signing and `*rsa.PublicKey` for validation
|
||||||
|
* The [ECDSA signing method](https://godoc.org/github.com/dgrijalva/jwt-go#SigningMethodECDSA) (`ES256`,`ES384`,`ES512`) expect `*ecdsa.PrivateKey` for signing and `*ecdsa.PublicKey` for validation
|
||||||
|
|
||||||
|
### JWT and OAuth
|
||||||
|
|
||||||
|
It's worth mentioning that OAuth and JWT are not the same thing. A JWT token is simply a signed JSON object. It can be used anywhere such a thing is useful. There is some confusion, though, as JWT is the most common type of bearer token used in OAuth2 authentication.
|
||||||
|
|
||||||
|
Without going too far down the rabbit hole, here's a description of the interaction of these technologies:
|
||||||
|
|
||||||
|
* OAuth is a protocol for allowing an identity provider to be separate from the service a user is logging in to. For example, whenever you use Facebook to log into a different service (Yelp, Spotify, etc), you are using OAuth.
|
||||||
|
* OAuth defines several options for passing around authentication data. One popular method is called a "bearer token". A bearer token is simply a string that _should_ only be held by an authenticated user. Thus, simply presenting this token proves your identity. You can probably derive from here why a JWT might make a good bearer token.
|
||||||
|
* Because bearer tokens are used for authentication, it's important they're kept secret. This is why transactions that use bearer tokens typically happen over SSL.
|
||||||
|
|
||||||
|
## More
|
||||||
|
|
||||||
|
Documentation can be found [on godoc.org](http://godoc.org/github.com/dgrijalva/jwt-go).
|
||||||
|
|
||||||
|
The command line utility included in this project (cmd/jwt) provides a straightforward example of token creation and parsing as well as a useful tool for debugging your own integration. You'll also find several implementation examples in the documentation.
|
||||||
118
vendor/github.com/golang-jwt/jwt/VERSION_HISTORY.md
generated
vendored
Normal file
118
vendor/github.com/golang-jwt/jwt/VERSION_HISTORY.md
generated
vendored
Normal file
|
|
@ -0,0 +1,118 @@
|
||||||
|
## `jwt-go` Version History
|
||||||
|
|
||||||
|
#### 3.2.0
|
||||||
|
|
||||||
|
* Added method `ParseUnverified` to allow users to split up the tasks of parsing and validation
|
||||||
|
* HMAC signing method returns `ErrInvalidKeyType` instead of `ErrInvalidKey` where appropriate
|
||||||
|
* Added options to `request.ParseFromRequest`, which allows for an arbitrary list of modifiers to parsing behavior. Initial set include `WithClaims` and `WithParser`. Existing usage of this function will continue to work as before.
|
||||||
|
* Deprecated `ParseFromRequestWithClaims` to simplify API in the future.
|
||||||
|
|
||||||
|
#### 3.1.0
|
||||||
|
|
||||||
|
* Improvements to `jwt` command line tool
|
||||||
|
* Added `SkipClaimsValidation` option to `Parser`
|
||||||
|
* Documentation updates
|
||||||
|
|
||||||
|
#### 3.0.0
|
||||||
|
|
||||||
|
* **Compatibility Breaking Changes**: See MIGRATION_GUIDE.md for tips on updating your code
|
||||||
|
* Dropped support for `[]byte` keys when using RSA signing methods. This convenience feature could contribute to security vulnerabilities involving mismatched key types with signing methods.
|
||||||
|
* `ParseFromRequest` has been moved to `request` subpackage and usage has changed
|
||||||
|
* The `Claims` property on `Token` is now type `Claims` instead of `map[string]interface{}`. The default value is type `MapClaims`, which is an alias to `map[string]interface{}`. This makes it possible to use a custom type when decoding claims.
|
||||||
|
* Other Additions and Changes
|
||||||
|
* Added `Claims` interface type to allow users to decode the claims into a custom type
|
||||||
|
* Added `ParseWithClaims`, which takes a third argument of type `Claims`. Use this function instead of `Parse` if you have a custom type you'd like to decode into.
|
||||||
|
* Dramatically improved the functionality and flexibility of `ParseFromRequest`, which is now in the `request` subpackage
|
||||||
|
* Added `ParseFromRequestWithClaims` which is the `FromRequest` equivalent of `ParseWithClaims`
|
||||||
|
* Added new interface type `Extractor`, which is used for extracting JWT strings from http requests. Used with `ParseFromRequest` and `ParseFromRequestWithClaims`.
|
||||||
|
* Added several new, more specific, validation errors to error type bitmask
|
||||||
|
* Moved examples from README to executable example files
|
||||||
|
* Signing method registry is now thread safe
|
||||||
|
* Added new property to `ValidationError`, which contains the raw error returned by calls made by parse/verify (such as those returned by keyfunc or json parser)
|
||||||
|
|
||||||
|
#### 2.7.0
|
||||||
|
|
||||||
|
This will likely be the last backwards compatible release before 3.0.0, excluding essential bug fixes.
|
||||||
|
|
||||||
|
* Added new option `-show` to the `jwt` command that will just output the decoded token without verifying
|
||||||
|
* Error text for expired tokens includes how long it's been expired
|
||||||
|
* Fixed incorrect error returned from `ParseRSAPublicKeyFromPEM`
|
||||||
|
* Documentation updates
|
||||||
|
|
||||||
|
#### 2.6.0
|
||||||
|
|
||||||
|
* Exposed inner error within ValidationError
|
||||||
|
* Fixed validation errors when using UseJSONNumber flag
|
||||||
|
* Added several unit tests
|
||||||
|
|
||||||
|
#### 2.5.0
|
||||||
|
|
||||||
|
* Added support for signing method none. You shouldn't use this. The API tries to make this clear.
|
||||||
|
* Updated/fixed some documentation
|
||||||
|
* Added more helpful error message when trying to parse tokens that begin with `BEARER `
|
||||||
|
|
||||||
|
#### 2.4.0
|
||||||
|
|
||||||
|
* Added new type, Parser, to allow for configuration of various parsing parameters
|
||||||
|
* You can now specify a list of valid signing methods. Anything outside this set will be rejected.
|
||||||
|
* You can now opt to use the `json.Number` type instead of `float64` when parsing token JSON
|
||||||
|
* Added support for [Travis CI](https://travis-ci.org/dgrijalva/jwt-go)
|
||||||
|
* Fixed some bugs with ECDSA parsing
|
||||||
|
|
||||||
|
#### 2.3.0
|
||||||
|
|
||||||
|
* Added support for ECDSA signing methods
|
||||||
|
* Added support for RSA PSS signing methods (requires go v1.4)
|
||||||
|
|
||||||
|
#### 2.2.0
|
||||||
|
|
||||||
|
* Gracefully handle a `nil` `Keyfunc` being passed to `Parse`. Result will now be the parsed token and an error, instead of a panic.
|
||||||
|
|
||||||
|
#### 2.1.0
|
||||||
|
|
||||||
|
Backwards compatible API change that was missed in 2.0.0.
|
||||||
|
|
||||||
|
* The `SignedString` method on `Token` now takes `interface{}` instead of `[]byte`
|
||||||
|
|
||||||
|
#### 2.0.0
|
||||||
|
|
||||||
|
There were two major reasons for breaking backwards compatibility with this update. The first was a refactor required to expand the width of the RSA and HMAC-SHA signing implementations. There will likely be no required code changes to support this change.
|
||||||
|
|
||||||
|
The second update, while unfortunately requiring a small change in integration, is required to open up this library to other signing methods. Not all keys used for all signing methods have a single standard on-disk representation. Requiring `[]byte` as the type for all keys proved too limiting. Additionally, this implementation allows for pre-parsed tokens to be reused, which might matter in an application that parses a high volume of tokens with a small set of keys. Backwards compatibilty has been maintained for passing `[]byte` to the RSA signing methods, but they will also accept `*rsa.PublicKey` and `*rsa.PrivateKey`.
|
||||||
|
|
||||||
|
It is likely the only integration change required here will be to change `func(t *jwt.Token) ([]byte, error)` to `func(t *jwt.Token) (interface{}, error)` when calling `Parse`.
|
||||||
|
|
||||||
|
* **Compatibility Breaking Changes**
|
||||||
|
* `SigningMethodHS256` is now `*SigningMethodHMAC` instead of `type struct`
|
||||||
|
* `SigningMethodRS256` is now `*SigningMethodRSA` instead of `type struct`
|
||||||
|
* `KeyFunc` now returns `interface{}` instead of `[]byte`
|
||||||
|
* `SigningMethod.Sign` now takes `interface{}` instead of `[]byte` for the key
|
||||||
|
* `SigningMethod.Verify` now takes `interface{}` instead of `[]byte` for the key
|
||||||
|
* Renamed type `SigningMethodHS256` to `SigningMethodHMAC`. Specific sizes are now just instances of this type.
|
||||||
|
* Added public package global `SigningMethodHS256`
|
||||||
|
* Added public package global `SigningMethodHS384`
|
||||||
|
* Added public package global `SigningMethodHS512`
|
||||||
|
* Renamed type `SigningMethodRS256` to `SigningMethodRSA`. Specific sizes are now just instances of this type.
|
||||||
|
* Added public package global `SigningMethodRS256`
|
||||||
|
* Added public package global `SigningMethodRS384`
|
||||||
|
* Added public package global `SigningMethodRS512`
|
||||||
|
* Moved sample private key for HMAC tests from an inline value to a file on disk. Value is unchanged.
|
||||||
|
* Refactored the RSA implementation to be easier to read
|
||||||
|
* Exposed helper methods `ParseRSAPrivateKeyFromPEM` and `ParseRSAPublicKeyFromPEM`
|
||||||
|
|
||||||
|
#### 1.0.2
|
||||||
|
|
||||||
|
* Fixed bug in parsing public keys from certificates
|
||||||
|
* Added more tests around the parsing of keys for RS256
|
||||||
|
* Code refactoring in RS256 implementation. No functional changes
|
||||||
|
|
||||||
|
#### 1.0.1
|
||||||
|
|
||||||
|
* Fixed panic if RS256 signing method was passed an invalid key
|
||||||
|
|
||||||
|
#### 1.0.0
|
||||||
|
|
||||||
|
* First versioned release
|
||||||
|
* API stabilized
|
||||||
|
* Supports creating, signing, parsing, and validating JWT tokens
|
||||||
|
* Supports RS256 and HS256 signing methods
|
||||||
134
vendor/github.com/golang-jwt/jwt/claims.go
generated
vendored
Normal file
134
vendor/github.com/golang-jwt/jwt/claims.go
generated
vendored
Normal file
|
|
@ -0,0 +1,134 @@
|
||||||
|
package jwt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/subtle"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// For a type to be a Claims object, it must just have a Valid method that determines
|
||||||
|
// if the token is invalid for any supported reason
|
||||||
|
type Claims interface {
|
||||||
|
Valid() error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Structured version of Claims Section, as referenced at
|
||||||
|
// https://tools.ietf.org/html/rfc7519#section-4.1
|
||||||
|
// See examples for how to use this with your own claim types
|
||||||
|
type StandardClaims struct {
|
||||||
|
Audience string `json:"aud,omitempty"`
|
||||||
|
ExpiresAt int64 `json:"exp,omitempty"`
|
||||||
|
Id string `json:"jti,omitempty"`
|
||||||
|
IssuedAt int64 `json:"iat,omitempty"`
|
||||||
|
Issuer string `json:"iss,omitempty"`
|
||||||
|
NotBefore int64 `json:"nbf,omitempty"`
|
||||||
|
Subject string `json:"sub,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validates time based claims "exp, iat, nbf".
|
||||||
|
// There is no accounting for clock skew.
|
||||||
|
// As well, if any of the above claims are not in the token, it will still
|
||||||
|
// be considered a valid claim.
|
||||||
|
func (c StandardClaims) Valid() error {
|
||||||
|
vErr := new(ValidationError)
|
||||||
|
now := TimeFunc().Unix()
|
||||||
|
|
||||||
|
// The claims below are optional, by default, so if they are set to the
|
||||||
|
// default value in Go, let's not fail the verification for them.
|
||||||
|
if c.VerifyExpiresAt(now, false) == false {
|
||||||
|
delta := time.Unix(now, 0).Sub(time.Unix(c.ExpiresAt, 0))
|
||||||
|
vErr.Inner = fmt.Errorf("token is expired by %v", delta)
|
||||||
|
vErr.Errors |= ValidationErrorExpired
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.VerifyIssuedAt(now, false) == false {
|
||||||
|
vErr.Inner = fmt.Errorf("Token used before issued")
|
||||||
|
vErr.Errors |= ValidationErrorIssuedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.VerifyNotBefore(now, false) == false {
|
||||||
|
vErr.Inner = fmt.Errorf("token is not valid yet")
|
||||||
|
vErr.Errors |= ValidationErrorNotValidYet
|
||||||
|
}
|
||||||
|
|
||||||
|
if vErr.valid() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return vErr
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compares the aud claim against cmp.
|
||||||
|
// If required is false, this method will return true if the value matches or is unset
|
||||||
|
func (c *StandardClaims) VerifyAudience(cmp string, req bool) bool {
|
||||||
|
return verifyAud(c.Audience, cmp, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compares the exp claim against cmp.
|
||||||
|
// If required is false, this method will return true if the value matches or is unset
|
||||||
|
func (c *StandardClaims) VerifyExpiresAt(cmp int64, req bool) bool {
|
||||||
|
return verifyExp(c.ExpiresAt, cmp, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compares the iat claim against cmp.
|
||||||
|
// If required is false, this method will return true if the value matches or is unset
|
||||||
|
func (c *StandardClaims) VerifyIssuedAt(cmp int64, req bool) bool {
|
||||||
|
return verifyIat(c.IssuedAt, cmp, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compares the iss claim against cmp.
|
||||||
|
// If required is false, this method will return true if the value matches or is unset
|
||||||
|
func (c *StandardClaims) VerifyIssuer(cmp string, req bool) bool {
|
||||||
|
return verifyIss(c.Issuer, cmp, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compares the nbf claim against cmp.
|
||||||
|
// If required is false, this method will return true if the value matches or is unset
|
||||||
|
func (c *StandardClaims) VerifyNotBefore(cmp int64, req bool) bool {
|
||||||
|
return verifyNbf(c.NotBefore, cmp, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----- helpers
|
||||||
|
|
||||||
|
func verifyAud(aud string, cmp string, required bool) bool {
|
||||||
|
if aud == "" {
|
||||||
|
return !required
|
||||||
|
}
|
||||||
|
if subtle.ConstantTimeCompare([]byte(aud), []byte(cmp)) != 0 {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func verifyExp(exp int64, now int64, required bool) bool {
|
||||||
|
if exp == 0 {
|
||||||
|
return !required
|
||||||
|
}
|
||||||
|
return now <= exp
|
||||||
|
}
|
||||||
|
|
||||||
|
func verifyIat(iat int64, now int64, required bool) bool {
|
||||||
|
if iat == 0 {
|
||||||
|
return !required
|
||||||
|
}
|
||||||
|
return now >= iat
|
||||||
|
}
|
||||||
|
|
||||||
|
func verifyIss(iss string, cmp string, required bool) bool {
|
||||||
|
if iss == "" {
|
||||||
|
return !required
|
||||||
|
}
|
||||||
|
if subtle.ConstantTimeCompare([]byte(iss), []byte(cmp)) != 0 {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func verifyNbf(nbf int64, now int64, required bool) bool {
|
||||||
|
if nbf == 0 {
|
||||||
|
return !required
|
||||||
|
}
|
||||||
|
return now >= nbf
|
||||||
|
}
|
||||||
4
vendor/github.com/golang-jwt/jwt/doc.go
generated
vendored
Normal file
4
vendor/github.com/golang-jwt/jwt/doc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
// Package jwt is a Go implementation of JSON Web Tokens: http://self-issued.info/docs/draft-jones-json-web-token.html
|
||||||
|
//
|
||||||
|
// See README.md for more info.
|
||||||
|
package jwt
|
||||||
148
vendor/github.com/golang-jwt/jwt/ecdsa.go
generated
vendored
Normal file
148
vendor/github.com/golang-jwt/jwt/ecdsa.go
generated
vendored
Normal file
|
|
@ -0,0 +1,148 @@
|
||||||
|
package jwt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto"
|
||||||
|
"crypto/ecdsa"
|
||||||
|
"crypto/rand"
|
||||||
|
"errors"
|
||||||
|
"math/big"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Sadly this is missing from crypto/ecdsa compared to crypto/rsa
|
||||||
|
ErrECDSAVerification = errors.New("crypto/ecdsa: verification error")
|
||||||
|
)
|
||||||
|
|
||||||
|
// Implements the ECDSA family of signing methods signing methods
|
||||||
|
// Expects *ecdsa.PrivateKey for signing and *ecdsa.PublicKey for verification
|
||||||
|
type SigningMethodECDSA struct {
|
||||||
|
Name string
|
||||||
|
Hash crypto.Hash
|
||||||
|
KeySize int
|
||||||
|
CurveBits int
|
||||||
|
}
|
||||||
|
|
||||||
|
// Specific instances for EC256 and company
|
||||||
|
var (
|
||||||
|
SigningMethodES256 *SigningMethodECDSA
|
||||||
|
SigningMethodES384 *SigningMethodECDSA
|
||||||
|
SigningMethodES512 *SigningMethodECDSA
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// ES256
|
||||||
|
SigningMethodES256 = &SigningMethodECDSA{"ES256", crypto.SHA256, 32, 256}
|
||||||
|
RegisterSigningMethod(SigningMethodES256.Alg(), func() SigningMethod {
|
||||||
|
return SigningMethodES256
|
||||||
|
})
|
||||||
|
|
||||||
|
// ES384
|
||||||
|
SigningMethodES384 = &SigningMethodECDSA{"ES384", crypto.SHA384, 48, 384}
|
||||||
|
RegisterSigningMethod(SigningMethodES384.Alg(), func() SigningMethod {
|
||||||
|
return SigningMethodES384
|
||||||
|
})
|
||||||
|
|
||||||
|
// ES512
|
||||||
|
SigningMethodES512 = &SigningMethodECDSA{"ES512", crypto.SHA512, 66, 521}
|
||||||
|
RegisterSigningMethod(SigningMethodES512.Alg(), func() SigningMethod {
|
||||||
|
return SigningMethodES512
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *SigningMethodECDSA) Alg() string {
|
||||||
|
return m.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implements the Verify method from SigningMethod
|
||||||
|
// For this verify method, key must be an ecdsa.PublicKey struct
|
||||||
|
func (m *SigningMethodECDSA) Verify(signingString, signature string, key interface{}) error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
// Decode the signature
|
||||||
|
var sig []byte
|
||||||
|
if sig, err = DecodeSegment(signature); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the key
|
||||||
|
var ecdsaKey *ecdsa.PublicKey
|
||||||
|
switch k := key.(type) {
|
||||||
|
case *ecdsa.PublicKey:
|
||||||
|
ecdsaKey = k
|
||||||
|
default:
|
||||||
|
return ErrInvalidKeyType
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(sig) != 2*m.KeySize {
|
||||||
|
return ErrECDSAVerification
|
||||||
|
}
|
||||||
|
|
||||||
|
r := big.NewInt(0).SetBytes(sig[:m.KeySize])
|
||||||
|
s := big.NewInt(0).SetBytes(sig[m.KeySize:])
|
||||||
|
|
||||||
|
// Create hasher
|
||||||
|
if !m.Hash.Available() {
|
||||||
|
return ErrHashUnavailable
|
||||||
|
}
|
||||||
|
hasher := m.Hash.New()
|
||||||
|
hasher.Write([]byte(signingString))
|
||||||
|
|
||||||
|
// Verify the signature
|
||||||
|
if verifystatus := ecdsa.Verify(ecdsaKey, hasher.Sum(nil), r, s); verifystatus == true {
|
||||||
|
return nil
|
||||||
|
} else {
|
||||||
|
return ErrECDSAVerification
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implements the Sign method from SigningMethod
|
||||||
|
// For this signing method, key must be an ecdsa.PrivateKey struct
|
||||||
|
func (m *SigningMethodECDSA) Sign(signingString string, key interface{}) (string, error) {
|
||||||
|
// Get the key
|
||||||
|
var ecdsaKey *ecdsa.PrivateKey
|
||||||
|
switch k := key.(type) {
|
||||||
|
case *ecdsa.PrivateKey:
|
||||||
|
ecdsaKey = k
|
||||||
|
default:
|
||||||
|
return "", ErrInvalidKeyType
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the hasher
|
||||||
|
if !m.Hash.Available() {
|
||||||
|
return "", ErrHashUnavailable
|
||||||
|
}
|
||||||
|
|
||||||
|
hasher := m.Hash.New()
|
||||||
|
hasher.Write([]byte(signingString))
|
||||||
|
|
||||||
|
// Sign the string and return r, s
|
||||||
|
if r, s, err := ecdsa.Sign(rand.Reader, ecdsaKey, hasher.Sum(nil)); err == nil {
|
||||||
|
curveBits := ecdsaKey.Curve.Params().BitSize
|
||||||
|
|
||||||
|
if m.CurveBits != curveBits {
|
||||||
|
return "", ErrInvalidKey
|
||||||
|
}
|
||||||
|
|
||||||
|
keyBytes := curveBits / 8
|
||||||
|
if curveBits%8 > 0 {
|
||||||
|
keyBytes += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// We serialize the outpus (r and s) into big-endian byte arrays and pad
|
||||||
|
// them with zeros on the left to make sure the sizes work out. Both arrays
|
||||||
|
// must be keyBytes long, and the output must be 2*keyBytes long.
|
||||||
|
rBytes := r.Bytes()
|
||||||
|
rBytesPadded := make([]byte, keyBytes)
|
||||||
|
copy(rBytesPadded[keyBytes-len(rBytes):], rBytes)
|
||||||
|
|
||||||
|
sBytes := s.Bytes()
|
||||||
|
sBytesPadded := make([]byte, keyBytes)
|
||||||
|
copy(sBytesPadded[keyBytes-len(sBytes):], sBytes)
|
||||||
|
|
||||||
|
out := append(rBytesPadded, sBytesPadded...)
|
||||||
|
|
||||||
|
return EncodeSegment(out), nil
|
||||||
|
} else {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
67
vendor/github.com/golang-jwt/jwt/ecdsa_utils.go
generated
vendored
Normal file
67
vendor/github.com/golang-jwt/jwt/ecdsa_utils.go
generated
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
package jwt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/ecdsa"
|
||||||
|
"crypto/x509"
|
||||||
|
"encoding/pem"
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrNotECPublicKey = errors.New("Key is not a valid ECDSA public key")
|
||||||
|
ErrNotECPrivateKey = errors.New("Key is not a valid ECDSA private key")
|
||||||
|
)
|
||||||
|
|
||||||
|
// Parse PEM encoded Elliptic Curve Private Key Structure
|
||||||
|
func ParseECPrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error) {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
// Parse PEM block
|
||||||
|
var block *pem.Block
|
||||||
|
if block, _ = pem.Decode(key); block == nil {
|
||||||
|
return nil, ErrKeyMustBePEMEncoded
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse the key
|
||||||
|
var parsedKey interface{}
|
||||||
|
if parsedKey, err = x509.ParseECPrivateKey(block.Bytes); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var pkey *ecdsa.PrivateKey
|
||||||
|
var ok bool
|
||||||
|
if pkey, ok = parsedKey.(*ecdsa.PrivateKey); !ok {
|
||||||
|
return nil, ErrNotECPrivateKey
|
||||||
|
}
|
||||||
|
|
||||||
|
return pkey, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse PEM encoded PKCS1 or PKCS8 public key
|
||||||
|
func ParseECPublicKeyFromPEM(key []byte) (*ecdsa.PublicKey, error) {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
// Parse PEM block
|
||||||
|
var block *pem.Block
|
||||||
|
if block, _ = pem.Decode(key); block == nil {
|
||||||
|
return nil, ErrKeyMustBePEMEncoded
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse the key
|
||||||
|
var parsedKey interface{}
|
||||||
|
if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil {
|
||||||
|
if cert, err := x509.ParseCertificate(block.Bytes); err == nil {
|
||||||
|
parsedKey = cert.PublicKey
|
||||||
|
} else {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var pkey *ecdsa.PublicKey
|
||||||
|
var ok bool
|
||||||
|
if pkey, ok = parsedKey.(*ecdsa.PublicKey); !ok {
|
||||||
|
return nil, ErrNotECPublicKey
|
||||||
|
}
|
||||||
|
|
||||||
|
return pkey, nil
|
||||||
|
}
|
||||||
59
vendor/github.com/golang-jwt/jwt/errors.go
generated
vendored
Normal file
59
vendor/github.com/golang-jwt/jwt/errors.go
generated
vendored
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
package jwt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Error constants
|
||||||
|
var (
|
||||||
|
ErrInvalidKey = errors.New("key is invalid")
|
||||||
|
ErrInvalidKeyType = errors.New("key is of invalid type")
|
||||||
|
ErrHashUnavailable = errors.New("the requested hash function is unavailable")
|
||||||
|
)
|
||||||
|
|
||||||
|
// The errors that might occur when parsing and validating a token
|
||||||
|
const (
|
||||||
|
ValidationErrorMalformed uint32 = 1 << iota // Token is malformed
|
||||||
|
ValidationErrorUnverifiable // Token could not be verified because of signing problems
|
||||||
|
ValidationErrorSignatureInvalid // Signature validation failed
|
||||||
|
|
||||||
|
// Standard Claim validation errors
|
||||||
|
ValidationErrorAudience // AUD validation failed
|
||||||
|
ValidationErrorExpired // EXP validation failed
|
||||||
|
ValidationErrorIssuedAt // IAT validation failed
|
||||||
|
ValidationErrorIssuer // ISS validation failed
|
||||||
|
ValidationErrorNotValidYet // NBF validation failed
|
||||||
|
ValidationErrorId // JTI validation failed
|
||||||
|
ValidationErrorClaimsInvalid // Generic claims validation error
|
||||||
|
)
|
||||||
|
|
||||||
|
// Helper for constructing a ValidationError with a string error message
|
||||||
|
func NewValidationError(errorText string, errorFlags uint32) *ValidationError {
|
||||||
|
return &ValidationError{
|
||||||
|
text: errorText,
|
||||||
|
Errors: errorFlags,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The error from Parse if token is not valid
|
||||||
|
type ValidationError struct {
|
||||||
|
Inner error // stores the error returned by external dependencies, i.e.: KeyFunc
|
||||||
|
Errors uint32 // bitfield. see ValidationError... constants
|
||||||
|
text string // errors that do not have a valid error just have text
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validation error is an error type
|
||||||
|
func (e ValidationError) Error() string {
|
||||||
|
if e.Inner != nil {
|
||||||
|
return e.Inner.Error()
|
||||||
|
} else if e.text != "" {
|
||||||
|
return e.text
|
||||||
|
} else {
|
||||||
|
return "token is invalid"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No errors
|
||||||
|
func (e *ValidationError) valid() bool {
|
||||||
|
return e.Errors == 0
|
||||||
|
}
|
||||||
95
vendor/github.com/golang-jwt/jwt/hmac.go
generated
vendored
Normal file
95
vendor/github.com/golang-jwt/jwt/hmac.go
generated
vendored
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
package jwt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto"
|
||||||
|
"crypto/hmac"
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Implements the HMAC-SHA family of signing methods signing methods
|
||||||
|
// Expects key type of []byte for both signing and validation
|
||||||
|
type SigningMethodHMAC struct {
|
||||||
|
Name string
|
||||||
|
Hash crypto.Hash
|
||||||
|
}
|
||||||
|
|
||||||
|
// Specific instances for HS256 and company
|
||||||
|
var (
|
||||||
|
SigningMethodHS256 *SigningMethodHMAC
|
||||||
|
SigningMethodHS384 *SigningMethodHMAC
|
||||||
|
SigningMethodHS512 *SigningMethodHMAC
|
||||||
|
ErrSignatureInvalid = errors.New("signature is invalid")
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// HS256
|
||||||
|
SigningMethodHS256 = &SigningMethodHMAC{"HS256", crypto.SHA256}
|
||||||
|
RegisterSigningMethod(SigningMethodHS256.Alg(), func() SigningMethod {
|
||||||
|
return SigningMethodHS256
|
||||||
|
})
|
||||||
|
|
||||||
|
// HS384
|
||||||
|
SigningMethodHS384 = &SigningMethodHMAC{"HS384", crypto.SHA384}
|
||||||
|
RegisterSigningMethod(SigningMethodHS384.Alg(), func() SigningMethod {
|
||||||
|
return SigningMethodHS384
|
||||||
|
})
|
||||||
|
|
||||||
|
// HS512
|
||||||
|
SigningMethodHS512 = &SigningMethodHMAC{"HS512", crypto.SHA512}
|
||||||
|
RegisterSigningMethod(SigningMethodHS512.Alg(), func() SigningMethod {
|
||||||
|
return SigningMethodHS512
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *SigningMethodHMAC) Alg() string {
|
||||||
|
return m.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify the signature of HSXXX tokens. Returns nil if the signature is valid.
|
||||||
|
func (m *SigningMethodHMAC) Verify(signingString, signature string, key interface{}) error {
|
||||||
|
// Verify the key is the right type
|
||||||
|
keyBytes, ok := key.([]byte)
|
||||||
|
if !ok {
|
||||||
|
return ErrInvalidKeyType
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode signature, for comparison
|
||||||
|
sig, err := DecodeSegment(signature)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can we use the specified hashing method?
|
||||||
|
if !m.Hash.Available() {
|
||||||
|
return ErrHashUnavailable
|
||||||
|
}
|
||||||
|
|
||||||
|
// This signing method is symmetric, so we validate the signature
|
||||||
|
// by reproducing the signature from the signing string and key, then
|
||||||
|
// comparing that against the provided signature.
|
||||||
|
hasher := hmac.New(m.Hash.New, keyBytes)
|
||||||
|
hasher.Write([]byte(signingString))
|
||||||
|
if !hmac.Equal(sig, hasher.Sum(nil)) {
|
||||||
|
return ErrSignatureInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
// No validation errors. Signature is good.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implements the Sign method from SigningMethod for this signing method.
|
||||||
|
// Key must be []byte
|
||||||
|
func (m *SigningMethodHMAC) Sign(signingString string, key interface{}) (string, error) {
|
||||||
|
if keyBytes, ok := key.([]byte); ok {
|
||||||
|
if !m.Hash.Available() {
|
||||||
|
return "", ErrHashUnavailable
|
||||||
|
}
|
||||||
|
|
||||||
|
hasher := hmac.New(m.Hash.New, keyBytes)
|
||||||
|
hasher.Write([]byte(signingString))
|
||||||
|
|
||||||
|
return EncodeSegment(hasher.Sum(nil)), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return "", ErrInvalidKeyType
|
||||||
|
}
|
||||||
94
vendor/github.com/golang-jwt/jwt/map_claims.go
generated
vendored
Normal file
94
vendor/github.com/golang-jwt/jwt/map_claims.go
generated
vendored
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
package jwt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
// "fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Claims type that uses the map[string]interface{} for JSON decoding
|
||||||
|
// This is the default claims type if you don't supply one
|
||||||
|
type MapClaims map[string]interface{}
|
||||||
|
|
||||||
|
// Compares the aud claim against cmp.
|
||||||
|
// If required is false, this method will return true if the value matches or is unset
|
||||||
|
func (m MapClaims) VerifyAudience(cmp string, req bool) bool {
|
||||||
|
aud, _ := m["aud"].(string)
|
||||||
|
return verifyAud(aud, cmp, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compares the exp claim against cmp.
|
||||||
|
// If required is false, this method will return true if the value matches or is unset
|
||||||
|
func (m MapClaims) VerifyExpiresAt(cmp int64, req bool) bool {
|
||||||
|
switch exp := m["exp"].(type) {
|
||||||
|
case float64:
|
||||||
|
return verifyExp(int64(exp), cmp, req)
|
||||||
|
case json.Number:
|
||||||
|
v, _ := exp.Int64()
|
||||||
|
return verifyExp(v, cmp, req)
|
||||||
|
}
|
||||||
|
return req == false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compares the iat claim against cmp.
|
||||||
|
// If required is false, this method will return true if the value matches or is unset
|
||||||
|
func (m MapClaims) VerifyIssuedAt(cmp int64, req bool) bool {
|
||||||
|
switch iat := m["iat"].(type) {
|
||||||
|
case float64:
|
||||||
|
return verifyIat(int64(iat), cmp, req)
|
||||||
|
case json.Number:
|
||||||
|
v, _ := iat.Int64()
|
||||||
|
return verifyIat(v, cmp, req)
|
||||||
|
}
|
||||||
|
return req == false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compares the iss claim against cmp.
|
||||||
|
// If required is false, this method will return true if the value matches or is unset
|
||||||
|
func (m MapClaims) VerifyIssuer(cmp string, req bool) bool {
|
||||||
|
iss, _ := m["iss"].(string)
|
||||||
|
return verifyIss(iss, cmp, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compares the nbf claim against cmp.
|
||||||
|
// If required is false, this method will return true if the value matches or is unset
|
||||||
|
func (m MapClaims) VerifyNotBefore(cmp int64, req bool) bool {
|
||||||
|
switch nbf := m["nbf"].(type) {
|
||||||
|
case float64:
|
||||||
|
return verifyNbf(int64(nbf), cmp, req)
|
||||||
|
case json.Number:
|
||||||
|
v, _ := nbf.Int64()
|
||||||
|
return verifyNbf(v, cmp, req)
|
||||||
|
}
|
||||||
|
return req == false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validates time based claims "exp, iat, nbf".
|
||||||
|
// There is no accounting for clock skew.
|
||||||
|
// As well, if any of the above claims are not in the token, it will still
|
||||||
|
// be considered a valid claim.
|
||||||
|
func (m MapClaims) Valid() error {
|
||||||
|
vErr := new(ValidationError)
|
||||||
|
now := TimeFunc().Unix()
|
||||||
|
|
||||||
|
if m.VerifyExpiresAt(now, false) == false {
|
||||||
|
vErr.Inner = errors.New("Token is expired")
|
||||||
|
vErr.Errors |= ValidationErrorExpired
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.VerifyIssuedAt(now, false) == false {
|
||||||
|
vErr.Inner = errors.New("Token used before issued")
|
||||||
|
vErr.Errors |= ValidationErrorIssuedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.VerifyNotBefore(now, false) == false {
|
||||||
|
vErr.Inner = errors.New("Token is not valid yet")
|
||||||
|
vErr.Errors |= ValidationErrorNotValidYet
|
||||||
|
}
|
||||||
|
|
||||||
|
if vErr.valid() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return vErr
|
||||||
|
}
|
||||||
52
vendor/github.com/golang-jwt/jwt/none.go
generated
vendored
Normal file
52
vendor/github.com/golang-jwt/jwt/none.go
generated
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
package jwt
|
||||||
|
|
||||||
|
// Implements the none signing method. This is required by the spec
|
||||||
|
// but you probably should never use it.
|
||||||
|
var SigningMethodNone *signingMethodNone
|
||||||
|
|
||||||
|
const UnsafeAllowNoneSignatureType unsafeNoneMagicConstant = "none signing method allowed"
|
||||||
|
|
||||||
|
var NoneSignatureTypeDisallowedError error
|
||||||
|
|
||||||
|
type signingMethodNone struct{}
|
||||||
|
type unsafeNoneMagicConstant string
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
SigningMethodNone = &signingMethodNone{}
|
||||||
|
NoneSignatureTypeDisallowedError = NewValidationError("'none' signature type is not allowed", ValidationErrorSignatureInvalid)
|
||||||
|
|
||||||
|
RegisterSigningMethod(SigningMethodNone.Alg(), func() SigningMethod {
|
||||||
|
return SigningMethodNone
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *signingMethodNone) Alg() string {
|
||||||
|
return "none"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only allow 'none' alg type if UnsafeAllowNoneSignatureType is specified as the key
|
||||||
|
func (m *signingMethodNone) Verify(signingString, signature string, key interface{}) (err error) {
|
||||||
|
// Key must be UnsafeAllowNoneSignatureType to prevent accidentally
|
||||||
|
// accepting 'none' signing method
|
||||||
|
if _, ok := key.(unsafeNoneMagicConstant); !ok {
|
||||||
|
return NoneSignatureTypeDisallowedError
|
||||||
|
}
|
||||||
|
// If signing method is none, signature must be an empty string
|
||||||
|
if signature != "" {
|
||||||
|
return NewValidationError(
|
||||||
|
"'none' signing method with non-empty signature",
|
||||||
|
ValidationErrorSignatureInvalid,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Accept 'none' signing method.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only allow 'none' signing if UnsafeAllowNoneSignatureType is specified as the key
|
||||||
|
func (m *signingMethodNone) Sign(signingString string, key interface{}) (string, error) {
|
||||||
|
if _, ok := key.(unsafeNoneMagicConstant); ok {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
return "", NoneSignatureTypeDisallowedError
|
||||||
|
}
|
||||||
148
vendor/github.com/golang-jwt/jwt/parser.go
generated
vendored
Normal file
148
vendor/github.com/golang-jwt/jwt/parser.go
generated
vendored
Normal file
|
|
@ -0,0 +1,148 @@
|
||||||
|
package jwt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Parser struct {
|
||||||
|
ValidMethods []string // If populated, only these methods will be considered valid
|
||||||
|
UseJSONNumber bool // Use JSON Number format in JSON decoder
|
||||||
|
SkipClaimsValidation bool // Skip claims validation during token parsing
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse, validate, and return a token.
|
||||||
|
// keyFunc will receive the parsed token and should return the key for validating.
|
||||||
|
// If everything is kosher, err will be nil
|
||||||
|
func (p *Parser) Parse(tokenString string, keyFunc Keyfunc) (*Token, error) {
|
||||||
|
return p.ParseWithClaims(tokenString, MapClaims{}, keyFunc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyfunc) (*Token, error) {
|
||||||
|
token, parts, err := p.ParseUnverified(tokenString, claims)
|
||||||
|
if err != nil {
|
||||||
|
return token, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify signing method is in the required set
|
||||||
|
if p.ValidMethods != nil {
|
||||||
|
var signingMethodValid = false
|
||||||
|
var alg = token.Method.Alg()
|
||||||
|
for _, m := range p.ValidMethods {
|
||||||
|
if m == alg {
|
||||||
|
signingMethodValid = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !signingMethodValid {
|
||||||
|
// signing method is not in the listed set
|
||||||
|
return token, NewValidationError(fmt.Sprintf("signing method %v is invalid", alg), ValidationErrorSignatureInvalid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lookup key
|
||||||
|
var key interface{}
|
||||||
|
if keyFunc == nil {
|
||||||
|
// keyFunc was not provided. short circuiting validation
|
||||||
|
return token, NewValidationError("no Keyfunc was provided.", ValidationErrorUnverifiable)
|
||||||
|
}
|
||||||
|
if key, err = keyFunc(token); err != nil {
|
||||||
|
// keyFunc returned an error
|
||||||
|
if ve, ok := err.(*ValidationError); ok {
|
||||||
|
return token, ve
|
||||||
|
}
|
||||||
|
return token, &ValidationError{Inner: err, Errors: ValidationErrorUnverifiable}
|
||||||
|
}
|
||||||
|
|
||||||
|
vErr := &ValidationError{}
|
||||||
|
|
||||||
|
// Validate Claims
|
||||||
|
if !p.SkipClaimsValidation {
|
||||||
|
if err := token.Claims.Valid(); err != nil {
|
||||||
|
|
||||||
|
// If the Claims Valid returned an error, check if it is a validation error,
|
||||||
|
// If it was another error type, create a ValidationError with a generic ClaimsInvalid flag set
|
||||||
|
if e, ok := err.(*ValidationError); !ok {
|
||||||
|
vErr = &ValidationError{Inner: err, Errors: ValidationErrorClaimsInvalid}
|
||||||
|
} else {
|
||||||
|
vErr = e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perform validation
|
||||||
|
token.Signature = parts[2]
|
||||||
|
if err = token.Method.Verify(strings.Join(parts[0:2], "."), token.Signature, key); err != nil {
|
||||||
|
vErr.Inner = err
|
||||||
|
vErr.Errors |= ValidationErrorSignatureInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
if vErr.valid() {
|
||||||
|
token.Valid = true
|
||||||
|
return token, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return token, vErr
|
||||||
|
}
|
||||||
|
|
||||||
|
// WARNING: Don't use this method unless you know what you're doing
|
||||||
|
//
|
||||||
|
// This method parses the token but doesn't validate the signature. It's only
|
||||||
|
// ever useful in cases where you know the signature is valid (because it has
|
||||||
|
// been checked previously in the stack) and you want to extract values from
|
||||||
|
// it.
|
||||||
|
func (p *Parser) ParseUnverified(tokenString string, claims Claims) (token *Token, parts []string, err error) {
|
||||||
|
parts = strings.Split(tokenString, ".")
|
||||||
|
if len(parts) != 3 {
|
||||||
|
return nil, parts, NewValidationError("token contains an invalid number of segments", ValidationErrorMalformed)
|
||||||
|
}
|
||||||
|
|
||||||
|
token = &Token{Raw: tokenString}
|
||||||
|
|
||||||
|
// parse Header
|
||||||
|
var headerBytes []byte
|
||||||
|
if headerBytes, err = DecodeSegment(parts[0]); err != nil {
|
||||||
|
if strings.HasPrefix(strings.ToLower(tokenString), "bearer ") {
|
||||||
|
return token, parts, NewValidationError("tokenstring should not contain 'bearer '", ValidationErrorMalformed)
|
||||||
|
}
|
||||||
|
return token, parts, &ValidationError{Inner: err, Errors: ValidationErrorMalformed}
|
||||||
|
}
|
||||||
|
if err = json.Unmarshal(headerBytes, &token.Header); err != nil {
|
||||||
|
return token, parts, &ValidationError{Inner: err, Errors: ValidationErrorMalformed}
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse Claims
|
||||||
|
var claimBytes []byte
|
||||||
|
token.Claims = claims
|
||||||
|
|
||||||
|
if claimBytes, err = DecodeSegment(parts[1]); err != nil {
|
||||||
|
return token, parts, &ValidationError{Inner: err, Errors: ValidationErrorMalformed}
|
||||||
|
}
|
||||||
|
dec := json.NewDecoder(bytes.NewBuffer(claimBytes))
|
||||||
|
if p.UseJSONNumber {
|
||||||
|
dec.UseNumber()
|
||||||
|
}
|
||||||
|
// JSON Decode. Special case for map type to avoid weird pointer behavior
|
||||||
|
if c, ok := token.Claims.(MapClaims); ok {
|
||||||
|
err = dec.Decode(&c)
|
||||||
|
} else {
|
||||||
|
err = dec.Decode(&claims)
|
||||||
|
}
|
||||||
|
// Handle decode error
|
||||||
|
if err != nil {
|
||||||
|
return token, parts, &ValidationError{Inner: err, Errors: ValidationErrorMalformed}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lookup signature method
|
||||||
|
if method, ok := token.Header["alg"].(string); ok {
|
||||||
|
if token.Method = GetSigningMethod(method); token.Method == nil {
|
||||||
|
return token, parts, NewValidationError("signing method (alg) is unavailable.", ValidationErrorUnverifiable)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return token, parts, NewValidationError("signing method (alg) is unspecified.", ValidationErrorUnverifiable)
|
||||||
|
}
|
||||||
|
|
||||||
|
return token, parts, nil
|
||||||
|
}
|
||||||
101
vendor/github.com/golang-jwt/jwt/rsa.go
generated
vendored
Normal file
101
vendor/github.com/golang-jwt/jwt/rsa.go
generated
vendored
Normal file
|
|
@ -0,0 +1,101 @@
|
||||||
|
package jwt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto"
|
||||||
|
"crypto/rand"
|
||||||
|
"crypto/rsa"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Implements the RSA family of signing methods signing methods
|
||||||
|
// Expects *rsa.PrivateKey for signing and *rsa.PublicKey for validation
|
||||||
|
type SigningMethodRSA struct {
|
||||||
|
Name string
|
||||||
|
Hash crypto.Hash
|
||||||
|
}
|
||||||
|
|
||||||
|
// Specific instances for RS256 and company
|
||||||
|
var (
|
||||||
|
SigningMethodRS256 *SigningMethodRSA
|
||||||
|
SigningMethodRS384 *SigningMethodRSA
|
||||||
|
SigningMethodRS512 *SigningMethodRSA
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// RS256
|
||||||
|
SigningMethodRS256 = &SigningMethodRSA{"RS256", crypto.SHA256}
|
||||||
|
RegisterSigningMethod(SigningMethodRS256.Alg(), func() SigningMethod {
|
||||||
|
return SigningMethodRS256
|
||||||
|
})
|
||||||
|
|
||||||
|
// RS384
|
||||||
|
SigningMethodRS384 = &SigningMethodRSA{"RS384", crypto.SHA384}
|
||||||
|
RegisterSigningMethod(SigningMethodRS384.Alg(), func() SigningMethod {
|
||||||
|
return SigningMethodRS384
|
||||||
|
})
|
||||||
|
|
||||||
|
// RS512
|
||||||
|
SigningMethodRS512 = &SigningMethodRSA{"RS512", crypto.SHA512}
|
||||||
|
RegisterSigningMethod(SigningMethodRS512.Alg(), func() SigningMethod {
|
||||||
|
return SigningMethodRS512
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *SigningMethodRSA) Alg() string {
|
||||||
|
return m.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implements the Verify method from SigningMethod
|
||||||
|
// For this signing method, must be an *rsa.PublicKey structure.
|
||||||
|
func (m *SigningMethodRSA) Verify(signingString, signature string, key interface{}) error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
// Decode the signature
|
||||||
|
var sig []byte
|
||||||
|
if sig, err = DecodeSegment(signature); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var rsaKey *rsa.PublicKey
|
||||||
|
var ok bool
|
||||||
|
|
||||||
|
if rsaKey, ok = key.(*rsa.PublicKey); !ok {
|
||||||
|
return ErrInvalidKeyType
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create hasher
|
||||||
|
if !m.Hash.Available() {
|
||||||
|
return ErrHashUnavailable
|
||||||
|
}
|
||||||
|
hasher := m.Hash.New()
|
||||||
|
hasher.Write([]byte(signingString))
|
||||||
|
|
||||||
|
// Verify the signature
|
||||||
|
return rsa.VerifyPKCS1v15(rsaKey, m.Hash, hasher.Sum(nil), sig)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implements the Sign method from SigningMethod
|
||||||
|
// For this signing method, must be an *rsa.PrivateKey structure.
|
||||||
|
func (m *SigningMethodRSA) Sign(signingString string, key interface{}) (string, error) {
|
||||||
|
var rsaKey *rsa.PrivateKey
|
||||||
|
var ok bool
|
||||||
|
|
||||||
|
// Validate type of key
|
||||||
|
if rsaKey, ok = key.(*rsa.PrivateKey); !ok {
|
||||||
|
return "", ErrInvalidKey
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the hasher
|
||||||
|
if !m.Hash.Available() {
|
||||||
|
return "", ErrHashUnavailable
|
||||||
|
}
|
||||||
|
|
||||||
|
hasher := m.Hash.New()
|
||||||
|
hasher.Write([]byte(signingString))
|
||||||
|
|
||||||
|
// Sign the string and return the encoded bytes
|
||||||
|
if sigBytes, err := rsa.SignPKCS1v15(rand.Reader, rsaKey, m.Hash, hasher.Sum(nil)); err == nil {
|
||||||
|
return EncodeSegment(sigBytes), nil
|
||||||
|
} else {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
126
vendor/github.com/golang-jwt/jwt/rsa_pss.go
generated
vendored
Normal file
126
vendor/github.com/golang-jwt/jwt/rsa_pss.go
generated
vendored
Normal file
|
|
@ -0,0 +1,126 @@
|
||||||
|
// +build go1.4
|
||||||
|
|
||||||
|
package jwt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto"
|
||||||
|
"crypto/rand"
|
||||||
|
"crypto/rsa"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Implements the RSAPSS family of signing methods signing methods
|
||||||
|
type SigningMethodRSAPSS struct {
|
||||||
|
*SigningMethodRSA
|
||||||
|
Options *rsa.PSSOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// Specific instances for RS/PS and company
|
||||||
|
var (
|
||||||
|
SigningMethodPS256 *SigningMethodRSAPSS
|
||||||
|
SigningMethodPS384 *SigningMethodRSAPSS
|
||||||
|
SigningMethodPS512 *SigningMethodRSAPSS
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// PS256
|
||||||
|
SigningMethodPS256 = &SigningMethodRSAPSS{
|
||||||
|
&SigningMethodRSA{
|
||||||
|
Name: "PS256",
|
||||||
|
Hash: crypto.SHA256,
|
||||||
|
},
|
||||||
|
&rsa.PSSOptions{
|
||||||
|
SaltLength: rsa.PSSSaltLengthAuto,
|
||||||
|
Hash: crypto.SHA256,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
RegisterSigningMethod(SigningMethodPS256.Alg(), func() SigningMethod {
|
||||||
|
return SigningMethodPS256
|
||||||
|
})
|
||||||
|
|
||||||
|
// PS384
|
||||||
|
SigningMethodPS384 = &SigningMethodRSAPSS{
|
||||||
|
&SigningMethodRSA{
|
||||||
|
Name: "PS384",
|
||||||
|
Hash: crypto.SHA384,
|
||||||
|
},
|
||||||
|
&rsa.PSSOptions{
|
||||||
|
SaltLength: rsa.PSSSaltLengthAuto,
|
||||||
|
Hash: crypto.SHA384,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
RegisterSigningMethod(SigningMethodPS384.Alg(), func() SigningMethod {
|
||||||
|
return SigningMethodPS384
|
||||||
|
})
|
||||||
|
|
||||||
|
// PS512
|
||||||
|
SigningMethodPS512 = &SigningMethodRSAPSS{
|
||||||
|
&SigningMethodRSA{
|
||||||
|
Name: "PS512",
|
||||||
|
Hash: crypto.SHA512,
|
||||||
|
},
|
||||||
|
&rsa.PSSOptions{
|
||||||
|
SaltLength: rsa.PSSSaltLengthAuto,
|
||||||
|
Hash: crypto.SHA512,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
RegisterSigningMethod(SigningMethodPS512.Alg(), func() SigningMethod {
|
||||||
|
return SigningMethodPS512
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implements the Verify method from SigningMethod
|
||||||
|
// For this verify method, key must be an rsa.PublicKey struct
|
||||||
|
func (m *SigningMethodRSAPSS) Verify(signingString, signature string, key interface{}) error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
// Decode the signature
|
||||||
|
var sig []byte
|
||||||
|
if sig, err = DecodeSegment(signature); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var rsaKey *rsa.PublicKey
|
||||||
|
switch k := key.(type) {
|
||||||
|
case *rsa.PublicKey:
|
||||||
|
rsaKey = k
|
||||||
|
default:
|
||||||
|
return ErrInvalidKey
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create hasher
|
||||||
|
if !m.Hash.Available() {
|
||||||
|
return ErrHashUnavailable
|
||||||
|
}
|
||||||
|
hasher := m.Hash.New()
|
||||||
|
hasher.Write([]byte(signingString))
|
||||||
|
|
||||||
|
return rsa.VerifyPSS(rsaKey, m.Hash, hasher.Sum(nil), sig, m.Options)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implements the Sign method from SigningMethod
|
||||||
|
// For this signing method, key must be an rsa.PrivateKey struct
|
||||||
|
func (m *SigningMethodRSAPSS) Sign(signingString string, key interface{}) (string, error) {
|
||||||
|
var rsaKey *rsa.PrivateKey
|
||||||
|
|
||||||
|
switch k := key.(type) {
|
||||||
|
case *rsa.PrivateKey:
|
||||||
|
rsaKey = k
|
||||||
|
default:
|
||||||
|
return "", ErrInvalidKeyType
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the hasher
|
||||||
|
if !m.Hash.Available() {
|
||||||
|
return "", ErrHashUnavailable
|
||||||
|
}
|
||||||
|
|
||||||
|
hasher := m.Hash.New()
|
||||||
|
hasher.Write([]byte(signingString))
|
||||||
|
|
||||||
|
// Sign the string and return the encoded bytes
|
||||||
|
if sigBytes, err := rsa.SignPSS(rand.Reader, rsaKey, m.Hash, hasher.Sum(nil), m.Options); err == nil {
|
||||||
|
return EncodeSegment(sigBytes), nil
|
||||||
|
} else {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
101
vendor/github.com/golang-jwt/jwt/rsa_utils.go
generated
vendored
Normal file
101
vendor/github.com/golang-jwt/jwt/rsa_utils.go
generated
vendored
Normal file
|
|
@ -0,0 +1,101 @@
|
||||||
|
package jwt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/rsa"
|
||||||
|
"crypto/x509"
|
||||||
|
"encoding/pem"
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrKeyMustBePEMEncoded = errors.New("Invalid Key: Key must be PEM encoded PKCS1 or PKCS8 private key")
|
||||||
|
ErrNotRSAPrivateKey = errors.New("Key is not a valid RSA private key")
|
||||||
|
ErrNotRSAPublicKey = errors.New("Key is not a valid RSA public key")
|
||||||
|
)
|
||||||
|
|
||||||
|
// Parse PEM encoded PKCS1 or PKCS8 private key
|
||||||
|
func ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error) {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
// Parse PEM block
|
||||||
|
var block *pem.Block
|
||||||
|
if block, _ = pem.Decode(key); block == nil {
|
||||||
|
return nil, ErrKeyMustBePEMEncoded
|
||||||
|
}
|
||||||
|
|
||||||
|
var parsedKey interface{}
|
||||||
|
if parsedKey, err = x509.ParsePKCS1PrivateKey(block.Bytes); err != nil {
|
||||||
|
if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var pkey *rsa.PrivateKey
|
||||||
|
var ok bool
|
||||||
|
if pkey, ok = parsedKey.(*rsa.PrivateKey); !ok {
|
||||||
|
return nil, ErrNotRSAPrivateKey
|
||||||
|
}
|
||||||
|
|
||||||
|
return pkey, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse PEM encoded PKCS1 or PKCS8 private key protected with password
|
||||||
|
func ParseRSAPrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error) {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
// Parse PEM block
|
||||||
|
var block *pem.Block
|
||||||
|
if block, _ = pem.Decode(key); block == nil {
|
||||||
|
return nil, ErrKeyMustBePEMEncoded
|
||||||
|
}
|
||||||
|
|
||||||
|
var parsedKey interface{}
|
||||||
|
|
||||||
|
var blockDecrypted []byte
|
||||||
|
if blockDecrypted, err = x509.DecryptPEMBlock(block, []byte(password)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if parsedKey, err = x509.ParsePKCS1PrivateKey(blockDecrypted); err != nil {
|
||||||
|
if parsedKey, err = x509.ParsePKCS8PrivateKey(blockDecrypted); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var pkey *rsa.PrivateKey
|
||||||
|
var ok bool
|
||||||
|
if pkey, ok = parsedKey.(*rsa.PrivateKey); !ok {
|
||||||
|
return nil, ErrNotRSAPrivateKey
|
||||||
|
}
|
||||||
|
|
||||||
|
return pkey, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse PEM encoded PKCS1 or PKCS8 public key
|
||||||
|
func ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error) {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
// Parse PEM block
|
||||||
|
var block *pem.Block
|
||||||
|
if block, _ = pem.Decode(key); block == nil {
|
||||||
|
return nil, ErrKeyMustBePEMEncoded
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse the key
|
||||||
|
var parsedKey interface{}
|
||||||
|
if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil {
|
||||||
|
if cert, err := x509.ParseCertificate(block.Bytes); err == nil {
|
||||||
|
parsedKey = cert.PublicKey
|
||||||
|
} else {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var pkey *rsa.PublicKey
|
||||||
|
var ok bool
|
||||||
|
if pkey, ok = parsedKey.(*rsa.PublicKey); !ok {
|
||||||
|
return nil, ErrNotRSAPublicKey
|
||||||
|
}
|
||||||
|
|
||||||
|
return pkey, nil
|
||||||
|
}
|
||||||
35
vendor/github.com/golang-jwt/jwt/signing_method.go
generated
vendored
Normal file
35
vendor/github.com/golang-jwt/jwt/signing_method.go
generated
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
package jwt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
var signingMethods = map[string]func() SigningMethod{}
|
||||||
|
var signingMethodLock = new(sync.RWMutex)
|
||||||
|
|
||||||
|
// Implement SigningMethod to add new methods for signing or verifying tokens.
|
||||||
|
type SigningMethod interface {
|
||||||
|
Verify(signingString, signature string, key interface{}) error // Returns nil if signature is valid
|
||||||
|
Sign(signingString string, key interface{}) (string, error) // Returns encoded signature or error
|
||||||
|
Alg() string // returns the alg identifier for this method (example: 'HS256')
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register the "alg" name and a factory function for signing method.
|
||||||
|
// This is typically done during init() in the method's implementation
|
||||||
|
func RegisterSigningMethod(alg string, f func() SigningMethod) {
|
||||||
|
signingMethodLock.Lock()
|
||||||
|
defer signingMethodLock.Unlock()
|
||||||
|
|
||||||
|
signingMethods[alg] = f
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a signing method from an "alg" string
|
||||||
|
func GetSigningMethod(alg string) (method SigningMethod) {
|
||||||
|
signingMethodLock.RLock()
|
||||||
|
defer signingMethodLock.RUnlock()
|
||||||
|
|
||||||
|
if methodF, ok := signingMethods[alg]; ok {
|
||||||
|
method = methodF()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
108
vendor/github.com/golang-jwt/jwt/token.go
generated
vendored
Normal file
108
vendor/github.com/golang-jwt/jwt/token.go
generated
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
package jwt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
"encoding/json"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TimeFunc provides the current time when parsing token to validate "exp" claim (expiration time).
|
||||||
|
// You can override it to use another time value. This is useful for testing or if your
|
||||||
|
// server uses a different time zone than your tokens.
|
||||||
|
var TimeFunc = time.Now
|
||||||
|
|
||||||
|
// Parse methods use this callback function to supply
|
||||||
|
// the key for verification. The function receives the parsed,
|
||||||
|
// but unverified Token. This allows you to use properties in the
|
||||||
|
// Header of the token (such as `kid`) to identify which key to use.
|
||||||
|
type Keyfunc func(*Token) (interface{}, error)
|
||||||
|
|
||||||
|
// A JWT Token. Different fields will be used depending on whether you're
|
||||||
|
// creating or parsing/verifying a token.
|
||||||
|
type Token struct {
|
||||||
|
Raw string // The raw token. Populated when you Parse a token
|
||||||
|
Method SigningMethod // The signing method used or to be used
|
||||||
|
Header map[string]interface{} // The first segment of the token
|
||||||
|
Claims Claims // The second segment of the token
|
||||||
|
Signature string // The third segment of the token. Populated when you Parse a token
|
||||||
|
Valid bool // Is the token valid? Populated when you Parse/Verify a token
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new Token. Takes a signing method
|
||||||
|
func New(method SigningMethod) *Token {
|
||||||
|
return NewWithClaims(method, MapClaims{})
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewWithClaims(method SigningMethod, claims Claims) *Token {
|
||||||
|
return &Token{
|
||||||
|
Header: map[string]interface{}{
|
||||||
|
"typ": "JWT",
|
||||||
|
"alg": method.Alg(),
|
||||||
|
},
|
||||||
|
Claims: claims,
|
||||||
|
Method: method,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the complete, signed token
|
||||||
|
func (t *Token) SignedString(key interface{}) (string, error) {
|
||||||
|
var sig, sstr string
|
||||||
|
var err error
|
||||||
|
if sstr, err = t.SigningString(); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if sig, err = t.Method.Sign(sstr, key); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return strings.Join([]string{sstr, sig}, "."), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate the signing string. This is the
|
||||||
|
// most expensive part of the whole deal. Unless you
|
||||||
|
// need this for something special, just go straight for
|
||||||
|
// the SignedString.
|
||||||
|
func (t *Token) SigningString() (string, error) {
|
||||||
|
var err error
|
||||||
|
parts := make([]string, 2)
|
||||||
|
for i, _ := range parts {
|
||||||
|
var jsonValue []byte
|
||||||
|
if i == 0 {
|
||||||
|
if jsonValue, err = json.Marshal(t.Header); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if jsonValue, err = json.Marshal(t.Claims); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
parts[i] = EncodeSegment(jsonValue)
|
||||||
|
}
|
||||||
|
return strings.Join(parts, "."), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse, validate, and return a token.
|
||||||
|
// keyFunc will receive the parsed token and should return the key for validating.
|
||||||
|
// If everything is kosher, err will be nil
|
||||||
|
func Parse(tokenString string, keyFunc Keyfunc) (*Token, error) {
|
||||||
|
return new(Parser).Parse(tokenString, keyFunc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ParseWithClaims(tokenString string, claims Claims, keyFunc Keyfunc) (*Token, error) {
|
||||||
|
return new(Parser).ParseWithClaims(tokenString, claims, keyFunc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encode JWT specific base64url encoding with padding stripped
|
||||||
|
func EncodeSegment(seg []byte) string {
|
||||||
|
return strings.TrimRight(base64.URLEncoding.EncodeToString(seg), "=")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode JWT specific base64url encoding with padding stripped
|
||||||
|
func DecodeSegment(seg string) ([]byte, error) {
|
||||||
|
if l := len(seg) % 4; l > 0 {
|
||||||
|
seg += strings.Repeat("=", 4-l)
|
||||||
|
}
|
||||||
|
|
||||||
|
return base64.URLEncoding.DecodeString(seg)
|
||||||
|
}
|
||||||
191
vendor/github.com/golang/glog/LICENSE
generated
vendored
Normal file
191
vendor/github.com/golang/glog/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,191 @@
|
||||||
|
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:
|
||||||
|
|
||||||
|
You must give any other recipients of the Work or Derivative Works a copy of
|
||||||
|
this License; and
|
||||||
|
You must cause any modified files to carry prominent notices stating that You
|
||||||
|
changed the files; and
|
||||||
|
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
|
||||||
|
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.
|
||||||
44
vendor/github.com/golang/glog/README
generated
vendored
Normal file
44
vendor/github.com/golang/glog/README
generated
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
glog
|
||||||
|
====
|
||||||
|
|
||||||
|
Leveled execution logs for Go.
|
||||||
|
|
||||||
|
This is an efficient pure Go implementation of leveled logs in the
|
||||||
|
manner of the open source C++ package
|
||||||
|
https://github.com/google/glog
|
||||||
|
|
||||||
|
By binding methods to booleans it is possible to use the log package
|
||||||
|
without paying the expense of evaluating the arguments to the log.
|
||||||
|
Through the -vmodule flag, the package also provides fine-grained
|
||||||
|
control over logging at the file level.
|
||||||
|
|
||||||
|
The comment from glog.go introduces the ideas:
|
||||||
|
|
||||||
|
Package glog implements logging analogous to the Google-internal
|
||||||
|
C++ INFO/ERROR/V setup. It provides functions Info, Warning,
|
||||||
|
Error, Fatal, plus formatting variants such as Infof. It
|
||||||
|
also provides V-style logging controlled by the -v and
|
||||||
|
-vmodule=file=2 flags.
|
||||||
|
|
||||||
|
Basic examples:
|
||||||
|
|
||||||
|
glog.Info("Prepare to repel boarders")
|
||||||
|
|
||||||
|
glog.Fatalf("Initialization failed: %s", err)
|
||||||
|
|
||||||
|
See the documentation for the V function for an explanation
|
||||||
|
of these examples:
|
||||||
|
|
||||||
|
if glog.V(2) {
|
||||||
|
glog.Info("Starting transaction...")
|
||||||
|
}
|
||||||
|
|
||||||
|
glog.V(2).Infoln("Processed", nItems, "elements")
|
||||||
|
|
||||||
|
|
||||||
|
The repository contains an open source version of the log package
|
||||||
|
used inside Google. The master copy of the source lives inside
|
||||||
|
Google, not here. The code in this repo is for export only and is not itself
|
||||||
|
under development. Feature requests will be ignored.
|
||||||
|
|
||||||
|
Send bug reports to golang-nuts@googlegroups.com.
|
||||||
1180
vendor/github.com/golang/glog/glog.go
generated
vendored
Normal file
1180
vendor/github.com/golang/glog/glog.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
124
vendor/github.com/golang/glog/glog_file.go
generated
vendored
Normal file
124
vendor/github.com/golang/glog/glog_file.go
generated
vendored
Normal file
|
|
@ -0,0 +1,124 @@
|
||||||
|
// Go support for leveled logs, analogous to https://code.google.com/p/google-glog/
|
||||||
|
//
|
||||||
|
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
// File I/O for logs.
|
||||||
|
|
||||||
|
package glog
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/user"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MaxSize is the maximum size of a log file in bytes.
|
||||||
|
var MaxSize uint64 = 1024 * 1024 * 1800
|
||||||
|
|
||||||
|
// logDirs lists the candidate directories for new log files.
|
||||||
|
var logDirs []string
|
||||||
|
|
||||||
|
// If non-empty, overrides the choice of directory in which to write logs.
|
||||||
|
// See createLogDirs for the full list of possible destinations.
|
||||||
|
var logDir = flag.String("log_dir", "", "If non-empty, write log files in this directory")
|
||||||
|
|
||||||
|
func createLogDirs() {
|
||||||
|
if *logDir != "" {
|
||||||
|
logDirs = append(logDirs, *logDir)
|
||||||
|
}
|
||||||
|
logDirs = append(logDirs, os.TempDir())
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
pid = os.Getpid()
|
||||||
|
program = filepath.Base(os.Args[0])
|
||||||
|
host = "unknownhost"
|
||||||
|
userName = "unknownuser"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
h, err := os.Hostname()
|
||||||
|
if err == nil {
|
||||||
|
host = shortHostname(h)
|
||||||
|
}
|
||||||
|
|
||||||
|
current, err := user.Current()
|
||||||
|
if err == nil {
|
||||||
|
userName = current.Username
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sanitize userName since it may contain filepath separators on Windows.
|
||||||
|
userName = strings.Replace(userName, `\`, "_", -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// shortHostname returns its argument, truncating at the first period.
|
||||||
|
// For instance, given "www.google.com" it returns "www".
|
||||||
|
func shortHostname(hostname string) string {
|
||||||
|
if i := strings.Index(hostname, "."); i >= 0 {
|
||||||
|
return hostname[:i]
|
||||||
|
}
|
||||||
|
return hostname
|
||||||
|
}
|
||||||
|
|
||||||
|
// logName returns a new log file name containing tag, with start time t, and
|
||||||
|
// the name for the symlink for tag.
|
||||||
|
func logName(tag string, t time.Time) (name, link string) {
|
||||||
|
name = fmt.Sprintf("%s.%s.%s.log.%s.%04d%02d%02d-%02d%02d%02d.%d",
|
||||||
|
program,
|
||||||
|
host,
|
||||||
|
userName,
|
||||||
|
tag,
|
||||||
|
t.Year(),
|
||||||
|
t.Month(),
|
||||||
|
t.Day(),
|
||||||
|
t.Hour(),
|
||||||
|
t.Minute(),
|
||||||
|
t.Second(),
|
||||||
|
pid)
|
||||||
|
return name, program + "." + tag
|
||||||
|
}
|
||||||
|
|
||||||
|
var onceLogDirs sync.Once
|
||||||
|
|
||||||
|
// create creates a new log file and returns the file and its filename, which
|
||||||
|
// contains tag ("INFO", "FATAL", etc.) and t. If the file is created
|
||||||
|
// successfully, create also attempts to update the symlink for that tag, ignoring
|
||||||
|
// errors.
|
||||||
|
func create(tag string, t time.Time) (f *os.File, filename string, err error) {
|
||||||
|
onceLogDirs.Do(createLogDirs)
|
||||||
|
if len(logDirs) == 0 {
|
||||||
|
return nil, "", errors.New("log: no log dirs")
|
||||||
|
}
|
||||||
|
name, link := logName(tag, t)
|
||||||
|
var lastErr error
|
||||||
|
for _, dir := range logDirs {
|
||||||
|
fname := filepath.Join(dir, name)
|
||||||
|
f, err := os.Create(fname)
|
||||||
|
if err == nil {
|
||||||
|
symlink := filepath.Join(dir, link)
|
||||||
|
os.Remove(symlink) // ignore err
|
||||||
|
os.Symlink(name, symlink) // ignore err
|
||||||
|
return f, fname, nil
|
||||||
|
}
|
||||||
|
lastErr = err
|
||||||
|
}
|
||||||
|
return nil, "", fmt.Errorf("log: cannot create log: %v", lastErr)
|
||||||
|
}
|
||||||
11
vendor/github.com/grokify/html-strip-tags-go/.codeclimate.yml
generated
vendored
Normal file
11
vendor/github.com/grokify/html-strip-tags-go/.codeclimate.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
engines:
|
||||||
|
gofmt:
|
||||||
|
enabled: true
|
||||||
|
golint:
|
||||||
|
enabled: true
|
||||||
|
govet:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
ratings:
|
||||||
|
paths:
|
||||||
|
- "**.go"
|
||||||
25
vendor/github.com/grokify/html-strip-tags-go/.travis.yml
generated
vendored
Normal file
25
vendor/github.com/grokify/html-strip-tags-go/.travis.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
language: go
|
||||||
|
go_import_path: github.com/grokify/html-strip-tags-go
|
||||||
|
go:
|
||||||
|
- "1.14.x"
|
||||||
|
- "1.13.x"
|
||||||
|
- "1.12.x"
|
||||||
|
- "1.11.x"
|
||||||
|
- "1.10.x"
|
||||||
|
- "1.9.x"
|
||||||
|
- "1.8.x"
|
||||||
|
- "1.7.x"
|
||||||
|
- "1.6.x"
|
||||||
|
- "1.5.x"
|
||||||
|
- "1.4.x"
|
||||||
|
- "1.3.x"
|
||||||
|
- "1.2.x"
|
||||||
|
- tip
|
||||||
|
matrix:
|
||||||
|
allow_failures:
|
||||||
|
- go: tip
|
||||||
|
install:
|
||||||
|
- go get -t -v ./...
|
||||||
|
script:
|
||||||
|
- go test -v ./...
|
||||||
|
|
||||||
27
vendor/github.com/grokify/html-strip-tags-go/LICENSE
generated
vendored
Normal file
27
vendor/github.com/grokify/html-strip-tags-go/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google Inc. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
22
vendor/github.com/grokify/html-strip-tags-go/PATENTS
generated
vendored
Normal file
22
vendor/github.com/grokify/html-strip-tags-go/PATENTS
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
Additional IP Rights Grant (Patents)
|
||||||
|
|
||||||
|
"This implementation" means the copyrightable works distributed by
|
||||||
|
Google as part of the Go project.
|
||||||
|
|
||||||
|
Google 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,
|
||||||
|
transfer and otherwise run, modify and propagate the contents of this
|
||||||
|
implementation of Go, where such license applies only to those patent
|
||||||
|
claims, both currently owned or controlled by Google and acquired in
|
||||||
|
the future, licensable by Google that are necessarily infringed by this
|
||||||
|
implementation of Go. This grant does not include claims that would be
|
||||||
|
infringed only as a consequence of further modification of this
|
||||||
|
implementation. If you or your agent or exclusive licensee institute or
|
||||||
|
order or agree to the institution of patent litigation against any
|
||||||
|
entity (including a cross-claim or counterclaim in a lawsuit) alleging
|
||||||
|
that this implementation of Go or any code incorporated within this
|
||||||
|
implementation of Go constitutes direct or contributory patent
|
||||||
|
infringement, or inducement of patent infringement, then any patent
|
||||||
|
rights granted to you under this License for this implementation of Go
|
||||||
|
shall terminate as of the date such litigation is filed.
|
||||||
52
vendor/github.com/grokify/html-strip-tags-go/README.md
generated
vendored
Normal file
52
vendor/github.com/grokify/html-strip-tags-go/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
HTML StripTags for Go
|
||||||
|
=====================
|
||||||
|
|
||||||
|
[![Used By][used-by-svg]][used-by-link]
|
||||||
|
[![Build Status][build-status-svg]][build-status-link]
|
||||||
|
[![Go Report Card][goreport-svg]][goreport-link]
|
||||||
|
[![Docs][docs-godoc-svg]][docs-godoc-link]
|
||||||
|
[![License][license-svg]][license-link]
|
||||||
|
|
||||||
|
This is a Go package containing an extracted version of the unexported `stripTags` function in `html/template/html.go`.
|
||||||
|
|
||||||
|
:warning: This package does not protect against untrusted input. Please use [bluemonday](https://github.com/microcosm-cc/bluemonday) if you have untrusted data :warning:
|
||||||
|
|
||||||
|
## Background
|
||||||
|
|
||||||
|
* The `stripTags` function in `html/template/html.go` is very useful, however, it is not exported.
|
||||||
|
* Requests were made [on GitHub](https://github.com/golang/go/issues/5884) without success.
|
||||||
|
* This package is a repo for work done by [Christopher Hesse](https://github.com/christopherhesse) provided in this [Gist](https://gist.github.com/christopherhesse/d422447a086d373a967f).
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ go get github.com/grokify/html-strip-tags-go
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```go
|
||||||
|
import(
|
||||||
|
"github.com/grokify/html-strip-tags-go" // => strip
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
original := "<h1>Hello World</h1>"
|
||||||
|
stripped := strip.StripTags(original) // => "Hello World"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
[used-by-svg]: https://sourcegraph.com/github.com/grokify/html-strip-tags-go/-/badge.svg
|
||||||
|
[used-by-link]: https://sourcegraph.com/github.com/grokify/html-strip-tags-go?badge
|
||||||
|
[goreport-svg]: https://goreportcard.com/badge/github.com/grokify/html-strip-tags-go
|
||||||
|
[goreport-link]: https://goreportcard.com/report/github.com/grokify/html-strip-tags-go
|
||||||
|
[build-status-svg]: https://api.travis-ci.org/grokify/html-strip-tags-go.svg?branch=master
|
||||||
|
[build-status-link]: https://travis-ci.org/grokify/html-strip-tags-go
|
||||||
|
[coverage-status-svg]: https://coveralls.io/repos/grokify/html-strip-tags-go/badge.svg?branch=master
|
||||||
|
[coverage-status-link]: https://coveralls.io/r/grokify/html-strip-tags-go?branch=master
|
||||||
|
[codeclimate-status-svg]: https://codeclimate.com/github/grokify/html-strip-tags-go/badges/gpa.svg
|
||||||
|
[codeclimate-status-link]: https://codeclimate.com/github/grokify/html-strip-tags-go
|
||||||
|
[docs-godoc-svg]: https://img.shields.io/badge/docs-godoc-blue.svg
|
||||||
|
[docs-godoc-link]: https://godoc.org/github.com/grokify/html-strip-tags-go
|
||||||
|
[license-svg]: https://img.shields.io/badge/license-BSD--style+patent--grant-blue.svg
|
||||||
|
[license-link]: https://github.com/grokify/html-strip-tags-go/blob/master/LICENSE
|
||||||
3
vendor/github.com/grokify/html-strip-tags-go/go.mod
generated
vendored
Normal file
3
vendor/github.com/grokify/html-strip-tags-go/go.mod
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
module github.com/grokify/html-strip-tags-go
|
||||||
|
|
||||||
|
go 1.13
|
||||||
3712
vendor/github.com/grokify/html-strip-tags-go/strip.go
generated
vendored
Normal file
3712
vendor/github.com/grokify/html-strip-tags-go/strip.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
3
vendor/github.com/json-iterator/go/.codecov.yml
generated
vendored
Normal file
3
vendor/github.com/json-iterator/go/.codecov.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
ignore:
|
||||||
|
- "output_tests/.*"
|
||||||
|
|
||||||
4
vendor/github.com/json-iterator/go/.gitignore
generated
vendored
Normal file
4
vendor/github.com/json-iterator/go/.gitignore
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
/vendor
|
||||||
|
/bug_test.go
|
||||||
|
/coverage.txt
|
||||||
|
/.idea
|
||||||
14
vendor/github.com/json-iterator/go/.travis.yml
generated
vendored
Normal file
14
vendor/github.com/json-iterator/go/.travis.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
language: go
|
||||||
|
|
||||||
|
go:
|
||||||
|
- 1.8.x
|
||||||
|
- 1.x
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- go get -t -v ./...
|
||||||
|
|
||||||
|
script:
|
||||||
|
- ./test.sh
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
- bash <(curl -s https://codecov.io/bash)
|
||||||
21
vendor/github.com/json-iterator/go/Gopkg.lock
generated
vendored
Normal file
21
vendor/github.com/json-iterator/go/Gopkg.lock
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||||
|
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/modern-go/concurrent"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "e0a39a4cb4216ea8db28e22a69f4ec25610d513a"
|
||||||
|
version = "1.0.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/modern-go/reflect2"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd"
|
||||||
|
version = "1.0.1"
|
||||||
|
|
||||||
|
[solve-meta]
|
||||||
|
analyzer-name = "dep"
|
||||||
|
analyzer-version = 1
|
||||||
|
inputs-digest = "ea54a775e5a354cb015502d2e7aa4b74230fc77e894f34a838b268c25ec8eeb8"
|
||||||
|
solver-name = "gps-cdcl"
|
||||||
|
solver-version = 1
|
||||||
26
vendor/github.com/json-iterator/go/Gopkg.toml
generated
vendored
Normal file
26
vendor/github.com/json-iterator/go/Gopkg.toml
generated
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
# Gopkg.toml example
|
||||||
|
#
|
||||||
|
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
|
||||||
|
# for detailed Gopkg.toml documentation.
|
||||||
|
#
|
||||||
|
# required = ["github.com/user/thing/cmd/thing"]
|
||||||
|
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
|
||||||
|
#
|
||||||
|
# [[constraint]]
|
||||||
|
# name = "github.com/user/project"
|
||||||
|
# version = "1.0.0"
|
||||||
|
#
|
||||||
|
# [[constraint]]
|
||||||
|
# name = "github.com/user/project2"
|
||||||
|
# branch = "dev"
|
||||||
|
# source = "github.com/myfork/project2"
|
||||||
|
#
|
||||||
|
# [[override]]
|
||||||
|
# name = "github.com/x/y"
|
||||||
|
# version = "2.4.0"
|
||||||
|
|
||||||
|
ignored = ["github.com/davecgh/go-spew*","github.com/google/gofuzz*","github.com/stretchr/testify*"]
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/modern-go/reflect2"
|
||||||
|
version = "1.0.1"
|
||||||
21
vendor/github.com/json-iterator/go/LICENSE
generated
vendored
Normal file
21
vendor/github.com/json-iterator/go/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2016 json-iterator
|
||||||
|
|
||||||
|
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.
|
||||||
87
vendor/github.com/json-iterator/go/README.md
generated
vendored
Normal file
87
vendor/github.com/json-iterator/go/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,87 @@
|
||||||
|
[](https://sourcegraph.com/github.com/json-iterator/go?badge)
|
||||||
|
[](https://pkg.go.dev/github.com/json-iterator/go)
|
||||||
|
[](https://travis-ci.org/json-iterator/go)
|
||||||
|
[](https://codecov.io/gh/json-iterator/go)
|
||||||
|
[](https://goreportcard.com/report/github.com/json-iterator/go)
|
||||||
|
[](https://raw.githubusercontent.com/json-iterator/go/master/LICENSE)
|
||||||
|
[](https://gitter.im/json-iterator/Lobby)
|
||||||
|
|
||||||
|
A high-performance 100% compatible drop-in replacement of "encoding/json"
|
||||||
|
|
||||||
|
You can also use thrift like JSON using [thrift-iterator](https://github.com/thrift-iterator/go)
|
||||||
|
|
||||||
|
# Benchmark
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Source code: https://github.com/json-iterator/go-benchmark/blob/master/src/github.com/json-iterator/go-benchmark/benchmark_medium_payload_test.go
|
||||||
|
|
||||||
|
Raw Result (easyjson requires static code generation)
|
||||||
|
|
||||||
|
| | ns/op | allocation bytes | allocation times |
|
||||||
|
| --------------- | ----------- | ---------------- | ---------------- |
|
||||||
|
| std decode | 35510 ns/op | 1960 B/op | 99 allocs/op |
|
||||||
|
| easyjson decode | 8499 ns/op | 160 B/op | 4 allocs/op |
|
||||||
|
| jsoniter decode | 5623 ns/op | 160 B/op | 3 allocs/op |
|
||||||
|
| std encode | 2213 ns/op | 712 B/op | 5 allocs/op |
|
||||||
|
| easyjson encode | 883 ns/op | 576 B/op | 3 allocs/op |
|
||||||
|
| jsoniter encode | 837 ns/op | 384 B/op | 4 allocs/op |
|
||||||
|
|
||||||
|
Always benchmark with your own workload.
|
||||||
|
The result depends heavily on the data input.
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
100% compatibility with standard lib
|
||||||
|
|
||||||
|
Replace
|
||||||
|
|
||||||
|
```go
|
||||||
|
import "encoding/json"
|
||||||
|
json.Marshal(&data)
|
||||||
|
```
|
||||||
|
|
||||||
|
with
|
||||||
|
|
||||||
|
```go
|
||||||
|
import jsoniter "github.com/json-iterator/go"
|
||||||
|
|
||||||
|
var json = jsoniter.ConfigCompatibleWithStandardLibrary
|
||||||
|
json.Marshal(&data)
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace
|
||||||
|
|
||||||
|
```go
|
||||||
|
import "encoding/json"
|
||||||
|
json.Unmarshal(input, &data)
|
||||||
|
```
|
||||||
|
|
||||||
|
with
|
||||||
|
|
||||||
|
```go
|
||||||
|
import jsoniter "github.com/json-iterator/go"
|
||||||
|
|
||||||
|
var json = jsoniter.ConfigCompatibleWithStandardLibrary
|
||||||
|
json.Unmarshal(input, &data)
|
||||||
|
```
|
||||||
|
|
||||||
|
[More documentation](http://jsoniter.com/migrate-from-go-std.html)
|
||||||
|
|
||||||
|
# How to get
|
||||||
|
|
||||||
|
```
|
||||||
|
go get github.com/json-iterator/go
|
||||||
|
```
|
||||||
|
|
||||||
|
# Contribution Welcomed !
|
||||||
|
|
||||||
|
Contributors
|
||||||
|
|
||||||
|
- [thockin](https://github.com/thockin)
|
||||||
|
- [mattn](https://github.com/mattn)
|
||||||
|
- [cch123](https://github.com/cch123)
|
||||||
|
- [Oleg Shaldybin](https://github.com/olegshaldybin)
|
||||||
|
- [Jason Toffaletti](https://github.com/toffaletti)
|
||||||
|
|
||||||
|
Report issue or pull request, or email taowen@gmail.com, or [](https://gitter.im/json-iterator/Lobby)
|
||||||
150
vendor/github.com/json-iterator/go/adapter.go
generated
vendored
Normal file
150
vendor/github.com/json-iterator/go/adapter.go
generated
vendored
Normal file
|
|
@ -0,0 +1,150 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RawMessage to make replace json with jsoniter
|
||||||
|
type RawMessage []byte
|
||||||
|
|
||||||
|
// Unmarshal adapts to json/encoding Unmarshal API
|
||||||
|
//
|
||||||
|
// Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v.
|
||||||
|
// Refer to https://godoc.org/encoding/json#Unmarshal for more information
|
||||||
|
func Unmarshal(data []byte, v interface{}) error {
|
||||||
|
return ConfigDefault.Unmarshal(data, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalFromString is a convenient method to read from string instead of []byte
|
||||||
|
func UnmarshalFromString(str string, v interface{}) error {
|
||||||
|
return ConfigDefault.UnmarshalFromString(str, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get quick method to get value from deeply nested JSON structure
|
||||||
|
func Get(data []byte, path ...interface{}) Any {
|
||||||
|
return ConfigDefault.Get(data, path...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Marshal adapts to json/encoding Marshal API
|
||||||
|
//
|
||||||
|
// Marshal returns the JSON encoding of v, adapts to json/encoding Marshal API
|
||||||
|
// Refer to https://godoc.org/encoding/json#Marshal for more information
|
||||||
|
func Marshal(v interface{}) ([]byte, error) {
|
||||||
|
return ConfigDefault.Marshal(v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalIndent same as json.MarshalIndent. Prefix is not supported.
|
||||||
|
func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) {
|
||||||
|
return ConfigDefault.MarshalIndent(v, prefix, indent)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalToString convenient method to write as string instead of []byte
|
||||||
|
func MarshalToString(v interface{}) (string, error) {
|
||||||
|
return ConfigDefault.MarshalToString(v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewDecoder adapts to json/stream NewDecoder API.
|
||||||
|
//
|
||||||
|
// NewDecoder returns a new decoder that reads from r.
|
||||||
|
//
|
||||||
|
// Instead of a json/encoding Decoder, an Decoder is returned
|
||||||
|
// Refer to https://godoc.org/encoding/json#NewDecoder for more information
|
||||||
|
func NewDecoder(reader io.Reader) *Decoder {
|
||||||
|
return ConfigDefault.NewDecoder(reader)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decoder reads and decodes JSON values from an input stream.
|
||||||
|
// Decoder provides identical APIs with json/stream Decoder (Token() and UseNumber() are in progress)
|
||||||
|
type Decoder struct {
|
||||||
|
iter *Iterator
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode decode JSON into interface{}
|
||||||
|
func (adapter *Decoder) Decode(obj interface{}) error {
|
||||||
|
if adapter.iter.head == adapter.iter.tail && adapter.iter.reader != nil {
|
||||||
|
if !adapter.iter.loadMore() {
|
||||||
|
return io.EOF
|
||||||
|
}
|
||||||
|
}
|
||||||
|
adapter.iter.ReadVal(obj)
|
||||||
|
err := adapter.iter.Error
|
||||||
|
if err == io.EOF {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return adapter.iter.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
// More is there more?
|
||||||
|
func (adapter *Decoder) More() bool {
|
||||||
|
iter := adapter.iter
|
||||||
|
if iter.Error != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
c := iter.nextToken()
|
||||||
|
if c == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
iter.unreadByte()
|
||||||
|
return c != ']' && c != '}'
|
||||||
|
}
|
||||||
|
|
||||||
|
// Buffered remaining buffer
|
||||||
|
func (adapter *Decoder) Buffered() io.Reader {
|
||||||
|
remaining := adapter.iter.buf[adapter.iter.head:adapter.iter.tail]
|
||||||
|
return bytes.NewReader(remaining)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UseNumber causes the Decoder to unmarshal a number into an interface{} as a
|
||||||
|
// Number instead of as a float64.
|
||||||
|
func (adapter *Decoder) UseNumber() {
|
||||||
|
cfg := adapter.iter.cfg.configBeforeFrozen
|
||||||
|
cfg.UseNumber = true
|
||||||
|
adapter.iter.cfg = cfg.frozeWithCacheReuse(adapter.iter.cfg.extraExtensions)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DisallowUnknownFields causes the Decoder to return an error when the destination
|
||||||
|
// is a struct and the input contains object keys which do not match any
|
||||||
|
// non-ignored, exported fields in the destination.
|
||||||
|
func (adapter *Decoder) DisallowUnknownFields() {
|
||||||
|
cfg := adapter.iter.cfg.configBeforeFrozen
|
||||||
|
cfg.DisallowUnknownFields = true
|
||||||
|
adapter.iter.cfg = cfg.frozeWithCacheReuse(adapter.iter.cfg.extraExtensions)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewEncoder same as json.NewEncoder
|
||||||
|
func NewEncoder(writer io.Writer) *Encoder {
|
||||||
|
return ConfigDefault.NewEncoder(writer)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encoder same as json.Encoder
|
||||||
|
type Encoder struct {
|
||||||
|
stream *Stream
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encode encode interface{} as JSON to io.Writer
|
||||||
|
func (adapter *Encoder) Encode(val interface{}) error {
|
||||||
|
adapter.stream.WriteVal(val)
|
||||||
|
adapter.stream.WriteRaw("\n")
|
||||||
|
adapter.stream.Flush()
|
||||||
|
return adapter.stream.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetIndent set the indention. Prefix is not supported
|
||||||
|
func (adapter *Encoder) SetIndent(prefix, indent string) {
|
||||||
|
config := adapter.stream.cfg.configBeforeFrozen
|
||||||
|
config.IndentionStep = len(indent)
|
||||||
|
adapter.stream.cfg = config.frozeWithCacheReuse(adapter.stream.cfg.extraExtensions)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEscapeHTML escape html by default, set to false to disable
|
||||||
|
func (adapter *Encoder) SetEscapeHTML(escapeHTML bool) {
|
||||||
|
config := adapter.stream.cfg.configBeforeFrozen
|
||||||
|
config.EscapeHTML = escapeHTML
|
||||||
|
adapter.stream.cfg = config.frozeWithCacheReuse(adapter.stream.cfg.extraExtensions)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Valid reports whether data is a valid JSON encoding.
|
||||||
|
func Valid(data []byte) bool {
|
||||||
|
return ConfigDefault.Valid(data)
|
||||||
|
}
|
||||||
325
vendor/github.com/json-iterator/go/any.go
generated
vendored
Normal file
325
vendor/github.com/json-iterator/go/any.go
generated
vendored
Normal file
|
|
@ -0,0 +1,325 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"github.com/modern-go/reflect2"
|
||||||
|
"io"
|
||||||
|
"reflect"
|
||||||
|
"strconv"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Any generic object representation.
|
||||||
|
// The lazy json implementation holds []byte and parse lazily.
|
||||||
|
type Any interface {
|
||||||
|
LastError() error
|
||||||
|
ValueType() ValueType
|
||||||
|
MustBeValid() Any
|
||||||
|
ToBool() bool
|
||||||
|
ToInt() int
|
||||||
|
ToInt32() int32
|
||||||
|
ToInt64() int64
|
||||||
|
ToUint() uint
|
||||||
|
ToUint32() uint32
|
||||||
|
ToUint64() uint64
|
||||||
|
ToFloat32() float32
|
||||||
|
ToFloat64() float64
|
||||||
|
ToString() string
|
||||||
|
ToVal(val interface{})
|
||||||
|
Get(path ...interface{}) Any
|
||||||
|
Size() int
|
||||||
|
Keys() []string
|
||||||
|
GetInterface() interface{}
|
||||||
|
WriteTo(stream *Stream)
|
||||||
|
}
|
||||||
|
|
||||||
|
type baseAny struct{}
|
||||||
|
|
||||||
|
func (any *baseAny) Get(path ...interface{}) Any {
|
||||||
|
return &invalidAny{baseAny{}, fmt.Errorf("GetIndex %v from simple value", path)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *baseAny) Size() int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *baseAny) Keys() []string {
|
||||||
|
return []string{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *baseAny) ToVal(obj interface{}) {
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// WrapInt32 turn int32 into Any interface
|
||||||
|
func WrapInt32(val int32) Any {
|
||||||
|
return &int32Any{baseAny{}, val}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WrapInt64 turn int64 into Any interface
|
||||||
|
func WrapInt64(val int64) Any {
|
||||||
|
return &int64Any{baseAny{}, val}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WrapUint32 turn uint32 into Any interface
|
||||||
|
func WrapUint32(val uint32) Any {
|
||||||
|
return &uint32Any{baseAny{}, val}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WrapUint64 turn uint64 into Any interface
|
||||||
|
func WrapUint64(val uint64) Any {
|
||||||
|
return &uint64Any{baseAny{}, val}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WrapFloat64 turn float64 into Any interface
|
||||||
|
func WrapFloat64(val float64) Any {
|
||||||
|
return &floatAny{baseAny{}, val}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WrapString turn string into Any interface
|
||||||
|
func WrapString(val string) Any {
|
||||||
|
return &stringAny{baseAny{}, val}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wrap turn a go object into Any interface
|
||||||
|
func Wrap(val interface{}) Any {
|
||||||
|
if val == nil {
|
||||||
|
return &nilAny{}
|
||||||
|
}
|
||||||
|
asAny, isAny := val.(Any)
|
||||||
|
if isAny {
|
||||||
|
return asAny
|
||||||
|
}
|
||||||
|
typ := reflect2.TypeOf(val)
|
||||||
|
switch typ.Kind() {
|
||||||
|
case reflect.Slice:
|
||||||
|
return wrapArray(val)
|
||||||
|
case reflect.Struct:
|
||||||
|
return wrapStruct(val)
|
||||||
|
case reflect.Map:
|
||||||
|
return wrapMap(val)
|
||||||
|
case reflect.String:
|
||||||
|
return WrapString(val.(string))
|
||||||
|
case reflect.Int:
|
||||||
|
if strconv.IntSize == 32 {
|
||||||
|
return WrapInt32(int32(val.(int)))
|
||||||
|
}
|
||||||
|
return WrapInt64(int64(val.(int)))
|
||||||
|
case reflect.Int8:
|
||||||
|
return WrapInt32(int32(val.(int8)))
|
||||||
|
case reflect.Int16:
|
||||||
|
return WrapInt32(int32(val.(int16)))
|
||||||
|
case reflect.Int32:
|
||||||
|
return WrapInt32(val.(int32))
|
||||||
|
case reflect.Int64:
|
||||||
|
return WrapInt64(val.(int64))
|
||||||
|
case reflect.Uint:
|
||||||
|
if strconv.IntSize == 32 {
|
||||||
|
return WrapUint32(uint32(val.(uint)))
|
||||||
|
}
|
||||||
|
return WrapUint64(uint64(val.(uint)))
|
||||||
|
case reflect.Uintptr:
|
||||||
|
if ptrSize == 32 {
|
||||||
|
return WrapUint32(uint32(val.(uintptr)))
|
||||||
|
}
|
||||||
|
return WrapUint64(uint64(val.(uintptr)))
|
||||||
|
case reflect.Uint8:
|
||||||
|
return WrapUint32(uint32(val.(uint8)))
|
||||||
|
case reflect.Uint16:
|
||||||
|
return WrapUint32(uint32(val.(uint16)))
|
||||||
|
case reflect.Uint32:
|
||||||
|
return WrapUint32(uint32(val.(uint32)))
|
||||||
|
case reflect.Uint64:
|
||||||
|
return WrapUint64(val.(uint64))
|
||||||
|
case reflect.Float32:
|
||||||
|
return WrapFloat64(float64(val.(float32)))
|
||||||
|
case reflect.Float64:
|
||||||
|
return WrapFloat64(val.(float64))
|
||||||
|
case reflect.Bool:
|
||||||
|
if val.(bool) == true {
|
||||||
|
return &trueAny{}
|
||||||
|
}
|
||||||
|
return &falseAny{}
|
||||||
|
}
|
||||||
|
return &invalidAny{baseAny{}, fmt.Errorf("unsupported type: %v", typ)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadAny read next JSON element as an Any object. It is a better json.RawMessage.
|
||||||
|
func (iter *Iterator) ReadAny() Any {
|
||||||
|
return iter.readAny()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) readAny() Any {
|
||||||
|
c := iter.nextToken()
|
||||||
|
switch c {
|
||||||
|
case '"':
|
||||||
|
iter.unreadByte()
|
||||||
|
return &stringAny{baseAny{}, iter.ReadString()}
|
||||||
|
case 'n':
|
||||||
|
iter.skipThreeBytes('u', 'l', 'l') // null
|
||||||
|
return &nilAny{}
|
||||||
|
case 't':
|
||||||
|
iter.skipThreeBytes('r', 'u', 'e') // true
|
||||||
|
return &trueAny{}
|
||||||
|
case 'f':
|
||||||
|
iter.skipFourBytes('a', 'l', 's', 'e') // false
|
||||||
|
return &falseAny{}
|
||||||
|
case '{':
|
||||||
|
return iter.readObjectAny()
|
||||||
|
case '[':
|
||||||
|
return iter.readArrayAny()
|
||||||
|
case '-':
|
||||||
|
return iter.readNumberAny(false)
|
||||||
|
case 0:
|
||||||
|
return &invalidAny{baseAny{}, errors.New("input is empty")}
|
||||||
|
default:
|
||||||
|
return iter.readNumberAny(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) readNumberAny(positive bool) Any {
|
||||||
|
iter.startCapture(iter.head - 1)
|
||||||
|
iter.skipNumber()
|
||||||
|
lazyBuf := iter.stopCapture()
|
||||||
|
return &numberLazyAny{baseAny{}, iter.cfg, lazyBuf, nil}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) readObjectAny() Any {
|
||||||
|
iter.startCapture(iter.head - 1)
|
||||||
|
iter.skipObject()
|
||||||
|
lazyBuf := iter.stopCapture()
|
||||||
|
return &objectLazyAny{baseAny{}, iter.cfg, lazyBuf, nil}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) readArrayAny() Any {
|
||||||
|
iter.startCapture(iter.head - 1)
|
||||||
|
iter.skipArray()
|
||||||
|
lazyBuf := iter.stopCapture()
|
||||||
|
return &arrayLazyAny{baseAny{}, iter.cfg, lazyBuf, nil}
|
||||||
|
}
|
||||||
|
|
||||||
|
func locateObjectField(iter *Iterator, target string) []byte {
|
||||||
|
var found []byte
|
||||||
|
iter.ReadObjectCB(func(iter *Iterator, field string) bool {
|
||||||
|
if field == target {
|
||||||
|
found = iter.SkipAndReturnBytes()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
iter.Skip()
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
return found
|
||||||
|
}
|
||||||
|
|
||||||
|
func locateArrayElement(iter *Iterator, target int) []byte {
|
||||||
|
var found []byte
|
||||||
|
n := 0
|
||||||
|
iter.ReadArrayCB(func(iter *Iterator) bool {
|
||||||
|
if n == target {
|
||||||
|
found = iter.SkipAndReturnBytes()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
iter.Skip()
|
||||||
|
n++
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
return found
|
||||||
|
}
|
||||||
|
|
||||||
|
func locatePath(iter *Iterator, path []interface{}) Any {
|
||||||
|
for i, pathKeyObj := range path {
|
||||||
|
switch pathKey := pathKeyObj.(type) {
|
||||||
|
case string:
|
||||||
|
valueBytes := locateObjectField(iter, pathKey)
|
||||||
|
if valueBytes == nil {
|
||||||
|
return newInvalidAny(path[i:])
|
||||||
|
}
|
||||||
|
iter.ResetBytes(valueBytes)
|
||||||
|
case int:
|
||||||
|
valueBytes := locateArrayElement(iter, pathKey)
|
||||||
|
if valueBytes == nil {
|
||||||
|
return newInvalidAny(path[i:])
|
||||||
|
}
|
||||||
|
iter.ResetBytes(valueBytes)
|
||||||
|
case int32:
|
||||||
|
if '*' == pathKey {
|
||||||
|
return iter.readAny().Get(path[i:]...)
|
||||||
|
}
|
||||||
|
return newInvalidAny(path[i:])
|
||||||
|
default:
|
||||||
|
return newInvalidAny(path[i:])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
|
return &invalidAny{baseAny{}, iter.Error}
|
||||||
|
}
|
||||||
|
return iter.readAny()
|
||||||
|
}
|
||||||
|
|
||||||
|
var anyType = reflect2.TypeOfPtr((*Any)(nil)).Elem()
|
||||||
|
|
||||||
|
func createDecoderOfAny(ctx *ctx, typ reflect2.Type) ValDecoder {
|
||||||
|
if typ == anyType {
|
||||||
|
return &directAnyCodec{}
|
||||||
|
}
|
||||||
|
if typ.Implements(anyType) {
|
||||||
|
return &anyCodec{
|
||||||
|
valType: typ,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func createEncoderOfAny(ctx *ctx, typ reflect2.Type) ValEncoder {
|
||||||
|
if typ == anyType {
|
||||||
|
return &directAnyCodec{}
|
||||||
|
}
|
||||||
|
if typ.Implements(anyType) {
|
||||||
|
return &anyCodec{
|
||||||
|
valType: typ,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type anyCodec struct {
|
||||||
|
valType reflect2.Type
|
||||||
|
}
|
||||||
|
|
||||||
|
func (codec *anyCodec) Decode(ptr unsafe.Pointer, iter *Iterator) {
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (codec *anyCodec) Encode(ptr unsafe.Pointer, stream *Stream) {
|
||||||
|
obj := codec.valType.UnsafeIndirect(ptr)
|
||||||
|
any := obj.(Any)
|
||||||
|
any.WriteTo(stream)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (codec *anyCodec) IsEmpty(ptr unsafe.Pointer) bool {
|
||||||
|
obj := codec.valType.UnsafeIndirect(ptr)
|
||||||
|
any := obj.(Any)
|
||||||
|
return any.Size() == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type directAnyCodec struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (codec *directAnyCodec) Decode(ptr unsafe.Pointer, iter *Iterator) {
|
||||||
|
*(*Any)(ptr) = iter.readAny()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (codec *directAnyCodec) Encode(ptr unsafe.Pointer, stream *Stream) {
|
||||||
|
any := *(*Any)(ptr)
|
||||||
|
if any == nil {
|
||||||
|
stream.WriteNil()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
any.WriteTo(stream)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (codec *directAnyCodec) IsEmpty(ptr unsafe.Pointer) bool {
|
||||||
|
any := *(*Any)(ptr)
|
||||||
|
return any.Size() == 0
|
||||||
|
}
|
||||||
278
vendor/github.com/json-iterator/go/any_array.go
generated
vendored
Normal file
278
vendor/github.com/json-iterator/go/any_array.go
generated
vendored
Normal file
|
|
@ -0,0 +1,278 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
type arrayLazyAny struct {
|
||||||
|
baseAny
|
||||||
|
cfg *frozenConfig
|
||||||
|
buf []byte
|
||||||
|
err error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayLazyAny) ValueType() ValueType {
|
||||||
|
return ArrayValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayLazyAny) MustBeValid() Any {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayLazyAny) LastError() error {
|
||||||
|
return any.err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayLazyAny) ToBool() bool {
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
return iter.ReadArray()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayLazyAny) ToInt() int {
|
||||||
|
if any.ToBool() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayLazyAny) ToInt32() int32 {
|
||||||
|
if any.ToBool() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayLazyAny) ToInt64() int64 {
|
||||||
|
if any.ToBool() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayLazyAny) ToUint() uint {
|
||||||
|
if any.ToBool() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayLazyAny) ToUint32() uint32 {
|
||||||
|
if any.ToBool() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayLazyAny) ToUint64() uint64 {
|
||||||
|
if any.ToBool() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayLazyAny) ToFloat32() float32 {
|
||||||
|
if any.ToBool() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayLazyAny) ToFloat64() float64 {
|
||||||
|
if any.ToBool() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayLazyAny) ToString() string {
|
||||||
|
return *(*string)(unsafe.Pointer(&any.buf))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayLazyAny) ToVal(val interface{}) {
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
iter.ReadVal(val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayLazyAny) Get(path ...interface{}) Any {
|
||||||
|
if len(path) == 0 {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
switch firstPath := path[0].(type) {
|
||||||
|
case int:
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
valueBytes := locateArrayElement(iter, firstPath)
|
||||||
|
if valueBytes == nil {
|
||||||
|
return newInvalidAny(path)
|
||||||
|
}
|
||||||
|
iter.ResetBytes(valueBytes)
|
||||||
|
return locatePath(iter, path[1:])
|
||||||
|
case int32:
|
||||||
|
if '*' == firstPath {
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
arr := make([]Any, 0)
|
||||||
|
iter.ReadArrayCB(func(iter *Iterator) bool {
|
||||||
|
found := iter.readAny().Get(path[1:]...)
|
||||||
|
if found.ValueType() != InvalidValue {
|
||||||
|
arr = append(arr, found)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
return wrapArray(arr)
|
||||||
|
}
|
||||||
|
return newInvalidAny(path)
|
||||||
|
default:
|
||||||
|
return newInvalidAny(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayLazyAny) Size() int {
|
||||||
|
size := 0
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
iter.ReadArrayCB(func(iter *Iterator) bool {
|
||||||
|
size++
|
||||||
|
iter.Skip()
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
return size
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayLazyAny) WriteTo(stream *Stream) {
|
||||||
|
stream.Write(any.buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayLazyAny) GetInterface() interface{} {
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
return iter.Read()
|
||||||
|
}
|
||||||
|
|
||||||
|
type arrayAny struct {
|
||||||
|
baseAny
|
||||||
|
val reflect.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
func wrapArray(val interface{}) *arrayAny {
|
||||||
|
return &arrayAny{baseAny{}, reflect.ValueOf(val)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayAny) ValueType() ValueType {
|
||||||
|
return ArrayValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayAny) MustBeValid() Any {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayAny) LastError() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayAny) ToBool() bool {
|
||||||
|
return any.val.Len() != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayAny) ToInt() int {
|
||||||
|
if any.val.Len() == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayAny) ToInt32() int32 {
|
||||||
|
if any.val.Len() == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayAny) ToInt64() int64 {
|
||||||
|
if any.val.Len() == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayAny) ToUint() uint {
|
||||||
|
if any.val.Len() == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayAny) ToUint32() uint32 {
|
||||||
|
if any.val.Len() == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayAny) ToUint64() uint64 {
|
||||||
|
if any.val.Len() == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayAny) ToFloat32() float32 {
|
||||||
|
if any.val.Len() == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayAny) ToFloat64() float64 {
|
||||||
|
if any.val.Len() == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayAny) ToString() string {
|
||||||
|
str, _ := MarshalToString(any.val.Interface())
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayAny) Get(path ...interface{}) Any {
|
||||||
|
if len(path) == 0 {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
switch firstPath := path[0].(type) {
|
||||||
|
case int:
|
||||||
|
if firstPath < 0 || firstPath >= any.val.Len() {
|
||||||
|
return newInvalidAny(path)
|
||||||
|
}
|
||||||
|
return Wrap(any.val.Index(firstPath).Interface())
|
||||||
|
case int32:
|
||||||
|
if '*' == firstPath {
|
||||||
|
mappedAll := make([]Any, 0)
|
||||||
|
for i := 0; i < any.val.Len(); i++ {
|
||||||
|
mapped := Wrap(any.val.Index(i).Interface()).Get(path[1:]...)
|
||||||
|
if mapped.ValueType() != InvalidValue {
|
||||||
|
mappedAll = append(mappedAll, mapped)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return wrapArray(mappedAll)
|
||||||
|
}
|
||||||
|
return newInvalidAny(path)
|
||||||
|
default:
|
||||||
|
return newInvalidAny(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayAny) Size() int {
|
||||||
|
return any.val.Len()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayAny) WriteTo(stream *Stream) {
|
||||||
|
stream.WriteVal(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *arrayAny) GetInterface() interface{} {
|
||||||
|
return any.val.Interface()
|
||||||
|
}
|
||||||
137
vendor/github.com/json-iterator/go/any_bool.go
generated
vendored
Normal file
137
vendor/github.com/json-iterator/go/any_bool.go
generated
vendored
Normal file
|
|
@ -0,0 +1,137 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
type trueAny struct {
|
||||||
|
baseAny
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *trueAny) LastError() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *trueAny) ToBool() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *trueAny) ToInt() int {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *trueAny) ToInt32() int32 {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *trueAny) ToInt64() int64 {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *trueAny) ToUint() uint {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *trueAny) ToUint32() uint32 {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *trueAny) ToUint64() uint64 {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *trueAny) ToFloat32() float32 {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *trueAny) ToFloat64() float64 {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *trueAny) ToString() string {
|
||||||
|
return "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *trueAny) WriteTo(stream *Stream) {
|
||||||
|
stream.WriteTrue()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *trueAny) Parse() *Iterator {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *trueAny) GetInterface() interface{} {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *trueAny) ValueType() ValueType {
|
||||||
|
return BoolValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *trueAny) MustBeValid() Any {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
|
||||||
|
type falseAny struct {
|
||||||
|
baseAny
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *falseAny) LastError() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *falseAny) ToBool() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *falseAny) ToInt() int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *falseAny) ToInt32() int32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *falseAny) ToInt64() int64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *falseAny) ToUint() uint {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *falseAny) ToUint32() uint32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *falseAny) ToUint64() uint64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *falseAny) ToFloat32() float32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *falseAny) ToFloat64() float64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *falseAny) ToString() string {
|
||||||
|
return "false"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *falseAny) WriteTo(stream *Stream) {
|
||||||
|
stream.WriteFalse()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *falseAny) Parse() *Iterator {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *falseAny) GetInterface() interface{} {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *falseAny) ValueType() ValueType {
|
||||||
|
return BoolValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *falseAny) MustBeValid() Any {
|
||||||
|
return any
|
||||||
|
}
|
||||||
83
vendor/github.com/json-iterator/go/any_float.go
generated
vendored
Normal file
83
vendor/github.com/json-iterator/go/any_float.go
generated
vendored
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
type floatAny struct {
|
||||||
|
baseAny
|
||||||
|
val float64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *floatAny) Parse() *Iterator {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *floatAny) ValueType() ValueType {
|
||||||
|
return NumberValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *floatAny) MustBeValid() Any {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *floatAny) LastError() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *floatAny) ToBool() bool {
|
||||||
|
return any.ToFloat64() != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *floatAny) ToInt() int {
|
||||||
|
return int(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *floatAny) ToInt32() int32 {
|
||||||
|
return int32(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *floatAny) ToInt64() int64 {
|
||||||
|
return int64(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *floatAny) ToUint() uint {
|
||||||
|
if any.val > 0 {
|
||||||
|
return uint(any.val)
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *floatAny) ToUint32() uint32 {
|
||||||
|
if any.val > 0 {
|
||||||
|
return uint32(any.val)
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *floatAny) ToUint64() uint64 {
|
||||||
|
if any.val > 0 {
|
||||||
|
return uint64(any.val)
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *floatAny) ToFloat32() float32 {
|
||||||
|
return float32(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *floatAny) ToFloat64() float64 {
|
||||||
|
return any.val
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *floatAny) ToString() string {
|
||||||
|
return strconv.FormatFloat(any.val, 'E', -1, 64)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *floatAny) WriteTo(stream *Stream) {
|
||||||
|
stream.WriteFloat64(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *floatAny) GetInterface() interface{} {
|
||||||
|
return any.val
|
||||||
|
}
|
||||||
74
vendor/github.com/json-iterator/go/any_int32.go
generated
vendored
Normal file
74
vendor/github.com/json-iterator/go/any_int32.go
generated
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
type int32Any struct {
|
||||||
|
baseAny
|
||||||
|
val int32
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int32Any) LastError() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int32Any) ValueType() ValueType {
|
||||||
|
return NumberValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int32Any) MustBeValid() Any {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int32Any) ToBool() bool {
|
||||||
|
return any.val != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int32Any) ToInt() int {
|
||||||
|
return int(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int32Any) ToInt32() int32 {
|
||||||
|
return any.val
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int32Any) ToInt64() int64 {
|
||||||
|
return int64(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int32Any) ToUint() uint {
|
||||||
|
return uint(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int32Any) ToUint32() uint32 {
|
||||||
|
return uint32(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int32Any) ToUint64() uint64 {
|
||||||
|
return uint64(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int32Any) ToFloat32() float32 {
|
||||||
|
return float32(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int32Any) ToFloat64() float64 {
|
||||||
|
return float64(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int32Any) ToString() string {
|
||||||
|
return strconv.FormatInt(int64(any.val), 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int32Any) WriteTo(stream *Stream) {
|
||||||
|
stream.WriteInt32(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int32Any) Parse() *Iterator {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int32Any) GetInterface() interface{} {
|
||||||
|
return any.val
|
||||||
|
}
|
||||||
74
vendor/github.com/json-iterator/go/any_int64.go
generated
vendored
Normal file
74
vendor/github.com/json-iterator/go/any_int64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
type int64Any struct {
|
||||||
|
baseAny
|
||||||
|
val int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int64Any) LastError() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int64Any) ValueType() ValueType {
|
||||||
|
return NumberValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int64Any) MustBeValid() Any {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int64Any) ToBool() bool {
|
||||||
|
return any.val != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int64Any) ToInt() int {
|
||||||
|
return int(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int64Any) ToInt32() int32 {
|
||||||
|
return int32(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int64Any) ToInt64() int64 {
|
||||||
|
return any.val
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int64Any) ToUint() uint {
|
||||||
|
return uint(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int64Any) ToUint32() uint32 {
|
||||||
|
return uint32(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int64Any) ToUint64() uint64 {
|
||||||
|
return uint64(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int64Any) ToFloat32() float32 {
|
||||||
|
return float32(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int64Any) ToFloat64() float64 {
|
||||||
|
return float64(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int64Any) ToString() string {
|
||||||
|
return strconv.FormatInt(any.val, 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int64Any) WriteTo(stream *Stream) {
|
||||||
|
stream.WriteInt64(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int64Any) Parse() *Iterator {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *int64Any) GetInterface() interface{} {
|
||||||
|
return any.val
|
||||||
|
}
|
||||||
82
vendor/github.com/json-iterator/go/any_invalid.go
generated
vendored
Normal file
82
vendor/github.com/json-iterator/go/any_invalid.go
generated
vendored
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
type invalidAny struct {
|
||||||
|
baseAny
|
||||||
|
err error
|
||||||
|
}
|
||||||
|
|
||||||
|
func newInvalidAny(path []interface{}) *invalidAny {
|
||||||
|
return &invalidAny{baseAny{}, fmt.Errorf("%v not found", path)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *invalidAny) LastError() error {
|
||||||
|
return any.err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *invalidAny) ValueType() ValueType {
|
||||||
|
return InvalidValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *invalidAny) MustBeValid() Any {
|
||||||
|
panic(any.err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *invalidAny) ToBool() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *invalidAny) ToInt() int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *invalidAny) ToInt32() int32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *invalidAny) ToInt64() int64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *invalidAny) ToUint() uint {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *invalidAny) ToUint32() uint32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *invalidAny) ToUint64() uint64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *invalidAny) ToFloat32() float32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *invalidAny) ToFloat64() float64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *invalidAny) ToString() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *invalidAny) WriteTo(stream *Stream) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *invalidAny) Get(path ...interface{}) Any {
|
||||||
|
if any.err == nil {
|
||||||
|
return &invalidAny{baseAny{}, fmt.Errorf("get %v from invalid", path)}
|
||||||
|
}
|
||||||
|
return &invalidAny{baseAny{}, fmt.Errorf("%v, get %v from invalid", any.err, path)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *invalidAny) Parse() *Iterator {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *invalidAny) GetInterface() interface{} {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
69
vendor/github.com/json-iterator/go/any_nil.go
generated
vendored
Normal file
69
vendor/github.com/json-iterator/go/any_nil.go
generated
vendored
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
type nilAny struct {
|
||||||
|
baseAny
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *nilAny) LastError() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *nilAny) ValueType() ValueType {
|
||||||
|
return NilValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *nilAny) MustBeValid() Any {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *nilAny) ToBool() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *nilAny) ToInt() int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *nilAny) ToInt32() int32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *nilAny) ToInt64() int64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *nilAny) ToUint() uint {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *nilAny) ToUint32() uint32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *nilAny) ToUint64() uint64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *nilAny) ToFloat32() float32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *nilAny) ToFloat64() float64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *nilAny) ToString() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *nilAny) WriteTo(stream *Stream) {
|
||||||
|
stream.WriteNil()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *nilAny) Parse() *Iterator {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *nilAny) GetInterface() interface{} {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
123
vendor/github.com/json-iterator/go/any_number.go
generated
vendored
Normal file
123
vendor/github.com/json-iterator/go/any_number.go
generated
vendored
Normal file
|
|
@ -0,0 +1,123 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
type numberLazyAny struct {
|
||||||
|
baseAny
|
||||||
|
cfg *frozenConfig
|
||||||
|
buf []byte
|
||||||
|
err error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *numberLazyAny) ValueType() ValueType {
|
||||||
|
return NumberValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *numberLazyAny) MustBeValid() Any {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *numberLazyAny) LastError() error {
|
||||||
|
return any.err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *numberLazyAny) ToBool() bool {
|
||||||
|
return any.ToFloat64() != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *numberLazyAny) ToInt() int {
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
val := iter.ReadInt()
|
||||||
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
|
any.err = iter.Error
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *numberLazyAny) ToInt32() int32 {
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
val := iter.ReadInt32()
|
||||||
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
|
any.err = iter.Error
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *numberLazyAny) ToInt64() int64 {
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
val := iter.ReadInt64()
|
||||||
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
|
any.err = iter.Error
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *numberLazyAny) ToUint() uint {
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
val := iter.ReadUint()
|
||||||
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
|
any.err = iter.Error
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *numberLazyAny) ToUint32() uint32 {
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
val := iter.ReadUint32()
|
||||||
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
|
any.err = iter.Error
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *numberLazyAny) ToUint64() uint64 {
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
val := iter.ReadUint64()
|
||||||
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
|
any.err = iter.Error
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *numberLazyAny) ToFloat32() float32 {
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
val := iter.ReadFloat32()
|
||||||
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
|
any.err = iter.Error
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *numberLazyAny) ToFloat64() float64 {
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
val := iter.ReadFloat64()
|
||||||
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
|
any.err = iter.Error
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *numberLazyAny) ToString() string {
|
||||||
|
return *(*string)(unsafe.Pointer(&any.buf))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *numberLazyAny) WriteTo(stream *Stream) {
|
||||||
|
stream.Write(any.buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *numberLazyAny) GetInterface() interface{} {
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
return iter.Read()
|
||||||
|
}
|
||||||
374
vendor/github.com/json-iterator/go/any_object.go
generated
vendored
Normal file
374
vendor/github.com/json-iterator/go/any_object.go
generated
vendored
Normal file
|
|
@ -0,0 +1,374 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
type objectLazyAny struct {
|
||||||
|
baseAny
|
||||||
|
cfg *frozenConfig
|
||||||
|
buf []byte
|
||||||
|
err error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) ValueType() ValueType {
|
||||||
|
return ObjectValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) MustBeValid() Any {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) LastError() error {
|
||||||
|
return any.err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) ToBool() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) ToInt() int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) ToInt32() int32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) ToInt64() int64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) ToUint() uint {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) ToUint32() uint32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) ToUint64() uint64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) ToFloat32() float32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) ToFloat64() float64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) ToString() string {
|
||||||
|
return *(*string)(unsafe.Pointer(&any.buf))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) ToVal(obj interface{}) {
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
iter.ReadVal(obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) Get(path ...interface{}) Any {
|
||||||
|
if len(path) == 0 {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
switch firstPath := path[0].(type) {
|
||||||
|
case string:
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
valueBytes := locateObjectField(iter, firstPath)
|
||||||
|
if valueBytes == nil {
|
||||||
|
return newInvalidAny(path)
|
||||||
|
}
|
||||||
|
iter.ResetBytes(valueBytes)
|
||||||
|
return locatePath(iter, path[1:])
|
||||||
|
case int32:
|
||||||
|
if '*' == firstPath {
|
||||||
|
mappedAll := map[string]Any{}
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
iter.ReadMapCB(func(iter *Iterator, field string) bool {
|
||||||
|
mapped := locatePath(iter, path[1:])
|
||||||
|
if mapped.ValueType() != InvalidValue {
|
||||||
|
mappedAll[field] = mapped
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
return wrapMap(mappedAll)
|
||||||
|
}
|
||||||
|
return newInvalidAny(path)
|
||||||
|
default:
|
||||||
|
return newInvalidAny(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) Keys() []string {
|
||||||
|
keys := []string{}
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
iter.ReadMapCB(func(iter *Iterator, field string) bool {
|
||||||
|
iter.Skip()
|
||||||
|
keys = append(keys, field)
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
return keys
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) Size() int {
|
||||||
|
size := 0
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
iter.ReadObjectCB(func(iter *Iterator, field string) bool {
|
||||||
|
iter.Skip()
|
||||||
|
size++
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
return size
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) WriteTo(stream *Stream) {
|
||||||
|
stream.Write(any.buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectLazyAny) GetInterface() interface{} {
|
||||||
|
iter := any.cfg.BorrowIterator(any.buf)
|
||||||
|
defer any.cfg.ReturnIterator(iter)
|
||||||
|
return iter.Read()
|
||||||
|
}
|
||||||
|
|
||||||
|
type objectAny struct {
|
||||||
|
baseAny
|
||||||
|
err error
|
||||||
|
val reflect.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
func wrapStruct(val interface{}) *objectAny {
|
||||||
|
return &objectAny{baseAny{}, nil, reflect.ValueOf(val)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) ValueType() ValueType {
|
||||||
|
return ObjectValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) MustBeValid() Any {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) Parse() *Iterator {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) LastError() error {
|
||||||
|
return any.err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) ToBool() bool {
|
||||||
|
return any.val.NumField() != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) ToInt() int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) ToInt32() int32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) ToInt64() int64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) ToUint() uint {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) ToUint32() uint32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) ToUint64() uint64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) ToFloat32() float32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) ToFloat64() float64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) ToString() string {
|
||||||
|
str, err := MarshalToString(any.val.Interface())
|
||||||
|
any.err = err
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) Get(path ...interface{}) Any {
|
||||||
|
if len(path) == 0 {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
switch firstPath := path[0].(type) {
|
||||||
|
case string:
|
||||||
|
field := any.val.FieldByName(firstPath)
|
||||||
|
if !field.IsValid() {
|
||||||
|
return newInvalidAny(path)
|
||||||
|
}
|
||||||
|
return Wrap(field.Interface())
|
||||||
|
case int32:
|
||||||
|
if '*' == firstPath {
|
||||||
|
mappedAll := map[string]Any{}
|
||||||
|
for i := 0; i < any.val.NumField(); i++ {
|
||||||
|
field := any.val.Field(i)
|
||||||
|
if field.CanInterface() {
|
||||||
|
mapped := Wrap(field.Interface()).Get(path[1:]...)
|
||||||
|
if mapped.ValueType() != InvalidValue {
|
||||||
|
mappedAll[any.val.Type().Field(i).Name] = mapped
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return wrapMap(mappedAll)
|
||||||
|
}
|
||||||
|
return newInvalidAny(path)
|
||||||
|
default:
|
||||||
|
return newInvalidAny(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) Keys() []string {
|
||||||
|
keys := make([]string, 0, any.val.NumField())
|
||||||
|
for i := 0; i < any.val.NumField(); i++ {
|
||||||
|
keys = append(keys, any.val.Type().Field(i).Name)
|
||||||
|
}
|
||||||
|
return keys
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) Size() int {
|
||||||
|
return any.val.NumField()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) WriteTo(stream *Stream) {
|
||||||
|
stream.WriteVal(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *objectAny) GetInterface() interface{} {
|
||||||
|
return any.val.Interface()
|
||||||
|
}
|
||||||
|
|
||||||
|
type mapAny struct {
|
||||||
|
baseAny
|
||||||
|
err error
|
||||||
|
val reflect.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
func wrapMap(val interface{}) *mapAny {
|
||||||
|
return &mapAny{baseAny{}, nil, reflect.ValueOf(val)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) ValueType() ValueType {
|
||||||
|
return ObjectValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) MustBeValid() Any {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) Parse() *Iterator {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) LastError() error {
|
||||||
|
return any.err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) ToBool() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) ToInt() int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) ToInt32() int32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) ToInt64() int64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) ToUint() uint {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) ToUint32() uint32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) ToUint64() uint64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) ToFloat32() float32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) ToFloat64() float64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) ToString() string {
|
||||||
|
str, err := MarshalToString(any.val.Interface())
|
||||||
|
any.err = err
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) Get(path ...interface{}) Any {
|
||||||
|
if len(path) == 0 {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
switch firstPath := path[0].(type) {
|
||||||
|
case int32:
|
||||||
|
if '*' == firstPath {
|
||||||
|
mappedAll := map[string]Any{}
|
||||||
|
for _, key := range any.val.MapKeys() {
|
||||||
|
keyAsStr := key.String()
|
||||||
|
element := Wrap(any.val.MapIndex(key).Interface())
|
||||||
|
mapped := element.Get(path[1:]...)
|
||||||
|
if mapped.ValueType() != InvalidValue {
|
||||||
|
mappedAll[keyAsStr] = mapped
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return wrapMap(mappedAll)
|
||||||
|
}
|
||||||
|
return newInvalidAny(path)
|
||||||
|
default:
|
||||||
|
value := any.val.MapIndex(reflect.ValueOf(firstPath))
|
||||||
|
if !value.IsValid() {
|
||||||
|
return newInvalidAny(path)
|
||||||
|
}
|
||||||
|
return Wrap(value.Interface())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) Keys() []string {
|
||||||
|
keys := make([]string, 0, any.val.Len())
|
||||||
|
for _, key := range any.val.MapKeys() {
|
||||||
|
keys = append(keys, key.String())
|
||||||
|
}
|
||||||
|
return keys
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) Size() int {
|
||||||
|
return any.val.Len()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) WriteTo(stream *Stream) {
|
||||||
|
stream.WriteVal(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *mapAny) GetInterface() interface{} {
|
||||||
|
return any.val.Interface()
|
||||||
|
}
|
||||||
166
vendor/github.com/json-iterator/go/any_str.go
generated
vendored
Normal file
166
vendor/github.com/json-iterator/go/any_str.go
generated
vendored
Normal file
|
|
@ -0,0 +1,166 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
type stringAny struct {
|
||||||
|
baseAny
|
||||||
|
val string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *stringAny) Get(path ...interface{}) Any {
|
||||||
|
if len(path) == 0 {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
return &invalidAny{baseAny{}, fmt.Errorf("GetIndex %v from simple value", path)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *stringAny) Parse() *Iterator {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *stringAny) ValueType() ValueType {
|
||||||
|
return StringValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *stringAny) MustBeValid() Any {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *stringAny) LastError() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *stringAny) ToBool() bool {
|
||||||
|
str := any.ToString()
|
||||||
|
if str == "0" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, c := range str {
|
||||||
|
switch c {
|
||||||
|
case ' ', '\n', '\r', '\t':
|
||||||
|
default:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *stringAny) ToInt() int {
|
||||||
|
return int(any.ToInt64())
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *stringAny) ToInt32() int32 {
|
||||||
|
return int32(any.ToInt64())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *stringAny) ToInt64() int64 {
|
||||||
|
if any.val == "" {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
flag := 1
|
||||||
|
startPos := 0
|
||||||
|
if any.val[0] == '+' || any.val[0] == '-' {
|
||||||
|
startPos = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if any.val[0] == '-' {
|
||||||
|
flag = -1
|
||||||
|
}
|
||||||
|
|
||||||
|
endPos := startPos
|
||||||
|
for i := startPos; i < len(any.val); i++ {
|
||||||
|
if any.val[i] >= '0' && any.val[i] <= '9' {
|
||||||
|
endPos = i + 1
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parsed, _ := strconv.ParseInt(any.val[startPos:endPos], 10, 64)
|
||||||
|
return int64(flag) * parsed
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *stringAny) ToUint() uint {
|
||||||
|
return uint(any.ToUint64())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *stringAny) ToUint32() uint32 {
|
||||||
|
return uint32(any.ToUint64())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *stringAny) ToUint64() uint64 {
|
||||||
|
if any.val == "" {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
startPos := 0
|
||||||
|
|
||||||
|
if any.val[0] == '-' {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if any.val[0] == '+' {
|
||||||
|
startPos = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
endPos := startPos
|
||||||
|
for i := startPos; i < len(any.val); i++ {
|
||||||
|
if any.val[i] >= '0' && any.val[i] <= '9' {
|
||||||
|
endPos = i + 1
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parsed, _ := strconv.ParseUint(any.val[startPos:endPos], 10, 64)
|
||||||
|
return parsed
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *stringAny) ToFloat32() float32 {
|
||||||
|
return float32(any.ToFloat64())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *stringAny) ToFloat64() float64 {
|
||||||
|
if len(any.val) == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// first char invalid
|
||||||
|
if any.val[0] != '+' && any.val[0] != '-' && (any.val[0] > '9' || any.val[0] < '0') {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// extract valid num expression from string
|
||||||
|
// eg 123true => 123, -12.12xxa => -12.12
|
||||||
|
endPos := 1
|
||||||
|
for i := 1; i < len(any.val); i++ {
|
||||||
|
if any.val[i] == '.' || any.val[i] == 'e' || any.val[i] == 'E' || any.val[i] == '+' || any.val[i] == '-' {
|
||||||
|
endPos = i + 1
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// end position is the first char which is not digit
|
||||||
|
if any.val[i] >= '0' && any.val[i] <= '9' {
|
||||||
|
endPos = i + 1
|
||||||
|
} else {
|
||||||
|
endPos = i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parsed, _ := strconv.ParseFloat(any.val[:endPos], 64)
|
||||||
|
return parsed
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *stringAny) ToString() string {
|
||||||
|
return any.val
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *stringAny) WriteTo(stream *Stream) {
|
||||||
|
stream.WriteString(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *stringAny) GetInterface() interface{} {
|
||||||
|
return any.val
|
||||||
|
}
|
||||||
74
vendor/github.com/json-iterator/go/any_uint32.go
generated
vendored
Normal file
74
vendor/github.com/json-iterator/go/any_uint32.go
generated
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
type uint32Any struct {
|
||||||
|
baseAny
|
||||||
|
val uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint32Any) LastError() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint32Any) ValueType() ValueType {
|
||||||
|
return NumberValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint32Any) MustBeValid() Any {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint32Any) ToBool() bool {
|
||||||
|
return any.val != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint32Any) ToInt() int {
|
||||||
|
return int(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint32Any) ToInt32() int32 {
|
||||||
|
return int32(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint32Any) ToInt64() int64 {
|
||||||
|
return int64(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint32Any) ToUint() uint {
|
||||||
|
return uint(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint32Any) ToUint32() uint32 {
|
||||||
|
return any.val
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint32Any) ToUint64() uint64 {
|
||||||
|
return uint64(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint32Any) ToFloat32() float32 {
|
||||||
|
return float32(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint32Any) ToFloat64() float64 {
|
||||||
|
return float64(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint32Any) ToString() string {
|
||||||
|
return strconv.FormatInt(int64(any.val), 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint32Any) WriteTo(stream *Stream) {
|
||||||
|
stream.WriteUint32(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint32Any) Parse() *Iterator {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint32Any) GetInterface() interface{} {
|
||||||
|
return any.val
|
||||||
|
}
|
||||||
74
vendor/github.com/json-iterator/go/any_uint64.go
generated
vendored
Normal file
74
vendor/github.com/json-iterator/go/any_uint64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
type uint64Any struct {
|
||||||
|
baseAny
|
||||||
|
val uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint64Any) LastError() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint64Any) ValueType() ValueType {
|
||||||
|
return NumberValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint64Any) MustBeValid() Any {
|
||||||
|
return any
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint64Any) ToBool() bool {
|
||||||
|
return any.val != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint64Any) ToInt() int {
|
||||||
|
return int(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint64Any) ToInt32() int32 {
|
||||||
|
return int32(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint64Any) ToInt64() int64 {
|
||||||
|
return int64(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint64Any) ToUint() uint {
|
||||||
|
return uint(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint64Any) ToUint32() uint32 {
|
||||||
|
return uint32(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint64Any) ToUint64() uint64 {
|
||||||
|
return any.val
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint64Any) ToFloat32() float32 {
|
||||||
|
return float32(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint64Any) ToFloat64() float64 {
|
||||||
|
return float64(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint64Any) ToString() string {
|
||||||
|
return strconv.FormatUint(any.val, 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint64Any) WriteTo(stream *Stream) {
|
||||||
|
stream.WriteUint64(any.val)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint64Any) Parse() *Iterator {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (any *uint64Any) GetInterface() interface{} {
|
||||||
|
return any.val
|
||||||
|
}
|
||||||
12
vendor/github.com/json-iterator/go/build.sh
generated
vendored
Normal file
12
vendor/github.com/json-iterator/go/build.sh
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
if [ ! -d /tmp/build-golang/src/github.com/json-iterator ]; then
|
||||||
|
mkdir -p /tmp/build-golang/src/github.com/json-iterator
|
||||||
|
ln -s $PWD /tmp/build-golang/src/github.com/json-iterator/go
|
||||||
|
fi
|
||||||
|
export GOPATH=/tmp/build-golang
|
||||||
|
go get -u github.com/golang/dep/cmd/dep
|
||||||
|
cd /tmp/build-golang/src/github.com/json-iterator/go
|
||||||
|
exec $GOPATH/bin/dep ensure -update
|
||||||
375
vendor/github.com/json-iterator/go/config.go
generated
vendored
Normal file
375
vendor/github.com/json-iterator/go/config.go
generated
vendored
Normal file
|
|
@ -0,0 +1,375 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"io"
|
||||||
|
"reflect"
|
||||||
|
"sync"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/modern-go/concurrent"
|
||||||
|
"github.com/modern-go/reflect2"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Config customize how the API should behave.
|
||||||
|
// The API is created from Config by Froze.
|
||||||
|
type Config struct {
|
||||||
|
IndentionStep int
|
||||||
|
MarshalFloatWith6Digits bool
|
||||||
|
EscapeHTML bool
|
||||||
|
SortMapKeys bool
|
||||||
|
UseNumber bool
|
||||||
|
DisallowUnknownFields bool
|
||||||
|
TagKey string
|
||||||
|
OnlyTaggedField bool
|
||||||
|
ValidateJsonRawMessage bool
|
||||||
|
ObjectFieldMustBeSimpleString bool
|
||||||
|
CaseSensitive bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// API the public interface of this package.
|
||||||
|
// Primary Marshal and Unmarshal.
|
||||||
|
type API interface {
|
||||||
|
IteratorPool
|
||||||
|
StreamPool
|
||||||
|
MarshalToString(v interface{}) (string, error)
|
||||||
|
Marshal(v interface{}) ([]byte, error)
|
||||||
|
MarshalIndent(v interface{}, prefix, indent string) ([]byte, error)
|
||||||
|
UnmarshalFromString(str string, v interface{}) error
|
||||||
|
Unmarshal(data []byte, v interface{}) error
|
||||||
|
Get(data []byte, path ...interface{}) Any
|
||||||
|
NewEncoder(writer io.Writer) *Encoder
|
||||||
|
NewDecoder(reader io.Reader) *Decoder
|
||||||
|
Valid(data []byte) bool
|
||||||
|
RegisterExtension(extension Extension)
|
||||||
|
DecoderOf(typ reflect2.Type) ValDecoder
|
||||||
|
EncoderOf(typ reflect2.Type) ValEncoder
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConfigDefault the default API
|
||||||
|
var ConfigDefault = Config{
|
||||||
|
EscapeHTML: true,
|
||||||
|
}.Froze()
|
||||||
|
|
||||||
|
// ConfigCompatibleWithStandardLibrary tries to be 100% compatible with standard library behavior
|
||||||
|
var ConfigCompatibleWithStandardLibrary = Config{
|
||||||
|
EscapeHTML: true,
|
||||||
|
SortMapKeys: true,
|
||||||
|
ValidateJsonRawMessage: true,
|
||||||
|
}.Froze()
|
||||||
|
|
||||||
|
// ConfigFastest marshals float with only 6 digits precision
|
||||||
|
var ConfigFastest = Config{
|
||||||
|
EscapeHTML: false,
|
||||||
|
MarshalFloatWith6Digits: true, // will lose precession
|
||||||
|
ObjectFieldMustBeSimpleString: true, // do not unescape object field
|
||||||
|
}.Froze()
|
||||||
|
|
||||||
|
type frozenConfig struct {
|
||||||
|
configBeforeFrozen Config
|
||||||
|
sortMapKeys bool
|
||||||
|
indentionStep int
|
||||||
|
objectFieldMustBeSimpleString bool
|
||||||
|
onlyTaggedField bool
|
||||||
|
disallowUnknownFields bool
|
||||||
|
decoderCache *concurrent.Map
|
||||||
|
encoderCache *concurrent.Map
|
||||||
|
encoderExtension Extension
|
||||||
|
decoderExtension Extension
|
||||||
|
extraExtensions []Extension
|
||||||
|
streamPool *sync.Pool
|
||||||
|
iteratorPool *sync.Pool
|
||||||
|
caseSensitive bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) initCache() {
|
||||||
|
cfg.decoderCache = concurrent.NewMap()
|
||||||
|
cfg.encoderCache = concurrent.NewMap()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) addDecoderToCache(cacheKey uintptr, decoder ValDecoder) {
|
||||||
|
cfg.decoderCache.Store(cacheKey, decoder)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) addEncoderToCache(cacheKey uintptr, encoder ValEncoder) {
|
||||||
|
cfg.encoderCache.Store(cacheKey, encoder)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) getDecoderFromCache(cacheKey uintptr) ValDecoder {
|
||||||
|
decoder, found := cfg.decoderCache.Load(cacheKey)
|
||||||
|
if found {
|
||||||
|
return decoder.(ValDecoder)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) getEncoderFromCache(cacheKey uintptr) ValEncoder {
|
||||||
|
encoder, found := cfg.encoderCache.Load(cacheKey)
|
||||||
|
if found {
|
||||||
|
return encoder.(ValEncoder)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var cfgCache = concurrent.NewMap()
|
||||||
|
|
||||||
|
func getFrozenConfigFromCache(cfg Config) *frozenConfig {
|
||||||
|
obj, found := cfgCache.Load(cfg)
|
||||||
|
if found {
|
||||||
|
return obj.(*frozenConfig)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func addFrozenConfigToCache(cfg Config, frozenConfig *frozenConfig) {
|
||||||
|
cfgCache.Store(cfg, frozenConfig)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Froze forge API from config
|
||||||
|
func (cfg Config) Froze() API {
|
||||||
|
api := &frozenConfig{
|
||||||
|
sortMapKeys: cfg.SortMapKeys,
|
||||||
|
indentionStep: cfg.IndentionStep,
|
||||||
|
objectFieldMustBeSimpleString: cfg.ObjectFieldMustBeSimpleString,
|
||||||
|
onlyTaggedField: cfg.OnlyTaggedField,
|
||||||
|
disallowUnknownFields: cfg.DisallowUnknownFields,
|
||||||
|
caseSensitive: cfg.CaseSensitive,
|
||||||
|
}
|
||||||
|
api.streamPool = &sync.Pool{
|
||||||
|
New: func() interface{} {
|
||||||
|
return NewStream(api, nil, 512)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
api.iteratorPool = &sync.Pool{
|
||||||
|
New: func() interface{} {
|
||||||
|
return NewIterator(api)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
api.initCache()
|
||||||
|
encoderExtension := EncoderExtension{}
|
||||||
|
decoderExtension := DecoderExtension{}
|
||||||
|
if cfg.MarshalFloatWith6Digits {
|
||||||
|
api.marshalFloatWith6Digits(encoderExtension)
|
||||||
|
}
|
||||||
|
if cfg.EscapeHTML {
|
||||||
|
api.escapeHTML(encoderExtension)
|
||||||
|
}
|
||||||
|
if cfg.UseNumber {
|
||||||
|
api.useNumber(decoderExtension)
|
||||||
|
}
|
||||||
|
if cfg.ValidateJsonRawMessage {
|
||||||
|
api.validateJsonRawMessage(encoderExtension)
|
||||||
|
}
|
||||||
|
api.encoderExtension = encoderExtension
|
||||||
|
api.decoderExtension = decoderExtension
|
||||||
|
api.configBeforeFrozen = cfg
|
||||||
|
return api
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg Config) frozeWithCacheReuse(extraExtensions []Extension) *frozenConfig {
|
||||||
|
api := getFrozenConfigFromCache(cfg)
|
||||||
|
if api != nil {
|
||||||
|
return api
|
||||||
|
}
|
||||||
|
api = cfg.Froze().(*frozenConfig)
|
||||||
|
for _, extension := range extraExtensions {
|
||||||
|
api.RegisterExtension(extension)
|
||||||
|
}
|
||||||
|
addFrozenConfigToCache(cfg, api)
|
||||||
|
return api
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) validateJsonRawMessage(extension EncoderExtension) {
|
||||||
|
encoder := &funcEncoder{func(ptr unsafe.Pointer, stream *Stream) {
|
||||||
|
rawMessage := *(*json.RawMessage)(ptr)
|
||||||
|
iter := cfg.BorrowIterator([]byte(rawMessage))
|
||||||
|
defer cfg.ReturnIterator(iter)
|
||||||
|
iter.Read()
|
||||||
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
|
stream.WriteRaw("null")
|
||||||
|
} else {
|
||||||
|
stream.WriteRaw(string(rawMessage))
|
||||||
|
}
|
||||||
|
}, func(ptr unsafe.Pointer) bool {
|
||||||
|
return len(*((*json.RawMessage)(ptr))) == 0
|
||||||
|
}}
|
||||||
|
extension[reflect2.TypeOfPtr((*json.RawMessage)(nil)).Elem()] = encoder
|
||||||
|
extension[reflect2.TypeOfPtr((*RawMessage)(nil)).Elem()] = encoder
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) useNumber(extension DecoderExtension) {
|
||||||
|
extension[reflect2.TypeOfPtr((*interface{})(nil)).Elem()] = &funcDecoder{func(ptr unsafe.Pointer, iter *Iterator) {
|
||||||
|
exitingValue := *((*interface{})(ptr))
|
||||||
|
if exitingValue != nil && reflect.TypeOf(exitingValue).Kind() == reflect.Ptr {
|
||||||
|
iter.ReadVal(exitingValue)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if iter.WhatIsNext() == NumberValue {
|
||||||
|
*((*interface{})(ptr)) = json.Number(iter.readNumberAsString())
|
||||||
|
} else {
|
||||||
|
*((*interface{})(ptr)) = iter.Read()
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
func (cfg *frozenConfig) getTagKey() string {
|
||||||
|
tagKey := cfg.configBeforeFrozen.TagKey
|
||||||
|
if tagKey == "" {
|
||||||
|
return "json"
|
||||||
|
}
|
||||||
|
return tagKey
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) RegisterExtension(extension Extension) {
|
||||||
|
cfg.extraExtensions = append(cfg.extraExtensions, extension)
|
||||||
|
copied := cfg.configBeforeFrozen
|
||||||
|
cfg.configBeforeFrozen = copied
|
||||||
|
}
|
||||||
|
|
||||||
|
type lossyFloat32Encoder struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder *lossyFloat32Encoder) Encode(ptr unsafe.Pointer, stream *Stream) {
|
||||||
|
stream.WriteFloat32Lossy(*((*float32)(ptr)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder *lossyFloat32Encoder) IsEmpty(ptr unsafe.Pointer) bool {
|
||||||
|
return *((*float32)(ptr)) == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type lossyFloat64Encoder struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder *lossyFloat64Encoder) Encode(ptr unsafe.Pointer, stream *Stream) {
|
||||||
|
stream.WriteFloat64Lossy(*((*float64)(ptr)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder *lossyFloat64Encoder) IsEmpty(ptr unsafe.Pointer) bool {
|
||||||
|
return *((*float64)(ptr)) == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnableLossyFloatMarshalling keeps 10**(-6) precision
|
||||||
|
// for float variables for better performance.
|
||||||
|
func (cfg *frozenConfig) marshalFloatWith6Digits(extension EncoderExtension) {
|
||||||
|
// for better performance
|
||||||
|
extension[reflect2.TypeOfPtr((*float32)(nil)).Elem()] = &lossyFloat32Encoder{}
|
||||||
|
extension[reflect2.TypeOfPtr((*float64)(nil)).Elem()] = &lossyFloat64Encoder{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type htmlEscapedStringEncoder struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder *htmlEscapedStringEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
|
||||||
|
str := *((*string)(ptr))
|
||||||
|
stream.WriteStringWithHTMLEscaped(str)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder *htmlEscapedStringEncoder) IsEmpty(ptr unsafe.Pointer) bool {
|
||||||
|
return *((*string)(ptr)) == ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) escapeHTML(encoderExtension EncoderExtension) {
|
||||||
|
encoderExtension[reflect2.TypeOfPtr((*string)(nil)).Elem()] = &htmlEscapedStringEncoder{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) cleanDecoders() {
|
||||||
|
typeDecoders = map[string]ValDecoder{}
|
||||||
|
fieldDecoders = map[string]ValDecoder{}
|
||||||
|
*cfg = *(cfg.configBeforeFrozen.Froze().(*frozenConfig))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) cleanEncoders() {
|
||||||
|
typeEncoders = map[string]ValEncoder{}
|
||||||
|
fieldEncoders = map[string]ValEncoder{}
|
||||||
|
*cfg = *(cfg.configBeforeFrozen.Froze().(*frozenConfig))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) MarshalToString(v interface{}) (string, error) {
|
||||||
|
stream := cfg.BorrowStream(nil)
|
||||||
|
defer cfg.ReturnStream(stream)
|
||||||
|
stream.WriteVal(v)
|
||||||
|
if stream.Error != nil {
|
||||||
|
return "", stream.Error
|
||||||
|
}
|
||||||
|
return string(stream.Buffer()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) Marshal(v interface{}) ([]byte, error) {
|
||||||
|
stream := cfg.BorrowStream(nil)
|
||||||
|
defer cfg.ReturnStream(stream)
|
||||||
|
stream.WriteVal(v)
|
||||||
|
if stream.Error != nil {
|
||||||
|
return nil, stream.Error
|
||||||
|
}
|
||||||
|
result := stream.Buffer()
|
||||||
|
copied := make([]byte, len(result))
|
||||||
|
copy(copied, result)
|
||||||
|
return copied, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) {
|
||||||
|
if prefix != "" {
|
||||||
|
panic("prefix is not supported")
|
||||||
|
}
|
||||||
|
for _, r := range indent {
|
||||||
|
if r != ' ' {
|
||||||
|
panic("indent can only be space")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newCfg := cfg.configBeforeFrozen
|
||||||
|
newCfg.IndentionStep = len(indent)
|
||||||
|
return newCfg.frozeWithCacheReuse(cfg.extraExtensions).Marshal(v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) UnmarshalFromString(str string, v interface{}) error {
|
||||||
|
data := []byte(str)
|
||||||
|
iter := cfg.BorrowIterator(data)
|
||||||
|
defer cfg.ReturnIterator(iter)
|
||||||
|
iter.ReadVal(v)
|
||||||
|
c := iter.nextToken()
|
||||||
|
if c == 0 {
|
||||||
|
if iter.Error == io.EOF {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return iter.Error
|
||||||
|
}
|
||||||
|
iter.ReportError("Unmarshal", "there are bytes left after unmarshal")
|
||||||
|
return iter.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) Get(data []byte, path ...interface{}) Any {
|
||||||
|
iter := cfg.BorrowIterator(data)
|
||||||
|
defer cfg.ReturnIterator(iter)
|
||||||
|
return locatePath(iter, path)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) Unmarshal(data []byte, v interface{}) error {
|
||||||
|
iter := cfg.BorrowIterator(data)
|
||||||
|
defer cfg.ReturnIterator(iter)
|
||||||
|
iter.ReadVal(v)
|
||||||
|
c := iter.nextToken()
|
||||||
|
if c == 0 {
|
||||||
|
if iter.Error == io.EOF {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return iter.Error
|
||||||
|
}
|
||||||
|
iter.ReportError("Unmarshal", "there are bytes left after unmarshal")
|
||||||
|
return iter.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) NewEncoder(writer io.Writer) *Encoder {
|
||||||
|
stream := NewStream(cfg, writer, 512)
|
||||||
|
return &Encoder{stream}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) NewDecoder(reader io.Reader) *Decoder {
|
||||||
|
iter := Parse(cfg, reader, 512)
|
||||||
|
return &Decoder{iter}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) Valid(data []byte) bool {
|
||||||
|
iter := cfg.BorrowIterator(data)
|
||||||
|
defer cfg.ReturnIterator(iter)
|
||||||
|
iter.Skip()
|
||||||
|
return iter.Error == nil
|
||||||
|
}
|
||||||
7
vendor/github.com/json-iterator/go/fuzzy_mode_convert_table.md
generated
vendored
Normal file
7
vendor/github.com/json-iterator/go/fuzzy_mode_convert_table.md
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
| json type \ dest type | bool | int | uint | float |string|
|
||||||
|
| --- | --- | --- | --- |--|--|
|
||||||
|
| number | positive => true <br/> negative => true <br/> zero => false| 23.2 => 23 <br/> -32.1 => -32| 12.1 => 12 <br/> -12.1 => 0|as normal|same as origin|
|
||||||
|
| string | empty string => false <br/> string "0" => false <br/> other strings => true | "123.32" => 123 <br/> "-123.4" => -123 <br/> "123.23xxxw" => 123 <br/> "abcde12" => 0 <br/> "-32.1" => -32| 13.2 => 13 <br/> -1.1 => 0 |12.1 => 12.1 <br/> -12.3 => -12.3<br/> 12.4xxa => 12.4 <br/> +1.1e2 =>110 |same as origin|
|
||||||
|
| bool | true => true <br/> false => false| true => 1 <br/> false => 0 | true => 1 <br/> false => 0 |true => 1 <br/>false => 0|true => "true" <br/> false => "false"|
|
||||||
|
| object | true | 0 | 0 |0|originnal json|
|
||||||
|
| array | empty array => false <br/> nonempty array => true| [] => 0 <br/> [1,2] => 1 | [] => 0 <br/> [1,2] => 1 |[] => 0<br/>[1,2] => 1|original json|
|
||||||
11
vendor/github.com/json-iterator/go/go.mod
generated
vendored
Normal file
11
vendor/github.com/json-iterator/go/go.mod
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
module github.com/json-iterator/go
|
||||||
|
|
||||||
|
go 1.12
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/davecgh/go-spew v1.1.1
|
||||||
|
github.com/google/gofuzz v1.0.0
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421
|
||||||
|
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742
|
||||||
|
github.com/stretchr/testify v1.3.0
|
||||||
|
)
|
||||||
14
vendor/github.com/json-iterator/go/go.sum
generated
vendored
Normal file
14
vendor/github.com/json-iterator/go/go.sum
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
|
||||||
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
|
||||||
|
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||||
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
349
vendor/github.com/json-iterator/go/iter.go
generated
vendored
Normal file
349
vendor/github.com/json-iterator/go/iter.go
generated
vendored
Normal file
|
|
@ -0,0 +1,349 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ValueType the type for JSON element
|
||||||
|
type ValueType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
// InvalidValue invalid JSON element
|
||||||
|
InvalidValue ValueType = iota
|
||||||
|
// StringValue JSON element "string"
|
||||||
|
StringValue
|
||||||
|
// NumberValue JSON element 100 or 0.10
|
||||||
|
NumberValue
|
||||||
|
// NilValue JSON element null
|
||||||
|
NilValue
|
||||||
|
// BoolValue JSON element true or false
|
||||||
|
BoolValue
|
||||||
|
// ArrayValue JSON element []
|
||||||
|
ArrayValue
|
||||||
|
// ObjectValue JSON element {}
|
||||||
|
ObjectValue
|
||||||
|
)
|
||||||
|
|
||||||
|
var hexDigits []byte
|
||||||
|
var valueTypes []ValueType
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
hexDigits = make([]byte, 256)
|
||||||
|
for i := 0; i < len(hexDigits); i++ {
|
||||||
|
hexDigits[i] = 255
|
||||||
|
}
|
||||||
|
for i := '0'; i <= '9'; i++ {
|
||||||
|
hexDigits[i] = byte(i - '0')
|
||||||
|
}
|
||||||
|
for i := 'a'; i <= 'f'; i++ {
|
||||||
|
hexDigits[i] = byte((i - 'a') + 10)
|
||||||
|
}
|
||||||
|
for i := 'A'; i <= 'F'; i++ {
|
||||||
|
hexDigits[i] = byte((i - 'A') + 10)
|
||||||
|
}
|
||||||
|
valueTypes = make([]ValueType, 256)
|
||||||
|
for i := 0; i < len(valueTypes); i++ {
|
||||||
|
valueTypes[i] = InvalidValue
|
||||||
|
}
|
||||||
|
valueTypes['"'] = StringValue
|
||||||
|
valueTypes['-'] = NumberValue
|
||||||
|
valueTypes['0'] = NumberValue
|
||||||
|
valueTypes['1'] = NumberValue
|
||||||
|
valueTypes['2'] = NumberValue
|
||||||
|
valueTypes['3'] = NumberValue
|
||||||
|
valueTypes['4'] = NumberValue
|
||||||
|
valueTypes['5'] = NumberValue
|
||||||
|
valueTypes['6'] = NumberValue
|
||||||
|
valueTypes['7'] = NumberValue
|
||||||
|
valueTypes['8'] = NumberValue
|
||||||
|
valueTypes['9'] = NumberValue
|
||||||
|
valueTypes['t'] = BoolValue
|
||||||
|
valueTypes['f'] = BoolValue
|
||||||
|
valueTypes['n'] = NilValue
|
||||||
|
valueTypes['['] = ArrayValue
|
||||||
|
valueTypes['{'] = ObjectValue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Iterator is a io.Reader like object, with JSON specific read functions.
|
||||||
|
// Error is not returned as return value, but stored as Error member on this iterator instance.
|
||||||
|
type Iterator struct {
|
||||||
|
cfg *frozenConfig
|
||||||
|
reader io.Reader
|
||||||
|
buf []byte
|
||||||
|
head int
|
||||||
|
tail int
|
||||||
|
depth int
|
||||||
|
captureStartedAt int
|
||||||
|
captured []byte
|
||||||
|
Error error
|
||||||
|
Attachment interface{} // open for customized decoder
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewIterator creates an empty Iterator instance
|
||||||
|
func NewIterator(cfg API) *Iterator {
|
||||||
|
return &Iterator{
|
||||||
|
cfg: cfg.(*frozenConfig),
|
||||||
|
reader: nil,
|
||||||
|
buf: nil,
|
||||||
|
head: 0,
|
||||||
|
tail: 0,
|
||||||
|
depth: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse creates an Iterator instance from io.Reader
|
||||||
|
func Parse(cfg API, reader io.Reader, bufSize int) *Iterator {
|
||||||
|
return &Iterator{
|
||||||
|
cfg: cfg.(*frozenConfig),
|
||||||
|
reader: reader,
|
||||||
|
buf: make([]byte, bufSize),
|
||||||
|
head: 0,
|
||||||
|
tail: 0,
|
||||||
|
depth: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseBytes creates an Iterator instance from byte array
|
||||||
|
func ParseBytes(cfg API, input []byte) *Iterator {
|
||||||
|
return &Iterator{
|
||||||
|
cfg: cfg.(*frozenConfig),
|
||||||
|
reader: nil,
|
||||||
|
buf: input,
|
||||||
|
head: 0,
|
||||||
|
tail: len(input),
|
||||||
|
depth: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseString creates an Iterator instance from string
|
||||||
|
func ParseString(cfg API, input string) *Iterator {
|
||||||
|
return ParseBytes(cfg, []byte(input))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pool returns a pool can provide more iterator with same configuration
|
||||||
|
func (iter *Iterator) Pool() IteratorPool {
|
||||||
|
return iter.cfg
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset reuse iterator instance by specifying another reader
|
||||||
|
func (iter *Iterator) Reset(reader io.Reader) *Iterator {
|
||||||
|
iter.reader = reader
|
||||||
|
iter.head = 0
|
||||||
|
iter.tail = 0
|
||||||
|
iter.depth = 0
|
||||||
|
return iter
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetBytes reuse iterator instance by specifying another byte array as input
|
||||||
|
func (iter *Iterator) ResetBytes(input []byte) *Iterator {
|
||||||
|
iter.reader = nil
|
||||||
|
iter.buf = input
|
||||||
|
iter.head = 0
|
||||||
|
iter.tail = len(input)
|
||||||
|
iter.depth = 0
|
||||||
|
return iter
|
||||||
|
}
|
||||||
|
|
||||||
|
// WhatIsNext gets ValueType of relatively next json element
|
||||||
|
func (iter *Iterator) WhatIsNext() ValueType {
|
||||||
|
valueType := valueTypes[iter.nextToken()]
|
||||||
|
iter.unreadByte()
|
||||||
|
return valueType
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) skipWhitespacesWithoutLoadMore() bool {
|
||||||
|
for i := iter.head; i < iter.tail; i++ {
|
||||||
|
c := iter.buf[i]
|
||||||
|
switch c {
|
||||||
|
case ' ', '\n', '\t', '\r':
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
iter.head = i
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) isObjectEnd() bool {
|
||||||
|
c := iter.nextToken()
|
||||||
|
if c == ',' {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if c == '}' {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
iter.ReportError("isObjectEnd", "object ended prematurely, unexpected char "+string([]byte{c}))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) nextToken() byte {
|
||||||
|
// a variation of skip whitespaces, returning the next non-whitespace token
|
||||||
|
for {
|
||||||
|
for i := iter.head; i < iter.tail; i++ {
|
||||||
|
c := iter.buf[i]
|
||||||
|
switch c {
|
||||||
|
case ' ', '\n', '\t', '\r':
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
iter.head = i + 1
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
if !iter.loadMore() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReportError record a error in iterator instance with current position.
|
||||||
|
func (iter *Iterator) ReportError(operation string, msg string) {
|
||||||
|
if iter.Error != nil {
|
||||||
|
if iter.Error != io.EOF {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
peekStart := iter.head - 10
|
||||||
|
if peekStart < 0 {
|
||||||
|
peekStart = 0
|
||||||
|
}
|
||||||
|
peekEnd := iter.head + 10
|
||||||
|
if peekEnd > iter.tail {
|
||||||
|
peekEnd = iter.tail
|
||||||
|
}
|
||||||
|
parsing := string(iter.buf[peekStart:peekEnd])
|
||||||
|
contextStart := iter.head - 50
|
||||||
|
if contextStart < 0 {
|
||||||
|
contextStart = 0
|
||||||
|
}
|
||||||
|
contextEnd := iter.head + 50
|
||||||
|
if contextEnd > iter.tail {
|
||||||
|
contextEnd = iter.tail
|
||||||
|
}
|
||||||
|
context := string(iter.buf[contextStart:contextEnd])
|
||||||
|
iter.Error = fmt.Errorf("%s: %s, error found in #%v byte of ...|%s|..., bigger context ...|%s|...",
|
||||||
|
operation, msg, iter.head-peekStart, parsing, context)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CurrentBuffer gets current buffer as string for debugging purpose
|
||||||
|
func (iter *Iterator) CurrentBuffer() string {
|
||||||
|
peekStart := iter.head - 10
|
||||||
|
if peekStart < 0 {
|
||||||
|
peekStart = 0
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("parsing #%v byte, around ...|%s|..., whole buffer ...|%s|...", iter.head,
|
||||||
|
string(iter.buf[peekStart:iter.head]), string(iter.buf[0:iter.tail]))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) readByte() (ret byte) {
|
||||||
|
if iter.head == iter.tail {
|
||||||
|
if iter.loadMore() {
|
||||||
|
ret = iter.buf[iter.head]
|
||||||
|
iter.head++
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
ret = iter.buf[iter.head]
|
||||||
|
iter.head++
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) loadMore() bool {
|
||||||
|
if iter.reader == nil {
|
||||||
|
if iter.Error == nil {
|
||||||
|
iter.head = iter.tail
|
||||||
|
iter.Error = io.EOF
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if iter.captured != nil {
|
||||||
|
iter.captured = append(iter.captured,
|
||||||
|
iter.buf[iter.captureStartedAt:iter.tail]...)
|
||||||
|
iter.captureStartedAt = 0
|
||||||
|
}
|
||||||
|
for {
|
||||||
|
n, err := iter.reader.Read(iter.buf)
|
||||||
|
if n == 0 {
|
||||||
|
if err != nil {
|
||||||
|
if iter.Error == nil {
|
||||||
|
iter.Error = err
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
iter.head = 0
|
||||||
|
iter.tail = n
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) unreadByte() {
|
||||||
|
if iter.Error != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
iter.head--
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read read the next JSON element as generic interface{}.
|
||||||
|
func (iter *Iterator) Read() interface{} {
|
||||||
|
valueType := iter.WhatIsNext()
|
||||||
|
switch valueType {
|
||||||
|
case StringValue:
|
||||||
|
return iter.ReadString()
|
||||||
|
case NumberValue:
|
||||||
|
if iter.cfg.configBeforeFrozen.UseNumber {
|
||||||
|
return json.Number(iter.readNumberAsString())
|
||||||
|
}
|
||||||
|
return iter.ReadFloat64()
|
||||||
|
case NilValue:
|
||||||
|
iter.skipFourBytes('n', 'u', 'l', 'l')
|
||||||
|
return nil
|
||||||
|
case BoolValue:
|
||||||
|
return iter.ReadBool()
|
||||||
|
case ArrayValue:
|
||||||
|
arr := []interface{}{}
|
||||||
|
iter.ReadArrayCB(func(iter *Iterator) bool {
|
||||||
|
var elem interface{}
|
||||||
|
iter.ReadVal(&elem)
|
||||||
|
arr = append(arr, elem)
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
return arr
|
||||||
|
case ObjectValue:
|
||||||
|
obj := map[string]interface{}{}
|
||||||
|
iter.ReadMapCB(func(Iter *Iterator, field string) bool {
|
||||||
|
var elem interface{}
|
||||||
|
iter.ReadVal(&elem)
|
||||||
|
obj[field] = elem
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
return obj
|
||||||
|
default:
|
||||||
|
iter.ReportError("Read", fmt.Sprintf("unexpected value type: %v", valueType))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// limit maximum depth of nesting, as allowed by https://tools.ietf.org/html/rfc7159#section-9
|
||||||
|
const maxDepth = 10000
|
||||||
|
|
||||||
|
func (iter *Iterator) incrementDepth() (success bool) {
|
||||||
|
iter.depth++
|
||||||
|
if iter.depth <= maxDepth {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
iter.ReportError("incrementDepth", "exceeded max depth")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) decrementDepth() (success bool) {
|
||||||
|
iter.depth--
|
||||||
|
if iter.depth >= 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
iter.ReportError("decrementDepth", "unexpected negative nesting")
|
||||||
|
return false
|
||||||
|
}
|
||||||
64
vendor/github.com/json-iterator/go/iter_array.go
generated
vendored
Normal file
64
vendor/github.com/json-iterator/go/iter_array.go
generated
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
// ReadArray read array element, tells if the array has more element to read.
|
||||||
|
func (iter *Iterator) ReadArray() (ret bool) {
|
||||||
|
c := iter.nextToken()
|
||||||
|
switch c {
|
||||||
|
case 'n':
|
||||||
|
iter.skipThreeBytes('u', 'l', 'l')
|
||||||
|
return false // null
|
||||||
|
case '[':
|
||||||
|
c = iter.nextToken()
|
||||||
|
if c != ']' {
|
||||||
|
iter.unreadByte()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
case ']':
|
||||||
|
return false
|
||||||
|
case ',':
|
||||||
|
return true
|
||||||
|
default:
|
||||||
|
iter.ReportError("ReadArray", "expect [ or , or ] or n, but found "+string([]byte{c}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadArrayCB read array with callback
|
||||||
|
func (iter *Iterator) ReadArrayCB(callback func(*Iterator) bool) (ret bool) {
|
||||||
|
c := iter.nextToken()
|
||||||
|
if c == '[' {
|
||||||
|
if !iter.incrementDepth() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
c = iter.nextToken()
|
||||||
|
if c != ']' {
|
||||||
|
iter.unreadByte()
|
||||||
|
if !callback(iter) {
|
||||||
|
iter.decrementDepth()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
c = iter.nextToken()
|
||||||
|
for c == ',' {
|
||||||
|
if !callback(iter) {
|
||||||
|
iter.decrementDepth()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
c = iter.nextToken()
|
||||||
|
}
|
||||||
|
if c != ']' {
|
||||||
|
iter.ReportError("ReadArrayCB", "expect ] in the end, but found "+string([]byte{c}))
|
||||||
|
iter.decrementDepth()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return iter.decrementDepth()
|
||||||
|
}
|
||||||
|
return iter.decrementDepth()
|
||||||
|
}
|
||||||
|
if c == 'n' {
|
||||||
|
iter.skipThreeBytes('u', 'l', 'l')
|
||||||
|
return true // null
|
||||||
|
}
|
||||||
|
iter.ReportError("ReadArrayCB", "expect [ or n, but found "+string([]byte{c}))
|
||||||
|
return false
|
||||||
|
}
|
||||||
339
vendor/github.com/json-iterator/go/iter_float.go
generated
vendored
Normal file
339
vendor/github.com/json-iterator/go/iter_float.go
generated
vendored
Normal file
|
|
@ -0,0 +1,339 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"io"
|
||||||
|
"math/big"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
var floatDigits []int8
|
||||||
|
|
||||||
|
const invalidCharForNumber = int8(-1)
|
||||||
|
const endOfNumber = int8(-2)
|
||||||
|
const dotInNumber = int8(-3)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
floatDigits = make([]int8, 256)
|
||||||
|
for i := 0; i < len(floatDigits); i++ {
|
||||||
|
floatDigits[i] = invalidCharForNumber
|
||||||
|
}
|
||||||
|
for i := int8('0'); i <= int8('9'); i++ {
|
||||||
|
floatDigits[i] = i - int8('0')
|
||||||
|
}
|
||||||
|
floatDigits[','] = endOfNumber
|
||||||
|
floatDigits[']'] = endOfNumber
|
||||||
|
floatDigits['}'] = endOfNumber
|
||||||
|
floatDigits[' '] = endOfNumber
|
||||||
|
floatDigits['\t'] = endOfNumber
|
||||||
|
floatDigits['\n'] = endOfNumber
|
||||||
|
floatDigits['.'] = dotInNumber
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadBigFloat read big.Float
|
||||||
|
func (iter *Iterator) ReadBigFloat() (ret *big.Float) {
|
||||||
|
str := iter.readNumberAsString()
|
||||||
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
prec := 64
|
||||||
|
if len(str) > prec {
|
||||||
|
prec = len(str)
|
||||||
|
}
|
||||||
|
val, _, err := big.ParseFloat(str, 10, uint(prec), big.ToZero)
|
||||||
|
if err != nil {
|
||||||
|
iter.Error = err
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadBigInt read big.Int
|
||||||
|
func (iter *Iterator) ReadBigInt() (ret *big.Int) {
|
||||||
|
str := iter.readNumberAsString()
|
||||||
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
ret = big.NewInt(0)
|
||||||
|
var success bool
|
||||||
|
ret, success = ret.SetString(str, 10)
|
||||||
|
if !success {
|
||||||
|
iter.ReportError("ReadBigInt", "invalid big int")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
//ReadFloat32 read float32
|
||||||
|
func (iter *Iterator) ReadFloat32() (ret float32) {
|
||||||
|
c := iter.nextToken()
|
||||||
|
if c == '-' {
|
||||||
|
return -iter.readPositiveFloat32()
|
||||||
|
}
|
||||||
|
iter.unreadByte()
|
||||||
|
return iter.readPositiveFloat32()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) readPositiveFloat32() (ret float32) {
|
||||||
|
i := iter.head
|
||||||
|
// first char
|
||||||
|
if i == iter.tail {
|
||||||
|
return iter.readFloat32SlowPath()
|
||||||
|
}
|
||||||
|
c := iter.buf[i]
|
||||||
|
i++
|
||||||
|
ind := floatDigits[c]
|
||||||
|
switch ind {
|
||||||
|
case invalidCharForNumber:
|
||||||
|
return iter.readFloat32SlowPath()
|
||||||
|
case endOfNumber:
|
||||||
|
iter.ReportError("readFloat32", "empty number")
|
||||||
|
return
|
||||||
|
case dotInNumber:
|
||||||
|
iter.ReportError("readFloat32", "leading dot is invalid")
|
||||||
|
return
|
||||||
|
case 0:
|
||||||
|
if i == iter.tail {
|
||||||
|
return iter.readFloat32SlowPath()
|
||||||
|
}
|
||||||
|
c = iter.buf[i]
|
||||||
|
switch c {
|
||||||
|
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
|
||||||
|
iter.ReportError("readFloat32", "leading zero is invalid")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value := uint64(ind)
|
||||||
|
// chars before dot
|
||||||
|
non_decimal_loop:
|
||||||
|
for ; i < iter.tail; i++ {
|
||||||
|
c = iter.buf[i]
|
||||||
|
ind := floatDigits[c]
|
||||||
|
switch ind {
|
||||||
|
case invalidCharForNumber:
|
||||||
|
return iter.readFloat32SlowPath()
|
||||||
|
case endOfNumber:
|
||||||
|
iter.head = i
|
||||||
|
return float32(value)
|
||||||
|
case dotInNumber:
|
||||||
|
break non_decimal_loop
|
||||||
|
}
|
||||||
|
if value > uint64SafeToMultiple10 {
|
||||||
|
return iter.readFloat32SlowPath()
|
||||||
|
}
|
||||||
|
value = (value << 3) + (value << 1) + uint64(ind) // value = value * 10 + ind;
|
||||||
|
}
|
||||||
|
// chars after dot
|
||||||
|
if c == '.' {
|
||||||
|
i++
|
||||||
|
decimalPlaces := 0
|
||||||
|
if i == iter.tail {
|
||||||
|
return iter.readFloat32SlowPath()
|
||||||
|
}
|
||||||
|
for ; i < iter.tail; i++ {
|
||||||
|
c = iter.buf[i]
|
||||||
|
ind := floatDigits[c]
|
||||||
|
switch ind {
|
||||||
|
case endOfNumber:
|
||||||
|
if decimalPlaces > 0 && decimalPlaces < len(pow10) {
|
||||||
|
iter.head = i
|
||||||
|
return float32(float64(value) / float64(pow10[decimalPlaces]))
|
||||||
|
}
|
||||||
|
// too many decimal places
|
||||||
|
return iter.readFloat32SlowPath()
|
||||||
|
case invalidCharForNumber, dotInNumber:
|
||||||
|
return iter.readFloat32SlowPath()
|
||||||
|
}
|
||||||
|
decimalPlaces++
|
||||||
|
if value > uint64SafeToMultiple10 {
|
||||||
|
return iter.readFloat32SlowPath()
|
||||||
|
}
|
||||||
|
value = (value << 3) + (value << 1) + uint64(ind)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return iter.readFloat32SlowPath()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) readNumberAsString() (ret string) {
|
||||||
|
strBuf := [16]byte{}
|
||||||
|
str := strBuf[0:0]
|
||||||
|
load_loop:
|
||||||
|
for {
|
||||||
|
for i := iter.head; i < iter.tail; i++ {
|
||||||
|
c := iter.buf[i]
|
||||||
|
switch c {
|
||||||
|
case '+', '-', '.', 'e', 'E', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
|
||||||
|
str = append(str, c)
|
||||||
|
continue
|
||||||
|
default:
|
||||||
|
iter.head = i
|
||||||
|
break load_loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !iter.loadMore() {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(str) == 0 {
|
||||||
|
iter.ReportError("readNumberAsString", "invalid number")
|
||||||
|
}
|
||||||
|
return *(*string)(unsafe.Pointer(&str))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) readFloat32SlowPath() (ret float32) {
|
||||||
|
str := iter.readNumberAsString()
|
||||||
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
errMsg := validateFloat(str)
|
||||||
|
if errMsg != "" {
|
||||||
|
iter.ReportError("readFloat32SlowPath", errMsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val, err := strconv.ParseFloat(str, 32)
|
||||||
|
if err != nil {
|
||||||
|
iter.Error = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return float32(val)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadFloat64 read float64
|
||||||
|
func (iter *Iterator) ReadFloat64() (ret float64) {
|
||||||
|
c := iter.nextToken()
|
||||||
|
if c == '-' {
|
||||||
|
return -iter.readPositiveFloat64()
|
||||||
|
}
|
||||||
|
iter.unreadByte()
|
||||||
|
return iter.readPositiveFloat64()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) readPositiveFloat64() (ret float64) {
|
||||||
|
i := iter.head
|
||||||
|
// first char
|
||||||
|
if i == iter.tail {
|
||||||
|
return iter.readFloat64SlowPath()
|
||||||
|
}
|
||||||
|
c := iter.buf[i]
|
||||||
|
i++
|
||||||
|
ind := floatDigits[c]
|
||||||
|
switch ind {
|
||||||
|
case invalidCharForNumber:
|
||||||
|
return iter.readFloat64SlowPath()
|
||||||
|
case endOfNumber:
|
||||||
|
iter.ReportError("readFloat64", "empty number")
|
||||||
|
return
|
||||||
|
case dotInNumber:
|
||||||
|
iter.ReportError("readFloat64", "leading dot is invalid")
|
||||||
|
return
|
||||||
|
case 0:
|
||||||
|
if i == iter.tail {
|
||||||
|
return iter.readFloat64SlowPath()
|
||||||
|
}
|
||||||
|
c = iter.buf[i]
|
||||||
|
switch c {
|
||||||
|
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
|
||||||
|
iter.ReportError("readFloat64", "leading zero is invalid")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value := uint64(ind)
|
||||||
|
// chars before dot
|
||||||
|
non_decimal_loop:
|
||||||
|
for ; i < iter.tail; i++ {
|
||||||
|
c = iter.buf[i]
|
||||||
|
ind := floatDigits[c]
|
||||||
|
switch ind {
|
||||||
|
case invalidCharForNumber:
|
||||||
|
return iter.readFloat64SlowPath()
|
||||||
|
case endOfNumber:
|
||||||
|
iter.head = i
|
||||||
|
return float64(value)
|
||||||
|
case dotInNumber:
|
||||||
|
break non_decimal_loop
|
||||||
|
}
|
||||||
|
if value > uint64SafeToMultiple10 {
|
||||||
|
return iter.readFloat64SlowPath()
|
||||||
|
}
|
||||||
|
value = (value << 3) + (value << 1) + uint64(ind) // value = value * 10 + ind;
|
||||||
|
}
|
||||||
|
// chars after dot
|
||||||
|
if c == '.' {
|
||||||
|
i++
|
||||||
|
decimalPlaces := 0
|
||||||
|
if i == iter.tail {
|
||||||
|
return iter.readFloat64SlowPath()
|
||||||
|
}
|
||||||
|
for ; i < iter.tail; i++ {
|
||||||
|
c = iter.buf[i]
|
||||||
|
ind := floatDigits[c]
|
||||||
|
switch ind {
|
||||||
|
case endOfNumber:
|
||||||
|
if decimalPlaces > 0 && decimalPlaces < len(pow10) {
|
||||||
|
iter.head = i
|
||||||
|
return float64(value) / float64(pow10[decimalPlaces])
|
||||||
|
}
|
||||||
|
// too many decimal places
|
||||||
|
return iter.readFloat64SlowPath()
|
||||||
|
case invalidCharForNumber, dotInNumber:
|
||||||
|
return iter.readFloat64SlowPath()
|
||||||
|
}
|
||||||
|
decimalPlaces++
|
||||||
|
if value > uint64SafeToMultiple10 {
|
||||||
|
return iter.readFloat64SlowPath()
|
||||||
|
}
|
||||||
|
value = (value << 3) + (value << 1) + uint64(ind)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return iter.readFloat64SlowPath()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) readFloat64SlowPath() (ret float64) {
|
||||||
|
str := iter.readNumberAsString()
|
||||||
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
errMsg := validateFloat(str)
|
||||||
|
if errMsg != "" {
|
||||||
|
iter.ReportError("readFloat64SlowPath", errMsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val, err := strconv.ParseFloat(str, 64)
|
||||||
|
if err != nil {
|
||||||
|
iter.Error = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
|
func validateFloat(str string) string {
|
||||||
|
// strconv.ParseFloat is not validating `1.` or `1.e1`
|
||||||
|
if len(str) == 0 {
|
||||||
|
return "empty number"
|
||||||
|
}
|
||||||
|
if str[0] == '-' {
|
||||||
|
return "-- is not valid"
|
||||||
|
}
|
||||||
|
dotPos := strings.IndexByte(str, '.')
|
||||||
|
if dotPos != -1 {
|
||||||
|
if dotPos == len(str)-1 {
|
||||||
|
return "dot can not be last character"
|
||||||
|
}
|
||||||
|
switch str[dotPos+1] {
|
||||||
|
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
|
||||||
|
default:
|
||||||
|
return "missing digit after dot"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadNumber read json.Number
|
||||||
|
func (iter *Iterator) ReadNumber() (ret json.Number) {
|
||||||
|
return json.Number(iter.readNumberAsString())
|
||||||
|
}
|
||||||
345
vendor/github.com/json-iterator/go/iter_int.go
generated
vendored
Normal file
345
vendor/github.com/json-iterator/go/iter_int.go
generated
vendored
Normal file
|
|
@ -0,0 +1,345 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
var intDigits []int8
|
||||||
|
|
||||||
|
const uint32SafeToMultiply10 = uint32(0xffffffff)/10 - 1
|
||||||
|
const uint64SafeToMultiple10 = uint64(0xffffffffffffffff)/10 - 1
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
intDigits = make([]int8, 256)
|
||||||
|
for i := 0; i < len(intDigits); i++ {
|
||||||
|
intDigits[i] = invalidCharForNumber
|
||||||
|
}
|
||||||
|
for i := int8('0'); i <= int8('9'); i++ {
|
||||||
|
intDigits[i] = i - int8('0')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadUint read uint
|
||||||
|
func (iter *Iterator) ReadUint() uint {
|
||||||
|
if strconv.IntSize == 32 {
|
||||||
|
return uint(iter.ReadUint32())
|
||||||
|
}
|
||||||
|
return uint(iter.ReadUint64())
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadInt read int
|
||||||
|
func (iter *Iterator) ReadInt() int {
|
||||||
|
if strconv.IntSize == 32 {
|
||||||
|
return int(iter.ReadInt32())
|
||||||
|
}
|
||||||
|
return int(iter.ReadInt64())
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadInt8 read int8
|
||||||
|
func (iter *Iterator) ReadInt8() (ret int8) {
|
||||||
|
c := iter.nextToken()
|
||||||
|
if c == '-' {
|
||||||
|
val := iter.readUint32(iter.readByte())
|
||||||
|
if val > math.MaxInt8+1 {
|
||||||
|
iter.ReportError("ReadInt8", "overflow: "+strconv.FormatInt(int64(val), 10))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return -int8(val)
|
||||||
|
}
|
||||||
|
val := iter.readUint32(c)
|
||||||
|
if val > math.MaxInt8 {
|
||||||
|
iter.ReportError("ReadInt8", "overflow: "+strconv.FormatInt(int64(val), 10))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return int8(val)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadUint8 read uint8
|
||||||
|
func (iter *Iterator) ReadUint8() (ret uint8) {
|
||||||
|
val := iter.readUint32(iter.nextToken())
|
||||||
|
if val > math.MaxUint8 {
|
||||||
|
iter.ReportError("ReadUint8", "overflow: "+strconv.FormatInt(int64(val), 10))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return uint8(val)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadInt16 read int16
|
||||||
|
func (iter *Iterator) ReadInt16() (ret int16) {
|
||||||
|
c := iter.nextToken()
|
||||||
|
if c == '-' {
|
||||||
|
val := iter.readUint32(iter.readByte())
|
||||||
|
if val > math.MaxInt16+1 {
|
||||||
|
iter.ReportError("ReadInt16", "overflow: "+strconv.FormatInt(int64(val), 10))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return -int16(val)
|
||||||
|
}
|
||||||
|
val := iter.readUint32(c)
|
||||||
|
if val > math.MaxInt16 {
|
||||||
|
iter.ReportError("ReadInt16", "overflow: "+strconv.FormatInt(int64(val), 10))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return int16(val)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadUint16 read uint16
|
||||||
|
func (iter *Iterator) ReadUint16() (ret uint16) {
|
||||||
|
val := iter.readUint32(iter.nextToken())
|
||||||
|
if val > math.MaxUint16 {
|
||||||
|
iter.ReportError("ReadUint16", "overflow: "+strconv.FormatInt(int64(val), 10))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return uint16(val)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadInt32 read int32
|
||||||
|
func (iter *Iterator) ReadInt32() (ret int32) {
|
||||||
|
c := iter.nextToken()
|
||||||
|
if c == '-' {
|
||||||
|
val := iter.readUint32(iter.readByte())
|
||||||
|
if val > math.MaxInt32+1 {
|
||||||
|
iter.ReportError("ReadInt32", "overflow: "+strconv.FormatInt(int64(val), 10))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return -int32(val)
|
||||||
|
}
|
||||||
|
val := iter.readUint32(c)
|
||||||
|
if val > math.MaxInt32 {
|
||||||
|
iter.ReportError("ReadInt32", "overflow: "+strconv.FormatInt(int64(val), 10))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return int32(val)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadUint32 read uint32
|
||||||
|
func (iter *Iterator) ReadUint32() (ret uint32) {
|
||||||
|
return iter.readUint32(iter.nextToken())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) readUint32(c byte) (ret uint32) {
|
||||||
|
ind := intDigits[c]
|
||||||
|
if ind == 0 {
|
||||||
|
iter.assertInteger()
|
||||||
|
return 0 // single zero
|
||||||
|
}
|
||||||
|
if ind == invalidCharForNumber {
|
||||||
|
iter.ReportError("readUint32", "unexpected character: "+string([]byte{byte(ind)}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
value := uint32(ind)
|
||||||
|
if iter.tail-iter.head > 10 {
|
||||||
|
i := iter.head
|
||||||
|
ind2 := intDigits[iter.buf[i]]
|
||||||
|
if ind2 == invalidCharForNumber {
|
||||||
|
iter.head = i
|
||||||
|
iter.assertInteger()
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
ind3 := intDigits[iter.buf[i]]
|
||||||
|
if ind3 == invalidCharForNumber {
|
||||||
|
iter.head = i
|
||||||
|
iter.assertInteger()
|
||||||
|
return value*10 + uint32(ind2)
|
||||||
|
}
|
||||||
|
//iter.head = i + 1
|
||||||
|
//value = value * 100 + uint32(ind2) * 10 + uint32(ind3)
|
||||||
|
i++
|
||||||
|
ind4 := intDigits[iter.buf[i]]
|
||||||
|
if ind4 == invalidCharForNumber {
|
||||||
|
iter.head = i
|
||||||
|
iter.assertInteger()
|
||||||
|
return value*100 + uint32(ind2)*10 + uint32(ind3)
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
ind5 := intDigits[iter.buf[i]]
|
||||||
|
if ind5 == invalidCharForNumber {
|
||||||
|
iter.head = i
|
||||||
|
iter.assertInteger()
|
||||||
|
return value*1000 + uint32(ind2)*100 + uint32(ind3)*10 + uint32(ind4)
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
ind6 := intDigits[iter.buf[i]]
|
||||||
|
if ind6 == invalidCharForNumber {
|
||||||
|
iter.head = i
|
||||||
|
iter.assertInteger()
|
||||||
|
return value*10000 + uint32(ind2)*1000 + uint32(ind3)*100 + uint32(ind4)*10 + uint32(ind5)
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
ind7 := intDigits[iter.buf[i]]
|
||||||
|
if ind7 == invalidCharForNumber {
|
||||||
|
iter.head = i
|
||||||
|
iter.assertInteger()
|
||||||
|
return value*100000 + uint32(ind2)*10000 + uint32(ind3)*1000 + uint32(ind4)*100 + uint32(ind5)*10 + uint32(ind6)
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
ind8 := intDigits[iter.buf[i]]
|
||||||
|
if ind8 == invalidCharForNumber {
|
||||||
|
iter.head = i
|
||||||
|
iter.assertInteger()
|
||||||
|
return value*1000000 + uint32(ind2)*100000 + uint32(ind3)*10000 + uint32(ind4)*1000 + uint32(ind5)*100 + uint32(ind6)*10 + uint32(ind7)
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
ind9 := intDigits[iter.buf[i]]
|
||||||
|
value = value*10000000 + uint32(ind2)*1000000 + uint32(ind3)*100000 + uint32(ind4)*10000 + uint32(ind5)*1000 + uint32(ind6)*100 + uint32(ind7)*10 + uint32(ind8)
|
||||||
|
iter.head = i
|
||||||
|
if ind9 == invalidCharForNumber {
|
||||||
|
iter.assertInteger()
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for {
|
||||||
|
for i := iter.head; i < iter.tail; i++ {
|
||||||
|
ind = intDigits[iter.buf[i]]
|
||||||
|
if ind == invalidCharForNumber {
|
||||||
|
iter.head = i
|
||||||
|
iter.assertInteger()
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
if value > uint32SafeToMultiply10 {
|
||||||
|
value2 := (value << 3) + (value << 1) + uint32(ind)
|
||||||
|
if value2 < value {
|
||||||
|
iter.ReportError("readUint32", "overflow")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
value = value2
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
value = (value << 3) + (value << 1) + uint32(ind)
|
||||||
|
}
|
||||||
|
if !iter.loadMore() {
|
||||||
|
iter.assertInteger()
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadInt64 read int64
|
||||||
|
func (iter *Iterator) ReadInt64() (ret int64) {
|
||||||
|
c := iter.nextToken()
|
||||||
|
if c == '-' {
|
||||||
|
val := iter.readUint64(iter.readByte())
|
||||||
|
if val > math.MaxInt64+1 {
|
||||||
|
iter.ReportError("ReadInt64", "overflow: "+strconv.FormatUint(uint64(val), 10))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return -int64(val)
|
||||||
|
}
|
||||||
|
val := iter.readUint64(c)
|
||||||
|
if val > math.MaxInt64 {
|
||||||
|
iter.ReportError("ReadInt64", "overflow: "+strconv.FormatUint(uint64(val), 10))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return int64(val)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadUint64 read uint64
|
||||||
|
func (iter *Iterator) ReadUint64() uint64 {
|
||||||
|
return iter.readUint64(iter.nextToken())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) readUint64(c byte) (ret uint64) {
|
||||||
|
ind := intDigits[c]
|
||||||
|
if ind == 0 {
|
||||||
|
iter.assertInteger()
|
||||||
|
return 0 // single zero
|
||||||
|
}
|
||||||
|
if ind == invalidCharForNumber {
|
||||||
|
iter.ReportError("readUint64", "unexpected character: "+string([]byte{byte(ind)}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
value := uint64(ind)
|
||||||
|
if iter.tail-iter.head > 10 {
|
||||||
|
i := iter.head
|
||||||
|
ind2 := intDigits[iter.buf[i]]
|
||||||
|
if ind2 == invalidCharForNumber {
|
||||||
|
iter.head = i
|
||||||
|
iter.assertInteger()
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
ind3 := intDigits[iter.buf[i]]
|
||||||
|
if ind3 == invalidCharForNumber {
|
||||||
|
iter.head = i
|
||||||
|
iter.assertInteger()
|
||||||
|
return value*10 + uint64(ind2)
|
||||||
|
}
|
||||||
|
//iter.head = i + 1
|
||||||
|
//value = value * 100 + uint32(ind2) * 10 + uint32(ind3)
|
||||||
|
i++
|
||||||
|
ind4 := intDigits[iter.buf[i]]
|
||||||
|
if ind4 == invalidCharForNumber {
|
||||||
|
iter.head = i
|
||||||
|
iter.assertInteger()
|
||||||
|
return value*100 + uint64(ind2)*10 + uint64(ind3)
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
ind5 := intDigits[iter.buf[i]]
|
||||||
|
if ind5 == invalidCharForNumber {
|
||||||
|
iter.head = i
|
||||||
|
iter.assertInteger()
|
||||||
|
return value*1000 + uint64(ind2)*100 + uint64(ind3)*10 + uint64(ind4)
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
ind6 := intDigits[iter.buf[i]]
|
||||||
|
if ind6 == invalidCharForNumber {
|
||||||
|
iter.head = i
|
||||||
|
iter.assertInteger()
|
||||||
|
return value*10000 + uint64(ind2)*1000 + uint64(ind3)*100 + uint64(ind4)*10 + uint64(ind5)
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
ind7 := intDigits[iter.buf[i]]
|
||||||
|
if ind7 == invalidCharForNumber {
|
||||||
|
iter.head = i
|
||||||
|
iter.assertInteger()
|
||||||
|
return value*100000 + uint64(ind2)*10000 + uint64(ind3)*1000 + uint64(ind4)*100 + uint64(ind5)*10 + uint64(ind6)
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
ind8 := intDigits[iter.buf[i]]
|
||||||
|
if ind8 == invalidCharForNumber {
|
||||||
|
iter.head = i
|
||||||
|
iter.assertInteger()
|
||||||
|
return value*1000000 + uint64(ind2)*100000 + uint64(ind3)*10000 + uint64(ind4)*1000 + uint64(ind5)*100 + uint64(ind6)*10 + uint64(ind7)
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
ind9 := intDigits[iter.buf[i]]
|
||||||
|
value = value*10000000 + uint64(ind2)*1000000 + uint64(ind3)*100000 + uint64(ind4)*10000 + uint64(ind5)*1000 + uint64(ind6)*100 + uint64(ind7)*10 + uint64(ind8)
|
||||||
|
iter.head = i
|
||||||
|
if ind9 == invalidCharForNumber {
|
||||||
|
iter.assertInteger()
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for {
|
||||||
|
for i := iter.head; i < iter.tail; i++ {
|
||||||
|
ind = intDigits[iter.buf[i]]
|
||||||
|
if ind == invalidCharForNumber {
|
||||||
|
iter.head = i
|
||||||
|
iter.assertInteger()
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
if value > uint64SafeToMultiple10 {
|
||||||
|
value2 := (value << 3) + (value << 1) + uint64(ind)
|
||||||
|
if value2 < value {
|
||||||
|
iter.ReportError("readUint64", "overflow")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
value = value2
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
value = (value << 3) + (value << 1) + uint64(ind)
|
||||||
|
}
|
||||||
|
if !iter.loadMore() {
|
||||||
|
iter.assertInteger()
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) assertInteger() {
|
||||||
|
if iter.head < len(iter.buf) && iter.buf[iter.head] == '.' {
|
||||||
|
iter.ReportError("assertInteger", "can not decode float as int")
|
||||||
|
}
|
||||||
|
}
|
||||||
267
vendor/github.com/json-iterator/go/iter_object.go
generated
vendored
Normal file
267
vendor/github.com/json-iterator/go/iter_object.go
generated
vendored
Normal file
|
|
@ -0,0 +1,267 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ReadObject read one field from object.
|
||||||
|
// If object ended, returns empty string.
|
||||||
|
// Otherwise, returns the field name.
|
||||||
|
func (iter *Iterator) ReadObject() (ret string) {
|
||||||
|
c := iter.nextToken()
|
||||||
|
switch c {
|
||||||
|
case 'n':
|
||||||
|
iter.skipThreeBytes('u', 'l', 'l')
|
||||||
|
return "" // null
|
||||||
|
case '{':
|
||||||
|
c = iter.nextToken()
|
||||||
|
if c == '"' {
|
||||||
|
iter.unreadByte()
|
||||||
|
field := iter.ReadString()
|
||||||
|
c = iter.nextToken()
|
||||||
|
if c != ':' {
|
||||||
|
iter.ReportError("ReadObject", "expect : after object field, but found "+string([]byte{c}))
|
||||||
|
}
|
||||||
|
return field
|
||||||
|
}
|
||||||
|
if c == '}' {
|
||||||
|
return "" // end of object
|
||||||
|
}
|
||||||
|
iter.ReportError("ReadObject", `expect " after {, but found `+string([]byte{c}))
|
||||||
|
return
|
||||||
|
case ',':
|
||||||
|
field := iter.ReadString()
|
||||||
|
c = iter.nextToken()
|
||||||
|
if c != ':' {
|
||||||
|
iter.ReportError("ReadObject", "expect : after object field, but found "+string([]byte{c}))
|
||||||
|
}
|
||||||
|
return field
|
||||||
|
case '}':
|
||||||
|
return "" // end of object
|
||||||
|
default:
|
||||||
|
iter.ReportError("ReadObject", fmt.Sprintf(`expect { or , or } or n, but found %s`, string([]byte{c})))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CaseInsensitive
|
||||||
|
func (iter *Iterator) readFieldHash() int64 {
|
||||||
|
hash := int64(0x811c9dc5)
|
||||||
|
c := iter.nextToken()
|
||||||
|
if c != '"' {
|
||||||
|
iter.ReportError("readFieldHash", `expect ", but found `+string([]byte{c}))
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
for {
|
||||||
|
for i := iter.head; i < iter.tail; i++ {
|
||||||
|
// require ascii string and no escape
|
||||||
|
b := iter.buf[i]
|
||||||
|
if b == '\\' {
|
||||||
|
iter.head = i
|
||||||
|
for _, b := range iter.readStringSlowPath() {
|
||||||
|
if 'A' <= b && b <= 'Z' && !iter.cfg.caseSensitive {
|
||||||
|
b += 'a' - 'A'
|
||||||
|
}
|
||||||
|
hash ^= int64(b)
|
||||||
|
hash *= 0x1000193
|
||||||
|
}
|
||||||
|
c = iter.nextToken()
|
||||||
|
if c != ':' {
|
||||||
|
iter.ReportError("readFieldHash", `expect :, but found `+string([]byte{c}))
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return hash
|
||||||
|
}
|
||||||
|
if b == '"' {
|
||||||
|
iter.head = i + 1
|
||||||
|
c = iter.nextToken()
|
||||||
|
if c != ':' {
|
||||||
|
iter.ReportError("readFieldHash", `expect :, but found `+string([]byte{c}))
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return hash
|
||||||
|
}
|
||||||
|
if 'A' <= b && b <= 'Z' && !iter.cfg.caseSensitive {
|
||||||
|
b += 'a' - 'A'
|
||||||
|
}
|
||||||
|
hash ^= int64(b)
|
||||||
|
hash *= 0x1000193
|
||||||
|
}
|
||||||
|
if !iter.loadMore() {
|
||||||
|
iter.ReportError("readFieldHash", `incomplete field name`)
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func calcHash(str string, caseSensitive bool) int64 {
|
||||||
|
if !caseSensitive {
|
||||||
|
str = strings.ToLower(str)
|
||||||
|
}
|
||||||
|
hash := int64(0x811c9dc5)
|
||||||
|
for _, b := range []byte(str) {
|
||||||
|
hash ^= int64(b)
|
||||||
|
hash *= 0x1000193
|
||||||
|
}
|
||||||
|
return int64(hash)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadObjectCB read object with callback, the key is ascii only and field name not copied
|
||||||
|
func (iter *Iterator) ReadObjectCB(callback func(*Iterator, string) bool) bool {
|
||||||
|
c := iter.nextToken()
|
||||||
|
var field string
|
||||||
|
if c == '{' {
|
||||||
|
if !iter.incrementDepth() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
c = iter.nextToken()
|
||||||
|
if c == '"' {
|
||||||
|
iter.unreadByte()
|
||||||
|
field = iter.ReadString()
|
||||||
|
c = iter.nextToken()
|
||||||
|
if c != ':' {
|
||||||
|
iter.ReportError("ReadObject", "expect : after object field, but found "+string([]byte{c}))
|
||||||
|
}
|
||||||
|
if !callback(iter, field) {
|
||||||
|
iter.decrementDepth()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
c = iter.nextToken()
|
||||||
|
for c == ',' {
|
||||||
|
field = iter.ReadString()
|
||||||
|
c = iter.nextToken()
|
||||||
|
if c != ':' {
|
||||||
|
iter.ReportError("ReadObject", "expect : after object field, but found "+string([]byte{c}))
|
||||||
|
}
|
||||||
|
if !callback(iter, field) {
|
||||||
|
iter.decrementDepth()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
c = iter.nextToken()
|
||||||
|
}
|
||||||
|
if c != '}' {
|
||||||
|
iter.ReportError("ReadObjectCB", `object not ended with }`)
|
||||||
|
iter.decrementDepth()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return iter.decrementDepth()
|
||||||
|
}
|
||||||
|
if c == '}' {
|
||||||
|
return iter.decrementDepth()
|
||||||
|
}
|
||||||
|
iter.ReportError("ReadObjectCB", `expect " after {, but found `+string([]byte{c}))
|
||||||
|
iter.decrementDepth()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if c == 'n' {
|
||||||
|
iter.skipThreeBytes('u', 'l', 'l')
|
||||||
|
return true // null
|
||||||
|
}
|
||||||
|
iter.ReportError("ReadObjectCB", `expect { or n, but found `+string([]byte{c}))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadMapCB read map with callback, the key can be any string
|
||||||
|
func (iter *Iterator) ReadMapCB(callback func(*Iterator, string) bool) bool {
|
||||||
|
c := iter.nextToken()
|
||||||
|
if c == '{' {
|
||||||
|
if !iter.incrementDepth() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
c = iter.nextToken()
|
||||||
|
if c == '"' {
|
||||||
|
iter.unreadByte()
|
||||||
|
field := iter.ReadString()
|
||||||
|
if iter.nextToken() != ':' {
|
||||||
|
iter.ReportError("ReadMapCB", "expect : after object field, but found "+string([]byte{c}))
|
||||||
|
iter.decrementDepth()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if !callback(iter, field) {
|
||||||
|
iter.decrementDepth()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
c = iter.nextToken()
|
||||||
|
for c == ',' {
|
||||||
|
field = iter.ReadString()
|
||||||
|
if iter.nextToken() != ':' {
|
||||||
|
iter.ReportError("ReadMapCB", "expect : after object field, but found "+string([]byte{c}))
|
||||||
|
iter.decrementDepth()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if !callback(iter, field) {
|
||||||
|
iter.decrementDepth()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
c = iter.nextToken()
|
||||||
|
}
|
||||||
|
if c != '}' {
|
||||||
|
iter.ReportError("ReadMapCB", `object not ended with }`)
|
||||||
|
iter.decrementDepth()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return iter.decrementDepth()
|
||||||
|
}
|
||||||
|
if c == '}' {
|
||||||
|
return iter.decrementDepth()
|
||||||
|
}
|
||||||
|
iter.ReportError("ReadMapCB", `expect " after {, but found `+string([]byte{c}))
|
||||||
|
iter.decrementDepth()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if c == 'n' {
|
||||||
|
iter.skipThreeBytes('u', 'l', 'l')
|
||||||
|
return true // null
|
||||||
|
}
|
||||||
|
iter.ReportError("ReadMapCB", `expect { or n, but found `+string([]byte{c}))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) readObjectStart() bool {
|
||||||
|
c := iter.nextToken()
|
||||||
|
if c == '{' {
|
||||||
|
c = iter.nextToken()
|
||||||
|
if c == '}' {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
iter.unreadByte()
|
||||||
|
return true
|
||||||
|
} else if c == 'n' {
|
||||||
|
iter.skipThreeBytes('u', 'l', 'l')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
iter.ReportError("readObjectStart", "expect { or n, but found "+string([]byte{c}))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) readObjectFieldAsBytes() (ret []byte) {
|
||||||
|
str := iter.ReadStringAsSlice()
|
||||||
|
if iter.skipWhitespacesWithoutLoadMore() {
|
||||||
|
if ret == nil {
|
||||||
|
ret = make([]byte, len(str))
|
||||||
|
copy(ret, str)
|
||||||
|
}
|
||||||
|
if !iter.loadMore() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if iter.buf[iter.head] != ':' {
|
||||||
|
iter.ReportError("readObjectFieldAsBytes", "expect : after object field, but found "+string([]byte{iter.buf[iter.head]}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
iter.head++
|
||||||
|
if iter.skipWhitespacesWithoutLoadMore() {
|
||||||
|
if ret == nil {
|
||||||
|
ret = make([]byte, len(str))
|
||||||
|
copy(ret, str)
|
||||||
|
}
|
||||||
|
if !iter.loadMore() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ret == nil {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
130
vendor/github.com/json-iterator/go/iter_skip.go
generated
vendored
Normal file
130
vendor/github.com/json-iterator/go/iter_skip.go
generated
vendored
Normal file
|
|
@ -0,0 +1,130 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
// ReadNil reads a json object as nil and
|
||||||
|
// returns whether it's a nil or not
|
||||||
|
func (iter *Iterator) ReadNil() (ret bool) {
|
||||||
|
c := iter.nextToken()
|
||||||
|
if c == 'n' {
|
||||||
|
iter.skipThreeBytes('u', 'l', 'l') // null
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
iter.unreadByte()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadBool reads a json object as BoolValue
|
||||||
|
func (iter *Iterator) ReadBool() (ret bool) {
|
||||||
|
c := iter.nextToken()
|
||||||
|
if c == 't' {
|
||||||
|
iter.skipThreeBytes('r', 'u', 'e')
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if c == 'f' {
|
||||||
|
iter.skipFourBytes('a', 'l', 's', 'e')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
iter.ReportError("ReadBool", "expect t or f, but found "+string([]byte{c}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// SkipAndReturnBytes skip next JSON element, and return its content as []byte.
|
||||||
|
// The []byte can be kept, it is a copy of data.
|
||||||
|
func (iter *Iterator) SkipAndReturnBytes() []byte {
|
||||||
|
iter.startCapture(iter.head)
|
||||||
|
iter.Skip()
|
||||||
|
return iter.stopCapture()
|
||||||
|
}
|
||||||
|
|
||||||
|
// SkipAndAppendBytes skips next JSON element and appends its content to
|
||||||
|
// buffer, returning the result.
|
||||||
|
func (iter *Iterator) SkipAndAppendBytes(buf []byte) []byte {
|
||||||
|
iter.startCaptureTo(buf, iter.head)
|
||||||
|
iter.Skip()
|
||||||
|
return iter.stopCapture()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) startCaptureTo(buf []byte, captureStartedAt int) {
|
||||||
|
if iter.captured != nil {
|
||||||
|
panic("already in capture mode")
|
||||||
|
}
|
||||||
|
iter.captureStartedAt = captureStartedAt
|
||||||
|
iter.captured = buf
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) startCapture(captureStartedAt int) {
|
||||||
|
iter.startCaptureTo(make([]byte, 0, 32), captureStartedAt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) stopCapture() []byte {
|
||||||
|
if iter.captured == nil {
|
||||||
|
panic("not in capture mode")
|
||||||
|
}
|
||||||
|
captured := iter.captured
|
||||||
|
remaining := iter.buf[iter.captureStartedAt:iter.head]
|
||||||
|
iter.captureStartedAt = -1
|
||||||
|
iter.captured = nil
|
||||||
|
return append(captured, remaining...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip skips a json object and positions to relatively the next json object
|
||||||
|
func (iter *Iterator) Skip() {
|
||||||
|
c := iter.nextToken()
|
||||||
|
switch c {
|
||||||
|
case '"':
|
||||||
|
iter.skipString()
|
||||||
|
case 'n':
|
||||||
|
iter.skipThreeBytes('u', 'l', 'l') // null
|
||||||
|
case 't':
|
||||||
|
iter.skipThreeBytes('r', 'u', 'e') // true
|
||||||
|
case 'f':
|
||||||
|
iter.skipFourBytes('a', 'l', 's', 'e') // false
|
||||||
|
case '0':
|
||||||
|
iter.unreadByte()
|
||||||
|
iter.ReadFloat32()
|
||||||
|
case '-', '1', '2', '3', '4', '5', '6', '7', '8', '9':
|
||||||
|
iter.skipNumber()
|
||||||
|
case '[':
|
||||||
|
iter.skipArray()
|
||||||
|
case '{':
|
||||||
|
iter.skipObject()
|
||||||
|
default:
|
||||||
|
iter.ReportError("Skip", fmt.Sprintf("do not know how to skip: %v", c))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) skipFourBytes(b1, b2, b3, b4 byte) {
|
||||||
|
if iter.readByte() != b1 {
|
||||||
|
iter.ReportError("skipFourBytes", fmt.Sprintf("expect %s", string([]byte{b1, b2, b3, b4})))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if iter.readByte() != b2 {
|
||||||
|
iter.ReportError("skipFourBytes", fmt.Sprintf("expect %s", string([]byte{b1, b2, b3, b4})))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if iter.readByte() != b3 {
|
||||||
|
iter.ReportError("skipFourBytes", fmt.Sprintf("expect %s", string([]byte{b1, b2, b3, b4})))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if iter.readByte() != b4 {
|
||||||
|
iter.ReportError("skipFourBytes", fmt.Sprintf("expect %s", string([]byte{b1, b2, b3, b4})))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) skipThreeBytes(b1, b2, b3 byte) {
|
||||||
|
if iter.readByte() != b1 {
|
||||||
|
iter.ReportError("skipThreeBytes", fmt.Sprintf("expect %s", string([]byte{b1, b2, b3})))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if iter.readByte() != b2 {
|
||||||
|
iter.ReportError("skipThreeBytes", fmt.Sprintf("expect %s", string([]byte{b1, b2, b3})))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if iter.readByte() != b3 {
|
||||||
|
iter.ReportError("skipThreeBytes", fmt.Sprintf("expect %s", string([]byte{b1, b2, b3})))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
163
vendor/github.com/json-iterator/go/iter_skip_sloppy.go
generated
vendored
Normal file
163
vendor/github.com/json-iterator/go/iter_skip_sloppy.go
generated
vendored
Normal file
|
|
@ -0,0 +1,163 @@
|
||||||
|
//+build jsoniter_sloppy
|
||||||
|
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
// sloppy but faster implementation, do not validate the input json
|
||||||
|
|
||||||
|
func (iter *Iterator) skipNumber() {
|
||||||
|
for {
|
||||||
|
for i := iter.head; i < iter.tail; i++ {
|
||||||
|
c := iter.buf[i]
|
||||||
|
switch c {
|
||||||
|
case ' ', '\n', '\r', '\t', ',', '}', ']':
|
||||||
|
iter.head = i
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !iter.loadMore() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) skipArray() {
|
||||||
|
level := 1
|
||||||
|
if !iter.incrementDepth() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for {
|
||||||
|
for i := iter.head; i < iter.tail; i++ {
|
||||||
|
switch iter.buf[i] {
|
||||||
|
case '"': // If inside string, skip it
|
||||||
|
iter.head = i + 1
|
||||||
|
iter.skipString()
|
||||||
|
i = iter.head - 1 // it will be i++ soon
|
||||||
|
case '[': // If open symbol, increase level
|
||||||
|
level++
|
||||||
|
if !iter.incrementDepth() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
case ']': // If close symbol, increase level
|
||||||
|
level--
|
||||||
|
if !iter.decrementDepth() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we have returned to the original level, we're done
|
||||||
|
if level == 0 {
|
||||||
|
iter.head = i + 1
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !iter.loadMore() {
|
||||||
|
iter.ReportError("skipObject", "incomplete array")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) skipObject() {
|
||||||
|
level := 1
|
||||||
|
if !iter.incrementDepth() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
for i := iter.head; i < iter.tail; i++ {
|
||||||
|
switch iter.buf[i] {
|
||||||
|
case '"': // If inside string, skip it
|
||||||
|
iter.head = i + 1
|
||||||
|
iter.skipString()
|
||||||
|
i = iter.head - 1 // it will be i++ soon
|
||||||
|
case '{': // If open symbol, increase level
|
||||||
|
level++
|
||||||
|
if !iter.incrementDepth() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
case '}': // If close symbol, increase level
|
||||||
|
level--
|
||||||
|
if !iter.decrementDepth() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we have returned to the original level, we're done
|
||||||
|
if level == 0 {
|
||||||
|
iter.head = i + 1
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !iter.loadMore() {
|
||||||
|
iter.ReportError("skipObject", "incomplete object")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) skipString() {
|
||||||
|
for {
|
||||||
|
end, escaped := iter.findStringEnd()
|
||||||
|
if end == -1 {
|
||||||
|
if !iter.loadMore() {
|
||||||
|
iter.ReportError("skipString", "incomplete string")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if escaped {
|
||||||
|
iter.head = 1 // skip the first char as last char read is \
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
iter.head = end
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// adapted from: https://github.com/buger/jsonparser/blob/master/parser.go
|
||||||
|
// Tries to find the end of string
|
||||||
|
// Support if string contains escaped quote symbols.
|
||||||
|
func (iter *Iterator) findStringEnd() (int, bool) {
|
||||||
|
escaped := false
|
||||||
|
for i := iter.head; i < iter.tail; i++ {
|
||||||
|
c := iter.buf[i]
|
||||||
|
if c == '"' {
|
||||||
|
if !escaped {
|
||||||
|
return i + 1, false
|
||||||
|
}
|
||||||
|
j := i - 1
|
||||||
|
for {
|
||||||
|
if j < iter.head || iter.buf[j] != '\\' {
|
||||||
|
// even number of backslashes
|
||||||
|
// either end of buffer, or " found
|
||||||
|
return i + 1, true
|
||||||
|
}
|
||||||
|
j--
|
||||||
|
if j < iter.head || iter.buf[j] != '\\' {
|
||||||
|
// odd number of backslashes
|
||||||
|
// it is \" or \\\"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
j--
|
||||||
|
}
|
||||||
|
} else if c == '\\' {
|
||||||
|
escaped = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
j := iter.tail - 1
|
||||||
|
for {
|
||||||
|
if j < iter.head || iter.buf[j] != '\\' {
|
||||||
|
// even number of backslashes
|
||||||
|
// either end of buffer, or " found
|
||||||
|
return -1, false // do not end with \
|
||||||
|
}
|
||||||
|
j--
|
||||||
|
if j < iter.head || iter.buf[j] != '\\' {
|
||||||
|
// odd number of backslashes
|
||||||
|
// it is \" or \\\"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
j--
|
||||||
|
|
||||||
|
}
|
||||||
|
return -1, true // end with \
|
||||||
|
}
|
||||||
99
vendor/github.com/json-iterator/go/iter_skip_strict.go
generated
vendored
Normal file
99
vendor/github.com/json-iterator/go/iter_skip_strict.go
generated
vendored
Normal file
|
|
@ -0,0 +1,99 @@
|
||||||
|
//+build !jsoniter_sloppy
|
||||||
|
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (iter *Iterator) skipNumber() {
|
||||||
|
if !iter.trySkipNumber() {
|
||||||
|
iter.unreadByte()
|
||||||
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
iter.ReadFloat64()
|
||||||
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
|
iter.Error = nil
|
||||||
|
iter.ReadBigFloat()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) trySkipNumber() bool {
|
||||||
|
dotFound := false
|
||||||
|
for i := iter.head; i < iter.tail; i++ {
|
||||||
|
c := iter.buf[i]
|
||||||
|
switch c {
|
||||||
|
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
|
||||||
|
case '.':
|
||||||
|
if dotFound {
|
||||||
|
iter.ReportError("validateNumber", `more than one dot found in number`)
|
||||||
|
return true // already failed
|
||||||
|
}
|
||||||
|
if i+1 == iter.tail {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
c = iter.buf[i+1]
|
||||||
|
switch c {
|
||||||
|
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
|
||||||
|
default:
|
||||||
|
iter.ReportError("validateNumber", `missing digit after dot`)
|
||||||
|
return true // already failed
|
||||||
|
}
|
||||||
|
dotFound = true
|
||||||
|
default:
|
||||||
|
switch c {
|
||||||
|
case ',', ']', '}', ' ', '\t', '\n', '\r':
|
||||||
|
if iter.head == i {
|
||||||
|
return false // if - without following digits
|
||||||
|
}
|
||||||
|
iter.head = i
|
||||||
|
return true // must be valid
|
||||||
|
}
|
||||||
|
return false // may be invalid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) skipString() {
|
||||||
|
if !iter.trySkipString() {
|
||||||
|
iter.unreadByte()
|
||||||
|
iter.ReadString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) trySkipString() bool {
|
||||||
|
for i := iter.head; i < iter.tail; i++ {
|
||||||
|
c := iter.buf[i]
|
||||||
|
if c == '"' {
|
||||||
|
iter.head = i + 1
|
||||||
|
return true // valid
|
||||||
|
} else if c == '\\' {
|
||||||
|
return false
|
||||||
|
} else if c < ' ' {
|
||||||
|
iter.ReportError("trySkipString",
|
||||||
|
fmt.Sprintf(`invalid control character found: %d`, c))
|
||||||
|
return true // already failed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) skipObject() {
|
||||||
|
iter.unreadByte()
|
||||||
|
iter.ReadObjectCB(func(iter *Iterator, field string) bool {
|
||||||
|
iter.Skip()
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) skipArray() {
|
||||||
|
iter.unreadByte()
|
||||||
|
iter.ReadArrayCB(func(iter *Iterator) bool {
|
||||||
|
iter.Skip()
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}
|
||||||
215
vendor/github.com/json-iterator/go/iter_str.go
generated
vendored
Normal file
215
vendor/github.com/json-iterator/go/iter_str.go
generated
vendored
Normal file
|
|
@ -0,0 +1,215 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"unicode/utf16"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ReadString read string from iterator
|
||||||
|
func (iter *Iterator) ReadString() (ret string) {
|
||||||
|
c := iter.nextToken()
|
||||||
|
if c == '"' {
|
||||||
|
for i := iter.head; i < iter.tail; i++ {
|
||||||
|
c := iter.buf[i]
|
||||||
|
if c == '"' {
|
||||||
|
ret = string(iter.buf[iter.head:i])
|
||||||
|
iter.head = i + 1
|
||||||
|
return ret
|
||||||
|
} else if c == '\\' {
|
||||||
|
break
|
||||||
|
} else if c < ' ' {
|
||||||
|
iter.ReportError("ReadString",
|
||||||
|
fmt.Sprintf(`invalid control character found: %d`, c))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return iter.readStringSlowPath()
|
||||||
|
} else if c == 'n' {
|
||||||
|
iter.skipThreeBytes('u', 'l', 'l')
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
iter.ReportError("ReadString", `expects " or n, but found `+string([]byte{c}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) readStringSlowPath() (ret string) {
|
||||||
|
var str []byte
|
||||||
|
var c byte
|
||||||
|
for iter.Error == nil {
|
||||||
|
c = iter.readByte()
|
||||||
|
if c == '"' {
|
||||||
|
return string(str)
|
||||||
|
}
|
||||||
|
if c == '\\' {
|
||||||
|
c = iter.readByte()
|
||||||
|
str = iter.readEscapedChar(c, str)
|
||||||
|
} else {
|
||||||
|
str = append(str, c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
iter.ReportError("readStringSlowPath", "unexpected end of input")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) readEscapedChar(c byte, str []byte) []byte {
|
||||||
|
switch c {
|
||||||
|
case 'u':
|
||||||
|
r := iter.readU4()
|
||||||
|
if utf16.IsSurrogate(r) {
|
||||||
|
c = iter.readByte()
|
||||||
|
if iter.Error != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if c != '\\' {
|
||||||
|
iter.unreadByte()
|
||||||
|
str = appendRune(str, r)
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
c = iter.readByte()
|
||||||
|
if iter.Error != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if c != 'u' {
|
||||||
|
str = appendRune(str, r)
|
||||||
|
return iter.readEscapedChar(c, str)
|
||||||
|
}
|
||||||
|
r2 := iter.readU4()
|
||||||
|
if iter.Error != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
combined := utf16.DecodeRune(r, r2)
|
||||||
|
if combined == '\uFFFD' {
|
||||||
|
str = appendRune(str, r)
|
||||||
|
str = appendRune(str, r2)
|
||||||
|
} else {
|
||||||
|
str = appendRune(str, combined)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
str = appendRune(str, r)
|
||||||
|
}
|
||||||
|
case '"':
|
||||||
|
str = append(str, '"')
|
||||||
|
case '\\':
|
||||||
|
str = append(str, '\\')
|
||||||
|
case '/':
|
||||||
|
str = append(str, '/')
|
||||||
|
case 'b':
|
||||||
|
str = append(str, '\b')
|
||||||
|
case 'f':
|
||||||
|
str = append(str, '\f')
|
||||||
|
case 'n':
|
||||||
|
str = append(str, '\n')
|
||||||
|
case 'r':
|
||||||
|
str = append(str, '\r')
|
||||||
|
case 't':
|
||||||
|
str = append(str, '\t')
|
||||||
|
default:
|
||||||
|
iter.ReportError("readEscapedChar",
|
||||||
|
`invalid escape char after \`)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadStringAsSlice read string from iterator without copying into string form.
|
||||||
|
// The []byte can not be kept, as it will change after next iterator call.
|
||||||
|
func (iter *Iterator) ReadStringAsSlice() (ret []byte) {
|
||||||
|
c := iter.nextToken()
|
||||||
|
if c == '"' {
|
||||||
|
for i := iter.head; i < iter.tail; i++ {
|
||||||
|
// require ascii string and no escape
|
||||||
|
// for: field name, base64, number
|
||||||
|
if iter.buf[i] == '"' {
|
||||||
|
// fast path: reuse the underlying buffer
|
||||||
|
ret = iter.buf[iter.head:i]
|
||||||
|
iter.head = i + 1
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
}
|
||||||
|
readLen := iter.tail - iter.head
|
||||||
|
copied := make([]byte, readLen, readLen*2)
|
||||||
|
copy(copied, iter.buf[iter.head:iter.tail])
|
||||||
|
iter.head = iter.tail
|
||||||
|
for iter.Error == nil {
|
||||||
|
c := iter.readByte()
|
||||||
|
if c == '"' {
|
||||||
|
return copied
|
||||||
|
}
|
||||||
|
copied = append(copied, c)
|
||||||
|
}
|
||||||
|
return copied
|
||||||
|
}
|
||||||
|
iter.ReportError("ReadStringAsSlice", `expects " or n, but found `+string([]byte{c}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iter *Iterator) readU4() (ret rune) {
|
||||||
|
for i := 0; i < 4; i++ {
|
||||||
|
c := iter.readByte()
|
||||||
|
if iter.Error != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if c >= '0' && c <= '9' {
|
||||||
|
ret = ret*16 + rune(c-'0')
|
||||||
|
} else if c >= 'a' && c <= 'f' {
|
||||||
|
ret = ret*16 + rune(c-'a'+10)
|
||||||
|
} else if c >= 'A' && c <= 'F' {
|
||||||
|
ret = ret*16 + rune(c-'A'+10)
|
||||||
|
} else {
|
||||||
|
iter.ReportError("readU4", "expects 0~9 or a~f, but found "+string([]byte{c}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
t1 = 0x00 // 0000 0000
|
||||||
|
tx = 0x80 // 1000 0000
|
||||||
|
t2 = 0xC0 // 1100 0000
|
||||||
|
t3 = 0xE0 // 1110 0000
|
||||||
|
t4 = 0xF0 // 1111 0000
|
||||||
|
t5 = 0xF8 // 1111 1000
|
||||||
|
|
||||||
|
maskx = 0x3F // 0011 1111
|
||||||
|
mask2 = 0x1F // 0001 1111
|
||||||
|
mask3 = 0x0F // 0000 1111
|
||||||
|
mask4 = 0x07 // 0000 0111
|
||||||
|
|
||||||
|
rune1Max = 1<<7 - 1
|
||||||
|
rune2Max = 1<<11 - 1
|
||||||
|
rune3Max = 1<<16 - 1
|
||||||
|
|
||||||
|
surrogateMin = 0xD800
|
||||||
|
surrogateMax = 0xDFFF
|
||||||
|
|
||||||
|
maxRune = '\U0010FFFF' // Maximum valid Unicode code point.
|
||||||
|
runeError = '\uFFFD' // the "error" Rune or "Unicode replacement character"
|
||||||
|
)
|
||||||
|
|
||||||
|
func appendRune(p []byte, r rune) []byte {
|
||||||
|
// Negative values are erroneous. Making it unsigned addresses the problem.
|
||||||
|
switch i := uint32(r); {
|
||||||
|
case i <= rune1Max:
|
||||||
|
p = append(p, byte(r))
|
||||||
|
return p
|
||||||
|
case i <= rune2Max:
|
||||||
|
p = append(p, t2|byte(r>>6))
|
||||||
|
p = append(p, tx|byte(r)&maskx)
|
||||||
|
return p
|
||||||
|
case i > maxRune, surrogateMin <= i && i <= surrogateMax:
|
||||||
|
r = runeError
|
||||||
|
fallthrough
|
||||||
|
case i <= rune3Max:
|
||||||
|
p = append(p, t3|byte(r>>12))
|
||||||
|
p = append(p, tx|byte(r>>6)&maskx)
|
||||||
|
p = append(p, tx|byte(r)&maskx)
|
||||||
|
return p
|
||||||
|
default:
|
||||||
|
p = append(p, t4|byte(r>>18))
|
||||||
|
p = append(p, tx|byte(r>>12)&maskx)
|
||||||
|
p = append(p, tx|byte(r>>6)&maskx)
|
||||||
|
p = append(p, tx|byte(r)&maskx)
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
}
|
||||||
18
vendor/github.com/json-iterator/go/jsoniter.go
generated
vendored
Normal file
18
vendor/github.com/json-iterator/go/jsoniter.go
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
// Package jsoniter implements encoding and decoding of JSON as defined in
|
||||||
|
// RFC 4627 and provides interfaces with identical syntax of standard lib encoding/json.
|
||||||
|
// Converting from encoding/json to jsoniter is no more than replacing the package with jsoniter
|
||||||
|
// and variable type declarations (if any).
|
||||||
|
// jsoniter interfaces gives 100% compatibility with code using standard lib.
|
||||||
|
//
|
||||||
|
// "JSON and Go"
|
||||||
|
// (https://golang.org/doc/articles/json_and_go.html)
|
||||||
|
// gives a description of how Marshal/Unmarshal operate
|
||||||
|
// between arbitrary or predefined json objects and bytes,
|
||||||
|
// and it applies to jsoniter.Marshal/Unmarshal as well.
|
||||||
|
//
|
||||||
|
// Besides, jsoniter.Iterator provides a different set of interfaces
|
||||||
|
// iterating given bytes/string/reader
|
||||||
|
// and yielding parsed elements one by one.
|
||||||
|
// This set of interfaces reads input as required and gives
|
||||||
|
// better performance.
|
||||||
|
package jsoniter
|
||||||
42
vendor/github.com/json-iterator/go/pool.go
generated
vendored
Normal file
42
vendor/github.com/json-iterator/go/pool.go
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IteratorPool a thread safe pool of iterators with same configuration
|
||||||
|
type IteratorPool interface {
|
||||||
|
BorrowIterator(data []byte) *Iterator
|
||||||
|
ReturnIterator(iter *Iterator)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StreamPool a thread safe pool of streams with same configuration
|
||||||
|
type StreamPool interface {
|
||||||
|
BorrowStream(writer io.Writer) *Stream
|
||||||
|
ReturnStream(stream *Stream)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) BorrowStream(writer io.Writer) *Stream {
|
||||||
|
stream := cfg.streamPool.Get().(*Stream)
|
||||||
|
stream.Reset(writer)
|
||||||
|
return stream
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) ReturnStream(stream *Stream) {
|
||||||
|
stream.out = nil
|
||||||
|
stream.Error = nil
|
||||||
|
stream.Attachment = nil
|
||||||
|
cfg.streamPool.Put(stream)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) BorrowIterator(data []byte) *Iterator {
|
||||||
|
iter := cfg.iteratorPool.Get().(*Iterator)
|
||||||
|
iter.ResetBytes(data)
|
||||||
|
return iter
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) ReturnIterator(iter *Iterator) {
|
||||||
|
iter.Error = nil
|
||||||
|
iter.Attachment = nil
|
||||||
|
cfg.iteratorPool.Put(iter)
|
||||||
|
}
|
||||||
337
vendor/github.com/json-iterator/go/reflect.go
generated
vendored
Normal file
337
vendor/github.com/json-iterator/go/reflect.go
generated
vendored
Normal file
|
|
@ -0,0 +1,337 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/modern-go/reflect2"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ValDecoder is an internal type registered to cache as needed.
|
||||||
|
// Don't confuse jsoniter.ValDecoder with json.Decoder.
|
||||||
|
// For json.Decoder's adapter, refer to jsoniter.AdapterDecoder(todo link).
|
||||||
|
//
|
||||||
|
// Reflection on type to create decoders, which is then cached
|
||||||
|
// Reflection on value is avoided as we can, as the reflect.Value itself will allocate, with following exceptions
|
||||||
|
// 1. create instance of new value, for example *int will need a int to be allocated
|
||||||
|
// 2. append to slice, if the existing cap is not enough, allocate will be done using Reflect.New
|
||||||
|
// 3. assignment to map, both key and value will be reflect.Value
|
||||||
|
// For a simple struct binding, it will be reflect.Value free and allocation free
|
||||||
|
type ValDecoder interface {
|
||||||
|
Decode(ptr unsafe.Pointer, iter *Iterator)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValEncoder is an internal type registered to cache as needed.
|
||||||
|
// Don't confuse jsoniter.ValEncoder with json.Encoder.
|
||||||
|
// For json.Encoder's adapter, refer to jsoniter.AdapterEncoder(todo godoc link).
|
||||||
|
type ValEncoder interface {
|
||||||
|
IsEmpty(ptr unsafe.Pointer) bool
|
||||||
|
Encode(ptr unsafe.Pointer, stream *Stream)
|
||||||
|
}
|
||||||
|
|
||||||
|
type checkIsEmpty interface {
|
||||||
|
IsEmpty(ptr unsafe.Pointer) bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type ctx struct {
|
||||||
|
*frozenConfig
|
||||||
|
prefix string
|
||||||
|
encoders map[reflect2.Type]ValEncoder
|
||||||
|
decoders map[reflect2.Type]ValDecoder
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *ctx) caseSensitive() bool {
|
||||||
|
if b.frozenConfig == nil {
|
||||||
|
// default is case-insensitive
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return b.frozenConfig.caseSensitive
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *ctx) append(prefix string) *ctx {
|
||||||
|
return &ctx{
|
||||||
|
frozenConfig: b.frozenConfig,
|
||||||
|
prefix: b.prefix + " " + prefix,
|
||||||
|
encoders: b.encoders,
|
||||||
|
decoders: b.decoders,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadVal copy the underlying JSON into go interface, same as json.Unmarshal
|
||||||
|
func (iter *Iterator) ReadVal(obj interface{}) {
|
||||||
|
depth := iter.depth
|
||||||
|
cacheKey := reflect2.RTypeOf(obj)
|
||||||
|
decoder := iter.cfg.getDecoderFromCache(cacheKey)
|
||||||
|
if decoder == nil {
|
||||||
|
typ := reflect2.TypeOf(obj)
|
||||||
|
if typ.Kind() != reflect.Ptr {
|
||||||
|
iter.ReportError("ReadVal", "can only unmarshal into pointer")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
decoder = iter.cfg.DecoderOf(typ)
|
||||||
|
}
|
||||||
|
ptr := reflect2.PtrOf(obj)
|
||||||
|
if ptr == nil {
|
||||||
|
iter.ReportError("ReadVal", "can not read into nil pointer")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
decoder.Decode(ptr, iter)
|
||||||
|
if iter.depth != depth {
|
||||||
|
iter.ReportError("ReadVal", "unexpected mismatched nesting")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteVal copy the go interface into underlying JSON, same as json.Marshal
|
||||||
|
func (stream *Stream) WriteVal(val interface{}) {
|
||||||
|
if nil == val {
|
||||||
|
stream.WriteNil()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cacheKey := reflect2.RTypeOf(val)
|
||||||
|
encoder := stream.cfg.getEncoderFromCache(cacheKey)
|
||||||
|
if encoder == nil {
|
||||||
|
typ := reflect2.TypeOf(val)
|
||||||
|
encoder = stream.cfg.EncoderOf(typ)
|
||||||
|
}
|
||||||
|
encoder.Encode(reflect2.PtrOf(val), stream)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) DecoderOf(typ reflect2.Type) ValDecoder {
|
||||||
|
cacheKey := typ.RType()
|
||||||
|
decoder := cfg.getDecoderFromCache(cacheKey)
|
||||||
|
if decoder != nil {
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
ctx := &ctx{
|
||||||
|
frozenConfig: cfg,
|
||||||
|
prefix: "",
|
||||||
|
decoders: map[reflect2.Type]ValDecoder{},
|
||||||
|
encoders: map[reflect2.Type]ValEncoder{},
|
||||||
|
}
|
||||||
|
ptrType := typ.(*reflect2.UnsafePtrType)
|
||||||
|
decoder = decoderOfType(ctx, ptrType.Elem())
|
||||||
|
cfg.addDecoderToCache(cacheKey, decoder)
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
|
||||||
|
func decoderOfType(ctx *ctx, typ reflect2.Type) ValDecoder {
|
||||||
|
decoder := getTypeDecoderFromExtension(ctx, typ)
|
||||||
|
if decoder != nil {
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
decoder = createDecoderOfType(ctx, typ)
|
||||||
|
for _, extension := range extensions {
|
||||||
|
decoder = extension.DecorateDecoder(typ, decoder)
|
||||||
|
}
|
||||||
|
decoder = ctx.decoderExtension.DecorateDecoder(typ, decoder)
|
||||||
|
for _, extension := range ctx.extraExtensions {
|
||||||
|
decoder = extension.DecorateDecoder(typ, decoder)
|
||||||
|
}
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
|
||||||
|
func createDecoderOfType(ctx *ctx, typ reflect2.Type) ValDecoder {
|
||||||
|
decoder := ctx.decoders[typ]
|
||||||
|
if decoder != nil {
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
placeholder := &placeholderDecoder{}
|
||||||
|
ctx.decoders[typ] = placeholder
|
||||||
|
decoder = _createDecoderOfType(ctx, typ)
|
||||||
|
placeholder.decoder = decoder
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
|
||||||
|
func _createDecoderOfType(ctx *ctx, typ reflect2.Type) ValDecoder {
|
||||||
|
decoder := createDecoderOfJsonRawMessage(ctx, typ)
|
||||||
|
if decoder != nil {
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
decoder = createDecoderOfJsonNumber(ctx, typ)
|
||||||
|
if decoder != nil {
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
decoder = createDecoderOfMarshaler(ctx, typ)
|
||||||
|
if decoder != nil {
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
decoder = createDecoderOfAny(ctx, typ)
|
||||||
|
if decoder != nil {
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
decoder = createDecoderOfNative(ctx, typ)
|
||||||
|
if decoder != nil {
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
switch typ.Kind() {
|
||||||
|
case reflect.Interface:
|
||||||
|
ifaceType, isIFace := typ.(*reflect2.UnsafeIFaceType)
|
||||||
|
if isIFace {
|
||||||
|
return &ifaceDecoder{valType: ifaceType}
|
||||||
|
}
|
||||||
|
return &efaceDecoder{}
|
||||||
|
case reflect.Struct:
|
||||||
|
return decoderOfStruct(ctx, typ)
|
||||||
|
case reflect.Array:
|
||||||
|
return decoderOfArray(ctx, typ)
|
||||||
|
case reflect.Slice:
|
||||||
|
return decoderOfSlice(ctx, typ)
|
||||||
|
case reflect.Map:
|
||||||
|
return decoderOfMap(ctx, typ)
|
||||||
|
case reflect.Ptr:
|
||||||
|
return decoderOfOptional(ctx, typ)
|
||||||
|
default:
|
||||||
|
return &lazyErrorDecoder{err: fmt.Errorf("%s%s is unsupported type", ctx.prefix, typ.String())}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg *frozenConfig) EncoderOf(typ reflect2.Type) ValEncoder {
|
||||||
|
cacheKey := typ.RType()
|
||||||
|
encoder := cfg.getEncoderFromCache(cacheKey)
|
||||||
|
if encoder != nil {
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
ctx := &ctx{
|
||||||
|
frozenConfig: cfg,
|
||||||
|
prefix: "",
|
||||||
|
decoders: map[reflect2.Type]ValDecoder{},
|
||||||
|
encoders: map[reflect2.Type]ValEncoder{},
|
||||||
|
}
|
||||||
|
encoder = encoderOfType(ctx, typ)
|
||||||
|
if typ.LikePtr() {
|
||||||
|
encoder = &onePtrEncoder{encoder}
|
||||||
|
}
|
||||||
|
cfg.addEncoderToCache(cacheKey, encoder)
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
|
||||||
|
type onePtrEncoder struct {
|
||||||
|
encoder ValEncoder
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder *onePtrEncoder) IsEmpty(ptr unsafe.Pointer) bool {
|
||||||
|
return encoder.encoder.IsEmpty(unsafe.Pointer(&ptr))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder *onePtrEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
|
||||||
|
encoder.encoder.Encode(unsafe.Pointer(&ptr), stream)
|
||||||
|
}
|
||||||
|
|
||||||
|
func encoderOfType(ctx *ctx, typ reflect2.Type) ValEncoder {
|
||||||
|
encoder := getTypeEncoderFromExtension(ctx, typ)
|
||||||
|
if encoder != nil {
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
encoder = createEncoderOfType(ctx, typ)
|
||||||
|
for _, extension := range extensions {
|
||||||
|
encoder = extension.DecorateEncoder(typ, encoder)
|
||||||
|
}
|
||||||
|
encoder = ctx.encoderExtension.DecorateEncoder(typ, encoder)
|
||||||
|
for _, extension := range ctx.extraExtensions {
|
||||||
|
encoder = extension.DecorateEncoder(typ, encoder)
|
||||||
|
}
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
|
||||||
|
func createEncoderOfType(ctx *ctx, typ reflect2.Type) ValEncoder {
|
||||||
|
encoder := ctx.encoders[typ]
|
||||||
|
if encoder != nil {
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
placeholder := &placeholderEncoder{}
|
||||||
|
ctx.encoders[typ] = placeholder
|
||||||
|
encoder = _createEncoderOfType(ctx, typ)
|
||||||
|
placeholder.encoder = encoder
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
func _createEncoderOfType(ctx *ctx, typ reflect2.Type) ValEncoder {
|
||||||
|
encoder := createEncoderOfJsonRawMessage(ctx, typ)
|
||||||
|
if encoder != nil {
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
encoder = createEncoderOfJsonNumber(ctx, typ)
|
||||||
|
if encoder != nil {
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
encoder = createEncoderOfMarshaler(ctx, typ)
|
||||||
|
if encoder != nil {
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
encoder = createEncoderOfAny(ctx, typ)
|
||||||
|
if encoder != nil {
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
encoder = createEncoderOfNative(ctx, typ)
|
||||||
|
if encoder != nil {
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
kind := typ.Kind()
|
||||||
|
switch kind {
|
||||||
|
case reflect.Interface:
|
||||||
|
return &dynamicEncoder{typ}
|
||||||
|
case reflect.Struct:
|
||||||
|
return encoderOfStruct(ctx, typ)
|
||||||
|
case reflect.Array:
|
||||||
|
return encoderOfArray(ctx, typ)
|
||||||
|
case reflect.Slice:
|
||||||
|
return encoderOfSlice(ctx, typ)
|
||||||
|
case reflect.Map:
|
||||||
|
return encoderOfMap(ctx, typ)
|
||||||
|
case reflect.Ptr:
|
||||||
|
return encoderOfOptional(ctx, typ)
|
||||||
|
default:
|
||||||
|
return &lazyErrorEncoder{err: fmt.Errorf("%s%s is unsupported type", ctx.prefix, typ.String())}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type lazyErrorDecoder struct {
|
||||||
|
err error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (decoder *lazyErrorDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
|
||||||
|
if iter.WhatIsNext() != NilValue {
|
||||||
|
if iter.Error == nil {
|
||||||
|
iter.Error = decoder.err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
iter.Skip()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type lazyErrorEncoder struct {
|
||||||
|
err error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder *lazyErrorEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
|
||||||
|
if ptr == nil {
|
||||||
|
stream.WriteNil()
|
||||||
|
} else if stream.Error == nil {
|
||||||
|
stream.Error = encoder.err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder *lazyErrorEncoder) IsEmpty(ptr unsafe.Pointer) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
type placeholderDecoder struct {
|
||||||
|
decoder ValDecoder
|
||||||
|
}
|
||||||
|
|
||||||
|
func (decoder *placeholderDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
|
||||||
|
decoder.decoder.Decode(ptr, iter)
|
||||||
|
}
|
||||||
|
|
||||||
|
type placeholderEncoder struct {
|
||||||
|
encoder ValEncoder
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder *placeholderEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
|
||||||
|
encoder.encoder.Encode(ptr, stream)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder *placeholderEncoder) IsEmpty(ptr unsafe.Pointer) bool {
|
||||||
|
return encoder.encoder.IsEmpty(ptr)
|
||||||
|
}
|
||||||
104
vendor/github.com/json-iterator/go/reflect_array.go
generated
vendored
Normal file
104
vendor/github.com/json-iterator/go/reflect_array.go
generated
vendored
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/modern-go/reflect2"
|
||||||
|
"io"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
func decoderOfArray(ctx *ctx, typ reflect2.Type) ValDecoder {
|
||||||
|
arrayType := typ.(*reflect2.UnsafeArrayType)
|
||||||
|
decoder := decoderOfType(ctx.append("[arrayElem]"), arrayType.Elem())
|
||||||
|
return &arrayDecoder{arrayType, decoder}
|
||||||
|
}
|
||||||
|
|
||||||
|
func encoderOfArray(ctx *ctx, typ reflect2.Type) ValEncoder {
|
||||||
|
arrayType := typ.(*reflect2.UnsafeArrayType)
|
||||||
|
if arrayType.Len() == 0 {
|
||||||
|
return emptyArrayEncoder{}
|
||||||
|
}
|
||||||
|
encoder := encoderOfType(ctx.append("[arrayElem]"), arrayType.Elem())
|
||||||
|
return &arrayEncoder{arrayType, encoder}
|
||||||
|
}
|
||||||
|
|
||||||
|
type emptyArrayEncoder struct{}
|
||||||
|
|
||||||
|
func (encoder emptyArrayEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
|
||||||
|
stream.WriteEmptyArray()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder emptyArrayEncoder) IsEmpty(ptr unsafe.Pointer) bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
type arrayEncoder struct {
|
||||||
|
arrayType *reflect2.UnsafeArrayType
|
||||||
|
elemEncoder ValEncoder
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder *arrayEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
|
||||||
|
stream.WriteArrayStart()
|
||||||
|
elemPtr := unsafe.Pointer(ptr)
|
||||||
|
encoder.elemEncoder.Encode(elemPtr, stream)
|
||||||
|
for i := 1; i < encoder.arrayType.Len(); i++ {
|
||||||
|
stream.WriteMore()
|
||||||
|
elemPtr = encoder.arrayType.UnsafeGetIndex(ptr, i)
|
||||||
|
encoder.elemEncoder.Encode(elemPtr, stream)
|
||||||
|
}
|
||||||
|
stream.WriteArrayEnd()
|
||||||
|
if stream.Error != nil && stream.Error != io.EOF {
|
||||||
|
stream.Error = fmt.Errorf("%v: %s", encoder.arrayType, stream.Error.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder *arrayEncoder) IsEmpty(ptr unsafe.Pointer) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
type arrayDecoder struct {
|
||||||
|
arrayType *reflect2.UnsafeArrayType
|
||||||
|
elemDecoder ValDecoder
|
||||||
|
}
|
||||||
|
|
||||||
|
func (decoder *arrayDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
|
||||||
|
decoder.doDecode(ptr, iter)
|
||||||
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
|
iter.Error = fmt.Errorf("%v: %s", decoder.arrayType, iter.Error.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (decoder *arrayDecoder) doDecode(ptr unsafe.Pointer, iter *Iterator) {
|
||||||
|
c := iter.nextToken()
|
||||||
|
arrayType := decoder.arrayType
|
||||||
|
if c == 'n' {
|
||||||
|
iter.skipThreeBytes('u', 'l', 'l')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if c != '[' {
|
||||||
|
iter.ReportError("decode array", "expect [ or n, but found "+string([]byte{c}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c = iter.nextToken()
|
||||||
|
if c == ']' {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
iter.unreadByte()
|
||||||
|
elemPtr := arrayType.UnsafeGetIndex(ptr, 0)
|
||||||
|
decoder.elemDecoder.Decode(elemPtr, iter)
|
||||||
|
length := 1
|
||||||
|
for c = iter.nextToken(); c == ','; c = iter.nextToken() {
|
||||||
|
if length >= arrayType.Len() {
|
||||||
|
iter.Skip()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
idx := length
|
||||||
|
length += 1
|
||||||
|
elemPtr = arrayType.UnsafeGetIndex(ptr, idx)
|
||||||
|
decoder.elemDecoder.Decode(elemPtr, iter)
|
||||||
|
}
|
||||||
|
if c != ']' {
|
||||||
|
iter.ReportError("decode array", "expect ], but found "+string([]byte{c}))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
70
vendor/github.com/json-iterator/go/reflect_dynamic.go
generated
vendored
Normal file
70
vendor/github.com/json-iterator/go/reflect_dynamic.go
generated
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/modern-go/reflect2"
|
||||||
|
"reflect"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
type dynamicEncoder struct {
|
||||||
|
valType reflect2.Type
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder *dynamicEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
|
||||||
|
obj := encoder.valType.UnsafeIndirect(ptr)
|
||||||
|
stream.WriteVal(obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder *dynamicEncoder) IsEmpty(ptr unsafe.Pointer) bool {
|
||||||
|
return encoder.valType.UnsafeIndirect(ptr) == nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type efaceDecoder struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (decoder *efaceDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
|
||||||
|
pObj := (*interface{})(ptr)
|
||||||
|
obj := *pObj
|
||||||
|
if obj == nil {
|
||||||
|
*pObj = iter.Read()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
typ := reflect2.TypeOf(obj)
|
||||||
|
if typ.Kind() != reflect.Ptr {
|
||||||
|
*pObj = iter.Read()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ptrType := typ.(*reflect2.UnsafePtrType)
|
||||||
|
ptrElemType := ptrType.Elem()
|
||||||
|
if iter.WhatIsNext() == NilValue {
|
||||||
|
if ptrElemType.Kind() != reflect.Ptr {
|
||||||
|
iter.skipFourBytes('n', 'u', 'l', 'l')
|
||||||
|
*pObj = nil
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if reflect2.IsNil(obj) {
|
||||||
|
obj := ptrElemType.New()
|
||||||
|
iter.ReadVal(obj)
|
||||||
|
*pObj = obj
|
||||||
|
return
|
||||||
|
}
|
||||||
|
iter.ReadVal(obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
type ifaceDecoder struct {
|
||||||
|
valType *reflect2.UnsafeIFaceType
|
||||||
|
}
|
||||||
|
|
||||||
|
func (decoder *ifaceDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
|
||||||
|
if iter.ReadNil() {
|
||||||
|
decoder.valType.UnsafeSet(ptr, decoder.valType.UnsafeNew())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
obj := decoder.valType.UnsafeIndirect(ptr)
|
||||||
|
if reflect2.IsNil(obj) {
|
||||||
|
iter.ReportError("decode non empty interface", "can not unmarshal into nil")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
iter.ReadVal(obj)
|
||||||
|
}
|
||||||
483
vendor/github.com/json-iterator/go/reflect_extension.go
generated
vendored
Normal file
483
vendor/github.com/json-iterator/go/reflect_extension.go
generated
vendored
Normal file
|
|
@ -0,0 +1,483 @@
|
||||||
|
package jsoniter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/modern-go/reflect2"
|
||||||
|
"reflect"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
"unicode"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
var typeDecoders = map[string]ValDecoder{}
|
||||||
|
var fieldDecoders = map[string]ValDecoder{}
|
||||||
|
var typeEncoders = map[string]ValEncoder{}
|
||||||
|
var fieldEncoders = map[string]ValEncoder{}
|
||||||
|
var extensions = []Extension{}
|
||||||
|
|
||||||
|
// StructDescriptor describe how should we encode/decode the struct
|
||||||
|
type StructDescriptor struct {
|
||||||
|
Type reflect2.Type
|
||||||
|
Fields []*Binding
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetField get one field from the descriptor by its name.
|
||||||
|
// Can not use map here to keep field orders.
|
||||||
|
func (structDescriptor *StructDescriptor) GetField(fieldName string) *Binding {
|
||||||
|
for _, binding := range structDescriptor.Fields {
|
||||||
|
if binding.Field.Name() == fieldName {
|
||||||
|
return binding
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Binding describe how should we encode/decode the struct field
|
||||||
|
type Binding struct {
|
||||||
|
levels []int
|
||||||
|
Field reflect2.StructField
|
||||||
|
FromNames []string
|
||||||
|
ToNames []string
|
||||||
|
Encoder ValEncoder
|
||||||
|
Decoder ValDecoder
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extension the one for all SPI. Customize encoding/decoding by specifying alternate encoder/decoder.
|
||||||
|
// Can also rename fields by UpdateStructDescriptor.
|
||||||
|
type Extension interface {
|
||||||
|
UpdateStructDescriptor(structDescriptor *StructDescriptor)
|
||||||
|
CreateMapKeyDecoder(typ reflect2.Type) ValDecoder
|
||||||
|
CreateMapKeyEncoder(typ reflect2.Type) ValEncoder
|
||||||
|
CreateDecoder(typ reflect2.Type) ValDecoder
|
||||||
|
CreateEncoder(typ reflect2.Type) ValEncoder
|
||||||
|
DecorateDecoder(typ reflect2.Type, decoder ValDecoder) ValDecoder
|
||||||
|
DecorateEncoder(typ reflect2.Type, encoder ValEncoder) ValEncoder
|
||||||
|
}
|
||||||
|
|
||||||
|
// DummyExtension embed this type get dummy implementation for all methods of Extension
|
||||||
|
type DummyExtension struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStructDescriptor No-op
|
||||||
|
func (extension *DummyExtension) UpdateStructDescriptor(structDescriptor *StructDescriptor) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateMapKeyDecoder No-op
|
||||||
|
func (extension *DummyExtension) CreateMapKeyDecoder(typ reflect2.Type) ValDecoder {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateMapKeyEncoder No-op
|
||||||
|
func (extension *DummyExtension) CreateMapKeyEncoder(typ reflect2.Type) ValEncoder {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateDecoder No-op
|
||||||
|
func (extension *DummyExtension) CreateDecoder(typ reflect2.Type) ValDecoder {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateEncoder No-op
|
||||||
|
func (extension *DummyExtension) CreateEncoder(typ reflect2.Type) ValEncoder {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DecorateDecoder No-op
|
||||||
|
func (extension *DummyExtension) DecorateDecoder(typ reflect2.Type, decoder ValDecoder) ValDecoder {
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
|
||||||
|
// DecorateEncoder No-op
|
||||||
|
func (extension *DummyExtension) DecorateEncoder(typ reflect2.Type, encoder ValEncoder) ValEncoder {
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
|
||||||
|
type EncoderExtension map[reflect2.Type]ValEncoder
|
||||||
|
|
||||||
|
// UpdateStructDescriptor No-op
|
||||||
|
func (extension EncoderExtension) UpdateStructDescriptor(structDescriptor *StructDescriptor) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateDecoder No-op
|
||||||
|
func (extension EncoderExtension) CreateDecoder(typ reflect2.Type) ValDecoder {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateEncoder get encoder from map
|
||||||
|
func (extension EncoderExtension) CreateEncoder(typ reflect2.Type) ValEncoder {
|
||||||
|
return extension[typ]
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateMapKeyDecoder No-op
|
||||||
|
func (extension EncoderExtension) CreateMapKeyDecoder(typ reflect2.Type) ValDecoder {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateMapKeyEncoder No-op
|
||||||
|
func (extension EncoderExtension) CreateMapKeyEncoder(typ reflect2.Type) ValEncoder {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DecorateDecoder No-op
|
||||||
|
func (extension EncoderExtension) DecorateDecoder(typ reflect2.Type, decoder ValDecoder) ValDecoder {
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
|
||||||
|
// DecorateEncoder No-op
|
||||||
|
func (extension EncoderExtension) DecorateEncoder(typ reflect2.Type, encoder ValEncoder) ValEncoder {
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
|
||||||
|
type DecoderExtension map[reflect2.Type]ValDecoder
|
||||||
|
|
||||||
|
// UpdateStructDescriptor No-op
|
||||||
|
func (extension DecoderExtension) UpdateStructDescriptor(structDescriptor *StructDescriptor) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateMapKeyDecoder No-op
|
||||||
|
func (extension DecoderExtension) CreateMapKeyDecoder(typ reflect2.Type) ValDecoder {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateMapKeyEncoder No-op
|
||||||
|
func (extension DecoderExtension) CreateMapKeyEncoder(typ reflect2.Type) ValEncoder {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateDecoder get decoder from map
|
||||||
|
func (extension DecoderExtension) CreateDecoder(typ reflect2.Type) ValDecoder {
|
||||||
|
return extension[typ]
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateEncoder No-op
|
||||||
|
func (extension DecoderExtension) CreateEncoder(typ reflect2.Type) ValEncoder {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DecorateDecoder No-op
|
||||||
|
func (extension DecoderExtension) DecorateDecoder(typ reflect2.Type, decoder ValDecoder) ValDecoder {
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
|
||||||
|
// DecorateEncoder No-op
|
||||||
|
func (extension DecoderExtension) DecorateEncoder(typ reflect2.Type, encoder ValEncoder) ValEncoder {
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
|
||||||
|
type funcDecoder struct {
|
||||||
|
fun DecoderFunc
|
||||||
|
}
|
||||||
|
|
||||||
|
func (decoder *funcDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
|
||||||
|
decoder.fun(ptr, iter)
|
||||||
|
}
|
||||||
|
|
||||||
|
type funcEncoder struct {
|
||||||
|
fun EncoderFunc
|
||||||
|
isEmptyFunc func(ptr unsafe.Pointer) bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder *funcEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
|
||||||
|
encoder.fun(ptr, stream)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (encoder *funcEncoder) IsEmpty(ptr unsafe.Pointer) bool {
|
||||||
|
if encoder.isEmptyFunc == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return encoder.isEmptyFunc(ptr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DecoderFunc the function form of TypeDecoder
|
||||||
|
type DecoderFunc func(ptr unsafe.Pointer, iter *Iterator)
|
||||||
|
|
||||||
|
// EncoderFunc the function form of TypeEncoder
|
||||||
|
type EncoderFunc func(ptr unsafe.Pointer, stream *Stream)
|
||||||
|
|
||||||
|
// RegisterTypeDecoderFunc register TypeDecoder for a type with function
|
||||||
|
func RegisterTypeDecoderFunc(typ string, fun DecoderFunc) {
|
||||||
|
typeDecoders[typ] = &funcDecoder{fun}
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterTypeDecoder register TypeDecoder for a typ
|
||||||
|
func RegisterTypeDecoder(typ string, decoder ValDecoder) {
|
||||||
|
typeDecoders[typ] = decoder
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterFieldDecoderFunc register TypeDecoder for a struct field with function
|
||||||
|
func RegisterFieldDecoderFunc(typ string, field string, fun DecoderFunc) {
|
||||||
|
RegisterFieldDecoder(typ, field, &funcDecoder{fun})
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterFieldDecoder register TypeDecoder for a struct field
|
||||||
|
func RegisterFieldDecoder(typ string, field string, decoder ValDecoder) {
|
||||||
|
fieldDecoders[fmt.Sprintf("%s/%s", typ, field)] = decoder
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterTypeEncoderFunc register TypeEncoder for a type with encode/isEmpty function
|
||||||
|
func RegisterTypeEncoderFunc(typ string, fun EncoderFunc, isEmptyFunc func(unsafe.Pointer) bool) {
|
||||||
|
typeEncoders[typ] = &funcEncoder{fun, isEmptyFunc}
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterTypeEncoder register TypeEncoder for a type
|
||||||
|
func RegisterTypeEncoder(typ string, encoder ValEncoder) {
|
||||||
|
typeEncoders[typ] = encoder
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterFieldEncoderFunc register TypeEncoder for a struct field with encode/isEmpty function
|
||||||
|
func RegisterFieldEncoderFunc(typ string, field string, fun EncoderFunc, isEmptyFunc func(unsafe.Pointer) bool) {
|
||||||
|
RegisterFieldEncoder(typ, field, &funcEncoder{fun, isEmptyFunc})
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterFieldEncoder register TypeEncoder for a struct field
|
||||||
|
func RegisterFieldEncoder(typ string, field string, encoder ValEncoder) {
|
||||||
|
fieldEncoders[fmt.Sprintf("%s/%s", typ, field)] = encoder
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterExtension register extension
|
||||||
|
func RegisterExtension(extension Extension) {
|
||||||
|
extensions = append(extensions, extension)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getTypeDecoderFromExtension(ctx *ctx, typ reflect2.Type) ValDecoder {
|
||||||
|
decoder := _getTypeDecoderFromExtension(ctx, typ)
|
||||||
|
if decoder != nil {
|
||||||
|
for _, extension := range extensions {
|
||||||
|
decoder = extension.DecorateDecoder(typ, decoder)
|
||||||
|
}
|
||||||
|
decoder = ctx.decoderExtension.DecorateDecoder(typ, decoder)
|
||||||
|
for _, extension := range ctx.extraExtensions {
|
||||||
|
decoder = extension.DecorateDecoder(typ, decoder)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
func _getTypeDecoderFromExtension(ctx *ctx, typ reflect2.Type) ValDecoder {
|
||||||
|
for _, extension := range extensions {
|
||||||
|
decoder := extension.CreateDecoder(typ)
|
||||||
|
if decoder != nil {
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
}
|
||||||
|
decoder := ctx.decoderExtension.CreateDecoder(typ)
|
||||||
|
if decoder != nil {
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
for _, extension := range ctx.extraExtensions {
|
||||||
|
decoder := extension.CreateDecoder(typ)
|
||||||
|
if decoder != nil {
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
}
|
||||||
|
typeName := typ.String()
|
||||||
|
decoder = typeDecoders[typeName]
|
||||||
|
if decoder != nil {
|
||||||
|
return decoder
|
||||||
|
}
|
||||||
|
if typ.Kind() == reflect.Ptr {
|
||||||
|
ptrType := typ.(*reflect2.UnsafePtrType)
|
||||||
|
decoder := typeDecoders[ptrType.Elem().String()]
|
||||||
|
if decoder != nil {
|
||||||
|
return &OptionalDecoder{ptrType.Elem(), decoder}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func getTypeEncoderFromExtension(ctx *ctx, typ reflect2.Type) ValEncoder {
|
||||||
|
encoder := _getTypeEncoderFromExtension(ctx, typ)
|
||||||
|
if encoder != nil {
|
||||||
|
for _, extension := range extensions {
|
||||||
|
encoder = extension.DecorateEncoder(typ, encoder)
|
||||||
|
}
|
||||||
|
encoder = ctx.encoderExtension.DecorateEncoder(typ, encoder)
|
||||||
|
for _, extension := range ctx.extraExtensions {
|
||||||
|
encoder = extension.DecorateEncoder(typ, encoder)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
|
||||||
|
func _getTypeEncoderFromExtension(ctx *ctx, typ reflect2.Type) ValEncoder {
|
||||||
|
for _, extension := range extensions {
|
||||||
|
encoder := extension.CreateEncoder(typ)
|
||||||
|
if encoder != nil {
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
}
|
||||||
|
encoder := ctx.encoderExtension.CreateEncoder(typ)
|
||||||
|
if encoder != nil {
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
for _, extension := range ctx.extraExtensions {
|
||||||
|
encoder := extension.CreateEncoder(typ)
|
||||||
|
if encoder != nil {
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
}
|
||||||
|
typeName := typ.String()
|
||||||
|
encoder = typeEncoders[typeName]
|
||||||
|
if encoder != nil {
|
||||||
|
return encoder
|
||||||
|
}
|
||||||
|
if typ.Kind() == reflect.Ptr {
|
||||||
|
typePtr := typ.(*reflect2.UnsafePtrType)
|
||||||
|
encoder := typeEncoders[typePtr.Elem().String()]
|
||||||
|
if encoder != nil {
|
||||||
|
return &OptionalEncoder{encoder}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func describeStruct(ctx *ctx, typ reflect2.Type) *StructDescriptor {
|
||||||
|
structType := typ.(*reflect2.UnsafeStructType)
|
||||||
|
embeddedBindings := []*Binding{}
|
||||||
|
bindings := []*Binding{}
|
||||||
|
for i := 0; i < structType.NumField(); i++ {
|
||||||
|
field := structType.Field(i)
|
||||||
|
tag, hastag := field.Tag().Lookup(ctx.getTagKey())
|
||||||
|
if ctx.onlyTaggedField && !hastag && !field.Anonymous() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if tag == "-" || field.Name() == "_" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
tagParts := strings.Split(tag, ",")
|
||||||
|
if field.Anonymous() && (tag == "" || tagParts[0] == "") {
|
||||||
|
if field.Type().Kind() == reflect.Struct {
|
||||||
|
structDescriptor := describeStruct(ctx, field.Type())
|
||||||
|
for _, binding := range structDescriptor.Fields {
|
||||||
|
binding.levels = append([]int{i}, binding.levels...)
|
||||||
|
omitempty := binding.Encoder.(*structFieldEncoder).omitempty
|
||||||
|
binding.Encoder = &structFieldEncoder{field, binding.Encoder, omitempty}
|
||||||
|
binding.Decoder = &structFieldDecoder{field, binding.Decoder}
|
||||||
|
embeddedBindings = append(embeddedBindings, binding)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
} else if field.Type().Kind() == reflect.Ptr {
|
||||||
|
ptrType := field.Type().(*reflect2.UnsafePtrType)
|
||||||
|
if ptrType.Elem().Kind() == reflect.Struct {
|
||||||
|
structDescriptor := describeStruct(ctx, ptrType.Elem())
|
||||||
|
for _, binding := range structDescriptor.Fields {
|
||||||
|
binding.levels = append([]int{i}, binding.levels...)
|
||||||
|
omitempty := binding.Encoder.(*structFieldEncoder).omitempty
|
||||||
|
binding.Encoder = &dereferenceEncoder{binding.Encoder}
|
||||||
|
binding.Encoder = &structFieldEncoder{field, binding.Encoder, omitempty}
|
||||||
|
binding.Decoder = &dereferenceDecoder{ptrType.Elem(), binding.Decoder}
|
||||||
|
binding.Decoder = &structFieldDecoder{field, binding.Decoder}
|
||||||
|
embeddedBindings = append(embeddedBindings, binding)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldNames := calcFieldNames(field.Name(), tagParts[0], tag)
|
||||||
|
fieldCacheKey := fmt.Sprintf("%s/%s", typ.String(), field.Name())
|
||||||
|
decoder := fieldDecoders[fieldCacheKey]
|
||||||
|
if decoder == nil {
|
||||||
|
decoder = decoderOfType(ctx.append(field.Name()), field.Type())
|
||||||
|
}
|
||||||
|
encoder := fieldEncoders[fieldCacheKey]
|
||||||
|
if encoder == nil {
|
||||||
|
encoder = encoderOfType(ctx.append(field.Name()), field.Type())
|
||||||
|
}
|
||||||
|
binding := &Binding{
|
||||||
|
Field: field,
|
||||||
|
FromNames: fieldNames,
|
||||||
|
ToNames: fieldNames,
|
||||||
|
Decoder: decoder,
|
||||||
|
Encoder: encoder,
|
||||||
|
}
|
||||||
|
binding.levels = []int{i}
|
||||||
|
bindings = append(bindings, binding)
|
||||||
|
}
|
||||||
|
return createStructDescriptor(ctx, typ, bindings, embeddedBindings)
|
||||||
|
}
|
||||||
|
func createStructDescriptor(ctx *ctx, typ reflect2.Type, bindings []*Binding, embeddedBindings []*Binding) *StructDescriptor {
|
||||||
|
structDescriptor := &StructDescriptor{
|
||||||
|
Type: typ,
|
||||||
|
Fields: bindings,
|
||||||
|
}
|
||||||
|
for _, extension := range extensions {
|
||||||
|
extension.UpdateStructDescriptor(structDescriptor)
|
||||||
|
}
|
||||||
|
ctx.encoderExtension.UpdateStructDescriptor(structDescriptor)
|
||||||
|
ctx.decoderExtension.UpdateStructDescriptor(structDescriptor)
|
||||||
|
for _, extension := range ctx.extraExtensions {
|
||||||
|
extension.UpdateStructDescriptor(structDescriptor)
|
||||||
|
}
|
||||||
|
processTags(structDescriptor, ctx.frozenConfig)
|
||||||
|
// merge normal & embedded bindings & sort with original order
|
||||||
|
allBindings := sortableBindings(append(embeddedBindings, structDescriptor.Fields...))
|
||||||
|
sort.Sort(allBindings)
|
||||||
|
structDescriptor.Fields = allBindings
|
||||||
|
return structDescriptor
|
||||||
|
}
|
||||||
|
|
||||||
|
type sortableBindings []*Binding
|
||||||
|
|
||||||
|
func (bindings sortableBindings) Len() int {
|
||||||
|
return len(bindings)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (bindings sortableBindings) Less(i, j int) bool {
|
||||||
|
left := bindings[i].levels
|
||||||
|
right := bindings[j].levels
|
||||||
|
k := 0
|
||||||
|
for {
|
||||||
|
if left[k] < right[k] {
|
||||||
|
return true
|
||||||
|
} else if left[k] > right[k] {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
k++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (bindings sortableBindings) Swap(i, j int) {
|
||||||
|
bindings[i], bindings[j] = bindings[j], bindings[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
func processTags(structDescriptor *StructDescriptor, cfg *frozenConfig) {
|
||||||
|
for _, binding := range structDescriptor.Fields {
|
||||||
|
shouldOmitEmpty := false
|
||||||
|
tagParts := strings.Split(binding.Field.Tag().Get(cfg.getTagKey()), ",")
|
||||||
|
for _, tagPart := range tagParts[1:] {
|
||||||
|
if tagPart == "omitempty" {
|
||||||
|
shouldOmitEmpty = true
|
||||||
|
} else if tagPart == "string" {
|
||||||
|
if binding.Field.Type().Kind() == reflect.String {
|
||||||
|
binding.Decoder = &stringModeStringDecoder{binding.Decoder, cfg}
|
||||||
|
binding.Encoder = &stringModeStringEncoder{binding.Encoder, cfg}
|
||||||
|
} else {
|
||||||
|
binding.Decoder = &stringModeNumberDecoder{binding.Decoder}
|
||||||
|
binding.Encoder = &stringModeNumberEncoder{binding.Encoder}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
binding.Decoder = &structFieldDecoder{binding.Field, binding.Decoder}
|
||||||
|
binding.Encoder = &structFieldEncoder{binding.Field, binding.Encoder, shouldOmitEmpty}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func calcFieldNames(originalFieldName string, tagProvidedFieldName string, wholeTag string) []string {
|
||||||
|
// ignore?
|
||||||
|
if wholeTag == "-" {
|
||||||
|
return []string{}
|
||||||
|
}
|
||||||
|
// rename?
|
||||||
|
var fieldNames []string
|
||||||
|
if tagProvidedFieldName == "" {
|
||||||
|
fieldNames = []string{originalFieldName}
|
||||||
|
} else {
|
||||||
|
fieldNames = []string{tagProvidedFieldName}
|
||||||
|
}
|
||||||
|
// private?
|
||||||
|
isNotExported := unicode.IsLower(rune(originalFieldName[0])) || originalFieldName[0] == '_'
|
||||||
|
if isNotExported {
|
||||||
|
fieldNames = []string{}
|
||||||
|
}
|
||||||
|
return fieldNames
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue