mirror of
https://github.com/containers/podman.git
synced 2025-06-21 01:19:15 +08:00
Merge pull request #12384 from containers/dependabot/go_modules/github.com/containers/image/v5-5.17.0
Bump github.com/containers/image/v5 from 5.16.1 to 5.17.0
This commit is contained in:
3
go.mod
3
go.mod
@ -14,7 +14,7 @@ require (
|
|||||||
github.com/containers/buildah v1.23.1
|
github.com/containers/buildah v1.23.1
|
||||||
github.com/containers/common v0.46.1-0.20211115170340-7ae7bd1c3f8e
|
github.com/containers/common v0.46.1-0.20211115170340-7ae7bd1c3f8e
|
||||||
github.com/containers/conmon v2.0.20+incompatible
|
github.com/containers/conmon v2.0.20+incompatible
|
||||||
github.com/containers/image/v5 v5.16.1
|
github.com/containers/image/v5 v5.17.0
|
||||||
github.com/containers/ocicrypt v1.1.2
|
github.com/containers/ocicrypt v1.1.2
|
||||||
github.com/containers/psgo v1.7.1
|
github.com/containers/psgo v1.7.1
|
||||||
github.com/containers/storage v1.37.1-0.20211014130921-5c5bf639ed01
|
github.com/containers/storage v1.37.1-0.20211014130921-5c5bf639ed01
|
||||||
@ -40,7 +40,6 @@ require (
|
|||||||
github.com/hashicorp/go-multierror v1.1.1
|
github.com/hashicorp/go-multierror v1.1.1
|
||||||
github.com/hpcloud/tail v1.0.0
|
github.com/hpcloud/tail v1.0.0
|
||||||
github.com/json-iterator/go v1.1.12
|
github.com/json-iterator/go v1.1.12
|
||||||
github.com/mattn/go-colorable v0.1.8 // indirect
|
|
||||||
github.com/mattn/go-isatty v0.0.14
|
github.com/mattn/go-isatty v0.0.14
|
||||||
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6
|
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6
|
||||||
github.com/mrunalp/fileutils v0.5.0
|
github.com/mrunalp/fileutils v0.5.0
|
||||||
|
28
go.sum
28
go.sum
@ -158,6 +158,7 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX
|
|||||||
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||||
github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||||
|
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||||
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
|
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
|
||||||
github.com/container-orchestrated-devices/container-device-interface v0.0.0-20210325223243-f99e8b6c10b9 h1:Kn0s9/APRtr5dk/83aXj97WX0+PYnJK9BO8g0Xclm0I=
|
github.com/container-orchestrated-devices/container-device-interface v0.0.0-20210325223243-f99e8b6c10b9 h1:Kn0s9/APRtr5dk/83aXj97WX0+PYnJK9BO8g0Xclm0I=
|
||||||
github.com/container-orchestrated-devices/container-device-interface v0.0.0-20210325223243-f99e8b6c10b9/go.mod h1:eQt66kIaJpUhCrjCtBFQGQxGLbAUl0OuuwjTH16ON4s=
|
github.com/container-orchestrated-devices/container-device-interface v0.0.0-20210325223243-f99e8b6c10b9/go.mod h1:eQt66kIaJpUhCrjCtBFQGQxGLbAUl0OuuwjTH16ON4s=
|
||||||
@ -263,8 +264,9 @@ github.com/containers/common v0.46.1-0.20211115170340-7ae7bd1c3f8e/go.mod h1:bu8
|
|||||||
github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg=
|
github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg=
|
||||||
github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I=
|
github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I=
|
||||||
github.com/containers/image/v5 v5.16.0/go.mod h1:XgTpfAPLRGOd1XYyCU5cISFr777bLmOerCSpt/v7+Q4=
|
github.com/containers/image/v5 v5.16.0/go.mod h1:XgTpfAPLRGOd1XYyCU5cISFr777bLmOerCSpt/v7+Q4=
|
||||||
github.com/containers/image/v5 v5.16.1 h1:4786k48/af3dOkVf9EM+xB880ArkXalICsGC4AXC6to=
|
|
||||||
github.com/containers/image/v5 v5.16.1/go.mod h1:mCvIFdzyyP1B0NBcZ80OIuaYqFn/OpFpaOMOMn1kU2M=
|
github.com/containers/image/v5 v5.16.1/go.mod h1:mCvIFdzyyP1B0NBcZ80OIuaYqFn/OpFpaOMOMn1kU2M=
|
||||||
|
github.com/containers/image/v5 v5.17.0 h1:KS5pro80CCsSp5qDBTMmSAWQo+xcBX19zUPExmYX2OQ=
|
||||||
|
github.com/containers/image/v5 v5.17.0/go.mod h1:GnYVusVRFPMMTAAUkrcS8NNSpBp8oyrjOUe04AAmRr4=
|
||||||
github.com/containers/libtrust v0.0.0-20190913040956-14b96171aa3b h1:Q8ePgVfHDplZ7U33NwHZkrVELsZP5fYj9pM5WBZB2GE=
|
github.com/containers/libtrust v0.0.0-20190913040956-14b96171aa3b h1:Q8ePgVfHDplZ7U33NwHZkrVELsZP5fYj9pM5WBZB2GE=
|
||||||
github.com/containers/libtrust v0.0.0-20190913040956-14b96171aa3b/go.mod h1:9rfv8iPl1ZP7aqh9YA68wnZv2NUDbXdcdPHVz0pFbPY=
|
github.com/containers/libtrust v0.0.0-20190913040956-14b96171aa3b/go.mod h1:9rfv8iPl1ZP7aqh9YA68wnZv2NUDbXdcdPHVz0pFbPY=
|
||||||
github.com/containers/ocicrypt v1.0.1/go.mod h1:MeJDzk1RJHv89LjsH0Sp5KTY3ZYkjXO/C+bKAeWFIrc=
|
github.com/containers/ocicrypt v1.0.1/go.mod h1:MeJDzk1RJHv89LjsH0Sp5KTY3ZYkjXO/C+bKAeWFIrc=
|
||||||
@ -374,6 +376,7 @@ github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5y
|
|||||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
|
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
|
||||||
|
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
|
||||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||||
github.com/evanphx/json-patch v4.11.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
github.com/evanphx/json-patch v4.11.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||||
@ -442,8 +445,9 @@ github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4er
|
|||||||
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=
|
|
||||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
||||||
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||||
@ -604,7 +608,6 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm
|
|||||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||||
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a h1:FaWFmfWdAUKbSCtOU2QjDaorUexogfaMgbipgYATUMU=
|
|
||||||
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a/go.mod h1:UJSiEoRfvx3hP73CvoARgeLjaIOjybY9vj8PUPPFGeU=
|
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a/go.mod h1:UJSiEoRfvx3hP73CvoARgeLjaIOjybY9vj8PUPPFGeU=
|
||||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||||
@ -634,7 +637,6 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
|||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/linuxkit/virtsock v0.0.0-20201010232012-f8cee7dfc7a3/go.mod h1:3r6x7q95whyfWQpmGZTu3gk3v2YkMi05HEzl7Tf7YEo=
|
github.com/linuxkit/virtsock v0.0.0-20201010232012-f8cee7dfc7a3/go.mod h1:3r6x7q95whyfWQpmGZTu3gk3v2YkMi05HEzl7Tf7YEo=
|
||||||
github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a h1:weJVJJRzAJBFRlAiJQROKQs8oC9vOxvm4rZmBBk0ONw=
|
|
||||||
github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
|
github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
|
||||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
@ -643,15 +645,13 @@ github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN
|
|||||||
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||||
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||||
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
|
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
|
||||||
github.com/manifoldco/promptui v0.8.0 h1:R95mMF+McvXZQ7j1g8ucVZE1gLP3Sv6j9vlF9kyRqQo=
|
|
||||||
github.com/manifoldco/promptui v0.8.0/go.mod h1:n4zTdgP0vr0S3w7/O/g98U+e0gwLScEXGwov2nIKuGQ=
|
github.com/manifoldco/promptui v0.8.0/go.mod h1:n4zTdgP0vr0S3w7/O/g98U+e0gwLScEXGwov2nIKuGQ=
|
||||||
|
github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA=
|
||||||
|
github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg=
|
||||||
github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho=
|
github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho=
|
||||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||||
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
|
|
||||||
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
|
||||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
|
||||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||||
@ -1110,6 +1110,7 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
|
|||||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||||
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/net v0.0.0-20211005001312-d4b1ae081e3b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20211105192438-b53810dc28af h1:SMeNJG/vclJ5wyBBd4xupMsSJIHTd1coW9g7q6KOjmY=
|
golang.org/x/net v0.0.0-20211105192438-b53810dc28af h1:SMeNJG/vclJ5wyBBd4xupMsSJIHTd1coW9g7q6KOjmY=
|
||||||
golang.org/x/net v0.0.0-20211105192438-b53810dc28af/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211105192438-b53810dc28af/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
@ -1179,7 +1180,6 @@ golang.org/x/sys v0.0.0-20191210023423-ac6580df4449/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200120151820-655fe14d7479/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200120151820-655fe14d7479/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
@ -1238,6 +1238,7 @@ golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20211004093028-2c5d950f24ef/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20211107104306-e0b2ad06fe42 h1:G2DDmludOQZoWbpCr7OKDxnl478ZBGMcOhrv+ooX/Q4=
|
golang.org/x/sys v0.0.0-20211107104306-e0b2ad06fe42 h1:G2DDmludOQZoWbpCr7OKDxnl478ZBGMcOhrv+ooX/Q4=
|
||||||
golang.org/x/sys v0.0.0-20211107104306-e0b2ad06fe42/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211107104306-e0b2ad06fe42/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
@ -1251,8 +1252,9 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
|||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||||
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
@ -1405,8 +1407,9 @@ google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6D
|
|||||||
google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||||
google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A=
|
google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A=
|
||||||
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c h1:wtujag7C+4D6KMoulW9YauvK2lgdvCMS260jsqqBXr0=
|
|
||||||
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
|
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
|
||||||
|
google.golang.org/genproto v0.0.0-20211005153810-c76a74d43a8e h1:Im71rbA1N3CbIag/PumYhQcNR8bLNmuOtRIyOnnLsT8=
|
||||||
|
google.golang.org/genproto v0.0.0-20211005153810-c76a74d43a8e/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||||
google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
|
google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
|
||||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||||
@ -1431,8 +1434,9 @@ google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG
|
|||||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||||
google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||||
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
|
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
|
||||||
google.golang.org/grpc v1.40.0 h1:AGJ0Ih4mHjSeibYkFGh1dD9KJ/eOtZ93I6hoHhukQ5Q=
|
|
||||||
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
|
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
|
||||||
|
google.golang.org/grpc v1.41.0 h1:f+PlOh7QV4iIJkPrx5NQ7qaNGFQ3OTse67yaDHfju4E=
|
||||||
|
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
|
40
vendor/github.com/containers/image/v5/docker/docker_image_dest.go
generated
vendored
40
vendor/github.com/containers/image/v5/docker/docker_image_dest.go
generated
vendored
@ -17,9 +17,9 @@ import (
|
|||||||
"github.com/containers/image/v5/docker/reference"
|
"github.com/containers/image/v5/docker/reference"
|
||||||
"github.com/containers/image/v5/internal/blobinfocache"
|
"github.com/containers/image/v5/internal/blobinfocache"
|
||||||
"github.com/containers/image/v5/internal/putblobdigest"
|
"github.com/containers/image/v5/internal/putblobdigest"
|
||||||
|
"github.com/containers/image/v5/internal/streamdigest"
|
||||||
"github.com/containers/image/v5/internal/uploadreader"
|
"github.com/containers/image/v5/internal/uploadreader"
|
||||||
"github.com/containers/image/v5/manifest"
|
"github.com/containers/image/v5/manifest"
|
||||||
"github.com/containers/image/v5/pkg/blobinfocache/none"
|
|
||||||
"github.com/containers/image/v5/types"
|
"github.com/containers/image/v5/types"
|
||||||
"github.com/docker/distribution/registry/api/errcode"
|
"github.com/docker/distribution/registry/api/errcode"
|
||||||
v2 "github.com/docker/distribution/registry/api/v2"
|
v2 "github.com/docker/distribution/registry/api/v2"
|
||||||
@ -131,11 +131,23 @@ func (d *dockerImageDestination) HasThreadSafePutBlob() bool {
|
|||||||
// to any other readers for download using the supplied digest.
|
// to any other readers for download using the supplied digest.
|
||||||
// If stream.Read() at any time, ESPECIALLY at end of input, returns an error, PutBlob MUST 1) fail, and 2) delete any data stored so far.
|
// If stream.Read() at any time, ESPECIALLY at end of input, returns an error, PutBlob MUST 1) fail, and 2) delete any data stored so far.
|
||||||
func (d *dockerImageDestination) PutBlob(ctx context.Context, stream io.Reader, inputInfo types.BlobInfo, cache types.BlobInfoCache, isConfig bool) (types.BlobInfo, error) {
|
func (d *dockerImageDestination) PutBlob(ctx context.Context, stream io.Reader, inputInfo types.BlobInfo, cache types.BlobInfoCache, isConfig bool) (types.BlobInfo, error) {
|
||||||
|
// If requested, precompute the blob digest to prevent uploading layers that already exist on the registry.
|
||||||
|
// This functionality is particularly useful when BlobInfoCache has not been populated with compressed digests,
|
||||||
|
// the source blob is uncompressed, and the destination blob is being compressed "on the fly".
|
||||||
|
if inputInfo.Digest == "" && d.c.sys.DockerRegistryPushPrecomputeDigests {
|
||||||
|
logrus.Debugf("Precomputing digest layer for %s", reference.Path(d.ref.ref))
|
||||||
|
streamCopy, cleanup, err := streamdigest.ComputeBlobInfo(d.c.sys, stream, &inputInfo)
|
||||||
|
if err != nil {
|
||||||
|
return types.BlobInfo{}, err
|
||||||
|
}
|
||||||
|
defer cleanup()
|
||||||
|
stream = streamCopy
|
||||||
|
}
|
||||||
|
|
||||||
if inputInfo.Digest != "" {
|
if inputInfo.Digest != "" {
|
||||||
// This should not really be necessary, at least the copy code calls TryReusingBlob automatically.
|
// This should not really be necessary, at least the copy code calls TryReusingBlob automatically.
|
||||||
// Still, we need to check, if only because the "initiate upload" endpoint does not have a documented "blob already exists" return value.
|
// Still, we need to check, if only because the "initiate upload" endpoint does not have a documented "blob already exists" return value.
|
||||||
// But we do that with NoCache, so that it _only_ checks the primary destination, instead of trying all mount candidates _again_.
|
haveBlob, reusedInfo, err := d.tryReusingExactBlob(ctx, inputInfo, cache)
|
||||||
haveBlob, reusedInfo, err := d.TryReusingBlob(ctx, inputInfo, none.NoCache, false)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.BlobInfo{}, err
|
return types.BlobInfo{}, err
|
||||||
}
|
}
|
||||||
@ -282,6 +294,21 @@ func (d *dockerImageDestination) mountBlob(ctx context.Context, srcRepo referenc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tryReusingExactBlob is a subset of TryReusingBlob which _only_ looks for exactly the specified
|
||||||
|
// blob in the current repository, with no cross-repo reuse or mounting; cache may be updated, it is not read.
|
||||||
|
// The caller must ensure info.Digest is set.
|
||||||
|
func (d *dockerImageDestination) tryReusingExactBlob(ctx context.Context, info types.BlobInfo, cache types.BlobInfoCache) (bool, types.BlobInfo, error) {
|
||||||
|
exists, size, err := d.blobExists(ctx, d.ref.ref, info.Digest, nil)
|
||||||
|
if err != nil {
|
||||||
|
return false, types.BlobInfo{}, err
|
||||||
|
}
|
||||||
|
if exists {
|
||||||
|
cache.RecordKnownLocation(d.ref.Transport(), bicTransportScope(d.ref), info.Digest, newBICLocationReference(d.ref))
|
||||||
|
return true, types.BlobInfo{Digest: info.Digest, MediaType: info.MediaType, Size: size}, nil
|
||||||
|
}
|
||||||
|
return false, types.BlobInfo{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// TryReusingBlob checks whether the transport already contains, or can efficiently reuse, a blob, and if so, applies it to the current destination
|
// TryReusingBlob checks whether the transport already contains, or can efficiently reuse, a blob, and if so, applies it to the current destination
|
||||||
// (e.g. if the blob is a filesystem layer, this signifies that the changes it describes need to be applied again when composing a filesystem tree).
|
// (e.g. if the blob is a filesystem layer, this signifies that the changes it describes need to be applied again when composing a filesystem tree).
|
||||||
// info.Digest must not be empty.
|
// info.Digest must not be empty.
|
||||||
@ -297,13 +324,12 @@ func (d *dockerImageDestination) TryReusingBlob(ctx context.Context, info types.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// First, check whether the blob happens to already exist at the destination.
|
// First, check whether the blob happens to already exist at the destination.
|
||||||
exists, size, err := d.blobExists(ctx, d.ref.ref, info.Digest, nil)
|
haveBlob, reusedInfo, err := d.tryReusingExactBlob(ctx, info, cache)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, types.BlobInfo{}, err
|
return false, types.BlobInfo{}, err
|
||||||
}
|
}
|
||||||
if exists {
|
if haveBlob {
|
||||||
cache.RecordKnownLocation(d.ref.Transport(), bicTransportScope(d.ref), info.Digest, newBICLocationReference(d.ref))
|
return true, reusedInfo, nil
|
||||||
return true, types.BlobInfo{Digest: info.Digest, MediaType: info.MediaType, Size: size}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then try reusing blobs from other locations.
|
// Then try reusing blobs from other locations.
|
||||||
|
22
vendor/github.com/containers/image/v5/docker/docker_image_src.go
generated
vendored
22
vendor/github.com/containers/image/v5/docker/docker_image_src.go
generated
vendored
@ -236,6 +236,9 @@ func (s *dockerImageSource) ensureManifestIsLoaded(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getExternalBlob returns the reader of the first available blob URL from urls, which must not be empty.
|
||||||
|
// This function can return nil reader when no url is supported by this function. In this case, the caller
|
||||||
|
// should fallback to fetch the non-external blob (i.e. pull from the registry).
|
||||||
func (s *dockerImageSource) getExternalBlob(ctx context.Context, urls []string) (io.ReadCloser, int64, error) {
|
func (s *dockerImageSource) getExternalBlob(ctx context.Context, urls []string) (io.ReadCloser, int64, error) {
|
||||||
var (
|
var (
|
||||||
resp *http.Response
|
resp *http.Response
|
||||||
@ -244,14 +247,17 @@ func (s *dockerImageSource) getExternalBlob(ctx context.Context, urls []string)
|
|||||||
if len(urls) == 0 {
|
if len(urls) == 0 {
|
||||||
return nil, 0, errors.New("internal error: getExternalBlob called with no URLs")
|
return nil, 0, errors.New("internal error: getExternalBlob called with no URLs")
|
||||||
}
|
}
|
||||||
for _, url := range urls {
|
for _, u := range urls {
|
||||||
|
if u, err := url.Parse(u); err != nil || (u.Scheme != "http" && u.Scheme != "https") {
|
||||||
|
continue // unsupported url. skip this url.
|
||||||
|
}
|
||||||
// NOTE: we must not authenticate on additional URLs as those
|
// NOTE: we must not authenticate on additional URLs as those
|
||||||
// can be abused to leak credentials or tokens. Please
|
// can be abused to leak credentials or tokens. Please
|
||||||
// refer to CVE-2020-15157 for more information.
|
// refer to CVE-2020-15157 for more information.
|
||||||
resp, err = s.c.makeRequestToResolvedURL(ctx, http.MethodGet, url, nil, nil, -1, noAuth, nil)
|
resp, err = s.c.makeRequestToResolvedURL(ctx, http.MethodGet, u, nil, nil, -1, noAuth, nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
err = errors.Errorf("error fetching external blob from %q: %d (%s)", url, resp.StatusCode, http.StatusText(resp.StatusCode))
|
err = errors.Errorf("error fetching external blob from %q: %d (%s)", u, resp.StatusCode, http.StatusText(resp.StatusCode))
|
||||||
logrus.Debug(err)
|
logrus.Debug(err)
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
continue
|
continue
|
||||||
@ -259,6 +265,9 @@ func (s *dockerImageSource) getExternalBlob(ctx context.Context, urls []string)
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if resp == nil && err == nil {
|
||||||
|
return nil, 0, nil // fallback to non-external blob
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
@ -408,7 +417,12 @@ func (s *dockerImageSource) GetBlobAt(ctx context.Context, info types.BlobInfo,
|
|||||||
// May update BlobInfoCache, preferably after it knows for certain that a blob truly exists at a specific location.
|
// May update BlobInfoCache, preferably after it knows for certain that a blob truly exists at a specific location.
|
||||||
func (s *dockerImageSource) GetBlob(ctx context.Context, info types.BlobInfo, cache types.BlobInfoCache) (io.ReadCloser, int64, error) {
|
func (s *dockerImageSource) GetBlob(ctx context.Context, info types.BlobInfo, cache types.BlobInfoCache) (io.ReadCloser, int64, error) {
|
||||||
if len(info.URLs) != 0 {
|
if len(info.URLs) != 0 {
|
||||||
return s.getExternalBlob(ctx, info.URLs)
|
r, s, err := s.getExternalBlob(ctx, info.URLs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
} else if r != nil {
|
||||||
|
return r, s, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
path := fmt.Sprintf(blobsPath, reference.Path(s.physicalRef.ref), info.Digest.String())
|
path := fmt.Sprintf(blobsPath, reference.Path(s.physicalRef.ref), info.Digest.String())
|
||||||
|
23
vendor/github.com/containers/image/v5/docker/internal/tarfile/dest.go
generated
vendored
23
vendor/github.com/containers/image/v5/docker/internal/tarfile/dest.go
generated
vendored
@ -5,13 +5,10 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/containers/image/v5/docker/reference"
|
"github.com/containers/image/v5/docker/reference"
|
||||||
"github.com/containers/image/v5/internal/iolimits"
|
"github.com/containers/image/v5/internal/iolimits"
|
||||||
"github.com/containers/image/v5/internal/putblobdigest"
|
"github.com/containers/image/v5/internal/streamdigest"
|
||||||
"github.com/containers/image/v5/internal/tmpdir"
|
|
||||||
"github.com/containers/image/v5/manifest"
|
"github.com/containers/image/v5/manifest"
|
||||||
"github.com/containers/image/v5/types"
|
"github.com/containers/image/v5/types"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
@ -98,25 +95,11 @@ func (d *Destination) PutBlob(ctx context.Context, stream io.Reader, inputInfo t
|
|||||||
// When the layer is decompressed, we also have to generate the digest on uncompressed data.
|
// When the layer is decompressed, we also have to generate the digest on uncompressed data.
|
||||||
if inputInfo.Size == -1 || inputInfo.Digest == "" {
|
if inputInfo.Size == -1 || inputInfo.Digest == "" {
|
||||||
logrus.Debugf("docker tarfile: input with unknown size, streaming to disk first ...")
|
logrus.Debugf("docker tarfile: input with unknown size, streaming to disk first ...")
|
||||||
streamCopy, err := ioutil.TempFile(tmpdir.TemporaryDirectoryForBigFiles(d.sysCtx), "docker-tarfile-blob")
|
streamCopy, cleanup, err := streamdigest.ComputeBlobInfo(d.sysCtx, stream, &inputInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.BlobInfo{}, err
|
return types.BlobInfo{}, err
|
||||||
}
|
}
|
||||||
defer os.Remove(streamCopy.Name())
|
defer cleanup()
|
||||||
defer streamCopy.Close()
|
|
||||||
|
|
||||||
digester, stream2 := putblobdigest.DigestIfUnknown(stream, inputInfo)
|
|
||||||
// TODO: This can take quite some time, and should ideally be cancellable using ctx.Done().
|
|
||||||
size, err := io.Copy(streamCopy, stream2)
|
|
||||||
if err != nil {
|
|
||||||
return types.BlobInfo{}, err
|
|
||||||
}
|
|
||||||
_, err = streamCopy.Seek(0, io.SeekStart)
|
|
||||||
if err != nil {
|
|
||||||
return types.BlobInfo{}, err
|
|
||||||
}
|
|
||||||
inputInfo.Size = size // inputInfo is a struct, so we are only modifying our copy.
|
|
||||||
inputInfo.Digest = digester.Digest()
|
|
||||||
stream = streamCopy
|
stream = streamCopy
|
||||||
logrus.Debugf("... streaming done")
|
logrus.Debugf("... streaming done")
|
||||||
}
|
}
|
||||||
|
41
vendor/github.com/containers/image/v5/internal/streamdigest/stream_digest.go
generated
vendored
Normal file
41
vendor/github.com/containers/image/v5/internal/streamdigest/stream_digest.go
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package streamdigest
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/containers/image/v5/internal/putblobdigest"
|
||||||
|
"github.com/containers/image/v5/internal/tmpdir"
|
||||||
|
"github.com/containers/image/v5/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ComputeBlobInfo streams a blob to a temporary file and populates Digest and Size in inputInfo.
|
||||||
|
// The temporary file is returned as an io.Reader along with a cleanup function.
|
||||||
|
// It is the caller's responsibility to call the cleanup function, which closes and removes the temporary file.
|
||||||
|
// If an error occurs, inputInfo is not modified.
|
||||||
|
func ComputeBlobInfo(sys *types.SystemContext, stream io.Reader, inputInfo *types.BlobInfo) (io.Reader, func(), error) {
|
||||||
|
diskBlob, err := ioutil.TempFile(tmpdir.TemporaryDirectoryForBigFiles(sys), "stream-blob")
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, fmt.Errorf("creating temporary on-disk layer: %w", err)
|
||||||
|
}
|
||||||
|
cleanup := func() {
|
||||||
|
diskBlob.Close()
|
||||||
|
os.Remove(diskBlob.Name())
|
||||||
|
}
|
||||||
|
digester, stream := putblobdigest.DigestIfCanonicalUnknown(stream, *inputInfo)
|
||||||
|
written, err := io.Copy(diskBlob, stream)
|
||||||
|
if err != nil {
|
||||||
|
cleanup()
|
||||||
|
return nil, nil, fmt.Errorf("writing to temporary on-disk layer: %w", err)
|
||||||
|
}
|
||||||
|
_, err = diskBlob.Seek(0, io.SeekStart)
|
||||||
|
if err != nil {
|
||||||
|
cleanup()
|
||||||
|
return nil, nil, fmt.Errorf("rewinding temporary on-disk layer: %w", err)
|
||||||
|
}
|
||||||
|
inputInfo.Digest = digester.Digest()
|
||||||
|
inputInfo.Size = written
|
||||||
|
return diskBlob, cleanup, nil
|
||||||
|
}
|
67
vendor/github.com/containers/image/v5/manifest/common.go
generated
vendored
67
vendor/github.com/containers/image/v5/manifest/common.go
generated
vendored
@ -1,6 +1,7 @@
|
|||||||
package manifest
|
package manifest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
compressiontypes "github.com/containers/image/v5/pkg/compression/types"
|
compressiontypes "github.com/containers/image/v5/pkg/compression/types"
|
||||||
@ -32,6 +33,72 @@ func dupStringStringMap(m map[string]string) map[string]string {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// allowedManifestFields is a bit mask of “essential” manifest fields that validateUnambiguousManifestFormat
|
||||||
|
// can expect to be present.
|
||||||
|
type allowedManifestFields int
|
||||||
|
|
||||||
|
const (
|
||||||
|
allowedFieldConfig allowedManifestFields = 1 << iota
|
||||||
|
allowedFieldFSLayers
|
||||||
|
allowedFieldHistory
|
||||||
|
allowedFieldLayers
|
||||||
|
allowedFieldManifests
|
||||||
|
allowedFieldFirstUnusedBit // Keep this at the end!
|
||||||
|
)
|
||||||
|
|
||||||
|
// validateUnambiguousManifestFormat rejects manifests (incl. multi-arch) that look like more than
|
||||||
|
// one kind we currently recognize, i.e. if they contain any of the known “essential” format fields
|
||||||
|
// other than the ones the caller specifically allows.
|
||||||
|
// expectedMIMEType is used only for diagnostics.
|
||||||
|
// NOTE: The caller should do the non-heuristic validations (e.g. check for any specified format
|
||||||
|
// identification/version, or other “magic numbers”) before calling this, to cleanly reject unambigous
|
||||||
|
// data that just isn’t what was expected, as opposed to actually ambiguous data.
|
||||||
|
func validateUnambiguousManifestFormat(manifest []byte, expectedMIMEType string,
|
||||||
|
allowed allowedManifestFields) error {
|
||||||
|
if allowed >= allowedFieldFirstUnusedBit {
|
||||||
|
return fmt.Errorf("internal error: invalid allowedManifestFields value %#v", allowed)
|
||||||
|
}
|
||||||
|
// Use a private type to decode, not just a map[string]interface{}, because we want
|
||||||
|
// to also reject case-insensitive matches (which would be used by Go when really decoding
|
||||||
|
// the manifest).
|
||||||
|
// (It is expected that as manifest formats are added or extended over time, more fields will be added
|
||||||
|
// here.)
|
||||||
|
detectedFields := struct {
|
||||||
|
Config interface{} `json:"config"`
|
||||||
|
FSLayers interface{} `json:"fsLayers"`
|
||||||
|
History interface{} `json:"history"`
|
||||||
|
Layers interface{} `json:"layers"`
|
||||||
|
Manifests interface{} `json:"manifests"`
|
||||||
|
}{}
|
||||||
|
if err := json.Unmarshal(manifest, &detectedFields); err != nil {
|
||||||
|
// The caller was supposed to already validate version numbers, so this shold not happen;
|
||||||
|
// let’s not bother with making this error “nice”.
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
unexpected := []string{}
|
||||||
|
// Sadly this isn’t easy to automate in Go, without reflection. So, copy&paste.
|
||||||
|
if detectedFields.Config != nil && (allowed&allowedFieldConfig) == 0 {
|
||||||
|
unexpected = append(unexpected, "config")
|
||||||
|
}
|
||||||
|
if detectedFields.FSLayers != nil && (allowed&allowedFieldFSLayers) == 0 {
|
||||||
|
unexpected = append(unexpected, "fsLayers")
|
||||||
|
}
|
||||||
|
if detectedFields.History != nil && (allowed&allowedFieldHistory) == 0 {
|
||||||
|
unexpected = append(unexpected, "history")
|
||||||
|
}
|
||||||
|
if detectedFields.Layers != nil && (allowed&allowedFieldLayers) == 0 {
|
||||||
|
unexpected = append(unexpected, "layers")
|
||||||
|
}
|
||||||
|
if detectedFields.Manifests != nil && (allowed&allowedFieldManifests) == 0 {
|
||||||
|
unexpected = append(unexpected, "manifests")
|
||||||
|
}
|
||||||
|
if len(unexpected) != 0 {
|
||||||
|
return fmt.Errorf(`rejecting ambiguous manifest, unexpected fields %#v in supposedly %s`,
|
||||||
|
unexpected, expectedMIMEType)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// layerInfosToStrings converts a list of layer infos, presumably obtained from a Manifest.LayerInfos()
|
// layerInfosToStrings converts a list of layer infos, presumably obtained from a Manifest.LayerInfos()
|
||||||
// method call, into a format suitable for inclusion in a types.ImageInspectInfo structure.
|
// method call, into a format suitable for inclusion in a types.ImageInspectInfo structure.
|
||||||
func layerInfosToStrings(infos []LayerInfo) []string {
|
func layerInfosToStrings(infos []LayerInfo) []string {
|
||||||
|
4
vendor/github.com/containers/image/v5/manifest/docker_schema1.go
generated
vendored
4
vendor/github.com/containers/image/v5/manifest/docker_schema1.go
generated
vendored
@ -60,6 +60,10 @@ func Schema1FromManifest(manifest []byte) (*Schema1, error) {
|
|||||||
if s1.SchemaVersion != 1 {
|
if s1.SchemaVersion != 1 {
|
||||||
return nil, errors.Errorf("unsupported schema version %d", s1.SchemaVersion)
|
return nil, errors.Errorf("unsupported schema version %d", s1.SchemaVersion)
|
||||||
}
|
}
|
||||||
|
if err := validateUnambiguousManifestFormat(manifest, DockerV2Schema1SignedMediaType,
|
||||||
|
allowedFieldFSLayers|allowedFieldHistory); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if err := s1.initialize(); err != nil {
|
if err := s1.initialize(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
4
vendor/github.com/containers/image/v5/manifest/docker_schema2.go
generated
vendored
4
vendor/github.com/containers/image/v5/manifest/docker_schema2.go
generated
vendored
@ -165,6 +165,10 @@ func Schema2FromManifest(manifest []byte) (*Schema2, error) {
|
|||||||
if err := json.Unmarshal(manifest, &s2); err != nil {
|
if err := json.Unmarshal(manifest, &s2); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if err := validateUnambiguousManifestFormat(manifest, DockerV2Schema2MediaType,
|
||||||
|
allowedFieldConfig|allowedFieldLayers); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
// Check manifest's and layers' media types.
|
// Check manifest's and layers' media types.
|
||||||
if err := SupportedSchema2MediaType(s2.MediaType); err != nil {
|
if err := SupportedSchema2MediaType(s2.MediaType); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
4
vendor/github.com/containers/image/v5/manifest/docker_schema2_list.go
generated
vendored
4
vendor/github.com/containers/image/v5/manifest/docker_schema2_list.go
generated
vendored
@ -192,6 +192,10 @@ func Schema2ListFromManifest(manifest []byte) (*Schema2List, error) {
|
|||||||
if err := json.Unmarshal(manifest, &list); err != nil {
|
if err := json.Unmarshal(manifest, &list); err != nil {
|
||||||
return nil, errors.Wrapf(err, "unmarshaling Schema2List %q", string(manifest))
|
return nil, errors.Wrapf(err, "unmarshaling Schema2List %q", string(manifest))
|
||||||
}
|
}
|
||||||
|
if err := validateUnambiguousManifestFormat(manifest, DockerV2ListMediaType,
|
||||||
|
allowedFieldManifests); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return &list, nil
|
return &list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
vendor/github.com/containers/image/v5/manifest/oci.go
generated
vendored
4
vendor/github.com/containers/image/v5/manifest/oci.go
generated
vendored
@ -54,6 +54,10 @@ func OCI1FromManifest(manifest []byte) (*OCI1, error) {
|
|||||||
if err := json.Unmarshal(manifest, &oci1); err != nil {
|
if err := json.Unmarshal(manifest, &oci1); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if err := validateUnambiguousManifestFormat(manifest, imgspecv1.MediaTypeImageIndex,
|
||||||
|
allowedFieldConfig|allowedFieldLayers); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return &oci1, nil
|
return &oci1, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
vendor/github.com/containers/image/v5/manifest/oci_index.go
generated
vendored
4
vendor/github.com/containers/image/v5/manifest/oci_index.go
generated
vendored
@ -202,6 +202,10 @@ func OCI1IndexFromManifest(manifest []byte) (*OCI1Index, error) {
|
|||||||
if err := json.Unmarshal(manifest, &index); err != nil {
|
if err := json.Unmarshal(manifest, &index); err != nil {
|
||||||
return nil, errors.Wrapf(err, "unmarshaling OCI1Index %q", string(manifest))
|
return nil, errors.Wrapf(err, "unmarshaling OCI1Index %q", string(manifest))
|
||||||
}
|
}
|
||||||
|
if err := validateUnambiguousManifestFormat(manifest, imgspecv1.MediaTypeImageIndex,
|
||||||
|
allowedFieldManifests); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return &index, nil
|
return &index, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
30
vendor/github.com/containers/image/v5/oci/layout/oci_src.go
generated
vendored
30
vendor/github.com/containers/image/v5/oci/layout/oci_src.go
generated
vendored
@ -5,6 +5,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@ -113,7 +114,12 @@ func (s *ociImageSource) HasThreadSafeGetBlob() bool {
|
|||||||
// May update BlobInfoCache, preferably after it knows for certain that a blob truly exists at a specific location.
|
// May update BlobInfoCache, preferably after it knows for certain that a blob truly exists at a specific location.
|
||||||
func (s *ociImageSource) GetBlob(ctx context.Context, info types.BlobInfo, cache types.BlobInfoCache) (io.ReadCloser, int64, error) {
|
func (s *ociImageSource) GetBlob(ctx context.Context, info types.BlobInfo, cache types.BlobInfoCache) (io.ReadCloser, int64, error) {
|
||||||
if len(info.URLs) != 0 {
|
if len(info.URLs) != 0 {
|
||||||
return s.getExternalBlob(ctx, info.URLs)
|
r, s, err := s.getExternalBlob(ctx, info.URLs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
} else if r != nil {
|
||||||
|
return r, s, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
path, err := s.ref.blobPath(info.Digest, s.sharedBlobDir)
|
path, err := s.ref.blobPath(info.Digest, s.sharedBlobDir)
|
||||||
@ -140,34 +146,44 @@ func (s *ociImageSource) GetSignatures(ctx context.Context, instanceDigest *dige
|
|||||||
return [][]byte{}, nil
|
return [][]byte{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getExternalBlob returns the reader of the first available blob URL from urls, which must not be empty.
|
||||||
|
// This function can return nil reader when no url is supported by this function. In this case, the caller
|
||||||
|
// should fallback to fetch the non-external blob (i.e. pull from the registry).
|
||||||
func (s *ociImageSource) getExternalBlob(ctx context.Context, urls []string) (io.ReadCloser, int64, error) {
|
func (s *ociImageSource) getExternalBlob(ctx context.Context, urls []string) (io.ReadCloser, int64, error) {
|
||||||
if len(urls) == 0 {
|
if len(urls) == 0 {
|
||||||
return nil, 0, errors.New("internal error: getExternalBlob called with no URLs")
|
return nil, 0, errors.New("internal error: getExternalBlob called with no URLs")
|
||||||
}
|
}
|
||||||
|
|
||||||
errWrap := errors.New("failed fetching external blob from all urls")
|
errWrap := errors.New("failed fetching external blob from all urls")
|
||||||
for _, url := range urls {
|
hasSupportedURL := false
|
||||||
|
for _, u := range urls {
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
if u, err := url.Parse(u); err != nil || (u.Scheme != "http" && u.Scheme != "https") {
|
||||||
|
continue // unsupported url. skip this url.
|
||||||
|
}
|
||||||
|
hasSupportedURL = true
|
||||||
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errWrap = errors.Wrapf(errWrap, "fetching %s failed %s", url, err.Error())
|
errWrap = errors.Wrapf(errWrap, "fetching %s failed %s", u, err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := s.client.Do(req)
|
resp, err := s.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errWrap = errors.Wrapf(errWrap, "fetching %s failed %s", url, err.Error())
|
errWrap = errors.Wrapf(errWrap, "fetching %s failed %s", u, err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
errWrap = errors.Wrapf(errWrap, "fetching %s failed, response code not 200", url)
|
errWrap = errors.Wrapf(errWrap, "fetching %s failed, response code not 200", u)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.Body, getBlobSize(resp), nil
|
return resp.Body, getBlobSize(resp), nil
|
||||||
}
|
}
|
||||||
|
if !hasSupportedURL {
|
||||||
|
return nil, 0, nil // fallback to non-external blob
|
||||||
|
}
|
||||||
|
|
||||||
return nil, 0, errWrap
|
return nil, 0, errWrap
|
||||||
}
|
}
|
||||||
|
23
vendor/github.com/containers/image/v5/pkg/docker/config/config.go
generated
vendored
23
vendor/github.com/containers/image/v5/pkg/docker/config/config.go
generated
vendored
@ -268,18 +268,18 @@ func getCredentialsWithHomeDir(sys *types.SystemContext, ref reference.Named, re
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Anonymous function to query credentials from auth files.
|
// Anonymous function to query credentials from auth files.
|
||||||
getCredentialsFromAuthFiles := func() (types.DockerAuthConfig, error) {
|
getCredentialsFromAuthFiles := func() (types.DockerAuthConfig, string, error) {
|
||||||
for _, path := range getAuthFilePaths(sys, homeDir) {
|
for _, path := range getAuthFilePaths(sys, homeDir) {
|
||||||
authConfig, err := findAuthentication(ref, registry, path.path, path.legacyFormat)
|
authConfig, err := findAuthentication(ref, registry, path.path, path.legacyFormat)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.DockerAuthConfig{}, err
|
return types.DockerAuthConfig{}, "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
if (authConfig.Username != "" && authConfig.Password != "") || authConfig.IdentityToken != "" {
|
if (authConfig.Username != "" && authConfig.Password != "") || authConfig.IdentityToken != "" {
|
||||||
return authConfig, nil
|
return authConfig, path.path, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return types.DockerAuthConfig{}, nil
|
return types.DockerAuthConfig{}, "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
helpers, err := sysregistriesv2.CredentialHelpers(sys)
|
helpers, err := sysregistriesv2.CredentialHelpers(sys)
|
||||||
@ -289,12 +289,15 @@ func getCredentialsWithHomeDir(sys *types.SystemContext, ref reference.Named, re
|
|||||||
|
|
||||||
var multiErr error
|
var multiErr error
|
||||||
for _, helper := range helpers {
|
for _, helper := range helpers {
|
||||||
var creds types.DockerAuthConfig
|
var (
|
||||||
var err error
|
creds types.DockerAuthConfig
|
||||||
|
credHelperPath string
|
||||||
|
err error
|
||||||
|
)
|
||||||
switch helper {
|
switch helper {
|
||||||
// Special-case the built-in helper for auth files.
|
// Special-case the built-in helper for auth files.
|
||||||
case sysregistriesv2.AuthenticationFileHelper:
|
case sysregistriesv2.AuthenticationFileHelper:
|
||||||
creds, err = getCredentialsFromAuthFiles()
|
creds, credHelperPath, err = getCredentialsFromAuthFiles()
|
||||||
// External helpers.
|
// External helpers.
|
||||||
default:
|
default:
|
||||||
creds, err = getAuthFromCredHelper(helper, registry)
|
creds, err = getAuthFromCredHelper(helper, registry)
|
||||||
@ -307,7 +310,11 @@ func getCredentialsWithHomeDir(sys *types.SystemContext, ref reference.Named, re
|
|||||||
if len(creds.Username)+len(creds.Password)+len(creds.IdentityToken) == 0 {
|
if len(creds.Username)+len(creds.Password)+len(creds.IdentityToken) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
logrus.Debugf("Found credentials for %s in credential helper %s", registry, helper)
|
msg := fmt.Sprintf("Found credentials for %s in credential helper %s", registry, helper)
|
||||||
|
if credHelperPath != "" {
|
||||||
|
msg = fmt.Sprintf("%s in file %s", msg, credHelperPath)
|
||||||
|
}
|
||||||
|
logrus.Debug(msg)
|
||||||
return creds, nil
|
return creds, nil
|
||||||
}
|
}
|
||||||
if multiErr != nil {
|
if multiErr != nil {
|
||||||
|
8
vendor/github.com/containers/image/v5/pkg/sysregistriesv2/system_registries_v2.go
generated
vendored
8
vendor/github.com/containers/image/v5/pkg/sysregistriesv2/system_registries_v2.go
generated
vendored
@ -80,7 +80,7 @@ func (e *Endpoint) rewriteReference(ref reference.Named, prefix string) (referen
|
|||||||
// be dropped.
|
// be dropped.
|
||||||
// https://github.com/containers/image/pull/1191#discussion_r610621608
|
// https://github.com/containers/image/pull/1191#discussion_r610621608
|
||||||
if e.Location == "" {
|
if e.Location == "" {
|
||||||
if prefix[:2] != "*." {
|
if !strings.HasPrefix(prefix, "*.") {
|
||||||
return nil, fmt.Errorf("invalid prefix '%v' for empty location, should be in the format: *.example.com", prefix)
|
return nil, fmt.Errorf("invalid prefix '%v' for empty location, should be in the format: *.example.com", prefix)
|
||||||
}
|
}
|
||||||
return ref, nil
|
return ref, nil
|
||||||
@ -369,7 +369,7 @@ func (config *V2RegistriesConf) postProcessRegistries() error {
|
|||||||
}
|
}
|
||||||
// FIXME: allow config authors to always use Prefix.
|
// FIXME: allow config authors to always use Prefix.
|
||||||
// https://github.com/containers/image/pull/1191#discussion_r610622495
|
// https://github.com/containers/image/pull/1191#discussion_r610622495
|
||||||
if reg.Prefix[:2] != "*." && reg.Location == "" {
|
if !strings.HasPrefix(reg.Prefix, "*.") && reg.Location == "" {
|
||||||
return &InvalidRegistries{s: "invalid condition: location is unset and prefix is not in the format: *.example.com"}
|
return &InvalidRegistries{s: "invalid condition: location is unset and prefix is not in the format: *.example.com"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -804,7 +804,7 @@ func refMatchingSubdomainPrefix(ref, prefix string) int {
|
|||||||
// (This is split from the caller primarily to make testing easier.)
|
// (This is split from the caller primarily to make testing easier.)
|
||||||
func refMatchingPrefix(ref, prefix string) int {
|
func refMatchingPrefix(ref, prefix string) int {
|
||||||
switch {
|
switch {
|
||||||
case prefix[0:2] == "*.":
|
case strings.HasPrefix(prefix, "*."):
|
||||||
return refMatchingSubdomainPrefix(ref, prefix)
|
return refMatchingSubdomainPrefix(ref, prefix)
|
||||||
case len(ref) < len(prefix):
|
case len(ref) < len(prefix):
|
||||||
return -1
|
return -1
|
||||||
@ -924,7 +924,7 @@ func loadConfigFile(path string, forceV2 bool) (*parsedConfig, error) {
|
|||||||
// https://github.com/containers/image/pull/1191#discussion_r610623829
|
// https://github.com/containers/image/pull/1191#discussion_r610623829
|
||||||
for i := range res.partialV2.Registries {
|
for i := range res.partialV2.Registries {
|
||||||
prefix := res.partialV2.Registries[i].Prefix
|
prefix := res.partialV2.Registries[i].Prefix
|
||||||
if prefix[:2] == "*." && strings.ContainsAny(prefix, "/@:") {
|
if strings.HasPrefix(prefix, "*.") && strings.ContainsAny(prefix, "/@:") {
|
||||||
msg := fmt.Sprintf("Wildcarded prefix should be in the format: *.example.com. Current prefix %q is incorrectly formatted", prefix)
|
msg := fmt.Sprintf("Wildcarded prefix should be in the format: *.example.com. Current prefix %q is incorrectly formatted", prefix)
|
||||||
return nil, &InvalidRegistries{s: msg}
|
return nil, &InvalidRegistries{s: msg}
|
||||||
}
|
}
|
||||||
|
2
vendor/github.com/containers/image/v5/storage/storage_transport.go
generated
vendored
2
vendor/github.com/containers/image/v5/storage/storage_transport.go
generated
vendored
@ -225,7 +225,7 @@ func (s *storageTransport) ParseReference(reference string) (types.ImageReferenc
|
|||||||
// needs to match a store that was previously initialized using
|
// needs to match a store that was previously initialized using
|
||||||
// storage.GetStore(), or be enough to let the storage library fill out
|
// storage.GetStore(), or be enough to let the storage library fill out
|
||||||
// the rest using knowledge that it has from elsewhere.
|
// the rest using knowledge that it has from elsewhere.
|
||||||
if reference[0] == '[' {
|
if len(reference) > 0 && reference[0] == '[' {
|
||||||
closeIndex := strings.IndexRune(reference, ']')
|
closeIndex := strings.IndexRune(reference, ']')
|
||||||
if closeIndex < 1 {
|
if closeIndex < 1 {
|
||||||
return nil, ErrInvalidReference
|
return nil, ErrInvalidReference
|
||||||
|
4
vendor/github.com/containers/image/v5/types/types.go
generated
vendored
4
vendor/github.com/containers/image/v5/types/types.go
generated
vendored
@ -622,6 +622,10 @@ type SystemContext struct {
|
|||||||
DockerLogMirrorChoice bool
|
DockerLogMirrorChoice bool
|
||||||
// Directory to use for OSTree temporary files
|
// Directory to use for OSTree temporary files
|
||||||
OSTreeTmpDirPath string
|
OSTreeTmpDirPath string
|
||||||
|
// If true, all blobs will have precomputed digests to ensure layers are not uploaded that already exist on the registry.
|
||||||
|
// Note that this requires writing blobs to temporary files, and takes more time than the default behavior,
|
||||||
|
// when the digest for a blob is unknown.
|
||||||
|
DockerRegistryPushPrecomputeDigests bool
|
||||||
|
|
||||||
// === docker/daemon.Transport overrides ===
|
// === docker/daemon.Transport overrides ===
|
||||||
// A directory containing a CA certificate (ending with ".crt"),
|
// A directory containing a CA certificate (ending with ".crt"),
|
||||||
|
4
vendor/github.com/containers/image/v5/version/version.go
generated
vendored
4
vendor/github.com/containers/image/v5/version/version.go
generated
vendored
@ -6,9 +6,9 @@ const (
|
|||||||
// VersionMajor is for an API incompatible changes
|
// VersionMajor is for an API incompatible changes
|
||||||
VersionMajor = 5
|
VersionMajor = 5
|
||||||
// VersionMinor is for functionality in a backwards-compatible manner
|
// VersionMinor is for functionality in a backwards-compatible manner
|
||||||
VersionMinor = 16
|
VersionMinor = 17
|
||||||
// VersionPatch is for backwards-compatible bug fixes
|
// VersionPatch is for backwards-compatible bug fixes
|
||||||
VersionPatch = 1
|
VersionPatch = 0
|
||||||
|
|
||||||
// VersionDev indicates development branch. Releases will be empty string.
|
// VersionDev indicates development branch. Releases will be empty string.
|
||||||
VersionDev = ""
|
VersionDev = ""
|
||||||
|
191
vendor/github.com/juju/ansiterm/LICENSE
generated
vendored
191
vendor/github.com/juju/ansiterm/LICENSE
generated
vendored
@ -1,191 +0,0 @@
|
|||||||
All files in this repository are licensed as follows. If you contribute
|
|
||||||
to this repository, it is assumed that you license your contribution
|
|
||||||
under the same license unless you state otherwise.
|
|
||||||
|
|
||||||
All files Copyright (C) 2015 Canonical Ltd. unless otherwise specified in the file.
|
|
||||||
|
|
||||||
This software is licensed under the LGPLv3, included below.
|
|
||||||
|
|
||||||
As a special exception to the GNU Lesser General Public License version 3
|
|
||||||
("LGPL3"), the copyright holders of this Library give you permission to
|
|
||||||
convey to a third party a Combined Work that links statically or dynamically
|
|
||||||
to this Library without providing any Minimal Corresponding Source or
|
|
||||||
Minimal Application Code as set out in 4d or providing the installation
|
|
||||||
information set out in section 4e, provided that you comply with the other
|
|
||||||
provisions of LGPL3 and provided that you meet, for the Application the
|
|
||||||
terms and conditions of the license(s) which apply to the Application.
|
|
||||||
|
|
||||||
Except as stated in this special exception, the provisions of LGPL3 will
|
|
||||||
continue to comply in full to this Library. If you modify this Library, you
|
|
||||||
may apply this exception to your version of this Library, but you are not
|
|
||||||
obliged to do so. If you do not wish to do so, delete this exception
|
|
||||||
statement from your version. This exception does not (and cannot) modify any
|
|
||||||
license terms which apply to the Application, with which you must still
|
|
||||||
comply.
|
|
||||||
|
|
||||||
|
|
||||||
GNU LESSER GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
|
|
||||||
This version of the GNU Lesser General Public License incorporates
|
|
||||||
the terms and conditions of version 3 of the GNU General Public
|
|
||||||
License, supplemented by the additional permissions listed below.
|
|
||||||
|
|
||||||
0. Additional Definitions.
|
|
||||||
|
|
||||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
||||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
||||||
General Public License.
|
|
||||||
|
|
||||||
"The Library" refers to a covered work governed by this License,
|
|
||||||
other than an Application or a Combined Work as defined below.
|
|
||||||
|
|
||||||
An "Application" is any work that makes use of an interface provided
|
|
||||||
by the Library, but which is not otherwise based on the Library.
|
|
||||||
Defining a subclass of a class defined by the Library is deemed a mode
|
|
||||||
of using an interface provided by the Library.
|
|
||||||
|
|
||||||
A "Combined Work" is a work produced by combining or linking an
|
|
||||||
Application with the Library. The particular version of the Library
|
|
||||||
with which the Combined Work was made is also called the "Linked
|
|
||||||
Version".
|
|
||||||
|
|
||||||
The "Minimal Corresponding Source" for a Combined Work means the
|
|
||||||
Corresponding Source for the Combined Work, excluding any source code
|
|
||||||
for portions of the Combined Work that, considered in isolation, are
|
|
||||||
based on the Application, and not on the Linked Version.
|
|
||||||
|
|
||||||
The "Corresponding Application Code" for a Combined Work means the
|
|
||||||
object code and/or source code for the Application, including any data
|
|
||||||
and utility programs needed for reproducing the Combined Work from the
|
|
||||||
Application, but excluding the System Libraries of the Combined Work.
|
|
||||||
|
|
||||||
1. Exception to Section 3 of the GNU GPL.
|
|
||||||
|
|
||||||
You may convey a covered work under sections 3 and 4 of this License
|
|
||||||
without being bound by section 3 of the GNU GPL.
|
|
||||||
|
|
||||||
2. Conveying Modified Versions.
|
|
||||||
|
|
||||||
If you modify a copy of the Library, and, in your modifications, a
|
|
||||||
facility refers to a function or data to be supplied by an Application
|
|
||||||
that uses the facility (other than as an argument passed when the
|
|
||||||
facility is invoked), then you may convey a copy of the modified
|
|
||||||
version:
|
|
||||||
|
|
||||||
a) under this License, provided that you make a good faith effort to
|
|
||||||
ensure that, in the event an Application does not supply the
|
|
||||||
function or data, the facility still operates, and performs
|
|
||||||
whatever part of its purpose remains meaningful, or
|
|
||||||
|
|
||||||
b) under the GNU GPL, with none of the additional permissions of
|
|
||||||
this License applicable to that copy.
|
|
||||||
|
|
||||||
3. Object Code Incorporating Material from Library Header Files.
|
|
||||||
|
|
||||||
The object code form of an Application may incorporate material from
|
|
||||||
a header file that is part of the Library. You may convey such object
|
|
||||||
code under terms of your choice, provided that, if the incorporated
|
|
||||||
material is not limited to numerical parameters, data structure
|
|
||||||
layouts and accessors, or small macros, inline functions and templates
|
|
||||||
(ten or fewer lines in length), you do both of the following:
|
|
||||||
|
|
||||||
a) Give prominent notice with each copy of the object code that the
|
|
||||||
Library is used in it and that the Library and its use are
|
|
||||||
covered by this License.
|
|
||||||
|
|
||||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
||||||
document.
|
|
||||||
|
|
||||||
4. Combined Works.
|
|
||||||
|
|
||||||
You may convey a Combined Work under terms of your choice that,
|
|
||||||
taken together, effectively do not restrict modification of the
|
|
||||||
portions of the Library contained in the Combined Work and reverse
|
|
||||||
engineering for debugging such modifications, if you also do each of
|
|
||||||
the following:
|
|
||||||
|
|
||||||
a) Give prominent notice with each copy of the Combined Work that
|
|
||||||
the Library is used in it and that the Library and its use are
|
|
||||||
covered by this License.
|
|
||||||
|
|
||||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
||||||
document.
|
|
||||||
|
|
||||||
c) For a Combined Work that displays copyright notices during
|
|
||||||
execution, include the copyright notice for the Library among
|
|
||||||
these notices, as well as a reference directing the user to the
|
|
||||||
copies of the GNU GPL and this license document.
|
|
||||||
|
|
||||||
d) Do one of the following:
|
|
||||||
|
|
||||||
0) Convey the Minimal Corresponding Source under the terms of this
|
|
||||||
License, and the Corresponding Application Code in a form
|
|
||||||
suitable for, and under terms that permit, the user to
|
|
||||||
recombine or relink the Application with a modified version of
|
|
||||||
the Linked Version to produce a modified Combined Work, in the
|
|
||||||
manner specified by section 6 of the GNU GPL for conveying
|
|
||||||
Corresponding Source.
|
|
||||||
|
|
||||||
1) Use a suitable shared library mechanism for linking with the
|
|
||||||
Library. A suitable mechanism is one that (a) uses at run time
|
|
||||||
a copy of the Library already present on the user's computer
|
|
||||||
system, and (b) will operate properly with a modified version
|
|
||||||
of the Library that is interface-compatible with the Linked
|
|
||||||
Version.
|
|
||||||
|
|
||||||
e) Provide Installation Information, but only if you would otherwise
|
|
||||||
be required to provide such information under section 6 of the
|
|
||||||
GNU GPL, and only to the extent that such information is
|
|
||||||
necessary to install and execute a modified version of the
|
|
||||||
Combined Work produced by recombining or relinking the
|
|
||||||
Application with a modified version of the Linked Version. (If
|
|
||||||
you use option 4d0, the Installation Information must accompany
|
|
||||||
the Minimal Corresponding Source and Corresponding Application
|
|
||||||
Code. If you use option 4d1, you must provide the Installation
|
|
||||||
Information in the manner specified by section 6 of the GNU GPL
|
|
||||||
for conveying Corresponding Source.)
|
|
||||||
|
|
||||||
5. Combined Libraries.
|
|
||||||
|
|
||||||
You may place library facilities that are a work based on the
|
|
||||||
Library side by side in a single library together with other library
|
|
||||||
facilities that are not Applications and are not covered by this
|
|
||||||
License, and convey such a combined library under terms of your
|
|
||||||
choice, if you do both of the following:
|
|
||||||
|
|
||||||
a) Accompany the combined library with a copy of the same work based
|
|
||||||
on the Library, uncombined with any other library facilities,
|
|
||||||
conveyed under the terms of this License.
|
|
||||||
|
|
||||||
b) Give prominent notice with the combined library that part of it
|
|
||||||
is a work based on the Library, and explaining where to find the
|
|
||||||
accompanying uncombined form of the same work.
|
|
||||||
|
|
||||||
6. Revised Versions of the GNU Lesser General Public License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions
|
|
||||||
of the GNU Lesser General Public License from time to time. Such new
|
|
||||||
versions will be similar in spirit to the present version, but may
|
|
||||||
differ in detail to address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Library as you received it specifies that a certain numbered version
|
|
||||||
of the GNU Lesser General Public License "or any later version"
|
|
||||||
applies to it, you have the option of following the terms and
|
|
||||||
conditions either of that published version or of any later version
|
|
||||||
published by the Free Software Foundation. If the Library as you
|
|
||||||
received it does not specify a version number of the GNU Lesser
|
|
||||||
General Public License, you may choose any version of the GNU Lesser
|
|
||||||
General Public License ever published by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Library as you received it specifies that a proxy can decide
|
|
||||||
whether future versions of the GNU Lesser General Public License shall
|
|
||||||
apply, that proxy's public statement of acceptance of any version is
|
|
||||||
permanent authorization for you to choose that version for the
|
|
||||||
Library.
|
|
14
vendor/github.com/juju/ansiterm/Makefile
generated
vendored
14
vendor/github.com/juju/ansiterm/Makefile
generated
vendored
@ -1,14 +0,0 @@
|
|||||||
# Copyright 2016 Canonical Ltd.
|
|
||||||
# Licensed under the LGPLv3, see LICENCE file for details.
|
|
||||||
|
|
||||||
default: check
|
|
||||||
|
|
||||||
check:
|
|
||||||
go test
|
|
||||||
|
|
||||||
docs:
|
|
||||||
godoc2md github.com/juju/ansiterm > README.md
|
|
||||||
sed -i 's|\[godoc-link-here\]|[](https://godoc.org/github.com/juju/ansiterm)|' README.md
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: default check docs
|
|
323
vendor/github.com/juju/ansiterm/README.md
generated
vendored
323
vendor/github.com/juju/ansiterm/README.md
generated
vendored
@ -1,323 +0,0 @@
|
|||||||
|
|
||||||
# ansiterm
|
|
||||||
import "github.com/juju/ansiterm"
|
|
||||||
|
|
||||||
Package ansiterm provides a Writer that writes out the ANSI escape
|
|
||||||
codes for color and styles.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## type Color
|
|
||||||
``` go
|
|
||||||
type Color int
|
|
||||||
```
|
|
||||||
Color represents one of the standard 16 ANSI colors.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
``` go
|
|
||||||
const (
|
|
||||||
Default Color
|
|
||||||
Black
|
|
||||||
Red
|
|
||||||
Green
|
|
||||||
Yellow
|
|
||||||
Blue
|
|
||||||
Magenta
|
|
||||||
Cyan
|
|
||||||
Gray
|
|
||||||
DarkGray
|
|
||||||
BrightRed
|
|
||||||
BrightGreen
|
|
||||||
BrightYellow
|
|
||||||
BrightBlue
|
|
||||||
BrightMagenta
|
|
||||||
BrightCyan
|
|
||||||
White
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func (Color) String
|
|
||||||
``` go
|
|
||||||
func (c Color) String() string
|
|
||||||
```
|
|
||||||
String returns the name of the color.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## type Context
|
|
||||||
``` go
|
|
||||||
type Context struct {
|
|
||||||
Foreground Color
|
|
||||||
Background Color
|
|
||||||
Styles []Style
|
|
||||||
}
|
|
||||||
```
|
|
||||||
Context provides a way to specify both foreground and background colors
|
|
||||||
along with other styles and write text to a Writer with those colors and
|
|
||||||
styles.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func Background
|
|
||||||
``` go
|
|
||||||
func Background(color Color) *Context
|
|
||||||
```
|
|
||||||
Background is a convenience function that creates a Context with the
|
|
||||||
specified color as the background color.
|
|
||||||
|
|
||||||
|
|
||||||
### func Foreground
|
|
||||||
``` go
|
|
||||||
func Foreground(color Color) *Context
|
|
||||||
```
|
|
||||||
Foreground is a convenience function that creates a Context with the
|
|
||||||
specified color as the foreground color.
|
|
||||||
|
|
||||||
|
|
||||||
### func Styles
|
|
||||||
``` go
|
|
||||||
func Styles(styles ...Style) *Context
|
|
||||||
```
|
|
||||||
Styles is a convenience function that creates a Context with the
|
|
||||||
specified styles set.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func (\*Context) Fprint
|
|
||||||
``` go
|
|
||||||
func (c *Context) Fprint(w sgrWriter, args ...interface{})
|
|
||||||
```
|
|
||||||
Fprint will set the sgr values of the writer to the specified foreground,
|
|
||||||
background and styles, then formats using the default formats for its
|
|
||||||
operands and writes to w. Spaces are added between operands when neither is
|
|
||||||
a string. It returns the number of bytes written and any write error
|
|
||||||
encountered.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func (\*Context) Fprintf
|
|
||||||
``` go
|
|
||||||
func (c *Context) Fprintf(w sgrWriter, format string, args ...interface{})
|
|
||||||
```
|
|
||||||
Fprintf will set the sgr values of the writer to the specified
|
|
||||||
foreground, background and styles, then write the formatted string,
|
|
||||||
then reset the writer.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func (\*Context) SetBackground
|
|
||||||
``` go
|
|
||||||
func (c *Context) SetBackground(color Color) *Context
|
|
||||||
```
|
|
||||||
SetBackground sets the background to the specified color.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func (\*Context) SetForeground
|
|
||||||
``` go
|
|
||||||
func (c *Context) SetForeground(color Color) *Context
|
|
||||||
```
|
|
||||||
SetForeground sets the foreground to the specified color.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func (\*Context) SetStyle
|
|
||||||
``` go
|
|
||||||
func (c *Context) SetStyle(styles ...Style) *Context
|
|
||||||
```
|
|
||||||
SetStyle replaces the styles with the new values.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## type Style
|
|
||||||
``` go
|
|
||||||
type Style int
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
``` go
|
|
||||||
const (
|
|
||||||
Bold Style
|
|
||||||
Faint
|
|
||||||
Italic
|
|
||||||
Underline
|
|
||||||
Blink
|
|
||||||
Reverse
|
|
||||||
Strikethrough
|
|
||||||
Conceal
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func (Style) String
|
|
||||||
``` go
|
|
||||||
func (s Style) String() string
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## type TabWriter
|
|
||||||
``` go
|
|
||||||
type TabWriter struct {
|
|
||||||
Writer
|
|
||||||
// contains filtered or unexported fields
|
|
||||||
}
|
|
||||||
```
|
|
||||||
TabWriter is a filter that inserts padding around tab-delimited
|
|
||||||
columns in its input to align them in the output.
|
|
||||||
|
|
||||||
It also setting of colors and styles over and above the standard
|
|
||||||
tabwriter package.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func NewTabWriter
|
|
||||||
``` go
|
|
||||||
func NewTabWriter(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *TabWriter
|
|
||||||
```
|
|
||||||
NewTabWriter returns a writer that is able to set colors and styels.
|
|
||||||
The ansi escape codes are stripped for width calculations.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func (\*TabWriter) Flush
|
|
||||||
``` go
|
|
||||||
func (t *TabWriter) Flush() error
|
|
||||||
```
|
|
||||||
Flush should be called after the last call to Write to ensure
|
|
||||||
that any data buffered in the Writer is written to output. Any
|
|
||||||
incomplete escape sequence at the end is considered
|
|
||||||
complete for formatting purposes.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func (\*TabWriter) Init
|
|
||||||
``` go
|
|
||||||
func (t *TabWriter) Init(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *TabWriter
|
|
||||||
```
|
|
||||||
A Writer must be initialized with a call to Init. The first parameter (output)
|
|
||||||
specifies the filter output. The remaining parameters control the formatting:
|
|
||||||
|
|
||||||
|
|
||||||
minwidth minimal cell width including any padding
|
|
||||||
tabwidth width of tab characters (equivalent number of spaces)
|
|
||||||
padding padding added to a cell before computing its width
|
|
||||||
padchar ASCII char used for padding
|
|
||||||
if padchar == '\t', the Writer will assume that the
|
|
||||||
width of a '\t' in the formatted output is tabwidth,
|
|
||||||
and cells are left-aligned independent of align_left
|
|
||||||
(for correct-looking results, tabwidth must correspond
|
|
||||||
to the tab width in the viewer displaying the result)
|
|
||||||
flags formatting control
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## type Writer
|
|
||||||
``` go
|
|
||||||
type Writer struct {
|
|
||||||
io.Writer
|
|
||||||
// contains filtered or unexported fields
|
|
||||||
}
|
|
||||||
```
|
|
||||||
Writer allows colors and styles to be specified. If the io.Writer
|
|
||||||
is not a terminal capable of color, all attempts to set colors or
|
|
||||||
styles are no-ops.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func NewWriter
|
|
||||||
``` go
|
|
||||||
func NewWriter(w io.Writer) *Writer
|
|
||||||
```
|
|
||||||
NewWriter returns a Writer that allows the caller to specify colors and
|
|
||||||
styles. If the io.Writer is not a terminal capable of color, all attempts
|
|
||||||
to set colors or styles are no-ops.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func (\*Writer) ClearStyle
|
|
||||||
``` go
|
|
||||||
func (w *Writer) ClearStyle(s Style)
|
|
||||||
```
|
|
||||||
ClearStyle clears the text style.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func (\*Writer) Reset
|
|
||||||
``` go
|
|
||||||
func (w *Writer) Reset()
|
|
||||||
```
|
|
||||||
Reset returns the default foreground and background colors with no styles.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func (\*Writer) SetBackground
|
|
||||||
``` go
|
|
||||||
func (w *Writer) SetBackground(c Color)
|
|
||||||
```
|
|
||||||
SetBackground sets the background color.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func (\*Writer) SetForeground
|
|
||||||
``` go
|
|
||||||
func (w *Writer) SetForeground(c Color)
|
|
||||||
```
|
|
||||||
SetForeground sets the foreground color.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### func (\*Writer) SetStyle
|
|
||||||
``` go
|
|
||||||
func (w *Writer) SetStyle(s Style)
|
|
||||||
```
|
|
||||||
SetStyle sets the text style.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- - -
|
|
||||||
Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md)
|
|
50
vendor/github.com/juju/ansiterm/attribute.go
generated
vendored
50
vendor/github.com/juju/ansiterm/attribute.go
generated
vendored
@ -1,50 +0,0 @@
|
|||||||
// Copyright 2016 Canonical Ltd.
|
|
||||||
// Licensed under the LGPLv3, see LICENCE file for details.
|
|
||||||
|
|
||||||
package ansiterm
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"sort"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
type attribute int
|
|
||||||
|
|
||||||
const (
|
|
||||||
unknownAttribute attribute = -1
|
|
||||||
reset attribute = 0
|
|
||||||
)
|
|
||||||
|
|
||||||
// sgr returns the escape sequence for the Select Graphic Rendition
|
|
||||||
// for the attribute.
|
|
||||||
func (a attribute) sgr() string {
|
|
||||||
if a < 0 {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("\x1b[%dm", a)
|
|
||||||
}
|
|
||||||
|
|
||||||
type attributes []attribute
|
|
||||||
|
|
||||||
func (a attributes) Len() int { return len(a) }
|
|
||||||
func (a attributes) Less(i, j int) bool { return a[i] < a[j] }
|
|
||||||
func (a attributes) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
|
||||||
|
|
||||||
// sgr returns the combined escape sequence for the Select Graphic Rendition
|
|
||||||
// for the sequence of attributes.
|
|
||||||
func (a attributes) sgr() string {
|
|
||||||
switch len(a) {
|
|
||||||
case 0:
|
|
||||||
return ""
|
|
||||||
case 1:
|
|
||||||
return a[0].sgr()
|
|
||||||
default:
|
|
||||||
sort.Sort(a)
|
|
||||||
var values []string
|
|
||||||
for _, attr := range a {
|
|
||||||
values = append(values, fmt.Sprint(attr))
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("\x1b[%sm", strings.Join(values, ";"))
|
|
||||||
}
|
|
||||||
}
|
|
119
vendor/github.com/juju/ansiterm/color.go
generated
vendored
119
vendor/github.com/juju/ansiterm/color.go
generated
vendored
@ -1,119 +0,0 @@
|
|||||||
// Copyright 2016 Canonical Ltd.
|
|
||||||
// Licensed under the LGPLv3, see LICENCE file for details.
|
|
||||||
|
|
||||||
package ansiterm
|
|
||||||
|
|
||||||
const (
|
|
||||||
_ Color = iota
|
|
||||||
Default
|
|
||||||
Black
|
|
||||||
Red
|
|
||||||
Green
|
|
||||||
Yellow
|
|
||||||
Blue
|
|
||||||
Magenta
|
|
||||||
Cyan
|
|
||||||
Gray
|
|
||||||
DarkGray
|
|
||||||
BrightRed
|
|
||||||
BrightGreen
|
|
||||||
BrightYellow
|
|
||||||
BrightBlue
|
|
||||||
BrightMagenta
|
|
||||||
BrightCyan
|
|
||||||
White
|
|
||||||
)
|
|
||||||
|
|
||||||
// Color represents one of the standard 16 ANSI colors.
|
|
||||||
type Color int
|
|
||||||
|
|
||||||
// String returns the name of the color.
|
|
||||||
func (c Color) String() string {
|
|
||||||
switch c {
|
|
||||||
case Default:
|
|
||||||
return "default"
|
|
||||||
case Black:
|
|
||||||
return "black"
|
|
||||||
case Red:
|
|
||||||
return "red"
|
|
||||||
case Green:
|
|
||||||
return "green"
|
|
||||||
case Yellow:
|
|
||||||
return "yellow"
|
|
||||||
case Blue:
|
|
||||||
return "blue"
|
|
||||||
case Magenta:
|
|
||||||
return "magenta"
|
|
||||||
case Cyan:
|
|
||||||
return "cyan"
|
|
||||||
case Gray:
|
|
||||||
return "gray"
|
|
||||||
case DarkGray:
|
|
||||||
return "darkgray"
|
|
||||||
case BrightRed:
|
|
||||||
return "brightred"
|
|
||||||
case BrightGreen:
|
|
||||||
return "brightgreen"
|
|
||||||
case BrightYellow:
|
|
||||||
return "brightyellow"
|
|
||||||
case BrightBlue:
|
|
||||||
return "brightblue"
|
|
||||||
case BrightMagenta:
|
|
||||||
return "brightmagenta"
|
|
||||||
case BrightCyan:
|
|
||||||
return "brightcyan"
|
|
||||||
case White:
|
|
||||||
return "white"
|
|
||||||
default:
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c Color) foreground() attribute {
|
|
||||||
switch c {
|
|
||||||
case Default:
|
|
||||||
return 39
|
|
||||||
case Black:
|
|
||||||
return 30
|
|
||||||
case Red:
|
|
||||||
return 31
|
|
||||||
case Green:
|
|
||||||
return 32
|
|
||||||
case Yellow:
|
|
||||||
return 33
|
|
||||||
case Blue:
|
|
||||||
return 34
|
|
||||||
case Magenta:
|
|
||||||
return 35
|
|
||||||
case Cyan:
|
|
||||||
return 36
|
|
||||||
case Gray:
|
|
||||||
return 37
|
|
||||||
case DarkGray:
|
|
||||||
return 90
|
|
||||||
case BrightRed:
|
|
||||||
return 91
|
|
||||||
case BrightGreen:
|
|
||||||
return 92
|
|
||||||
case BrightYellow:
|
|
||||||
return 93
|
|
||||||
case BrightBlue:
|
|
||||||
return 94
|
|
||||||
case BrightMagenta:
|
|
||||||
return 95
|
|
||||||
case BrightCyan:
|
|
||||||
return 96
|
|
||||||
case White:
|
|
||||||
return 97
|
|
||||||
default:
|
|
||||||
return unknownAttribute
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c Color) background() attribute {
|
|
||||||
value := c.foreground()
|
|
||||||
if value != unknownAttribute {
|
|
||||||
return value + 10
|
|
||||||
}
|
|
||||||
return value
|
|
||||||
}
|
|
95
vendor/github.com/juju/ansiterm/context.go
generated
vendored
95
vendor/github.com/juju/ansiterm/context.go
generated
vendored
@ -1,95 +0,0 @@
|
|||||||
// Copyright 2016 Canonical Ltd.
|
|
||||||
// Licensed under the LGPLv3, see LICENCE file for details.
|
|
||||||
|
|
||||||
package ansiterm
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Context provides a way to specify both foreground and background colors
|
|
||||||
// along with other styles and write text to a Writer with those colors and
|
|
||||||
// styles.
|
|
||||||
type Context struct {
|
|
||||||
Foreground Color
|
|
||||||
Background Color
|
|
||||||
Styles []Style
|
|
||||||
}
|
|
||||||
|
|
||||||
// Foreground is a convenience function that creates a Context with the
|
|
||||||
// specified color as the foreground color.
|
|
||||||
func Foreground(color Color) *Context {
|
|
||||||
return &Context{Foreground: color}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Background is a convenience function that creates a Context with the
|
|
||||||
// specified color as the background color.
|
|
||||||
func Background(color Color) *Context {
|
|
||||||
return &Context{Background: color}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Styles is a convenience function that creates a Context with the
|
|
||||||
// specified styles set.
|
|
||||||
func Styles(styles ...Style) *Context {
|
|
||||||
return &Context{Styles: styles}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetForeground sets the foreground to the specified color.
|
|
||||||
func (c *Context) SetForeground(color Color) *Context {
|
|
||||||
c.Foreground = color
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetBackground sets the background to the specified color.
|
|
||||||
func (c *Context) SetBackground(color Color) *Context {
|
|
||||||
c.Background = color
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetStyle replaces the styles with the new values.
|
|
||||||
func (c *Context) SetStyle(styles ...Style) *Context {
|
|
||||||
c.Styles = styles
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
type sgrWriter interface {
|
|
||||||
io.Writer
|
|
||||||
writeSGR(value sgr)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fprintf will set the sgr values of the writer to the specified
|
|
||||||
// foreground, background and styles, then write the formatted string,
|
|
||||||
// then reset the writer.
|
|
||||||
func (c *Context) Fprintf(w sgrWriter, format string, args ...interface{}) {
|
|
||||||
w.writeSGR(c)
|
|
||||||
fmt.Fprintf(w, format, args...)
|
|
||||||
w.writeSGR(reset)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fprint will set the sgr values of the writer to the specified foreground,
|
|
||||||
// background and styles, then formats using the default formats for its
|
|
||||||
// operands and writes to w. Spaces are added between operands when neither is
|
|
||||||
// a string. It returns the number of bytes written and any write error
|
|
||||||
// encountered.
|
|
||||||
func (c *Context) Fprint(w sgrWriter, args ...interface{}) {
|
|
||||||
w.writeSGR(c)
|
|
||||||
fmt.Fprint(w, args...)
|
|
||||||
w.writeSGR(reset)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Context) sgr() string {
|
|
||||||
var values attributes
|
|
||||||
if foreground := c.Foreground.foreground(); foreground != unknownAttribute {
|
|
||||||
values = append(values, foreground)
|
|
||||||
}
|
|
||||||
if background := c.Background.background(); background != unknownAttribute {
|
|
||||||
values = append(values, background)
|
|
||||||
}
|
|
||||||
for _, style := range c.Styles {
|
|
||||||
if value := style.enable(); value != unknownAttribute {
|
|
||||||
values = append(values, value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return values.sgr()
|
|
||||||
}
|
|
6
vendor/github.com/juju/ansiterm/doc.go
generated
vendored
6
vendor/github.com/juju/ansiterm/doc.go
generated
vendored
@ -1,6 +0,0 @@
|
|||||||
// Copyright 2016 Canonical Ltd.
|
|
||||||
// Licensed under the LGPLv3, see LICENCE file for details.
|
|
||||||
|
|
||||||
// Package ansiterm provides a Writer that writes out the ANSI escape
|
|
||||||
// codes for color and styles.
|
|
||||||
package ansiterm
|
|
72
vendor/github.com/juju/ansiterm/style.go
generated
vendored
72
vendor/github.com/juju/ansiterm/style.go
generated
vendored
@ -1,72 +0,0 @@
|
|||||||
// Copyright 2016 Canonical Ltd.
|
|
||||||
// Licensed under the LGPLv3, see LICENCE file for details.
|
|
||||||
|
|
||||||
package ansiterm
|
|
||||||
|
|
||||||
const (
|
|
||||||
_ Style = iota
|
|
||||||
Bold
|
|
||||||
Faint
|
|
||||||
Italic
|
|
||||||
Underline
|
|
||||||
Blink
|
|
||||||
Reverse
|
|
||||||
Strikethrough
|
|
||||||
Conceal
|
|
||||||
)
|
|
||||||
|
|
||||||
type Style int
|
|
||||||
|
|
||||||
func (s Style) String() string {
|
|
||||||
switch s {
|
|
||||||
case Bold:
|
|
||||||
return "bold"
|
|
||||||
case Faint:
|
|
||||||
return "faint"
|
|
||||||
case Italic:
|
|
||||||
return "italic"
|
|
||||||
case Underline:
|
|
||||||
return "underline"
|
|
||||||
case Blink:
|
|
||||||
return "blink"
|
|
||||||
case Reverse:
|
|
||||||
return "reverse"
|
|
||||||
case Strikethrough:
|
|
||||||
return "strikethrough"
|
|
||||||
case Conceal:
|
|
||||||
return "conceal"
|
|
||||||
default:
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Style) enable() attribute {
|
|
||||||
switch s {
|
|
||||||
case Bold:
|
|
||||||
return 1
|
|
||||||
case Faint:
|
|
||||||
return 2
|
|
||||||
case Italic:
|
|
||||||
return 3
|
|
||||||
case Underline:
|
|
||||||
return 4
|
|
||||||
case Blink:
|
|
||||||
return 5
|
|
||||||
case Reverse:
|
|
||||||
return 7
|
|
||||||
case Conceal:
|
|
||||||
return 8
|
|
||||||
case Strikethrough:
|
|
||||||
return 9
|
|
||||||
default:
|
|
||||||
return unknownAttribute
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Style) disable() attribute {
|
|
||||||
value := s.enable()
|
|
||||||
if value != unknownAttribute {
|
|
||||||
return value + 20
|
|
||||||
}
|
|
||||||
return value
|
|
||||||
}
|
|
64
vendor/github.com/juju/ansiterm/tabwriter.go
generated
vendored
64
vendor/github.com/juju/ansiterm/tabwriter.go
generated
vendored
@ -1,64 +0,0 @@
|
|||||||
// Copyright 2016 Canonical Ltd.
|
|
||||||
// Licensed under the LGPLv3, see LICENCE file for details.
|
|
||||||
|
|
||||||
package ansiterm
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
|
|
||||||
"github.com/juju/ansiterm/tabwriter"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewTabWriter returns a writer that is able to set colors and styels.
|
|
||||||
// The ansi escape codes are stripped for width calculations.
|
|
||||||
func NewTabWriter(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *TabWriter {
|
|
||||||
return new(TabWriter).Init(output, minwidth, tabwidth, padding, padchar, flags)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TabWriter is a filter that inserts padding around tab-delimited
|
|
||||||
// columns in its input to align them in the output.
|
|
||||||
//
|
|
||||||
// It also setting of colors and styles over and above the standard
|
|
||||||
// tabwriter package.
|
|
||||||
type TabWriter struct {
|
|
||||||
Writer
|
|
||||||
tw tabwriter.Writer
|
|
||||||
}
|
|
||||||
|
|
||||||
// Flush should be called after the last call to Write to ensure
|
|
||||||
// that any data buffered in the Writer is written to output. Any
|
|
||||||
// incomplete escape sequence at the end is considered
|
|
||||||
// complete for formatting purposes.
|
|
||||||
//
|
|
||||||
func (t *TabWriter) Flush() error {
|
|
||||||
return t.tw.Flush()
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetColumnAlignRight will mark a particular column as align right.
|
|
||||||
// This is reset on the next flush.
|
|
||||||
func (t *TabWriter) SetColumnAlignRight(column int) {
|
|
||||||
t.tw.SetColumnAlignRight(column)
|
|
||||||
}
|
|
||||||
|
|
||||||
// A Writer must be initialized with a call to Init. The first parameter (output)
|
|
||||||
// specifies the filter output. The remaining parameters control the formatting:
|
|
||||||
//
|
|
||||||
// minwidth minimal cell width including any padding
|
|
||||||
// tabwidth width of tab characters (equivalent number of spaces)
|
|
||||||
// padding padding added to a cell before computing its width
|
|
||||||
// padchar ASCII char used for padding
|
|
||||||
// if padchar == '\t', the Writer will assume that the
|
|
||||||
// width of a '\t' in the formatted output is tabwidth,
|
|
||||||
// and cells are left-aligned independent of align_left
|
|
||||||
// (for correct-looking results, tabwidth must correspond
|
|
||||||
// to the tab width in the viewer displaying the result)
|
|
||||||
// flags formatting control
|
|
||||||
//
|
|
||||||
func (t *TabWriter) Init(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *TabWriter {
|
|
||||||
writer, colorCapable := colorEnabledWriter(output)
|
|
||||||
t.Writer = Writer{
|
|
||||||
Writer: t.tw.Init(writer, minwidth, tabwidth, padding, padchar, flags),
|
|
||||||
noColor: !colorCapable,
|
|
||||||
}
|
|
||||||
return t
|
|
||||||
}
|
|
27
vendor/github.com/juju/ansiterm/tabwriter/LICENSE
generated
vendored
27
vendor/github.com/juju/ansiterm/tabwriter/LICENSE
generated
vendored
@ -1,27 +0,0 @@
|
|||||||
Copyright (c) 2012 The Go Authors. All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are
|
|
||||||
met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the following disclaimer
|
|
||||||
in the documentation and/or other materials provided with the
|
|
||||||
distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
contributors may be used to endorse or promote products derived from
|
|
||||||
this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
587
vendor/github.com/juju/ansiterm/tabwriter/tabwriter.go
generated
vendored
587
vendor/github.com/juju/ansiterm/tabwriter/tabwriter.go
generated
vendored
@ -1,587 +0,0 @@
|
|||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// This file is mostly a copy of the go standard library text/tabwriter. With
|
|
||||||
// the additional stripping of ansi control characters for width calculations.
|
|
||||||
|
|
||||||
// Package tabwriter implements a write filter (tabwriter.Writer) that
|
|
||||||
// translates tabbed columns in input into properly aligned text.
|
|
||||||
//
|
|
||||||
// The package is using the Elastic Tabstops algorithm described at
|
|
||||||
// http://nickgravgaard.com/elastictabstops/index.html.
|
|
||||||
//
|
|
||||||
package tabwriter
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"io"
|
|
||||||
"unicode/utf8"
|
|
||||||
|
|
||||||
"github.com/lunixbochs/vtclean"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// Filter implementation
|
|
||||||
|
|
||||||
// A cell represents a segment of text terminated by tabs or line breaks.
|
|
||||||
// The text itself is stored in a separate buffer; cell only describes the
|
|
||||||
// segment's size in bytes, its width in runes, and whether it's an htab
|
|
||||||
// ('\t') terminated cell.
|
|
||||||
//
|
|
||||||
type cell struct {
|
|
||||||
size int // cell size in bytes
|
|
||||||
width int // cell width in runes
|
|
||||||
htab bool // true if the cell is terminated by an htab ('\t')
|
|
||||||
}
|
|
||||||
|
|
||||||
// A Writer is a filter that inserts padding around tab-delimited
|
|
||||||
// columns in its input to align them in the output.
|
|
||||||
//
|
|
||||||
// The Writer treats incoming bytes as UTF-8 encoded text consisting
|
|
||||||
// of cells terminated by (horizontal or vertical) tabs or line
|
|
||||||
// breaks (newline or formfeed characters). Cells in adjacent lines
|
|
||||||
// constitute a column. The Writer inserts padding as needed to
|
|
||||||
// make all cells in a column have the same width, effectively
|
|
||||||
// aligning the columns. It assumes that all characters have the
|
|
||||||
// same width except for tabs for which a tabwidth must be specified.
|
|
||||||
// Note that cells are tab-terminated, not tab-separated: trailing
|
|
||||||
// non-tab text at the end of a line does not form a column cell.
|
|
||||||
//
|
|
||||||
// The Writer assumes that all Unicode code points have the same width;
|
|
||||||
// this may not be true in some fonts.
|
|
||||||
//
|
|
||||||
// If DiscardEmptyColumns is set, empty columns that are terminated
|
|
||||||
// entirely by vertical (or "soft") tabs are discarded. Columns
|
|
||||||
// terminated by horizontal (or "hard") tabs are not affected by
|
|
||||||
// this flag.
|
|
||||||
//
|
|
||||||
// If a Writer is configured to filter HTML, HTML tags and entities
|
|
||||||
// are passed through. The widths of tags and entities are
|
|
||||||
// assumed to be zero (tags) and one (entities) for formatting purposes.
|
|
||||||
//
|
|
||||||
// A segment of text may be escaped by bracketing it with Escape
|
|
||||||
// characters. The tabwriter passes escaped text segments through
|
|
||||||
// unchanged. In particular, it does not interpret any tabs or line
|
|
||||||
// breaks within the segment. If the StripEscape flag is set, the
|
|
||||||
// Escape characters are stripped from the output; otherwise they
|
|
||||||
// are passed through as well. For the purpose of formatting, the
|
|
||||||
// width of the escaped text is always computed excluding the Escape
|
|
||||||
// characters.
|
|
||||||
//
|
|
||||||
// The formfeed character ('\f') acts like a newline but it also
|
|
||||||
// terminates all columns in the current line (effectively calling
|
|
||||||
// Flush). Cells in the next line start new columns. Unless found
|
|
||||||
// inside an HTML tag or inside an escaped text segment, formfeed
|
|
||||||
// characters appear as newlines in the output.
|
|
||||||
//
|
|
||||||
// The Writer must buffer input internally, because proper spacing
|
|
||||||
// of one line may depend on the cells in future lines. Clients must
|
|
||||||
// call Flush when done calling Write.
|
|
||||||
//
|
|
||||||
type Writer struct {
|
|
||||||
// configuration
|
|
||||||
output io.Writer
|
|
||||||
minwidth int
|
|
||||||
tabwidth int
|
|
||||||
padding int
|
|
||||||
padbytes [8]byte
|
|
||||||
flags uint
|
|
||||||
|
|
||||||
// current state
|
|
||||||
buf bytes.Buffer // collected text excluding tabs or line breaks
|
|
||||||
pos int // buffer position up to which cell.width of incomplete cell has been computed
|
|
||||||
cell cell // current incomplete cell; cell.width is up to buf[pos] excluding ignored sections
|
|
||||||
endChar byte // terminating char of escaped sequence (Escape for escapes, '>', ';' for HTML tags/entities, or 0)
|
|
||||||
lines [][]cell // list of lines; each line is a list of cells
|
|
||||||
widths []int // list of column widths in runes - re-used during formatting
|
|
||||||
alignment map[int]uint // column alignment
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *Writer) addLine() { b.lines = append(b.lines, []cell{}) }
|
|
||||||
|
|
||||||
// Reset the current state.
|
|
||||||
func (b *Writer) reset() {
|
|
||||||
b.buf.Reset()
|
|
||||||
b.pos = 0
|
|
||||||
b.cell = cell{}
|
|
||||||
b.endChar = 0
|
|
||||||
b.lines = b.lines[0:0]
|
|
||||||
b.widths = b.widths[0:0]
|
|
||||||
b.alignment = make(map[int]uint)
|
|
||||||
b.addLine()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Internal representation (current state):
|
|
||||||
//
|
|
||||||
// - all text written is appended to buf; tabs and line breaks are stripped away
|
|
||||||
// - at any given time there is a (possibly empty) incomplete cell at the end
|
|
||||||
// (the cell starts after a tab or line break)
|
|
||||||
// - cell.size is the number of bytes belonging to the cell so far
|
|
||||||
// - cell.width is text width in runes of that cell from the start of the cell to
|
|
||||||
// position pos; html tags and entities are excluded from this width if html
|
|
||||||
// filtering is enabled
|
|
||||||
// - the sizes and widths of processed text are kept in the lines list
|
|
||||||
// which contains a list of cells for each line
|
|
||||||
// - the widths list is a temporary list with current widths used during
|
|
||||||
// formatting; it is kept in Writer because it's re-used
|
|
||||||
//
|
|
||||||
// |<---------- size ---------->|
|
|
||||||
// | |
|
|
||||||
// |<- width ->|<- ignored ->| |
|
|
||||||
// | | | |
|
|
||||||
// [---processed---tab------------<tag>...</tag>...]
|
|
||||||
// ^ ^ ^
|
|
||||||
// | | |
|
|
||||||
// buf start of incomplete cell pos
|
|
||||||
|
|
||||||
// Formatting can be controlled with these flags.
|
|
||||||
const (
|
|
||||||
// Ignore html tags and treat entities (starting with '&'
|
|
||||||
// and ending in ';') as single characters (width = 1).
|
|
||||||
FilterHTML uint = 1 << iota
|
|
||||||
|
|
||||||
// Strip Escape characters bracketing escaped text segments
|
|
||||||
// instead of passing them through unchanged with the text.
|
|
||||||
StripEscape
|
|
||||||
|
|
||||||
// Force right-alignment of cell content.
|
|
||||||
// Default is left-alignment.
|
|
||||||
AlignRight
|
|
||||||
|
|
||||||
// Handle empty columns as if they were not present in
|
|
||||||
// the input in the first place.
|
|
||||||
DiscardEmptyColumns
|
|
||||||
|
|
||||||
// Always use tabs for indentation columns (i.e., padding of
|
|
||||||
// leading empty cells on the left) independent of padchar.
|
|
||||||
TabIndent
|
|
||||||
|
|
||||||
// Print a vertical bar ('|') between columns (after formatting).
|
|
||||||
// Discarded columns appear as zero-width columns ("||").
|
|
||||||
Debug
|
|
||||||
)
|
|
||||||
|
|
||||||
// A Writer must be initialized with a call to Init. The first parameter (output)
|
|
||||||
// specifies the filter output. The remaining parameters control the formatting:
|
|
||||||
//
|
|
||||||
// minwidth minimal cell width including any padding
|
|
||||||
// tabwidth width of tab characters (equivalent number of spaces)
|
|
||||||
// padding padding added to a cell before computing its width
|
|
||||||
// padchar ASCII char used for padding
|
|
||||||
// if padchar == '\t', the Writer will assume that the
|
|
||||||
// width of a '\t' in the formatted output is tabwidth,
|
|
||||||
// and cells are left-aligned independent of align_left
|
|
||||||
// (for correct-looking results, tabwidth must correspond
|
|
||||||
// to the tab width in the viewer displaying the result)
|
|
||||||
// flags formatting control
|
|
||||||
//
|
|
||||||
func (b *Writer) Init(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *Writer {
|
|
||||||
if minwidth < 0 || tabwidth < 0 || padding < 0 {
|
|
||||||
panic("negative minwidth, tabwidth, or padding")
|
|
||||||
}
|
|
||||||
b.output = output
|
|
||||||
b.minwidth = minwidth
|
|
||||||
b.tabwidth = tabwidth
|
|
||||||
b.padding = padding
|
|
||||||
for i := range b.padbytes {
|
|
||||||
b.padbytes[i] = padchar
|
|
||||||
}
|
|
||||||
if padchar == '\t' {
|
|
||||||
// tab padding enforces left-alignment
|
|
||||||
flags &^= AlignRight
|
|
||||||
}
|
|
||||||
b.flags = flags
|
|
||||||
|
|
||||||
b.reset()
|
|
||||||
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
// debugging support (keep code around)
|
|
||||||
func (b *Writer) dump() {
|
|
||||||
pos := 0
|
|
||||||
for i, line := range b.lines {
|
|
||||||
print("(", i, ") ")
|
|
||||||
for _, c := range line {
|
|
||||||
print("[", string(b.buf.Bytes()[pos:pos+c.size]), "]")
|
|
||||||
pos += c.size
|
|
||||||
}
|
|
||||||
print("\n")
|
|
||||||
}
|
|
||||||
print("\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
// local error wrapper so we can distinguish errors we want to return
|
|
||||||
// as errors from genuine panics (which we don't want to return as errors)
|
|
||||||
type osError struct {
|
|
||||||
err error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *Writer) write0(buf []byte) {
|
|
||||||
n, err := b.output.Write(buf)
|
|
||||||
if n != len(buf) && err == nil {
|
|
||||||
err = io.ErrShortWrite
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
panic(osError{err})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *Writer) writeN(src []byte, n int) {
|
|
||||||
for n > len(src) {
|
|
||||||
b.write0(src)
|
|
||||||
n -= len(src)
|
|
||||||
}
|
|
||||||
b.write0(src[0:n])
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
newline = []byte{'\n'}
|
|
||||||
tabs = []byte("\t\t\t\t\t\t\t\t")
|
|
||||||
)
|
|
||||||
|
|
||||||
func (b *Writer) writePadding(textw, cellw int, useTabs bool) {
|
|
||||||
if b.padbytes[0] == '\t' || useTabs {
|
|
||||||
// padding is done with tabs
|
|
||||||
if b.tabwidth == 0 {
|
|
||||||
return // tabs have no width - can't do any padding
|
|
||||||
}
|
|
||||||
// make cellw the smallest multiple of b.tabwidth
|
|
||||||
cellw = (cellw + b.tabwidth - 1) / b.tabwidth * b.tabwidth
|
|
||||||
n := cellw - textw // amount of padding
|
|
||||||
if n < 0 {
|
|
||||||
panic("internal error")
|
|
||||||
}
|
|
||||||
b.writeN(tabs, (n+b.tabwidth-1)/b.tabwidth)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// padding is done with non-tab characters
|
|
||||||
b.writeN(b.padbytes[0:], cellw-textw)
|
|
||||||
}
|
|
||||||
|
|
||||||
var vbar = []byte{'|'}
|
|
||||||
|
|
||||||
func (b *Writer) writeLines(pos0 int, line0, line1 int) (pos int) {
|
|
||||||
pos = pos0
|
|
||||||
for i := line0; i < line1; i++ {
|
|
||||||
line := b.lines[i]
|
|
||||||
|
|
||||||
// if TabIndent is set, use tabs to pad leading empty cells
|
|
||||||
useTabs := b.flags&TabIndent != 0
|
|
||||||
|
|
||||||
for j, c := range line {
|
|
||||||
if j > 0 && b.flags&Debug != 0 {
|
|
||||||
// indicate column break
|
|
||||||
b.write0(vbar)
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.size == 0 {
|
|
||||||
// empty cell
|
|
||||||
if j < len(b.widths) {
|
|
||||||
b.writePadding(c.width, b.widths[j], useTabs)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// non-empty cell
|
|
||||||
useTabs = false
|
|
||||||
alignColumnRight := b.alignment[j] == AlignRight
|
|
||||||
if (b.flags&AlignRight == 0) && !alignColumnRight { // align left
|
|
||||||
b.write0(b.buf.Bytes()[pos : pos+c.size])
|
|
||||||
pos += c.size
|
|
||||||
if j < len(b.widths) {
|
|
||||||
b.writePadding(c.width, b.widths[j], false)
|
|
||||||
}
|
|
||||||
} else if alignColumnRight && j < len(b.widths) {
|
|
||||||
// just this column
|
|
||||||
internalSize := b.widths[j] - b.padding
|
|
||||||
if j < len(b.widths) {
|
|
||||||
b.writePadding(c.width, internalSize, false)
|
|
||||||
}
|
|
||||||
b.write0(b.buf.Bytes()[pos : pos+c.size])
|
|
||||||
if b.padding > 0 {
|
|
||||||
b.writePadding(0, b.padding, false)
|
|
||||||
}
|
|
||||||
pos += c.size
|
|
||||||
} else { // align right
|
|
||||||
if j < len(b.widths) {
|
|
||||||
b.writePadding(c.width, b.widths[j], false)
|
|
||||||
}
|
|
||||||
b.write0(b.buf.Bytes()[pos : pos+c.size])
|
|
||||||
pos += c.size
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if i+1 == len(b.lines) {
|
|
||||||
// last buffered line - we don't have a newline, so just write
|
|
||||||
// any outstanding buffered data
|
|
||||||
b.write0(b.buf.Bytes()[pos : pos+b.cell.size])
|
|
||||||
pos += b.cell.size
|
|
||||||
} else {
|
|
||||||
// not the last line - write newline
|
|
||||||
b.write0(newline)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Format the text between line0 and line1 (excluding line1); pos
|
|
||||||
// is the buffer position corresponding to the beginning of line0.
|
|
||||||
// Returns the buffer position corresponding to the beginning of
|
|
||||||
// line1 and an error, if any.
|
|
||||||
//
|
|
||||||
func (b *Writer) format(pos0 int, line0, line1 int) (pos int) {
|
|
||||||
pos = pos0
|
|
||||||
column := len(b.widths)
|
|
||||||
for this := line0; this < line1; this++ {
|
|
||||||
line := b.lines[this]
|
|
||||||
|
|
||||||
if column < len(line)-1 {
|
|
||||||
// cell exists in this column => this line
|
|
||||||
// has more cells than the previous line
|
|
||||||
// (the last cell per line is ignored because cells are
|
|
||||||
// tab-terminated; the last cell per line describes the
|
|
||||||
// text before the newline/formfeed and does not belong
|
|
||||||
// to a column)
|
|
||||||
|
|
||||||
// print unprinted lines until beginning of block
|
|
||||||
pos = b.writeLines(pos, line0, this)
|
|
||||||
line0 = this
|
|
||||||
|
|
||||||
// column block begin
|
|
||||||
width := b.minwidth // minimal column width
|
|
||||||
discardable := true // true if all cells in this column are empty and "soft"
|
|
||||||
for ; this < line1; this++ {
|
|
||||||
line = b.lines[this]
|
|
||||||
if column < len(line)-1 {
|
|
||||||
// cell exists in this column
|
|
||||||
c := line[column]
|
|
||||||
// update width
|
|
||||||
if w := c.width + b.padding; w > width {
|
|
||||||
width = w
|
|
||||||
}
|
|
||||||
// update discardable
|
|
||||||
if c.width > 0 || c.htab {
|
|
||||||
discardable = false
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// column block end
|
|
||||||
|
|
||||||
// discard empty columns if necessary
|
|
||||||
if discardable && b.flags&DiscardEmptyColumns != 0 {
|
|
||||||
width = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// format and print all columns to the right of this column
|
|
||||||
// (we know the widths of this column and all columns to the left)
|
|
||||||
b.widths = append(b.widths, width) // push width
|
|
||||||
pos = b.format(pos, line0, this)
|
|
||||||
b.widths = b.widths[0 : len(b.widths)-1] // pop width
|
|
||||||
line0 = this
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// print unprinted lines until end
|
|
||||||
return b.writeLines(pos, line0, line1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append text to current cell.
|
|
||||||
func (b *Writer) append(text []byte) {
|
|
||||||
b.buf.Write(text)
|
|
||||||
b.cell.size += len(text)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the cell width.
|
|
||||||
func (b *Writer) updateWidth() {
|
|
||||||
// ---- Changes here -----
|
|
||||||
newChars := b.buf.Bytes()[b.pos:b.buf.Len()]
|
|
||||||
cleaned := vtclean.Clean(string(newChars), false) // false to strip colors
|
|
||||||
b.cell.width += utf8.RuneCount([]byte(cleaned))
|
|
||||||
// --- end of changes ----
|
|
||||||
b.pos = b.buf.Len()
|
|
||||||
}
|
|
||||||
|
|
||||||
// To escape a text segment, bracket it with Escape characters.
|
|
||||||
// For instance, the tab in this string "Ignore this tab: \xff\t\xff"
|
|
||||||
// does not terminate a cell and constitutes a single character of
|
|
||||||
// width one for formatting purposes.
|
|
||||||
//
|
|
||||||
// The value 0xff was chosen because it cannot appear in a valid UTF-8 sequence.
|
|
||||||
//
|
|
||||||
const Escape = '\xff'
|
|
||||||
|
|
||||||
// Start escaped mode.
|
|
||||||
func (b *Writer) startEscape(ch byte) {
|
|
||||||
switch ch {
|
|
||||||
case Escape:
|
|
||||||
b.endChar = Escape
|
|
||||||
case '<':
|
|
||||||
b.endChar = '>'
|
|
||||||
case '&':
|
|
||||||
b.endChar = ';'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Terminate escaped mode. If the escaped text was an HTML tag, its width
|
|
||||||
// is assumed to be zero for formatting purposes; if it was an HTML entity,
|
|
||||||
// its width is assumed to be one. In all other cases, the width is the
|
|
||||||
// unicode width of the text.
|
|
||||||
//
|
|
||||||
func (b *Writer) endEscape() {
|
|
||||||
switch b.endChar {
|
|
||||||
case Escape:
|
|
||||||
b.updateWidth()
|
|
||||||
if b.flags&StripEscape == 0 {
|
|
||||||
b.cell.width -= 2 // don't count the Escape chars
|
|
||||||
}
|
|
||||||
case '>': // tag of zero width
|
|
||||||
case ';':
|
|
||||||
b.cell.width++ // entity, count as one rune
|
|
||||||
}
|
|
||||||
b.pos = b.buf.Len()
|
|
||||||
b.endChar = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Terminate the current cell by adding it to the list of cells of the
|
|
||||||
// current line. Returns the number of cells in that line.
|
|
||||||
//
|
|
||||||
func (b *Writer) terminateCell(htab bool) int {
|
|
||||||
b.cell.htab = htab
|
|
||||||
line := &b.lines[len(b.lines)-1]
|
|
||||||
*line = append(*line, b.cell)
|
|
||||||
b.cell = cell{}
|
|
||||||
return len(*line)
|
|
||||||
}
|
|
||||||
|
|
||||||
func handlePanic(err *error, op string) {
|
|
||||||
if e := recover(); e != nil {
|
|
||||||
if nerr, ok := e.(osError); ok {
|
|
||||||
*err = nerr.err
|
|
||||||
return
|
|
||||||
}
|
|
||||||
panic("tabwriter: panic during " + op)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Flush should be called after the last call to Write to ensure
|
|
||||||
// that any data buffered in the Writer is written to output. Any
|
|
||||||
// incomplete escape sequence at the end is considered
|
|
||||||
// complete for formatting purposes.
|
|
||||||
//
|
|
||||||
func (b *Writer) Flush() (err error) {
|
|
||||||
defer b.reset() // even in the presence of errors
|
|
||||||
defer handlePanic(&err, "Flush")
|
|
||||||
|
|
||||||
// add current cell if not empty
|
|
||||||
if b.cell.size > 0 {
|
|
||||||
if b.endChar != 0 {
|
|
||||||
// inside escape - terminate it even if incomplete
|
|
||||||
b.endEscape()
|
|
||||||
}
|
|
||||||
b.terminateCell(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
// format contents of buffer
|
|
||||||
b.format(0, 0, len(b.lines))
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var hbar = []byte("---\n")
|
|
||||||
|
|
||||||
// SetColumnAlignRight will mark a particular column as align right.
|
|
||||||
// This is reset on the next flush.
|
|
||||||
func (b *Writer) SetColumnAlignRight(column int) {
|
|
||||||
b.alignment[column] = AlignRight
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write writes buf to the writer b.
|
|
||||||
// The only errors returned are ones encountered
|
|
||||||
// while writing to the underlying output stream.
|
|
||||||
//
|
|
||||||
func (b *Writer) Write(buf []byte) (n int, err error) {
|
|
||||||
defer handlePanic(&err, "Write")
|
|
||||||
|
|
||||||
// split text into cells
|
|
||||||
n = 0
|
|
||||||
for i, ch := range buf {
|
|
||||||
if b.endChar == 0 {
|
|
||||||
// outside escape
|
|
||||||
switch ch {
|
|
||||||
case '\t', '\v', '\n', '\f':
|
|
||||||
// end of cell
|
|
||||||
b.append(buf[n:i])
|
|
||||||
b.updateWidth()
|
|
||||||
n = i + 1 // ch consumed
|
|
||||||
ncells := b.terminateCell(ch == '\t')
|
|
||||||
if ch == '\n' || ch == '\f' {
|
|
||||||
// terminate line
|
|
||||||
b.addLine()
|
|
||||||
if ch == '\f' || ncells == 1 {
|
|
||||||
// A '\f' always forces a flush. Otherwise, if the previous
|
|
||||||
// line has only one cell which does not have an impact on
|
|
||||||
// the formatting of the following lines (the last cell per
|
|
||||||
// line is ignored by format()), thus we can flush the
|
|
||||||
// Writer contents.
|
|
||||||
if err = b.Flush(); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if ch == '\f' && b.flags&Debug != 0 {
|
|
||||||
// indicate section break
|
|
||||||
b.write0(hbar)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case Escape:
|
|
||||||
// start of escaped sequence
|
|
||||||
b.append(buf[n:i])
|
|
||||||
b.updateWidth()
|
|
||||||
n = i
|
|
||||||
if b.flags&StripEscape != 0 {
|
|
||||||
n++ // strip Escape
|
|
||||||
}
|
|
||||||
b.startEscape(Escape)
|
|
||||||
|
|
||||||
case '<', '&':
|
|
||||||
// possibly an html tag/entity
|
|
||||||
if b.flags&FilterHTML != 0 {
|
|
||||||
// begin of tag/entity
|
|
||||||
b.append(buf[n:i])
|
|
||||||
b.updateWidth()
|
|
||||||
n = i
|
|
||||||
b.startEscape(ch)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// inside escape
|
|
||||||
if ch == b.endChar {
|
|
||||||
// end of tag/entity
|
|
||||||
j := i + 1
|
|
||||||
if ch == Escape && b.flags&StripEscape != 0 {
|
|
||||||
j = i // strip Escape
|
|
||||||
}
|
|
||||||
b.append(buf[n:j])
|
|
||||||
n = i + 1 // ch consumed
|
|
||||||
b.endEscape()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// append leftover text
|
|
||||||
b.append(buf[n:])
|
|
||||||
n = len(buf)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewWriter allocates and initializes a new tabwriter.Writer.
|
|
||||||
// The parameters are the same as for the Init function.
|
|
||||||
//
|
|
||||||
func NewWriter(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *Writer {
|
|
||||||
return new(Writer).Init(output, minwidth, tabwidth, padding, padchar, flags)
|
|
||||||
}
|
|
32
vendor/github.com/juju/ansiterm/terminal.go
generated
vendored
32
vendor/github.com/juju/ansiterm/terminal.go
generated
vendored
@ -1,32 +0,0 @@
|
|||||||
// Copyright 2016 Canonical Ltd.
|
|
||||||
// Licensed under the LGPLv3, see LICENCE file for details.
|
|
||||||
|
|
||||||
package ansiterm
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/mattn/go-colorable"
|
|
||||||
"github.com/mattn/go-isatty"
|
|
||||||
)
|
|
||||||
|
|
||||||
// colorEnabledWriter returns a writer that can handle the ansi color codes
|
|
||||||
// and true if the writer passed in is a terminal capable of color. If the
|
|
||||||
// TERM environment variable is set to "dumb", the terminal is not considered
|
|
||||||
// color capable.
|
|
||||||
func colorEnabledWriter(w io.Writer) (io.Writer, bool) {
|
|
||||||
f, ok := w.(*os.File)
|
|
||||||
if !ok {
|
|
||||||
return w, false
|
|
||||||
}
|
|
||||||
// Check the TERM environment variable specifically
|
|
||||||
// to check for "dumb" terminals.
|
|
||||||
if os.Getenv("TERM") == "dumb" {
|
|
||||||
return w, false
|
|
||||||
}
|
|
||||||
if !isatty.IsTerminal(f.Fd()) {
|
|
||||||
return w, false
|
|
||||||
}
|
|
||||||
return colorable.NewColorable(f), true
|
|
||||||
}
|
|
74
vendor/github.com/juju/ansiterm/writer.go
generated
vendored
74
vendor/github.com/juju/ansiterm/writer.go
generated
vendored
@ -1,74 +0,0 @@
|
|||||||
// Copyright 2016 Canonical Ltd.
|
|
||||||
// Licensed under the LGPLv3, see LICENCE file for details.
|
|
||||||
|
|
||||||
package ansiterm
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Writer allows colors and styles to be specified. If the io.Writer
|
|
||||||
// is not a terminal capable of color, all attempts to set colors or
|
|
||||||
// styles are no-ops.
|
|
||||||
type Writer struct {
|
|
||||||
io.Writer
|
|
||||||
|
|
||||||
noColor bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewWriter returns a Writer that allows the caller to specify colors and
|
|
||||||
// styles. If the io.Writer is not a terminal capable of color, all attempts
|
|
||||||
// to set colors or styles are no-ops.
|
|
||||||
func NewWriter(w io.Writer) *Writer {
|
|
||||||
writer, colorCapable := colorEnabledWriter(w)
|
|
||||||
return &Writer{
|
|
||||||
Writer: writer,
|
|
||||||
noColor: !colorCapable,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetColorCapable forces the writer to either write the ANSI escape color
|
|
||||||
// if capable is true, or to not write them if capable is false.
|
|
||||||
func (w *Writer) SetColorCapable(capable bool) {
|
|
||||||
w.noColor = !capable
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetForeground sets the foreground color.
|
|
||||||
func (w *Writer) SetForeground(c Color) {
|
|
||||||
w.writeSGR(c.foreground())
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetBackground sets the background color.
|
|
||||||
func (w *Writer) SetBackground(c Color) {
|
|
||||||
w.writeSGR(c.background())
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetStyle sets the text style.
|
|
||||||
func (w *Writer) SetStyle(s Style) {
|
|
||||||
w.writeSGR(s.enable())
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClearStyle clears the text style.
|
|
||||||
func (w *Writer) ClearStyle(s Style) {
|
|
||||||
w.writeSGR(s.disable())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset returns the default foreground and background colors with no styles.
|
|
||||||
func (w *Writer) Reset() {
|
|
||||||
w.writeSGR(reset)
|
|
||||||
}
|
|
||||||
|
|
||||||
type sgr interface {
|
|
||||||
// sgr returns the combined escape sequence for the Select Graphic Rendition.
|
|
||||||
sgr() string
|
|
||||||
}
|
|
||||||
|
|
||||||
// writeSGR takes the appropriate integer SGR parameters
|
|
||||||
// and writes out the ANIS escape code.
|
|
||||||
func (w *Writer) writeSGR(value sgr) {
|
|
||||||
if w.noColor {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Fprint(w, value.sgr())
|
|
||||||
}
|
|
9
vendor/github.com/lunixbochs/vtclean/.travis.yml
generated
vendored
9
vendor/github.com/lunixbochs/vtclean/.travis.yml
generated
vendored
@ -1,9 +0,0 @@
|
|||||||
language: go
|
|
||||||
sudo: false
|
|
||||||
|
|
||||||
script: go test -v
|
|
||||||
|
|
||||||
go:
|
|
||||||
- 1.5
|
|
||||||
- 1.6
|
|
||||||
- 1.7
|
|
19
vendor/github.com/lunixbochs/vtclean/LICENSE
generated
vendored
19
vendor/github.com/lunixbochs/vtclean/LICENSE
generated
vendored
@ -1,19 +0,0 @@
|
|||||||
Copyright (c) 2015 Ryan Hileman
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
46
vendor/github.com/lunixbochs/vtclean/README.md
generated
vendored
46
vendor/github.com/lunixbochs/vtclean/README.md
generated
vendored
@ -1,46 +0,0 @@
|
|||||||
[](https://travis-ci.org/lunixbochs/vtclean)
|
|
||||||
|
|
||||||
vtclean
|
|
||||||
----
|
|
||||||
|
|
||||||
Clean up raw terminal output by stripping escape sequences, optionally preserving color.
|
|
||||||
|
|
||||||
Get it: `go get github.com/lunixbochs/vtclean/vtclean`
|
|
||||||
|
|
||||||
API:
|
|
||||||
|
|
||||||
import "github.com/lunixbochs/vtclean"
|
|
||||||
vtclean.Clean(line string, color bool) string
|
|
||||||
|
|
||||||
Command line example:
|
|
||||||
|
|
||||||
$ echo -e '\x1b[1;32mcolor example
|
|
||||||
color forced to stop at end of line
|
|
||||||
backspace is ba\b\bgood
|
|
||||||
no beeps!\x07\x07' | ./vtclean -color
|
|
||||||
|
|
||||||
color example
|
|
||||||
color forced to stop at end of line
|
|
||||||
backspace is good
|
|
||||||
no beeps!
|
|
||||||
|
|
||||||
Go example:
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/lunixbochs/vtclean"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
line := vtclean.Clean(
|
|
||||||
"\033[1;32mcolor, " +
|
|
||||||
"curs\033[Aor, " +
|
|
||||||
"backspace\b\b\b\b\b\b\b\b\b\b\b\033[K", false)
|
|
||||||
fmt.Println(line)
|
|
||||||
}
|
|
||||||
|
|
||||||
Output:
|
|
||||||
|
|
||||||
color, cursor
|
|
93
vendor/github.com/lunixbochs/vtclean/io.go
generated
vendored
93
vendor/github.com/lunixbochs/vtclean/io.go
generated
vendored
@ -1,93 +0,0 @@
|
|||||||
package vtclean
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bufio"
|
|
||||||
"bytes"
|
|
||||||
"io"
|
|
||||||
)
|
|
||||||
|
|
||||||
type reader struct {
|
|
||||||
io.Reader
|
|
||||||
scanner *bufio.Scanner
|
|
||||||
buf []byte
|
|
||||||
|
|
||||||
color bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewReader(r io.Reader, color bool) io.Reader {
|
|
||||||
return &reader{Reader: r, color: color}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *reader) scan() bool {
|
|
||||||
if r.scanner == nil {
|
|
||||||
r.scanner = bufio.NewScanner(r.Reader)
|
|
||||||
}
|
|
||||||
if len(r.buf) > 0 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if r.scanner.Scan() {
|
|
||||||
r.buf = []byte(Clean(r.scanner.Text(), r.color) + "\n")
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *reader) fill(p []byte) int {
|
|
||||||
n := len(r.buf)
|
|
||||||
copy(p, r.buf)
|
|
||||||
if len(p) < len(r.buf) {
|
|
||||||
r.buf = r.buf[len(p):]
|
|
||||||
n = len(p)
|
|
||||||
} else {
|
|
||||||
r.buf = nil
|
|
||||||
}
|
|
||||||
return n
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *reader) Read(p []byte) (int, error) {
|
|
||||||
n := r.fill(p)
|
|
||||||
if n < len(p) {
|
|
||||||
if !r.scan() {
|
|
||||||
if n == 0 {
|
|
||||||
return 0, io.EOF
|
|
||||||
}
|
|
||||||
return n, nil
|
|
||||||
}
|
|
||||||
n += r.fill(p[n:])
|
|
||||||
}
|
|
||||||
return n, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type writer struct {
|
|
||||||
io.Writer
|
|
||||||
buf []byte
|
|
||||||
color bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewWriter(w io.Writer, color bool) io.WriteCloser {
|
|
||||||
return &writer{Writer: w, color: color}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *writer) Write(p []byte) (int, error) {
|
|
||||||
buf := append(w.buf, p...)
|
|
||||||
lines := bytes.Split(buf, []byte("\n"))
|
|
||||||
if len(lines) > 0 {
|
|
||||||
last := len(lines) - 1
|
|
||||||
w.buf = lines[last]
|
|
||||||
count := 0
|
|
||||||
for _, line := range lines[:last] {
|
|
||||||
n, err := w.Writer.Write([]byte(Clean(string(line), w.color) + "\n"))
|
|
||||||
count += n
|
|
||||||
if err != nil {
|
|
||||||
return count, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return len(p), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *writer) Close() error {
|
|
||||||
cl := Clean(string(w.buf), w.color)
|
|
||||||
_, err := w.Writer.Write([]byte(cl))
|
|
||||||
return err
|
|
||||||
}
|
|
113
vendor/github.com/lunixbochs/vtclean/line.go
generated
vendored
113
vendor/github.com/lunixbochs/vtclean/line.go
generated
vendored
@ -1,113 +0,0 @@
|
|||||||
package vtclean
|
|
||||||
|
|
||||||
type char struct {
|
|
||||||
char byte
|
|
||||||
vt100 []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
func chars(p []byte) []char {
|
|
||||||
tmp := make([]char, len(p))
|
|
||||||
for i, v := range p {
|
|
||||||
tmp[i].char = v
|
|
||||||
}
|
|
||||||
return tmp
|
|
||||||
}
|
|
||||||
|
|
||||||
type lineEdit struct {
|
|
||||||
buf []char
|
|
||||||
pos, size int
|
|
||||||
vt100 []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
func newLineEdit(length int) *lineEdit {
|
|
||||||
return &lineEdit{buf: make([]char, length)}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *lineEdit) Vt100(p []byte) {
|
|
||||||
l.vt100 = p
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *lineEdit) Move(x int) {
|
|
||||||
if x < 0 && l.pos <= -x {
|
|
||||||
l.pos = 0
|
|
||||||
} else if x > 0 && l.pos+x > l.size {
|
|
||||||
l.pos = l.size
|
|
||||||
} else {
|
|
||||||
l.pos += x
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *lineEdit) MoveAbs(x int) {
|
|
||||||
if x < l.size {
|
|
||||||
l.pos = x
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *lineEdit) Write(p []byte) {
|
|
||||||
c := chars(p)
|
|
||||||
if len(c) > 0 {
|
|
||||||
c[0].vt100 = l.vt100
|
|
||||||
l.vt100 = nil
|
|
||||||
}
|
|
||||||
if len(l.buf)-l.pos < len(c) {
|
|
||||||
l.buf = append(l.buf[:l.pos], c...)
|
|
||||||
} else {
|
|
||||||
copy(l.buf[l.pos:], c)
|
|
||||||
}
|
|
||||||
l.pos += len(c)
|
|
||||||
if l.pos > l.size {
|
|
||||||
l.size = l.pos
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *lineEdit) Insert(p []byte) {
|
|
||||||
c := chars(p)
|
|
||||||
if len(c) > 0 {
|
|
||||||
c[0].vt100 = l.vt100
|
|
||||||
l.vt100 = nil
|
|
||||||
}
|
|
||||||
l.size += len(c)
|
|
||||||
c = append(c, l.buf[l.pos:]...)
|
|
||||||
l.buf = append(l.buf[:l.pos], c...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *lineEdit) Delete(n int) {
|
|
||||||
most := l.size - l.pos
|
|
||||||
if n > most {
|
|
||||||
n = most
|
|
||||||
}
|
|
||||||
copy(l.buf[l.pos:], l.buf[l.pos+n:])
|
|
||||||
l.size -= n
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *lineEdit) Clear() {
|
|
||||||
for i := 0; i < len(l.buf); i++ {
|
|
||||||
l.buf[i].char = ' '
|
|
||||||
}
|
|
||||||
}
|
|
||||||
func (l *lineEdit) ClearLeft() {
|
|
||||||
for i := 0; i < l.pos+1; i++ {
|
|
||||||
l.buf[i].char = ' '
|
|
||||||
}
|
|
||||||
}
|
|
||||||
func (l *lineEdit) ClearRight() {
|
|
||||||
l.size = l.pos
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *lineEdit) Bytes() []byte {
|
|
||||||
length := 0
|
|
||||||
buf := l.buf[:l.size]
|
|
||||||
for _, v := range buf {
|
|
||||||
length += 1 + len(v.vt100)
|
|
||||||
}
|
|
||||||
tmp := make([]byte, 0, length)
|
|
||||||
for _, v := range buf {
|
|
||||||
tmp = append(tmp, v.vt100...)
|
|
||||||
tmp = append(tmp, v.char)
|
|
||||||
}
|
|
||||||
return tmp
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *lineEdit) String() string {
|
|
||||||
return string(l.Bytes())
|
|
||||||
}
|
|
95
vendor/github.com/lunixbochs/vtclean/vtclean.go
generated
vendored
95
vendor/github.com/lunixbochs/vtclean/vtclean.go
generated
vendored
@ -1,95 +0,0 @@
|
|||||||
package vtclean
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"regexp"
|
|
||||||
"strconv"
|
|
||||||
)
|
|
||||||
|
|
||||||
// regex based on ECMA-48:
|
|
||||||
// 1. optional:
|
|
||||||
// one of [ or ]
|
|
||||||
// any amount of 0x30-0x3f
|
|
||||||
// any amount of 0x20-0x2f
|
|
||||||
// 3. exactly one 0x40-0x7e
|
|
||||||
var vt100re = regexp.MustCompile(`^\033([\[\]]([0-9:;<=>\?]*)([!"#$%&'()*+,\-./]*))?([@A-Z\[\]^_\x60a-z{|}~])`)
|
|
||||||
var vt100exc = regexp.MustCompile(`^\033(\[[^a-zA-Z0-9@\?]+|[\(\)]).`)
|
|
||||||
|
|
||||||
// this is to handle the RGB escape generated by `tput initc 1 500 500 500`
|
|
||||||
var vt100long = regexp.MustCompile(`^\033](\d+);([^\033]+)\033\\`)
|
|
||||||
|
|
||||||
func Clean(line string, color bool) string {
|
|
||||||
var edit = newLineEdit(len(line))
|
|
||||||
lineb := []byte(line)
|
|
||||||
|
|
||||||
hadColor := false
|
|
||||||
for i := 0; i < len(lineb); {
|
|
||||||
c := lineb[i]
|
|
||||||
switch c {
|
|
||||||
case '\r':
|
|
||||||
edit.MoveAbs(0)
|
|
||||||
case '\b':
|
|
||||||
edit.Move(-1)
|
|
||||||
case '\033':
|
|
||||||
// set terminal title
|
|
||||||
if bytes.HasPrefix(lineb[i:], []byte("\x1b]0;")) {
|
|
||||||
pos := bytes.Index(lineb[i:], []byte("\a"))
|
|
||||||
if pos != -1 {
|
|
||||||
i += pos + 1
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if m := vt100long.Find(lineb[i:]); m != nil {
|
|
||||||
i += len(m)
|
|
||||||
} else if m := vt100exc.Find(lineb[i:]); m != nil {
|
|
||||||
i += len(m)
|
|
||||||
} else if m := vt100re.FindSubmatch(lineb[i:]); m != nil {
|
|
||||||
i += len(m[0])
|
|
||||||
num := string(m[2])
|
|
||||||
n, err := strconv.Atoi(num)
|
|
||||||
if err != nil || n > 10000 {
|
|
||||||
n = 1
|
|
||||||
}
|
|
||||||
switch m[4][0] {
|
|
||||||
case 'm':
|
|
||||||
if color {
|
|
||||||
hadColor = true
|
|
||||||
edit.Vt100(m[0])
|
|
||||||
}
|
|
||||||
case '@':
|
|
||||||
edit.Insert(bytes.Repeat([]byte{' '}, n))
|
|
||||||
case 'G':
|
|
||||||
edit.MoveAbs(n)
|
|
||||||
case 'C':
|
|
||||||
edit.Move(n)
|
|
||||||
case 'D':
|
|
||||||
edit.Move(-n)
|
|
||||||
case 'P':
|
|
||||||
edit.Delete(n)
|
|
||||||
case 'K':
|
|
||||||
switch num {
|
|
||||||
case "", "0":
|
|
||||||
edit.ClearRight()
|
|
||||||
case "1":
|
|
||||||
edit.ClearLeft()
|
|
||||||
case "2":
|
|
||||||
edit.Clear()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
i += 1
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
default:
|
|
||||||
if c == '\n' || c == '\t' || c >= ' ' {
|
|
||||||
edit.Write([]byte{c})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i += 1
|
|
||||||
}
|
|
||||||
out := edit.Bytes()
|
|
||||||
if hadColor {
|
|
||||||
out = append(out, []byte("\033[0m")...)
|
|
||||||
}
|
|
||||||
return string(out)
|
|
||||||
}
|
|
7
vendor/github.com/manifoldco/promptui/CHANGELOG.md
generated
vendored
7
vendor/github.com/manifoldco/promptui/CHANGELOG.md
generated
vendored
@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
## [0.9.0] - 2021-10-30
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Resolve license incompatibility in tabwriter
|
||||||
|
|
||||||
|
|
||||||
## [0.8.0] - 2020-09-28
|
## [0.8.0] - 2020-09-28
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
6
vendor/github.com/manifoldco/promptui/go.mod
generated
vendored
6
vendor/github.com/manifoldco/promptui/go.mod
generated
vendored
@ -6,11 +6,5 @@ require (
|
|||||||
github.com/chzyer/logex v1.1.10 // indirect
|
github.com/chzyer/logex v1.1.10 // indirect
|
||||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
|
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
|
||||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect
|
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect
|
||||||
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a
|
|
||||||
github.com/kr/pretty v0.1.0 // indirect
|
|
||||||
github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a // indirect
|
|
||||||
github.com/mattn/go-colorable v0.0.9 // indirect
|
|
||||||
github.com/mattn/go-isatty v0.0.4 // indirect
|
|
||||||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b // indirect
|
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b // indirect
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
|
|
||||||
)
|
)
|
||||||
|
15
vendor/github.com/manifoldco/promptui/go.sum
generated
vendored
15
vendor/github.com/manifoldco/promptui/go.sum
generated
vendored
@ -4,20 +4,5 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5O
|
|||||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=
|
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=
|
||||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||||
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a h1:FaWFmfWdAUKbSCtOU2QjDaorUexogfaMgbipgYATUMU=
|
|
||||||
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a/go.mod h1:UJSiEoRfvx3hP73CvoARgeLjaIOjybY9vj8PUPPFGeU=
|
|
||||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
|
||||||
github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a h1:weJVJJRzAJBFRlAiJQROKQs8oC9vOxvm4rZmBBk0ONw=
|
|
||||||
github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
|
|
||||||
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
|
|
||||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
|
||||||
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
|
|
||||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
|
||||||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b h1:MQE+LT/ABUuuvEZ+YQAMSXindAdUh7slEmAkup74op4=
|
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b h1:MQE+LT/ABUuuvEZ+YQAMSXindAdUh7slEmAkup74op4=
|
||||||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
|
5
vendor/github.com/manifoldco/promptui/select.go
generated
vendored
5
vendor/github.com/manifoldco/promptui/select.go
generated
vendored
@ -5,10 +5,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"text/tabwriter"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/chzyer/readline"
|
"github.com/chzyer/readline"
|
||||||
"github.com/juju/ansiterm"
|
|
||||||
"github.com/manifoldco/promptui/list"
|
"github.com/manifoldco/promptui/list"
|
||||||
"github.com/manifoldco/promptui/screenbuf"
|
"github.com/manifoldco/promptui/screenbuf"
|
||||||
)
|
)
|
||||||
@ -587,7 +587,8 @@ func (s *Select) renderDetails(item interface{}) [][]byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
w := ansiterm.NewTabWriter(&buf, 0, 0, 8, ' ', 0)
|
|
||||||
|
w := tabwriter.NewWriter(&buf, 0, 0, 8, ' ', 0)
|
||||||
|
|
||||||
err := s.Templates.details.Execute(w, item)
|
err := s.Templates.details.Execute(w, item)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
15
vendor/github.com/mattn/go-colorable/.travis.yml
generated
vendored
15
vendor/github.com/mattn/go-colorable/.travis.yml
generated
vendored
@ -1,15 +0,0 @@
|
|||||||
language: go
|
|
||||||
sudo: false
|
|
||||||
go:
|
|
||||||
- 1.13.x
|
|
||||||
- tip
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- go get -t -v ./...
|
|
||||||
|
|
||||||
script:
|
|
||||||
- ./go.test.sh
|
|
||||||
|
|
||||||
after_success:
|
|
||||||
- bash <(curl -s https://codecov.io/bash)
|
|
||||||
|
|
21
vendor/github.com/mattn/go-colorable/LICENSE
generated
vendored
21
vendor/github.com/mattn/go-colorable/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2016 Yasuhiro Matsumoto
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
48
vendor/github.com/mattn/go-colorable/README.md
generated
vendored
48
vendor/github.com/mattn/go-colorable/README.md
generated
vendored
@ -1,48 +0,0 @@
|
|||||||
# go-colorable
|
|
||||||
|
|
||||||
[](https://travis-ci.org/mattn/go-colorable)
|
|
||||||
[](https://codecov.io/gh/mattn/go-colorable)
|
|
||||||
[](http://godoc.org/github.com/mattn/go-colorable)
|
|
||||||
[](https://goreportcard.com/report/mattn/go-colorable)
|
|
||||||
|
|
||||||
Colorable writer for windows.
|
|
||||||
|
|
||||||
For example, most of logger packages doesn't show colors on windows. (I know we can do it with ansicon. But I don't want.)
|
|
||||||
This package is possible to handle escape sequence for ansi color on windows.
|
|
||||||
|
|
||||||
## Too Bad!
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
## So Good!
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```go
|
|
||||||
logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true})
|
|
||||||
logrus.SetOutput(colorable.NewColorableStdout())
|
|
||||||
|
|
||||||
logrus.Info("succeeded")
|
|
||||||
logrus.Warn("not correct")
|
|
||||||
logrus.Error("something error")
|
|
||||||
logrus.Fatal("panic")
|
|
||||||
```
|
|
||||||
|
|
||||||
You can compile above code on non-windows OSs.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
```
|
|
||||||
$ go get github.com/mattn/go-colorable
|
|
||||||
```
|
|
||||||
|
|
||||||
# License
|
|
||||||
|
|
||||||
MIT
|
|
||||||
|
|
||||||
# Author
|
|
||||||
|
|
||||||
Yasuhiro Matsumoto (a.k.a mattn)
|
|
37
vendor/github.com/mattn/go-colorable/colorable_appengine.go
generated
vendored
37
vendor/github.com/mattn/go-colorable/colorable_appengine.go
generated
vendored
@ -1,37 +0,0 @@
|
|||||||
// +build appengine
|
|
||||||
|
|
||||||
package colorable
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
_ "github.com/mattn/go-isatty"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewColorable returns new instance of Writer which handles escape sequence.
|
|
||||||
func NewColorable(file *os.File) io.Writer {
|
|
||||||
if file == nil {
|
|
||||||
panic("nil passed instead of *os.File to NewColorable()")
|
|
||||||
}
|
|
||||||
|
|
||||||
return file
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewColorableStdout returns new instance of Writer which handles escape sequence for stdout.
|
|
||||||
func NewColorableStdout() io.Writer {
|
|
||||||
return os.Stdout
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewColorableStderr returns new instance of Writer which handles escape sequence for stderr.
|
|
||||||
func NewColorableStderr() io.Writer {
|
|
||||||
return os.Stderr
|
|
||||||
}
|
|
||||||
|
|
||||||
// EnableColorsStdout enable colors if possible.
|
|
||||||
func EnableColorsStdout(enabled *bool) func() {
|
|
||||||
if enabled != nil {
|
|
||||||
*enabled = true
|
|
||||||
}
|
|
||||||
return func() {}
|
|
||||||
}
|
|
38
vendor/github.com/mattn/go-colorable/colorable_others.go
generated
vendored
38
vendor/github.com/mattn/go-colorable/colorable_others.go
generated
vendored
@ -1,38 +0,0 @@
|
|||||||
// +build !windows
|
|
||||||
// +build !appengine
|
|
||||||
|
|
||||||
package colorable
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
_ "github.com/mattn/go-isatty"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewColorable returns new instance of Writer which handles escape sequence.
|
|
||||||
func NewColorable(file *os.File) io.Writer {
|
|
||||||
if file == nil {
|
|
||||||
panic("nil passed instead of *os.File to NewColorable()")
|
|
||||||
}
|
|
||||||
|
|
||||||
return file
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewColorableStdout returns new instance of Writer which handles escape sequence for stdout.
|
|
||||||
func NewColorableStdout() io.Writer {
|
|
||||||
return os.Stdout
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewColorableStderr returns new instance of Writer which handles escape sequence for stderr.
|
|
||||||
func NewColorableStderr() io.Writer {
|
|
||||||
return os.Stderr
|
|
||||||
}
|
|
||||||
|
|
||||||
// EnableColorsStdout enable colors if possible.
|
|
||||||
func EnableColorsStdout(enabled *bool) func() {
|
|
||||||
if enabled != nil {
|
|
||||||
*enabled = true
|
|
||||||
}
|
|
||||||
return func() {}
|
|
||||||
}
|
|
1043
vendor/github.com/mattn/go-colorable/colorable_windows.go
generated
vendored
1043
vendor/github.com/mattn/go-colorable/colorable_windows.go
generated
vendored
File diff suppressed because it is too large
Load Diff
8
vendor/github.com/mattn/go-colorable/go.mod
generated
vendored
8
vendor/github.com/mattn/go-colorable/go.mod
generated
vendored
@ -1,8 +0,0 @@
|
|||||||
module github.com/mattn/go-colorable
|
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/mattn/go-isatty v0.0.12
|
|
||||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae // indirect
|
|
||||||
)
|
|
||||||
|
|
||||||
go 1.13
|
|
5
vendor/github.com/mattn/go-colorable/go.sum
generated
vendored
5
vendor/github.com/mattn/go-colorable/go.sum
generated
vendored
@ -1,5 +0,0 @@
|
|||||||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
|
||||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
|
||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8=
|
|
||||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
12
vendor/github.com/mattn/go-colorable/go.test.sh
generated
vendored
12
vendor/github.com/mattn/go-colorable/go.test.sh
generated
vendored
@ -1,12 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
echo "" > coverage.txt
|
|
||||||
|
|
||||||
for d in $(go list ./... | grep -v vendor); do
|
|
||||||
go test -race -coverprofile=profile.out -covermode=atomic "$d"
|
|
||||||
if [ -f profile.out ]; then
|
|
||||||
cat profile.out >> coverage.txt
|
|
||||||
rm profile.out
|
|
||||||
fi
|
|
||||||
done
|
|
55
vendor/github.com/mattn/go-colorable/noncolorable.go
generated
vendored
55
vendor/github.com/mattn/go-colorable/noncolorable.go
generated
vendored
@ -1,55 +0,0 @@
|
|||||||
package colorable
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"io"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NonColorable holds writer but removes escape sequence.
|
|
||||||
type NonColorable struct {
|
|
||||||
out io.Writer
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewNonColorable returns new instance of Writer which removes escape sequence from Writer.
|
|
||||||
func NewNonColorable(w io.Writer) io.Writer {
|
|
||||||
return &NonColorable{out: w}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write writes data on console
|
|
||||||
func (w *NonColorable) Write(data []byte) (n int, err error) {
|
|
||||||
er := bytes.NewReader(data)
|
|
||||||
var bw [1]byte
|
|
||||||
loop:
|
|
||||||
for {
|
|
||||||
c1, err := er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
if c1 != 0x1b {
|
|
||||||
bw[0] = c1
|
|
||||||
w.out.Write(bw[:])
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
c2, err := er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
if c2 != 0x5b {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
var buf bytes.Buffer
|
|
||||||
for {
|
|
||||||
c, err := er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
buf.Write([]byte(string(c)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return len(data), nil
|
|
||||||
}
|
|
43
vendor/golang.org/x/text/internal/language/language.go
generated
vendored
43
vendor/golang.org/x/text/internal/language/language.go
generated
vendored
@ -251,6 +251,13 @@ func (t Tag) Parent() Tag {
|
|||||||
|
|
||||||
// ParseExtension parses s as an extension and returns it on success.
|
// ParseExtension parses s as an extension and returns it on success.
|
||||||
func ParseExtension(s string) (ext string, err error) {
|
func ParseExtension(s string) (ext string, err error) {
|
||||||
|
defer func() {
|
||||||
|
if recover() != nil {
|
||||||
|
ext = ""
|
||||||
|
err = ErrSyntax
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
scan := makeScannerString(s)
|
scan := makeScannerString(s)
|
||||||
var end int
|
var end int
|
||||||
if n := len(scan.token); n != 1 {
|
if n := len(scan.token); n != 1 {
|
||||||
@ -461,7 +468,14 @@ func (t Tag) findTypeForKey(key string) (start, sep, end int, hasExt bool) {
|
|||||||
// ParseBase parses a 2- or 3-letter ISO 639 code.
|
// ParseBase parses a 2- or 3-letter ISO 639 code.
|
||||||
// It returns a ValueError if s is a well-formed but unknown language identifier
|
// It returns a ValueError if s is a well-formed but unknown language identifier
|
||||||
// or another error if another error occurred.
|
// or another error if another error occurred.
|
||||||
func ParseBase(s string) (Language, error) {
|
func ParseBase(s string) (l Language, err error) {
|
||||||
|
defer func() {
|
||||||
|
if recover() != nil {
|
||||||
|
l = 0
|
||||||
|
err = ErrSyntax
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
if n := len(s); n < 2 || 3 < n {
|
if n := len(s); n < 2 || 3 < n {
|
||||||
return 0, ErrSyntax
|
return 0, ErrSyntax
|
||||||
}
|
}
|
||||||
@ -472,7 +486,14 @@ func ParseBase(s string) (Language, error) {
|
|||||||
// ParseScript parses a 4-letter ISO 15924 code.
|
// ParseScript parses a 4-letter ISO 15924 code.
|
||||||
// It returns a ValueError if s is a well-formed but unknown script identifier
|
// It returns a ValueError if s is a well-formed but unknown script identifier
|
||||||
// or another error if another error occurred.
|
// or another error if another error occurred.
|
||||||
func ParseScript(s string) (Script, error) {
|
func ParseScript(s string) (scr Script, err error) {
|
||||||
|
defer func() {
|
||||||
|
if recover() != nil {
|
||||||
|
scr = 0
|
||||||
|
err = ErrSyntax
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
if len(s) != 4 {
|
if len(s) != 4 {
|
||||||
return 0, ErrSyntax
|
return 0, ErrSyntax
|
||||||
}
|
}
|
||||||
@ -489,7 +510,14 @@ func EncodeM49(r int) (Region, error) {
|
|||||||
// ParseRegion parses a 2- or 3-letter ISO 3166-1 or a UN M.49 code.
|
// ParseRegion parses a 2- or 3-letter ISO 3166-1 or a UN M.49 code.
|
||||||
// It returns a ValueError if s is a well-formed but unknown region identifier
|
// It returns a ValueError if s is a well-formed but unknown region identifier
|
||||||
// or another error if another error occurred.
|
// or another error if another error occurred.
|
||||||
func ParseRegion(s string) (Region, error) {
|
func ParseRegion(s string) (r Region, err error) {
|
||||||
|
defer func() {
|
||||||
|
if recover() != nil {
|
||||||
|
r = 0
|
||||||
|
err = ErrSyntax
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
if n := len(s); n < 2 || 3 < n {
|
if n := len(s); n < 2 || 3 < n {
|
||||||
return 0, ErrSyntax
|
return 0, ErrSyntax
|
||||||
}
|
}
|
||||||
@ -578,7 +606,14 @@ type Variant struct {
|
|||||||
|
|
||||||
// ParseVariant parses and returns a Variant. An error is returned if s is not
|
// ParseVariant parses and returns a Variant. An error is returned if s is not
|
||||||
// a valid variant.
|
// a valid variant.
|
||||||
func ParseVariant(s string) (Variant, error) {
|
func ParseVariant(s string) (v Variant, err error) {
|
||||||
|
defer func() {
|
||||||
|
if recover() != nil {
|
||||||
|
v = Variant{}
|
||||||
|
err = ErrSyntax
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
s = strings.ToLower(s)
|
s = strings.ToLower(s)
|
||||||
if id, ok := variantIndex[s]; ok {
|
if id, ok := variantIndex[s]; ok {
|
||||||
return Variant{id, s}, nil
|
return Variant{id, s}, nil
|
||||||
|
7
vendor/golang.org/x/text/internal/language/parse.go
generated
vendored
7
vendor/golang.org/x/text/internal/language/parse.go
generated
vendored
@ -232,6 +232,13 @@ func Parse(s string) (t Tag, err error) {
|
|||||||
if s == "" {
|
if s == "" {
|
||||||
return Und, ErrSyntax
|
return Und, ErrSyntax
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
if recover() != nil {
|
||||||
|
t = Und
|
||||||
|
err = ErrSyntax
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
if len(s) <= maxAltTaglen {
|
if len(s) <= maxAltTaglen {
|
||||||
b := [maxAltTaglen]byte{}
|
b := [maxAltTaglen]byte{}
|
||||||
for i, c := range s {
|
for i, c := range s {
|
||||||
|
22
vendor/golang.org/x/text/language/parse.go
generated
vendored
22
vendor/golang.org/x/text/language/parse.go
generated
vendored
@ -43,6 +43,13 @@ func Parse(s string) (t Tag, err error) {
|
|||||||
// https://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers.
|
// https://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers.
|
||||||
// The resulting tag is canonicalized using the canonicalization type c.
|
// The resulting tag is canonicalized using the canonicalization type c.
|
||||||
func (c CanonType) Parse(s string) (t Tag, err error) {
|
func (c CanonType) Parse(s string) (t Tag, err error) {
|
||||||
|
defer func() {
|
||||||
|
if recover() != nil {
|
||||||
|
t = Tag{}
|
||||||
|
err = language.ErrSyntax
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
tt, err := language.Parse(s)
|
tt, err := language.Parse(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return makeTag(tt), err
|
return makeTag(tt), err
|
||||||
@ -79,6 +86,13 @@ func Compose(part ...interface{}) (t Tag, err error) {
|
|||||||
// tag is returned after canonicalizing using CanonType c. If one or more errors
|
// tag is returned after canonicalizing using CanonType c. If one or more errors
|
||||||
// are encountered, one of the errors is returned.
|
// are encountered, one of the errors is returned.
|
||||||
func (c CanonType) Compose(part ...interface{}) (t Tag, err error) {
|
func (c CanonType) Compose(part ...interface{}) (t Tag, err error) {
|
||||||
|
defer func() {
|
||||||
|
if recover() != nil {
|
||||||
|
t = Tag{}
|
||||||
|
err = language.ErrSyntax
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
var b language.Builder
|
var b language.Builder
|
||||||
if err = update(&b, part...); err != nil {
|
if err = update(&b, part...); err != nil {
|
||||||
return und, err
|
return und, err
|
||||||
@ -142,6 +156,14 @@ var errInvalidWeight = errors.New("ParseAcceptLanguage: invalid weight")
|
|||||||
// Tags with a weight of zero will be dropped. An error will be returned if the
|
// Tags with a weight of zero will be dropped. An error will be returned if the
|
||||||
// input could not be parsed.
|
// input could not be parsed.
|
||||||
func ParseAcceptLanguage(s string) (tag []Tag, q []float32, err error) {
|
func ParseAcceptLanguage(s string) (tag []Tag, q []float32, err error) {
|
||||||
|
defer func() {
|
||||||
|
if recover() != nil {
|
||||||
|
tag = nil
|
||||||
|
q = nil
|
||||||
|
err = language.ErrSyntax
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
var entry string
|
var entry string
|
||||||
for s != "" {
|
for s != "" {
|
||||||
if entry, s = split(s, ','); entry == "" {
|
if entry, s = split(s, ','); entry == "" {
|
||||||
|
9
vendor/google.golang.org/genproto/googleapis/rpc/status/status.pb.go
generated
vendored
9
vendor/google.golang.org/genproto/googleapis/rpc/status/status.pb.go
generated
vendored
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.25.0
|
// protoc-gen-go v1.26.0
|
||||||
// protoc v3.13.0
|
// protoc v3.12.2
|
||||||
// source: google/rpc/status.proto
|
// source: google/rpc/status.proto
|
||||||
|
|
||||||
package status
|
package status
|
||||||
@ -24,7 +24,6 @@ import (
|
|||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
|
|
||||||
proto "github.com/golang/protobuf/proto"
|
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
anypb "google.golang.org/protobuf/types/known/anypb"
|
anypb "google.golang.org/protobuf/types/known/anypb"
|
||||||
@ -37,10 +36,6 @@ const (
|
|||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
)
|
)
|
||||||
|
|
||||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
|
||||||
// of the legacy proto package is being used.
|
|
||||||
const _ = proto.ProtoPackageIsVersion4
|
|
||||||
|
|
||||||
// The `Status` type defines a logical error model that is suitable for
|
// The `Status` type defines a logical error model that is suitable for
|
||||||
// different programming environments, including REST APIs and RPC APIs. It is
|
// different programming environments, including REST APIs and RPC APIs. It is
|
||||||
// used by [gRPC](https://github.com/grpc). Each `Status` message contains
|
// used by [gRPC](https://github.com/grpc). Each `Status` message contains
|
||||||
|
5
vendor/google.golang.org/grpc/MAINTAINERS.md
generated
vendored
5
vendor/google.golang.org/grpc/MAINTAINERS.md
generated
vendored
@ -8,17 +8,18 @@ See [CONTRIBUTING.md](https://github.com/grpc/grpc-community/blob/master/CONTRIB
|
|||||||
for general contribution guidelines.
|
for general contribution guidelines.
|
||||||
|
|
||||||
## Maintainers (in alphabetical order)
|
## Maintainers (in alphabetical order)
|
||||||
- [canguler](https://github.com/canguler), Google LLC
|
|
||||||
- [cesarghali](https://github.com/cesarghali), Google LLC
|
- [cesarghali](https://github.com/cesarghali), Google LLC
|
||||||
- [dfawley](https://github.com/dfawley), Google LLC
|
- [dfawley](https://github.com/dfawley), Google LLC
|
||||||
- [easwars](https://github.com/easwars), Google LLC
|
- [easwars](https://github.com/easwars), Google LLC
|
||||||
- [jadekler](https://github.com/jadekler), Google LLC
|
|
||||||
- [menghanl](https://github.com/menghanl), Google LLC
|
- [menghanl](https://github.com/menghanl), Google LLC
|
||||||
- [srini100](https://github.com/srini100), Google LLC
|
- [srini100](https://github.com/srini100), Google LLC
|
||||||
|
|
||||||
## Emeritus Maintainers (in alphabetical order)
|
## Emeritus Maintainers (in alphabetical order)
|
||||||
- [adelez](https://github.com/adelez), Google LLC
|
- [adelez](https://github.com/adelez), Google LLC
|
||||||
|
- [canguler](https://github.com/canguler), Google LLC
|
||||||
- [iamqizhao](https://github.com/iamqizhao), Google LLC
|
- [iamqizhao](https://github.com/iamqizhao), Google LLC
|
||||||
|
- [jadekler](https://github.com/jadekler), Google LLC
|
||||||
- [jtattermusch](https://github.com/jtattermusch), Google LLC
|
- [jtattermusch](https://github.com/jtattermusch), Google LLC
|
||||||
- [lyuxuan](https://github.com/lyuxuan), Google LLC
|
- [lyuxuan](https://github.com/lyuxuan), Google LLC
|
||||||
- [makmukhi](https://github.com/makmukhi), Google LLC
|
- [makmukhi](https://github.com/makmukhi), Google LLC
|
||||||
|
2
vendor/google.golang.org/grpc/Makefile
generated
vendored
2
vendor/google.golang.org/grpc/Makefile
generated
vendored
@ -41,8 +41,6 @@ vetdeps:
|
|||||||
clean \
|
clean \
|
||||||
proto \
|
proto \
|
||||||
test \
|
test \
|
||||||
testappengine \
|
|
||||||
testappenginedeps \
|
|
||||||
testrace \
|
testrace \
|
||||||
vet \
|
vet \
|
||||||
vetdeps
|
vetdeps
|
||||||
|
13
vendor/google.golang.org/grpc/NOTICE.txt
generated
vendored
Normal file
13
vendor/google.golang.org/grpc/NOTICE.txt
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
Copyright 2014 gRPC authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
68
vendor/google.golang.org/grpc/balancer/balancer.go
generated
vendored
68
vendor/google.golang.org/grpc/balancer/balancer.go
generated
vendored
@ -75,24 +75,26 @@ func Get(name string) Builder {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SubConn represents a gRPC sub connection.
|
// A SubConn represents a single connection to a gRPC backend service.
|
||||||
// Each sub connection contains a list of addresses. gRPC will
|
|
||||||
// try to connect to them (in sequence), and stop trying the
|
|
||||||
// remainder once one connection is successful.
|
|
||||||
//
|
//
|
||||||
// The reconnect backoff will be applied on the list, not a single address.
|
// Each SubConn contains a list of addresses.
|
||||||
// For example, try_on_all_addresses -> backoff -> try_on_all_addresses.
|
|
||||||
//
|
//
|
||||||
// All SubConns start in IDLE, and will not try to connect. To trigger
|
// All SubConns start in IDLE, and will not try to connect. To trigger the
|
||||||
// the connecting, Balancers must call Connect.
|
// connecting, Balancers must call Connect. If a connection re-enters IDLE,
|
||||||
// When the connection encounters an error, it will reconnect immediately.
|
// Balancers must call Connect again to trigger a new connection attempt.
|
||||||
// When the connection becomes IDLE, it will not reconnect unless Connect is
|
|
||||||
// called.
|
|
||||||
//
|
//
|
||||||
// This interface is to be implemented by gRPC. Users should not need a
|
// gRPC will try to connect to the addresses in sequence, and stop trying the
|
||||||
// brand new implementation of this interface. For the situations like
|
// remainder once the first connection is successful. If an attempt to connect
|
||||||
// testing, the new implementation should embed this interface. This allows
|
// to all addresses encounters an error, the SubConn will enter
|
||||||
// gRPC to add new methods to this interface.
|
// TRANSIENT_FAILURE for a backoff period, and then transition to IDLE.
|
||||||
|
//
|
||||||
|
// Once established, if a connection is lost, the SubConn will transition
|
||||||
|
// directly to IDLE.
|
||||||
|
//
|
||||||
|
// This interface is to be implemented by gRPC. Users should not need their own
|
||||||
|
// implementation of this interface. For situations like testing, any
|
||||||
|
// implementations should embed this interface. This allows gRPC to add new
|
||||||
|
// methods to this interface.
|
||||||
type SubConn interface {
|
type SubConn interface {
|
||||||
// UpdateAddresses updates the addresses used in this SubConn.
|
// UpdateAddresses updates the addresses used in this SubConn.
|
||||||
// gRPC checks if currently-connected address is still in the new list.
|
// gRPC checks if currently-connected address is still in the new list.
|
||||||
@ -326,6 +328,20 @@ type Balancer interface {
|
|||||||
Close()
|
Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExitIdler is an optional interface for balancers to implement. If
|
||||||
|
// implemented, ExitIdle will be called when ClientConn.Connect is called, if
|
||||||
|
// the ClientConn is idle. If unimplemented, ClientConn.Connect will cause
|
||||||
|
// all SubConns to connect.
|
||||||
|
//
|
||||||
|
// Notice: it will be required for all balancers to implement this in a future
|
||||||
|
// release.
|
||||||
|
type ExitIdler interface {
|
||||||
|
// ExitIdle instructs the LB policy to reconnect to backends / exit the
|
||||||
|
// IDLE state, if appropriate and possible. Note that SubConns that enter
|
||||||
|
// the IDLE state will not reconnect until SubConn.Connect is called.
|
||||||
|
ExitIdle()
|
||||||
|
}
|
||||||
|
|
||||||
// SubConnState describes the state of a SubConn.
|
// SubConnState describes the state of a SubConn.
|
||||||
type SubConnState struct {
|
type SubConnState struct {
|
||||||
// ConnectivityState is the connectivity state of the SubConn.
|
// ConnectivityState is the connectivity state of the SubConn.
|
||||||
@ -353,8 +369,10 @@ var ErrBadResolverState = errors.New("bad resolver state")
|
|||||||
//
|
//
|
||||||
// It's not thread safe.
|
// It's not thread safe.
|
||||||
type ConnectivityStateEvaluator struct {
|
type ConnectivityStateEvaluator struct {
|
||||||
numReady uint64 // Number of addrConns in ready state.
|
numReady uint64 // Number of addrConns in ready state.
|
||||||
numConnecting uint64 // Number of addrConns in connecting state.
|
numConnecting uint64 // Number of addrConns in connecting state.
|
||||||
|
numTransientFailure uint64 // Number of addrConns in transient failure state.
|
||||||
|
numIdle uint64 // Number of addrConns in idle state.
|
||||||
}
|
}
|
||||||
|
|
||||||
// RecordTransition records state change happening in subConn and based on that
|
// RecordTransition records state change happening in subConn and based on that
|
||||||
@ -362,9 +380,11 @@ type ConnectivityStateEvaluator struct {
|
|||||||
//
|
//
|
||||||
// - If at least one SubConn in Ready, the aggregated state is Ready;
|
// - If at least one SubConn in Ready, the aggregated state is Ready;
|
||||||
// - Else if at least one SubConn in Connecting, the aggregated state is Connecting;
|
// - Else if at least one SubConn in Connecting, the aggregated state is Connecting;
|
||||||
// - Else the aggregated state is TransientFailure.
|
// - Else if at least one SubConn is TransientFailure, the aggregated state is Transient Failure;
|
||||||
|
// - Else if at least one SubConn is Idle, the aggregated state is Idle;
|
||||||
|
// - Else there are no subconns and the aggregated state is Transient Failure
|
||||||
//
|
//
|
||||||
// Idle and Shutdown are not considered.
|
// Shutdown is not considered.
|
||||||
func (cse *ConnectivityStateEvaluator) RecordTransition(oldState, newState connectivity.State) connectivity.State {
|
func (cse *ConnectivityStateEvaluator) RecordTransition(oldState, newState connectivity.State) connectivity.State {
|
||||||
// Update counters.
|
// Update counters.
|
||||||
for idx, state := range []connectivity.State{oldState, newState} {
|
for idx, state := range []connectivity.State{oldState, newState} {
|
||||||
@ -374,6 +394,10 @@ func (cse *ConnectivityStateEvaluator) RecordTransition(oldState, newState conne
|
|||||||
cse.numReady += updateVal
|
cse.numReady += updateVal
|
||||||
case connectivity.Connecting:
|
case connectivity.Connecting:
|
||||||
cse.numConnecting += updateVal
|
cse.numConnecting += updateVal
|
||||||
|
case connectivity.TransientFailure:
|
||||||
|
cse.numTransientFailure += updateVal
|
||||||
|
case connectivity.Idle:
|
||||||
|
cse.numIdle += updateVal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,5 +408,11 @@ func (cse *ConnectivityStateEvaluator) RecordTransition(oldState, newState conne
|
|||||||
if cse.numConnecting > 0 {
|
if cse.numConnecting > 0 {
|
||||||
return connectivity.Connecting
|
return connectivity.Connecting
|
||||||
}
|
}
|
||||||
|
if cse.numTransientFailure > 0 {
|
||||||
|
return connectivity.TransientFailure
|
||||||
|
}
|
||||||
|
if cse.numIdle > 0 {
|
||||||
|
return connectivity.Idle
|
||||||
|
}
|
||||||
return connectivity.TransientFailure
|
return connectivity.TransientFailure
|
||||||
}
|
}
|
||||||
|
15
vendor/google.golang.org/grpc/balancer/base/balancer.go
generated
vendored
15
vendor/google.golang.org/grpc/balancer/base/balancer.go
generated
vendored
@ -133,6 +133,7 @@ func (b *baseBalancer) UpdateClientConnState(s balancer.ClientConnState) error {
|
|||||||
}
|
}
|
||||||
b.subConns[aNoAttrs] = subConnInfo{subConn: sc, attrs: a.Attributes}
|
b.subConns[aNoAttrs] = subConnInfo{subConn: sc, attrs: a.Attributes}
|
||||||
b.scStates[sc] = connectivity.Idle
|
b.scStates[sc] = connectivity.Idle
|
||||||
|
b.csEvltr.RecordTransition(connectivity.Shutdown, connectivity.Idle)
|
||||||
sc.Connect()
|
sc.Connect()
|
||||||
} else {
|
} else {
|
||||||
// Always update the subconn's address in case the attributes
|
// Always update the subconn's address in case the attributes
|
||||||
@ -213,10 +214,14 @@ func (b *baseBalancer) UpdateSubConnState(sc balancer.SubConn, state balancer.Su
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if oldS == connectivity.TransientFailure && s == connectivity.Connecting {
|
if oldS == connectivity.TransientFailure &&
|
||||||
// Once a subconn enters TRANSIENT_FAILURE, ignore subsequent
|
(s == connectivity.Connecting || s == connectivity.Idle) {
|
||||||
|
// Once a subconn enters TRANSIENT_FAILURE, ignore subsequent IDLE or
|
||||||
// CONNECTING transitions to prevent the aggregated state from being
|
// CONNECTING transitions to prevent the aggregated state from being
|
||||||
// always CONNECTING when many backends exist but are all down.
|
// always CONNECTING when many backends exist but are all down.
|
||||||
|
if s == connectivity.Idle {
|
||||||
|
sc.Connect()
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
b.scStates[sc] = s
|
b.scStates[sc] = s
|
||||||
@ -242,7 +247,6 @@ func (b *baseBalancer) UpdateSubConnState(sc balancer.SubConn, state balancer.Su
|
|||||||
b.state == connectivity.TransientFailure {
|
b.state == connectivity.TransientFailure {
|
||||||
b.regeneratePicker()
|
b.regeneratePicker()
|
||||||
}
|
}
|
||||||
|
|
||||||
b.cc.UpdateState(balancer.State{ConnectivityState: b.state, Picker: b.picker})
|
b.cc.UpdateState(balancer.State{ConnectivityState: b.state, Picker: b.picker})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,6 +255,11 @@ func (b *baseBalancer) UpdateSubConnState(sc balancer.SubConn, state balancer.Su
|
|||||||
func (b *baseBalancer) Close() {
|
func (b *baseBalancer) Close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExitIdle is a nop because the base balancer attempts to stay connected to
|
||||||
|
// all SubConns at all times.
|
||||||
|
func (b *baseBalancer) ExitIdle() {
|
||||||
|
}
|
||||||
|
|
||||||
// NewErrPicker returns a Picker that always returns err on Pick().
|
// NewErrPicker returns a Picker that always returns err on Pick().
|
||||||
func NewErrPicker(err error) balancer.Picker {
|
func NewErrPicker(err error) balancer.Picker {
|
||||||
return &errPicker{err: err}
|
return &errPicker{err: err}
|
||||||
|
4
vendor/google.golang.org/grpc/balancer/roundrobin/roundrobin.go
generated
vendored
4
vendor/google.golang.org/grpc/balancer/roundrobin/roundrobin.go
generated
vendored
@ -47,11 +47,11 @@ func init() {
|
|||||||
type rrPickerBuilder struct{}
|
type rrPickerBuilder struct{}
|
||||||
|
|
||||||
func (*rrPickerBuilder) Build(info base.PickerBuildInfo) balancer.Picker {
|
func (*rrPickerBuilder) Build(info base.PickerBuildInfo) balancer.Picker {
|
||||||
logger.Infof("roundrobinPicker: newPicker called with info: %v", info)
|
logger.Infof("roundrobinPicker: Build called with info: %v", info)
|
||||||
if len(info.ReadySCs) == 0 {
|
if len(info.ReadySCs) == 0 {
|
||||||
return base.NewErrPicker(balancer.ErrNoSubConnAvailable)
|
return base.NewErrPicker(balancer.ErrNoSubConnAvailable)
|
||||||
}
|
}
|
||||||
var scs []balancer.SubConn
|
scs := make([]balancer.SubConn, 0, len(info.ReadySCs))
|
||||||
for sc := range info.ReadySCs {
|
for sc := range info.ReadySCs {
|
||||||
scs = append(scs, sc)
|
scs = append(scs, sc)
|
||||||
}
|
}
|
||||||
|
53
vendor/google.golang.org/grpc/balancer_conn_wrappers.go
generated
vendored
53
vendor/google.golang.org/grpc/balancer_conn_wrappers.go
generated
vendored
@ -37,15 +37,20 @@ type scStateUpdate struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// exitIdle contains no data and is just a signal sent on the updateCh in
|
||||||
|
// ccBalancerWrapper to instruct the balancer to exit idle.
|
||||||
|
type exitIdle struct{}
|
||||||
|
|
||||||
// ccBalancerWrapper is a wrapper on top of cc for balancers.
|
// ccBalancerWrapper is a wrapper on top of cc for balancers.
|
||||||
// It implements balancer.ClientConn interface.
|
// It implements balancer.ClientConn interface.
|
||||||
type ccBalancerWrapper struct {
|
type ccBalancerWrapper struct {
|
||||||
cc *ClientConn
|
cc *ClientConn
|
||||||
balancerMu sync.Mutex // synchronizes calls to the balancer
|
balancerMu sync.Mutex // synchronizes calls to the balancer
|
||||||
balancer balancer.Balancer
|
balancer balancer.Balancer
|
||||||
updateCh *buffer.Unbounded
|
hasExitIdle bool
|
||||||
closed *grpcsync.Event
|
updateCh *buffer.Unbounded
|
||||||
done *grpcsync.Event
|
closed *grpcsync.Event
|
||||||
|
done *grpcsync.Event
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
subConns map[*acBalancerWrapper]struct{}
|
subConns map[*acBalancerWrapper]struct{}
|
||||||
@ -61,6 +66,7 @@ func newCCBalancerWrapper(cc *ClientConn, b balancer.Builder, bopts balancer.Bui
|
|||||||
}
|
}
|
||||||
go ccb.watcher()
|
go ccb.watcher()
|
||||||
ccb.balancer = b.Build(ccb, bopts)
|
ccb.balancer = b.Build(ccb, bopts)
|
||||||
|
_, ccb.hasExitIdle = ccb.balancer.(balancer.ExitIdler)
|
||||||
return ccb
|
return ccb
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,6 +92,17 @@ func (ccb *ccBalancerWrapper) watcher() {
|
|||||||
ccb.cc.removeAddrConn(u.getAddrConn(), errConnDrain)
|
ccb.cc.removeAddrConn(u.getAddrConn(), errConnDrain)
|
||||||
}
|
}
|
||||||
ccb.mu.Unlock()
|
ccb.mu.Unlock()
|
||||||
|
case exitIdle:
|
||||||
|
if ccb.cc.GetState() == connectivity.Idle {
|
||||||
|
if ei, ok := ccb.balancer.(balancer.ExitIdler); ok {
|
||||||
|
// We already checked that the balancer implements
|
||||||
|
// ExitIdle before pushing the event to updateCh, but
|
||||||
|
// check conditionally again as defensive programming.
|
||||||
|
ccb.balancerMu.Lock()
|
||||||
|
ei.ExitIdle()
|
||||||
|
ccb.balancerMu.Unlock()
|
||||||
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
logger.Errorf("ccBalancerWrapper.watcher: unknown update %+v, type %T", t, t)
|
logger.Errorf("ccBalancerWrapper.watcher: unknown update %+v, type %T", t, t)
|
||||||
}
|
}
|
||||||
@ -118,6 +135,14 @@ func (ccb *ccBalancerWrapper) close() {
|
|||||||
<-ccb.done.Done()
|
<-ccb.done.Done()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ccb *ccBalancerWrapper) exitIdle() bool {
|
||||||
|
if !ccb.hasExitIdle {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
ccb.updateCh.Put(exitIdle{})
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (ccb *ccBalancerWrapper) handleSubConnStateChange(sc balancer.SubConn, s connectivity.State, err error) {
|
func (ccb *ccBalancerWrapper) handleSubConnStateChange(sc balancer.SubConn, s connectivity.State, err error) {
|
||||||
// When updating addresses for a SubConn, if the address in use is not in
|
// When updating addresses for a SubConn, if the address in use is not in
|
||||||
// the new addresses, the old ac will be tearDown() and a new ac will be
|
// the new addresses, the old ac will be tearDown() and a new ac will be
|
||||||
@ -144,8 +169,8 @@ func (ccb *ccBalancerWrapper) updateClientConnState(ccs *balancer.ClientConnStat
|
|||||||
|
|
||||||
func (ccb *ccBalancerWrapper) resolverError(err error) {
|
func (ccb *ccBalancerWrapper) resolverError(err error) {
|
||||||
ccb.balancerMu.Lock()
|
ccb.balancerMu.Lock()
|
||||||
|
defer ccb.balancerMu.Unlock()
|
||||||
ccb.balancer.ResolverError(err)
|
ccb.balancer.ResolverError(err)
|
||||||
ccb.balancerMu.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ccb *ccBalancerWrapper) NewSubConn(addrs []resolver.Address, opts balancer.NewSubConnOptions) (balancer.SubConn, error) {
|
func (ccb *ccBalancerWrapper) NewSubConn(addrs []resolver.Address, opts balancer.NewSubConnOptions) (balancer.SubConn, error) {
|
||||||
@ -239,17 +264,17 @@ func (acbw *acBalancerWrapper) UpdateAddresses(addrs []resolver.Address) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ac, err := cc.newAddrConn(addrs, opts)
|
newAC, err := cc.newAddrConn(addrs, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
channelz.Warningf(logger, acbw.ac.channelzID, "acBalancerWrapper: UpdateAddresses: failed to newAddrConn: %v", err)
|
channelz.Warningf(logger, acbw.ac.channelzID, "acBalancerWrapper: UpdateAddresses: failed to newAddrConn: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
acbw.ac = ac
|
acbw.ac = newAC
|
||||||
ac.mu.Lock()
|
newAC.mu.Lock()
|
||||||
ac.acbw = acbw
|
newAC.acbw = acbw
|
||||||
ac.mu.Unlock()
|
newAC.mu.Unlock()
|
||||||
if acState != connectivity.Idle {
|
if acState != connectivity.Idle {
|
||||||
ac.connect()
|
go newAC.connect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -257,7 +282,7 @@ func (acbw *acBalancerWrapper) UpdateAddresses(addrs []resolver.Address) {
|
|||||||
func (acbw *acBalancerWrapper) Connect() {
|
func (acbw *acBalancerWrapper) Connect() {
|
||||||
acbw.mu.Lock()
|
acbw.mu.Lock()
|
||||||
defer acbw.mu.Unlock()
|
defer acbw.mu.Unlock()
|
||||||
acbw.ac.connect()
|
go acbw.ac.connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (acbw *acBalancerWrapper) getAddrConn() *addrConn {
|
func (acbw *acBalancerWrapper) getAddrConn() *addrConn {
|
||||||
|
342
vendor/google.golang.org/grpc/clientconn.go
generated
vendored
342
vendor/google.golang.org/grpc/clientconn.go
generated
vendored
@ -322,6 +322,7 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
|
|||||||
// A blocking dial blocks until the clientConn is ready.
|
// A blocking dial blocks until the clientConn is ready.
|
||||||
if cc.dopts.block {
|
if cc.dopts.block {
|
||||||
for {
|
for {
|
||||||
|
cc.Connect()
|
||||||
s := cc.GetState()
|
s := cc.GetState()
|
||||||
if s == connectivity.Ready {
|
if s == connectivity.Ready {
|
||||||
break
|
break
|
||||||
@ -539,12 +540,31 @@ func (cc *ClientConn) WaitForStateChange(ctx context.Context, sourceState connec
|
|||||||
//
|
//
|
||||||
// Experimental
|
// Experimental
|
||||||
//
|
//
|
||||||
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
|
// Notice: This API is EXPERIMENTAL and may be changed or removed in a later
|
||||||
// later release.
|
// release.
|
||||||
func (cc *ClientConn) GetState() connectivity.State {
|
func (cc *ClientConn) GetState() connectivity.State {
|
||||||
return cc.csMgr.getState()
|
return cc.csMgr.getState()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Connect causes all subchannels in the ClientConn to attempt to connect if
|
||||||
|
// the channel is idle. Does not wait for the connection attempts to begin
|
||||||
|
// before returning.
|
||||||
|
//
|
||||||
|
// Experimental
|
||||||
|
//
|
||||||
|
// Notice: This API is EXPERIMENTAL and may be changed or removed in a later
|
||||||
|
// release.
|
||||||
|
func (cc *ClientConn) Connect() {
|
||||||
|
cc.mu.Lock()
|
||||||
|
defer cc.mu.Unlock()
|
||||||
|
if cc.balancerWrapper != nil && cc.balancerWrapper.exitIdle() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for ac := range cc.conns {
|
||||||
|
go ac.connect()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (cc *ClientConn) scWatcher() {
|
func (cc *ClientConn) scWatcher() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -845,8 +865,7 @@ func (ac *addrConn) connect() error {
|
|||||||
ac.updateConnectivityState(connectivity.Connecting, nil)
|
ac.updateConnectivityState(connectivity.Connecting, nil)
|
||||||
ac.mu.Unlock()
|
ac.mu.Unlock()
|
||||||
|
|
||||||
// Start a goroutine connecting to the server asynchronously.
|
ac.resetTransport()
|
||||||
go ac.resetTransport()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -883,6 +902,10 @@ func (ac *addrConn) tryUpdateAddrs(addrs []resolver.Address) bool {
|
|||||||
// ac.state is Ready, try to find the connected address.
|
// ac.state is Ready, try to find the connected address.
|
||||||
var curAddrFound bool
|
var curAddrFound bool
|
||||||
for _, a := range addrs {
|
for _, a := range addrs {
|
||||||
|
// a.ServerName takes precedent over ClientConn authority, if present.
|
||||||
|
if a.ServerName == "" {
|
||||||
|
a.ServerName = ac.cc.authority
|
||||||
|
}
|
||||||
if reflect.DeepEqual(ac.curAddr, a) {
|
if reflect.DeepEqual(ac.curAddr, a) {
|
||||||
curAddrFound = true
|
curAddrFound = true
|
||||||
break
|
break
|
||||||
@ -1135,112 +1158,86 @@ func (ac *addrConn) adjustParams(r transport.GoAwayReason) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ac *addrConn) resetTransport() {
|
func (ac *addrConn) resetTransport() {
|
||||||
for i := 0; ; i++ {
|
ac.mu.Lock()
|
||||||
if i > 0 {
|
if ac.state == connectivity.Shutdown {
|
||||||
ac.cc.resolveNow(resolver.ResolveNowOptions{})
|
|
||||||
}
|
|
||||||
|
|
||||||
ac.mu.Lock()
|
|
||||||
if ac.state == connectivity.Shutdown {
|
|
||||||
ac.mu.Unlock()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
addrs := ac.addrs
|
|
||||||
backoffFor := ac.dopts.bs.Backoff(ac.backoffIdx)
|
|
||||||
// This will be the duration that dial gets to finish.
|
|
||||||
dialDuration := minConnectTimeout
|
|
||||||
if ac.dopts.minConnectTimeout != nil {
|
|
||||||
dialDuration = ac.dopts.minConnectTimeout()
|
|
||||||
}
|
|
||||||
|
|
||||||
if dialDuration < backoffFor {
|
|
||||||
// Give dial more time as we keep failing to connect.
|
|
||||||
dialDuration = backoffFor
|
|
||||||
}
|
|
||||||
// We can potentially spend all the time trying the first address, and
|
|
||||||
// if the server accepts the connection and then hangs, the following
|
|
||||||
// addresses will never be tried.
|
|
||||||
//
|
|
||||||
// The spec doesn't mention what should be done for multiple addresses.
|
|
||||||
// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md#proposed-backoff-algorithm
|
|
||||||
connectDeadline := time.Now().Add(dialDuration)
|
|
||||||
|
|
||||||
ac.updateConnectivityState(connectivity.Connecting, nil)
|
|
||||||
ac.transport = nil
|
|
||||||
ac.mu.Unlock()
|
ac.mu.Unlock()
|
||||||
|
return
|
||||||
newTr, addr, reconnect, err := ac.tryAllAddrs(addrs, connectDeadline)
|
|
||||||
if err != nil {
|
|
||||||
// After exhausting all addresses, the addrConn enters
|
|
||||||
// TRANSIENT_FAILURE.
|
|
||||||
ac.mu.Lock()
|
|
||||||
if ac.state == connectivity.Shutdown {
|
|
||||||
ac.mu.Unlock()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ac.updateConnectivityState(connectivity.TransientFailure, err)
|
|
||||||
|
|
||||||
// Backoff.
|
|
||||||
b := ac.resetBackoff
|
|
||||||
ac.mu.Unlock()
|
|
||||||
|
|
||||||
timer := time.NewTimer(backoffFor)
|
|
||||||
select {
|
|
||||||
case <-timer.C:
|
|
||||||
ac.mu.Lock()
|
|
||||||
ac.backoffIdx++
|
|
||||||
ac.mu.Unlock()
|
|
||||||
case <-b:
|
|
||||||
timer.Stop()
|
|
||||||
case <-ac.ctx.Done():
|
|
||||||
timer.Stop()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
ac.mu.Lock()
|
|
||||||
if ac.state == connectivity.Shutdown {
|
|
||||||
ac.mu.Unlock()
|
|
||||||
newTr.Close(fmt.Errorf("reached connectivity state: SHUTDOWN"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ac.curAddr = addr
|
|
||||||
ac.transport = newTr
|
|
||||||
ac.backoffIdx = 0
|
|
||||||
|
|
||||||
hctx, hcancel := context.WithCancel(ac.ctx)
|
|
||||||
ac.startHealthCheck(hctx)
|
|
||||||
ac.mu.Unlock()
|
|
||||||
|
|
||||||
// Block until the created transport is down. And when this happens,
|
|
||||||
// we restart from the top of the addr list.
|
|
||||||
<-reconnect.Done()
|
|
||||||
hcancel()
|
|
||||||
// restart connecting - the top of the loop will set state to
|
|
||||||
// CONNECTING. This is against the current connectivity semantics doc,
|
|
||||||
// however it allows for graceful behavior for RPCs not yet dispatched
|
|
||||||
// - unfortunate timing would otherwise lead to the RPC failing even
|
|
||||||
// though the TRANSIENT_FAILURE state (called for by the doc) would be
|
|
||||||
// instantaneous.
|
|
||||||
//
|
|
||||||
// Ideally we should transition to Idle here and block until there is
|
|
||||||
// RPC activity that leads to the balancer requesting a reconnect of
|
|
||||||
// the associated SubConn.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addrs := ac.addrs
|
||||||
|
backoffFor := ac.dopts.bs.Backoff(ac.backoffIdx)
|
||||||
|
// This will be the duration that dial gets to finish.
|
||||||
|
dialDuration := minConnectTimeout
|
||||||
|
if ac.dopts.minConnectTimeout != nil {
|
||||||
|
dialDuration = ac.dopts.minConnectTimeout()
|
||||||
|
}
|
||||||
|
|
||||||
|
if dialDuration < backoffFor {
|
||||||
|
// Give dial more time as we keep failing to connect.
|
||||||
|
dialDuration = backoffFor
|
||||||
|
}
|
||||||
|
// We can potentially spend all the time trying the first address, and
|
||||||
|
// if the server accepts the connection and then hangs, the following
|
||||||
|
// addresses will never be tried.
|
||||||
|
//
|
||||||
|
// The spec doesn't mention what should be done for multiple addresses.
|
||||||
|
// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md#proposed-backoff-algorithm
|
||||||
|
connectDeadline := time.Now().Add(dialDuration)
|
||||||
|
|
||||||
|
ac.updateConnectivityState(connectivity.Connecting, nil)
|
||||||
|
ac.mu.Unlock()
|
||||||
|
|
||||||
|
if err := ac.tryAllAddrs(addrs, connectDeadline); err != nil {
|
||||||
|
ac.cc.resolveNow(resolver.ResolveNowOptions{})
|
||||||
|
// After exhausting all addresses, the addrConn enters
|
||||||
|
// TRANSIENT_FAILURE.
|
||||||
|
ac.mu.Lock()
|
||||||
|
if ac.state == connectivity.Shutdown {
|
||||||
|
ac.mu.Unlock()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ac.updateConnectivityState(connectivity.TransientFailure, err)
|
||||||
|
|
||||||
|
// Backoff.
|
||||||
|
b := ac.resetBackoff
|
||||||
|
ac.mu.Unlock()
|
||||||
|
|
||||||
|
timer := time.NewTimer(backoffFor)
|
||||||
|
select {
|
||||||
|
case <-timer.C:
|
||||||
|
ac.mu.Lock()
|
||||||
|
ac.backoffIdx++
|
||||||
|
ac.mu.Unlock()
|
||||||
|
case <-b:
|
||||||
|
timer.Stop()
|
||||||
|
case <-ac.ctx.Done():
|
||||||
|
timer.Stop()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ac.mu.Lock()
|
||||||
|
if ac.state != connectivity.Shutdown {
|
||||||
|
ac.updateConnectivityState(connectivity.Idle, err)
|
||||||
|
}
|
||||||
|
ac.mu.Unlock()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Success; reset backoff.
|
||||||
|
ac.mu.Lock()
|
||||||
|
ac.backoffIdx = 0
|
||||||
|
ac.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// tryAllAddrs tries to creates a connection to the addresses, and stop when at the
|
// tryAllAddrs tries to creates a connection to the addresses, and stop when at
|
||||||
// first successful one. It returns the transport, the address and a Event in
|
// the first successful one. It returns an error if no address was successfully
|
||||||
// the successful case. The Event fires when the returned transport disconnects.
|
// connected, or updates ac appropriately with the new transport.
|
||||||
func (ac *addrConn) tryAllAddrs(addrs []resolver.Address, connectDeadline time.Time) (transport.ClientTransport, resolver.Address, *grpcsync.Event, error) {
|
func (ac *addrConn) tryAllAddrs(addrs []resolver.Address, connectDeadline time.Time) error {
|
||||||
var firstConnErr error
|
var firstConnErr error
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
ac.mu.Lock()
|
ac.mu.Lock()
|
||||||
if ac.state == connectivity.Shutdown {
|
if ac.state == connectivity.Shutdown {
|
||||||
ac.mu.Unlock()
|
ac.mu.Unlock()
|
||||||
return nil, resolver.Address{}, nil, errConnClosing
|
return errConnClosing
|
||||||
}
|
}
|
||||||
|
|
||||||
ac.cc.mu.RLock()
|
ac.cc.mu.RLock()
|
||||||
@ -1255,9 +1252,9 @@ func (ac *addrConn) tryAllAddrs(addrs []resolver.Address, connectDeadline time.T
|
|||||||
|
|
||||||
channelz.Infof(logger, ac.channelzID, "Subchannel picks a new address %q to connect", addr.Addr)
|
channelz.Infof(logger, ac.channelzID, "Subchannel picks a new address %q to connect", addr.Addr)
|
||||||
|
|
||||||
newTr, reconnect, err := ac.createTransport(addr, copts, connectDeadline)
|
err := ac.createTransport(addr, copts, connectDeadline)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return newTr, addr, reconnect, nil
|
return nil
|
||||||
}
|
}
|
||||||
if firstConnErr == nil {
|
if firstConnErr == nil {
|
||||||
firstConnErr = err
|
firstConnErr = err
|
||||||
@ -1266,57 +1263,54 @@ func (ac *addrConn) tryAllAddrs(addrs []resolver.Address, connectDeadline time.T
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Couldn't connect to any address.
|
// Couldn't connect to any address.
|
||||||
return nil, resolver.Address{}, nil, firstConnErr
|
return firstConnErr
|
||||||
}
|
}
|
||||||
|
|
||||||
// createTransport creates a connection to addr. It returns the transport and a
|
// createTransport creates a connection to addr. It returns an error if the
|
||||||
// Event in the successful case. The Event fires when the returned transport
|
// address was not successfully connected, or updates ac appropriately with the
|
||||||
// disconnects.
|
// new transport.
|
||||||
func (ac *addrConn) createTransport(addr resolver.Address, copts transport.ConnectOptions, connectDeadline time.Time) (transport.ClientTransport, *grpcsync.Event, error) {
|
func (ac *addrConn) createTransport(addr resolver.Address, copts transport.ConnectOptions, connectDeadline time.Time) error {
|
||||||
prefaceReceived := make(chan struct{})
|
// TODO: Delete prefaceReceived and move the logic to wait for it into the
|
||||||
onCloseCalled := make(chan struct{})
|
// transport.
|
||||||
reconnect := grpcsync.NewEvent()
|
prefaceReceived := grpcsync.NewEvent()
|
||||||
|
connClosed := grpcsync.NewEvent()
|
||||||
|
|
||||||
// addr.ServerName takes precedent over ClientConn authority, if present.
|
// addr.ServerName takes precedent over ClientConn authority, if present.
|
||||||
if addr.ServerName == "" {
|
if addr.ServerName == "" {
|
||||||
addr.ServerName = ac.cc.authority
|
addr.ServerName = ac.cc.authority
|
||||||
}
|
}
|
||||||
|
|
||||||
once := sync.Once{}
|
hctx, hcancel := context.WithCancel(ac.ctx)
|
||||||
onGoAway := func(r transport.GoAwayReason) {
|
hcStarted := false // protected by ac.mu
|
||||||
ac.mu.Lock()
|
|
||||||
ac.adjustParams(r)
|
|
||||||
once.Do(func() {
|
|
||||||
if ac.state == connectivity.Ready {
|
|
||||||
// Prevent this SubConn from being used for new RPCs by setting its
|
|
||||||
// state to Connecting.
|
|
||||||
//
|
|
||||||
// TODO: this should be Idle when grpc-go properly supports it.
|
|
||||||
ac.updateConnectivityState(connectivity.Connecting, nil)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
ac.mu.Unlock()
|
|
||||||
reconnect.Fire()
|
|
||||||
}
|
|
||||||
|
|
||||||
onClose := func() {
|
onClose := func() {
|
||||||
ac.mu.Lock()
|
ac.mu.Lock()
|
||||||
once.Do(func() {
|
defer ac.mu.Unlock()
|
||||||
if ac.state == connectivity.Ready {
|
defer connClosed.Fire()
|
||||||
// Prevent this SubConn from being used for new RPCs by setting its
|
if !hcStarted || hctx.Err() != nil {
|
||||||
// state to Connecting.
|
// We didn't start the health check or set the state to READY, so
|
||||||
//
|
// no need to do anything else here.
|
||||||
// TODO: this should be Idle when grpc-go properly supports it.
|
//
|
||||||
ac.updateConnectivityState(connectivity.Connecting, nil)
|
// OR, we have already cancelled the health check context, meaning
|
||||||
}
|
// we have already called onClose once for this transport. In this
|
||||||
})
|
// case it would be dangerous to clear the transport and update the
|
||||||
ac.mu.Unlock()
|
// state, since there may be a new transport in this addrConn.
|
||||||
close(onCloseCalled)
|
return
|
||||||
reconnect.Fire()
|
}
|
||||||
|
hcancel()
|
||||||
|
ac.transport = nil
|
||||||
|
// Refresh the name resolver
|
||||||
|
ac.cc.resolveNow(resolver.ResolveNowOptions{})
|
||||||
|
if ac.state != connectivity.Shutdown {
|
||||||
|
ac.updateConnectivityState(connectivity.Idle, nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onPrefaceReceipt := func() {
|
onGoAway := func(r transport.GoAwayReason) {
|
||||||
close(prefaceReceived)
|
ac.mu.Lock()
|
||||||
|
ac.adjustParams(r)
|
||||||
|
ac.mu.Unlock()
|
||||||
|
onClose()
|
||||||
}
|
}
|
||||||
|
|
||||||
connectCtx, cancel := context.WithDeadline(ac.ctx, connectDeadline)
|
connectCtx, cancel := context.WithDeadline(ac.ctx, connectDeadline)
|
||||||
@ -1325,27 +1319,67 @@ func (ac *addrConn) createTransport(addr resolver.Address, copts transport.Conne
|
|||||||
copts.ChannelzParentID = ac.channelzID
|
copts.ChannelzParentID = ac.channelzID
|
||||||
}
|
}
|
||||||
|
|
||||||
newTr, err := transport.NewClientTransport(connectCtx, ac.cc.ctx, addr, copts, onPrefaceReceipt, onGoAway, onClose)
|
newTr, err := transport.NewClientTransport(connectCtx, ac.cc.ctx, addr, copts, func() { prefaceReceived.Fire() }, onGoAway, onClose)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// newTr is either nil, or closed.
|
// newTr is either nil, or closed.
|
||||||
channelz.Warningf(logger, ac.channelzID, "grpc: addrConn.createTransport failed to connect to %v. Err: %v. Reconnecting...", addr, err)
|
channelz.Warningf(logger, ac.channelzID, "grpc: addrConn.createTransport failed to connect to %v. Err: %v", addr, err)
|
||||||
return nil, nil, err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-time.After(time.Until(connectDeadline)):
|
case <-connectCtx.Done():
|
||||||
// We didn't get the preface in time.
|
// We didn't get the preface in time.
|
||||||
newTr.Close(fmt.Errorf("failed to receive server preface within timeout"))
|
// The error we pass to Close() is immaterial since there are no open
|
||||||
channelz.Warningf(logger, ac.channelzID, "grpc: addrConn.createTransport failed to connect to %v: didn't receive server preface in time. Reconnecting...", addr)
|
// streams at this point, so no trailers with error details will be sent
|
||||||
return nil, nil, errors.New("timed out waiting for server handshake")
|
// out. We just need to pass a non-nil error.
|
||||||
case <-prefaceReceived:
|
newTr.Close(transport.ErrConnClosing)
|
||||||
|
if connectCtx.Err() == context.DeadlineExceeded {
|
||||||
|
err := errors.New("failed to receive server preface within timeout")
|
||||||
|
channelz.Warningf(logger, ac.channelzID, "grpc: addrConn.createTransport failed to connect to %v: %v", addr, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
case <-prefaceReceived.Done():
|
||||||
// We got the preface - huzzah! things are good.
|
// We got the preface - huzzah! things are good.
|
||||||
case <-onCloseCalled:
|
ac.mu.Lock()
|
||||||
// The transport has already closed - noop.
|
defer ac.mu.Unlock()
|
||||||
return nil, nil, errors.New("connection closed")
|
if connClosed.HasFired() {
|
||||||
// TODO(deklerk) this should bail on ac.ctx.Done(). Add a test and fix.
|
// onClose called first; go idle but do nothing else.
|
||||||
|
if ac.state != connectivity.Shutdown {
|
||||||
|
ac.updateConnectivityState(connectivity.Idle, nil)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if ac.state == connectivity.Shutdown {
|
||||||
|
// This can happen if the subConn was removed while in `Connecting`
|
||||||
|
// state. tearDown() would have set the state to `Shutdown`, but
|
||||||
|
// would not have closed the transport since ac.transport would not
|
||||||
|
// been set at that point.
|
||||||
|
//
|
||||||
|
// We run this in a goroutine because newTr.Close() calls onClose()
|
||||||
|
// inline, which requires locking ac.mu.
|
||||||
|
//
|
||||||
|
// The error we pass to Close() is immaterial since there are no open
|
||||||
|
// streams at this point, so no trailers with error details will be sent
|
||||||
|
// out. We just need to pass a non-nil error.
|
||||||
|
go newTr.Close(transport.ErrConnClosing)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
ac.curAddr = addr
|
||||||
|
ac.transport = newTr
|
||||||
|
hcStarted = true
|
||||||
|
ac.startHealthCheck(hctx) // Will set state to READY if appropriate.
|
||||||
|
return nil
|
||||||
|
case <-connClosed.Done():
|
||||||
|
// The transport has already closed. If we received the preface, too,
|
||||||
|
// this is not an error.
|
||||||
|
select {
|
||||||
|
case <-prefaceReceived.Done():
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
return errors.New("connection closed before server preface received")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return newTr, reconnect, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// startHealthCheck starts the health checking stream (RPC) to watch the health
|
// startHealthCheck starts the health checking stream (RPC) to watch the health
|
||||||
|
35
vendor/google.golang.org/grpc/connectivity/connectivity.go
generated
vendored
35
vendor/google.golang.org/grpc/connectivity/connectivity.go
generated
vendored
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
// Package connectivity defines connectivity semantics.
|
// Package connectivity defines connectivity semantics.
|
||||||
// For details, see https://github.com/grpc/grpc/blob/master/doc/connectivity-semantics-and-api.md.
|
// For details, see https://github.com/grpc/grpc/blob/master/doc/connectivity-semantics-and-api.md.
|
||||||
// All APIs in this package are experimental.
|
|
||||||
package connectivity
|
package connectivity
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -45,7 +44,7 @@ func (s State) String() string {
|
|||||||
return "SHUTDOWN"
|
return "SHUTDOWN"
|
||||||
default:
|
default:
|
||||||
logger.Errorf("unknown connectivity state: %d", s)
|
logger.Errorf("unknown connectivity state: %d", s)
|
||||||
return "Invalid-State"
|
return "INVALID_STATE"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,3 +60,35 @@ const (
|
|||||||
// Shutdown indicates the ClientConn has started shutting down.
|
// Shutdown indicates the ClientConn has started shutting down.
|
||||||
Shutdown
|
Shutdown
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ServingMode indicates the current mode of operation of the server.
|
||||||
|
//
|
||||||
|
// Only xDS enabled gRPC servers currently report their serving mode.
|
||||||
|
type ServingMode int
|
||||||
|
|
||||||
|
const (
|
||||||
|
// ServingModeStarting indicates that the server is starting up.
|
||||||
|
ServingModeStarting ServingMode = iota
|
||||||
|
// ServingModeServing indicates that the server contains all required
|
||||||
|
// configuration and is serving RPCs.
|
||||||
|
ServingModeServing
|
||||||
|
// ServingModeNotServing indicates that the server is not accepting new
|
||||||
|
// connections. Existing connections will be closed gracefully, allowing
|
||||||
|
// in-progress RPCs to complete. A server enters this mode when it does not
|
||||||
|
// contain the required configuration to serve RPCs.
|
||||||
|
ServingModeNotServing
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s ServingMode) String() string {
|
||||||
|
switch s {
|
||||||
|
case ServingModeStarting:
|
||||||
|
return "STARTING"
|
||||||
|
case ServingModeServing:
|
||||||
|
return "SERVING"
|
||||||
|
case ServingModeNotServing:
|
||||||
|
return "NOT_SERVING"
|
||||||
|
default:
|
||||||
|
logger.Errorf("unknown serving mode: %d", s)
|
||||||
|
return "INVALID_MODE"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
30
vendor/google.golang.org/grpc/credentials/go12.go
generated
vendored
30
vendor/google.golang.org/grpc/credentials/go12.go
generated
vendored
@ -1,30 +0,0 @@
|
|||||||
// +build go1.12
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2019 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package credentials
|
|
||||||
|
|
||||||
import "crypto/tls"
|
|
||||||
|
|
||||||
// This init function adds cipher suite constants only defined in Go 1.12.
|
|
||||||
func init() {
|
|
||||||
cipherSuiteLookup[tls.TLS_AES_128_GCM_SHA256] = "TLS_AES_128_GCM_SHA256"
|
|
||||||
cipherSuiteLookup[tls.TLS_AES_256_GCM_SHA384] = "TLS_AES_256_GCM_SHA384"
|
|
||||||
cipherSuiteLookup[tls.TLS_CHACHA20_POLY1305_SHA256] = "TLS_CHACHA20_POLY1305_SHA256"
|
|
||||||
}
|
|
3
vendor/google.golang.org/grpc/credentials/tls.go
generated
vendored
3
vendor/google.golang.org/grpc/credentials/tls.go
generated
vendored
@ -230,4 +230,7 @@ var cipherSuiteLookup = map[uint16]string{
|
|||||||
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256: "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
|
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256: "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
|
||||||
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
|
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
|
||||||
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
|
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
|
||||||
|
tls.TLS_AES_128_GCM_SHA256: "TLS_AES_128_GCM_SHA256",
|
||||||
|
tls.TLS_AES_256_GCM_SHA384: "TLS_AES_256_GCM_SHA384",
|
||||||
|
tls.TLS_CHACHA20_POLY1305_SHA256: "TLS_CHACHA20_POLY1305_SHA256",
|
||||||
}
|
}
|
||||||
|
6
vendor/google.golang.org/grpc/go.mod
generated
vendored
6
vendor/google.golang.org/grpc/go.mod
generated
vendored
@ -1,11 +1,11 @@
|
|||||||
module google.golang.org/grpc
|
module google.golang.org/grpc
|
||||||
|
|
||||||
go 1.11
|
go 1.14
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/cespare/xxhash v1.1.0
|
github.com/cespare/xxhash/v2 v2.1.1
|
||||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403
|
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403
|
||||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0
|
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
|
||||||
github.com/golang/protobuf v1.4.3
|
github.com/golang/protobuf v1.4.3
|
||||||
github.com/google/go-cmp v0.5.0
|
github.com/google/go-cmp v0.5.0
|
||||||
|
22
vendor/google.golang.org/grpc/go.sum
generated
vendored
22
vendor/google.golang.org/grpc/go.sum
generated
vendored
@ -2,27 +2,25 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
|
|||||||
cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg=
|
cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg=
|
||||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
|
|
||||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
|
||||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||||
github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=
|
github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=
|
||||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
|
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403 h1:cqQfy1jclcSy/FwLjemeg3SR1yaINm74aQyupQ0Bl8M=
|
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403 h1:cqQfy1jclcSy/FwLjemeg3SR1yaINm74aQyupQ0Bl8M=
|
||||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||||
github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed h1:OZmjad4L3H8ncOIR8rnb5MREYqG8ixi5+WbeUsquF0c=
|
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158 h1:CevA8fI91PAnP8vpnXuB8ZYAZ5wqY86nAbxfgK8tWO4=
|
||||||
github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0 h1:dulLQAYQFYtG5MTplgNGHWuV2D+OBD+Z8lmDBmbLg+s=
|
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021 h1:fP+fF0up6oPY49OrjPrhIJ8yQfdIM85NXMLkMg1EXVs=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
|
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
|
||||||
github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=
|
github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=
|
||||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||||
@ -54,11 +52,10 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
|||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=
|
|
||||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
|
||||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
@ -122,7 +119,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
|
|||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI=
|
|
||||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
6
vendor/google.golang.org/grpc/install_gae.sh
generated
vendored
6
vendor/google.golang.org/grpc/install_gae.sh
generated
vendored
@ -1,6 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
TMP=$(mktemp -d /tmp/sdk.XXX) \
|
|
||||||
&& curl -o $TMP.zip "https://storage.googleapis.com/appengine-sdks/featured/go_appengine_sdk_linux_amd64-1.9.68.zip" \
|
|
||||||
&& unzip -q $TMP.zip -d $TMP \
|
|
||||||
&& export PATH="$PATH:$TMP/go_appengine"
|
|
2
vendor/google.golang.org/grpc/internal/channelz/funcs.go
generated
vendored
2
vendor/google.golang.org/grpc/internal/channelz/funcs.go
generated
vendored
@ -630,7 +630,7 @@ func (c *channelMap) GetServerSockets(id int64, startID int64, maxResults int64)
|
|||||||
if count == 0 {
|
if count == 0 {
|
||||||
end = true
|
end = true
|
||||||
}
|
}
|
||||||
var s []*SocketMetric
|
s := make([]*SocketMetric, 0, len(sks))
|
||||||
for _, ns := range sks {
|
for _, ns := range sks {
|
||||||
sm := &SocketMetric{}
|
sm := &SocketMetric{}
|
||||||
sm.SocketData = ns.s.ChannelzMetric()
|
sm.SocketData = ns.s.ChannelzMetric()
|
||||||
|
2
vendor/google.golang.org/grpc/internal/channelz/types_linux.go
generated
vendored
2
vendor/google.golang.org/grpc/internal/channelz/types_linux.go
generated
vendored
@ -1,5 +1,3 @@
|
|||||||
// +build !appengine
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2018 gRPC authors.
|
* Copyright 2018 gRPC authors.
|
||||||
|
5
vendor/google.golang.org/grpc/internal/channelz/types_nonlinux.go
generated
vendored
5
vendor/google.golang.org/grpc/internal/channelz/types_nonlinux.go
generated
vendored
@ -1,4 +1,5 @@
|
|||||||
// +build !linux appengine
|
//go:build !linux
|
||||||
|
// +build !linux
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
@ -37,6 +38,6 @@ type SocketOptionData struct {
|
|||||||
// Windows OS doesn't support Socket Option
|
// Windows OS doesn't support Socket Option
|
||||||
func (s *SocketOptionData) Getsockopt(fd uintptr) {
|
func (s *SocketOptionData) Getsockopt(fd uintptr) {
|
||||||
once.Do(func() {
|
once.Do(func() {
|
||||||
logger.Warning("Channelz: socket options are not supported on non-linux os and appengine.")
|
logger.Warning("Channelz: socket options are not supported on non-linux environments")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
2
vendor/google.golang.org/grpc/internal/channelz/util_linux.go
generated
vendored
2
vendor/google.golang.org/grpc/internal/channelz/util_linux.go
generated
vendored
@ -1,5 +1,3 @@
|
|||||||
// +build linux,!appengine
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2018 gRPC authors.
|
* Copyright 2018 gRPC authors.
|
||||||
|
3
vendor/google.golang.org/grpc/internal/channelz/util_nonlinux.go
generated
vendored
3
vendor/google.golang.org/grpc/internal/channelz/util_nonlinux.go
generated
vendored
@ -1,4 +1,5 @@
|
|||||||
// +build !linux appengine
|
//go:build !linux
|
||||||
|
// +build !linux
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
2
vendor/google.golang.org/grpc/internal/credentials/spiffe.go
generated
vendored
2
vendor/google.golang.org/grpc/internal/credentials/spiffe.go
generated
vendored
@ -1,5 +1,3 @@
|
|||||||
// +build !appengine
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2020 gRPC authors.
|
* Copyright 2020 gRPC authors.
|
||||||
|
31
vendor/google.golang.org/grpc/internal/credentials/spiffe_appengine.go
generated
vendored
31
vendor/google.golang.org/grpc/internal/credentials/spiffe_appengine.go
generated
vendored
@ -1,31 +0,0 @@
|
|||||||
// +build appengine
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2020 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package credentials
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/tls"
|
|
||||||
"net/url"
|
|
||||||
)
|
|
||||||
|
|
||||||
// SPIFFEIDFromState is a no-op for appengine builds.
|
|
||||||
func SPIFFEIDFromState(state tls.ConnectionState) *url.URL {
|
|
||||||
return nil
|
|
||||||
}
|
|
2
vendor/google.golang.org/grpc/internal/credentials/syscallconn.go
generated
vendored
2
vendor/google.golang.org/grpc/internal/credentials/syscallconn.go
generated
vendored
@ -1,5 +1,3 @@
|
|||||||
// +build !appengine
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2018 gRPC authors.
|
* Copyright 2018 gRPC authors.
|
||||||
|
30
vendor/google.golang.org/grpc/internal/credentials/syscallconn_appengine.go
generated
vendored
30
vendor/google.golang.org/grpc/internal/credentials/syscallconn_appengine.go
generated
vendored
@ -1,30 +0,0 @@
|
|||||||
// +build appengine
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2018 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package credentials
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net"
|
|
||||||
)
|
|
||||||
|
|
||||||
// WrapSyscallConn returns newConn on appengine.
|
|
||||||
func WrapSyscallConn(rawConn, newConn net.Conn) net.Conn {
|
|
||||||
return newConn
|
|
||||||
}
|
|
4
vendor/google.golang.org/grpc/internal/credentials/util.go
generated
vendored
4
vendor/google.golang.org/grpc/internal/credentials/util.go
generated
vendored
@ -18,7 +18,9 @@
|
|||||||
|
|
||||||
package credentials
|
package credentials
|
||||||
|
|
||||||
import "crypto/tls"
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
)
|
||||||
|
|
||||||
const alpnProtoStrH2 = "h2"
|
const alpnProtoStrH2 = "h2"
|
||||||
|
|
||||||
|
6
vendor/google.golang.org/grpc/internal/envconfig/envconfig.go
generated
vendored
6
vendor/google.golang.org/grpc/internal/envconfig/envconfig.go
generated
vendored
@ -22,6 +22,8 @@ package envconfig
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
xdsenv "google.golang.org/grpc/internal/xds/env"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -31,8 +33,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Retry is set if retry is explicitly enabled via "GRPC_GO_RETRY=on".
|
// Retry is set if retry is explicitly enabled via "GRPC_GO_RETRY=on" or if XDS retry support is enabled.
|
||||||
Retry = strings.EqualFold(os.Getenv(retryStr), "on")
|
Retry = strings.EqualFold(os.Getenv(retryStr), "on") || xdsenv.RetrySupport
|
||||||
// TXTErrIgnore is set if TXT errors should be ignored ("GRPC_GO_IGNORE_TXT_ERRORS" is not "false").
|
// TXTErrIgnore is set if TXT errors should be ignored ("GRPC_GO_IGNORE_TXT_ERRORS" is not "false").
|
||||||
TXTErrIgnore = !strings.EqualFold(os.Getenv(txtErrIgnoreStr), "false")
|
TXTErrIgnore = !strings.EqualFold(os.Getenv(txtErrIgnoreStr), "false")
|
||||||
)
|
)
|
||||||
|
7
vendor/google.golang.org/grpc/internal/resolver/config_selector.go
generated
vendored
7
vendor/google.golang.org/grpc/internal/resolver/config_selector.go
generated
vendored
@ -117,9 +117,12 @@ type ClientInterceptor interface {
|
|||||||
NewStream(ctx context.Context, ri RPCInfo, done func(), newStream func(ctx context.Context, done func()) (ClientStream, error)) (ClientStream, error)
|
NewStream(ctx context.Context, ri RPCInfo, done func(), newStream func(ctx context.Context, done func()) (ClientStream, error)) (ClientStream, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServerInterceptor is unimplementable; do not use.
|
// ServerInterceptor is an interceptor for incoming RPC's on gRPC server side.
|
||||||
type ServerInterceptor interface {
|
type ServerInterceptor interface {
|
||||||
notDefined()
|
// AllowRPC checks if an incoming RPC is allowed to proceed based on
|
||||||
|
// information about connection RPC was received on, and HTTP Headers. This
|
||||||
|
// information will be piped into context.
|
||||||
|
AllowRPC(ctx context.Context) error // TODO: Make this a real interceptor for filters such as rate limiting.
|
||||||
}
|
}
|
||||||
|
|
||||||
type csKeyType string
|
type csKeyType string
|
||||||
|
9
vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go
generated
vendored
9
vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go
generated
vendored
@ -277,18 +277,13 @@ func (d *dnsResolver) lookupSRV() ([]resolver.Address, error) {
|
|||||||
return newAddrs, nil
|
return newAddrs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var filterError = func(err error) error {
|
func handleDNSError(err error, lookupType string) error {
|
||||||
if dnsErr, ok := err.(*net.DNSError); ok && !dnsErr.IsTimeout && !dnsErr.IsTemporary {
|
if dnsErr, ok := err.(*net.DNSError); ok && !dnsErr.IsTimeout && !dnsErr.IsTemporary {
|
||||||
// Timeouts and temporary errors should be communicated to gRPC to
|
// Timeouts and temporary errors should be communicated to gRPC to
|
||||||
// attempt another DNS query (with backoff). Other errors should be
|
// attempt another DNS query (with backoff). Other errors should be
|
||||||
// suppressed (they may represent the absence of a TXT record).
|
// suppressed (they may represent the absence of a TXT record).
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func handleDNSError(err error, lookupType string) error {
|
|
||||||
err = filterError(err)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("dns: %v record lookup error: %v", lookupType, err)
|
err = fmt.Errorf("dns: %v record lookup error: %v", lookupType, err)
|
||||||
logger.Info(err)
|
logger.Info(err)
|
||||||
@ -323,12 +318,12 @@ func (d *dnsResolver) lookupTXT() *serviceconfig.ParseResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *dnsResolver) lookupHost() ([]resolver.Address, error) {
|
func (d *dnsResolver) lookupHost() ([]resolver.Address, error) {
|
||||||
var newAddrs []resolver.Address
|
|
||||||
addrs, err := d.resolver.LookupHost(d.ctx, d.host)
|
addrs, err := d.resolver.LookupHost(d.ctx, d.host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = handleDNSError(err, "A")
|
err = handleDNSError(err, "A")
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
newAddrs := make([]resolver.Address, 0, len(addrs))
|
||||||
for _, a := range addrs {
|
for _, a := range addrs {
|
||||||
ip, ok := formatIP(a)
|
ip, ok := formatIP(a)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
33
vendor/google.golang.org/grpc/internal/resolver/dns/go113.go
generated
vendored
33
vendor/google.golang.org/grpc/internal/resolver/dns/go113.go
generated
vendored
@ -1,33 +0,0 @@
|
|||||||
// +build go1.13
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2019 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package dns
|
|
||||||
|
|
||||||
import "net"
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
filterError = func(err error) error {
|
|
||||||
if dnsErr, ok := err.(*net.DNSError); ok && dnsErr.IsNotFound {
|
|
||||||
// The name does not exist; not an error.
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
4
vendor/google.golang.org/grpc/internal/serviceconfig/serviceconfig.go
generated
vendored
4
vendor/google.golang.org/grpc/internal/serviceconfig/serviceconfig.go
generated
vendored
@ -78,6 +78,7 @@ func (bc *BalancerConfig) UnmarshalJSON(b []byte) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var names []string
|
||||||
for i, lbcfg := range ir {
|
for i, lbcfg := range ir {
|
||||||
if len(lbcfg) != 1 {
|
if len(lbcfg) != 1 {
|
||||||
return fmt.Errorf("invalid loadBalancingConfig: entry %v does not contain exactly 1 policy/config pair: %q", i, lbcfg)
|
return fmt.Errorf("invalid loadBalancingConfig: entry %v does not contain exactly 1 policy/config pair: %q", i, lbcfg)
|
||||||
@ -92,6 +93,7 @@ func (bc *BalancerConfig) UnmarshalJSON(b []byte) error {
|
|||||||
for name, jsonCfg = range lbcfg {
|
for name, jsonCfg = range lbcfg {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
names = append(names, name)
|
||||||
builder := balancer.Get(name)
|
builder := balancer.Get(name)
|
||||||
if builder == nil {
|
if builder == nil {
|
||||||
// If the balancer is not registered, move on to the next config.
|
// If the balancer is not registered, move on to the next config.
|
||||||
@ -120,7 +122,7 @@ func (bc *BalancerConfig) UnmarshalJSON(b []byte) error {
|
|||||||
// return. This means we had a loadBalancingConfig slice but did not
|
// return. This means we had a loadBalancingConfig slice but did not
|
||||||
// encounter a registered policy. The config is considered invalid in this
|
// encounter a registered policy. The config is considered invalid in this
|
||||||
// case.
|
// case.
|
||||||
return fmt.Errorf("invalid loadBalancingConfig: no supported policies found")
|
return fmt.Errorf("invalid loadBalancingConfig: no supported policies found in %v", names)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MethodConfig defines the configuration recommended by the service providers for a
|
// MethodConfig defines the configuration recommended by the service providers for a
|
||||||
|
2
vendor/google.golang.org/grpc/internal/syscall/syscall_linux.go
generated
vendored
2
vendor/google.golang.org/grpc/internal/syscall/syscall_linux.go
generated
vendored
@ -1,5 +1,3 @@
|
|||||||
// +build !appengine
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2018 gRPC authors.
|
* Copyright 2018 gRPC authors.
|
||||||
|
21
vendor/google.golang.org/grpc/internal/syscall/syscall_nonlinux.go
generated
vendored
21
vendor/google.golang.org/grpc/internal/syscall/syscall_nonlinux.go
generated
vendored
@ -1,4 +1,5 @@
|
|||||||
// +build !linux appengine
|
//go:build !linux
|
||||||
|
// +build !linux
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
@ -35,41 +36,41 @@ var logger = grpclog.Component("core")
|
|||||||
|
|
||||||
func log() {
|
func log() {
|
||||||
once.Do(func() {
|
once.Do(func() {
|
||||||
logger.Info("CPU time info is unavailable on non-linux or appengine environment.")
|
logger.Info("CPU time info is unavailable on non-linux environments.")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCPUTime returns the how much CPU time has passed since the start of this process.
|
// GetCPUTime returns the how much CPU time has passed since the start of this
|
||||||
// It always returns 0 under non-linux or appengine environment.
|
// process. It always returns 0 under non-linux environments.
|
||||||
func GetCPUTime() int64 {
|
func GetCPUTime() int64 {
|
||||||
log()
|
log()
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rusage is an empty struct under non-linux or appengine environment.
|
// Rusage is an empty struct under non-linux environments.
|
||||||
type Rusage struct{}
|
type Rusage struct{}
|
||||||
|
|
||||||
// GetRusage is a no-op function under non-linux or appengine environment.
|
// GetRusage is a no-op function under non-linux environments.
|
||||||
func GetRusage() *Rusage {
|
func GetRusage() *Rusage {
|
||||||
log()
|
log()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CPUTimeDiff returns the differences of user CPU time and system CPU time used
|
// CPUTimeDiff returns the differences of user CPU time and system CPU time used
|
||||||
// between two Rusage structs. It a no-op function for non-linux or appengine environment.
|
// between two Rusage structs. It a no-op function for non-linux environments.
|
||||||
func CPUTimeDiff(first *Rusage, latest *Rusage) (float64, float64) {
|
func CPUTimeDiff(first *Rusage, latest *Rusage) (float64, float64) {
|
||||||
log()
|
log()
|
||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTCPUserTimeout is a no-op function under non-linux or appengine environments
|
// SetTCPUserTimeout is a no-op function under non-linux environments.
|
||||||
func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error {
|
func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error {
|
||||||
log()
|
log()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTCPUserTimeout is a no-op function under non-linux or appengine environments
|
// GetTCPUserTimeout is a no-op function under non-linux environments.
|
||||||
// a negative return value indicates the operation is not supported
|
// A negative return value indicates the operation is not supported
|
||||||
func GetTCPUserTimeout(conn net.Conn) (int, error) {
|
func GetTCPUserTimeout(conn net.Conn) (int, error) {
|
||||||
log()
|
log()
|
||||||
return -1, nil
|
return -1, nil
|
||||||
|
42
vendor/google.golang.org/grpc/internal/transport/http2_client.go
generated
vendored
42
vendor/google.golang.org/grpc/internal/transport/http2_client.go
generated
vendored
@ -616,12 +616,22 @@ func (t *http2Client) getCallAuthData(ctx context.Context, audience string, call
|
|||||||
return callAuthData, nil
|
return callAuthData, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewStreamError wraps an error and reports additional information.
|
// NewStreamError wraps an error and reports additional information. Typically
|
||||||
|
// NewStream errors result in transparent retry, as they mean nothing went onto
|
||||||
|
// the wire. However, there are two notable exceptions:
|
||||||
|
//
|
||||||
|
// 1. If the stream headers violate the max header list size allowed by the
|
||||||
|
// server. In this case there is no reason to retry at all, as it is
|
||||||
|
// assumed the RPC would continue to fail on subsequent attempts.
|
||||||
|
// 2. If the credentials errored when requesting their headers. In this case,
|
||||||
|
// it's possible a retry can fix the problem, but indefinitely transparently
|
||||||
|
// retrying is not appropriate as it is likely the credentials, if they can
|
||||||
|
// eventually succeed, would need I/O to do so.
|
||||||
type NewStreamError struct {
|
type NewStreamError struct {
|
||||||
Err error
|
Err error
|
||||||
|
|
||||||
DoNotRetry bool
|
DoNotRetry bool
|
||||||
PerformedIO bool
|
DoNotTransparentRetry bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e NewStreamError) Error() string {
|
func (e NewStreamError) Error() string {
|
||||||
@ -631,24 +641,10 @@ func (e NewStreamError) Error() string {
|
|||||||
// NewStream creates a stream and registers it into the transport as "active"
|
// NewStream creates a stream and registers it into the transport as "active"
|
||||||
// streams. All non-nil errors returned will be *NewStreamError.
|
// streams. All non-nil errors returned will be *NewStreamError.
|
||||||
func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Stream, err error) {
|
func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Stream, err error) {
|
||||||
defer func() {
|
|
||||||
if err != nil {
|
|
||||||
nse, ok := err.(*NewStreamError)
|
|
||||||
if !ok {
|
|
||||||
nse = &NewStreamError{Err: err}
|
|
||||||
}
|
|
||||||
if len(t.perRPCCreds) > 0 || callHdr.Creds != nil {
|
|
||||||
// We may have performed I/O in the per-RPC creds callback, so do not
|
|
||||||
// allow transparent retry.
|
|
||||||
nse.PerformedIO = true
|
|
||||||
}
|
|
||||||
err = nse
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
ctx = peer.NewContext(ctx, t.getPeer())
|
ctx = peer.NewContext(ctx, t.getPeer())
|
||||||
headerFields, err := t.createHeaderFields(ctx, callHdr)
|
headerFields, err := t.createHeaderFields(ctx, callHdr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, &NewStreamError{Err: err, DoNotTransparentRetry: true}
|
||||||
}
|
}
|
||||||
s := t.newStream(ctx, callHdr)
|
s := t.newStream(ctx, callHdr)
|
||||||
cleanup := func(err error) {
|
cleanup := func(err error) {
|
||||||
@ -748,7 +744,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Strea
|
|||||||
return true
|
return true
|
||||||
}, hdr)
|
}, hdr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, &NewStreamError{Err: err}
|
||||||
}
|
}
|
||||||
if success {
|
if success {
|
||||||
break
|
break
|
||||||
@ -759,12 +755,12 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Strea
|
|||||||
firstTry = false
|
firstTry = false
|
||||||
select {
|
select {
|
||||||
case <-ch:
|
case <-ch:
|
||||||
case <-s.ctx.Done():
|
case <-ctx.Done():
|
||||||
return nil, ContextErr(s.ctx.Err())
|
return nil, &NewStreamError{Err: ContextErr(ctx.Err())}
|
||||||
case <-t.goAway:
|
case <-t.goAway:
|
||||||
return nil, errStreamDrain
|
return nil, &NewStreamError{Err: errStreamDrain}
|
||||||
case <-t.ctx.Done():
|
case <-t.ctx.Done():
|
||||||
return nil, ErrConnClosing
|
return nil, &NewStreamError{Err: ErrConnClosing}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if t.statsHandler != nil {
|
if t.statsHandler != nil {
|
||||||
|
36
vendor/google.golang.org/grpc/internal/transport/http2_server.go
generated
vendored
36
vendor/google.golang.org/grpc/internal/transport/http2_server.go
generated
vendored
@ -133,6 +133,22 @@ type http2Server struct {
|
|||||||
// underlying conn gets closed before the client preface could be read, it
|
// underlying conn gets closed before the client preface could be read, it
|
||||||
// returns a nil transport and a nil error.
|
// returns a nil transport and a nil error.
|
||||||
func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport, err error) {
|
func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport, err error) {
|
||||||
|
var authInfo credentials.AuthInfo
|
||||||
|
rawConn := conn
|
||||||
|
if config.Credentials != nil {
|
||||||
|
var err error
|
||||||
|
conn, authInfo, err = config.Credentials.ServerHandshake(rawConn)
|
||||||
|
if err != nil {
|
||||||
|
// ErrConnDispatched means that the connection was dispatched away
|
||||||
|
// from gRPC; those connections should be left open. io.EOF means
|
||||||
|
// the connection was closed before handshaking completed, which can
|
||||||
|
// happen naturally from probers. Return these errors directly.
|
||||||
|
if err == credentials.ErrConnDispatched || err == io.EOF {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return nil, connectionErrorf(false, err, "ServerHandshake(%q) failed: %v", rawConn.RemoteAddr(), err)
|
||||||
|
}
|
||||||
|
}
|
||||||
writeBufSize := config.WriteBufferSize
|
writeBufSize := config.WriteBufferSize
|
||||||
readBufSize := config.ReadBufferSize
|
readBufSize := config.ReadBufferSize
|
||||||
maxHeaderListSize := defaultServerMaxHeaderListSize
|
maxHeaderListSize := defaultServerMaxHeaderListSize
|
||||||
@ -215,14 +231,15 @@ func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport,
|
|||||||
if kep.MinTime == 0 {
|
if kep.MinTime == 0 {
|
||||||
kep.MinTime = defaultKeepalivePolicyMinTime
|
kep.MinTime = defaultKeepalivePolicyMinTime
|
||||||
}
|
}
|
||||||
|
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
t := &http2Server{
|
t := &http2Server{
|
||||||
ctx: context.Background(),
|
ctx: setConnection(context.Background(), rawConn),
|
||||||
done: done,
|
done: done,
|
||||||
conn: conn,
|
conn: conn,
|
||||||
remoteAddr: conn.RemoteAddr(),
|
remoteAddr: conn.RemoteAddr(),
|
||||||
localAddr: conn.LocalAddr(),
|
localAddr: conn.LocalAddr(),
|
||||||
authInfo: config.AuthInfo,
|
authInfo: authInfo,
|
||||||
framer: framer,
|
framer: framer,
|
||||||
readerDone: make(chan struct{}),
|
readerDone: make(chan struct{}),
|
||||||
writerDone: make(chan struct{}),
|
writerDone: make(chan struct{}),
|
||||||
@ -1345,3 +1362,18 @@ func getJitter(v time.Duration) time.Duration {
|
|||||||
j := grpcrand.Int63n(2*r) - r
|
j := grpcrand.Int63n(2*r) - r
|
||||||
return time.Duration(j)
|
return time.Duration(j)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type connectionKey struct{}
|
||||||
|
|
||||||
|
// GetConnection gets the connection from the context.
|
||||||
|
func GetConnection(ctx context.Context) net.Conn {
|
||||||
|
conn, _ := ctx.Value(connectionKey{}).(net.Conn)
|
||||||
|
return conn
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetConnection adds the connection to the context to be able to get
|
||||||
|
// information about the destination ip and port for an incoming RPC. This also
|
||||||
|
// allows any unary or streaming interceptors to see the connection.
|
||||||
|
func setConnection(ctx context.Context, conn net.Conn) context.Context {
|
||||||
|
return context.WithValue(ctx, connectionKey{}, conn)
|
||||||
|
}
|
||||||
|
4
vendor/google.golang.org/grpc/internal/transport/transport.go
generated
vendored
4
vendor/google.golang.org/grpc/internal/transport/transport.go
generated
vendored
@ -30,6 +30,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
|
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
@ -518,7 +519,8 @@ const (
|
|||||||
// ServerConfig consists of all the configurations to establish a server transport.
|
// ServerConfig consists of all the configurations to establish a server transport.
|
||||||
type ServerConfig struct {
|
type ServerConfig struct {
|
||||||
MaxStreams uint32
|
MaxStreams uint32
|
||||||
AuthInfo credentials.AuthInfo
|
ConnectionTimeout time.Duration
|
||||||
|
Credentials credentials.TransportCredentials
|
||||||
InTapHandle tap.ServerInHandle
|
InTapHandle tap.ServerInHandle
|
||||||
StatsHandler stats.Handler
|
StatsHandler stats.Handler
|
||||||
KeepaliveParams keepalive.ServerParameters
|
KeepaliveParams keepalive.ServerParameters
|
||||||
|
95
vendor/google.golang.org/grpc/internal/xds/env/env.go
generated
vendored
Normal file
95
vendor/google.golang.org/grpc/internal/xds/env/env.go
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright 2020 gRPC authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Package env acts a single source of definition for all environment variables
|
||||||
|
// related to the xDS implementation in gRPC.
|
||||||
|
package env
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// BootstrapFileNameEnv is the env variable to set bootstrap file name.
|
||||||
|
// Do not use this and read from env directly. Its value is read and kept in
|
||||||
|
// variable BootstrapFileName.
|
||||||
|
//
|
||||||
|
// When both bootstrap FileName and FileContent are set, FileName is used.
|
||||||
|
BootstrapFileNameEnv = "GRPC_XDS_BOOTSTRAP"
|
||||||
|
// BootstrapFileContentEnv is the env variable to set bootstrapp file
|
||||||
|
// content. Do not use this and read from env directly. Its value is read
|
||||||
|
// and kept in variable BootstrapFileName.
|
||||||
|
//
|
||||||
|
// When both bootstrap FileName and FileContent are set, FileName is used.
|
||||||
|
BootstrapFileContentEnv = "GRPC_XDS_BOOTSTRAP_CONFIG"
|
||||||
|
|
||||||
|
ringHashSupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_RING_HASH"
|
||||||
|
clientSideSecuritySupportEnv = "GRPC_XDS_EXPERIMENTAL_SECURITY_SUPPORT"
|
||||||
|
aggregateAndDNSSupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER"
|
||||||
|
retrySupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_RETRY"
|
||||||
|
rbacSupportEnv = "GRPC_XDS_EXPERIMENTAL_ENABLE_RBAC"
|
||||||
|
|
||||||
|
c2pResolverSupportEnv = "GRPC_EXPERIMENTAL_GOOGLE_C2P_RESOLVER"
|
||||||
|
c2pResolverTestOnlyTrafficDirectorURIEnv = "GRPC_TEST_ONLY_GOOGLE_C2P_RESOLVER_TRAFFIC_DIRECTOR_URI"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// BootstrapFileName holds the name of the file which contains xDS bootstrap
|
||||||
|
// configuration. Users can specify the location of the bootstrap file by
|
||||||
|
// setting the environment variable "GRPC_XDS_BOOTSTRAP".
|
||||||
|
//
|
||||||
|
// When both bootstrap FileName and FileContent are set, FileName is used.
|
||||||
|
BootstrapFileName = os.Getenv(BootstrapFileNameEnv)
|
||||||
|
// BootstrapFileContent holds the content of the xDS bootstrap
|
||||||
|
// configuration. Users can specify the bootstrap config by
|
||||||
|
// setting the environment variable "GRPC_XDS_BOOTSTRAP_CONFIG".
|
||||||
|
//
|
||||||
|
// When both bootstrap FileName and FileContent are set, FileName is used.
|
||||||
|
BootstrapFileContent = os.Getenv(BootstrapFileContentEnv)
|
||||||
|
// RingHashSupport indicates whether ring hash support is enabled, which can
|
||||||
|
// be disabled by setting the environment variable
|
||||||
|
// "GRPC_XDS_EXPERIMENTAL_ENABLE_RING_HASH" to "false".
|
||||||
|
RingHashSupport = !strings.EqualFold(os.Getenv(ringHashSupportEnv), "false")
|
||||||
|
// ClientSideSecuritySupport is used to control processing of security
|
||||||
|
// configuration on the client-side.
|
||||||
|
//
|
||||||
|
// Note that there is no env var protection for the server-side because we
|
||||||
|
// have a brand new API on the server-side and users explicitly need to use
|
||||||
|
// the new API to get security integration on the server.
|
||||||
|
ClientSideSecuritySupport = !strings.EqualFold(os.Getenv(clientSideSecuritySupportEnv), "false")
|
||||||
|
// AggregateAndDNSSupportEnv indicates whether processing of aggregated
|
||||||
|
// cluster and DNS cluster is enabled, which can be enabled by setting the
|
||||||
|
// environment variable
|
||||||
|
// "GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER" to
|
||||||
|
// "true".
|
||||||
|
AggregateAndDNSSupportEnv = strings.EqualFold(os.Getenv(aggregateAndDNSSupportEnv), "true")
|
||||||
|
|
||||||
|
// RetrySupport indicates whether xDS retry is enabled.
|
||||||
|
RetrySupport = !strings.EqualFold(os.Getenv(retrySupportEnv), "false")
|
||||||
|
|
||||||
|
// RBACSupport indicates whether xDS configured RBAC HTTP Filter is enabled.
|
||||||
|
RBACSupport = strings.EqualFold(os.Getenv(rbacSupportEnv), "true")
|
||||||
|
|
||||||
|
// C2PResolverSupport indicates whether support for C2P resolver is enabled.
|
||||||
|
// This can be enabled by setting the environment variable
|
||||||
|
// "GRPC_EXPERIMENTAL_GOOGLE_C2P_RESOLVER" to "true".
|
||||||
|
C2PResolverSupport = strings.EqualFold(os.Getenv(c2pResolverSupportEnv), "true")
|
||||||
|
// C2PResolverTestOnlyTrafficDirectorURI is the TD URI for testing.
|
||||||
|
C2PResolverTestOnlyTrafficDirectorURI = os.Getenv(c2pResolverTestOnlyTrafficDirectorURIEnv)
|
||||||
|
)
|
21
vendor/google.golang.org/grpc/pickfirst.go
generated
vendored
21
vendor/google.golang.org/grpc/pickfirst.go
generated
vendored
@ -107,10 +107,12 @@ func (b *pickfirstBalancer) UpdateSubConnState(sc balancer.SubConn, s balancer.S
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch s.ConnectivityState {
|
switch s.ConnectivityState {
|
||||||
case connectivity.Ready, connectivity.Idle:
|
case connectivity.Ready:
|
||||||
b.cc.UpdateState(balancer.State{ConnectivityState: s.ConnectivityState, Picker: &picker{result: balancer.PickResult{SubConn: sc}}})
|
b.cc.UpdateState(balancer.State{ConnectivityState: s.ConnectivityState, Picker: &picker{result: balancer.PickResult{SubConn: sc}}})
|
||||||
case connectivity.Connecting:
|
case connectivity.Connecting:
|
||||||
b.cc.UpdateState(balancer.State{ConnectivityState: s.ConnectivityState, Picker: &picker{err: balancer.ErrNoSubConnAvailable}})
|
b.cc.UpdateState(balancer.State{ConnectivityState: s.ConnectivityState, Picker: &picker{err: balancer.ErrNoSubConnAvailable}})
|
||||||
|
case connectivity.Idle:
|
||||||
|
b.cc.UpdateState(balancer.State{ConnectivityState: s.ConnectivityState, Picker: &idlePicker{sc: sc}})
|
||||||
case connectivity.TransientFailure:
|
case connectivity.TransientFailure:
|
||||||
b.cc.UpdateState(balancer.State{
|
b.cc.UpdateState(balancer.State{
|
||||||
ConnectivityState: s.ConnectivityState,
|
ConnectivityState: s.ConnectivityState,
|
||||||
@ -122,6 +124,12 @@ func (b *pickfirstBalancer) UpdateSubConnState(sc balancer.SubConn, s balancer.S
|
|||||||
func (b *pickfirstBalancer) Close() {
|
func (b *pickfirstBalancer) Close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *pickfirstBalancer) ExitIdle() {
|
||||||
|
if b.state == connectivity.Idle {
|
||||||
|
b.sc.Connect()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type picker struct {
|
type picker struct {
|
||||||
result balancer.PickResult
|
result balancer.PickResult
|
||||||
err error
|
err error
|
||||||
@ -131,6 +139,17 @@ func (p *picker) Pick(info balancer.PickInfo) (balancer.PickResult, error) {
|
|||||||
return p.result, p.err
|
return p.result, p.err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// idlePicker is used when the SubConn is IDLE and kicks the SubConn into
|
||||||
|
// CONNECTING when Pick is called.
|
||||||
|
type idlePicker struct {
|
||||||
|
sc balancer.SubConn
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *idlePicker) Pick(info balancer.PickInfo) (balancer.PickResult, error) {
|
||||||
|
i.sc.Connect()
|
||||||
|
return balancer.PickResult{}, balancer.ErrNoSubConnAvailable
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
balancer.Register(newPickfirstBuilder())
|
balancer.Register(newPickfirstBuilder())
|
||||||
}
|
}
|
||||||
|
50
vendor/google.golang.org/grpc/server.go
generated
vendored
50
vendor/google.golang.org/grpc/server.go
generated
vendored
@ -710,13 +710,6 @@ func (s *Server) GetServiceInfo() map[string]ServiceInfo {
|
|||||||
// the server being stopped.
|
// the server being stopped.
|
||||||
var ErrServerStopped = errors.New("grpc: the server has been stopped")
|
var ErrServerStopped = errors.New("grpc: the server has been stopped")
|
||||||
|
|
||||||
func (s *Server) useTransportAuthenticator(rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) {
|
|
||||||
if s.opts.creds == nil {
|
|
||||||
return rawConn, nil, nil
|
|
||||||
}
|
|
||||||
return s.opts.creds.ServerHandshake(rawConn)
|
|
||||||
}
|
|
||||||
|
|
||||||
type listenSocket struct {
|
type listenSocket struct {
|
||||||
net.Listener
|
net.Listener
|
||||||
channelzID int64
|
channelzID int64
|
||||||
@ -839,35 +832,14 @@ func (s *Server) handleRawConn(lisAddr string, rawConn net.Conn) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
rawConn.SetDeadline(time.Now().Add(s.opts.connectionTimeout))
|
rawConn.SetDeadline(time.Now().Add(s.opts.connectionTimeout))
|
||||||
conn, authInfo, err := s.useTransportAuthenticator(rawConn)
|
|
||||||
if err != nil {
|
|
||||||
// ErrConnDispatched means that the connection was dispatched away from
|
|
||||||
// gRPC; those connections should be left open.
|
|
||||||
if err != credentials.ErrConnDispatched {
|
|
||||||
// In deployments where a gRPC server runs behind a cloud load
|
|
||||||
// balancer which performs regular TCP level health checks, the
|
|
||||||
// connection is closed immediately by the latter. Skipping the
|
|
||||||
// error here will help reduce log clutter.
|
|
||||||
if err != io.EOF {
|
|
||||||
s.mu.Lock()
|
|
||||||
s.errorf("ServerHandshake(%q) failed: %v", rawConn.RemoteAddr(), err)
|
|
||||||
s.mu.Unlock()
|
|
||||||
channelz.Warningf(logger, s.channelzID, "grpc: Server.Serve failed to complete security handshake from %q: %v", rawConn.RemoteAddr(), err)
|
|
||||||
}
|
|
||||||
rawConn.Close()
|
|
||||||
}
|
|
||||||
rawConn.SetDeadline(time.Time{})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finish handshaking (HTTP2)
|
// Finish handshaking (HTTP2)
|
||||||
st := s.newHTTP2Transport(conn, authInfo)
|
st := s.newHTTP2Transport(rawConn)
|
||||||
|
rawConn.SetDeadline(time.Time{})
|
||||||
if st == nil {
|
if st == nil {
|
||||||
conn.Close()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
rawConn.SetDeadline(time.Time{})
|
|
||||||
if !s.addConn(lisAddr, st) {
|
if !s.addConn(lisAddr, st) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -888,10 +860,11 @@ func (s *Server) drainServerTransports(addr string) {
|
|||||||
|
|
||||||
// newHTTP2Transport sets up a http/2 transport (using the
|
// newHTTP2Transport sets up a http/2 transport (using the
|
||||||
// gRPC http2 server transport in transport/http2_server.go).
|
// gRPC http2 server transport in transport/http2_server.go).
|
||||||
func (s *Server) newHTTP2Transport(c net.Conn, authInfo credentials.AuthInfo) transport.ServerTransport {
|
func (s *Server) newHTTP2Transport(c net.Conn) transport.ServerTransport {
|
||||||
config := &transport.ServerConfig{
|
config := &transport.ServerConfig{
|
||||||
MaxStreams: s.opts.maxConcurrentStreams,
|
MaxStreams: s.opts.maxConcurrentStreams,
|
||||||
AuthInfo: authInfo,
|
ConnectionTimeout: s.opts.connectionTimeout,
|
||||||
|
Credentials: s.opts.creds,
|
||||||
InTapHandle: s.opts.inTapHandle,
|
InTapHandle: s.opts.inTapHandle,
|
||||||
StatsHandler: s.opts.statsHandler,
|
StatsHandler: s.opts.statsHandler,
|
||||||
KeepaliveParams: s.opts.keepaliveParams,
|
KeepaliveParams: s.opts.keepaliveParams,
|
||||||
@ -909,8 +882,17 @@ func (s *Server) newHTTP2Transport(c net.Conn, authInfo credentials.AuthInfo) tr
|
|||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
s.errorf("NewServerTransport(%q) failed: %v", c.RemoteAddr(), err)
|
s.errorf("NewServerTransport(%q) failed: %v", c.RemoteAddr(), err)
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
c.Close()
|
// ErrConnDispatched means that the connection was dispatched away from
|
||||||
channelz.Warning(logger, s.channelzID, "grpc: Server.Serve failed to create ServerTransport: ", err)
|
// gRPC; those connections should be left open.
|
||||||
|
if err != credentials.ErrConnDispatched {
|
||||||
|
c.Close()
|
||||||
|
}
|
||||||
|
// Don't log on ErrConnDispatched and io.EOF to prevent log spam.
|
||||||
|
if err != credentials.ErrConnDispatched {
|
||||||
|
if err != io.EOF {
|
||||||
|
channelz.Warning(logger, s.channelzID, "grpc: Server.Serve failed to create ServerTransport: ", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
vendor/google.golang.org/grpc/stats/stats.go
generated
vendored
7
vendor/google.golang.org/grpc/stats/stats.go
generated
vendored
@ -36,12 +36,12 @@ type RPCStats interface {
|
|||||||
IsClient() bool
|
IsClient() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Begin contains stats when an RPC begins.
|
// Begin contains stats when an RPC attempt begins.
|
||||||
// FailFast is only valid if this Begin is from client side.
|
// FailFast is only valid if this Begin is from client side.
|
||||||
type Begin struct {
|
type Begin struct {
|
||||||
// Client is true if this Begin is from client side.
|
// Client is true if this Begin is from client side.
|
||||||
Client bool
|
Client bool
|
||||||
// BeginTime is the time when the RPC begins.
|
// BeginTime is the time when the RPC attempt begins.
|
||||||
BeginTime time.Time
|
BeginTime time.Time
|
||||||
// FailFast indicates if this RPC is failfast.
|
// FailFast indicates if this RPC is failfast.
|
||||||
FailFast bool
|
FailFast bool
|
||||||
@ -49,6 +49,9 @@ type Begin struct {
|
|||||||
IsClientStream bool
|
IsClientStream bool
|
||||||
// IsServerStream indicates whether the RPC is a server streaming RPC.
|
// IsServerStream indicates whether the RPC is a server streaming RPC.
|
||||||
IsServerStream bool
|
IsServerStream bool
|
||||||
|
// IsTransparentRetryAttempt indicates whether this attempt was initiated
|
||||||
|
// due to transparently retrying a previous attempt.
|
||||||
|
IsTransparentRetryAttempt bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsClient indicates if the stats information is from client side.
|
// IsClient indicates if the stats information is from client side.
|
||||||
|
131
vendor/google.golang.org/grpc/stream.go
generated
vendored
131
vendor/google.golang.org/grpc/stream.go
generated
vendored
@ -274,35 +274,6 @@ func newClientStreamWithParams(ctx context.Context, desc *StreamDesc, cc *Client
|
|||||||
if c.creds != nil {
|
if c.creds != nil {
|
||||||
callHdr.Creds = c.creds
|
callHdr.Creds = c.creds
|
||||||
}
|
}
|
||||||
var trInfo *traceInfo
|
|
||||||
if EnableTracing {
|
|
||||||
trInfo = &traceInfo{
|
|
||||||
tr: trace.New("grpc.Sent."+methodFamily(method), method),
|
|
||||||
firstLine: firstLine{
|
|
||||||
client: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
if deadline, ok := ctx.Deadline(); ok {
|
|
||||||
trInfo.firstLine.deadline = time.Until(deadline)
|
|
||||||
}
|
|
||||||
trInfo.tr.LazyLog(&trInfo.firstLine, false)
|
|
||||||
ctx = trace.NewContext(ctx, trInfo.tr)
|
|
||||||
}
|
|
||||||
ctx = newContextWithRPCInfo(ctx, c.failFast, c.codec, cp, comp)
|
|
||||||
sh := cc.dopts.copts.StatsHandler
|
|
||||||
var beginTime time.Time
|
|
||||||
if sh != nil {
|
|
||||||
ctx = sh.TagRPC(ctx, &stats.RPCTagInfo{FullMethodName: method, FailFast: c.failFast})
|
|
||||||
beginTime = time.Now()
|
|
||||||
begin := &stats.Begin{
|
|
||||||
Client: true,
|
|
||||||
BeginTime: beginTime,
|
|
||||||
FailFast: c.failFast,
|
|
||||||
IsClientStream: desc.ClientStreams,
|
|
||||||
IsServerStream: desc.ServerStreams,
|
|
||||||
}
|
|
||||||
sh.HandleRPC(ctx, begin)
|
|
||||||
}
|
|
||||||
|
|
||||||
cs := &clientStream{
|
cs := &clientStream{
|
||||||
callHdr: callHdr,
|
callHdr: callHdr,
|
||||||
@ -316,7 +287,6 @@ func newClientStreamWithParams(ctx context.Context, desc *StreamDesc, cc *Client
|
|||||||
cp: cp,
|
cp: cp,
|
||||||
comp: comp,
|
comp: comp,
|
||||||
cancel: cancel,
|
cancel: cancel,
|
||||||
beginTime: beginTime,
|
|
||||||
firstAttempt: true,
|
firstAttempt: true,
|
||||||
onCommit: onCommit,
|
onCommit: onCommit,
|
||||||
}
|
}
|
||||||
@ -325,9 +295,7 @@ func newClientStreamWithParams(ctx context.Context, desc *StreamDesc, cc *Client
|
|||||||
}
|
}
|
||||||
cs.binlog = binarylog.GetMethodLogger(method)
|
cs.binlog = binarylog.GetMethodLogger(method)
|
||||||
|
|
||||||
// Only this initial attempt has stats/tracing.
|
if err := cs.newAttemptLocked(false /* isTransparent */); err != nil {
|
||||||
// TODO(dfawley): move to newAttempt when per-attempt stats are implemented.
|
|
||||||
if err := cs.newAttemptLocked(sh, trInfo); err != nil {
|
|
||||||
cs.finish(err)
|
cs.finish(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -375,8 +343,43 @@ func newClientStreamWithParams(ctx context.Context, desc *StreamDesc, cc *Client
|
|||||||
|
|
||||||
// newAttemptLocked creates a new attempt with a transport.
|
// newAttemptLocked creates a new attempt with a transport.
|
||||||
// If it succeeds, then it replaces clientStream's attempt with this new attempt.
|
// If it succeeds, then it replaces clientStream's attempt with this new attempt.
|
||||||
func (cs *clientStream) newAttemptLocked(sh stats.Handler, trInfo *traceInfo) (retErr error) {
|
func (cs *clientStream) newAttemptLocked(isTransparent bool) (retErr error) {
|
||||||
|
ctx := newContextWithRPCInfo(cs.ctx, cs.callInfo.failFast, cs.callInfo.codec, cs.cp, cs.comp)
|
||||||
|
method := cs.callHdr.Method
|
||||||
|
sh := cs.cc.dopts.copts.StatsHandler
|
||||||
|
var beginTime time.Time
|
||||||
|
if sh != nil {
|
||||||
|
ctx = sh.TagRPC(ctx, &stats.RPCTagInfo{FullMethodName: method, FailFast: cs.callInfo.failFast})
|
||||||
|
beginTime = time.Now()
|
||||||
|
begin := &stats.Begin{
|
||||||
|
Client: true,
|
||||||
|
BeginTime: beginTime,
|
||||||
|
FailFast: cs.callInfo.failFast,
|
||||||
|
IsClientStream: cs.desc.ClientStreams,
|
||||||
|
IsServerStream: cs.desc.ServerStreams,
|
||||||
|
IsTransparentRetryAttempt: isTransparent,
|
||||||
|
}
|
||||||
|
sh.HandleRPC(ctx, begin)
|
||||||
|
}
|
||||||
|
|
||||||
|
var trInfo *traceInfo
|
||||||
|
if EnableTracing {
|
||||||
|
trInfo = &traceInfo{
|
||||||
|
tr: trace.New("grpc.Sent."+methodFamily(method), method),
|
||||||
|
firstLine: firstLine{
|
||||||
|
client: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if deadline, ok := ctx.Deadline(); ok {
|
||||||
|
trInfo.firstLine.deadline = time.Until(deadline)
|
||||||
|
}
|
||||||
|
trInfo.tr.LazyLog(&trInfo.firstLine, false)
|
||||||
|
ctx = trace.NewContext(ctx, trInfo.tr)
|
||||||
|
}
|
||||||
|
|
||||||
newAttempt := &csAttempt{
|
newAttempt := &csAttempt{
|
||||||
|
ctx: ctx,
|
||||||
|
beginTime: beginTime,
|
||||||
cs: cs,
|
cs: cs,
|
||||||
dc: cs.cc.dopts.dc,
|
dc: cs.cc.dopts.dc,
|
||||||
statsHandler: sh,
|
statsHandler: sh,
|
||||||
@ -391,15 +394,14 @@ func (cs *clientStream) newAttemptLocked(sh stats.Handler, trInfo *traceInfo) (r
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err := cs.ctx.Err(); err != nil {
|
if err := ctx.Err(); err != nil {
|
||||||
return toRPCErr(err)
|
return toRPCErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := cs.ctx
|
|
||||||
if cs.cc.parsedTarget.Scheme == "xds" {
|
if cs.cc.parsedTarget.Scheme == "xds" {
|
||||||
// Add extra metadata (metadata that will be added by transport) to context
|
// Add extra metadata (metadata that will be added by transport) to context
|
||||||
// so the balancer can see them.
|
// so the balancer can see them.
|
||||||
ctx = grpcutil.WithExtraMetadata(cs.ctx, metadata.Pairs(
|
ctx = grpcutil.WithExtraMetadata(ctx, metadata.Pairs(
|
||||||
"content-type", grpcutil.ContentType(cs.callHdr.ContentSubtype),
|
"content-type", grpcutil.ContentType(cs.callHdr.ContentSubtype),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -419,7 +421,7 @@ func (cs *clientStream) newAttemptLocked(sh stats.Handler, trInfo *traceInfo) (r
|
|||||||
func (a *csAttempt) newStream() error {
|
func (a *csAttempt) newStream() error {
|
||||||
cs := a.cs
|
cs := a.cs
|
||||||
cs.callHdr.PreviousAttempts = cs.numRetries
|
cs.callHdr.PreviousAttempts = cs.numRetries
|
||||||
s, err := a.t.NewStream(cs.ctx, cs.callHdr)
|
s, err := a.t.NewStream(a.ctx, cs.callHdr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Return without converting to an RPC error so retry code can
|
// Return without converting to an RPC error so retry code can
|
||||||
// inspect.
|
// inspect.
|
||||||
@ -444,8 +446,7 @@ type clientStream struct {
|
|||||||
|
|
||||||
cancel context.CancelFunc // cancels all attempts
|
cancel context.CancelFunc // cancels all attempts
|
||||||
|
|
||||||
sentLast bool // sent an end stream
|
sentLast bool // sent an end stream
|
||||||
beginTime time.Time
|
|
||||||
|
|
||||||
methodConfig *MethodConfig
|
methodConfig *MethodConfig
|
||||||
|
|
||||||
@ -485,6 +486,7 @@ type clientStream struct {
|
|||||||
// csAttempt implements a single transport stream attempt within a
|
// csAttempt implements a single transport stream attempt within a
|
||||||
// clientStream.
|
// clientStream.
|
||||||
type csAttempt struct {
|
type csAttempt struct {
|
||||||
|
ctx context.Context
|
||||||
cs *clientStream
|
cs *clientStream
|
||||||
t transport.ClientTransport
|
t transport.ClientTransport
|
||||||
s *transport.Stream
|
s *transport.Stream
|
||||||
@ -503,6 +505,7 @@ type csAttempt struct {
|
|||||||
trInfo *traceInfo
|
trInfo *traceInfo
|
||||||
|
|
||||||
statsHandler stats.Handler
|
statsHandler stats.Handler
|
||||||
|
beginTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *clientStream) commitAttemptLocked() {
|
func (cs *clientStream) commitAttemptLocked() {
|
||||||
@ -520,15 +523,16 @@ func (cs *clientStream) commitAttempt() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// shouldRetry returns nil if the RPC should be retried; otherwise it returns
|
// shouldRetry returns nil if the RPC should be retried; otherwise it returns
|
||||||
// the error that should be returned by the operation.
|
// the error that should be returned by the operation. If the RPC should be
|
||||||
func (cs *clientStream) shouldRetry(err error) error {
|
// retried, the bool indicates whether it is being retried transparently.
|
||||||
|
func (cs *clientStream) shouldRetry(err error) (bool, error) {
|
||||||
if cs.attempt.s == nil {
|
if cs.attempt.s == nil {
|
||||||
// Error from NewClientStream.
|
// Error from NewClientStream.
|
||||||
nse, ok := err.(*transport.NewStreamError)
|
nse, ok := err.(*transport.NewStreamError)
|
||||||
if !ok {
|
if !ok {
|
||||||
// Unexpected, but assume no I/O was performed and the RPC is not
|
// Unexpected, but assume no I/O was performed and the RPC is not
|
||||||
// fatal, so retry indefinitely.
|
// fatal, so retry indefinitely.
|
||||||
return nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unwrap and convert error.
|
// Unwrap and convert error.
|
||||||
@ -537,19 +541,19 @@ func (cs *clientStream) shouldRetry(err error) error {
|
|||||||
// Never retry DoNotRetry errors, which indicate the RPC should not be
|
// Never retry DoNotRetry errors, which indicate the RPC should not be
|
||||||
// retried due to max header list size violation, etc.
|
// retried due to max header list size violation, etc.
|
||||||
if nse.DoNotRetry {
|
if nse.DoNotRetry {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// In the event of a non-IO operation error from NewStream, we never
|
// In the event of a non-IO operation error from NewStream, we never
|
||||||
// attempted to write anything to the wire, so we can retry
|
// attempted to write anything to the wire, so we can retry
|
||||||
// indefinitely.
|
// indefinitely.
|
||||||
if !nse.PerformedIO {
|
if !nse.DoNotTransparentRetry {
|
||||||
return nil
|
return true, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if cs.finished || cs.committed {
|
if cs.finished || cs.committed {
|
||||||
// RPC is finished or committed; cannot retry.
|
// RPC is finished or committed; cannot retry.
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
// Wait for the trailers.
|
// Wait for the trailers.
|
||||||
unprocessed := false
|
unprocessed := false
|
||||||
@ -559,17 +563,17 @@ func (cs *clientStream) shouldRetry(err error) error {
|
|||||||
}
|
}
|
||||||
if cs.firstAttempt && unprocessed {
|
if cs.firstAttempt && unprocessed {
|
||||||
// First attempt, stream unprocessed: transparently retry.
|
// First attempt, stream unprocessed: transparently retry.
|
||||||
return nil
|
return true, nil
|
||||||
}
|
}
|
||||||
if cs.cc.dopts.disableRetry {
|
if cs.cc.dopts.disableRetry {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
pushback := 0
|
pushback := 0
|
||||||
hasPushback := false
|
hasPushback := false
|
||||||
if cs.attempt.s != nil {
|
if cs.attempt.s != nil {
|
||||||
if !cs.attempt.s.TrailersOnly() {
|
if !cs.attempt.s.TrailersOnly() {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(retry): Move down if the spec changes to not check server pushback
|
// TODO(retry): Move down if the spec changes to not check server pushback
|
||||||
@ -580,13 +584,13 @@ func (cs *clientStream) shouldRetry(err error) error {
|
|||||||
if pushback, e = strconv.Atoi(sps[0]); e != nil || pushback < 0 {
|
if pushback, e = strconv.Atoi(sps[0]); e != nil || pushback < 0 {
|
||||||
channelz.Infof(logger, cs.cc.channelzID, "Server retry pushback specified to abort (%q).", sps[0])
|
channelz.Infof(logger, cs.cc.channelzID, "Server retry pushback specified to abort (%q).", sps[0])
|
||||||
cs.retryThrottler.throttle() // This counts as a failure for throttling.
|
cs.retryThrottler.throttle() // This counts as a failure for throttling.
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
hasPushback = true
|
hasPushback = true
|
||||||
} else if len(sps) > 1 {
|
} else if len(sps) > 1 {
|
||||||
channelz.Warningf(logger, cs.cc.channelzID, "Server retry pushback specified multiple values (%q); not retrying.", sps)
|
channelz.Warningf(logger, cs.cc.channelzID, "Server retry pushback specified multiple values (%q); not retrying.", sps)
|
||||||
cs.retryThrottler.throttle() // This counts as a failure for throttling.
|
cs.retryThrottler.throttle() // This counts as a failure for throttling.
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -599,16 +603,16 @@ func (cs *clientStream) shouldRetry(err error) error {
|
|||||||
|
|
||||||
rp := cs.methodConfig.RetryPolicy
|
rp := cs.methodConfig.RetryPolicy
|
||||||
if rp == nil || !rp.RetryableStatusCodes[code] {
|
if rp == nil || !rp.RetryableStatusCodes[code] {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: the ordering here is important; we count this as a failure
|
// Note: the ordering here is important; we count this as a failure
|
||||||
// only if the code matched a retryable code.
|
// only if the code matched a retryable code.
|
||||||
if cs.retryThrottler.throttle() {
|
if cs.retryThrottler.throttle() {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
if cs.numRetries+1 >= rp.MaxAttempts {
|
if cs.numRetries+1 >= rp.MaxAttempts {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var dur time.Duration
|
var dur time.Duration
|
||||||
@ -631,10 +635,10 @@ func (cs *clientStream) shouldRetry(err error) error {
|
|||||||
select {
|
select {
|
||||||
case <-t.C:
|
case <-t.C:
|
||||||
cs.numRetries++
|
cs.numRetries++
|
||||||
return nil
|
return false, nil
|
||||||
case <-cs.ctx.Done():
|
case <-cs.ctx.Done():
|
||||||
t.Stop()
|
t.Stop()
|
||||||
return status.FromContextError(cs.ctx.Err()).Err()
|
return false, status.FromContextError(cs.ctx.Err()).Err()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -642,12 +646,13 @@ func (cs *clientStream) shouldRetry(err error) error {
|
|||||||
func (cs *clientStream) retryLocked(lastErr error) error {
|
func (cs *clientStream) retryLocked(lastErr error) error {
|
||||||
for {
|
for {
|
||||||
cs.attempt.finish(toRPCErr(lastErr))
|
cs.attempt.finish(toRPCErr(lastErr))
|
||||||
if err := cs.shouldRetry(lastErr); err != nil {
|
isTransparent, err := cs.shouldRetry(lastErr)
|
||||||
|
if err != nil {
|
||||||
cs.commitAttemptLocked()
|
cs.commitAttemptLocked()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cs.firstAttempt = false
|
cs.firstAttempt = false
|
||||||
if err := cs.newAttemptLocked(nil, nil); err != nil {
|
if err := cs.newAttemptLocked(isTransparent); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if lastErr = cs.replayBufferLocked(); lastErr == nil {
|
if lastErr = cs.replayBufferLocked(); lastErr == nil {
|
||||||
@ -937,7 +942,7 @@ func (a *csAttempt) sendMsg(m interface{}, hdr, payld, data []byte) error {
|
|||||||
return io.EOF
|
return io.EOF
|
||||||
}
|
}
|
||||||
if a.statsHandler != nil {
|
if a.statsHandler != nil {
|
||||||
a.statsHandler.HandleRPC(cs.ctx, outPayload(true, m, data, payld, time.Now()))
|
a.statsHandler.HandleRPC(a.ctx, outPayload(true, m, data, payld, time.Now()))
|
||||||
}
|
}
|
||||||
if channelz.IsOn() {
|
if channelz.IsOn() {
|
||||||
a.t.IncrMsgSent()
|
a.t.IncrMsgSent()
|
||||||
@ -985,7 +990,7 @@ func (a *csAttempt) recvMsg(m interface{}, payInfo *payloadInfo) (err error) {
|
|||||||
a.mu.Unlock()
|
a.mu.Unlock()
|
||||||
}
|
}
|
||||||
if a.statsHandler != nil {
|
if a.statsHandler != nil {
|
||||||
a.statsHandler.HandleRPC(cs.ctx, &stats.InPayload{
|
a.statsHandler.HandleRPC(a.ctx, &stats.InPayload{
|
||||||
Client: true,
|
Client: true,
|
||||||
RecvTime: time.Now(),
|
RecvTime: time.Now(),
|
||||||
Payload: m,
|
Payload: m,
|
||||||
@ -1047,12 +1052,12 @@ func (a *csAttempt) finish(err error) {
|
|||||||
if a.statsHandler != nil {
|
if a.statsHandler != nil {
|
||||||
end := &stats.End{
|
end := &stats.End{
|
||||||
Client: true,
|
Client: true,
|
||||||
BeginTime: a.cs.beginTime,
|
BeginTime: a.beginTime,
|
||||||
EndTime: time.Now(),
|
EndTime: time.Now(),
|
||||||
Trailer: tr,
|
Trailer: tr,
|
||||||
Error: err,
|
Error: err,
|
||||||
}
|
}
|
||||||
a.statsHandler.HandleRPC(a.cs.ctx, end)
|
a.statsHandler.HandleRPC(a.ctx, end)
|
||||||
}
|
}
|
||||||
if a.trInfo != nil && a.trInfo.tr != nil {
|
if a.trInfo != nil && a.trInfo.tr != nil {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
2
vendor/google.golang.org/grpc/version.go
generated
vendored
2
vendor/google.golang.org/grpc/version.go
generated
vendored
@ -19,4 +19,4 @@
|
|||||||
package grpc
|
package grpc
|
||||||
|
|
||||||
// Version is the current grpc version.
|
// Version is the current grpc version.
|
||||||
const Version = "1.40.0"
|
const Version = "1.41.0"
|
||||||
|
4
vendor/google.golang.org/grpc/vet.sh
generated
vendored
4
vendor/google.golang.org/grpc/vet.sh
generated
vendored
@ -89,10 +89,6 @@ not git grep "\(import \|^\s*\)\"github.com/golang/protobuf/ptypes/" -- "*.go"
|
|||||||
# - Ensure all xds proto imports are renamed to *pb or *grpc.
|
# - Ensure all xds proto imports are renamed to *pb or *grpc.
|
||||||
git grep '"github.com/envoyproxy/go-control-plane/envoy' -- '*.go' ':(exclude)*.pb.go' | not grep -v 'pb "\|grpc "'
|
git grep '"github.com/envoyproxy/go-control-plane/envoy' -- '*.go' ':(exclude)*.pb.go' | not grep -v 'pb "\|grpc "'
|
||||||
|
|
||||||
# - Check imports that are illegal in appengine (until Go 1.11).
|
|
||||||
# TODO: Remove when we drop Go 1.10 support
|
|
||||||
go list -f {{.Dir}} ./... | xargs go run test/go_vet/vet.go
|
|
||||||
|
|
||||||
misspell -error .
|
misspell -error .
|
||||||
|
|
||||||
# - Check that generated proto files are up to date.
|
# - Check that generated proto files are up to date.
|
||||||
|
22
vendor/modules.txt
vendored
22
vendor/modules.txt
vendored
@ -142,7 +142,7 @@ github.com/containers/common/version
|
|||||||
# github.com/containers/conmon v2.0.20+incompatible
|
# github.com/containers/conmon v2.0.20+incompatible
|
||||||
## explicit
|
## explicit
|
||||||
github.com/containers/conmon/runner/config
|
github.com/containers/conmon/runner/config
|
||||||
# github.com/containers/image/v5 v5.16.1
|
# github.com/containers/image/v5 v5.17.0
|
||||||
## explicit
|
## explicit
|
||||||
github.com/containers/image/v5/copy
|
github.com/containers/image/v5/copy
|
||||||
github.com/containers/image/v5/directory
|
github.com/containers/image/v5/directory
|
||||||
@ -160,6 +160,7 @@ github.com/containers/image/v5/internal/pkg/keyctl
|
|||||||
github.com/containers/image/v5/internal/pkg/platform
|
github.com/containers/image/v5/internal/pkg/platform
|
||||||
github.com/containers/image/v5/internal/putblobdigest
|
github.com/containers/image/v5/internal/putblobdigest
|
||||||
github.com/containers/image/v5/internal/rootless
|
github.com/containers/image/v5/internal/rootless
|
||||||
|
github.com/containers/image/v5/internal/streamdigest
|
||||||
github.com/containers/image/v5/internal/tmpdir
|
github.com/containers/image/v5/internal/tmpdir
|
||||||
github.com/containers/image/v5/internal/types
|
github.com/containers/image/v5/internal/types
|
||||||
github.com/containers/image/v5/internal/uploadreader
|
github.com/containers/image/v5/internal/uploadreader
|
||||||
@ -385,7 +386,7 @@ github.com/gogo/protobuf/gogoproto
|
|||||||
github.com/gogo/protobuf/proto
|
github.com/gogo/protobuf/proto
|
||||||
github.com/gogo/protobuf/protoc-gen-gogo/descriptor
|
github.com/gogo/protobuf/protoc-gen-gogo/descriptor
|
||||||
github.com/gogo/protobuf/sortkeys
|
github.com/gogo/protobuf/sortkeys
|
||||||
# github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e
|
# github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
|
||||||
github.com/golang/groupcache/lru
|
github.com/golang/groupcache/lru
|
||||||
# github.com/golang/protobuf v1.5.2
|
# github.com/golang/protobuf v1.5.2
|
||||||
github.com/golang/protobuf/proto
|
github.com/golang/protobuf/proto
|
||||||
@ -441,9 +442,6 @@ github.com/jinzhu/copier
|
|||||||
# github.com/json-iterator/go v1.1.12
|
# github.com/json-iterator/go v1.1.12
|
||||||
## explicit
|
## explicit
|
||||||
github.com/json-iterator/go
|
github.com/json-iterator/go
|
||||||
# github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a
|
|
||||||
github.com/juju/ansiterm
|
|
||||||
github.com/juju/ansiterm/tabwriter
|
|
||||||
# github.com/klauspost/compress v1.13.6
|
# github.com/klauspost/compress v1.13.6
|
||||||
github.com/klauspost/compress
|
github.com/klauspost/compress
|
||||||
github.com/klauspost/compress/flate
|
github.com/klauspost/compress/flate
|
||||||
@ -454,15 +452,10 @@ github.com/klauspost/compress/zstd
|
|||||||
github.com/klauspost/compress/zstd/internal/xxhash
|
github.com/klauspost/compress/zstd/internal/xxhash
|
||||||
# github.com/klauspost/pgzip v1.2.5
|
# github.com/klauspost/pgzip v1.2.5
|
||||||
github.com/klauspost/pgzip
|
github.com/klauspost/pgzip
|
||||||
# github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a
|
# github.com/manifoldco/promptui v0.9.0
|
||||||
github.com/lunixbochs/vtclean
|
|
||||||
# github.com/manifoldco/promptui v0.8.0
|
|
||||||
github.com/manifoldco/promptui
|
github.com/manifoldco/promptui
|
||||||
github.com/manifoldco/promptui/list
|
github.com/manifoldco/promptui/list
|
||||||
github.com/manifoldco/promptui/screenbuf
|
github.com/manifoldco/promptui/screenbuf
|
||||||
# github.com/mattn/go-colorable v0.1.8
|
|
||||||
## explicit
|
|
||||||
github.com/mattn/go-colorable
|
|
||||||
# github.com/mattn/go-isatty v0.0.14
|
# github.com/mattn/go-isatty v0.0.14
|
||||||
## explicit
|
## explicit
|
||||||
github.com/mattn/go-isatty
|
github.com/mattn/go-isatty
|
||||||
@ -751,7 +744,7 @@ golang.org/x/sys/unix
|
|||||||
golang.org/x/sys/windows
|
golang.org/x/sys/windows
|
||||||
# golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b
|
# golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b
|
||||||
golang.org/x/term
|
golang.org/x/term
|
||||||
# golang.org/x/text v0.3.6
|
# golang.org/x/text v0.3.7
|
||||||
golang.org/x/text/encoding
|
golang.org/x/text/encoding
|
||||||
golang.org/x/text/encoding/charmap
|
golang.org/x/text/encoding/charmap
|
||||||
golang.org/x/text/encoding/htmlindex
|
golang.org/x/text/encoding/htmlindex
|
||||||
@ -774,9 +767,9 @@ golang.org/x/text/unicode/bidi
|
|||||||
golang.org/x/text/unicode/norm
|
golang.org/x/text/unicode/norm
|
||||||
# golang.org/x/tools v0.1.2
|
# golang.org/x/tools v0.1.2
|
||||||
golang.org/x/tools/go/ast/inspector
|
golang.org/x/tools/go/ast/inspector
|
||||||
# google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c
|
# google.golang.org/genproto v0.0.0-20211005153810-c76a74d43a8e
|
||||||
google.golang.org/genproto/googleapis/rpc/status
|
google.golang.org/genproto/googleapis/rpc/status
|
||||||
# google.golang.org/grpc v1.40.0
|
# google.golang.org/grpc v1.41.0
|
||||||
google.golang.org/grpc
|
google.golang.org/grpc
|
||||||
google.golang.org/grpc/attributes
|
google.golang.org/grpc/attributes
|
||||||
google.golang.org/grpc/backoff
|
google.golang.org/grpc/backoff
|
||||||
@ -813,6 +806,7 @@ google.golang.org/grpc/internal/status
|
|||||||
google.golang.org/grpc/internal/syscall
|
google.golang.org/grpc/internal/syscall
|
||||||
google.golang.org/grpc/internal/transport
|
google.golang.org/grpc/internal/transport
|
||||||
google.golang.org/grpc/internal/transport/networktype
|
google.golang.org/grpc/internal/transport/networktype
|
||||||
|
google.golang.org/grpc/internal/xds/env
|
||||||
google.golang.org/grpc/keepalive
|
google.golang.org/grpc/keepalive
|
||||||
google.golang.org/grpc/metadata
|
google.golang.org/grpc/metadata
|
||||||
google.golang.org/grpc/peer
|
google.golang.org/grpc/peer
|
||||||
|
Reference in New Issue
Block a user