chore: make deps
This commit is contained in:
40
go.mod
40
go.mod
@ -1,50 +1,54 @@
|
||||
module git.coopcloud.tech/decentral1se/blurp
|
||||
|
||||
go 1.21.1
|
||||
go 1.23.0
|
||||
|
||||
toolchain go1.24.1
|
||||
|
||||
require (
|
||||
git.coopcloud.tech/decentral1se/gtslib v0.0.0-20240731204718-e4ade9c75895
|
||||
git.coopcloud.tech/decentral1se/gtslib-auth-keyring v0.0.0-20240801204536-25747ed03350
|
||||
git.coopcloud.tech/decentral1se/gtslib v0.0.0-20240801205943-6bd88e34a77e
|
||||
git.coopcloud.tech/decentral1se/gtslib-auth-keyring v0.0.0-20240804090000-79e827af5626
|
||||
github.com/peterhellberg/link v1.2.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/spf13/cobra v1.8.1
|
||||
github.com/spf13/cobra v1.9.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/adrg/xdg v0.5.0 // indirect
|
||||
al.essio.dev/pkg/shellescape v1.6.0 // indirect
|
||||
github.com/adrg/xdg v0.5.3 // indirect
|
||||
github.com/alessio/shellescape v1.4.2 // indirect
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
|
||||
github.com/danieljoos/wincred v1.2.2 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-openapi/analysis v0.23.0 // indirect
|
||||
github.com/go-openapi/errors v0.22.0 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.21.0 // indirect
|
||||
github.com/go-openapi/errors v0.22.1 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.21.1 // indirect
|
||||
github.com/go-openapi/jsonreference v0.21.0 // indirect
|
||||
github.com/go-openapi/loads v0.22.0 // indirect
|
||||
github.com/go-openapi/runtime v0.28.0 // indirect
|
||||
github.com/go-openapi/spec v0.21.0 // indirect
|
||||
github.com/go-openapi/strfmt v0.23.0 // indirect
|
||||
github.com/go-openapi/swag v0.23.0 // indirect
|
||||
github.com/go-openapi/swag v0.23.1 // indirect
|
||||
github.com/go-openapi/validate v0.24.0 // indirect
|
||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mailru/easyjson v0.9.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/oklog/ulid v1.3.1 // indirect
|
||||
github.com/opentracing/opentracing-go v1.2.0 // indirect
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/zalando/go-keyring v0.2.5 // indirect
|
||||
go.mongodb.org/mongo-driver v1.16.0 // indirect
|
||||
go.opentelemetry.io/otel v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.28.0 // indirect
|
||||
golang.org/x/sync v0.7.0 // indirect
|
||||
golang.org/x/sys v0.22.0 // indirect
|
||||
golang.org/x/time v0.5.0 // indirect
|
||||
github.com/spf13/pflag v1.0.6 // indirect
|
||||
github.com/zalando/go-keyring v0.2.6 // indirect
|
||||
go.mongodb.org/mongo-driver v1.17.3 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
||||
go.opentelemetry.io/otel v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.35.0 // indirect
|
||||
golang.org/x/sync v0.13.0 // indirect
|
||||
golang.org/x/sys v0.32.0 // indirect
|
||||
golang.org/x/time v0.11.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
webfinger.net/go/webfinger v0.1.0 // indirect
|
||||
)
|
||||
|
39
go.sum
39
go.sum
@ -1,14 +1,23 @@
|
||||
al.essio.dev/pkg/shellescape v1.6.0 h1:NxFcEqzFSEVCGN2yq7Huv/9hyCEGVa/TncnOOBBeXHA=
|
||||
al.essio.dev/pkg/shellescape v1.6.0/go.mod h1:6sIqp7X2P6mThCQ7twERpZTuigpr6KbZWtls1U8I890=
|
||||
git.coopcloud.tech/decentral1se/gtslib v0.0.0-20240731204718-e4ade9c75895 h1:J+Vp8/7Oa/mMEMOzhra17+kMuhsdlNHKBSDapCw/jM8=
|
||||
git.coopcloud.tech/decentral1se/gtslib v0.0.0-20240731204718-e4ade9c75895/go.mod h1:isFkvbxjltfWUlzdVETbupmKLZvDf5XviBkgd2/+A5M=
|
||||
git.coopcloud.tech/decentral1se/gtslib v0.0.0-20240801205943-6bd88e34a77e h1:e6UQbCi+x98gTYqkU8jcCnAaBLNkdSb7+784NHjwn8M=
|
||||
git.coopcloud.tech/decentral1se/gtslib v0.0.0-20240801205943-6bd88e34a77e/go.mod h1:isFkvbxjltfWUlzdVETbupmKLZvDf5XviBkgd2/+A5M=
|
||||
git.coopcloud.tech/decentral1se/gtslib-auth-keyring v0.0.0-20240801204536-25747ed03350 h1:7XV8zvvBowccEnQWaq7Cv1y9U9ZV4xJuS9xNwDeFMuo=
|
||||
git.coopcloud.tech/decentral1se/gtslib-auth-keyring v0.0.0-20240801204536-25747ed03350/go.mod h1:fWMf/Wlc6Qjosg4xoaJg0UOb9GHoP7GrlIXz38wZAws=
|
||||
git.coopcloud.tech/decentral1se/gtslib-auth-keyring v0.0.0-20240804090000-79e827af5626 h1:ANwWWKa5VO+LTDOZO9aBvEC4ViDC+o9cY/f9ihvg4F8=
|
||||
git.coopcloud.tech/decentral1se/gtslib-auth-keyring v0.0.0-20240804090000-79e827af5626/go.mod h1:fWMf/Wlc6Qjosg4xoaJg0UOb9GHoP7GrlIXz38wZAws=
|
||||
github.com/adrg/xdg v0.5.0 h1:dDaZvhMXatArP1NPHhnfaQUqWBLBsmx1h1HXQdMoFCY=
|
||||
github.com/adrg/xdg v0.5.0/go.mod h1:dDdY4M4DF9Rjy4kHPeNL+ilVF+p2lK8IdM9/rTSGcI4=
|
||||
github.com/adrg/xdg v0.5.3 h1:xRnxJXne7+oWDatRhR1JLnvuccuIeCoBu2rtuLqQB78=
|
||||
github.com/adrg/xdg v0.5.3/go.mod h1:nlTsY+NNiCBGCK2tpm09vRqfVzrc2fLmXGpBLF0zlTQ=
|
||||
github.com/alessio/shellescape v1.4.2 h1:MHPfaU+ddJ0/bYWpgIeUnQUqKrlJ1S7BfEYPM4uEoM0=
|
||||
github.com/alessio/shellescape v1.4.2/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30=
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||
github.com/danieljoos/wincred v1.2.2 h1:774zMFJrqaeYCK2W57BgAem/MLi6mtSE47MB6BOJ0i0=
|
||||
github.com/danieljoos/wincred v1.2.2/go.mod h1:w7w4Utbrz8lqeMbDAK0lkNJUv5sAOkFi7nd/ogr0Uh8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@ -23,8 +32,12 @@ github.com/go-openapi/analysis v0.23.0 h1:aGday7OWupfMs+LbmLZG4k0MYXIANxcuBTYUC0
|
||||
github.com/go-openapi/analysis v0.23.0/go.mod h1:9mz9ZWaSlV8TvjQHLl2mUW2PbZtemkE8yA5v22ohupo=
|
||||
github.com/go-openapi/errors v0.22.0 h1:c4xY/OLxUBSTiepAg3j/MHuAv5mJhnf53LLMWFB+u/w=
|
||||
github.com/go-openapi/errors v0.22.0/go.mod h1:J3DmZScxCDufmIMsdOuDHxJbdOGC0xtUynjIx092vXE=
|
||||
github.com/go-openapi/errors v0.22.1 h1:kslMRRnK7NCb/CvR1q1VWuEQCEIsBGn5GgKD9e+HYhU=
|
||||
github.com/go-openapi/errors v0.22.1/go.mod h1:+n/5UdIqdVnLIJ6Q9Se8HNGUXYaY6CN8ImWzfi/Gzp0=
|
||||
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
|
||||
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
|
||||
github.com/go-openapi/jsonpointer v0.21.1 h1:whnzv/pNXtK2FbX/W9yJfRmE2gsmkfahjMKB0fZvcic=
|
||||
github.com/go-openapi/jsonpointer v0.21.1/go.mod h1:50I1STOfbY1ycR8jGz8DaMeLCdXiI6aDteEdRNNzpdk=
|
||||
github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ=
|
||||
github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4=
|
||||
github.com/go-openapi/loads v0.22.0 h1:ECPGd4jX1U6NApCGG1We+uEozOAvXvJSF4nnwHZ8Aco=
|
||||
@ -37,6 +50,8 @@ github.com/go-openapi/strfmt v0.23.0 h1:nlUS6BCqcnAk0pyhi9Y+kdDVZdZMHfEKQiS4HaMg
|
||||
github.com/go-openapi/strfmt v0.23.0/go.mod h1:NrtIpfKtWIygRkKVsxh7XQMDQW5HKQl6S5ik2elW+K4=
|
||||
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
|
||||
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
|
||||
github.com/go-openapi/swag v0.23.1 h1:lpsStH0n2ittzTnbaSloVZLuB5+fvSY/+hnagBjSNZU=
|
||||
github.com/go-openapi/swag v0.23.1/go.mod h1:STZs8TbRvEQQKUA+JZNAm3EWlgaOBGpyFDqQnDHMef0=
|
||||
github.com/go-openapi/validate v0.24.0 h1:LdfDKwNbpB6Vn40xhTdNZAnfLECL81w+VX3BumrGD58=
|
||||
github.com/go-openapi/validate v0.24.0/go.mod h1:iyeX1sEufmv3nPbBdX3ieNviWnOZaJ1+zquzJEf2BAQ=
|
||||
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
|
||||
@ -55,6 +70,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
||||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
|
||||
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
|
||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
|
||||
@ -75,8 +92,12 @@ github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
|
||||
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
|
||||
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
|
||||
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
|
||||
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
@ -85,23 +106,41 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/zalando/go-keyring v0.2.5 h1:Bc2HHpjALryKD62ppdEzaFG6VxL6Bc+5v0LYpN8Lba8=
|
||||
github.com/zalando/go-keyring v0.2.5/go.mod h1:HL4k+OXQfJUWaMnqyuSOc0drfGPX2b51Du6K+MRgZMk=
|
||||
github.com/zalando/go-keyring v0.2.6 h1:r7Yc3+H+Ux0+M72zacZoItR3UDxeWfKTcabvkI8ua9s=
|
||||
github.com/zalando/go-keyring v0.2.6/go.mod h1:2TCrxYrbUNYfNS/Kgy/LSrkSQzZ5UPVH85RwfczwvcI=
|
||||
go.mongodb.org/mongo-driver v1.16.0 h1:tpRsfBJMROVHKpdGyc1BBEzzjDUWjItxbVSZ8Ls4BQ4=
|
||||
go.mongodb.org/mongo-driver v1.16.0/go.mod h1:oB6AhJQvFQL4LEHyXi6aJzQJtBiTQHiAd83l0GdFaiw=
|
||||
go.mongodb.org/mongo-driver v1.17.3 h1:TQyXhnsWfWtgAhMtOgtYHMTkZIfBTpMTsMnd9ZBeHxQ=
|
||||
go.mongodb.org/mongo-driver v1.17.3/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
||||
go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo=
|
||||
go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4=
|
||||
go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ=
|
||||
go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y=
|
||||
go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q=
|
||||
go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s=
|
||||
go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M=
|
||||
go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE=
|
||||
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw=
|
||||
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg=
|
||||
go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g=
|
||||
go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI=
|
||||
go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs=
|
||||
go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc=
|
||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
|
||||
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
|
||||
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
||||
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0=
|
||||
golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
|
@ -26,3 +26,7 @@ _testmain.go
|
||||
.idea/
|
||||
|
||||
escargs
|
||||
|
||||
config.hcl
|
||||
|
||||
.DS_Store
|
@ -6,7 +6,9 @@ linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- bodyclose
|
||||
- copyloopvar
|
||||
- dogsled
|
||||
- gci
|
||||
- goconst
|
||||
- gocritic
|
||||
- gofmt
|
||||
@ -17,15 +19,14 @@ linters:
|
||||
- ineffassign
|
||||
- misspell
|
||||
- prealloc
|
||||
- exportloopref
|
||||
- revive
|
||||
- staticcheck
|
||||
- stylecheck
|
||||
- typecheck
|
||||
- thelper
|
||||
- unconvert
|
||||
- unparam
|
||||
- unused
|
||||
- misspell
|
||||
- wsl
|
||||
|
||||
issues:
|
||||
@ -42,18 +43,19 @@ issues:
|
||||
- text: "ST1003:"
|
||||
linters:
|
||||
- stylecheck
|
||||
# FIXME: Disabled until golangci-lint updates stylecheck with this fix:
|
||||
# https://github.com/dominikh/go-tools/issues/389
|
||||
- text: "ST1016:"
|
||||
- path: "_test.go"
|
||||
linters:
|
||||
- stylecheck
|
||||
- wsl
|
||||
|
||||
linters-settings:
|
||||
dogsled:
|
||||
max-blank-identifiers: 3
|
||||
maligned:
|
||||
# print struct with more effective memory layout or not, false by default
|
||||
suggest-new: true
|
||||
|
||||
run:
|
||||
tests: false
|
||||
# define the import orders
|
||||
gci:
|
||||
sections:
|
||||
# Standard section: captures all standard packages.
|
||||
- standard
|
||||
# Default section: catchall that is not standard or custom
|
||||
- default
|
||||
# linters that related to local tool, so they should be separated
|
||||
- localmodule
|
134
vendor/al.essio.dev/pkg/shellescape/CODE_OF_CONDUCT.md
vendored
Normal file
134
vendor/al.essio.dev/pkg/shellescape/CODE_OF_CONDUCT.md
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, caste, color, religion, or sexual
|
||||
identity and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the overall
|
||||
community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or advances of
|
||||
any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email address,
|
||||
without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official email address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
[alessio AT debian DOT org][contact].
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series of
|
||||
actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or permanent
|
||||
ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within the
|
||||
community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.1, available at
|
||||
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||
|
||||
Community Impact Guidelines were inspired by
|
||||
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
||||
[https://www.contributor-covenant.org/translations][translations].
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||
[FAQ]: https://www.contributor-covenant.org/faq
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
||||
[contact]: mailto:alessio_AT_debian_DOT_org
|
25
vendor/al.essio.dev/pkg/shellescape/Makefile
vendored
Normal file
25
vendor/al.essio.dev/pkg/shellescape/Makefile
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
#!/usr/bin/make -f
|
||||
|
||||
VERSION := $(shell git describe)
|
||||
|
||||
all: build
|
||||
|
||||
build:
|
||||
go build -a -v
|
||||
|
||||
install:
|
||||
go install ./cmd/escargs
|
||||
|
||||
escargs: build
|
||||
go build -v \
|
||||
-ldflags="-X 'main.version=$(VERSION)'" \
|
||||
./cmd/escargs
|
||||
|
||||
clean:
|
||||
rm -rfv escargs
|
||||
|
||||
uninstall:
|
||||
rm -v $(shell go env GOPATH)/bin/escargs
|
||||
|
||||
.PHONY: build clean install uninstall
|
@ -1,12 +1,13 @@
|
||||
# shellescape
|
||||
|
||||

|
||||
[](https://pkg.go.dev/github.com/alessio/shellescape?tab=overview)
|
||||
[](https://sourcegraph.com/github.com/alessio/shellescape)
|
||||
[](https://codecov.io/gh/alessio/shellescape)
|
||||
[](https://gocover.io/github.com/alessio/shellescape)
|
||||
[](https://goreportcard.com/report/github.com/alessio/shellescape)
|
||||
|
||||
# shellescape
|
||||
Escape arbitrary strings for safe use as command line arguments.
|
||||
|
||||
## Contents of the package
|
||||
|
||||
This package provides the `shellescape.Quote()` function that returns a
|
||||
@ -32,6 +33,7 @@ import (
|
||||
func main() {
|
||||
fmt.Printf("ls -l %s\n", os.Args[1])
|
||||
}
|
||||
|
||||
```
|
||||
_[See in Go Playground](https://play.golang.org/p/Wj2WoUfH_d)_
|
||||
|
||||
@ -48,14 +50,15 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"gopkg.in/alessio/shellescape.v1"
|
||||
"al.essio.dev/pkg/shellescape"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Printf("ls -l %s\n", shellescape.Quote(os.Args[1]))
|
||||
}
|
||||
```
|
||||
_[See in Go Playground](https://play.golang.org/p/HJ_CXgSrmp)_
|
||||
_[See in Go Playground](https://go.dev/play/p/GeguukpSUTk)_
|
||||
|
||||
## The escargs utility
|
||||
__escargs__ reads lines from the standard input and prints shell-escaped versions. Unlinke __xargs__, blank lines on the standard input are not discarded.
|
||||
|
||||
__escargs__ reads lines from the standard input and prints shell-escaped versions. Unlike __xargs__, blank lines on the standard input are not discarded.
|
@ -6,7 +6,7 @@ POSIX shells.
|
||||
The original Python package which this work was inspired by can be found
|
||||
at https://pypi.python.org/pypi/shellescape.
|
||||
*/
|
||||
package shellescape // "import gopkg.in/alessio/shellescape.v1"
|
||||
package shellescape // "import al.essio.dev/pkg/shellescape"
|
||||
|
||||
/*
|
||||
The functionality provided by shellescape.Quote could be helpful
|
||||
@ -15,6 +15,7 @@ be appended to/used in the context of shell programs' command line arguments.
|
||||
*/
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"regexp"
|
||||
"strings"
|
||||
"unicode"
|
||||
@ -64,3 +65,24 @@ func StripUnsafe(s string) string {
|
||||
return -1
|
||||
}, s)
|
||||
}
|
||||
|
||||
// ScanTokens is a split function for a bufio.Scanner that returns each word of text, stripped
|
||||
// of amy trailing end-of-text empty byte.
|
||||
func ScanTokens(data []byte, atEOF bool) (advance int, token []byte, err error) {
|
||||
// Return nothing if at end-of-file and no data passed.
|
||||
if atEOF && len(data) == 0 {
|
||||
return 0, nil, nil
|
||||
}
|
||||
|
||||
// Find the index of the input of a null character.
|
||||
if i := bytes.IndexByte(data, '\x00'); i >= 0 {
|
||||
return i + 1, data[0:i], nil
|
||||
}
|
||||
// If we're at EOF, we have a final, non-terminated line. Return it.
|
||||
if atEOF {
|
||||
return len(data), data, nil
|
||||
}
|
||||
|
||||
// Request more data.
|
||||
return 0, nil, nil
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
# gtslib-auth-keyring
|
||||
|
||||
[](https://build.coopcloud.tech/decentral1se/gtslib-auth-keyring)
|
||||
[](https://goreportcard.com/report/git.coopcloud.tech/decentral1se/gtslib-auth-keyring)
|
||||
[](https://pkg.go.dev/git.coopcloud.tech/gtslib-auth-keyring)
|
||||
|
||||
> [GoToSocial](https://gotosocial.org) client auth with keyring support
|
||||
|
||||
@ -15,10 +17,9 @@ import (
|
||||
|
||||
func main() {
|
||||
if err := auth.Login("foo@bar.zone"); err != nil {
|
||||
slog.Error("unable to login", err)
|
||||
slog.Error("unable to login", "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## ACK
|
||||
|
42
vendor/github.com/adrg/xdg/README.md
generated
vendored
42
vendor/github.com/adrg/xdg/README.md
generated
vendored
@ -41,8 +41,9 @@ Provides an implementation of the [XDG Base Directory Specification](https://spe
|
||||
The specification defines a set of standard paths for storing application files,
|
||||
including data and configuration files. For portability and flexibility reasons,
|
||||
applications should use the XDG defined locations instead of hardcoding paths.
|
||||
The package also includes the locations of well known [user directories](https://wiki.archlinux.org/index.php/XDG_user_directories), as well as
|
||||
other common directories such as fonts and applications.
|
||||
|
||||
The package also includes the locations of well known [user directories](https://wiki.archlinux.org/index.php/XDG_user_directories),
|
||||
support for the non-standard `XDG_BIN_HOME` directory, as well as other common directories such as fonts and applications.
|
||||
|
||||
The current implementation supports **most flavors of Unix**, **Windows**, **macOS** and **Plan 9**.
|
||||
On Windows, where XDG environment variables are not usually set, the package uses [Known Folders](https://docs.microsoft.com/en-us/windows/win32/shell/known-folders)
|
||||
@ -70,15 +71,16 @@ Sensible fallback locations are used for the folders which are not set.
|
||||
<summary><strong>Unix-like operating systems</strong></summary>
|
||||
<br/>
|
||||
|
||||
| <a href="#xdg-base-directory"><img width="400" height="0"></a> | <a href="#xdg-base-directory"><img width="500" height="0"></a><p>Unix</p> | <a href="#xdg-base-directory"><img width="600" height="0"></a><p>macOS</p> | <a href="#xdg-base-directory"><img width="500" height="0"></a><p>Plan 9</p> |
|
||||
| :------------------------------------------------------------: | :-----------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------: |
|
||||
| <kbd><b>XDG_DATA_HOME</b></kbd> | <kbd>~/.local/share</kbd> | <kbd>~/Library/Application Support</kbd> | <kbd>$home/lib</kbd> |
|
||||
| <kbd><b>XDG_DATA_DIRS</b></kbd> | <kbd>/usr/local/share</kbd><br/><kbd>/usr/share</kbd> | <kbd>/Library/Application Support</kbd> | <kbd>/lib</kbd> |
|
||||
| <kbd><b>XDG_CONFIG_HOME</b></kbd> | <kbd>~/.config</kbd> | <kbd>~/Library/Application Support</kbd> | <kbd>$home/lib</kbd> |
|
||||
| <kbd><b>XDG_CONFIG_DIRS</b></kbd> | <kbd>/etc/xdg</kbd> | <kbd>~/Library/Preferences</kbd><br/><kbd>/Library/Application Support</kbd><br/><kbd>/Library/Preferences</kbd> | <kbd>/lib</kbd> |
|
||||
| <kbd><b>XDG_STATE_HOME</b></kbd> | <kbd>~/.local/state</kbd> | <kbd>~/Library/Application Support</kbd> | <kbd>$home/lib/state</kbd> |
|
||||
| <kbd><b>XDG_CACHE_HOME</b></kbd> | <kbd>~/.cache</kbd> | <kbd>~/Library/Caches</kbd> | <kbd>$home/lib/cache</kbd> |
|
||||
| <kbd><b>XDG_RUNTIME_DIR</b></kbd> | <kbd>/run/user/UID</kbd> | <kbd>~/Library/Application Support</kbd> | <kbd>/tmp</kbd> |
|
||||
| <a href="#xdg-base-directory"><img width="400" height="0"></a> | <a href="#xdg-base-directory"><img width="500" height="0"></a><p>Unix</p> | <a href="#xdg-base-directory"><img width="600" height="0"></a><p>macOS</p> | <a href="#xdg-base-directory"><img width="500" height="0"></a><p>Plan 9</p> |
|
||||
| :------------------------------------------------------------: | :-----------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------: |
|
||||
| <kbd><b>XDG_DATA_HOME</b></kbd> | <kbd>~/.local/share</kbd> | <kbd>~/Library/Application Support</kbd> | <kbd>$home/lib</kbd> |
|
||||
| <kbd><b>XDG_DATA_DIRS</b></kbd> | <kbd>/usr/local/share</kbd><br/><kbd>/usr/share</kbd> | <kbd>/Library/Application Support</kbd><kbd>~/.local/share</kbd> | <kbd>/lib</kbd> |
|
||||
| <kbd><b>XDG_CONFIG_HOME</b></kbd> | <kbd>~/.config</kbd> | <kbd>~/Library/Application Support</kbd> | <kbd>$home/lib</kbd> |
|
||||
| <kbd><b>XDG_CONFIG_DIRS</b></kbd> | <kbd>/etc/xdg</kbd> | <kbd>~/Library/Preferences</kbd><br/><kbd>/Library/Application Support</kbd><br/><kbd>/Library/Preferences</kbd><br/><kbd>~/.config</kbd> | <kbd>/lib</kbd> |
|
||||
| <kbd><b>XDG_STATE_HOME</b></kbd> | <kbd>~/.local/state</kbd> | <kbd>~/Library/Application Support</kbd> | <kbd>$home/lib/state</kbd> |
|
||||
| <kbd><b>XDG_CACHE_HOME</b></kbd> | <kbd>~/.cache</kbd> | <kbd>~/Library/Caches</kbd> | <kbd>$home/lib/cache</kbd> |
|
||||
| <kbd><b>XDG_RUNTIME_DIR</b></kbd> | <kbd>/run/user/$UID</kbd> | <kbd>~/Library/Application Support</kbd> | <kbd>/tmp</kbd> |
|
||||
| <kbd><b>XDG_BIN_HOME</b></kbd> | <kbd>~/.local/bin</kbd> | <kbd>~/.local/bin</kbd> | <kbd>$home/bin</kbd> |
|
||||
|
||||
</details>
|
||||
|
||||
@ -95,6 +97,7 @@ Sensible fallback locations are used for the folders which are not set.
|
||||
| <kbd><b>XDG_STATE_HOME</b></kbd> | <kbd>LocalAppData</kbd> | <kbd>%LOCALAPPDATA%</kbd> |
|
||||
| <kbd><b>XDG_CACHE_HOME</b></kbd> | <kbd>LocalAppData\cache</kbd> | <kbd>%LOCALAPPDATA%\cache</kbd> |
|
||||
| <kbd><b>XDG_RUNTIME_DIR</b></kbd> | <kbd>LocalAppData</kbd> | <kbd>%LOCALAPPDATA%</kbd> |
|
||||
| <kbd><b>XDG_BIN_HOME</b></kbd> | <kbd>UserProgramFiles</kbd> | <kbd>%LOCALAPPDATA%\Programs</kbd> |
|
||||
|
||||
</details>
|
||||
|
||||
@ -163,11 +166,11 @@ as shown in the following tables.
|
||||
<summary><strong>Microsoft Windows</strong></summary>
|
||||
<br/>
|
||||
|
||||
| <a href="#other-directories"><img width="400" height="0"></a> | <a href="#other-directories"><img width="300" height="0"></a><p>Known Folder(s)</p> | <a href="#other-directories"><img width="1300" height="0"></a><p>Fallback(s)</p> |
|
||||
| :-----------------------------------------------------------: | :--------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------: |
|
||||
| <kbd><b>Home</b></kbd> | <kbd>Profile</kbd> | <kbd>%USERPROFILE%</kbd> |
|
||||
| <kbd><b>Applications</b></kbd> | <kbd>Programs</kbd><br/><kbd>CommonPrograms</kbd> | <kbd>%APPDATA%\Microsoft\Windows\Start Menu\Programs</kbd><br/><kbd>%ProgramData%\Microsoft\Windows\Start Menu\Programs</kbd> |
|
||||
| <kbd><b>Fonts</b></kbd> | <kbd>Fonts</kbd> | <kbd>%SystemRoot%\Fonts</kbd><br/><kbd>%LOCALAPPDATA%\Microsoft\Windows\Fonts</kbd> |
|
||||
| <a href="#other-directories"><img width="400" height="0"></a> | <a href="#other-directories"><img width="300" height="0"></a><p>Known Folder(s)</p> | <a href="#other-directories"><img width="1300" height="0"></a><p>Fallback(s)</p> |
|
||||
| :-----------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
||||
| <kbd><b>Home</b></kbd> | <kbd>Profile</kbd> | <kbd>%USERPROFILE%</kbd> |
|
||||
| <kbd><b>Applications</b></kbd> | <kbd>Programs</kbd><br/><kbd>CommonPrograms</kbd> <br/><kbd>ProgramFiles</kbd><br/><kbd>ProgramFilesCommon</kbd><br/><kbd>UserProgramFiles</kbd><br/><kbd>UserProgramFilesCommon</kbd> | <kbd>%APPDATA%\Microsoft\Windows\Start Menu\Programs</kbd><br/><kbd>%ProgramData%\Microsoft\Windows\Start Menu\Programs</kbd><br/><kbd>%ProgramFiles%</kbd><br/><kbd>%ProgramFiles%\Common Files</kbd><br/><kbd>%LOCALAPPDATA%\Programs</kbd><br/><kbd>%LOCALAPPDATA%\Programs\Common</kbd>|
|
||||
| <kbd><b>Fonts</b></kbd> | <kbd>Fonts</kbd> | <kbd>%SystemRoot%\Fonts</kbd><br/><kbd>%LOCALAPPDATA%\Microsoft\Windows\Fonts</kbd> |
|
||||
|
||||
</details>
|
||||
|
||||
@ -193,6 +196,7 @@ func main() {
|
||||
log.Println("Home state directory:", xdg.StateHome)
|
||||
log.Println("Cache directory:", xdg.CacheHome)
|
||||
log.Println("Runtime directory:", xdg.RuntimeDir)
|
||||
log.Println("Home binaries directory:", xdg.BinHome)
|
||||
|
||||
// Other common directories.
|
||||
log.Println("Home directory:", xdg.Home)
|
||||
@ -203,6 +207,9 @@ func main() {
|
||||
// ConfigFile takes one parameter which must contain the name of the file,
|
||||
// but it can also contain a set of parent directories. If the directories
|
||||
// don't exist, they will be created relative to the base config directory.
|
||||
// It is recommended for files to be saved inside an application directory
|
||||
// relative to the base directory rather than directly inside the base
|
||||
// directory (e.g. `appname/config.yaml` instead of `appname-config.yaml`).
|
||||
configFilePath, err := xdg.ConfigFile("appname/config.yaml")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@ -277,7 +284,8 @@ See [CONTRIBUTING.MD](CONTRIBUTING.md).
|
||||
[djdv](https://github.com/djdv),
|
||||
[rrjjvv](https://github.com/rrjjvv),
|
||||
[GreyXor](https://github.com/GreyXor),
|
||||
[Rican7](https://github.com/Rican7).
|
||||
[Rican7](https://github.com/Rican7),
|
||||
[nothub](https://github.com/nothub).
|
||||
|
||||
## References
|
||||
|
||||
|
22
vendor/github.com/adrg/xdg/base_dirs.go
generated
vendored
22
vendor/github.com/adrg/xdg/base_dirs.go
generated
vendored
@ -1,6 +1,10 @@
|
||||
package xdg
|
||||
|
||||
import "github.com/adrg/xdg/internal/pathutil"
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/adrg/xdg/internal/pathutil"
|
||||
)
|
||||
|
||||
// XDG Base Directory environment variables.
|
||||
const (
|
||||
@ -11,6 +15,9 @@ const (
|
||||
envStateHome = "XDG_STATE_HOME"
|
||||
envCacheHome = "XDG_CACHE_HOME"
|
||||
envRuntimeDir = "XDG_RUNTIME_DIR"
|
||||
|
||||
// Non-standard.
|
||||
envBinHome = "XDG_BIN_HOME"
|
||||
)
|
||||
|
||||
type baseDirectories struct {
|
||||
@ -22,7 +29,8 @@ type baseDirectories struct {
|
||||
cacheHome string
|
||||
runtime string
|
||||
|
||||
// Non-standard directories.
|
||||
// Non-standard.
|
||||
binHome string
|
||||
fonts []string
|
||||
applications []string
|
||||
}
|
||||
@ -44,7 +52,13 @@ func (bd baseDirectories) cacheFile(relPath string) (string, error) {
|
||||
}
|
||||
|
||||
func (bd baseDirectories) runtimeFile(relPath string) (string, error) {
|
||||
return pathutil.Create(relPath, []string{bd.runtime})
|
||||
var paths []string
|
||||
for _, p := range pathutil.Unique([]string{bd.runtime, os.TempDir()}) {
|
||||
if pathutil.Exists(p) {
|
||||
paths = append(paths, p)
|
||||
}
|
||||
}
|
||||
return pathutil.Create(relPath, paths)
|
||||
}
|
||||
|
||||
func (bd baseDirectories) searchDataFile(relPath string) (string, error) {
|
||||
@ -64,5 +78,5 @@ func (bd baseDirectories) searchCacheFile(relPath string) (string, error) {
|
||||
}
|
||||
|
||||
func (bd baseDirectories) searchRuntimeFile(relPath string) (string, error) {
|
||||
return pathutil.Search(relPath, []string{bd.runtime})
|
||||
return pathutil.Search(relPath, pathutil.Unique([]string{bd.runtime, os.TempDir()}))
|
||||
}
|
||||
|
4
vendor/github.com/adrg/xdg/doc.go
generated
vendored
4
vendor/github.com/adrg/xdg/doc.go
generated
vendored
@ -37,6 +37,7 @@ XDG Base Directory
|
||||
log.Println("Home state directory:", xdg.StateHome)
|
||||
log.Println("Cache directory:", xdg.CacheHome)
|
||||
log.Println("Runtime directory:", xdg.RuntimeDir)
|
||||
log.Println("Home binaries directory:", xdg.BinHome)
|
||||
|
||||
// Other common directories.
|
||||
log.Println("Home directory:", xdg.Home)
|
||||
@ -47,6 +48,9 @@ XDG Base Directory
|
||||
// ConfigFile takes one parameter which must contain the name of the file,
|
||||
// but it can also contain a set of parent directories. If the directories
|
||||
// don't exist, they will be created relative to the base config directory.
|
||||
// It is recommended for files to be saved inside an application directory
|
||||
// relative to the base directory rather than directly inside the base
|
||||
// directory (e.g. `appname/config.yaml` instead of `appname-config.yaml`).
|
||||
configFilePath, err := xdg.ConfigFile("appname/config.yaml")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
11
vendor/github.com/adrg/xdg/internal/pathutil/pathutil.go
generated
vendored
11
vendor/github.com/adrg/xdg/internal/pathutil/pathutil.go
generated
vendored
@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Unique eliminates the duplicate paths from the provided slice and returns
|
||||
@ -52,7 +51,6 @@ func First(paths []string) string {
|
||||
// relative to the selected parent path.
|
||||
func Create(name string, paths []string) (string, error) {
|
||||
searchedPaths := make([]string, 0, len(paths))
|
||||
|
||||
for _, p := range paths {
|
||||
p = filepath.Join(p, name)
|
||||
|
||||
@ -67,8 +65,8 @@ func Create(name string, paths []string) (string, error) {
|
||||
searchedPaths = append(searchedPaths, dir)
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("could not create any of the following paths: %s",
|
||||
strings.Join(searchedPaths, ", "))
|
||||
return "", fmt.Errorf("could not create any of the following paths: %v",
|
||||
searchedPaths)
|
||||
}
|
||||
|
||||
// Search searches for the file with the specified `name` in the provided
|
||||
@ -76,7 +74,6 @@ func Create(name string, paths []string) (string, error) {
|
||||
// but it can also contain a set of parent directories.
|
||||
func Search(name string, paths []string) (string, error) {
|
||||
searchedPaths := make([]string, 0, len(paths))
|
||||
|
||||
for _, p := range paths {
|
||||
p = filepath.Join(p, name)
|
||||
if Exists(p) {
|
||||
@ -86,8 +83,8 @@ func Search(name string, paths []string) (string, error) {
|
||||
searchedPaths = append(searchedPaths, filepath.Dir(p))
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("could not locate `%s` in any of the following paths: %s",
|
||||
filepath.Base(name), strings.Join(searchedPaths, ", "))
|
||||
return "", fmt.Errorf("could not locate `%s` in any of the following paths: %v",
|
||||
filepath.Base(name), searchedPaths)
|
||||
}
|
||||
|
||||
// EnvPath returns the value of the environment variable with the specified
|
||||
|
8
vendor/github.com/adrg/xdg/paths_darwin.go
generated
vendored
8
vendor/github.com/adrg/xdg/paths_darwin.go
generated
vendored
@ -18,18 +18,24 @@ func initBaseDirs(home string) {
|
||||
|
||||
// Initialize standard directories.
|
||||
baseDirs.dataHome = pathutil.EnvPath(envDataHome, homeAppSupport)
|
||||
baseDirs.data = pathutil.EnvPathList(envDataDirs, rootAppSupport)
|
||||
baseDirs.data = pathutil.EnvPathList(envDataDirs,
|
||||
rootAppSupport,
|
||||
filepath.Join(home, ".local", "share"),
|
||||
)
|
||||
baseDirs.configHome = pathutil.EnvPath(envConfigHome, homeAppSupport)
|
||||
baseDirs.config = pathutil.EnvPathList(envConfigDirs,
|
||||
filepath.Join(home, "Library", "Preferences"),
|
||||
rootAppSupport,
|
||||
"/Library/Preferences",
|
||||
filepath.Join(home, ".config"),
|
||||
)
|
||||
baseDirs.stateHome = pathutil.EnvPath(envStateHome, homeAppSupport)
|
||||
baseDirs.cacheHome = pathutil.EnvPath(envCacheHome, filepath.Join(home, "Library", "Caches"))
|
||||
baseDirs.runtime = pathutil.EnvPath(envRuntimeDir, homeAppSupport)
|
||||
|
||||
// Initialize non-standard directories.
|
||||
baseDirs.binHome = pathutil.EnvPath(envBinHome, filepath.Join(home, ".local", "bin"))
|
||||
|
||||
baseDirs.applications = []string{
|
||||
"/Applications",
|
||||
}
|
||||
|
2
vendor/github.com/adrg/xdg/paths_plan9.go
generated
vendored
2
vendor/github.com/adrg/xdg/paths_plan9.go
generated
vendored
@ -26,6 +26,8 @@ func initBaseDirs(home string) {
|
||||
baseDirs.runtime = pathutil.EnvPath(envRuntimeDir, "/tmp")
|
||||
|
||||
// Initialize non-standard directories.
|
||||
baseDirs.binHome = pathutil.EnvPath(envBinHome, filepath.Join(home, "bin"))
|
||||
|
||||
baseDirs.applications = []string{
|
||||
filepath.Join(home, "bin"),
|
||||
"/bin",
|
||||
|
2
vendor/github.com/adrg/xdg/paths_unix.go
generated
vendored
2
vendor/github.com/adrg/xdg/paths_unix.go
generated
vendored
@ -27,6 +27,8 @@ func initBaseDirs(home string) {
|
||||
baseDirs.runtime = pathutil.EnvPath(envRuntimeDir, filepath.Join("/run/user", strconv.Itoa(os.Getuid())))
|
||||
|
||||
// Initialize non-standard directories.
|
||||
baseDirs.binHome = pathutil.EnvPath(envBinHome, filepath.Join(home, ".local", "bin"))
|
||||
|
||||
appDirs := []string{
|
||||
filepath.Join(baseDirs.dataHome, "applications"),
|
||||
filepath.Join(home, ".local/share/applications"),
|
||||
|
71
vendor/github.com/adrg/xdg/paths_windows.go
generated
vendored
71
vendor/github.com/adrg/xdg/paths_windows.go
generated
vendored
@ -25,10 +25,17 @@ func initBaseDirs(home string, kf *knownFolders) {
|
||||
baseDirs.runtime = pathutil.EnvPath(envRuntimeDir, kf.localAppData)
|
||||
|
||||
// Initialize non-standard directories.
|
||||
baseDirs.binHome = pathutil.EnvPath(envBinHome, kf.userProgramFiles)
|
||||
|
||||
baseDirs.applications = []string{
|
||||
kf.programs,
|
||||
kf.commonPrograms,
|
||||
kf.programFiles,
|
||||
kf.programFilesCommon,
|
||||
kf.userProgramFiles,
|
||||
kf.userProgramFilesCommon,
|
||||
}
|
||||
|
||||
baseDirs.fonts = []string{
|
||||
kf.fonts,
|
||||
filepath.Join(kf.localAppData, "Microsoft", "Windows", "Fonts"),
|
||||
@ -47,24 +54,28 @@ func initUserDirs(home string, kf *knownFolders) {
|
||||
}
|
||||
|
||||
type knownFolders struct {
|
||||
systemDrive string
|
||||
systemRoot string
|
||||
programData string
|
||||
userProfile string
|
||||
userProfiles string
|
||||
roamingAppData string
|
||||
localAppData string
|
||||
desktop string
|
||||
downloads string
|
||||
documents string
|
||||
music string
|
||||
pictures string
|
||||
videos string
|
||||
templates string
|
||||
public string
|
||||
fonts string
|
||||
programs string
|
||||
commonPrograms string
|
||||
systemDrive string
|
||||
systemRoot string
|
||||
programData string
|
||||
userProfile string
|
||||
userProfiles string
|
||||
roamingAppData string
|
||||
localAppData string
|
||||
desktop string
|
||||
downloads string
|
||||
documents string
|
||||
music string
|
||||
pictures string
|
||||
videos string
|
||||
templates string
|
||||
public string
|
||||
fonts string
|
||||
programs string
|
||||
commonPrograms string
|
||||
programFiles string
|
||||
programFilesCommon string
|
||||
userProgramFiles string
|
||||
userProgramFilesCommon string
|
||||
}
|
||||
|
||||
func initKnownFolders(home string) *knownFolders {
|
||||
@ -156,6 +167,30 @@ func initKnownFolders(home string) *knownFolders {
|
||||
nil,
|
||||
[]string{filepath.Join(kf.programData, "Microsoft", "Windows", "Start Menu", "Programs")},
|
||||
)
|
||||
kf.programFiles = pathutil.KnownFolder(
|
||||
windows.FOLDERID_ProgramFiles,
|
||||
[]string{"ProgramFiles"},
|
||||
[]string{filepath.Join(kf.systemDrive, "Program Files")},
|
||||
)
|
||||
kf.programFilesCommon = pathutil.KnownFolder(
|
||||
windows.FOLDERID_ProgramFilesCommon,
|
||||
nil,
|
||||
[]string{filepath.Join(kf.programFiles, "Common Files")},
|
||||
)
|
||||
kf.userProgramFiles = pathutil.KnownFolder(
|
||||
windows.FOLDERID_UserProgramFiles,
|
||||
nil,
|
||||
[]string{
|
||||
filepath.Join(kf.localAppData, "Programs"),
|
||||
},
|
||||
)
|
||||
kf.userProgramFilesCommon = pathutil.KnownFolder(
|
||||
windows.FOLDERID_UserProgramFilesCommon,
|
||||
nil,
|
||||
[]string{
|
||||
filepath.Join(kf.userProgramFiles, "Common"),
|
||||
},
|
||||
)
|
||||
|
||||
return kf
|
||||
}
|
||||
|
19
vendor/github.com/adrg/xdg/xdg.go
generated
vendored
19
vendor/github.com/adrg/xdg/xdg.go
generated
vendored
@ -67,6 +67,12 @@ var (
|
||||
// swapped out to disk.
|
||||
RuntimeDir string
|
||||
|
||||
// BinHome defines the base directory relative to which user-specific
|
||||
// binary files should be written. This directory is defined by
|
||||
// the non-standard $XDG_BIN_HOME environment variable. If the variable is
|
||||
// not set, a default equal to $HOME/.local/bin should be used.
|
||||
BinHome string
|
||||
|
||||
// UserDirs defines the locations of well known user directories.
|
||||
UserDirs UserDirectories
|
||||
|
||||
@ -104,6 +110,7 @@ func Reload() {
|
||||
RuntimeDir = baseDirs.runtime
|
||||
|
||||
// Set non-standard directories.
|
||||
BinHome = baseDirs.binHome
|
||||
FontDirs = baseDirs.fonts
|
||||
ApplicationDirs = baseDirs.applications
|
||||
}
|
||||
@ -154,8 +161,9 @@ func CacheFile(relPath string) (string, error) {
|
||||
// The relPath parameter must contain the name of the runtime file, and
|
||||
// optionally, a set of parent directories (e.g. appname/app.pid).
|
||||
// If the specified directories do not exist, they will be created relative
|
||||
// to the base runtime directory. On failure, an error containing the
|
||||
// attempted paths is returned.
|
||||
// to the base runtime directory. If the base runtime directory does not exist,
|
||||
// the operating system's temporary directory is used as a fallback. On failure,
|
||||
// an error containing the attempted paths is returned.
|
||||
func RuntimeFile(relPath string) (string, error) {
|
||||
return baseDirs.runtimeFile(relPath)
|
||||
}
|
||||
@ -194,8 +202,11 @@ func SearchCacheFile(relPath string) (string, error) {
|
||||
|
||||
// SearchRuntimeFile searches for the specified file in the runtime search path.
|
||||
// The relPath parameter must contain the name of the runtime file, and
|
||||
// optionally, a set of parent directories (e.g. appname/app.pid). If the
|
||||
// file cannot be found, an error specifying the searched path is returned.
|
||||
// optionally, a set of parent directories (e.g. appname/app.pid). The runtime
|
||||
// file is also searched in the operating system's temporary directory in order
|
||||
// to cover cases in which the runtime base directory does not exist or is not
|
||||
// accessible. If the file cannot be found, an error specifying the searched
|
||||
// paths is returned.
|
||||
func SearchRuntimeFile(relPath string) (string, error) {
|
||||
return baseDirs.searchRuntimeFile(relPath)
|
||||
}
|
||||
|
76
vendor/github.com/alessio/shellescape/CODE_OF_CONDUCT.md
generated
vendored
76
vendor/github.com/alessio/shellescape/CODE_OF_CONDUCT.md
generated
vendored
@ -1,76 +0,0 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at alessio@debian.org. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
31
vendor/github.com/go-openapi/errors/.golangci.yml
generated
vendored
31
vendor/github.com/go-openapi/errors/.golangci.yml
generated
vendored
@ -1,12 +1,6 @@
|
||||
linters-settings:
|
||||
govet:
|
||||
check-shadowing: true
|
||||
golint:
|
||||
min-confidence: 0
|
||||
gocyclo:
|
||||
min-complexity: 45
|
||||
maligned:
|
||||
suggest-new: true
|
||||
dupl:
|
||||
threshold: 200
|
||||
goconst:
|
||||
@ -16,8 +10,6 @@ linters-settings:
|
||||
linters:
|
||||
enable-all: true
|
||||
disable:
|
||||
- errname # this repo doesn't follow the convention advised by this linter
|
||||
- maligned
|
||||
- unparam
|
||||
- lll
|
||||
- gochecknoinits
|
||||
@ -30,9 +22,6 @@ linters:
|
||||
- wrapcheck
|
||||
- testpackage
|
||||
- nlreturn
|
||||
- gomnd
|
||||
- exhaustivestruct
|
||||
- goerr113
|
||||
- errorlint
|
||||
- nestif
|
||||
- godot
|
||||
@ -40,7 +29,6 @@ linters:
|
||||
- paralleltest
|
||||
- tparallel
|
||||
- thelper
|
||||
- ifshort
|
||||
- exhaustruct
|
||||
- varnamelen
|
||||
- gci
|
||||
@ -53,10 +41,15 @@ linters:
|
||||
- forcetypeassert
|
||||
- cyclop
|
||||
# deprecated linters
|
||||
- deadcode
|
||||
- interfacer
|
||||
- scopelint
|
||||
- varcheck
|
||||
- structcheck
|
||||
- golint
|
||||
- nosnakecase
|
||||
#- deadcode
|
||||
#- interfacer
|
||||
#- scopelint
|
||||
#- varcheck
|
||||
#- structcheck
|
||||
#- golint
|
||||
#- nosnakecase
|
||||
#- maligned
|
||||
#- goerr113
|
||||
#- ifshort
|
||||
#- gomnd
|
||||
#- exhaustivestruct
|
||||
|
2
vendor/github.com/go-openapi/errors/api.go
generated
vendored
2
vendor/github.com/go-openapi/errors/api.go
generated
vendored
@ -185,7 +185,7 @@ func ServeError(rw http.ResponseWriter, r *http.Request, err error) {
|
||||
}
|
||||
|
||||
func asHTTPCode(input int) int {
|
||||
if input >= 600 {
|
||||
if input >= maximumValidHTTPCode {
|
||||
return DefaultHTTPCode
|
||||
}
|
||||
return input
|
||||
|
2
vendor/github.com/go-openapi/errors/headers.go
generated
vendored
2
vendor/github.com/go-openapi/errors/headers.go
generated
vendored
@ -21,7 +21,7 @@ import (
|
||||
)
|
||||
|
||||
// Validation represents a failure of a precondition
|
||||
type Validation struct {
|
||||
type Validation struct { //nolint: errname
|
||||
code int32
|
||||
Name string
|
||||
In string
|
||||
|
2
vendor/github.com/go-openapi/errors/middleware.go
generated
vendored
2
vendor/github.com/go-openapi/errors/middleware.go
generated
vendored
@ -22,7 +22,7 @@ import (
|
||||
|
||||
// APIVerificationFailed is an error that contains all the missing info for a mismatched section
|
||||
// between the api registrations and the api spec
|
||||
type APIVerificationFailed struct {
|
||||
type APIVerificationFailed struct { //nolint: errname
|
||||
Section string `json:"section,omitempty"`
|
||||
MissingSpecification []string `json:"missingSpecification,omitempty"`
|
||||
MissingRegistration []string `json:"missingRegistration,omitempty"`
|
||||
|
3
vendor/github.com/go-openapi/errors/parsing.go
generated
vendored
3
vendor/github.com/go-openapi/errors/parsing.go
generated
vendored
@ -17,6 +17,7 @@ package errors
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// ParseError represents a parsing error
|
||||
@ -68,7 +69,7 @@ func NewParseError(name, in, value string, reason error) *ParseError {
|
||||
msg = fmt.Sprintf(parseErrorTemplContent, name, in, value, reason)
|
||||
}
|
||||
return &ParseError{
|
||||
code: 400,
|
||||
code: http.StatusBadRequest,
|
||||
Name: name,
|
||||
In: in,
|
||||
Value: value,
|
||||
|
110
vendor/github.com/go-openapi/errors/schema.go
generated
vendored
110
vendor/github.com/go-openapi/errors/schema.go
generated
vendored
@ -17,6 +17,7 @@ package errors
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -32,12 +33,12 @@ const (
|
||||
patternFail = "%s in %s should match '%s'"
|
||||
enumFail = "%s in %s should be one of %v"
|
||||
multipleOfFail = "%s in %s should be a multiple of %v"
|
||||
maxIncFail = "%s in %s should be less than or equal to %v"
|
||||
maxExcFail = "%s in %s should be less than %v"
|
||||
maximumIncFail = "%s in %s should be less than or equal to %v"
|
||||
maximumExcFail = "%s in %s should be less than %v"
|
||||
minIncFail = "%s in %s should be greater than or equal to %v"
|
||||
minExcFail = "%s in %s should be greater than %v"
|
||||
uniqueFail = "%s in %s shouldn't contain duplicates"
|
||||
maxItemsFail = "%s in %s should have at most %d items"
|
||||
maximumItemsFail = "%s in %s should have at most %d items"
|
||||
minItemsFail = "%s in %s should have at least %d items"
|
||||
typeFailNoIn = "%s must be of type %s"
|
||||
typeFailWithDataNoIn = "%s must be of type %s: %q"
|
||||
@ -49,12 +50,12 @@ const (
|
||||
patternFailNoIn = "%s should match '%s'"
|
||||
enumFailNoIn = "%s should be one of %v"
|
||||
multipleOfFailNoIn = "%s should be a multiple of %v"
|
||||
maxIncFailNoIn = "%s should be less than or equal to %v"
|
||||
maxExcFailNoIn = "%s should be less than %v"
|
||||
maximumIncFailNoIn = "%s should be less than or equal to %v"
|
||||
maximumExcFailNoIn = "%s should be less than %v"
|
||||
minIncFailNoIn = "%s should be greater than or equal to %v"
|
||||
minExcFailNoIn = "%s should be greater than %v"
|
||||
uniqueFailNoIn = "%s shouldn't contain duplicates"
|
||||
maxItemsFailNoIn = "%s should have at most %d items"
|
||||
maximumItemsFailNoIn = "%s should have at most %d items"
|
||||
minItemsFailNoIn = "%s should have at least %d items"
|
||||
noAdditionalItems = "%s in %s can't have additional items"
|
||||
noAdditionalItemsNoIn = "%s can't have additional items"
|
||||
@ -69,14 +70,17 @@ const (
|
||||
multipleOfMustBePositive = "factor MultipleOf declared for %s must be positive: %v"
|
||||
)
|
||||
|
||||
const maximumValidHTTPCode = 600
|
||||
|
||||
// All code responses can be used to differentiate errors for different handling
|
||||
// by the consuming program
|
||||
const (
|
||||
// CompositeErrorCode remains 422 for backwards-compatibility
|
||||
// and to separate it from validation errors with cause
|
||||
CompositeErrorCode = 422
|
||||
CompositeErrorCode = http.StatusUnprocessableEntity
|
||||
|
||||
// InvalidTypeCode is used for any subclass of invalid types
|
||||
InvalidTypeCode = 600 + iota
|
||||
InvalidTypeCode = maximumValidHTTPCode + iota
|
||||
RequiredFailCode
|
||||
TooLongFailCode
|
||||
TooShortFailCode
|
||||
@ -298,10 +302,10 @@ func DuplicateItems(name, in string) *Validation {
|
||||
}
|
||||
|
||||
// TooManyItems error for when an array contains too many items
|
||||
func TooManyItems(name, in string, max int64, value interface{}) *Validation {
|
||||
msg := fmt.Sprintf(maxItemsFail, name, in, max)
|
||||
func TooManyItems(name, in string, maximum int64, value interface{}) *Validation {
|
||||
msg := fmt.Sprintf(maximumItemsFail, name, in, maximum)
|
||||
if in == "" {
|
||||
msg = fmt.Sprintf(maxItemsFailNoIn, name, max)
|
||||
msg = fmt.Sprintf(maximumItemsFailNoIn, name, maximum)
|
||||
}
|
||||
|
||||
return &Validation{
|
||||
@ -314,10 +318,10 @@ func TooManyItems(name, in string, max int64, value interface{}) *Validation {
|
||||
}
|
||||
|
||||
// TooFewItems error for when an array contains too few items
|
||||
func TooFewItems(name, in string, min int64, value interface{}) *Validation {
|
||||
msg := fmt.Sprintf(minItemsFail, name, in, min)
|
||||
func TooFewItems(name, in string, minimum int64, value interface{}) *Validation {
|
||||
msg := fmt.Sprintf(minItemsFail, name, in, minimum)
|
||||
if in == "" {
|
||||
msg = fmt.Sprintf(minItemsFailNoIn, name, min)
|
||||
msg = fmt.Sprintf(minItemsFailNoIn, name, minimum)
|
||||
}
|
||||
return &Validation{
|
||||
code: MinItemsFailCode,
|
||||
@ -328,21 +332,21 @@ func TooFewItems(name, in string, min int64, value interface{}) *Validation {
|
||||
}
|
||||
}
|
||||
|
||||
// ExceedsMaximumInt error for when maximum validation fails
|
||||
func ExceedsMaximumInt(name, in string, max int64, exclusive bool, value interface{}) *Validation {
|
||||
// ExceedsMaximumInt error for when maximumimum validation fails
|
||||
func ExceedsMaximumInt(name, in string, maximum int64, exclusive bool, value interface{}) *Validation {
|
||||
var message string
|
||||
if in == "" {
|
||||
m := maxIncFailNoIn
|
||||
m := maximumIncFailNoIn
|
||||
if exclusive {
|
||||
m = maxExcFailNoIn
|
||||
m = maximumExcFailNoIn
|
||||
}
|
||||
message = fmt.Sprintf(m, name, max)
|
||||
message = fmt.Sprintf(m, name, maximum)
|
||||
} else {
|
||||
m := maxIncFail
|
||||
m := maximumIncFail
|
||||
if exclusive {
|
||||
m = maxExcFail
|
||||
m = maximumExcFail
|
||||
}
|
||||
message = fmt.Sprintf(m, name, in, max)
|
||||
message = fmt.Sprintf(m, name, in, maximum)
|
||||
}
|
||||
return &Validation{
|
||||
code: MaxFailCode,
|
||||
@ -353,21 +357,21 @@ func ExceedsMaximumInt(name, in string, max int64, exclusive bool, value interfa
|
||||
}
|
||||
}
|
||||
|
||||
// ExceedsMaximumUint error for when maximum validation fails
|
||||
func ExceedsMaximumUint(name, in string, max uint64, exclusive bool, value interface{}) *Validation {
|
||||
// ExceedsMaximumUint error for when maximumimum validation fails
|
||||
func ExceedsMaximumUint(name, in string, maximum uint64, exclusive bool, value interface{}) *Validation {
|
||||
var message string
|
||||
if in == "" {
|
||||
m := maxIncFailNoIn
|
||||
m := maximumIncFailNoIn
|
||||
if exclusive {
|
||||
m = maxExcFailNoIn
|
||||
m = maximumExcFailNoIn
|
||||
}
|
||||
message = fmt.Sprintf(m, name, max)
|
||||
message = fmt.Sprintf(m, name, maximum)
|
||||
} else {
|
||||
m := maxIncFail
|
||||
m := maximumIncFail
|
||||
if exclusive {
|
||||
m = maxExcFail
|
||||
m = maximumExcFail
|
||||
}
|
||||
message = fmt.Sprintf(m, name, in, max)
|
||||
message = fmt.Sprintf(m, name, in, maximum)
|
||||
}
|
||||
return &Validation{
|
||||
code: MaxFailCode,
|
||||
@ -378,21 +382,21 @@ func ExceedsMaximumUint(name, in string, max uint64, exclusive bool, value inter
|
||||
}
|
||||
}
|
||||
|
||||
// ExceedsMaximum error for when maximum validation fails
|
||||
func ExceedsMaximum(name, in string, max float64, exclusive bool, value interface{}) *Validation {
|
||||
// ExceedsMaximum error for when maximumimum validation fails
|
||||
func ExceedsMaximum(name, in string, maximum float64, exclusive bool, value interface{}) *Validation {
|
||||
var message string
|
||||
if in == "" {
|
||||
m := maxIncFailNoIn
|
||||
m := maximumIncFailNoIn
|
||||
if exclusive {
|
||||
m = maxExcFailNoIn
|
||||
m = maximumExcFailNoIn
|
||||
}
|
||||
message = fmt.Sprintf(m, name, max)
|
||||
message = fmt.Sprintf(m, name, maximum)
|
||||
} else {
|
||||
m := maxIncFail
|
||||
m := maximumIncFail
|
||||
if exclusive {
|
||||
m = maxExcFail
|
||||
m = maximumExcFail
|
||||
}
|
||||
message = fmt.Sprintf(m, name, in, max)
|
||||
message = fmt.Sprintf(m, name, in, maximum)
|
||||
}
|
||||
return &Validation{
|
||||
code: MaxFailCode,
|
||||
@ -404,20 +408,20 @@ func ExceedsMaximum(name, in string, max float64, exclusive bool, value interfac
|
||||
}
|
||||
|
||||
// ExceedsMinimumInt error for when minimum validation fails
|
||||
func ExceedsMinimumInt(name, in string, min int64, exclusive bool, value interface{}) *Validation {
|
||||
func ExceedsMinimumInt(name, in string, minimum int64, exclusive bool, value interface{}) *Validation {
|
||||
var message string
|
||||
if in == "" {
|
||||
m := minIncFailNoIn
|
||||
if exclusive {
|
||||
m = minExcFailNoIn
|
||||
}
|
||||
message = fmt.Sprintf(m, name, min)
|
||||
message = fmt.Sprintf(m, name, minimum)
|
||||
} else {
|
||||
m := minIncFail
|
||||
if exclusive {
|
||||
m = minExcFail
|
||||
}
|
||||
message = fmt.Sprintf(m, name, in, min)
|
||||
message = fmt.Sprintf(m, name, in, minimum)
|
||||
}
|
||||
return &Validation{
|
||||
code: MinFailCode,
|
||||
@ -429,20 +433,20 @@ func ExceedsMinimumInt(name, in string, min int64, exclusive bool, value interfa
|
||||
}
|
||||
|
||||
// ExceedsMinimumUint error for when minimum validation fails
|
||||
func ExceedsMinimumUint(name, in string, min uint64, exclusive bool, value interface{}) *Validation {
|
||||
func ExceedsMinimumUint(name, in string, minimum uint64, exclusive bool, value interface{}) *Validation {
|
||||
var message string
|
||||
if in == "" {
|
||||
m := minIncFailNoIn
|
||||
if exclusive {
|
||||
m = minExcFailNoIn
|
||||
}
|
||||
message = fmt.Sprintf(m, name, min)
|
||||
message = fmt.Sprintf(m, name, minimum)
|
||||
} else {
|
||||
m := minIncFail
|
||||
if exclusive {
|
||||
m = minExcFail
|
||||
}
|
||||
message = fmt.Sprintf(m, name, in, min)
|
||||
message = fmt.Sprintf(m, name, in, minimum)
|
||||
}
|
||||
return &Validation{
|
||||
code: MinFailCode,
|
||||
@ -454,20 +458,20 @@ func ExceedsMinimumUint(name, in string, min uint64, exclusive bool, value inter
|
||||
}
|
||||
|
||||
// ExceedsMinimum error for when minimum validation fails
|
||||
func ExceedsMinimum(name, in string, min float64, exclusive bool, value interface{}) *Validation {
|
||||
func ExceedsMinimum(name, in string, minimum float64, exclusive bool, value interface{}) *Validation {
|
||||
var message string
|
||||
if in == "" {
|
||||
m := minIncFailNoIn
|
||||
if exclusive {
|
||||
m = minExcFailNoIn
|
||||
}
|
||||
message = fmt.Sprintf(m, name, min)
|
||||
message = fmt.Sprintf(m, name, minimum)
|
||||
} else {
|
||||
m := minIncFail
|
||||
if exclusive {
|
||||
m = minExcFail
|
||||
}
|
||||
message = fmt.Sprintf(m, name, in, min)
|
||||
message = fmt.Sprintf(m, name, in, minimum)
|
||||
}
|
||||
return &Validation{
|
||||
code: MinFailCode,
|
||||
@ -549,12 +553,12 @@ func ReadOnly(name, in string, value interface{}) *Validation {
|
||||
}
|
||||
|
||||
// TooLong error for when a string is too long
|
||||
func TooLong(name, in string, max int64, value interface{}) *Validation {
|
||||
func TooLong(name, in string, maximum int64, value interface{}) *Validation {
|
||||
var msg string
|
||||
if in == "" {
|
||||
msg = fmt.Sprintf(tooLongMessageNoIn, name, max)
|
||||
msg = fmt.Sprintf(tooLongMessageNoIn, name, maximum)
|
||||
} else {
|
||||
msg = fmt.Sprintf(tooLongMessage, name, in, max)
|
||||
msg = fmt.Sprintf(tooLongMessage, name, in, maximum)
|
||||
}
|
||||
return &Validation{
|
||||
code: TooLongFailCode,
|
||||
@ -566,12 +570,12 @@ func TooLong(name, in string, max int64, value interface{}) *Validation {
|
||||
}
|
||||
|
||||
// TooShort error for when a string is too short
|
||||
func TooShort(name, in string, min int64, value interface{}) *Validation {
|
||||
func TooShort(name, in string, minimum int64, value interface{}) *Validation {
|
||||
var msg string
|
||||
if in == "" {
|
||||
msg = fmt.Sprintf(tooShortMessageNoIn, name, min)
|
||||
msg = fmt.Sprintf(tooShortMessageNoIn, name, minimum)
|
||||
} else {
|
||||
msg = fmt.Sprintf(tooShortMessage, name, in, min)
|
||||
msg = fmt.Sprintf(tooShortMessage, name, in, minimum)
|
||||
}
|
||||
|
||||
return &Validation{
|
||||
|
31
vendor/github.com/go-openapi/jsonpointer/.golangci.yml
generated
vendored
31
vendor/github.com/go-openapi/jsonpointer/.golangci.yml
generated
vendored
@ -1,12 +1,6 @@
|
||||
linters-settings:
|
||||
govet:
|
||||
check-shadowing: true
|
||||
golint:
|
||||
min-confidence: 0
|
||||
gocyclo:
|
||||
min-complexity: 45
|
||||
maligned:
|
||||
suggest-new: true
|
||||
dupl:
|
||||
threshold: 200
|
||||
goconst:
|
||||
@ -16,7 +10,7 @@ linters-settings:
|
||||
linters:
|
||||
enable-all: true
|
||||
disable:
|
||||
- maligned
|
||||
- recvcheck
|
||||
- unparam
|
||||
- lll
|
||||
- gochecknoinits
|
||||
@ -29,9 +23,6 @@ linters:
|
||||
- wrapcheck
|
||||
- testpackage
|
||||
- nlreturn
|
||||
- gomnd
|
||||
- exhaustivestruct
|
||||
- goerr113
|
||||
- errorlint
|
||||
- nestif
|
||||
- godot
|
||||
@ -39,7 +30,6 @@ linters:
|
||||
- paralleltest
|
||||
- tparallel
|
||||
- thelper
|
||||
- ifshort
|
||||
- exhaustruct
|
||||
- varnamelen
|
||||
- gci
|
||||
@ -52,10 +42,15 @@ linters:
|
||||
- forcetypeassert
|
||||
- cyclop
|
||||
# deprecated linters
|
||||
- deadcode
|
||||
- interfacer
|
||||
- scopelint
|
||||
- varcheck
|
||||
- structcheck
|
||||
- golint
|
||||
- nosnakecase
|
||||
#- deadcode
|
||||
#- interfacer
|
||||
#- scopelint
|
||||
#- varcheck
|
||||
#- structcheck
|
||||
#- golint
|
||||
#- nosnakecase
|
||||
#- maligned
|
||||
#- goerr113
|
||||
#- ifshort
|
||||
#- gomnd
|
||||
#- exhaustivestruct
|
||||
|
18
vendor/github.com/go-openapi/jsonpointer/errors.go
generated
vendored
Normal file
18
vendor/github.com/go-openapi/jsonpointer/errors.go
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
package jsonpointer
|
||||
|
||||
type pointerError string
|
||||
|
||||
func (e pointerError) Error() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
const (
|
||||
// ErrPointer is an error raised by the jsonpointer package
|
||||
ErrPointer pointerError = "JSON pointer error"
|
||||
|
||||
// ErrInvalidStart states that a JSON pointer must start with a separator ("/")
|
||||
ErrInvalidStart pointerError = `JSON pointer must be empty or start with a "` + pointerSeparator
|
||||
|
||||
// ErrUnsupportedValueType indicates that a value of the wrong type is being set
|
||||
ErrUnsupportedValueType pointerError = "only structs, pointers, maps and slices are supported for setting values"
|
||||
)
|
49
vendor/github.com/go-openapi/jsonpointer/pointer.go
generated
vendored
49
vendor/github.com/go-openapi/jsonpointer/pointer.go
generated
vendored
@ -39,9 +39,6 @@ import (
|
||||
const (
|
||||
emptyPointer = ``
|
||||
pointerSeparator = `/`
|
||||
|
||||
invalidStart = `JSON pointer must be empty or start with a "` + pointerSeparator
|
||||
notFound = `Can't find the pointer in the document`
|
||||
)
|
||||
|
||||
var jsonPointableType = reflect.TypeOf(new(JSONPointable)).Elem()
|
||||
@ -80,7 +77,7 @@ func (p *Pointer) parse(jsonPointerString string) error {
|
||||
|
||||
if jsonPointerString != emptyPointer {
|
||||
if !strings.HasPrefix(jsonPointerString, pointerSeparator) {
|
||||
err = errors.New(invalidStart)
|
||||
err = errors.Join(ErrInvalidStart, ErrPointer)
|
||||
} else {
|
||||
referenceTokens := strings.Split(jsonPointerString, pointerSeparator)
|
||||
p.referenceTokens = append(p.referenceTokens, referenceTokens[1:]...)
|
||||
@ -128,7 +125,7 @@ func getSingleImpl(node any, decodedToken string, nameProvider *swag.NameProvide
|
||||
rValue := reflect.Indirect(reflect.ValueOf(node))
|
||||
kind := rValue.Kind()
|
||||
if isNil(node) {
|
||||
return nil, kind, fmt.Errorf("nil value has not field %q", decodedToken)
|
||||
return nil, kind, fmt.Errorf("nil value has no field %q: %w", decodedToken, ErrPointer)
|
||||
}
|
||||
|
||||
switch typed := node.(type) {
|
||||
@ -146,7 +143,7 @@ func getSingleImpl(node any, decodedToken string, nameProvider *swag.NameProvide
|
||||
case reflect.Struct:
|
||||
nm, ok := nameProvider.GetGoNameForType(rValue.Type(), decodedToken)
|
||||
if !ok {
|
||||
return nil, kind, fmt.Errorf("object has no field %q", decodedToken)
|
||||
return nil, kind, fmt.Errorf("object has no field %q: %w", decodedToken, ErrPointer)
|
||||
}
|
||||
fld := rValue.FieldByName(nm)
|
||||
return fld.Interface(), kind, nil
|
||||
@ -158,7 +155,7 @@ func getSingleImpl(node any, decodedToken string, nameProvider *swag.NameProvide
|
||||
if mv.IsValid() {
|
||||
return mv.Interface(), kind, nil
|
||||
}
|
||||
return nil, kind, fmt.Errorf("object has no key %q", decodedToken)
|
||||
return nil, kind, fmt.Errorf("object has no key %q: %w", decodedToken, ErrPointer)
|
||||
|
||||
case reflect.Slice:
|
||||
tokenIndex, err := strconv.Atoi(decodedToken)
|
||||
@ -167,14 +164,14 @@ func getSingleImpl(node any, decodedToken string, nameProvider *swag.NameProvide
|
||||
}
|
||||
sLength := rValue.Len()
|
||||
if tokenIndex < 0 || tokenIndex >= sLength {
|
||||
return nil, kind, fmt.Errorf("index out of bounds array[0,%d] index '%d'", sLength-1, tokenIndex)
|
||||
return nil, kind, fmt.Errorf("index out of bounds array[0,%d] index '%d': %w", sLength-1, tokenIndex, ErrPointer)
|
||||
}
|
||||
|
||||
elem := rValue.Index(tokenIndex)
|
||||
return elem.Interface(), kind, nil
|
||||
|
||||
default:
|
||||
return nil, kind, fmt.Errorf("invalid token reference %q", decodedToken)
|
||||
return nil, kind, fmt.Errorf("invalid token reference %q: %w", decodedToken, ErrPointer)
|
||||
}
|
||||
|
||||
}
|
||||
@ -194,7 +191,7 @@ func setSingleImpl(node, data any, decodedToken string, nameProvider *swag.NameP
|
||||
case reflect.Struct:
|
||||
nm, ok := nameProvider.GetGoNameForType(rValue.Type(), decodedToken)
|
||||
if !ok {
|
||||
return fmt.Errorf("object has no field %q", decodedToken)
|
||||
return fmt.Errorf("object has no field %q: %w", decodedToken, ErrPointer)
|
||||
}
|
||||
fld := rValue.FieldByName(nm)
|
||||
if fld.IsValid() {
|
||||
@ -214,18 +211,18 @@ func setSingleImpl(node, data any, decodedToken string, nameProvider *swag.NameP
|
||||
}
|
||||
sLength := rValue.Len()
|
||||
if tokenIndex < 0 || tokenIndex >= sLength {
|
||||
return fmt.Errorf("index out of bounds array[0,%d] index '%d'", sLength, tokenIndex)
|
||||
return fmt.Errorf("index out of bounds array[0,%d] index '%d': %w", sLength, tokenIndex, ErrPointer)
|
||||
}
|
||||
|
||||
elem := rValue.Index(tokenIndex)
|
||||
if !elem.CanSet() {
|
||||
return fmt.Errorf("can't set slice index %s to %v", decodedToken, data)
|
||||
return fmt.Errorf("can't set slice index %s to %v: %w", decodedToken, data, ErrPointer)
|
||||
}
|
||||
elem.Set(reflect.ValueOf(data))
|
||||
return nil
|
||||
|
||||
default:
|
||||
return fmt.Errorf("invalid token reference %q", decodedToken)
|
||||
return fmt.Errorf("invalid token reference %q: %w", decodedToken, ErrPointer)
|
||||
}
|
||||
|
||||
}
|
||||
@ -244,7 +241,6 @@ func (p *Pointer) get(node any, nameProvider *swag.NameProvider) (any, reflect.K
|
||||
}
|
||||
|
||||
for _, token := range p.referenceTokens {
|
||||
|
||||
decodedToken := Unescape(token)
|
||||
|
||||
r, knd, err := getSingleImpl(node, decodedToken, nameProvider)
|
||||
@ -264,7 +260,10 @@ func (p *Pointer) set(node, data any, nameProvider *swag.NameProvider) error {
|
||||
knd := reflect.ValueOf(node).Kind()
|
||||
|
||||
if knd != reflect.Ptr && knd != reflect.Struct && knd != reflect.Map && knd != reflect.Slice && knd != reflect.Array {
|
||||
return errors.New("only structs, pointers, maps and slices are supported for setting values")
|
||||
return errors.Join(
|
||||
ErrUnsupportedValueType,
|
||||
ErrPointer,
|
||||
)
|
||||
}
|
||||
|
||||
if nameProvider == nil {
|
||||
@ -307,7 +306,7 @@ func (p *Pointer) set(node, data any, nameProvider *swag.NameProvider) error {
|
||||
case reflect.Struct:
|
||||
nm, ok := nameProvider.GetGoNameForType(rValue.Type(), decodedToken)
|
||||
if !ok {
|
||||
return fmt.Errorf("object has no field %q", decodedToken)
|
||||
return fmt.Errorf("object has no field %q: %w", decodedToken, ErrPointer)
|
||||
}
|
||||
fld := rValue.FieldByName(nm)
|
||||
if fld.CanAddr() && fld.Kind() != reflect.Interface && fld.Kind() != reflect.Map && fld.Kind() != reflect.Slice && fld.Kind() != reflect.Ptr {
|
||||
@ -321,7 +320,7 @@ func (p *Pointer) set(node, data any, nameProvider *swag.NameProvider) error {
|
||||
mv := rValue.MapIndex(kv)
|
||||
|
||||
if !mv.IsValid() {
|
||||
return fmt.Errorf("object has no key %q", decodedToken)
|
||||
return fmt.Errorf("object has no key %q: %w", decodedToken, ErrPointer)
|
||||
}
|
||||
if mv.CanAddr() && mv.Kind() != reflect.Interface && mv.Kind() != reflect.Map && mv.Kind() != reflect.Slice && mv.Kind() != reflect.Ptr {
|
||||
node = mv.Addr().Interface()
|
||||
@ -336,7 +335,7 @@ func (p *Pointer) set(node, data any, nameProvider *swag.NameProvider) error {
|
||||
}
|
||||
sLength := rValue.Len()
|
||||
if tokenIndex < 0 || tokenIndex >= sLength {
|
||||
return fmt.Errorf("index out of bounds array[0,%d] index '%d'", sLength, tokenIndex)
|
||||
return fmt.Errorf("index out of bounds array[0,%d] index '%d': %w", sLength, tokenIndex, ErrPointer)
|
||||
}
|
||||
|
||||
elem := rValue.Index(tokenIndex)
|
||||
@ -347,7 +346,7 @@ func (p *Pointer) set(node, data any, nameProvider *swag.NameProvider) error {
|
||||
node = elem.Interface()
|
||||
|
||||
default:
|
||||
return fmt.Errorf("invalid token reference %q", decodedToken)
|
||||
return fmt.Errorf("invalid token reference %q: %w", decodedToken, ErrPointer)
|
||||
}
|
||||
|
||||
}
|
||||
@ -404,10 +403,10 @@ func (p *Pointer) Offset(document string) (int64, error) {
|
||||
return 0, err
|
||||
}
|
||||
default:
|
||||
return 0, fmt.Errorf("invalid token %#v", tk)
|
||||
return 0, fmt.Errorf("invalid token %#v: %w", tk, ErrPointer)
|
||||
}
|
||||
default:
|
||||
return 0, fmt.Errorf("invalid token %#v", tk)
|
||||
return 0, fmt.Errorf("invalid token %#v: %w", tk, ErrPointer)
|
||||
}
|
||||
}
|
||||
return offset, nil
|
||||
@ -437,16 +436,16 @@ func offsetSingleObject(dec *json.Decoder, decodedToken string) (int64, error) {
|
||||
return offset, nil
|
||||
}
|
||||
default:
|
||||
return 0, fmt.Errorf("invalid token %#v", tk)
|
||||
return 0, fmt.Errorf("invalid token %#v: %w", tk, ErrPointer)
|
||||
}
|
||||
}
|
||||
return 0, fmt.Errorf("token reference %q not found", decodedToken)
|
||||
return 0, fmt.Errorf("token reference %q not found: %w", decodedToken, ErrPointer)
|
||||
}
|
||||
|
||||
func offsetSingleArray(dec *json.Decoder, decodedToken string) (int64, error) {
|
||||
idx, err := strconv.Atoi(decodedToken)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("token reference %q is not a number: %v", decodedToken, err)
|
||||
return 0, fmt.Errorf("token reference %q is not a number: %v: %w", decodedToken, err, ErrPointer)
|
||||
}
|
||||
var i int
|
||||
for i = 0; i < idx && dec.More(); i++ {
|
||||
@ -470,7 +469,7 @@ func offsetSingleArray(dec *json.Decoder, decodedToken string) (int64, error) {
|
||||
}
|
||||
|
||||
if !dec.More() {
|
||||
return 0, fmt.Errorf("token reference %q not found", decodedToken)
|
||||
return 0, fmt.Errorf("token reference %q not found: %w", decodedToken, ErrPointer)
|
||||
}
|
||||
return dec.InputOffset(), nil
|
||||
}
|
||||
|
34
vendor/github.com/go-openapi/swag/.golangci.yml
generated
vendored
34
vendor/github.com/go-openapi/swag/.golangci.yml
generated
vendored
@ -1,22 +1,17 @@
|
||||
linters-settings:
|
||||
govet:
|
||||
check-shadowing: true
|
||||
golint:
|
||||
min-confidence: 0
|
||||
gocyclo:
|
||||
min-complexity: 45
|
||||
maligned:
|
||||
suggest-new: true
|
||||
dupl:
|
||||
threshold: 200
|
||||
goconst:
|
||||
min-len: 3
|
||||
min-len: 2
|
||||
min-occurrences: 3
|
||||
|
||||
linters:
|
||||
enable-all: true
|
||||
disable:
|
||||
- maligned
|
||||
- recvcheck
|
||||
- unparam
|
||||
- lll
|
||||
- gochecknoinits
|
||||
- gochecknoglobals
|
||||
@ -28,9 +23,6 @@ linters:
|
||||
- wrapcheck
|
||||
- testpackage
|
||||
- nlreturn
|
||||
- gomnd
|
||||
- exhaustivestruct
|
||||
- goerr113
|
||||
- errorlint
|
||||
- nestif
|
||||
- godot
|
||||
@ -38,7 +30,6 @@ linters:
|
||||
- paralleltest
|
||||
- tparallel
|
||||
- thelper
|
||||
- ifshort
|
||||
- exhaustruct
|
||||
- varnamelen
|
||||
- gci
|
||||
@ -51,10 +42,15 @@ linters:
|
||||
- forcetypeassert
|
||||
- cyclop
|
||||
# deprecated linters
|
||||
- deadcode
|
||||
- interfacer
|
||||
- scopelint
|
||||
- varcheck
|
||||
- structcheck
|
||||
- golint
|
||||
- nosnakecase
|
||||
#- deadcode
|
||||
#- interfacer
|
||||
#- scopelint
|
||||
#- varcheck
|
||||
#- structcheck
|
||||
#- golint
|
||||
#- nosnakecase
|
||||
#- maligned
|
||||
#- goerr113
|
||||
#- ifshort
|
||||
#- gomnd
|
||||
#- exhaustivestruct
|
||||
|
15
vendor/github.com/go-openapi/swag/errors.go
generated
vendored
Normal file
15
vendor/github.com/go-openapi/swag/errors.go
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
package swag
|
||||
|
||||
type swagError string
|
||||
|
||||
const (
|
||||
// ErrYAML is an error raised by YAML utilities
|
||||
ErrYAML swagError = "yaml error"
|
||||
|
||||
// ErrLoader is an error raised by the file loader utility
|
||||
ErrLoader swagError = "loader error"
|
||||
)
|
||||
|
||||
func (e swagError) Error() string {
|
||||
return string(e)
|
||||
}
|
3
vendor/github.com/go-openapi/swag/json.go
generated
vendored
3
vendor/github.com/go-openapi/swag/json.go
generated
vendored
@ -126,7 +126,8 @@ func ConcatJSON(blobs ...[]byte) []byte {
|
||||
continue // don't know how to concatenate non container objects
|
||||
}
|
||||
|
||||
if len(b) < 3 { // yep empty but also the last one, so closing this thing
|
||||
const minLengthIfNotEmpty = 3
|
||||
if len(b) < minLengthIfNotEmpty { // yep empty but also the last one, so closing this thing
|
||||
if i == last && a > 0 {
|
||||
if err := buf.WriteByte(closing); err != nil {
|
||||
log.Println(err)
|
||||
|
2
vendor/github.com/go-openapi/swag/loading.go
generated
vendored
2
vendor/github.com/go-openapi/swag/loading.go
generated
vendored
@ -168,7 +168,7 @@ func loadHTTPBytes(timeout time.Duration) func(path string) ([]byte, error) {
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf("could not access document at %q [%s] ", path, resp.Status)
|
||||
return nil, fmt.Errorf("could not access document at %q [%s]: %w", path, resp.Status, ErrLoader)
|
||||
}
|
||||
|
||||
return io.ReadAll(resp.Body)
|
||||
|
32
vendor/github.com/go-openapi/swag/yaml.go
generated
vendored
32
vendor/github.com/go-openapi/swag/yaml.go
generated
vendored
@ -16,7 +16,6 @@ package swag
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
@ -51,7 +50,7 @@ func BytesToYAMLDoc(data []byte) (interface{}, error) {
|
||||
return nil, err
|
||||
}
|
||||
if document.Kind != yaml.DocumentNode || len(document.Content) != 1 || document.Content[0].Kind != yaml.MappingNode {
|
||||
return nil, errors.New("only YAML documents that are objects are supported")
|
||||
return nil, fmt.Errorf("only YAML documents that are objects are supported: %w", ErrYAML)
|
||||
}
|
||||
return &document, nil
|
||||
}
|
||||
@ -69,31 +68,32 @@ func yamlNode(root *yaml.Node) (interface{}, error) {
|
||||
case yaml.AliasNode:
|
||||
return yamlNode(root.Alias)
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported YAML node type: %v", root.Kind)
|
||||
return nil, fmt.Errorf("unsupported YAML node type: %v: %w", root.Kind, ErrYAML)
|
||||
}
|
||||
}
|
||||
|
||||
func yamlDocument(node *yaml.Node) (interface{}, error) {
|
||||
if len(node.Content) != 1 {
|
||||
return nil, fmt.Errorf("unexpected YAML Document node content length: %d", len(node.Content))
|
||||
return nil, fmt.Errorf("unexpected YAML Document node content length: %d: %w", len(node.Content), ErrYAML)
|
||||
}
|
||||
return yamlNode(node.Content[0])
|
||||
}
|
||||
|
||||
func yamlMapping(node *yaml.Node) (interface{}, error) {
|
||||
m := make(JSONMapSlice, len(node.Content)/2)
|
||||
const sensibleAllocDivider = 2
|
||||
m := make(JSONMapSlice, len(node.Content)/sensibleAllocDivider)
|
||||
|
||||
var j int
|
||||
for i := 0; i < len(node.Content); i += 2 {
|
||||
var nmi JSONMapItem
|
||||
k, err := yamlStringScalarC(node.Content[i])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to decode YAML map key: %w", err)
|
||||
return nil, fmt.Errorf("unable to decode YAML map key: %w: %w", err, ErrYAML)
|
||||
}
|
||||
nmi.Key = k
|
||||
v, err := yamlNode(node.Content[i+1])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to process YAML map value for key %q: %w", k, err)
|
||||
return nil, fmt.Errorf("unable to process YAML map value for key %q: %w: %w", k, err, ErrYAML)
|
||||
}
|
||||
nmi.Value = v
|
||||
m[j] = nmi
|
||||
@ -109,7 +109,7 @@ func yamlSequence(node *yaml.Node) (interface{}, error) {
|
||||
|
||||
v, err := yamlNode(node.Content[i])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to decode YAML sequence value: %w", err)
|
||||
return nil, fmt.Errorf("unable to decode YAML sequence value: %w: %w", err, ErrYAML)
|
||||
}
|
||||
s = append(s, v)
|
||||
}
|
||||
@ -132,19 +132,19 @@ func yamlScalar(node *yaml.Node) (interface{}, error) {
|
||||
case yamlBoolScalar:
|
||||
b, err := strconv.ParseBool(node.Value)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to process scalar node. Got %q. Expecting bool content: %w", node.Value, err)
|
||||
return nil, fmt.Errorf("unable to process scalar node. Got %q. Expecting bool content: %w: %w", node.Value, err, ErrYAML)
|
||||
}
|
||||
return b, nil
|
||||
case yamlIntScalar:
|
||||
i, err := strconv.ParseInt(node.Value, 10, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to process scalar node. Got %q. Expecting integer content: %w", node.Value, err)
|
||||
return nil, fmt.Errorf("unable to process scalar node. Got %q. Expecting integer content: %w: %w", node.Value, err, ErrYAML)
|
||||
}
|
||||
return i, nil
|
||||
case yamlFloatScalar:
|
||||
f, err := strconv.ParseFloat(node.Value, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to process scalar node. Got %q. Expecting float content: %w", node.Value, err)
|
||||
return nil, fmt.Errorf("unable to process scalar node. Got %q. Expecting float content: %w: %w", node.Value, err, ErrYAML)
|
||||
}
|
||||
return f, nil
|
||||
case yamlTimestamp:
|
||||
@ -152,19 +152,19 @@ func yamlScalar(node *yaml.Node) (interface{}, error) {
|
||||
case yamlNull:
|
||||
return nil, nil //nolint:nilnil
|
||||
default:
|
||||
return nil, fmt.Errorf("YAML tag %q is not supported", node.LongTag())
|
||||
return nil, fmt.Errorf("YAML tag %q is not supported: %w", node.LongTag(), ErrYAML)
|
||||
}
|
||||
}
|
||||
|
||||
func yamlStringScalarC(node *yaml.Node) (string, error) {
|
||||
if node.Kind != yaml.ScalarNode {
|
||||
return "", fmt.Errorf("expecting a string scalar but got %q", node.Kind)
|
||||
return "", fmt.Errorf("expecting a string scalar but got %q: %w", node.Kind, ErrYAML)
|
||||
}
|
||||
switch node.LongTag() {
|
||||
case yamlStringScalar, yamlIntScalar, yamlFloatScalar:
|
||||
return node.Value, nil
|
||||
default:
|
||||
return "", fmt.Errorf("YAML tag %q is not supported as map key", node.LongTag())
|
||||
return "", fmt.Errorf("YAML tag %q is not supported as map key: %w", node.LongTag(), ErrYAML)
|
||||
}
|
||||
}
|
||||
|
||||
@ -349,7 +349,7 @@ func json2yaml(item interface{}) (*yaml.Node, error) {
|
||||
Value: strconv.FormatBool(val),
|
||||
}, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unhandled type: %T", val)
|
||||
return nil, fmt.Errorf("unhandled type: %T: %w", val, ErrYAML)
|
||||
}
|
||||
}
|
||||
|
||||
@ -416,7 +416,7 @@ func transformData(input interface{}) (out interface{}, err error) {
|
||||
case int64:
|
||||
return strconv.FormatInt(k, 10), nil
|
||||
default:
|
||||
return "", fmt.Errorf("unexpected map key type, got: %T", k)
|
||||
return "", fmt.Errorf("unexpected map key type, got: %T: %w", k, ErrYAML)
|
||||
}
|
||||
}
|
||||
|
||||
|
5
vendor/github.com/mailru/easyjson/jlexer/bytestostr.go
generated
vendored
5
vendor/github.com/mailru/easyjson/jlexer/bytestostr.go
generated
vendored
@ -8,7 +8,6 @@
|
||||
package jlexer
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
@ -18,7 +17,5 @@ import (
|
||||
// chunk may be either blocked from being freed by GC because of a single string or the buffer.Data
|
||||
// may be garbage-collected even when the string exists.
|
||||
func bytesToStr(data []byte) string {
|
||||
h := (*reflect.SliceHeader)(unsafe.Pointer(&data))
|
||||
shdr := reflect.StringHeader{Data: h.Data, Len: h.Len}
|
||||
return *(*string)(unsafe.Pointer(&shdr))
|
||||
return *(*string)(unsafe.Pointer(&data))
|
||||
}
|
||||
|
113
vendor/github.com/mailru/easyjson/jlexer/lexer.go
generated
vendored
113
vendor/github.com/mailru/easyjson/jlexer/lexer.go
generated
vendored
@ -19,21 +19,21 @@ import (
|
||||
"github.com/josharian/intern"
|
||||
)
|
||||
|
||||
// tokenKind determines type of a token.
|
||||
type tokenKind byte
|
||||
// TokenKind determines type of a token.
|
||||
type TokenKind byte
|
||||
|
||||
const (
|
||||
tokenUndef tokenKind = iota // No token.
|
||||
tokenDelim // Delimiter: one of '{', '}', '[' or ']'.
|
||||
tokenString // A string literal, e.g. "abc\u1234"
|
||||
tokenNumber // Number literal, e.g. 1.5e5
|
||||
tokenBool // Boolean literal: true or false.
|
||||
tokenNull // null keyword.
|
||||
TokenUndef TokenKind = iota // No token.
|
||||
TokenDelim // Delimiter: one of '{', '}', '[' or ']'.
|
||||
TokenString // A string literal, e.g. "abc\u1234"
|
||||
TokenNumber // Number literal, e.g. 1.5e5
|
||||
TokenBool // Boolean literal: true or false.
|
||||
TokenNull // null keyword.
|
||||
)
|
||||
|
||||
// token describes a single token: type, position in the input and value.
|
||||
type token struct {
|
||||
kind tokenKind // Type of a token.
|
||||
kind TokenKind // Type of a token.
|
||||
|
||||
boolValue bool // Value if a boolean literal token.
|
||||
byteValueCloned bool // true if byteValue was allocated and does not refer to original json body
|
||||
@ -47,7 +47,7 @@ type Lexer struct {
|
||||
|
||||
start int // Start of the current token.
|
||||
pos int // Current unscanned position in the input stream.
|
||||
token token // Last scanned token, if token.kind != tokenUndef.
|
||||
token token // Last scanned token, if token.kind != TokenUndef.
|
||||
|
||||
firstElement bool // Whether current element is the first in array or an object.
|
||||
wantSep byte // A comma or a colon character, which need to occur before a token.
|
||||
@ -59,7 +59,7 @@ type Lexer struct {
|
||||
|
||||
// FetchToken scans the input for the next token.
|
||||
func (r *Lexer) FetchToken() {
|
||||
r.token.kind = tokenUndef
|
||||
r.token.kind = TokenUndef
|
||||
r.start = r.pos
|
||||
|
||||
// Check if r.Data has r.pos element
|
||||
@ -90,7 +90,7 @@ func (r *Lexer) FetchToken() {
|
||||
r.errSyntax()
|
||||
}
|
||||
|
||||
r.token.kind = tokenString
|
||||
r.token.kind = TokenString
|
||||
r.fetchString()
|
||||
return
|
||||
|
||||
@ -99,7 +99,7 @@ func (r *Lexer) FetchToken() {
|
||||
r.errSyntax()
|
||||
}
|
||||
r.firstElement = true
|
||||
r.token.kind = tokenDelim
|
||||
r.token.kind = TokenDelim
|
||||
r.token.delimValue = r.Data[r.pos]
|
||||
r.pos++
|
||||
return
|
||||
@ -109,7 +109,7 @@ func (r *Lexer) FetchToken() {
|
||||
r.errSyntax()
|
||||
}
|
||||
r.wantSep = 0
|
||||
r.token.kind = tokenDelim
|
||||
r.token.kind = TokenDelim
|
||||
r.token.delimValue = r.Data[r.pos]
|
||||
r.pos++
|
||||
return
|
||||
@ -118,7 +118,7 @@ func (r *Lexer) FetchToken() {
|
||||
if r.wantSep != 0 {
|
||||
r.errSyntax()
|
||||
}
|
||||
r.token.kind = tokenNumber
|
||||
r.token.kind = TokenNumber
|
||||
r.fetchNumber()
|
||||
return
|
||||
|
||||
@ -127,7 +127,7 @@ func (r *Lexer) FetchToken() {
|
||||
r.errSyntax()
|
||||
}
|
||||
|
||||
r.token.kind = tokenNull
|
||||
r.token.kind = TokenNull
|
||||
r.fetchNull()
|
||||
return
|
||||
|
||||
@ -136,7 +136,7 @@ func (r *Lexer) FetchToken() {
|
||||
r.errSyntax()
|
||||
}
|
||||
|
||||
r.token.kind = tokenBool
|
||||
r.token.kind = TokenBool
|
||||
r.token.boolValue = true
|
||||
r.fetchTrue()
|
||||
return
|
||||
@ -146,7 +146,7 @@ func (r *Lexer) FetchToken() {
|
||||
r.errSyntax()
|
||||
}
|
||||
|
||||
r.token.kind = tokenBool
|
||||
r.token.kind = TokenBool
|
||||
r.token.boolValue = false
|
||||
r.fetchFalse()
|
||||
return
|
||||
@ -391,7 +391,7 @@ func (r *Lexer) fetchString() {
|
||||
|
||||
// scanToken scans the next token if no token is currently available in the lexer.
|
||||
func (r *Lexer) scanToken() {
|
||||
if r.token.kind != tokenUndef || r.fatalError != nil {
|
||||
if r.token.kind != TokenUndef || r.fatalError != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@ -400,7 +400,7 @@ func (r *Lexer) scanToken() {
|
||||
|
||||
// consume resets the current token to allow scanning the next one.
|
||||
func (r *Lexer) consume() {
|
||||
r.token.kind = tokenUndef
|
||||
r.token.kind = TokenUndef
|
||||
r.token.byteValueCloned = false
|
||||
r.token.delimValue = 0
|
||||
}
|
||||
@ -443,10 +443,10 @@ func (r *Lexer) errInvalidToken(expected string) {
|
||||
switch expected {
|
||||
case "[":
|
||||
r.token.delimValue = ']'
|
||||
r.token.kind = tokenDelim
|
||||
r.token.kind = TokenDelim
|
||||
case "{":
|
||||
r.token.delimValue = '}'
|
||||
r.token.kind = tokenDelim
|
||||
r.token.kind = TokenDelim
|
||||
}
|
||||
r.addNonfatalError(&LexerError{
|
||||
Reason: fmt.Sprintf("expected %s", expected),
|
||||
@ -475,7 +475,7 @@ func (r *Lexer) GetPos() int {
|
||||
|
||||
// Delim consumes a token and verifies that it is the given delimiter.
|
||||
func (r *Lexer) Delim(c byte) {
|
||||
if r.token.kind == tokenUndef && r.Ok() {
|
||||
if r.token.kind == TokenUndef && r.Ok() {
|
||||
r.FetchToken()
|
||||
}
|
||||
|
||||
@ -489,7 +489,7 @@ func (r *Lexer) Delim(c byte) {
|
||||
|
||||
// IsDelim returns true if there was no scanning error and next token is the given delimiter.
|
||||
func (r *Lexer) IsDelim(c byte) bool {
|
||||
if r.token.kind == tokenUndef && r.Ok() {
|
||||
if r.token.kind == TokenUndef && r.Ok() {
|
||||
r.FetchToken()
|
||||
}
|
||||
return !r.Ok() || r.token.delimValue == c
|
||||
@ -497,10 +497,10 @@ func (r *Lexer) IsDelim(c byte) bool {
|
||||
|
||||
// Null verifies that the next token is null and consumes it.
|
||||
func (r *Lexer) Null() {
|
||||
if r.token.kind == tokenUndef && r.Ok() {
|
||||
if r.token.kind == TokenUndef && r.Ok() {
|
||||
r.FetchToken()
|
||||
}
|
||||
if !r.Ok() || r.token.kind != tokenNull {
|
||||
if !r.Ok() || r.token.kind != TokenNull {
|
||||
r.errInvalidToken("null")
|
||||
}
|
||||
r.consume()
|
||||
@ -508,15 +508,15 @@ func (r *Lexer) Null() {
|
||||
|
||||
// IsNull returns true if the next token is a null keyword.
|
||||
func (r *Lexer) IsNull() bool {
|
||||
if r.token.kind == tokenUndef && r.Ok() {
|
||||
if r.token.kind == TokenUndef && r.Ok() {
|
||||
r.FetchToken()
|
||||
}
|
||||
return r.Ok() && r.token.kind == tokenNull
|
||||
return r.Ok() && r.token.kind == TokenNull
|
||||
}
|
||||
|
||||
// Skip skips a single token.
|
||||
func (r *Lexer) Skip() {
|
||||
if r.token.kind == tokenUndef && r.Ok() {
|
||||
if r.token.kind == TokenUndef && r.Ok() {
|
||||
r.FetchToken()
|
||||
}
|
||||
r.consume()
|
||||
@ -621,10 +621,10 @@ func (r *Lexer) Consumed() {
|
||||
}
|
||||
|
||||
func (r *Lexer) unsafeString(skipUnescape bool) (string, []byte) {
|
||||
if r.token.kind == tokenUndef && r.Ok() {
|
||||
if r.token.kind == TokenUndef && r.Ok() {
|
||||
r.FetchToken()
|
||||
}
|
||||
if !r.Ok() || r.token.kind != tokenString {
|
||||
if !r.Ok() || r.token.kind != TokenString {
|
||||
r.errInvalidToken("string")
|
||||
return "", nil
|
||||
}
|
||||
@ -664,10 +664,10 @@ func (r *Lexer) UnsafeFieldName(skipUnescape bool) string {
|
||||
|
||||
// String reads a string literal.
|
||||
func (r *Lexer) String() string {
|
||||
if r.token.kind == tokenUndef && r.Ok() {
|
||||
if r.token.kind == TokenUndef && r.Ok() {
|
||||
r.FetchToken()
|
||||
}
|
||||
if !r.Ok() || r.token.kind != tokenString {
|
||||
if !r.Ok() || r.token.kind != TokenString {
|
||||
r.errInvalidToken("string")
|
||||
return ""
|
||||
}
|
||||
@ -687,10 +687,10 @@ func (r *Lexer) String() string {
|
||||
|
||||
// StringIntern reads a string literal, and performs string interning on it.
|
||||
func (r *Lexer) StringIntern() string {
|
||||
if r.token.kind == tokenUndef && r.Ok() {
|
||||
if r.token.kind == TokenUndef && r.Ok() {
|
||||
r.FetchToken()
|
||||
}
|
||||
if !r.Ok() || r.token.kind != tokenString {
|
||||
if !r.Ok() || r.token.kind != TokenString {
|
||||
r.errInvalidToken("string")
|
||||
return ""
|
||||
}
|
||||
@ -705,10 +705,10 @@ func (r *Lexer) StringIntern() string {
|
||||
|
||||
// Bytes reads a string literal and base64 decodes it into a byte slice.
|
||||
func (r *Lexer) Bytes() []byte {
|
||||
if r.token.kind == tokenUndef && r.Ok() {
|
||||
if r.token.kind == TokenUndef && r.Ok() {
|
||||
r.FetchToken()
|
||||
}
|
||||
if !r.Ok() || r.token.kind != tokenString {
|
||||
if !r.Ok() || r.token.kind != TokenString {
|
||||
r.errInvalidToken("string")
|
||||
return nil
|
||||
}
|
||||
@ -731,10 +731,10 @@ func (r *Lexer) Bytes() []byte {
|
||||
|
||||
// Bool reads a true or false boolean keyword.
|
||||
func (r *Lexer) Bool() bool {
|
||||
if r.token.kind == tokenUndef && r.Ok() {
|
||||
if r.token.kind == TokenUndef && r.Ok() {
|
||||
r.FetchToken()
|
||||
}
|
||||
if !r.Ok() || r.token.kind != tokenBool {
|
||||
if !r.Ok() || r.token.kind != TokenBool {
|
||||
r.errInvalidToken("bool")
|
||||
return false
|
||||
}
|
||||
@ -744,10 +744,10 @@ func (r *Lexer) Bool() bool {
|
||||
}
|
||||
|
||||
func (r *Lexer) number() string {
|
||||
if r.token.kind == tokenUndef && r.Ok() {
|
||||
if r.token.kind == TokenUndef && r.Ok() {
|
||||
r.FetchToken()
|
||||
}
|
||||
if !r.Ok() || r.token.kind != tokenNumber {
|
||||
if !r.Ok() || r.token.kind != TokenNumber {
|
||||
r.errInvalidToken("number")
|
||||
return ""
|
||||
}
|
||||
@ -1151,7 +1151,7 @@ func (r *Lexer) GetNonFatalErrors() []*LexerError {
|
||||
// JsonNumber fetches and json.Number from 'encoding/json' package.
|
||||
// Both int, float or string, contains them are valid values
|
||||
func (r *Lexer) JsonNumber() json.Number {
|
||||
if r.token.kind == tokenUndef && r.Ok() {
|
||||
if r.token.kind == TokenUndef && r.Ok() {
|
||||
r.FetchToken()
|
||||
}
|
||||
if !r.Ok() {
|
||||
@ -1160,11 +1160,11 @@ func (r *Lexer) JsonNumber() json.Number {
|
||||
}
|
||||
|
||||
switch r.token.kind {
|
||||
case tokenString:
|
||||
case TokenString:
|
||||
return json.Number(r.String())
|
||||
case tokenNumber:
|
||||
case TokenNumber:
|
||||
return json.Number(r.Raw())
|
||||
case tokenNull:
|
||||
case TokenNull:
|
||||
r.Null()
|
||||
return json.Number("")
|
||||
default:
|
||||
@ -1175,7 +1175,7 @@ func (r *Lexer) JsonNumber() json.Number {
|
||||
|
||||
// Interface fetches an interface{} analogous to the 'encoding/json' package.
|
||||
func (r *Lexer) Interface() interface{} {
|
||||
if r.token.kind == tokenUndef && r.Ok() {
|
||||
if r.token.kind == TokenUndef && r.Ok() {
|
||||
r.FetchToken()
|
||||
}
|
||||
|
||||
@ -1183,13 +1183,13 @@ func (r *Lexer) Interface() interface{} {
|
||||
return nil
|
||||
}
|
||||
switch r.token.kind {
|
||||
case tokenString:
|
||||
case TokenString:
|
||||
return r.String()
|
||||
case tokenNumber:
|
||||
case TokenNumber:
|
||||
return r.Float64()
|
||||
case tokenBool:
|
||||
case TokenBool:
|
||||
return r.Bool()
|
||||
case tokenNull:
|
||||
case TokenNull:
|
||||
r.Null()
|
||||
return nil
|
||||
}
|
||||
@ -1242,3 +1242,16 @@ func (r *Lexer) WantColon() {
|
||||
r.wantSep = ':'
|
||||
r.firstElement = false
|
||||
}
|
||||
|
||||
// CurrentToken returns current token kind if there were no errors and TokenUndef otherwise
|
||||
func (r *Lexer) CurrentToken() TokenKind {
|
||||
if r.token.kind == TokenUndef && r.Ok() {
|
||||
r.FetchToken()
|
||||
}
|
||||
|
||||
if !r.Ok() {
|
||||
return TokenUndef
|
||||
}
|
||||
|
||||
return r.token.kind
|
||||
}
|
||||
|
12
vendor/github.com/mailru/easyjson/jwriter/writer.go
generated
vendored
12
vendor/github.com/mailru/easyjson/jwriter/writer.go
generated
vendored
@ -67,6 +67,18 @@ func (w *Writer) RawString(s string) {
|
||||
w.Buffer.AppendString(s)
|
||||
}
|
||||
|
||||
// RawBytesString appends string from bytes to the buffer.
|
||||
func (w *Writer) RawBytesString(data []byte, err error) {
|
||||
switch {
|
||||
case w.Error != nil:
|
||||
return
|
||||
case err != nil:
|
||||
w.Error = err
|
||||
default:
|
||||
w.String(string(data))
|
||||
}
|
||||
}
|
||||
|
||||
// Raw appends raw binary data to the buffer or sets the error if it is given. Useful for
|
||||
// calling with results of MarshalJSON-like functions.
|
||||
func (w *Writer) Raw(data []byte, err error) {
|
||||
|
5
vendor/github.com/spf13/cobra/README.md
generated
vendored
5
vendor/github.com/spf13/cobra/README.md
generated
vendored
@ -1,4 +1,5 @@
|
||||

|
||||
|
||||

|
||||
|
||||
Cobra is a library for creating powerful modern CLI applications.
|
||||
|
||||
@ -105,7 +106,7 @@ go install github.com/spf13/cobra-cli@latest
|
||||
|
||||
For complete details on using the Cobra-CLI generator, please read [The Cobra Generator README](https://github.com/spf13/cobra-cli/blob/main/README.md)
|
||||
|
||||
For complete details on using the Cobra library, please read the [The Cobra User Guide](site/content/user_guide.md).
|
||||
For complete details on using the Cobra library, please read [The Cobra User Guide](site/content/user_guide.md).
|
||||
|
||||
# License
|
||||
|
||||
|
2
vendor/github.com/spf13/cobra/active_help.go
generated
vendored
2
vendor/github.com/spf13/cobra/active_help.go
generated
vendored
@ -35,7 +35,7 @@ const (
|
||||
// This function can be called multiple times before and/or after completions are added to
|
||||
// the array. Each time this function is called with the same array, the new
|
||||
// ActiveHelp line will be shown below the previous ones when completion is triggered.
|
||||
func AppendActiveHelp(compArray []string, activeHelpStr string) []string {
|
||||
func AppendActiveHelp(compArray []Completion, activeHelpStr string) []Completion {
|
||||
return append(compArray, fmt.Sprintf("%s%s", activeHelpMarker, activeHelpStr))
|
||||
}
|
||||
|
||||
|
152
vendor/github.com/spf13/cobra/bash_completionsV2.go
generated
vendored
152
vendor/github.com/spf13/cobra/bash_completionsV2.go
generated
vendored
@ -146,7 +146,7 @@ __%[1]s_process_completion_results() {
|
||||
|
||||
if (((directive & shellCompDirectiveFilterFileExt) != 0)); then
|
||||
# File extension filtering
|
||||
local fullFilter filter filteringCmd
|
||||
local fullFilter="" filter filteringCmd
|
||||
|
||||
# Do not use quotes around the $completions variable or else newline
|
||||
# characters will be kept.
|
||||
@ -177,20 +177,71 @@ __%[1]s_process_completion_results() {
|
||||
__%[1]s_handle_special_char "$cur" =
|
||||
|
||||
# Print the activeHelp statements before we finish
|
||||
if ((${#activeHelp[*]} != 0)); then
|
||||
printf "\n";
|
||||
printf "%%s\n" "${activeHelp[@]}"
|
||||
printf "\n"
|
||||
__%[1]s_handle_activeHelp
|
||||
}
|
||||
|
||||
# The prompt format is only available from bash 4.4.
|
||||
# We test if it is available before using it.
|
||||
if (x=${PS1@P}) 2> /dev/null; then
|
||||
printf "%%s" "${PS1@P}${COMP_LINE[@]}"
|
||||
else
|
||||
# Can't print the prompt. Just print the
|
||||
# text the user had typed, it is workable enough.
|
||||
printf "%%s" "${COMP_LINE[@]}"
|
||||
__%[1]s_handle_activeHelp() {
|
||||
# Print the activeHelp statements
|
||||
if ((${#activeHelp[*]} != 0)); then
|
||||
if [ -z $COMP_TYPE ]; then
|
||||
# Bash v3 does not set the COMP_TYPE variable.
|
||||
printf "\n";
|
||||
printf "%%s\n" "${activeHelp[@]}"
|
||||
printf "\n"
|
||||
__%[1]s_reprint_commandLine
|
||||
return
|
||||
fi
|
||||
|
||||
# Only print ActiveHelp on the second TAB press
|
||||
if [ $COMP_TYPE -eq 63 ]; then
|
||||
printf "\n"
|
||||
printf "%%s\n" "${activeHelp[@]}"
|
||||
|
||||
if ((${#COMPREPLY[*]} == 0)); then
|
||||
# When there are no completion choices from the program, file completion
|
||||
# may kick in if the program has not disabled it; in such a case, we want
|
||||
# to know if any files will match what the user typed, so that we know if
|
||||
# there will be completions presented, so that we know how to handle ActiveHelp.
|
||||
# To find out, we actually trigger the file completion ourselves;
|
||||
# the call to _filedir will fill COMPREPLY if files match.
|
||||
if (((directive & shellCompDirectiveNoFileComp) == 0)); then
|
||||
__%[1]s_debug "Listing files"
|
||||
_filedir
|
||||
fi
|
||||
fi
|
||||
|
||||
if ((${#COMPREPLY[*]} != 0)); then
|
||||
# If there are completion choices to be shown, print a delimiter.
|
||||
# Re-printing the command-line will automatically be done
|
||||
# by the shell when it prints the completion choices.
|
||||
printf -- "--"
|
||||
else
|
||||
# When there are no completion choices at all, we need
|
||||
# to re-print the command-line since the shell will
|
||||
# not be doing it itself.
|
||||
__%[1]s_reprint_commandLine
|
||||
fi
|
||||
elif [ $COMP_TYPE -eq 37 ] || [ $COMP_TYPE -eq 42 ]; then
|
||||
# For completion type: menu-complete/menu-complete-backward and insert-completions
|
||||
# the completions are immediately inserted into the command-line, so we first
|
||||
# print the activeHelp message and reprint the command-line since the shell won't.
|
||||
printf "\n"
|
||||
printf "%%s\n" "${activeHelp[@]}"
|
||||
|
||||
__%[1]s_reprint_commandLine
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
__%[1]s_reprint_commandLine() {
|
||||
# The prompt format is only available from bash 4.4.
|
||||
# We test if it is available before using it.
|
||||
if (x=${PS1@P}) 2> /dev/null; then
|
||||
printf "%%s" "${PS1@P}${COMP_LINE[@]}"
|
||||
else
|
||||
# Can't print the prompt. Just print the
|
||||
# text the user had typed, it is workable enough.
|
||||
printf "%%s" "${COMP_LINE[@]}"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -201,6 +252,8 @@ __%[1]s_extract_activeHelp() {
|
||||
local endIndex=${#activeHelpMarker}
|
||||
|
||||
while IFS='' read -r comp; do
|
||||
[[ -z $comp ]] && continue
|
||||
|
||||
if [[ ${comp:0:endIndex} == $activeHelpMarker ]]; then
|
||||
comp=${comp:endIndex}
|
||||
__%[1]s_debug "ActiveHelp found: $comp"
|
||||
@ -223,16 +276,21 @@ __%[1]s_handle_completion_types() {
|
||||
# If the user requested inserting one completion at a time, or all
|
||||
# completions at once on the command-line we must remove the descriptions.
|
||||
# https://github.com/spf13/cobra/issues/1508
|
||||
local tab=$'\t' comp
|
||||
while IFS='' read -r comp; do
|
||||
[[ -z $comp ]] && continue
|
||||
# Strip any description
|
||||
comp=${comp%%%%$tab*}
|
||||
# Only consider the completions that match
|
||||
if [[ $comp == "$cur"* ]]; then
|
||||
COMPREPLY+=("$comp")
|
||||
fi
|
||||
done < <(printf "%%s\n" "${completions[@]}")
|
||||
|
||||
# If there are no completions, we don't need to do anything
|
||||
(( ${#completions[@]} == 0 )) && return 0
|
||||
|
||||
local tab=$'\t'
|
||||
|
||||
# Strip any description and escape the completion to handled special characters
|
||||
IFS=$'\n' read -ra completions -d '' < <(printf "%%q\n" "${completions[@]%%%%$tab*}")
|
||||
|
||||
# Only consider the completions that match
|
||||
IFS=$'\n' read -ra COMPREPLY -d '' < <(IFS=$'\n'; compgen -W "${completions[*]}" -- "${cur}")
|
||||
|
||||
# compgen looses the escaping so we need to escape all completions again since they will
|
||||
# all be inserted on the command-line.
|
||||
IFS=$'\n' read -ra COMPREPLY -d '' < <(printf "%%q\n" "${COMPREPLY[@]}")
|
||||
;;
|
||||
|
||||
*)
|
||||
@ -243,11 +301,25 @@ __%[1]s_handle_completion_types() {
|
||||
}
|
||||
|
||||
__%[1]s_handle_standard_completion_case() {
|
||||
local tab=$'\t' comp
|
||||
local tab=$'\t'
|
||||
|
||||
# If there are no completions, we don't need to do anything
|
||||
(( ${#completions[@]} == 0 )) && return 0
|
||||
|
||||
# Short circuit to optimize if we don't have descriptions
|
||||
if [[ "${completions[*]}" != *$tab* ]]; then
|
||||
IFS=$'\n' read -ra COMPREPLY -d '' < <(compgen -W "${completions[*]}" -- "$cur")
|
||||
# First, escape the completions to handle special characters
|
||||
IFS=$'\n' read -ra completions -d '' < <(printf "%%q\n" "${completions[@]}")
|
||||
# Only consider the completions that match what the user typed
|
||||
IFS=$'\n' read -ra COMPREPLY -d '' < <(IFS=$'\n'; compgen -W "${completions[*]}" -- "${cur}")
|
||||
|
||||
# compgen looses the escaping so, if there is only a single completion, we need to
|
||||
# escape it again because it will be inserted on the command-line. If there are multiple
|
||||
# completions, we don't want to escape them because they will be printed in a list
|
||||
# and we don't want to show escape characters in that list.
|
||||
if (( ${#COMPREPLY[@]} == 1 )); then
|
||||
COMPREPLY[0]=$(printf "%%q" "${COMPREPLY[0]}")
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
|
||||
@ -256,23 +328,39 @@ __%[1]s_handle_standard_completion_case() {
|
||||
# Look for the longest completion so that we can format things nicely
|
||||
while IFS='' read -r compline; do
|
||||
[[ -z $compline ]] && continue
|
||||
# Strip any description before checking the length
|
||||
comp=${compline%%%%$tab*}
|
||||
|
||||
# Before checking if the completion matches what the user typed,
|
||||
# we need to strip any description and escape the completion to handle special
|
||||
# characters because those escape characters are part of what the user typed.
|
||||
# Don't call "printf" in a sub-shell because it will be much slower
|
||||
# since we are in a loop.
|
||||
printf -v comp "%%q" "${compline%%%%$tab*}" &>/dev/null || comp=$(printf "%%q" "${compline%%%%$tab*}")
|
||||
|
||||
# Only consider the completions that match
|
||||
[[ $comp == "$cur"* ]] || continue
|
||||
|
||||
# The completions matches. Add it to the list of full completions including
|
||||
# its description. We don't escape the completion because it may get printed
|
||||
# in a list if there are more than one and we don't want show escape characters
|
||||
# in that list.
|
||||
COMPREPLY+=("$compline")
|
||||
|
||||
# Strip any description before checking the length, and again, don't escape
|
||||
# the completion because this length is only used when printing the completions
|
||||
# in a list and we don't want show escape characters in that list.
|
||||
comp=${compline%%%%$tab*}
|
||||
if ((${#comp}>longest)); then
|
||||
longest=${#comp}
|
||||
fi
|
||||
done < <(printf "%%s\n" "${completions[@]}")
|
||||
|
||||
# If there is a single completion left, remove the description text
|
||||
# If there is a single completion left, remove the description text and escape any special characters
|
||||
if ((${#COMPREPLY[*]} == 1)); then
|
||||
__%[1]s_debug "COMPREPLY[0]: ${COMPREPLY[0]}"
|
||||
comp="${COMPREPLY[0]%%%%$tab*}"
|
||||
__%[1]s_debug "Removed description from single completion, which is now: ${comp}"
|
||||
COMPREPLY[0]=$comp
|
||||
else # Format the descriptions
|
||||
COMPREPLY[0]=$(printf "%%q" "${COMPREPLY[0]%%%%$tab*}")
|
||||
__%[1]s_debug "Removed description from single completion, which is now: ${COMPREPLY[0]}"
|
||||
else
|
||||
# Format the descriptions
|
||||
__%[1]s_format_comp_descriptions $longest
|
||||
fi
|
||||
}
|
||||
|
16
vendor/github.com/spf13/cobra/cobra.go
generated
vendored
16
vendor/github.com/spf13/cobra/cobra.go
generated
vendored
@ -176,12 +176,16 @@ func rpad(s string, padding int) string {
|
||||
return fmt.Sprintf(formattedString, s)
|
||||
}
|
||||
|
||||
// tmpl executes the given template text on data, writing the result to w.
|
||||
func tmpl(w io.Writer, text string, data interface{}) error {
|
||||
t := template.New("top")
|
||||
t.Funcs(templateFuncs)
|
||||
template.Must(t.Parse(text))
|
||||
return t.Execute(w, data)
|
||||
func tmpl(text string) *tmplFunc {
|
||||
return &tmplFunc{
|
||||
tmpl: text,
|
||||
fn: func(w io.Writer, data interface{}) error {
|
||||
t := template.New("top")
|
||||
t.Funcs(templateFuncs)
|
||||
template.Must(t.Parse(text))
|
||||
return t.Execute(w, data)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// ld compares two strings and returns the levenshtein distance between them.
|
||||
|
331
vendor/github.com/spf13/cobra/command.go
generated
vendored
331
vendor/github.com/spf13/cobra/command.go
generated
vendored
@ -33,6 +33,9 @@ import (
|
||||
const (
|
||||
FlagSetByCobraAnnotation = "cobra_annotation_flag_set_by_cobra"
|
||||
CommandDisplayNameAnnotation = "cobra_annotation_command_display_name"
|
||||
|
||||
helpFlagName = "help"
|
||||
helpCommandName = "help"
|
||||
)
|
||||
|
||||
// FParseErrWhitelist configures Flag parse errors to be ignored
|
||||
@ -80,11 +83,11 @@ type Command struct {
|
||||
Example string
|
||||
|
||||
// ValidArgs is list of all valid non-flag arguments that are accepted in shell completions
|
||||
ValidArgs []string
|
||||
ValidArgs []Completion
|
||||
// ValidArgsFunction is an optional function that provides valid non-flag arguments for shell completion.
|
||||
// It is a dynamic version of using ValidArgs.
|
||||
// Only one of ValidArgs and ValidArgsFunction can be used for a command.
|
||||
ValidArgsFunction func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective)
|
||||
ValidArgsFunction CompletionFunc
|
||||
|
||||
// Expected arguments
|
||||
Args PositionalArgs
|
||||
@ -168,12 +171,12 @@ type Command struct {
|
||||
// usageFunc is usage func defined by user.
|
||||
usageFunc func(*Command) error
|
||||
// usageTemplate is usage template defined by user.
|
||||
usageTemplate string
|
||||
usageTemplate *tmplFunc
|
||||
// flagErrorFunc is func defined by user and it's called when the parsing of
|
||||
// flags returns an error.
|
||||
flagErrorFunc func(*Command, error) error
|
||||
// helpTemplate is help template defined by user.
|
||||
helpTemplate string
|
||||
helpTemplate *tmplFunc
|
||||
// helpFunc is help func defined by user.
|
||||
helpFunc func(*Command, []string)
|
||||
// helpCommand is command with usage 'help'. If it's not defined by user,
|
||||
@ -186,7 +189,7 @@ type Command struct {
|
||||
completionCommandGroupID string
|
||||
|
||||
// versionTemplate is the version template defined by user.
|
||||
versionTemplate string
|
||||
versionTemplate *tmplFunc
|
||||
|
||||
// errPrefix is the error message prefix defined by user.
|
||||
errPrefix string
|
||||
@ -281,6 +284,7 @@ func (c *Command) SetArgs(a []string) {
|
||||
|
||||
// SetOutput sets the destination for usage and error messages.
|
||||
// If output is nil, os.Stderr is used.
|
||||
//
|
||||
// Deprecated: Use SetOut and/or SetErr instead
|
||||
func (c *Command) SetOutput(output io.Writer) {
|
||||
c.outWriter = output
|
||||
@ -312,7 +316,11 @@ func (c *Command) SetUsageFunc(f func(*Command) error) {
|
||||
|
||||
// SetUsageTemplate sets usage template. Can be defined by Application.
|
||||
func (c *Command) SetUsageTemplate(s string) {
|
||||
c.usageTemplate = s
|
||||
if s == "" {
|
||||
c.usageTemplate = nil
|
||||
return
|
||||
}
|
||||
c.usageTemplate = tmpl(s)
|
||||
}
|
||||
|
||||
// SetFlagErrorFunc sets a function to generate an error when flag parsing
|
||||
@ -348,12 +356,20 @@ func (c *Command) SetCompletionCommandGroupID(groupID string) {
|
||||
|
||||
// SetHelpTemplate sets help template to be used. Application can use it to set custom template.
|
||||
func (c *Command) SetHelpTemplate(s string) {
|
||||
c.helpTemplate = s
|
||||
if s == "" {
|
||||
c.helpTemplate = nil
|
||||
return
|
||||
}
|
||||
c.helpTemplate = tmpl(s)
|
||||
}
|
||||
|
||||
// SetVersionTemplate sets version template to be used. Application can use it to set custom template.
|
||||
func (c *Command) SetVersionTemplate(s string) {
|
||||
c.versionTemplate = s
|
||||
if s == "" {
|
||||
c.versionTemplate = nil
|
||||
return
|
||||
}
|
||||
c.versionTemplate = tmpl(s)
|
||||
}
|
||||
|
||||
// SetErrPrefix sets error message prefix to be used. Application can use it to set custom prefix.
|
||||
@ -434,7 +450,8 @@ func (c *Command) UsageFunc() (f func(*Command) error) {
|
||||
}
|
||||
return func(c *Command) error {
|
||||
c.mergePersistentFlags()
|
||||
err := tmpl(c.OutOrStderr(), c.UsageTemplate(), c)
|
||||
fn := c.getUsageTemplateFunc()
|
||||
err := fn(c.OutOrStderr(), c)
|
||||
if err != nil {
|
||||
c.PrintErrln(err)
|
||||
}
|
||||
@ -442,6 +459,19 @@ func (c *Command) UsageFunc() (f func(*Command) error) {
|
||||
}
|
||||
}
|
||||
|
||||
// getUsageTemplateFunc returns the usage template function for the command
|
||||
// going up the command tree if necessary.
|
||||
func (c *Command) getUsageTemplateFunc() func(w io.Writer, data interface{}) error {
|
||||
if c.usageTemplate != nil {
|
||||
return c.usageTemplate.fn
|
||||
}
|
||||
|
||||
if c.HasParent() {
|
||||
return c.parent.getUsageTemplateFunc()
|
||||
}
|
||||
return defaultUsageFunc
|
||||
}
|
||||
|
||||
// Usage puts out the usage for the command.
|
||||
// Used when a user provides invalid input.
|
||||
// Can be defined by user by overriding UsageFunc.
|
||||
@ -460,15 +490,30 @@ func (c *Command) HelpFunc() func(*Command, []string) {
|
||||
}
|
||||
return func(c *Command, a []string) {
|
||||
c.mergePersistentFlags()
|
||||
fn := c.getHelpTemplateFunc()
|
||||
// The help should be sent to stdout
|
||||
// See https://github.com/spf13/cobra/issues/1002
|
||||
err := tmpl(c.OutOrStdout(), c.HelpTemplate(), c)
|
||||
err := fn(c.OutOrStdout(), c)
|
||||
if err != nil {
|
||||
c.PrintErrln(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// getHelpTemplateFunc returns the help template function for the command
|
||||
// going up the command tree if necessary.
|
||||
func (c *Command) getHelpTemplateFunc() func(w io.Writer, data interface{}) error {
|
||||
if c.helpTemplate != nil {
|
||||
return c.helpTemplate.fn
|
||||
}
|
||||
|
||||
if c.HasParent() {
|
||||
return c.parent.getHelpTemplateFunc()
|
||||
}
|
||||
|
||||
return defaultHelpFunc
|
||||
}
|
||||
|
||||
// Help puts out the help for the command.
|
||||
// Used when a user calls help [command].
|
||||
// Can be defined by user by overriding HelpFunc.
|
||||
@ -543,71 +588,55 @@ func (c *Command) NamePadding() int {
|
||||
}
|
||||
|
||||
// UsageTemplate returns usage template for the command.
|
||||
// This function is kept for backwards-compatibility reasons.
|
||||
func (c *Command) UsageTemplate() string {
|
||||
if c.usageTemplate != "" {
|
||||
return c.usageTemplate
|
||||
if c.usageTemplate != nil {
|
||||
return c.usageTemplate.tmpl
|
||||
}
|
||||
|
||||
if c.HasParent() {
|
||||
return c.parent.UsageTemplate()
|
||||
}
|
||||
return `Usage:{{if .Runnable}}
|
||||
{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
|
||||
{{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
|
||||
|
||||
Aliases:
|
||||
{{.NameAndAliases}}{{end}}{{if .HasExample}}
|
||||
|
||||
Examples:
|
||||
{{.Example}}{{end}}{{if .HasAvailableSubCommands}}{{$cmds := .Commands}}{{if eq (len .Groups) 0}}
|
||||
|
||||
Available Commands:{{range $cmds}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
|
||||
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{else}}{{range $group := .Groups}}
|
||||
|
||||
{{.Title}}{{range $cmds}}{{if (and (eq .GroupID $group.ID) (or .IsAvailableCommand (eq .Name "help")))}}
|
||||
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if not .AllChildCommandsHaveGroup}}
|
||||
|
||||
Additional Commands:{{range $cmds}}{{if (and (eq .GroupID "") (or .IsAvailableCommand (eq .Name "help")))}}
|
||||
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
|
||||
|
||||
Flags:
|
||||
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}
|
||||
|
||||
Global Flags:
|
||||
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
|
||||
|
||||
Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
|
||||
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
|
||||
|
||||
Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
|
||||
`
|
||||
return defaultUsageTemplate
|
||||
}
|
||||
|
||||
// HelpTemplate return help template for the command.
|
||||
// This function is kept for backwards-compatibility reasons.
|
||||
func (c *Command) HelpTemplate() string {
|
||||
if c.helpTemplate != "" {
|
||||
return c.helpTemplate
|
||||
if c.helpTemplate != nil {
|
||||
return c.helpTemplate.tmpl
|
||||
}
|
||||
|
||||
if c.HasParent() {
|
||||
return c.parent.HelpTemplate()
|
||||
}
|
||||
return `{{with (or .Long .Short)}}{{. | trimTrailingWhitespaces}}
|
||||
|
||||
{{end}}{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}`
|
||||
return defaultHelpTemplate
|
||||
}
|
||||
|
||||
// VersionTemplate return version template for the command.
|
||||
// This function is kept for backwards-compatibility reasons.
|
||||
func (c *Command) VersionTemplate() string {
|
||||
if c.versionTemplate != "" {
|
||||
return c.versionTemplate
|
||||
if c.versionTemplate != nil {
|
||||
return c.versionTemplate.tmpl
|
||||
}
|
||||
|
||||
if c.HasParent() {
|
||||
return c.parent.VersionTemplate()
|
||||
}
|
||||
return `{{with .Name}}{{printf "%s " .}}{{end}}{{printf "version %s" .Version}}
|
||||
`
|
||||
return defaultVersionTemplate
|
||||
}
|
||||
|
||||
// getVersionTemplateFunc returns the version template function for the command
|
||||
// going up the command tree if necessary.
|
||||
func (c *Command) getVersionTemplateFunc() func(w io.Writer, data interface{}) error {
|
||||
if c.versionTemplate != nil {
|
||||
return c.versionTemplate.fn
|
||||
}
|
||||
|
||||
if c.HasParent() {
|
||||
return c.parent.getVersionTemplateFunc()
|
||||
}
|
||||
return defaultVersionFunc
|
||||
}
|
||||
|
||||
// ErrPrefix return error message prefix for the command
|
||||
@ -894,7 +923,7 @@ func (c *Command) execute(a []string) (err error) {
|
||||
|
||||
// If help is called, regardless of other flags, return we want help.
|
||||
// Also say we need help if the command isn't runnable.
|
||||
helpVal, err := c.Flags().GetBool("help")
|
||||
helpVal, err := c.Flags().GetBool(helpFlagName)
|
||||
if err != nil {
|
||||
// should be impossible to get here as we always declare a help
|
||||
// flag in InitDefaultHelpFlag()
|
||||
@ -914,7 +943,8 @@ func (c *Command) execute(a []string) (err error) {
|
||||
return err
|
||||
}
|
||||
if versionVal {
|
||||
err := tmpl(c.OutOrStdout(), c.VersionTemplate(), c)
|
||||
fn := c.getVersionTemplateFunc()
|
||||
err := fn(c.OutOrStdout(), c)
|
||||
if err != nil {
|
||||
c.Println(err)
|
||||
}
|
||||
@ -1068,12 +1098,6 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
|
||||
|
||||
// initialize help at the last point to allow for user overriding
|
||||
c.InitDefaultHelpCmd()
|
||||
// initialize completion at the last point to allow for user overriding
|
||||
c.InitDefaultCompletionCmd()
|
||||
|
||||
// Now that all commands have been created, let's make sure all groups
|
||||
// are properly created also
|
||||
c.checkCommandGroups()
|
||||
|
||||
args := c.args
|
||||
|
||||
@ -1082,9 +1106,16 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
|
||||
args = os.Args[1:]
|
||||
}
|
||||
|
||||
// initialize the hidden command to be used for shell completion
|
||||
// initialize the __complete command to be used for shell completion
|
||||
c.initCompleteCmd(args)
|
||||
|
||||
// initialize the default completion command
|
||||
c.InitDefaultCompletionCmd(args...)
|
||||
|
||||
// Now that all commands have been created, let's make sure all groups
|
||||
// are properly created also
|
||||
c.checkCommandGroups()
|
||||
|
||||
var flags []string
|
||||
if c.TraverseChildren {
|
||||
cmd, flags, err = c.Traverse(args)
|
||||
@ -1187,16 +1218,16 @@ func (c *Command) checkCommandGroups() {
|
||||
// If c already has help flag, it will do nothing.
|
||||
func (c *Command) InitDefaultHelpFlag() {
|
||||
c.mergePersistentFlags()
|
||||
if c.Flags().Lookup("help") == nil {
|
||||
if c.Flags().Lookup(helpFlagName) == nil {
|
||||
usage := "help for "
|
||||
name := c.displayName()
|
||||
name := c.DisplayName()
|
||||
if name == "" {
|
||||
usage += "this command"
|
||||
} else {
|
||||
usage += name
|
||||
}
|
||||
c.Flags().BoolP("help", "h", false, usage)
|
||||
_ = c.Flags().SetAnnotation("help", FlagSetByCobraAnnotation, []string{"true"})
|
||||
c.Flags().BoolP(helpFlagName, "h", false, usage)
|
||||
_ = c.Flags().SetAnnotation(helpFlagName, FlagSetByCobraAnnotation, []string{"true"})
|
||||
}
|
||||
}
|
||||
|
||||
@ -1215,7 +1246,7 @@ func (c *Command) InitDefaultVersionFlag() {
|
||||
if c.Name() == "" {
|
||||
usage += "this command"
|
||||
} else {
|
||||
usage += c.Name()
|
||||
usage += c.DisplayName()
|
||||
}
|
||||
if c.Flags().ShorthandLookup("v") == nil {
|
||||
c.Flags().BoolP("version", "v", false, usage)
|
||||
@ -1239,9 +1270,9 @@ func (c *Command) InitDefaultHelpCmd() {
|
||||
Use: "help [command]",
|
||||
Short: "Help about any command",
|
||||
Long: `Help provides help for any command in the application.
|
||||
Simply type ` + c.displayName() + ` help [path to command] for full details.`,
|
||||
ValidArgsFunction: func(c *Command, args []string, toComplete string) ([]string, ShellCompDirective) {
|
||||
var completions []string
|
||||
Simply type ` + c.DisplayName() + ` help [path to command] for full details.`,
|
||||
ValidArgsFunction: func(c *Command, args []string, toComplete string) ([]Completion, ShellCompDirective) {
|
||||
var completions []Completion
|
||||
cmd, _, e := c.Root().Find(args)
|
||||
if e != nil {
|
||||
return nil, ShellCompDirectiveNoFileComp
|
||||
@ -1253,7 +1284,7 @@ Simply type ` + c.displayName() + ` help [path to command] for full details.`,
|
||||
for _, subCmd := range cmd.Commands() {
|
||||
if subCmd.IsAvailableCommand() || subCmd == cmd.helpCommand {
|
||||
if strings.HasPrefix(subCmd.Name(), toComplete) {
|
||||
completions = append(completions, fmt.Sprintf("%s\t%s", subCmd.Name(), subCmd.Short))
|
||||
completions = append(completions, CompletionWithDesc(subCmd.Name(), subCmd.Short))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1430,10 +1461,12 @@ func (c *Command) CommandPath() string {
|
||||
if c.HasParent() {
|
||||
return c.Parent().CommandPath() + " " + c.Name()
|
||||
}
|
||||
return c.displayName()
|
||||
return c.DisplayName()
|
||||
}
|
||||
|
||||
func (c *Command) displayName() string {
|
||||
// DisplayName returns the name to display in help text. Returns command Name()
|
||||
// If CommandDisplayNameAnnoation is not set
|
||||
func (c *Command) DisplayName() string {
|
||||
if displayName, ok := c.Annotations[CommandDisplayNameAnnotation]; ok {
|
||||
return displayName
|
||||
}
|
||||
@ -1443,7 +1476,7 @@ func (c *Command) displayName() string {
|
||||
// UseLine puts out the full usage for a given command (including parents).
|
||||
func (c *Command) UseLine() string {
|
||||
var useline string
|
||||
use := strings.Replace(c.Use, c.Name(), c.displayName(), 1)
|
||||
use := strings.Replace(c.Use, c.Name(), c.DisplayName(), 1)
|
||||
if c.HasParent() {
|
||||
useline = c.parent.CommandPath() + " " + use
|
||||
} else {
|
||||
@ -1649,7 +1682,7 @@ func (c *Command) GlobalNormalizationFunc() func(f *flag.FlagSet, name string) f
|
||||
// to this command (local and persistent declared here and by all parents).
|
||||
func (c *Command) Flags() *flag.FlagSet {
|
||||
if c.flags == nil {
|
||||
c.flags = flag.NewFlagSet(c.displayName(), flag.ContinueOnError)
|
||||
c.flags = flag.NewFlagSet(c.DisplayName(), flag.ContinueOnError)
|
||||
if c.flagErrorBuf == nil {
|
||||
c.flagErrorBuf = new(bytes.Buffer)
|
||||
}
|
||||
@ -1664,7 +1697,7 @@ func (c *Command) Flags() *flag.FlagSet {
|
||||
func (c *Command) LocalNonPersistentFlags() *flag.FlagSet {
|
||||
persistentFlags := c.PersistentFlags()
|
||||
|
||||
out := flag.NewFlagSet(c.displayName(), flag.ContinueOnError)
|
||||
out := flag.NewFlagSet(c.DisplayName(), flag.ContinueOnError)
|
||||
c.LocalFlags().VisitAll(func(f *flag.Flag) {
|
||||
if persistentFlags.Lookup(f.Name) == nil {
|
||||
out.AddFlag(f)
|
||||
@ -1679,7 +1712,7 @@ func (c *Command) LocalFlags() *flag.FlagSet {
|
||||
c.mergePersistentFlags()
|
||||
|
||||
if c.lflags == nil {
|
||||
c.lflags = flag.NewFlagSet(c.displayName(), flag.ContinueOnError)
|
||||
c.lflags = flag.NewFlagSet(c.DisplayName(), flag.ContinueOnError)
|
||||
if c.flagErrorBuf == nil {
|
||||
c.flagErrorBuf = new(bytes.Buffer)
|
||||
}
|
||||
@ -1707,7 +1740,7 @@ func (c *Command) InheritedFlags() *flag.FlagSet {
|
||||
c.mergePersistentFlags()
|
||||
|
||||
if c.iflags == nil {
|
||||
c.iflags = flag.NewFlagSet(c.displayName(), flag.ContinueOnError)
|
||||
c.iflags = flag.NewFlagSet(c.DisplayName(), flag.ContinueOnError)
|
||||
if c.flagErrorBuf == nil {
|
||||
c.flagErrorBuf = new(bytes.Buffer)
|
||||
}
|
||||
@ -1736,7 +1769,7 @@ func (c *Command) NonInheritedFlags() *flag.FlagSet {
|
||||
// PersistentFlags returns the persistent FlagSet specifically set in the current command.
|
||||
func (c *Command) PersistentFlags() *flag.FlagSet {
|
||||
if c.pflags == nil {
|
||||
c.pflags = flag.NewFlagSet(c.displayName(), flag.ContinueOnError)
|
||||
c.pflags = flag.NewFlagSet(c.DisplayName(), flag.ContinueOnError)
|
||||
if c.flagErrorBuf == nil {
|
||||
c.flagErrorBuf = new(bytes.Buffer)
|
||||
}
|
||||
@ -1749,9 +1782,9 @@ func (c *Command) PersistentFlags() *flag.FlagSet {
|
||||
func (c *Command) ResetFlags() {
|
||||
c.flagErrorBuf = new(bytes.Buffer)
|
||||
c.flagErrorBuf.Reset()
|
||||
c.flags = flag.NewFlagSet(c.displayName(), flag.ContinueOnError)
|
||||
c.flags = flag.NewFlagSet(c.DisplayName(), flag.ContinueOnError)
|
||||
c.flags.SetOutput(c.flagErrorBuf)
|
||||
c.pflags = flag.NewFlagSet(c.displayName(), flag.ContinueOnError)
|
||||
c.pflags = flag.NewFlagSet(c.DisplayName(), flag.ContinueOnError)
|
||||
c.pflags.SetOutput(c.flagErrorBuf)
|
||||
|
||||
c.lflags = nil
|
||||
@ -1868,7 +1901,7 @@ func (c *Command) mergePersistentFlags() {
|
||||
// If c.parentsPflags == nil, it makes new.
|
||||
func (c *Command) updateParentsPflags() {
|
||||
if c.parentsPflags == nil {
|
||||
c.parentsPflags = flag.NewFlagSet(c.displayName(), flag.ContinueOnError)
|
||||
c.parentsPflags = flag.NewFlagSet(c.DisplayName(), flag.ContinueOnError)
|
||||
c.parentsPflags.SetOutput(c.flagErrorBuf)
|
||||
c.parentsPflags.SortFlags = false
|
||||
}
|
||||
@ -1894,3 +1927,141 @@ func commandNameMatches(s string, t string) bool {
|
||||
|
||||
return s == t
|
||||
}
|
||||
|
||||
// tmplFunc holds a template and a function that will execute said template.
|
||||
type tmplFunc struct {
|
||||
tmpl string
|
||||
fn func(io.Writer, interface{}) error
|
||||
}
|
||||
|
||||
var defaultUsageTemplate = `Usage:{{if .Runnable}}
|
||||
{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
|
||||
{{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
|
||||
|
||||
Aliases:
|
||||
{{.NameAndAliases}}{{end}}{{if .HasExample}}
|
||||
|
||||
Examples:
|
||||
{{.Example}}{{end}}{{if .HasAvailableSubCommands}}{{$cmds := .Commands}}{{if eq (len .Groups) 0}}
|
||||
|
||||
Available Commands:{{range $cmds}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
|
||||
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{else}}{{range $group := .Groups}}
|
||||
|
||||
{{.Title}}{{range $cmds}}{{if (and (eq .GroupID $group.ID) (or .IsAvailableCommand (eq .Name "help")))}}
|
||||
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if not .AllChildCommandsHaveGroup}}
|
||||
|
||||
Additional Commands:{{range $cmds}}{{if (and (eq .GroupID "") (or .IsAvailableCommand (eq .Name "help")))}}
|
||||
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
|
||||
|
||||
Flags:
|
||||
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}
|
||||
|
||||
Global Flags:
|
||||
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
|
||||
|
||||
Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
|
||||
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
|
||||
|
||||
Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
|
||||
`
|
||||
|
||||
// defaultUsageFunc is equivalent to executing defaultUsageTemplate. The two should be changed in sync.
|
||||
func defaultUsageFunc(w io.Writer, in interface{}) error {
|
||||
c := in.(*Command)
|
||||
fmt.Fprint(w, "Usage:")
|
||||
if c.Runnable() {
|
||||
fmt.Fprintf(w, "\n %s", c.UseLine())
|
||||
}
|
||||
if c.HasAvailableSubCommands() {
|
||||
fmt.Fprintf(w, "\n %s [command]", c.CommandPath())
|
||||
}
|
||||
if len(c.Aliases) > 0 {
|
||||
fmt.Fprintf(w, "\n\nAliases:\n")
|
||||
fmt.Fprintf(w, " %s", c.NameAndAliases())
|
||||
}
|
||||
if c.HasExample() {
|
||||
fmt.Fprintf(w, "\n\nExamples:\n")
|
||||
fmt.Fprintf(w, "%s", c.Example)
|
||||
}
|
||||
if c.HasAvailableSubCommands() {
|
||||
cmds := c.Commands()
|
||||
if len(c.Groups()) == 0 {
|
||||
fmt.Fprintf(w, "\n\nAvailable Commands:")
|
||||
for _, subcmd := range cmds {
|
||||
if subcmd.IsAvailableCommand() || subcmd.Name() == helpCommandName {
|
||||
fmt.Fprintf(w, "\n %s %s", rpad(subcmd.Name(), subcmd.NamePadding()), subcmd.Short)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, group := range c.Groups() {
|
||||
fmt.Fprintf(w, "\n\n%s", group.Title)
|
||||
for _, subcmd := range cmds {
|
||||
if subcmd.GroupID == group.ID && (subcmd.IsAvailableCommand() || subcmd.Name() == helpCommandName) {
|
||||
fmt.Fprintf(w, "\n %s %s", rpad(subcmd.Name(), subcmd.NamePadding()), subcmd.Short)
|
||||
}
|
||||
}
|
||||
}
|
||||
if !c.AllChildCommandsHaveGroup() {
|
||||
fmt.Fprintf(w, "\n\nAdditional Commands:")
|
||||
for _, subcmd := range cmds {
|
||||
if subcmd.GroupID == "" && (subcmd.IsAvailableCommand() || subcmd.Name() == helpCommandName) {
|
||||
fmt.Fprintf(w, "\n %s %s", rpad(subcmd.Name(), subcmd.NamePadding()), subcmd.Short)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if c.HasAvailableLocalFlags() {
|
||||
fmt.Fprintf(w, "\n\nFlags:\n")
|
||||
fmt.Fprint(w, trimRightSpace(c.LocalFlags().FlagUsages()))
|
||||
}
|
||||
if c.HasAvailableInheritedFlags() {
|
||||
fmt.Fprintf(w, "\n\nGlobal Flags:\n")
|
||||
fmt.Fprint(w, trimRightSpace(c.InheritedFlags().FlagUsages()))
|
||||
}
|
||||
if c.HasHelpSubCommands() {
|
||||
fmt.Fprintf(w, "\n\nAdditional help topcis:")
|
||||
for _, subcmd := range c.Commands() {
|
||||
if subcmd.IsAdditionalHelpTopicCommand() {
|
||||
fmt.Fprintf(w, "\n %s %s", rpad(subcmd.CommandPath(), subcmd.CommandPathPadding()), subcmd.Short)
|
||||
}
|
||||
}
|
||||
}
|
||||
if c.HasAvailableSubCommands() {
|
||||
fmt.Fprintf(w, "\n\nUse \"%s [command] --help\" for more information about a command.", c.CommandPath())
|
||||
}
|
||||
fmt.Fprintln(w)
|
||||
return nil
|
||||
}
|
||||
|
||||
var defaultHelpTemplate = `{{with (or .Long .Short)}}{{. | trimTrailingWhitespaces}}
|
||||
|
||||
{{end}}{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}`
|
||||
|
||||
// defaultHelpFunc is equivalent to executing defaultHelpTemplate. The two should be changed in sync.
|
||||
func defaultHelpFunc(w io.Writer, in interface{}) error {
|
||||
c := in.(*Command)
|
||||
usage := c.Long
|
||||
if usage == "" {
|
||||
usage = c.Short
|
||||
}
|
||||
usage = trimRightSpace(usage)
|
||||
if usage != "" {
|
||||
fmt.Fprintln(w, usage)
|
||||
fmt.Fprintln(w)
|
||||
}
|
||||
if c.Runnable() || c.HasSubCommands() {
|
||||
fmt.Fprint(w, c.UsageString())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var defaultVersionTemplate = `{{with .DisplayName}}{{printf "%s " .}}{{end}}{{printf "version %s" .Version}}
|
||||
`
|
||||
|
||||
// defaultVersionFunc is equivalent to executing defaultVersionTemplate. The two should be changed in sync.
|
||||
func defaultVersionFunc(w io.Writer, in interface{}) error {
|
||||
c := in.(*Command)
|
||||
_, err := fmt.Fprintf(w, "%s version %s\n", c.DisplayName(), c.Version)
|
||||
return err
|
||||
}
|
||||
|
126
vendor/github.com/spf13/cobra/completions.go
generated
vendored
126
vendor/github.com/spf13/cobra/completions.go
generated
vendored
@ -35,7 +35,7 @@ const (
|
||||
)
|
||||
|
||||
// Global map of flag completion functions. Make sure to use flagCompletionMutex before you try to read and write from it.
|
||||
var flagCompletionFunctions = map[*pflag.Flag]func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective){}
|
||||
var flagCompletionFunctions = map[*pflag.Flag]CompletionFunc{}
|
||||
|
||||
// lock for reading and writing from flagCompletionFunctions
|
||||
var flagCompletionMutex = &sync.RWMutex{}
|
||||
@ -117,22 +117,50 @@ type CompletionOptions struct {
|
||||
HiddenDefaultCmd bool
|
||||
}
|
||||
|
||||
// Completion is a string that can be used for completions
|
||||
//
|
||||
// two formats are supported:
|
||||
// - the completion choice
|
||||
// - the completion choice with a textual description (separated by a TAB).
|
||||
//
|
||||
// [CompletionWithDesc] can be used to create a completion string with a textual description.
|
||||
//
|
||||
// Note: Go type alias is used to provide a more descriptive name in the documentation, but any string can be used.
|
||||
type Completion = string
|
||||
|
||||
// CompletionFunc is a function that provides completion results.
|
||||
type CompletionFunc = func(cmd *Command, args []string, toComplete string) ([]Completion, ShellCompDirective)
|
||||
|
||||
// CompletionWithDesc returns a [Completion] with a description by using the TAB delimited format.
|
||||
func CompletionWithDesc(choice string, description string) Completion {
|
||||
return choice + "\t" + description
|
||||
}
|
||||
|
||||
// NoFileCompletions can be used to disable file completion for commands that should
|
||||
// not trigger file completions.
|
||||
func NoFileCompletions(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective) {
|
||||
//
|
||||
// This method satisfies [CompletionFunc].
|
||||
// It can be used with [Command.RegisterFlagCompletionFunc] and for [Command.ValidArgsFunction].
|
||||
func NoFileCompletions(cmd *Command, args []string, toComplete string) ([]Completion, ShellCompDirective) {
|
||||
return nil, ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
// FixedCompletions can be used to create a completion function which always
|
||||
// returns the same results.
|
||||
func FixedCompletions(choices []string, directive ShellCompDirective) func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective) {
|
||||
return func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective) {
|
||||
//
|
||||
// This method returns a function that satisfies [CompletionFunc]
|
||||
// It can be used with [Command.RegisterFlagCompletionFunc] and for [Command.ValidArgsFunction].
|
||||
func FixedCompletions(choices []Completion, directive ShellCompDirective) CompletionFunc {
|
||||
return func(cmd *Command, args []string, toComplete string) ([]Completion, ShellCompDirective) {
|
||||
return choices, directive
|
||||
}
|
||||
}
|
||||
|
||||
// RegisterFlagCompletionFunc should be called to register a function to provide completion for a flag.
|
||||
func (c *Command) RegisterFlagCompletionFunc(flagName string, f func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective)) error {
|
||||
//
|
||||
// You can use pre-defined completion functions such as [FixedCompletions] or [NoFileCompletions],
|
||||
// or you can define your own.
|
||||
func (c *Command) RegisterFlagCompletionFunc(flagName string, f CompletionFunc) error {
|
||||
flag := c.Flag(flagName)
|
||||
if flag == nil {
|
||||
return fmt.Errorf("RegisterFlagCompletionFunc: flag '%s' does not exist", flagName)
|
||||
@ -148,7 +176,7 @@ func (c *Command) RegisterFlagCompletionFunc(flagName string, f func(cmd *Comman
|
||||
}
|
||||
|
||||
// GetFlagCompletionFunc returns the completion function for the given flag of the command, if available.
|
||||
func (c *Command) GetFlagCompletionFunc(flagName string) (func(*Command, []string, string) ([]string, ShellCompDirective), bool) {
|
||||
func (c *Command) GetFlagCompletionFunc(flagName string) (CompletionFunc, bool) {
|
||||
flag := c.Flag(flagName)
|
||||
if flag == nil {
|
||||
return nil, false
|
||||
@ -270,7 +298,15 @@ func (c *Command) initCompleteCmd(args []string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDirective, error) {
|
||||
// SliceValue is a reduced version of [pflag.SliceValue]. It is used to detect
|
||||
// flags that accept multiple values and therefore can provide completion
|
||||
// multiple times.
|
||||
type SliceValue interface {
|
||||
// GetSlice returns the flag value list as an array of strings.
|
||||
GetSlice() []string
|
||||
}
|
||||
|
||||
func (c *Command) getCompletions(args []string) (*Command, []Completion, ShellCompDirective, error) {
|
||||
// The last argument, which is not completely typed by the user,
|
||||
// should not be part of the list of arguments
|
||||
toComplete := args[len(args)-1]
|
||||
@ -298,7 +334,7 @@ func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDi
|
||||
}
|
||||
if err != nil {
|
||||
// Unable to find the real command. E.g., <program> someInvalidCmd <TAB>
|
||||
return c, []string{}, ShellCompDirectiveDefault, fmt.Errorf("unable to find a command for arguments: %v", trimmedArgs)
|
||||
return c, []Completion{}, ShellCompDirectiveDefault, fmt.Errorf("unable to find a command for arguments: %v", trimmedArgs)
|
||||
}
|
||||
finalCmd.ctx = c.ctx
|
||||
|
||||
@ -328,7 +364,7 @@ func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDi
|
||||
|
||||
// Parse the flags early so we can check if required flags are set
|
||||
if err = finalCmd.ParseFlags(finalArgs); err != nil {
|
||||
return finalCmd, []string{}, ShellCompDirectiveDefault, fmt.Errorf("Error while parsing flags from args %v: %s", finalArgs, err.Error())
|
||||
return finalCmd, []Completion{}, ShellCompDirectiveDefault, fmt.Errorf("Error while parsing flags from args %v: %s", finalArgs, err.Error())
|
||||
}
|
||||
|
||||
realArgCount := finalCmd.Flags().NArg()
|
||||
@ -340,14 +376,14 @@ func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDi
|
||||
if flagErr != nil {
|
||||
// If error type is flagCompError and we don't want flagCompletion we should ignore the error
|
||||
if _, ok := flagErr.(*flagCompError); !(ok && !flagCompletion) {
|
||||
return finalCmd, []string{}, ShellCompDirectiveDefault, flagErr
|
||||
return finalCmd, []Completion{}, ShellCompDirectiveDefault, flagErr
|
||||
}
|
||||
}
|
||||
|
||||
// Look for the --help or --version flags. If they are present,
|
||||
// there should be no further completions.
|
||||
if helpOrVersionFlagPresent(finalCmd) {
|
||||
return finalCmd, []string{}, ShellCompDirectiveNoFileComp, nil
|
||||
return finalCmd, []Completion{}, ShellCompDirectiveNoFileComp, nil
|
||||
}
|
||||
|
||||
// We only remove the flags from the arguments if DisableFlagParsing is not set.
|
||||
@ -376,11 +412,11 @@ func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDi
|
||||
return finalCmd, subDir, ShellCompDirectiveFilterDirs, nil
|
||||
}
|
||||
// Directory completion
|
||||
return finalCmd, []string{}, ShellCompDirectiveFilterDirs, nil
|
||||
return finalCmd, []Completion{}, ShellCompDirectiveFilterDirs, nil
|
||||
}
|
||||
}
|
||||
|
||||
var completions []string
|
||||
var completions []Completion
|
||||
var directive ShellCompDirective
|
||||
|
||||
// Enforce flag groups before doing flag completions
|
||||
@ -399,10 +435,14 @@ func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDi
|
||||
// If we have not found any required flags, only then can we show regular flags
|
||||
if len(completions) == 0 {
|
||||
doCompleteFlags := func(flag *pflag.Flag) {
|
||||
if !flag.Changed ||
|
||||
_, acceptsMultiple := flag.Value.(SliceValue)
|
||||
acceptsMultiple = acceptsMultiple ||
|
||||
strings.Contains(flag.Value.Type(), "Slice") ||
|
||||
strings.Contains(flag.Value.Type(), "Array") {
|
||||
// If the flag is not already present, or if it can be specified multiple times (Array or Slice)
|
||||
strings.Contains(flag.Value.Type(), "Array") ||
|
||||
strings.HasPrefix(flag.Value.Type(), "stringTo")
|
||||
|
||||
if !flag.Changed || acceptsMultiple {
|
||||
// If the flag is not already present, or if it can be specified multiple times (Array, Slice, or stringTo)
|
||||
// we suggest it as a completion
|
||||
completions = append(completions, getFlagNameCompletions(flag, toComplete)...)
|
||||
}
|
||||
@ -462,7 +502,7 @@ func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDi
|
||||
for _, subCmd := range finalCmd.Commands() {
|
||||
if subCmd.IsAvailableCommand() || subCmd == finalCmd.helpCommand {
|
||||
if strings.HasPrefix(subCmd.Name(), toComplete) {
|
||||
completions = append(completions, fmt.Sprintf("%s\t%s", subCmd.Name(), subCmd.Short))
|
||||
completions = append(completions, CompletionWithDesc(subCmd.Name(), subCmd.Short))
|
||||
}
|
||||
directive = ShellCompDirectiveNoFileComp
|
||||
}
|
||||
@ -507,7 +547,7 @@ func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDi
|
||||
}
|
||||
|
||||
// Find the completion function for the flag or command
|
||||
var completionFn func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective)
|
||||
var completionFn CompletionFunc
|
||||
if flag != nil && flagCompletion {
|
||||
flagCompletionMutex.RLock()
|
||||
completionFn = flagCompletionFunctions[flag]
|
||||
@ -518,7 +558,7 @@ func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDi
|
||||
if completionFn != nil {
|
||||
// Go custom completion defined for this flag or command.
|
||||
// Call the registered completion function to get the completions.
|
||||
var comps []string
|
||||
var comps []Completion
|
||||
comps, directive = completionFn(finalCmd, finalArgs, toComplete)
|
||||
completions = append(completions, comps...)
|
||||
}
|
||||
@ -531,23 +571,23 @@ func helpOrVersionFlagPresent(cmd *Command) bool {
|
||||
len(versionFlag.Annotations[FlagSetByCobraAnnotation]) > 0 && versionFlag.Changed {
|
||||
return true
|
||||
}
|
||||
if helpFlag := cmd.Flags().Lookup("help"); helpFlag != nil &&
|
||||
if helpFlag := cmd.Flags().Lookup(helpFlagName); helpFlag != nil &&
|
||||
len(helpFlag.Annotations[FlagSetByCobraAnnotation]) > 0 && helpFlag.Changed {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func getFlagNameCompletions(flag *pflag.Flag, toComplete string) []string {
|
||||
func getFlagNameCompletions(flag *pflag.Flag, toComplete string) []Completion {
|
||||
if nonCompletableFlag(flag) {
|
||||
return []string{}
|
||||
return []Completion{}
|
||||
}
|
||||
|
||||
var completions []string
|
||||
var completions []Completion
|
||||
flagName := "--" + flag.Name
|
||||
if strings.HasPrefix(flagName, toComplete) {
|
||||
// Flag without the =
|
||||
completions = append(completions, fmt.Sprintf("%s\t%s", flagName, flag.Usage))
|
||||
completions = append(completions, CompletionWithDesc(flagName, flag.Usage))
|
||||
|
||||
// Why suggest both long forms: --flag and --flag= ?
|
||||
// This forces the user to *always* have to type either an = or a space after the flag name.
|
||||
@ -559,20 +599,20 @@ func getFlagNameCompletions(flag *pflag.Flag, toComplete string) []string {
|
||||
// if len(flag.NoOptDefVal) == 0 {
|
||||
// // Flag requires a value, so it can be suffixed with =
|
||||
// flagName += "="
|
||||
// completions = append(completions, fmt.Sprintf("%s\t%s", flagName, flag.Usage))
|
||||
// completions = append(completions, CompletionWithDesc(flagName, flag.Usage))
|
||||
// }
|
||||
}
|
||||
|
||||
flagName = "-" + flag.Shorthand
|
||||
if len(flag.Shorthand) > 0 && strings.HasPrefix(flagName, toComplete) {
|
||||
completions = append(completions, fmt.Sprintf("%s\t%s", flagName, flag.Usage))
|
||||
completions = append(completions, CompletionWithDesc(flagName, flag.Usage))
|
||||
}
|
||||
|
||||
return completions
|
||||
}
|
||||
|
||||
func completeRequireFlags(finalCmd *Command, toComplete string) []string {
|
||||
var completions []string
|
||||
func completeRequireFlags(finalCmd *Command, toComplete string) []Completion {
|
||||
var completions []Completion
|
||||
|
||||
doCompleteRequiredFlags := func(flag *pflag.Flag) {
|
||||
if _, present := flag.Annotations[BashCompOneRequiredFlag]; present {
|
||||
@ -687,8 +727,8 @@ func checkIfFlagCompletion(finalCmd *Command, args []string, lastArg string) (*p
|
||||
// 1- the feature has been explicitly disabled by the program,
|
||||
// 2- c has no subcommands (to avoid creating one),
|
||||
// 3- c already has a 'completion' command provided by the program.
|
||||
func (c *Command) InitDefaultCompletionCmd() {
|
||||
if c.CompletionOptions.DisableDefaultCmd || !c.HasSubCommands() {
|
||||
func (c *Command) InitDefaultCompletionCmd(args ...string) {
|
||||
if c.CompletionOptions.DisableDefaultCmd {
|
||||
return
|
||||
}
|
||||
|
||||
@ -701,6 +741,16 @@ func (c *Command) InitDefaultCompletionCmd() {
|
||||
|
||||
haveNoDescFlag := !c.CompletionOptions.DisableNoDescFlag && !c.CompletionOptions.DisableDescriptions
|
||||
|
||||
// Special case to know if there are sub-commands or not.
|
||||
hasSubCommands := false
|
||||
for _, cmd := range c.commands {
|
||||
if cmd.Name() != ShellCompRequestCmd && cmd.Name() != helpCommandName {
|
||||
// We found a real sub-command (not 'help' or '__complete')
|
||||
hasSubCommands = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
completionCmd := &Command{
|
||||
Use: compCmdName,
|
||||
Short: "Generate the autocompletion script for the specified shell",
|
||||
@ -714,6 +764,22 @@ See each sub-command's help for details on how to use the generated script.
|
||||
}
|
||||
c.AddCommand(completionCmd)
|
||||
|
||||
if !hasSubCommands {
|
||||
// If the 'completion' command will be the only sub-command,
|
||||
// we only create it if it is actually being called.
|
||||
// This avoids breaking programs that would suddenly find themselves with
|
||||
// a subcommand, which would prevent them from accepting arguments.
|
||||
// We also create the 'completion' command if the user is triggering
|
||||
// shell completion for it (prog __complete completion '')
|
||||
subCmd, cmdArgs, err := c.Find(args)
|
||||
if err != nil || subCmd.Name() != compCmdName &&
|
||||
!(subCmd.Name() == ShellCompRequestCmd && len(cmdArgs) > 1 && cmdArgs[0] == compCmdName) {
|
||||
// The completion command is not being called or being completed so we remove it.
|
||||
c.RemoveCommand(completionCmd)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
out := c.OutOrStdout()
|
||||
noDesc := c.CompletionOptions.DisableDescriptions
|
||||
shortDesc := "Generate the autocompletion script for %s"
|
||||
|
35
vendor/github.com/spf13/cobra/powershell_completions.go
generated
vendored
35
vendor/github.com/spf13/cobra/powershell_completions.go
generated
vendored
@ -162,7 +162,10 @@ filter __%[1]s_escapeStringWithSpecialChars {
|
||||
if (-Not $Description) {
|
||||
$Description = " "
|
||||
}
|
||||
@{Name="$Name";Description="$Description"}
|
||||
New-Object -TypeName PSCustomObject -Property @{
|
||||
Name = "$Name"
|
||||
Description = "$Description"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -240,7 +243,12 @@ filter __%[1]s_escapeStringWithSpecialChars {
|
||||
__%[1]s_debug "Only one completion left"
|
||||
|
||||
# insert space after value
|
||||
[System.Management.Automation.CompletionResult]::new($($comp.Name | __%[1]s_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
||||
$CompletionText = $($comp.Name | __%[1]s_escapeStringWithSpecialChars) + $Space
|
||||
if ($ExecutionContext.SessionState.LanguageMode -eq "FullLanguage"){
|
||||
[System.Management.Automation.CompletionResult]::new($CompletionText, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
||||
} else {
|
||||
$CompletionText
|
||||
}
|
||||
|
||||
} else {
|
||||
# Add the proper number of spaces to align the descriptions
|
||||
@ -255,7 +263,12 @@ filter __%[1]s_escapeStringWithSpecialChars {
|
||||
$Description = " ($($comp.Description))"
|
||||
}
|
||||
|
||||
[System.Management.Automation.CompletionResult]::new("$($comp.Name)$Description", "$($comp.Name)$Description", 'ParameterValue', "$($comp.Description)")
|
||||
$CompletionText = "$($comp.Name)$Description"
|
||||
if ($ExecutionContext.SessionState.LanguageMode -eq "FullLanguage"){
|
||||
[System.Management.Automation.CompletionResult]::new($CompletionText, "$($comp.Name)$Description", 'ParameterValue', "$($comp.Description)")
|
||||
} else {
|
||||
$CompletionText
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,7 +277,13 @@ filter __%[1]s_escapeStringWithSpecialChars {
|
||||
# insert space after value
|
||||
# MenuComplete will automatically show the ToolTip of
|
||||
# the highlighted value at the bottom of the suggestions.
|
||||
[System.Management.Automation.CompletionResult]::new($($comp.Name | __%[1]s_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
||||
|
||||
$CompletionText = $($comp.Name | __%[1]s_escapeStringWithSpecialChars) + $Space
|
||||
if ($ExecutionContext.SessionState.LanguageMode -eq "FullLanguage"){
|
||||
[System.Management.Automation.CompletionResult]::new($CompletionText, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
||||
} else {
|
||||
$CompletionText
|
||||
}
|
||||
}
|
||||
|
||||
# TabCompleteNext and in case we get something unknown
|
||||
@ -272,7 +291,13 @@ filter __%[1]s_escapeStringWithSpecialChars {
|
||||
# Like MenuComplete but we don't want to add a space here because
|
||||
# the user need to press space anyway to get the completion.
|
||||
# Description will not be shown because that's not possible with TabCompleteNext
|
||||
[System.Management.Automation.CompletionResult]::new($($comp.Name | __%[1]s_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
||||
|
||||
$CompletionText = $($comp.Name | __%[1]s_escapeStringWithSpecialChars)
|
||||
if ($ExecutionContext.SessionState.LanguageMode -eq "FullLanguage"){
|
||||
[System.Management.Automation.CompletionResult]::new($CompletionText, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
|
||||
} else {
|
||||
$CompletionText
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
12
vendor/github.com/spf13/pflag/.editorconfig
generated
vendored
Normal file
12
vendor/github.com/spf13/pflag/.editorconfig
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.go]
|
||||
indent_style = tab
|
4
vendor/github.com/spf13/pflag/.golangci.yaml
generated
vendored
Normal file
4
vendor/github.com/spf13/pflag/.golangci.yaml
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- nolintlint
|
29
vendor/github.com/spf13/pflag/flag.go
generated
vendored
29
vendor/github.com/spf13/pflag/flag.go
generated
vendored
@ -173,7 +173,7 @@ type FlagSet struct {
|
||||
args []string // arguments after flags
|
||||
argsLenAtDash int // len(args) when a '--' was located when parsing, or -1 if no --
|
||||
errorHandling ErrorHandling
|
||||
output io.Writer // nil means stderr; use out() accessor
|
||||
output io.Writer // nil means stderr; use Output() accessor
|
||||
interspersed bool // allow interspersed option/non-option args
|
||||
normalizeNameFunc func(f *FlagSet, name string) NormalizedName
|
||||
|
||||
@ -268,13 +268,20 @@ func (f *FlagSet) normalizeFlagName(name string) NormalizedName {
|
||||
return n(f, name)
|
||||
}
|
||||
|
||||
func (f *FlagSet) out() io.Writer {
|
||||
// Output returns the destination for usage and error messages. os.Stderr is returned if
|
||||
// output was not set or was set to nil.
|
||||
func (f *FlagSet) Output() io.Writer {
|
||||
if f.output == nil {
|
||||
return os.Stderr
|
||||
}
|
||||
return f.output
|
||||
}
|
||||
|
||||
// Name returns the name of the flag set.
|
||||
func (f *FlagSet) Name() string {
|
||||
return f.name
|
||||
}
|
||||
|
||||
// SetOutput sets the destination for usage and error messages.
|
||||
// If output is nil, os.Stderr is used.
|
||||
func (f *FlagSet) SetOutput(output io.Writer) {
|
||||
@ -371,7 +378,7 @@ func (f *FlagSet) ShorthandLookup(name string) *Flag {
|
||||
}
|
||||
if len(name) > 1 {
|
||||
msg := fmt.Sprintf("can not look up shorthand which is more than one ASCII character: %q", name)
|
||||
fmt.Fprintf(f.out(), msg)
|
||||
fmt.Fprintf(f.Output(), msg)
|
||||
panic(msg)
|
||||
}
|
||||
c := name[0]
|
||||
@ -495,7 +502,7 @@ func (f *FlagSet) Set(name, value string) error {
|
||||
}
|
||||
|
||||
if flag.Deprecated != "" {
|
||||
fmt.Fprintf(f.out(), "Flag --%s has been deprecated, %s\n", flag.Name, flag.Deprecated)
|
||||
fmt.Fprintf(f.Output(), "Flag --%s has been deprecated, %s\n", flag.Name, flag.Deprecated)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -536,7 +543,7 @@ func Set(name, value string) error {
|
||||
// otherwise, the default values of all defined flags in the set.
|
||||
func (f *FlagSet) PrintDefaults() {
|
||||
usages := f.FlagUsages()
|
||||
fmt.Fprint(f.out(), usages)
|
||||
fmt.Fprint(f.Output(), usages)
|
||||
}
|
||||
|
||||
// defaultIsZeroValue returns true if the default value for this flag represents
|
||||
@ -771,7 +778,7 @@ func PrintDefaults() {
|
||||
|
||||
// defaultUsage is the default function to print a usage message.
|
||||
func defaultUsage(f *FlagSet) {
|
||||
fmt.Fprintf(f.out(), "Usage of %s:\n", f.name)
|
||||
fmt.Fprintf(f.Output(), "Usage of %s:\n", f.name)
|
||||
f.PrintDefaults()
|
||||
}
|
||||
|
||||
@ -857,7 +864,7 @@ func (f *FlagSet) AddFlag(flag *Flag) {
|
||||
_, alreadyThere := f.formal[normalizedFlagName]
|
||||
if alreadyThere {
|
||||
msg := fmt.Sprintf("%s flag redefined: %s", f.name, flag.Name)
|
||||
fmt.Fprintln(f.out(), msg)
|
||||
fmt.Fprintln(f.Output(), msg)
|
||||
panic(msg) // Happens only if flags are declared with identical names
|
||||
}
|
||||
if f.formal == nil {
|
||||
@ -873,7 +880,7 @@ func (f *FlagSet) AddFlag(flag *Flag) {
|
||||
}
|
||||
if len(flag.Shorthand) > 1 {
|
||||
msg := fmt.Sprintf("%q shorthand is more than one ASCII character", flag.Shorthand)
|
||||
fmt.Fprintf(f.out(), msg)
|
||||
fmt.Fprintf(f.Output(), msg)
|
||||
panic(msg)
|
||||
}
|
||||
if f.shorthands == nil {
|
||||
@ -883,7 +890,7 @@ func (f *FlagSet) AddFlag(flag *Flag) {
|
||||
used, alreadyThere := f.shorthands[c]
|
||||
if alreadyThere {
|
||||
msg := fmt.Sprintf("unable to redefine %q shorthand in %q flagset: it's already used for %q flag", c, f.name, used.Name)
|
||||
fmt.Fprintf(f.out(), msg)
|
||||
fmt.Fprintf(f.Output(), msg)
|
||||
panic(msg)
|
||||
}
|
||||
f.shorthands[c] = flag
|
||||
@ -922,7 +929,7 @@ func VarP(value Value, name, shorthand, usage string) {
|
||||
func (f *FlagSet) failf(format string, a ...interface{}) error {
|
||||
err := fmt.Errorf(format, a...)
|
||||
if f.errorHandling != ContinueOnError {
|
||||
fmt.Fprintln(f.out(), err)
|
||||
fmt.Fprintln(f.Output(), err)
|
||||
f.usage()
|
||||
}
|
||||
return err
|
||||
@ -1073,7 +1080,7 @@ func (f *FlagSet) parseSingleShortArg(shorthands string, args []string, fn parse
|
||||
}
|
||||
|
||||
if flag.ShorthandDeprecated != "" {
|
||||
fmt.Fprintf(f.out(), "Flag shorthand -%s has been deprecated, %s\n", flag.Shorthand, flag.ShorthandDeprecated)
|
||||
fmt.Fprintf(f.Output(), "Flag shorthand -%s has been deprecated, %s\n", flag.Shorthand, flag.ShorthandDeprecated)
|
||||
}
|
||||
|
||||
err = fn(flag, value)
|
||||
|
3
vendor/github.com/spf13/pflag/ip.go
generated
vendored
3
vendor/github.com/spf13/pflag/ip.go
generated
vendored
@ -16,6 +16,9 @@ func newIPValue(val net.IP, p *net.IP) *ipValue {
|
||||
|
||||
func (i *ipValue) String() string { return net.IP(*i).String() }
|
||||
func (i *ipValue) Set(s string) error {
|
||||
if s == "" {
|
||||
return nil
|
||||
}
|
||||
ip := net.ParseIP(strings.TrimSpace(s))
|
||||
if ip == nil {
|
||||
return fmt.Errorf("failed to parse IP: %q", s)
|
||||
|
147
vendor/github.com/spf13/pflag/ipnet_slice.go
generated
vendored
Normal file
147
vendor/github.com/spf13/pflag/ipnet_slice.go
generated
vendored
Normal file
@ -0,0 +1,147 @@
|
||||
package pflag
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// -- ipNetSlice Value
|
||||
type ipNetSliceValue struct {
|
||||
value *[]net.IPNet
|
||||
changed bool
|
||||
}
|
||||
|
||||
func newIPNetSliceValue(val []net.IPNet, p *[]net.IPNet) *ipNetSliceValue {
|
||||
ipnsv := new(ipNetSliceValue)
|
||||
ipnsv.value = p
|
||||
*ipnsv.value = val
|
||||
return ipnsv
|
||||
}
|
||||
|
||||
// Set converts, and assigns, the comma-separated IPNet argument string representation as the []net.IPNet value of this flag.
|
||||
// If Set is called on a flag that already has a []net.IPNet assigned, the newly converted values will be appended.
|
||||
func (s *ipNetSliceValue) Set(val string) error {
|
||||
|
||||
// remove all quote characters
|
||||
rmQuote := strings.NewReplacer(`"`, "", `'`, "", "`", "")
|
||||
|
||||
// read flag arguments with CSV parser
|
||||
ipNetStrSlice, err := readAsCSV(rmQuote.Replace(val))
|
||||
if err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
// parse ip values into slice
|
||||
out := make([]net.IPNet, 0, len(ipNetStrSlice))
|
||||
for _, ipNetStr := range ipNetStrSlice {
|
||||
_, n, err := net.ParseCIDR(strings.TrimSpace(ipNetStr))
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid string being converted to CIDR: %s", ipNetStr)
|
||||
}
|
||||
out = append(out, *n)
|
||||
}
|
||||
|
||||
if !s.changed {
|
||||
*s.value = out
|
||||
} else {
|
||||
*s.value = append(*s.value, out...)
|
||||
}
|
||||
|
||||
s.changed = true
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Type returns a string that uniquely represents this flag's type.
|
||||
func (s *ipNetSliceValue) Type() string {
|
||||
return "ipNetSlice"
|
||||
}
|
||||
|
||||
// String defines a "native" format for this net.IPNet slice flag value.
|
||||
func (s *ipNetSliceValue) String() string {
|
||||
|
||||
ipNetStrSlice := make([]string, len(*s.value))
|
||||
for i, n := range *s.value {
|
||||
ipNetStrSlice[i] = n.String()
|
||||
}
|
||||
|
||||
out, _ := writeAsCSV(ipNetStrSlice)
|
||||
return "[" + out + "]"
|
||||
}
|
||||
|
||||
func ipNetSliceConv(val string) (interface{}, error) {
|
||||
val = strings.Trim(val, "[]")
|
||||
// Emtpy string would cause a slice with one (empty) entry
|
||||
if len(val) == 0 {
|
||||
return []net.IPNet{}, nil
|
||||
}
|
||||
ss := strings.Split(val, ",")
|
||||
out := make([]net.IPNet, len(ss))
|
||||
for i, sval := range ss {
|
||||
_, n, err := net.ParseCIDR(strings.TrimSpace(sval))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid string being converted to CIDR: %s", sval)
|
||||
}
|
||||
out[i] = *n
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// GetIPNetSlice returns the []net.IPNet value of a flag with the given name
|
||||
func (f *FlagSet) GetIPNetSlice(name string) ([]net.IPNet, error) {
|
||||
val, err := f.getFlagType(name, "ipNetSlice", ipNetSliceConv)
|
||||
if err != nil {
|
||||
return []net.IPNet{}, err
|
||||
}
|
||||
return val.([]net.IPNet), nil
|
||||
}
|
||||
|
||||
// IPNetSliceVar defines a ipNetSlice flag with specified name, default value, and usage string.
|
||||
// The argument p points to a []net.IPNet variable in which to store the value of the flag.
|
||||
func (f *FlagSet) IPNetSliceVar(p *[]net.IPNet, name string, value []net.IPNet, usage string) {
|
||||
f.VarP(newIPNetSliceValue(value, p), name, "", usage)
|
||||
}
|
||||
|
||||
// IPNetSliceVarP is like IPNetSliceVar, but accepts a shorthand letter that can be used after a single dash.
|
||||
func (f *FlagSet) IPNetSliceVarP(p *[]net.IPNet, name, shorthand string, value []net.IPNet, usage string) {
|
||||
f.VarP(newIPNetSliceValue(value, p), name, shorthand, usage)
|
||||
}
|
||||
|
||||
// IPNetSliceVar defines a []net.IPNet flag with specified name, default value, and usage string.
|
||||
// The argument p points to a []net.IPNet variable in which to store the value of the flag.
|
||||
func IPNetSliceVar(p *[]net.IPNet, name string, value []net.IPNet, usage string) {
|
||||
CommandLine.VarP(newIPNetSliceValue(value, p), name, "", usage)
|
||||
}
|
||||
|
||||
// IPNetSliceVarP is like IPNetSliceVar, but accepts a shorthand letter that can be used after a single dash.
|
||||
func IPNetSliceVarP(p *[]net.IPNet, name, shorthand string, value []net.IPNet, usage string) {
|
||||
CommandLine.VarP(newIPNetSliceValue(value, p), name, shorthand, usage)
|
||||
}
|
||||
|
||||
// IPNetSlice defines a []net.IPNet flag with specified name, default value, and usage string.
|
||||
// The return value is the address of a []net.IPNet variable that stores the value of that flag.
|
||||
func (f *FlagSet) IPNetSlice(name string, value []net.IPNet, usage string) *[]net.IPNet {
|
||||
p := []net.IPNet{}
|
||||
f.IPNetSliceVarP(&p, name, "", value, usage)
|
||||
return &p
|
||||
}
|
||||
|
||||
// IPNetSliceP is like IPNetSlice, but accepts a shorthand letter that can be used after a single dash.
|
||||
func (f *FlagSet) IPNetSliceP(name, shorthand string, value []net.IPNet, usage string) *[]net.IPNet {
|
||||
p := []net.IPNet{}
|
||||
f.IPNetSliceVarP(&p, name, shorthand, value, usage)
|
||||
return &p
|
||||
}
|
||||
|
||||
// IPNetSlice defines a []net.IPNet flag with specified name, default value, and usage string.
|
||||
// The return value is the address of a []net.IP variable that stores the value of the flag.
|
||||
func IPNetSlice(name string, value []net.IPNet, usage string) *[]net.IPNet {
|
||||
return CommandLine.IPNetSliceP(name, "", value, usage)
|
||||
}
|
||||
|
||||
// IPNetSliceP is like IPNetSlice, but accepts a shorthand letter that can be used after a single dash.
|
||||
func IPNetSliceP(name, shorthand string, value []net.IPNet, usage string) *[]net.IPNet {
|
||||
return CommandLine.IPNetSliceP(name, shorthand, value, usage)
|
||||
}
|
4
vendor/github.com/spf13/pflag/string_array.go
generated
vendored
4
vendor/github.com/spf13/pflag/string_array.go
generated
vendored
@ -31,11 +31,7 @@ func (s *stringArrayValue) Append(val string) error {
|
||||
func (s *stringArrayValue) Replace(val []string) error {
|
||||
out := make([]string, len(val))
|
||||
for i, d := range val {
|
||||
var err error
|
||||
out[i] = d
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
*s.value = out
|
||||
return nil
|
||||
|
7
vendor/github.com/zalando/go-keyring/keyring.go
generated
vendored
7
vendor/github.com/zalando/go-keyring/keyring.go
generated
vendored
@ -25,6 +25,8 @@ type Keyring interface {
|
||||
Get(service, user string) (string, error)
|
||||
// Delete secret from keyring.
|
||||
Delete(service, user string) error
|
||||
// DeleteAll deletes all secrets for a given service
|
||||
DeleteAll(service string) error
|
||||
}
|
||||
|
||||
// Set password in keyring for user.
|
||||
@ -41,3 +43,8 @@ func Get(service, user string) (string, error) {
|
||||
func Delete(service, user string) error {
|
||||
return provider.Delete(service, user)
|
||||
}
|
||||
|
||||
// DeleteAll deletes all secrets for a given service
|
||||
func DeleteAll(service string) error {
|
||||
return provider.DeleteAll(service)
|
||||
}
|
||||
|
24
vendor/github.com/zalando/go-keyring/keyring_darwin.go
generated
vendored
24
vendor/github.com/zalando/go-keyring/keyring_darwin.go
generated
vendored
@ -22,7 +22,7 @@ import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/alessio/shellescape"
|
||||
"al.essio.dev/pkg/shellescape"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -113,6 +113,28 @@ func (k macOSXKeychain) Delete(service, username string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteAll deletes all secrets for a given service
|
||||
func (k macOSXKeychain) DeleteAll(service string) error {
|
||||
// if service is empty, do nothing otherwise it might accidentally delete all secrets
|
||||
if service == "" {
|
||||
return ErrNotFound
|
||||
}
|
||||
// Delete each secret in a while loop until there is no more left
|
||||
// under the service
|
||||
for {
|
||||
out, err := exec.Command(
|
||||
execPathKeychain,
|
||||
"delete-generic-password",
|
||||
"-s", service).CombinedOutput()
|
||||
if strings.Contains(string(out), "could not be found") {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func init() {
|
||||
provider = macOSXKeychain{}
|
||||
}
|
||||
|
4
vendor/github.com/zalando/go-keyring/keyring_fallback.go
generated
vendored
4
vendor/github.com/zalando/go-keyring/keyring_fallback.go
generated
vendored
@ -21,3 +21,7 @@ func (fallbackServiceProvider) Get(service, user string) (string, error) {
|
||||
func (fallbackServiceProvider) Delete(service, user string) error {
|
||||
return ErrUnsupportedPlatform
|
||||
}
|
||||
|
||||
func (fallbackServiceProvider) DeleteAll(service string) error {
|
||||
return ErrUnsupportedPlatform
|
||||
}
|
||||
|
9
vendor/github.com/zalando/go-keyring/keyring_mock.go
generated
vendored
9
vendor/github.com/zalando/go-keyring/keyring_mock.go
generated
vendored
@ -50,6 +50,15 @@ func (m *mockProvider) Delete(service, user string) error {
|
||||
return ErrNotFound
|
||||
}
|
||||
|
||||
// DeleteAll deletes all secrets for a given service
|
||||
func (m *mockProvider) DeleteAll(service string) error {
|
||||
if m.mockError != nil {
|
||||
return m.mockError
|
||||
}
|
||||
delete(m.mockStore, service)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MockInit sets the provider to a mocked memory store
|
||||
func MockInit() {
|
||||
provider = &mockProvider{}
|
||||
|
53
vendor/github.com/zalando/go-keyring/keyring_unix.go
generated
vendored
53
vendor/github.com/zalando/go-keyring/keyring_unix.go
generated
vendored
@ -76,6 +76,31 @@ func (s secretServiceProvider) findItem(svc *ss.SecretService, service, user str
|
||||
return results[0], nil
|
||||
}
|
||||
|
||||
// findServiceItems looksup all items by service.
|
||||
func (s secretServiceProvider) findServiceItems(svc *ss.SecretService, service string) ([]dbus.ObjectPath, error) {
|
||||
collection := svc.GetLoginCollection()
|
||||
|
||||
search := map[string]string{
|
||||
"service": service,
|
||||
}
|
||||
|
||||
err := svc.Unlock(collection.Path())
|
||||
if err != nil {
|
||||
return []dbus.ObjectPath{}, err
|
||||
}
|
||||
|
||||
results, err := svc.SearchItems(collection, search)
|
||||
if err != nil {
|
||||
return []dbus.ObjectPath{}, err
|
||||
}
|
||||
|
||||
if len(results) == 0 {
|
||||
return []dbus.ObjectPath{}, ErrNotFound
|
||||
}
|
||||
|
||||
return results, nil
|
||||
}
|
||||
|
||||
// Get gets a secret from the keyring given a service name and a user.
|
||||
func (s secretServiceProvider) Get(service, user string) (string, error) {
|
||||
svc, err := ss.NewSecretService()
|
||||
@ -124,6 +149,34 @@ func (s secretServiceProvider) Delete(service, user string) error {
|
||||
return svc.Delete(item)
|
||||
}
|
||||
|
||||
// DeleteAll deletes all secrets for a given service
|
||||
func (s secretServiceProvider) DeleteAll(service string) error {
|
||||
// if service is empty, do nothing otherwise it might accidentally delete all secrets
|
||||
if service == "" {
|
||||
return ErrNotFound
|
||||
}
|
||||
|
||||
svc, err := ss.NewSecretService()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// find all items for the service
|
||||
items, err := s.findServiceItems(svc, service)
|
||||
if err != nil {
|
||||
if err == ErrNotFound {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
for _, item := range items {
|
||||
err = svc.Delete(item)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
provider = secretServiceProvider{}
|
||||
}
|
||||
|
34
vendor/github.com/zalando/go-keyring/keyring_windows.go
generated
vendored
34
vendor/github.com/zalando/go-keyring/keyring_windows.go
generated
vendored
@ -1,6 +1,7 @@
|
||||
package keyring
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/danieljoos/wincred"
|
||||
@ -59,6 +60,39 @@ func (k windowsKeychain) Delete(service, username string) error {
|
||||
return cred.Delete()
|
||||
}
|
||||
|
||||
func (k windowsKeychain) DeleteAll(service string) error {
|
||||
// if service is empty, do nothing otherwise it might accidentally delete all secrets
|
||||
if service == "" {
|
||||
return ErrNotFound
|
||||
}
|
||||
|
||||
creds, err := wincred.List()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
prefix := k.credName(service, "")
|
||||
deletedCount := 0
|
||||
|
||||
for _, cred := range creds {
|
||||
if strings.HasPrefix(cred.TargetName, prefix) {
|
||||
genericCred, err := wincred.GetGenericCredential(cred.TargetName)
|
||||
if err != nil {
|
||||
if err != syscall.ERROR_NOT_FOUND {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
err := genericCred.Delete()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
deletedCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// credName combines service and username to a single string.
|
||||
func (k windowsKeychain) credName(service, username string) string {
|
||||
return service + ":" + username
|
||||
|
12
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go
generated
vendored
12
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go
generated
vendored
@ -1521,6 +1521,18 @@ func (dvd DefaultValueDecoders) ValueUnmarshalerDecodeValue(_ DecodeContext, vr
|
||||
return ValueDecoderError{Name: "ValueUnmarshalerDecodeValue", Types: []reflect.Type{tValueUnmarshaler}, Received: val}
|
||||
}
|
||||
|
||||
// If BSON value is null and the go value is a pointer, then don't call
|
||||
// UnmarshalBSONValue. Even if the Go pointer is already initialized (i.e.,
|
||||
// non-nil), encountering null in BSON will result in the pointer being
|
||||
// directly set to nil here. Since the pointer is being replaced with nil,
|
||||
// there is no opportunity (or reason) for the custom UnmarshalBSONValue logic
|
||||
// to be called.
|
||||
if vr.Type() == bsontype.Null && val.Kind() == reflect.Ptr {
|
||||
val.Set(reflect.Zero(val.Type()))
|
||||
|
||||
return vr.ReadNull()
|
||||
}
|
||||
|
||||
if val.Kind() == reflect.Ptr && val.IsNil() {
|
||||
if !val.CanSet() {
|
||||
return ValueDecoderError{Name: "ValueUnmarshalerDecodeValue", Types: []reflect.Type{tValueUnmarshaler}, Received: val}
|
||||
|
2
vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_parser.go
generated
vendored
2
vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_parser.go
generated
vendored
@ -305,7 +305,7 @@ func (ejp *extJSONParser) readValue(t bsontype.Type) (*extJSONValue, error) {
|
||||
}
|
||||
|
||||
// remove hyphens
|
||||
uuidNoHyphens := strings.Replace(uuid, "-", "", -1)
|
||||
uuidNoHyphens := strings.ReplaceAll(uuid, "-", "")
|
||||
if len(uuidNoHyphens) != 32 {
|
||||
return nil, fmt.Errorf("$uuid value does not follow RFC 4122 format regarding length and hyphens")
|
||||
}
|
||||
|
13
vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_writer.go
generated
vendored
13
vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_writer.go
generated
vendored
@ -628,13 +628,14 @@ func (ejvw *extJSONValueWriter) WriteArrayEnd() error {
|
||||
|
||||
func formatDouble(f float64) string {
|
||||
var s string
|
||||
if math.IsInf(f, 1) {
|
||||
switch {
|
||||
case math.IsInf(f, 1):
|
||||
s = "Infinity"
|
||||
} else if math.IsInf(f, -1) {
|
||||
case math.IsInf(f, -1):
|
||||
s = "-Infinity"
|
||||
} else if math.IsNaN(f) {
|
||||
case math.IsNaN(f):
|
||||
s = "NaN"
|
||||
} else {
|
||||
default:
|
||||
// Print exactly one decimalType place for integers; otherwise, print as many are necessary to
|
||||
// perfectly represent it.
|
||||
s = strconv.FormatFloat(f, 'G', -1, 64)
|
||||
@ -739,9 +740,7 @@ func (ss sortableString) Less(i, j int) bool {
|
||||
}
|
||||
|
||||
func (ss sortableString) Swap(i, j int) {
|
||||
oldI := ss[i]
|
||||
ss[i] = ss[j]
|
||||
ss[j] = oldI
|
||||
ss[i], ss[j] = ss[j], ss[i]
|
||||
}
|
||||
|
||||
func sortStringAlphebeticAscending(s string) string {
|
||||
|
37
vendor/go.mongodb.org/mongo-driver/bson/bsonrw/json_scanner.go
generated
vendored
37
vendor/go.mongodb.org/mongo-driver/bson/bsonrw/json_scanner.go
generated
vendored
@ -82,12 +82,13 @@ func (js *jsonScanner) nextToken() (*jsonToken, error) {
|
||||
return js.scanString()
|
||||
default:
|
||||
// check if it's a number
|
||||
if c == '-' || isDigit(c) {
|
||||
switch {
|
||||
case c == '-' || isDigit(c):
|
||||
return js.scanNumber(c)
|
||||
} else if c == 't' || c == 'f' || c == 'n' {
|
||||
case c == 't' || c == 'f' || c == 'n':
|
||||
// maybe a literal
|
||||
return js.scanLiteral(c)
|
||||
} else {
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid JSON input. Position: %d. Character: %c", js.pos-1, c)
|
||||
}
|
||||
}
|
||||
@ -174,7 +175,7 @@ func getu4(s []byte) rune {
|
||||
for _, c := range s[:4] {
|
||||
switch {
|
||||
case '0' <= c && c <= '9':
|
||||
c = c - '0'
|
||||
c -= '0'
|
||||
case 'a' <= c && c <= 'f':
|
||||
c = c - 'a' + 10
|
||||
case 'A' <= c && c <= 'F':
|
||||
@ -325,13 +326,14 @@ func (js *jsonScanner) scanLiteral(first byte) (*jsonToken, error) {
|
||||
|
||||
c5, err := js.readNextByte()
|
||||
|
||||
if bytes.Equal([]byte("true"), lit) && (isValueTerminator(c5) || errors.Is(err, io.EOF)) {
|
||||
switch {
|
||||
case bytes.Equal([]byte("true"), lit) && (isValueTerminator(c5) || errors.Is(err, io.EOF)):
|
||||
js.pos = int(math.Max(0, float64(js.pos-1)))
|
||||
return &jsonToken{t: jttBool, v: true, p: p}, nil
|
||||
} else if bytes.Equal([]byte("null"), lit) && (isValueTerminator(c5) || errors.Is(err, io.EOF)) {
|
||||
case bytes.Equal([]byte("null"), lit) && (isValueTerminator(c5) || errors.Is(err, io.EOF)):
|
||||
js.pos = int(math.Max(0, float64(js.pos-1)))
|
||||
return &jsonToken{t: jttNull, v: nil, p: p}, nil
|
||||
} else if bytes.Equal([]byte("fals"), lit) {
|
||||
case bytes.Equal([]byte("fals"), lit):
|
||||
if c5 == 'e' {
|
||||
c5, err = js.readNextByte()
|
||||
|
||||
@ -430,12 +432,13 @@ func (js *jsonScanner) scanNumber(first byte) (*jsonToken, error) {
|
||||
case '}', ']', ',':
|
||||
s = nssDone
|
||||
default:
|
||||
if isWhiteSpace(c) || errors.Is(err, io.EOF) {
|
||||
switch {
|
||||
case isWhiteSpace(c) || errors.Is(err, io.EOF):
|
||||
s = nssDone
|
||||
} else if isDigit(c) {
|
||||
case isDigit(c):
|
||||
s = nssSawIntegerDigits
|
||||
b.WriteByte(c)
|
||||
} else {
|
||||
default:
|
||||
s = nssInvalid
|
||||
}
|
||||
}
|
||||
@ -455,12 +458,13 @@ func (js *jsonScanner) scanNumber(first byte) (*jsonToken, error) {
|
||||
case '}', ']', ',':
|
||||
s = nssDone
|
||||
default:
|
||||
if isWhiteSpace(c) || errors.Is(err, io.EOF) {
|
||||
switch {
|
||||
case isWhiteSpace(c) || errors.Is(err, io.EOF):
|
||||
s = nssDone
|
||||
} else if isDigit(c) {
|
||||
case isDigit(c):
|
||||
s = nssSawFractionDigits
|
||||
b.WriteByte(c)
|
||||
} else {
|
||||
default:
|
||||
s = nssInvalid
|
||||
}
|
||||
}
|
||||
@ -490,12 +494,13 @@ func (js *jsonScanner) scanNumber(first byte) (*jsonToken, error) {
|
||||
case '}', ']', ',':
|
||||
s = nssDone
|
||||
default:
|
||||
if isWhiteSpace(c) || errors.Is(err, io.EOF) {
|
||||
switch {
|
||||
case isWhiteSpace(c) || errors.Is(err, io.EOF):
|
||||
s = nssDone
|
||||
} else if isDigit(c) {
|
||||
case isDigit(c):
|
||||
s = nssSawExponentDigits
|
||||
b.WriteByte(c)
|
||||
} else {
|
||||
default:
|
||||
s = nssInvalid
|
||||
}
|
||||
}
|
||||
|
2
vendor/go.mongodb.org/mongo-driver/bson/bsonrw/value_writer.go
generated
vendored
2
vendor/go.mongodb.org/mongo-driver/bson/bsonrw/value_writer.go
generated
vendored
@ -598,7 +598,7 @@ func (vw *valueWriter) writeLength() error {
|
||||
return errMaxDocumentSizeExceeded{size: int64(len(vw.buf))}
|
||||
}
|
||||
frame := &vw.stack[vw.frame]
|
||||
length = length - int(frame.start)
|
||||
length -= int(frame.start)
|
||||
start := frame.start
|
||||
|
||||
_ = vw.buf[start+3] // BCE
|
||||
|
11
vendor/go.mongodb.org/mongo-driver/bson/doc.go
generated
vendored
11
vendor/go.mongodb.org/mongo-driver/bson/doc.go
generated
vendored
@ -107,10 +107,13 @@
|
||||
// The name may be empty in order to specify options without overriding the default field name. The following options can
|
||||
// be used to configure behavior:
|
||||
//
|
||||
// 1. omitempty: If the omitempty struct tag is specified on a field, the field will be omitted from the marshaling if
|
||||
// the field has an empty value, defined as false, 0, a nil pointer, a nil interface value, and any empty array,
|
||||
// slice, map, or string.
|
||||
// NOTE: It is recommended that this tag be used for all slice and map fields.
|
||||
// 1. omitempty: If the "omitempty" struct tag is specified on a field, the field will not be marshaled if it is set to
|
||||
// an "empty" value. Numbers, booleans, and strings are considered empty if their value is equal to the zero value for
|
||||
// the type (i.e. 0 for numbers, false for booleans, and "" for strings). Slices, maps, and arrays are considered
|
||||
// empty if they are of length zero. Interfaces and pointers are considered empty if their value is nil. By default,
|
||||
// structs are only considered empty if the struct type implements [bsoncodec.Zeroer] and the IsZero
|
||||
// method returns true. Struct types that do not implement [bsoncodec.Zeroer] are never considered empty and will be
|
||||
// marshaled as embedded documents. NOTE: It is recommended that this tag be used for all slice and map fields.
|
||||
//
|
||||
// 2. minsize: If the minsize struct tag is specified on a field of type int64, uint, uint32, or uint64 and the value of
|
||||
// the field can fit in a signed int32, the field will be serialized as a BSON int32 rather than a BSON int64. For
|
||||
|
6
vendor/go.mongodb.org/mongo-driver/bson/primitive/decimal.go
generated
vendored
6
vendor/go.mongodb.org/mongo-driver/bson/primitive/decimal.go
generated
vendored
@ -70,7 +70,6 @@ func (d Decimal128) String() string {
|
||||
// Bits: 1*sign 2*ignored 14*exponent 111*significand.
|
||||
// Implicit 0b100 prefix in significand.
|
||||
exp = int(d.h >> 47 & (1<<14 - 1))
|
||||
//high = 4<<47 | d.h&(1<<47-1)
|
||||
// Spec says all of these values are out of range.
|
||||
high, low = 0, 0
|
||||
} else {
|
||||
@ -152,13 +151,12 @@ func (d Decimal128) BigInt() (*big.Int, int, error) {
|
||||
// Bits: 1*sign 2*ignored 14*exponent 111*significand.
|
||||
// Implicit 0b100 prefix in significand.
|
||||
exp = int(high >> 47 & (1<<14 - 1))
|
||||
//high = 4<<47 | d.h&(1<<47-1)
|
||||
// Spec says all of these values are out of range.
|
||||
high, low = 0, 0
|
||||
} else {
|
||||
// Bits: 1*sign 14*exponent 113*significand
|
||||
exp = int(high >> 49 & (1<<14 - 1))
|
||||
high = high & (1<<49 - 1)
|
||||
high &= (1<<49 - 1)
|
||||
}
|
||||
exp += MinDecimal128Exp
|
||||
|
||||
@ -352,7 +350,7 @@ var (
|
||||
|
||||
// ParseDecimal128FromBigInt attempts to parse the given significand and exponent into a valid Decimal128 value.
|
||||
func ParseDecimal128FromBigInt(bi *big.Int, exp int) (Decimal128, bool) {
|
||||
//copy
|
||||
// copy
|
||||
bi = new(big.Int).Set(bi)
|
||||
|
||||
q := new(big.Int)
|
||||
|
3
vendor/go.mongodb.org/mongo-driver/bson/unmarshal.go
generated
vendored
3
vendor/go.mongodb.org/mongo-driver/bson/unmarshal.go
generated
vendored
@ -41,6 +41,9 @@ type ValueUnmarshaler interface {
|
||||
// Unmarshal parses the BSON-encoded data and stores the result in the value
|
||||
// pointed to by val. If val is nil or not a pointer, Unmarshal returns
|
||||
// InvalidUnmarshalError.
|
||||
//
|
||||
// When unmarshaling BSON, if the BSON value is null and the Go value is a
|
||||
// pointer, the pointer is set to nil without calling UnmarshalBSONValue.
|
||||
func Unmarshal(data []byte, val interface{}) error {
|
||||
return UnmarshalWithRegistry(DefaultRegistry, data, val)
|
||||
}
|
||||
|
8
vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/element.go
generated
vendored
8
vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/element.go
generated
vendored
@ -51,7 +51,7 @@ func (e Element) KeyErr() (string, error) {
|
||||
// KeyBytesErr returns the key for this element as a []byte, returning an error if the element is
|
||||
// not valid.
|
||||
func (e Element) KeyBytesErr() ([]byte, error) {
|
||||
if len(e) <= 0 {
|
||||
if len(e) == 0 {
|
||||
return nil, ErrElementMissingType
|
||||
}
|
||||
idx := bytes.IndexByte(e[1:], 0x00)
|
||||
@ -99,7 +99,7 @@ func (e Element) Value() Value {
|
||||
|
||||
// ValueErr returns the value for this element, returning an error if the element is not valid.
|
||||
func (e Element) ValueErr() (Value, error) {
|
||||
if len(e) <= 0 {
|
||||
if len(e) == 0 {
|
||||
return Value{}, ErrElementMissingType
|
||||
}
|
||||
idx := bytes.IndexByte(e[1:], 0x00)
|
||||
@ -116,7 +116,7 @@ func (e Element) ValueErr() (Value, error) {
|
||||
|
||||
// String implements the fmt.String interface. The output will be in extended JSON format.
|
||||
func (e Element) String() string {
|
||||
if len(e) <= 0 {
|
||||
if len(e) == 0 {
|
||||
return ""
|
||||
}
|
||||
t := bsontype.Type(e[0])
|
||||
@ -135,7 +135,7 @@ func (e Element) String() string {
|
||||
// DebugString outputs a human readable version of RawElement. It will attempt to stringify the
|
||||
// valid components of the element even if the entire element is not valid.
|
||||
func (e Element) DebugString() string {
|
||||
if len(e) <= 0 {
|
||||
if len(e) == 0 {
|
||||
return "<malformed>"
|
||||
}
|
||||
t := bsontype.Type(e[0])
|
||||
|
13
vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/value.go
generated
vendored
13
vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/value.go
generated
vendored
@ -924,13 +924,14 @@ func escapeString(s string) string {
|
||||
|
||||
func formatDouble(f float64) string {
|
||||
var s string
|
||||
if math.IsInf(f, 1) {
|
||||
switch {
|
||||
case math.IsInf(f, 1):
|
||||
s = "Infinity"
|
||||
} else if math.IsInf(f, -1) {
|
||||
case math.IsInf(f, -1):
|
||||
s = "-Infinity"
|
||||
} else if math.IsNaN(f) {
|
||||
case math.IsNaN(f):
|
||||
s = "NaN"
|
||||
} else {
|
||||
default:
|
||||
// Print exactly one decimalType place for integers; otherwise, print as many are necessary to
|
||||
// perfectly represent it.
|
||||
s = strconv.FormatFloat(f, 'G', -1, 64)
|
||||
@ -953,9 +954,7 @@ func (ss sortableString) Less(i, j int) bool {
|
||||
}
|
||||
|
||||
func (ss sortableString) Swap(i, j int) {
|
||||
oldI := ss[i]
|
||||
ss[i] = ss[j]
|
||||
ss[j] = oldI
|
||||
ss[i], ss[j] = ss[j], ss[i]
|
||||
}
|
||||
|
||||
func sortStringAlphebeticAscending(s string) string {
|
||||
|
27
vendor/go.opentelemetry.io/auto/sdk/CONTRIBUTING.md
generated
vendored
Normal file
27
vendor/go.opentelemetry.io/auto/sdk/CONTRIBUTING.md
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
# Contributing to go.opentelemetry.io/auto/sdk
|
||||
|
||||
The `go.opentelemetry.io/auto/sdk` module is a purpose built OpenTelemetry SDK.
|
||||
It is designed to be:
|
||||
|
||||
0. An OpenTelemetry compliant SDK
|
||||
1. Instrumented by auto-instrumentation (serializable into OTLP JSON)
|
||||
2. Lightweight
|
||||
3. User-friendly
|
||||
|
||||
These design choices are listed in the order of their importance.
|
||||
|
||||
The primary design goal of this module is to be an OpenTelemetry SDK.
|
||||
This means that it needs to implement the Go APIs found in `go.opentelemetry.io/otel`.
|
||||
|
||||
Having met the requirement of SDK compliance, this module needs to provide code that the `go.opentelemetry.io/auto` module can instrument.
|
||||
The chosen approach to meet this goal is to ensure the telemetry from the SDK is serializable into JSON encoded OTLP.
|
||||
This ensures then that the serialized form is compatible with other OpenTelemetry systems, and the auto-instrumentation can use these systems to deserialize any telemetry it is sent.
|
||||
|
||||
Outside of these first two goals, the intended use becomes relevant.
|
||||
This package is intended to be used in the `go.opentelemetry.io/otel` global API as a default when the auto-instrumentation is running.
|
||||
Because of this, this package needs to not add unnecessary dependencies to that API.
|
||||
Ideally, it adds none.
|
||||
It also needs to operate efficiently.
|
||||
|
||||
Finally, this module is designed to be user-friendly to Go development.
|
||||
It hides complexity in order to provide simpler APIs when the previous goals can all still be met.
|
201
vendor/go.opentelemetry.io/auto/sdk/LICENSE
generated
vendored
Normal file
201
vendor/go.opentelemetry.io/auto/sdk/LICENSE
generated
vendored
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
15
vendor/go.opentelemetry.io/auto/sdk/VERSIONING.md
generated
vendored
Normal file
15
vendor/go.opentelemetry.io/auto/sdk/VERSIONING.md
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# Versioning
|
||||
|
||||
This document describes the versioning policy for this module.
|
||||
This policy is designed so the following goals can be achieved.
|
||||
|
||||
**Users are provided a codebase of value that is stable and secure.**
|
||||
|
||||
## Policy
|
||||
|
||||
* Versioning of this module will be idiomatic of a Go project using [Go modules](https://github.com/golang/go/wiki/Modules).
|
||||
* [Semantic import versioning](https://github.com/golang/go/wiki/Modules#semantic-import-versioning) will be used.
|
||||
* Versions will comply with [semver 2.0](https://semver.org/spec/v2.0.0.html).
|
||||
* Any `v2` or higher version of this module will be included as a `/vN` at the end of the module path used in `go.mod` files and in the package import path.
|
||||
|
||||
* GitHub releases will be made for all releases.
|
14
vendor/go.opentelemetry.io/auto/sdk/doc.go
generated
vendored
Normal file
14
vendor/go.opentelemetry.io/auto/sdk/doc.go
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/*
|
||||
Package sdk provides an auto-instrumentable OpenTelemetry SDK.
|
||||
|
||||
An [go.opentelemetry.io/auto.Instrumentation] can be configured to target the
|
||||
process running this SDK. In that case, all telemetry the SDK produces will be
|
||||
processed and handled by that [go.opentelemetry.io/auto.Instrumentation].
|
||||
|
||||
By default, if there is no [go.opentelemetry.io/auto.Instrumentation] set to
|
||||
auto-instrument the SDK, the SDK will not generate any telemetry.
|
||||
*/
|
||||
package sdk
|
58
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/attr.go
generated
vendored
Normal file
58
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/attr.go
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package telemetry
|
||||
|
||||
// Attr is a key-value pair.
|
||||
type Attr struct {
|
||||
Key string `json:"key,omitempty"`
|
||||
Value Value `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// String returns an Attr for a string value.
|
||||
func String(key, value string) Attr {
|
||||
return Attr{key, StringValue(value)}
|
||||
}
|
||||
|
||||
// Int64 returns an Attr for an int64 value.
|
||||
func Int64(key string, value int64) Attr {
|
||||
return Attr{key, Int64Value(value)}
|
||||
}
|
||||
|
||||
// Int returns an Attr for an int value.
|
||||
func Int(key string, value int) Attr {
|
||||
return Int64(key, int64(value))
|
||||
}
|
||||
|
||||
// Float64 returns an Attr for a float64 value.
|
||||
func Float64(key string, value float64) Attr {
|
||||
return Attr{key, Float64Value(value)}
|
||||
}
|
||||
|
||||
// Bool returns an Attr for a bool value.
|
||||
func Bool(key string, value bool) Attr {
|
||||
return Attr{key, BoolValue(value)}
|
||||
}
|
||||
|
||||
// Bytes returns an Attr for a []byte value.
|
||||
// The passed slice must not be changed after it is passed.
|
||||
func Bytes(key string, value []byte) Attr {
|
||||
return Attr{key, BytesValue(value)}
|
||||
}
|
||||
|
||||
// Slice returns an Attr for a []Value value.
|
||||
// The passed slice must not be changed after it is passed.
|
||||
func Slice(key string, value ...Value) Attr {
|
||||
return Attr{key, SliceValue(value...)}
|
||||
}
|
||||
|
||||
// Map returns an Attr for a map value.
|
||||
// The passed slice must not be changed after it is passed.
|
||||
func Map(key string, value ...Attr) Attr {
|
||||
return Attr{key, MapValue(value...)}
|
||||
}
|
||||
|
||||
// Equal returns if a is equal to b.
|
||||
func (a Attr) Equal(b Attr) bool {
|
||||
return a.Key == b.Key && a.Value.Equal(b.Value)
|
||||
}
|
8
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/doc.go
generated
vendored
Normal file
8
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/doc.go
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/*
|
||||
Package telemetry provides a lightweight representations of OpenTelemetry
|
||||
telemetry that is compatible with the OTLP JSON protobuf encoding.
|
||||
*/
|
||||
package telemetry
|
103
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/id.go
generated
vendored
Normal file
103
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/id.go
generated
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package telemetry
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const (
|
||||
traceIDSize = 16
|
||||
spanIDSize = 8
|
||||
)
|
||||
|
||||
// TraceID is a custom data type that is used for all trace IDs.
|
||||
type TraceID [traceIDSize]byte
|
||||
|
||||
// String returns the hex string representation form of a TraceID.
|
||||
func (tid TraceID) String() string {
|
||||
return hex.EncodeToString(tid[:])
|
||||
}
|
||||
|
||||
// IsEmpty returns false if id contains at least one non-zero byte.
|
||||
func (tid TraceID) IsEmpty() bool {
|
||||
return tid == [traceIDSize]byte{}
|
||||
}
|
||||
|
||||
// MarshalJSON converts the trace ID into a hex string enclosed in quotes.
|
||||
func (tid TraceID) MarshalJSON() ([]byte, error) {
|
||||
if tid.IsEmpty() {
|
||||
return []byte(`""`), nil
|
||||
}
|
||||
return marshalJSON(tid[:])
|
||||
}
|
||||
|
||||
// UnmarshalJSON inflates the trace ID from hex string, possibly enclosed in
|
||||
// quotes.
|
||||
func (tid *TraceID) UnmarshalJSON(data []byte) error {
|
||||
*tid = [traceIDSize]byte{}
|
||||
return unmarshalJSON(tid[:], data)
|
||||
}
|
||||
|
||||
// SpanID is a custom data type that is used for all span IDs.
|
||||
type SpanID [spanIDSize]byte
|
||||
|
||||
// String returns the hex string representation form of a SpanID.
|
||||
func (sid SpanID) String() string {
|
||||
return hex.EncodeToString(sid[:])
|
||||
}
|
||||
|
||||
// IsEmpty returns true if the span ID contains at least one non-zero byte.
|
||||
func (sid SpanID) IsEmpty() bool {
|
||||
return sid == [spanIDSize]byte{}
|
||||
}
|
||||
|
||||
// MarshalJSON converts span ID into a hex string enclosed in quotes.
|
||||
func (sid SpanID) MarshalJSON() ([]byte, error) {
|
||||
if sid.IsEmpty() {
|
||||
return []byte(`""`), nil
|
||||
}
|
||||
return marshalJSON(sid[:])
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes span ID from hex string, possibly enclosed in quotes.
|
||||
func (sid *SpanID) UnmarshalJSON(data []byte) error {
|
||||
*sid = [spanIDSize]byte{}
|
||||
return unmarshalJSON(sid[:], data)
|
||||
}
|
||||
|
||||
// marshalJSON converts id into a hex string enclosed in quotes.
|
||||
func marshalJSON(id []byte) ([]byte, error) {
|
||||
// Plus 2 quote chars at the start and end.
|
||||
hexLen := hex.EncodedLen(len(id)) + 2
|
||||
|
||||
b := make([]byte, hexLen)
|
||||
hex.Encode(b[1:hexLen-1], id)
|
||||
b[0], b[hexLen-1] = '"', '"'
|
||||
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// unmarshalJSON inflates trace id from hex string, possibly enclosed in quotes.
|
||||
func unmarshalJSON(dst []byte, src []byte) error {
|
||||
if l := len(src); l >= 2 && src[0] == '"' && src[l-1] == '"' {
|
||||
src = src[1 : l-1]
|
||||
}
|
||||
nLen := len(src)
|
||||
if nLen == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(dst) != hex.DecodedLen(nLen) {
|
||||
return errors.New("invalid length for ID")
|
||||
}
|
||||
|
||||
_, err := hex.Decode(dst, src)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot unmarshal ID from string '%s': %w", string(src), err)
|
||||
}
|
||||
return nil
|
||||
}
|
67
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/number.go
generated
vendored
Normal file
67
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/number.go
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package telemetry
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// protoInt64 represents the protobuf encoding of integers which can be either
|
||||
// strings or integers.
|
||||
type protoInt64 int64
|
||||
|
||||
// Int64 returns the protoInt64 as an int64.
|
||||
func (i *protoInt64) Int64() int64 { return int64(*i) }
|
||||
|
||||
// UnmarshalJSON decodes both strings and integers.
|
||||
func (i *protoInt64) UnmarshalJSON(data []byte) error {
|
||||
if data[0] == '"' {
|
||||
var str string
|
||||
if err := json.Unmarshal(data, &str); err != nil {
|
||||
return err
|
||||
}
|
||||
parsedInt, err := strconv.ParseInt(str, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*i = protoInt64(parsedInt)
|
||||
} else {
|
||||
var parsedInt int64
|
||||
if err := json.Unmarshal(data, &parsedInt); err != nil {
|
||||
return err
|
||||
}
|
||||
*i = protoInt64(parsedInt)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// protoUint64 represents the protobuf encoding of integers which can be either
|
||||
// strings or integers.
|
||||
type protoUint64 uint64
|
||||
|
||||
// Int64 returns the protoUint64 as a uint64.
|
||||
func (i *protoUint64) Uint64() uint64 { return uint64(*i) }
|
||||
|
||||
// UnmarshalJSON decodes both strings and integers.
|
||||
func (i *protoUint64) UnmarshalJSON(data []byte) error {
|
||||
if data[0] == '"' {
|
||||
var str string
|
||||
if err := json.Unmarshal(data, &str); err != nil {
|
||||
return err
|
||||
}
|
||||
parsedUint, err := strconv.ParseUint(str, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*i = protoUint64(parsedUint)
|
||||
} else {
|
||||
var parsedUint uint64
|
||||
if err := json.Unmarshal(data, &parsedUint); err != nil {
|
||||
return err
|
||||
}
|
||||
*i = protoUint64(parsedUint)
|
||||
}
|
||||
return nil
|
||||
}
|
66
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/resource.go
generated
vendored
Normal file
66
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/resource.go
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package telemetry
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
// Resource information.
|
||||
type Resource struct {
|
||||
// Attrs are the set of attributes that describe the resource. Attribute
|
||||
// keys MUST be unique (it is not allowed to have more than one attribute
|
||||
// with the same key).
|
||||
Attrs []Attr `json:"attributes,omitempty"`
|
||||
// DroppedAttrs is the number of dropped attributes. If the value
|
||||
// is 0, then no attributes were dropped.
|
||||
DroppedAttrs uint32 `json:"droppedAttributesCount,omitempty"`
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes the OTLP formatted JSON contained in data into r.
|
||||
func (r *Resource) UnmarshalJSON(data []byte) error {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != json.Delim('{') {
|
||||
return errors.New("invalid Resource type")
|
||||
}
|
||||
|
||||
for decoder.More() {
|
||||
keyIface, err := decoder.Token()
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// Empty.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
key, ok := keyIface.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid Resource field: %#v", keyIface)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "attributes":
|
||||
err = decoder.Decode(&r.Attrs)
|
||||
case "droppedAttributesCount", "dropped_attributes_count":
|
||||
err = decoder.Decode(&r.DroppedAttrs)
|
||||
default:
|
||||
// Skip unknown.
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
67
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/scope.go
generated
vendored
Normal file
67
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/scope.go
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package telemetry
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
// Scope is the identifying values of the instrumentation scope.
|
||||
type Scope struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
Attrs []Attr `json:"attributes,omitempty"`
|
||||
DroppedAttrs uint32 `json:"droppedAttributesCount,omitempty"`
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes the OTLP formatted JSON contained in data into r.
|
||||
func (s *Scope) UnmarshalJSON(data []byte) error {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != json.Delim('{') {
|
||||
return errors.New("invalid Scope type")
|
||||
}
|
||||
|
||||
for decoder.More() {
|
||||
keyIface, err := decoder.Token()
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// Empty.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
key, ok := keyIface.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid Scope field: %#v", keyIface)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "name":
|
||||
err = decoder.Decode(&s.Name)
|
||||
case "version":
|
||||
err = decoder.Decode(&s.Version)
|
||||
case "attributes":
|
||||
err = decoder.Decode(&s.Attrs)
|
||||
case "droppedAttributesCount", "dropped_attributes_count":
|
||||
err = decoder.Decode(&s.DroppedAttrs)
|
||||
default:
|
||||
// Skip unknown.
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
456
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/span.go
generated
vendored
Normal file
456
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/span.go
generated
vendored
Normal file
@ -0,0 +1,456 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package telemetry
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"time"
|
||||
)
|
||||
|
||||
// A Span represents a single operation performed by a single component of the
|
||||
// system.
|
||||
type Span struct {
|
||||
// A unique identifier for a trace. All spans from the same trace share
|
||||
// the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR
|
||||
// of length other than 16 bytes is considered invalid (empty string in OTLP/JSON
|
||||
// is zero-length and thus is also invalid).
|
||||
//
|
||||
// This field is required.
|
||||
TraceID TraceID `json:"traceId,omitempty"`
|
||||
// A unique identifier for a span within a trace, assigned when the span
|
||||
// is created. The ID is an 8-byte array. An ID with all zeroes OR of length
|
||||
// other than 8 bytes is considered invalid (empty string in OTLP/JSON
|
||||
// is zero-length and thus is also invalid).
|
||||
//
|
||||
// This field is required.
|
||||
SpanID SpanID `json:"spanId,omitempty"`
|
||||
// trace_state conveys information about request position in multiple distributed tracing graphs.
|
||||
// It is a trace_state in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header
|
||||
// See also https://github.com/w3c/distributed-tracing for more details about this field.
|
||||
TraceState string `json:"traceState,omitempty"`
|
||||
// The `span_id` of this span's parent span. If this is a root span, then this
|
||||
// field must be empty. The ID is an 8-byte array.
|
||||
ParentSpanID SpanID `json:"parentSpanId,omitempty"`
|
||||
// Flags, a bit field.
|
||||
//
|
||||
// Bits 0-7 (8 least significant bits) are the trace flags as defined in W3C Trace
|
||||
// Context specification. To read the 8-bit W3C trace flag, use
|
||||
// `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`.
|
||||
//
|
||||
// See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions.
|
||||
//
|
||||
// Bits 8 and 9 represent the 3 states of whether a span's parent
|
||||
// is remote. The states are (unknown, is not remote, is remote).
|
||||
// To read whether the value is known, use `(flags & SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK) != 0`.
|
||||
// To read whether the span is remote, use `(flags & SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK) != 0`.
|
||||
//
|
||||
// When creating span messages, if the message is logically forwarded from another source
|
||||
// with an equivalent flags fields (i.e., usually another OTLP span message), the field SHOULD
|
||||
// be copied as-is. If creating from a source that does not have an equivalent flags field
|
||||
// (such as a runtime representation of an OpenTelemetry span), the high 22 bits MUST
|
||||
// be set to zero.
|
||||
// Readers MUST NOT assume that bits 10-31 (22 most significant bits) will be zero.
|
||||
//
|
||||
// [Optional].
|
||||
Flags uint32 `json:"flags,omitempty"`
|
||||
// A description of the span's operation.
|
||||
//
|
||||
// For example, the name can be a qualified method name or a file name
|
||||
// and a line number where the operation is called. A best practice is to use
|
||||
// the same display name at the same call point in an application.
|
||||
// This makes it easier to correlate spans in different traces.
|
||||
//
|
||||
// This field is semantically required to be set to non-empty string.
|
||||
// Empty value is equivalent to an unknown span name.
|
||||
//
|
||||
// This field is required.
|
||||
Name string `json:"name"`
|
||||
// Distinguishes between spans generated in a particular context. For example,
|
||||
// two spans with the same name may be distinguished using `CLIENT` (caller)
|
||||
// and `SERVER` (callee) to identify queueing latency associated with the span.
|
||||
Kind SpanKind `json:"kind,omitempty"`
|
||||
// start_time_unix_nano is the start time of the span. On the client side, this is the time
|
||||
// kept by the local machine where the span execution starts. On the server side, this
|
||||
// is the time when the server's application handler starts running.
|
||||
// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
|
||||
//
|
||||
// This field is semantically required and it is expected that end_time >= start_time.
|
||||
StartTime time.Time `json:"startTimeUnixNano,omitempty"`
|
||||
// end_time_unix_nano is the end time of the span. On the client side, this is the time
|
||||
// kept by the local machine where the span execution ends. On the server side, this
|
||||
// is the time when the server application handler stops running.
|
||||
// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
|
||||
//
|
||||
// This field is semantically required and it is expected that end_time >= start_time.
|
||||
EndTime time.Time `json:"endTimeUnixNano,omitempty"`
|
||||
// attributes is a collection of key/value pairs. Note, global attributes
|
||||
// like server name can be set using the resource API. Examples of attributes:
|
||||
//
|
||||
// "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
|
||||
// "/http/server_latency": 300
|
||||
// "example.com/myattribute": true
|
||||
// "example.com/score": 10.239
|
||||
//
|
||||
// The OpenTelemetry API specification further restricts the allowed value types:
|
||||
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute
|
||||
// Attribute keys MUST be unique (it is not allowed to have more than one
|
||||
// attribute with the same key).
|
||||
Attrs []Attr `json:"attributes,omitempty"`
|
||||
// dropped_attributes_count is the number of attributes that were discarded. Attributes
|
||||
// can be discarded because their keys are too long or because there are too many
|
||||
// attributes. If this value is 0, then no attributes were dropped.
|
||||
DroppedAttrs uint32 `json:"droppedAttributesCount,omitempty"`
|
||||
// events is a collection of Event items.
|
||||
Events []*SpanEvent `json:"events,omitempty"`
|
||||
// dropped_events_count is the number of dropped events. If the value is 0, then no
|
||||
// events were dropped.
|
||||
DroppedEvents uint32 `json:"droppedEventsCount,omitempty"`
|
||||
// links is a collection of Links, which are references from this span to a span
|
||||
// in the same or different trace.
|
||||
Links []*SpanLink `json:"links,omitempty"`
|
||||
// dropped_links_count is the number of dropped links after the maximum size was
|
||||
// enforced. If this value is 0, then no links were dropped.
|
||||
DroppedLinks uint32 `json:"droppedLinksCount,omitempty"`
|
||||
// An optional final status for this span. Semantically when Status isn't set, it means
|
||||
// span's status code is unset, i.e. assume STATUS_CODE_UNSET (code = 0).
|
||||
Status *Status `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON encodes s into OTLP formatted JSON.
|
||||
func (s Span) MarshalJSON() ([]byte, error) {
|
||||
startT := s.StartTime.UnixNano()
|
||||
if s.StartTime.IsZero() || startT < 0 {
|
||||
startT = 0
|
||||
}
|
||||
|
||||
endT := s.EndTime.UnixNano()
|
||||
if s.EndTime.IsZero() || endT < 0 {
|
||||
endT = 0
|
||||
}
|
||||
|
||||
// Override non-empty default SpanID marshal and omitempty.
|
||||
var parentSpanId string
|
||||
if !s.ParentSpanID.IsEmpty() {
|
||||
b := make([]byte, hex.EncodedLen(spanIDSize))
|
||||
hex.Encode(b, s.ParentSpanID[:])
|
||||
parentSpanId = string(b)
|
||||
}
|
||||
|
||||
type Alias Span
|
||||
return json.Marshal(struct {
|
||||
Alias
|
||||
ParentSpanID string `json:"parentSpanId,omitempty"`
|
||||
StartTime uint64 `json:"startTimeUnixNano,omitempty"`
|
||||
EndTime uint64 `json:"endTimeUnixNano,omitempty"`
|
||||
}{
|
||||
Alias: Alias(s),
|
||||
ParentSpanID: parentSpanId,
|
||||
StartTime: uint64(startT),
|
||||
EndTime: uint64(endT),
|
||||
})
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes the OTLP formatted JSON contained in data into s.
|
||||
func (s *Span) UnmarshalJSON(data []byte) error {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != json.Delim('{') {
|
||||
return errors.New("invalid Span type")
|
||||
}
|
||||
|
||||
for decoder.More() {
|
||||
keyIface, err := decoder.Token()
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// Empty.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
key, ok := keyIface.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid Span field: %#v", keyIface)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "traceId", "trace_id":
|
||||
err = decoder.Decode(&s.TraceID)
|
||||
case "spanId", "span_id":
|
||||
err = decoder.Decode(&s.SpanID)
|
||||
case "traceState", "trace_state":
|
||||
err = decoder.Decode(&s.TraceState)
|
||||
case "parentSpanId", "parent_span_id":
|
||||
err = decoder.Decode(&s.ParentSpanID)
|
||||
case "flags":
|
||||
err = decoder.Decode(&s.Flags)
|
||||
case "name":
|
||||
err = decoder.Decode(&s.Name)
|
||||
case "kind":
|
||||
err = decoder.Decode(&s.Kind)
|
||||
case "startTimeUnixNano", "start_time_unix_nano":
|
||||
var val protoUint64
|
||||
err = decoder.Decode(&val)
|
||||
s.StartTime = time.Unix(0, int64(val.Uint64()))
|
||||
case "endTimeUnixNano", "end_time_unix_nano":
|
||||
var val protoUint64
|
||||
err = decoder.Decode(&val)
|
||||
s.EndTime = time.Unix(0, int64(val.Uint64()))
|
||||
case "attributes":
|
||||
err = decoder.Decode(&s.Attrs)
|
||||
case "droppedAttributesCount", "dropped_attributes_count":
|
||||
err = decoder.Decode(&s.DroppedAttrs)
|
||||
case "events":
|
||||
err = decoder.Decode(&s.Events)
|
||||
case "droppedEventsCount", "dropped_events_count":
|
||||
err = decoder.Decode(&s.DroppedEvents)
|
||||
case "links":
|
||||
err = decoder.Decode(&s.Links)
|
||||
case "droppedLinksCount", "dropped_links_count":
|
||||
err = decoder.Decode(&s.DroppedLinks)
|
||||
case "status":
|
||||
err = decoder.Decode(&s.Status)
|
||||
default:
|
||||
// Skip unknown.
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SpanFlags represents constants used to interpret the
|
||||
// Span.flags field, which is protobuf 'fixed32' type and is to
|
||||
// be used as bit-fields. Each non-zero value defined in this enum is
|
||||
// a bit-mask. To extract the bit-field, for example, use an
|
||||
// expression like:
|
||||
//
|
||||
// (span.flags & SPAN_FLAGS_TRACE_FLAGS_MASK)
|
||||
//
|
||||
// See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions.
|
||||
//
|
||||
// Note that Span flags were introduced in version 1.1 of the
|
||||
// OpenTelemetry protocol. Older Span producers do not set this
|
||||
// field, consequently consumers should not rely on the absence of a
|
||||
// particular flag bit to indicate the presence of a particular feature.
|
||||
type SpanFlags int32
|
||||
|
||||
const (
|
||||
// Bits 0-7 are used for trace flags.
|
||||
SpanFlagsTraceFlagsMask SpanFlags = 255
|
||||
// Bits 8 and 9 are used to indicate that the parent span or link span is remote.
|
||||
// Bit 8 (`HAS_IS_REMOTE`) indicates whether the value is known.
|
||||
// Bit 9 (`IS_REMOTE`) indicates whether the span or link is remote.
|
||||
SpanFlagsContextHasIsRemoteMask SpanFlags = 256
|
||||
// SpanFlagsContextHasIsRemoteMask indicates the Span is remote.
|
||||
SpanFlagsContextIsRemoteMask SpanFlags = 512
|
||||
)
|
||||
|
||||
// SpanKind is the type of span. Can be used to specify additional relationships between spans
|
||||
// in addition to a parent/child relationship.
|
||||
type SpanKind int32
|
||||
|
||||
const (
|
||||
// Indicates that the span represents an internal operation within an application,
|
||||
// as opposed to an operation happening at the boundaries. Default value.
|
||||
SpanKindInternal SpanKind = 1
|
||||
// Indicates that the span covers server-side handling of an RPC or other
|
||||
// remote network request.
|
||||
SpanKindServer SpanKind = 2
|
||||
// Indicates that the span describes a request to some remote service.
|
||||
SpanKindClient SpanKind = 3
|
||||
// Indicates that the span describes a producer sending a message to a broker.
|
||||
// Unlike CLIENT and SERVER, there is often no direct critical path latency relationship
|
||||
// between producer and consumer spans. A PRODUCER span ends when the message was accepted
|
||||
// by the broker while the logical processing of the message might span a much longer time.
|
||||
SpanKindProducer SpanKind = 4
|
||||
// Indicates that the span describes consumer receiving a message from a broker.
|
||||
// Like the PRODUCER kind, there is often no direct critical path latency relationship
|
||||
// between producer and consumer spans.
|
||||
SpanKindConsumer SpanKind = 5
|
||||
)
|
||||
|
||||
// Event is a time-stamped annotation of the span, consisting of user-supplied
|
||||
// text description and key-value pairs.
|
||||
type SpanEvent struct {
|
||||
// time_unix_nano is the time the event occurred.
|
||||
Time time.Time `json:"timeUnixNano,omitempty"`
|
||||
// name of the event.
|
||||
// This field is semantically required to be set to non-empty string.
|
||||
Name string `json:"name,omitempty"`
|
||||
// attributes is a collection of attribute key/value pairs on the event.
|
||||
// Attribute keys MUST be unique (it is not allowed to have more than one
|
||||
// attribute with the same key).
|
||||
Attrs []Attr `json:"attributes,omitempty"`
|
||||
// dropped_attributes_count is the number of dropped attributes. If the value is 0,
|
||||
// then no attributes were dropped.
|
||||
DroppedAttrs uint32 `json:"droppedAttributesCount,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON encodes e into OTLP formatted JSON.
|
||||
func (e SpanEvent) MarshalJSON() ([]byte, error) {
|
||||
t := e.Time.UnixNano()
|
||||
if e.Time.IsZero() || t < 0 {
|
||||
t = 0
|
||||
}
|
||||
|
||||
type Alias SpanEvent
|
||||
return json.Marshal(struct {
|
||||
Alias
|
||||
Time uint64 `json:"timeUnixNano,omitempty"`
|
||||
}{
|
||||
Alias: Alias(e),
|
||||
Time: uint64(t),
|
||||
})
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes the OTLP formatted JSON contained in data into se.
|
||||
func (se *SpanEvent) UnmarshalJSON(data []byte) error {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != json.Delim('{') {
|
||||
return errors.New("invalid SpanEvent type")
|
||||
}
|
||||
|
||||
for decoder.More() {
|
||||
keyIface, err := decoder.Token()
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// Empty.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
key, ok := keyIface.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid SpanEvent field: %#v", keyIface)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "timeUnixNano", "time_unix_nano":
|
||||
var val protoUint64
|
||||
err = decoder.Decode(&val)
|
||||
se.Time = time.Unix(0, int64(val.Uint64()))
|
||||
case "name":
|
||||
err = decoder.Decode(&se.Name)
|
||||
case "attributes":
|
||||
err = decoder.Decode(&se.Attrs)
|
||||
case "droppedAttributesCount", "dropped_attributes_count":
|
||||
err = decoder.Decode(&se.DroppedAttrs)
|
||||
default:
|
||||
// Skip unknown.
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// A pointer from the current span to another span in the same trace or in a
|
||||
// different trace. For example, this can be used in batching operations,
|
||||
// where a single batch handler processes multiple requests from different
|
||||
// traces or when the handler receives a request from a different project.
|
||||
type SpanLink struct {
|
||||
// A unique identifier of a trace that this linked span is part of. The ID is a
|
||||
// 16-byte array.
|
||||
TraceID TraceID `json:"traceId,omitempty"`
|
||||
// A unique identifier for the linked span. The ID is an 8-byte array.
|
||||
SpanID SpanID `json:"spanId,omitempty"`
|
||||
// The trace_state associated with the link.
|
||||
TraceState string `json:"traceState,omitempty"`
|
||||
// attributes is a collection of attribute key/value pairs on the link.
|
||||
// Attribute keys MUST be unique (it is not allowed to have more than one
|
||||
// attribute with the same key).
|
||||
Attrs []Attr `json:"attributes,omitempty"`
|
||||
// dropped_attributes_count is the number of dropped attributes. If the value is 0,
|
||||
// then no attributes were dropped.
|
||||
DroppedAttrs uint32 `json:"droppedAttributesCount,omitempty"`
|
||||
// Flags, a bit field.
|
||||
//
|
||||
// Bits 0-7 (8 least significant bits) are the trace flags as defined in W3C Trace
|
||||
// Context specification. To read the 8-bit W3C trace flag, use
|
||||
// `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`.
|
||||
//
|
||||
// See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions.
|
||||
//
|
||||
// Bits 8 and 9 represent the 3 states of whether the link is remote.
|
||||
// The states are (unknown, is not remote, is remote).
|
||||
// To read whether the value is known, use `(flags & SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK) != 0`.
|
||||
// To read whether the link is remote, use `(flags & SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK) != 0`.
|
||||
//
|
||||
// Readers MUST NOT assume that bits 10-31 (22 most significant bits) will be zero.
|
||||
// When creating new spans, bits 10-31 (most-significant 22-bits) MUST be zero.
|
||||
//
|
||||
// [Optional].
|
||||
Flags uint32 `json:"flags,omitempty"`
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes the OTLP formatted JSON contained in data into sl.
|
||||
func (sl *SpanLink) UnmarshalJSON(data []byte) error {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != json.Delim('{') {
|
||||
return errors.New("invalid SpanLink type")
|
||||
}
|
||||
|
||||
for decoder.More() {
|
||||
keyIface, err := decoder.Token()
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// Empty.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
key, ok := keyIface.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid SpanLink field: %#v", keyIface)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "traceId", "trace_id":
|
||||
err = decoder.Decode(&sl.TraceID)
|
||||
case "spanId", "span_id":
|
||||
err = decoder.Decode(&sl.SpanID)
|
||||
case "traceState", "trace_state":
|
||||
err = decoder.Decode(&sl.TraceState)
|
||||
case "attributes":
|
||||
err = decoder.Decode(&sl.Attrs)
|
||||
case "droppedAttributesCount", "dropped_attributes_count":
|
||||
err = decoder.Decode(&sl.DroppedAttrs)
|
||||
case "flags":
|
||||
err = decoder.Decode(&sl.Flags)
|
||||
default:
|
||||
// Skip unknown.
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
40
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/status.go
generated
vendored
Normal file
40
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/status.go
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package telemetry
|
||||
|
||||
// For the semantics of status codes see
|
||||
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status
|
||||
type StatusCode int32
|
||||
|
||||
const (
|
||||
// The default status.
|
||||
StatusCodeUnset StatusCode = 0
|
||||
// The Span has been validated by an Application developer or Operator to
|
||||
// have completed successfully.
|
||||
StatusCodeOK StatusCode = 1
|
||||
// The Span contains an error.
|
||||
StatusCodeError StatusCode = 2
|
||||
)
|
||||
|
||||
var statusCodeStrings = []string{
|
||||
"Unset",
|
||||
"OK",
|
||||
"Error",
|
||||
}
|
||||
|
||||
func (s StatusCode) String() string {
|
||||
if s >= 0 && int(s) < len(statusCodeStrings) {
|
||||
return statusCodeStrings[s]
|
||||
}
|
||||
return "<unknown telemetry.StatusCode>"
|
||||
}
|
||||
|
||||
// The Status type defines a logical error model that is suitable for different
|
||||
// programming environments, including REST APIs and RPC APIs.
|
||||
type Status struct {
|
||||
// A developer-facing human readable error message.
|
||||
Message string `json:"message,omitempty"`
|
||||
// The status code.
|
||||
Code StatusCode `json:"code,omitempty"`
|
||||
}
|
189
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/traces.go
generated
vendored
Normal file
189
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/traces.go
generated
vendored
Normal file
@ -0,0 +1,189 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package telemetry
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
// Traces represents the traces data that can be stored in a persistent storage,
|
||||
// OR can be embedded by other protocols that transfer OTLP traces data but do
|
||||
// not implement the OTLP protocol.
|
||||
//
|
||||
// The main difference between this message and collector protocol is that
|
||||
// in this message there will not be any "control" or "metadata" specific to
|
||||
// OTLP protocol.
|
||||
//
|
||||
// When new fields are added into this message, the OTLP request MUST be updated
|
||||
// as well.
|
||||
type Traces struct {
|
||||
// An array of ResourceSpans.
|
||||
// For data coming from a single resource this array will typically contain
|
||||
// one element. Intermediary nodes that receive data from multiple origins
|
||||
// typically batch the data before forwarding further and in that case this
|
||||
// array will contain multiple elements.
|
||||
ResourceSpans []*ResourceSpans `json:"resourceSpans,omitempty"`
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes the OTLP formatted JSON contained in data into td.
|
||||
func (td *Traces) UnmarshalJSON(data []byte) error {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != json.Delim('{') {
|
||||
return errors.New("invalid TracesData type")
|
||||
}
|
||||
|
||||
for decoder.More() {
|
||||
keyIface, err := decoder.Token()
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// Empty.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
key, ok := keyIface.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid TracesData field: %#v", keyIface)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "resourceSpans", "resource_spans":
|
||||
err = decoder.Decode(&td.ResourceSpans)
|
||||
default:
|
||||
// Skip unknown.
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// A collection of ScopeSpans from a Resource.
|
||||
type ResourceSpans struct {
|
||||
// The resource for the spans in this message.
|
||||
// If this field is not set then no resource info is known.
|
||||
Resource Resource `json:"resource"`
|
||||
// A list of ScopeSpans that originate from a resource.
|
||||
ScopeSpans []*ScopeSpans `json:"scopeSpans,omitempty"`
|
||||
// This schema_url applies to the data in the "resource" field. It does not apply
|
||||
// to the data in the "scope_spans" field which have their own schema_url field.
|
||||
SchemaURL string `json:"schemaUrl,omitempty"`
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes the OTLP formatted JSON contained in data into rs.
|
||||
func (rs *ResourceSpans) UnmarshalJSON(data []byte) error {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != json.Delim('{') {
|
||||
return errors.New("invalid ResourceSpans type")
|
||||
}
|
||||
|
||||
for decoder.More() {
|
||||
keyIface, err := decoder.Token()
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// Empty.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
key, ok := keyIface.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid ResourceSpans field: %#v", keyIface)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "resource":
|
||||
err = decoder.Decode(&rs.Resource)
|
||||
case "scopeSpans", "scope_spans":
|
||||
err = decoder.Decode(&rs.ScopeSpans)
|
||||
case "schemaUrl", "schema_url":
|
||||
err = decoder.Decode(&rs.SchemaURL)
|
||||
default:
|
||||
// Skip unknown.
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// A collection of Spans produced by an InstrumentationScope.
|
||||
type ScopeSpans struct {
|
||||
// The instrumentation scope information for the spans in this message.
|
||||
// Semantically when InstrumentationScope isn't set, it is equivalent with
|
||||
// an empty instrumentation scope name (unknown).
|
||||
Scope *Scope `json:"scope"`
|
||||
// A list of Spans that originate from an instrumentation scope.
|
||||
Spans []*Span `json:"spans,omitempty"`
|
||||
// The Schema URL, if known. This is the identifier of the Schema that the span data
|
||||
// is recorded in. To learn more about Schema URL see
|
||||
// https://opentelemetry.io/docs/specs/otel/schemas/#schema-url
|
||||
// This schema_url applies to all spans and span events in the "spans" field.
|
||||
SchemaURL string `json:"schemaUrl,omitempty"`
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes the OTLP formatted JSON contained in data into ss.
|
||||
func (ss *ScopeSpans) UnmarshalJSON(data []byte) error {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != json.Delim('{') {
|
||||
return errors.New("invalid ScopeSpans type")
|
||||
}
|
||||
|
||||
for decoder.More() {
|
||||
keyIface, err := decoder.Token()
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// Empty.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
key, ok := keyIface.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid ScopeSpans field: %#v", keyIface)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "scope":
|
||||
err = decoder.Decode(&ss.Scope)
|
||||
case "spans":
|
||||
err = decoder.Decode(&ss.Spans)
|
||||
case "schemaUrl", "schema_url":
|
||||
err = decoder.Decode(&ss.SchemaURL)
|
||||
default:
|
||||
// Skip unknown.
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
452
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/value.go
generated
vendored
Normal file
452
vendor/go.opentelemetry.io/auto/sdk/internal/telemetry/value.go
generated
vendored
Normal file
@ -0,0 +1,452 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
//go:generate stringer -type=ValueKind -trimprefix=ValueKind
|
||||
|
||||
package telemetry
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"cmp"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"slices"
|
||||
"strconv"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// A Value represents a structured value.
|
||||
// A zero value is valid and represents an empty value.
|
||||
type Value struct {
|
||||
// Ensure forward compatibility by explicitly making this not comparable.
|
||||
noCmp [0]func() //nolint: unused // This is indeed used.
|
||||
|
||||
// num holds the value for Int64, Float64, and Bool. It holds the length
|
||||
// for String, Bytes, Slice, Map.
|
||||
num uint64
|
||||
// any holds either the KindBool, KindInt64, KindFloat64, stringptr,
|
||||
// bytesptr, sliceptr, or mapptr. If KindBool, KindInt64, or KindFloat64
|
||||
// then the value of Value is in num as described above. Otherwise, it
|
||||
// contains the value wrapped in the appropriate type.
|
||||
any any
|
||||
}
|
||||
|
||||
type (
|
||||
// sliceptr represents a value in Value.any for KindString Values.
|
||||
stringptr *byte
|
||||
// bytesptr represents a value in Value.any for KindBytes Values.
|
||||
bytesptr *byte
|
||||
// sliceptr represents a value in Value.any for KindSlice Values.
|
||||
sliceptr *Value
|
||||
// mapptr represents a value in Value.any for KindMap Values.
|
||||
mapptr *Attr
|
||||
)
|
||||
|
||||
// ValueKind is the kind of a [Value].
|
||||
type ValueKind int
|
||||
|
||||
// ValueKind values.
|
||||
const (
|
||||
ValueKindEmpty ValueKind = iota
|
||||
ValueKindBool
|
||||
ValueKindFloat64
|
||||
ValueKindInt64
|
||||
ValueKindString
|
||||
ValueKindBytes
|
||||
ValueKindSlice
|
||||
ValueKindMap
|
||||
)
|
||||
|
||||
var valueKindStrings = []string{
|
||||
"Empty",
|
||||
"Bool",
|
||||
"Float64",
|
||||
"Int64",
|
||||
"String",
|
||||
"Bytes",
|
||||
"Slice",
|
||||
"Map",
|
||||
}
|
||||
|
||||
func (k ValueKind) String() string {
|
||||
if k >= 0 && int(k) < len(valueKindStrings) {
|
||||
return valueKindStrings[k]
|
||||
}
|
||||
return "<unknown telemetry.ValueKind>"
|
||||
}
|
||||
|
||||
// StringValue returns a new [Value] for a string.
|
||||
func StringValue(v string) Value {
|
||||
return Value{
|
||||
num: uint64(len(v)),
|
||||
any: stringptr(unsafe.StringData(v)),
|
||||
}
|
||||
}
|
||||
|
||||
// IntValue returns a [Value] for an int.
|
||||
func IntValue(v int) Value { return Int64Value(int64(v)) }
|
||||
|
||||
// Int64Value returns a [Value] for an int64.
|
||||
func Int64Value(v int64) Value {
|
||||
return Value{num: uint64(v), any: ValueKindInt64}
|
||||
}
|
||||
|
||||
// Float64Value returns a [Value] for a float64.
|
||||
func Float64Value(v float64) Value {
|
||||
return Value{num: math.Float64bits(v), any: ValueKindFloat64}
|
||||
}
|
||||
|
||||
// BoolValue returns a [Value] for a bool.
|
||||
func BoolValue(v bool) Value { //nolint:revive // Not a control flag.
|
||||
var n uint64
|
||||
if v {
|
||||
n = 1
|
||||
}
|
||||
return Value{num: n, any: ValueKindBool}
|
||||
}
|
||||
|
||||
// BytesValue returns a [Value] for a byte slice. The passed slice must not be
|
||||
// changed after it is passed.
|
||||
func BytesValue(v []byte) Value {
|
||||
return Value{
|
||||
num: uint64(len(v)),
|
||||
any: bytesptr(unsafe.SliceData(v)),
|
||||
}
|
||||
}
|
||||
|
||||
// SliceValue returns a [Value] for a slice of [Value]. The passed slice must
|
||||
// not be changed after it is passed.
|
||||
func SliceValue(vs ...Value) Value {
|
||||
return Value{
|
||||
num: uint64(len(vs)),
|
||||
any: sliceptr(unsafe.SliceData(vs)),
|
||||
}
|
||||
}
|
||||
|
||||
// MapValue returns a new [Value] for a slice of key-value pairs. The passed
|
||||
// slice must not be changed after it is passed.
|
||||
func MapValue(kvs ...Attr) Value {
|
||||
return Value{
|
||||
num: uint64(len(kvs)),
|
||||
any: mapptr(unsafe.SliceData(kvs)),
|
||||
}
|
||||
}
|
||||
|
||||
// AsString returns the value held by v as a string.
|
||||
func (v Value) AsString() string {
|
||||
if sp, ok := v.any.(stringptr); ok {
|
||||
return unsafe.String(sp, v.num)
|
||||
}
|
||||
// TODO: error handle
|
||||
return ""
|
||||
}
|
||||
|
||||
// asString returns the value held by v as a string. It will panic if the Value
|
||||
// is not KindString.
|
||||
func (v Value) asString() string {
|
||||
return unsafe.String(v.any.(stringptr), v.num)
|
||||
}
|
||||
|
||||
// AsInt64 returns the value held by v as an int64.
|
||||
func (v Value) AsInt64() int64 {
|
||||
if v.Kind() != ValueKindInt64 {
|
||||
// TODO: error handle
|
||||
return 0
|
||||
}
|
||||
return v.asInt64()
|
||||
}
|
||||
|
||||
// asInt64 returns the value held by v as an int64. If v is not of KindInt64,
|
||||
// this will return garbage.
|
||||
func (v Value) asInt64() int64 {
|
||||
// Assumes v.num was a valid int64 (overflow not checked).
|
||||
return int64(v.num) // nolint: gosec
|
||||
}
|
||||
|
||||
// AsBool returns the value held by v as a bool.
|
||||
func (v Value) AsBool() bool {
|
||||
if v.Kind() != ValueKindBool {
|
||||
// TODO: error handle
|
||||
return false
|
||||
}
|
||||
return v.asBool()
|
||||
}
|
||||
|
||||
// asBool returns the value held by v as a bool. If v is not of KindBool, this
|
||||
// will return garbage.
|
||||
func (v Value) asBool() bool { return v.num == 1 }
|
||||
|
||||
// AsFloat64 returns the value held by v as a float64.
|
||||
func (v Value) AsFloat64() float64 {
|
||||
if v.Kind() != ValueKindFloat64 {
|
||||
// TODO: error handle
|
||||
return 0
|
||||
}
|
||||
return v.asFloat64()
|
||||
}
|
||||
|
||||
// asFloat64 returns the value held by v as a float64. If v is not of
|
||||
// KindFloat64, this will return garbage.
|
||||
func (v Value) asFloat64() float64 { return math.Float64frombits(v.num) }
|
||||
|
||||
// AsBytes returns the value held by v as a []byte.
|
||||
func (v Value) AsBytes() []byte {
|
||||
if sp, ok := v.any.(bytesptr); ok {
|
||||
return unsafe.Slice((*byte)(sp), v.num)
|
||||
}
|
||||
// TODO: error handle
|
||||
return nil
|
||||
}
|
||||
|
||||
// asBytes returns the value held by v as a []byte. It will panic if the Value
|
||||
// is not KindBytes.
|
||||
func (v Value) asBytes() []byte {
|
||||
return unsafe.Slice((*byte)(v.any.(bytesptr)), v.num)
|
||||
}
|
||||
|
||||
// AsSlice returns the value held by v as a []Value.
|
||||
func (v Value) AsSlice() []Value {
|
||||
if sp, ok := v.any.(sliceptr); ok {
|
||||
return unsafe.Slice((*Value)(sp), v.num)
|
||||
}
|
||||
// TODO: error handle
|
||||
return nil
|
||||
}
|
||||
|
||||
// asSlice returns the value held by v as a []Value. It will panic if the Value
|
||||
// is not KindSlice.
|
||||
func (v Value) asSlice() []Value {
|
||||
return unsafe.Slice((*Value)(v.any.(sliceptr)), v.num)
|
||||
}
|
||||
|
||||
// AsMap returns the value held by v as a []Attr.
|
||||
func (v Value) AsMap() []Attr {
|
||||
if sp, ok := v.any.(mapptr); ok {
|
||||
return unsafe.Slice((*Attr)(sp), v.num)
|
||||
}
|
||||
// TODO: error handle
|
||||
return nil
|
||||
}
|
||||
|
||||
// asMap returns the value held by v as a []Attr. It will panic if the
|
||||
// Value is not KindMap.
|
||||
func (v Value) asMap() []Attr {
|
||||
return unsafe.Slice((*Attr)(v.any.(mapptr)), v.num)
|
||||
}
|
||||
|
||||
// Kind returns the Kind of v.
|
||||
func (v Value) Kind() ValueKind {
|
||||
switch x := v.any.(type) {
|
||||
case ValueKind:
|
||||
return x
|
||||
case stringptr:
|
||||
return ValueKindString
|
||||
case bytesptr:
|
||||
return ValueKindBytes
|
||||
case sliceptr:
|
||||
return ValueKindSlice
|
||||
case mapptr:
|
||||
return ValueKindMap
|
||||
default:
|
||||
return ValueKindEmpty
|
||||
}
|
||||
}
|
||||
|
||||
// Empty returns if v does not hold any value.
|
||||
func (v Value) Empty() bool { return v.Kind() == ValueKindEmpty }
|
||||
|
||||
// Equal returns if v is equal to w.
|
||||
func (v Value) Equal(w Value) bool {
|
||||
k1 := v.Kind()
|
||||
k2 := w.Kind()
|
||||
if k1 != k2 {
|
||||
return false
|
||||
}
|
||||
switch k1 {
|
||||
case ValueKindInt64, ValueKindBool:
|
||||
return v.num == w.num
|
||||
case ValueKindString:
|
||||
return v.asString() == w.asString()
|
||||
case ValueKindFloat64:
|
||||
return v.asFloat64() == w.asFloat64()
|
||||
case ValueKindSlice:
|
||||
return slices.EqualFunc(v.asSlice(), w.asSlice(), Value.Equal)
|
||||
case ValueKindMap:
|
||||
sv := sortMap(v.asMap())
|
||||
sw := sortMap(w.asMap())
|
||||
return slices.EqualFunc(sv, sw, Attr.Equal)
|
||||
case ValueKindBytes:
|
||||
return bytes.Equal(v.asBytes(), w.asBytes())
|
||||
case ValueKindEmpty:
|
||||
return true
|
||||
default:
|
||||
// TODO: error handle
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func sortMap(m []Attr) []Attr {
|
||||
sm := make([]Attr, len(m))
|
||||
copy(sm, m)
|
||||
slices.SortFunc(sm, func(a, b Attr) int {
|
||||
return cmp.Compare(a.Key, b.Key)
|
||||
})
|
||||
|
||||
return sm
|
||||
}
|
||||
|
||||
// String returns Value's value as a string, formatted like [fmt.Sprint].
|
||||
//
|
||||
// The returned string is meant for debugging;
|
||||
// the string representation is not stable.
|
||||
func (v Value) String() string {
|
||||
switch v.Kind() {
|
||||
case ValueKindString:
|
||||
return v.asString()
|
||||
case ValueKindInt64:
|
||||
// Assumes v.num was a valid int64 (overflow not checked).
|
||||
return strconv.FormatInt(int64(v.num), 10) // nolint: gosec
|
||||
case ValueKindFloat64:
|
||||
return strconv.FormatFloat(v.asFloat64(), 'g', -1, 64)
|
||||
case ValueKindBool:
|
||||
return strconv.FormatBool(v.asBool())
|
||||
case ValueKindBytes:
|
||||
return fmt.Sprint(v.asBytes())
|
||||
case ValueKindMap:
|
||||
return fmt.Sprint(v.asMap())
|
||||
case ValueKindSlice:
|
||||
return fmt.Sprint(v.asSlice())
|
||||
case ValueKindEmpty:
|
||||
return "<nil>"
|
||||
default:
|
||||
// Try to handle this as gracefully as possible.
|
||||
//
|
||||
// Don't panic here. The goal here is to have developers find this
|
||||
// first if a slog.Kind is is not handled. It is
|
||||
// preferable to have user's open issue asking why their attributes
|
||||
// have a "unhandled: " prefix than say that their code is panicking.
|
||||
return fmt.Sprintf("<unhandled telemetry.ValueKind: %s>", v.Kind())
|
||||
}
|
||||
}
|
||||
|
||||
// MarshalJSON encodes v into OTLP formatted JSON.
|
||||
func (v *Value) MarshalJSON() ([]byte, error) {
|
||||
switch v.Kind() {
|
||||
case ValueKindString:
|
||||
return json.Marshal(struct {
|
||||
Value string `json:"stringValue"`
|
||||
}{v.asString()})
|
||||
case ValueKindInt64:
|
||||
return json.Marshal(struct {
|
||||
Value string `json:"intValue"`
|
||||
}{strconv.FormatInt(int64(v.num), 10)})
|
||||
case ValueKindFloat64:
|
||||
return json.Marshal(struct {
|
||||
Value float64 `json:"doubleValue"`
|
||||
}{v.asFloat64()})
|
||||
case ValueKindBool:
|
||||
return json.Marshal(struct {
|
||||
Value bool `json:"boolValue"`
|
||||
}{v.asBool()})
|
||||
case ValueKindBytes:
|
||||
return json.Marshal(struct {
|
||||
Value []byte `json:"bytesValue"`
|
||||
}{v.asBytes()})
|
||||
case ValueKindMap:
|
||||
return json.Marshal(struct {
|
||||
Value struct {
|
||||
Values []Attr `json:"values"`
|
||||
} `json:"kvlistValue"`
|
||||
}{struct {
|
||||
Values []Attr `json:"values"`
|
||||
}{v.asMap()}})
|
||||
case ValueKindSlice:
|
||||
return json.Marshal(struct {
|
||||
Value struct {
|
||||
Values []Value `json:"values"`
|
||||
} `json:"arrayValue"`
|
||||
}{struct {
|
||||
Values []Value `json:"values"`
|
||||
}{v.asSlice()}})
|
||||
case ValueKindEmpty:
|
||||
return nil, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown Value kind: %s", v.Kind().String())
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalJSON decodes the OTLP formatted JSON contained in data into v.
|
||||
func (v *Value) UnmarshalJSON(data []byte) error {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t != json.Delim('{') {
|
||||
return errors.New("invalid Value type")
|
||||
}
|
||||
|
||||
for decoder.More() {
|
||||
keyIface, err := decoder.Token()
|
||||
if err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
// Empty.
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
key, ok := keyIface.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid Value key: %#v", keyIface)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "stringValue", "string_value":
|
||||
var val string
|
||||
err = decoder.Decode(&val)
|
||||
*v = StringValue(val)
|
||||
case "boolValue", "bool_value":
|
||||
var val bool
|
||||
err = decoder.Decode(&val)
|
||||
*v = BoolValue(val)
|
||||
case "intValue", "int_value":
|
||||
var val protoInt64
|
||||
err = decoder.Decode(&val)
|
||||
*v = Int64Value(val.Int64())
|
||||
case "doubleValue", "double_value":
|
||||
var val float64
|
||||
err = decoder.Decode(&val)
|
||||
*v = Float64Value(val)
|
||||
case "bytesValue", "bytes_value":
|
||||
var val64 string
|
||||
if err := decoder.Decode(&val64); err != nil {
|
||||
return err
|
||||
}
|
||||
var val []byte
|
||||
val, err = base64.StdEncoding.DecodeString(val64)
|
||||
*v = BytesValue(val)
|
||||
case "arrayValue", "array_value":
|
||||
var val struct{ Values []Value }
|
||||
err = decoder.Decode(&val)
|
||||
*v = SliceValue(val.Values...)
|
||||
case "kvlistValue", "kvlist_value":
|
||||
var val struct{ Values []Attr }
|
||||
err = decoder.Decode(&val)
|
||||
*v = MapValue(val.Values...)
|
||||
default:
|
||||
// Skip unknown.
|
||||
continue
|
||||
}
|
||||
// Use first valid. Ignore the rest.
|
||||
return err
|
||||
}
|
||||
|
||||
// Only unknown fields. Return nil without unmarshaling any value.
|
||||
return nil
|
||||
}
|
94
vendor/go.opentelemetry.io/auto/sdk/limit.go
generated
vendored
Normal file
94
vendor/go.opentelemetry.io/auto/sdk/limit.go
generated
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sdk
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// maxSpan are the span limits resolved during startup.
|
||||
var maxSpan = newSpanLimits()
|
||||
|
||||
type spanLimits struct {
|
||||
// Attrs is the number of allowed attributes for a span.
|
||||
//
|
||||
// This is resolved from the environment variable value for the
|
||||
// OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT key if it exists. Otherwise, the
|
||||
// environment variable value for OTEL_ATTRIBUTE_COUNT_LIMIT, or 128 if
|
||||
// that is not set, is used.
|
||||
Attrs int
|
||||
// AttrValueLen is the maximum attribute value length allowed for a span.
|
||||
//
|
||||
// This is resolved from the environment variable value for the
|
||||
// OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT key if it exists. Otherwise, the
|
||||
// environment variable value for OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT, or -1
|
||||
// if that is not set, is used.
|
||||
AttrValueLen int
|
||||
// Events is the number of allowed events for a span.
|
||||
//
|
||||
// This is resolved from the environment variable value for the
|
||||
// OTEL_SPAN_EVENT_COUNT_LIMIT key, or 128 is used if that is not set.
|
||||
Events int
|
||||
// EventAttrs is the number of allowed attributes for a span event.
|
||||
//
|
||||
// The is resolved from the environment variable value for the
|
||||
// OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT key, or 128 is used if that is not set.
|
||||
EventAttrs int
|
||||
// Links is the number of allowed Links for a span.
|
||||
//
|
||||
// This is resolved from the environment variable value for the
|
||||
// OTEL_SPAN_LINK_COUNT_LIMIT, or 128 is used if that is not set.
|
||||
Links int
|
||||
// LinkAttrs is the number of allowed attributes for a span link.
|
||||
//
|
||||
// This is resolved from the environment variable value for the
|
||||
// OTEL_LINK_ATTRIBUTE_COUNT_LIMIT, or 128 is used if that is not set.
|
||||
LinkAttrs int
|
||||
}
|
||||
|
||||
func newSpanLimits() spanLimits {
|
||||
return spanLimits{
|
||||
Attrs: firstEnv(
|
||||
128,
|
||||
"OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT",
|
||||
"OTEL_ATTRIBUTE_COUNT_LIMIT",
|
||||
),
|
||||
AttrValueLen: firstEnv(
|
||||
-1, // Unlimited.
|
||||
"OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT",
|
||||
"OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT",
|
||||
),
|
||||
Events: firstEnv(128, "OTEL_SPAN_EVENT_COUNT_LIMIT"),
|
||||
EventAttrs: firstEnv(128, "OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT"),
|
||||
Links: firstEnv(128, "OTEL_SPAN_LINK_COUNT_LIMIT"),
|
||||
LinkAttrs: firstEnv(128, "OTEL_LINK_ATTRIBUTE_COUNT_LIMIT"),
|
||||
}
|
||||
}
|
||||
|
||||
// firstEnv returns the parsed integer value of the first matching environment
|
||||
// variable from keys. The defaultVal is returned if the value is not an
|
||||
// integer or no match is found.
|
||||
func firstEnv(defaultVal int, keys ...string) int {
|
||||
for _, key := range keys {
|
||||
strV := os.Getenv(key)
|
||||
if strV == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
v, err := strconv.Atoi(strV)
|
||||
if err == nil {
|
||||
return v
|
||||
}
|
||||
slog.Warn(
|
||||
"invalid limit environment variable",
|
||||
"error", err,
|
||||
"key", key,
|
||||
"value", strV,
|
||||
)
|
||||
}
|
||||
|
||||
return defaultVal
|
||||
}
|
432
vendor/go.opentelemetry.io/auto/sdk/span.go
generated
vendored
Normal file
432
vendor/go.opentelemetry.io/auto/sdk/span.go
generated
vendored
Normal file
@ -0,0 +1,432 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sdk
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"go.opentelemetry.io/otel/trace/noop"
|
||||
|
||||
"go.opentelemetry.io/auto/sdk/internal/telemetry"
|
||||
)
|
||||
|
||||
type span struct {
|
||||
noop.Span
|
||||
|
||||
spanContext trace.SpanContext
|
||||
sampled atomic.Bool
|
||||
|
||||
mu sync.Mutex
|
||||
traces *telemetry.Traces
|
||||
span *telemetry.Span
|
||||
}
|
||||
|
||||
func (s *span) SpanContext() trace.SpanContext {
|
||||
if s == nil {
|
||||
return trace.SpanContext{}
|
||||
}
|
||||
// s.spanContext is immutable, do not acquire lock s.mu.
|
||||
return s.spanContext
|
||||
}
|
||||
|
||||
func (s *span) IsRecording() bool {
|
||||
if s == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return s.sampled.Load()
|
||||
}
|
||||
|
||||
func (s *span) SetStatus(c codes.Code, msg string) {
|
||||
if s == nil || !s.sampled.Load() {
|
||||
return
|
||||
}
|
||||
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
if s.span.Status == nil {
|
||||
s.span.Status = new(telemetry.Status)
|
||||
}
|
||||
|
||||
s.span.Status.Message = msg
|
||||
|
||||
switch c {
|
||||
case codes.Unset:
|
||||
s.span.Status.Code = telemetry.StatusCodeUnset
|
||||
case codes.Error:
|
||||
s.span.Status.Code = telemetry.StatusCodeError
|
||||
case codes.Ok:
|
||||
s.span.Status.Code = telemetry.StatusCodeOK
|
||||
}
|
||||
}
|
||||
|
||||
func (s *span) SetAttributes(attrs ...attribute.KeyValue) {
|
||||
if s == nil || !s.sampled.Load() {
|
||||
return
|
||||
}
|
||||
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
limit := maxSpan.Attrs
|
||||
if limit == 0 {
|
||||
// No attributes allowed.
|
||||
s.span.DroppedAttrs += uint32(len(attrs))
|
||||
return
|
||||
}
|
||||
|
||||
m := make(map[string]int)
|
||||
for i, a := range s.span.Attrs {
|
||||
m[a.Key] = i
|
||||
}
|
||||
|
||||
for _, a := range attrs {
|
||||
val := convAttrValue(a.Value)
|
||||
if val.Empty() {
|
||||
s.span.DroppedAttrs++
|
||||
continue
|
||||
}
|
||||
|
||||
if idx, ok := m[string(a.Key)]; ok {
|
||||
s.span.Attrs[idx] = telemetry.Attr{
|
||||
Key: string(a.Key),
|
||||
Value: val,
|
||||
}
|
||||
} else if limit < 0 || len(s.span.Attrs) < limit {
|
||||
s.span.Attrs = append(s.span.Attrs, telemetry.Attr{
|
||||
Key: string(a.Key),
|
||||
Value: val,
|
||||
})
|
||||
m[string(a.Key)] = len(s.span.Attrs) - 1
|
||||
} else {
|
||||
s.span.DroppedAttrs++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// convCappedAttrs converts up to limit attrs into a []telemetry.Attr. The
|
||||
// number of dropped attributes is also returned.
|
||||
func convCappedAttrs(limit int, attrs []attribute.KeyValue) ([]telemetry.Attr, uint32) {
|
||||
if limit == 0 {
|
||||
return nil, uint32(len(attrs))
|
||||
}
|
||||
|
||||
if limit < 0 {
|
||||
// Unlimited.
|
||||
return convAttrs(attrs), 0
|
||||
}
|
||||
|
||||
limit = min(len(attrs), limit)
|
||||
return convAttrs(attrs[:limit]), uint32(len(attrs) - limit)
|
||||
}
|
||||
|
||||
func convAttrs(attrs []attribute.KeyValue) []telemetry.Attr {
|
||||
if len(attrs) == 0 {
|
||||
// Avoid allocations if not necessary.
|
||||
return nil
|
||||
}
|
||||
|
||||
out := make([]telemetry.Attr, 0, len(attrs))
|
||||
for _, attr := range attrs {
|
||||
key := string(attr.Key)
|
||||
val := convAttrValue(attr.Value)
|
||||
if val.Empty() {
|
||||
continue
|
||||
}
|
||||
out = append(out, telemetry.Attr{Key: key, Value: val})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func convAttrValue(value attribute.Value) telemetry.Value {
|
||||
switch value.Type() {
|
||||
case attribute.BOOL:
|
||||
return telemetry.BoolValue(value.AsBool())
|
||||
case attribute.INT64:
|
||||
return telemetry.Int64Value(value.AsInt64())
|
||||
case attribute.FLOAT64:
|
||||
return telemetry.Float64Value(value.AsFloat64())
|
||||
case attribute.STRING:
|
||||
v := truncate(maxSpan.AttrValueLen, value.AsString())
|
||||
return telemetry.StringValue(v)
|
||||
case attribute.BOOLSLICE:
|
||||
slice := value.AsBoolSlice()
|
||||
out := make([]telemetry.Value, 0, len(slice))
|
||||
for _, v := range slice {
|
||||
out = append(out, telemetry.BoolValue(v))
|
||||
}
|
||||
return telemetry.SliceValue(out...)
|
||||
case attribute.INT64SLICE:
|
||||
slice := value.AsInt64Slice()
|
||||
out := make([]telemetry.Value, 0, len(slice))
|
||||
for _, v := range slice {
|
||||
out = append(out, telemetry.Int64Value(v))
|
||||
}
|
||||
return telemetry.SliceValue(out...)
|
||||
case attribute.FLOAT64SLICE:
|
||||
slice := value.AsFloat64Slice()
|
||||
out := make([]telemetry.Value, 0, len(slice))
|
||||
for _, v := range slice {
|
||||
out = append(out, telemetry.Float64Value(v))
|
||||
}
|
||||
return telemetry.SliceValue(out...)
|
||||
case attribute.STRINGSLICE:
|
||||
slice := value.AsStringSlice()
|
||||
out := make([]telemetry.Value, 0, len(slice))
|
||||
for _, v := range slice {
|
||||
v = truncate(maxSpan.AttrValueLen, v)
|
||||
out = append(out, telemetry.StringValue(v))
|
||||
}
|
||||
return telemetry.SliceValue(out...)
|
||||
}
|
||||
return telemetry.Value{}
|
||||
}
|
||||
|
||||
// truncate returns a truncated version of s such that it contains less than
|
||||
// the limit number of characters. Truncation is applied by returning the limit
|
||||
// number of valid characters contained in s.
|
||||
//
|
||||
// If limit is negative, it returns the original string.
|
||||
//
|
||||
// UTF-8 is supported. When truncating, all invalid characters are dropped
|
||||
// before applying truncation.
|
||||
//
|
||||
// If s already contains less than the limit number of bytes, it is returned
|
||||
// unchanged. No invalid characters are removed.
|
||||
func truncate(limit int, s string) string {
|
||||
// This prioritize performance in the following order based on the most
|
||||
// common expected use-cases.
|
||||
//
|
||||
// - Short values less than the default limit (128).
|
||||
// - Strings with valid encodings that exceed the limit.
|
||||
// - No limit.
|
||||
// - Strings with invalid encodings that exceed the limit.
|
||||
if limit < 0 || len(s) <= limit {
|
||||
return s
|
||||
}
|
||||
|
||||
// Optimistically, assume all valid UTF-8.
|
||||
var b strings.Builder
|
||||
count := 0
|
||||
for i, c := range s {
|
||||
if c != utf8.RuneError {
|
||||
count++
|
||||
if count > limit {
|
||||
return s[:i]
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
_, size := utf8.DecodeRuneInString(s[i:])
|
||||
if size == 1 {
|
||||
// Invalid encoding.
|
||||
b.Grow(len(s) - 1)
|
||||
_, _ = b.WriteString(s[:i])
|
||||
s = s[i:]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Fast-path, no invalid input.
|
||||
if b.Cap() == 0 {
|
||||
return s
|
||||
}
|
||||
|
||||
// Truncate while validating UTF-8.
|
||||
for i := 0; i < len(s) && count < limit; {
|
||||
c := s[i]
|
||||
if c < utf8.RuneSelf {
|
||||
// Optimization for single byte runes (common case).
|
||||
_ = b.WriteByte(c)
|
||||
i++
|
||||
count++
|
||||
continue
|
||||
}
|
||||
|
||||
_, size := utf8.DecodeRuneInString(s[i:])
|
||||
if size == 1 {
|
||||
// We checked for all 1-byte runes above, this is a RuneError.
|
||||
i++
|
||||
continue
|
||||
}
|
||||
|
||||
_, _ = b.WriteString(s[i : i+size])
|
||||
i += size
|
||||
count++
|
||||
}
|
||||
|
||||
return b.String()
|
||||
}
|
||||
|
||||
func (s *span) End(opts ...trace.SpanEndOption) {
|
||||
if s == nil || !s.sampled.Swap(false) {
|
||||
return
|
||||
}
|
||||
|
||||
// s.end exists so the lock (s.mu) is not held while s.ended is called.
|
||||
s.ended(s.end(opts))
|
||||
}
|
||||
|
||||
func (s *span) end(opts []trace.SpanEndOption) []byte {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
cfg := trace.NewSpanEndConfig(opts...)
|
||||
if t := cfg.Timestamp(); !t.IsZero() {
|
||||
s.span.EndTime = cfg.Timestamp()
|
||||
} else {
|
||||
s.span.EndTime = time.Now()
|
||||
}
|
||||
|
||||
b, _ := json.Marshal(s.traces) // TODO: do not ignore this error.
|
||||
return b
|
||||
}
|
||||
|
||||
// Expected to be implemented in eBPF.
|
||||
//
|
||||
//go:noinline
|
||||
func (*span) ended(buf []byte) { ended(buf) }
|
||||
|
||||
// ended is used for testing.
|
||||
var ended = func([]byte) {}
|
||||
|
||||
func (s *span) RecordError(err error, opts ...trace.EventOption) {
|
||||
if s == nil || err == nil || !s.sampled.Load() {
|
||||
return
|
||||
}
|
||||
|
||||
cfg := trace.NewEventConfig(opts...)
|
||||
|
||||
attrs := cfg.Attributes()
|
||||
attrs = append(attrs,
|
||||
semconv.ExceptionType(typeStr(err)),
|
||||
semconv.ExceptionMessage(err.Error()),
|
||||
)
|
||||
if cfg.StackTrace() {
|
||||
buf := make([]byte, 2048)
|
||||
n := runtime.Stack(buf, false)
|
||||
attrs = append(attrs, semconv.ExceptionStacktrace(string(buf[0:n])))
|
||||
}
|
||||
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
s.addEvent(semconv.ExceptionEventName, cfg.Timestamp(), attrs)
|
||||
}
|
||||
|
||||
func typeStr(i any) string {
|
||||
t := reflect.TypeOf(i)
|
||||
if t.PkgPath() == "" && t.Name() == "" {
|
||||
// Likely a builtin type.
|
||||
return t.String()
|
||||
}
|
||||
return fmt.Sprintf("%s.%s", t.PkgPath(), t.Name())
|
||||
}
|
||||
|
||||
func (s *span) AddEvent(name string, opts ...trace.EventOption) {
|
||||
if s == nil || !s.sampled.Load() {
|
||||
return
|
||||
}
|
||||
|
||||
cfg := trace.NewEventConfig(opts...)
|
||||
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
s.addEvent(name, cfg.Timestamp(), cfg.Attributes())
|
||||
}
|
||||
|
||||
// addEvent adds an event with name and attrs at tStamp to the span. The span
|
||||
// lock (s.mu) needs to be held by the caller.
|
||||
func (s *span) addEvent(name string, tStamp time.Time, attrs []attribute.KeyValue) {
|
||||
limit := maxSpan.Events
|
||||
|
||||
if limit == 0 {
|
||||
s.span.DroppedEvents++
|
||||
return
|
||||
}
|
||||
|
||||
if limit > 0 && len(s.span.Events) == limit {
|
||||
// Drop head while avoiding allocation of more capacity.
|
||||
copy(s.span.Events[:limit-1], s.span.Events[1:])
|
||||
s.span.Events = s.span.Events[:limit-1]
|
||||
s.span.DroppedEvents++
|
||||
}
|
||||
|
||||
e := &telemetry.SpanEvent{Time: tStamp, Name: name}
|
||||
e.Attrs, e.DroppedAttrs = convCappedAttrs(maxSpan.EventAttrs, attrs)
|
||||
|
||||
s.span.Events = append(s.span.Events, e)
|
||||
}
|
||||
|
||||
func (s *span) AddLink(link trace.Link) {
|
||||
if s == nil || !s.sampled.Load() {
|
||||
return
|
||||
}
|
||||
|
||||
l := maxSpan.Links
|
||||
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
if l == 0 {
|
||||
s.span.DroppedLinks++
|
||||
return
|
||||
}
|
||||
|
||||
if l > 0 && len(s.span.Links) == l {
|
||||
// Drop head while avoiding allocation of more capacity.
|
||||
copy(s.span.Links[:l-1], s.span.Links[1:])
|
||||
s.span.Links = s.span.Links[:l-1]
|
||||
s.span.DroppedLinks++
|
||||
}
|
||||
|
||||
s.span.Links = append(s.span.Links, convLink(link))
|
||||
}
|
||||
|
||||
func convLinks(links []trace.Link) []*telemetry.SpanLink {
|
||||
out := make([]*telemetry.SpanLink, 0, len(links))
|
||||
for _, link := range links {
|
||||
out = append(out, convLink(link))
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func convLink(link trace.Link) *telemetry.SpanLink {
|
||||
l := &telemetry.SpanLink{
|
||||
TraceID: telemetry.TraceID(link.SpanContext.TraceID()),
|
||||
SpanID: telemetry.SpanID(link.SpanContext.SpanID()),
|
||||
TraceState: link.SpanContext.TraceState().String(),
|
||||
Flags: uint32(link.SpanContext.TraceFlags()),
|
||||
}
|
||||
l.Attrs, l.DroppedAttrs = convCappedAttrs(maxSpan.LinkAttrs, link.Attributes)
|
||||
|
||||
return l
|
||||
}
|
||||
|
||||
func (s *span) SetName(name string) {
|
||||
if s == nil || !s.sampled.Load() {
|
||||
return
|
||||
}
|
||||
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
s.span.Name = name
|
||||
}
|
||||
|
||||
func (*span) TracerProvider() trace.TracerProvider { return TracerProvider() }
|
124
vendor/go.opentelemetry.io/auto/sdk/tracer.go
generated
vendored
Normal file
124
vendor/go.opentelemetry.io/auto/sdk/tracer.go
generated
vendored
Normal file
@ -0,0 +1,124 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sdk
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"go.opentelemetry.io/otel/trace/noop"
|
||||
|
||||
"go.opentelemetry.io/auto/sdk/internal/telemetry"
|
||||
)
|
||||
|
||||
type tracer struct {
|
||||
noop.Tracer
|
||||
|
||||
name, schemaURL, version string
|
||||
}
|
||||
|
||||
var _ trace.Tracer = tracer{}
|
||||
|
||||
func (t tracer) Start(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
|
||||
var psc trace.SpanContext
|
||||
sampled := true
|
||||
span := new(span)
|
||||
|
||||
// Ask eBPF for sampling decision and span context info.
|
||||
t.start(ctx, span, &psc, &sampled, &span.spanContext)
|
||||
|
||||
span.sampled.Store(sampled)
|
||||
|
||||
ctx = trace.ContextWithSpan(ctx, span)
|
||||
|
||||
if sampled {
|
||||
// Only build traces if sampled.
|
||||
cfg := trace.NewSpanStartConfig(opts...)
|
||||
span.traces, span.span = t.traces(name, cfg, span.spanContext, psc)
|
||||
}
|
||||
|
||||
return ctx, span
|
||||
}
|
||||
|
||||
// Expected to be implemented in eBPF.
|
||||
//
|
||||
//go:noinline
|
||||
func (t *tracer) start(
|
||||
ctx context.Context,
|
||||
spanPtr *span,
|
||||
psc *trace.SpanContext,
|
||||
sampled *bool,
|
||||
sc *trace.SpanContext,
|
||||
) {
|
||||
start(ctx, spanPtr, psc, sampled, sc)
|
||||
}
|
||||
|
||||
// start is used for testing.
|
||||
var start = func(context.Context, *span, *trace.SpanContext, *bool, *trace.SpanContext) {}
|
||||
|
||||
func (t tracer) traces(name string, cfg trace.SpanConfig, sc, psc trace.SpanContext) (*telemetry.Traces, *telemetry.Span) {
|
||||
span := &telemetry.Span{
|
||||
TraceID: telemetry.TraceID(sc.TraceID()),
|
||||
SpanID: telemetry.SpanID(sc.SpanID()),
|
||||
Flags: uint32(sc.TraceFlags()),
|
||||
TraceState: sc.TraceState().String(),
|
||||
ParentSpanID: telemetry.SpanID(psc.SpanID()),
|
||||
Name: name,
|
||||
Kind: spanKind(cfg.SpanKind()),
|
||||
}
|
||||
|
||||
span.Attrs, span.DroppedAttrs = convCappedAttrs(maxSpan.Attrs, cfg.Attributes())
|
||||
|
||||
links := cfg.Links()
|
||||
if limit := maxSpan.Links; limit == 0 {
|
||||
span.DroppedLinks = uint32(len(links))
|
||||
} else {
|
||||
if limit > 0 {
|
||||
n := max(len(links)-limit, 0)
|
||||
span.DroppedLinks = uint32(n)
|
||||
links = links[n:]
|
||||
}
|
||||
span.Links = convLinks(links)
|
||||
}
|
||||
|
||||
if t := cfg.Timestamp(); !t.IsZero() {
|
||||
span.StartTime = cfg.Timestamp()
|
||||
} else {
|
||||
span.StartTime = time.Now()
|
||||
}
|
||||
|
||||
return &telemetry.Traces{
|
||||
ResourceSpans: []*telemetry.ResourceSpans{
|
||||
{
|
||||
ScopeSpans: []*telemetry.ScopeSpans{
|
||||
{
|
||||
Scope: &telemetry.Scope{
|
||||
Name: t.name,
|
||||
Version: t.version,
|
||||
},
|
||||
Spans: []*telemetry.Span{span},
|
||||
SchemaURL: t.schemaURL,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}, span
|
||||
}
|
||||
|
||||
func spanKind(kind trace.SpanKind) telemetry.SpanKind {
|
||||
switch kind {
|
||||
case trace.SpanKindInternal:
|
||||
return telemetry.SpanKindInternal
|
||||
case trace.SpanKindServer:
|
||||
return telemetry.SpanKindServer
|
||||
case trace.SpanKindClient:
|
||||
return telemetry.SpanKindClient
|
||||
case trace.SpanKindProducer:
|
||||
return telemetry.SpanKindProducer
|
||||
case trace.SpanKindConsumer:
|
||||
return telemetry.SpanKindConsumer
|
||||
}
|
||||
return telemetry.SpanKind(0) // undefined.
|
||||
}
|
33
vendor/go.opentelemetry.io/auto/sdk/tracer_provider.go
generated
vendored
Normal file
33
vendor/go.opentelemetry.io/auto/sdk/tracer_provider.go
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sdk
|
||||
|
||||
import (
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"go.opentelemetry.io/otel/trace/noop"
|
||||
)
|
||||
|
||||
// TracerProvider returns an auto-instrumentable [trace.TracerProvider].
|
||||
//
|
||||
// If an [go.opentelemetry.io/auto.Instrumentation] is configured to instrument
|
||||
// the process using the returned TracerProvider, all of the telemetry it
|
||||
// produces will be processed and handled by that Instrumentation. By default,
|
||||
// if no Instrumentation instruments the TracerProvider it will not generate
|
||||
// any trace telemetry.
|
||||
func TracerProvider() trace.TracerProvider { return tracerProviderInstance }
|
||||
|
||||
var tracerProviderInstance = new(tracerProvider)
|
||||
|
||||
type tracerProvider struct{ noop.TracerProvider }
|
||||
|
||||
var _ trace.TracerProvider = tracerProvider{}
|
||||
|
||||
func (p tracerProvider) Tracer(name string, opts ...trace.TracerOption) trace.Tracer {
|
||||
cfg := trace.NewTracerConfig(opts...)
|
||||
return tracer{
|
||||
name: name,
|
||||
version: cfg.InstrumentationVersion(),
|
||||
schemaURL: cfg.SchemaURL(),
|
||||
}
|
||||
}
|
9
vendor/go.opentelemetry.io/otel/.gitignore
generated
vendored
9
vendor/go.opentelemetry.io/otel/.gitignore
generated
vendored
@ -1,6 +1,7 @@
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
.cache/
|
||||
.tools/
|
||||
venv/
|
||||
.idea/
|
||||
@ -12,11 +13,3 @@ go.work
|
||||
go.work.sum
|
||||
|
||||
gen/
|
||||
|
||||
/example/dice/dice
|
||||
/example/namedtracer/namedtracer
|
||||
/example/otel-collector/otel-collector
|
||||
/example/opencensus/opencensus
|
||||
/example/passthrough/passthrough
|
||||
/example/prometheus/prometheus
|
||||
/example/zipkin/zipkin
|
||||
|
138
vendor/go.opentelemetry.io/otel/.golangci.yml
generated
vendored
138
vendor/go.opentelemetry.io/otel/.golangci.yml
generated
vendored
@ -9,6 +9,8 @@ linters:
|
||||
disable-all: true
|
||||
# Specifically enable linters we want to use.
|
||||
enable:
|
||||
- asasalint
|
||||
- bodyclose
|
||||
- depguard
|
||||
- errcheck
|
||||
- errorlint
|
||||
@ -20,13 +22,16 @@ linters:
|
||||
- govet
|
||||
- ineffassign
|
||||
- misspell
|
||||
- perfsprint
|
||||
- revive
|
||||
- staticcheck
|
||||
- tenv
|
||||
- testifylint
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unused
|
||||
- unparam
|
||||
- usestdlibvars
|
||||
- usetesting
|
||||
|
||||
issues:
|
||||
# Maximum issues count per one linter.
|
||||
@ -58,16 +63,17 @@ issues:
|
||||
text: "calls to (.+) only in main[(][)] or init[(][)] functions"
|
||||
linters:
|
||||
- revive
|
||||
# It's okay to not run gosec in a test.
|
||||
# It's okay to not run gosec and perfsprint in a test.
|
||||
- path: _test\.go
|
||||
linters:
|
||||
- gosec
|
||||
# Igonoring gosec G404: Use of weak random number generator (math/rand instead of crypto/rand)
|
||||
- perfsprint
|
||||
# Ignoring gosec G404: Use of weak random number generator (math/rand instead of crypto/rand)
|
||||
# as we commonly use it in tests and examples.
|
||||
- text: "G404:"
|
||||
linters:
|
||||
- gosec
|
||||
# Igonoring gosec G402: TLS MinVersion too low
|
||||
# Ignoring gosec G402: TLS MinVersion too low
|
||||
# as the https://pkg.go.dev/crypto/tls#Config handles MinVersion default well.
|
||||
- text: "G402: TLS MinVersion too low."
|
||||
linters:
|
||||
@ -92,6 +98,13 @@ linters-settings:
|
||||
- pkg: "crypto/md5"
|
||||
- pkg: "crypto/sha1"
|
||||
- pkg: "crypto/**/pkix"
|
||||
auto/sdk:
|
||||
files:
|
||||
- "!internal/global/trace.go"
|
||||
- "~internal/global/trace_test.go"
|
||||
deny:
|
||||
- pkg: "go.opentelemetry.io/auto/sdk"
|
||||
desc: Do not use SDK from automatic instrumentation.
|
||||
otlp-internal:
|
||||
files:
|
||||
- "!**/exporters/otlp/internal/**/*.go"
|
||||
@ -124,8 +137,6 @@ linters-settings:
|
||||
- "**/metric/**/*.go"
|
||||
- "**/bridge/*.go"
|
||||
- "**/bridge/**/*.go"
|
||||
- "**/example/*.go"
|
||||
- "**/example/**/*.go"
|
||||
- "**/trace/*.go"
|
||||
- "**/trace/**/*.go"
|
||||
- "**/log/*.go"
|
||||
@ -153,137 +164,71 @@ linters-settings:
|
||||
locale: US
|
||||
ignore-words:
|
||||
- cancelled
|
||||
perfsprint:
|
||||
err-error: true
|
||||
errorf: true
|
||||
int-conversion: true
|
||||
sprintf1: true
|
||||
strconcat: true
|
||||
revive:
|
||||
# Sets the default failure confidence.
|
||||
# This means that linting errors with less than 0.8 confidence will be ignored.
|
||||
# Default: 0.8
|
||||
confidence: 0.01
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
|
||||
rules:
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#blank-imports
|
||||
- name: blank-imports
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
|
||||
- name: bool-literal-in-expr
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#constant-logical-expr
|
||||
- name: constant-logical-expr
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-as-argument
|
||||
# TODO (#3372) re-enable linter when it is compatible. https://github.com/golangci/golangci-lint/issues/3280
|
||||
- name: context-as-argument
|
||||
disabled: true
|
||||
arguments:
|
||||
allowTypesBefore: "*testing.T"
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-keys-type
|
||||
- allowTypesBefore: "*testing.T"
|
||||
- name: context-keys-type
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#deep-exit
|
||||
- name: deep-exit
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#defer
|
||||
- name: defer
|
||||
disabled: false
|
||||
arguments:
|
||||
- ["call-chain", "loop"]
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#dot-imports
|
||||
- name: dot-imports
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#duplicated-imports
|
||||
- name: duplicated-imports
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return
|
||||
- name: early-return
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-block
|
||||
arguments:
|
||||
- "preserveScope"
|
||||
- name: empty-block
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines
|
||||
- name: empty-lines
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-naming
|
||||
- name: error-naming
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-return
|
||||
- name: error-return
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-strings
|
||||
- name: error-strings
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#errorf
|
||||
- name: errorf
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#exported
|
||||
- name: exported
|
||||
disabled: false
|
||||
arguments:
|
||||
- "sayRepetitiveInsteadOfStutters"
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#flag-parameter
|
||||
- name: flag-parameter
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#identical-branches
|
||||
- name: identical-branches
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#if-return
|
||||
- name: if-return
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#increment-decrement
|
||||
- name: increment-decrement
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#indent-error-flow
|
||||
- name: indent-error-flow
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing
|
||||
- name: import-shadowing
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#package-comments
|
||||
- name: increment-decrement
|
||||
- name: indent-error-flow
|
||||
arguments:
|
||||
- "preserveScope"
|
||||
- name: package-comments
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range
|
||||
- name: range
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-in-closure
|
||||
- name: range-val-in-closure
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-address
|
||||
- name: range-val-address
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redefines-builtin-id
|
||||
- name: redefines-builtin-id
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-format
|
||||
- name: string-format
|
||||
disabled: false
|
||||
arguments:
|
||||
- - panic
|
||||
- '/^[^\n]*$/'
|
||||
- must not contain line breaks
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag
|
||||
- name: struct-tag
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#superfluous-else
|
||||
- name: superfluous-else
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-equal
|
||||
- name: time-equal
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming
|
||||
- name: var-naming
|
||||
disabled: false
|
||||
arguments:
|
||||
- ["ID"] # AllowList
|
||||
- ["Otel", "Aws", "Gcp"] # DenyList
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration
|
||||
- name: var-declaration
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unconditional-recursion
|
||||
- "preserveScope"
|
||||
- name: time-equal
|
||||
- name: unconditional-recursion
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return
|
||||
- name: unexported-return
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error
|
||||
- name: unhandled-error
|
||||
disabled: false
|
||||
arguments:
|
||||
- "fmt.Fprint"
|
||||
- "fmt.Fprintf"
|
||||
@ -291,12 +236,17 @@ linters-settings:
|
||||
- "fmt.Print"
|
||||
- "fmt.Printf"
|
||||
- "fmt.Println"
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unnecessary-stmt
|
||||
- name: unnecessary-stmt
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break
|
||||
- name: useless-break
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#waitgroup-by-value
|
||||
- name: var-declaration
|
||||
- name: var-naming
|
||||
arguments:
|
||||
- ["ID"] # AllowList
|
||||
- ["Otel", "Aws", "Gcp"] # DenyList
|
||||
- name: waitgroup-by-value
|
||||
disabled: false
|
||||
testifylint:
|
||||
enable-all: true
|
||||
disable:
|
||||
- float-compare
|
||||
- go-require
|
||||
- require-error
|
||||
|
253
vendor/go.opentelemetry.io/otel/CHANGELOG.md
generated
vendored
253
vendor/go.opentelemetry.io/otel/CHANGELOG.md
generated
vendored
@ -8,6 +8,239 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
<!-- Released section -->
|
||||
<!-- Don't change this section unless doing release -->
|
||||
|
||||
## [1.35.0/0.57.0/0.11.0] 2025-03-05
|
||||
|
||||
This release is the last to support [Go 1.22].
|
||||
The next release will require at least [Go 1.23].
|
||||
|
||||
### Added
|
||||
|
||||
- Add `ValueFromAttribute` and `KeyValueFromAttribute` in `go.opentelemetry.io/otel/log`. (#6180)
|
||||
- Add `EventName` and `SetEventName` to `Record` in `go.opentelemetry.io/otel/log`. (#6187)
|
||||
- Add `EventName` to `RecordFactory` in `go.opentelemetry.io/otel/log/logtest`. (#6187)
|
||||
- `AssertRecordEqual` in `go.opentelemetry.io/otel/log/logtest` checks `Record.EventName`. (#6187)
|
||||
- Add `EventName` and `SetEventName` to `Record` in `go.opentelemetry.io/otel/sdk/log`. (#6193)
|
||||
- Add `EventName` to `RecordFactory` in `go.opentelemetry.io/otel/sdk/log/logtest`. (#6193)
|
||||
- Emit `Record.EventName` field in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc`. (#6211)
|
||||
- Emit `Record.EventName` field in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#6211)
|
||||
- Emit `Record.EventName` field in `go.opentelemetry.io/otel/exporters/stdout/stdoutlog` (#6210)
|
||||
- The `go.opentelemetry.io/otel/semconv/v1.28.0` package.
|
||||
The package contains semantic conventions from the `v1.28.0` version of the OpenTelemetry Semantic Conventions.
|
||||
See the [migration documentation](./semconv/v1.28.0/MIGRATION.md) for information on how to upgrade from `go.opentelemetry.io/otel/semconv/v1.27.0`(#6236)
|
||||
- The `go.opentelemetry.io/otel/semconv/v1.30.0` package.
|
||||
The package contains semantic conventions from the `v1.30.0` version of the OpenTelemetry Semantic Conventions.
|
||||
See the [migration documentation](./semconv/v1.30.0/MIGRATION.md) for information on how to upgrade from `go.opentelemetry.io/otel/semconv/v1.28.0`(#6240)
|
||||
- Document the pitfalls of using `Resource` as a comparable type.
|
||||
`Resource.Equal` and `Resource.Equivalent` should be used instead. (#6272)
|
||||
- Support [Go 1.24]. (#6304)
|
||||
- Add `FilterProcessor` and `EnabledParameters` in `go.opentelemetry.io/otel/sdk/log`.
|
||||
It replaces `go.opentelemetry.io/otel/sdk/log/internal/x.FilterProcessor`.
|
||||
Compared to previous version it additionally gives the possibility to filter by resource and instrumentation scope. (#6317)
|
||||
|
||||
### Changed
|
||||
|
||||
- Update `github.com/prometheus/common` to `v0.62.0`, which changes the `NameValidationScheme` to `NoEscaping`.
|
||||
This allows metrics names to keep original delimiters (e.g. `.`), rather than replacing with underscores.
|
||||
This is controlled by the `Content-Type` header, or can be reverted by setting `NameValidationScheme` to `LegacyValidation` in `github.com/prometheus/common/model`. (#6198)
|
||||
|
||||
### Fixes
|
||||
|
||||
- Eliminate goroutine leak for the processor returned by `NewSimpleSpanProcessor` in `go.opentelemetry.io/otel/sdk/trace` when `Shutdown` is called and the passed `ctx` is canceled and `SpanExporter.Shutdown` has not returned. (#6368)
|
||||
- Eliminate goroutine leak for the processor returned by `NewBatchSpanProcessor` in `go.opentelemetry.io/otel/sdk/trace` when `ForceFlush` is called and the passed `ctx` is canceled and `SpanExporter.Export` has not returned. (#6369)
|
||||
|
||||
## [1.34.0/0.56.0/0.10.0] 2025-01-17
|
||||
|
||||
### Changed
|
||||
|
||||
- Remove the notices from `Logger` to make the whole Logs API user-facing in `go.opentelemetry.io/otel/log`. (#6167)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Relax minimum Go version to 1.22.0 in various modules. (#6073)
|
||||
- The `Type` name logged for the `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc` client is corrected from `otlphttpgrpc` to `otlptracegrpc`. (#6143)
|
||||
- The `Type` name logged for the `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlphttpgrpc` client is corrected from `otlphttphttp` to `otlptracehttp`. (#6143)
|
||||
|
||||
## [1.33.0/0.55.0/0.9.0/0.0.12] 2024-12-12
|
||||
|
||||
### Added
|
||||
|
||||
- Add `Reset` method to `SpanRecorder` in `go.opentelemetry.io/otel/sdk/trace/tracetest`. (#5994)
|
||||
- Add `EnabledInstrument` interface in `go.opentelemetry.io/otel/sdk/metric/internal/x`.
|
||||
This is an experimental interface that is implemented by synchronous instruments provided by `go.opentelemetry.io/otel/sdk/metric`.
|
||||
Users can use it to avoid performing computationally expensive operations when recording measurements.
|
||||
It does not fall within the scope of the OpenTelemetry Go versioning and stability [policy](./VERSIONING.md) and it may be changed in backwards incompatible ways or removed in feature releases. (#6016)
|
||||
|
||||
### Changed
|
||||
|
||||
- The default global API now supports full auto-instrumentation from the `go.opentelemetry.io/auto` package.
|
||||
See that package for more information. (#5920)
|
||||
- Propagate non-retryable error messages to client in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#5929)
|
||||
- Propagate non-retryable error messages to client in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`. (#5929)
|
||||
- Propagate non-retryable error messages to client in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`. (#5929)
|
||||
- Performance improvements for attribute value `AsStringSlice`, `AsFloat64Slice`, `AsInt64Slice`, `AsBoolSlice`. (#6011)
|
||||
- Change `EnabledParameters` to have a `Severity` field instead of a getter and setter in `go.opentelemetry.io/otel/log`. (#6009)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix inconsistent request body closing in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#5954)
|
||||
- Fix inconsistent request body closing in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`. (#5954)
|
||||
- Fix inconsistent request body closing in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`. (#5954)
|
||||
- Fix invalid exemplar keys in `go.opentelemetry.io/otel/exporters/prometheus`. (#5995)
|
||||
- Fix attribute value truncation in `go.opentelemetry.io/otel/sdk/trace`. (#5997)
|
||||
- Fix attribute value truncation in `go.opentelemetry.io/otel/sdk/log`. (#6032)
|
||||
|
||||
## [1.32.0/0.54.0/0.8.0/0.0.11] 2024-11-08
|
||||
|
||||
### Added
|
||||
|
||||
- Add `go.opentelemetry.io/otel/sdk/metric/exemplar.AlwaysOffFilter`, which can be used to disable exemplar recording. (#5850)
|
||||
- Add `go.opentelemetry.io/otel/sdk/metric.WithExemplarFilter`, which can be used to configure the exemplar filter used by the metrics SDK. (#5850)
|
||||
- Add `ExemplarReservoirProviderSelector` and `DefaultExemplarReservoirProviderSelector` to `go.opentelemetry.io/otel/sdk/metric`, which defines the exemplar reservoir to use based on the aggregation of the metric. (#5861)
|
||||
- Add `ExemplarReservoirProviderSelector` to `go.opentelemetry.io/otel/sdk/metric.Stream` to allow using views to configure the exemplar reservoir to use for a metric. (#5861)
|
||||
- Add `ReservoirProvider`, `HistogramReservoirProvider` and `FixedSizeReservoirProvider` to `go.opentelemetry.io/otel/sdk/metric/exemplar` to make it convenient to use providers of Reservoirs. (#5861)
|
||||
- The `go.opentelemetry.io/otel/semconv/v1.27.0` package.
|
||||
The package contains semantic conventions from the `v1.27.0` version of the OpenTelemetry Semantic Conventions. (#5894)
|
||||
- Add `Attributes attribute.Set` field to `Scope` in `go.opentelemetry.io/otel/sdk/instrumentation`. (#5903)
|
||||
- Add `Attributes attribute.Set` field to `ScopeRecords` in `go.opentelemetry.io/otel/log/logtest`. (#5927)
|
||||
- `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc` adds instrumentation scope attributes. (#5934)
|
||||
- `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp` adds instrumentation scope attributes. (#5934)
|
||||
- `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` adds instrumentation scope attributes. (#5935)
|
||||
- `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp` adds instrumentation scope attributes. (#5935)
|
||||
- `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc` adds instrumentation scope attributes. (#5933)
|
||||
- `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp` adds instrumentation scope attributes. (#5933)
|
||||
- `go.opentelemetry.io/otel/exporters/prometheus` adds instrumentation scope attributes in `otel_scope_info` metric as labels. (#5932)
|
||||
|
||||
### Changed
|
||||
|
||||
- Support scope attributes and make them as identifying for `Tracer` in `go.opentelemetry.io/otel` and `go.opentelemetry.io/otel/sdk/trace`. (#5924)
|
||||
- Support scope attributes and make them as identifying for `Meter` in `go.opentelemetry.io/otel` and `go.opentelemetry.io/otel/sdk/metric`. (#5926)
|
||||
- Support scope attributes and make them as identifying for `Logger` in `go.opentelemetry.io/otel` and `go.opentelemetry.io/otel/sdk/log`. (#5925)
|
||||
- Make schema URL and scope attributes as identifying for `Tracer` in `go.opentelemetry.io/otel/bridge/opentracing`. (#5931)
|
||||
- Clear unneeded slice elements to allow GC to collect the objects in `go.opentelemetry.io/otel/sdk/metric` and `go.opentelemetry.io/otel/sdk/trace`. (#5804)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Global MeterProvider registration unwraps global instrument Observers, the undocumented Unwrap() methods are now private. (#5881)
|
||||
- `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` now keeps the metadata already present in the context when `WithHeaders` is used. (#5892)
|
||||
- `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc` now keeps the metadata already present in the context when `WithHeaders` is used. (#5911)
|
||||
- `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc` now keeps the metadata already present in the context when `WithHeaders` is used. (#5915)
|
||||
- Fix `go.opentelemetry.io/otel/exporters/prometheus` trying to add exemplars to Gauge metrics, which is unsupported. (#5912)
|
||||
- Fix `WithEndpointURL` to always use a secure connection when an https URL is passed in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc`. (#5944)
|
||||
- Fix `WithEndpointURL` to always use a secure connection when an https URL is passed in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`. (#5944)
|
||||
- Fix `WithEndpointURL` to always use a secure connection when an https URL is passed in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc`. (#5944)
|
||||
- Fix `WithEndpointURL` to always use a secure connection when an https URL is passed in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`. (#5944)
|
||||
- Fix incorrect metrics generated from callbacks when multiple readers are used in `go.opentelemetry.io/otel/sdk/metric`. (#5900)
|
||||
|
||||
### Removed
|
||||
|
||||
- Remove all examples under `go.opentelemetry.io/otel/example` as they are moved to [Contrib repository](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/examples). (#5930)
|
||||
|
||||
## [1.31.0/0.53.0/0.7.0/0.0.10] 2024-10-11
|
||||
|
||||
### Added
|
||||
|
||||
- Add `go.opentelemetry.io/otel/sdk/metric/exemplar` package which includes `Exemplar`, `Filter`, `TraceBasedFilter`, `AlwaysOnFilter`, `HistogramReservoir`, `FixedSizeReservoir`, `Reservoir`, `Value` and `ValueType` types. These will be used for configuring the exemplar reservoir for the metrics sdk. (#5747, #5862)
|
||||
- Add `WithExportBufferSize` option to log batch processor.(#5877)
|
||||
|
||||
### Changed
|
||||
|
||||
- Enable exemplars by default in `go.opentelemetry.io/otel/sdk/metric`. Exemplars can be disabled by setting `OTEL_METRICS_EXEMPLAR_FILTER=always_off` (#5778)
|
||||
- `Logger.Enabled` in `go.opentelemetry.io/otel/log` now accepts a newly introduced `EnabledParameters` type instead of `Record`. (#5791)
|
||||
- `FilterProcessor.Enabled` in `go.opentelemetry.io/otel/sdk/log/internal/x` now accepts `EnabledParameters` instead of `Record`. (#5791)
|
||||
- The `Record` type in `go.opentelemetry.io/otel/log` is no longer comparable. (#5847)
|
||||
- Performance improvements for the trace SDK `SetAttributes` method in `Span`. (#5864)
|
||||
- Reduce memory allocations for the `Event` and `Link` lists in `Span`. (#5858)
|
||||
- Performance improvements for the trace SDK `AddEvent`, `AddLink`, `RecordError` and `End` methods in `Span`. (#5874)
|
||||
|
||||
### Deprecated
|
||||
|
||||
- Deprecate all examples under `go.opentelemetry.io/otel/example` as they are moved to [Contrib repository](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/examples). (#5854)
|
||||
|
||||
### Fixed
|
||||
|
||||
- The race condition for multiple `FixedSize` exemplar reservoirs identified in #5814 is resolved. (#5819)
|
||||
- Fix log records duplication in case of heterogeneous resource attributes by correctly mapping each log record to it's resource and scope. (#5803)
|
||||
- Fix timer channel drain to avoid hanging on Go 1.23. (#5868)
|
||||
- Fix delegation for global meter providers, and panic when calling otel.SetMeterProvider. (#5827)
|
||||
- Change the `reflect.TypeOf` to use a nil pointer to not allocate on the heap unless necessary. (#5827)
|
||||
|
||||
## [1.30.0/0.52.0/0.6.0/0.0.9] 2024-09-09
|
||||
|
||||
### Added
|
||||
|
||||
- Support `OTEL_EXPORTER_OTLP_LOGS_INSECURE` and `OTEL_EXPORTER_OTLP_INSECURE` environments in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc`. (#5739)
|
||||
- The `WithResource` option for `NewMeterProvider` now merges the provided resources with the ones from environment variables. (#5773)
|
||||
- The `WithResource` option for `NewLoggerProvider` now merges the provided resources with the ones from environment variables. (#5773)
|
||||
- Add UTF-8 support to `go.opentelemetry.io/otel/exporters/prometheus`. (#5755)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix memory leak in the global `MeterProvider` when identical instruments are repeatedly created. (#5754)
|
||||
- Fix panic on instruments creation when setting meter provider. (#5758)
|
||||
- Fix an issue where `SetMeterProvider` in `go.opentelemetry.io/otel` might miss the delegation for instruments and registries. (#5780)
|
||||
|
||||
### Removed
|
||||
|
||||
- Drop support for [Go 1.21]. (#5736, #5740, #5800)
|
||||
|
||||
## [1.29.0/0.51.0/0.5.0] 2024-08-23
|
||||
|
||||
This release is the last to support [Go 1.21].
|
||||
The next release will require at least [Go 1.22].
|
||||
|
||||
### Added
|
||||
|
||||
- Add MacOS ARM64 platform to the compatibility testing suite. (#5577)
|
||||
- Add `InstrumentationScope` field to `SpanStub` in `go.opentelemetry.io/otel/sdk/trace/tracetest`, as a replacement for the deprecated `InstrumentationLibrary`. (#5627)
|
||||
- Make the initial release of `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc`.
|
||||
This new module contains an OTLP exporter that transmits log telemetry using gRPC.
|
||||
This module is unstable and breaking changes may be introduced.
|
||||
See our [versioning policy](VERSIONING.md) for more information about these stability guarantees. (#5629)
|
||||
- Add `Walk` function to `TraceState` in `go.opentelemetry.io/otel/trace` to iterate all the key-value pairs. (#5651)
|
||||
- Bridge the trace state in `go.opentelemetry.io/otel/bridge/opencensus`. (#5651)
|
||||
- Zero value of `SimpleProcessor` in `go.opentelemetry.io/otel/sdk/log` no longer panics. (#5665)
|
||||
- The `FilterProcessor` interface type is added in `go.opentelemetry.io/otel/sdk/log/internal/x`.
|
||||
This is an optional and experimental interface that log `Processor`s can implement to instruct the `Logger` if a `Record` will be processed or not.
|
||||
It replaces the existing `Enabled` method that is removed from the `Processor` interface itself.
|
||||
It does not fall within the scope of the OpenTelemetry Go versioning and stability [policy](./VERSIONING.md) and it may be changed in backwards incompatible ways or removed in feature releases. (#5692)
|
||||
- Support [Go 1.23]. (#5720)
|
||||
|
||||
### Changed
|
||||
|
||||
- `NewMemberRaw`, `NewKeyProperty` and `NewKeyValuePropertyRaw` in `go.opentelemetry.io/otel/baggage` allow UTF-8 string in key. (#5132)
|
||||
- `Processor.OnEmit` in `go.opentelemetry.io/otel/sdk/log` now accepts a pointer to `Record` instead of a value so that the record modifications done in a processor are propagated to subsequent registered processors. (#5636)
|
||||
- `SimpleProcessor.Enabled` in `go.opentelemetry.io/otel/sdk/log` now returns `false` if the exporter is `nil`. (#5665)
|
||||
- Update the concurrency requirements of `Exporter` in `go.opentelemetry.io/otel/sdk/log`. (#5666)
|
||||
- `SimpleProcessor` in `go.opentelemetry.io/otel/sdk/log` synchronizes `OnEmit` calls. (#5666)
|
||||
- The `Processor` interface in `go.opentelemetry.io/otel/sdk/log` no longer includes the `Enabled` method.
|
||||
See the `FilterProcessor` interface type added in `go.opentelemetry.io/otel/sdk/log/internal/x` to continue providing this functionality. (#5692)
|
||||
- The `SimpleProcessor` type in `go.opentelemetry.io/otel/sdk/log` is no longer comparable. (#5693)
|
||||
- The `BatchProcessor` type in `go.opentelemetry.io/otel/sdk/log` is no longer comparable. (#5693)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Correct comments for the priority of the `WithEndpoint` and `WithEndpointURL` options and their corresponding environment variables in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`. (#5584)
|
||||
- Pass the underlying error rather than a generic retry-able failure in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`, `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp` and `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`. (#5541)
|
||||
- Correct the `Tracer`, `Meter`, and `Logger` names used in `go.opentelemetry.io/otel/example/dice`. (#5612)
|
||||
- Correct the `Tracer` names used in `go.opentelemetry.io/otel/example/namedtracer`. (#5612)
|
||||
- Correct the `Tracer` name used in `go.opentelemetry.io/otel/example/opencensus`. (#5612)
|
||||
- Correct the `Tracer` and `Meter` names used in `go.opentelemetry.io/otel/example/otel-collector`. (#5612)
|
||||
- Correct the `Tracer` names used in `go.opentelemetry.io/otel/example/passthrough`. (#5612)
|
||||
- Correct the `Meter` name used in `go.opentelemetry.io/otel/example/prometheus`. (#5612)
|
||||
- Correct the `Tracer` names used in `go.opentelemetry.io/otel/example/zipkin`. (#5612)
|
||||
- Correct comments for the priority of the `WithEndpoint` and `WithEndpointURL` options and their corresponding environment variables in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` and `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`. (#5641)
|
||||
- Correct comments for the priority of the `WithEndpoint` and `WithEndpointURL` options and their corresponding environment variables in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#5650)
|
||||
- Stop percent encoding header environment variables in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc`, `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`, `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` and `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp` (#5705)
|
||||
- Remove invalid environment variable header keys in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc`, `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`, `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` and `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp` (#5705)
|
||||
|
||||
### Removed
|
||||
|
||||
- The `Enabled` method of the `SimpleProcessor` in `go.opentelemetry.io/otel/sdk/log` is removed. (#5692)
|
||||
- The `Enabled` method of the `BatchProcessor` in `go.opentelemetry.io/otel/sdk/log` is removed. (#5692)
|
||||
|
||||
## [1.28.0/0.50.0/0.4.0] 2024-07-02
|
||||
|
||||
### Added
|
||||
@ -49,6 +282,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
- Fix stale timestamps reported by the last-value aggregation. (#5517)
|
||||
- Indicate the `Exporter` in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp` must be created by the `New` method. (#5521)
|
||||
- Improved performance in all `{Bool,Int64,Float64,String}SliceValue` functions of `go.opentelemetry.io/attributes` by reducing the number of allocations. (#5549)
|
||||
- Replace invalid percent-encoded octet sequences with replacement char in `go.opentelemetry.io/otel/baggage`. (#5528)
|
||||
|
||||
## [1.27.0/0.49.0/0.3.0] 2024-05-21
|
||||
|
||||
@ -175,7 +409,7 @@ The next release will require at least [Go 1.21].
|
||||
This module includes OpenTelemetry Go's implementation of the Logs Bridge API.
|
||||
This module is in an alpha state, it is subject to breaking changes.
|
||||
See our [versioning policy](./VERSIONING.md) for more info. (#4961)
|
||||
- ARM64 platform to the compatibility testing suite. (#4994)
|
||||
- Add ARM64 platform to the compatibility testing suite. (#4994)
|
||||
|
||||
### Fixed
|
||||
|
||||
@ -1836,7 +2070,7 @@ with major version 0.
|
||||
- Setting error status while recording error with Span from oteltest package. (#1729)
|
||||
- The concept of a remote and local Span stored in a context is unified to just the current Span.
|
||||
Because of this `"go.opentelemetry.io/otel/trace".RemoteSpanContextFromContext` is removed as it is no longer needed.
|
||||
Instead, `"go.opentelemetry.io/otel/trace".SpanContextFromContex` can be used to return the current Span.
|
||||
Instead, `"go.opentelemetry.io/otel/trace".SpanContextFromContext` can be used to return the current Span.
|
||||
If needed, that Span's `SpanContext.IsRemote()` can then be used to determine if it is remote or not. (#1731)
|
||||
- The `HasRemoteParent` field of the `"go.opentelemetry.io/otel/sdk/trace".SamplingParameters` is removed.
|
||||
This field is redundant to the information returned from the `Remote` method of the `SpanContext` held in the `ParentContext` field. (#1749)
|
||||
@ -2410,7 +2644,7 @@ This release migrates the default OpenTelemetry SDK into its own Go module, deco
|
||||
- Prometheus exporter will not apply stale updates or forget inactive metrics. (#903)
|
||||
- Add test for api.standard `HTTPClientAttributesFromHTTPRequest`. (#905)
|
||||
- Bump github.com/golangci/golangci-lint from 1.27.0 to 1.28.1 in /tools. (#901, #913)
|
||||
- Update otel-colector example to use the v0.5.0 collector. (#915)
|
||||
- Update otel-collector example to use the v0.5.0 collector. (#915)
|
||||
- The `grpctrace` instrumentation uses a span name conforming to the OpenTelemetry semantic conventions (does not contain a leading slash (`/`)). (#922)
|
||||
- The `grpctrace` instrumentation includes an `rpc.method` attribute now set to the gRPC method name. (#900, #922)
|
||||
- The `grpctrace` instrumentation `rpc.service` attribute now contains the package name if one exists.
|
||||
@ -3003,7 +3237,14 @@ It contains api and sdk for trace and meter.
|
||||
- CircleCI build CI manifest files.
|
||||
- CODEOWNERS file to track owners of this project.
|
||||
|
||||
[Unreleased]: https://github.com/open-telemetry/opentelemetry-go/compare/v1.28.0...HEAD
|
||||
[Unreleased]: https://github.com/open-telemetry/opentelemetry-go/compare/v1.35.0...HEAD
|
||||
[1.35.0/0.57.0/0.11.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.35.0
|
||||
[1.34.0/0.56.0/0.10.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.34.0
|
||||
[1.33.0/0.55.0/0.9.0/0.0.12]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.33.0
|
||||
[1.32.0/0.54.0/0.8.0/0.0.11]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.32.0
|
||||
[1.31.0/0.53.0/0.7.0/0.0.10]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.31.0
|
||||
[1.30.0/0.52.0/0.6.0/0.0.9]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.30.0
|
||||
[1.29.0/0.51.0/0.5.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.29.0
|
||||
[1.28.0/0.50.0/0.4.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.28.0
|
||||
[1.27.0/0.49.0/0.3.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.27.0
|
||||
[1.26.0/0.48.0/0.2.0-alpha]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.26.0
|
||||
@ -3086,6 +3327,10 @@ It contains api and sdk for trace and meter.
|
||||
[0.1.1]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v0.1.1
|
||||
[0.1.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v0.1.0
|
||||
|
||||
<!-- Released section ended -->
|
||||
|
||||
[Go 1.24]: https://go.dev/doc/go1.24
|
||||
[Go 1.23]: https://go.dev/doc/go1.23
|
||||
[Go 1.22]: https://go.dev/doc/go1.22
|
||||
[Go 1.21]: https://go.dev/doc/go1.21
|
||||
[Go 1.20]: https://go.dev/doc/go1.20
|
||||
|
6
vendor/go.opentelemetry.io/otel/CODEOWNERS
generated
vendored
6
vendor/go.opentelemetry.io/otel/CODEOWNERS
generated
vendored
@ -5,13 +5,13 @@
|
||||
#####################################################
|
||||
#
|
||||
# Learn about membership in OpenTelemetry community:
|
||||
# https://github.com/open-telemetry/community/blob/main/community-membership.md
|
||||
# https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md
|
||||
#
|
||||
#
|
||||
# Learn about CODEOWNERS file format:
|
||||
# https://help.github.com/en/articles/about-code-owners
|
||||
#
|
||||
|
||||
* @MrAlias @XSAM @dashpole @MadVikingGod @pellared @hanyuancheung @dmathieu
|
||||
* @MrAlias @XSAM @dashpole @pellared @dmathieu
|
||||
|
||||
CODEOWNERS @MrAlias @MadVikingGod @pellared @dashpole @XSAM @dmathieu
|
||||
CODEOWNERS @MrAlias @pellared @dashpole @XSAM @dmathieu
|
||||
|
38
vendor/go.opentelemetry.io/otel/CONTRIBUTING.md
generated
vendored
38
vendor/go.opentelemetry.io/otel/CONTRIBUTING.md
generated
vendored
@ -181,6 +181,18 @@ patterns in the spec.
|
||||
For a deeper discussion, see
|
||||
[this](https://github.com/open-telemetry/opentelemetry-specification/issues/165).
|
||||
|
||||
## Tests
|
||||
|
||||
Each functionality should be covered by tests.
|
||||
|
||||
Performance-critical functionality should also be covered by benchmarks.
|
||||
|
||||
- Pull requests adding a performance-critical functionality
|
||||
should have `go test -bench` output in their description.
|
||||
- Pull requests changing a performance-critical functionality
|
||||
should have [`benchstat`](https://pkg.go.dev/golang.org/x/perf/cmd/benchstat)
|
||||
output in their description.
|
||||
|
||||
## Documentation
|
||||
|
||||
Each (non-internal, non-test) package must be documented using
|
||||
@ -578,7 +590,10 @@ See also:
|
||||
The tests should never leak goroutines.
|
||||
|
||||
Use the term `ConcurrentSafe` in the test name when it aims to verify the
|
||||
absence of race conditions.
|
||||
absence of race conditions. The top-level tests with this term will be run
|
||||
many times in the `test-concurrent-safe` CI job to increase the chance of
|
||||
catching concurrency issues. This does not apply to subtests when this term
|
||||
is not in their root name.
|
||||
|
||||
### Internal packages
|
||||
|
||||
@ -626,13 +641,14 @@ should be canceled.
|
||||
|
||||
## Approvers and Maintainers
|
||||
|
||||
### Approvers
|
||||
### Triagers
|
||||
|
||||
- [Chester Cheung](https://github.com/hanyuancheung), Tencent
|
||||
- [Cheng-Zhen Yang](https://github.com/scorpionknifes), Independent
|
||||
|
||||
### Approvers
|
||||
|
||||
### Maintainers
|
||||
|
||||
- [Aaron Clawson](https://github.com/MadVikingGod), LightStep
|
||||
- [Damien Mathieu](https://github.com/dmathieu), Elastic
|
||||
- [David Ashpole](https://github.com/dashpole), Google
|
||||
- [Robert Pająk](https://github.com/pellared), Splunk
|
||||
@ -641,16 +657,18 @@ should be canceled.
|
||||
|
||||
### Emeritus
|
||||
|
||||
- [Liz Fong-Jones](https://github.com/lizthegrey), Honeycomb
|
||||
- [Gustavo Silva Paiva](https://github.com/paivagustavo), LightStep
|
||||
- [Josh MacDonald](https://github.com/jmacd), LightStep
|
||||
- [Anthony Mirabella](https://github.com/Aneurysm9), AWS
|
||||
- [Evan Torrie](https://github.com/evantorrie), Yahoo
|
||||
- [Aaron Clawson](https://github.com/MadVikingGod)
|
||||
- [Anthony Mirabella](https://github.com/Aneurysm9)
|
||||
- [Chester Cheung](https://github.com/hanyuancheung)
|
||||
- [Evan Torrie](https://github.com/evantorrie)
|
||||
- [Gustavo Silva Paiva](https://github.com/paivagustavo)
|
||||
- [Josh MacDonald](https://github.com/jmacd)
|
||||
- [Liz Fong-Jones](https://github.com/lizthegrey)
|
||||
|
||||
### Become an Approver or a Maintainer
|
||||
|
||||
See the [community membership document in OpenTelemetry community
|
||||
repo](https://github.com/open-telemetry/community/blob/main/community-membership.md).
|
||||
repo](https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md).
|
||||
|
||||
[Approver]: #approvers
|
||||
[Maintainer]: #maintainers
|
||||
|
75
vendor/go.opentelemetry.io/otel/Makefile
generated
vendored
75
vendor/go.opentelemetry.io/otel/Makefile
generated
vendored
@ -11,11 +11,15 @@ ALL_COVERAGE_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {}
|
||||
GO = go
|
||||
TIMEOUT = 60
|
||||
|
||||
# User to run as in docker images.
|
||||
DOCKER_USER=$(shell id -u):$(shell id -g)
|
||||
DEPENDENCIES_DOCKERFILE=./dependencies.Dockerfile
|
||||
|
||||
.DEFAULT_GOAL := precommit
|
||||
|
||||
.PHONY: precommit ci
|
||||
precommit: generate license-check misspell go-mod-tidy golangci-lint-fix verify-readmes verify-mods test-default
|
||||
ci: generate license-check lint vanity-import-check verify-readmes verify-mods build test-default check-clean-work-tree test-coverage
|
||||
precommit: generate toolchain-check license-check misspell go-mod-tidy golangci-lint-fix verify-readmes verify-mods test-default
|
||||
ci: generate toolchain-check license-check lint vanity-import-check verify-readmes verify-mods build test-default check-clean-work-tree test-coverage
|
||||
|
||||
# Tools
|
||||
|
||||
@ -54,9 +58,6 @@ $(TOOLS)/stringer: PACKAGE=golang.org/x/tools/cmd/stringer
|
||||
PORTO = $(TOOLS)/porto
|
||||
$(TOOLS)/porto: PACKAGE=github.com/jcchavezs/porto/cmd/porto
|
||||
|
||||
GOJQ = $(TOOLS)/gojq
|
||||
$(TOOLS)/gojq: PACKAGE=github.com/itchyny/gojq/cmd/gojq
|
||||
|
||||
GOTMPL = $(TOOLS)/gotmpl
|
||||
$(GOTMPL): PACKAGE=go.opentelemetry.io/build-tools/gotmpl
|
||||
|
||||
@ -67,7 +68,7 @@ GOVULNCHECK = $(TOOLS)/govulncheck
|
||||
$(TOOLS)/govulncheck: PACKAGE=golang.org/x/vuln/cmd/govulncheck
|
||||
|
||||
.PHONY: tools
|
||||
tools: $(CROSSLINK) $(GOLANGCI_LINT) $(MISSPELL) $(GOCOVMERGE) $(STRINGER) $(PORTO) $(GOJQ) $(SEMCONVGEN) $(MULTIMOD) $(SEMCONVKIT) $(GOTMPL) $(GORELEASE)
|
||||
tools: $(CROSSLINK) $(GOLANGCI_LINT) $(MISSPELL) $(GOCOVMERGE) $(STRINGER) $(PORTO) $(SEMCONVGEN) $(MULTIMOD) $(SEMCONVKIT) $(GOTMPL) $(GORELEASE)
|
||||
|
||||
# Virtualized python tools via docker
|
||||
|
||||
@ -84,20 +85,20 @@ PIP := $(PYTOOLS)/pip
|
||||
WORKDIR := /workdir
|
||||
|
||||
# The python image to use for the virtual environment.
|
||||
PYTHONIMAGE := python:3.11.3-slim-bullseye
|
||||
PYTHONIMAGE := $(shell awk '$$4=="python" {print $$2}' $(DEPENDENCIES_DOCKERFILE))
|
||||
|
||||
# Run the python image with the current directory mounted.
|
||||
DOCKERPY := docker run --rm -v "$(CURDIR):$(WORKDIR)" -w $(WORKDIR) $(PYTHONIMAGE)
|
||||
DOCKERPY := docker run --rm -u $(DOCKER_USER) -v "$(CURDIR):$(WORKDIR)" -w $(WORKDIR) $(PYTHONIMAGE)
|
||||
|
||||
# Create a virtual environment for Python tools.
|
||||
$(PYTOOLS):
|
||||
# The `--upgrade` flag is needed to ensure that the virtual environment is
|
||||
# created with the latest pip version.
|
||||
@$(DOCKERPY) bash -c "python3 -m venv $(VENVDIR) && $(PIP) install --upgrade pip"
|
||||
@$(DOCKERPY) bash -c "python3 -m venv $(VENVDIR) && $(PIP) install --upgrade --cache-dir=$(WORKDIR)/.cache/pip pip"
|
||||
|
||||
# Install python packages into the virtual environment.
|
||||
$(PYTOOLS)/%: $(PYTOOLS)
|
||||
@$(DOCKERPY) $(PIP) install -r requirements.txt
|
||||
@$(DOCKERPY) $(PIP) install --cache-dir=$(WORKDIR)/.cache/pip -r requirements.txt
|
||||
|
||||
CODESPELL = $(PYTOOLS)/codespell
|
||||
$(CODESPELL): PACKAGE=codespell
|
||||
@ -122,7 +123,7 @@ vanity-import-fix: $(PORTO)
|
||||
# Generate go.work file for local development.
|
||||
.PHONY: go-work
|
||||
go-work: $(CROSSLINK)
|
||||
$(CROSSLINK) work --root=$(shell pwd)
|
||||
$(CROSSLINK) work --root=$(shell pwd) --go=1.22.7
|
||||
|
||||
# Build
|
||||
|
||||
@ -145,12 +146,14 @@ build-tests/%:
|
||||
|
||||
# Tests
|
||||
|
||||
TEST_TARGETS := test-default test-bench test-short test-verbose test-race
|
||||
TEST_TARGETS := test-default test-bench test-short test-verbose test-race test-concurrent-safe
|
||||
.PHONY: $(TEST_TARGETS) test
|
||||
test-default test-race: ARGS=-race
|
||||
test-bench: ARGS=-run=xxxxxMatchNothingxxxxx -test.benchtime=1ms -bench=.
|
||||
test-short: ARGS=-short
|
||||
test-verbose: ARGS=-v -race
|
||||
test-concurrent-safe: ARGS=-run=ConcurrentSafe -count=100 -race
|
||||
test-concurrent-safe: TIMEOUT=120
|
||||
$(TEST_TARGETS): test
|
||||
test: $(OTEL_GO_MOD_DIRS:%=test/%)
|
||||
test/%: DIR=$*
|
||||
@ -178,17 +181,14 @@ test-coverage: $(GOCOVMERGE)
|
||||
done; \
|
||||
$(GOCOVMERGE) $$(find . -name coverage.out) > coverage.txt
|
||||
|
||||
# Adding a directory will include all benchmarks in that directory if a filter is not specified.
|
||||
BENCHMARK_TARGETS := sdk/trace
|
||||
.PHONY: benchmark
|
||||
benchmark: $(BENCHMARK_TARGETS:%=benchmark/%)
|
||||
BENCHMARK_FILTER = .
|
||||
# You can override the filter for a particular directory by adding a rule here.
|
||||
benchmark/sdk/trace: BENCHMARK_FILTER = SpanWithAttributes_8/AlwaysSample
|
||||
benchmark: $(OTEL_GO_MOD_DIRS:%=benchmark/%)
|
||||
benchmark/%:
|
||||
@echo "$(GO) test -timeout $(TIMEOUT)s -run=xxxxxMatchNothingxxxxx -bench=$(BENCHMARK_FILTER) $*..." \
|
||||
@echo "$(GO) test -run=xxxxxMatchNothingxxxxx -bench=. $*..." \
|
||||
&& cd $* \
|
||||
$(foreach filter, $(BENCHMARK_FILTER), && $(GO) test -timeout $(TIMEOUT)s -run=xxxxxMatchNothingxxxxx -bench=$(filter))
|
||||
&& $(GO) list ./... \
|
||||
| grep -v third_party \
|
||||
| xargs $(GO) test -run=xxxxxMatchNothingxxxxx -bench=.
|
||||
|
||||
.PHONY: golangci-lint golangci-lint-fix
|
||||
golangci-lint-fix: ARGS=--fix
|
||||
@ -239,6 +239,16 @@ govulncheck/%: $(GOVULNCHECK)
|
||||
codespell: $(CODESPELL)
|
||||
@$(DOCKERPY) $(CODESPELL)
|
||||
|
||||
.PHONY: toolchain-check
|
||||
toolchain-check:
|
||||
@toolchainRes=$$(for f in $(ALL_GO_MOD_DIRS); do \
|
||||
awk '/^toolchain/ { found=1; next } END { if (found) print FILENAME }' $$f/go.mod; \
|
||||
done); \
|
||||
if [ -n "$${toolchainRes}" ]; then \
|
||||
echo "toolchain checking failed:"; echo "$${toolchainRes}"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
.PHONY: license-check
|
||||
license-check:
|
||||
@licRes=$$(for f in $$(find . -type f \( -iname '*.go' -o -iname '*.sh' \) ! -path '**/third_party/*' ! -path './.git/*' ) ; do \
|
||||
@ -259,13 +269,30 @@ check-clean-work-tree:
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
# The weaver docker image to use for semconv-generate.
|
||||
WEAVER_IMAGE := $(shell awk '$$4=="weaver" {print $$2}' $(DEPENDENCIES_DOCKERFILE))
|
||||
|
||||
SEMCONVPKG ?= "semconv/"
|
||||
.PHONY: semconv-generate
|
||||
semconv-generate: $(SEMCONVGEN) $(SEMCONVKIT)
|
||||
semconv-generate: $(SEMCONVKIT)
|
||||
[ "$(TAG)" ] || ( echo "TAG unset: missing opentelemetry semantic-conventions tag"; exit 1 )
|
||||
[ "$(OTEL_SEMCONV_REPO)" ] || ( echo "OTEL_SEMCONV_REPO unset: missing path to opentelemetry semantic-conventions repo"; exit 1 )
|
||||
$(SEMCONVGEN) -i "$(OTEL_SEMCONV_REPO)/model/." --only=attribute_group -p conventionType=trace -f attribute_group.go -t "$(SEMCONVPKG)/template.j2" -s "$(TAG)"
|
||||
$(SEMCONVGEN) -i "$(OTEL_SEMCONV_REPO)/model/." --only=metric -f metric.go -t "$(SEMCONVPKG)/metric_template.j2" -s "$(TAG)"
|
||||
# Ensure the target directory for source code is available.
|
||||
mkdir -p $(PWD)/$(SEMCONVPKG)/${TAG}
|
||||
# Note: We mount a home directory for downloading/storing the semconv repository.
|
||||
# Weaver will automatically clean the cache when finished, but the directories will remain.
|
||||
mkdir -p ~/.weaver
|
||||
docker run --rm \
|
||||
-u $(DOCKER_USER) \
|
||||
--env HOME=/tmp/weaver \
|
||||
--mount 'type=bind,source=$(PWD)/semconv,target=/home/weaver/templates/registry/go,readonly' \
|
||||
--mount 'type=bind,source=$(PWD)/semconv/${TAG},target=/home/weaver/target' \
|
||||
--mount 'type=bind,source=$(HOME)/.weaver,target=/tmp/weaver/.weaver' \
|
||||
$(WEAVER_IMAGE) registry generate \
|
||||
--registry=https://github.com/open-telemetry/semantic-conventions/archive/refs/tags/$(TAG).zip[model] \
|
||||
--templates=/home/weaver/templates \
|
||||
--param tag=$(TAG) \
|
||||
go \
|
||||
/home/weaver/target
|
||||
$(SEMCONVKIT) -output "$(SEMCONVPKG)/$(TAG)" -tag "$(TAG)"
|
||||
|
||||
.PHONY: gorelease
|
||||
|
45
vendor/go.opentelemetry.io/otel/README.md
generated
vendored
45
vendor/go.opentelemetry.io/otel/README.md
generated
vendored
@ -1,9 +1,11 @@
|
||||
# OpenTelemetry-Go
|
||||
|
||||
[](https://github.com/open-telemetry/opentelemetry-go/actions?query=workflow%3Aci+branch%3Amain)
|
||||
[](https://github.com/open-telemetry/opentelemetry-go/actions/workflows/ci.yml)
|
||||
[](https://app.codecov.io/gh/open-telemetry/opentelemetry-go?branch=main)
|
||||
[](https://pkg.go.dev/go.opentelemetry.io/otel)
|
||||
[](https://goreportcard.com/report/go.opentelemetry.io/otel)
|
||||
[](https://scorecard.dev/viewer/?uri=github.com/open-telemetry/opentelemetry-go)
|
||||
[](https://www.bestpractices.dev/projects/9996)
|
||||
[](https://cloud-native.slack.com/archives/C01NPAXACKT)
|
||||
|
||||
OpenTelemetry-Go is the [Go](https://golang.org/) implementation of [OpenTelemetry](https://opentelemetry.io/).
|
||||
@ -47,20 +49,29 @@ stop ensuring compatibility with these versions in the following manner:
|
||||
|
||||
Currently, this project supports the following environments.
|
||||
|
||||
| OS | Go Version | Architecture |
|
||||
|---------|------------|--------------|
|
||||
| Ubuntu | 1.22 | amd64 |
|
||||
| Ubuntu | 1.21 | amd64 |
|
||||
| Ubuntu | 1.22 | 386 |
|
||||
| Ubuntu | 1.21 | 386 |
|
||||
| Linux | 1.22 | arm64 |
|
||||
| Linux | 1.21 | arm64 |
|
||||
| MacOS | 1.22 | amd64 |
|
||||
| MacOS | 1.21 | amd64 |
|
||||
| Windows | 1.22 | amd64 |
|
||||
| Windows | 1.21 | amd64 |
|
||||
| Windows | 1.22 | 386 |
|
||||
| Windows | 1.21 | 386 |
|
||||
| OS | Go Version | Architecture |
|
||||
|----------|------------|--------------|
|
||||
| Ubuntu | 1.24 | amd64 |
|
||||
| Ubuntu | 1.23 | amd64 |
|
||||
| Ubuntu | 1.22 | amd64 |
|
||||
| Ubuntu | 1.24 | 386 |
|
||||
| Ubuntu | 1.23 | 386 |
|
||||
| Ubuntu | 1.22 | 386 |
|
||||
| Ubuntu | 1.24 | arm64 |
|
||||
| Ubuntu | 1.23 | arm64 |
|
||||
| Ubuntu | 1.22 | arm64 |
|
||||
| macOS 13 | 1.24 | amd64 |
|
||||
| macOS 13 | 1.23 | amd64 |
|
||||
| macOS 13 | 1.22 | amd64 |
|
||||
| macOS | 1.24 | arm64 |
|
||||
| macOS | 1.23 | arm64 |
|
||||
| macOS | 1.22 | arm64 |
|
||||
| Windows | 1.24 | amd64 |
|
||||
| Windows | 1.23 | amd64 |
|
||||
| Windows | 1.22 | amd64 |
|
||||
| Windows | 1.24 | 386 |
|
||||
| Windows | 1.23 | 386 |
|
||||
| Windows | 1.22 | 386 |
|
||||
|
||||
While this project should work for other systems, no compatibility guarantees
|
||||
are made for those systems currently.
|
||||
@ -87,8 +98,8 @@ If you need to extend the telemetry an instrumentation library provides or want
|
||||
to build your own instrumentation for your application directly you will need
|
||||
to use the
|
||||
[Go otel](https://pkg.go.dev/go.opentelemetry.io/otel)
|
||||
package. The included [examples](./example/) are a good way to see some
|
||||
practical uses of this process.
|
||||
package. The [examples](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/examples)
|
||||
are a good way to see some practical uses of this process.
|
||||
|
||||
### Export
|
||||
|
||||
|
29
vendor/go.opentelemetry.io/otel/RELEASING.md
generated
vendored
29
vendor/go.opentelemetry.io/otel/RELEASING.md
generated
vendored
@ -5,17 +5,14 @@
|
||||
New versions of the [OpenTelemetry Semantic Conventions] mean new versions of the `semconv` package need to be generated.
|
||||
The `semconv-generate` make target is used for this.
|
||||
|
||||
1. Checkout a local copy of the [OpenTelemetry Semantic Conventions] to the desired release tag.
|
||||
2. Pull the latest `otel/semconvgen` image: `docker pull otel/semconvgen:latest`
|
||||
3. Run the `make semconv-generate ...` target from this repository.
|
||||
1. Set the `TAG` environment variable to the semantic convention tag you want to generate.
|
||||
2. Run the `make semconv-generate ...` target from this repository.
|
||||
|
||||
For example,
|
||||
|
||||
```sh
|
||||
export TAG="v1.21.0" # Change to the release version you are generating.
|
||||
export OTEL_SEMCONV_REPO="/absolute/path/to/opentelemetry/semantic-conventions"
|
||||
docker pull otel/semconvgen:latest
|
||||
make semconv-generate # Uses the exported TAG and OTEL_SEMCONV_REPO.
|
||||
export TAG="v1.30.0" # Change to the release version you are generating.
|
||||
make semconv-generate # Uses the exported TAG.
|
||||
```
|
||||
|
||||
This should create a new sub-package of [`semconv`](./semconv).
|
||||
@ -69,6 +66,7 @@ Update go.mod for submodules to depend on the new release which will happen in t
|
||||
```
|
||||
|
||||
- Move all the `Unreleased` changes into a new section following the title scheme (`[<new tag>] - <date of release>`).
|
||||
- Make sure the new section is under the comment for released section, like `<!-- Released section -->`, so it is protected from being overwritten in the future.
|
||||
- Update all the appropriate links at the bottom.
|
||||
|
||||
4. Push the changes to upstream and create a Pull Request on GitHub.
|
||||
@ -110,17 +108,6 @@ It is critical you make sure the version you push upstream is correct.
|
||||
Finally create a Release for the new `<new tag>` on GitHub.
|
||||
The release body should include all the release notes from the Changelog for this release.
|
||||
|
||||
## Verify Examples
|
||||
|
||||
After releasing verify that examples build outside of the repository.
|
||||
|
||||
```
|
||||
./verify_examples.sh
|
||||
```
|
||||
|
||||
The script copies examples into a different directory removes any `replace` declarations in `go.mod` and builds them.
|
||||
This ensures they build with the published release, not the local copy.
|
||||
|
||||
## Post-Release
|
||||
|
||||
### Contrib Repository
|
||||
@ -140,6 +127,6 @@ Importantly, bump any package versions referenced to be the latest one you just
|
||||
|
||||
Bump the dependencies in the following Go services:
|
||||
|
||||
- [`accountingservice`](https://github.com/open-telemetry/opentelemetry-demo/tree/main/src/accountingservice)
|
||||
- [`checkoutservice`](https://github.com/open-telemetry/opentelemetry-demo/tree/main/src/checkoutservice)
|
||||
- [`productcatalogservice`](https://github.com/open-telemetry/opentelemetry-demo/tree/main/src/productcatalogservice)
|
||||
- [`accounting`](https://github.com/open-telemetry/opentelemetry-demo/tree/main/src/accounting)
|
||||
- [`checkoutservice`](https://github.com/open-telemetry/opentelemetry-demo/tree/main/src/checkout)
|
||||
- [`productcatalogservice`](https://github.com/open-telemetry/opentelemetry-demo/tree/main/src/product-catalog)
|
||||
|
2
vendor/go.opentelemetry.io/otel/VERSIONING.md
generated
vendored
2
vendor/go.opentelemetry.io/otel/VERSIONING.md
generated
vendored
@ -26,7 +26,7 @@ is designed so the following goals can be achieved.
|
||||
go.opentelemetry.io/otel/v2 v2.0.1`) and in the package import path
|
||||
(e.g., `import "go.opentelemetry.io/otel/v2/trace"`). This includes the
|
||||
paths used in `go get` commands (e.g., `go get
|
||||
go.opentelemetry.io/otel/v2@v2.0.1`. Note there is both a `/v2` and a
|
||||
go.opentelemetry.io/otel/v2@v2.0.1`). Note there is both a `/v2` and a
|
||||
`@v2.0.1` in that example. One way to think about it is that the module
|
||||
name now includes the `/v2`, so include `/v2` whenever you are using the
|
||||
module name).
|
||||
|
40
vendor/go.opentelemetry.io/otel/attribute/set.go
generated
vendored
40
vendor/go.opentelemetry.io/otel/attribute/set.go
generated
vendored
@ -347,45 +347,25 @@ func computeDistinct(kvs []KeyValue) Distinct {
|
||||
func computeDistinctFixed(kvs []KeyValue) interface{} {
|
||||
switch len(kvs) {
|
||||
case 1:
|
||||
ptr := new([1]KeyValue)
|
||||
copy((*ptr)[:], kvs)
|
||||
return *ptr
|
||||
return [1]KeyValue(kvs)
|
||||
case 2:
|
||||
ptr := new([2]KeyValue)
|
||||
copy((*ptr)[:], kvs)
|
||||
return *ptr
|
||||
return [2]KeyValue(kvs)
|
||||
case 3:
|
||||
ptr := new([3]KeyValue)
|
||||
copy((*ptr)[:], kvs)
|
||||
return *ptr
|
||||
return [3]KeyValue(kvs)
|
||||
case 4:
|
||||
ptr := new([4]KeyValue)
|
||||
copy((*ptr)[:], kvs)
|
||||
return *ptr
|
||||
return [4]KeyValue(kvs)
|
||||
case 5:
|
||||
ptr := new([5]KeyValue)
|
||||
copy((*ptr)[:], kvs)
|
||||
return *ptr
|
||||
return [5]KeyValue(kvs)
|
||||
case 6:
|
||||
ptr := new([6]KeyValue)
|
||||
copy((*ptr)[:], kvs)
|
||||
return *ptr
|
||||
return [6]KeyValue(kvs)
|
||||
case 7:
|
||||
ptr := new([7]KeyValue)
|
||||
copy((*ptr)[:], kvs)
|
||||
return *ptr
|
||||
return [7]KeyValue(kvs)
|
||||
case 8:
|
||||
ptr := new([8]KeyValue)
|
||||
copy((*ptr)[:], kvs)
|
||||
return *ptr
|
||||
return [8]KeyValue(kvs)
|
||||
case 9:
|
||||
ptr := new([9]KeyValue)
|
||||
copy((*ptr)[:], kvs)
|
||||
return *ptr
|
||||
return [9]KeyValue(kvs)
|
||||
case 10:
|
||||
ptr := new([10]KeyValue)
|
||||
copy((*ptr)[:], kvs)
|
||||
return *ptr
|
||||
return [10]KeyValue(kvs)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
150
vendor/go.opentelemetry.io/otel/baggage/baggage.go
generated
vendored
150
vendor/go.opentelemetry.io/otel/baggage/baggage.go
generated
vendored
@ -44,9 +44,15 @@ type Property struct {
|
||||
|
||||
// NewKeyProperty returns a new Property for key.
|
||||
//
|
||||
// The passed key must be valid, non-empty UTF-8 string.
|
||||
// If key is invalid, an error will be returned.
|
||||
// However, the specific Propagators that are used to transmit baggage entries across
|
||||
// component boundaries may impose their own restrictions on Property key.
|
||||
// For example, the W3C Baggage specification restricts the Property keys to strings that
|
||||
// satisfy the token definition from RFC7230, Section 3.2.6.
|
||||
// For maximum compatibility, alphanumeric value are strongly recommended to be used as Property key.
|
||||
func NewKeyProperty(key string) (Property, error) {
|
||||
if !validateKey(key) {
|
||||
if !validateBaggageName(key) {
|
||||
return newInvalidProperty(), fmt.Errorf("%w: %q", errInvalidKey, key)
|
||||
}
|
||||
|
||||
@ -62,6 +68,10 @@ func NewKeyProperty(key string) (Property, error) {
|
||||
// Notice: Consider using [NewKeyValuePropertyRaw] instead
|
||||
// that does not require percent-encoding of the value.
|
||||
func NewKeyValueProperty(key, value string) (Property, error) {
|
||||
if !validateKey(key) {
|
||||
return newInvalidProperty(), fmt.Errorf("%w: %q", errInvalidKey, key)
|
||||
}
|
||||
|
||||
if !validateValue(value) {
|
||||
return newInvalidProperty(), fmt.Errorf("%w: %q", errInvalidValue, value)
|
||||
}
|
||||
@ -74,11 +84,20 @@ func NewKeyValueProperty(key, value string) (Property, error) {
|
||||
|
||||
// NewKeyValuePropertyRaw returns a new Property for key with value.
|
||||
//
|
||||
// The passed key must be compliant with W3C Baggage specification.
|
||||
// The passed key must be valid, non-empty UTF-8 string.
|
||||
// The passed value must be valid UTF-8 string.
|
||||
// However, the specific Propagators that are used to transmit baggage entries across
|
||||
// component boundaries may impose their own restrictions on Property key.
|
||||
// For example, the W3C Baggage specification restricts the Property keys to strings that
|
||||
// satisfy the token definition from RFC7230, Section 3.2.6.
|
||||
// For maximum compatibility, alphanumeric value are strongly recommended to be used as Property key.
|
||||
func NewKeyValuePropertyRaw(key, value string) (Property, error) {
|
||||
if !validateKey(key) {
|
||||
if !validateBaggageName(key) {
|
||||
return newInvalidProperty(), fmt.Errorf("%w: %q", errInvalidKey, key)
|
||||
}
|
||||
if !validateBaggageValue(value) {
|
||||
return newInvalidProperty(), fmt.Errorf("%w: %q", errInvalidValue, value)
|
||||
}
|
||||
|
||||
p := Property{
|
||||
key: key,
|
||||
@ -115,12 +134,15 @@ func (p Property) validate() error {
|
||||
return fmt.Errorf("invalid property: %w", err)
|
||||
}
|
||||
|
||||
if !validateKey(p.key) {
|
||||
if !validateBaggageName(p.key) {
|
||||
return errFunc(fmt.Errorf("%w: %q", errInvalidKey, p.key))
|
||||
}
|
||||
if !p.hasValue && p.value != "" {
|
||||
return errFunc(errors.New("inconsistent value"))
|
||||
}
|
||||
if p.hasValue && !validateBaggageValue(p.value) {
|
||||
return errFunc(fmt.Errorf("%w: %q", errInvalidValue, p.value))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -138,7 +160,15 @@ func (p Property) Value() (string, bool) {
|
||||
|
||||
// String encodes Property into a header string compliant with the W3C Baggage
|
||||
// specification.
|
||||
// It would return empty string if the key is invalid with the W3C Baggage
|
||||
// specification. This could happen for a UTF-8 key, as it may contain
|
||||
// invalid characters.
|
||||
func (p Property) String() string {
|
||||
// W3C Baggage specification does not allow percent-encoded keys.
|
||||
if !validateKey(p.key) {
|
||||
return ""
|
||||
}
|
||||
|
||||
if p.hasValue {
|
||||
return fmt.Sprintf("%s%s%v", p.key, keyValueDelimiter, valueEscape(p.value))
|
||||
}
|
||||
@ -203,9 +233,14 @@ func (p properties) validate() error {
|
||||
// String encodes properties into a header string compliant with the W3C Baggage
|
||||
// specification.
|
||||
func (p properties) String() string {
|
||||
props := make([]string, len(p))
|
||||
for i, prop := range p {
|
||||
props[i] = prop.String()
|
||||
props := make([]string, 0, len(p))
|
||||
for _, prop := range p {
|
||||
s := prop.String()
|
||||
|
||||
// Ignored empty properties.
|
||||
if s != "" {
|
||||
props = append(props, s)
|
||||
}
|
||||
}
|
||||
return strings.Join(props, propertyDelimiter)
|
||||
}
|
||||
@ -230,6 +265,10 @@ type Member struct {
|
||||
// Notice: Consider using [NewMemberRaw] instead
|
||||
// that does not require percent-encoding of the value.
|
||||
func NewMember(key, value string, props ...Property) (Member, error) {
|
||||
if !validateKey(key) {
|
||||
return newInvalidMember(), fmt.Errorf("%w: %q", errInvalidKey, key)
|
||||
}
|
||||
|
||||
if !validateValue(value) {
|
||||
return newInvalidMember(), fmt.Errorf("%w: %q", errInvalidValue, value)
|
||||
}
|
||||
@ -242,7 +281,13 @@ func NewMember(key, value string, props ...Property) (Member, error) {
|
||||
|
||||
// NewMemberRaw returns a new Member from the passed arguments.
|
||||
//
|
||||
// The passed key must be compliant with W3C Baggage specification.
|
||||
// The passed key must be valid, non-empty UTF-8 string.
|
||||
// The passed value must be valid UTF-8 string.
|
||||
// However, the specific Propagators that are used to transmit baggage entries across
|
||||
// component boundaries may impose their own restrictions on baggage key.
|
||||
// For example, the W3C Baggage specification restricts the baggage keys to strings that
|
||||
// satisfy the token definition from RFC7230, Section 3.2.6.
|
||||
// For maximum compatibility, alphanumeric value are strongly recommended to be used as baggage key.
|
||||
func NewMemberRaw(key, value string, props ...Property) (Member, error) {
|
||||
m := Member{
|
||||
key: key,
|
||||
@ -294,19 +339,45 @@ func parseMember(member string) (Member, error) {
|
||||
return newInvalidMember(), fmt.Errorf("%w: %q", errInvalidKey, key)
|
||||
}
|
||||
|
||||
val := strings.TrimSpace(v)
|
||||
if !validateValue(val) {
|
||||
rawVal := strings.TrimSpace(v)
|
||||
if !validateValue(rawVal) {
|
||||
return newInvalidMember(), fmt.Errorf("%w: %q", errInvalidValue, v)
|
||||
}
|
||||
|
||||
// Decode a percent-encoded value.
|
||||
value, err := url.PathUnescape(val)
|
||||
unescapeVal, err := url.PathUnescape(rawVal)
|
||||
if err != nil {
|
||||
return newInvalidMember(), fmt.Errorf("%w: %w", errInvalidValue, err)
|
||||
}
|
||||
|
||||
value := replaceInvalidUTF8Sequences(len(rawVal), unescapeVal)
|
||||
return Member{key: key, value: value, properties: props, hasData: true}, nil
|
||||
}
|
||||
|
||||
// replaceInvalidUTF8Sequences replaces invalid UTF-8 sequences with '<27>'.
|
||||
func replaceInvalidUTF8Sequences(c int, unescapeVal string) string {
|
||||
if utf8.ValidString(unescapeVal) {
|
||||
return unescapeVal
|
||||
}
|
||||
// W3C baggage spec:
|
||||
// https://github.com/w3c/baggage/blob/8c215efbeebd3fa4b1aceb937a747e56444f22f3/baggage/HTTP_HEADER_FORMAT.md?plain=1#L69
|
||||
|
||||
var b strings.Builder
|
||||
b.Grow(c)
|
||||
for i := 0; i < len(unescapeVal); {
|
||||
r, size := utf8.DecodeRuneInString(unescapeVal[i:])
|
||||
if r == utf8.RuneError && size == 1 {
|
||||
// Invalid UTF-8 sequence found, replace it with '<27>'
|
||||
_, _ = b.WriteString("<22>")
|
||||
} else {
|
||||
_, _ = b.WriteRune(r)
|
||||
}
|
||||
i += size
|
||||
}
|
||||
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// validate ensures m conforms to the W3C Baggage specification.
|
||||
// A key must be an ASCII string, returning an error otherwise.
|
||||
func (m Member) validate() error {
|
||||
@ -314,9 +385,12 @@ func (m Member) validate() error {
|
||||
return fmt.Errorf("%w: %q", errInvalidMember, m)
|
||||
}
|
||||
|
||||
if !validateKey(m.key) {
|
||||
if !validateBaggageName(m.key) {
|
||||
return fmt.Errorf("%w: %q", errInvalidKey, m.key)
|
||||
}
|
||||
if !validateBaggageValue(m.value) {
|
||||
return fmt.Errorf("%w: %q", errInvalidValue, m.value)
|
||||
}
|
||||
return m.properties.validate()
|
||||
}
|
||||
|
||||
@ -331,10 +405,15 @@ func (m Member) Properties() []Property { return m.properties.Copy() }
|
||||
|
||||
// String encodes Member into a header string compliant with the W3C Baggage
|
||||
// specification.
|
||||
// It would return empty string if the key is invalid with the W3C Baggage
|
||||
// specification. This could happen for a UTF-8 key, as it may contain
|
||||
// invalid characters.
|
||||
func (m Member) String() string {
|
||||
// A key is just an ASCII string. A value is restricted to be
|
||||
// US-ASCII characters excluding CTLs, whitespace,
|
||||
// DQUOTE, comma, semicolon, and backslash.
|
||||
// W3C Baggage specification does not allow percent-encoded keys.
|
||||
if !validateKey(m.key) {
|
||||
return ""
|
||||
}
|
||||
|
||||
s := m.key + keyValueDelimiter + valueEscape(m.value)
|
||||
if len(m.properties) > 0 {
|
||||
s += propertyDelimiter + m.properties.String()
|
||||
@ -448,7 +527,7 @@ func (b Baggage) Member(key string) Member {
|
||||
}
|
||||
|
||||
// Members returns all the baggage list-members.
|
||||
// The order of the returned list-members does not have significance.
|
||||
// The order of the returned list-members is not significant.
|
||||
//
|
||||
// The returned members are not validated, as we assume the validation happened
|
||||
// when they were added to the Baggage.
|
||||
@ -469,8 +548,8 @@ func (b Baggage) Members() []Member {
|
||||
return members
|
||||
}
|
||||
|
||||
// SetMember returns a copy the Baggage with the member included. If the
|
||||
// baggage contains a Member with the same key the existing Member is
|
||||
// SetMember returns a copy of the Baggage with the member included. If the
|
||||
// baggage contains a Member with the same key, the existing Member is
|
||||
// replaced.
|
||||
//
|
||||
// If member is invalid according to the W3C Baggage specification, an error
|
||||
@ -528,14 +607,22 @@ func (b Baggage) Len() int {
|
||||
|
||||
// String encodes Baggage into a header string compliant with the W3C Baggage
|
||||
// specification.
|
||||
// It would ignore members where the member key is invalid with the W3C Baggage
|
||||
// specification. This could happen for a UTF-8 key, as it may contain
|
||||
// invalid characters.
|
||||
func (b Baggage) String() string {
|
||||
members := make([]string, 0, len(b.list))
|
||||
for k, v := range b.list {
|
||||
members = append(members, Member{
|
||||
s := Member{
|
||||
key: k,
|
||||
value: v.Value,
|
||||
properties: fromInternalProperties(v.Properties),
|
||||
}.String())
|
||||
}.String()
|
||||
|
||||
// Ignored empty members.
|
||||
if s != "" {
|
||||
members = append(members, s)
|
||||
}
|
||||
}
|
||||
return strings.Join(members, listDelimiter)
|
||||
}
|
||||
@ -607,10 +694,12 @@ func parsePropertyInternal(s string) (p Property, ok bool) {
|
||||
}
|
||||
|
||||
// Decode a percent-encoded value.
|
||||
value, err := url.PathUnescape(s[valueStart:valueEnd])
|
||||
rawVal := s[valueStart:valueEnd]
|
||||
unescapeVal, err := url.PathUnescape(rawVal)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
value := replaceInvalidUTF8Sequences(len(rawVal), unescapeVal)
|
||||
|
||||
ok = true
|
||||
p.key = s[keyStart:keyEnd]
|
||||
@ -720,6 +809,24 @@ var safeKeyCharset = [utf8.RuneSelf]bool{
|
||||
'~': true,
|
||||
}
|
||||
|
||||
// validateBaggageName checks if the string is a valid OpenTelemetry Baggage name.
|
||||
// Baggage name is a valid, non-empty UTF-8 string.
|
||||
func validateBaggageName(s string) bool {
|
||||
if len(s) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
return utf8.ValidString(s)
|
||||
}
|
||||
|
||||
// validateBaggageValue checks if the string is a valid OpenTelemetry Baggage value.
|
||||
// Baggage value is a valid UTF-8 strings.
|
||||
// Empty string is also a valid UTF-8 string.
|
||||
func validateBaggageValue(s string) bool {
|
||||
return utf8.ValidString(s)
|
||||
}
|
||||
|
||||
// validateKey checks if the string is a valid W3C Baggage key.
|
||||
func validateKey(s string) bool {
|
||||
if len(s) == 0 {
|
||||
return false
|
||||
@ -738,6 +845,7 @@ func validateKeyChar(c int32) bool {
|
||||
return c >= 0 && c < int32(utf8.RuneSelf) && safeKeyCharset[c]
|
||||
}
|
||||
|
||||
// validateValue checks if the string is a valid W3C Baggage value.
|
||||
func validateValue(s string) bool {
|
||||
for _, c := range s {
|
||||
if !validateValueChar(c) {
|
||||
|
5
vendor/go.opentelemetry.io/otel/codes/codes.go
generated
vendored
5
vendor/go.opentelemetry.io/otel/codes/codes.go
generated
vendored
@ -5,6 +5,7 @@ package codes // import "go.opentelemetry.io/otel/codes"
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
@ -63,7 +64,7 @@ func (c *Code) UnmarshalJSON(b []byte) error {
|
||||
return nil
|
||||
}
|
||||
if c == nil {
|
||||
return fmt.Errorf("nil receiver passed to UnmarshalJSON")
|
||||
return errors.New("nil receiver passed to UnmarshalJSON")
|
||||
}
|
||||
|
||||
var x interface{}
|
||||
@ -83,7 +84,7 @@ func (c *Code) UnmarshalJSON(b []byte) error {
|
||||
return fmt.Errorf("invalid code: %q", ci)
|
||||
}
|
||||
|
||||
*c = Code(ci)
|
||||
*c = Code(ci) // nolint: gosec // Bit size of 32 check above.
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("invalid code: %q", string(b))
|
||||
|
3
vendor/go.opentelemetry.io/otel/dependencies.Dockerfile
generated
vendored
Normal file
3
vendor/go.opentelemetry.io/otel/dependencies.Dockerfile
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# This is a renovate-friendly source of Docker images.
|
||||
FROM python:3.13.2-slim-bullseye@sha256:31b581c8218e1f3c58672481b3b7dba8e898852866b408c6a984c22832523935 AS python
|
||||
FROM otel/weaver:v0.13.2@sha256:ae7346b992e477f629ea327e0979e8a416a97f7956ab1f7e95ac1f44edf1a893 AS weaver
|
2
vendor/go.opentelemetry.io/otel/doc.go
generated
vendored
2
vendor/go.opentelemetry.io/otel/doc.go
generated
vendored
@ -17,6 +17,8 @@ To read more about tracing, see go.opentelemetry.io/otel/trace.
|
||||
|
||||
To read more about metrics, see go.opentelemetry.io/otel/metric.
|
||||
|
||||
To read more about logs, see go.opentelemetry.io/otel/log.
|
||||
|
||||
To read more about propagation, see go.opentelemetry.io/otel/propagation and
|
||||
go.opentelemetry.io/otel/baggage.
|
||||
*/
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user