Compare commits
1 commit
a6c81531e4
...
7790586456
Author | SHA1 | Date | |
---|---|---|---|
7790586456 |
70 changed files with 2937 additions and 13907 deletions
10
go.mod
10
go.mod
|
@ -3,17 +3,17 @@ module idun
|
|||
go 1.21
|
||||
|
||||
require (
|
||||
github.com/aws/aws-sdk-go v1.55.5
|
||||
github.com/aws/aws-sdk-go v1.45.25
|
||||
github.com/pkg/sftp v1.13.6
|
||||
github.com/rs/zerolog v1.33.0
|
||||
github.com/rs/zerolog v1.31.0
|
||||
github.com/stretchr/testify v1.8.4
|
||||
github.com/urfave/cli/v2 v2.27.4
|
||||
github.com/urfave/cli/v2 v2.25.7
|
||||
golang.org/x/crypto v0.27.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/kr/fs v0.1.0 // indirect
|
||||
|
@ -21,6 +21,6 @@ require (
|
|||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||
golang.org/x/sys v0.25.0 // indirect
|
||||
)
|
||||
|
|
10
go.sum
10
go.sum
|
@ -1,12 +1,8 @@
|
|||
github.com/aws/aws-sdk-go v1.45.25 h1:c4fLlh5sLdK2DCRTY1z0hyuJZU4ygxX8m1FswL6/nF4=
|
||||
github.com/aws/aws-sdk-go v1.45.25/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
|
||||
github.com/aws/aws-sdk-go v1.55.5 h1:KKUZBfBoyqy5d3swXyiC7Q76ic40rYcbqH7qjh59kzU=
|
||||
github.com/aws/aws-sdk-go v1.55.5/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
|
||||
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
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=
|
||||
|
@ -30,8 +26,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
|||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
|
||||
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
|
||||
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
|
@ -42,12 +36,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
|
|||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
|
||||
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
|
||||
github.com/urfave/cli/v2 v2.27.4 h1:o1owoI+02Eb+K107p27wEX9Bb8eqIoZCfLXloLUSWJ8=
|
||||
github.com/urfave/cli/v2 v2.27.4/go.mod h1:m4QzxcD2qpra4z7WhzEGn74WZLViBnMpb1ToCAKdGRQ=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
||||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
|
||||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
|
|
11
vendor/github.com/aws/aws-sdk-go/aws/config.go
generated
vendored
11
vendor/github.com/aws/aws-sdk-go/aws/config.go
generated
vendored
|
@ -442,17 +442,6 @@ func (c *Config) WithUseDualStack(enable bool) *Config {
|
|||
return c
|
||||
}
|
||||
|
||||
// WithUseFIPSEndpoint sets a config UseFIPSEndpoint value returning a Config
|
||||
// pointer for chaining.
|
||||
func (c *Config) WithUseFIPSEndpoint(enable bool) *Config {
|
||||
if enable {
|
||||
c.UseFIPSEndpoint = endpoints.FIPSEndpointStateEnabled
|
||||
} else {
|
||||
c.UseFIPSEndpoint = endpoints.FIPSEndpointStateDisabled
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
// WithEC2MetadataDisableTimeoutOverride sets a config EC2MetadataDisableTimeoutOverride value
|
||||
// returning a Config pointer for chaining.
|
||||
func (c *Config) WithEC2MetadataDisableTimeoutOverride(enable bool) *Config {
|
||||
|
|
47
vendor/github.com/aws/aws-sdk-go/aws/credentials/endpointcreds/provider.go
generated
vendored
47
vendor/github.com/aws/aws-sdk-go/aws/credentials/endpointcreds/provider.go
generated
vendored
|
@ -31,8 +31,6 @@ package endpointcreds
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
|
@ -71,37 +69,7 @@ type Provider struct {
|
|||
|
||||
// Optional authorization token value if set will be used as the value of
|
||||
// the Authorization header of the endpoint credential request.
|
||||
//
|
||||
// When constructed from environment, the provider will use the value of
|
||||
// AWS_CONTAINER_AUTHORIZATION_TOKEN environment variable as the token
|
||||
//
|
||||
// Will be overridden if AuthorizationTokenProvider is configured
|
||||
AuthorizationToken string
|
||||
|
||||
// Optional auth provider func to dynamically load the auth token from a file
|
||||
// everytime a credential is retrieved
|
||||
//
|
||||
// When constructed from environment, the provider will read and use the content
|
||||
// of the file pointed to by AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE environment variable
|
||||
// as the auth token everytime credentials are retrieved
|
||||
//
|
||||
// Will override AuthorizationToken if configured
|
||||
AuthorizationTokenProvider AuthTokenProvider
|
||||
}
|
||||
|
||||
// AuthTokenProvider defines an interface to dynamically load a value to be passed
|
||||
// for the Authorization header of a credentials request.
|
||||
type AuthTokenProvider interface {
|
||||
GetToken() (string, error)
|
||||
}
|
||||
|
||||
// TokenProviderFunc is a func type implementing AuthTokenProvider interface
|
||||
// and enables customizing token provider behavior
|
||||
type TokenProviderFunc func() (string, error)
|
||||
|
||||
// GetToken func retrieves auth token according to TokenProviderFunc implementation
|
||||
func (p TokenProviderFunc) GetToken() (string, error) {
|
||||
return p()
|
||||
}
|
||||
|
||||
// NewProviderClient returns a credentials Provider for retrieving AWS credentials
|
||||
|
@ -196,20 +164,7 @@ func (p *Provider) getCredentials(ctx aws.Context) (*getCredentialsOutput, error
|
|||
req := p.Client.NewRequest(op, nil, out)
|
||||
req.SetContext(ctx)
|
||||
req.HTTPRequest.Header.Set("Accept", "application/json")
|
||||
|
||||
authToken := p.AuthorizationToken
|
||||
var err error
|
||||
if p.AuthorizationTokenProvider != nil {
|
||||
authToken, err = p.AuthorizationTokenProvider.GetToken()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("get authorization token: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if strings.ContainsAny(authToken, "\r\n") {
|
||||
return nil, fmt.Errorf("authorization token contains invalid newline sequence")
|
||||
}
|
||||
if len(authToken) != 0 {
|
||||
if authToken := p.AuthorizationToken; len(authToken) != 0 {
|
||||
req.HTTPRequest.Header.Set("Authorization", authToken)
|
||||
}
|
||||
|
||||
|
|
64
vendor/github.com/aws/aws-sdk-go/aws/defaults/defaults.go
generated
vendored
64
vendor/github.com/aws/aws-sdk-go/aws/defaults/defaults.go
generated
vendored
|
@ -9,7 +9,6 @@ package defaults
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
@ -116,31 +115,9 @@ func CredProviders(cfg *aws.Config, handlers request.Handlers) []credentials.Pro
|
|||
|
||||
const (
|
||||
httpProviderAuthorizationEnvVar = "AWS_CONTAINER_AUTHORIZATION_TOKEN"
|
||||
httpProviderAuthFileEnvVar = "AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE"
|
||||
httpProviderEnvVar = "AWS_CONTAINER_CREDENTIALS_FULL_URI"
|
||||
)
|
||||
|
||||
// direct representation of the IPv4 address for the ECS container
|
||||
// "169.254.170.2"
|
||||
var ecsContainerIPv4 net.IP = []byte{
|
||||
169, 254, 170, 2,
|
||||
}
|
||||
|
||||
// direct representation of the IPv4 address for the EKS container
|
||||
// "169.254.170.23"
|
||||
var eksContainerIPv4 net.IP = []byte{
|
||||
169, 254, 170, 23,
|
||||
}
|
||||
|
||||
// direct representation of the IPv6 address for the EKS container
|
||||
// "fd00:ec2::23"
|
||||
var eksContainerIPv6 net.IP = []byte{
|
||||
0xFD, 0, 0xE, 0xC2,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0x23,
|
||||
}
|
||||
|
||||
// RemoteCredProvider returns a credentials provider for the default remote
|
||||
// endpoints such as EC2 or ECS Roles.
|
||||
func RemoteCredProvider(cfg aws.Config, handlers request.Handlers) credentials.Provider {
|
||||
|
@ -158,22 +135,19 @@ func RemoteCredProvider(cfg aws.Config, handlers request.Handlers) credentials.P
|
|||
|
||||
var lookupHostFn = net.LookupHost
|
||||
|
||||
// isAllowedHost allows host to be loopback or known ECS/EKS container IPs
|
||||
//
|
||||
// host can either be an IP address OR an unresolved hostname - resolution will
|
||||
// be automatically performed in the latter case
|
||||
func isAllowedHost(host string) (bool, error) {
|
||||
if ip := net.ParseIP(host); ip != nil {
|
||||
return isIPAllowed(ip), nil
|
||||
func isLoopbackHost(host string) (bool, error) {
|
||||
ip := net.ParseIP(host)
|
||||
if ip != nil {
|
||||
return ip.IsLoopback(), nil
|
||||
}
|
||||
|
||||
// Host is not an ip, perform lookup
|
||||
addrs, err := lookupHostFn(host)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
for _, addr := range addrs {
|
||||
if ip := net.ParseIP(addr); ip == nil || !isIPAllowed(ip) {
|
||||
if !net.ParseIP(addr).IsLoopback() {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
|
@ -181,13 +155,6 @@ func isAllowedHost(host string) (bool, error) {
|
|||
return true, nil
|
||||
}
|
||||
|
||||
func isIPAllowed(ip net.IP) bool {
|
||||
return ip.IsLoopback() ||
|
||||
ip.Equal(ecsContainerIPv4) ||
|
||||
ip.Equal(eksContainerIPv4) ||
|
||||
ip.Equal(eksContainerIPv6)
|
||||
}
|
||||
|
||||
func localHTTPCredProvider(cfg aws.Config, handlers request.Handlers, u string) credentials.Provider {
|
||||
var errMsg string
|
||||
|
||||
|
@ -198,12 +165,10 @@ func localHTTPCredProvider(cfg aws.Config, handlers request.Handlers, u string)
|
|||
host := aws.URLHostname(parsed)
|
||||
if len(host) == 0 {
|
||||
errMsg = "unable to parse host from local HTTP cred provider URL"
|
||||
} else if parsed.Scheme == "http" {
|
||||
if isAllowedHost, allowHostErr := isAllowedHost(host); allowHostErr != nil {
|
||||
errMsg = fmt.Sprintf("failed to resolve host %q, %v", host, allowHostErr)
|
||||
} else if !isAllowedHost {
|
||||
errMsg = fmt.Sprintf("invalid endpoint host, %q, only loopback/ecs/eks hosts are allowed.", host)
|
||||
}
|
||||
} else if isLoopback, loopbackErr := isLoopbackHost(host); loopbackErr != nil {
|
||||
errMsg = fmt.Sprintf("failed to resolve host %q, %v", host, loopbackErr)
|
||||
} else if !isLoopback {
|
||||
errMsg = fmt.Sprintf("invalid endpoint host, %q, only loopback hosts are allowed.", host)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,15 +190,6 @@ func httpCredProvider(cfg aws.Config, handlers request.Handlers, u string) crede
|
|||
func(p *endpointcreds.Provider) {
|
||||
p.ExpiryWindow = 5 * time.Minute
|
||||
p.AuthorizationToken = os.Getenv(httpProviderAuthorizationEnvVar)
|
||||
if authFilePath := os.Getenv(httpProviderAuthFileEnvVar); authFilePath != "" {
|
||||
p.AuthorizationTokenProvider = endpointcreds.TokenProviderFunc(func() (string, error) {
|
||||
if contents, err := ioutil.ReadFile(authFilePath); err != nil {
|
||||
return "", fmt.Errorf("failed to read authorization token from %v: %v", authFilePath, err)
|
||||
} else {
|
||||
return string(contents), nil
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
5
vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/token_provider.go
generated
vendored
5
vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/token_provider.go
generated
vendored
|
@ -2,7 +2,6 @@ package ec2metadata
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"net/http"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
@ -66,9 +65,7 @@ func (t *tokenProvider) fetchTokenHandler(r *request.Request) {
|
|||
switch requestFailureError.StatusCode() {
|
||||
case http.StatusForbidden, http.StatusNotFound, http.StatusMethodNotAllowed:
|
||||
atomic.StoreUint32(&t.disabled, 1)
|
||||
if t.client.Config.LogLevel.Matches(aws.LogDebugWithDeprecated) {
|
||||
t.client.Config.Logger.Log(fmt.Sprintf("WARN: failed to get session token, falling back to IMDSv1: %v", requestFailureError))
|
||||
}
|
||||
t.client.Config.Logger.Log(fmt.Sprintf("WARN: failed to get session token, falling back to IMDSv1: %v", requestFailureError))
|
||||
case http.StatusBadRequest:
|
||||
r.Error = requestFailureError
|
||||
}
|
||||
|
|
6925
vendor/github.com/aws/aws-sdk-go/aws/endpoints/defaults.go
generated
vendored
6925
vendor/github.com/aws/aws-sdk-go/aws/endpoints/defaults.go
generated
vendored
File diff suppressed because it is too large
Load diff
13
vendor/github.com/aws/aws-sdk-go/aws/request/waiter.go
generated
vendored
13
vendor/github.com/aws/aws-sdk-go/aws/request/waiter.go
generated
vendored
|
@ -256,17 +256,8 @@ func (a *WaiterAcceptor) match(name string, l aws.Logger, req *Request, err erro
|
|||
s := a.Expected.(int)
|
||||
result = s == req.HTTPResponse.StatusCode
|
||||
case ErrorWaiterMatch:
|
||||
switch ex := a.Expected.(type) {
|
||||
case string:
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
result = aerr.Code() == ex
|
||||
}
|
||||
case bool:
|
||||
if ex {
|
||||
result = err != nil
|
||||
} else {
|
||||
result = err == nil
|
||||
}
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
result = aerr.Code() == a.Expected.(string)
|
||||
}
|
||||
default:
|
||||
waiterLogf(l, "WARNING: Waiter %s encountered unexpected matcher: %s",
|
||||
|
|
28
vendor/github.com/aws/aws-sdk-go/aws/session/env_config.go
generated
vendored
28
vendor/github.com/aws/aws-sdk-go/aws/session/env_config.go
generated
vendored
|
@ -171,12 +171,6 @@ type envConfig struct {
|
|||
// AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE=IPv6
|
||||
EC2IMDSEndpointMode endpoints.EC2IMDSEndpointModeState
|
||||
|
||||
// Specifies that IMDS clients should not fallback to IMDSv1 if token
|
||||
// requests fail.
|
||||
//
|
||||
// AWS_EC2_METADATA_V1_DISABLED=true
|
||||
EC2IMDSv1Disabled *bool
|
||||
|
||||
// Specifies that SDK clients must resolve a dual-stack endpoint for
|
||||
// services.
|
||||
//
|
||||
|
@ -257,9 +251,6 @@ var (
|
|||
ec2IMDSEndpointModeEnvKey = []string{
|
||||
"AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE",
|
||||
}
|
||||
ec2MetadataV1DisabledEnvKey = []string{
|
||||
"AWS_EC2_METADATA_V1_DISABLED",
|
||||
}
|
||||
useCABundleKey = []string{
|
||||
"AWS_CA_BUNDLE",
|
||||
}
|
||||
|
@ -402,7 +393,6 @@ func envConfigLoad(enableSharedConfig bool) (envConfig, error) {
|
|||
if err := setEC2IMDSEndpointMode(&cfg.EC2IMDSEndpointMode, ec2IMDSEndpointModeEnvKey); err != nil {
|
||||
return envConfig{}, err
|
||||
}
|
||||
setBoolPtrFromEnvVal(&cfg.EC2IMDSv1Disabled, ec2MetadataV1DisabledEnvKey)
|
||||
|
||||
if err := setUseDualStackEndpointFromEnvVal(&cfg.UseDualStackEndpoint, awsUseDualStackEndpoint); err != nil {
|
||||
return cfg, err
|
||||
|
@ -424,24 +414,6 @@ func setFromEnvVal(dst *string, keys []string) {
|
|||
}
|
||||
}
|
||||
|
||||
func setBoolPtrFromEnvVal(dst **bool, keys []string) {
|
||||
for _, k := range keys {
|
||||
value := os.Getenv(k)
|
||||
if len(value) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
switch {
|
||||
case strings.EqualFold(value, "false"):
|
||||
*dst = new(bool)
|
||||
**dst = false
|
||||
case strings.EqualFold(value, "true"):
|
||||
*dst = new(bool)
|
||||
**dst = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func setEC2IMDSEndpointMode(mode *endpoints.EC2IMDSEndpointModeState, keys []string) error {
|
||||
for _, k := range keys {
|
||||
value := os.Getenv(k)
|
||||
|
|
8
vendor/github.com/aws/aws-sdk-go/aws/session/session.go
generated
vendored
8
vendor/github.com/aws/aws-sdk-go/aws/session/session.go
generated
vendored
|
@ -779,14 +779,6 @@ func mergeConfigSrcs(cfg, userCfg *aws.Config,
|
|||
cfg.EndpointResolver = wrapEC2IMDSEndpoint(cfg.EndpointResolver, ec2IMDSEndpoint, endpointMode)
|
||||
}
|
||||
|
||||
cfg.EC2MetadataEnableFallback = userCfg.EC2MetadataEnableFallback
|
||||
if cfg.EC2MetadataEnableFallback == nil && envCfg.EC2IMDSv1Disabled != nil {
|
||||
cfg.EC2MetadataEnableFallback = aws.Bool(!*envCfg.EC2IMDSv1Disabled)
|
||||
}
|
||||
if cfg.EC2MetadataEnableFallback == nil && sharedCfg.EC2IMDSv1Disabled != nil {
|
||||
cfg.EC2MetadataEnableFallback = aws.Bool(!*sharedCfg.EC2IMDSv1Disabled)
|
||||
}
|
||||
|
||||
cfg.S3UseARNRegion = userCfg.S3UseARNRegion
|
||||
if cfg.S3UseARNRegion == nil {
|
||||
cfg.S3UseARNRegion = &envCfg.S3UseARNRegion
|
||||
|
|
10
vendor/github.com/aws/aws-sdk-go/aws/session/shared_config.go
generated
vendored
10
vendor/github.com/aws/aws-sdk-go/aws/session/shared_config.go
generated
vendored
|
@ -80,9 +80,6 @@ const (
|
|||
// EC2 IMDS Endpoint
|
||||
ec2MetadataServiceEndpointKey = "ec2_metadata_service_endpoint"
|
||||
|
||||
// ECS IMDSv1 disable fallback
|
||||
ec2MetadataV1DisabledKey = "ec2_metadata_v1_disabled"
|
||||
|
||||
// Use DualStack Endpoint Resolution
|
||||
useDualStackEndpoint = "use_dualstack_endpoint"
|
||||
|
||||
|
@ -182,12 +179,6 @@ type sharedConfig struct {
|
|||
// ec2_metadata_service_endpoint=http://fd00:ec2::254
|
||||
EC2IMDSEndpoint string
|
||||
|
||||
// Specifies that IMDS clients should not fallback to IMDSv1 if token
|
||||
// requests fail.
|
||||
//
|
||||
// ec2_metadata_v1_disabled=true
|
||||
EC2IMDSv1Disabled *bool
|
||||
|
||||
// Specifies that SDK clients must resolve a dual-stack endpoint for
|
||||
// services.
|
||||
//
|
||||
|
@ -443,7 +434,6 @@ func (cfg *sharedConfig) setFromIniFile(profile string, file sharedConfigFile, e
|
|||
ec2MetadataServiceEndpointModeKey, file.Filename, err)
|
||||
}
|
||||
updateString(&cfg.EC2IMDSEndpoint, section, ec2MetadataServiceEndpointKey)
|
||||
updateBoolPtr(&cfg.EC2IMDSv1Disabled, section, ec2MetadataV1DisabledKey)
|
||||
|
||||
updateUseDualStackEndpoint(&cfg.UseDualStackEndpoint, section, useDualStackEndpoint)
|
||||
|
||||
|
|
1
vendor/github.com/aws/aws-sdk-go/aws/signer/v4/v4.go
generated
vendored
1
vendor/github.com/aws/aws-sdk-go/aws/signer/v4/v4.go
generated
vendored
|
@ -125,7 +125,6 @@ var requiredSignedHeaders = rules{
|
|||
"X-Amz-Copy-Source-Server-Side-Encryption-Customer-Algorithm": struct{}{},
|
||||
"X-Amz-Copy-Source-Server-Side-Encryption-Customer-Key": struct{}{},
|
||||
"X-Amz-Copy-Source-Server-Side-Encryption-Customer-Key-Md5": struct{}{},
|
||||
"X-Amz-Expected-Bucket-Owner": struct{}{},
|
||||
"X-Amz-Grant-Full-control": struct{}{},
|
||||
"X-Amz-Grant-Read": struct{}{},
|
||||
"X-Amz-Grant-Read-Acp": struct{}{},
|
||||
|
|
2
vendor/github.com/aws/aws-sdk-go/aws/version.go
generated
vendored
2
vendor/github.com/aws/aws-sdk-go/aws/version.go
generated
vendored
|
@ -5,4 +5,4 @@ package aws
|
|||
const SDKName = "aws-sdk-go"
|
||||
|
||||
// SDKVersion is the version of this SDK
|
||||
const SDKVersion = "1.55.5"
|
||||
const SDKVersion = "1.45.25"
|
||||
|
|
4
vendor/github.com/aws/aws-sdk-go/private/protocol/query/queryutil/queryutil.go
generated
vendored
4
vendor/github.com/aws/aws-sdk-go/private/protocol/query/queryutil/queryutil.go
generated
vendored
|
@ -122,8 +122,8 @@ func (q *queryParser) parseStruct(v url.Values, value reflect.Value, prefix stri
|
|||
}
|
||||
|
||||
func (q *queryParser) parseList(v url.Values, value reflect.Value, prefix string, tag reflect.StructTag) error {
|
||||
// If it's empty, and not ec2, generate an empty value
|
||||
if !value.IsNil() && value.Len() == 0 && !q.isEC2 {
|
||||
// If it's empty, generate an empty value
|
||||
if !value.IsNil() && value.Len() == 0 {
|
||||
v.Set(prefix, "")
|
||||
return nil
|
||||
}
|
||||
|
|
7626
vendor/github.com/aws/aws-sdk-go/service/s3/api.go
generated
vendored
7626
vendor/github.com/aws/aws-sdk-go/service/s3/api.go
generated
vendored
File diff suppressed because it is too large
Load diff
9
vendor/github.com/aws/aws-sdk-go/service/s3/errors.go
generated
vendored
9
vendor/github.com/aws/aws-sdk-go/service/s3/errors.go
generated
vendored
|
@ -25,15 +25,6 @@ const (
|
|||
// "InvalidObjectState".
|
||||
//
|
||||
// Object is archived and inaccessible until restored.
|
||||
//
|
||||
// If the object you are retrieving is stored in the S3 Glacier Flexible Retrieval
|
||||
// storage class, the S3 Glacier Deep Archive storage class, the S3 Intelligent-Tiering
|
||||
// Archive Access tier, or the S3 Intelligent-Tiering Deep Archive Access tier,
|
||||
// before you can retrieve the object you must first restore a copy using RestoreObject
|
||||
// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_RestoreObject.html).
|
||||
// Otherwise, this operation returns an InvalidObjectState error. For information
|
||||
// about restoring archived objects, see Restoring Archived Objects (https://docs.aws.amazon.com/AmazonS3/latest/dev/restoring-objects.html)
|
||||
// in the Amazon S3 User Guide.
|
||||
ErrCodeInvalidObjectState = "InvalidObjectState"
|
||||
|
||||
// ErrCodeNoSuchBucket for service response error code
|
||||
|
|
818
vendor/github.com/aws/aws-sdk-go/service/ssooidc/api.go
generated
vendored
818
vendor/github.com/aws/aws-sdk-go/service/ssooidc/api.go
generated
vendored
File diff suppressed because it is too large
Load diff
39
vendor/github.com/aws/aws-sdk-go/service/ssooidc/doc.go
generated
vendored
39
vendor/github.com/aws/aws-sdk-go/service/ssooidc/doc.go
generated
vendored
|
@ -3,13 +3,15 @@
|
|||
// Package ssooidc provides the client and types for making API
|
||||
// requests to AWS SSO OIDC.
|
||||
//
|
||||
// IAM Identity Center OpenID Connect (OIDC) is a web service that enables a
|
||||
// client (such as CLI or a native application) to register with IAM Identity
|
||||
// Center. The service also enables the client to fetch the user’s access
|
||||
// token upon successful authentication and authorization with IAM Identity
|
||||
// Center.
|
||||
// AWS IAM Identity Center (successor to AWS Single Sign-On) OpenID Connect
|
||||
// (OIDC) is a web service that enables a client (such as AWS CLI or a native
|
||||
// application) to register with IAM Identity Center. The service also enables
|
||||
// the client to fetch the user’s access token upon successful authentication
|
||||
// and authorization with IAM Identity Center.
|
||||
//
|
||||
// IAM Identity Center uses the sso and identitystore API namespaces.
|
||||
// Although AWS Single Sign-On was renamed, the sso and identitystore API namespaces
|
||||
// will continue to retain their original name for backward compatibility purposes.
|
||||
// For more information, see IAM Identity Center rename (https://docs.aws.amazon.com/singlesignon/latest/userguide/what-is.html#renamed).
|
||||
//
|
||||
// # Considerations for Using This Guide
|
||||
//
|
||||
|
@ -20,24 +22,21 @@
|
|||
// - The IAM Identity Center OIDC service currently implements only the portions
|
||||
// of the OAuth 2.0 Device Authorization Grant standard (https://tools.ietf.org/html/rfc8628
|
||||
// (https://tools.ietf.org/html/rfc8628)) that are necessary to enable single
|
||||
// sign-on authentication with the CLI.
|
||||
// sign-on authentication with the AWS CLI. Support for other OIDC flows
|
||||
// frequently needed for native applications, such as Authorization Code
|
||||
// Flow (+ PKCE), will be addressed in future releases.
|
||||
//
|
||||
// - With older versions of the CLI, the service only emits OIDC access tokens,
|
||||
// so to obtain a new token, users must explicitly re-authenticate. To access
|
||||
// the OIDC flow that supports token refresh and doesn’t require re-authentication,
|
||||
// update to the latest CLI version (1.27.10 for CLI V1 and 2.9.0 for CLI
|
||||
// V2) with support for OIDC token refresh and configurable IAM Identity
|
||||
// Center session durations. For more information, see Configure Amazon Web
|
||||
// Services access portal session duration (https://docs.aws.amazon.com/singlesignon/latest/userguide/configure-user-session.html).
|
||||
// - The service emits only OIDC access tokens, such that obtaining a new
|
||||
// token (For example, token refresh) requires explicit user re-authentication.
|
||||
//
|
||||
// - The access tokens provided by this service grant access to all Amazon
|
||||
// Web Services account entitlements assigned to an IAM Identity Center user,
|
||||
// not just a particular application.
|
||||
// - The access tokens provided by this service grant access to all AWS account
|
||||
// entitlements assigned to an IAM Identity Center user, not just a particular
|
||||
// application.
|
||||
//
|
||||
// - The documentation in this guide does not describe the mechanism to convert
|
||||
// the access token into Amazon Web Services Auth (“sigv4”) credentials
|
||||
// for use with IAM-protected Amazon Web Services service endpoints. For
|
||||
// more information, see GetRoleCredentials (https://docs.aws.amazon.com/singlesignon/latest/PortalAPIReference/API_GetRoleCredentials.html)
|
||||
// the access token into AWS Auth (“sigv4”) credentials for use with
|
||||
// IAM-protected AWS service endpoints. For more information, see GetRoleCredentials
|
||||
// (https://docs.aws.amazon.com/singlesignon/latest/PortalAPIReference/API_GetRoleCredentials.html)
|
||||
// in the IAM Identity Center Portal API Reference Guide.
|
||||
//
|
||||
// For general information about IAM Identity Center, see What is IAM Identity
|
||||
|
|
16
vendor/github.com/aws/aws-sdk-go/service/ssooidc/errors.go
generated
vendored
16
vendor/github.com/aws/aws-sdk-go/service/ssooidc/errors.go
generated
vendored
|
@ -57,13 +57,6 @@ const (
|
|||
// makes a CreateToken request with an invalid grant type.
|
||||
ErrCodeInvalidGrantException = "InvalidGrantException"
|
||||
|
||||
// ErrCodeInvalidRedirectUriException for service response error code
|
||||
// "InvalidRedirectUriException".
|
||||
//
|
||||
// Indicates that one or more redirect URI in the request is not supported for
|
||||
// this operation.
|
||||
ErrCodeInvalidRedirectUriException = "InvalidRedirectUriException"
|
||||
|
||||
// ErrCodeInvalidRequestException for service response error code
|
||||
// "InvalidRequestException".
|
||||
//
|
||||
|
@ -71,13 +64,6 @@ const (
|
|||
// a required parameter might be missing or out of range.
|
||||
ErrCodeInvalidRequestException = "InvalidRequestException"
|
||||
|
||||
// ErrCodeInvalidRequestRegionException for service response error code
|
||||
// "InvalidRequestRegionException".
|
||||
//
|
||||
// Indicates that a token provided as input to the request was issued by and
|
||||
// is only usable by calling IAM Identity Center endpoints in another region.
|
||||
ErrCodeInvalidRequestRegionException = "InvalidRequestRegionException"
|
||||
|
||||
// ErrCodeInvalidScopeException for service response error code
|
||||
// "InvalidScopeException".
|
||||
//
|
||||
|
@ -113,9 +99,7 @@ var exceptionFromCode = map[string]func(protocol.ResponseMetadata) error{
|
|||
"InvalidClientException": newErrorInvalidClientException,
|
||||
"InvalidClientMetadataException": newErrorInvalidClientMetadataException,
|
||||
"InvalidGrantException": newErrorInvalidGrantException,
|
||||
"InvalidRedirectUriException": newErrorInvalidRedirectUriException,
|
||||
"InvalidRequestException": newErrorInvalidRequestException,
|
||||
"InvalidRequestRegionException": newErrorInvalidRequestRegionException,
|
||||
"InvalidScopeException": newErrorInvalidScopeException,
|
||||
"SlowDownException": newErrorSlowDownException,
|
||||
"UnauthorizedClientException": newErrorUnauthorizedClientException,
|
||||
|
|
2
vendor/github.com/aws/aws-sdk-go/service/ssooidc/service.go
generated
vendored
2
vendor/github.com/aws/aws-sdk-go/service/ssooidc/service.go
generated
vendored
|
@ -51,7 +51,7 @@ const (
|
|||
func New(p client.ConfigProvider, cfgs ...*aws.Config) *SSOOIDC {
|
||||
c := p.ClientConfig(EndpointsID, cfgs...)
|
||||
if c.SigningNameDerived || len(c.SigningName) == 0 {
|
||||
c.SigningName = "sso-oauth"
|
||||
c.SigningName = "awsssooidc"
|
||||
}
|
||||
return newClient(*c.Config, c.Handlers, c.PartitionID, c.Endpoint, c.SigningRegion, c.SigningName, c.ResolvedRegion)
|
||||
}
|
||||
|
|
20
vendor/github.com/aws/aws-sdk-go/service/sts/api.go
generated
vendored
20
vendor/github.com/aws/aws-sdk-go/service/sts/api.go
generated
vendored
|
@ -1460,15 +1460,7 @@ type AssumeRoleInput struct {
|
|||
// in the IAM User Guide.
|
||||
PolicyArns []*PolicyDescriptorType `type:"list"`
|
||||
|
||||
// A list of previously acquired trusted context assertions in the format of
|
||||
// a JSON array. The trusted context assertion is signed and encrypted by Amazon
|
||||
// Web Services STS.
|
||||
//
|
||||
// The following is an example of a ProvidedContext value that includes a single
|
||||
// trusted context assertion and the ARN of the context provider from which
|
||||
// the trusted context assertion was generated.
|
||||
//
|
||||
// [{"ProviderArn":"arn:aws:iam::aws:contextProvider/IdentityCenter","ContextAssertion":"trusted-context-assertion"}]
|
||||
// Reserved for future use.
|
||||
ProvidedContexts []*ProvidedContext `type:"list"`
|
||||
|
||||
// The Amazon Resource Name (ARN) of the role to assume.
|
||||
|
@ -3413,18 +3405,14 @@ func (s *PolicyDescriptorType) SetArn(v string) *PolicyDescriptorType {
|
|||
return s
|
||||
}
|
||||
|
||||
// Contains information about the provided context. This includes the signed
|
||||
// and encrypted trusted context assertion and the context provider ARN from
|
||||
// which the trusted context assertion was generated.
|
||||
// Reserved for future use.
|
||||
type ProvidedContext struct {
|
||||
_ struct{} `type:"structure"`
|
||||
|
||||
// The signed and encrypted trusted context assertion generated by the context
|
||||
// provider. The trusted context assertion is signed and encrypted by Amazon
|
||||
// Web Services STS.
|
||||
// Reserved for future use.
|
||||
ContextAssertion *string `min:"4" type:"string"`
|
||||
|
||||
// The context provider ARN from which the trusted context assertion was generated.
|
||||
// Reserved for future use.
|
||||
ProviderArn *string `min:"20" type:"string"`
|
||||
}
|
||||
|
||||
|
|
6
vendor/github.com/cpuguy83/go-md2man/v2/md2man/md2man.go
generated
vendored
6
vendor/github.com/cpuguy83/go-md2man/v2/md2man/md2man.go
generated
vendored
|
@ -9,8 +9,6 @@ func Render(doc []byte) []byte {
|
|||
renderer := NewRoffRenderer()
|
||||
|
||||
return blackfriday.Run(doc,
|
||||
[]blackfriday.Option{
|
||||
blackfriday.WithRenderer(renderer),
|
||||
blackfriday.WithExtensions(renderer.GetExtensions()),
|
||||
}...)
|
||||
[]blackfriday.Option{blackfriday.WithRenderer(renderer),
|
||||
blackfriday.WithExtensions(renderer.GetExtensions())}...)
|
||||
}
|
||||
|
|
114
vendor/github.com/cpuguy83/go-md2man/v2/md2man/roff.go
generated
vendored
114
vendor/github.com/cpuguy83/go-md2man/v2/md2man/roff.go
generated
vendored
|
@ -1,8 +1,6 @@
|
|||
package md2man
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
@ -22,35 +20,34 @@ type roffRenderer struct {
|
|||
}
|
||||
|
||||
const (
|
||||
titleHeader = ".TH "
|
||||
topLevelHeader = "\n\n.SH "
|
||||
secondLevelHdr = "\n.SH "
|
||||
otherHeader = "\n.SS "
|
||||
crTag = "\n"
|
||||
emphTag = "\\fI"
|
||||
emphCloseTag = "\\fP"
|
||||
strongTag = "\\fB"
|
||||
strongCloseTag = "\\fP"
|
||||
breakTag = "\n.br\n"
|
||||
paraTag = "\n.PP\n"
|
||||
hruleTag = "\n.ti 0\n\\l'\\n(.lu'\n"
|
||||
linkTag = "\n\\[la]"
|
||||
linkCloseTag = "\\[ra]"
|
||||
codespanTag = "\\fB"
|
||||
codespanCloseTag = "\\fR"
|
||||
codeTag = "\n.EX\n"
|
||||
codeCloseTag = ".EE\n" // Do not prepend a newline character since code blocks, by definition, include a newline already (or at least as how blackfriday gives us on).
|
||||
quoteTag = "\n.PP\n.RS\n"
|
||||
quoteCloseTag = "\n.RE\n"
|
||||
listTag = "\n.RS\n"
|
||||
listCloseTag = "\n.RE\n"
|
||||
dtTag = "\n.TP\n"
|
||||
dd2Tag = "\n"
|
||||
tableStart = "\n.TS\nallbox;\n"
|
||||
tableEnd = ".TE\n"
|
||||
tableCellStart = "T{\n"
|
||||
tableCellEnd = "\nT}\n"
|
||||
tablePreprocessor = `'\" t`
|
||||
titleHeader = ".TH "
|
||||
topLevelHeader = "\n\n.SH "
|
||||
secondLevelHdr = "\n.SH "
|
||||
otherHeader = "\n.SS "
|
||||
crTag = "\n"
|
||||
emphTag = "\\fI"
|
||||
emphCloseTag = "\\fP"
|
||||
strongTag = "\\fB"
|
||||
strongCloseTag = "\\fP"
|
||||
breakTag = "\n.br\n"
|
||||
paraTag = "\n.PP\n"
|
||||
hruleTag = "\n.ti 0\n\\l'\\n(.lu'\n"
|
||||
linkTag = "\n\\[la]"
|
||||
linkCloseTag = "\\[ra]"
|
||||
codespanTag = "\\fB\\fC"
|
||||
codespanCloseTag = "\\fR"
|
||||
codeTag = "\n.PP\n.RS\n\n.nf\n"
|
||||
codeCloseTag = "\n.fi\n.RE\n"
|
||||
quoteTag = "\n.PP\n.RS\n"
|
||||
quoteCloseTag = "\n.RE\n"
|
||||
listTag = "\n.RS\n"
|
||||
listCloseTag = "\n.RE\n"
|
||||
dtTag = "\n.TP\n"
|
||||
dd2Tag = "\n"
|
||||
tableStart = "\n.TS\nallbox;\n"
|
||||
tableEnd = ".TE\n"
|
||||
tableCellStart = "T{\n"
|
||||
tableCellEnd = "\nT}\n"
|
||||
)
|
||||
|
||||
// NewRoffRenderer creates a new blackfriday Renderer for generating roff documents
|
||||
|
@ -77,16 +74,6 @@ func (r *roffRenderer) GetExtensions() blackfriday.Extensions {
|
|||
|
||||
// RenderHeader handles outputting the header at document start
|
||||
func (r *roffRenderer) RenderHeader(w io.Writer, ast *blackfriday.Node) {
|
||||
// We need to walk the tree to check if there are any tables.
|
||||
// If there are, we need to enable the roff table preprocessor.
|
||||
ast.Walk(func(node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
|
||||
if node.Type == blackfriday.Table {
|
||||
out(w, tablePreprocessor+"\n")
|
||||
return blackfriday.Terminate
|
||||
}
|
||||
return blackfriday.GoToNext
|
||||
})
|
||||
|
||||
// disable hyphenation
|
||||
out(w, ".nh\n")
|
||||
}
|
||||
|
@ -99,7 +86,8 @@ func (r *roffRenderer) RenderFooter(w io.Writer, ast *blackfriday.Node) {
|
|||
// RenderNode is called for each node in a markdown document; based on the node
|
||||
// type the equivalent roff output is sent to the writer
|
||||
func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
|
||||
walkAction := blackfriday.GoToNext
|
||||
|
||||
var walkAction = blackfriday.GoToNext
|
||||
|
||||
switch node.Type {
|
||||
case blackfriday.Text:
|
||||
|
@ -121,16 +109,9 @@ func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering
|
|||
out(w, strongCloseTag)
|
||||
}
|
||||
case blackfriday.Link:
|
||||
// Don't render the link text for automatic links, because this
|
||||
// will only duplicate the URL in the roff output.
|
||||
// See https://daringfireball.net/projects/markdown/syntax#autolink
|
||||
if !bytes.Equal(node.LinkData.Destination, node.FirstChild.Literal) {
|
||||
out(w, string(node.FirstChild.Literal))
|
||||
if !entering {
|
||||
out(w, linkTag+string(node.LinkData.Destination)+linkCloseTag)
|
||||
}
|
||||
// Hyphens in a link must be escaped to avoid word-wrap in the rendered man page.
|
||||
escapedLink := strings.ReplaceAll(string(node.LinkData.Destination), "-", "\\-")
|
||||
out(w, linkTag+escapedLink+linkCloseTag)
|
||||
walkAction = blackfriday.SkipChildren
|
||||
case blackfriday.Image:
|
||||
// ignore images
|
||||
walkAction = blackfriday.SkipChildren
|
||||
|
@ -179,11 +160,6 @@ func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering
|
|||
r.handleTableCell(w, node, entering)
|
||||
case blackfriday.HTMLSpan:
|
||||
// ignore other HTML tags
|
||||
case blackfriday.HTMLBlock:
|
||||
if bytes.HasPrefix(node.Literal, []byte("<!--")) {
|
||||
break // ignore comments, no warning
|
||||
}
|
||||
fmt.Fprintln(os.Stderr, "WARNING: go-md2man does not handle node type "+node.Type.String())
|
||||
default:
|
||||
fmt.Fprintln(os.Stderr, "WARNING: go-md2man does not handle node type "+node.Type.String())
|
||||
}
|
||||
|
@ -278,7 +254,7 @@ func (r *roffRenderer) handleTableCell(w io.Writer, node *blackfriday.Node, ente
|
|||
start = "\t"
|
||||
}
|
||||
if node.IsHeader {
|
||||
start += strongTag
|
||||
start += codespanTag
|
||||
} else if nodeLiteralSize(node) > 30 {
|
||||
start += tableCellStart
|
||||
}
|
||||
|
@ -286,7 +262,7 @@ func (r *roffRenderer) handleTableCell(w io.Writer, node *blackfriday.Node, ente
|
|||
} else {
|
||||
var end string
|
||||
if node.IsHeader {
|
||||
end = strongCloseTag
|
||||
end = codespanCloseTag
|
||||
} else if nodeLiteralSize(node) > 30 {
|
||||
end = tableCellEnd
|
||||
}
|
||||
|
@ -334,28 +310,6 @@ func out(w io.Writer, output string) {
|
|||
}
|
||||
|
||||
func escapeSpecialChars(w io.Writer, text []byte) {
|
||||
scanner := bufio.NewScanner(bytes.NewReader(text))
|
||||
|
||||
// count the number of lines in the text
|
||||
// we need to know this to avoid adding a newline after the last line
|
||||
n := bytes.Count(text, []byte{'\n'})
|
||||
idx := 0
|
||||
|
||||
for scanner.Scan() {
|
||||
dt := scanner.Bytes()
|
||||
if idx < n {
|
||||
idx++
|
||||
dt = append(dt, '\n')
|
||||
}
|
||||
escapeSpecialCharsLine(w, dt)
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func escapeSpecialCharsLine(w io.Writer, text []byte) {
|
||||
for i := 0; i < len(text); i++ {
|
||||
// escape initial apostrophe or period
|
||||
if len(text) >= 1 && (text[0] == '\'' || text[0] == '.') {
|
||||
|
|
20
vendor/github.com/rs/zerolog/README.md
generated
vendored
20
vendor/github.com/rs/zerolog/README.md
generated
vendored
|
@ -60,7 +60,7 @@ func main() {
|
|||
// Output: {"time":1516134303,"level":"debug","message":"hello world"}
|
||||
```
|
||||
> Note: By default log writes to `os.Stderr`
|
||||
> Note: The default log level for `log.Print` is *trace*
|
||||
> Note: The default log level for `log.Print` is *debug*
|
||||
|
||||
### Contextual Logging
|
||||
|
||||
|
@ -412,7 +412,15 @@ Equivalent of `Lshortfile`:
|
|||
|
||||
```go
|
||||
zerolog.CallerMarshalFunc = func(pc uintptr, file string, line int) string {
|
||||
return filepath.Base(file) + ":" + strconv.Itoa(line)
|
||||
short := file
|
||||
for i := len(file) - 1; i > 0; i-- {
|
||||
if file[i] == '/' {
|
||||
short = file[i+1:]
|
||||
break
|
||||
}
|
||||
}
|
||||
file = short
|
||||
return file + ":" + strconv.Itoa(line)
|
||||
}
|
||||
log.Logger = log.With().Caller().Logger()
|
||||
log.Info().Msg("hello world")
|
||||
|
@ -539,7 +547,7 @@ and facilitates the unification of logging and tracing in some systems:
|
|||
type TracingHook struct{}
|
||||
|
||||
func (h TracingHook) Run(e *zerolog.Event, level zerolog.Level, msg string) {
|
||||
ctx := e.GetCtx()
|
||||
ctx := e.Ctx()
|
||||
spanId := getSpanIdFromContext(ctx) // as per your tracing framework
|
||||
e.Str("span-id", spanId)
|
||||
}
|
||||
|
@ -638,14 +646,10 @@ Some settings can be changed and will be applied to all loggers:
|
|||
* `zerolog.LevelFieldName`: Can be set to customize level field name.
|
||||
* `zerolog.MessageFieldName`: Can be set to customize message field name.
|
||||
* `zerolog.ErrorFieldName`: Can be set to customize `Err` field name.
|
||||
* `zerolog.TimeFieldFormat`: Can be set to customize `Time` field value formatting. If set with `zerolog.TimeFormatUnix`, `zerolog.TimeFormatUnixMs` or `zerolog.TimeFormatUnixMicro`, times are formatted as UNIX timestamp.
|
||||
* `zerolog.TimeFieldFormat`: Can be set to customize `Time` field value formatting. If set with `zerolog.TimeFormatUnix`, `zerolog.TimeFormatUnixMs` or `zerolog.TimeFormatUnixMicro`, times are formated as UNIX timestamp.
|
||||
* `zerolog.DurationFieldUnit`: Can be set to customize the unit for time.Duration type fields added by `Dur` (default: `time.Millisecond`).
|
||||
* `zerolog.DurationFieldInteger`: If set to `true`, `Dur` fields are formatted as integers instead of floats (default: `false`).
|
||||
* `zerolog.ErrorHandler`: Called whenever zerolog fails to write an event on its output. If not set, an error is printed on the stderr. This handler must be thread safe and non-blocking.
|
||||
* `zerolog.FloatingPointPrecision`: If set to a value other than -1, controls the number
|
||||
of digits when formatting float numbers in JSON. See
|
||||
[strconv.FormatFloat](https://pkg.go.dev/strconv#FormatFloat)
|
||||
for more details.
|
||||
|
||||
## Field Types
|
||||
|
||||
|
|
6
vendor/github.com/rs/zerolog/array.go
generated
vendored
6
vendor/github.com/rs/zerolog/array.go
generated
vendored
|
@ -183,13 +183,13 @@ func (a *Array) Uint64(i uint64) *Array {
|
|||
|
||||
// Float32 appends f as a float32 to the array.
|
||||
func (a *Array) Float32(f float32) *Array {
|
||||
a.buf = enc.AppendFloat32(enc.AppendArrayDelim(a.buf), f, FloatingPointPrecision)
|
||||
a.buf = enc.AppendFloat32(enc.AppendArrayDelim(a.buf), f)
|
||||
return a
|
||||
}
|
||||
|
||||
// Float64 appends f as a float64 to the array.
|
||||
func (a *Array) Float64(f float64) *Array {
|
||||
a.buf = enc.AppendFloat64(enc.AppendArrayDelim(a.buf), f, FloatingPointPrecision)
|
||||
a.buf = enc.AppendFloat64(enc.AppendArrayDelim(a.buf), f)
|
||||
return a
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ func (a *Array) Time(t time.Time) *Array {
|
|||
|
||||
// Dur appends d to the array.
|
||||
func (a *Array) Dur(d time.Duration) *Array {
|
||||
a.buf = enc.AppendDuration(enc.AppendArrayDelim(a.buf), d, DurationFieldUnit, DurationFieldInteger, FloatingPointPrecision)
|
||||
a.buf = enc.AppendDuration(enc.AppendArrayDelim(a.buf), d, DurationFieldUnit, DurationFieldInteger)
|
||||
return a
|
||||
}
|
||||
|
||||
|
|
149
vendor/github.com/rs/zerolog/console.go
generated
vendored
149
vendor/github.com/rs/zerolog/console.go
generated
vendored
|
@ -28,8 +28,6 @@ const (
|
|||
|
||||
colorBold = 1
|
||||
colorDarkGray = 90
|
||||
|
||||
unknownLevel = "???"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -59,21 +57,12 @@ type ConsoleWriter struct {
|
|||
// TimeFormat specifies the format for timestamp in output.
|
||||
TimeFormat string
|
||||
|
||||
// TimeLocation tells ConsoleWriter’s default FormatTimestamp
|
||||
// how to localize the time.
|
||||
TimeLocation *time.Location
|
||||
|
||||
// PartsOrder defines the order of parts in output.
|
||||
PartsOrder []string
|
||||
|
||||
// PartsExclude defines parts to not display in output.
|
||||
PartsExclude []string
|
||||
|
||||
// FieldsOrder defines the order of contextual fields in output.
|
||||
FieldsOrder []string
|
||||
|
||||
fieldIsOrdered map[string]int
|
||||
|
||||
// FieldsExclude defines contextual fields to not display in output.
|
||||
FieldsExclude []string
|
||||
|
||||
|
@ -87,16 +76,14 @@ type ConsoleWriter struct {
|
|||
FormatErrFieldValue Formatter
|
||||
|
||||
FormatExtra func(map[string]interface{}, *bytes.Buffer) error
|
||||
|
||||
FormatPrepare func(map[string]interface{}) error
|
||||
}
|
||||
|
||||
// NewConsoleWriter creates and initializes a new ConsoleWriter.
|
||||
func NewConsoleWriter(options ...func(w *ConsoleWriter)) ConsoleWriter {
|
||||
w := ConsoleWriter{
|
||||
Out: os.Stdout,
|
||||
TimeFormat: consoleDefaultTimeFormat,
|
||||
PartsOrder: consoleDefaultPartsOrder(),
|
||||
Out: os.Stdout,
|
||||
TimeFormat: consoleDefaultTimeFormat,
|
||||
PartsOrder: consoleDefaultPartsOrder(),
|
||||
}
|
||||
|
||||
for _, opt := range options {
|
||||
|
@ -137,13 +124,6 @@ func (w ConsoleWriter) Write(p []byte) (n int, err error) {
|
|||
return n, fmt.Errorf("cannot decode event: %s", err)
|
||||
}
|
||||
|
||||
if w.FormatPrepare != nil {
|
||||
err = w.FormatPrepare(evt)
|
||||
if err != nil {
|
||||
return n, err
|
||||
}
|
||||
}
|
||||
|
||||
for _, p := range w.PartsOrder {
|
||||
w.writePart(buf, evt, p)
|
||||
}
|
||||
|
@ -166,15 +146,6 @@ func (w ConsoleWriter) Write(p []byte) (n int, err error) {
|
|||
return len(p), err
|
||||
}
|
||||
|
||||
// Call the underlying writer's Close method if it is an io.Closer. Otherwise
|
||||
// does nothing.
|
||||
func (w ConsoleWriter) Close() error {
|
||||
if closer, ok := w.Out.(io.Closer); ok {
|
||||
return closer.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// writeFields appends formatted key-value pairs to buf.
|
||||
func (w ConsoleWriter) writeFields(evt map[string]interface{}, buf *bytes.Buffer) {
|
||||
var fields = make([]string, 0, len(evt))
|
||||
|
@ -196,12 +167,7 @@ func (w ConsoleWriter) writeFields(evt map[string]interface{}, buf *bytes.Buffer
|
|||
}
|
||||
fields = append(fields, field)
|
||||
}
|
||||
|
||||
if len(w.FieldsOrder) > 0 {
|
||||
w.orderFields(fields)
|
||||
} else {
|
||||
sort.Strings(fields)
|
||||
}
|
||||
sort.Strings(fields)
|
||||
|
||||
// Write space only if something has already been written to the buffer, and if there are fields.
|
||||
if buf.Len() > 0 && len(fields) > 0 {
|
||||
|
@ -300,13 +266,13 @@ func (w ConsoleWriter) writePart(buf *bytes.Buffer, evt map[string]interface{},
|
|||
}
|
||||
case TimestampFieldName:
|
||||
if w.FormatTimestamp == nil {
|
||||
f = consoleDefaultFormatTimestamp(w.TimeFormat, w.TimeLocation, w.NoColor)
|
||||
f = consoleDefaultFormatTimestamp(w.TimeFormat, w.NoColor)
|
||||
} else {
|
||||
f = w.FormatTimestamp
|
||||
}
|
||||
case MessageFieldName:
|
||||
if w.FormatMessage == nil {
|
||||
f = consoleDefaultFormatMessage(w.NoColor, evt[LevelFieldName])
|
||||
f = consoleDefaultFormatMessage
|
||||
} else {
|
||||
f = w.FormatMessage
|
||||
}
|
||||
|
@ -334,32 +300,6 @@ func (w ConsoleWriter) writePart(buf *bytes.Buffer, evt map[string]interface{},
|
|||
}
|
||||
}
|
||||
|
||||
// orderFields takes an array of field names and an array representing field order
|
||||
// and returns an array with any ordered fields at the beginning, in order,
|
||||
// and the remaining fields after in their original order.
|
||||
func (w ConsoleWriter) orderFields(fields []string) {
|
||||
if w.fieldIsOrdered == nil {
|
||||
w.fieldIsOrdered = make(map[string]int)
|
||||
for i, fieldName := range w.FieldsOrder {
|
||||
w.fieldIsOrdered[fieldName] = i
|
||||
}
|
||||
}
|
||||
sort.Slice(fields, func(i, j int) bool {
|
||||
ii, iOrdered := w.fieldIsOrdered[fields[i]]
|
||||
jj, jOrdered := w.fieldIsOrdered[fields[j]]
|
||||
if iOrdered && jOrdered {
|
||||
return ii < jj
|
||||
}
|
||||
if iOrdered {
|
||||
return true
|
||||
}
|
||||
if jOrdered {
|
||||
return false
|
||||
}
|
||||
return fields[i] < fields[j]
|
||||
})
|
||||
}
|
||||
|
||||
// needsQuote returns true when the string s should be quoted in output.
|
||||
func needsQuote(s string) bool {
|
||||
for i := range s {
|
||||
|
@ -370,10 +310,10 @@ func needsQuote(s string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// colorize returns the string s wrapped in ANSI code c, unless disabled is true or c is 0.
|
||||
// colorize returns the string s wrapped in ANSI code c, unless disabled is true.
|
||||
func colorize(s interface{}, c int, disabled bool) string {
|
||||
e := os.Getenv("NO_COLOR")
|
||||
if e != "" || c == 0 {
|
||||
if e != "" {
|
||||
disabled = true
|
||||
}
|
||||
|
||||
|
@ -394,23 +334,19 @@ func consoleDefaultPartsOrder() []string {
|
|||
}
|
||||
}
|
||||
|
||||
func consoleDefaultFormatTimestamp(timeFormat string, location *time.Location, noColor bool) Formatter {
|
||||
func consoleDefaultFormatTimestamp(timeFormat string, noColor bool) Formatter {
|
||||
if timeFormat == "" {
|
||||
timeFormat = consoleDefaultTimeFormat
|
||||
}
|
||||
if location == nil {
|
||||
location = time.Local
|
||||
}
|
||||
|
||||
return func(i interface{}) string {
|
||||
t := "<nil>"
|
||||
switch tt := i.(type) {
|
||||
case string:
|
||||
ts, err := time.ParseInLocation(TimeFieldFormat, tt, location)
|
||||
ts, err := time.ParseInLocation(TimeFieldFormat, tt, time.Local)
|
||||
if err != nil {
|
||||
t = tt
|
||||
} else {
|
||||
t = ts.In(location).Format(timeFormat)
|
||||
t = ts.Local().Format(timeFormat)
|
||||
}
|
||||
case json.Number:
|
||||
i, err := tt.Int64()
|
||||
|
@ -431,37 +367,43 @@ func consoleDefaultFormatTimestamp(timeFormat string, location *time.Location, n
|
|||
}
|
||||
|
||||
ts := time.Unix(sec, nsec)
|
||||
t = ts.In(location).Format(timeFormat)
|
||||
t = ts.Format(timeFormat)
|
||||
}
|
||||
}
|
||||
return colorize(t, colorDarkGray, noColor)
|
||||
}
|
||||
}
|
||||
|
||||
func stripLevel(ll string) string {
|
||||
if len(ll) == 0 {
|
||||
return unknownLevel
|
||||
}
|
||||
if len(ll) > 3 {
|
||||
ll = ll[:3]
|
||||
}
|
||||
return strings.ToUpper(ll)
|
||||
}
|
||||
|
||||
func consoleDefaultFormatLevel(noColor bool) Formatter {
|
||||
return func(i interface{}) string {
|
||||
var l string
|
||||
if ll, ok := i.(string); ok {
|
||||
level, _ := ParseLevel(ll)
|
||||
fl, ok := FormattedLevels[level]
|
||||
if ok {
|
||||
return colorize(fl, LevelColors[level], noColor)
|
||||
switch ll {
|
||||
case LevelTraceValue:
|
||||
l = colorize("TRC", colorMagenta, noColor)
|
||||
case LevelDebugValue:
|
||||
l = colorize("DBG", colorYellow, noColor)
|
||||
case LevelInfoValue:
|
||||
l = colorize("INF", colorGreen, noColor)
|
||||
case LevelWarnValue:
|
||||
l = colorize("WRN", colorRed, noColor)
|
||||
case LevelErrorValue:
|
||||
l = colorize(colorize("ERR", colorRed, noColor), colorBold, noColor)
|
||||
case LevelFatalValue:
|
||||
l = colorize(colorize("FTL", colorRed, noColor), colorBold, noColor)
|
||||
case LevelPanicValue:
|
||||
l = colorize(colorize("PNC", colorRed, noColor), colorBold, noColor)
|
||||
default:
|
||||
l = colorize(ll, colorBold, noColor)
|
||||
}
|
||||
} else {
|
||||
if i == nil {
|
||||
l = colorize("???", colorBold, noColor)
|
||||
} else {
|
||||
l = strings.ToUpper(fmt.Sprintf("%s", i))[0:3]
|
||||
}
|
||||
return stripLevel(ll)
|
||||
}
|
||||
if i == nil {
|
||||
return unknownLevel
|
||||
}
|
||||
return stripLevel(fmt.Sprintf("%s", i))
|
||||
return l
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -483,18 +425,11 @@ func consoleDefaultFormatCaller(noColor bool) Formatter {
|
|||
}
|
||||
}
|
||||
|
||||
func consoleDefaultFormatMessage(noColor bool, level interface{}) Formatter {
|
||||
return func(i interface{}) string {
|
||||
if i == nil || i == "" {
|
||||
return ""
|
||||
}
|
||||
switch level {
|
||||
case LevelInfoValue, LevelWarnValue, LevelErrorValue, LevelFatalValue, LevelPanicValue:
|
||||
return colorize(fmt.Sprintf("%s", i), colorBold, noColor)
|
||||
default:
|
||||
return fmt.Sprintf("%s", i)
|
||||
}
|
||||
func consoleDefaultFormatMessage(i interface{}) string {
|
||||
if i == nil {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("%s", i)
|
||||
}
|
||||
|
||||
func consoleDefaultFormatFieldName(noColor bool) Formatter {
|
||||
|
@ -515,6 +450,6 @@ func consoleDefaultFormatErrFieldName(noColor bool) Formatter {
|
|||
|
||||
func consoleDefaultFormatErrFieldValue(noColor bool) Formatter {
|
||||
return func(i interface{}) string {
|
||||
return colorize(colorize(fmt.Sprintf("%s", i), colorBold, noColor), colorRed, noColor)
|
||||
return colorize(fmt.Sprintf("%s", i), colorRed, noColor)
|
||||
}
|
||||
}
|
||||
|
|
55
vendor/github.com/rs/zerolog/context.go
generated
vendored
55
vendor/github.com/rs/zerolog/context.go
generated
vendored
|
@ -3,7 +3,7 @@ package zerolog
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"net"
|
||||
"time"
|
||||
|
@ -23,7 +23,7 @@ func (c Context) Logger() Logger {
|
|||
// Only map[string]interface{} and []interface{} are accepted. []interface{} must
|
||||
// alternate string keys and arbitrary values, and extraneous ones are ignored.
|
||||
func (c Context) Fields(fields interface{}) Context {
|
||||
c.l.context = appendFields(c.l.context, fields, c.l.stack)
|
||||
c.l.context = appendFields(c.l.context, fields)
|
||||
return c
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ func (c Context) Array(key string, arr LogArrayMarshaler) Context {
|
|||
|
||||
// Object marshals an object that implement the LogObjectMarshaler interface.
|
||||
func (c Context) Object(key string, obj LogObjectMarshaler) Context {
|
||||
e := newEvent(LevelWriterAdapter{io.Discard}, 0)
|
||||
e := newEvent(LevelWriterAdapter{ioutil.Discard}, 0)
|
||||
e.Object(key, obj)
|
||||
c.l.context = enc.AppendObjectData(c.l.context, e.buf)
|
||||
putEvent(e)
|
||||
|
@ -66,7 +66,7 @@ func (c Context) Object(key string, obj LogObjectMarshaler) Context {
|
|||
|
||||
// EmbedObject marshals and Embeds an object that implement the LogObjectMarshaler interface.
|
||||
func (c Context) EmbedObject(obj LogObjectMarshaler) Context {
|
||||
e := newEvent(LevelWriterAdapter{io.Discard}, 0)
|
||||
e := newEvent(LevelWriterAdapter{ioutil.Discard}, 0)
|
||||
e.EmbedObject(obj)
|
||||
c.l.context = enc.AppendObjectData(c.l.context, e.buf)
|
||||
putEvent(e)
|
||||
|
@ -163,22 +163,6 @@ func (c Context) Errs(key string, errs []error) Context {
|
|||
|
||||
// Err adds the field "error" with serialized err to the logger context.
|
||||
func (c Context) Err(err error) Context {
|
||||
if c.l.stack && ErrorStackMarshaler != nil {
|
||||
switch m := ErrorStackMarshaler(err).(type) {
|
||||
case nil:
|
||||
case LogObjectMarshaler:
|
||||
c = c.Object(ErrorStackFieldName, m)
|
||||
case error:
|
||||
if m != nil && !isNilValue(m) {
|
||||
c = c.Str(ErrorStackFieldName, m.Error())
|
||||
}
|
||||
case string:
|
||||
c = c.Str(ErrorStackFieldName, m)
|
||||
default:
|
||||
c = c.Interface(ErrorStackFieldName, m)
|
||||
}
|
||||
}
|
||||
|
||||
return c.AnErr(ErrorFieldName, err)
|
||||
}
|
||||
|
||||
|
@ -325,25 +309,25 @@ func (c Context) Uints64(key string, i []uint64) Context {
|
|||
|
||||
// Float32 adds the field key with f as a float32 to the logger context.
|
||||
func (c Context) Float32(key string, f float32) Context {
|
||||
c.l.context = enc.AppendFloat32(enc.AppendKey(c.l.context, key), f, FloatingPointPrecision)
|
||||
c.l.context = enc.AppendFloat32(enc.AppendKey(c.l.context, key), f)
|
||||
return c
|
||||
}
|
||||
|
||||
// Floats32 adds the field key with f as a []float32 to the logger context.
|
||||
func (c Context) Floats32(key string, f []float32) Context {
|
||||
c.l.context = enc.AppendFloats32(enc.AppendKey(c.l.context, key), f, FloatingPointPrecision)
|
||||
c.l.context = enc.AppendFloats32(enc.AppendKey(c.l.context, key), f)
|
||||
return c
|
||||
}
|
||||
|
||||
// Float64 adds the field key with f as a float64 to the logger context.
|
||||
func (c Context) Float64(key string, f float64) Context {
|
||||
c.l.context = enc.AppendFloat64(enc.AppendKey(c.l.context, key), f, FloatingPointPrecision)
|
||||
c.l.context = enc.AppendFloat64(enc.AppendKey(c.l.context, key), f)
|
||||
return c
|
||||
}
|
||||
|
||||
// Floats64 adds the field key with f as a []float64 to the logger context.
|
||||
func (c Context) Floats64(key string, f []float64) Context {
|
||||
c.l.context = enc.AppendFloats64(enc.AppendKey(c.l.context, key), f, FloatingPointPrecision)
|
||||
c.l.context = enc.AppendFloats64(enc.AppendKey(c.l.context, key), f)
|
||||
return c
|
||||
}
|
||||
|
||||
|
@ -365,13 +349,13 @@ func (c Context) Timestamp() Context {
|
|||
return c
|
||||
}
|
||||
|
||||
// Time adds the field key with t formatted as string using zerolog.TimeFieldFormat.
|
||||
// Time adds the field key with t formated as string using zerolog.TimeFieldFormat.
|
||||
func (c Context) Time(key string, t time.Time) Context {
|
||||
c.l.context = enc.AppendTime(enc.AppendKey(c.l.context, key), t, TimeFieldFormat)
|
||||
return c
|
||||
}
|
||||
|
||||
// Times adds the field key with t formatted as string using zerolog.TimeFieldFormat.
|
||||
// Times adds the field key with t formated as string using zerolog.TimeFieldFormat.
|
||||
func (c Context) Times(key string, t []time.Time) Context {
|
||||
c.l.context = enc.AppendTimes(enc.AppendKey(c.l.context, key), t, TimeFieldFormat)
|
||||
return c
|
||||
|
@ -379,42 +363,27 @@ func (c Context) Times(key string, t []time.Time) Context {
|
|||
|
||||
// Dur adds the fields key with d divided by unit and stored as a float.
|
||||
func (c Context) Dur(key string, d time.Duration) Context {
|
||||
c.l.context = enc.AppendDuration(enc.AppendKey(c.l.context, key), d, DurationFieldUnit, DurationFieldInteger, FloatingPointPrecision)
|
||||
c.l.context = enc.AppendDuration(enc.AppendKey(c.l.context, key), d, DurationFieldUnit, DurationFieldInteger)
|
||||
return c
|
||||
}
|
||||
|
||||
// Durs adds the fields key with d divided by unit and stored as a float.
|
||||
func (c Context) Durs(key string, d []time.Duration) Context {
|
||||
c.l.context = enc.AppendDurations(enc.AppendKey(c.l.context, key), d, DurationFieldUnit, DurationFieldInteger, FloatingPointPrecision)
|
||||
c.l.context = enc.AppendDurations(enc.AppendKey(c.l.context, key), d, DurationFieldUnit, DurationFieldInteger)
|
||||
return c
|
||||
}
|
||||
|
||||
// Interface adds the field key with obj marshaled using reflection.
|
||||
func (c Context) Interface(key string, i interface{}) Context {
|
||||
if obj, ok := i.(LogObjectMarshaler); ok {
|
||||
return c.Object(key, obj)
|
||||
}
|
||||
c.l.context = enc.AppendInterface(enc.AppendKey(c.l.context, key), i)
|
||||
return c
|
||||
}
|
||||
|
||||
// Type adds the field key with val's type using reflection.
|
||||
func (c Context) Type(key string, val interface{}) Context {
|
||||
c.l.context = enc.AppendType(enc.AppendKey(c.l.context, key), val)
|
||||
return c
|
||||
}
|
||||
|
||||
// Any is a wrapper around Context.Interface.
|
||||
func (c Context) Any(key string, i interface{}) Context {
|
||||
return c.Interface(key, i)
|
||||
}
|
||||
|
||||
// Reset removes all the context fields.
|
||||
func (c Context) Reset() Context {
|
||||
c.l.context = enc.AppendBeginMarker(make([]byte, 0, 500))
|
||||
return c
|
||||
}
|
||||
|
||||
type callerHook struct {
|
||||
callerSkipFrameCount int
|
||||
}
|
||||
|
|
12
vendor/github.com/rs/zerolog/encoder.go
generated
vendored
12
vendor/github.com/rs/zerolog/encoder.go
generated
vendored
|
@ -13,13 +13,13 @@ type encoder interface {
|
|||
AppendBool(dst []byte, val bool) []byte
|
||||
AppendBools(dst []byte, vals []bool) []byte
|
||||
AppendBytes(dst, s []byte) []byte
|
||||
AppendDuration(dst []byte, d time.Duration, unit time.Duration, useInt bool, precision int) []byte
|
||||
AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool, precision int) []byte
|
||||
AppendDuration(dst []byte, d time.Duration, unit time.Duration, useInt bool) []byte
|
||||
AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool) []byte
|
||||
AppendEndMarker(dst []byte) []byte
|
||||
AppendFloat32(dst []byte, val float32, precision int) []byte
|
||||
AppendFloat64(dst []byte, val float64, precision int) []byte
|
||||
AppendFloats32(dst []byte, vals []float32, precision int) []byte
|
||||
AppendFloats64(dst []byte, vals []float64, precision int) []byte
|
||||
AppendFloat32(dst []byte, val float32) []byte
|
||||
AppendFloat64(dst []byte, val float64) []byte
|
||||
AppendFloats32(dst []byte, vals []float32) []byte
|
||||
AppendFloats64(dst []byte, vals []float64) []byte
|
||||
AppendHex(dst, s []byte) []byte
|
||||
AppendIPAddr(dst []byte, ip net.IP) []byte
|
||||
AppendIPPrefix(dst []byte, pfx net.IPNet) []byte
|
||||
|
|
16
vendor/github.com/rs/zerolog/event.go
generated
vendored
16
vendor/github.com/rs/zerolog/event.go
generated
vendored
|
@ -164,7 +164,7 @@ func (e *Event) Fields(fields interface{}) *Event {
|
|||
if e == nil {
|
||||
return e
|
||||
}
|
||||
e.buf = appendFields(e.buf, fields, e.stack)
|
||||
e.buf = appendFields(e.buf, fields)
|
||||
return e
|
||||
}
|
||||
|
||||
|
@ -644,7 +644,7 @@ func (e *Event) Float32(key string, f float32) *Event {
|
|||
if e == nil {
|
||||
return e
|
||||
}
|
||||
e.buf = enc.AppendFloat32(enc.AppendKey(e.buf, key), f, FloatingPointPrecision)
|
||||
e.buf = enc.AppendFloat32(enc.AppendKey(e.buf, key), f)
|
||||
return e
|
||||
}
|
||||
|
||||
|
@ -653,7 +653,7 @@ func (e *Event) Floats32(key string, f []float32) *Event {
|
|||
if e == nil {
|
||||
return e
|
||||
}
|
||||
e.buf = enc.AppendFloats32(enc.AppendKey(e.buf, key), f, FloatingPointPrecision)
|
||||
e.buf = enc.AppendFloats32(enc.AppendKey(e.buf, key), f)
|
||||
return e
|
||||
}
|
||||
|
||||
|
@ -662,7 +662,7 @@ func (e *Event) Float64(key string, f float64) *Event {
|
|||
if e == nil {
|
||||
return e
|
||||
}
|
||||
e.buf = enc.AppendFloat64(enc.AppendKey(e.buf, key), f, FloatingPointPrecision)
|
||||
e.buf = enc.AppendFloat64(enc.AppendKey(e.buf, key), f)
|
||||
return e
|
||||
}
|
||||
|
||||
|
@ -671,7 +671,7 @@ func (e *Event) Floats64(key string, f []float64) *Event {
|
|||
if e == nil {
|
||||
return e
|
||||
}
|
||||
e.buf = enc.AppendFloats64(enc.AppendKey(e.buf, key), f, FloatingPointPrecision)
|
||||
e.buf = enc.AppendFloats64(enc.AppendKey(e.buf, key), f)
|
||||
return e
|
||||
}
|
||||
|
||||
|
@ -713,7 +713,7 @@ func (e *Event) Dur(key string, d time.Duration) *Event {
|
|||
if e == nil {
|
||||
return e
|
||||
}
|
||||
e.buf = enc.AppendDuration(enc.AppendKey(e.buf, key), d, DurationFieldUnit, DurationFieldInteger, FloatingPointPrecision)
|
||||
e.buf = enc.AppendDuration(enc.AppendKey(e.buf, key), d, DurationFieldUnit, DurationFieldInteger)
|
||||
return e
|
||||
}
|
||||
|
||||
|
@ -724,7 +724,7 @@ func (e *Event) Durs(key string, d []time.Duration) *Event {
|
|||
if e == nil {
|
||||
return e
|
||||
}
|
||||
e.buf = enc.AppendDurations(enc.AppendKey(e.buf, key), d, DurationFieldUnit, DurationFieldInteger, FloatingPointPrecision)
|
||||
e.buf = enc.AppendDurations(enc.AppendKey(e.buf, key), d, DurationFieldUnit, DurationFieldInteger)
|
||||
return e
|
||||
}
|
||||
|
||||
|
@ -739,7 +739,7 @@ func (e *Event) TimeDiff(key string, t time.Time, start time.Time) *Event {
|
|||
if t.After(start) {
|
||||
d = t.Sub(start)
|
||||
}
|
||||
e.buf = enc.AppendDuration(enc.AppendKey(e.buf, key), d, DurationFieldUnit, DurationFieldInteger, FloatingPointPrecision)
|
||||
e.buf = enc.AppendDuration(enc.AppendKey(e.buf, key), d, DurationFieldUnit, DurationFieldInteger)
|
||||
return e
|
||||
}
|
||||
|
||||
|
|
7
vendor/github.com/rs/zerolog/example.jsonl
generated
vendored
7
vendor/github.com/rs/zerolog/example.jsonl
generated
vendored
|
@ -1,7 +0,0 @@
|
|||
{"time":"5:41PM","level":"info","message":"Starting listener","listen":":8080","pid":37556}
|
||||
{"time":"5:41PM","level":"debug","message":"Access","database":"myapp","host":"localhost:4962","pid":37556}
|
||||
{"time":"5:41PM","level":"info","message":"Access","method":"GET","path":"/users","pid":37556,"resp_time":23}
|
||||
{"time":"5:41PM","level":"info","message":"Access","method":"POST","path":"/posts","pid":37556,"resp_time":532}
|
||||
{"time":"5:41PM","level":"warn","message":"Slow request","method":"POST","path":"/posts","pid":37556,"resp_time":532}
|
||||
{"time":"5:41PM","level":"info","message":"Access","method":"GET","path":"/users","pid":37556,"resp_time":10}
|
||||
{"time":"5:41PM","level":"error","message":"Database connection lost","database":"myapp","pid":37556,"error":"connection reset by peer"}
|
41
vendor/github.com/rs/zerolog/fields.go
generated
vendored
41
vendor/github.com/rs/zerolog/fields.go
generated
vendored
|
@ -12,13 +12,13 @@ func isNilValue(i interface{}) bool {
|
|||
return (*[2]uintptr)(unsafe.Pointer(&i))[1] == 0
|
||||
}
|
||||
|
||||
func appendFields(dst []byte, fields interface{}, stack bool) []byte {
|
||||
func appendFields(dst []byte, fields interface{}) []byte {
|
||||
switch fields := fields.(type) {
|
||||
case []interface{}:
|
||||
if n := len(fields); n&0x1 == 1 { // odd number
|
||||
fields = fields[:n-1]
|
||||
}
|
||||
dst = appendFieldList(dst, fields, stack)
|
||||
dst = appendFieldList(dst, fields)
|
||||
case map[string]interface{}:
|
||||
keys := make([]string, 0, len(fields))
|
||||
for key := range fields {
|
||||
|
@ -28,13 +28,13 @@ func appendFields(dst []byte, fields interface{}, stack bool) []byte {
|
|||
kv := make([]interface{}, 2)
|
||||
for _, key := range keys {
|
||||
kv[0], kv[1] = key, fields[key]
|
||||
dst = appendFieldList(dst, kv, stack)
|
||||
dst = appendFieldList(dst, kv)
|
||||
}
|
||||
}
|
||||
return dst
|
||||
}
|
||||
|
||||
func appendFieldList(dst []byte, kvList []interface{}, stack bool) []byte {
|
||||
func appendFieldList(dst []byte, kvList []interface{}) []byte {
|
||||
for i, n := 0, len(kvList); i < n; i += 2 {
|
||||
key, val := kvList[i], kvList[i+1]
|
||||
if key, ok := key.(string); ok {
|
||||
|
@ -74,21 +74,6 @@ func appendFieldList(dst []byte, kvList []interface{}, stack bool) []byte {
|
|||
default:
|
||||
dst = enc.AppendInterface(dst, m)
|
||||
}
|
||||
|
||||
if stack && ErrorStackMarshaler != nil {
|
||||
dst = enc.AppendKey(dst, ErrorStackFieldName)
|
||||
switch m := ErrorStackMarshaler(val).(type) {
|
||||
case nil:
|
||||
case error:
|
||||
if m != nil && !isNilValue(m) {
|
||||
dst = enc.AppendString(dst, m.Error())
|
||||
}
|
||||
case string:
|
||||
dst = enc.AppendString(dst, m)
|
||||
default:
|
||||
dst = enc.AppendInterface(dst, m)
|
||||
}
|
||||
}
|
||||
case []error:
|
||||
dst = enc.AppendArrayStart(dst)
|
||||
for i, err := range val {
|
||||
|
@ -139,13 +124,13 @@ func appendFieldList(dst []byte, kvList []interface{}, stack bool) []byte {
|
|||
case uint64:
|
||||
dst = enc.AppendUint64(dst, val)
|
||||
case float32:
|
||||
dst = enc.AppendFloat32(dst, val, FloatingPointPrecision)
|
||||
dst = enc.AppendFloat32(dst, val)
|
||||
case float64:
|
||||
dst = enc.AppendFloat64(dst, val, FloatingPointPrecision)
|
||||
dst = enc.AppendFloat64(dst, val)
|
||||
case time.Time:
|
||||
dst = enc.AppendTime(dst, val, TimeFieldFormat)
|
||||
case time.Duration:
|
||||
dst = enc.AppendDuration(dst, val, DurationFieldUnit, DurationFieldInteger, FloatingPointPrecision)
|
||||
dst = enc.AppendDuration(dst, val, DurationFieldUnit, DurationFieldInteger)
|
||||
case *string:
|
||||
if val != nil {
|
||||
dst = enc.AppendString(dst, *val)
|
||||
|
@ -220,13 +205,13 @@ func appendFieldList(dst []byte, kvList []interface{}, stack bool) []byte {
|
|||
}
|
||||
case *float32:
|
||||
if val != nil {
|
||||
dst = enc.AppendFloat32(dst, *val, FloatingPointPrecision)
|
||||
dst = enc.AppendFloat32(dst, *val)
|
||||
} else {
|
||||
dst = enc.AppendNil(dst)
|
||||
}
|
||||
case *float64:
|
||||
if val != nil {
|
||||
dst = enc.AppendFloat64(dst, *val, FloatingPointPrecision)
|
||||
dst = enc.AppendFloat64(dst, *val)
|
||||
} else {
|
||||
dst = enc.AppendNil(dst)
|
||||
}
|
||||
|
@ -238,7 +223,7 @@ func appendFieldList(dst []byte, kvList []interface{}, stack bool) []byte {
|
|||
}
|
||||
case *time.Duration:
|
||||
if val != nil {
|
||||
dst = enc.AppendDuration(dst, *val, DurationFieldUnit, DurationFieldInteger, FloatingPointPrecision)
|
||||
dst = enc.AppendDuration(dst, *val, DurationFieldUnit, DurationFieldInteger)
|
||||
} else {
|
||||
dst = enc.AppendNil(dst)
|
||||
}
|
||||
|
@ -267,13 +252,13 @@ func appendFieldList(dst []byte, kvList []interface{}, stack bool) []byte {
|
|||
case []uint64:
|
||||
dst = enc.AppendUints64(dst, val)
|
||||
case []float32:
|
||||
dst = enc.AppendFloats32(dst, val, FloatingPointPrecision)
|
||||
dst = enc.AppendFloats32(dst, val)
|
||||
case []float64:
|
||||
dst = enc.AppendFloats64(dst, val, FloatingPointPrecision)
|
||||
dst = enc.AppendFloats64(dst, val)
|
||||
case []time.Time:
|
||||
dst = enc.AppendTimes(dst, val, TimeFieldFormat)
|
||||
case []time.Duration:
|
||||
dst = enc.AppendDurations(dst, val, DurationFieldUnit, DurationFieldInteger, FloatingPointPrecision)
|
||||
dst = enc.AppendDurations(dst, val, DurationFieldUnit, DurationFieldInteger)
|
||||
case nil:
|
||||
dst = enc.AppendNil(dst)
|
||||
case net.IP:
|
||||
|
|
52
vendor/github.com/rs/zerolog/globals.go
generated
vendored
52
vendor/github.com/rs/zerolog/globals.go
generated
vendored
|
@ -1,7 +1,6 @@
|
|||
package zerolog
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"sync/atomic"
|
||||
|
@ -82,22 +81,8 @@ var (
|
|||
}
|
||||
|
||||
// InterfaceMarshalFunc allows customization of interface marshaling.
|
||||
// Default: "encoding/json.Marshal" with disabled HTML escaping
|
||||
InterfaceMarshalFunc = func(v interface{}) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
encoder := json.NewEncoder(&buf)
|
||||
encoder.SetEscapeHTML(false)
|
||||
err := encoder.Encode(v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b := buf.Bytes()
|
||||
if len(b) > 0 {
|
||||
// Remove trailing \n which is added by Encode.
|
||||
return b[:len(b)-1], nil
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
// Default: "encoding/json.Marshal"
|
||||
InterfaceMarshalFunc = json.Marshal
|
||||
|
||||
// TimeFieldFormat defines the time format of the Time field type. If set to
|
||||
// TimeFormatUnix, TimeFormatUnixMs, TimeFormatUnixMicro or TimeFormatUnixNano, the time is formatted as a UNIX
|
||||
|
@ -123,39 +108,6 @@ var (
|
|||
// DefaultContextLogger is returned from Ctx() if there is no logger associated
|
||||
// with the context.
|
||||
DefaultContextLogger *Logger
|
||||
|
||||
// LevelColors are used by ConsoleWriter's consoleDefaultFormatLevel to color
|
||||
// log levels.
|
||||
LevelColors = map[Level]int{
|
||||
TraceLevel: colorBlue,
|
||||
DebugLevel: 0,
|
||||
InfoLevel: colorGreen,
|
||||
WarnLevel: colorYellow,
|
||||
ErrorLevel: colorRed,
|
||||
FatalLevel: colorRed,
|
||||
PanicLevel: colorRed,
|
||||
}
|
||||
|
||||
// FormattedLevels are used by ConsoleWriter's consoleDefaultFormatLevel
|
||||
// for a short level name.
|
||||
FormattedLevels = map[Level]string{
|
||||
TraceLevel: "TRC",
|
||||
DebugLevel: "DBG",
|
||||
InfoLevel: "INF",
|
||||
WarnLevel: "WRN",
|
||||
ErrorLevel: "ERR",
|
||||
FatalLevel: "FTL",
|
||||
PanicLevel: "PNC",
|
||||
}
|
||||
|
||||
// TriggerLevelWriterBufferReuseLimit is a limit in bytes that a buffer is dropped
|
||||
// from the TriggerLevelWriter buffer pool if the buffer grows above the limit.
|
||||
TriggerLevelWriterBufferReuseLimit = 64 * 1024
|
||||
|
||||
// FloatingPointPrecision, if set to a value other than -1, controls the number
|
||||
// of digits when formatting float numbers in JSON. See strconv.FormatFloat for
|
||||
// more details.
|
||||
FloatingPointPrecision = -1
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
2
vendor/github.com/rs/zerolog/internal/cbor/decode_stream.go
generated
vendored
2
vendor/github.com/rs/zerolog/internal/cbor/decode_stream.go
generated
vendored
|
@ -95,7 +95,7 @@ func decodeFloat(src *bufio.Reader) (float64, int) {
|
|||
|
||||
switch minor {
|
||||
case additionalTypeFloat16:
|
||||
panic(fmt.Errorf("float16 is not supported in decodeFloat"))
|
||||
panic(fmt.Errorf("float16 is not suppported in decodeFloat"))
|
||||
|
||||
case additionalTypeFloat32:
|
||||
pb := readNBytes(src, 4)
|
||||
|
|
10
vendor/github.com/rs/zerolog/internal/cbor/time.go
generated
vendored
10
vendor/github.com/rs/zerolog/internal/cbor/time.go
generated
vendored
|
@ -29,7 +29,7 @@ func (e Encoder) appendFloatTimestamp(dst []byte, t time.Time) []byte {
|
|||
nanos := t.Nanosecond()
|
||||
var val float64
|
||||
val = float64(secs)*1.0 + float64(nanos)*1e-9
|
||||
return e.AppendFloat64(dst, val, -1)
|
||||
return e.AppendFloat64(dst, val)
|
||||
}
|
||||
|
||||
// AppendTime encodes and adds a timestamp to the dst byte array.
|
||||
|
@ -64,17 +64,17 @@ func (e Encoder) AppendTimes(dst []byte, vals []time.Time, unused string) []byte
|
|||
// AppendDuration encodes and adds a duration to the dst byte array.
|
||||
// useInt field indicates whether to store the duration as seconds (integer) or
|
||||
// as seconds+nanoseconds (float).
|
||||
func (e Encoder) AppendDuration(dst []byte, d time.Duration, unit time.Duration, useInt bool, unused int) []byte {
|
||||
func (e Encoder) AppendDuration(dst []byte, d time.Duration, unit time.Duration, useInt bool) []byte {
|
||||
if useInt {
|
||||
return e.AppendInt64(dst, int64(d/unit))
|
||||
}
|
||||
return e.AppendFloat64(dst, float64(d)/float64(unit), unused)
|
||||
return e.AppendFloat64(dst, float64(d)/float64(unit))
|
||||
}
|
||||
|
||||
// AppendDurations encodes and adds an array of durations to the dst byte array.
|
||||
// useInt field indicates whether to store the duration as seconds (integer) or
|
||||
// as seconds+nanoseconds (float).
|
||||
func (e Encoder) AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool, unused int) []byte {
|
||||
func (e Encoder) AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool) []byte {
|
||||
major := majorTypeArray
|
||||
l := len(vals)
|
||||
if l == 0 {
|
||||
|
@ -87,7 +87,7 @@ func (e Encoder) AppendDurations(dst []byte, vals []time.Duration, unit time.Dur
|
|||
dst = appendCborTypePrefix(dst, major, uint64(l))
|
||||
}
|
||||
for _, d := range vals {
|
||||
dst = e.AppendDuration(dst, d, unit, useInt, unused)
|
||||
dst = e.AppendDuration(dst, d, unit, useInt)
|
||||
}
|
||||
return dst
|
||||
}
|
||||
|
|
12
vendor/github.com/rs/zerolog/internal/cbor/types.go
generated
vendored
12
vendor/github.com/rs/zerolog/internal/cbor/types.go
generated
vendored
|
@ -352,7 +352,7 @@ func (e Encoder) AppendUints64(dst []byte, vals []uint64) []byte {
|
|||
}
|
||||
|
||||
// AppendFloat32 encodes and inserts a single precision float value into the dst byte array.
|
||||
func (Encoder) AppendFloat32(dst []byte, val float32, unused int) []byte {
|
||||
func (Encoder) AppendFloat32(dst []byte, val float32) []byte {
|
||||
switch {
|
||||
case math.IsNaN(float64(val)):
|
||||
return append(dst, "\xfa\x7f\xc0\x00\x00"...)
|
||||
|
@ -372,7 +372,7 @@ func (Encoder) AppendFloat32(dst []byte, val float32, unused int) []byte {
|
|||
}
|
||||
|
||||
// AppendFloats32 encodes and inserts an array of single precision float value into the dst byte array.
|
||||
func (e Encoder) AppendFloats32(dst []byte, vals []float32, unused int) []byte {
|
||||
func (e Encoder) AppendFloats32(dst []byte, vals []float32) []byte {
|
||||
major := majorTypeArray
|
||||
l := len(vals)
|
||||
if l == 0 {
|
||||
|
@ -385,13 +385,13 @@ func (e Encoder) AppendFloats32(dst []byte, vals []float32, unused int) []byte {
|
|||
dst = appendCborTypePrefix(dst, major, uint64(l))
|
||||
}
|
||||
for _, v := range vals {
|
||||
dst = e.AppendFloat32(dst, v, unused)
|
||||
dst = e.AppendFloat32(dst, v)
|
||||
}
|
||||
return dst
|
||||
}
|
||||
|
||||
// AppendFloat64 encodes and inserts a double precision float value into the dst byte array.
|
||||
func (Encoder) AppendFloat64(dst []byte, val float64, unused int) []byte {
|
||||
func (Encoder) AppendFloat64(dst []byte, val float64) []byte {
|
||||
switch {
|
||||
case math.IsNaN(val):
|
||||
return append(dst, "\xfb\x7f\xf8\x00\x00\x00\x00\x00\x00"...)
|
||||
|
@ -412,7 +412,7 @@ func (Encoder) AppendFloat64(dst []byte, val float64, unused int) []byte {
|
|||
}
|
||||
|
||||
// AppendFloats64 encodes and inserts an array of double precision float values into the dst byte array.
|
||||
func (e Encoder) AppendFloats64(dst []byte, vals []float64, unused int) []byte {
|
||||
func (e Encoder) AppendFloats64(dst []byte, vals []float64) []byte {
|
||||
major := majorTypeArray
|
||||
l := len(vals)
|
||||
if l == 0 {
|
||||
|
@ -425,7 +425,7 @@ func (e Encoder) AppendFloats64(dst []byte, vals []float64, unused int) []byte {
|
|||
dst = appendCborTypePrefix(dst, major, uint64(l))
|
||||
}
|
||||
for _, v := range vals {
|
||||
dst = e.AppendFloat64(dst, v, unused)
|
||||
dst = e.AppendFloat64(dst, v)
|
||||
}
|
||||
return dst
|
||||
}
|
||||
|
|
10
vendor/github.com/rs/zerolog/internal/json/time.go
generated
vendored
10
vendor/github.com/rs/zerolog/internal/json/time.go
generated
vendored
|
@ -88,24 +88,24 @@ func appendUnixNanoTimes(dst []byte, vals []time.Time, div int64) []byte {
|
|||
|
||||
// AppendDuration formats the input duration with the given unit & format
|
||||
// and appends the encoded string to the input byte slice.
|
||||
func (e Encoder) AppendDuration(dst []byte, d time.Duration, unit time.Duration, useInt bool, precision int) []byte {
|
||||
func (e Encoder) AppendDuration(dst []byte, d time.Duration, unit time.Duration, useInt bool) []byte {
|
||||
if useInt {
|
||||
return strconv.AppendInt(dst, int64(d/unit), 10)
|
||||
}
|
||||
return e.AppendFloat64(dst, float64(d)/float64(unit), precision)
|
||||
return e.AppendFloat64(dst, float64(d)/float64(unit))
|
||||
}
|
||||
|
||||
// AppendDurations formats the input durations with the given unit & format
|
||||
// and appends the encoded string list to the input byte slice.
|
||||
func (e Encoder) AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool, precision int) []byte {
|
||||
func (e Encoder) AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool) []byte {
|
||||
if len(vals) == 0 {
|
||||
return append(dst, '[', ']')
|
||||
}
|
||||
dst = append(dst, '[')
|
||||
dst = e.AppendDuration(dst, vals[0], unit, useInt, precision)
|
||||
dst = e.AppendDuration(dst, vals[0], unit, useInt)
|
||||
if len(vals) > 1 {
|
||||
for _, d := range vals[1:] {
|
||||
dst = e.AppendDuration(append(dst, ','), d, unit, useInt, precision)
|
||||
dst = e.AppendDuration(append(dst, ','), d, unit, useInt)
|
||||
}
|
||||
}
|
||||
dst = append(dst, ']')
|
||||
|
|
45
vendor/github.com/rs/zerolog/internal/json/types.go
generated
vendored
45
vendor/github.com/rs/zerolog/internal/json/types.go
generated
vendored
|
@ -299,7 +299,7 @@ func (Encoder) AppendUints64(dst []byte, vals []uint64) []byte {
|
|||
return dst
|
||||
}
|
||||
|
||||
func appendFloat(dst []byte, val float64, bitSize, precision int) []byte {
|
||||
func appendFloat(dst []byte, val float64, bitSize int) []byte {
|
||||
// JSON does not permit NaN or Infinity. A typical JSON encoder would fail
|
||||
// with an error, but a logging library wants the data to get through so we
|
||||
// make a tradeoff and store those types as string.
|
||||
|
@ -311,47 +311,26 @@ func appendFloat(dst []byte, val float64, bitSize, precision int) []byte {
|
|||
case math.IsInf(val, -1):
|
||||
return append(dst, `"-Inf"`...)
|
||||
}
|
||||
// convert as if by es6 number to string conversion
|
||||
// see also https://cs.opensource.google/go/go/+/refs/tags/go1.20.3:src/encoding/json/encode.go;l=573
|
||||
strFmt := byte('f')
|
||||
// If precision is set to a value other than -1, we always just format the float using that precision.
|
||||
if precision == -1 {
|
||||
// Use float32 comparisons for underlying float32 value to get precise cutoffs right.
|
||||
if abs := math.Abs(val); abs != 0 {
|
||||
if bitSize == 64 && (abs < 1e-6 || abs >= 1e21) || bitSize == 32 && (float32(abs) < 1e-6 || float32(abs) >= 1e21) {
|
||||
strFmt = 'e'
|
||||
}
|
||||
}
|
||||
}
|
||||
dst = strconv.AppendFloat(dst, val, strFmt, precision, bitSize)
|
||||
if strFmt == 'e' {
|
||||
// Clean up e-09 to e-9
|
||||
n := len(dst)
|
||||
if n >= 4 && dst[n-4] == 'e' && dst[n-3] == '-' && dst[n-2] == '0' {
|
||||
dst[n-2] = dst[n-1]
|
||||
dst = dst[:n-1]
|
||||
}
|
||||
}
|
||||
return dst
|
||||
return strconv.AppendFloat(dst, val, 'f', -1, bitSize)
|
||||
}
|
||||
|
||||
// AppendFloat32 converts the input float32 to a string and
|
||||
// appends the encoded string to the input byte slice.
|
||||
func (Encoder) AppendFloat32(dst []byte, val float32, precision int) []byte {
|
||||
return appendFloat(dst, float64(val), 32, precision)
|
||||
func (Encoder) AppendFloat32(dst []byte, val float32) []byte {
|
||||
return appendFloat(dst, float64(val), 32)
|
||||
}
|
||||
|
||||
// AppendFloats32 encodes the input float32s to json and
|
||||
// appends the encoded string list to the input byte slice.
|
||||
func (Encoder) AppendFloats32(dst []byte, vals []float32, precision int) []byte {
|
||||
func (Encoder) AppendFloats32(dst []byte, vals []float32) []byte {
|
||||
if len(vals) == 0 {
|
||||
return append(dst, '[', ']')
|
||||
}
|
||||
dst = append(dst, '[')
|
||||
dst = appendFloat(dst, float64(vals[0]), 32, precision)
|
||||
dst = appendFloat(dst, float64(vals[0]), 32)
|
||||
if len(vals) > 1 {
|
||||
for _, val := range vals[1:] {
|
||||
dst = appendFloat(append(dst, ','), float64(val), 32, precision)
|
||||
dst = appendFloat(append(dst, ','), float64(val), 32)
|
||||
}
|
||||
}
|
||||
dst = append(dst, ']')
|
||||
|
@ -360,21 +339,21 @@ func (Encoder) AppendFloats32(dst []byte, vals []float32, precision int) []byte
|
|||
|
||||
// AppendFloat64 converts the input float64 to a string and
|
||||
// appends the encoded string to the input byte slice.
|
||||
func (Encoder) AppendFloat64(dst []byte, val float64, precision int) []byte {
|
||||
return appendFloat(dst, val, 64, precision)
|
||||
func (Encoder) AppendFloat64(dst []byte, val float64) []byte {
|
||||
return appendFloat(dst, val, 64)
|
||||
}
|
||||
|
||||
// AppendFloats64 encodes the input float64s to json and
|
||||
// appends the encoded string list to the input byte slice.
|
||||
func (Encoder) AppendFloats64(dst []byte, vals []float64, precision int) []byte {
|
||||
func (Encoder) AppendFloats64(dst []byte, vals []float64) []byte {
|
||||
if len(vals) == 0 {
|
||||
return append(dst, '[', ']')
|
||||
}
|
||||
dst = append(dst, '[')
|
||||
dst = appendFloat(dst, vals[0], 64, precision)
|
||||
dst = appendFloat(dst, vals[0], 64)
|
||||
if len(vals) > 1 {
|
||||
for _, val := range vals[1:] {
|
||||
dst = appendFloat(append(dst, ','), val, 64, precision)
|
||||
dst = appendFloat(append(dst, ','), val, 64)
|
||||
}
|
||||
}
|
||||
dst = append(dst, ']')
|
||||
|
|
34
vendor/github.com/rs/zerolog/log.go
generated
vendored
34
vendor/github.com/rs/zerolog/log.go
generated
vendored
|
@ -24,7 +24,7 @@
|
|||
//
|
||||
// Sub-loggers let you chain loggers with additional context:
|
||||
//
|
||||
// sublogger := log.With().Str("component", "foo").Logger()
|
||||
// sublogger := log.With().Str("component": "foo").Logger()
|
||||
// sublogger.Info().Msg("hello world")
|
||||
// // Output: {"time":1494567715,"level":"info","message":"hello world","component":"foo"}
|
||||
//
|
||||
|
@ -118,6 +118,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -245,7 +246,7 @@ type Logger struct {
|
|||
// you may consider using sync wrapper.
|
||||
func New(w io.Writer) Logger {
|
||||
if w == nil {
|
||||
w = io.Discard
|
||||
w = ioutil.Discard
|
||||
}
|
||||
lw, ok := w.(LevelWriter)
|
||||
if !ok {
|
||||
|
@ -325,13 +326,10 @@ func (l Logger) Sample(s Sampler) Logger {
|
|||
}
|
||||
|
||||
// Hook returns a logger with the h Hook.
|
||||
func (l Logger) Hook(hooks ...Hook) Logger {
|
||||
if len(hooks) == 0 {
|
||||
return l
|
||||
}
|
||||
newHooks := make([]Hook, len(l.hooks), len(l.hooks)+len(hooks))
|
||||
func (l Logger) Hook(h Hook) Logger {
|
||||
newHooks := make([]Hook, len(l.hooks), len(l.hooks)+1)
|
||||
copy(newHooks, l.hooks)
|
||||
l.hooks = append(newHooks, hooks...)
|
||||
l.hooks = append(newHooks, h)
|
||||
return l
|
||||
}
|
||||
|
||||
|
@ -387,14 +385,7 @@ func (l *Logger) Err(err error) *Event {
|
|||
//
|
||||
// You must call Msg on the returned event in order to send the event.
|
||||
func (l *Logger) Fatal() *Event {
|
||||
return l.newEvent(FatalLevel, func(msg string) {
|
||||
if closer, ok := l.w.(io.Closer); ok {
|
||||
// Close the writer to flush any buffered message. Otherwise the message
|
||||
// will be lost as os.Exit() terminates the program immediately.
|
||||
closer.Close()
|
||||
}
|
||||
os.Exit(1)
|
||||
})
|
||||
return l.newEvent(FatalLevel, func(msg string) { os.Exit(1) })
|
||||
}
|
||||
|
||||
// Panic starts a new message with panic level. The panic() function
|
||||
|
@ -459,14 +450,6 @@ func (l *Logger) Printf(format string, v ...interface{}) {
|
|||
}
|
||||
}
|
||||
|
||||
// Println sends a log event using debug level and no extra field.
|
||||
// Arguments are handled in the manner of fmt.Println.
|
||||
func (l *Logger) Println(v ...interface{}) {
|
||||
if e := l.Debug(); e.Enabled() {
|
||||
e.CallerSkipFrame(1).Msg(fmt.Sprintln(v...))
|
||||
}
|
||||
}
|
||||
|
||||
// Write implements the io.Writer interface. This is useful to set as a writer
|
||||
// for the standard library log.
|
||||
func (l Logger) Write(p []byte) (n int, err error) {
|
||||
|
@ -505,9 +488,6 @@ func (l *Logger) newEvent(level Level, done func(string)) *Event {
|
|||
|
||||
// should returns true if the log event should be logged.
|
||||
func (l *Logger) should(lvl Level) bool {
|
||||
if l.w == nil {
|
||||
return false
|
||||
}
|
||||
if lvl < l.level || lvl < GlobalLevel() {
|
||||
return false
|
||||
}
|
||||
|
|
BIN
vendor/github.com/rs/zerolog/pretty.png
generated
vendored
BIN
vendor/github.com/rs/zerolog/pretty.png
generated
vendored
Binary file not shown.
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 82 KiB |
2
vendor/github.com/rs/zerolog/sampler.go
generated
vendored
2
vendor/github.com/rs/zerolog/sampler.go
generated
vendored
|
@ -84,7 +84,7 @@ func (s *BurstSampler) Sample(lvl Level) bool {
|
|||
}
|
||||
|
||||
func (s *BurstSampler) inc() uint32 {
|
||||
now := TimestampFunc().UnixNano()
|
||||
now := time.Now().UnixNano()
|
||||
resetAt := atomic.LoadInt64(&s.resetAt)
|
||||
var c uint32
|
||||
if now > resetAt {
|
||||
|
|
9
vendor/github.com/rs/zerolog/syslog.go
generated
vendored
9
vendor/github.com/rs/zerolog/syslog.go
generated
vendored
|
@ -78,12 +78,3 @@ func (sw syslogWriter) WriteLevel(level Level, p []byte) (n int, err error) {
|
|||
n = len(p)
|
||||
return
|
||||
}
|
||||
|
||||
// Call the underlying writer's Close method if it is an io.Closer. Otherwise
|
||||
// does nothing.
|
||||
func (sw syslogWriter) Close() error {
|
||||
if c, ok := sw.w.(io.Closer); ok {
|
||||
return c.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
164
vendor/github.com/rs/zerolog/writer.go
generated
vendored
164
vendor/github.com/rs/zerolog/writer.go
generated
vendored
|
@ -27,15 +27,6 @@ func (lw LevelWriterAdapter) WriteLevel(l Level, p []byte) (n int, err error) {
|
|||
return lw.Write(p)
|
||||
}
|
||||
|
||||
// Call the underlying writer's Close method if it is an io.Closer. Otherwise
|
||||
// does nothing.
|
||||
func (lw LevelWriterAdapter) Close() error {
|
||||
if closer, ok := lw.Writer.(io.Closer); ok {
|
||||
return closer.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type syncWriter struct {
|
||||
mu sync.Mutex
|
||||
lw LevelWriter
|
||||
|
@ -66,15 +57,6 @@ func (s *syncWriter) WriteLevel(l Level, p []byte) (n int, err error) {
|
|||
return s.lw.WriteLevel(l, p)
|
||||
}
|
||||
|
||||
func (s *syncWriter) Close() error {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if closer, ok := s.lw.(io.Closer); ok {
|
||||
return closer.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type multiLevelWriter struct {
|
||||
writers []LevelWriter
|
||||
}
|
||||
|
@ -107,20 +89,6 @@ func (t multiLevelWriter) WriteLevel(l Level, p []byte) (n int, err error) {
|
|||
return n, err
|
||||
}
|
||||
|
||||
// Calls close on all the underlying writers that are io.Closers. If any of the
|
||||
// Close methods return an error, the remainder of the closers are not closed
|
||||
// and the error is returned.
|
||||
func (t multiLevelWriter) Close() error {
|
||||
for _, w := range t.writers {
|
||||
if closer, ok := w.(io.Closer); ok {
|
||||
if err := closer.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MultiLevelWriter creates a writer that duplicates its writes to all the
|
||||
// provided writers, similar to the Unix tee(1) command. If some writers
|
||||
// implement LevelWriter, their WriteLevel method will be used instead of Write.
|
||||
|
@ -212,135 +180,3 @@ func (w *FilteredLevelWriter) WriteLevel(level Level, p []byte) (int, error) {
|
|||
}
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
var triggerWriterPool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
return bytes.NewBuffer(make([]byte, 0, 1024))
|
||||
},
|
||||
}
|
||||
|
||||
// TriggerLevelWriter buffers log lines at the ConditionalLevel or below
|
||||
// until a trigger level (or higher) line is emitted. Log lines with level
|
||||
// higher than ConditionalLevel are always written out to the destination
|
||||
// writer. If trigger never happens, buffered log lines are never written out.
|
||||
//
|
||||
// It can be used to configure "log level per request".
|
||||
type TriggerLevelWriter struct {
|
||||
// Destination writer. If LevelWriter is provided (usually), its WriteLevel is used
|
||||
// instead of Write.
|
||||
io.Writer
|
||||
|
||||
// ConditionalLevel is the level (and below) at which lines are buffered until
|
||||
// a trigger level (or higher) line is emitted. Usually this is set to DebugLevel.
|
||||
ConditionalLevel Level
|
||||
|
||||
// TriggerLevel is the lowest level that triggers the sending of the conditional
|
||||
// level lines. Usually this is set to ErrorLevel.
|
||||
TriggerLevel Level
|
||||
|
||||
buf *bytes.Buffer
|
||||
triggered bool
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (w *TriggerLevelWriter) WriteLevel(l Level, p []byte) (n int, err error) {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
|
||||
// At first trigger level or above log line, we flush the buffer and change the
|
||||
// trigger state to triggered.
|
||||
if !w.triggered && l >= w.TriggerLevel {
|
||||
err := w.trigger()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
|
||||
// Unless triggered, we buffer everything at and below ConditionalLevel.
|
||||
if !w.triggered && l <= w.ConditionalLevel {
|
||||
if w.buf == nil {
|
||||
w.buf = triggerWriterPool.Get().(*bytes.Buffer)
|
||||
}
|
||||
|
||||
// We prefix each log line with a byte with the level.
|
||||
// Hopefully we will never have a level value which equals a newline
|
||||
// (which could interfere with reconstruction of log lines in the trigger method).
|
||||
w.buf.WriteByte(byte(l))
|
||||
w.buf.Write(p)
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
// Anything above ConditionalLevel is always passed through.
|
||||
// Once triggered, everything is passed through.
|
||||
if lw, ok := w.Writer.(LevelWriter); ok {
|
||||
return lw.WriteLevel(l, p)
|
||||
}
|
||||
return w.Write(p)
|
||||
}
|
||||
|
||||
// trigger expects lock to be held.
|
||||
func (w *TriggerLevelWriter) trigger() error {
|
||||
if w.triggered {
|
||||
return nil
|
||||
}
|
||||
w.triggered = true
|
||||
|
||||
if w.buf == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
p := w.buf.Bytes()
|
||||
for len(p) > 0 {
|
||||
// We do not use bufio.Scanner here because we already have full buffer
|
||||
// in the memory and we do not want extra copying from the buffer to
|
||||
// scanner's token slice, nor we want to hit scanner's token size limit,
|
||||
// and we also want to preserve newlines.
|
||||
i := bytes.IndexByte(p, '\n')
|
||||
line := p[0 : i+1]
|
||||
p = p[i+1:]
|
||||
// We prefixed each log line with a byte with the level.
|
||||
level := Level(line[0])
|
||||
line = line[1:]
|
||||
var err error
|
||||
if lw, ok := w.Writer.(LevelWriter); ok {
|
||||
_, err = lw.WriteLevel(level, line)
|
||||
} else {
|
||||
_, err = w.Write(line)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Trigger forces flushing the buffer and change the trigger state to
|
||||
// triggered, if the writer has not already been triggered before.
|
||||
func (w *TriggerLevelWriter) Trigger() error {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
|
||||
return w.trigger()
|
||||
}
|
||||
|
||||
// Close closes the writer and returns the buffer to the pool.
|
||||
func (w *TriggerLevelWriter) Close() error {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
|
||||
if w.buf == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// We return the buffer only if it has not grown above the limit.
|
||||
// This prevents accumulation of large buffers in the pool just
|
||||
// because occasionally a large buffer might be needed.
|
||||
if w.buf.Cap() <= TriggerLevelWriterBufferReuseLimit {
|
||||
w.buf.Reset()
|
||||
triggerWriterPool.Put(w.buf)
|
||||
}
|
||||
w.buf = nil
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
1
vendor/github.com/urfave/cli/v2/.gitignore
generated
vendored
1
vendor/github.com/urfave/cli/v2/.gitignore
generated
vendored
|
@ -4,7 +4,6 @@
|
|||
.*envrc
|
||||
.envrc
|
||||
.idea
|
||||
# goimports is installed here if not available
|
||||
/.local/
|
||||
/site/
|
||||
coverage.txt
|
||||
|
|
4
vendor/github.com/urfave/cli/v2/.golangci.yaml
generated
vendored
4
vendor/github.com/urfave/cli/v2/.golangci.yaml
generated
vendored
|
@ -1,4 +0,0 @@
|
|||
# https://golangci-lint.run/usage/configuration/
|
||||
linters:
|
||||
enable:
|
||||
- misspell
|
40
vendor/github.com/urfave/cli/v2/app.go
generated
vendored
40
vendor/github.com/urfave/cli/v2/app.go
generated
vendored
|
@ -23,8 +23,8 @@ var (
|
|||
fmt.Sprintf("See %s", appActionDeprecationURL), 2)
|
||||
ignoreFlagPrefix = "test." // this is to ignore test flags when adding flags from other packages
|
||||
|
||||
SuggestFlag SuggestFlagFunc = nil // initialized in suggestions.go unless built with urfave_cli_no_suggest
|
||||
SuggestCommand SuggestCommandFunc = nil // initialized in suggestions.go unless built with urfave_cli_no_suggest
|
||||
SuggestFlag SuggestFlagFunc = suggestFlag
|
||||
SuggestCommand SuggestCommandFunc = suggestCommand
|
||||
SuggestDidYouMeanTemplate string = suggestDidYouMeanTemplate
|
||||
)
|
||||
|
||||
|
@ -39,8 +39,6 @@ type App struct {
|
|||
Usage string
|
||||
// Text to override the USAGE section of help
|
||||
UsageText string
|
||||
// Whether this command supports arguments
|
||||
Args bool
|
||||
// Description of the program argument format.
|
||||
ArgsUsage string
|
||||
// Version of the program
|
||||
|
@ -229,6 +227,8 @@ func (a *App) Setup() {
|
|||
a.separator.disabled = true
|
||||
}
|
||||
|
||||
var newCommands []*Command
|
||||
|
||||
for _, c := range a.Commands {
|
||||
cname := c.Name
|
||||
if c.HelpName != "" {
|
||||
|
@ -237,7 +237,9 @@ func (a *App) Setup() {
|
|||
c.separator = a.separator
|
||||
c.HelpName = fmt.Sprintf("%s %s", a.HelpName, cname)
|
||||
c.flagCategories = newFlagCategoriesFromFlags(c.Flags)
|
||||
newCommands = append(newCommands, c)
|
||||
}
|
||||
a.Commands = newCommands
|
||||
|
||||
if a.Command(helpCommand.Name) == nil && !a.HideHelp {
|
||||
if !a.HideHelpCommand {
|
||||
|
@ -327,9 +329,6 @@ func (a *App) RunContext(ctx context.Context, arguments []string) (err error) {
|
|||
a.rootCommand = a.newRootCommand()
|
||||
cCtx.Command = a.rootCommand
|
||||
|
||||
if err := checkDuplicatedCmds(a.rootCommand); err != nil {
|
||||
return err
|
||||
}
|
||||
return a.rootCommand.Run(cCtx, arguments...)
|
||||
}
|
||||
|
||||
|
@ -364,9 +363,6 @@ func (a *App) suggestFlagFromError(err error, command string) (string, error) {
|
|||
hideHelp = hideHelp || cmd.HideHelp
|
||||
}
|
||||
|
||||
if SuggestFlag == nil {
|
||||
return "", err
|
||||
}
|
||||
suggestion := SuggestFlag(flags, flag, hideHelp)
|
||||
if len(suggestion) == 0 {
|
||||
return "", err
|
||||
|
@ -459,6 +455,30 @@ func (a *App) handleExitCoder(cCtx *Context, err error) {
|
|||
}
|
||||
}
|
||||
|
||||
func (a *App) commandNames() []string {
|
||||
var cmdNames []string
|
||||
|
||||
for _, cmd := range a.Commands {
|
||||
cmdNames = append(cmdNames, cmd.Names()...)
|
||||
}
|
||||
|
||||
return cmdNames
|
||||
}
|
||||
|
||||
func (a *App) validCommandName(checkCmdName string) bool {
|
||||
valid := false
|
||||
allCommandNames := a.commandNames()
|
||||
|
||||
for _, cmdName := range allCommandNames {
|
||||
if checkCmdName == cmdName {
|
||||
valid = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return valid
|
||||
}
|
||||
|
||||
func (a *App) argsWithDefaultCommand(oldArgs Args) Args {
|
||||
if a.DefaultCommand != "" {
|
||||
rawArgs := append([]string{a.DefaultCommand}, oldArgs.Slice()...)
|
||||
|
|
6
vendor/github.com/urfave/cli/v2/category.go
generated
vendored
6
vendor/github.com/urfave/cli/v2/category.go
generated
vendored
|
@ -104,17 +104,17 @@ func newFlagCategoriesFromFlags(fs []Flag) FlagCategories {
|
|||
var categorized bool
|
||||
for _, fl := range fs {
|
||||
if cf, ok := fl.(CategorizableFlag); ok {
|
||||
if cat := cf.GetCategory(); cat != "" && cf.IsVisible() {
|
||||
if cat := cf.GetCategory(); cat != "" {
|
||||
fc.AddFlag(cat, cf)
|
||||
categorized = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if categorized {
|
||||
if categorized == true {
|
||||
for _, fl := range fs {
|
||||
if cf, ok := fl.(CategorizableFlag); ok {
|
||||
if cf.GetCategory() == "" && cf.IsVisible() {
|
||||
if cf.GetCategory() == "" {
|
||||
fc.AddFlag("", fl)
|
||||
}
|
||||
}
|
||||
|
|
21
vendor/github.com/urfave/cli/v2/command.go
generated
vendored
21
vendor/github.com/urfave/cli/v2/command.go
generated
vendored
|
@ -20,8 +20,6 @@ type Command struct {
|
|||
UsageText string
|
||||
// A longer explanation of how the command works
|
||||
Description string
|
||||
// Whether this command supports arguments
|
||||
Args bool
|
||||
// A short description of the arguments of this command
|
||||
ArgsUsage string
|
||||
// The category the command is part of
|
||||
|
@ -132,12 +130,15 @@ func (c *Command) setup(ctx *Context) {
|
|||
}
|
||||
sort.Sort(c.categories.(*commandCategories))
|
||||
|
||||
var newCmds []*Command
|
||||
for _, scmd := range c.Subcommands {
|
||||
if scmd.HelpName == "" {
|
||||
scmd.HelpName = fmt.Sprintf("%s %s", c.HelpName, scmd.Name)
|
||||
}
|
||||
scmd.separator = c.separator
|
||||
newCmds = append(newCmds, scmd)
|
||||
}
|
||||
c.Subcommands = newCmds
|
||||
|
||||
if c.BashComplete == nil {
|
||||
c.BashComplete = DefaultCompleteWithFlags(c)
|
||||
|
@ -148,9 +149,6 @@ func (c *Command) Run(cCtx *Context, arguments ...string) (err error) {
|
|||
|
||||
if !c.isRoot {
|
||||
c.setup(cCtx)
|
||||
if err := checkDuplicatedCmds(c); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
a := args(arguments)
|
||||
|
@ -406,16 +404,3 @@ func hasCommand(commands []*Command, command *Command) bool {
|
|||
|
||||
return false
|
||||
}
|
||||
|
||||
func checkDuplicatedCmds(parent *Command) error {
|
||||
seen := make(map[string]struct{})
|
||||
for _, c := range parent.Subcommands {
|
||||
for _, name := range c.Names() {
|
||||
if _, exists := seen[name]; exists {
|
||||
return fmt.Errorf("parent command [%s] has duplicated subcommand name or alias: %s", parent.Name, name)
|
||||
}
|
||||
seen[name] = struct{}{}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
2
vendor/github.com/urfave/cli/v2/context.go
generated
vendored
2
vendor/github.com/urfave/cli/v2/context.go
generated
vendored
|
@ -144,7 +144,7 @@ func (cCtx *Context) Lineage() []*Context {
|
|||
return lineage
|
||||
}
|
||||
|
||||
// Count returns the num of occurrences of this flag
|
||||
// Count returns the num of occurences of this flag
|
||||
func (cCtx *Context) Count(name string) int {
|
||||
if fs := cCtx.lookupFlagSet(name); fs != nil {
|
||||
if cf, ok := fs.Lookup(name).Value.(Countable); ok {
|
||||
|
|
6
vendor/github.com/urfave/cli/v2/flag_bool.go
generated
vendored
6
vendor/github.com/urfave/cli/v2/flag_bool.go
generated
vendored
|
@ -84,10 +84,7 @@ func (f *BoolFlag) GetDefaultText() string {
|
|||
if f.DefaultText != "" {
|
||||
return f.DefaultText
|
||||
}
|
||||
if f.defaultValueSet {
|
||||
return fmt.Sprintf("%v", f.defaultValue)
|
||||
}
|
||||
return fmt.Sprintf("%v", f.Value)
|
||||
return fmt.Sprintf("%v", f.defaultValue)
|
||||
}
|
||||
|
||||
// GetEnvVars returns the env vars for this flag
|
||||
|
@ -108,7 +105,6 @@ func (f *BoolFlag) RunAction(c *Context) error {
|
|||
func (f *BoolFlag) Apply(set *flag.FlagSet) error {
|
||||
// set default value so that environment wont be able to overwrite it
|
||||
f.defaultValue = f.Value
|
||||
f.defaultValueSet = true
|
||||
|
||||
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
||||
if val != "" {
|
||||
|
|
6
vendor/github.com/urfave/cli/v2/flag_duration.go
generated
vendored
6
vendor/github.com/urfave/cli/v2/flag_duration.go
generated
vendored
|
@ -32,10 +32,7 @@ func (f *DurationFlag) GetDefaultText() string {
|
|||
if f.DefaultText != "" {
|
||||
return f.DefaultText
|
||||
}
|
||||
if f.defaultValueSet {
|
||||
return f.defaultValue.String()
|
||||
}
|
||||
return f.Value.String()
|
||||
return f.defaultValue.String()
|
||||
}
|
||||
|
||||
// GetEnvVars returns the env vars for this flag
|
||||
|
@ -47,7 +44,6 @@ func (f *DurationFlag) GetEnvVars() []string {
|
|||
func (f *DurationFlag) Apply(set *flag.FlagSet) error {
|
||||
// set default value so that environment wont be able to overwrite it
|
||||
f.defaultValue = f.Value
|
||||
f.defaultValueSet = true
|
||||
|
||||
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
||||
if val != "" {
|
||||
|
|
8
vendor/github.com/urfave/cli/v2/flag_float64.go
generated
vendored
8
vendor/github.com/urfave/cli/v2/flag_float64.go
generated
vendored
|
@ -32,10 +32,7 @@ func (f *Float64Flag) GetDefaultText() string {
|
|||
if f.DefaultText != "" {
|
||||
return f.DefaultText
|
||||
}
|
||||
if f.defaultValueSet {
|
||||
return fmt.Sprintf("%v", f.defaultValue)
|
||||
}
|
||||
return fmt.Sprintf("%v", f.Value)
|
||||
return f.GetValue()
|
||||
}
|
||||
|
||||
// GetEnvVars returns the env vars for this flag
|
||||
|
@ -45,9 +42,6 @@ func (f *Float64Flag) GetEnvVars() []string {
|
|||
|
||||
// Apply populates the flag given the flag set and environment
|
||||
func (f *Float64Flag) Apply(set *flag.FlagSet) error {
|
||||
f.defaultValue = f.Value
|
||||
f.defaultValueSet = true
|
||||
|
||||
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
||||
if val != "" {
|
||||
valFloat, err := strconv.ParseFloat(val, 64)
|
||||
|
|
11
vendor/github.com/urfave/cli/v2/flag_generic.go
generated
vendored
11
vendor/github.com/urfave/cli/v2/flag_generic.go
generated
vendored
|
@ -53,15 +53,9 @@ func (f *GenericFlag) GetDefaultText() string {
|
|||
if f.DefaultText != "" {
|
||||
return f.DefaultText
|
||||
}
|
||||
val := f.Value
|
||||
if f.defaultValueSet {
|
||||
val = f.defaultValue
|
||||
if f.defaultValue != nil {
|
||||
return f.defaultValue.String()
|
||||
}
|
||||
|
||||
if val != nil {
|
||||
return val.String()
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -76,7 +70,6 @@ func (f *GenericFlag) Apply(set *flag.FlagSet) error {
|
|||
// set default value so that environment wont be able to overwrite it
|
||||
if f.Value != nil {
|
||||
f.defaultValue = &stringGeneric{value: f.Value.String()}
|
||||
f.defaultValueSet = true
|
||||
}
|
||||
|
||||
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
||||
|
|
6
vendor/github.com/urfave/cli/v2/flag_int.go
generated
vendored
6
vendor/github.com/urfave/cli/v2/flag_int.go
generated
vendored
|
@ -32,10 +32,7 @@ func (f *IntFlag) GetDefaultText() string {
|
|||
if f.DefaultText != "" {
|
||||
return f.DefaultText
|
||||
}
|
||||
if f.defaultValueSet {
|
||||
return fmt.Sprintf("%d", f.defaultValue)
|
||||
}
|
||||
return fmt.Sprintf("%d", f.Value)
|
||||
return fmt.Sprintf("%d", f.defaultValue)
|
||||
}
|
||||
|
||||
// GetEnvVars returns the env vars for this flag
|
||||
|
@ -47,7 +44,6 @@ func (f *IntFlag) GetEnvVars() []string {
|
|||
func (f *IntFlag) Apply(set *flag.FlagSet) error {
|
||||
// set default value so that environment wont be able to overwrite it
|
||||
f.defaultValue = f.Value
|
||||
f.defaultValueSet = true
|
||||
|
||||
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
||||
if val != "" {
|
||||
|
|
6
vendor/github.com/urfave/cli/v2/flag_int64.go
generated
vendored
6
vendor/github.com/urfave/cli/v2/flag_int64.go
generated
vendored
|
@ -32,10 +32,7 @@ func (f *Int64Flag) GetDefaultText() string {
|
|||
if f.DefaultText != "" {
|
||||
return f.DefaultText
|
||||
}
|
||||
if f.defaultValueSet {
|
||||
return fmt.Sprintf("%d", f.defaultValue)
|
||||
}
|
||||
return fmt.Sprintf("%d", f.Value)
|
||||
return fmt.Sprintf("%d", f.defaultValue)
|
||||
}
|
||||
|
||||
// GetEnvVars returns the env vars for this flag
|
||||
|
@ -47,7 +44,6 @@ func (f *Int64Flag) GetEnvVars() []string {
|
|||
func (f *Int64Flag) Apply(set *flag.FlagSet) error {
|
||||
// set default value so that environment wont be able to overwrite it
|
||||
f.defaultValue = f.Value
|
||||
f.defaultValueSet = true
|
||||
|
||||
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
||||
if val != "" {
|
||||
|
|
11
vendor/github.com/urfave/cli/v2/flag_path.go
generated
vendored
11
vendor/github.com/urfave/cli/v2/flag_path.go
generated
vendored
|
@ -33,14 +33,10 @@ func (f *PathFlag) GetDefaultText() string {
|
|||
if f.DefaultText != "" {
|
||||
return f.DefaultText
|
||||
}
|
||||
val := f.Value
|
||||
if f.defaultValueSet {
|
||||
val = f.defaultValue
|
||||
if f.defaultValue == "" {
|
||||
return f.defaultValue
|
||||
}
|
||||
if val == "" {
|
||||
return val
|
||||
}
|
||||
return fmt.Sprintf("%q", val)
|
||||
return fmt.Sprintf("%q", f.defaultValue)
|
||||
}
|
||||
|
||||
// GetEnvVars returns the env vars for this flag
|
||||
|
@ -52,7 +48,6 @@ func (f *PathFlag) GetEnvVars() []string {
|
|||
func (f *PathFlag) Apply(set *flag.FlagSet) error {
|
||||
// set default value so that environment wont be able to overwrite it
|
||||
f.defaultValue = f.Value
|
||||
f.defaultValueSet = true
|
||||
|
||||
if val, _, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
||||
f.Value = val
|
||||
|
|
12
vendor/github.com/urfave/cli/v2/flag_string.go
generated
vendored
12
vendor/github.com/urfave/cli/v2/flag_string.go
generated
vendored
|
@ -31,15 +31,10 @@ func (f *StringFlag) GetDefaultText() string {
|
|||
if f.DefaultText != "" {
|
||||
return f.DefaultText
|
||||
}
|
||||
val := f.Value
|
||||
if f.defaultValueSet {
|
||||
val = f.defaultValue
|
||||
if f.defaultValue == "" {
|
||||
return f.defaultValue
|
||||
}
|
||||
|
||||
if val == "" {
|
||||
return val
|
||||
}
|
||||
return fmt.Sprintf("%q", val)
|
||||
return fmt.Sprintf("%q", f.defaultValue)
|
||||
}
|
||||
|
||||
// GetEnvVars returns the env vars for this flag
|
||||
|
@ -51,7 +46,6 @@ func (f *StringFlag) GetEnvVars() []string {
|
|||
func (f *StringFlag) Apply(set *flag.FlagSet) error {
|
||||
// set default value so that environment wont be able to overwrite it
|
||||
f.defaultValue = f.Value
|
||||
f.defaultValueSet = true
|
||||
|
||||
if val, _, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
||||
f.Value = val
|
||||
|
|
10
vendor/github.com/urfave/cli/v2/flag_timestamp.go
generated
vendored
10
vendor/github.com/urfave/cli/v2/flag_timestamp.go
generated
vendored
|
@ -120,13 +120,8 @@ func (f *TimestampFlag) GetDefaultText() string {
|
|||
if f.DefaultText != "" {
|
||||
return f.DefaultText
|
||||
}
|
||||
val := f.Value
|
||||
if f.defaultValueSet {
|
||||
val = f.defaultValue
|
||||
}
|
||||
|
||||
if val != nil && val.timestamp != nil {
|
||||
return val.timestamp.String()
|
||||
if f.defaultValue != nil && f.defaultValue.timestamp != nil {
|
||||
return f.defaultValue.timestamp.String()
|
||||
}
|
||||
|
||||
return ""
|
||||
|
@ -149,7 +144,6 @@ func (f *TimestampFlag) Apply(set *flag.FlagSet) error {
|
|||
f.Value.SetLocation(f.Timezone)
|
||||
|
||||
f.defaultValue = f.Value.clone()
|
||||
f.defaultValueSet = true
|
||||
|
||||
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
||||
if err := f.Value.Set(val); err != nil {
|
||||
|
|
6
vendor/github.com/urfave/cli/v2/flag_uint.go
generated
vendored
6
vendor/github.com/urfave/cli/v2/flag_uint.go
generated
vendored
|
@ -25,7 +25,6 @@ func (f *UintFlag) GetCategory() string {
|
|||
func (f *UintFlag) Apply(set *flag.FlagSet) error {
|
||||
// set default value so that environment wont be able to overwrite it
|
||||
f.defaultValue = f.Value
|
||||
f.defaultValueSet = true
|
||||
|
||||
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
||||
if val != "" {
|
||||
|
@ -70,10 +69,7 @@ func (f *UintFlag) GetDefaultText() string {
|
|||
if f.DefaultText != "" {
|
||||
return f.DefaultText
|
||||
}
|
||||
if f.defaultValueSet {
|
||||
return fmt.Sprintf("%d", f.defaultValue)
|
||||
}
|
||||
return fmt.Sprintf("%d", f.Value)
|
||||
return fmt.Sprintf("%d", f.defaultValue)
|
||||
}
|
||||
|
||||
// GetEnvVars returns the env vars for this flag
|
||||
|
|
6
vendor/github.com/urfave/cli/v2/flag_uint64.go
generated
vendored
6
vendor/github.com/urfave/cli/v2/flag_uint64.go
generated
vendored
|
@ -25,7 +25,6 @@ func (f *Uint64Flag) GetCategory() string {
|
|||
func (f *Uint64Flag) Apply(set *flag.FlagSet) error {
|
||||
// set default value so that environment wont be able to overwrite it
|
||||
f.defaultValue = f.Value
|
||||
f.defaultValueSet = true
|
||||
|
||||
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
||||
if val != "" {
|
||||
|
@ -70,10 +69,7 @@ func (f *Uint64Flag) GetDefaultText() string {
|
|||
if f.DefaultText != "" {
|
||||
return f.DefaultText
|
||||
}
|
||||
if f.defaultValueSet {
|
||||
return fmt.Sprintf("%d", f.defaultValue)
|
||||
}
|
||||
return fmt.Sprintf("%d", f.Value)
|
||||
return fmt.Sprintf("%d", f.defaultValue)
|
||||
}
|
||||
|
||||
// GetEnvVars returns the env vars for this flag
|
||||
|
|
9
vendor/github.com/urfave/cli/v2/flag_uint64_slice.go
generated
vendored
9
vendor/github.com/urfave/cli/v2/flag_uint64_slice.go
generated
vendored
|
@ -190,15 +190,6 @@ func (f *Uint64SliceFlag) Get(ctx *Context) []uint64 {
|
|||
return ctx.Uint64Slice(f.Name)
|
||||
}
|
||||
|
||||
// RunAction executes flag action if set
|
||||
func (f *Uint64SliceFlag) RunAction(c *Context) error {
|
||||
if f.Action != nil {
|
||||
return f.Action(c, c.Uint64Slice(f.Name))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Uint64Slice looks up the value of a local Uint64SliceFlag, returns
|
||||
// nil if not found
|
||||
func (cCtx *Context) Uint64Slice(name string) []uint64 {
|
||||
|
|
9
vendor/github.com/urfave/cli/v2/flag_uint_slice.go
generated
vendored
9
vendor/github.com/urfave/cli/v2/flag_uint_slice.go
generated
vendored
|
@ -201,15 +201,6 @@ func (f *UintSliceFlag) Get(ctx *Context) []uint {
|
|||
return ctx.UintSlice(f.Name)
|
||||
}
|
||||
|
||||
// RunAction executes flag action if set
|
||||
func (f *UintSliceFlag) RunAction(c *Context) error {
|
||||
if f.Action != nil {
|
||||
return f.Action(c, c.UintSlice(f.Name))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UintSlice looks up the value of a local UintSliceFlag, returns
|
||||
// nil if not found
|
||||
func (cCtx *Context) UintSlice(name string) []uint {
|
||||
|
|
20
vendor/github.com/urfave/cli/v2/godoc-current.txt
generated
vendored
20
vendor/github.com/urfave/cli/v2/godoc-current.txt
generated
vendored
|
@ -27,15 +27,15 @@ application:
|
|||
VARIABLES
|
||||
|
||||
var (
|
||||
SuggestFlag SuggestFlagFunc = nil // initialized in suggestions.go unless built with urfave_cli_no_suggest
|
||||
SuggestCommand SuggestCommandFunc = nil // initialized in suggestions.go unless built with urfave_cli_no_suggest
|
||||
SuggestFlag SuggestFlagFunc = suggestFlag
|
||||
SuggestCommand SuggestCommandFunc = suggestCommand
|
||||
SuggestDidYouMeanTemplate string = suggestDidYouMeanTemplate
|
||||
)
|
||||
var AppHelpTemplate = `NAME:
|
||||
{{template "helpNameTemplate" .}}
|
||||
|
||||
USAGE:
|
||||
{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}}{{if .ArgsUsage}} {{.ArgsUsage}}{{else}}{{if .Args}} [arguments...]{{end}}{{end}}{{end}}{{if .Version}}{{if not .HideVersion}}
|
||||
{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Version}}{{if not .HideVersion}}
|
||||
|
||||
VERSION:
|
||||
{{.Version}}{{end}}{{end}}{{if .Description}}
|
||||
|
@ -136,7 +136,7 @@ var SubcommandHelpTemplate = `NAME:
|
|||
{{template "helpNameTemplate" .}}
|
||||
|
||||
USAGE:
|
||||
{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.HelpName}} {{if .VisibleFlags}}command [command options]{{end}}{{if .ArgsUsage}} {{.ArgsUsage}}{{else}}{{if .Args}} [arguments...]{{end}}{{end}}{{end}}{{if .Description}}
|
||||
{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.HelpName}} {{if .VisibleFlags}}command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Description}}
|
||||
|
||||
DESCRIPTION:
|
||||
{{template "descriptionTemplate" .}}{{end}}{{if .VisibleCommands}}
|
||||
|
@ -253,8 +253,6 @@ type App struct {
|
|||
Usage string
|
||||
// Text to override the USAGE section of help
|
||||
UsageText string
|
||||
// Whether this command supports arguments
|
||||
Args bool
|
||||
// Description of the program argument format.
|
||||
ArgsUsage string
|
||||
// Version of the program
|
||||
|
@ -525,8 +523,6 @@ type Command struct {
|
|||
UsageText string
|
||||
// A longer explanation of how the command works
|
||||
Description string
|
||||
// Whether this command supports arguments
|
||||
Args bool
|
||||
// A short description of the arguments of this command
|
||||
ArgsUsage string
|
||||
// The category the command is part of
|
||||
|
@ -653,7 +649,7 @@ func (cCtx *Context) Bool(name string) bool
|
|||
Bool looks up the value of a local BoolFlag, returns false if not found
|
||||
|
||||
func (cCtx *Context) Count(name string) int
|
||||
Count returns the num of occurrences of this flag
|
||||
Count returns the num of occurences of this flag
|
||||
|
||||
func (cCtx *Context) Duration(name string) time.Duration
|
||||
Duration looks up the value of a local DurationFlag, returns 0 if not found
|
||||
|
@ -2146,9 +2142,6 @@ func (f *Uint64SliceFlag) IsVisible() bool
|
|||
func (f *Uint64SliceFlag) Names() []string
|
||||
Names returns the names of the flag
|
||||
|
||||
func (f *Uint64SliceFlag) RunAction(c *Context) error
|
||||
RunAction executes flag action if set
|
||||
|
||||
func (f *Uint64SliceFlag) String() string
|
||||
String returns a readable representation of this value (for usage defaults)
|
||||
|
||||
|
@ -2314,9 +2307,6 @@ func (f *UintSliceFlag) IsVisible() bool
|
|||
func (f *UintSliceFlag) Names() []string
|
||||
Names returns the names of the flag
|
||||
|
||||
func (f *UintSliceFlag) RunAction(c *Context) error
|
||||
RunAction executes flag action if set
|
||||
|
||||
func (f *UintSliceFlag) String() string
|
||||
String returns a readable representation of this value (for usage defaults)
|
||||
|
||||
|
|
69
vendor/github.com/urfave/cli/v2/help.go
generated
vendored
69
vendor/github.com/urfave/cli/v2/help.go
generated
vendored
|
@ -69,7 +69,7 @@ var helpCommand = &Command{
|
|||
}
|
||||
|
||||
// Case 3, 5
|
||||
if (len(cCtx.Command.Subcommands) == 1 && !cCtx.Command.HideHelp && !cCtx.Command.HideHelpCommand) ||
|
||||
if (len(cCtx.Command.Subcommands) == 1 && !cCtx.Command.HideHelp) ||
|
||||
(len(cCtx.Command.Subcommands) == 0 && cCtx.Command.HideHelp) {
|
||||
templ := cCtx.Command.CustomHelpTemplate
|
||||
if templ == "" {
|
||||
|
@ -248,6 +248,7 @@ func ShowCommandHelpAndExit(c *Context, command string, code int) {
|
|||
|
||||
// ShowCommandHelp prints help for the given command
|
||||
func ShowCommandHelp(ctx *Context, command string) error {
|
||||
|
||||
commands := ctx.App.Commands
|
||||
if ctx.Command.Subcommands != nil {
|
||||
commands = ctx.Command.Subcommands
|
||||
|
@ -277,7 +278,7 @@ func ShowCommandHelp(ctx *Context, command string) error {
|
|||
|
||||
if ctx.App.CommandNotFound == nil {
|
||||
errMsg := fmt.Sprintf("No help topic for '%v'", command)
|
||||
if ctx.App.Suggest && SuggestCommand != nil {
|
||||
if ctx.App.Suggest {
|
||||
if suggestion := SuggestCommand(ctx.Command.Subcommands, command); suggestion != "" {
|
||||
errMsg += ". " + suggestion
|
||||
}
|
||||
|
@ -336,6 +337,7 @@ func ShowCommandCompletions(ctx *Context, command string) {
|
|||
DefaultCompleteWithFlags(c)(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// printHelpCustom is the default implementation of HelpPrinterCustom.
|
||||
|
@ -343,6 +345,7 @@ func ShowCommandCompletions(ctx *Context, command string) {
|
|||
// The customFuncs map will be combined with a default template.FuncMap to
|
||||
// allow using arbitrary functions in template rendering.
|
||||
func printHelpCustom(out io.Writer, templ string, data interface{}, customFuncs map[string]interface{}) {
|
||||
|
||||
const maxLineLength = 10000
|
||||
|
||||
funcMap := template.FuncMap{
|
||||
|
@ -373,26 +376,17 @@ func printHelpCustom(out io.Writer, templ string, data interface{}, customFuncs
|
|||
|
||||
w := tabwriter.NewWriter(out, 1, 8, 2, ' ', 0)
|
||||
t := template.Must(template.New("help").Funcs(funcMap).Parse(templ))
|
||||
templates := map[string]string{
|
||||
"helpNameTemplate": helpNameTemplate,
|
||||
"usageTemplate": usageTemplate,
|
||||
"descriptionTemplate": descriptionTemplate,
|
||||
"visibleCommandTemplate": visibleCommandTemplate,
|
||||
"copyrightTemplate": copyrightTemplate,
|
||||
"versionTemplate": versionTemplate,
|
||||
"visibleFlagCategoryTemplate": visibleFlagCategoryTemplate,
|
||||
"visibleFlagTemplate": visibleFlagTemplate,
|
||||
"visibleGlobalFlagCategoryTemplate": strings.Replace(visibleFlagCategoryTemplate, "OPTIONS", "GLOBAL OPTIONS", -1),
|
||||
"authorsTemplate": authorsTemplate,
|
||||
"visibleCommandCategoryTemplate": visibleCommandCategoryTemplate,
|
||||
}
|
||||
for name, value := range templates {
|
||||
if _, err := t.New(name).Parse(value); err != nil {
|
||||
if os.Getenv("CLI_TEMPLATE_ERROR_DEBUG") != "" {
|
||||
_, _ = fmt.Fprintf(ErrWriter, "CLI TEMPLATE ERROR: %#v\n", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
t.New("helpNameTemplate").Parse(helpNameTemplate)
|
||||
t.New("usageTemplate").Parse(usageTemplate)
|
||||
t.New("descriptionTemplate").Parse(descriptionTemplate)
|
||||
t.New("visibleCommandTemplate").Parse(visibleCommandTemplate)
|
||||
t.New("copyrightTemplate").Parse(copyrightTemplate)
|
||||
t.New("versionTemplate").Parse(versionTemplate)
|
||||
t.New("visibleFlagCategoryTemplate").Parse(visibleFlagCategoryTemplate)
|
||||
t.New("visibleFlagTemplate").Parse(visibleFlagTemplate)
|
||||
t.New("visibleGlobalFlagCategoryTemplate").Parse(strings.Replace(visibleFlagCategoryTemplate, "OPTIONS", "GLOBAL OPTIONS", -1))
|
||||
t.New("authorsTemplate").Parse(authorsTemplate)
|
||||
t.New("visibleCommandCategoryTemplate").Parse(visibleCommandCategoryTemplate)
|
||||
|
||||
err := t.Execute(w, data)
|
||||
if err != nil {
|
||||
|
@ -421,9 +415,6 @@ func checkVersion(cCtx *Context) bool {
|
|||
}
|
||||
|
||||
func checkHelp(cCtx *Context) bool {
|
||||
if HelpFlag == nil {
|
||||
return false
|
||||
}
|
||||
found := false
|
||||
for _, name := range HelpFlag.Names() {
|
||||
if cCtx.Bool(name) {
|
||||
|
@ -435,6 +426,24 @@ func checkHelp(cCtx *Context) bool {
|
|||
return found
|
||||
}
|
||||
|
||||
func checkCommandHelp(c *Context, name string) bool {
|
||||
if c.Bool("h") || c.Bool("help") {
|
||||
_ = ShowCommandHelp(c, name)
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func checkSubcommandHelp(cCtx *Context) bool {
|
||||
if cCtx.Bool("h") || cCtx.Bool("help") {
|
||||
_ = ShowSubcommandHelp(cCtx)
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func checkShellCompleteFlag(a *App, arguments []string) (bool, []string) {
|
||||
if !a.EnableBashCompletion {
|
||||
return false, arguments
|
||||
|
@ -447,15 +456,6 @@ func checkShellCompleteFlag(a *App, arguments []string) (bool, []string) {
|
|||
return false, arguments
|
||||
}
|
||||
|
||||
for _, arg := range arguments {
|
||||
// If arguments include "--", shell completion is disabled
|
||||
// because after "--" only positional arguments are accepted.
|
||||
// https://unix.stackexchange.com/a/11382
|
||||
if arg == "--" {
|
||||
return false, arguments
|
||||
}
|
||||
}
|
||||
|
||||
return true, arguments[:pos]
|
||||
}
|
||||
|
||||
|
@ -505,6 +505,7 @@ func wrap(input string, offset int, wrapAt int) string {
|
|||
ss = append(ss, wrapped)
|
||||
} else {
|
||||
ss = append(ss, padding+wrapped)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
2
vendor/github.com/urfave/cli/v2/mkdocs.yml
generated
vendored
2
vendor/github.com/urfave/cli/v2/mkdocs.yml
generated
vendored
|
@ -1,7 +1,7 @@
|
|||
# NOTE: the mkdocs dependencies will need to be installed out of
|
||||
# band until this whole thing gets more automated:
|
||||
#
|
||||
# pip install -r mkdocs-reqs.txt
|
||||
# pip install -r mkdocs-requirements.txt
|
||||
#
|
||||
|
||||
site_name: urfave/cli
|
||||
|
|
10
vendor/github.com/urfave/cli/v2/suggestions.go
generated
vendored
10
vendor/github.com/urfave/cli/v2/suggestions.go
generated
vendored
|
@ -1,6 +1,3 @@
|
|||
//go:build !urfave_cli_no_suggest
|
||||
// +build !urfave_cli_no_suggest
|
||||
|
||||
package cli
|
||||
|
||||
import (
|
||||
|
@ -9,11 +6,6 @@ import (
|
|||
"github.com/xrash/smetrics"
|
||||
)
|
||||
|
||||
func init() {
|
||||
SuggestFlag = suggestFlag
|
||||
SuggestCommand = suggestCommand
|
||||
}
|
||||
|
||||
func jaroWinkler(a, b string) float64 {
|
||||
// magic values are from https://github.com/xrash/smetrics/blob/039620a656736e6ad994090895784a7af15e0b80/jaro-winkler.go#L8
|
||||
const (
|
||||
|
@ -29,7 +21,7 @@ func suggestFlag(flags []Flag, provided string, hideHelp bool) string {
|
|||
|
||||
for _, flag := range flags {
|
||||
flagNames := flag.Names()
|
||||
if !hideHelp && HelpFlag != nil {
|
||||
if !hideHelp {
|
||||
flagNames = append(flagNames, HelpFlag.Names()...)
|
||||
}
|
||||
for _, name := range flagNames {
|
||||
|
|
6
vendor/github.com/urfave/cli/v2/template.go
generated
vendored
6
vendor/github.com/urfave/cli/v2/template.go
generated
vendored
|
@ -1,7 +1,7 @@
|
|||
package cli
|
||||
|
||||
var helpNameTemplate = `{{$v := offset .HelpName 6}}{{wrap .HelpName 3}}{{if .Usage}} - {{wrap .Usage $v}}{{end}}`
|
||||
var usageTemplate = `{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.HelpName}}{{if .VisibleFlags}} [command options]{{end}}{{if .ArgsUsage}} {{.ArgsUsage}}{{else}}{{if .Args}} [arguments...]{{end}}{{end}}{{end}}`
|
||||
var usageTemplate = `{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.HelpName}}{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}`
|
||||
var descriptionTemplate = `{{wrap .Description 3}}`
|
||||
var authorsTemplate = `{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}:
|
||||
{{range $index, $author := .Authors}}{{if $index}}
|
||||
|
@ -35,7 +35,7 @@ var AppHelpTemplate = `NAME:
|
|||
{{template "helpNameTemplate" .}}
|
||||
|
||||
USAGE:
|
||||
{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}}{{if .ArgsUsage}} {{.ArgsUsage}}{{else}}{{if .Args}} [arguments...]{{end}}{{end}}{{end}}{{if .Version}}{{if not .HideVersion}}
|
||||
{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Version}}{{if not .HideVersion}}
|
||||
|
||||
VERSION:
|
||||
{{.Version}}{{end}}{{end}}{{if .Description}}
|
||||
|
@ -83,7 +83,7 @@ var SubcommandHelpTemplate = `NAME:
|
|||
{{template "helpNameTemplate" .}}
|
||||
|
||||
USAGE:
|
||||
{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.HelpName}} {{if .VisibleFlags}}command [command options]{{end}}{{if .ArgsUsage}} {{.ArgsUsage}}{{else}}{{if .Args}} [arguments...]{{end}}{{end}}{{end}}{{if .Description}}
|
||||
{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.HelpName}} {{if .VisibleFlags}}command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Description}}
|
||||
|
||||
DESCRIPTION:
|
||||
{{template "descriptionTemplate" .}}{{end}}{{if .VisibleCommands}}
|
||||
|
|
51
vendor/github.com/urfave/cli/v2/zz_generated.flags.go
generated
vendored
51
vendor/github.com/urfave/cli/v2/zz_generated.flags.go
generated
vendored
|
@ -23,8 +23,7 @@ type Float64SliceFlag struct {
|
|||
Aliases []string
|
||||
EnvVars []string
|
||||
|
||||
defaultValue *Float64Slice
|
||||
defaultValueSet bool
|
||||
defaultValue *Float64Slice
|
||||
|
||||
separator separatorSpec
|
||||
|
||||
|
@ -70,8 +69,7 @@ type GenericFlag struct {
|
|||
Aliases []string
|
||||
EnvVars []string
|
||||
|
||||
defaultValue Generic
|
||||
defaultValueSet bool
|
||||
defaultValue Generic
|
||||
|
||||
TakesFile bool
|
||||
|
||||
|
@ -122,8 +120,7 @@ type Int64SliceFlag struct {
|
|||
Aliases []string
|
||||
EnvVars []string
|
||||
|
||||
defaultValue *Int64Slice
|
||||
defaultValueSet bool
|
||||
defaultValue *Int64Slice
|
||||
|
||||
separator separatorSpec
|
||||
|
||||
|
@ -169,8 +166,7 @@ type IntSliceFlag struct {
|
|||
Aliases []string
|
||||
EnvVars []string
|
||||
|
||||
defaultValue *IntSlice
|
||||
defaultValueSet bool
|
||||
defaultValue *IntSlice
|
||||
|
||||
separator separatorSpec
|
||||
|
||||
|
@ -216,8 +212,7 @@ type PathFlag struct {
|
|||
Aliases []string
|
||||
EnvVars []string
|
||||
|
||||
defaultValue Path
|
||||
defaultValueSet bool
|
||||
defaultValue Path
|
||||
|
||||
TakesFile bool
|
||||
|
||||
|
@ -268,8 +263,7 @@ type StringSliceFlag struct {
|
|||
Aliases []string
|
||||
EnvVars []string
|
||||
|
||||
defaultValue *StringSlice
|
||||
defaultValueSet bool
|
||||
defaultValue *StringSlice
|
||||
|
||||
separator separatorSpec
|
||||
|
||||
|
@ -319,8 +313,7 @@ type TimestampFlag struct {
|
|||
Aliases []string
|
||||
EnvVars []string
|
||||
|
||||
defaultValue *Timestamp
|
||||
defaultValueSet bool
|
||||
defaultValue *Timestamp
|
||||
|
||||
Layout string
|
||||
|
||||
|
@ -373,8 +366,7 @@ type Uint64SliceFlag struct {
|
|||
Aliases []string
|
||||
EnvVars []string
|
||||
|
||||
defaultValue *Uint64Slice
|
||||
defaultValueSet bool
|
||||
defaultValue *Uint64Slice
|
||||
|
||||
separator separatorSpec
|
||||
|
||||
|
@ -420,8 +412,7 @@ type UintSliceFlag struct {
|
|||
Aliases []string
|
||||
EnvVars []string
|
||||
|
||||
defaultValue *UintSlice
|
||||
defaultValueSet bool
|
||||
defaultValue *UintSlice
|
||||
|
||||
separator separatorSpec
|
||||
|
||||
|
@ -467,8 +458,7 @@ type BoolFlag struct {
|
|||
Aliases []string
|
||||
EnvVars []string
|
||||
|
||||
defaultValue bool
|
||||
defaultValueSet bool
|
||||
defaultValue bool
|
||||
|
||||
Count *int
|
||||
|
||||
|
@ -521,8 +511,7 @@ type Float64Flag struct {
|
|||
Aliases []string
|
||||
EnvVars []string
|
||||
|
||||
defaultValue float64
|
||||
defaultValueSet bool
|
||||
defaultValue float64
|
||||
|
||||
Action func(*Context, float64) error
|
||||
}
|
||||
|
@ -571,8 +560,7 @@ type IntFlag struct {
|
|||
Aliases []string
|
||||
EnvVars []string
|
||||
|
||||
defaultValue int
|
||||
defaultValueSet bool
|
||||
defaultValue int
|
||||
|
||||
Base int
|
||||
|
||||
|
@ -623,8 +611,7 @@ type Int64Flag struct {
|
|||
Aliases []string
|
||||
EnvVars []string
|
||||
|
||||
defaultValue int64
|
||||
defaultValueSet bool
|
||||
defaultValue int64
|
||||
|
||||
Base int
|
||||
|
||||
|
@ -675,8 +662,7 @@ type StringFlag struct {
|
|||
Aliases []string
|
||||
EnvVars []string
|
||||
|
||||
defaultValue string
|
||||
defaultValueSet bool
|
||||
defaultValue string
|
||||
|
||||
TakesFile bool
|
||||
|
||||
|
@ -727,8 +713,7 @@ type DurationFlag struct {
|
|||
Aliases []string
|
||||
EnvVars []string
|
||||
|
||||
defaultValue time.Duration
|
||||
defaultValueSet bool
|
||||
defaultValue time.Duration
|
||||
|
||||
Action func(*Context, time.Duration) error
|
||||
}
|
||||
|
@ -777,8 +762,7 @@ type UintFlag struct {
|
|||
Aliases []string
|
||||
EnvVars []string
|
||||
|
||||
defaultValue uint
|
||||
defaultValueSet bool
|
||||
defaultValue uint
|
||||
|
||||
Base int
|
||||
|
||||
|
@ -829,8 +813,7 @@ type Uint64Flag struct {
|
|||
Aliases []string
|
||||
EnvVars []string
|
||||
|
||||
defaultValue uint64
|
||||
defaultValueSet bool
|
||||
defaultValue uint64
|
||||
|
||||
Base int
|
||||
|
||||
|
|
58
vendor/github.com/xrash/smetrics/soundex.go
generated
vendored
58
vendor/github.com/xrash/smetrics/soundex.go
generated
vendored
|
@ -6,58 +6,36 @@ import (
|
|||
|
||||
// The Soundex encoding. It is a phonetic algorithm that considers how the words sound in English. Soundex maps a string to a 4-byte code consisting of the first letter of the original string and three numbers. Strings that sound similar should map to the same code.
|
||||
func Soundex(s string) string {
|
||||
b := strings.Builder{}
|
||||
b.Grow(4)
|
||||
|
||||
p := s[0]
|
||||
if p <= 'z' && p >= 'a' {
|
||||
p -= 32 // convert to uppercase
|
||||
m := map[byte]string{
|
||||
'B': "1", 'P': "1", 'F': "1", 'V': "1",
|
||||
'C': "2", 'S': "2", 'K': "2", 'G': "2", 'J': "2", 'Q': "2", 'X': "2", 'Z': "2",
|
||||
'D': "3", 'T': "3",
|
||||
'L': "4",
|
||||
'M': "5", 'N': "5",
|
||||
'R': "6",
|
||||
}
|
||||
b.WriteByte(p)
|
||||
|
||||
n := 0
|
||||
for i := 1; i < len(s); i++ {
|
||||
s = strings.ToUpper(s)
|
||||
|
||||
r := string(s[0])
|
||||
p := s[0]
|
||||
for i := 1; i < len(s) && len(r) < 4; i++ {
|
||||
c := s[i]
|
||||
|
||||
if c <= 'z' && c >= 'a' {
|
||||
c -= 32 // convert to uppercase
|
||||
} else if c < 'A' || c > 'Z' {
|
||||
continue
|
||||
}
|
||||
|
||||
if c == p {
|
||||
if (c < 'A' || c > 'Z') || (c == p) {
|
||||
continue
|
||||
}
|
||||
|
||||
p = c
|
||||
|
||||
switch c {
|
||||
case 'B', 'P', 'F', 'V':
|
||||
c = '1'
|
||||
case 'C', 'S', 'K', 'G', 'J', 'Q', 'X', 'Z':
|
||||
c = '2'
|
||||
case 'D', 'T':
|
||||
c = '3'
|
||||
case 'L':
|
||||
c = '4'
|
||||
case 'M', 'N':
|
||||
c = '5'
|
||||
case 'R':
|
||||
c = '6'
|
||||
default:
|
||||
continue
|
||||
}
|
||||
|
||||
b.WriteByte(c)
|
||||
n++
|
||||
if n == 3 {
|
||||
break
|
||||
if n, ok := m[c]; ok {
|
||||
r += n
|
||||
}
|
||||
}
|
||||
|
||||
for i := n; i < 3; i++ {
|
||||
b.WriteByte('0')
|
||||
for i := len(r); i < 4; i++ {
|
||||
r += "0"
|
||||
}
|
||||
|
||||
return b.String()
|
||||
return r
|
||||
}
|
||||
|
|
14
vendor/modules.txt
vendored
14
vendor/modules.txt
vendored
|
@ -1,5 +1,5 @@
|
|||
# github.com/aws/aws-sdk-go v1.55.5
|
||||
## explicit; go 1.19
|
||||
# github.com/aws/aws-sdk-go v1.45.25
|
||||
## explicit; go 1.11
|
||||
github.com/aws/aws-sdk-go/aws
|
||||
github.com/aws/aws-sdk-go/aws/arn
|
||||
github.com/aws/aws-sdk-go/aws/auth/bearer
|
||||
|
@ -51,7 +51,7 @@ github.com/aws/aws-sdk-go/service/sso/ssoiface
|
|||
github.com/aws/aws-sdk-go/service/ssooidc
|
||||
github.com/aws/aws-sdk-go/service/sts
|
||||
github.com/aws/aws-sdk-go/service/sts/stsiface
|
||||
# github.com/cpuguy83/go-md2man/v2 v2.0.4
|
||||
# github.com/cpuguy83/go-md2man/v2 v2.0.2
|
||||
## explicit; go 1.11
|
||||
github.com/cpuguy83/go-md2man/v2/md2man
|
||||
# github.com/davecgh/go-spew v1.1.1
|
||||
|
@ -76,7 +76,7 @@ github.com/pkg/sftp/internal/encoding/ssh/filexfer
|
|||
# github.com/pmezard/go-difflib v1.0.0
|
||||
## explicit
|
||||
github.com/pmezard/go-difflib/difflib
|
||||
# github.com/rs/zerolog v1.33.0
|
||||
# github.com/rs/zerolog v1.31.0
|
||||
## explicit; go 1.15
|
||||
github.com/rs/zerolog
|
||||
github.com/rs/zerolog/internal/cbor
|
||||
|
@ -88,11 +88,11 @@ github.com/russross/blackfriday/v2
|
|||
# github.com/stretchr/testify v1.8.4
|
||||
## explicit; go 1.20
|
||||
github.com/stretchr/testify/assert
|
||||
# github.com/urfave/cli/v2 v2.27.4
|
||||
# github.com/urfave/cli/v2 v2.25.7
|
||||
## explicit; go 1.18
|
||||
github.com/urfave/cli/v2
|
||||
# github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1
|
||||
## explicit; go 1.15
|
||||
# github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673
|
||||
## explicit
|
||||
github.com/xrash/smetrics
|
||||
# golang.org/x/crypto v0.27.0
|
||||
## explicit; go 1.20
|
||||
|
|
Loading…
Reference in a new issue