diff --git a/go.mod b/go.mod index 1d6a13c4452..9e19dbbe1e7 100644 --- a/go.mod +++ b/go.mod @@ -10,11 +10,10 @@ require ( github.com/ghodss/yaml v1.0.0 github.com/go-openapi/spec v0.20.2 github.com/gogo/protobuf v1.3.2 // indirect - github.com/google/go-cmp v0.5.4 + github.com/google/go-cmp v0.5.5 github.com/google/go-containerregistry v0.4.1-0.20210128200529-19c2b639fab1 github.com/google/go-containerregistry/pkg/authn/k8schain v0.0.0-20210129212729-5c4818de4025 - github.com/google/gofuzz v1.2.0 // indirect - github.com/google/uuid v1.1.2 + github.com/google/uuid v1.2.0 github.com/googleapis/gnostic v0.5.3 // indirect github.com/hashicorp/go-multierror v1.1.0 github.com/hashicorp/golang-lru v0.5.4 @@ -24,7 +23,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.7.0 // indirect github.com/tektoncd/plumbing v0.0.0-20210420200944-17170d5e7bc9 - go.opencensus.io v0.22.5 + go.opencensus.io v0.23.0 go.uber.org/zap v1.16.0 golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect golang.org/x/mod v0.4.1 // indirect @@ -42,7 +41,7 @@ require ( k8s.io/klog v1.0.0 k8s.io/kube-openapi v0.0.0-20210113233702-8566a335510f k8s.io/utils v0.0.0-20210111153108-fddb29f9d009 // indirect - knative.dev/pkg v0.0.0-20210127163530-0d31134d5f4e + knative.dev/pkg v0.0.0-20210331065221-952fdd90dbb0 ) // Knative deps (release-0.20) diff --git a/go.sum b/go.sum index c7960b83440..d4b664e820c 100644 --- a/go.sum +++ b/go.sum @@ -152,7 +152,7 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cloudevents/sdk-go/v2 v2.1.0 h1:bmgrU8k+K2ppZ+G/q5xEQx/Xk9HRtJmkrEO3qtDO2k0= github.com/cloudevents/sdk-go/v2 v2.1.0/go.mod h1:3CTrpB4+u7Iaj6fd7E2Xvm5IxMdRoaAhqaRVnOr2rCU= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -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/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/containerd/containerd v1.3.0/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= @@ -182,13 +182,11 @@ github.com/dgryski/go-gk v0.0.0-20200319235926-a69029f61654/go.mod h1:qm+vckxRlD github.com/dgryski/go-lttb v0.0.0-20180810165845-318fcdf10a77/go.mod h1:Va5MyIzkU0rAM92tn3hb3Anb7oz7KcnixF49+2wOMe4= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= -github.com/docker/cli v0.0.0-20191017083524-a8ff7f821017 h1:2HQmlpI3yI9deH18Q6xiSOIjXD4sLI55Y/gfpa8/558= github.com/docker/cli v0.0.0-20191017083524-a8ff7f821017/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/cli v20.10.2+incompatible h1:CR/6BZX5w3TLgAHZTyRpVh3yi+Q8Sj5j1fCsb0J2rCk= github.com/docker/cli v20.10.2+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v1.4.2-0.20190924003213-a8608b5b67c7 h1:Cvj7S8I4Xpx78KAl6TwTmMHuHlZ/0SM60NUneGJQ7IE= github.com/docker/docker v1.4.2-0.20190924003213-a8608b5b67c7/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v20.10.2+incompatible h1:vFgEHPqWBTp4pTjdLwjAA4bSo3gvIGOYwuJTlEjVBCw= github.com/docker/docker v20.10.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= @@ -208,17 +206,15 @@ github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaB github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful v2.9.5+incompatible h1:spTtZBk5DYEvbxMVutUuTyh1Ao2r4iyvLdACqsl/Ljk= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.15.0+incompatible h1:8KpYO/Xl/ZudZs5RNOEhWMBY4hmzlZhhRd9cu+jrZP4= github.com/emicklei/go-restful v2.15.0+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.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.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= @@ -308,9 +304,8 @@ github.com/go-openapi/validate v0.19.5/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85n github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gobuffalo/envy v1.6.5/go.mod h1:N+GkhhZ/93bGZc6ZKhJLP6+m+tCNPKwgSpH9kaifseQ= -github.com/gobuffalo/envy v1.7.1 h1:OQl5ys5MBea7OGCdvPbBJWRgnhC/fGona6QKfvFeau8= -github.com/gobuffalo/envy v1.7.1/go.mod h1:FurDp9+EDPE4aIUS3ZLyD+7/9fpx7YRt/ukY6jIHf0w= +github.com/gobuffalo/flect v0.2.2 h1:PAVD7sp0KOdfswjAw9BpLCU9hXo7wFSzgpQ+zNeks/A= +github.com/gobuffalo/flect v0.2.2/go.mod h1:vmkQwuZYhN5Pc4ljYQZzP+1sq+NEkK+lh20jmEmX3jc= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -319,7 +314,6 @@ github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zV github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -370,21 +364,21 @@ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-containerregistry v0.4.1-0.20210128200529-19c2b639fab1 h1:o2ykCuuhHeUwtzNg89pH2hi+821aqjLWkaREVR3ziTQ= github.com/google/go-containerregistry v0.4.1-0.20210128200529-19c2b639fab1/go.mod h1:GU9FUA/X9rd2cV3ZoUNaWihp27tki6/38EsVzL2Dyzc= github.com/google/go-containerregistry/pkg/authn/k8schain v0.0.0-20210129212729-5c4818de4025 h1:3o5qj2tOnL5eMB9b8YbcJ25sJI8oLrfy6Z0YYZl6lGY= github.com/google/go-containerregistry/pkg/authn/k8schain v0.0.0-20210129212729-5c4818de4025/go.mod h1:n9wRxRfKkHy6ZFyj0jJQHw11P+mGLnED4sqegwrXxDk= github.com/google/go-github/v27 v27.0.6/go.mod h1:/0Gr8pJ55COkmv+S/yPKCczSkUPIM/LnFyubufRNIS0= -github.com/google/go-licenses v0.0.0-20200602185517-f29a4c695c3d h1:r8YwMrdIrMvQUlRJT/D5BCIy42bMMxS7zxV89k0i3ik= github.com/google/go-licenses v0.0.0-20200602185517-f29a4c695c3d/go.mod h1:g1VOUGKZYIqe8lDq2mL7plhAWXqrEaGUs7eIjthN1sk= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/licenseclassifier v0.0.0-20190926221455-842c0d70d702 h1:nVgx26pAe6l/02mYomOuZssv28XkacGw/0WeiTVorqw= github.com/google/licenseclassifier v0.0.0-20190926221455-842c0d70d702/go.mod h1:qsqn2hxC+vURpyBRygGUuinTO42MFRLcsmQ/P8v94+M= github.com/google/mako v0.0.0-20190821191249-122f8dcef9e3/go.mod h1:YzLcVlL+NqWnmUEPuhS1LxDDwGO9WNbVlEXaF4IH35g= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -401,8 +395,9 @@ github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLe github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs= +github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= @@ -468,7 +463,6 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/influxdata/tdigest v0.0.0-20180711151920-a7d76c6f093a/go.mod h1:9GkyshztGufsdPQWjH+ifgnIr3xNUL5syI70g2dzU1o= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jenkins-x/go-scm v1.5.117 h1:D7d1sDWUU+xocCNLQVoYKpMjVKnQvsPva+hPzruchbM= github.com/jenkins-x/go-scm v1.5.117/go.mod h1:PCT338UhP/pQ0IeEeMEf/hoLTYKcH7qjGEKd7jPkeYg= @@ -477,8 +471,6 @@ github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc= github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8= -github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= @@ -496,7 +488,6 @@ github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8= github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= -github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY= github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= @@ -528,8 +519,6 @@ github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7 github.com/mailru/easyjson v0.7.1-0.20191009090205-6c0755d89d1e/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA= github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/markbates/inflect v1.0.4 h1:5fh1gzTFhfae06u3hzHYO9xe3l3v3nW5Pwt3naLTP5g= -github.com/markbates/inflect v1.0.4/go.mod h1:1fR9+pO2KHEO9ZRtto13gDwwZaAKstQzferVeWqbgNs= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= 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= @@ -612,7 +601,6 @@ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnh github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.5 h1:UwtQQx2pyPIgWYHRg+epgdx1/HnBQTgN3/oIYEJTQzU= github.com/openzipkin/zipkin-go v0.2.5/go.mod h1:KpXfKdgRDnnhsxw4pNIH9Md5lyFqKUa4YDFlwRYAMyE= -github.com/otiai10/copy v1.2.0 h1:HvG945u96iNadPoG2/Ja2+AUJeW5YuFQMixq9yirC+k= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= @@ -643,8 +631,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.2.1/go.mod h1:XMU6Z2MjaRKVu/dC1qupJI9SiNkDYzz3xecMgSW/F+U= github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.8.0 h1:zvJNkoCFAnYFNC24FV8nW4JdRJ3GIFcLbg65lL/JDcw= -github.com/prometheus/client_golang v1.8.0/go.mod h1:O9VU6huf47PktckDQfMTX0Y8tY0/7TSWwj+ITvv0TnM= +github.com/prometheus/client_golang v1.9.0 h1:Rrch9mh17XcxvEu9D9DEpb4isxjGBtcevQjKvxPRQIU= +github.com/prometheus/client_golang v1.9.0/go.mod h1:FqZLKOZnGdFAhOK4nqGHa7D66IdsO+O441Eve7ptJDU= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -658,9 +646,9 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.14.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.15.0 h1:4fgOnadei3EZvgRwxJ7RMpG1k1pOZth5Pc13tyspaKM= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= +github.com/prometheus/common v0.19.0 h1:Itb4+NjG9wRdkAWgVucbM/adyIXxEhbw0866e0uZE6A= +github.com/prometheus/common v0.19.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= @@ -678,9 +666,6 @@ github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqn github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.3.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.5.2 h1:qLvObTrvO/XRCqmkKxUlOBc48bI3efyDuAZe25QiF0w= -github.com/rogpeppe/go-internal v1.5.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rubiojr/go-vhd v0.0.0-20200706105327-02e210299021/go.mod h1:DM5xW0nvfNNm2uytzsvhI3OnX8uzaRAg8UX/CnDqbto= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -689,7 +674,6 @@ github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0 github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sclevine/spec v1.2.0/go.mod h1:W4J29eT/Kzv7/b9IWLB055Z+qvVC9vt0Arko24q7p+U= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shurcooL/githubv4 v0.0.0-20190718010115-4ba037080260 h1:xKXiRdBUtMVp64NaxACcyX4kvfmHJ9KrLU+JvyB1mdM= github.com/shurcooL/githubv4 v0.0.0-20190718010115-4ba037080260/go.mod h1:hAF0iLZy4td2EX+/8Tw+4nodhlMrwN3HupfaXj3zkGo= @@ -712,7 +696,6 @@ github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTd github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -722,7 +705,6 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= -github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4= github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= @@ -757,7 +739,6 @@ github.com/vdemeester/k8s-pkg-credentialprovider v1.19.7 h1:MJ5fV2Z0OyIuPvFVs0vi github.com/vdemeester/k8s-pkg-credentialprovider v1.19.7/go.mod h1:K2nMO14cgZitdwBqdQps9tInJgcaXcU/7q5F59lpbNI= github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw= github.com/vmware/govmomi v0.20.3/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= -github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70= github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= @@ -781,16 +762,17 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4-0.20200608061201-1901b56b9515/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.5 h1:dntmOdLpSpHlVqbW5Eay97DelsZHe+55D+xC6i0dDS0= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/automaxprocs v1.3.0 h1:II28aZoGdaglS5vVNnspf28lnZpXScxtIozx1lAjdb0= -go.uber.org/automaxprocs v1.3.0/go.mod h1:9CWT6lKIep8U41DDaPiH6eFscnTyjfTANNQNx6LrIcA= +go.uber.org/automaxprocs v1.4.0 h1:CpDZl6aOlLhReez+8S3eEotD7Jx0Os++lemPlMULQP0= +go.uber.org/automaxprocs v1.4.0/go.mod h1:/mTEdr7LvHhs0v7mjdxDreTz1OG5zdZGqgOnhWiR/+Q= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A= @@ -979,10 +961,10 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1071,7 +1053,7 @@ golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82u golang.org/x/tools v0.0.0-20200916195026-c9a70fc28ce3/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= @@ -1154,8 +1136,8 @@ google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201211151036-40ec1c210f7a h1:GnJAhasbD8HiT8DZMvsEx3QLVy/X0icq/MGr0MqRJ2M= -google.golang.org/genproto v0.0.0-20201211151036-40ec1c210f7a/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d h1:HV9Z9qMhQEsdlvxNFELgQ11RkMzO3CMkjEySjCtuLes= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -1175,8 +1157,8 @@ google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.34.0 h1:raiipEjMOIC/TO2AvyTxP25XFdLxNIBwzDh3FM3XztI= -google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= +google.golang.org/grpc v1.36.0 h1:o1bcQ6imQMIOpdrO3SWf2z5RV72WbDwdXuK0MDlc8As= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= 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-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -1209,15 +1191,12 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= -gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg= gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98= gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g= -gopkg.in/src-d/go-git.v4 v4.13.1 h1:SRtFyV8Kxc0UP7aCHcijOMQGPxHSmMOPrzulQWolkYE= gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.1/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= -gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -1229,7 +1208,6 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= @@ -1286,9 +1264,9 @@ k8s.io/legacy-cloud-providers v0.19.7/go.mod h1:dsZk4gH9QIwAtHQ8CK0Ps257xlfgoXE3 k8s.io/utils v0.0.0-20200729134348-d5654de09c73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20210111153108-fddb29f9d009 h1:0T5IaWHO3sJTEmCP6mUlBvMukxPKUQWqiI/YuiBNMiQ= k8s.io/utils v0.0.0-20210111153108-fddb29f9d009/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -knative.dev/hack v0.0.0-20210120165453-8d623a0af457/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= -knative.dev/pkg v0.0.0-20210127163530-0d31134d5f4e h1:gChYSjSASTy59BGX9R1zaZy7s4tP9EFhAA7WMwQo8nY= -knative.dev/pkg v0.0.0-20210127163530-0d31134d5f4e/go.mod h1:X4NPrCo8NK3hbDVan9Vm7mf5io3ZoINakAdrpSXVB08= +knative.dev/hack v0.0.0-20210325223819-b6ab329907d3/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= +knative.dev/pkg v0.0.0-20210331065221-952fdd90dbb0 h1:z05hcB4br0qz7JdwIoUSTXLTF+7ThuJ+R6NFfXd1Y4Q= +knative.dev/pkg v0.0.0-20210331065221-952fdd90dbb0/go.mod h1:PD5g8hUCXq6iR3tILjmZeJBvQfXGnHMPKryq54qHJhg= pgregory.net/rapid v0.3.3/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= diff --git a/hack/update-deps.sh b/hack/update-deps.sh index 46c665b1eaf..e11866c0fff 100755 --- a/hack/update-deps.sh +++ b/hack/update-deps.sh @@ -22,7 +22,7 @@ source $(git rev-parse --show-toplevel)/vendor/github.com/tektoncd/plumbing/scri cd ${REPO_ROOT_DIR} -VERSION="master" +VERSION="release-0.22" # The list of dependencies that we track at HEAD and periodically # float forward in this repository. diff --git a/pkg/client/injection/client/client.go b/pkg/client/injection/client/client.go index 13c3847a39b..043293206cd 100644 --- a/pkg/client/injection/client/client.go +++ b/pkg/client/injection/client/client.go @@ -29,6 +29,9 @@ import ( func init() { injection.Default.RegisterClient(withClient) + injection.Default.RegisterClientFetcher(func(ctx context.Context) interface{} { + return Get(ctx) + }) } // Key is used as the key for associating information with a context.Context. diff --git a/pkg/client/injection/client/fake/fake.go b/pkg/client/injection/client/fake/fake.go index b3cff4152c4..a2814d38ac3 100644 --- a/pkg/client/injection/client/fake/fake.go +++ b/pkg/client/injection/client/fake/fake.go @@ -31,6 +31,9 @@ import ( func init() { injection.Fake.RegisterClient(withClient) + injection.Fake.RegisterClientFetcher(func(ctx context.Context) interface{} { + return Get(ctx) + }) } func withClient(ctx context.Context, cfg *rest.Config) context.Context { diff --git a/pkg/client/injection/reconciler/pipeline/v1alpha1/run/controller.go b/pkg/client/injection/reconciler/pipeline/v1alpha1/run/controller.go index 8fa98d10d3f..587cc02f0f5 100644 --- a/pkg/client/injection/reconciler/pipeline/v1alpha1/run/controller.go +++ b/pkg/client/injection/reconciler/pipeline/v1alpha1/run/controller.go @@ -50,7 +50,7 @@ const ( // NewImpl returns a controller.Impl that handles queuing and feeding work from // the queue through an implementation of controller.Reconciler, delegating to // the provided Interface and optional Finalizer methods. OptionsFn is used to return -// controller.Options to be used but the internal reconciler. +// controller.Options to be used by the internal reconciler. func NewImpl(ctx context.Context, r Interface, optionsFns ...controller.OptionsFn) *controller.Impl { logger := logging.FromContext(ctx) @@ -113,6 +113,9 @@ func NewImpl(ctx context.Context, r Interface, optionsFns ...controller.OptionsF if opts.SkipStatusUpdates { rec.skipStatusUpdates = true } + if opts.DemoteFunc != nil { + rec.DemoteFunc = opts.DemoteFunc + } } rec.Recorder = createRecorder(ctx, agentName) diff --git a/pkg/client/injection/reconciler/pipeline/v1alpha1/run/reconciler.go b/pkg/client/injection/reconciler/pipeline/v1alpha1/run/reconciler.go index 78c3892e1f5..2d4022314dd 100644 --- a/pkg/client/injection/reconciler/pipeline/v1alpha1/run/reconciler.go +++ b/pkg/client/injection/reconciler/pipeline/v1alpha1/run/reconciler.go @@ -169,6 +169,9 @@ func NewReconciler(ctx context.Context, logger *zap.SugaredLogger, client versio if opts.SkipStatusUpdates { rec.skipStatusUpdates = true } + if opts.DemoteFunc != nil { + rec.DemoteFunc = opts.DemoteFunc + } } return rec diff --git a/pkg/client/injection/reconciler/pipeline/v1alpha1/run/stub/controller.go b/pkg/client/injection/reconciler/pipeline/v1alpha1/run/stub/controller.go deleted file mode 100644 index 144ec4f89d1..00000000000 --- a/pkg/client/injection/reconciler/pipeline/v1alpha1/run/stub/controller.go +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright 2020 The Tekton 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. -*/ - -// Code generated by injection-gen. DO NOT EDIT. - -package run - -import ( - context "context" - - run "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/run" - v1alpha1run "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1alpha1/run" - configmap "knative.dev/pkg/configmap" - controller "knative.dev/pkg/controller" - logging "knative.dev/pkg/logging" -) - -// TODO: PLEASE COPY AND MODIFY THIS FILE AS A STARTING POINT - -// NewController creates a Reconciler for Run and returns the result of NewImpl. -func NewController( - ctx context.Context, - cmw configmap.Watcher, -) *controller.Impl { - logger := logging.FromContext(ctx) - - runInformer := run.Get(ctx) - - // TODO: setup additional informers here. - - r := &Reconciler{} - impl := v1alpha1run.NewImpl(ctx, r) - - logger.Info("Setting up event handlers.") - - runInformer.Informer().AddEventHandler(controller.HandleAll(impl.Enqueue)) - - // TODO: add additional informer event handlers here. - - return impl -} diff --git a/pkg/client/injection/reconciler/pipeline/v1alpha1/run/stub/reconciler.go b/pkg/client/injection/reconciler/pipeline/v1alpha1/run/stub/reconciler.go deleted file mode 100644 index 812b0b770b6..00000000000 --- a/pkg/client/injection/reconciler/pipeline/v1alpha1/run/stub/reconciler.go +++ /dev/null @@ -1,87 +0,0 @@ -/* -Copyright 2020 The Tekton 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. -*/ - -// Code generated by injection-gen. DO NOT EDIT. - -package run - -import ( - context "context" - - v1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" - run "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1alpha1/run" - v1 "k8s.io/api/core/v1" - reconciler "knative.dev/pkg/reconciler" -) - -// TODO: PLEASE COPY AND MODIFY THIS FILE AS A STARTING POINT - -// newReconciledNormal makes a new reconciler event with event type Normal, and -// reason RunReconciled. -func newReconciledNormal(namespace, name string) reconciler.Event { - return reconciler.NewEvent(v1.EventTypeNormal, "RunReconciled", "Run reconciled: \"%s/%s\"", namespace, name) -} - -// Reconciler implements controller.Reconciler for Run resources. -type Reconciler struct { - // TODO: add additional requirements here. -} - -// Check that our Reconciler implements Interface -var _ run.Interface = (*Reconciler)(nil) - -// Optionally check that our Reconciler implements Finalizer -//var _ run.Finalizer = (*Reconciler)(nil) - -// Optionally check that our Reconciler implements ReadOnlyInterface -// Implement this to observe resources even when we are not the leader. -//var _ run.ReadOnlyInterface = (*Reconciler)(nil) - -// Optionally check that our Reconciler implements ReadOnlyFinalizer -// Implement this to observe tombstoned resources even when we are not -// the leader (best effort). -//var _ run.ReadOnlyFinalizer = (*Reconciler)(nil) - -// ReconcileKind implements Interface.ReconcileKind. -func (r *Reconciler) ReconcileKind(ctx context.Context, o *v1alpha1.Run) reconciler.Event { - // TODO: use this if the resource implements InitializeConditions. - // o.Status.InitializeConditions() - - // TODO: add custom reconciliation logic here. - - // TODO: use this if the object has .status.ObservedGeneration. - // o.Status.ObservedGeneration = o.Generation - return newReconciledNormal(o.Namespace, o.Name) -} - -// Optionally, use FinalizeKind to add finalizers. FinalizeKind will be called -// when the resource is deleted. -//func (r *Reconciler) FinalizeKind(ctx context.Context, o *v1alpha1.Run) reconciler.Event { -// // TODO: add custom finalization logic here. -// return nil -//} - -// Optionally, use ObserveKind to observe the resource when we are not the leader. -// func (r *Reconciler) ObserveKind(ctx context.Context, o *v1alpha1.Run) reconciler.Event { -// // TODO: add custom observation logic here. -// return nil -// } - -// Optionally, use ObserveFinalizeKind to observe resources being finalized when we are no the leader. -//func (r *Reconciler) ObserveFinalizeKind(ctx context.Context, o *v1alpha1.Run) reconciler.Event { -// // TODO: add custom observation logic here. -// return nil -//} diff --git a/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun/controller.go b/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun/controller.go index eadc31f76ba..63a1ea5e5f8 100644 --- a/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun/controller.go +++ b/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun/controller.go @@ -50,7 +50,7 @@ const ( // NewImpl returns a controller.Impl that handles queuing and feeding work from // the queue through an implementation of controller.Reconciler, delegating to // the provided Interface and optional Finalizer methods. OptionsFn is used to return -// controller.Options to be used but the internal reconciler. +// controller.Options to be used by the internal reconciler. func NewImpl(ctx context.Context, r Interface, optionsFns ...controller.OptionsFn) *controller.Impl { logger := logging.FromContext(ctx) @@ -113,6 +113,9 @@ func NewImpl(ctx context.Context, r Interface, optionsFns ...controller.OptionsF if opts.SkipStatusUpdates { rec.skipStatusUpdates = true } + if opts.DemoteFunc != nil { + rec.DemoteFunc = opts.DemoteFunc + } } rec.Recorder = createRecorder(ctx, agentName) diff --git a/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun/reconciler.go b/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun/reconciler.go index 002aeb0371f..9bc098f3892 100644 --- a/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun/reconciler.go +++ b/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun/reconciler.go @@ -169,6 +169,9 @@ func NewReconciler(ctx context.Context, logger *zap.SugaredLogger, client versio if opts.SkipStatusUpdates { rec.skipStatusUpdates = true } + if opts.DemoteFunc != nil { + rec.DemoteFunc = opts.DemoteFunc + } } return rec diff --git a/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun/stub/controller.go b/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun/stub/controller.go deleted file mode 100644 index 5b8b29f7897..00000000000 --- a/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun/stub/controller.go +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright 2020 The Tekton 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. -*/ - -// Code generated by injection-gen. DO NOT EDIT. - -package pipelinerun - -import ( - context "context" - - pipelinerun "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/pipelinerun" - v1beta1pipelinerun "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun" - configmap "knative.dev/pkg/configmap" - controller "knative.dev/pkg/controller" - logging "knative.dev/pkg/logging" -) - -// TODO: PLEASE COPY AND MODIFY THIS FILE AS A STARTING POINT - -// NewController creates a Reconciler for PipelineRun and returns the result of NewImpl. -func NewController( - ctx context.Context, - cmw configmap.Watcher, -) *controller.Impl { - logger := logging.FromContext(ctx) - - pipelinerunInformer := pipelinerun.Get(ctx) - - // TODO: setup additional informers here. - - r := &Reconciler{} - impl := v1beta1pipelinerun.NewImpl(ctx, r) - - logger.Info("Setting up event handlers.") - - pipelinerunInformer.Informer().AddEventHandler(controller.HandleAll(impl.Enqueue)) - - // TODO: add additional informer event handlers here. - - return impl -} diff --git a/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun/stub/reconciler.go b/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun/stub/reconciler.go deleted file mode 100644 index 9596ac0538a..00000000000 --- a/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun/stub/reconciler.go +++ /dev/null @@ -1,87 +0,0 @@ -/* -Copyright 2020 The Tekton 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. -*/ - -// Code generated by injection-gen. DO NOT EDIT. - -package pipelinerun - -import ( - context "context" - - v1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - pipelinerun "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1beta1/pipelinerun" - v1 "k8s.io/api/core/v1" - reconciler "knative.dev/pkg/reconciler" -) - -// TODO: PLEASE COPY AND MODIFY THIS FILE AS A STARTING POINT - -// newReconciledNormal makes a new reconciler event with event type Normal, and -// reason PipelineRunReconciled. -func newReconciledNormal(namespace, name string) reconciler.Event { - return reconciler.NewEvent(v1.EventTypeNormal, "PipelineRunReconciled", "PipelineRun reconciled: \"%s/%s\"", namespace, name) -} - -// Reconciler implements controller.Reconciler for PipelineRun resources. -type Reconciler struct { - // TODO: add additional requirements here. -} - -// Check that our Reconciler implements Interface -var _ pipelinerun.Interface = (*Reconciler)(nil) - -// Optionally check that our Reconciler implements Finalizer -//var _ pipelinerun.Finalizer = (*Reconciler)(nil) - -// Optionally check that our Reconciler implements ReadOnlyInterface -// Implement this to observe resources even when we are not the leader. -//var _ pipelinerun.ReadOnlyInterface = (*Reconciler)(nil) - -// Optionally check that our Reconciler implements ReadOnlyFinalizer -// Implement this to observe tombstoned resources even when we are not -// the leader (best effort). -//var _ pipelinerun.ReadOnlyFinalizer = (*Reconciler)(nil) - -// ReconcileKind implements Interface.ReconcileKind. -func (r *Reconciler) ReconcileKind(ctx context.Context, o *v1beta1.PipelineRun) reconciler.Event { - // TODO: use this if the resource implements InitializeConditions. - // o.Status.InitializeConditions() - - // TODO: add custom reconciliation logic here. - - // TODO: use this if the object has .status.ObservedGeneration. - // o.Status.ObservedGeneration = o.Generation - return newReconciledNormal(o.Namespace, o.Name) -} - -// Optionally, use FinalizeKind to add finalizers. FinalizeKind will be called -// when the resource is deleted. -//func (r *Reconciler) FinalizeKind(ctx context.Context, o *v1beta1.PipelineRun) reconciler.Event { -// // TODO: add custom finalization logic here. -// return nil -//} - -// Optionally, use ObserveKind to observe the resource when we are not the leader. -// func (r *Reconciler) ObserveKind(ctx context.Context, o *v1beta1.PipelineRun) reconciler.Event { -// // TODO: add custom observation logic here. -// return nil -// } - -// Optionally, use ObserveFinalizeKind to observe resources being finalized when we are no the leader. -//func (r *Reconciler) ObserveFinalizeKind(ctx context.Context, o *v1beta1.PipelineRun) reconciler.Event { -// // TODO: add custom observation logic here. -// return nil -//} diff --git a/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun/controller.go b/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun/controller.go index fd9a8c7f558..6492c4bb948 100644 --- a/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun/controller.go +++ b/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun/controller.go @@ -50,7 +50,7 @@ const ( // NewImpl returns a controller.Impl that handles queuing and feeding work from // the queue through an implementation of controller.Reconciler, delegating to // the provided Interface and optional Finalizer methods. OptionsFn is used to return -// controller.Options to be used but the internal reconciler. +// controller.Options to be used by the internal reconciler. func NewImpl(ctx context.Context, r Interface, optionsFns ...controller.OptionsFn) *controller.Impl { logger := logging.FromContext(ctx) @@ -113,6 +113,9 @@ func NewImpl(ctx context.Context, r Interface, optionsFns ...controller.OptionsF if opts.SkipStatusUpdates { rec.skipStatusUpdates = true } + if opts.DemoteFunc != nil { + rec.DemoteFunc = opts.DemoteFunc + } } rec.Recorder = createRecorder(ctx, agentName) diff --git a/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun/reconciler.go b/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun/reconciler.go index 6958c479abc..4e5eee6ae22 100644 --- a/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun/reconciler.go +++ b/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun/reconciler.go @@ -169,6 +169,9 @@ func NewReconciler(ctx context.Context, logger *zap.SugaredLogger, client versio if opts.SkipStatusUpdates { rec.skipStatusUpdates = true } + if opts.DemoteFunc != nil { + rec.DemoteFunc = opts.DemoteFunc + } } return rec diff --git a/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun/stub/controller.go b/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun/stub/controller.go deleted file mode 100644 index 5be1ff8ef17..00000000000 --- a/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun/stub/controller.go +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright 2020 The Tekton 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. -*/ - -// Code generated by injection-gen. DO NOT EDIT. - -package taskrun - -import ( - context "context" - - taskrun "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/taskrun" - v1beta1taskrun "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun" - configmap "knative.dev/pkg/configmap" - controller "knative.dev/pkg/controller" - logging "knative.dev/pkg/logging" -) - -// TODO: PLEASE COPY AND MODIFY THIS FILE AS A STARTING POINT - -// NewController creates a Reconciler for TaskRun and returns the result of NewImpl. -func NewController( - ctx context.Context, - cmw configmap.Watcher, -) *controller.Impl { - logger := logging.FromContext(ctx) - - taskrunInformer := taskrun.Get(ctx) - - // TODO: setup additional informers here. - - r := &Reconciler{} - impl := v1beta1taskrun.NewImpl(ctx, r) - - logger.Info("Setting up event handlers.") - - taskrunInformer.Informer().AddEventHandler(controller.HandleAll(impl.Enqueue)) - - // TODO: add additional informer event handlers here. - - return impl -} diff --git a/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun/stub/reconciler.go b/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun/stub/reconciler.go deleted file mode 100644 index 26d95a3cefb..00000000000 --- a/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun/stub/reconciler.go +++ /dev/null @@ -1,87 +0,0 @@ -/* -Copyright 2020 The Tekton 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. -*/ - -// Code generated by injection-gen. DO NOT EDIT. - -package taskrun - -import ( - context "context" - - v1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - taskrun "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1beta1/taskrun" - v1 "k8s.io/api/core/v1" - reconciler "knative.dev/pkg/reconciler" -) - -// TODO: PLEASE COPY AND MODIFY THIS FILE AS A STARTING POINT - -// newReconciledNormal makes a new reconciler event with event type Normal, and -// reason TaskRunReconciled. -func newReconciledNormal(namespace, name string) reconciler.Event { - return reconciler.NewEvent(v1.EventTypeNormal, "TaskRunReconciled", "TaskRun reconciled: \"%s/%s\"", namespace, name) -} - -// Reconciler implements controller.Reconciler for TaskRun resources. -type Reconciler struct { - // TODO: add additional requirements here. -} - -// Check that our Reconciler implements Interface -var _ taskrun.Interface = (*Reconciler)(nil) - -// Optionally check that our Reconciler implements Finalizer -//var _ taskrun.Finalizer = (*Reconciler)(nil) - -// Optionally check that our Reconciler implements ReadOnlyInterface -// Implement this to observe resources even when we are not the leader. -//var _ taskrun.ReadOnlyInterface = (*Reconciler)(nil) - -// Optionally check that our Reconciler implements ReadOnlyFinalizer -// Implement this to observe tombstoned resources even when we are not -// the leader (best effort). -//var _ taskrun.ReadOnlyFinalizer = (*Reconciler)(nil) - -// ReconcileKind implements Interface.ReconcileKind. -func (r *Reconciler) ReconcileKind(ctx context.Context, o *v1beta1.TaskRun) reconciler.Event { - // TODO: use this if the resource implements InitializeConditions. - // o.Status.InitializeConditions() - - // TODO: add custom reconciliation logic here. - - // TODO: use this if the object has .status.ObservedGeneration. - // o.Status.ObservedGeneration = o.Generation - return newReconciledNormal(o.Namespace, o.Name) -} - -// Optionally, use FinalizeKind to add finalizers. FinalizeKind will be called -// when the resource is deleted. -//func (r *Reconciler) FinalizeKind(ctx context.Context, o *v1beta1.TaskRun) reconciler.Event { -// // TODO: add custom finalization logic here. -// return nil -//} - -// Optionally, use ObserveKind to observe the resource when we are not the leader. -// func (r *Reconciler) ObserveKind(ctx context.Context, o *v1beta1.TaskRun) reconciler.Event { -// // TODO: add custom observation logic here. -// return nil -// } - -// Optionally, use ObserveFinalizeKind to observe resources being finalized when we are no the leader. -//func (r *Reconciler) ObserveFinalizeKind(ctx context.Context, o *v1beta1.TaskRun) reconciler.Event { -// // TODO: add custom observation logic here. -// return nil -//} diff --git a/pkg/client/resource/injection/client/client.go b/pkg/client/resource/injection/client/client.go index f514060dabd..10c74d9efc0 100644 --- a/pkg/client/resource/injection/client/client.go +++ b/pkg/client/resource/injection/client/client.go @@ -29,6 +29,9 @@ import ( func init() { injection.Default.RegisterClient(withClient) + injection.Default.RegisterClientFetcher(func(ctx context.Context) interface{} { + return Get(ctx) + }) } // Key is used as the key for associating information with a context.Context. diff --git a/pkg/client/resource/injection/client/fake/fake.go b/pkg/client/resource/injection/client/fake/fake.go index 88a4e256727..1447b8e6ace 100644 --- a/pkg/client/resource/injection/client/fake/fake.go +++ b/pkg/client/resource/injection/client/fake/fake.go @@ -31,6 +31,9 @@ import ( func init() { injection.Fake.RegisterClient(withClient) + injection.Fake.RegisterClientFetcher(func(ctx context.Context) interface{} { + return Get(ctx) + }) } func withClient(ctx context.Context, cfg *rest.Config) context.Context { diff --git a/third_party/github.com/gobuffalo/envy/LICENSE b/third_party/github.com/gobuffalo/flect/LICENSE similarity index 100% rename from third_party/github.com/gobuffalo/envy/LICENSE rename to third_party/github.com/gobuffalo/flect/LICENSE diff --git a/third_party/github.com/hashicorp/errwrap/errwrap_test.go b/third_party/github.com/hashicorp/errwrap/errwrap_test.go deleted file mode 100644 index 5ae5f8e3cde..00000000000 --- a/third_party/github.com/hashicorp/errwrap/errwrap_test.go +++ /dev/null @@ -1,94 +0,0 @@ -package errwrap - -import ( - "fmt" - "testing" -) - -func TestWrappedError_impl(t *testing.T) { - var _ error = new(wrappedError) -} - -func TestGetAll(t *testing.T) { - cases := []struct { - Err error - Msg string - Len int - }{ - {}, - { - fmt.Errorf("foo"), - "foo", - 1, - }, - { - fmt.Errorf("bar"), - "foo", - 0, - }, - { - Wrapf("bar", fmt.Errorf("foo")), - "foo", - 1, - }, - { - Wrapf("{{err}}", fmt.Errorf("foo")), - "foo", - 2, - }, - { - Wrapf("bar", Wrapf("baz", fmt.Errorf("foo"))), - "foo", - 1, - }, - } - - for i, tc := range cases { - actual := GetAll(tc.Err, tc.Msg) - if len(actual) != tc.Len { - t.Fatalf("%d: bad: %#v", i, actual) - } - for _, v := range actual { - if v.Error() != tc.Msg { - t.Fatalf("%d: bad: %#v", i, actual) - } - } - } -} - -func TestGetAllType(t *testing.T) { - cases := []struct { - Err error - Type interface{} - Len int - }{ - {}, - { - fmt.Errorf("foo"), - "foo", - 0, - }, - { - fmt.Errorf("bar"), - fmt.Errorf("foo"), - 1, - }, - { - Wrapf("bar", fmt.Errorf("foo")), - fmt.Errorf("baz"), - 2, - }, - { - Wrapf("bar", Wrapf("baz", fmt.Errorf("foo"))), - Wrapf("", nil), - 0, - }, - } - - for i, tc := range cases { - actual := GetAllType(tc.Err, tc.Type) - if len(actual) != tc.Len { - t.Fatalf("%d: bad: %#v", i, actual) - } - } -} diff --git a/third_party/github.com/hashicorp/go-multierror/append_test.go b/third_party/github.com/hashicorp/go-multierror/append_test.go deleted file mode 100644 index 58ddafa8dde..00000000000 --- a/third_party/github.com/hashicorp/go-multierror/append_test.go +++ /dev/null @@ -1,82 +0,0 @@ -package multierror - -import ( - "errors" - "testing" -) - -func TestAppend_Error(t *testing.T) { - original := &Error{ - Errors: []error{errors.New("foo")}, - } - - result := Append(original, errors.New("bar")) - if len(result.Errors) != 2 { - t.Fatalf("wrong len: %d", len(result.Errors)) - } - - original = &Error{} - result = Append(original, errors.New("bar")) - if len(result.Errors) != 1 { - t.Fatalf("wrong len: %d", len(result.Errors)) - } - - // Test when a typed nil is passed - var e *Error - result = Append(e, errors.New("baz")) - if len(result.Errors) != 1 { - t.Fatalf("wrong len: %d", len(result.Errors)) - } - - // Test flattening - original = &Error{ - Errors: []error{errors.New("foo")}, - } - - result = Append(original, Append(nil, errors.New("foo"), errors.New("bar"))) - if len(result.Errors) != 3 { - t.Fatalf("wrong len: %d", len(result.Errors)) - } -} - -func TestAppend_NilError(t *testing.T) { - var err error - result := Append(err, errors.New("bar")) - if len(result.Errors) != 1 { - t.Fatalf("wrong len: %d", len(result.Errors)) - } -} - -func TestAppend_NilErrorArg(t *testing.T) { - var err error - var nilErr *Error - result := Append(err, nilErr) - if len(result.Errors) != 0 { - t.Fatalf("wrong len: %d", len(result.Errors)) - } -} - -func TestAppend_NilErrorIfaceArg(t *testing.T) { - var err error - var nilErr error - result := Append(err, nilErr) - if len(result.Errors) != 0 { - t.Fatalf("wrong len: %d", len(result.Errors)) - } -} - -func TestAppend_NonError(t *testing.T) { - original := errors.New("foo") - result := Append(original, errors.New("bar")) - if len(result.Errors) != 2 { - t.Fatalf("wrong len: %d", len(result.Errors)) - } -} - -func TestAppend_NonError_Error(t *testing.T) { - original := errors.New("foo") - result := Append(original, Append(nil, errors.New("bar"))) - if len(result.Errors) != 2 { - t.Fatalf("wrong len: %d", len(result.Errors)) - } -} diff --git a/third_party/github.com/hashicorp/go-multierror/flatten_test.go b/third_party/github.com/hashicorp/go-multierror/flatten_test.go deleted file mode 100644 index e99c4101b5b..00000000000 --- a/third_party/github.com/hashicorp/go-multierror/flatten_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package multierror - -import ( - "errors" - "fmt" - "reflect" - "testing" -) - -func TestFlatten(t *testing.T) { - original := &Error{ - Errors: []error{ - errors.New("one"), - &Error{ - Errors: []error{ - errors.New("two"), - &Error{ - Errors: []error{ - errors.New("three"), - }, - }, - }, - }, - }, - } - - expected := `3 errors occurred: - * one - * two - * three - -` - actual := fmt.Sprintf("%s", Flatten(original)) - - if expected != actual { - t.Fatalf("expected: %s, got: %s", expected, actual) - } -} - -func TestFlatten_nonError(t *testing.T) { - err := errors.New("foo") - actual := Flatten(err) - if !reflect.DeepEqual(actual, err) { - t.Fatalf("bad: %#v", actual) - } -} diff --git a/third_party/github.com/hashicorp/go-multierror/format_test.go b/third_party/github.com/hashicorp/go-multierror/format_test.go deleted file mode 100644 index 2b6da1defcd..00000000000 --- a/third_party/github.com/hashicorp/go-multierror/format_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package multierror - -import ( - "errors" - "testing" -) - -func TestListFormatFuncSingle(t *testing.T) { - expected := `1 error occurred: - * foo - -` - - errors := []error{ - errors.New("foo"), - } - - actual := ListFormatFunc(errors) - if actual != expected { - t.Fatalf("bad: %#v", actual) - } -} - -func TestListFormatFuncMultiple(t *testing.T) { - expected := `2 errors occurred: - * foo - * bar - -` - - errors := []error{ - errors.New("foo"), - errors.New("bar"), - } - - actual := ListFormatFunc(errors) - if actual != expected { - t.Fatalf("bad: %#v", actual) - } -} diff --git a/third_party/github.com/hashicorp/go-multierror/group_test.go b/third_party/github.com/hashicorp/go-multierror/group_test.go deleted file mode 100644 index 9d472fd6655..00000000000 --- a/third_party/github.com/hashicorp/go-multierror/group_test.go +++ /dev/null @@ -1,44 +0,0 @@ -package multierror - -import ( - "errors" - "strings" - "testing" -) - -func TestGroup(t *testing.T) { - err1 := errors.New("group_test: 1") - err2 := errors.New("group_test: 2") - - cases := []struct { - errs []error - nilResult bool - }{ - {errs: []error{}, nilResult: true}, - {errs: []error{nil}, nilResult: true}, - {errs: []error{err1}}, - {errs: []error{err1, nil}}, - {errs: []error{err1, nil, err2}}, - } - - for _, tc := range cases { - var g Group - - for _, err := range tc.errs { - err := err - g.Go(func() error { return err }) - - } - - gErr := g.Wait() - if gErr != nil { - for i := range tc.errs { - if tc.errs[i] != nil && !strings.Contains(gErr.Error(), tc.errs[i].Error()) { - t.Fatalf("expected error to contain %q, actual: %v", tc.errs[i].Error(), gErr) - } - } - } else if !tc.nilResult { - t.Fatalf("Group.Wait() should not have returned nil for errs: %v", tc.errs) - } - } -} diff --git a/third_party/github.com/hashicorp/go-multierror/multierror_test.go b/third_party/github.com/hashicorp/go-multierror/multierror_test.go deleted file mode 100644 index 972c52d00d6..00000000000 --- a/third_party/github.com/hashicorp/go-multierror/multierror_test.go +++ /dev/null @@ -1,203 +0,0 @@ -package multierror - -import ( - "errors" - "fmt" - "reflect" - "testing" -) - -func TestError_Impl(t *testing.T) { - var _ error = new(Error) -} - -func TestErrorError_custom(t *testing.T) { - errors := []error{ - errors.New("foo"), - errors.New("bar"), - } - - fn := func(es []error) string { - return "foo" - } - - multi := &Error{Errors: errors, ErrorFormat: fn} - if multi.Error() != "foo" { - t.Fatalf("bad: %s", multi.Error()) - } -} - -func TestErrorError_default(t *testing.T) { - expected := `2 errors occurred: - * foo - * bar - -` - - errors := []error{ - errors.New("foo"), - errors.New("bar"), - } - - multi := &Error{Errors: errors} - if multi.Error() != expected { - t.Fatalf("bad: %s", multi.Error()) - } -} - -func TestErrorErrorOrNil(t *testing.T) { - err := new(Error) - if err.ErrorOrNil() != nil { - t.Fatalf("bad: %#v", err.ErrorOrNil()) - } - - err.Errors = []error{errors.New("foo")} - if v := err.ErrorOrNil(); v == nil { - t.Fatal("should not be nil") - } else if !reflect.DeepEqual(v, err) { - t.Fatalf("bad: %#v", v) - } -} - -func TestErrorWrappedErrors(t *testing.T) { - errors := []error{ - errors.New("foo"), - errors.New("bar"), - } - - multi := &Error{Errors: errors} - if !reflect.DeepEqual(multi.Errors, multi.WrappedErrors()) { - t.Fatalf("bad: %s", multi.WrappedErrors()) - } -} - -func TestErrorUnwrap(t *testing.T) { - t.Run("with errors", func(t *testing.T) { - err := &Error{Errors: []error{ - errors.New("foo"), - errors.New("bar"), - errors.New("baz"), - }} - - var current error = err - for i := 0; i < len(err.Errors); i++ { - current = errors.Unwrap(current) - if !errors.Is(current, err.Errors[i]) { - t.Fatal("should be next value") - } - } - - if errors.Unwrap(current) != nil { - t.Fatal("should be nil at the end") - } - }) - - t.Run("with no errors", func(t *testing.T) { - err := &Error{Errors: nil} - if errors.Unwrap(err) != nil { - t.Fatal("should be nil") - } - }) - - t.Run("with nil multierror", func(t *testing.T) { - var err *Error - if errors.Unwrap(err) != nil { - t.Fatal("should be nil") - } - }) -} - -func TestErrorIs(t *testing.T) { - errBar := errors.New("bar") - - t.Run("with errBar", func(t *testing.T) { - err := &Error{Errors: []error{ - errors.New("foo"), - errBar, - errors.New("baz"), - }} - - if !errors.Is(err, errBar) { - t.Fatal("should be true") - } - }) - - t.Run("with errBar wrapped by fmt.Errorf", func(t *testing.T) { - err := &Error{Errors: []error{ - errors.New("foo"), - fmt.Errorf("errorf: %w", errBar), - errors.New("baz"), - }} - - if !errors.Is(err, errBar) { - t.Fatal("should be true") - } - }) - - t.Run("without errBar", func(t *testing.T) { - err := &Error{Errors: []error{ - errors.New("foo"), - errors.New("baz"), - }} - - if errors.Is(err, errBar) { - t.Fatal("should be false") - } - }) -} - -func TestErrorAs(t *testing.T) { - match := &nestedError{} - - t.Run("with the value", func(t *testing.T) { - err := &Error{Errors: []error{ - errors.New("foo"), - match, - errors.New("baz"), - }} - - var target *nestedError - if !errors.As(err, &target) { - t.Fatal("should be true") - } - if target == nil { - t.Fatal("target should not be nil") - } - }) - - t.Run("with the value wrapped by fmt.Errorf", func(t *testing.T) { - err := &Error{Errors: []error{ - errors.New("foo"), - fmt.Errorf("errorf: %w", match), - errors.New("baz"), - }} - - var target *nestedError - if !errors.As(err, &target) { - t.Fatal("should be true") - } - if target == nil { - t.Fatal("target should not be nil") - } - }) - - t.Run("without the value", func(t *testing.T) { - err := &Error{Errors: []error{ - errors.New("foo"), - errors.New("baz"), - }} - - var target *nestedError - if errors.As(err, &target) { - t.Fatal("should be false") - } - if target != nil { - t.Fatal("target should be nil") - } - }) -} - -// nestedError implements error and is used for tests. -type nestedError struct{} - -func (*nestedError) Error() string { return "" } diff --git a/third_party/github.com/hashicorp/go-multierror/prefix_test.go b/third_party/github.com/hashicorp/go-multierror/prefix_test.go deleted file mode 100644 index 1d4a6f6d333..00000000000 --- a/third_party/github.com/hashicorp/go-multierror/prefix_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package multierror - -import ( - "errors" - "testing" -) - -func TestPrefix_Error(t *testing.T) { - original := &Error{ - Errors: []error{errors.New("foo")}, - } - - result := Prefix(original, "bar") - if result.(*Error).Errors[0].Error() != "bar foo" { - t.Fatalf("bad: %s", result) - } -} - -func TestPrefix_NilError(t *testing.T) { - var err error - result := Prefix(err, "bar") - if result != nil { - t.Fatalf("bad: %#v", result) - } -} - -func TestPrefix_NonError(t *testing.T) { - original := errors.New("foo") - result := Prefix(original, "bar") - if result.Error() != "bar foo" { - t.Fatalf("bad: %s", result) - } -} diff --git a/third_party/github.com/hashicorp/go-multierror/sort_test.go b/third_party/github.com/hashicorp/go-multierror/sort_test.go deleted file mode 100644 index 7fd04e8c560..00000000000 --- a/third_party/github.com/hashicorp/go-multierror/sort_test.go +++ /dev/null @@ -1,52 +0,0 @@ -package multierror - -import ( - "errors" - "reflect" - "sort" - "testing" -) - -func TestSortSingle(t *testing.T) { - errFoo := errors.New("foo") - - expected := []error{ - errFoo, - } - - err := &Error{ - Errors: []error{ - errFoo, - }, - } - - sort.Sort(err) - if !reflect.DeepEqual(err.Errors, expected) { - t.Fatalf("bad: %#v", err) - } -} - -func TestSortMultiple(t *testing.T) { - errBar := errors.New("bar") - errBaz := errors.New("baz") - errFoo := errors.New("foo") - - expected := []error{ - errBar, - errBaz, - errFoo, - } - - err := &Error{ - Errors: []error{ - errFoo, - errBar, - errBaz, - }, - } - - sort.Sort(err) - if !reflect.DeepEqual(err.Errors, expected) { - t.Fatalf("bad: %#v", err) - } -} diff --git a/third_party/github.com/hashicorp/golang-lru/2q_test.go b/third_party/github.com/hashicorp/golang-lru/2q_test.go deleted file mode 100644 index 1b0f3518178..00000000000 --- a/third_party/github.com/hashicorp/golang-lru/2q_test.go +++ /dev/null @@ -1,306 +0,0 @@ -package lru - -import ( - "math/rand" - "testing" -) - -func Benchmark2Q_Rand(b *testing.B) { - l, err := New2Q(8192) - if err != nil { - b.Fatalf("err: %v", err) - } - - trace := make([]int64, b.N*2) - for i := 0; i < b.N*2; i++ { - trace[i] = rand.Int63() % 32768 - } - - b.ResetTimer() - - var hit, miss int - for i := 0; i < 2*b.N; i++ { - if i%2 == 0 { - l.Add(trace[i], trace[i]) - } else { - _, ok := l.Get(trace[i]) - if ok { - hit++ - } else { - miss++ - } - } - } - b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(miss)) -} - -func Benchmark2Q_Freq(b *testing.B) { - l, err := New2Q(8192) - if err != nil { - b.Fatalf("err: %v", err) - } - - trace := make([]int64, b.N*2) - for i := 0; i < b.N*2; i++ { - if i%2 == 0 { - trace[i] = rand.Int63() % 16384 - } else { - trace[i] = rand.Int63() % 32768 - } - } - - b.ResetTimer() - - for i := 0; i < b.N; i++ { - l.Add(trace[i], trace[i]) - } - var hit, miss int - for i := 0; i < b.N; i++ { - _, ok := l.Get(trace[i]) - if ok { - hit++ - } else { - miss++ - } - } - b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(miss)) -} - -func Test2Q_RandomOps(t *testing.T) { - size := 128 - l, err := New2Q(128) - if err != nil { - t.Fatalf("err: %v", err) - } - - n := 200000 - for i := 0; i < n; i++ { - key := rand.Int63() % 512 - r := rand.Int63() - switch r % 3 { - case 0: - l.Add(key, key) - case 1: - l.Get(key) - case 2: - l.Remove(key) - } - - if l.recent.Len()+l.frequent.Len() > size { - t.Fatalf("bad: recent: %d freq: %d", - l.recent.Len(), l.frequent.Len()) - } - } -} - -func Test2Q_Get_RecentToFrequent(t *testing.T) { - l, err := New2Q(128) - if err != nil { - t.Fatalf("err: %v", err) - } - - // Touch all the entries, should be in t1 - for i := 0; i < 128; i++ { - l.Add(i, i) - } - if n := l.recent.Len(); n != 128 { - t.Fatalf("bad: %d", n) - } - if n := l.frequent.Len(); n != 0 { - t.Fatalf("bad: %d", n) - } - - // Get should upgrade to t2 - for i := 0; i < 128; i++ { - _, ok := l.Get(i) - if !ok { - t.Fatalf("missing: %d", i) - } - } - if n := l.recent.Len(); n != 0 { - t.Fatalf("bad: %d", n) - } - if n := l.frequent.Len(); n != 128 { - t.Fatalf("bad: %d", n) - } - - // Get be from t2 - for i := 0; i < 128; i++ { - _, ok := l.Get(i) - if !ok { - t.Fatalf("missing: %d", i) - } - } - if n := l.recent.Len(); n != 0 { - t.Fatalf("bad: %d", n) - } - if n := l.frequent.Len(); n != 128 { - t.Fatalf("bad: %d", n) - } -} - -func Test2Q_Add_RecentToFrequent(t *testing.T) { - l, err := New2Q(128) - if err != nil { - t.Fatalf("err: %v", err) - } - - // Add initially to recent - l.Add(1, 1) - if n := l.recent.Len(); n != 1 { - t.Fatalf("bad: %d", n) - } - if n := l.frequent.Len(); n != 0 { - t.Fatalf("bad: %d", n) - } - - // Add should upgrade to frequent - l.Add(1, 1) - if n := l.recent.Len(); n != 0 { - t.Fatalf("bad: %d", n) - } - if n := l.frequent.Len(); n != 1 { - t.Fatalf("bad: %d", n) - } - - // Add should remain in frequent - l.Add(1, 1) - if n := l.recent.Len(); n != 0 { - t.Fatalf("bad: %d", n) - } - if n := l.frequent.Len(); n != 1 { - t.Fatalf("bad: %d", n) - } -} - -func Test2Q_Add_RecentEvict(t *testing.T) { - l, err := New2Q(4) - if err != nil { - t.Fatalf("err: %v", err) - } - - // Add 1,2,3,4,5 -> Evict 1 - l.Add(1, 1) - l.Add(2, 2) - l.Add(3, 3) - l.Add(4, 4) - l.Add(5, 5) - if n := l.recent.Len(); n != 4 { - t.Fatalf("bad: %d", n) - } - if n := l.recentEvict.Len(); n != 1 { - t.Fatalf("bad: %d", n) - } - if n := l.frequent.Len(); n != 0 { - t.Fatalf("bad: %d", n) - } - - // Pull in the recently evicted - l.Add(1, 1) - if n := l.recent.Len(); n != 3 { - t.Fatalf("bad: %d", n) - } - if n := l.recentEvict.Len(); n != 1 { - t.Fatalf("bad: %d", n) - } - if n := l.frequent.Len(); n != 1 { - t.Fatalf("bad: %d", n) - } - - // Add 6, should cause another recent evict - l.Add(6, 6) - if n := l.recent.Len(); n != 3 { - t.Fatalf("bad: %d", n) - } - if n := l.recentEvict.Len(); n != 2 { - t.Fatalf("bad: %d", n) - } - if n := l.frequent.Len(); n != 1 { - t.Fatalf("bad: %d", n) - } -} - -func Test2Q(t *testing.T) { - l, err := New2Q(128) - if err != nil { - t.Fatalf("err: %v", err) - } - - for i := 0; i < 256; i++ { - l.Add(i, i) - } - if l.Len() != 128 { - t.Fatalf("bad len: %v", l.Len()) - } - - for i, k := range l.Keys() { - if v, ok := l.Get(k); !ok || v != k || v != i+128 { - t.Fatalf("bad key: %v", k) - } - } - for i := 0; i < 128; i++ { - _, ok := l.Get(i) - if ok { - t.Fatalf("should be evicted") - } - } - for i := 128; i < 256; i++ { - _, ok := l.Get(i) - if !ok { - t.Fatalf("should not be evicted") - } - } - for i := 128; i < 192; i++ { - l.Remove(i) - _, ok := l.Get(i) - if ok { - t.Fatalf("should be deleted") - } - } - - l.Purge() - if l.Len() != 0 { - t.Fatalf("bad len: %v", l.Len()) - } - if _, ok := l.Get(200); ok { - t.Fatalf("should contain nothing") - } -} - -// Test that Contains doesn't update recent-ness -func Test2Q_Contains(t *testing.T) { - l, err := New2Q(2) - if err != nil { - t.Fatalf("err: %v", err) - } - - l.Add(1, 1) - l.Add(2, 2) - if !l.Contains(1) { - t.Errorf("1 should be contained") - } - - l.Add(3, 3) - if l.Contains(1) { - t.Errorf("Contains should not have updated recent-ness of 1") - } -} - -// Test that Peek doesn't update recent-ness -func Test2Q_Peek(t *testing.T) { - l, err := New2Q(2) - if err != nil { - t.Fatalf("err: %v", err) - } - - l.Add(1, 1) - l.Add(2, 2) - if v, ok := l.Peek(1); !ok || v != 1 { - t.Errorf("1 should be set to 1: %v, %v", v, ok) - } - - l.Add(3, 3) - if l.Contains(1) { - t.Errorf("should not have updated recent-ness of 1") - } -} diff --git a/third_party/github.com/hashicorp/golang-lru/arc_test.go b/third_party/github.com/hashicorp/golang-lru/arc_test.go deleted file mode 100644 index e2d9b68c6ae..00000000000 --- a/third_party/github.com/hashicorp/golang-lru/arc_test.go +++ /dev/null @@ -1,377 +0,0 @@ -package lru - -import ( - "math/rand" - "testing" - "time" -) - -func init() { - rand.Seed(time.Now().Unix()) -} - -func BenchmarkARC_Rand(b *testing.B) { - l, err := NewARC(8192) - if err != nil { - b.Fatalf("err: %v", err) - } - - trace := make([]int64, b.N*2) - for i := 0; i < b.N*2; i++ { - trace[i] = rand.Int63() % 32768 - } - - b.ResetTimer() - - var hit, miss int - for i := 0; i < 2*b.N; i++ { - if i%2 == 0 { - l.Add(trace[i], trace[i]) - } else { - _, ok := l.Get(trace[i]) - if ok { - hit++ - } else { - miss++ - } - } - } - b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(miss)) -} - -func BenchmarkARC_Freq(b *testing.B) { - l, err := NewARC(8192) - if err != nil { - b.Fatalf("err: %v", err) - } - - trace := make([]int64, b.N*2) - for i := 0; i < b.N*2; i++ { - if i%2 == 0 { - trace[i] = rand.Int63() % 16384 - } else { - trace[i] = rand.Int63() % 32768 - } - } - - b.ResetTimer() - - for i := 0; i < b.N; i++ { - l.Add(trace[i], trace[i]) - } - var hit, miss int - for i := 0; i < b.N; i++ { - _, ok := l.Get(trace[i]) - if ok { - hit++ - } else { - miss++ - } - } - b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(miss)) -} - -func TestARC_RandomOps(t *testing.T) { - size := 128 - l, err := NewARC(128) - if err != nil { - t.Fatalf("err: %v", err) - } - - n := 200000 - for i := 0; i < n; i++ { - key := rand.Int63() % 512 - r := rand.Int63() - switch r % 3 { - case 0: - l.Add(key, key) - case 1: - l.Get(key) - case 2: - l.Remove(key) - } - - if l.t1.Len()+l.t2.Len() > size { - t.Fatalf("bad: t1: %d t2: %d b1: %d b2: %d p: %d", - l.t1.Len(), l.t2.Len(), l.b1.Len(), l.b2.Len(), l.p) - } - if l.b1.Len()+l.b2.Len() > size { - t.Fatalf("bad: t1: %d t2: %d b1: %d b2: %d p: %d", - l.t1.Len(), l.t2.Len(), l.b1.Len(), l.b2.Len(), l.p) - } - } -} - -func TestARC_Get_RecentToFrequent(t *testing.T) { - l, err := NewARC(128) - if err != nil { - t.Fatalf("err: %v", err) - } - - // Touch all the entries, should be in t1 - for i := 0; i < 128; i++ { - l.Add(i, i) - } - if n := l.t1.Len(); n != 128 { - t.Fatalf("bad: %d", n) - } - if n := l.t2.Len(); n != 0 { - t.Fatalf("bad: %d", n) - } - - // Get should upgrade to t2 - for i := 0; i < 128; i++ { - _, ok := l.Get(i) - if !ok { - t.Fatalf("missing: %d", i) - } - } - if n := l.t1.Len(); n != 0 { - t.Fatalf("bad: %d", n) - } - if n := l.t2.Len(); n != 128 { - t.Fatalf("bad: %d", n) - } - - // Get be from t2 - for i := 0; i < 128; i++ { - _, ok := l.Get(i) - if !ok { - t.Fatalf("missing: %d", i) - } - } - if n := l.t1.Len(); n != 0 { - t.Fatalf("bad: %d", n) - } - if n := l.t2.Len(); n != 128 { - t.Fatalf("bad: %d", n) - } -} - -func TestARC_Add_RecentToFrequent(t *testing.T) { - l, err := NewARC(128) - if err != nil { - t.Fatalf("err: %v", err) - } - - // Add initially to t1 - l.Add(1, 1) - if n := l.t1.Len(); n != 1 { - t.Fatalf("bad: %d", n) - } - if n := l.t2.Len(); n != 0 { - t.Fatalf("bad: %d", n) - } - - // Add should upgrade to t2 - l.Add(1, 1) - if n := l.t1.Len(); n != 0 { - t.Fatalf("bad: %d", n) - } - if n := l.t2.Len(); n != 1 { - t.Fatalf("bad: %d", n) - } - - // Add should remain in t2 - l.Add(1, 1) - if n := l.t1.Len(); n != 0 { - t.Fatalf("bad: %d", n) - } - if n := l.t2.Len(); n != 1 { - t.Fatalf("bad: %d", n) - } -} - -func TestARC_Adaptive(t *testing.T) { - l, err := NewARC(4) - if err != nil { - t.Fatalf("err: %v", err) - } - - // Fill t1 - for i := 0; i < 4; i++ { - l.Add(i, i) - } - if n := l.t1.Len(); n != 4 { - t.Fatalf("bad: %d", n) - } - - // Move to t2 - l.Get(0) - l.Get(1) - if n := l.t2.Len(); n != 2 { - t.Fatalf("bad: %d", n) - } - - // Evict from t1 - l.Add(4, 4) - if n := l.b1.Len(); n != 1 { - t.Fatalf("bad: %d", n) - } - - // Current state - // t1 : (MRU) [4, 3] (LRU) - // t2 : (MRU) [1, 0] (LRU) - // b1 : (MRU) [2] (LRU) - // b2 : (MRU) [] (LRU) - - // Add 2, should cause hit on b1 - l.Add(2, 2) - if n := l.b1.Len(); n != 1 { - t.Fatalf("bad: %d", n) - } - if l.p != 1 { - t.Fatalf("bad: %d", l.p) - } - if n := l.t2.Len(); n != 3 { - t.Fatalf("bad: %d", n) - } - - // Current state - // t1 : (MRU) [4] (LRU) - // t2 : (MRU) [2, 1, 0] (LRU) - // b1 : (MRU) [3] (LRU) - // b2 : (MRU) [] (LRU) - - // Add 4, should migrate to t2 - l.Add(4, 4) - if n := l.t1.Len(); n != 0 { - t.Fatalf("bad: %d", n) - } - if n := l.t2.Len(); n != 4 { - t.Fatalf("bad: %d", n) - } - - // Current state - // t1 : (MRU) [] (LRU) - // t2 : (MRU) [4, 2, 1, 0] (LRU) - // b1 : (MRU) [3] (LRU) - // b2 : (MRU) [] (LRU) - - // Add 4, should evict to b2 - l.Add(5, 5) - if n := l.t1.Len(); n != 1 { - t.Fatalf("bad: %d", n) - } - if n := l.t2.Len(); n != 3 { - t.Fatalf("bad: %d", n) - } - if n := l.b2.Len(); n != 1 { - t.Fatalf("bad: %d", n) - } - - // Current state - // t1 : (MRU) [5] (LRU) - // t2 : (MRU) [4, 2, 1] (LRU) - // b1 : (MRU) [3] (LRU) - // b2 : (MRU) [0] (LRU) - - // Add 0, should decrease p - l.Add(0, 0) - if n := l.t1.Len(); n != 0 { - t.Fatalf("bad: %d", n) - } - if n := l.t2.Len(); n != 4 { - t.Fatalf("bad: %d", n) - } - if n := l.b1.Len(); n != 2 { - t.Fatalf("bad: %d", n) - } - if n := l.b2.Len(); n != 0 { - t.Fatalf("bad: %d", n) - } - if l.p != 0 { - t.Fatalf("bad: %d", l.p) - } - - // Current state - // t1 : (MRU) [] (LRU) - // t2 : (MRU) [0, 4, 2, 1] (LRU) - // b1 : (MRU) [5, 3] (LRU) - // b2 : (MRU) [0] (LRU) -} - -func TestARC(t *testing.T) { - l, err := NewARC(128) - if err != nil { - t.Fatalf("err: %v", err) - } - - for i := 0; i < 256; i++ { - l.Add(i, i) - } - if l.Len() != 128 { - t.Fatalf("bad len: %v", l.Len()) - } - - for i, k := range l.Keys() { - if v, ok := l.Get(k); !ok || v != k || v != i+128 { - t.Fatalf("bad key: %v", k) - } - } - for i := 0; i < 128; i++ { - _, ok := l.Get(i) - if ok { - t.Fatalf("should be evicted") - } - } - for i := 128; i < 256; i++ { - _, ok := l.Get(i) - if !ok { - t.Fatalf("should not be evicted") - } - } - for i := 128; i < 192; i++ { - l.Remove(i) - _, ok := l.Get(i) - if ok { - t.Fatalf("should be deleted") - } - } - - l.Purge() - if l.Len() != 0 { - t.Fatalf("bad len: %v", l.Len()) - } - if _, ok := l.Get(200); ok { - t.Fatalf("should contain nothing") - } -} - -// Test that Contains doesn't update recent-ness -func TestARC_Contains(t *testing.T) { - l, err := NewARC(2) - if err != nil { - t.Fatalf("err: %v", err) - } - - l.Add(1, 1) - l.Add(2, 2) - if !l.Contains(1) { - t.Errorf("1 should be contained") - } - - l.Add(3, 3) - if l.Contains(1) { - t.Errorf("Contains should not have updated recent-ness of 1") - } -} - -// Test that Peek doesn't update recent-ness -func TestARC_Peek(t *testing.T) { - l, err := NewARC(2) - if err != nil { - t.Fatalf("err: %v", err) - } - - l.Add(1, 1) - l.Add(2, 2) - if v, ok := l.Peek(1); !ok || v != 1 { - t.Errorf("1 should be set to 1: %v, %v", v, ok) - } - - l.Add(3, 3) - if l.Contains(1) { - t.Errorf("should not have updated recent-ness of 1") - } -} diff --git a/third_party/github.com/hashicorp/golang-lru/lru_test.go b/third_party/github.com/hashicorp/golang-lru/lru_test.go deleted file mode 100644 index b52eafdb8a6..00000000000 --- a/third_party/github.com/hashicorp/golang-lru/lru_test.go +++ /dev/null @@ -1,293 +0,0 @@ -package lru - -import ( - "math/rand" - "testing" -) - -func BenchmarkLRU_Rand(b *testing.B) { - l, err := New(8192) - if err != nil { - b.Fatalf("err: %v", err) - } - - trace := make([]int64, b.N*2) - for i := 0; i < b.N*2; i++ { - trace[i] = rand.Int63() % 32768 - } - - b.ResetTimer() - - var hit, miss int - for i := 0; i < 2*b.N; i++ { - if i%2 == 0 { - l.Add(trace[i], trace[i]) - } else { - _, ok := l.Get(trace[i]) - if ok { - hit++ - } else { - miss++ - } - } - } - b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(miss)) -} - -func BenchmarkLRU_Freq(b *testing.B) { - l, err := New(8192) - if err != nil { - b.Fatalf("err: %v", err) - } - - trace := make([]int64, b.N*2) - for i := 0; i < b.N*2; i++ { - if i%2 == 0 { - trace[i] = rand.Int63() % 16384 - } else { - trace[i] = rand.Int63() % 32768 - } - } - - b.ResetTimer() - - for i := 0; i < b.N; i++ { - l.Add(trace[i], trace[i]) - } - var hit, miss int - for i := 0; i < b.N; i++ { - _, ok := l.Get(trace[i]) - if ok { - hit++ - } else { - miss++ - } - } - b.Logf("hit: %d miss: %d ratio: %f", hit, miss, float64(hit)/float64(miss)) -} - -func TestLRU(t *testing.T) { - evictCounter := 0 - onEvicted := func(k interface{}, v interface{}) { - if k != v { - t.Fatalf("Evict values not equal (%v!=%v)", k, v) - } - evictCounter++ - } - l, err := NewWithEvict(128, onEvicted) - if err != nil { - t.Fatalf("err: %v", err) - } - - for i := 0; i < 256; i++ { - l.Add(i, i) - } - if l.Len() != 128 { - t.Fatalf("bad len: %v", l.Len()) - } - - if evictCounter != 128 { - t.Fatalf("bad evict count: %v", evictCounter) - } - - for i, k := range l.Keys() { - if v, ok := l.Get(k); !ok || v != k || v != i+128 { - t.Fatalf("bad key: %v", k) - } - } - for i := 0; i < 128; i++ { - _, ok := l.Get(i) - if ok { - t.Fatalf("should be evicted") - } - } - for i := 128; i < 256; i++ { - _, ok := l.Get(i) - if !ok { - t.Fatalf("should not be evicted") - } - } - for i := 128; i < 192; i++ { - l.Remove(i) - _, ok := l.Get(i) - if ok { - t.Fatalf("should be deleted") - } - } - - l.Get(192) // expect 192 to be last key in l.Keys() - - for i, k := range l.Keys() { - if (i < 63 && k != i+193) || (i == 63 && k != 192) { - t.Fatalf("out of order key: %v", k) - } - } - - l.Purge() - if l.Len() != 0 { - t.Fatalf("bad len: %v", l.Len()) - } - if _, ok := l.Get(200); ok { - t.Fatalf("should contain nothing") - } -} - -// test that Add returns true/false if an eviction occurred -func TestLRUAdd(t *testing.T) { - evictCounter := 0 - onEvicted := func(k interface{}, v interface{}) { - evictCounter++ - } - - l, err := NewWithEvict(1, onEvicted) - if err != nil { - t.Fatalf("err: %v", err) - } - - if l.Add(1, 1) == true || evictCounter != 0 { - t.Errorf("should not have an eviction") - } - if l.Add(2, 2) == false || evictCounter != 1 { - t.Errorf("should have an eviction") - } -} - -// test that Contains doesn't update recent-ness -func TestLRUContains(t *testing.T) { - l, err := New(2) - if err != nil { - t.Fatalf("err: %v", err) - } - - l.Add(1, 1) - l.Add(2, 2) - if !l.Contains(1) { - t.Errorf("1 should be contained") - } - - l.Add(3, 3) - if l.Contains(1) { - t.Errorf("Contains should not have updated recent-ness of 1") - } -} - -// test that ContainsOrAdd doesn't update recent-ness -func TestLRUContainsOrAdd(t *testing.T) { - l, err := New(2) - if err != nil { - t.Fatalf("err: %v", err) - } - - l.Add(1, 1) - l.Add(2, 2) - contains, evict := l.ContainsOrAdd(1, 1) - if !contains { - t.Errorf("1 should be contained") - } - if evict { - t.Errorf("nothing should be evicted here") - } - - l.Add(3, 3) - contains, evict = l.ContainsOrAdd(1, 1) - if contains { - t.Errorf("1 should not have been contained") - } - if !evict { - t.Errorf("an eviction should have occurred") - } - if !l.Contains(1) { - t.Errorf("now 1 should be contained") - } -} - -// test that PeekOrAdd doesn't update recent-ness -func TestLRUPeekOrAdd(t *testing.T) { - l, err := New(2) - if err != nil { - t.Fatalf("err: %v", err) - } - - l.Add(1, 1) - l.Add(2, 2) - previous, contains, evict := l.PeekOrAdd(1, 1) - if !contains { - t.Errorf("1 should be contained") - } - if evict { - t.Errorf("nothing should be evicted here") - } - if previous != 1 { - t.Errorf("previous is not equal to 1") - } - - l.Add(3, 3) - contains, evict = l.ContainsOrAdd(1, 1) - if contains { - t.Errorf("1 should not have been contained") - } - if !evict { - t.Errorf("an eviction should have occurred") - } - if !l.Contains(1) { - t.Errorf("now 1 should be contained") - } -} - -// test that Peek doesn't update recent-ness -func TestLRUPeek(t *testing.T) { - l, err := New(2) - if err != nil { - t.Fatalf("err: %v", err) - } - - l.Add(1, 1) - l.Add(2, 2) - if v, ok := l.Peek(1); !ok || v != 1 { - t.Errorf("1 should be set to 1: %v, %v", v, ok) - } - - l.Add(3, 3) - if l.Contains(1) { - t.Errorf("should not have updated recent-ness of 1") - } -} - -// test that Resize can upsize and downsize -func TestLRUResize(t *testing.T) { - onEvictCounter := 0 - onEvicted := func(k interface{}, v interface{}) { - onEvictCounter++ - } - l, err := NewWithEvict(2, onEvicted) - if err != nil { - t.Fatalf("err: %v", err) - } - - // Downsize - l.Add(1, 1) - l.Add(2, 2) - evicted := l.Resize(1); - if evicted != 1 { - t.Errorf("1 element should have been evicted: %v", evicted) - } - if onEvictCounter != 1 { - t.Errorf("onEvicted should have been called 1 time: %v", onEvictCounter) - } - - l.Add(3, 3) - if l.Contains(1) { - t.Errorf("Element 1 should have been evicted") - } - - // Upsize - evicted = l.Resize(2); - if evicted != 0 { - t.Errorf("0 elements should have been evicted: %v", evicted) - } - - l.Add(4, 4) - if !l.Contains(3) || !l.Contains(4) { - t.Errorf("Cache should have contained 2 elements") - } -} diff --git a/third_party/github.com/hashicorp/golang-lru/simplelru/lru_test.go b/third_party/github.com/hashicorp/golang-lru/simplelru/lru_test.go deleted file mode 100644 index bc7f696cc74..00000000000 --- a/third_party/github.com/hashicorp/golang-lru/simplelru/lru_test.go +++ /dev/null @@ -1,206 +0,0 @@ -package simplelru - -import "testing" - -func TestLRU(t *testing.T) { - evictCounter := 0 - onEvicted := func(k interface{}, v interface{}) { - if k != v { - t.Fatalf("Evict values not equal (%v!=%v)", k, v) - } - evictCounter++ - } - l, err := NewLRU(128, onEvicted) - if err != nil { - t.Fatalf("err: %v", err) - } - - for i := 0; i < 256; i++ { - l.Add(i, i) - } - if l.Len() != 128 { - t.Fatalf("bad len: %v", l.Len()) - } - - if evictCounter != 128 { - t.Fatalf("bad evict count: %v", evictCounter) - } - - for i, k := range l.Keys() { - if v, ok := l.Get(k); !ok || v != k || v != i+128 { - t.Fatalf("bad key: %v", k) - } - } - for i := 0; i < 128; i++ { - _, ok := l.Get(i) - if ok { - t.Fatalf("should be evicted") - } - } - for i := 128; i < 256; i++ { - _, ok := l.Get(i) - if !ok { - t.Fatalf("should not be evicted") - } - } - for i := 128; i < 192; i++ { - ok := l.Remove(i) - if !ok { - t.Fatalf("should be contained") - } - ok = l.Remove(i) - if ok { - t.Fatalf("should not be contained") - } - _, ok = l.Get(i) - if ok { - t.Fatalf("should be deleted") - } - } - - l.Get(192) // expect 192 to be last key in l.Keys() - - for i, k := range l.Keys() { - if (i < 63 && k != i+193) || (i == 63 && k != 192) { - t.Fatalf("out of order key: %v", k) - } - } - - l.Purge() - if l.Len() != 0 { - t.Fatalf("bad len: %v", l.Len()) - } - if _, ok := l.Get(200); ok { - t.Fatalf("should contain nothing") - } -} - -func TestLRU_GetOldest_RemoveOldest(t *testing.T) { - l, err := NewLRU(128, nil) - if err != nil { - t.Fatalf("err: %v", err) - } - for i := 0; i < 256; i++ { - l.Add(i, i) - } - k, _, ok := l.GetOldest() - if !ok { - t.Fatalf("missing") - } - if k.(int) != 128 { - t.Fatalf("bad: %v", k) - } - - k, _, ok = l.RemoveOldest() - if !ok { - t.Fatalf("missing") - } - if k.(int) != 128 { - t.Fatalf("bad: %v", k) - } - - k, _, ok = l.RemoveOldest() - if !ok { - t.Fatalf("missing") - } - if k.(int) != 129 { - t.Fatalf("bad: %v", k) - } -} - -// Test that Add returns true/false if an eviction occurred -func TestLRU_Add(t *testing.T) { - evictCounter := 0 - onEvicted := func(k interface{}, v interface{}) { - evictCounter++ - } - - l, err := NewLRU(1, onEvicted) - if err != nil { - t.Fatalf("err: %v", err) - } - - if l.Add(1, 1) == true || evictCounter != 0 { - t.Errorf("should not have an eviction") - } - if l.Add(2, 2) == false || evictCounter != 1 { - t.Errorf("should have an eviction") - } -} - -// Test that Contains doesn't update recent-ness -func TestLRU_Contains(t *testing.T) { - l, err := NewLRU(2, nil) - if err != nil { - t.Fatalf("err: %v", err) - } - - l.Add(1, 1) - l.Add(2, 2) - if !l.Contains(1) { - t.Errorf("1 should be contained") - } - - l.Add(3, 3) - if l.Contains(1) { - t.Errorf("Contains should not have updated recent-ness of 1") - } -} - -// Test that Peek doesn't update recent-ness -func TestLRU_Peek(t *testing.T) { - l, err := NewLRU(2, nil) - if err != nil { - t.Fatalf("err: %v", err) - } - - l.Add(1, 1) - l.Add(2, 2) - if v, ok := l.Peek(1); !ok || v != 1 { - t.Errorf("1 should be set to 1: %v, %v", v, ok) - } - - l.Add(3, 3) - if l.Contains(1) { - t.Errorf("should not have updated recent-ness of 1") - } -} - -// Test that Resize can upsize and downsize -func TestLRU_Resize(t *testing.T) { - onEvictCounter := 0 - onEvicted := func(k interface{}, v interface{}) { - onEvictCounter++ - } - l, err := NewLRU(2, onEvicted) - if err != nil { - t.Fatalf("err: %v", err) - } - - // Downsize - l.Add(1, 1) - l.Add(2, 2) - evicted := l.Resize(1); - if evicted != 1 { - t.Errorf("1 element should have been evicted: %v", evicted) - } - if onEvictCounter != 1 { - t.Errorf("onEvicted should have been called 1 time: %v", onEvictCounter) - } - - l.Add(3, 3) - if l.Contains(1) { - t.Errorf("Element 1 should have been evicted") - } - - // Upsize - evicted = l.Resize(2); - if evicted != 0 { - t.Errorf("0 elements should have been evicted: %v", evicted) - } - - l.Add(4, 4) - if !l.Contains(3) || !l.Contains(4) { - t.Errorf("Cache should have contained 2 elements") - } -} diff --git a/third_party/github.com/joho/godotenv/LICENCE b/third_party/github.com/joho/godotenv/LICENCE deleted file mode 100644 index e7ddd51be90..00000000000 --- a/third_party/github.com/joho/godotenv/LICENCE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2013 John Barton - -MIT License - -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. - diff --git a/third_party/github.com/markbates/inflect/LICENCE b/third_party/github.com/markbates/inflect/LICENCE deleted file mode 100644 index 8a36b944a5e..00000000000 --- a/third_party/github.com/markbates/inflect/LICENCE +++ /dev/null @@ -1,7 +0,0 @@ -Copyright (c) 2011 Chris Farmiloe - -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. diff --git a/third_party/github.com/rogpeppe/go-internal/LICENSE b/third_party/github.com/rogpeppe/go-internal/LICENSE deleted file mode 100644 index 49ea0f92882..00000000000 --- a/third_party/github.com/rogpeppe/go-internal/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2018 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. diff --git a/third_party/golang.org/x/xerrors/LICENSE b/third_party/golang.org/x/xerrors/LICENSE deleted file mode 100644 index e4a47e17f14..00000000000 --- a/third_party/golang.org/x/xerrors/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2019 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. diff --git a/vendor/github.com/gobuffalo/envy/.env b/vendor/github.com/gobuffalo/envy/.env deleted file mode 100644 index 33eeb3b13b9..00000000000 --- a/vendor/github.com/gobuffalo/envy/.env +++ /dev/null @@ -1,5 +0,0 @@ -# This is a comment -# We can use equal or colon notation -DIR: root -FLAVOUR: none -INSIDE_FOLDER=false \ No newline at end of file diff --git a/vendor/github.com/gobuffalo/envy/.gitignore b/vendor/github.com/gobuffalo/envy/.gitignore deleted file mode 100644 index 49ca1f459f7..00000000000 --- a/vendor/github.com/gobuffalo/envy/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -*.log -.DS_Store -doc -tmp -pkg -*.pid -coverage -coverage.data -build/* -*.pbxuser -*.mode1v3 -.svn -profile -.console_history -.sass-cache/* -solr/ -.jhw-cache/ -jhw.* -*.sublime* -node_modules/ -dist/ -generated/ -.vendor/ -bin/* -gin-bin -.idea/ -.vscode diff --git a/vendor/github.com/gobuffalo/envy/LICENSE.txt b/vendor/github.com/gobuffalo/envy/LICENSE.txt deleted file mode 100644 index 123ddc0d804..00000000000 --- a/vendor/github.com/gobuffalo/envy/LICENSE.txt +++ /dev/null @@ -1,8 +0,0 @@ -The MIT License (MIT) -Copyright (c) 2018 Mark Bates - -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. diff --git a/vendor/github.com/gobuffalo/envy/README.md b/vendor/github.com/gobuffalo/envy/README.md deleted file mode 100644 index f54462a7732..00000000000 --- a/vendor/github.com/gobuffalo/envy/README.md +++ /dev/null @@ -1,93 +0,0 @@ -# envy -[![Build Status](https://travis-ci.org/gobuffalo/envy.svg?branch=master)](https://travis-ci.org/gobuffalo/envy) - -Envy makes working with ENV variables in Go trivial. - -* Get ENV variables with default values. -* Set ENV variables safely without affecting the underlying system. -* Temporarily change ENV vars; useful for testing. -* Map all of the key/values in the ENV. -* Loads .env files (by using [godotenv](https://github.com/joho/godotenv/)) -* More! - -## Installation - -```text -$ go get -u github.com/gobuffalo/envy -``` - -## Usage - -```go -func Test_Get(t *testing.T) { - r := require.New(t) - r.NotZero(os.Getenv("GOPATH")) - r.Equal(os.Getenv("GOPATH"), envy.Get("GOPATH", "foo")) - r.Equal("bar", envy.Get("IDONTEXIST", "bar")) -} - -func Test_MustGet(t *testing.T) { - r := require.New(t) - r.NotZero(os.Getenv("GOPATH")) - v, err := envy.MustGet("GOPATH") - r.NoError(err) - r.Equal(os.Getenv("GOPATH"), v) - - _, err = envy.MustGet("IDONTEXIST") - r.Error(err) -} - -func Test_Set(t *testing.T) { - r := require.New(t) - _, err := envy.MustGet("FOO") - r.Error(err) - - envy.Set("FOO", "foo") - r.Equal("foo", envy.Get("FOO", "bar")) -} - -func Test_Temp(t *testing.T) { - r := require.New(t) - - _, err := envy.MustGet("BAR") - r.Error(err) - - envy.Temp(func() { - envy.Set("BAR", "foo") - r.Equal("foo", envy.Get("BAR", "bar")) - _, err = envy.MustGet("BAR") - r.NoError(err) - }) - - _, err = envy.MustGet("BAR") - r.Error(err) -} -``` -## .env files support - -Envy now supports loading `.env` files by using the [godotenv library](https://github.com/joho/godotenv/). -That means one can use and define multiple `.env` files which will be loaded on-demand. By default, no env files will be loaded. To load one or more, you need to call the `envy.Load` function in one of the following ways: - -```go -envy.Load() // 1 - -envy.Load("MY_ENV_FILE") // 2 - -envy.Load(".env", ".env.prod") // 3 - -envy.Load(".env", "NON_EXISTING_FILE") // 4 - -// 5 -envy.Load(".env") -envy.Load("NON_EXISTING_FILE") - -// 6 -envy.Load(".env", "NON_EXISTING_FILE", ".env.prod") -``` - -1. Will load the default `.env` file -2. Will load the file `MY_ENV_FILE`, **but not** `.env` -3. Will load the file `.env`, and after that will load the `.env.prod` file. If any variable is redefined in `. env.prod` it will be overwritten (will contain the `env.prod` value) -4. Will load the `.env` file and return an error as the second file does not exist. The values in `.env` will be loaded and available. -5. Same as 4 -6. Will load the `.env` file and return an error as the second file does not exist. The values in `.env` will be loaded and available, **but the ones in** `.env.prod` **won't**. diff --git a/vendor/github.com/gobuffalo/envy/SHOULDERS.md b/vendor/github.com/gobuffalo/envy/SHOULDERS.md deleted file mode 100644 index b5a88bb89ac..00000000000 --- a/vendor/github.com/gobuffalo/envy/SHOULDERS.md +++ /dev/null @@ -1,30 +0,0 @@ -# github.com/gobuffalo/envy Stands on the Shoulders of Giants - -github.com/gobuffalo/envy does not try to reinvent the wheel! Instead, it uses the already great wheels developed by the Go community and puts them all together in the best way possible. Without these giants, this project would not be possible. Please make sure to check them out and thank them for all of their hard work. - -Thank you to the following **GIANTS**: - - -* [github.com/davecgh/go-spew](https://godoc.org/github.com/davecgh/go-spew) - -* [github.com/joho/godotenv](https://godoc.org/github.com/joho/godotenv) - -* [github.com/kr/pretty](https://godoc.org/github.com/kr/pretty) - -* [github.com/kr/pty](https://godoc.org/github.com/kr/pty) - -* [github.com/kr/text](https://godoc.org/github.com/kr/text) - -* [github.com/pmezard/go-difflib](https://godoc.org/github.com/pmezard/go-difflib) - -* [github.com/rogpeppe/go-internal](https://godoc.org/github.com/rogpeppe/go-internal) - -* [github.com/stretchr/objx](https://godoc.org/github.com/stretchr/objx) - -* [github.com/stretchr/testify](https://godoc.org/github.com/stretchr/testify) - -* [gopkg.in/check.v1](https://godoc.org/gopkg.in/check.v1) - -* [gopkg.in/errgo.v2](https://godoc.org/gopkg.in/errgo.v2) - -* [gopkg.in/yaml.v2](https://godoc.org/gopkg.in/yaml.v2) diff --git a/vendor/github.com/gobuffalo/envy/azure-pipelines.yml b/vendor/github.com/gobuffalo/envy/azure-pipelines.yml deleted file mode 100644 index 82a343c51d2..00000000000 --- a/vendor/github.com/gobuffalo/envy/azure-pipelines.yml +++ /dev/null @@ -1,66 +0,0 @@ -variables: - GOPROXY: "https://proxy.golang.org" - GOBIN: "$(GOPATH)/bin" # Go binaries path - GOPATH: "$(system.defaultWorkingDirectory)/gopath" # Go workspace path - modulePath: "$(GOPATH)/src/github.com/$(build.repository.name)" # Path to the module"s code - -jobs: -- job: Windows - pool: - vmImage: "vs2017-win2016" - strategy: - matrix: - go 1.12 (on): - go_version: "1.12.9" - GO111MODULE: "on" - go 1.12 (off): - go_version: "1.12.9" - GO111MODULE: "off" - go 1.13 (on): - go_version: "1.13" - GO111MODULE: "on" - go 1.13 (off): - go_version: "1.13" - GO111MODULE: "off" - steps: - - template: azure-tests.yml - -- job: macOS - pool: - vmImage: "macOS-10.13" - strategy: - matrix: - go 1.12 (on): - go_version: "1.12.9" - GO111MODULE: "on" - go 1.12 (off): - go_version: "1.12.9" - GO111MODULE: "off" - go 1.13 (on): - go_version: "1.13" - GO111MODULE: "on" - go 1.13 (off): - go_version: "1.13" - GO111MODULE: "off" - steps: - - template: azure-tests.yml - -- job: Linux - pool: - vmImage: "ubuntu-16.04" - strategy: - matrix: - go 1.12 (on): - go_version: "1.12.9" - GO111MODULE: "on" - go 1.12 (off): - go_version: "1.12.9" - GO111MODULE: "off" - go 1.13 (on): - go_version: "1.13" - GO111MODULE: "on" - go 1.13 (off): - go_version: "1.13" - GO111MODULE: "off" - steps: - - template: azure-tests.yml diff --git a/vendor/github.com/gobuffalo/envy/azure-tests.yml b/vendor/github.com/gobuffalo/envy/azure-tests.yml deleted file mode 100644 index eea5822fad5..00000000000 --- a/vendor/github.com/gobuffalo/envy/azure-tests.yml +++ /dev/null @@ -1,19 +0,0 @@ -steps: - - task: GoTool@0 - inputs: - version: $(go_version) - - task: Bash@3 - inputs: - targetType: inline - script: | - mkdir -p "$(GOBIN)" - mkdir -p "$(GOPATH)/pkg" - mkdir -p "$(modulePath)" - shopt -s extglob - mv !(gopath) "$(modulePath)" - displayName: "Setup Go Workspace" - - script: | - go get -t -v ./... - go test -race ./... - workingDirectory: "$(modulePath)" - displayName: "Tests" diff --git a/vendor/github.com/gobuffalo/envy/azure.sh b/vendor/github.com/gobuffalo/envy/azure.sh deleted file mode 100644 index f70949796f8..00000000000 --- a/vendor/github.com/gobuffalo/envy/azure.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -set -xe - -cat >> .env << EOF -# This is a comment -# We can use equal or colon notation -DIR: root -FLAVOUR: none -INSIDE_FOLDER=false -EOF diff --git a/vendor/github.com/gobuffalo/envy/env b/vendor/github.com/gobuffalo/envy/env deleted file mode 100644 index 33eeb3b13b9..00000000000 --- a/vendor/github.com/gobuffalo/envy/env +++ /dev/null @@ -1,5 +0,0 @@ -# This is a comment -# We can use equal or colon notation -DIR: root -FLAVOUR: none -INSIDE_FOLDER=false \ No newline at end of file diff --git a/vendor/github.com/gobuffalo/envy/envy.go b/vendor/github.com/gobuffalo/envy/envy.go deleted file mode 100644 index dc31ba2c0ce..00000000000 --- a/vendor/github.com/gobuffalo/envy/envy.go +++ /dev/null @@ -1,276 +0,0 @@ -/* -package envy makes working with ENV variables in Go trivial. - -* Get ENV variables with default values. -* Set ENV variables safely without affecting the underlying system. -* Temporarily change ENV vars; useful for testing. -* Map all of the key/values in the ENV. -* Loads .env files (by using [godotenv](https://github.com/joho/godotenv/)) -* More! -*/ -package envy - -import ( - "errors" - "flag" - "fmt" - "io/ioutil" - "os" - "os/exec" - "path/filepath" - "runtime" - "strings" - "sync" - - "github.com/joho/godotenv" - "github.com/rogpeppe/go-internal/modfile" -) - -var gil = &sync.RWMutex{} -var env = map[string]string{} - -// GO111MODULE is ENV for turning mods on/off -const GO111MODULE = "GO111MODULE" - -func init() { - Load() - loadEnv() -} - -// Load the ENV variables to the env map -func loadEnv() { - gil.Lock() - defer gil.Unlock() - - if os.Getenv("GO_ENV") == "" { - // if the flag "test.v" is *defined*, we're running as a unit test. Note that we don't care - // about v.Value (verbose test mode); we just want to know if the test environment has defined - // it. It's also possible that the flags are not yet fully parsed (i.e. flag.Parsed() == false), - // so we could not depend on v.Value anyway. - // - if v := flag.Lookup("test.v"); v != nil { - env["GO_ENV"] = "test" - } - } - - // set the GOPATH if using >= 1.8 and the GOPATH isn't set - if os.Getenv("GOPATH") == "" { - out, err := exec.Command("go", "env", "GOPATH").Output() - if err == nil { - gp := strings.TrimSpace(string(out)) - os.Setenv("GOPATH", gp) - } - } - - for _, e := range os.Environ() { - pair := strings.Split(e, "=") - env[pair[0]] = os.Getenv(pair[0]) - } -} - -// Mods returns true if module support is enabled, false otherwise -// See https://github.com/golang/go/wiki/Modules#how-to-install-and-activate-module-support for details -func Mods() bool { - go111 := Get(GO111MODULE, "") - - if !InGoPath() { - return go111 != "off" - } - - return go111 == "on" -} - -// Reload the ENV variables. Useful if -// an external ENV manager has been used -func Reload() { - env = map[string]string{} - loadEnv() -} - -// Load .env files. Files will be loaded in the same order that are received. -// Redefined vars will override previously existing values. -// IE: envy.Load(".env", "test_env/.env") will result in DIR=test_env -// If no arg passed, it will try to load a .env file. -func Load(files ...string) error { - - // If no files received, load the default one - if len(files) == 0 { - err := godotenv.Overload() - if err == nil { - Reload() - } - return err - } - - // We received a list of files - for _, file := range files { - - // Check if it exists or we can access - if _, err := os.Stat(file); err != nil { - // It does not exist or we can not access. - // Return and stop loading - return err - } - - // It exists and we have permission. Load it - if err := godotenv.Overload(file); err != nil { - return err - } - - // Reload the env so all new changes are noticed - Reload() - - } - return nil -} - -// Get a value from the ENV. If it doesn't exist the -// default value will be returned. -func Get(key string, value string) string { - gil.RLock() - defer gil.RUnlock() - if v, ok := env[key]; ok { - return v - } - return value -} - -// Get a value from the ENV. If it doesn't exist -// an error will be returned -func MustGet(key string) (string, error) { - gil.RLock() - defer gil.RUnlock() - if v, ok := env[key]; ok { - return v, nil - } - return "", fmt.Errorf("could not find ENV var with %s", key) -} - -// Set a value into the ENV. This is NOT permanent. It will -// only affect values accessed through envy. -func Set(key string, value string) { - gil.Lock() - defer gil.Unlock() - env[key] = value -} - -// MustSet the value into the underlying ENV, as well as envy. -// This may return an error if there is a problem setting the -// underlying ENV value. -func MustSet(key string, value string) error { - gil.Lock() - defer gil.Unlock() - err := os.Setenv(key, value) - if err != nil { - return err - } - env[key] = value - return nil -} - -// Map all of the keys/values set in envy. -func Map() map[string]string { - gil.RLock() - defer gil.RUnlock() - cp := map[string]string{} - for k, v := range env { - cp[k] = v - } - return cp -} - -// Temp makes a copy of the values and allows operation on -// those values temporarily during the run of the function. -// At the end of the function run the copy is discarded and -// the original values are replaced. This is useful for testing. -// Warning: This function is NOT safe to use from a goroutine or -// from code which may access any Get or Set function from a goroutine -func Temp(f func()) { - oenv := env - env = map[string]string{} - for k, v := range oenv { - env[k] = v - } - defer func() { env = oenv }() - f() -} - -func GoPath() string { - return Get("GOPATH", "") -} - -func GoBin() string { - return Get("GO_BIN", "go") -} - -func InGoPath() bool { - pwd, _ := os.Getwd() - for _, p := range GoPaths() { - if strings.HasPrefix(pwd, p) { - return true - } - } - return false -} - -// GoPaths returns all possible GOPATHS that are set. -func GoPaths() []string { - gp := Get("GOPATH", "") - if runtime.GOOS == "windows" { - return strings.Split(gp, ";") // Windows uses a different separator - } - return strings.Split(gp, ":") -} - -func importPath(path string) string { - path = strings.TrimPrefix(path, "/private") - for _, gopath := range GoPaths() { - srcpath := filepath.Join(gopath, "src") - rel, err := filepath.Rel(srcpath, path) - if err == nil { - return filepath.ToSlash(rel) - } - } - - // fallback to trim - rel := strings.TrimPrefix(path, filepath.Join(GoPath(), "src")) - rel = strings.TrimPrefix(rel, string(filepath.Separator)) - return filepath.ToSlash(rel) -} - -// CurrentModule will attempt to return the module name from `go.mod` if -// modules are enabled. -// If modules are not enabled it will fallback to using CurrentPackage instead. -func CurrentModule() (string, error) { - if !Mods() { - return CurrentPackage(), nil - } - moddata, err := ioutil.ReadFile("go.mod") - if err != nil { - return "", errors.New("go.mod cannot be read or does not exist while go module is enabled") - } - packagePath := modfile.ModulePath(moddata) - if packagePath == "" { - return "", errors.New("go.mod is malformed") - } - return packagePath, nil -} - -// CurrentPackage attempts to figure out the current package name from the PWD -// Use CurrentModule for a more accurate package name. -func CurrentPackage() string { - if Mods() { - } - pwd, _ := os.Getwd() - return importPath(pwd) -} - -func Environ() []string { - gil.RLock() - defer gil.RUnlock() - var e []string - for k, v := range env { - e = append(e, fmt.Sprintf("%s=%s", k, v)) - } - return e -} diff --git a/vendor/github.com/gobuffalo/envy/go.mod b/vendor/github.com/gobuffalo/envy/go.mod deleted file mode 100644 index 2c3747369e9..00000000000 --- a/vendor/github.com/gobuffalo/envy/go.mod +++ /dev/null @@ -1,10 +0,0 @@ -module github.com/gobuffalo/envy - -go 1.13 - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/joho/godotenv v1.3.0 - github.com/rogpeppe/go-internal v1.3.2 - github.com/stretchr/testify v1.4.0 -) diff --git a/vendor/github.com/gobuffalo/envy/go.sum b/vendor/github.com/gobuffalo/envy/go.sum deleted file mode 100644 index d6e470567c3..00000000000 --- a/vendor/github.com/gobuffalo/envy/go.sum +++ /dev/null @@ -1,24 +0,0 @@ -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.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= -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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.3.2 h1:XU784Pr0wdahMY2bYcyK6N1KuaRAdLtqD4qd8D18Bfs= -github.com/rogpeppe/go-internal v1.3.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -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= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/gobuffalo/envy/version.go b/vendor/github.com/gobuffalo/envy/version.go deleted file mode 100644 index e2cff15d62f..00000000000 --- a/vendor/github.com/gobuffalo/envy/version.go +++ /dev/null @@ -1,3 +0,0 @@ -package envy - -const Version = "v1.7.1" diff --git a/vendor/github.com/markbates/inflect/.gitignore b/vendor/github.com/gobuffalo/flect/.gitignore similarity index 100% rename from vendor/github.com/markbates/inflect/.gitignore rename to vendor/github.com/gobuffalo/flect/.gitignore diff --git a/vendor/github.com/markbates/inflect/.gometalinter.json b/vendor/github.com/gobuffalo/flect/.gometalinter.json similarity index 100% rename from vendor/github.com/markbates/inflect/.gometalinter.json rename to vendor/github.com/gobuffalo/flect/.gometalinter.json diff --git a/vendor/github.com/gobuffalo/envy/LICENSE b/vendor/github.com/gobuffalo/flect/LICENSE similarity index 100% rename from vendor/github.com/gobuffalo/envy/LICENSE rename to vendor/github.com/gobuffalo/flect/LICENSE diff --git a/vendor/github.com/gobuffalo/envy/Makefile b/vendor/github.com/gobuffalo/flect/Makefile similarity index 92% rename from vendor/github.com/gobuffalo/envy/Makefile rename to vendor/github.com/gobuffalo/flect/Makefile index 83a6d20ac04..0ac539f1c2e 100644 --- a/vendor/github.com/gobuffalo/envy/Makefile +++ b/vendor/github.com/gobuffalo/flect/Makefile @@ -1,8 +1,7 @@ TAGS ?= "" GO_BIN ?= "go" -GO_ENV ?= "test" -install: +install: $(GO_BIN) install -tags ${TAGS} -v . make tidy @@ -17,18 +16,18 @@ deps: $(GO_BIN) get -tags ${TAGS} -t ./... make tidy -build: +build: $(GO_BIN) build -v . make tidy -test: +test: $(GO_BIN) test -cover -tags ${TAGS} ./... make tidy -ci-deps: +ci-deps: $(GO_BIN) get -tags ${TAGS} -t ./... -ci-test: +ci-test: $(GO_BIN) test -tags ${TAGS} -race ./... lint: @@ -48,7 +47,7 @@ endif make install make tidy -release-test: +release-test: $(GO_BIN) test -tags ${TAGS} -race ./... make tidy diff --git a/vendor/github.com/gobuffalo/flect/README.md b/vendor/github.com/gobuffalo/flect/README.md new file mode 100644 index 00000000000..2d9a1bd3b6a --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/README.md @@ -0,0 +1,36 @@ +# Flect + +

+GoDoc +CI +Go Report Card +

+ +This is a new inflection engine to replace [https://github.com/markbates/inflect](https://github.com/markbates/inflect) designed to be more modular, more readable, and easier to fix issues on than the original. + +## Installation + +```bash +$ go get -u -v github.com/gobuffalo/flect +``` + +## `github.com/gobuffalo/flect` +GoDoc + +The `github.com/gobuffalo/flect` package contains "basic" inflection tools, like pluralization, singularization, etc... + +### The `Ident` Type + +In addition to helpful methods that take in a `string` and return a `string`, there is an `Ident` type that can be used to create new, custom, inflection rules. + +The `Ident` type contains two fields. + +* `Original` - This is the original `string` that was used to create the `Ident` +* `Parts` - This is a `[]string` that represents all of the "parts" of the string, that have been split apart, making the segments easier to work with + +Examples of creating new inflection rules using `Ident` can be found in the `github.com/gobuffalo/flect/name` package. + +## `github.com/gobuffalo/flect/name` +GoDoc + +The `github.com/gobuffalo/flect/name` package contains more "business" inflection rules like creating proper names, table names, etc... diff --git a/vendor/github.com/gobuffalo/flect/SHOULDERS.md b/vendor/github.com/gobuffalo/flect/SHOULDERS.md new file mode 100644 index 00000000000..8c359f157e6 --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/SHOULDERS.md @@ -0,0 +1,10 @@ +# github.com/gobuffalo/flect Stands on the Shoulders of Giants + +github.com/gobuffalo/flect does not try to reinvent the wheel! Instead, it uses the already great wheels developed by the Go community and puts them all together in the best way possible. Without these giants, this project would not be possible. Please make sure to check them out and thank them for all of their hard work. + +Thank you to the following **GIANTS**: + + +* [github.com/davecgh/go-spew](https://godoc.org/github.com/davecgh/go-spew) + +* [github.com/stretchr/testify](https://godoc.org/github.com/stretchr/testify) diff --git a/vendor/github.com/gobuffalo/flect/acronyms.go b/vendor/github.com/gobuffalo/flect/acronyms.go new file mode 100644 index 00000000000..b169724a4ca --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/acronyms.go @@ -0,0 +1,152 @@ +package flect + +import "sync" + +var acronymsMoot = &sync.RWMutex{} + +var baseAcronyms = map[string]bool{ + "OK": true, + "UTF8": true, + "HTML": true, + "JSON": true, + "JWT": true, + "ID": true, + "UUID": true, + "SQL": true, + "ACK": true, + "ACL": true, + "ADSL": true, + "AES": true, + "ANSI": true, + "API": true, + "ARP": true, + "ATM": true, + "BGP": true, + "BSS": true, + "CCITT": true, + "CHAP": true, + "CIDR": true, + "CIR": true, + "CLI": true, + "CPE": true, + "CPU": true, + "CRC": true, + "CRT": true, + "CSMA": true, + "CMOS": true, + "DCE": true, + "DEC": true, + "DES": true, + "DHCP": true, + "DNS": true, + "DRAM": true, + "DSL": true, + "DSLAM": true, + "DTE": true, + "DMI": true, + "EHA": true, + "EIA": true, + "EIGRP": true, + "EOF": true, + "ESS": true, + "FCC": true, + "FCS": true, + "FDDI": true, + "FTP": true, + "GBIC": true, + "gbps": true, + "GEPOF": true, + "HDLC": true, + "HTTP": true, + "HTTPS": true, + "IANA": true, + "ICMP": true, + "IDF": true, + "IDS": true, + "IEEE": true, + "IETF": true, + "IMAP": true, + "IP": true, + "IPS": true, + "ISDN": true, + "ISP": true, + "kbps": true, + "LACP": true, + "LAN": true, + "LAPB": true, + "LAPF": true, + "LLC": true, + "MAC": true, + "Mbps": true, + "MC": true, + "MDF": true, + "MIB": true, + "MoCA": true, + "MPLS": true, + "MTU": true, + "NAC": true, + "NAT": true, + "NBMA": true, + "NIC": true, + "NRZ": true, + "NRZI": true, + "NVRAM": true, + "OSI": true, + "OSPF": true, + "OUI": true, + "PAP": true, + "PAT": true, + "PC": true, + "PIM": true, + "PCM": true, + "PDU": true, + "POP3": true, + "POTS": true, + "PPP": true, + "PPTP": true, + "PTT": true, + "PVST": true, + "RAM": true, + "RARP": true, + "RFC": true, + "RIP": true, + "RLL": true, + "ROM": true, + "RSTP": true, + "RTP": true, + "RCP": true, + "SDLC": true, + "SFD": true, + "SFP": true, + "SLARP": true, + "SLIP": true, + "SMTP": true, + "SNA": true, + "SNAP": true, + "SNMP": true, + "SOF": true, + "SRAM": true, + "SSH": true, + "SSID": true, + "STP": true, + "SYN": true, + "TDM": true, + "TFTP": true, + "TIA": true, + "TOFU": true, + "UDP": true, + "URL": true, + "URI": true, + "USB": true, + "UTP": true, + "VC": true, + "VLAN": true, + "VLSM": true, + "VPN": true, + "W3C": true, + "WAN": true, + "WEP": true, + "WiFi": true, + "WPA": true, + "WWW": true, +} diff --git a/vendor/github.com/gobuffalo/flect/camelize.go b/vendor/github.com/gobuffalo/flect/camelize.go new file mode 100644 index 00000000000..8a9928e8bee --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/camelize.go @@ -0,0 +1,48 @@ +package flect + +import ( + "strings" + "unicode" +) + +// Camelize returns a camelize version of a string +// bob dylan = bobDylan +// widget_id = widgetID +// WidgetID = widgetID +func Camelize(s string) string { + return New(s).Camelize().String() +} + +// Camelize returns a camelize version of a string +// bob dylan = bobDylan +// widget_id = widgetID +// WidgetID = widgetID +func (i Ident) Camelize() Ident { + var out []string + for i, part := range i.Parts { + var x string + var capped bool + if strings.ToLower(part) == "id" { + out = append(out, "ID") + continue + } + for _, c := range part { + if unicode.IsLetter(c) || unicode.IsDigit(c) { + if i == 0 { + x += string(unicode.ToLower(c)) + continue + } + if !capped { + capped = true + x += string(unicode.ToUpper(c)) + continue + } + x += string(c) + } + } + if x != "" { + out = append(out, x) + } + } + return New(strings.Join(out, "")) +} diff --git a/vendor/github.com/gobuffalo/flect/capitalize.go b/vendor/github.com/gobuffalo/flect/capitalize.go new file mode 100644 index 00000000000..78334fc0f91 --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/capitalize.go @@ -0,0 +1,24 @@ +package flect + +import "unicode" + +// Capitalize will cap the first letter of string +// user = User +// bob dylan = Bob dylan +// widget_id = Widget_id +func Capitalize(s string) string { + return New(s).Capitalize().String() +} + +// Capitalize will cap the first letter of string +// user = User +// bob dylan = Bob dylan +// widget_id = Widget_id +func (i Ident) Capitalize() Ident { + if len(i.Parts) == 0 { + return New("") + } + runes := []rune(i.Original) + runes[0] = unicode.ToTitle(runes[0]) + return New(string(runes)) +} diff --git a/vendor/github.com/gobuffalo/flect/custom_data.go b/vendor/github.com/gobuffalo/flect/custom_data.go new file mode 100644 index 00000000000..9a2dfc74ad8 --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/custom_data.go @@ -0,0 +1,83 @@ +package flect + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" +) + +func init() { + loadCustomData("inflections.json", "INFLECT_PATH", "could not read inflection file", LoadInflections) + loadCustomData("acronyms.json", "ACRONYMS_PATH", "could not read acronyms file", LoadAcronyms) +} + +//CustomDataParser are functions that parse data like acronyms or +//plurals in the shape of a io.Reader it receives. +type CustomDataParser func(io.Reader) error + +func loadCustomData(defaultFile, env, readErrorMessage string, parser CustomDataParser) { + pwd, _ := os.Getwd() + path, found := os.LookupEnv(env) + if !found { + path = filepath.Join(pwd, defaultFile) + } + + if _, err := os.Stat(path); err != nil { + return + } + + b, err := ioutil.ReadFile(path) + if err != nil { + fmt.Printf("%s %s (%s)\n", readErrorMessage, path, err) + return + } + + if err = parser(bytes.NewReader(b)); err != nil { + fmt.Println(err) + } +} + +//LoadAcronyms loads rules from io.Reader param +func LoadAcronyms(r io.Reader) error { + m := []string{} + err := json.NewDecoder(r).Decode(&m) + + if err != nil { + return fmt.Errorf("could not decode acronyms JSON from reader: %s", err) + } + + acronymsMoot.Lock() + defer acronymsMoot.Unlock() + + for _, acronym := range m { + baseAcronyms[acronym] = true + } + + return nil +} + +//LoadInflections loads rules from io.Reader param +func LoadInflections(r io.Reader) error { + m := map[string]string{} + + err := json.NewDecoder(r).Decode(&m) + if err != nil { + return fmt.Errorf("could not decode inflection JSON from reader: %s", err) + } + + pluralMoot.Lock() + defer pluralMoot.Unlock() + singularMoot.Lock() + defer singularMoot.Unlock() + + for s, p := range m { + singleToPlural[s] = p + pluralToSingle[p] = s + } + + return nil +} diff --git a/vendor/github.com/gobuffalo/flect/dasherize.go b/vendor/github.com/gobuffalo/flect/dasherize.go new file mode 100644 index 00000000000..c7a8a33e366 --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/dasherize.go @@ -0,0 +1,34 @@ +package flect + +import ( + "strings" + "unicode" +) + +// Dasherize returns an alphanumeric, lowercased, dashed string +// Donald E. Knuth = donald-e-knuth +// Test with + sign = test-with-sign +// admin/WidgetID = admin-widget-id +func Dasherize(s string) string { + return New(s).Dasherize().String() +} + +// Dasherize returns an alphanumeric, lowercased, dashed string +// Donald E. Knuth = donald-e-knuth +// Test with + sign = test-with-sign +// admin/WidgetID = admin-widget-id +func (i Ident) Dasherize() Ident { + var parts []string + + for _, part := range i.Parts { + var x string + for _, c := range part { + if unicode.IsLetter(c) || unicode.IsDigit(c) { + x += string(c) + } + } + parts = xappend(parts, x) + } + + return New(strings.ToLower(strings.Join(parts, "-"))) +} diff --git a/vendor/github.com/gobuffalo/flect/flect.go b/vendor/github.com/gobuffalo/flect/flect.go new file mode 100644 index 00000000000..ee81b6f2bcd --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/flect.go @@ -0,0 +1,43 @@ +/* +Package flect is a new inflection engine to replace [https://github.com/markbates/inflect](https://github.com/markbates/inflect) designed to be more modular, more readable, and easier to fix issues on than the original. +*/ +package flect + +import ( + "strings" + "unicode" +) + +var spaces = []rune{'_', ' ', ':', '-', '/'} + +func isSpace(c rune) bool { + for _, r := range spaces { + if r == c { + return true + } + } + return unicode.IsSpace(c) +} + +func xappend(a []string, ss ...string) []string { + for _, s := range ss { + s = strings.TrimSpace(s) + for _, x := range spaces { + s = strings.Trim(s, string(x)) + } + if _, ok := baseAcronyms[strings.ToUpper(s)]; ok { + s = strings.ToUpper(s) + } + if s != "" { + a = append(a, s) + } + } + return a +} + +func abs(x int) int { + if x < 0 { + return -x + } + return x +} diff --git a/vendor/github.com/gobuffalo/flect/go.mod b/vendor/github.com/gobuffalo/flect/go.mod new file mode 100644 index 00000000000..7c8d049abaa --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/go.mod @@ -0,0 +1,5 @@ +module github.com/gobuffalo/flect + +go 1.13 + +require github.com/stretchr/testify v1.4.0 diff --git a/vendor/github.com/gobuffalo/flect/go.sum b/vendor/github.com/gobuffalo/flect/go.sum new file mode 100644 index 00000000000..8fdee5854f1 --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/go.sum @@ -0,0 +1,11 @@ +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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +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/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/gobuffalo/flect/humanize.go b/vendor/github.com/gobuffalo/flect/humanize.go new file mode 100644 index 00000000000..6a0b75af7bf --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/humanize.go @@ -0,0 +1,35 @@ +package flect + +import ( + "strings" +) + +// Humanize returns first letter of sentence capitalized. +// Common acronyms are capitalized as well. +// Other capital letters in string are left as provided. +// employee_salary = Employee salary +// employee_id = employee ID +// employee_mobile_number = Employee mobile number +// first_Name = First Name +// firstName = First Name +func Humanize(s string) string { + return New(s).Humanize().String() +} + +// Humanize First letter of sentence capitalized +func (i Ident) Humanize() Ident { + if len(i.Original) == 0 { + return New("") + } + + var parts []string + for index, part := range i.Parts { + if index == 0 { + part = strings.Title(i.Parts[0]) + } + + parts = xappend(parts, part) + } + + return New(strings.Join(parts, " ")) +} diff --git a/vendor/github.com/gobuffalo/flect/ident.go b/vendor/github.com/gobuffalo/flect/ident.go new file mode 100644 index 00000000000..9189e9a39b6 --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/ident.go @@ -0,0 +1,122 @@ +package flect + +import ( + "encoding" + "strings" + "unicode" + "unicode/utf8" +) + +// Ident represents the string and it's parts +type Ident struct { + Original string + Parts []string +} + +// String implements fmt.Stringer and returns the original string +func (i Ident) String() string { + return i.Original +} + +// New creates a new Ident from the string +func New(s string) Ident { + i := Ident{ + Original: s, + Parts: toParts(s), + } + + return i +} + +func toParts(s string) []string { + parts := []string{} + s = strings.TrimSpace(s) + if len(s) == 0 { + return parts + } + if _, ok := baseAcronyms[strings.ToUpper(s)]; ok { + return []string{strings.ToUpper(s)} + } + var prev rune + var x strings.Builder + x.Grow(len(s)) + for _, c := range s { + // fmt.Println("### cs ->", cs) + // fmt.Println("### unicode.IsControl(c) ->", unicode.IsControl(c)) + // fmt.Println("### unicode.IsDigit(c) ->", unicode.IsDigit(c)) + // fmt.Println("### unicode.IsGraphic(c) ->", unicode.IsGraphic(c)) + // fmt.Println("### unicode.IsLetter(c) ->", unicode.IsLetter(c)) + // fmt.Println("### unicode.IsLower(c) ->", unicode.IsLower(c)) + // fmt.Println("### unicode.IsMark(c) ->", unicode.IsMark(c)) + // fmt.Println("### unicode.IsPrint(c) ->", unicode.IsPrint(c)) + // fmt.Println("### unicode.IsPunct(c) ->", unicode.IsPunct(c)) + // fmt.Println("### unicode.IsSpace(c) ->", unicode.IsSpace(c)) + // fmt.Println("### unicode.IsTitle(c) ->", unicode.IsTitle(c)) + // fmt.Println("### unicode.IsUpper(c) ->", unicode.IsUpper(c)) + if !utf8.ValidRune(c) { + continue + } + + if isSpace(c) { + parts = xappend(parts, x.String()) + x.Reset() + x.WriteRune(c) + prev = c + continue + } + + if unicode.IsUpper(c) && !unicode.IsUpper(prev) { + parts = xappend(parts, x.String()) + x.Reset() + x.WriteRune(c) + prev = c + continue + } + if unicode.IsUpper(c) && baseAcronyms[strings.ToUpper(x.String())] { + parts = xappend(parts, x.String()) + x.Reset() + x.WriteRune(c) + prev = c + continue + } + if unicode.IsLetter(c) || unicode.IsDigit(c) || unicode.IsPunct(c) || c == '`' { + prev = c + x.WriteRune(c) + continue + } + + parts = xappend(parts, x.String()) + x.Reset() + prev = c + } + parts = xappend(parts, x.String()) + + return parts +} + +var _ encoding.TextUnmarshaler = &Ident{} +var _ encoding.TextMarshaler = &Ident{} + +// LastPart returns the last part/word of the original string +func (i *Ident) LastPart() string { + if len(i.Parts) == 0 { + return "" + } + return i.Parts[len(i.Parts)-1] +} + +// ReplaceSuffix creates a new Ident with the original suffix replaced by new +func (i Ident) ReplaceSuffix(orig, new string) Ident { + return New(strings.TrimSuffix(i.Original, orig) + new) +} + +//UnmarshalText unmarshalls byte array into the Ident +func (i *Ident) UnmarshalText(data []byte) error { + (*i) = New(string(data)) + return nil +} + +//MarshalText marshals Ident into byte array +func (i Ident) MarshalText() ([]byte, error) { + return []byte(i.Original), nil +} diff --git a/vendor/github.com/gobuffalo/flect/lower_upper.go b/vendor/github.com/gobuffalo/flect/lower_upper.go new file mode 100644 index 00000000000..930da58d8c7 --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/lower_upper.go @@ -0,0 +1,13 @@ +package flect + +import "strings" + +// ToUpper is a convience wrapper for strings.ToUpper +func (i Ident) ToUpper() Ident { + return New(strings.ToUpper(i.Original)) +} + +// ToLower is a convience wrapper for strings.ToLower +func (i Ident) ToLower() Ident { + return New(strings.ToLower(i.Original)) +} diff --git a/vendor/github.com/gobuffalo/flect/ordinalize.go b/vendor/github.com/gobuffalo/flect/ordinalize.go new file mode 100644 index 00000000000..1ce27b3a0d4 --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/ordinalize.go @@ -0,0 +1,43 @@ +package flect + +import ( + "fmt" + "strconv" +) + +// Ordinalize converts a number to an ordinal version +// 42 = 42nd +// 45 = 45th +// 1 = 1st +func Ordinalize(s string) string { + return New(s).Ordinalize().String() +} + +// Ordinalize converts a number to an ordinal version +// 42 = 42nd +// 45 = 45th +// 1 = 1st +func (i Ident) Ordinalize() Ident { + number, err := strconv.Atoi(i.Original) + if err != nil { + return i + } + var s string + switch abs(number) % 100 { + case 11, 12, 13: + s = fmt.Sprintf("%dth", number) + default: + switch abs(number) % 10 { + case 1: + s = fmt.Sprintf("%dst", number) + case 2: + s = fmt.Sprintf("%dnd", number) + case 3: + s = fmt.Sprintf("%drd", number) + } + } + if s != "" { + return New(s) + } + return New(fmt.Sprintf("%dth", number)) +} diff --git a/vendor/github.com/gobuffalo/flect/pascalize.go b/vendor/github.com/gobuffalo/flect/pascalize.go new file mode 100644 index 00000000000..76f0c6a7066 --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/pascalize.go @@ -0,0 +1,25 @@ +package flect + +import ( + "unicode" +) + +// Pascalize returns a string with each segment capitalized +// user = User +// bob dylan = BobDylan +// widget_id = WidgetID +func Pascalize(s string) string { + return New(s).Pascalize().String() +} + +// Pascalize returns a string with each segment capitalized +// user = User +// bob dylan = BobDylan +// widget_id = WidgetID +func (i Ident) Pascalize() Ident { + c := i.Camelize() + if len(c.String()) == 0 { + return c + } + return New(string(unicode.ToUpper(rune(c.Original[0]))) + c.Original[1:]) +} diff --git a/vendor/github.com/gobuffalo/flect/plural_rules.go b/vendor/github.com/gobuffalo/flect/plural_rules.go new file mode 100644 index 00000000000..8cd3ba72e7a --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/plural_rules.go @@ -0,0 +1,287 @@ +package flect + +var pluralRules = []rule{} + +// AddPlural adds a rule that will replace the given suffix with the replacement suffix. +func AddPlural(suffix string, repl string) { + pluralMoot.Lock() + defer pluralMoot.Unlock() + pluralRules = append(pluralRules, rule{ + suffix: suffix, + fn: func(s string) string { + s = s[:len(s)-len(suffix)] + return s + repl + }, + }) + + pluralRules = append(pluralRules, rule{ + suffix: repl, + fn: noop, + }) +} + +var singleToPlural = map[string]string{ + "aircraft": "aircraft", + "alias": "aliases", + "alumna": "alumnae", + "alumnus": "alumni", + "analysis": "analyses", + "antenna": "antennas", + "antithesis": "antitheses", + "apex": "apexes", + "appendix": "appendices", + "axis": "axes", + "bacillus": "bacilli", + "bacterium": "bacteria", + "basis": "bases", + "beau": "beaus", + "bison": "bison", + "bureau": "bureaus", + "bus": "buses", + "campus": "campuses", + "caucus": "caucuses", + "child": "children", + "château": "châteaux", + "circus": "circuses", + "codex": "codices", + "concerto": "concertos", + "corpus": "corpora", + "crisis": "crises", + "curriculum": "curriculums", + "datum": "data", + "deer": "deer", + "diagnosis": "diagnoses", + "die": "dice", + "dwarf": "dwarves", + "ellipsis": "ellipses", + "equipment": "equipment", + "erratum": "errata", + "faux pas": "faux pas", + "fez": "fezzes", + "fish": "fish", + "focus": "foci", + "foo": "foos", + "foot": "feet", + "formula": "formulas", + "fungus": "fungi", + "genus": "genera", + "goose": "geese", + "graffito": "graffiti", + "grouse": "grouse", + "half": "halves", + "halo": "halos", + "hoof": "hooves", + "human": "humans", + "hypothesis": "hypotheses", + "index": "indices", + "information": "information", + "jeans": "jeans", + "larva": "larvae", + "libretto": "librettos", + "loaf": "loaves", + "locus": "loci", + "louse": "lice", + "matrix": "matrices", + "minutia": "minutiae", + "money": "money", + "moose": "moose", + "mouse": "mice", + "nebula": "nebulae", + "news": "news", + "nucleus": "nuclei", + "oasis": "oases", + "octopus": "octopi", + "offspring": "offspring", + "opus": "opera", + "ovum": "ova", + "ox": "oxen", + "parenthesis": "parentheses", + "phenomenon": "phenomena", + "photo": "photos", + "phylum": "phyla", + "piano": "pianos", + "plus": "pluses", + "police": "police", + "prognosis": "prognoses", + "prometheus": "prometheuses", + "quiz": "quizzes", + "quota": "quotas", + "radius": "radiuses", + "referendum": "referendums", + "ress": "resses", + "rice": "rice", + "salmon": "salmon", + "sex": "sexes", + "series": "series", + "sheep": "sheep", + "shoe": "shoes", + "shrimp": "shrimp", + "species": "species", + "stimulus": "stimuli", + "stratum": "strata", + "swine": "swine", + "syllabus": "syllabi", + "symposium": "symposiums", + "synapse": "synapses", + "synopsis": "synopses", + "tableau": "tableaus", + "testis": "testes", + "thesis": "theses", + "thief": "thieves", + "tooth": "teeth", + "trout": "trout", + "tuna": "tuna", + "vedalia": "vedalias", + "vertebra": "vertebrae", + "vertix": "vertices", + "vita": "vitae", + "vortex": "vortices", + "wharf": "wharves", + "wife": "wives", + "woman": "women", + "wolf": "wolves", + "you": "you", +} + +var pluralToSingle = map[string]string{} + +func init() { + for k, v := range singleToPlural { + pluralToSingle[v] = k + } +} + +type singularToPluralSuffix struct { + singular string + plural string +} + +var singularToPluralSuffixList = []singularToPluralSuffix{ + {"iterion", "iteria"}, + {"campus", "campuses"}, + {"genera", "genus"}, + {"person", "people"}, + {"phylum", "phyla"}, + {"randum", "randa"}, + {"actus", "acti"}, + {"adium", "adia"}, + {"basis", "basis"}, + {"child", "children"}, + {"chive", "chives"}, + {"focus", "foci"}, + {"hello", "hellos"}, + {"jeans", "jeans"}, + {"louse", "lice"}, + {"media", "media"}, + {"mouse", "mice"}, + {"movie", "movies"}, + {"oasis", "oasis"}, + {"atum", "ata"}, + {"atus", "atuses"}, + {"base", "bases"}, + {"cess", "cesses"}, + {"dium", "diums"}, + {"eses", "esis"}, + {"half", "halves"}, + {"hive", "hives"}, + {"iano", "ianos"}, + {"irus", "iri"}, + {"isis", "ises"}, + {"leus", "li"}, + {"mnus", "mni"}, + {"move", "moves"}, + {"news", "news"}, + {"odex", "odice"}, + {"oose", "eese"}, + {"ouse", "ouses"}, + {"ovum", "ova"}, + {"rion", "ria"}, + {"shoe", "shoes"}, + {"stis", "stes"}, + {"tive", "tives"}, + {"wife", "wives"}, + {"afe", "aves"}, + {"bfe", "bves"}, + {"box", "boxes"}, + {"cfe", "cves"}, + {"dfe", "dves"}, + {"dge", "dges"}, + {"efe", "eves"}, + {"gfe", "gves"}, + {"hfe", "hves"}, + {"ife", "ives"}, + {"itz", "itzes"}, + {"ium", "ia"}, + {"ize", "izes"}, + {"jfe", "jves"}, + {"kfe", "kves"}, + {"man", "men"}, + {"mfe", "mves"}, + {"nfe", "nves"}, + {"nna", "nnas"}, + {"oaf", "oaves"}, + {"oci", "ocus"}, + {"ode", "odes"}, + {"ofe", "oves"}, + {"oot", "eet"}, + {"pfe", "pves"}, + {"pse", "psis"}, + {"qfe", "qves"}, + {"quy", "quies"}, + {"rfe", "rves"}, + {"sfe", "sves"}, + {"tfe", "tves"}, + {"tum", "ta"}, + {"tus", "tuses"}, + {"ufe", "uves"}, + {"ula", "ulae"}, + {"ula", "ulas"}, + {"uli", "ulus"}, + {"use", "uses"}, + {"uss", "usses"}, + {"vfe", "vves"}, + {"wfe", "wves"}, + {"xfe", "xves"}, + {"yfe", "yves"}, + {"you", "you"}, + {"zfe", "zves"}, + {"by", "bies"}, + {"ch", "ches"}, + {"cy", "cies"}, + {"dy", "dies"}, + {"ex", "ices"}, + {"fy", "fies"}, + {"gy", "gies"}, + {"hy", "hies"}, + {"io", "ios"}, + {"jy", "jies"}, + {"ky", "kies"}, + {"lf", "lves"}, + {"ly", "lies"}, + {"my", "mies"}, + {"ny", "nies"}, + {"py", "pies"}, + {"qy", "qies"}, + {"rf", "rves"}, + {"ry", "ries"}, + {"sh", "shes"}, + {"ss", "sses"}, + {"sy", "sies"}, + {"ty", "ties"}, + {"tz", "tzes"}, + {"va", "vae"}, + {"vy", "vies"}, + {"wy", "wies"}, + {"xy", "xies"}, + {"zy", "zies"}, + {"zz", "zzes"}, + {"o", "oes"}, + {"x", "xes"}, +} + +func init() { + for _, suffix := range singularToPluralSuffixList { + AddPlural(suffix.singular, suffix.plural) + AddSingular(suffix.plural, suffix.singular) + } +} diff --git a/vendor/github.com/gobuffalo/flect/pluralize.go b/vendor/github.com/gobuffalo/flect/pluralize.go new file mode 100644 index 00000000000..e265f84e91d --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/pluralize.go @@ -0,0 +1,59 @@ +package flect + +import ( + "strings" + "sync" +) + +var pluralMoot = &sync.RWMutex{} + +// Pluralize returns a plural version of the string +// user = users +// person = people +// datum = data +func Pluralize(s string) string { + return New(s).Pluralize().String() +} + +// PluralizeWithSize will pluralize a string taking a number number into account. +// PluralizeWithSize("user", 1) = user +// PluralizeWithSize("user", 2) = users +func PluralizeWithSize(s string, i int) string { + if i == 1 || i == -1 { + return New(s).Singularize().String() + } + return New(s).Pluralize().String() +} + +// Pluralize returns a plural version of the string +// user = users +// person = people +// datum = data +func (i Ident) Pluralize() Ident { + s := i.LastPart() + if len(s) == 0 { + return New("") + } + + pluralMoot.RLock() + defer pluralMoot.RUnlock() + + ls := strings.ToLower(s) + if _, ok := pluralToSingle[ls]; ok { + return i + } + if p, ok := singleToPlural[ls]; ok { + return i.ReplaceSuffix(s, p) + } + for _, r := range pluralRules { + if strings.HasSuffix(ls, r.suffix) { + return i.ReplaceSuffix(s, r.fn(s)) + } + } + + if strings.HasSuffix(ls, "s") { + return i + } + + return New(i.String() + "s") +} diff --git a/vendor/github.com/gobuffalo/flect/rule.go b/vendor/github.com/gobuffalo/flect/rule.go new file mode 100644 index 00000000000..dc616b337dd --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/rule.go @@ -0,0 +1,10 @@ +package flect + +type ruleFn func(string) string + +type rule struct { + suffix string + fn ruleFn +} + +func noop(s string) string { return s } diff --git a/vendor/github.com/gobuffalo/flect/singular_rules.go b/vendor/github.com/gobuffalo/flect/singular_rules.go new file mode 100644 index 00000000000..b20371b3558 --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/singular_rules.go @@ -0,0 +1,23 @@ +package flect + +var singularRules = []rule{} + +// AddSingular adds a rule that will replace the given suffix with the replacement suffix. +func AddSingular(ext string, repl string) { + singularMoot.Lock() + defer singularMoot.Unlock() + singularRules = append(singularRules, rule{ + suffix: ext, + fn: func(s string) string { + s = s[:len(s)-len(ext)] + return s + repl + }, + }) + + singularRules = append(singularRules, rule{ + suffix: repl, + fn: func(s string) string { + return s + }, + }) +} diff --git a/vendor/github.com/gobuffalo/flect/singularize.go b/vendor/github.com/gobuffalo/flect/singularize.go new file mode 100644 index 00000000000..1ed4995053e --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/singularize.go @@ -0,0 +1,57 @@ +package flect + +import ( + "strings" + "sync" +) + +var singularMoot = &sync.RWMutex{} + +// Singularize returns a singular version of the string +// users = user +// data = datum +// people = person +func Singularize(s string) string { + return New(s).Singularize().String() +} + +// SingularizeWithSize will singular a string taking a number number into account. +// SingularizeWithSize("user", 1) = user +// SingularizeWithSize("user", 2) = users +func SingularizeWithSize(s string, i int) string { + if i == 1 || i == -1 { + return New(s).Singularize().String() + } + return New(s).Pluralize().String() +} + +// Singularize returns a singular version of the string +// users = user +// data = datum +// people = person +func (i Ident) Singularize() Ident { + s := i.Original + if len(s) == 0 { + return i + } + + singularMoot.RLock() + defer singularMoot.RUnlock() + ls := strings.ToLower(s) + if p, ok := pluralToSingle[ls]; ok { + return New(p) + } + if _, ok := singleToPlural[ls]; ok { + return i + } + for _, r := range singularRules { + if strings.HasSuffix(ls, r.suffix) { + return New(r.fn(s)) + } + } + + if strings.HasSuffix(s, "s") { + return New(s[:len(s)-1]) + } + return i +} diff --git a/vendor/github.com/gobuffalo/flect/titleize.go b/vendor/github.com/gobuffalo/flect/titleize.go new file mode 100644 index 00000000000..cbbf08a5aa2 --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/titleize.go @@ -0,0 +1,30 @@ +package flect + +import ( + "strings" + "unicode" +) + +// Titleize will capitalize the start of each part +// "Nice to see you!" = "Nice To See You!" +// "i've read a book! have you?" = "I've Read A Book! Have You?" +// "This is `code` ok" = "This Is `code` OK" +func Titleize(s string) string { + return New(s).Titleize().String() +} + +// Titleize will capitalize the start of each part +// "Nice to see you!" = "Nice To See You!" +// "i've read a book! have you?" = "I've Read A Book! Have You?" +// "This is `code` ok" = "This Is `code` OK" +func (i Ident) Titleize() Ident { + var parts []string + for _, part := range i.Parts { + x := string(unicode.ToTitle(rune(part[0]))) + if len(part) > 1 { + x += part[1:] + } + parts = append(parts, x) + } + return New(strings.Join(parts, " ")) +} diff --git a/vendor/github.com/gobuffalo/flect/underscore.go b/vendor/github.com/gobuffalo/flect/underscore.go new file mode 100644 index 00000000000..e1466d99b9f --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/underscore.go @@ -0,0 +1,35 @@ +package flect + +import ( + "strings" + "unicode" +) + +// Underscore a string +// bob dylan = bob_dylan +// Nice to see you! = nice_to_see_you +// widgetID = widget_id +func Underscore(s string) string { + return New(s).Underscore().String() +} + +// Underscore a string +// bob dylan = bob_dylan +// Nice to see you! = nice_to_see_you +// widgetID = widget_id +func (i Ident) Underscore() Ident { + out := make([]string, 0, len(i.Parts)) + for _, part := range i.Parts { + var x strings.Builder + x.Grow(len(part)) + for _, c := range part { + if unicode.IsLetter(c) || unicode.IsDigit(c) { + x.WriteRune(c) + } + } + if x.Len() > 0 { + out = append(out, x.String()) + } + } + return New(strings.ToLower(strings.Join(out, "_"))) +} diff --git a/vendor/github.com/gobuffalo/flect/version.go b/vendor/github.com/gobuffalo/flect/version.go new file mode 100644 index 00000000000..9624d5df2d0 --- /dev/null +++ b/vendor/github.com/gobuffalo/flect/version.go @@ -0,0 +1,4 @@ +package flect + +//Version holds Flect version number +const Version = "v0.1.6" diff --git a/vendor/github.com/google/go-cmp/cmp/cmpopts/equate.go b/vendor/github.com/google/go-cmp/cmp/cmpopts/equate.go index 51ce36fb60d..e4ffca838a1 100644 --- a/vendor/github.com/google/go-cmp/cmp/cmpopts/equate.go +++ b/vendor/github.com/google/go-cmp/cmp/cmpopts/equate.go @@ -11,7 +11,6 @@ import ( "time" "github.com/google/go-cmp/cmp" - "golang.org/x/xerrors" ) func equateAlways(_, _ interface{}) bool { return true } @@ -147,10 +146,3 @@ func areConcreteErrors(x, y interface{}) bool { _, ok2 := y.(error) return ok1 && ok2 } - -func compareErrors(x, y interface{}) bool { - xe := x.(error) - ye := y.(error) - // TODO(≥go1.13): Use standard definition of errors.Is. - return xerrors.Is(xe, ye) || xerrors.Is(ye, xe) -} diff --git a/vendor/github.com/google/go-cmp/cmp/cmpopts/errors_go113.go b/vendor/github.com/google/go-cmp/cmp/cmpopts/errors_go113.go new file mode 100644 index 00000000000..26fe25d6afb --- /dev/null +++ b/vendor/github.com/google/go-cmp/cmp/cmpopts/errors_go113.go @@ -0,0 +1,15 @@ +// Copyright 2021, 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. + +// +build go1.13 + +package cmpopts + +import "errors" + +func compareErrors(x, y interface{}) bool { + xe := x.(error) + ye := y.(error) + return errors.Is(xe, ye) || errors.Is(ye, xe) +} diff --git a/vendor/github.com/google/go-cmp/cmp/cmpopts/errors_xerrors.go b/vendor/github.com/google/go-cmp/cmp/cmpopts/errors_xerrors.go new file mode 100644 index 00000000000..6eeb8d6e654 --- /dev/null +++ b/vendor/github.com/google/go-cmp/cmp/cmpopts/errors_xerrors.go @@ -0,0 +1,18 @@ +// Copyright 2021, 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. + +// +build !go1.13 + +// TODO(≥go1.13): For support on 0: return false // Some ignore option was used case v.NumTransformed > 0: @@ -45,7 +43,16 @@ func (opts formatOptions) CanFormatDiffSlice(v *valueNode) bool { return false } - switch t := v.Type; t.Kind() { + // Check whether this is an interface with the same concrete types. + t := v.Type + vx, vy := v.ValueX, v.ValueY + if t.Kind() == reflect.Interface && !vx.IsNil() && !vy.IsNil() && vx.Elem().Type() == vy.Elem().Type() { + vx, vy = vx.Elem(), vy.Elem() + t = vx.Type() + } + + // Check whether we provide specialized diffing for this type. + switch t.Kind() { case reflect.String: case reflect.Array, reflect.Slice: // Only slices of primitive types have specialized handling. @@ -57,6 +64,11 @@ func (opts formatOptions) CanFormatDiffSlice(v *valueNode) bool { return false } + // Both slice values have to be non-empty. + if t.Kind() == reflect.Slice && (vx.Len() == 0 || vy.Len() == 0) { + return false + } + // If a sufficient number of elements already differ, // use specialized formatting even if length requirement is not met. if v.NumDiff > v.NumSame { @@ -68,7 +80,7 @@ func (opts formatOptions) CanFormatDiffSlice(v *valueNode) bool { // Use specialized string diffing for longer slices or strings. const minLength = 64 - return v.ValueX.Len() >= minLength && v.ValueY.Len() >= minLength + return vx.Len() >= minLength && vy.Len() >= minLength } // FormatDiffSlice prints a diff for the slices (or strings) represented by v. @@ -77,6 +89,11 @@ func (opts formatOptions) CanFormatDiffSlice(v *valueNode) bool { func (opts formatOptions) FormatDiffSlice(v *valueNode) textNode { assert(opts.DiffMode == diffUnknown) t, vx, vy := v.Type, v.ValueX, v.ValueY + if t.Kind() == reflect.Interface { + vx, vy = vx.Elem(), vy.Elem() + t = vx.Type() + opts = opts.WithTypeMode(emitType) + } // Auto-detect the type of the data. var isLinedText, isText, isBinary bool diff --git a/vendor/github.com/google/uuid/hash.go b/vendor/github.com/google/uuid/hash.go index b1746163151..b404f4bec27 100644 --- a/vendor/github.com/google/uuid/hash.go +++ b/vendor/github.com/google/uuid/hash.go @@ -26,8 +26,8 @@ var ( // NewMD5 and NewSHA1. func NewHash(h hash.Hash, space UUID, data []byte, version int) UUID { h.Reset() - h.Write(space[:]) - h.Write(data) + h.Write(space[:]) //nolint:errcheck + h.Write(data) //nolint:errcheck s := h.Sum(nil) var uuid UUID copy(uuid[:], s) diff --git a/vendor/github.com/google/uuid/sql.go b/vendor/github.com/google/uuid/sql.go index f326b54db37..2e02ec06c01 100644 --- a/vendor/github.com/google/uuid/sql.go +++ b/vendor/github.com/google/uuid/sql.go @@ -9,7 +9,7 @@ import ( "fmt" ) -// Scan implements sql.Scanner so UUIDs can be read from databases transparently +// Scan implements sql.Scanner so UUIDs can be read from databases transparently. // Currently, database types that map to string and []byte are supported. Please // consult database-specific driver documentation for matching types. func (uuid *UUID) Scan(src interface{}) error { diff --git a/vendor/github.com/google/uuid/uuid.go b/vendor/github.com/google/uuid/uuid.go index 524404cc522..60d26bb50c6 100644 --- a/vendor/github.com/google/uuid/uuid.go +++ b/vendor/github.com/google/uuid/uuid.go @@ -35,6 +35,12 @@ const ( var rander = rand.Reader // random function +type invalidLengthError struct{ len int } + +func (err invalidLengthError) Error() string { + return fmt.Sprintf("invalid UUID length: %d", err.len) +} + // Parse decodes s into a UUID or returns an error. Both the standard UUID // forms of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and // urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx are decoded as well as the @@ -68,7 +74,7 @@ func Parse(s string) (UUID, error) { } return uuid, nil default: - return uuid, fmt.Errorf("invalid UUID length: %d", len(s)) + return uuid, invalidLengthError{len(s)} } // s is now at least 36 bytes long // it must be of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx @@ -112,7 +118,7 @@ func ParseBytes(b []byte) (UUID, error) { } return uuid, nil default: - return uuid, fmt.Errorf("invalid UUID length: %d", len(b)) + return uuid, invalidLengthError{len(b)} } // s is now at least 36 bytes long // it must be of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx diff --git a/vendor/github.com/google/uuid/version4.go b/vendor/github.com/google/uuid/version4.go index c110465db59..86160fbd072 100644 --- a/vendor/github.com/google/uuid/version4.go +++ b/vendor/github.com/google/uuid/version4.go @@ -14,6 +14,14 @@ func New() UUID { return Must(NewRandom()) } +// NewString creates a new random UUID and returns it as a string or panics. +// NewString is equivalent to the expression +// +// uuid.New().String() +func NewString() string { + return Must(NewRandom()).String() +} + // NewRandom returns a Random (Version 4) UUID. // // The strength of the UUIDs is based on the strength of the crypto/rand diff --git a/vendor/github.com/joho/godotenv/.gitignore b/vendor/github.com/joho/godotenv/.gitignore deleted file mode 100644 index e43b0f98895..00000000000 --- a/vendor/github.com/joho/godotenv/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.DS_Store diff --git a/vendor/github.com/joho/godotenv/.travis.yml b/vendor/github.com/joho/godotenv/.travis.yml deleted file mode 100644 index f0db1adcdb1..00000000000 --- a/vendor/github.com/joho/godotenv/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: go - -go: - - 1.x - -os: - - linux - - osx diff --git a/vendor/github.com/joho/godotenv/LICENCE b/vendor/github.com/joho/godotenv/LICENCE deleted file mode 100644 index e7ddd51be90..00000000000 --- a/vendor/github.com/joho/godotenv/LICENCE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2013 John Barton - -MIT License - -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. - diff --git a/vendor/github.com/joho/godotenv/README.md b/vendor/github.com/joho/godotenv/README.md deleted file mode 100644 index 4e8fcf2e9cd..00000000000 --- a/vendor/github.com/joho/godotenv/README.md +++ /dev/null @@ -1,163 +0,0 @@ -# GoDotEnv [![Build Status](https://travis-ci.org/joho/godotenv.svg?branch=master)](https://travis-ci.org/joho/godotenv) [![Build status](https://ci.appveyor.com/api/projects/status/9v40vnfvvgde64u4?svg=true)](https://ci.appveyor.com/project/joho/godotenv) [![Go Report Card](https://goreportcard.com/badge/github.com/joho/godotenv)](https://goreportcard.com/report/github.com/joho/godotenv) - -A Go (golang) port of the Ruby dotenv project (which loads env vars from a .env file) - -From the original Library: - -> Storing configuration in the environment is one of the tenets of a twelve-factor app. Anything that is likely to change between deployment environments–such as resource handles for databases or credentials for external services–should be extracted from the code into environment variables. -> -> But it is not always practical to set environment variables on development machines or continuous integration servers where multiple projects are run. Dotenv load variables from a .env file into ENV when the environment is bootstrapped. - -It can be used as a library (for loading in env for your own daemons etc) or as a bin command. - -There is test coverage and CI for both linuxish and windows environments, but I make no guarantees about the bin version working on windows. - -## Installation - -As a library - -```shell -go get github.com/joho/godotenv -``` - -or if you want to use it as a bin command -```shell -go get github.com/joho/godotenv/cmd/godotenv -``` - -## Usage - -Add your application configuration to your `.env` file in the root of your project: - -```shell -S3_BUCKET=YOURS3BUCKET -SECRET_KEY=YOURSECRETKEYGOESHERE -``` - -Then in your Go app you can do something like - -```go -package main - -import ( - "github.com/joho/godotenv" - "log" - "os" -) - -func main() { - err := godotenv.Load() - if err != nil { - log.Fatal("Error loading .env file") - } - - s3Bucket := os.Getenv("S3_BUCKET") - secretKey := os.Getenv("SECRET_KEY") - - // now do something with s3 or whatever -} -``` - -If you're even lazier than that, you can just take advantage of the autoload package which will read in `.env` on import - -```go -import _ "github.com/joho/godotenv/autoload" -``` - -While `.env` in the project root is the default, you don't have to be constrained, both examples below are 100% legit - -```go -_ = godotenv.Load("somerandomfile") -_ = godotenv.Load("filenumberone.env", "filenumbertwo.env") -``` - -If you want to be really fancy with your env file you can do comments and exports (below is a valid env file) - -```shell -# I am a comment and that is OK -SOME_VAR=someval -FOO=BAR # comments at line end are OK too -export BAR=BAZ -``` - -Or finally you can do YAML(ish) style - -```yaml -FOO: bar -BAR: baz -``` - -as a final aside, if you don't want godotenv munging your env you can just get a map back instead - -```go -var myEnv map[string]string -myEnv, err := godotenv.Read() - -s3Bucket := myEnv["S3_BUCKET"] -``` - -... or from an `io.Reader` instead of a local file - -```go -reader := getRemoteFile() -myEnv, err := godotenv.Parse(reader) -``` - -... or from a `string` if you so desire - -```go -content := getRemoteFileContent() -myEnv, err := godotenv.Unmarshal(content) -``` - -### Command Mode - -Assuming you've installed the command as above and you've got `$GOPATH/bin` in your `$PATH` - -``` -godotenv -f /some/path/to/.env some_command with some args -``` - -If you don't specify `-f` it will fall back on the default of loading `.env` in `PWD` - -### Writing Env Files - -Godotenv can also write a map representing the environment to a correctly-formatted and escaped file - -```go -env, err := godotenv.Unmarshal("KEY=value") -err := godotenv.Write(env, "./.env") -``` - -... or to a string - -```go -env, err := godotenv.Unmarshal("KEY=value") -content, err := godotenv.Marshal(env) -``` - -## Contributing - -Contributions are most welcome! The parser itself is pretty stupidly naive and I wouldn't be surprised if it breaks with edge cases. - -*code changes without tests will not be accepted* - -1. Fork it -2. Create your feature branch (`git checkout -b my-new-feature`) -3. Commit your changes (`git commit -am 'Added some feature'`) -4. Push to the branch (`git push origin my-new-feature`) -5. Create new Pull Request - -## Releases - -Releases should follow [Semver](http://semver.org/) though the first couple of releases are `v1` and `v1.1`. - -Use [annotated tags for all releases](https://github.com/joho/godotenv/issues/30). Example `git tag -a v1.2.1` - -## CI - -Linux: [![Build Status](https://travis-ci.org/joho/godotenv.svg?branch=master)](https://travis-ci.org/joho/godotenv) Windows: [![Build status](https://ci.appveyor.com/api/projects/status/9v40vnfvvgde64u4)](https://ci.appveyor.com/project/joho/godotenv) - -## Who? - -The original library [dotenv](https://github.com/bkeepers/dotenv) was written by [Brandon Keepers](http://opensoul.org/), and this port was done by [John Barton](https://johnbarton.co/) based off the tests/fixtures in the original library. diff --git a/vendor/github.com/joho/godotenv/godotenv.go b/vendor/github.com/joho/godotenv/godotenv.go deleted file mode 100644 index 29b436c77c0..00000000000 --- a/vendor/github.com/joho/godotenv/godotenv.go +++ /dev/null @@ -1,346 +0,0 @@ -// Package godotenv is a go port of the ruby dotenv library (https://github.com/bkeepers/dotenv) -// -// Examples/readme can be found on the github page at https://github.com/joho/godotenv -// -// The TL;DR is that you make a .env file that looks something like -// -// SOME_ENV_VAR=somevalue -// -// and then in your go code you can call -// -// godotenv.Load() -// -// and all the env vars declared in .env will be available through os.Getenv("SOME_ENV_VAR") -package godotenv - -import ( - "bufio" - "errors" - "fmt" - "io" - "os" - "os/exec" - "regexp" - "sort" - "strings" -) - -const doubleQuoteSpecialChars = "\\\n\r\"!$`" - -// Load will read your env file(s) and load them into ENV for this process. -// -// Call this function as close as possible to the start of your program (ideally in main) -// -// If you call Load without any args it will default to loading .env in the current path -// -// You can otherwise tell it which files to load (there can be more than one) like -// -// godotenv.Load("fileone", "filetwo") -// -// It's important to note that it WILL NOT OVERRIDE an env variable that already exists - consider the .env file to set dev vars or sensible defaults -func Load(filenames ...string) (err error) { - filenames = filenamesOrDefault(filenames) - - for _, filename := range filenames { - err = loadFile(filename, false) - if err != nil { - return // return early on a spazout - } - } - return -} - -// Overload will read your env file(s) and load them into ENV for this process. -// -// Call this function as close as possible to the start of your program (ideally in main) -// -// If you call Overload without any args it will default to loading .env in the current path -// -// You can otherwise tell it which files to load (there can be more than one) like -// -// godotenv.Overload("fileone", "filetwo") -// -// It's important to note this WILL OVERRIDE an env variable that already exists - consider the .env file to forcefilly set all vars. -func Overload(filenames ...string) (err error) { - filenames = filenamesOrDefault(filenames) - - for _, filename := range filenames { - err = loadFile(filename, true) - if err != nil { - return // return early on a spazout - } - } - return -} - -// Read all env (with same file loading semantics as Load) but return values as -// a map rather than automatically writing values into env -func Read(filenames ...string) (envMap map[string]string, err error) { - filenames = filenamesOrDefault(filenames) - envMap = make(map[string]string) - - for _, filename := range filenames { - individualEnvMap, individualErr := readFile(filename) - - if individualErr != nil { - err = individualErr - return // return early on a spazout - } - - for key, value := range individualEnvMap { - envMap[key] = value - } - } - - return -} - -// Parse reads an env file from io.Reader, returning a map of keys and values. -func Parse(r io.Reader) (envMap map[string]string, err error) { - envMap = make(map[string]string) - - var lines []string - scanner := bufio.NewScanner(r) - for scanner.Scan() { - lines = append(lines, scanner.Text()) - } - - if err = scanner.Err(); err != nil { - return - } - - for _, fullLine := range lines { - if !isIgnoredLine(fullLine) { - var key, value string - key, value, err = parseLine(fullLine, envMap) - - if err != nil { - return - } - envMap[key] = value - } - } - return -} - -//Unmarshal reads an env file from a string, returning a map of keys and values. -func Unmarshal(str string) (envMap map[string]string, err error) { - return Parse(strings.NewReader(str)) -} - -// Exec loads env vars from the specified filenames (empty map falls back to default) -// then executes the cmd specified. -// -// Simply hooks up os.Stdin/err/out to the command and calls Run() -// -// If you want more fine grained control over your command it's recommended -// that you use `Load()` or `Read()` and the `os/exec` package yourself. -func Exec(filenames []string, cmd string, cmdArgs []string) error { - Load(filenames...) - - command := exec.Command(cmd, cmdArgs...) - command.Stdin = os.Stdin - command.Stdout = os.Stdout - command.Stderr = os.Stderr - return command.Run() -} - -// Write serializes the given environment and writes it to a file -func Write(envMap map[string]string, filename string) error { - content, error := Marshal(envMap) - if error != nil { - return error - } - file, error := os.Create(filename) - if error != nil { - return error - } - _, err := file.WriteString(content) - return err -} - -// Marshal outputs the given environment as a dotenv-formatted environment file. -// Each line is in the format: KEY="VALUE" where VALUE is backslash-escaped. -func Marshal(envMap map[string]string) (string, error) { - lines := make([]string, 0, len(envMap)) - for k, v := range envMap { - lines = append(lines, fmt.Sprintf(`%s="%s"`, k, doubleQuoteEscape(v))) - } - sort.Strings(lines) - return strings.Join(lines, "\n"), nil -} - -func filenamesOrDefault(filenames []string) []string { - if len(filenames) == 0 { - return []string{".env"} - } - return filenames -} - -func loadFile(filename string, overload bool) error { - envMap, err := readFile(filename) - if err != nil { - return err - } - - currentEnv := map[string]bool{} - rawEnv := os.Environ() - for _, rawEnvLine := range rawEnv { - key := strings.Split(rawEnvLine, "=")[0] - currentEnv[key] = true - } - - for key, value := range envMap { - if !currentEnv[key] || overload { - os.Setenv(key, value) - } - } - - return nil -} - -func readFile(filename string) (envMap map[string]string, err error) { - file, err := os.Open(filename) - if err != nil { - return - } - defer file.Close() - - return Parse(file) -} - -func parseLine(line string, envMap map[string]string) (key string, value string, err error) { - if len(line) == 0 { - err = errors.New("zero length string") - return - } - - // ditch the comments (but keep quoted hashes) - if strings.Contains(line, "#") { - segmentsBetweenHashes := strings.Split(line, "#") - quotesAreOpen := false - var segmentsToKeep []string - for _, segment := range segmentsBetweenHashes { - if strings.Count(segment, "\"") == 1 || strings.Count(segment, "'") == 1 { - if quotesAreOpen { - quotesAreOpen = false - segmentsToKeep = append(segmentsToKeep, segment) - } else { - quotesAreOpen = true - } - } - - if len(segmentsToKeep) == 0 || quotesAreOpen { - segmentsToKeep = append(segmentsToKeep, segment) - } - } - - line = strings.Join(segmentsToKeep, "#") - } - - firstEquals := strings.Index(line, "=") - firstColon := strings.Index(line, ":") - splitString := strings.SplitN(line, "=", 2) - if firstColon != -1 && (firstColon < firstEquals || firstEquals == -1) { - //this is a yaml-style line - splitString = strings.SplitN(line, ":", 2) - } - - if len(splitString) != 2 { - err = errors.New("Can't separate key from value") - return - } - - // Parse the key - key = splitString[0] - if strings.HasPrefix(key, "export") { - key = strings.TrimPrefix(key, "export") - } - key = strings.Trim(key, " ") - - // Parse the value - value = parseValue(splitString[1], envMap) - return -} - -func parseValue(value string, envMap map[string]string) string { - - // trim - value = strings.Trim(value, " ") - - // check if we've got quoted values or possible escapes - if len(value) > 1 { - rs := regexp.MustCompile(`\A'(.*)'\z`) - singleQuotes := rs.FindStringSubmatch(value) - - rd := regexp.MustCompile(`\A"(.*)"\z`) - doubleQuotes := rd.FindStringSubmatch(value) - - if singleQuotes != nil || doubleQuotes != nil { - // pull the quotes off the edges - value = value[1 : len(value)-1] - } - - if doubleQuotes != nil { - // expand newlines - escapeRegex := regexp.MustCompile(`\\.`) - value = escapeRegex.ReplaceAllStringFunc(value, func(match string) string { - c := strings.TrimPrefix(match, `\`) - switch c { - case "n": - return "\n" - case "r": - return "\r" - default: - return match - } - }) - // unescape characters - e := regexp.MustCompile(`\\([^$])`) - value = e.ReplaceAllString(value, "$1") - } - - if singleQuotes == nil { - value = expandVariables(value, envMap) - } - } - - return value -} - -func expandVariables(v string, m map[string]string) string { - r := regexp.MustCompile(`(\\)?(\$)(\()?\{?([A-Z0-9_]+)?\}?`) - - return r.ReplaceAllStringFunc(v, func(s string) string { - submatch := r.FindStringSubmatch(s) - - if submatch == nil { - return s - } - if submatch[1] == "\\" || submatch[2] == "(" { - return submatch[0][1:] - } else if submatch[4] != "" { - return m[submatch[4]] - } - return s - }) -} - -func isIgnoredLine(line string) bool { - trimmedLine := strings.Trim(line, " \n\t") - return len(trimmedLine) == 0 || strings.HasPrefix(trimmedLine, "#") -} - -func doubleQuoteEscape(line string) string { - for _, c := range doubleQuoteSpecialChars { - toReplace := "\\" + string(c) - if c == '\n' { - toReplace = `\n` - } - if c == '\r' { - toReplace = `\r` - } - line = strings.Replace(line, string(c), toReplace, -1) - } - return line -} diff --git a/vendor/github.com/markbates/inflect/.hgignore b/vendor/github.com/markbates/inflect/.hgignore deleted file mode 100644 index 6cc3d7ce113..00000000000 --- a/vendor/github.com/markbates/inflect/.hgignore +++ /dev/null @@ -1 +0,0 @@ -swp$ diff --git a/vendor/github.com/markbates/inflect/.travis.yml b/vendor/github.com/markbates/inflect/.travis.yml deleted file mode 100644 index cf1d2c7d42e..00000000000 --- a/vendor/github.com/markbates/inflect/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: go - -sudo: false - -matrix: - include: - - go: "1.9.x" - - go: "1.10.x" - - go: "1.11.x" - env: - - GO111MODULE=off - - go: "1.11.x" - env: - - GO111MODULE=on - - go: "tip" - env: - - GO111MODULE=off - - go: "tip" - env: - - GO111MODULE=on - allow_failures: - - go: "tip" - -install: make deps - -script: make ci-test diff --git a/vendor/github.com/markbates/inflect/LICENCE b/vendor/github.com/markbates/inflect/LICENCE deleted file mode 100644 index 8a36b944a5e..00000000000 --- a/vendor/github.com/markbates/inflect/LICENCE +++ /dev/null @@ -1,7 +0,0 @@ -Copyright (c) 2011 Chris Farmiloe - -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. diff --git a/vendor/github.com/markbates/inflect/Makefile b/vendor/github.com/markbates/inflect/Makefile deleted file mode 100644 index e0e2f3baa4d..00000000000 --- a/vendor/github.com/markbates/inflect/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -TAGS ?= "sqlite" -GO_BIN ?= go - -install: - packr - $(GO_BIN) install -tags ${TAGS} -v . - make tidy - -tidy: -ifeq ($(GO111MODULE),on) - $(GO_BIN) mod tidy -else - echo skipping go mod tidy -endif - -deps: - $(GO_BIN) get github.com/gobuffalo/release - $(GO_BIN) get github.com/gobuffalo/packr/packr - $(GO_BIN) get -tags ${TAGS} -t ./... - make tidy - -build: - packr - $(GO_BIN) build -v . - make tidy - -test: - packr - $(GO_BIN) test -tags ${TAGS} ./... - make tidy - -ci-test: - $(GO_BIN) test -tags ${TAGS} -race ./... - make tidy - -lint: - gometalinter --vendor ./... --deadline=1m --skip=internal - make tidy - -update: - $(GO_BIN) get -u -tags ${TAGS} - make tidy - packr - make test - make install - make tidy - -release-test: - $(GO_BIN) test -tags ${TAGS} -race ./... - make tidy - -release: - make tidy - release -y -f version.go - make tidy diff --git a/vendor/github.com/markbates/inflect/README.md b/vendor/github.com/markbates/inflect/README.md deleted file mode 100644 index 9b62b1d9a43..00000000000 --- a/vendor/github.com/markbates/inflect/README.md +++ /dev/null @@ -1,214 +0,0 @@ -[![Build Status](https://travis-ci.org/markbates/inflect.svg?branch=master)](https://travis-ci.org/markbates/inflect) - -#### INSTALLATION - -go get github.com/markbates/inflect - -#### PACKAGE -package inflect - - -#### FUNCTIONS -```go -func AddAcronym(word string) -func AddHuman(suffix, replacement string) -func AddIrregular(singular, plural string) -func AddPlural(suffix, replacement string) -func AddSingular(suffix, replacement string) -func AddUncountable(word string) -func Asciify(word string) string -func Camelize(word string) string -func CamelizeDownFirst(word string) string -func Capitalize(word string) string -func Dasherize(word string) string -func ForeignKey(word string) string -func ForeignKeyCondensed(word string) string -func Humanize(word string) string -func Ordinalize(word string) string -func Parameterize(word string) string -func ParameterizeJoin(word, sep string) string -func Pluralize(word string) string -func Singularize(word string) string -func Tableize(word string) string -func Titleize(word string) string -func Typeify(word string) string -func Uncountables() map[string]bool -func Underscore(word string) string -``` - -#### TYPES -```go -type Rule struct { - // contains filtered or unexported fields -} -``` - -used by rulesets - -```go -type Ruleset struct { - // contains filtered or unexported fields -} -``` - -a Ruleset is the config of pluralization rules -you can extend the rules with the Add* methods - -``` -func NewDefaultRuleset() *Ruleset -``` -create a new ruleset and load it with the default -set of common English pluralization rules - -``` -func NewRuleset() *Ruleset -``` - -create a blank ruleset. Unless you are going to -build your own rules from scratch you probably -won't need this and can just use the defaultRuleset -via the global inflect.* methods - -``` -func (rs *Ruleset) AddAcronym(word string) -``` -if you use acronym you may need to add them to the ruleset -to prevent Underscored words of things like "HTML" coming out -as "h_t_m_l" - -``` -func (rs *Ruleset) AddHuman(suffix, replacement string) -``` - -Human rules are applied by humanize to show more friendly -versions of words - -``` -func (rs *Ruleset) AddIrregular(singular, plural string) -``` - -Add any inconsistent pluralizing/singularizing rules -to the set here. - -``` -func (rs *Ruleset) AddPlural(suffix, replacement string) -``` - -add a pluralization rule - -``` -func (rs *Ruleset) AddPluralExact(suffix, replacement string, exact bool) -``` - -add a pluralization rule with full string match - -``` -func (rs *Ruleset) AddSingular(suffix, replacement string) -``` - -add a singular rule - -``` -func (rs *Ruleset) AddSingularExact(suffix, replacement string, exact bool) -``` -same as AddSingular but you can set `exact` to force -a full string match - -``` -func (rs *Ruleset) AddUncountable(word string) -``` -add a word to this ruleset that has the same singular and plural form -for example: "rice" - -``` -func (rs *Ruleset) Asciify(word string) string -``` -transforms Latin characters like é -> e - -``` -func (rs *Ruleset) Camelize(word string) string -``` -"dino_party" -> "DinoParty" - -``` -func (rs *Ruleset) CamelizeDownFirst(word string) string -``` -same as Camelcase but with first letter downcased - -``` -func (rs *Ruleset) Capitalize(word string) string -``` -uppercase first character - -``` -func (rs *Ruleset) Dasherize(word string) string -``` -"SomeText" -> "some-text" - -``` -func (rs *Ruleset) ForeignKey(word string) string -``` -an underscored foreign key name "Person" -> "person_id" - -``` -func (rs *Ruleset) ForeignKeyCondensed(word string) string -``` -a foreign key (with an underscore) "Person" -> "personid" - -``` -func (rs *Ruleset) Humanize(word string) string -``` -First letter of sentence capitalized -Uses custom friendly replacements via AddHuman() - -``` -func (rs *Ruleset) Ordinalize(str string) string -``` -"1031" -> "1031st" - -``` -func (rs *Ruleset) Parameterize(word string) string -``` -param safe dasherized names like "my-param" - -``` -func (rs *Ruleset) ParameterizeJoin(word, sep string) string -``` -param safe dasherized names with custom separator - -``` -func (rs *Ruleset) Pluralize(word string) string -``` -returns the plural form of a singular word - -``` -func (rs *Ruleset) Singularize(word string) string -``` -returns the singular form of a plural word - -``` -func (rs *Ruleset) Tableize(word string) string -``` -Rails style pluralized table names: "SuperPerson" -> "super_people" - -``` -func (rs *Ruleset) Titleize(word string) string -``` -Capitalize every word in sentence "hello there" -> "Hello There" - -``` -func (rs *Ruleset) Typeify(word string) string -``` -"something_like_this" -> "SomethingLikeThis" - -``` -func (rs *Ruleset) Uncountables() map[string]bool -``` - -``` -func (rs *Ruleset) Underscore(word string) string -``` - -lowercase underscore version "BigBen" -> "big_ben" - - diff --git a/vendor/github.com/markbates/inflect/go.mod b/vendor/github.com/markbates/inflect/go.mod deleted file mode 100644 index 3d7baa77f73..00000000000 --- a/vendor/github.com/markbates/inflect/go.mod +++ /dev/null @@ -1,6 +0,0 @@ -module github.com/markbates/inflect - -require ( - github.com/gobuffalo/envy v1.6.5 - github.com/stretchr/testify v1.2.2 -) diff --git a/vendor/github.com/markbates/inflect/go.sum b/vendor/github.com/markbates/inflect/go.sum deleted file mode 100644 index 6d42090d0a8..00000000000 --- a/vendor/github.com/markbates/inflect/go.sum +++ /dev/null @@ -1,10 +0,0 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gobuffalo/envy v1.6.5 h1:X3is06x7v0nW2xiy2yFbbIjwHz57CD6z6MkvqULTCm8= -github.com/gobuffalo/envy v1.6.5/go.mod h1:N+GkhhZ/93bGZc6ZKhJLP6+m+tCNPKwgSpH9kaifseQ= -github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/vendor/github.com/markbates/inflect/helpers.go b/vendor/github.com/markbates/inflect/helpers.go deleted file mode 100644 index 24050c70a04..00000000000 --- a/vendor/github.com/markbates/inflect/helpers.go +++ /dev/null @@ -1,19 +0,0 @@ -package inflect - -//Helpers is a map of the helper names with its corresponding inflect function -var Helpers = map[string]interface{}{ - "asciffy": Asciify, - "camelize": Camelize, - "camelize_down_first": CamelizeDownFirst, - "capitalize": Capitalize, - "dasherize": Dasherize, - "humanize": Humanize, - "ordinalize": Ordinalize, - "parameterize": Parameterize, - "pluralize": Pluralize, - "pluralize_with_size": PluralizeWithSize, - "singularize": Singularize, - "tableize": Tableize, - "typeify": Typeify, - "underscore": Underscore, -} diff --git a/vendor/github.com/markbates/inflect/inflect.go b/vendor/github.com/markbates/inflect/inflect.go deleted file mode 100644 index 9b6776c191c..00000000000 --- a/vendor/github.com/markbates/inflect/inflect.go +++ /dev/null @@ -1,892 +0,0 @@ -package inflect - -import ( - "bytes" - "encoding/json" - "fmt" - "io" - "io/ioutil" - "os" - "path/filepath" - "regexp" - "strconv" - "strings" - "unicode" - "unicode/utf8" -) - -// baseAcronyms comes from https://en.wikipedia.org/wiki/List_of_information_technology_acronymss -const baseAcronyms = `JSON,JWT,ID,UUID,SQL,ACK,ACL,ADSL,AES,ANSI,API,ARP,ATM,BGP,BSS,CAT,CCITT,CHAP,CIDR,CIR,CLI,CPE,CPU,CRC,CRT,CSMA,CMOS,DCE,DEC,DES,DHCP,DNS,DRAM,DSL,DSLAM,DTE,DMI,EHA,EIA,EIGRP,EOF,ESS,FCC,FCS,FDDI,FTP,GBIC,gbps,GEPOF,HDLC,HTTP,HTTPS,IANA,ICMP,IDF,IDS,IEEE,IETF,IMAP,IP,IPS,ISDN,ISP,kbps,LACP,LAN,LAPB,LAPF,LLC,MAC,MAN,Mbps,MC,MDF,MIB,MoCA,MPLS,MTU,NAC,NAT,NBMA,NIC,NRZ,NRZI,NVRAM,OSI,OSPF,OUI,PAP,PAT,PC,PIM,PIM,PCM,PDU,POP3,POP,POTS,PPP,PPTP,PTT,PVST,RADIUS,RAM,RARP,RFC,RIP,RLL,ROM,RSTP,RTP,RCP,SDLC,SFD,SFP,SLARP,SLIP,SMTP,SNA,SNAP,SNMP,SOF,SRAM,SSH,SSID,STP,SYN,TDM,TFTP,TIA,TOFU,UDP,URL,URI,USB,UTP,VC,VLAN,VLSM,VPN,W3C,WAN,WEP,WiFi,WPA,WWW` - -// Rule used by rulesets -type Rule struct { - suffix string - replacement string - exact bool -} - -// Ruleset a Ruleset is the config of pluralization rules -// you can extend the rules with the Add* methods -type Ruleset struct { - uncountables map[string]bool - plurals []*Rule - singulars []*Rule - humans []*Rule - acronyms []*Rule -} - -// NewRuleset creates a blank ruleset. Unless you are going to -// build your own rules from scratch you probably -// won't need this and can just use the defaultRuleset -// via the global inflect.* methods -func NewRuleset() *Ruleset { - rs := new(Ruleset) - rs.uncountables = make(map[string]bool) - rs.plurals = make([]*Rule, 0) - rs.singulars = make([]*Rule, 0) - rs.humans = make([]*Rule, 0) - rs.acronyms = make([]*Rule, 0) - return rs -} - -// NewDefaultRuleset creates a new ruleset and load it with the default -// set of common English pluralization rules -func NewDefaultRuleset() *Ruleset { - rs := NewRuleset() - rs.AddPlural("movie", "movies") - rs.AddPlural("s", "s") - rs.AddPlural("testis", "testes") - rs.AddPlural("axis", "axes") - rs.AddPlural("octopus", "octopi") - rs.AddPlural("virus", "viri") - rs.AddPlural("octopi", "octopi") - rs.AddPlural("viri", "viri") - rs.AddPlural("alias", "aliases") - rs.AddPlural("status", "statuses") - rs.AddPlural("Status", "Statuses") - rs.AddPlural("campus", "campuses") - rs.AddPlural("bus", "buses") - rs.AddPlural("buffalo", "buffaloes") - rs.AddPlural("tomato", "tomatoes") - rs.AddPlural("tum", "ta") - rs.AddPlural("ium", "ia") - rs.AddPlural("ta", "ta") - rs.AddPlural("ia", "ia") - rs.AddPlural("sis", "ses") - rs.AddPlural("lf", "lves") - rs.AddPlural("rf", "rves") - rs.AddPlural("afe", "aves") - rs.AddPlural("bfe", "bves") - rs.AddPlural("cfe", "cves") - rs.AddPlural("dfe", "dves") - rs.AddPlural("efe", "eves") - rs.AddPlural("gfe", "gves") - rs.AddPlural("hfe", "hves") - rs.AddPlural("ife", "ives") - rs.AddPlural("jfe", "jves") - rs.AddPlural("kfe", "kves") - rs.AddPlural("lfe", "lves") - rs.AddPlural("mfe", "mves") - rs.AddPlural("nfe", "nves") - rs.AddPlural("ofe", "oves") - rs.AddPlural("pfe", "pves") - rs.AddPlural("qfe", "qves") - rs.AddPlural("rfe", "rves") - rs.AddPlural("sfe", "sves") - rs.AddPlural("tfe", "tves") - rs.AddPlural("ufe", "uves") - rs.AddPlural("vfe", "vves") - rs.AddPlural("wfe", "wves") - rs.AddPlural("xfe", "xves") - rs.AddPlural("yfe", "yves") - rs.AddPlural("zfe", "zves") - rs.AddPlural("hive", "hives") - rs.AddPlural("quy", "quies") - rs.AddPlural("by", "bies") - rs.AddPlural("cy", "cies") - rs.AddPlural("dy", "dies") - rs.AddPlural("fy", "fies") - rs.AddPlural("gy", "gies") - rs.AddPlural("hy", "hies") - rs.AddPlural("jy", "jies") - rs.AddPlural("ky", "kies") - rs.AddPlural("ly", "lies") - rs.AddPlural("my", "mies") - rs.AddPlural("ny", "nies") - rs.AddPlural("py", "pies") - rs.AddPlural("qy", "qies") - rs.AddPlural("ry", "ries") - rs.AddPlural("sy", "sies") - rs.AddPlural("ty", "ties") - rs.AddPlural("vy", "vies") - rs.AddPlural("wy", "wies") - rs.AddPlural("xy", "xies") - rs.AddPlural("zy", "zies") - rs.AddPlural("x", "xes") - rs.AddPlural("ch", "ches") - rs.AddPlural("ss", "sses") - rs.AddPlural("sh", "shes") - rs.AddPlural("matrix", "matrices") - rs.AddPlural("vertix", "vertices") - rs.AddPlural("indix", "indices") - rs.AddPlural("matrex", "matrices") - rs.AddPlural("vertex", "vertices") - rs.AddPlural("index", "indices") - rs.AddPlural("mouse", "mice") - rs.AddPlural("louse", "lice") - rs.AddPlural("mice", "mice") - rs.AddPlural("lice", "lice") - rs.AddPlural("ress", "resses") - rs.AddPluralExact("ox", "oxen", true) - rs.AddPluralExact("oxen", "oxen", true) - rs.AddPluralExact("quiz", "quizzes", true) - rs.AddSingular("s", "") - rs.AddSingular("ss", "ss") - rs.AddSingular("news", "news") - rs.AddSingular("ta", "tum") - rs.AddSingular("ia", "ium") - rs.AddSingular("analyses", "analysis") - rs.AddSingular("bases", "basis") - rs.AddSingularExact("basis", "basis", true) - rs.AddSingular("diagnoses", "diagnosis") - rs.AddSingularExact("diagnosis", "diagnosis", true) - rs.AddSingular("parentheses", "parenthesis") - rs.AddSingular("prognoses", "prognosis") - rs.AddSingular("synopses", "synopsis") - rs.AddSingular("theses", "thesis") - rs.AddSingular("analyses", "analysis") - rs.AddSingularExact("analysis", "analysis", true) - rs.AddSingular("ovies", "ovie") - rs.AddSingular("aves", "afe") - rs.AddSingular("bves", "bfe") - rs.AddSingular("cves", "cfe") - rs.AddSingular("dves", "dfe") - rs.AddSingular("eves", "efe") - rs.AddSingular("gves", "gfe") - rs.AddSingular("hves", "hfe") - rs.AddSingular("ives", "ife") - rs.AddSingular("jves", "jfe") - rs.AddSingular("kves", "kfe") - rs.AddSingular("lves", "lfe") - rs.AddSingular("mves", "mfe") - rs.AddSingular("nves", "nfe") - rs.AddSingular("oves", "ofe") - rs.AddSingular("pves", "pfe") - rs.AddSingular("qves", "qfe") - rs.AddSingular("rves", "rfe") - rs.AddSingular("sves", "sfe") - rs.AddSingular("tves", "tfe") - rs.AddSingular("uves", "ufe") - rs.AddSingular("vves", "vfe") - rs.AddSingular("wves", "wfe") - rs.AddSingular("xves", "xfe") - rs.AddSingular("yves", "yfe") - rs.AddSingular("zves", "zfe") - rs.AddSingular("hives", "hive") - rs.AddSingular("tives", "tive") - rs.AddSingular("lves", "lf") - rs.AddSingular("rves", "rf") - rs.AddSingular("quies", "quy") - rs.AddSingular("bies", "by") - rs.AddSingular("cies", "cy") - rs.AddSingular("dies", "dy") - rs.AddSingular("fies", "fy") - rs.AddSingular("gies", "gy") - rs.AddSingular("hies", "hy") - rs.AddSingular("jies", "jy") - rs.AddSingular("kies", "ky") - rs.AddSingular("lies", "ly") - rs.AddSingular("mies", "my") - rs.AddSingular("nies", "ny") - rs.AddSingular("pies", "py") - rs.AddSingular("qies", "qy") - rs.AddSingular("ries", "ry") - rs.AddSingular("sies", "sy") - rs.AddSingular("ties", "ty") - // rs.AddSingular("vies", "vy") - rs.AddSingular("wies", "wy") - rs.AddSingular("xies", "xy") - rs.AddSingular("zies", "zy") - rs.AddSingular("series", "series") - rs.AddSingular("xes", "x") - rs.AddSingular("ches", "ch") - rs.AddSingular("sses", "ss") - rs.AddSingular("shes", "sh") - rs.AddSingular("mice", "mouse") - rs.AddSingular("lice", "louse") - rs.AddSingular("buses", "bus") - rs.AddSingularExact("bus", "bus", true) - rs.AddSingular("oes", "o") - rs.AddSingular("shoes", "shoe") - rs.AddSingular("crises", "crisis") - rs.AddSingularExact("crisis", "crisis", true) - rs.AddSingular("axes", "axis") - rs.AddSingularExact("axis", "axis", true) - rs.AddSingular("testes", "testis") - rs.AddSingularExact("testis", "testis", true) - rs.AddSingular("octopi", "octopus") - rs.AddSingularExact("octopus", "octopus", true) - rs.AddSingular("viri", "virus") - rs.AddSingularExact("virus", "virus", true) - rs.AddSingular("statuses", "status") - rs.AddSingular("Statuses", "Status") - rs.AddSingular("campuses", "campus") - rs.AddSingularExact("status", "status", true) - rs.AddSingularExact("Status", "Status", true) - rs.AddSingularExact("campus", "campus", true) - rs.AddSingular("aliases", "alias") - rs.AddSingularExact("alias", "alias", true) - rs.AddSingularExact("oxen", "ox", true) - rs.AddSingular("vertices", "vertex") - rs.AddSingular("indices", "index") - rs.AddSingular("matrices", "matrix") - rs.AddSingularExact("quizzes", "quiz", true) - rs.AddSingular("databases", "database") - rs.AddSingular("resses", "ress") - rs.AddSingular("ress", "ress") - rs.AddIrregular("person", "people") - rs.AddIrregular("man", "men") - rs.AddIrregular("child", "children") - rs.AddIrregular("sex", "sexes") - rs.AddIrregular("move", "moves") - rs.AddIrregular("zombie", "zombies") - rs.AddIrregular("Status", "Statuses") - rs.AddIrregular("status", "statuses") - rs.AddIrregular("campus", "campuses") - rs.AddIrregular("human", "humans") - rs.AddUncountable("equipment") - rs.AddUncountable("information") - rs.AddUncountable("rice") - rs.AddUncountable("money") - rs.AddUncountable("species") - rs.AddUncountable("series") - rs.AddUncountable("fish") - rs.AddUncountable("sheep") - rs.AddUncountable("jeans") - rs.AddUncountable("police") - - acronyms := strings.Split(baseAcronyms, ",") - for _, acr := range acronyms { - rs.AddAcronym(acr) - } - - return rs -} - -// Uncountables returns a map of uncountables in the ruleset -func (rs *Ruleset) Uncountables() map[string]bool { - return rs.uncountables -} - -// AddPlural add a pluralization rule -func (rs *Ruleset) AddPlural(suffix, replacement string) { - rs.AddPluralExact(suffix, replacement, false) -} - -// AddPluralExact add a pluralization rule with full string match -func (rs *Ruleset) AddPluralExact(suffix, replacement string, exact bool) { - // remove uncountable - delete(rs.uncountables, suffix) - // create rule - r := new(Rule) - r.suffix = suffix - r.replacement = replacement - r.exact = exact - // prepend - rs.plurals = append([]*Rule{r}, rs.plurals...) -} - -// AddSingular add a singular rule -func (rs *Ruleset) AddSingular(suffix, replacement string) { - rs.AddSingularExact(suffix, replacement, false) -} - -// AddSingularExact same as AddSingular but you can set `exact` to force -// a full string match -func (rs *Ruleset) AddSingularExact(suffix, replacement string, exact bool) { - // remove from uncountable - delete(rs.uncountables, suffix) - // create rule - r := new(Rule) - r.suffix = suffix - r.replacement = replacement - r.exact = exact - rs.singulars = append([]*Rule{r}, rs.singulars...) -} - -// AddHuman Human rules are applied by humanize to show more friendly -// versions of words -func (rs *Ruleset) AddHuman(suffix, replacement string) { - r := new(Rule) - r.suffix = suffix - r.replacement = replacement - rs.humans = append([]*Rule{r}, rs.humans...) -} - -// AddIrregular Add any inconsistent pluralizing/singularizing rules -// to the set here. -func (rs *Ruleset) AddIrregular(singular, plural string) { - delete(rs.uncountables, singular) - delete(rs.uncountables, plural) - rs.AddPlural(singular, plural) - rs.AddPlural(plural, plural) - rs.AddSingular(plural, singular) -} - -// AddAcronym if you use acronym you may need to add them to the ruleset -// to prevent Underscored words of things like "HTML" coming out -// as "h_t_m_l" -func (rs *Ruleset) AddAcronym(word string) { - r := new(Rule) - r.suffix = word - r.replacement = rs.Titleize(strings.ToLower(word)) - rs.acronyms = append(rs.acronyms, r) -} - -// AddUncountable add a word to this ruleset that has the same singular and plural form -// for example: "rice" -func (rs *Ruleset) AddUncountable(word string) { - rs.uncountables[strings.ToLower(word)] = true -} - -func (rs *Ruleset) isUncountable(word string) bool { - // handle multiple words by using the last one - words := strings.Split(word, " ") - if _, exists := rs.uncountables[strings.ToLower(words[len(words)-1])]; exists { - return true - } - return false -} - -//isAcronym returns if a word is acronym or not. -func (rs *Ruleset) isAcronym(word string) bool { - for _, rule := range rs.acronyms { - if strings.ToUpper(rule.suffix) == strings.ToUpper(word) { - return true - } - } - - return false -} - -//PluralizeWithSize pluralize with taking number into account -func (rs *Ruleset) PluralizeWithSize(word string, size int) string { - if size == 1 { - return rs.Singularize(word) - } - return rs.Pluralize(word) -} - -// Pluralize returns the plural form of a singular word -func (rs *Ruleset) Pluralize(word string) string { - if len(word) == 0 { - return word - } - lWord := strings.ToLower(word) - if rs.isUncountable(lWord) { - return word - } - - var candidate string - for _, rule := range rs.plurals { - if rule.exact { - if lWord == rule.suffix { - // Capitalized word - if lWord[0] != word[0] && lWord[1:] == word[1:] { - return rs.Capitalize(rule.replacement) - } - return rule.replacement - } - continue - } - - if strings.EqualFold(word, rule.suffix) { - candidate = rule.replacement - } - - if strings.HasSuffix(word, rule.suffix) { - return replaceLast(word, rule.suffix, rule.replacement) - } - } - - if candidate != "" { - return candidate - } - return word + "s" -} - -//Singularize returns the singular form of a plural word -func (rs *Ruleset) Singularize(word string) string { - if len(word) <= 1 { - return word - } - lWord := strings.ToLower(word) - if rs.isUncountable(lWord) { - return word - } - - var candidate string - - for _, rule := range rs.singulars { - if rule.exact { - if lWord == rule.suffix { - // Capitalized word - if lWord[0] != word[0] && lWord[1:] == word[1:] { - return rs.Capitalize(rule.replacement) - } - return rule.replacement - } - continue - } - - if strings.EqualFold(word, rule.suffix) { - candidate = rule.replacement - } - - if strings.HasSuffix(word, rule.suffix) { - return replaceLast(word, rule.suffix, rule.replacement) - } - } - - if candidate != "" { - return candidate - } - - return word -} - -//Capitalize uppercase first character -func (rs *Ruleset) Capitalize(word string) string { - if rs.isAcronym(word) { - return strings.ToUpper(word) - } - return strings.ToUpper(word[:1]) + word[1:] -} - -//Camelize "dino_party" -> "DinoParty" -func (rs *Ruleset) Camelize(word string) string { - if rs.isAcronym(word) { - return strings.ToUpper(word) - } - words := splitAtCaseChangeWithTitlecase(word) - return strings.Join(words, "") -} - -//CamelizeDownFirst same as Camelcase but with first letter downcased -func (rs *Ruleset) CamelizeDownFirst(word string) string { - word = Camelize(word) - return strings.ToLower(word[:1]) + word[1:] -} - -//Titleize Capitalize every word in sentence "hello there" -> "Hello There" -func (rs *Ruleset) Titleize(word string) string { - words := splitAtCaseChangeWithTitlecase(word) - result := strings.Join(words, " ") - - var acronymWords []string - for index, word := range words { - if len(word) == 1 { - acronymWords = append(acronymWords, word) - } - - if len(word) > 1 || index == len(words)-1 || len(acronymWords) > 1 { - acronym := strings.Join(acronymWords, "") - if !rs.isAcronym(acronym) { - acronymWords = acronymWords[:len(acronymWords)] - continue - } - - result = strings.Replace(result, strings.Join(acronymWords, " "), acronym, 1) - acronymWords = []string{} - } - } - - return result -} - -func (rs *Ruleset) safeCaseAcronyms(word string) string { - // convert an acronym like HTML into Html - for _, rule := range rs.acronyms { - word = strings.Replace(word, rule.suffix, rule.replacement, -1) - } - return word -} - -func (rs *Ruleset) separatedWords(word, sep string) string { - word = rs.safeCaseAcronyms(word) - words := splitAtCaseChange(word) - return strings.Join(words, sep) -} - -//Underscore lowercase underscore version "BigBen" -> "big_ben" -func (rs *Ruleset) Underscore(word string) string { - return rs.separatedWords(word, "_") -} - -//Humanize First letter of sentence capitalized -// Uses custom friendly replacements via AddHuman() -func (rs *Ruleset) Humanize(word string) string { - word = replaceLast(word, "_id", "") // strip foreign key kinds - // replace and strings in humans list - for _, rule := range rs.humans { - word = strings.Replace(word, rule.suffix, rule.replacement, -1) - } - sentence := rs.separatedWords(word, " ") - - r, n := utf8.DecodeRuneInString(sentence) - return string(unicode.ToUpper(r)) + sentence[n:] -} - -//ForeignKey an underscored foreign key name "Person" -> "person_id" -func (rs *Ruleset) ForeignKey(word string) string { - return rs.Underscore(rs.Singularize(word)) + "_id" -} - -//ForeignKeyCondensed a foreign key (with an underscore) "Person" -> "personid" -func (rs *Ruleset) ForeignKeyCondensed(word string) string { - return rs.Underscore(word) + "id" -} - -//Tableize Rails style pluralized table names: "SuperPerson" -> "super_people" -func (rs *Ruleset) Tableize(word string) string { - return rs.Pluralize(rs.Underscore(rs.Typeify(word))) -} - -var notUrlSafe *regexp.Regexp = regexp.MustCompile(`[^\w\d\-_ ]`) - -//Parameterize param safe dasherized names like "my-param" -func (rs *Ruleset) Parameterize(word string) string { - return ParameterizeJoin(word, "-") -} - -//ParameterizeJoin param safe dasherized names with custom separator -func (rs *Ruleset) ParameterizeJoin(word, sep string) string { - word = strings.ToLower(word) - word = rs.Asciify(word) - word = notUrlSafe.ReplaceAllString(word, "") - word = strings.Replace(word, " ", sep, -1) - if len(sep) > 0 { - squash, err := regexp.Compile(sep + "+") - if err == nil { - word = squash.ReplaceAllString(word, sep) - } - } - word = strings.Trim(word, sep+" ") - return word -} - -var lookalikes = map[string]*regexp.Regexp{ - "A": regexp.MustCompile(`À|Á|Â|Ã|Ä|Å`), - "AE": regexp.MustCompile(`Æ`), - "C": regexp.MustCompile(`Ç`), - "E": regexp.MustCompile(`È|É|Ê|Ë`), - "G": regexp.MustCompile(`Ğ`), - "I": regexp.MustCompile(`Ì|Í|Î|Ï|İ`), - "N": regexp.MustCompile(`Ñ`), - "O": regexp.MustCompile(`Ò|Ó|Ô|Õ|Ö|Ø`), - "S": regexp.MustCompile(`Ş`), - "U": regexp.MustCompile(`Ù|Ú|Û|Ü`), - "Y": regexp.MustCompile(`Ý`), - "ss": regexp.MustCompile(`ß`), - "a": regexp.MustCompile(`à|á|â|ã|ä|å`), - "ae": regexp.MustCompile(`æ`), - "c": regexp.MustCompile(`ç`), - "e": regexp.MustCompile(`è|é|ê|ë`), - "g": regexp.MustCompile(`ğ`), - "i": regexp.MustCompile(`ì|í|î|ï|ı`), - "n": regexp.MustCompile(`ñ`), - "o": regexp.MustCompile(`ò|ó|ô|õ|ö|ø`), - "s": regexp.MustCompile(`ş`), - "u": regexp.MustCompile(`ù|ú|û|ü|ũ|ū|ŭ|ů|ű|ų`), - "y": regexp.MustCompile(`ý|ÿ`), -} - -//Asciify transforms Latin characters like é -> e -func (rs *Ruleset) Asciify(word string) string { - for repl, regex := range lookalikes { - word = regex.ReplaceAllString(word, repl) - } - return word -} - -var tablePrefix = regexp.MustCompile(`^[^.]*\.`) - -//Typeify "something_like_this" -> "SomethingLikeThis" -func (rs *Ruleset) Typeify(word string) string { - word = tablePrefix.ReplaceAllString(word, "") - return rs.Camelize(rs.Singularize(word)) -} - -//Dasherize "SomeText" -> "some-text" -func (rs *Ruleset) Dasherize(word string) string { - return rs.separatedWords(word, "-") -} - -//Ordinalize "1031" -> "1031st" -func (rs *Ruleset) Ordinalize(str string) string { - number, err := strconv.Atoi(str) - if err != nil { - return str - } - switch abs(number) % 100 { - case 11, 12, 13: - return fmt.Sprintf("%dth", number) - default: - switch abs(number) % 10 { - case 1: - return fmt.Sprintf("%dst", number) - case 2: - return fmt.Sprintf("%dnd", number) - case 3: - return fmt.Sprintf("%drd", number) - } - } - return fmt.Sprintf("%dth", number) -} - -//ForeignKeyToAttribute returns the attribute name from the foreign key -func (rs *Ruleset) ForeignKeyToAttribute(str string) string { - w := rs.Camelize(str) - if strings.HasSuffix(w, "Id") { - return strings.TrimSuffix(w, "Id") + "ID" - } - return w -} - -//LoadReader loads rules from io.Reader param -func (rs *Ruleset) LoadReader(r io.Reader) error { - m := map[string]string{} - err := json.NewDecoder(r).Decode(&m) - if err != nil { - return fmt.Errorf("could not decode inflection JSON from reader: %s", err) - } - for s, p := range m { - defaultRuleset.AddIrregular(s, p) - } - return nil -} - -///////////////////////////////////////// -// the default global ruleset -////////////////////////////////////////// - -var defaultRuleset *Ruleset - -//LoadReader loads rules from io.Reader param -func LoadReader(r io.Reader) error { - return defaultRuleset.LoadReader(r) -} - -func init() { - defaultRuleset = NewDefaultRuleset() - - pwd, _ := os.Getwd() - cfg := filepath.Join(pwd, "inflections.json") - if p := os.Getenv("INFLECT_PATH"); p != "" { - cfg = p - } - if _, err := os.Stat(cfg); err == nil { - b, err := ioutil.ReadFile(cfg) - if err != nil { - fmt.Printf("could not read inflection file %s (%s)\n", cfg, err) - return - } - if err = defaultRuleset.LoadReader(bytes.NewReader(b)); err != nil { - fmt.Println(err) - } - } -} - -//Uncountables returns a list of uncountables rules -func Uncountables() map[string]bool { - return defaultRuleset.Uncountables() -} - -//AddPlural adds plural to the ruleset -func AddPlural(suffix, replacement string) { - defaultRuleset.AddPlural(suffix, replacement) -} - -//AddSingular adds singular to the ruleset -func AddSingular(suffix, replacement string) { - defaultRuleset.AddSingular(suffix, replacement) -} - -//AddHuman adds human -func AddHuman(suffix, replacement string) { - defaultRuleset.AddHuman(suffix, replacement) -} - -func AddIrregular(singular, plural string) { - defaultRuleset.AddIrregular(singular, plural) -} - -func AddAcronym(word string) { - defaultRuleset.AddAcronym(word) -} - -func AddUncountable(word string) { - defaultRuleset.AddUncountable(word) -} - -func Pluralize(word string) string { - return defaultRuleset.Pluralize(word) -} - -func PluralizeWithSize(word string, size int) string { - return defaultRuleset.PluralizeWithSize(word, size) -} - -func Singularize(word string) string { - return defaultRuleset.Singularize(word) -} - -func Capitalize(word string) string { - return defaultRuleset.Capitalize(word) -} - -func Camelize(word string) string { - return defaultRuleset.Camelize(word) -} - -func CamelizeDownFirst(word string) string { - return defaultRuleset.CamelizeDownFirst(word) -} - -func Titleize(word string) string { - return defaultRuleset.Titleize(word) -} - -func Underscore(word string) string { - return defaultRuleset.Underscore(word) -} - -func Humanize(word string) string { - return defaultRuleset.Humanize(word) -} - -func ForeignKey(word string) string { - return defaultRuleset.ForeignKey(word) -} - -func ForeignKeyCondensed(word string) string { - return defaultRuleset.ForeignKeyCondensed(word) -} - -func Tableize(word string) string { - return defaultRuleset.Tableize(word) -} - -func Parameterize(word string) string { - return defaultRuleset.Parameterize(word) -} - -func ParameterizeJoin(word, sep string) string { - return defaultRuleset.ParameterizeJoin(word, sep) -} - -func Typeify(word string) string { - return defaultRuleset.Typeify(word) -} - -func Dasherize(word string) string { - return defaultRuleset.Dasherize(word) -} - -func Ordinalize(word string) string { - return defaultRuleset.Ordinalize(word) -} - -func Asciify(word string) string { - return defaultRuleset.Asciify(word) -} - -func ForeignKeyToAttribute(word string) string { - return defaultRuleset.ForeignKeyToAttribute(word) -} - -// helper funcs - -func reverse(s string) string { - o := make([]rune, utf8.RuneCountInString(s)) - i := len(o) - for _, c := range s { - i-- - o[i] = c - } - return string(o) -} - -func isSpacerChar(c rune) bool { - switch { - case c == rune("_"[0]): - return true - case c == rune(" "[0]): - return true - case c == rune(":"[0]): - return true - case c == rune("-"[0]): - return true - } - return false -} - -func splitAtCaseChange(s string) []string { - words := make([]string, 0) - word := make([]rune, 0) - for _, c := range s { - spacer := isSpacerChar(c) - if len(word) > 0 { - if unicode.IsUpper(c) || spacer { - words = append(words, string(word)) - word = make([]rune, 0) - } - } - if !spacer { - word = append(word, unicode.ToLower(c)) - } - } - words = append(words, string(word)) - return words -} - -func splitAtCaseChangeWithTitlecase(s string) []string { - words := make([]string, 0) - word := make([]rune, 0) - - for _, c := range s { - spacer := isSpacerChar(c) - if len(word) > 0 { - if unicode.IsUpper(c) || spacer { - words = append(words, string(word)) - word = make([]rune, 0) - } - } - if !spacer { - if len(word) > 0 { - word = append(word, unicode.ToLower(c)) - } else { - word = append(word, unicode.ToUpper(c)) - } - } - } - - words = append(words, string(word)) - return words -} - -func replaceLast(s, match, repl string) string { - // reverse strings - srev := reverse(s) - mrev := reverse(match) - rrev := reverse(repl) - // match first and reverse back - return reverse(strings.Replace(srev, mrev, rrev, 1)) -} - -func abs(x int) int { - if x < 0 { - return -x - } - return x -} diff --git a/vendor/github.com/markbates/inflect/inflections.json b/vendor/github.com/markbates/inflect/inflections.json deleted file mode 100644 index 5fd3cbf279b..00000000000 --- a/vendor/github.com/markbates/inflect/inflections.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "feedback": "feedback", - "buffalo!": "buffalos!" -} diff --git a/vendor/github.com/markbates/inflect/name.go b/vendor/github.com/markbates/inflect/name.go deleted file mode 100644 index e6863e28a68..00000000000 --- a/vendor/github.com/markbates/inflect/name.go +++ /dev/null @@ -1,163 +0,0 @@ -package inflect - -import ( - "fmt" - "path/filepath" - "strings" - - "github.com/gobuffalo/envy" -) - -// Name is a string that represents the "name" of a thing, like an app, model, etc... -type Name string - -// Title version of a name. ie. "foo_bar" => "Foo Bar" -func (n Name) Title() string { - x := strings.Split(string(n), "/") - for i, s := range x { - x[i] = Titleize(s) - } - - return strings.Join(x, " ") -} - -// Underscore version of a name. ie. "FooBar" => "foo_bar" -func (n Name) Underscore() string { - w := string(n) - if strings.ToUpper(w) == w { - return strings.ToLower(w) - } - return Underscore(w) -} - -// Plural version of a name -func (n Name) Plural() string { - return Pluralize(string(n)) -} - -// Singular version of a name -func (n Name) Singular() string { - return Singularize(string(n)) -} - -// Camel version of a name -func (n Name) Camel() string { - c := Camelize(string(n)) - if strings.HasSuffix(c, "Id") { - c = strings.TrimSuffix(c, "Id") - c += "ID" - } - return c -} - -// Model version of a name. ie. "user" => "User" -func (n Name) Model() string { - x := strings.Split(string(n), "/") - for i, s := range x { - x[i] = Camelize(Singularize(s)) - } - - return strings.Join(x, "") -} - -// Resource version of a name -func (n Name) Resource() string { - name := n.Underscore() - x := strings.FieldsFunc(name, func(r rune) bool { - return r == '_' || r == '/' - }) - - for i, w := range x { - if i == len(x)-1 { - x[i] = Camelize(Pluralize(strings.ToLower(w))) - continue - } - - x[i] = Camelize(w) - } - - return strings.Join(x, "") -} - -// ModelPlural version of a name. ie. "user" => "Users" -func (n Name) ModelPlural() string { - return Camelize(Pluralize(n.Model())) -} - -// File version of a name -func (n Name) File() string { - return Underscore(Camelize(string(n))) -} - -// Table version of a name -func (n Name) Table() string { - return Underscore(Pluralize(string(n))) -} - -// UnderSingular version of a name -func (n Name) UnderSingular() string { - return Underscore(Singularize(string(n))) -} - -// PluralCamel version of a name -func (n Name) PluralCamel() string { - return Pluralize(Camelize(string(n))) -} - -// PluralUnder version of a name -func (n Name) PluralUnder() string { - return Pluralize(Underscore(string(n))) -} - -// URL version of a name -func (n Name) URL() string { - return n.PluralUnder() -} - -// CamelSingular version of a name -func (n Name) CamelSingular() string { - return Camelize(Singularize(string(n))) -} - -// VarCaseSingular version of a name. ie. "FooBar" => "fooBar" -func (n Name) VarCaseSingular() string { - return CamelizeDownFirst(Singularize(Underscore(n.Resource()))) -} - -// VarCasePlural version of a name. ie. "FooBar" => "fooBar" -func (n Name) VarCasePlural() string { - return CamelizeDownFirst(n.Resource()) -} - -// Lower case version of a string -func (n Name) Lower() string { - return strings.ToLower(string(n)) -} - -// ParamID returns foo_bar_id -func (n Name) ParamID() string { - return fmt.Sprintf("%s_id", strings.Replace(n.UnderSingular(), "/", "_", -1)) -} - -// Package returns go package -func (n Name) Package() string { - key := string(n) - - for _, gp := range envy.GoPaths() { - key = strings.TrimPrefix(key, filepath.Join(gp, "src")) - key = strings.TrimPrefix(key, gp) - } - key = strings.TrimPrefix(key, string(filepath.Separator)) - - key = strings.Replace(key, "\\", "/", -1) - return key -} - -// Char returns first character in lower case, this is useful for methods inside a struct. -func (n Name) Char() string { - return strings.ToLower(string(n[0])) -} - -func (n Name) String() string { - return string(n) -} diff --git a/vendor/github.com/markbates/inflect/shoulders.md b/vendor/github.com/markbates/inflect/shoulders.md deleted file mode 100644 index 619e7892f78..00000000000 --- a/vendor/github.com/markbates/inflect/shoulders.md +++ /dev/null @@ -1,12 +0,0 @@ -# github.com/markbates/inflect Stands on the Shoulders of Giants - -github.com/markbates/inflect does not try to reinvent the wheel! Instead, it uses the already great wheels developed by the Go community and puts them all together in the best way possible. Without these giants this project would not be possible. Please make sure to check them out and thank them for all of their hard work. - -Thank you to the following **GIANTS**: - - -* [github.com/gobuffalo/envy](https://godoc.org/github.com/gobuffalo/envy) - -* [github.com/joho/godotenv](https://godoc.org/github.com/joho/godotenv) - -* [github.com/markbates/inflect](https://godoc.org/github.com/markbates/inflect) diff --git a/vendor/github.com/markbates/inflect/version.go b/vendor/github.com/markbates/inflect/version.go deleted file mode 100644 index a1674498419..00000000000 --- a/vendor/github.com/markbates/inflect/version.go +++ /dev/null @@ -1,3 +0,0 @@ -package inflect - -const Version = "v1.0.4" diff --git a/vendor/github.com/prometheus/client_golang/prometheus/process_collector.go b/vendor/github.com/prometheus/client_golang/prometheus/process_collector.go index 9b809794212..c46702d60b5 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/process_collector.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/process_collector.go @@ -15,7 +15,11 @@ package prometheus import ( "errors" + "fmt" + "io/ioutil" "os" + "strconv" + "strings" ) type processCollector struct { @@ -149,3 +153,20 @@ func (c *processCollector) reportError(ch chan<- Metric, desc *Desc, err error) } ch <- NewInvalidMetric(desc, err) } + +// NewPidFileFn returns a function that retrieves a pid from the specified file. +// It is meant to be used for the PidFn field in ProcessCollectorOpts. +func NewPidFileFn(pidFilePath string) func() (int, error) { + return func() (int, error) { + content, err := ioutil.ReadFile(pidFilePath) + if err != nil { + return 0, fmt.Errorf("can't read pid file %q: %+v", pidFilePath, err) + } + pid, err := strconv.Atoi(strings.TrimSpace(string(content))) + if err != nil { + return 0, fmt.Errorf("can't parse pid file %q: %+v", pidFilePath, err) + } + + return pid, nil + } +} diff --git a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go index 5e1c4546ceb..d86d0cf4b0e 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go @@ -99,7 +99,7 @@ func HandlerFor(reg prometheus.Gatherer, opts HandlerOpts) http.Handler { inFlightSem = make(chan struct{}, opts.MaxRequestsInFlight) } if opts.Registry != nil { - // Initialize all possibilites that can occur below. + // Initialize all possibilities that can occur below. errCnt.WithLabelValues("gathering") errCnt.WithLabelValues("encoding") if err := opts.Registry.Register(errCnt); err != nil { @@ -303,8 +303,12 @@ type Logger interface { // HandlerOpts specifies options how to serve metrics via an http.Handler. The // zero value of HandlerOpts is a reasonable default. type HandlerOpts struct { - // ErrorLog specifies an optional logger for errors collecting and - // serving metrics. If nil, errors are not logged at all. + // ErrorLog specifies an optional Logger for errors collecting and + // serving metrics. If nil, errors are not logged at all. Note that the + // type of a reported error is often prometheus.MultiError, which + // formats into a multi-line error string. If you want to avoid the + // latter, create a Logger implementation that detects a + // prometheus.MultiError and formats the contained errors into one line. ErrorLog Logger // ErrorHandling defines how errors are handled. Note that errors are // logged regardless of the configured ErrorHandling provided ErrorLog diff --git a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go index 9db24380533..ab037db8619 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go @@ -43,14 +43,14 @@ func InstrumentHandlerInFlight(g prometheus.Gauge, next http.Handler) http.Handl // InstrumentHandlerDuration is a middleware that wraps the provided // http.Handler to observe the request duration with the provided ObserverVec. -// The ObserverVec must have zero, one, or two non-const non-curried labels. For -// those, the only allowed label names are "code" and "method". The function -// panics otherwise. The Observe method of the Observer in the ObserverVec is -// called with the request duration in seconds. Partitioning happens by HTTP -// status code and/or HTTP method if the respective instance label names are -// present in the ObserverVec. For unpartitioned observations, use an -// ObserverVec with zero labels. Note that partitioning of Histograms is -// expensive and should be used judiciously. +// The ObserverVec must have valid metric and label names and must have zero, +// one, or two non-const non-curried labels. For those, the only allowed label +// names are "code" and "method". The function panics otherwise. The Observe +// method of the Observer in the ObserverVec is called with the request duration +// in seconds. Partitioning happens by HTTP status code and/or HTTP method if +// the respective instance label names are present in the ObserverVec. For +// unpartitioned observations, use an ObserverVec with zero labels. Note that +// partitioning of Histograms is expensive and should be used judiciously. // // If the wrapped Handler does not set a status code, a status code of 200 is assumed. // @@ -79,12 +79,13 @@ func InstrumentHandlerDuration(obs prometheus.ObserverVec, next http.Handler) ht } // InstrumentHandlerCounter is a middleware that wraps the provided http.Handler -// to observe the request result with the provided CounterVec. The CounterVec -// must have zero, one, or two non-const non-curried labels. For those, the only -// allowed label names are "code" and "method". The function panics -// otherwise. Partitioning of the CounterVec happens by HTTP status code and/or -// HTTP method if the respective instance label names are present in the -// CounterVec. For unpartitioned counting, use a CounterVec with zero labels. +// to observe the request result with the provided CounterVec. The CounterVec +// must have valid metric and label names and must have zero, one, or two +// non-const non-curried labels. For those, the only allowed label names are +// "code" and "method". The function panics otherwise. Partitioning of the +// CounterVec happens by HTTP status code and/or HTTP method if the respective +// instance label names are present in the CounterVec. For unpartitioned +// counting, use a CounterVec with zero labels. // // If the wrapped Handler does not set a status code, a status code of 200 is assumed. // @@ -110,14 +111,15 @@ func InstrumentHandlerCounter(counter *prometheus.CounterVec, next http.Handler) // InstrumentHandlerTimeToWriteHeader is a middleware that wraps the provided // http.Handler to observe with the provided ObserverVec the request duration -// until the response headers are written. The ObserverVec must have zero, one, -// or two non-const non-curried labels. For those, the only allowed label names -// are "code" and "method". The function panics otherwise. The Observe method of -// the Observer in the ObserverVec is called with the request duration in -// seconds. Partitioning happens by HTTP status code and/or HTTP method if the -// respective instance label names are present in the ObserverVec. For -// unpartitioned observations, use an ObserverVec with zero labels. Note that -// partitioning of Histograms is expensive and should be used judiciously. +// until the response headers are written. The ObserverVec must have valid +// metric and label names and must have zero, one, or two non-const non-curried +// labels. For those, the only allowed label names are "code" and "method". The +// function panics otherwise. The Observe method of the Observer in the +// ObserverVec is called with the request duration in seconds. Partitioning +// happens by HTTP status code and/or HTTP method if the respective instance +// label names are present in the ObserverVec. For unpartitioned observations, +// use an ObserverVec with zero labels. Note that partitioning of Histograms is +// expensive and should be used judiciously. // // If the wrapped Handler panics before calling WriteHeader, no value is // reported. @@ -139,15 +141,15 @@ func InstrumentHandlerTimeToWriteHeader(obs prometheus.ObserverVec, next http.Ha } // InstrumentHandlerRequestSize is a middleware that wraps the provided -// http.Handler to observe the request size with the provided ObserverVec. The -// ObserverVec must have zero, one, or two non-const non-curried labels. For -// those, the only allowed label names are "code" and "method". The function -// panics otherwise. The Observe method of the Observer in the ObserverVec is -// called with the request size in bytes. Partitioning happens by HTTP status -// code and/or HTTP method if the respective instance label names are present in -// the ObserverVec. For unpartitioned observations, use an ObserverVec with zero -// labels. Note that partitioning of Histograms is expensive and should be used -// judiciously. +// http.Handler to observe the request size with the provided ObserverVec. The +// ObserverVec must have valid metric and label names and must have zero, one, +// or two non-const non-curried labels. For those, the only allowed label names +// are "code" and "method". The function panics otherwise. The Observe method of +// the Observer in the ObserverVec is called with the request size in +// bytes. Partitioning happens by HTTP status code and/or HTTP method if the +// respective instance label names are present in the ObserverVec. For +// unpartitioned observations, use an ObserverVec with zero labels. Note that +// partitioning of Histograms is expensive and should be used judiciously. // // If the wrapped Handler does not set a status code, a status code of 200 is assumed. // @@ -174,15 +176,15 @@ func InstrumentHandlerRequestSize(obs prometheus.ObserverVec, next http.Handler) } // InstrumentHandlerResponseSize is a middleware that wraps the provided -// http.Handler to observe the response size with the provided ObserverVec. The -// ObserverVec must have zero, one, or two non-const non-curried labels. For -// those, the only allowed label names are "code" and "method". The function -// panics otherwise. The Observe method of the Observer in the ObserverVec is -// called with the response size in bytes. Partitioning happens by HTTP status -// code and/or HTTP method if the respective instance label names are present in -// the ObserverVec. For unpartitioned observations, use an ObserverVec with zero -// labels. Note that partitioning of Histograms is expensive and should be used -// judiciously. +// http.Handler to observe the response size with the provided ObserverVec. The +// ObserverVec must have valid metric and label names and must have zero, one, +// or two non-const non-curried labels. For those, the only allowed label names +// are "code" and "method". The function panics otherwise. The Observe method of +// the Observer in the ObserverVec is called with the response size in +// bytes. Partitioning happens by HTTP status code and/or HTTP method if the +// respective instance label names are present in the ObserverVec. For +// unpartitioned observations, use an ObserverVec with zero labels. Note that +// partitioning of Histograms is expensive and should be used judiciously. // // If the wrapped Handler does not set a status code, a status code of 200 is assumed. // @@ -198,6 +200,11 @@ func InstrumentHandlerResponseSize(obs prometheus.ObserverVec, next http.Handler }) } +// checkLabels returns whether the provided Collector has a non-const, +// non-curried label named "code" and/or "method". It panics if the provided +// Collector does not have a Desc or has more than one Desc or its Desc is +// invalid. It also panics if the Collector has any non-const, non-curried +// labels that are not named "code" or "method". func checkLabels(c prometheus.Collector) (code bool, method bool) { // TODO(beorn7): Remove this hacky way to check for instance labels // once Descriptors can have their dimensionality queried. @@ -225,6 +232,10 @@ func checkLabels(c prometheus.Collector) (code bool, method bool) { close(descc) + // Make sure the Collector has a valid Desc by registering it with a + // temporary registry. + prometheus.NewRegistry().MustRegister(c) + // Create a ConstMetric with the Desc. Since we don't know how many // variable labels there are, try for as long as it needs. for err := errors.New("dummy"); err != nil; lvs = append(lvs, magicString) { diff --git a/vendor/github.com/prometheus/client_golang/prometheus/registry.go b/vendor/github.com/prometheus/client_golang/prometheus/registry.go index ba94405af4c..48f5ef9d72f 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/registry.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/registry.go @@ -215,6 +215,8 @@ func (err AlreadyRegisteredError) Error() string { // by a Gatherer to report multiple errors during MetricFamily gathering. type MultiError []error +// Error formats the contained errors as a bullet point list, preceded by the +// total number of errors. Note that this results in a multi-line string. func (errs MultiError) Error() string { if len(errs) == 0 { return "" diff --git a/vendor/github.com/prometheus/common/model/time.go b/vendor/github.com/prometheus/common/model/time.go index c40e6403ca8..e684ebd11af 100644 --- a/vendor/github.com/prometheus/common/model/time.go +++ b/vendor/github.com/prometheus/common/model/time.go @@ -14,6 +14,7 @@ package model import ( + "encoding/json" "fmt" "math" "regexp" @@ -254,6 +255,37 @@ func (d Duration) String() string { return r } +// MarshalJSON implements the json.Marshaler interface. +func (d Duration) MarshalJSON() ([]byte, error) { + return json.Marshal(d.String()) +} + +// UnmarshalJSON implements the json.Unmarshaler interface. +func (d *Duration) UnmarshalJSON(bytes []byte) error { + var s string + if err := json.Unmarshal(bytes, &s); err != nil { + return err + } + dur, err := ParseDuration(s) + if err != nil { + return err + } + *d = dur + return nil +} + +// MarshalText implements the encoding.TextMarshaler interface. +func (d *Duration) MarshalText() ([]byte, error) { + return []byte(d.String()), nil +} + +// UnmarshalText implements the encoding.TextUnmarshaler interface. +func (d *Duration) UnmarshalText(text []byte) error { + var err error + *d, err = ParseDuration(string(text)) + return err +} + // MarshalYAML implements the yaml.Marshaler interface. func (d Duration) MarshalYAML() (interface{}, error) { return d.String(), nil diff --git a/vendor/github.com/rogpeppe/go-internal/LICENSE b/vendor/github.com/rogpeppe/go-internal/LICENSE deleted file mode 100644 index 49ea0f92882..00000000000 --- a/vendor/github.com/rogpeppe/go-internal/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2018 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. diff --git a/vendor/github.com/rogpeppe/go-internal/modfile/gopkgin.go b/vendor/github.com/rogpeppe/go-internal/modfile/gopkgin.go deleted file mode 100644 index c94b3848a0e..00000000000 --- a/vendor/github.com/rogpeppe/go-internal/modfile/gopkgin.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2018 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. - -// TODO: Figure out what gopkg.in should do. - -package modfile - -import "strings" - -// ParseGopkgIn splits gopkg.in import paths into their constituent parts -func ParseGopkgIn(path string) (root, repo, major, subdir string, ok bool) { - if !strings.HasPrefix(path, "gopkg.in/") { - return - } - f := strings.Split(path, "/") - if len(f) >= 2 { - if elem, v, ok := dotV(f[1]); ok { - root = strings.Join(f[:2], "/") - repo = "github.com/go-" + elem + "/" + elem - major = v - subdir = strings.Join(f[2:], "/") - return root, repo, major, subdir, true - } - } - if len(f) >= 3 { - if elem, v, ok := dotV(f[2]); ok { - root = strings.Join(f[:3], "/") - repo = "github.com/" + f[1] + "/" + elem - major = v - subdir = strings.Join(f[3:], "/") - return root, repo, major, subdir, true - } - } - return -} - -func dotV(name string) (elem, v string, ok bool) { - i := len(name) - 1 - for i >= 0 && '0' <= name[i] && name[i] <= '9' { - i-- - } - if i <= 2 || i+1 >= len(name) || name[i-1] != '.' || name[i] != 'v' || name[i+1] == '0' && len(name) != i+2 { - return "", "", false - } - return name[:i-1], name[i:], true -} diff --git a/vendor/github.com/rogpeppe/go-internal/modfile/print.go b/vendor/github.com/rogpeppe/go-internal/modfile/print.go deleted file mode 100644 index 7b1dd8f9533..00000000000 --- a/vendor/github.com/rogpeppe/go-internal/modfile/print.go +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright 2018 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. - -// Package modfile implements parsing and formatting for -// go.mod files. -package modfile - -import ( - "bytes" - "fmt" - "strings" -) - -func Format(f *FileSyntax) []byte { - pr := &printer{} - pr.file(f) - return pr.Bytes() -} - -// A printer collects the state during printing of a file or expression. -type printer struct { - bytes.Buffer // output buffer - comment []Comment // pending end-of-line comments - margin int // left margin (indent), a number of tabs -} - -// printf prints to the buffer. -func (p *printer) printf(format string, args ...interface{}) { - fmt.Fprintf(p, format, args...) -} - -// indent returns the position on the current line, in bytes, 0-indexed. -func (p *printer) indent() int { - b := p.Bytes() - n := 0 - for n < len(b) && b[len(b)-1-n] != '\n' { - n++ - } - return n -} - -// newline ends the current line, flushing end-of-line comments. -func (p *printer) newline() { - if len(p.comment) > 0 { - p.printf(" ") - for i, com := range p.comment { - if i > 0 { - p.trim() - p.printf("\n") - for i := 0; i < p.margin; i++ { - p.printf("\t") - } - } - p.printf("%s", strings.TrimSpace(com.Token)) - } - p.comment = p.comment[:0] - } - - p.trim() - p.printf("\n") - for i := 0; i < p.margin; i++ { - p.printf("\t") - } -} - -// trim removes trailing spaces and tabs from the current line. -func (p *printer) trim() { - // Remove trailing spaces and tabs from line we're about to end. - b := p.Bytes() - n := len(b) - for n > 0 && (b[n-1] == '\t' || b[n-1] == ' ') { - n-- - } - p.Truncate(n) -} - -// file formats the given file into the print buffer. -func (p *printer) file(f *FileSyntax) { - for _, com := range f.Before { - p.printf("%s", strings.TrimSpace(com.Token)) - p.newline() - } - - for i, stmt := range f.Stmt { - switch x := stmt.(type) { - case *CommentBlock: - // comments already handled - p.expr(x) - - default: - p.expr(x) - p.newline() - } - - for _, com := range stmt.Comment().After { - p.printf("%s", strings.TrimSpace(com.Token)) - p.newline() - } - - if i+1 < len(f.Stmt) { - p.newline() - } - } -} - -func (p *printer) expr(x Expr) { - // Emit line-comments preceding this expression. - if before := x.Comment().Before; len(before) > 0 { - // Want to print a line comment. - // Line comments must be at the current margin. - p.trim() - if p.indent() > 0 { - // There's other text on the line. Start a new line. - p.printf("\n") - } - // Re-indent to margin. - for i := 0; i < p.margin; i++ { - p.printf("\t") - } - for _, com := range before { - p.printf("%s", strings.TrimSpace(com.Token)) - p.newline() - } - } - - switch x := x.(type) { - default: - panic(fmt.Errorf("printer: unexpected type %T", x)) - - case *CommentBlock: - // done - - case *LParen: - p.printf("(") - case *RParen: - p.printf(")") - - case *Line: - sep := "" - for _, tok := range x.Token { - p.printf("%s%s", sep, tok) - sep = " " - } - - case *LineBlock: - for _, tok := range x.Token { - p.printf("%s ", tok) - } - p.expr(&x.LParen) - p.margin++ - for _, l := range x.Line { - p.newline() - p.expr(l) - } - p.margin-- - p.newline() - p.expr(&x.RParen) - } - - // Queue end-of-line comments for printing when we - // reach the end of the line. - p.comment = append(p.comment, x.Comment().Suffix...) -} diff --git a/vendor/github.com/rogpeppe/go-internal/modfile/read.go b/vendor/github.com/rogpeppe/go-internal/modfile/read.go deleted file mode 100644 index 1d81ff1ab7a..00000000000 --- a/vendor/github.com/rogpeppe/go-internal/modfile/read.go +++ /dev/null @@ -1,869 +0,0 @@ -// Copyright 2018 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. - -// Module file parser. -// This is a simplified copy of Google's buildifier parser. - -package modfile - -import ( - "bytes" - "fmt" - "os" - "strconv" - "strings" - "unicode" - "unicode/utf8" -) - -// A Position describes the position between two bytes of input. -type Position struct { - Line int // line in input (starting at 1) - LineRune int // rune in line (starting at 1) - Byte int // byte in input (starting at 0) -} - -// add returns the position at the end of s, assuming it starts at p. -func (p Position) add(s string) Position { - p.Byte += len(s) - if n := strings.Count(s, "\n"); n > 0 { - p.Line += n - s = s[strings.LastIndex(s, "\n")+1:] - p.LineRune = 1 - } - p.LineRune += utf8.RuneCountInString(s) - return p -} - -// An Expr represents an input element. -type Expr interface { - // Span returns the start and end position of the expression, - // excluding leading or trailing comments. - Span() (start, end Position) - - // Comment returns the comments attached to the expression. - // This method would normally be named 'Comments' but that - // would interfere with embedding a type of the same name. - Comment() *Comments -} - -// A Comment represents a single // comment. -type Comment struct { - Start Position - Token string // without trailing newline - Suffix bool // an end of line (not whole line) comment -} - -// Comments collects the comments associated with an expression. -type Comments struct { - Before []Comment // whole-line comments before this expression - Suffix []Comment // end-of-line comments after this expression - - // For top-level expressions only, After lists whole-line - // comments following the expression. - After []Comment -} - -// Comment returns the receiver. This isn't useful by itself, but -// a Comments struct is embedded into all the expression -// implementation types, and this gives each of those a Comment -// method to satisfy the Expr interface. -func (c *Comments) Comment() *Comments { - return c -} - -// A FileSyntax represents an entire go.mod file. -type FileSyntax struct { - Name string // file path - Comments - Stmt []Expr -} - -func (x *FileSyntax) Span() (start, end Position) { - if len(x.Stmt) == 0 { - return - } - start, _ = x.Stmt[0].Span() - _, end = x.Stmt[len(x.Stmt)-1].Span() - return start, end -} - -func (x *FileSyntax) addLine(hint Expr, tokens ...string) *Line { - if hint == nil { - // If no hint given, add to the last statement of the given type. - Loop: - for i := len(x.Stmt) - 1; i >= 0; i-- { - stmt := x.Stmt[i] - switch stmt := stmt.(type) { - case *Line: - if stmt.Token != nil && stmt.Token[0] == tokens[0] { - hint = stmt - break Loop - } - case *LineBlock: - if stmt.Token[0] == tokens[0] { - hint = stmt - break Loop - } - } - } - } - - if hint != nil { - for i, stmt := range x.Stmt { - switch stmt := stmt.(type) { - case *Line: - if stmt == hint { - // Convert line to line block. - stmt.InBlock = true - block := &LineBlock{Token: stmt.Token[:1], Line: []*Line{stmt}} - stmt.Token = stmt.Token[1:] - x.Stmt[i] = block - new := &Line{Token: tokens[1:], InBlock: true} - block.Line = append(block.Line, new) - return new - } - case *LineBlock: - if stmt == hint { - new := &Line{Token: tokens[1:], InBlock: true} - stmt.Line = append(stmt.Line, new) - return new - } - for j, line := range stmt.Line { - if line == hint { - // Add new line after hint. - stmt.Line = append(stmt.Line, nil) - copy(stmt.Line[j+2:], stmt.Line[j+1:]) - new := &Line{Token: tokens[1:], InBlock: true} - stmt.Line[j+1] = new - return new - } - } - } - } - } - - new := &Line{Token: tokens} - x.Stmt = append(x.Stmt, new) - return new -} - -func (x *FileSyntax) updateLine(line *Line, tokens ...string) { - if line.InBlock { - tokens = tokens[1:] - } - line.Token = tokens -} - -func (x *FileSyntax) removeLine(line *Line) { - line.Token = nil -} - -// Cleanup cleans up the file syntax x after any edit operations. -// To avoid quadratic behavior, removeLine marks the line as dead -// by setting line.Token = nil but does not remove it from the slice -// in which it appears. After edits have all been indicated, -// calling Cleanup cleans out the dead lines. -func (x *FileSyntax) Cleanup() { - w := 0 - for _, stmt := range x.Stmt { - switch stmt := stmt.(type) { - case *Line: - if stmt.Token == nil { - continue - } - case *LineBlock: - ww := 0 - for _, line := range stmt.Line { - if line.Token != nil { - stmt.Line[ww] = line - ww++ - } - } - if ww == 0 { - continue - } - if ww == 1 { - // Collapse block into single line. - line := &Line{ - Comments: Comments{ - Before: commentsAdd(stmt.Before, stmt.Line[0].Before), - Suffix: commentsAdd(stmt.Line[0].Suffix, stmt.Suffix), - After: commentsAdd(stmt.Line[0].After, stmt.After), - }, - Token: stringsAdd(stmt.Token, stmt.Line[0].Token), - } - x.Stmt[w] = line - w++ - continue - } - stmt.Line = stmt.Line[:ww] - } - x.Stmt[w] = stmt - w++ - } - x.Stmt = x.Stmt[:w] -} - -func commentsAdd(x, y []Comment) []Comment { - return append(x[:len(x):len(x)], y...) -} - -func stringsAdd(x, y []string) []string { - return append(x[:len(x):len(x)], y...) -} - -// A CommentBlock represents a top-level block of comments separate -// from any rule. -type CommentBlock struct { - Comments - Start Position -} - -func (x *CommentBlock) Span() (start, end Position) { - return x.Start, x.Start -} - -// A Line is a single line of tokens. -type Line struct { - Comments - Start Position - Token []string - InBlock bool - End Position -} - -func (x *Line) Span() (start, end Position) { - return x.Start, x.End -} - -// A LineBlock is a factored block of lines, like -// -// require ( -// "x" -// "y" -// ) -// -type LineBlock struct { - Comments - Start Position - LParen LParen - Token []string - Line []*Line - RParen RParen -} - -func (x *LineBlock) Span() (start, end Position) { - return x.Start, x.RParen.Pos.add(")") -} - -// An LParen represents the beginning of a parenthesized line block. -// It is a place to store suffix comments. -type LParen struct { - Comments - Pos Position -} - -func (x *LParen) Span() (start, end Position) { - return x.Pos, x.Pos.add(")") -} - -// An RParen represents the end of a parenthesized line block. -// It is a place to store whole-line (before) comments. -type RParen struct { - Comments - Pos Position -} - -func (x *RParen) Span() (start, end Position) { - return x.Pos, x.Pos.add(")") -} - -// An input represents a single input file being parsed. -type input struct { - // Lexing state. - filename string // name of input file, for errors - complete []byte // entire input - remaining []byte // remaining input - token []byte // token being scanned - lastToken string // most recently returned token, for error messages - pos Position // current input position - comments []Comment // accumulated comments - endRule int // position of end of current rule - - // Parser state. - file *FileSyntax // returned top-level syntax tree - parseError error // error encountered during parsing - - // Comment assignment state. - pre []Expr // all expressions, in preorder traversal - post []Expr // all expressions, in postorder traversal -} - -func newInput(filename string, data []byte) *input { - return &input{ - filename: filename, - complete: data, - remaining: data, - pos: Position{Line: 1, LineRune: 1, Byte: 0}, - } -} - -// parse parses the input file. -func parse(file string, data []byte) (f *FileSyntax, err error) { - in := newInput(file, data) - // The parser panics for both routine errors like syntax errors - // and for programmer bugs like array index errors. - // Turn both into error returns. Catching bug panics is - // especially important when processing many files. - defer func() { - if e := recover(); e != nil { - if e == in.parseError { - err = in.parseError - } else { - err = fmt.Errorf("%s:%d:%d: internal error: %v", in.filename, in.pos.Line, in.pos.LineRune, e) - } - } - }() - - // Invoke the parser. - in.parseFile() - if in.parseError != nil { - return nil, in.parseError - } - in.file.Name = in.filename - - // Assign comments to nearby syntax. - in.assignComments() - - return in.file, nil -} - -// Error is called to report an error. -// The reason s is often "syntax error". -// Error does not return: it panics. -func (in *input) Error(s string) { - if s == "syntax error" && in.lastToken != "" { - s += " near " + in.lastToken - } - in.parseError = fmt.Errorf("%s:%d:%d: %v", in.filename, in.pos.Line, in.pos.LineRune, s) - panic(in.parseError) -} - -// eof reports whether the input has reached end of file. -func (in *input) eof() bool { - return len(in.remaining) == 0 -} - -// peekRune returns the next rune in the input without consuming it. -func (in *input) peekRune() int { - if len(in.remaining) == 0 { - return 0 - } - r, _ := utf8.DecodeRune(in.remaining) - return int(r) -} - -// peekPrefix reports whether the remaining input begins with the given prefix. -func (in *input) peekPrefix(prefix string) bool { - // This is like bytes.HasPrefix(in.remaining, []byte(prefix)) - // but without the allocation of the []byte copy of prefix. - for i := 0; i < len(prefix); i++ { - if i >= len(in.remaining) || in.remaining[i] != prefix[i] { - return false - } - } - return true -} - -// readRune consumes and returns the next rune in the input. -func (in *input) readRune() int { - if len(in.remaining) == 0 { - in.Error("internal lexer error: readRune at EOF") - } - r, size := utf8.DecodeRune(in.remaining) - in.remaining = in.remaining[size:] - if r == '\n' { - in.pos.Line++ - in.pos.LineRune = 1 - } else { - in.pos.LineRune++ - } - in.pos.Byte += size - return int(r) -} - -type symType struct { - pos Position - endPos Position - text string -} - -// startToken marks the beginning of the next input token. -// It must be followed by a call to endToken, once the token has -// been consumed using readRune. -func (in *input) startToken(sym *symType) { - in.token = in.remaining - sym.text = "" - sym.pos = in.pos -} - -// endToken marks the end of an input token. -// It records the actual token string in sym.text if the caller -// has not done that already. -func (in *input) endToken(sym *symType) { - if sym.text == "" { - tok := string(in.token[:len(in.token)-len(in.remaining)]) - sym.text = tok - in.lastToken = sym.text - } - sym.endPos = in.pos -} - -// lex is called from the parser to obtain the next input token. -// It returns the token value (either a rune like '+' or a symbolic token _FOR) -// and sets val to the data associated with the token. -// For all our input tokens, the associated data is -// val.Pos (the position where the token begins) -// and val.Token (the input string corresponding to the token). -func (in *input) lex(sym *symType) int { - // Skip past spaces, stopping at non-space or EOF. - countNL := 0 // number of newlines we've skipped past - for !in.eof() { - // Skip over spaces. Count newlines so we can give the parser - // information about where top-level blank lines are, - // for top-level comment assignment. - c := in.peekRune() - if c == ' ' || c == '\t' || c == '\r' { - in.readRune() - continue - } - - // Comment runs to end of line. - if in.peekPrefix("//") { - in.startToken(sym) - - // Is this comment the only thing on its line? - // Find the last \n before this // and see if it's all - // spaces from there to here. - i := bytes.LastIndex(in.complete[:in.pos.Byte], []byte("\n")) - suffix := len(bytes.TrimSpace(in.complete[i+1:in.pos.Byte])) > 0 - in.readRune() - in.readRune() - - // Consume comment. - for len(in.remaining) > 0 && in.readRune() != '\n' { - } - in.endToken(sym) - - sym.text = strings.TrimRight(sym.text, "\n") - in.lastToken = "comment" - - // If we are at top level (not in a statement), hand the comment to - // the parser as a _COMMENT token. The grammar is written - // to handle top-level comments itself. - if !suffix { - // Not in a statement. Tell parser about top-level comment. - return _COMMENT - } - - // Otherwise, save comment for later attachment to syntax tree. - if countNL > 1 { - in.comments = append(in.comments, Comment{sym.pos, "", false}) - } - in.comments = append(in.comments, Comment{sym.pos, sym.text, suffix}) - countNL = 1 - return _EOL - } - - if in.peekPrefix("/*") { - in.Error(fmt.Sprintf("mod files must use // comments (not /* */ comments)")) - } - - // Found non-space non-comment. - break - } - - // Found the beginning of the next token. - in.startToken(sym) - defer in.endToken(sym) - - // End of file. - if in.eof() { - in.lastToken = "EOF" - return _EOF - } - - // Punctuation tokens. - switch c := in.peekRune(); c { - case '\n': - in.readRune() - return c - - case '(': - in.readRune() - return c - - case ')': - in.readRune() - return c - - case '"', '`': // quoted string - quote := c - in.readRune() - for { - if in.eof() { - in.pos = sym.pos - in.Error("unexpected EOF in string") - } - if in.peekRune() == '\n' { - in.Error("unexpected newline in string") - } - c := in.readRune() - if c == quote { - break - } - if c == '\\' && quote != '`' { - if in.eof() { - in.pos = sym.pos - in.Error("unexpected EOF in string") - } - in.readRune() - } - } - in.endToken(sym) - return _STRING - } - - // Checked all punctuation. Must be identifier token. - if c := in.peekRune(); !isIdent(c) { - in.Error(fmt.Sprintf("unexpected input character %#q", c)) - } - - // Scan over identifier. - for isIdent(in.peekRune()) { - if in.peekPrefix("//") { - break - } - if in.peekPrefix("/*") { - in.Error(fmt.Sprintf("mod files must use // comments (not /* */ comments)")) - } - in.readRune() - } - return _IDENT -} - -// isIdent reports whether c is an identifier rune. -// We treat nearly all runes as identifier runes. -func isIdent(c int) bool { - return c != 0 && !unicode.IsSpace(rune(c)) -} - -// Comment assignment. -// We build two lists of all subexpressions, preorder and postorder. -// The preorder list is ordered by start location, with outer expressions first. -// The postorder list is ordered by end location, with outer expressions last. -// We use the preorder list to assign each whole-line comment to the syntax -// immediately following it, and we use the postorder list to assign each -// end-of-line comment to the syntax immediately preceding it. - -// order walks the expression adding it and its subexpressions to the -// preorder and postorder lists. -func (in *input) order(x Expr) { - if x != nil { - in.pre = append(in.pre, x) - } - switch x := x.(type) { - default: - panic(fmt.Errorf("order: unexpected type %T", x)) - case nil: - // nothing - case *LParen, *RParen: - // nothing - case *CommentBlock: - // nothing - case *Line: - // nothing - case *FileSyntax: - for _, stmt := range x.Stmt { - in.order(stmt) - } - case *LineBlock: - in.order(&x.LParen) - for _, l := range x.Line { - in.order(l) - } - in.order(&x.RParen) - } - if x != nil { - in.post = append(in.post, x) - } -} - -// assignComments attaches comments to nearby syntax. -func (in *input) assignComments() { - const debug = false - - // Generate preorder and postorder lists. - in.order(in.file) - - // Split into whole-line comments and suffix comments. - var line, suffix []Comment - for _, com := range in.comments { - if com.Suffix { - suffix = append(suffix, com) - } else { - line = append(line, com) - } - } - - if debug { - for _, c := range line { - fmt.Fprintf(os.Stderr, "LINE %q :%d:%d #%d\n", c.Token, c.Start.Line, c.Start.LineRune, c.Start.Byte) - } - } - - // Assign line comments to syntax immediately following. - for _, x := range in.pre { - start, _ := x.Span() - if debug { - fmt.Printf("pre %T :%d:%d #%d\n", x, start.Line, start.LineRune, start.Byte) - } - xcom := x.Comment() - for len(line) > 0 && start.Byte >= line[0].Start.Byte { - if debug { - fmt.Fprintf(os.Stderr, "ASSIGN LINE %q #%d\n", line[0].Token, line[0].Start.Byte) - } - xcom.Before = append(xcom.Before, line[0]) - line = line[1:] - } - } - - // Remaining line comments go at end of file. - in.file.After = append(in.file.After, line...) - - if debug { - for _, c := range suffix { - fmt.Fprintf(os.Stderr, "SUFFIX %q :%d:%d #%d\n", c.Token, c.Start.Line, c.Start.LineRune, c.Start.Byte) - } - } - - // Assign suffix comments to syntax immediately before. - for i := len(in.post) - 1; i >= 0; i-- { - x := in.post[i] - - start, end := x.Span() - if debug { - fmt.Printf("post %T :%d:%d #%d :%d:%d #%d\n", x, start.Line, start.LineRune, start.Byte, end.Line, end.LineRune, end.Byte) - } - - // Do not assign suffix comments to end of line block or whole file. - // Instead assign them to the last element inside. - switch x.(type) { - case *FileSyntax: - continue - } - - // Do not assign suffix comments to something that starts - // on an earlier line, so that in - // - // x ( y - // z ) // comment - // - // we assign the comment to z and not to x ( ... ). - if start.Line != end.Line { - continue - } - xcom := x.Comment() - for len(suffix) > 0 && end.Byte <= suffix[len(suffix)-1].Start.Byte { - if debug { - fmt.Fprintf(os.Stderr, "ASSIGN SUFFIX %q #%d\n", suffix[len(suffix)-1].Token, suffix[len(suffix)-1].Start.Byte) - } - xcom.Suffix = append(xcom.Suffix, suffix[len(suffix)-1]) - suffix = suffix[:len(suffix)-1] - } - } - - // We assigned suffix comments in reverse. - // If multiple suffix comments were appended to the same - // expression node, they are now in reverse. Fix that. - for _, x := range in.post { - reverseComments(x.Comment().Suffix) - } - - // Remaining suffix comments go at beginning of file. - in.file.Before = append(in.file.Before, suffix...) -} - -// reverseComments reverses the []Comment list. -func reverseComments(list []Comment) { - for i, j := 0, len(list)-1; i < j; i, j = i+1, j-1 { - list[i], list[j] = list[j], list[i] - } -} - -func (in *input) parseFile() { - in.file = new(FileSyntax) - var sym symType - var cb *CommentBlock - for { - tok := in.lex(&sym) - switch tok { - case '\n': - if cb != nil { - in.file.Stmt = append(in.file.Stmt, cb) - cb = nil - } - case _COMMENT: - if cb == nil { - cb = &CommentBlock{Start: sym.pos} - } - com := cb.Comment() - com.Before = append(com.Before, Comment{Start: sym.pos, Token: sym.text}) - case _EOF: - if cb != nil { - in.file.Stmt = append(in.file.Stmt, cb) - } - return - default: - in.parseStmt(&sym) - if cb != nil { - in.file.Stmt[len(in.file.Stmt)-1].Comment().Before = cb.Before - cb = nil - } - } - } -} - -func (in *input) parseStmt(sym *symType) { - start := sym.pos - end := sym.endPos - token := []string{sym.text} - for { - tok := in.lex(sym) - switch tok { - case '\n', _EOF, _EOL: - in.file.Stmt = append(in.file.Stmt, &Line{ - Start: start, - Token: token, - End: end, - }) - return - case '(': - in.file.Stmt = append(in.file.Stmt, in.parseLineBlock(start, token, sym)) - return - default: - token = append(token, sym.text) - end = sym.endPos - } - } -} - -func (in *input) parseLineBlock(start Position, token []string, sym *symType) *LineBlock { - x := &LineBlock{ - Start: start, - Token: token, - LParen: LParen{Pos: sym.pos}, - } - var comments []Comment - for { - tok := in.lex(sym) - switch tok { - case _EOL: - // ignore - case '\n': - if len(comments) == 0 && len(x.Line) > 0 || len(comments) > 0 && comments[len(comments)-1].Token != "" { - comments = append(comments, Comment{}) - } - case _COMMENT: - comments = append(comments, Comment{Start: sym.pos, Token: sym.text}) - case _EOF: - in.Error(fmt.Sprintf("syntax error (unterminated block started at %s:%d:%d)", in.filename, x.Start.Line, x.Start.LineRune)) - case ')': - x.RParen.Before = comments - x.RParen.Pos = sym.pos - tok = in.lex(sym) - if tok != '\n' && tok != _EOF && tok != _EOL { - in.Error("syntax error (expected newline after closing paren)") - } - return x - default: - l := in.parseLine(sym) - x.Line = append(x.Line, l) - l.Comment().Before = comments - comments = nil - } - } -} - -func (in *input) parseLine(sym *symType) *Line { - start := sym.pos - end := sym.endPos - token := []string{sym.text} - for { - tok := in.lex(sym) - switch tok { - case '\n', _EOF, _EOL: - return &Line{ - Start: start, - Token: token, - End: end, - InBlock: true, - } - default: - token = append(token, sym.text) - end = sym.endPos - } - } -} - -const ( - _EOF = -(1 + iota) - _EOL - _IDENT - _STRING - _COMMENT -) - -var ( - slashSlash = []byte("//") - moduleStr = []byte("module") -) - -// ModulePath returns the module path from the gomod file text. -// If it cannot find a module path, it returns an empty string. -// It is tolerant of unrelated problems in the go.mod file. -func ModulePath(mod []byte) string { - for len(mod) > 0 { - line := mod - mod = nil - if i := bytes.IndexByte(line, '\n'); i >= 0 { - line, mod = line[:i], line[i+1:] - } - if i := bytes.Index(line, slashSlash); i >= 0 { - line = line[:i] - } - line = bytes.TrimSpace(line) - if !bytes.HasPrefix(line, moduleStr) { - continue - } - line = line[len(moduleStr):] - n := len(line) - line = bytes.TrimSpace(line) - if len(line) == n || len(line) == 0 { - continue - } - - if line[0] == '"' || line[0] == '`' { - p, err := strconv.Unquote(string(line)) - if err != nil { - return "" // malformed quoted string or multiline module path - } - return p - } - - return string(line) - } - return "" // missing module path -} diff --git a/vendor/github.com/rogpeppe/go-internal/modfile/rule.go b/vendor/github.com/rogpeppe/go-internal/modfile/rule.go deleted file mode 100644 index 24d275f12f2..00000000000 --- a/vendor/github.com/rogpeppe/go-internal/modfile/rule.go +++ /dev/null @@ -1,724 +0,0 @@ -// Copyright 2018 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. - -package modfile - -import ( - "bytes" - "errors" - "fmt" - "path/filepath" - "regexp" - "sort" - "strconv" - "strings" - "unicode" - - "github.com/rogpeppe/go-internal/module" - "github.com/rogpeppe/go-internal/semver" -) - -// A File is the parsed, interpreted form of a go.mod file. -type File struct { - Module *Module - Go *Go - Require []*Require - Exclude []*Exclude - Replace []*Replace - - Syntax *FileSyntax -} - -// A Module is the module statement. -type Module struct { - Mod module.Version - Syntax *Line -} - -// A Go is the go statement. -type Go struct { - Version string // "1.23" - Syntax *Line -} - -// A Require is a single require statement. -type Require struct { - Mod module.Version - Indirect bool // has "// indirect" comment - Syntax *Line -} - -// An Exclude is a single exclude statement. -type Exclude struct { - Mod module.Version - Syntax *Line -} - -// A Replace is a single replace statement. -type Replace struct { - Old module.Version - New module.Version - Syntax *Line -} - -func (f *File) AddModuleStmt(path string) error { - if f.Syntax == nil { - f.Syntax = new(FileSyntax) - } - if f.Module == nil { - f.Module = &Module{ - Mod: module.Version{Path: path}, - Syntax: f.Syntax.addLine(nil, "module", AutoQuote(path)), - } - } else { - f.Module.Mod.Path = path - f.Syntax.updateLine(f.Module.Syntax, "module", AutoQuote(path)) - } - return nil -} - -func (f *File) AddComment(text string) { - if f.Syntax == nil { - f.Syntax = new(FileSyntax) - } - f.Syntax.Stmt = append(f.Syntax.Stmt, &CommentBlock{ - Comments: Comments{ - Before: []Comment{ - { - Token: text, - }, - }, - }, - }) -} - -type VersionFixer func(path, version string) (string, error) - -// Parse parses the data, reported in errors as being from file, -// into a File struct. It applies fix, if non-nil, to canonicalize all module versions found. -func Parse(file string, data []byte, fix VersionFixer) (*File, error) { - return parseToFile(file, data, fix, true) -} - -// ParseLax is like Parse but ignores unknown statements. -// It is used when parsing go.mod files other than the main module, -// under the theory that most statement types we add in the future will -// only apply in the main module, like exclude and replace, -// and so we get better gradual deployments if old go commands -// simply ignore those statements when found in go.mod files -// in dependencies. -func ParseLax(file string, data []byte, fix VersionFixer) (*File, error) { - return parseToFile(file, data, fix, false) -} - -func parseToFile(file string, data []byte, fix VersionFixer, strict bool) (*File, error) { - fs, err := parse(file, data) - if err != nil { - return nil, err - } - f := &File{ - Syntax: fs, - } - - var errs bytes.Buffer - for _, x := range fs.Stmt { - switch x := x.(type) { - case *Line: - f.add(&errs, x, x.Token[0], x.Token[1:], fix, strict) - - case *LineBlock: - if len(x.Token) > 1 { - if strict { - fmt.Fprintf(&errs, "%s:%d: unknown block type: %s\n", file, x.Start.Line, strings.Join(x.Token, " ")) - } - continue - } - switch x.Token[0] { - default: - if strict { - fmt.Fprintf(&errs, "%s:%d: unknown block type: %s\n", file, x.Start.Line, strings.Join(x.Token, " ")) - } - continue - case "module", "require", "exclude", "replace": - for _, l := range x.Line { - f.add(&errs, l, x.Token[0], l.Token, fix, strict) - } - } - } - } - - if errs.Len() > 0 { - return nil, errors.New(strings.TrimRight(errs.String(), "\n")) - } - return f, nil -} - -var goVersionRE = regexp.MustCompile(`([1-9][0-9]*)\.(0|[1-9][0-9]*)`) - -func (f *File) add(errs *bytes.Buffer, line *Line, verb string, args []string, fix VersionFixer, strict bool) { - // If strict is false, this module is a dependency. - // We ignore all unknown directives as well as main-module-only - // directives like replace and exclude. It will work better for - // forward compatibility if we can depend on modules that have unknown - // statements (presumed relevant only when acting as the main module) - // and simply ignore those statements. - if !strict { - switch verb { - case "module", "require", "go": - // want these even for dependency go.mods - default: - return - } - } - - switch verb { - default: - fmt.Fprintf(errs, "%s:%d: unknown directive: %s\n", f.Syntax.Name, line.Start.Line, verb) - - case "go": - if f.Go != nil { - fmt.Fprintf(errs, "%s:%d: repeated go statement\n", f.Syntax.Name, line.Start.Line) - return - } - if len(args) != 1 || !goVersionRE.MatchString(args[0]) { - fmt.Fprintf(errs, "%s:%d: usage: go 1.23\n", f.Syntax.Name, line.Start.Line) - return - } - f.Go = &Go{Syntax: line} - f.Go.Version = args[0] - case "module": - if f.Module != nil { - fmt.Fprintf(errs, "%s:%d: repeated module statement\n", f.Syntax.Name, line.Start.Line) - return - } - f.Module = &Module{Syntax: line} - if len(args) != 1 { - - fmt.Fprintf(errs, "%s:%d: usage: module module/path [version]\n", f.Syntax.Name, line.Start.Line) - return - } - s, err := parseString(&args[0]) - if err != nil { - fmt.Fprintf(errs, "%s:%d: invalid quoted string: %v\n", f.Syntax.Name, line.Start.Line, err) - return - } - f.Module.Mod = module.Version{Path: s} - case "require", "exclude": - if len(args) != 2 { - fmt.Fprintf(errs, "%s:%d: usage: %s module/path v1.2.3\n", f.Syntax.Name, line.Start.Line, verb) - return - } - s, err := parseString(&args[0]) - if err != nil { - fmt.Fprintf(errs, "%s:%d: invalid quoted string: %v\n", f.Syntax.Name, line.Start.Line, err) - return - } - old := args[1] - v, err := parseVersion(s, &args[1], fix) - if err != nil { - fmt.Fprintf(errs, "%s:%d: invalid module version %q: %v\n", f.Syntax.Name, line.Start.Line, old, err) - return - } - pathMajor, err := modulePathMajor(s) - if err != nil { - fmt.Fprintf(errs, "%s:%d: %v\n", f.Syntax.Name, line.Start.Line, err) - return - } - if !module.MatchPathMajor(v, pathMajor) { - if pathMajor == "" { - pathMajor = "v0 or v1" - } - fmt.Fprintf(errs, "%s:%d: invalid module: %s should be %s, not %s (%s)\n", f.Syntax.Name, line.Start.Line, s, pathMajor, semver.Major(v), v) - return - } - if verb == "require" { - f.Require = append(f.Require, &Require{ - Mod: module.Version{Path: s, Version: v}, - Syntax: line, - Indirect: isIndirect(line), - }) - } else { - f.Exclude = append(f.Exclude, &Exclude{ - Mod: module.Version{Path: s, Version: v}, - Syntax: line, - }) - } - case "replace": - arrow := 2 - if len(args) >= 2 && args[1] == "=>" { - arrow = 1 - } - if len(args) < arrow+2 || len(args) > arrow+3 || args[arrow] != "=>" { - fmt.Fprintf(errs, "%s:%d: usage: %s module/path [v1.2.3] => other/module v1.4\n\t or %s module/path [v1.2.3] => ../local/directory\n", f.Syntax.Name, line.Start.Line, verb, verb) - return - } - s, err := parseString(&args[0]) - if err != nil { - fmt.Fprintf(errs, "%s:%d: invalid quoted string: %v\n", f.Syntax.Name, line.Start.Line, err) - return - } - pathMajor, err := modulePathMajor(s) - if err != nil { - fmt.Fprintf(errs, "%s:%d: %v\n", f.Syntax.Name, line.Start.Line, err) - return - } - var v string - if arrow == 2 { - old := args[1] - v, err = parseVersion(s, &args[1], fix) - if err != nil { - fmt.Fprintf(errs, "%s:%d: invalid module version %v: %v\n", f.Syntax.Name, line.Start.Line, old, err) - return - } - if !module.MatchPathMajor(v, pathMajor) { - if pathMajor == "" { - pathMajor = "v0 or v1" - } - fmt.Fprintf(errs, "%s:%d: invalid module: %s should be %s, not %s (%s)\n", f.Syntax.Name, line.Start.Line, s, pathMajor, semver.Major(v), v) - return - } - } - ns, err := parseString(&args[arrow+1]) - if err != nil { - fmt.Fprintf(errs, "%s:%d: invalid quoted string: %v\n", f.Syntax.Name, line.Start.Line, err) - return - } - nv := "" - if len(args) == arrow+2 { - if !IsDirectoryPath(ns) { - fmt.Fprintf(errs, "%s:%d: replacement module without version must be directory path (rooted or starting with ./ or ../)\n", f.Syntax.Name, line.Start.Line) - return - } - if filepath.Separator == '/' && strings.Contains(ns, `\`) { - fmt.Fprintf(errs, "%s:%d: replacement directory appears to be Windows path (on a non-windows system)\n", f.Syntax.Name, line.Start.Line) - return - } - } - if len(args) == arrow+3 { - old := args[arrow+1] - nv, err = parseVersion(ns, &args[arrow+2], fix) - if err != nil { - fmt.Fprintf(errs, "%s:%d: invalid module version %v: %v\n", f.Syntax.Name, line.Start.Line, old, err) - return - } - if IsDirectoryPath(ns) { - fmt.Fprintf(errs, "%s:%d: replacement module directory path %q cannot have version\n", f.Syntax.Name, line.Start.Line, ns) - return - } - } - f.Replace = append(f.Replace, &Replace{ - Old: module.Version{Path: s, Version: v}, - New: module.Version{Path: ns, Version: nv}, - Syntax: line, - }) - } -} - -// isIndirect reports whether line has a "// indirect" comment, -// meaning it is in go.mod only for its effect on indirect dependencies, -// so that it can be dropped entirely once the effective version of the -// indirect dependency reaches the given minimum version. -func isIndirect(line *Line) bool { - if len(line.Suffix) == 0 { - return false - } - f := strings.Fields(line.Suffix[0].Token) - return (len(f) == 2 && f[1] == "indirect" || len(f) > 2 && f[1] == "indirect;") && f[0] == "//" -} - -// setIndirect sets line to have (or not have) a "// indirect" comment. -func setIndirect(line *Line, indirect bool) { - if isIndirect(line) == indirect { - return - } - if indirect { - // Adding comment. - if len(line.Suffix) == 0 { - // New comment. - line.Suffix = []Comment{{Token: "// indirect", Suffix: true}} - return - } - // Insert at beginning of existing comment. - com := &line.Suffix[0] - space := " " - if len(com.Token) > 2 && com.Token[2] == ' ' || com.Token[2] == '\t' { - space = "" - } - com.Token = "// indirect;" + space + com.Token[2:] - return - } - - // Removing comment. - f := strings.Fields(line.Suffix[0].Token) - if len(f) == 2 { - // Remove whole comment. - line.Suffix = nil - return - } - - // Remove comment prefix. - com := &line.Suffix[0] - i := strings.Index(com.Token, "indirect;") - com.Token = "//" + com.Token[i+len("indirect;"):] -} - -// IsDirectoryPath reports whether the given path should be interpreted -// as a directory path. Just like on the go command line, relative paths -// and rooted paths are directory paths; the rest are module paths. -func IsDirectoryPath(ns string) bool { - // Because go.mod files can move from one system to another, - // we check all known path syntaxes, both Unix and Windows. - return strings.HasPrefix(ns, "./") || strings.HasPrefix(ns, "../") || strings.HasPrefix(ns, "/") || - strings.HasPrefix(ns, `.\`) || strings.HasPrefix(ns, `..\`) || strings.HasPrefix(ns, `\`) || - len(ns) >= 2 && ('A' <= ns[0] && ns[0] <= 'Z' || 'a' <= ns[0] && ns[0] <= 'z') && ns[1] == ':' -} - -// MustQuote reports whether s must be quoted in order to appear as -// a single token in a go.mod line. -func MustQuote(s string) bool { - for _, r := range s { - if !unicode.IsPrint(r) || r == ' ' || r == '"' || r == '\'' || r == '`' { - return true - } - } - return s == "" || strings.Contains(s, "//") || strings.Contains(s, "/*") -} - -// AutoQuote returns s or, if quoting is required for s to appear in a go.mod, -// the quotation of s. -func AutoQuote(s string) string { - if MustQuote(s) { - return strconv.Quote(s) - } - return s -} - -func parseString(s *string) (string, error) { - t := *s - if strings.HasPrefix(t, `"`) { - var err error - if t, err = strconv.Unquote(t); err != nil { - return "", err - } - } else if strings.ContainsAny(t, "\"'`") { - // Other quotes are reserved both for possible future expansion - // and to avoid confusion. For example if someone types 'x' - // we want that to be a syntax error and not a literal x in literal quotation marks. - return "", fmt.Errorf("unquoted string cannot contain quote") - } - *s = AutoQuote(t) - return t, nil -} - -func parseVersion(path string, s *string, fix VersionFixer) (string, error) { - t, err := parseString(s) - if err != nil { - return "", err - } - if fix != nil { - var err error - t, err = fix(path, t) - if err != nil { - return "", err - } - } - if v := module.CanonicalVersion(t); v != "" { - *s = v - return *s, nil - } - return "", fmt.Errorf("version must be of the form v1.2.3") -} - -func modulePathMajor(path string) (string, error) { - _, major, ok := module.SplitPathVersion(path) - if !ok { - return "", fmt.Errorf("invalid module path") - } - return major, nil -} - -func (f *File) Format() ([]byte, error) { - return Format(f.Syntax), nil -} - -// Cleanup cleans up the file f after any edit operations. -// To avoid quadratic behavior, modifications like DropRequire -// clear the entry but do not remove it from the slice. -// Cleanup cleans out all the cleared entries. -func (f *File) Cleanup() { - w := 0 - for _, r := range f.Require { - if r.Mod.Path != "" { - f.Require[w] = r - w++ - } - } - f.Require = f.Require[:w] - - w = 0 - for _, x := range f.Exclude { - if x.Mod.Path != "" { - f.Exclude[w] = x - w++ - } - } - f.Exclude = f.Exclude[:w] - - w = 0 - for _, r := range f.Replace { - if r.Old.Path != "" { - f.Replace[w] = r - w++ - } - } - f.Replace = f.Replace[:w] - - f.Syntax.Cleanup() -} - -func (f *File) AddRequire(path, vers string) error { - need := true - for _, r := range f.Require { - if r.Mod.Path == path { - if need { - r.Mod.Version = vers - f.Syntax.updateLine(r.Syntax, "require", AutoQuote(path), vers) - need = false - } else { - f.Syntax.removeLine(r.Syntax) - *r = Require{} - } - } - } - - if need { - f.AddNewRequire(path, vers, false) - } - return nil -} - -func (f *File) AddNewRequire(path, vers string, indirect bool) { - line := f.Syntax.addLine(nil, "require", AutoQuote(path), vers) - setIndirect(line, indirect) - f.Require = append(f.Require, &Require{module.Version{Path: path, Version: vers}, indirect, line}) -} - -func (f *File) SetRequire(req []*Require) { - need := make(map[string]string) - indirect := make(map[string]bool) - for _, r := range req { - need[r.Mod.Path] = r.Mod.Version - indirect[r.Mod.Path] = r.Indirect - } - - for _, r := range f.Require { - if v, ok := need[r.Mod.Path]; ok { - r.Mod.Version = v - r.Indirect = indirect[r.Mod.Path] - } - } - - var newStmts []Expr - for _, stmt := range f.Syntax.Stmt { - switch stmt := stmt.(type) { - case *LineBlock: - if len(stmt.Token) > 0 && stmt.Token[0] == "require" { - var newLines []*Line - for _, line := range stmt.Line { - if p, err := parseString(&line.Token[0]); err == nil && need[p] != "" { - line.Token[1] = need[p] - delete(need, p) - setIndirect(line, indirect[p]) - newLines = append(newLines, line) - } - } - if len(newLines) == 0 { - continue // drop stmt - } - stmt.Line = newLines - } - - case *Line: - if len(stmt.Token) > 0 && stmt.Token[0] == "require" { - if p, err := parseString(&stmt.Token[1]); err == nil && need[p] != "" { - stmt.Token[2] = need[p] - delete(need, p) - setIndirect(stmt, indirect[p]) - } else { - continue // drop stmt - } - } - } - newStmts = append(newStmts, stmt) - } - f.Syntax.Stmt = newStmts - - for path, vers := range need { - f.AddNewRequire(path, vers, indirect[path]) - } - f.SortBlocks() -} - -func (f *File) DropRequire(path string) error { - for _, r := range f.Require { - if r.Mod.Path == path { - f.Syntax.removeLine(r.Syntax) - *r = Require{} - } - } - return nil -} - -func (f *File) AddExclude(path, vers string) error { - var hint *Line - for _, x := range f.Exclude { - if x.Mod.Path == path && x.Mod.Version == vers { - return nil - } - if x.Mod.Path == path { - hint = x.Syntax - } - } - - f.Exclude = append(f.Exclude, &Exclude{Mod: module.Version{Path: path, Version: vers}, Syntax: f.Syntax.addLine(hint, "exclude", AutoQuote(path), vers)}) - return nil -} - -func (f *File) DropExclude(path, vers string) error { - for _, x := range f.Exclude { - if x.Mod.Path == path && x.Mod.Version == vers { - f.Syntax.removeLine(x.Syntax) - *x = Exclude{} - } - } - return nil -} - -func (f *File) AddReplace(oldPath, oldVers, newPath, newVers string) error { - need := true - old := module.Version{Path: oldPath, Version: oldVers} - new := module.Version{Path: newPath, Version: newVers} - tokens := []string{"replace", AutoQuote(oldPath)} - if oldVers != "" { - tokens = append(tokens, oldVers) - } - tokens = append(tokens, "=>", AutoQuote(newPath)) - if newVers != "" { - tokens = append(tokens, newVers) - } - - var hint *Line - for _, r := range f.Replace { - if r.Old.Path == oldPath && (oldVers == "" || r.Old.Version == oldVers) { - if need { - // Found replacement for old; update to use new. - r.New = new - f.Syntax.updateLine(r.Syntax, tokens...) - need = false - continue - } - // Already added; delete other replacements for same. - f.Syntax.removeLine(r.Syntax) - *r = Replace{} - } - if r.Old.Path == oldPath { - hint = r.Syntax - } - } - if need { - f.Replace = append(f.Replace, &Replace{Old: old, New: new, Syntax: f.Syntax.addLine(hint, tokens...)}) - } - return nil -} - -func (f *File) DropReplace(oldPath, oldVers string) error { - for _, r := range f.Replace { - if r.Old.Path == oldPath && r.Old.Version == oldVers { - f.Syntax.removeLine(r.Syntax) - *r = Replace{} - } - } - return nil -} - -func (f *File) SortBlocks() { - f.removeDups() // otherwise sorting is unsafe - - for _, stmt := range f.Syntax.Stmt { - block, ok := stmt.(*LineBlock) - if !ok { - continue - } - sort.Slice(block.Line, func(i, j int) bool { - li := block.Line[i] - lj := block.Line[j] - for k := 0; k < len(li.Token) && k < len(lj.Token); k++ { - if li.Token[k] != lj.Token[k] { - return li.Token[k] < lj.Token[k] - } - } - return len(li.Token) < len(lj.Token) - }) - } -} - -func (f *File) removeDups() { - have := make(map[module.Version]bool) - kill := make(map[*Line]bool) - for _, x := range f.Exclude { - if have[x.Mod] { - kill[x.Syntax] = true - continue - } - have[x.Mod] = true - } - var excl []*Exclude - for _, x := range f.Exclude { - if !kill[x.Syntax] { - excl = append(excl, x) - } - } - f.Exclude = excl - - have = make(map[module.Version]bool) - // Later replacements take priority over earlier ones. - for i := len(f.Replace) - 1; i >= 0; i-- { - x := f.Replace[i] - if have[x.Old] { - kill[x.Syntax] = true - continue - } - have[x.Old] = true - } - var repl []*Replace - for _, x := range f.Replace { - if !kill[x.Syntax] { - repl = append(repl, x) - } - } - f.Replace = repl - - var stmts []Expr - for _, stmt := range f.Syntax.Stmt { - switch stmt := stmt.(type) { - case *Line: - if kill[stmt] { - continue - } - case *LineBlock: - var lines []*Line - for _, line := range stmt.Line { - if !kill[line] { - lines = append(lines, line) - } - } - stmt.Line = lines - if len(lines) == 0 { - continue - } - } - stmts = append(stmts, stmt) - } - f.Syntax.Stmt = stmts -} diff --git a/vendor/github.com/rogpeppe/go-internal/module/module.go b/vendor/github.com/rogpeppe/go-internal/module/module.go deleted file mode 100644 index 3ff6d9bf535..00000000000 --- a/vendor/github.com/rogpeppe/go-internal/module/module.go +++ /dev/null @@ -1,540 +0,0 @@ -// Copyright 2018 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. - -// Package module defines the module.Version type -// along with support code. -package module - -// IMPORTANT NOTE -// -// This file essentially defines the set of valid import paths for the go command. -// There are many subtle considerations, including Unicode ambiguity, -// security, network, and file system representations. -// -// This file also defines the set of valid module path and version combinations, -// another topic with many subtle considerations. -// -// Changes to the semantics in this file require approval from rsc. - -import ( - "fmt" - "sort" - "strings" - "unicode" - "unicode/utf8" - - "github.com/rogpeppe/go-internal/semver" -) - -// A Version is defined by a module path and version pair. -type Version struct { - Path string - - // Version is usually a semantic version in canonical form. - // There are two exceptions to this general rule. - // First, the top-level target of a build has no specific version - // and uses Version = "". - // Second, during MVS calculations the version "none" is used - // to represent the decision to take no version of a given module. - Version string `json:",omitempty"` -} - -// Check checks that a given module path, version pair is valid. -// In addition to the path being a valid module path -// and the version being a valid semantic version, -// the two must correspond. -// For example, the path "yaml/v2" only corresponds to -// semantic versions beginning with "v2.". -func Check(path, version string) error { - if err := CheckPath(path); err != nil { - return err - } - if !semver.IsValid(version) { - return fmt.Errorf("malformed semantic version %v", version) - } - _, pathMajor, _ := SplitPathVersion(path) - if !MatchPathMajor(version, pathMajor) { - if pathMajor == "" { - pathMajor = "v0 or v1" - } - if pathMajor[0] == '.' { // .v1 - pathMajor = pathMajor[1:] - } - return fmt.Errorf("mismatched module path %v and version %v (want %v)", path, version, pathMajor) - } - return nil -} - -// firstPathOK reports whether r can appear in the first element of a module path. -// The first element of the path must be an LDH domain name, at least for now. -// To avoid case ambiguity, the domain name must be entirely lower case. -func firstPathOK(r rune) bool { - return r == '-' || r == '.' || - '0' <= r && r <= '9' || - 'a' <= r && r <= 'z' -} - -// pathOK reports whether r can appear in an import path element. -// Paths can be ASCII letters, ASCII digits, and limited ASCII punctuation: + - . _ and ~. -// This matches what "go get" has historically recognized in import paths. -// TODO(rsc): We would like to allow Unicode letters, but that requires additional -// care in the safe encoding (see note below). -func pathOK(r rune) bool { - if r < utf8.RuneSelf { - return r == '+' || r == '-' || r == '.' || r == '_' || r == '~' || - '0' <= r && r <= '9' || - 'A' <= r && r <= 'Z' || - 'a' <= r && r <= 'z' - } - return false -} - -// fileNameOK reports whether r can appear in a file name. -// For now we allow all Unicode letters but otherwise limit to pathOK plus a few more punctuation characters. -// If we expand the set of allowed characters here, we have to -// work harder at detecting potential case-folding and normalization collisions. -// See note about "safe encoding" below. -func fileNameOK(r rune) bool { - if r < utf8.RuneSelf { - // Entire set of ASCII punctuation, from which we remove characters: - // ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ - // We disallow some shell special characters: " ' * < > ? ` | - // (Note that some of those are disallowed by the Windows file system as well.) - // We also disallow path separators / : and \ (fileNameOK is only called on path element characters). - // We allow spaces (U+0020) in file names. - const allowed = "!#$%&()+,-.=@[]^_{}~ " - if '0' <= r && r <= '9' || 'A' <= r && r <= 'Z' || 'a' <= r && r <= 'z' { - return true - } - for i := 0; i < len(allowed); i++ { - if rune(allowed[i]) == r { - return true - } - } - return false - } - // It may be OK to add more ASCII punctuation here, but only carefully. - // For example Windows disallows < > \, and macOS disallows :, so we must not allow those. - return unicode.IsLetter(r) -} - -// CheckPath checks that a module path is valid. -func CheckPath(path string) error { - if err := checkPath(path, false); err != nil { - return fmt.Errorf("malformed module path %q: %v", path, err) - } - i := strings.Index(path, "/") - if i < 0 { - i = len(path) - } - if i == 0 { - return fmt.Errorf("malformed module path %q: leading slash", path) - } - if !strings.Contains(path[:i], ".") { - return fmt.Errorf("malformed module path %q: missing dot in first path element", path) - } - if path[0] == '-' { - return fmt.Errorf("malformed module path %q: leading dash in first path element", path) - } - for _, r := range path[:i] { - if !firstPathOK(r) { - return fmt.Errorf("malformed module path %q: invalid char %q in first path element", path, r) - } - } - if _, _, ok := SplitPathVersion(path); !ok { - return fmt.Errorf("malformed module path %q: invalid version", path) - } - return nil -} - -// CheckImportPath checks that an import path is valid. -func CheckImportPath(path string) error { - if err := checkPath(path, false); err != nil { - return fmt.Errorf("malformed import path %q: %v", path, err) - } - return nil -} - -// checkPath checks that a general path is valid. -// It returns an error describing why but not mentioning path. -// Because these checks apply to both module paths and import paths, -// the caller is expected to add the "malformed ___ path %q: " prefix. -// fileName indicates whether the final element of the path is a file name -// (as opposed to a directory name). -func checkPath(path string, fileName bool) error { - if !utf8.ValidString(path) { - return fmt.Errorf("invalid UTF-8") - } - if path == "" { - return fmt.Errorf("empty string") - } - if strings.Contains(path, "..") { - return fmt.Errorf("double dot") - } - if strings.Contains(path, "//") { - return fmt.Errorf("double slash") - } - if path[len(path)-1] == '/' { - return fmt.Errorf("trailing slash") - } - elemStart := 0 - for i, r := range path { - if r == '/' { - if err := checkElem(path[elemStart:i], fileName); err != nil { - return err - } - elemStart = i + 1 - } - } - if err := checkElem(path[elemStart:], fileName); err != nil { - return err - } - return nil -} - -// checkElem checks whether an individual path element is valid. -// fileName indicates whether the element is a file name (not a directory name). -func checkElem(elem string, fileName bool) error { - if elem == "" { - return fmt.Errorf("empty path element") - } - if strings.Count(elem, ".") == len(elem) { - return fmt.Errorf("invalid path element %q", elem) - } - if elem[0] == '.' && !fileName { - return fmt.Errorf("leading dot in path element") - } - if elem[len(elem)-1] == '.' { - return fmt.Errorf("trailing dot in path element") - } - charOK := pathOK - if fileName { - charOK = fileNameOK - } - for _, r := range elem { - if !charOK(r) { - return fmt.Errorf("invalid char %q", r) - } - } - - // Windows disallows a bunch of path elements, sadly. - // See https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file - short := elem - if i := strings.Index(short, "."); i >= 0 { - short = short[:i] - } - for _, bad := range badWindowsNames { - if strings.EqualFold(bad, short) { - return fmt.Errorf("disallowed path element %q", elem) - } - } - return nil -} - -// CheckFilePath checks whether a slash-separated file path is valid. -func CheckFilePath(path string) error { - if err := checkPath(path, true); err != nil { - return fmt.Errorf("malformed file path %q: %v", path, err) - } - return nil -} - -// badWindowsNames are the reserved file path elements on Windows. -// See https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file -var badWindowsNames = []string{ - "CON", - "PRN", - "AUX", - "NUL", - "COM1", - "COM2", - "COM3", - "COM4", - "COM5", - "COM6", - "COM7", - "COM8", - "COM9", - "LPT1", - "LPT2", - "LPT3", - "LPT4", - "LPT5", - "LPT6", - "LPT7", - "LPT8", - "LPT9", -} - -// SplitPathVersion returns prefix and major version such that prefix+pathMajor == path -// and version is either empty or "/vN" for N >= 2. -// As a special case, gopkg.in paths are recognized directly; -// they require ".vN" instead of "/vN", and for all N, not just N >= 2. -func SplitPathVersion(path string) (prefix, pathMajor string, ok bool) { - if strings.HasPrefix(path, "gopkg.in/") { - return splitGopkgIn(path) - } - - i := len(path) - dot := false - for i > 0 && ('0' <= path[i-1] && path[i-1] <= '9' || path[i-1] == '.') { - if path[i-1] == '.' { - dot = true - } - i-- - } - if i <= 1 || path[i-1] != 'v' || path[i-2] != '/' { - return path, "", true - } - prefix, pathMajor = path[:i-2], path[i-2:] - if dot || len(pathMajor) <= 2 || pathMajor[2] == '0' || pathMajor == "/v1" { - return path, "", false - } - return prefix, pathMajor, true -} - -// splitGopkgIn is like SplitPathVersion but only for gopkg.in paths. -func splitGopkgIn(path string) (prefix, pathMajor string, ok bool) { - if !strings.HasPrefix(path, "gopkg.in/") { - return path, "", false - } - i := len(path) - if strings.HasSuffix(path, "-unstable") { - i -= len("-unstable") - } - for i > 0 && ('0' <= path[i-1] && path[i-1] <= '9') { - i-- - } - if i <= 1 || path[i-1] != 'v' || path[i-2] != '.' { - // All gopkg.in paths must end in vN for some N. - return path, "", false - } - prefix, pathMajor = path[:i-2], path[i-2:] - if len(pathMajor) <= 2 || pathMajor[2] == '0' && pathMajor != ".v0" { - return path, "", false - } - return prefix, pathMajor, true -} - -// MatchPathMajor reports whether the semantic version v -// matches the path major version pathMajor. -func MatchPathMajor(v, pathMajor string) bool { - if strings.HasPrefix(pathMajor, ".v") && strings.HasSuffix(pathMajor, "-unstable") { - pathMajor = strings.TrimSuffix(pathMajor, "-unstable") - } - if strings.HasPrefix(v, "v0.0.0-") && pathMajor == ".v1" { - // Allow old bug in pseudo-versions that generated v0.0.0- pseudoversion for gopkg .v1. - // For example, gopkg.in/yaml.v2@v2.2.1's go.mod requires gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405. - return true - } - m := semver.Major(v) - if pathMajor == "" { - return m == "v0" || m == "v1" || semver.Build(v) == "+incompatible" - } - return (pathMajor[0] == '/' || pathMajor[0] == '.') && m == pathMajor[1:] -} - -// CanonicalVersion returns the canonical form of the version string v. -// It is the same as semver.Canonical(v) except that it preserves the special build suffix "+incompatible". -func CanonicalVersion(v string) string { - cv := semver.Canonical(v) - if semver.Build(v) == "+incompatible" { - cv += "+incompatible" - } - return cv -} - -// Sort sorts the list by Path, breaking ties by comparing Versions. -func Sort(list []Version) { - sort.Slice(list, func(i, j int) bool { - mi := list[i] - mj := list[j] - if mi.Path != mj.Path { - return mi.Path < mj.Path - } - // To help go.sum formatting, allow version/file. - // Compare semver prefix by semver rules, - // file by string order. - vi := mi.Version - vj := mj.Version - var fi, fj string - if k := strings.Index(vi, "/"); k >= 0 { - vi, fi = vi[:k], vi[k:] - } - if k := strings.Index(vj, "/"); k >= 0 { - vj, fj = vj[:k], vj[k:] - } - if vi != vj { - return semver.Compare(vi, vj) < 0 - } - return fi < fj - }) -} - -// Safe encodings -// -// Module paths appear as substrings of file system paths -// (in the download cache) and of web server URLs in the proxy protocol. -// In general we cannot rely on file systems to be case-sensitive, -// nor can we rely on web servers, since they read from file systems. -// That is, we cannot rely on the file system to keep rsc.io/QUOTE -// and rsc.io/quote separate. Windows and macOS don't. -// Instead, we must never require two different casings of a file path. -// Because we want the download cache to match the proxy protocol, -// and because we want the proxy protocol to be possible to serve -// from a tree of static files (which might be stored on a case-insensitive -// file system), the proxy protocol must never require two different casings -// of a URL path either. -// -// One possibility would be to make the safe encoding be the lowercase -// hexadecimal encoding of the actual path bytes. This would avoid ever -// needing different casings of a file path, but it would be fairly illegible -// to most programmers when those paths appeared in the file system -// (including in file paths in compiler errors and stack traces) -// in web server logs, and so on. Instead, we want a safe encoding that -// leaves most paths unaltered. -// -// The safe encoding is this: -// replace every uppercase letter with an exclamation mark -// followed by the letter's lowercase equivalent. -// -// For example, -// github.com/Azure/azure-sdk-for-go -> github.com/!azure/azure-sdk-for-go. -// github.com/GoogleCloudPlatform/cloudsql-proxy -> github.com/!google!cloud!platform/cloudsql-proxy -// github.com/Sirupsen/logrus -> github.com/!sirupsen/logrus. -// -// Import paths that avoid upper-case letters are left unchanged. -// Note that because import paths are ASCII-only and avoid various -// problematic punctuation (like : < and >), the safe encoding is also ASCII-only -// and avoids the same problematic punctuation. -// -// Import paths have never allowed exclamation marks, so there is no -// need to define how to encode a literal !. -// -// Although paths are disallowed from using Unicode (see pathOK above), -// the eventual plan is to allow Unicode letters as well, to assume that -// file systems and URLs are Unicode-safe (storing UTF-8), and apply -// the !-for-uppercase convention. Note however that not all runes that -// are different but case-fold equivalent are an upper/lower pair. -// For example, U+004B ('K'), U+006B ('k'), and U+212A ('K' for Kelvin) -// are considered to case-fold to each other. When we do add Unicode -// letters, we must not assume that upper/lower are the only case-equivalent pairs. -// Perhaps the Kelvin symbol would be disallowed entirely, for example. -// Or perhaps it would encode as "!!k", or perhaps as "(212A)". -// -// Also, it would be nice to allow Unicode marks as well as letters, -// but marks include combining marks, and then we must deal not -// only with case folding but also normalization: both U+00E9 ('é') -// and U+0065 U+0301 ('e' followed by combining acute accent) -// look the same on the page and are treated by some file systems -// as the same path. If we do allow Unicode marks in paths, there -// must be some kind of normalization to allow only one canonical -// encoding of any character used in an import path. - -// EncodePath returns the safe encoding of the given module path. -// It fails if the module path is invalid. -func EncodePath(path string) (encoding string, err error) { - if err := CheckPath(path); err != nil { - return "", err - } - - return encodeString(path) -} - -// EncodeVersion returns the safe encoding of the given module version. -// Versions are allowed to be in non-semver form but must be valid file names -// and not contain exclamation marks. -func EncodeVersion(v string) (encoding string, err error) { - if err := checkElem(v, true); err != nil || strings.Contains(v, "!") { - return "", fmt.Errorf("disallowed version string %q", v) - } - return encodeString(v) -} - -func encodeString(s string) (encoding string, err error) { - haveUpper := false - for _, r := range s { - if r == '!' || r >= utf8.RuneSelf { - // This should be disallowed by CheckPath, but diagnose anyway. - // The correctness of the encoding loop below depends on it. - return "", fmt.Errorf("internal error: inconsistency in EncodePath") - } - if 'A' <= r && r <= 'Z' { - haveUpper = true - } - } - - if !haveUpper { - return s, nil - } - - var buf []byte - for _, r := range s { - if 'A' <= r && r <= 'Z' { - buf = append(buf, '!', byte(r+'a'-'A')) - } else { - buf = append(buf, byte(r)) - } - } - return string(buf), nil -} - -// DecodePath returns the module path of the given safe encoding. -// It fails if the encoding is invalid or encodes an invalid path. -func DecodePath(encoding string) (path string, err error) { - path, ok := decodeString(encoding) - if !ok { - return "", fmt.Errorf("invalid module path encoding %q", encoding) - } - if err := CheckPath(path); err != nil { - return "", fmt.Errorf("invalid module path encoding %q: %v", encoding, err) - } - return path, nil -} - -// DecodeVersion returns the version string for the given safe encoding. -// It fails if the encoding is invalid or encodes an invalid version. -// Versions are allowed to be in non-semver form but must be valid file names -// and not contain exclamation marks. -func DecodeVersion(encoding string) (v string, err error) { - v, ok := decodeString(encoding) - if !ok { - return "", fmt.Errorf("invalid version encoding %q", encoding) - } - if err := checkElem(v, true); err != nil { - return "", fmt.Errorf("disallowed version string %q", v) - } - return v, nil -} - -func decodeString(encoding string) (string, bool) { - var buf []byte - - bang := false - for _, r := range encoding { - if r >= utf8.RuneSelf { - return "", false - } - if bang { - bang = false - if r < 'a' || 'z' < r { - return "", false - } - buf = append(buf, byte(r+'A'-'a')) - continue - } - if r == '!' { - bang = true - continue - } - if 'A' <= r && r <= 'Z' { - return "", false - } - buf = append(buf, byte(r)) - } - if bang { - return "", false - } - return string(buf), true -} diff --git a/vendor/github.com/rogpeppe/go-internal/semver/semver.go b/vendor/github.com/rogpeppe/go-internal/semver/semver.go deleted file mode 100644 index 4af7118e55d..00000000000 --- a/vendor/github.com/rogpeppe/go-internal/semver/semver.go +++ /dev/null @@ -1,388 +0,0 @@ -// Copyright 2018 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. - -// Package semver implements comparison of semantic version strings. -// In this package, semantic version strings must begin with a leading "v", -// as in "v1.0.0". -// -// The general form of a semantic version string accepted by this package is -// -// vMAJOR[.MINOR[.PATCH[-PRERELEASE][+BUILD]]] -// -// where square brackets indicate optional parts of the syntax; -// MAJOR, MINOR, and PATCH are decimal integers without extra leading zeros; -// PRERELEASE and BUILD are each a series of non-empty dot-separated identifiers -// using only alphanumeric characters and hyphens; and -// all-numeric PRERELEASE identifiers must not have leading zeros. -// -// This package follows Semantic Versioning 2.0.0 (see semver.org) -// with two exceptions. First, it requires the "v" prefix. Second, it recognizes -// vMAJOR and vMAJOR.MINOR (with no prerelease or build suffixes) -// as shorthands for vMAJOR.0.0 and vMAJOR.MINOR.0. -package semver - -// parsed returns the parsed form of a semantic version string. -type parsed struct { - major string - minor string - patch string - short string - prerelease string - build string - err string -} - -// IsValid reports whether v is a valid semantic version string. -func IsValid(v string) bool { - _, ok := parse(v) - return ok -} - -// Canonical returns the canonical formatting of the semantic version v. -// It fills in any missing .MINOR or .PATCH and discards build metadata. -// Two semantic versions compare equal only if their canonical formattings -// are identical strings. -// The canonical invalid semantic version is the empty string. -func Canonical(v string) string { - p, ok := parse(v) - if !ok { - return "" - } - if p.build != "" { - return v[:len(v)-len(p.build)] - } - if p.short != "" { - return v + p.short - } - return v -} - -// Major returns the major version prefix of the semantic version v. -// For example, Major("v2.1.0") == "v2". -// If v is an invalid semantic version string, Major returns the empty string. -func Major(v string) string { - pv, ok := parse(v) - if !ok { - return "" - } - return v[:1+len(pv.major)] -} - -// MajorMinor returns the major.minor version prefix of the semantic version v. -// For example, MajorMinor("v2.1.0") == "v2.1". -// If v is an invalid semantic version string, MajorMinor returns the empty string. -func MajorMinor(v string) string { - pv, ok := parse(v) - if !ok { - return "" - } - i := 1 + len(pv.major) - if j := i + 1 + len(pv.minor); j <= len(v) && v[i] == '.' && v[i+1:j] == pv.minor { - return v[:j] - } - return v[:i] + "." + pv.minor -} - -// Prerelease returns the prerelease suffix of the semantic version v. -// For example, Prerelease("v2.1.0-pre+meta") == "-pre". -// If v is an invalid semantic version string, Prerelease returns the empty string. -func Prerelease(v string) string { - pv, ok := parse(v) - if !ok { - return "" - } - return pv.prerelease -} - -// Build returns the build suffix of the semantic version v. -// For example, Build("v2.1.0+meta") == "+meta". -// If v is an invalid semantic version string, Build returns the empty string. -func Build(v string) string { - pv, ok := parse(v) - if !ok { - return "" - } - return pv.build -} - -// Compare returns an integer comparing two versions according to -// according to semantic version precedence. -// The result will be 0 if v == w, -1 if v < w, or +1 if v > w. -// -// An invalid semantic version string is considered less than a valid one. -// All invalid semantic version strings compare equal to each other. -func Compare(v, w string) int { - pv, ok1 := parse(v) - pw, ok2 := parse(w) - if !ok1 && !ok2 { - return 0 - } - if !ok1 { - return -1 - } - if !ok2 { - return +1 - } - if c := compareInt(pv.major, pw.major); c != 0 { - return c - } - if c := compareInt(pv.minor, pw.minor); c != 0 { - return c - } - if c := compareInt(pv.patch, pw.patch); c != 0 { - return c - } - return comparePrerelease(pv.prerelease, pw.prerelease) -} - -// Max canonicalizes its arguments and then returns the version string -// that compares greater. -func Max(v, w string) string { - v = Canonical(v) - w = Canonical(w) - if Compare(v, w) > 0 { - return v - } - return w -} - -func parse(v string) (p parsed, ok bool) { - if v == "" || v[0] != 'v' { - p.err = "missing v prefix" - return - } - p.major, v, ok = parseInt(v[1:]) - if !ok { - p.err = "bad major version" - return - } - if v == "" { - p.minor = "0" - p.patch = "0" - p.short = ".0.0" - return - } - if v[0] != '.' { - p.err = "bad minor prefix" - ok = false - return - } - p.minor, v, ok = parseInt(v[1:]) - if !ok { - p.err = "bad minor version" - return - } - if v == "" { - p.patch = "0" - p.short = ".0" - return - } - if v[0] != '.' { - p.err = "bad patch prefix" - ok = false - return - } - p.patch, v, ok = parseInt(v[1:]) - if !ok { - p.err = "bad patch version" - return - } - if len(v) > 0 && v[0] == '-' { - p.prerelease, v, ok = parsePrerelease(v) - if !ok { - p.err = "bad prerelease" - return - } - } - if len(v) > 0 && v[0] == '+' { - p.build, v, ok = parseBuild(v) - if !ok { - p.err = "bad build" - return - } - } - if v != "" { - p.err = "junk on end" - ok = false - return - } - ok = true - return -} - -func parseInt(v string) (t, rest string, ok bool) { - if v == "" { - return - } - if v[0] < '0' || '9' < v[0] { - return - } - i := 1 - for i < len(v) && '0' <= v[i] && v[i] <= '9' { - i++ - } - if v[0] == '0' && i != 1 { - return - } - return v[:i], v[i:], true -} - -func parsePrerelease(v string) (t, rest string, ok bool) { - // "A pre-release version MAY be denoted by appending a hyphen and - // a series of dot separated identifiers immediately following the patch version. - // Identifiers MUST comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. - // Identifiers MUST NOT be empty. Numeric identifiers MUST NOT include leading zeroes." - if v == "" || v[0] != '-' { - return - } - i := 1 - start := 1 - for i < len(v) && v[i] != '+' { - if !isIdentChar(v[i]) && v[i] != '.' { - return - } - if v[i] == '.' { - if start == i || isBadNum(v[start:i]) { - return - } - start = i + 1 - } - i++ - } - if start == i || isBadNum(v[start:i]) { - return - } - return v[:i], v[i:], true -} - -func parseBuild(v string) (t, rest string, ok bool) { - if v == "" || v[0] != '+' { - return - } - i := 1 - start := 1 - for i < len(v) { - if !isIdentChar(v[i]) { - return - } - if v[i] == '.' { - if start == i { - return - } - start = i + 1 - } - i++ - } - if start == i { - return - } - return v[:i], v[i:], true -} - -func isIdentChar(c byte) bool { - return 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || '0' <= c && c <= '9' || c == '-' -} - -func isBadNum(v string) bool { - i := 0 - for i < len(v) && '0' <= v[i] && v[i] <= '9' { - i++ - } - return i == len(v) && i > 1 && v[0] == '0' -} - -func isNum(v string) bool { - i := 0 - for i < len(v) && '0' <= v[i] && v[i] <= '9' { - i++ - } - return i == len(v) -} - -func compareInt(x, y string) int { - if x == y { - return 0 - } - if len(x) < len(y) { - return -1 - } - if len(x) > len(y) { - return +1 - } - if x < y { - return -1 - } else { - return +1 - } -} - -func comparePrerelease(x, y string) int { - // "When major, minor, and patch are equal, a pre-release version has - // lower precedence than a normal version. - // Example: 1.0.0-alpha < 1.0.0. - // Precedence for two pre-release versions with the same major, minor, - // and patch version MUST be determined by comparing each dot separated - // identifier from left to right until a difference is found as follows: - // identifiers consisting of only digits are compared numerically and - // identifiers with letters or hyphens are compared lexically in ASCII - // sort order. Numeric identifiers always have lower precedence than - // non-numeric identifiers. A larger set of pre-release fields has a - // higher precedence than a smaller set, if all of the preceding - // identifiers are equal. - // Example: 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < - // 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0." - if x == y { - return 0 - } - if x == "" { - return +1 - } - if y == "" { - return -1 - } - for x != "" && y != "" { - x = x[1:] // skip - or . - y = y[1:] // skip - or . - var dx, dy string - dx, x = nextIdent(x) - dy, y = nextIdent(y) - if dx != dy { - ix := isNum(dx) - iy := isNum(dy) - if ix != iy { - if ix { - return -1 - } else { - return +1 - } - } - if ix { - if len(dx) < len(dy) { - return -1 - } - if len(dx) > len(dy) { - return +1 - } - } - if dx < dy { - return -1 - } else { - return +1 - } - } - } - if x == "" { - return -1 - } else { - return +1 - } -} - -func nextIdent(x string) (dx, rest string) { - i := 0 - for i < len(x) && x[i] != '.' { - i++ - } - return x[:i], x[i:] -} diff --git a/vendor/go.opencensus.io/.travis.yml b/vendor/go.opencensus.io/.travis.yml deleted file mode 100644 index bd6b66ee83d..00000000000 --- a/vendor/go.opencensus.io/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: go - -go_import_path: go.opencensus.io - -go: - - 1.11.x - -env: - global: - GO111MODULE=on - -before_script: - - make install-tools - -script: - - make travis-ci - - go run internal/check/version.go # TODO move this to makefile diff --git a/vendor/go.opencensus.io/go.mod b/vendor/go.opencensus.io/go.mod index 29707156269..95b2522a7fa 100644 --- a/vendor/go.opencensus.io/go.mod +++ b/vendor/go.opencensus.io/go.mod @@ -1,15 +1,12 @@ module go.opencensus.io require ( - github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 - github.com/golang/protobuf v1.3.1 - github.com/google/go-cmp v0.3.0 - github.com/stretchr/testify v1.4.0 - golang.org/x/net v0.0.0-20190620200207-3b0461eec859 - golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd // indirect - golang.org/x/text v0.3.3 // indirect - google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb // indirect - google.golang.org/grpc v1.20.1 + github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e + github.com/golang/protobuf v1.4.3 + github.com/google/go-cmp v0.5.3 + github.com/stretchr/testify v1.6.1 + golang.org/x/net v0.0.0-20201110031124-69a78807bb2b + google.golang.org/grpc v1.33.2 ) go 1.13 diff --git a/vendor/go.opencensus.io/go.sum b/vendor/go.opencensus.io/go.sum index 01c02972c7e..c97cd1b551e 100644 --- a/vendor/go.opencensus.io/go.sum +++ b/vendor/go.opencensus.io/go.sum @@ -1,25 +1,47 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= 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/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/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.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 h1:ZgQEtGgCBiWRM39fZuwSd1LwSqqSW0hOdXCYYDX0R3I= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/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/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3 h1:x95R7cp+rSeeqAMI2knLtQ0DKlaBhv2NrtrOvafPHRo= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 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/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -30,24 +52,25 @@ golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd h1:r7DufRZuZbWB7j439YfAzP8RPDa9unLkpwQKUYbIMPI= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -55,20 +78,39 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3 golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd h1:/e+gpKk9r3dJobndpTytxS2gOy6m5uvpg+ISQoEcusQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb h1:i1Ppqkc3WQXikh8bXiwHqAN5Rv3/qDCcRk0/Otx73BY= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8= google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8= 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 h1:Hz2g2wirWK7H0qIIhGIqRGTuMwTE8HEKFnDZZ7lm9NU= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +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-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= 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/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/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-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/vendor/go.opencensus.io/metric/metricexport/reader.go b/vendor/go.opencensus.io/metric/metricexport/reader.go index b920bacd870..8a09d0f0076 100644 --- a/vendor/go.opencensus.io/metric/metricexport/reader.go +++ b/vendor/go.opencensus.io/metric/metricexport/reader.go @@ -130,7 +130,7 @@ func (ir *IntervalReader) Start() error { reportingInterval = ir.ReportingInterval } - if ir.done != nil { + if ir.quit != nil { return errAlreadyStarted } ir.timer = time.NewTicker(reportingInterval) @@ -172,6 +172,19 @@ func (ir *IntervalReader) Stop() { ir.quit = nil } +// Flush flushes the metrics if IntervalReader is stopped, otherwise no-op. +func (ir *IntervalReader) Flush() { + ir.mu.Lock() + defer ir.mu.Unlock() + + // No-op if IntervalReader is not stopped + if ir.quit != nil { + return + } + + ir.reader.ReadAndExport(ir.exporter) +} + // ReadAndExport reads metrics from all producer registered with // producer manager and then exports them using provided exporter. func (r *Reader) ReadAndExport(exporter Exporter) { diff --git a/vendor/go.opencensus.io/trace/basetypes.go b/vendor/go.opencensus.io/trace/basetypes.go index 0c54492a2b1..c8e26ed6355 100644 --- a/vendor/go.opencensus.io/trace/basetypes.go +++ b/vendor/go.opencensus.io/trace/basetypes.go @@ -49,6 +49,16 @@ type Attribute struct { value interface{} } +// Key returns the attribute's key +func (a *Attribute) Key() string { + return a.key +} + +// Value returns the attribute's value +func (a *Attribute) Value() interface{} { + return a.value +} + // BoolAttribute returns a bool-valued attribute. func BoolAttribute(key string, value bool) Attribute { return Attribute{key: key, value: value} diff --git a/vendor/go.opencensus.io/trace/spanstore.go b/vendor/go.opencensus.io/trace/spanstore.go index c442d990218..e601f76f2c8 100644 --- a/vendor/go.opencensus.io/trace/spanstore.go +++ b/vendor/go.opencensus.io/trace/spanstore.go @@ -48,8 +48,10 @@ func (i internalOnly) ReportActiveSpans(name string) []*SpanData { var out []*SpanData s.mu.Lock() defer s.mu.Unlock() - for span := range s.active { - out = append(out, span.makeSpanData()) + for activeSpan := range s.active { + if s, ok := activeSpan.(*span); ok { + out = append(out, s.makeSpanData()) + } } return out } @@ -185,7 +187,7 @@ func (i internalOnly) ReportSpansByLatency(name string, minLatency, maxLatency t // bucketed by latency. type spanStore struct { mu sync.Mutex // protects everything below. - active map[*Span]struct{} + active map[SpanInterface]struct{} errors map[int32]*bucket latency []bucket maxSpansPerErrorBucket int @@ -194,7 +196,7 @@ type spanStore struct { // newSpanStore creates a span store. func newSpanStore(name string, latencyBucketSize int, errorBucketSize int) *spanStore { s := &spanStore{ - active: make(map[*Span]struct{}), + active: make(map[SpanInterface]struct{}), latency: make([]bucket, len(defaultLatencies)+1), maxSpansPerErrorBucket: errorBucketSize, } @@ -271,7 +273,7 @@ func (s *spanStore) resize(latencyBucketSize int, errorBucketSize int) { } // add adds a span to the active bucket of the spanStore. -func (s *spanStore) add(span *Span) { +func (s *spanStore) add(span SpanInterface) { s.mu.Lock() s.active[span] = struct{}{} s.mu.Unlock() @@ -279,7 +281,7 @@ func (s *spanStore) add(span *Span) { // finished removes a span from the active set, and adds a corresponding // SpanData to a latency or error bucket. -func (s *spanStore) finished(span *Span, sd *SpanData) { +func (s *spanStore) finished(span SpanInterface, sd *SpanData) { latency := sd.EndTime.Sub(sd.StartTime) if latency < 0 { latency = 0 diff --git a/vendor/go.opencensus.io/trace/trace.go b/vendor/go.opencensus.io/trace/trace.go index daf895596a9..861df9d3913 100644 --- a/vendor/go.opencensus.io/trace/trace.go +++ b/vendor/go.opencensus.io/trace/trace.go @@ -28,12 +28,16 @@ import ( "go.opencensus.io/trace/tracestate" ) +type tracer struct{} + +var _ Tracer = &tracer{} + // Span represents a span of a trace. It has an associated SpanContext, and // stores data accumulated while the span is active. // // Ideally users should interact with Spans by calling the functions in this // package that take a Context parameter. -type Span struct { +type span struct { // data contains information recorded about the span. // // It will be non-nil if we are exporting the span or recording events for it. @@ -66,7 +70,7 @@ type Span struct { // IsRecordingEvents returns true if events are being recorded for this span. // Use this check to avoid computing expensive annotations when they will never // be used. -func (s *Span) IsRecordingEvents() bool { +func (s *span) IsRecordingEvents() bool { if s == nil { return false } @@ -109,13 +113,13 @@ type SpanContext struct { type contextKey struct{} // FromContext returns the Span stored in a context, or nil if there isn't one. -func FromContext(ctx context.Context) *Span { +func (t *tracer) FromContext(ctx context.Context) *Span { s, _ := ctx.Value(contextKey{}).(*Span) return s } // NewContext returns a new context with the given Span attached. -func NewContext(parent context.Context, s *Span) context.Context { +func (t *tracer) NewContext(parent context.Context, s *Span) context.Context { return context.WithValue(parent, contextKey{}, s) } @@ -166,12 +170,14 @@ func WithSampler(sampler Sampler) StartOption { // // Returned context contains the newly created span. You can use it to // propagate the returned span in process. -func StartSpan(ctx context.Context, name string, o ...StartOption) (context.Context, *Span) { +func (t *tracer) StartSpan(ctx context.Context, name string, o ...StartOption) (context.Context, *Span) { var opts StartOptions var parent SpanContext - if p := FromContext(ctx); p != nil { - p.addChild() - parent = p.spanContext + if p := t.FromContext(ctx); p != nil { + if ps, ok := p.internal.(*span); ok { + ps.addChild() + } + parent = p.SpanContext() } for _, op := range o { op(&opts) @@ -180,7 +186,8 @@ func StartSpan(ctx context.Context, name string, o ...StartOption) (context.Cont ctx, end := startExecutionTracerTask(ctx, name) span.executionTracerTaskEnd = end - return NewContext(ctx, span), span + extSpan := NewSpan(span) + return t.NewContext(ctx, extSpan), extSpan } // StartSpanWithRemoteParent starts a new child span of the span from the given parent. @@ -190,7 +197,7 @@ func StartSpan(ctx context.Context, name string, o ...StartOption) (context.Cont // // Returned context contains the newly created span. You can use it to // propagate the returned span in process. -func StartSpanWithRemoteParent(ctx context.Context, name string, parent SpanContext, o ...StartOption) (context.Context, *Span) { +func (t *tracer) StartSpanWithRemoteParent(ctx context.Context, name string, parent SpanContext, o ...StartOption) (context.Context, *Span) { var opts StartOptions for _, op := range o { op(&opts) @@ -198,12 +205,13 @@ func StartSpanWithRemoteParent(ctx context.Context, name string, parent SpanCont span := startSpanInternal(name, parent != SpanContext{}, parent, true, opts) ctx, end := startExecutionTracerTask(ctx, name) span.executionTracerTaskEnd = end - return NewContext(ctx, span), span + extSpan := NewSpan(span) + return t.NewContext(ctx, extSpan), extSpan } -func startSpanInternal(name string, hasParent bool, parent SpanContext, remoteParent bool, o StartOptions) *Span { - span := &Span{} - span.spanContext = parent +func startSpanInternal(name string, hasParent bool, parent SpanContext, remoteParent bool, o StartOptions) *span { + s := &span{} + s.spanContext = parent cfg := config.Load().(*Config) if gen, ok := cfg.IDGenerator.(*defaultIDGenerator); ok { @@ -212,9 +220,9 @@ func startSpanInternal(name string, hasParent bool, parent SpanContext, remotePa } if !hasParent { - span.spanContext.TraceID = cfg.IDGenerator.NewTraceID() + s.spanContext.TraceID = cfg.IDGenerator.NewTraceID() } - span.spanContext.SpanID = cfg.IDGenerator.NewSpanID() + s.spanContext.SpanID = cfg.IDGenerator.NewSpanID() sampler := cfg.DefaultSampler if !hasParent || remoteParent || o.Sampler != nil { @@ -226,47 +234,47 @@ func startSpanInternal(name string, hasParent bool, parent SpanContext, remotePa if o.Sampler != nil { sampler = o.Sampler } - span.spanContext.setIsSampled(sampler(SamplingParameters{ + s.spanContext.setIsSampled(sampler(SamplingParameters{ ParentContext: parent, - TraceID: span.spanContext.TraceID, - SpanID: span.spanContext.SpanID, + TraceID: s.spanContext.TraceID, + SpanID: s.spanContext.SpanID, Name: name, HasRemoteParent: remoteParent}).Sample) } - if !internal.LocalSpanStoreEnabled && !span.spanContext.IsSampled() { - return span + if !internal.LocalSpanStoreEnabled && !s.spanContext.IsSampled() { + return s } - span.data = &SpanData{ - SpanContext: span.spanContext, + s.data = &SpanData{ + SpanContext: s.spanContext, StartTime: time.Now(), SpanKind: o.SpanKind, Name: name, HasRemoteParent: remoteParent, } - span.lruAttributes = newLruMap(cfg.MaxAttributesPerSpan) - span.annotations = newEvictedQueue(cfg.MaxAnnotationEventsPerSpan) - span.messageEvents = newEvictedQueue(cfg.MaxMessageEventsPerSpan) - span.links = newEvictedQueue(cfg.MaxLinksPerSpan) + s.lruAttributes = newLruMap(cfg.MaxAttributesPerSpan) + s.annotations = newEvictedQueue(cfg.MaxAnnotationEventsPerSpan) + s.messageEvents = newEvictedQueue(cfg.MaxMessageEventsPerSpan) + s.links = newEvictedQueue(cfg.MaxLinksPerSpan) if hasParent { - span.data.ParentSpanID = parent.SpanID + s.data.ParentSpanID = parent.SpanID } if internal.LocalSpanStoreEnabled { var ss *spanStore ss = spanStoreForNameCreateIfNew(name) if ss != nil { - span.spanStore = ss - ss.add(span) + s.spanStore = ss + ss.add(s) } } - return span + return s } // End ends the span. -func (s *Span) End() { +func (s *span) End() { if s == nil { return } @@ -296,7 +304,7 @@ func (s *Span) End() { // makeSpanData produces a SpanData representing the current state of the Span. // It requires that s.data is non-nil. -func (s *Span) makeSpanData() *SpanData { +func (s *span) makeSpanData() *SpanData { var sd SpanData s.mu.Lock() sd = *s.data @@ -321,7 +329,7 @@ func (s *Span) makeSpanData() *SpanData { } // SpanContext returns the SpanContext of the span. -func (s *Span) SpanContext() SpanContext { +func (s *span) SpanContext() SpanContext { if s == nil { return SpanContext{} } @@ -329,7 +337,7 @@ func (s *Span) SpanContext() SpanContext { } // SetName sets the name of the span, if it is recording events. -func (s *Span) SetName(name string) { +func (s *span) SetName(name string) { if !s.IsRecordingEvents() { return } @@ -339,7 +347,7 @@ func (s *Span) SetName(name string) { } // SetStatus sets the status of the span, if it is recording events. -func (s *Span) SetStatus(status Status) { +func (s *span) SetStatus(status Status) { if !s.IsRecordingEvents() { return } @@ -348,7 +356,7 @@ func (s *Span) SetStatus(status Status) { s.mu.Unlock() } -func (s *Span) interfaceArrayToLinksArray() []Link { +func (s *span) interfaceArrayToLinksArray() []Link { linksArr := make([]Link, 0, len(s.links.queue)) for _, value := range s.links.queue { linksArr = append(linksArr, value.(Link)) @@ -356,7 +364,7 @@ func (s *Span) interfaceArrayToLinksArray() []Link { return linksArr } -func (s *Span) interfaceArrayToMessageEventArray() []MessageEvent { +func (s *span) interfaceArrayToMessageEventArray() []MessageEvent { messageEventArr := make([]MessageEvent, 0, len(s.messageEvents.queue)) for _, value := range s.messageEvents.queue { messageEventArr = append(messageEventArr, value.(MessageEvent)) @@ -364,7 +372,7 @@ func (s *Span) interfaceArrayToMessageEventArray() []MessageEvent { return messageEventArr } -func (s *Span) interfaceArrayToAnnotationArray() []Annotation { +func (s *span) interfaceArrayToAnnotationArray() []Annotation { annotationArr := make([]Annotation, 0, len(s.annotations.queue)) for _, value := range s.annotations.queue { annotationArr = append(annotationArr, value.(Annotation)) @@ -372,7 +380,7 @@ func (s *Span) interfaceArrayToAnnotationArray() []Annotation { return annotationArr } -func (s *Span) lruAttributesToAttributeMap() map[string]interface{} { +func (s *span) lruAttributesToAttributeMap() map[string]interface{} { attributes := make(map[string]interface{}, s.lruAttributes.len()) for _, key := range s.lruAttributes.keys() { value, ok := s.lruAttributes.get(key) @@ -384,13 +392,13 @@ func (s *Span) lruAttributesToAttributeMap() map[string]interface{} { return attributes } -func (s *Span) copyToCappedAttributes(attributes []Attribute) { +func (s *span) copyToCappedAttributes(attributes []Attribute) { for _, a := range attributes { s.lruAttributes.add(a.key, a.value) } } -func (s *Span) addChild() { +func (s *span) addChild() { if !s.IsRecordingEvents() { return } @@ -402,7 +410,7 @@ func (s *Span) addChild() { // AddAttributes sets attributes in the span. // // Existing attributes whose keys appear in the attributes parameter are overwritten. -func (s *Span) AddAttributes(attributes ...Attribute) { +func (s *span) AddAttributes(attributes ...Attribute) { if !s.IsRecordingEvents() { return } @@ -411,49 +419,27 @@ func (s *Span) AddAttributes(attributes ...Attribute) { s.mu.Unlock() } -// copyAttributes copies a slice of Attributes into a map. -func copyAttributes(m map[string]interface{}, attributes []Attribute) { - for _, a := range attributes { - m[a.key] = a.value - } -} - -func (s *Span) lazyPrintfInternal(attributes []Attribute, format string, a ...interface{}) { +func (s *span) printStringInternal(attributes []Attribute, str string) { now := time.Now() - msg := fmt.Sprintf(format, a...) - var m map[string]interface{} - s.mu.Lock() + var am map[string]interface{} if len(attributes) != 0 { - m = make(map[string]interface{}, len(attributes)) - copyAttributes(m, attributes) + am = make(map[string]interface{}, len(attributes)) + for _, attr := range attributes { + am[attr.key] = attr.value + } } - s.annotations.add(Annotation{ - Time: now, - Message: msg, - Attributes: m, - }) - s.mu.Unlock() -} - -func (s *Span) printStringInternal(attributes []Attribute, str string) { - now := time.Now() - var a map[string]interface{} s.mu.Lock() - if len(attributes) != 0 { - a = make(map[string]interface{}, len(attributes)) - copyAttributes(a, attributes) - } s.annotations.add(Annotation{ Time: now, Message: str, - Attributes: a, + Attributes: am, }) s.mu.Unlock() } // Annotate adds an annotation with attributes. // Attributes can be nil. -func (s *Span) Annotate(attributes []Attribute, str string) { +func (s *span) Annotate(attributes []Attribute, str string) { if !s.IsRecordingEvents() { return } @@ -461,11 +447,11 @@ func (s *Span) Annotate(attributes []Attribute, str string) { } // Annotatef adds an annotation with attributes. -func (s *Span) Annotatef(attributes []Attribute, format string, a ...interface{}) { +func (s *span) Annotatef(attributes []Attribute, format string, a ...interface{}) { if !s.IsRecordingEvents() { return } - s.lazyPrintfInternal(attributes, format, a...) + s.printStringInternal(attributes, fmt.Sprintf(format, a...)) } // AddMessageSendEvent adds a message send event to the span. @@ -474,7 +460,7 @@ func (s *Span) Annotatef(attributes []Attribute, format string, a ...interface{} // unique in this span and the same between the send event and the receive // event (this allows to identify a message between the sender and receiver). // For example, this could be a sequence id. -func (s *Span) AddMessageSendEvent(messageID, uncompressedByteSize, compressedByteSize int64) { +func (s *span) AddMessageSendEvent(messageID, uncompressedByteSize, compressedByteSize int64) { if !s.IsRecordingEvents() { return } @@ -496,7 +482,7 @@ func (s *Span) AddMessageSendEvent(messageID, uncompressedByteSize, compressedBy // unique in this span and the same between the send event and the receive // event (this allows to identify a message between the sender and receiver). // For example, this could be a sequence id. -func (s *Span) AddMessageReceiveEvent(messageID, uncompressedByteSize, compressedByteSize int64) { +func (s *span) AddMessageReceiveEvent(messageID, uncompressedByteSize, compressedByteSize int64) { if !s.IsRecordingEvents() { return } @@ -513,7 +499,7 @@ func (s *Span) AddMessageReceiveEvent(messageID, uncompressedByteSize, compresse } // AddLink adds a link to the span. -func (s *Span) AddLink(l Link) { +func (s *span) AddLink(l Link) { if !s.IsRecordingEvents() { return } @@ -522,7 +508,7 @@ func (s *Span) AddLink(l Link) { s.mu.Unlock() } -func (s *Span) String() string { +func (s *span) String() string { if s == nil { return "" } diff --git a/vendor/go.opencensus.io/trace/trace_api.go b/vendor/go.opencensus.io/trace/trace_api.go new file mode 100644 index 00000000000..9e2c3a99926 --- /dev/null +++ b/vendor/go.opencensus.io/trace/trace_api.go @@ -0,0 +1,265 @@ +// Copyright 2020, OpenCensus 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 trace + +import ( + "context" +) + +// DefaultTracer is the tracer used when package-level exported functions are invoked. +var DefaultTracer Tracer = &tracer{} + +// Tracer can start spans and access context functions. +type Tracer interface { + + // StartSpan starts a new child span of the current span in the context. If + // there is no span in the context, creates a new trace and span. + // + // Returned context contains the newly created span. You can use it to + // propagate the returned span in process. + StartSpan(ctx context.Context, name string, o ...StartOption) (context.Context, *Span) + + // StartSpanWithRemoteParent starts a new child span of the span from the given parent. + // + // If the incoming context contains a parent, it ignores. StartSpanWithRemoteParent is + // preferred for cases where the parent is propagated via an incoming request. + // + // Returned context contains the newly created span. You can use it to + // propagate the returned span in process. + StartSpanWithRemoteParent(ctx context.Context, name string, parent SpanContext, o ...StartOption) (context.Context, *Span) + + // FromContext returns the Span stored in a context, or nil if there isn't one. + FromContext(ctx context.Context) *Span + + // NewContext returns a new context with the given Span attached. + NewContext(parent context.Context, s *Span) context.Context +} + +// StartSpan starts a new child span of the current span in the context. If +// there is no span in the context, creates a new trace and span. +// +// Returned context contains the newly created span. You can use it to +// propagate the returned span in process. +func StartSpan(ctx context.Context, name string, o ...StartOption) (context.Context, *Span) { + return DefaultTracer.StartSpan(ctx, name, o...) +} + +// StartSpanWithRemoteParent starts a new child span of the span from the given parent. +// +// If the incoming context contains a parent, it ignores. StartSpanWithRemoteParent is +// preferred for cases where the parent is propagated via an incoming request. +// +// Returned context contains the newly created span. You can use it to +// propagate the returned span in process. +func StartSpanWithRemoteParent(ctx context.Context, name string, parent SpanContext, o ...StartOption) (context.Context, *Span) { + return DefaultTracer.StartSpanWithRemoteParent(ctx, name, parent, o...) +} + +// FromContext returns the Span stored in a context, or a Span that is not +// recording events if there isn't one. +func FromContext(ctx context.Context) *Span { + return DefaultTracer.FromContext(ctx) +} + +// NewContext returns a new context with the given Span attached. +func NewContext(parent context.Context, s *Span) context.Context { + return DefaultTracer.NewContext(parent, s) +} + +// SpanInterface represents a span of a trace. It has an associated SpanContext, and +// stores data accumulated while the span is active. +// +// Ideally users should interact with Spans by calling the functions in this +// package that take a Context parameter. +type SpanInterface interface { + + // IsRecordingEvents returns true if events are being recorded for this span. + // Use this check to avoid computing expensive annotations when they will never + // be used. + IsRecordingEvents() bool + + // End ends the span. + End() + + // SpanContext returns the SpanContext of the span. + SpanContext() SpanContext + + // SetName sets the name of the span, if it is recording events. + SetName(name string) + + // SetStatus sets the status of the span, if it is recording events. + SetStatus(status Status) + + // AddAttributes sets attributes in the span. + // + // Existing attributes whose keys appear in the attributes parameter are overwritten. + AddAttributes(attributes ...Attribute) + + // Annotate adds an annotation with attributes. + // Attributes can be nil. + Annotate(attributes []Attribute, str string) + + // Annotatef adds an annotation with attributes. + Annotatef(attributes []Attribute, format string, a ...interface{}) + + // AddMessageSendEvent adds a message send event to the span. + // + // messageID is an identifier for the message, which is recommended to be + // unique in this span and the same between the send event and the receive + // event (this allows to identify a message between the sender and receiver). + // For example, this could be a sequence id. + AddMessageSendEvent(messageID, uncompressedByteSize, compressedByteSize int64) + + // AddMessageReceiveEvent adds a message receive event to the span. + // + // messageID is an identifier for the message, which is recommended to be + // unique in this span and the same between the send event and the receive + // event (this allows to identify a message between the sender and receiver). + // For example, this could be a sequence id. + AddMessageReceiveEvent(messageID, uncompressedByteSize, compressedByteSize int64) + + // AddLink adds a link to the span. + AddLink(l Link) + + // String prints a string representation of a span. + String() string +} + +// NewSpan is a convenience function for creating a *Span out of a *span +func NewSpan(s SpanInterface) *Span { + return &Span{internal: s} +} + +// Span is a struct wrapper around the SpanInt interface, which allows correctly handling +// nil spans, while also allowing the SpanInterface implementation to be swapped out. +type Span struct { + internal SpanInterface +} + +// Internal returns the underlying implementation of the Span +func (s *Span) Internal() SpanInterface { + return s.internal +} + +// IsRecordingEvents returns true if events are being recorded for this span. +// Use this check to avoid computing expensive annotations when they will never +// be used. +func (s *Span) IsRecordingEvents() bool { + if s == nil { + return false + } + return s.internal.IsRecordingEvents() +} + +// End ends the span. +func (s *Span) End() { + if s == nil { + return + } + s.internal.End() +} + +// SpanContext returns the SpanContext of the span. +func (s *Span) SpanContext() SpanContext { + if s == nil { + return SpanContext{} + } + return s.internal.SpanContext() +} + +// SetName sets the name of the span, if it is recording events. +func (s *Span) SetName(name string) { + if !s.IsRecordingEvents() { + return + } + s.internal.SetName(name) +} + +// SetStatus sets the status of the span, if it is recording events. +func (s *Span) SetStatus(status Status) { + if !s.IsRecordingEvents() { + return + } + s.internal.SetStatus(status) +} + +// AddAttributes sets attributes in the span. +// +// Existing attributes whose keys appear in the attributes parameter are overwritten. +func (s *Span) AddAttributes(attributes ...Attribute) { + if !s.IsRecordingEvents() { + return + } + s.internal.AddAttributes(attributes...) +} + +// Annotate adds an annotation with attributes. +// Attributes can be nil. +func (s *Span) Annotate(attributes []Attribute, str string) { + if !s.IsRecordingEvents() { + return + } + s.internal.Annotate(attributes, str) +} + +// Annotatef adds an annotation with attributes. +func (s *Span) Annotatef(attributes []Attribute, format string, a ...interface{}) { + if !s.IsRecordingEvents() { + return + } + s.internal.Annotatef(attributes, format, a...) +} + +// AddMessageSendEvent adds a message send event to the span. +// +// messageID is an identifier for the message, which is recommended to be +// unique in this span and the same between the send event and the receive +// event (this allows to identify a message between the sender and receiver). +// For example, this could be a sequence id. +func (s *Span) AddMessageSendEvent(messageID, uncompressedByteSize, compressedByteSize int64) { + if !s.IsRecordingEvents() { + return + } + s.internal.AddMessageSendEvent(messageID, uncompressedByteSize, compressedByteSize) +} + +// AddMessageReceiveEvent adds a message receive event to the span. +// +// messageID is an identifier for the message, which is recommended to be +// unique in this span and the same between the send event and the receive +// event (this allows to identify a message between the sender and receiver). +// For example, this could be a sequence id. +func (s *Span) AddMessageReceiveEvent(messageID, uncompressedByteSize, compressedByteSize int64) { + if !s.IsRecordingEvents() { + return + } + s.internal.AddMessageReceiveEvent(messageID, uncompressedByteSize, compressedByteSize) +} + +// AddLink adds a link to the span. +func (s *Span) AddLink(l Link) { + if !s.IsRecordingEvents() { + return + } + s.internal.AddLink(l) +} + +// String prints a string representation of a span. +func (s *Span) String() string { + if s == nil { + return "" + } + return s.internal.String() +} diff --git a/vendor/go.uber.org/automaxprocs/internal/cgroups/subsys.go b/vendor/go.uber.org/automaxprocs/internal/cgroups/subsys.go index 6dc1b6453cb..103e86f3cc5 100644 --- a/vendor/go.uber.org/automaxprocs/internal/cgroups/subsys.go +++ b/vendor/go.uber.org/automaxprocs/internal/cgroups/subsys.go @@ -52,7 +52,7 @@ type CGroupSubsys struct { // NewCGroupSubsysFromLine returns a new *CGroupSubsys by parsing a string in // the format of `/proc/$PID/cgroup` func NewCGroupSubsysFromLine(line string) (*CGroupSubsys, error) { - fields := strings.Split(line, _cgroupSep) + fields := strings.SplitN(line, _cgroupSep, _csFieldCount) if len(fields) != _csFieldCount { return nil, cgroupSubsysFormatInvalidError{line} diff --git a/vendor/go.uber.org/automaxprocs/internal/runtime/runtime.go b/vendor/go.uber.org/automaxprocs/internal/runtime/runtime.go index a0b078147ca..3a751564915 100644 --- a/vendor/go.uber.org/automaxprocs/internal/runtime/runtime.go +++ b/vendor/go.uber.org/automaxprocs/internal/runtime/runtime.go @@ -28,6 +28,6 @@ const ( CPUQuotaUndefined CPUQuotaStatus = iota // CPUQuotaUsed is returned when a valid CPU quota can be used CPUQuotaUsed - // CPUQuotaMinUsed is return when CPU quota is larger than the min value + // CPUQuotaMinUsed is return when CPU quota is smaller than the min value CPUQuotaMinUsed ) diff --git a/vendor/go.uber.org/automaxprocs/maxprocs/version.go b/vendor/go.uber.org/automaxprocs/maxprocs/version.go index 0161a67cd90..d9ad8f4cf1d 100644 --- a/vendor/go.uber.org/automaxprocs/maxprocs/version.go +++ b/vendor/go.uber.org/automaxprocs/maxprocs/version.go @@ -21,4 +21,4 @@ package maxprocs // Version is the current package version. -const Version = "1.3.0" +const Version = "1.4.0" diff --git a/vendor/google.golang.org/grpc/Makefile b/vendor/google.golang.org/grpc/Makefile index 3f661a7879d..1f0722f1624 100644 --- a/vendor/google.golang.org/grpc/Makefile +++ b/vendor/google.golang.org/grpc/Makefile @@ -1,13 +1,13 @@ all: vet test testrace -build: deps +build: go build google.golang.org/grpc/... clean: go clean -i google.golang.org/grpc/... deps: - go get -d -v google.golang.org/grpc/... + GO111MODULE=on go get -d -v google.golang.org/grpc/... proto: @ if ! which protoc > /dev/null; then \ @@ -16,30 +16,18 @@ proto: fi go generate google.golang.org/grpc/... -test: testdeps +test: go test -cpu 1,4 -timeout 7m google.golang.org/grpc/... -testsubmodule: testdeps +testsubmodule: cd security/advancedtls && go test -cpu 1,4 -timeout 7m google.golang.org/grpc/security/advancedtls/... cd security/authorization && go test -cpu 1,4 -timeout 7m google.golang.org/grpc/security/authorization/... -testappengine: testappenginedeps - goapp test -cpu 1,4 -timeout 7m google.golang.org/grpc/... - -testappenginedeps: - goapp get -d -v -t -tags 'appengine appenginevm' google.golang.org/grpc/... - -testdeps: - go get -d -v -t google.golang.org/grpc/... - -testrace: testdeps +testrace: go test -race -cpu 1,4 -timeout 7m google.golang.org/grpc/... -updatedeps: - go get -d -v -u -f google.golang.org/grpc/... - -updatetestdeps: - go get -d -v -t -u -f google.golang.org/grpc/... +testdeps: + GO111MODULE=on go get -d -v -t google.golang.org/grpc/... vet: vetdeps ./vet.sh @@ -51,14 +39,10 @@ vetdeps: all \ build \ clean \ - deps \ proto \ test \ testappengine \ testappenginedeps \ - testdeps \ testrace \ - updatedeps \ - updatetestdeps \ vet \ vetdeps diff --git a/vendor/google.golang.org/grpc/SECURITY.md b/vendor/google.golang.org/grpc/SECURITY.md new file mode 100644 index 00000000000..be6e108705c --- /dev/null +++ b/vendor/google.golang.org/grpc/SECURITY.md @@ -0,0 +1,3 @@ +# Security Policy + +For information on gRPC Security Policy and reporting potentional security issues, please see [gRPC CVE Process](https://github.com/grpc/proposal/blob/master/P4-grpc-cve-process.md). diff --git a/vendor/google.golang.org/grpc/balancer/base/balancer.go b/vendor/google.golang.org/grpc/balancer/base/balancer.go index 32d782f1cf5..e0d34288ccf 100644 --- a/vendor/google.golang.org/grpc/balancer/base/balancer.go +++ b/vendor/google.golang.org/grpc/balancer/base/balancer.go @@ -64,7 +64,7 @@ type baseBalancer struct { csEvltr *balancer.ConnectivityStateEvaluator state connectivity.State - subConns map[resolver.Address]balancer.SubConn + subConns map[resolver.Address]balancer.SubConn // `attributes` is stripped from the keys of this map (the addresses) scStates map[balancer.SubConn]connectivity.State picker balancer.Picker config Config @@ -101,17 +101,41 @@ func (b *baseBalancer) UpdateClientConnState(s balancer.ClientConnState) error { // addrsSet is the set converted from addrs, it's used for quick lookup of an address. addrsSet := make(map[resolver.Address]struct{}) for _, a := range s.ResolverState.Addresses { - addrsSet[a] = struct{}{} - if _, ok := b.subConns[a]; !ok { + // Strip attributes from addresses before using them as map keys. So + // that when two addresses only differ in attributes pointers (but with + // the same attribute content), they are considered the same address. + // + // Note that this doesn't handle the case where the attribute content is + // different. So if users want to set different attributes to create + // duplicate connections to the same backend, it doesn't work. This is + // fine for now, because duplicate is done by setting Metadata today. + // + // TODO: read attributes to handle duplicate connections. + aNoAttrs := a + aNoAttrs.Attributes = nil + addrsSet[aNoAttrs] = struct{}{} + if sc, ok := b.subConns[aNoAttrs]; !ok { // a is a new address (not existing in b.subConns). + // + // When creating SubConn, the original address with attributes is + // passed through. So that connection configurations in attributes + // (like creds) will be used. sc, err := b.cc.NewSubConn([]resolver.Address{a}, balancer.NewSubConnOptions{HealthCheckEnabled: b.config.HealthCheck}) if err != nil { logger.Warningf("base.baseBalancer: failed to create new SubConn: %v", err) continue } - b.subConns[a] = sc + b.subConns[aNoAttrs] = sc b.scStates[sc] = connectivity.Idle sc.Connect() + } else { + // Always update the subconn's address in case the attributes + // changed. + // + // The SubConn does a reflect.DeepEqual of the new and old + // addresses. So this is a noop if the current address is the same + // as the old one (including attributes). + sc.UpdateAddresses([]resolver.Address{a}) } } for a, sc := range b.subConns { diff --git a/vendor/google.golang.org/grpc/balancer/grpclb/grpc_lb_v1/load_balancer_grpc.pb.go b/vendor/google.golang.org/grpc/balancer/grpclb/grpc_lb_v1/load_balancer_grpc.pb.go index a0061631daa..d56b77cca63 100644 --- a/vendor/google.golang.org/grpc/balancer/grpclb/grpc_lb_v1/load_balancer_grpc.pb.go +++ b/vendor/google.golang.org/grpc/balancer/grpclb/grpc_lb_v1/load_balancer_grpc.pb.go @@ -11,6 +11,7 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 // LoadBalancerClient is the client API for LoadBalancer service. @@ -30,7 +31,7 @@ func NewLoadBalancerClient(cc grpc.ClientConnInterface) LoadBalancerClient { } func (c *loadBalancerClient) BalanceLoad(ctx context.Context, opts ...grpc.CallOption) (LoadBalancer_BalanceLoadClient, error) { - stream, err := c.cc.NewStream(ctx, &_LoadBalancer_serviceDesc.Streams[0], "/grpc.lb.v1.LoadBalancer/BalanceLoad", opts...) + stream, err := c.cc.NewStream(ctx, &LoadBalancer_ServiceDesc.Streams[0], "/grpc.lb.v1.LoadBalancer/BalanceLoad", opts...) if err != nil { return nil, err } @@ -84,7 +85,7 @@ type UnsafeLoadBalancerServer interface { } func RegisterLoadBalancerServer(s grpc.ServiceRegistrar, srv LoadBalancerServer) { - s.RegisterService(&_LoadBalancer_serviceDesc, srv) + s.RegisterService(&LoadBalancer_ServiceDesc, srv) } func _LoadBalancer_BalanceLoad_Handler(srv interface{}, stream grpc.ServerStream) error { @@ -113,7 +114,10 @@ func (x *loadBalancerBalanceLoadServer) Recv() (*LoadBalanceRequest, error) { return m, nil } -var _LoadBalancer_serviceDesc = grpc.ServiceDesc{ +// LoadBalancer_ServiceDesc is the grpc.ServiceDesc for LoadBalancer service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var LoadBalancer_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.lb.v1.LoadBalancer", HandlerType: (*LoadBalancerServer)(nil), Methods: []grpc.MethodDesc{}, diff --git a/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_remote_balancer.go b/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_remote_balancer.go index 8fdda09034f..08d326ab40b 100644 --- a/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_remote_balancer.go +++ b/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_remote_balancer.go @@ -35,6 +35,7 @@ import ( "google.golang.org/grpc/connectivity" "google.golang.org/grpc/internal/backoff" "google.golang.org/grpc/internal/channelz" + imetadata "google.golang.org/grpc/internal/metadata" "google.golang.org/grpc/keepalive" "google.golang.org/grpc/metadata" "google.golang.org/grpc/resolver" @@ -76,10 +77,7 @@ func (lb *lbBalancer) processServerList(l *lbpb.ServerList) { // net.SplitHostPort() will return too many colons error. ipStr = fmt.Sprintf("[%s]", ipStr) } - addr := resolver.Address{ - Addr: fmt.Sprintf("%s:%d", ipStr, s.Port), - Metadata: &md, - } + addr := imetadata.Set(resolver.Address{Addr: fmt.Sprintf("%s:%d", ipStr, s.Port)}, md) if logger.V(2) { logger.Infof("lbBalancer: server list entry[%d]: ipStr:|%s|, port:|%d|, load balancer token:|%v|", i, ipStr, s.Port, s.LoadBalanceToken) @@ -163,19 +161,19 @@ func (lb *lbBalancer) refreshSubConns(backendAddrs []resolver.Address, fallback addrsSet := make(map[resolver.Address]struct{}) // Create new SubConns. for _, addr := range backendAddrs { - addrWithoutMD := addr - addrWithoutMD.Metadata = nil - addrsSet[addrWithoutMD] = struct{}{} - lb.backendAddrsWithoutMetadata = append(lb.backendAddrsWithoutMetadata, addrWithoutMD) + addrWithoutAttrs := addr + addrWithoutAttrs.Attributes = nil + addrsSet[addrWithoutAttrs] = struct{}{} + lb.backendAddrsWithoutMetadata = append(lb.backendAddrsWithoutMetadata, addrWithoutAttrs) - if _, ok := lb.subConns[addrWithoutMD]; !ok { + if _, ok := lb.subConns[addrWithoutAttrs]; !ok { // Use addrWithMD to create the SubConn. sc, err := lb.cc.NewSubConn([]resolver.Address{addr}, opts) if err != nil { logger.Warningf("grpclb: failed to create new SubConn: %v", err) continue } - lb.subConns[addrWithoutMD] = sc // Use the addr without MD as key for the map. + lb.subConns[addrWithoutAttrs] = sc // Use the addr without MD as key for the map. if _, ok := lb.scStates[sc]; !ok { // Only set state of new sc to IDLE. The state could already be // READY for cached SubConns. diff --git a/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_util.go b/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_util.go index 636725e5416..373f04b98d3 100644 --- a/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_util.go +++ b/vendor/google.golang.org/grpc/balancer/grpclb/grpclb_util.go @@ -124,16 +124,16 @@ func (ccc *lbCacheClientConn) NewSubConn(addrs []resolver.Address, opts balancer if len(addrs) != 1 { return nil, fmt.Errorf("grpclb calling NewSubConn with addrs of length %v", len(addrs)) } - addrWithoutMD := addrs[0] - addrWithoutMD.Metadata = nil + addrWithoutAttrs := addrs[0] + addrWithoutAttrs.Attributes = nil ccc.mu.Lock() defer ccc.mu.Unlock() - if entry, ok := ccc.subConnCache[addrWithoutMD]; ok { + if entry, ok := ccc.subConnCache[addrWithoutAttrs]; ok { // If entry is in subConnCache, the SubConn was being deleted. // cancel function will never be nil. entry.cancel() - delete(ccc.subConnCache, addrWithoutMD) + delete(ccc.subConnCache, addrWithoutAttrs) return entry.sc, nil } @@ -142,7 +142,7 @@ func (ccc *lbCacheClientConn) NewSubConn(addrs []resolver.Address, opts balancer return nil, err } - ccc.subConnToAddr[scNew] = addrWithoutMD + ccc.subConnToAddr[scNew] = addrWithoutAttrs return scNew, nil } diff --git a/vendor/google.golang.org/grpc/clientconn.go b/vendor/google.golang.org/grpc/clientconn.go index b35ba94f292..77a08fd33bf 100644 --- a/vendor/google.golang.org/grpc/clientconn.go +++ b/vendor/google.golang.org/grpc/clientconn.go @@ -109,11 +109,11 @@ type defaultConfigSelector struct { sc *ServiceConfig } -func (dcs *defaultConfigSelector) SelectConfig(rpcInfo iresolver.RPCInfo) *iresolver.RPCConfig { +func (dcs *defaultConfigSelector) SelectConfig(rpcInfo iresolver.RPCInfo) (*iresolver.RPCConfig, error) { return &iresolver.RPCConfig{ Context: rpcInfo.Context, MethodConfig: getMethodConfig(dcs.sc, rpcInfo.Method), - } + }, nil } // DialContext creates a client connection to the given target. By default, it's @@ -270,7 +270,7 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn * cc.authority = creds.Info().ServerName } else if cc.dopts.insecure && cc.dopts.authority != "" { cc.authority = cc.dopts.authority - } else if strings.HasPrefix(cc.target, "unix:") { + } else if strings.HasPrefix(cc.target, "unix:") || strings.HasPrefix(cc.target, "unix-abstract:") { cc.authority = "localhost" } else if strings.HasPrefix(cc.parsedTarget.Endpoint, ":") { cc.authority = "localhost" + cc.parsedTarget.Endpoint diff --git a/vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/handshaker_grpc.pb.go b/vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/handshaker_grpc.pb.go index 6dd4158546a..efdbd13fa30 100644 --- a/vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/handshaker_grpc.pb.go +++ b/vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/handshaker_grpc.pb.go @@ -11,6 +11,7 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 // HandshakerServiceClient is the client API for HandshakerService service. @@ -35,7 +36,7 @@ func NewHandshakerServiceClient(cc grpc.ClientConnInterface) HandshakerServiceCl } func (c *handshakerServiceClient) DoHandshake(ctx context.Context, opts ...grpc.CallOption) (HandshakerService_DoHandshakeClient, error) { - stream, err := c.cc.NewStream(ctx, &_HandshakerService_serviceDesc.Streams[0], "/grpc.gcp.HandshakerService/DoHandshake", opts...) + stream, err := c.cc.NewStream(ctx, &HandshakerService_ServiceDesc.Streams[0], "/grpc.gcp.HandshakerService/DoHandshake", opts...) if err != nil { return nil, err } @@ -96,7 +97,7 @@ type UnsafeHandshakerServiceServer interface { } func RegisterHandshakerServiceServer(s grpc.ServiceRegistrar, srv HandshakerServiceServer) { - s.RegisterService(&_HandshakerService_serviceDesc, srv) + s.RegisterService(&HandshakerService_ServiceDesc, srv) } func _HandshakerService_DoHandshake_Handler(srv interface{}, stream grpc.ServerStream) error { @@ -125,7 +126,10 @@ func (x *handshakerServiceDoHandshakeServer) Recv() (*HandshakerReq, error) { return m, nil } -var _HandshakerService_serviceDesc = grpc.ServiceDesc{ +// HandshakerService_ServiceDesc is the grpc.ServiceDesc for HandshakerService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var HandshakerService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gcp.HandshakerService", HandlerType: (*HandshakerServiceServer)(nil), Methods: []grpc.MethodDesc{}, diff --git a/vendor/google.golang.org/grpc/encoding/proto/proto.go b/vendor/google.golang.org/grpc/encoding/proto/proto.go index e1230fdd358..3009b35afe7 100644 --- a/vendor/google.golang.org/grpc/encoding/proto/proto.go +++ b/vendor/google.golang.org/grpc/encoding/proto/proto.go @@ -21,6 +21,8 @@ package proto import ( + "fmt" + "github.com/golang/protobuf/proto" "google.golang.org/grpc/encoding" ) @@ -36,11 +38,19 @@ func init() { type codec struct{} func (codec) Marshal(v interface{}) ([]byte, error) { - return proto.Marshal(v.(proto.Message)) + vv, ok := v.(proto.Message) + if !ok { + return nil, fmt.Errorf("failed to marshal, message is %T, want proto.Message", v) + } + return proto.Marshal(vv) } func (codec) Unmarshal(data []byte, v interface{}) error { - return proto.Unmarshal(data, v.(proto.Message)) + vv, ok := v.(proto.Message) + if !ok { + return fmt.Errorf("failed to unmarshal, message is %T, want proto.Message", v) + } + return proto.Unmarshal(data, vv) } func (codec) Name() string { diff --git a/vendor/google.golang.org/grpc/go.mod b/vendor/google.golang.org/grpc/go.mod index 6feb697bbda..cab74e55774 100644 --- a/vendor/google.golang.org/grpc/go.mod +++ b/vendor/google.golang.org/grpc/go.mod @@ -3,8 +3,8 @@ module google.golang.org/grpc go 1.11 require ( - github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354 - github.com/envoyproxy/go-control-plane v0.9.7 + github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403 + github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/golang/protobuf v1.4.2 github.com/google/go-cmp v0.5.0 diff --git a/vendor/google.golang.org/grpc/go.sum b/vendor/google.golang.org/grpc/go.sum index 293f5490353..77ee70b4435 100644 --- a/vendor/google.golang.org/grpc/go.sum +++ b/vendor/google.golang.org/grpc/go.sum @@ -6,13 +6,14 @@ github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354 h1:9kRtNpqLHbZVO/NNxhHp2ymxFxsHOe3x2efJGn//Tas= -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 h1:cqQfy1jclcSy/FwLjemeg3SR1yaINm74aQyupQ0Bl8M= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +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/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.7 h1:EARl0OvqMoxq/UMgMSCLnXzkaXbxzskluEBlMQCJPms= -github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad h1:EmNYJhPYy0pOFjCx2PrgtaBXmee0iUX9hLlxE1xHOJE= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= 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/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= @@ -36,10 +37,13 @@ github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 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= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -87,7 +91,9 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +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/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 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= diff --git a/vendor/google.golang.org/grpc/internal/grpcutil/target.go b/vendor/google.golang.org/grpc/internal/grpcutil/target.go index 3e1b22f5a8c..8833021da02 100644 --- a/vendor/google.golang.org/grpc/internal/grpcutil/target.go +++ b/vendor/google.golang.org/grpc/internal/grpcutil/target.go @@ -41,16 +41,37 @@ func split2(s, sep string) (string, string, bool) { // not parse "unix:[path]" cases. This should be true in cases where a custom // dialer is present, to prevent a behavior change. // -// If target is not a valid scheme://authority/endpoint, it returns {Endpoint: -// target}. +// If target is not a valid scheme://authority/endpoint as specified in +// https://github.com/grpc/grpc/blob/master/doc/naming.md, +// it returns {Endpoint: target}. func ParseTarget(target string, skipUnixColonParsing bool) (ret resolver.Target) { var ok bool + if strings.HasPrefix(target, "unix-abstract:") { + if strings.HasPrefix(target, "unix-abstract://") { + // Maybe, with Authority specified, try to parse it + var remain string + ret.Scheme, remain, _ = split2(target, "://") + ret.Authority, ret.Endpoint, ok = split2(remain, "/") + if !ok { + // No Authority, add the "//" back + ret.Endpoint = "//" + remain + } else { + // Found Authority, add the "/" back + ret.Endpoint = "/" + ret.Endpoint + } + } else { + // Without Authority specified, split target on ":" + ret.Scheme, ret.Endpoint, _ = split2(target, ":") + } + return ret + } ret.Scheme, ret.Endpoint, ok = split2(target, "://") if !ok { if strings.HasPrefix(target, "unix:") && !skipUnixColonParsing { - // Handle the "unix:[path]" case, because splitting on :// only - // handles the "unix://[/absolute/path]" case. Only handle if the - // dialer is nil, to avoid a behavior change with custom dialers. + // Handle the "unix:[local/path]" and "unix:[/absolute/path]" cases, + // because splitting on :// only handles the + // "unix://[/absolute/path]" case. Only handle if the dialer is nil, + // to avoid a behavior change with custom dialers. return resolver.Target{Scheme: "unix", Endpoint: target[len("unix:"):]} } return resolver.Target{Endpoint: target} @@ -61,7 +82,7 @@ func ParseTarget(target string, skipUnixColonParsing bool) (ret resolver.Target) } if ret.Scheme == "unix" { // Add the "/" back in the unix case, so the unix resolver receives the - // actual endpoint. + // actual endpoint in the "unix://[/absolute/path]" case. ret.Endpoint = "/" + ret.Endpoint } return ret diff --git a/vendor/google.golang.org/grpc/internal/internal.go b/vendor/google.golang.org/grpc/internal/internal.go index f83d6625988..1e2834c70f6 100644 --- a/vendor/google.golang.org/grpc/internal/internal.go +++ b/vendor/google.golang.org/grpc/internal/internal.go @@ -60,7 +60,11 @@ var ( // GetXDSHandshakeInfoForTesting returns a pointer to the xds.HandshakeInfo // stored in the passed in attributes. This is set by // credentials/xds/xds.go. - GetXDSHandshakeInfoForTesting interface{} // func (attr *attributes.Attributes) *xds.HandshakeInfo + GetXDSHandshakeInfoForTesting interface{} // func (*attributes.Attributes) *xds.HandshakeInfo + // GetServerCredentials returns the transport credentials configured on a + // gRPC server. An xDS-enabled server needs to know what type of credentials + // is configured on the underlying gRPC server. This is set by server.go. + GetServerCredentials interface{} // func (*grpc.Server) credentials.TransportCredentials ) // HealthChecker defines the signature of the client-side LB channel health checking function. diff --git a/vendor/google.golang.org/grpc/internal/metadata/metadata.go b/vendor/google.golang.org/grpc/internal/metadata/metadata.go new file mode 100644 index 00000000000..302262613a0 --- /dev/null +++ b/vendor/google.golang.org/grpc/internal/metadata/metadata.go @@ -0,0 +1,50 @@ +/* + * + * 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 metadata contains functions to set and get metadata from addresses. +// +// This package is experimental. +package metadata + +import ( + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/resolver" +) + +type mdKeyType string + +const mdKey = mdKeyType("grpc.internal.address.metadata") + +// Get returns the metadata of addr. +func Get(addr resolver.Address) metadata.MD { + attrs := addr.Attributes + if attrs == nil { + return nil + } + md, _ := attrs.Value(mdKey).(metadata.MD) + return md +} + +// Set sets (overrides) the metadata in addr. +// +// When a SubConn is created with this address, the RPCs sent on it will all +// have this metadata. +func Set(addr resolver.Address, md metadata.MD) resolver.Address { + addr.Attributes = addr.Attributes.WithValues(mdKey, md) + return addr +} diff --git a/vendor/google.golang.org/grpc/internal/resolver/config_selector.go b/vendor/google.golang.org/grpc/internal/resolver/config_selector.go index 5ef9262e51d..e6990040056 100644 --- a/vendor/google.golang.org/grpc/internal/resolver/config_selector.go +++ b/vendor/google.golang.org/grpc/internal/resolver/config_selector.go @@ -29,8 +29,10 @@ import ( // ConfigSelector controls what configuration to use for every RPC. type ConfigSelector interface { - // Selects the configuration for the RPC. - SelectConfig(RPCInfo) *RPCConfig + // Selects the configuration for the RPC, or terminates it using the error. + // This error will be converted by the gRPC library to a status error with + // code UNKNOWN if it is not returned as a status error. + SelectConfig(RPCInfo) (*RPCConfig, error) } // RPCInfo contains RPC information needed by a ConfigSelector. @@ -86,7 +88,7 @@ func (scs *SafeConfigSelector) UpdateConfigSelector(cs ConfigSelector) { } // SelectConfig defers to the current ConfigSelector in scs. -func (scs *SafeConfigSelector) SelectConfig(r RPCInfo) *RPCConfig { +func (scs *SafeConfigSelector) SelectConfig(r RPCInfo) (*RPCConfig, error) { scs.mu.RLock() defer scs.mu.RUnlock() return scs.cs.SelectConfig(r) diff --git a/vendor/google.golang.org/grpc/internal/resolver/unix/unix.go b/vendor/google.golang.org/grpc/internal/resolver/unix/unix.go index d046e50613d..0d5a811ddfa 100644 --- a/vendor/google.golang.org/grpc/internal/resolver/unix/unix.go +++ b/vendor/google.golang.org/grpc/internal/resolver/unix/unix.go @@ -20,21 +20,34 @@ package unix import ( + "fmt" + "google.golang.org/grpc/internal/transport/networktype" "google.golang.org/grpc/resolver" ) -const scheme = "unix" +const unixScheme = "unix" +const unixAbstractScheme = "unix-abstract" -type builder struct{} +type builder struct { + scheme string +} -func (*builder) Build(target resolver.Target, cc resolver.ClientConn, _ resolver.BuildOptions) (resolver.Resolver, error) { - cc.UpdateState(resolver.State{Addresses: []resolver.Address{networktype.Set(resolver.Address{Addr: target.Endpoint}, "unix")}}) +func (b *builder) Build(target resolver.Target, cc resolver.ClientConn, _ resolver.BuildOptions) (resolver.Resolver, error) { + if target.Authority != "" { + return nil, fmt.Errorf("invalid (non-empty) authority: %v", target.Authority) + } + addr := resolver.Address{Addr: target.Endpoint} + if b.scheme == unixAbstractScheme { + // prepend "\x00" to address for unix-abstract + addr.Addr = "\x00" + addr.Addr + } + cc.UpdateState(resolver.State{Addresses: []resolver.Address{networktype.Set(addr, "unix")}}) return &nopResolver{}, nil } -func (*builder) Scheme() string { - return scheme +func (b *builder) Scheme() string { + return b.scheme } type nopResolver struct { @@ -45,5 +58,6 @@ func (*nopResolver) ResolveNow(resolver.ResolveNowOptions) {} func (*nopResolver) Close() {} func init() { - resolver.Register(&builder{}) + resolver.Register(&builder{scheme: unixScheme}) + resolver.Register(&builder{scheme: unixAbstractScheme}) } diff --git a/vendor/google.golang.org/grpc/internal/syscall/syscall_linux.go b/vendor/google.golang.org/grpc/internal/syscall/syscall_linux.go index 2fdcb76e6c7..4b2964f2a1e 100644 --- a/vendor/google.golang.org/grpc/internal/syscall/syscall_linux.go +++ b/vendor/google.golang.org/grpc/internal/syscall/syscall_linux.go @@ -44,25 +44,23 @@ func GetCPUTime() int64 { } // Rusage is an alias for syscall.Rusage under linux environment. -type Rusage syscall.Rusage +type Rusage = syscall.Rusage // GetRusage returns the resource usage of current process. -func GetRusage() (rusage *Rusage) { - rusage = new(Rusage) - syscall.Getrusage(syscall.RUSAGE_SELF, (*syscall.Rusage)(rusage)) - return +func GetRusage() *Rusage { + rusage := new(Rusage) + syscall.Getrusage(syscall.RUSAGE_SELF, rusage) + return rusage } // CPUTimeDiff returns the differences of user CPU time and system CPU time used // between two Rusage structs. func CPUTimeDiff(first *Rusage, latest *Rusage) (float64, float64) { - f := (*syscall.Rusage)(first) - l := (*syscall.Rusage)(latest) var ( - utimeDiffs = l.Utime.Sec - f.Utime.Sec - utimeDiffus = l.Utime.Usec - f.Utime.Usec - stimeDiffs = l.Stime.Sec - f.Stime.Sec - stimeDiffus = l.Stime.Usec - f.Stime.Usec + utimeDiffs = latest.Utime.Sec - first.Utime.Sec + utimeDiffus = latest.Utime.Usec - first.Utime.Usec + stimeDiffs = latest.Stime.Sec - first.Stime.Sec + stimeDiffus = latest.Stime.Usec - first.Stime.Usec ) uTimeElapsed := float64(utimeDiffs) + float64(utimeDiffus)*1.0e-6 diff --git a/vendor/google.golang.org/grpc/internal/syscall/syscall_nonlinux.go b/vendor/google.golang.org/grpc/internal/syscall/syscall_nonlinux.go index adae60d6518..7913ef1dbfb 100644 --- a/vendor/google.golang.org/grpc/internal/syscall/syscall_nonlinux.go +++ b/vendor/google.golang.org/grpc/internal/syscall/syscall_nonlinux.go @@ -50,7 +50,7 @@ func GetCPUTime() int64 { type Rusage struct{} // GetRusage is a no-op function under non-linux or appengine environment. -func GetRusage() (rusage *Rusage) { +func GetRusage() *Rusage { log() return nil } diff --git a/vendor/google.golang.org/grpc/internal/transport/http2_client.go b/vendor/google.golang.org/grpc/internal/transport/http2_client.go index fef365c0d28..8902b7f90d9 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http2_client.go +++ b/vendor/google.golang.org/grpc/internal/transport/http2_client.go @@ -33,6 +33,7 @@ import ( "golang.org/x/net/http2" "golang.org/x/net/http2/hpack" "google.golang.org/grpc/internal/grpcutil" + imetadata "google.golang.org/grpc/internal/metadata" "google.golang.org/grpc/internal/transport/networktype" "google.golang.org/grpc/codes" @@ -60,7 +61,7 @@ type http2Client struct { cancel context.CancelFunc ctxDone <-chan struct{} // Cache the ctx.Done() chan. userAgent string - md interface{} + md metadata.MD conn net.Conn // underlying communication channel loopy *loopyWriter remoteAddr net.Addr @@ -139,17 +140,26 @@ type http2Client struct { } func dial(ctx context.Context, fn func(context.Context, string) (net.Conn, error), addr resolver.Address, useProxy bool, grpcUA string) (net.Conn, error) { + address := addr.Addr + networkType, ok := networktype.Get(addr) if fn != nil { - return fn(ctx, addr.Addr) + if networkType == "unix" && !strings.HasPrefix(address, "\x00") { + // For backward compatibility, if the user dialed "unix:///path", + // the passthrough resolver would be used and the user's custom + // dialer would see "unix:///path". Since the unix resolver is used + // and the address is now "/path", prepend "unix://" so the user's + // custom dialer sees the same address. + return fn(ctx, "unix://"+address) + } + return fn(ctx, address) } - networkType := "tcp" - if n, ok := networktype.Get(addr); ok { - networkType = n + if !ok { + networkType, address = parseDialTarget(address) } if networkType == "tcp" && useProxy { - return proxyDial(ctx, addr.Addr, grpcUA) + return proxyDial(ctx, address, grpcUA) } - return (&net.Dialer{}).DialContext(ctx, networkType, addr.Addr) + return (&net.Dialer{}).DialContext(ctx, networkType, address) } func isTemporary(err error) bool { @@ -268,7 +278,6 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts ctxDone: ctx.Done(), // Cache Done chan. cancel: cancel, userAgent: opts.UserAgent, - md: addr.Metadata, conn: conn, remoteAddr: conn.RemoteAddr(), localAddr: conn.LocalAddr(), @@ -296,6 +305,12 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts keepaliveEnabled: keepaliveEnabled, bufferPool: newBufferPool(), } + + if md, ok := addr.Metadata.(*metadata.MD); ok { + t.md = *md + } else if md := imetadata.Get(addr); md != nil { + t.md = md + } t.controlBuf = newControlBuffer(t.ctxDone) if opts.InitialWindowSize >= defaultWindowSize { t.initialWindowSize = opts.InitialWindowSize @@ -512,14 +527,12 @@ func (t *http2Client) createHeaderFields(ctx context.Context, callHdr *CallHdr) } } } - if md, ok := t.md.(*metadata.MD); ok { - for k, vv := range *md { - if isReservedHeader(k) { - continue - } - for _, v := range vv { - headerFields = append(headerFields, hpack.HeaderField{Name: k, Value: encodeMetadataHeader(k, v)}) - } + for k, vv := range t.md { + if isReservedHeader(k) { + continue + } + for _, v := range vv { + headerFields = append(headerFields, hpack.HeaderField{Name: k, Value: encodeMetadataHeader(k, v)}) } } return headerFields, nil diff --git a/vendor/google.golang.org/grpc/internal/transport/http_util.go b/vendor/google.golang.org/grpc/internal/transport/http_util.go index 4d15afbf73f..7e41d1183f9 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http_util.go +++ b/vendor/google.golang.org/grpc/internal/transport/http_util.go @@ -27,6 +27,7 @@ import ( "math" "net" "net/http" + "net/url" "strconv" "strings" "time" @@ -598,3 +599,31 @@ func newFramer(conn net.Conn, writeBufferSize, readBufferSize int, maxHeaderList f.fr.ReadMetaHeaders = hpack.NewDecoder(http2InitHeaderTableSize, nil) return f } + +// parseDialTarget returns the network and address to pass to dialer. +func parseDialTarget(target string) (string, string) { + net := "tcp" + m1 := strings.Index(target, ":") + m2 := strings.Index(target, ":/") + // handle unix:addr which will fail with url.Parse + if m1 >= 0 && m2 < 0 { + if n := target[0:m1]; n == "unix" { + return n, target[m1+1:] + } + } + if m2 >= 0 { + t, err := url.Parse(target) + if err != nil { + return net, target + } + scheme := t.Scheme + addr := t.Path + if scheme == "unix" { + if addr == "" { + addr = t.Host + } + return scheme, addr + } + } + return net, target +} diff --git a/vendor/google.golang.org/grpc/regenerate.sh b/vendor/google.golang.org/grpc/regenerate.sh index 3443ad97591..fc6725b89f8 100644 --- a/vendor/google.golang.org/grpc/regenerate.sh +++ b/vendor/google.golang.org/grpc/regenerate.sh @@ -40,24 +40,14 @@ echo "go install cmd/protoc-gen-go-grpc" echo "git clone https://github.com/grpc/grpc-proto" git clone --quiet https://github.com/grpc/grpc-proto ${WORKDIR}/grpc-proto +echo "git clone https://github.com/protocolbuffers/protobuf" +git clone --quiet https://github.com/protocolbuffers/protobuf ${WORKDIR}/protobuf + # Pull in code.proto as a proto dependency mkdir -p ${WORKDIR}/googleapis/google/rpc echo "curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/rpc/code.proto" curl --silent https://raw.githubusercontent.com/googleapis/googleapis/master/google/rpc/code.proto > ${WORKDIR}/googleapis/google/rpc/code.proto -# Pull in the following repos to build the MeshCA config proto. -ENVOY_API_REPOS=( - "https://github.com/envoyproxy/data-plane-api" - "https://github.com/cncf/udpa" - "https://github.com/envoyproxy/protoc-gen-validate" -) -for repo in ${ENVOY_API_REPOS[@]}; do - dirname=$(basename ${repo}) - mkdir -p ${WORKDIR}/${dirname} - echo "git clone ${repo}" - git clone --quiet ${repo} ${WORKDIR}/${dirname} -done - # Pull in the MeshCA service proto. mkdir -p ${WORKDIR}/istio/istio/google/security/meshca/v1 echo "curl https://raw.githubusercontent.com/istio/istio/master/security/proto/providers/google/meshca.proto" @@ -84,15 +74,15 @@ SOURCES=( ${WORKDIR}/grpc-proto/grpc/lookup/v1/rls.proto ${WORKDIR}/grpc-proto/grpc/lookup/v1/rls_config.proto ${WORKDIR}/grpc-proto/grpc/service_config/service_config.proto - ${WORKDIR}/grpc-proto/grpc/tls/provider/meshca/experimental/config.proto + ${WORKDIR}/grpc-proto/grpc/testing/*.proto + ${WORKDIR}/grpc-proto/grpc/core/*.proto ${WORKDIR}/istio/istio/google/security/meshca/v1/meshca.proto ) # These options of the form 'Mfoo.proto=bar' instruct the codegen to use an # import path of 'bar' in the generated code when 'foo.proto' is imported in # one of the sources. -OPTS=Mgrpc/service_config/service_config.proto=/internal/proto/grpc_service_config,\ -Menvoy/config/core/v3/config_source.proto=github.com/envoyproxy/go-control-plane/envoy/config/core/v3 +OPTS=Mgrpc/service_config/service_config.proto=/internal/proto/grpc_service_config,Mgrpc/core/stats.proto=google.golang.org/grpc/interop/grpc_testing/core for src in ${SOURCES[@]}; do echo "protoc ${src}" @@ -100,9 +90,7 @@ for src in ${SOURCES[@]}; do -I"." \ -I${WORKDIR}/grpc-proto \ -I${WORKDIR}/googleapis \ - -I${WORKDIR}/data-plane-api \ - -I${WORKDIR}/udpa \ - -I${WORKDIR}/protoc-gen-validate \ + -I${WORKDIR}/protobuf/src \ -I${WORKDIR}/istio \ ${src} done @@ -113,9 +101,7 @@ for src in ${LEGACY_SOURCES[@]}; do -I"." \ -I${WORKDIR}/grpc-proto \ -I${WORKDIR}/googleapis \ - -I${WORKDIR}/data-plane-api \ - -I${WORKDIR}/udpa \ - -I${WORKDIR}/protoc-gen-validate \ + -I${WORKDIR}/protobuf/src \ -I${WORKDIR}/istio \ ${src} done @@ -132,6 +118,10 @@ rm ${WORKDIR}/out/google.golang.org/grpc/reflection/grpc_testingv3/*.pb.go # grpc/service_config/service_config.proto does not have a go_package option. mv ${WORKDIR}/out/grpc/service_config/service_config.pb.go internal/proto/grpc_service_config +# grpc/testing does not have a go_package option. +mv ${WORKDIR}/out/grpc/testing/*.pb.go interop/grpc_testing/ +mv ${WORKDIR}/out/grpc/core/*.pb.go interop/grpc_testing/core/ + # istio/google/security/meshca/v1/meshca.proto does not have a go_package option. mkdir -p ${WORKDIR}/out/google.golang.org/grpc/credentials/tls/certprovider/meshca/internal/v1/ mv ${WORKDIR}/out/istio/google/security/meshca/v1/* ${WORKDIR}/out/google.golang.org/grpc/credentials/tls/certprovider/meshca/internal/v1/ diff --git a/vendor/google.golang.org/grpc/rpc_util.go b/vendor/google.golang.org/grpc/rpc_util.go index ea5bb8d0c2b..c0a1208f2f3 100644 --- a/vendor/google.golang.org/grpc/rpc_util.go +++ b/vendor/google.golang.org/grpc/rpc_util.go @@ -888,8 +888,7 @@ type channelzData struct { // buffer files to ensure compatibility with the gRPC version used. The latest // support package version is 7. // -// Older versions are kept for compatibility. They may be removed if -// compatibility cannot be maintained. +// Older versions are kept for compatibility. // // These constants should not be referenced from any other code. const ( diff --git a/vendor/google.golang.org/grpc/server.go b/vendor/google.golang.org/grpc/server.go index 968eb598e1e..7a2aa28a114 100644 --- a/vendor/google.golang.org/grpc/server.go +++ b/vendor/google.golang.org/grpc/server.go @@ -40,6 +40,7 @@ import ( "google.golang.org/grpc/encoding" "google.golang.org/grpc/encoding/proto" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/internal" "google.golang.org/grpc/internal/binarylog" "google.golang.org/grpc/internal/channelz" "google.golang.org/grpc/internal/grpcrand" @@ -58,6 +59,12 @@ const ( defaultServerMaxSendMessageSize = math.MaxInt32 ) +func init() { + internal.GetServerCredentials = func(srv *Server) credentials.TransportCredentials { + return srv.opts.creds + } +} + var statusOK = status.New(codes.OK, "") var logger = grpclog.Component("core") diff --git a/vendor/google.golang.org/grpc/status/status.go b/vendor/google.golang.org/grpc/status/status.go index 01e182c306c..54d187186b8 100644 --- a/vendor/google.golang.org/grpc/status/status.go +++ b/vendor/google.golang.org/grpc/status/status.go @@ -73,9 +73,11 @@ func FromProto(s *spb.Status) *Status { return status.FromProto(s) } -// FromError returns a Status representing err if it was produced from this -// package or has a method `GRPCStatus() *Status`. Otherwise, ok is false and a -// Status is returned with codes.Unknown and the original error message. +// FromError returns a Status representing err if it was produced by this +// package or has a method `GRPCStatus() *Status`. +// If err is nil, a Status is returned with codes.OK and no message. +// Otherwise, ok is false and a Status is returned with codes.Unknown and +// the original error message. func FromError(err error) (s *Status, ok bool) { if err == nil { return nil, true diff --git a/vendor/google.golang.org/grpc/stream.go b/vendor/google.golang.org/grpc/stream.go index 8d4694a33f9..eda1248d60c 100644 --- a/vendor/google.golang.org/grpc/stream.go +++ b/vendor/google.golang.org/grpc/stream.go @@ -175,7 +175,10 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth var mc serviceconfig.MethodConfig var onCommit func() - rpcConfig := cc.safeConfigSelector.SelectConfig(iresolver.RPCInfo{Context: ctx, Method: method}) + rpcConfig, err := cc.safeConfigSelector.SelectConfig(iresolver.RPCInfo{Context: ctx, Method: method}) + if err != nil { + return nil, status.Convert(err).Err() + } if rpcConfig != nil { if rpcConfig.Context != nil { ctx = rpcConfig.Context diff --git a/vendor/google.golang.org/grpc/version.go b/vendor/google.golang.org/grpc/version.go index 01f41739d56..51024d6b318 100644 --- a/vendor/google.golang.org/grpc/version.go +++ b/vendor/google.golang.org/grpc/version.go @@ -19,4 +19,4 @@ package grpc // Version is the current grpc version. -const Version = "1.34.0" +const Version = "1.36.0" diff --git a/vendor/knative.dev/pkg/apis/duck/ABOUT.md b/vendor/knative.dev/pkg/apis/duck/ABOUT.md index 98ffc9424b7..b223412a012 100644 --- a/vendor/knative.dev/pkg/apis/duck/ABOUT.md +++ b/vendor/knative.dev/pkg/apis/duck/ABOUT.md @@ -73,7 +73,7 @@ the resulting JSON Patch can only contain fields relevant to the resource. In Knative, we follow the Kubernetes API principles of using `conditions` as a key part of our resources’ status, but we go a step further in -[defining particular conventions](https://github.com/knative/serving/blob/master/docs/spec/errors.md#error-conditions-and-reporting) +[defining particular conventions](https://github.com/knative/serving/blob/main/docs/spec/errors.md#error-conditions-and-reporting) on how these are used. To support this, we define: diff --git a/vendor/knative.dev/pkg/client/injection/apiextensions/client/client.go b/vendor/knative.dev/pkg/client/injection/apiextensions/client/client.go index 3edca7e9ef6..e8695e03fc6 100644 --- a/vendor/knative.dev/pkg/client/injection/apiextensions/client/client.go +++ b/vendor/knative.dev/pkg/client/injection/apiextensions/client/client.go @@ -29,6 +29,9 @@ import ( func init() { injection.Default.RegisterClient(withClient) + injection.Default.RegisterClientFetcher(func(ctx context.Context) interface{} { + return Get(ctx) + }) } // Key is used as the key for associating information with a context.Context. diff --git a/vendor/knative.dev/pkg/client/injection/kube/client/client.go b/vendor/knative.dev/pkg/client/injection/kube/client/client.go index 00591ff5789..b7994cb7256 100644 --- a/vendor/knative.dev/pkg/client/injection/kube/client/client.go +++ b/vendor/knative.dev/pkg/client/injection/kube/client/client.go @@ -29,6 +29,9 @@ import ( func init() { injection.Default.RegisterClient(withClient) + injection.Default.RegisterClientFetcher(func(ctx context.Context) interface{} { + return Get(ctx) + }) } // Key is used as the key for associating information with a context.Context. diff --git a/vendor/knative.dev/pkg/client/injection/kube/client/fake/fake.go b/vendor/knative.dev/pkg/client/injection/kube/client/fake/fake.go index 022ae42f0f2..e1662229492 100644 --- a/vendor/knative.dev/pkg/client/injection/kube/client/fake/fake.go +++ b/vendor/knative.dev/pkg/client/injection/kube/client/fake/fake.go @@ -31,6 +31,9 @@ import ( func init() { injection.Fake.RegisterClient(withClient) + injection.Fake.RegisterClientFetcher(func(ctx context.Context) interface{} { + return Get(ctx) + }) } func withClient(ctx context.Context, cfg *rest.Config) context.Context { diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/client.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/client.go index 317e12a4440..d7cb717ed55 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/client.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/client.go @@ -66,7 +66,11 @@ func (g *clientGenerator) GenerateType(c *generator.Context, t *types.Type, w io "clientSetNewForConfigOrDie": c.Universe.Function(types.Name{Package: g.clientSetPackage, Name: "NewForConfigOrDie"}), "clientSetInterface": c.Universe.Type(types.Name{Package: g.clientSetPackage, Name: "Interface"}), "injectionRegisterClient": c.Universe.Function(types.Name{Package: "knative.dev/pkg/injection", Name: "Default.RegisterClient"}), - "restConfig": c.Universe.Type(types.Name{Package: "k8s.io/client-go/rest", Name: "Config"}), + "injectionRegisterClientFetcher": c.Universe.Function(types.Name{ + Package: "knative.dev/pkg/injection", + Name: "Default.RegisterClientFetcher", + }), + "restConfig": c.Universe.Type(types.Name{Package: "k8s.io/client-go/rest", Name: "Config"}), "loggingFromContext": c.Universe.Function(types.Name{ Package: "knative.dev/pkg/logging", Name: "FromContext", @@ -85,6 +89,9 @@ func (g *clientGenerator) GenerateType(c *generator.Context, t *types.Type, w io var injectionClient = ` func init() { {{.injectionRegisterClient|raw}}(withClient) + {{.injectionRegisterClientFetcher|raw}}(func(ctx context.Context) interface{} { + return Get(ctx) + }) } // Key is used as the key for associating information with a context.Context. diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/fake_client.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/fake_client.go index 3e98ce3818a..76725f2bd96 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/fake_client.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/fake_client.go @@ -71,6 +71,10 @@ func (g *fakeClientGenerator) GenerateType(c *generator.Context, t *types.Type, Package: "knative.dev/pkg/injection", Name: "Fake.RegisterClient", }), + "injectionRegisterClientFetcher": c.Universe.Function(types.Name{ + Package: "knative.dev/pkg/injection", + Name: "Fake.RegisterClientFetcher", + }), "loggingFromContext": c.Universe.Function(types.Name{ Package: "knative.dev/pkg/logging", Name: "FromContext", @@ -91,6 +95,9 @@ func (g *fakeClientGenerator) GenerateType(c *generator.Context, t *types.Type, var injectionFakeClient = ` func init() { {{.injectionRegisterClient|raw}}(withClient) + {{.injectionRegisterClientFetcher|raw}}(func(ctx context.Context) interface{} { + return Get(ctx) + }) } func withClient(ctx {{.contextContext|raw}}, cfg *{{.restConfig|raw}}) {{.contextContext|raw}} { diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/packages.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/packages.go index 75dafbf1b53..e71e92dc247 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/packages.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/packages.go @@ -552,6 +552,7 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp schemePkg: filepath.Join(customArgs.VersionedClientSetPackage, "scheme"), reconcilerClass: reconcilerClass, hasReconcilerClass: hasReconcilerClass, + hasStatus: hasStatus(t), }) return generators }, @@ -613,6 +614,7 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp hasReconcilerClass: hasReconcilerClass, nonNamespaced: nonNamespaced, isKRShaped: isKRShaped, + hasStatus: hasStatus(t), }) return generators }, @@ -737,3 +739,12 @@ func versionDuckPackages(basePackage string, groupPkgName string, gv clientgenty } return vers } + +func hasStatus(t *types.Type) bool { + for _, member := range t.Members { + if member.Name == "Status" { + return true + } + } + return false +} diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go index 0f0f417ecdc..9471b5db8a5 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go @@ -40,6 +40,7 @@ type reconcilerControllerGenerator struct { reconcilerClass string hasReconcilerClass bool + hasStatus bool } var _ generator.Generator = (*reconcilerControllerGenerator)(nil) @@ -66,10 +67,11 @@ func (g *reconcilerControllerGenerator) GenerateType(c *generator.Context, t *ty klog.V(5).Info("processing type ", t) m := map[string]interface{}{ - "type": t, - "group": g.groupName, - "class": g.reconcilerClass, - "hasClass": g.hasReconcilerClass, + "type": t, + "group": g.groupName, + "class": g.reconcilerClass, + "hasClass": g.hasReconcilerClass, + "hasStatus": g.hasStatus, "controllerImpl": c.Universe.Type(types.Name{ Package: "knative.dev/pkg/controller", Name: "Impl", @@ -202,7 +204,7 @@ const ( // NewImpl returns a {{.controllerImpl|raw}} that handles queuing and feeding work from // the queue through an implementation of {{.controllerReconciler|raw}}, delegating to // the provided Interface and optional Finalizer methods. OptionsFn is used to return -// {{.controllerOptions|raw}} to be used but the internal reconciler. +// {{.controllerOptions|raw}} to be used by the internal reconciler. func NewImpl(ctx {{.contextContext|raw}}, r Interface{{if .hasClass}}, classValue string{{end}}, optionsFns ...{{.controllerOptionsFn|raw}}) *{{.controllerImpl|raw}} { logger := {{.loggingFromContext|raw}}(ctx) @@ -264,9 +266,14 @@ func NewImpl(ctx {{.contextContext|raw}}, r Interface{{if .hasClass}}, classValu if opts.AgentName != "" { agentName = opts.AgentName } + {{- if .hasStatus}} if opts.SkipStatusUpdates { rec.skipStatusUpdates = true } + {{- end}} + if opts.DemoteFunc != nil { + rec.DemoteFunc = opts.DemoteFunc + } } rec.Recorder = createRecorder(ctx, agentName) diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go index 0c6e3e04edb..cc6757da8a5 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go @@ -41,6 +41,7 @@ type reconcilerReconcilerGenerator struct { hasReconcilerClass bool nonNamespaced bool isKRShaped bool + hasStatus bool groupGoName string groupVersion clientgentypes.GroupVersion @@ -76,6 +77,7 @@ func (g *reconcilerReconcilerGenerator) GenerateType(c *generator.Context, t *ty "class": g.reconcilerClass, "hasClass": g.hasReconcilerClass, "isKRShaped": g.isKRShaped, + "hasStatus": g.hasStatus, "nonNamespaced": g.nonNamespaced, "controllerImpl": c.Universe.Type(types.Name{ Package: "knative.dev/pkg/controller", @@ -213,7 +215,9 @@ func (g *reconcilerReconcilerGenerator) GenerateType(c *generator.Context, t *ty sw.Do(reconcilerInterfaceFactory, m) sw.Do(reconcilerNewReconciler, m) sw.Do(reconcilerImplFactory, m) - sw.Do(reconcilerStatusFactory, m) + if g.hasStatus { + sw.Do(reconcilerStatusFactory, m) + } sw.Do(reconcilerFinalizerFactory, m) return sw.Error() @@ -289,9 +293,11 @@ type reconcilerImpl struct { // finalizerName is the name of the finalizer to reconcile. finalizerName string + {{if .hasStatus}} // skipStatusUpdates configures whether or not this reconciler automatically updates // the status of the reconciled resource. skipStatusUpdates bool + {{end}} {{if .hasClass}} // classValue is the resource annotation[{{ .class }}] instance value this reconciler instance filters on. @@ -352,9 +358,14 @@ func NewReconciler(ctx {{.contextContext|raw}}, logger *{{.zapSugaredLogger|raw} if opts.FinalizerName != "" { rec.finalizerName = opts.FinalizerName } + {{- if .hasStatus}} if opts.SkipStatusUpdates { rec.skipStatusUpdates = true } + {{- end}} + if opts.DemoteFunc != nil { + rec.DemoteFunc = opts.DemoteFunc + } } return rec @@ -460,6 +471,7 @@ func (r *reconcilerImpl) Reconcile(ctx {{.contextContext|raw}}, key string) erro } + {{if .hasStatus}} // Synchronize the status. switch { case r.skipStatusUpdates: @@ -482,6 +494,7 @@ func (r *reconcilerImpl) Reconcile(ctx {{.contextContext|raw}}, key string) erro return err } } + {{end}} // Report the reconciler event, if any. if reconcileEvent != nil { diff --git a/vendor/knative.dev/pkg/configmap/informer/informed_watcher.go b/vendor/knative.dev/pkg/configmap/informer/informed_watcher.go index 2231ee52f22..1ae7ef8d403 100644 --- a/vendor/knative.dev/pkg/configmap/informer/informed_watcher.go +++ b/vendor/knative.dev/pkg/configmap/informer/informed_watcher.go @@ -107,7 +107,8 @@ var _ configmap.Watcher = (*InformedWatcher)(nil) // Asserts that InformedWatcher implements DefaultingWatcher. var _ configmap.DefaultingWatcher = (*InformedWatcher)(nil) -// WatchWithDefault implements DefaultingWatcher. +// WatchWithDefault implements DefaultingWatcher. Adding a default for the configMap being watched means that when +// Start is called, Start will not wait for the add event from the API server. func (i *InformedWatcher) WatchWithDefault(cm corev1.ConfigMap, o ...configmap.Observer) { i.defaults[cm.Name] = &cm @@ -126,31 +127,59 @@ func (i *InformedWatcher) WatchWithDefault(cm corev1.ConfigMap, o ...configmap.O i.Watch(cm.Name, o...) } -// Start implements Watcher. -func (i *InformedWatcher) Start(stopCh <-chan struct{}) error { - // Pretend that all the defaulted ConfigMaps were just created. This is done before we start - // the informer to ensure that if a defaulted ConfigMap does exist, then the real value is - // processed after the default one. +func (i *InformedWatcher) triggerAddEventForDefaultedConfigMaps(addConfigMapEvent func(obj interface{})) { i.ForEach(func(k string, _ []configmap.Observer) error { if def, ok := i.defaults[k]; ok { - i.addConfigMapEvent(def) + addConfigMapEvent(def) } return nil }) +} + +func (i *InformedWatcher) getConfigMapNames() []string { + var configMaps []string + i.ForEach(func(k string, _ []configmap.Observer) error { + configMaps = append(configMaps, k) + return nil + }) + return configMaps +} - if err := i.registerCallbackAndStartInformer(stopCh); err != nil { +// Start implements Watcher. Start will wait for all watched resources to exist and for the add event handler to be +// invoked at least once for each before continuing or for the stopCh to be signalled, whichever happens first. If +// the watched resource is defaulted, Start will invoke the add event handler directly and will not wait for a further +// add event from the API server. +func (i *InformedWatcher) Start(stopCh <-chan struct{}) error { + // using the synced callback wrapper around the add event handler will allow the caller + // to wait for the add event to be processed for all configmaps + s := newSyncedCallback(i.getConfigMapNames(), i.addConfigMapEvent) + addConfigMapEvent := func(obj interface{}) { + configMap := obj.(*corev1.ConfigMap) + s.Call(obj, configMap.Name) + } + // Pretend that all the defaulted ConfigMaps were just created. This is done before we start + // the informer to ensure that if a defaulted ConfigMap does exist, then the real value is + // processed after the default one. + i.triggerAddEventForDefaultedConfigMaps(addConfigMapEvent) + + if err := i.registerCallbackAndStartInformer(addConfigMapEvent, stopCh); err != nil { return err } - // Wait until it has been synced (WITHOUT holing the mutex, so callbacks happen) + // Wait until the shared informer has been synced (WITHOUT holing the mutex, so callbacks happen) if ok := cache.WaitForCacheSync(stopCh, i.informer.Informer().HasSynced); !ok { return errors.New("error waiting for ConfigMap informer to sync") } - return i.checkObservedResourcesExist() + if err := i.checkObservedResourcesExist(); err != nil { + return err + } + + // Wait until all config maps have been at least initially processed + return s.WaitForAllKeys(stopCh) } -func (i *InformedWatcher) registerCallbackAndStartInformer(stopCh <-chan struct{}) error { +func (i *InformedWatcher) registerCallbackAndStartInformer(addConfigMapEvent func(obj interface{}), stopCh <-chan struct{}) error { i.Lock() defer i.Unlock() if i.started { @@ -159,13 +188,14 @@ func (i *InformedWatcher) registerCallbackAndStartInformer(stopCh <-chan struct{ i.started = true i.informer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: i.addConfigMapEvent, + AddFunc: addConfigMapEvent, UpdateFunc: i.updateConfigMapEvent, DeleteFunc: i.deleteConfigMapEvent, }) // Start the shared informer factory (non-blocking). i.sif.Start(stopCh) + return nil } diff --git a/vendor/knative.dev/pkg/configmap/informer/synced_callback.go b/vendor/knative.dev/pkg/configmap/informer/synced_callback.go new file mode 100644 index 00000000000..355c512b502 --- /dev/null +++ b/vendor/knative.dev/pkg/configmap/informer/synced_callback.go @@ -0,0 +1,112 @@ +/* +Copyright 2021 The Knative 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 informer + +import ( + "sync" + + "k8s.io/apimachinery/pkg/util/sets" + "k8s.io/apimachinery/pkg/util/wait" +) + +// namedWaitGroup is used to increment and decrement a WaitGroup by name +type namedWaitGroup struct { + waitGroup sync.WaitGroup + keys sets.String + mu sync.Mutex +} + +// newNamedWaitGroup returns an instantiated namedWaitGroup. +func newNamedWaitGroup() *namedWaitGroup { + return &namedWaitGroup{ + keys: sets.NewString(), + } +} + +// Add will add the key to the list of keys being tracked and increment the wait group. +// If the key has already been added, the wait group will not be incremented again. +func (n *namedWaitGroup) Add(key string) { + n.mu.Lock() + defer n.mu.Unlock() + + if !n.keys.Has(key) { + n.keys.Insert(key) + n.waitGroup.Add(1) + } +} + +// Done will decrement the counter if the key is present in the tracked keys. If it is not present +// it will be ignored. +func (n *namedWaitGroup) Done(key string) { + n.mu.Lock() + defer n.mu.Unlock() + + if n.keys.Has(key) { + n.keys.Delete(key) + n.waitGroup.Done() + } +} + +// Wait will wait for the underlying waitGroup to complete. +func (n *namedWaitGroup) Wait() { + n.waitGroup.Wait() +} + +// syncedCallback can be used to wait for a callback to be called at least once for a list of keys. +type syncedCallback struct { + // namedWaitGroup will block until the callback has been called for all tracked entities + namedWaitGroup *namedWaitGroup + + // callback is the callback that is intended to be called at least once for each key + // being tracked via WaitGroup + callback func(obj interface{}) +} + +// newSyncedCallback will return a syncedCallback that will track the provided keys. +func newSyncedCallback(keys []string, callback func(obj interface{})) *syncedCallback { + s := &syncedCallback{ + callback: callback, + namedWaitGroup: newNamedWaitGroup(), + } + for _, key := range keys { + s.namedWaitGroup.Add(key) + } + return s +} + +// Event is intended to be a wrapper for the actual event handler; this wrapper will signal via +// the wait group that the event handler has been called at least once for the key. +func (s *syncedCallback) Call(obj interface{}, key string) { + s.callback(obj) + s.namedWaitGroup.Done(key) +} + +// WaitForAllKeys will block until s.Call has been called for all the keys we are tracking or the stop signal is +// received. +func (s *syncedCallback) WaitForAllKeys(stopCh <-chan struct{}) error { + c := make(chan struct{}) + go func() { + defer close(c) + s.namedWaitGroup.Wait() + }() + select { + case <-c: + return nil + case <-stopCh: + return wait.ErrWaitTimeout + } +} diff --git a/vendor/knative.dev/pkg/controller/controller.go b/vendor/knative.dev/pkg/controller/controller.go index 26030626ec1..747cf58efcd 100644 --- a/vendor/knative.dev/pkg/controller/controller.go +++ b/vendor/knative.dev/pkg/controller/controller.go @@ -31,6 +31,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/record" "k8s.io/client-go/util/workqueue" @@ -152,6 +153,13 @@ func FilterControllerGK(gk schema.GroupKind) func(obj interface{}) bool { } } +// FilterController makes it simple to create FilterFunc's for use with +// cache.FilteringResourceEventHandler that filter based on the +// controlling resource. +func FilterController(r kmeta.OwnerRefable) func(obj interface{}) bool { + return FilterControllerGK(r.GetGroupVersionKind().GroupKind()) +} + // FilterWithName makes it simple to create FilterFunc's for use with // cache.FilteringResourceEventHandler that filter based on a name. func FilterWithName(name string) func(obj interface{}) bool { @@ -514,7 +522,7 @@ func (c *Impl) processNextWorkItem() bool { // Embed the key into the logger and attach that to the context we pass // to the Reconciler. - logger := c.logger.With(zap.String(logkey.TraceID, uuid.New().String()), zap.String(logkey.Key, keyStr)) + logger := c.logger.With(zap.String(logkey.TraceID, uuid.NewString()), zap.String(logkey.Key, keyStr)) ctx := logging.WithLogger(context.Background(), logger) // Run Reconcile, passing it the namespace/name string of the @@ -578,8 +586,8 @@ func NewSkipKey(key string) error { return skipKeyError{key: key} } -// permanentError is an error that is considered not transient. -// We should not re-queue keys when it returns with thus error in reconcile. +// skipKeyError is an error that indicates a key was skipped. +// We should not re-queue keys when it returns this error from Reconcile. type skipKeyError struct { key string } @@ -685,13 +693,29 @@ func RunInformers(stopCh <-chan struct{}, informers ...Informer) (func(), error) } for i, informer := range informers { - if ok := cache.WaitForCacheSync(stopCh, informer.HasSynced); !ok { + if ok := WaitForCacheSyncQuick(stopCh, informer.HasSynced); !ok { return wg.Wait, fmt.Errorf("failed to wait for cache at index %d to sync", i) } } return wg.Wait, nil } +// WaitForCacheSyncQuick is the same as cache.WaitForCacheSync but with a much reduced +// check-rate for the sync period. +func WaitForCacheSyncQuick(stopCh <-chan struct{}, cacheSyncs ...cache.InformerSynced) bool { + err := wait.PollImmediateUntil(time.Millisecond, + func() (bool, error) { + for _, syncFunc := range cacheSyncs { + if !syncFunc() { + return false, nil + } + } + return true, nil + }, + stopCh) + return err == nil +} + // StartAll kicks off all of the passed controllers with DefaultThreadsPerController. func StartAll(ctx context.Context, controllers ...*Impl) { wg := sync.WaitGroup{} diff --git a/vendor/knative.dev/pkg/controller/options.go b/vendor/knative.dev/pkg/controller/options.go index b40b5a35962..8d61835e691 100644 --- a/vendor/knative.dev/pkg/controller/options.go +++ b/vendor/knative.dev/pkg/controller/options.go @@ -35,6 +35,9 @@ type Options struct { // SkipStatusUpdates configures this reconciler to either do automated status // updates (default) or skip them if this is set to true. SkipStatusUpdates bool + + // DemoteFunc configures the demote function this reconciler uses + DemoteFunc func(b reconciler.Bucket) } // OptionsFn is a callback method signature that accepts an Impl and returns diff --git a/vendor/knative.dev/pkg/controller/stats_reporter.go b/vendor/knative.dev/pkg/controller/stats_reporter.go index 92a5848a1da..474bab3fc61 100644 --- a/vendor/knative.dev/pkg/controller/stats_reporter.go +++ b/vendor/knative.dev/pkg/controller/stats_reporter.go @@ -26,7 +26,6 @@ import ( "go.opencensus.io/tag" "go.uber.org/zap" "k8s.io/apimachinery/pkg/types" - "k8s.io/client-go/tools/cache" kubemetrics "k8s.io/client-go/tools/metrics" "k8s.io/client-go/util/workqueue" "knative.dev/pkg/metrics" @@ -34,8 +33,8 @@ import ( ) var ( - workQueueDepthStat = stats.Int64("work_queue_depth", "Depth of the work queue", stats.UnitNone) - reconcileCountStat = stats.Int64("reconcile_count", "Number of reconcile operations", stats.UnitNone) + workQueueDepthStat = stats.Int64("work_queue_depth", "Depth of the work queue", stats.UnitDimensionless) + reconcileCountStat = stats.Int64("reconcile_count", "Number of reconcile operations", stats.UnitDimensionless) reconcileLatencyStat = stats.Int64("reconcile_latency", "Latency of reconcile operations", stats.UnitMilliseconds) // reconcileDistribution defines the bucket boundaries for the histogram of reconcile latency metric. @@ -58,104 +57,51 @@ func init() { Adds: stats.Int64( "workqueue_adds_total", "Total number of adds handled by workqueue", - stats.UnitNone, + stats.UnitDimensionless, ), Depth: stats.Int64( "workqueue_depth", "Current depth of workqueue", - stats.UnitNone, + stats.UnitDimensionless, ), Latency: stats.Float64( "workqueue_queue_latency_seconds", "How long in seconds an item stays in workqueue before being requested.", - "s", + stats.UnitSeconds, ), Retries: stats.Int64( "workqueue_retries_total", "Total number of retries handled by workqueue", - "s", + stats.UnitDimensionless, ), WorkDuration: stats.Float64( "workqueue_work_duration_seconds", "How long in seconds processing an item from workqueue takes.", - "s", + stats.UnitSeconds, ), UnfinishedWorkSeconds: stats.Float64( "workqueue_unfinished_work_seconds", "How long in seconds the outstanding workqueue items have been in flight (total).", - "s", + stats.UnitSeconds, ), LongestRunningProcessorSeconds: stats.Float64( "workqueue_longest_running_processor_seconds", "How long in seconds the longest outstanding workqueue item has been in flight.", - "s", + stats.UnitSeconds, ), } workqueue.SetProvider(wp) - // Register to receive metrics from kubernetes reflectors (what powers informers) - // NOTE: today these don't actually seem to wire up to anything in Kubernetes. - rp := &metrics.ReflectorProvider{ - ItemsInList: stats.Float64( - "reflector_items_in_list", - "How many items an API list returns to the reflectors", - stats.UnitNone, - ), - // TODO(mattmoor): This is not in the latest version, so it will - // be removed in a future version. - ItemsInMatch: stats.Float64( - "reflector_items_in_match", - "", - stats.UnitNone, - ), - ItemsInWatch: stats.Float64( - "reflector_items_in_watch", - "How many items an API watch returns to the reflectors", - stats.UnitNone, - ), - LastResourceVersion: stats.Float64( - "reflector_last_resource_version", - "Last resource version seen for the reflectors", - stats.UnitNone, - ), - ListDuration: stats.Float64( - "reflector_list_duration_seconds", - "How long an API list takes to return and decode for the reflectors", - stats.UnitNone, - ), - Lists: stats.Int64( - "reflector_lists_total", - "Total number of API lists done by the reflectors", - stats.UnitNone, - ), - ShortWatches: stats.Int64( - "reflector_short_watches_total", - "Total number of short API watches done by the reflectors", - stats.UnitNone, - ), - WatchDuration: stats.Float64( - "reflector_watch_duration_seconds", - "How long an API watch takes to return and decode for the reflectors", - stats.UnitNone, - ), - Watches: stats.Int64( - "reflector_watches_total", - "Total number of API watches done by the reflectors", - stats.UnitNone, - ), - } - cache.SetReflectorMetricsProvider(rp) - cp := &metrics.ClientProvider{ Latency: stats.Float64( "client_latency", "How long Kubernetes API requests take", - "s", + stats.UnitSeconds, ), Result: stats.Int64( "client_results", "Total number of API requests (broken down by status code)", - stats.UnitNone, + stats.UnitDimensionless, ), } opts := kubemetrics.RegisterOpts{ @@ -181,7 +127,6 @@ func init() { TagKeys: []tag.Key{reconcilerTagKey, successTagKey, NamespaceTagKey}, }} views = append(views, wp.DefaultViews()...) - views = append(views, rp.DefaultViews()...) views = append(views, cp.DefaultViews()...) // Create views to see our measurements. This can return an error if diff --git a/vendor/knative.dev/pkg/injection/clients.go b/vendor/knative.dev/pkg/injection/clients.go index 5c464924c70..b71ef1d9430 100644 --- a/vendor/knative.dev/pkg/injection/clients.go +++ b/vendor/knative.dev/pkg/injection/clients.go @@ -26,6 +26,10 @@ import ( // client type to a context. type ClientInjector func(context.Context, *rest.Config) context.Context +// ClientFetcher holds the type of a callback that returns a particular client type +// from a context. +type ClientFetcher func(context.Context) interface{} + func (i *impl) RegisterClient(ci ClientInjector) { i.m.Lock() defer i.m.Unlock() @@ -40,3 +44,21 @@ func (i *impl) GetClients() []ClientInjector { // Copy the slice before returning. return append(i.clients[:0:0], i.clients...) } + +func (i *impl) RegisterClientFetcher(f ClientFetcher) { + i.m.Lock() + defer i.m.Unlock() + + i.clientFetchers = append(i.clientFetchers, f) +} + +func (i *impl) FetchAllClients(ctx context.Context) []interface{} { + i.m.RLock() + defer i.m.RUnlock() + + clients := make([]interface{}, 0, len(i.clientFetchers)) + for _, f := range i.clientFetchers { + clients = append(clients, f(ctx)) + } + return clients +} diff --git a/vendor/knative.dev/pkg/injection/interface.go b/vendor/knative.dev/pkg/injection/interface.go index 7d2764cdcc1..112a6415f25 100644 --- a/vendor/knative.dev/pkg/injection/interface.go +++ b/vendor/knative.dev/pkg/injection/interface.go @@ -36,6 +36,13 @@ type Interface interface { // GetClients fetches all of the registered client injectors. GetClients() []ClientInjector + // RegisterClientFetcher registers a new callback that fetches a client from + // a given context. + RegisterClientFetcher(ClientFetcher) + + // FetchAllClients returns all known clients from the given context. + FetchAllClients(context.Context) []interface{} + // RegisterInformerFactory registers a new injector callback for associating // a new informer factory with a context. RegisterInformerFactory(InformerFactoryInjector) @@ -92,6 +99,7 @@ type impl struct { m sync.RWMutex clients []ClientInjector + clientFetchers []ClientFetcher factories []InformerFactoryInjector informers []InformerInjector filteredInformers []FilteredInformersInjector diff --git a/vendor/knative.dev/pkg/leaderelection/config.go b/vendor/knative.dev/pkg/leaderelection/config.go index 96164bd0017..3d9df1dc79d 100644 --- a/vendor/knative.dev/pkg/leaderelection/config.go +++ b/vendor/knative.dev/pkg/leaderelection/config.go @@ -134,8 +134,8 @@ type statefulSetID struct { func (ssID *statefulSetID) Decode(v string) error { if i := strings.LastIndex(v, "-"); i != -1 { - ui, err := strconv.ParseUint(v[i+1:], 10, 64) - ssID.ordinal = int(ui) + ui, err := strconv.Atoi(v[i+1:]) + ssID.ordinal = ui ssID.ssName = v[:i] return err } diff --git a/vendor/knative.dev/pkg/metrics/config.go b/vendor/knative.dev/pkg/metrics/config.go index c4c9c7f84e2..6407a1b0de4 100644 --- a/vendor/knative.dev/pkg/metrics/config.go +++ b/vendor/knative.dev/pkg/metrics/config.go @@ -41,7 +41,7 @@ const ( DomainEnv = "METRICS_DOMAIN" // The following keys are used to configure metrics reporting. - // See https://github.com/knative/serving/blob/master/config/config-observability.yaml + // See https://github.com/knative/serving/blob/main/config/config-observability.yaml // for details. allowStackdriverCustomMetricsKey = "metrics.allow-stackdriver-custom-metrics" collectorAddressKey = "metrics.opencensus-address" diff --git a/vendor/knative.dev/pkg/metrics/exporter.go b/vendor/knative.dev/pkg/metrics/exporter.go index b98a18de1ff..46e5916dec3 100644 --- a/vendor/knative.dev/pkg/metrics/exporter.go +++ b/vendor/knative.dev/pkg/metrics/exporter.go @@ -21,7 +21,6 @@ import ( "errors" "fmt" "strings" - "sync" "go.opencensus.io/resource" "go.opencensus.io/stats/view" @@ -32,9 +31,14 @@ import ( var ( curMetricsExporter view.Exporter curMetricsConfig *metricsConfig - metricsMux sync.RWMutex + mWorker *metricsWorker ) +func init() { + mWorker = newMetricsWorker() + go mWorker.start() +} + // SecretFetcher is a function (extracted from SecretNamespaceLister) for fetching // a specific Secret. This avoids requiring global or namespace list in controllers. type SecretFetcher func(string) (*corev1.Secret, error) @@ -77,7 +81,7 @@ type ExporterOptions struct { PrometheusHost string // ConfigMap is the data from config map config-observability. Must be present. - // See https://github.com/knative/serving/blob/master/config/config-observability.yaml + // See https://github.com/knative/serving/blob/main/config/config-observability.yaml // for details. ConfigMap map[string]string @@ -154,28 +158,14 @@ func UpdateExporter(ctx context.Context, ops ExporterOptions, logger *zap.Sugare // Updating the metrics config and the metrics exporters needs to be atomic to // avoid using an outdated metrics config with new exporters. - metricsMux.Lock() - defer metricsMux.Unlock() - - if isNewExporterRequired(newConfig) { - logger.Info("Flushing the existing exporter before setting up the new exporter.") - flushGivenExporter(curMetricsExporter) - e, f, err := newMetricsExporter(newConfig, logger) - if err != nil { - logger.Errorw("Failed to update a new metrics exporter based on metric config", zap.Error(err), "config", newConfig) - return err - } - existingConfig := curMetricsConfig - curMetricsExporter = e - if err := setFactory(f); err != nil { - logger.Errorw("Failed to update metrics factory when loading metric config", zap.Error(err), "config", newConfig) - return err - } - logger.Infof("Successfully updated the metrics exporter; old config: %v; new config %v", existingConfig, newConfig) + updateCmd := &updateMetricsConfigWithExporter{ + ctx: ctx, + newConfig: newConfig, + done: make(chan error), } - - setCurMetricsConfigUnlocked(newConfig) - return nil + mWorker.c <- updateCmd + err = <-updateCmd.done + return err } // isNewExporterRequired compares the non-nil newConfig against curMetricsConfig. When backend changes, @@ -228,27 +218,35 @@ func newMetricsExporter(config *metricsConfig, logger *zap.SugaredLogger) (view. } func getCurMetricsExporter() view.Exporter { - metricsMux.RLock() - defer metricsMux.RUnlock() - return curMetricsExporter + readCmd := &readExporter{done: make(chan *view.Exporter)} + mWorker.c <- readCmd + e := <-readCmd.done + return *e } func setCurMetricsExporter(e view.Exporter) { - metricsMux.Lock() - defer metricsMux.Unlock() - curMetricsExporter = e + setCmd := &setExporter{ + newExporter: &e, + done: make(chan struct{}), + } + mWorker.c <- setCmd + <-setCmd.done } func getCurMetricsConfig() *metricsConfig { - metricsMux.RLock() - defer metricsMux.RUnlock() - return curMetricsConfig + readCmd := &readMetricsConfig{done: make(chan *metricsConfig)} + mWorker.c <- readCmd + cfg := <-readCmd.done + return cfg } func setCurMetricsConfig(c *metricsConfig) { - metricsMux.Lock() - defer metricsMux.Unlock() - setCurMetricsConfigUnlocked(c) + setCmd := &setMetricsConfig{ + newConfig: c, + done: make(chan struct{}), + } + mWorker.c <- setCmd + <-setCmd.done } func setCurMetricsConfigUnlocked(c *metricsConfig) { diff --git a/vendor/knative.dev/pkg/metrics/memstats.go b/vendor/knative.dev/pkg/metrics/memstats.go index 719c7e0189e..d96a0f4bc5c 100644 --- a/vendor/knative.dev/pkg/metrics/memstats.go +++ b/vendor/knative.dev/pkg/metrics/memstats.go @@ -33,112 +33,112 @@ func NewMemStatsAll() *MemStatsProvider { Alloc: stats.Int64( "go_alloc", "The number of bytes of allocated heap objects.", - stats.UnitNone, + stats.UnitDimensionless, ), TotalAlloc: stats.Int64( "go_total_alloc", "The cumulative bytes allocated for heap objects.", - stats.UnitNone, + stats.UnitDimensionless, ), Sys: stats.Int64( "go_sys", "The total bytes of memory obtained from the OS.", - stats.UnitNone, + stats.UnitDimensionless, ), Lookups: stats.Int64( "go_lookups", "The number of pointer lookups performed by the runtime.", - stats.UnitNone, + stats.UnitDimensionless, ), Mallocs: stats.Int64( "go_mallocs", "The cumulative count of heap objects allocated.", - stats.UnitNone, + stats.UnitDimensionless, ), Frees: stats.Int64( "go_frees", "The cumulative count of heap objects freed.", - stats.UnitNone, + stats.UnitDimensionless, ), HeapAlloc: stats.Int64( "go_heap_alloc", "The number of bytes of allocated heap objects.", - stats.UnitNone, + stats.UnitDimensionless, ), HeapSys: stats.Int64( "go_heap_sys", "The number of bytes of heap memory obtained from the OS.", - stats.UnitNone, + stats.UnitDimensionless, ), HeapIdle: stats.Int64( "go_heap_idle", "The number of bytes in idle (unused) spans.", - stats.UnitNone, + stats.UnitDimensionless, ), HeapInuse: stats.Int64( "go_heap_in_use", "The number of bytes in in-use spans.", - stats.UnitNone, + stats.UnitDimensionless, ), HeapReleased: stats.Int64( "go_heap_released", "The number of bytes of physical memory returned to the OS.", - stats.UnitNone, + stats.UnitDimensionless, ), HeapObjects: stats.Int64( "go_heap_objects", "The number of allocated heap objects.", - stats.UnitNone, + stats.UnitDimensionless, ), StackInuse: stats.Int64( "go_stack_in_use", "The number of bytes in stack spans.", - stats.UnitNone, + stats.UnitDimensionless, ), StackSys: stats.Int64( "go_stack_sys", "The number of bytes of stack memory obtained from the OS.", - stats.UnitNone, + stats.UnitDimensionless, ), MSpanInuse: stats.Int64( "go_mspan_in_use", "The number of bytes of allocated mspan structures.", - stats.UnitNone, + stats.UnitDimensionless, ), MSpanSys: stats.Int64( "go_mspan_sys", "The number of bytes of memory obtained from the OS for mspan structures.", - stats.UnitNone, + stats.UnitDimensionless, ), MCacheInuse: stats.Int64( "go_mcache_in_use", "The number of bytes of allocated mcache structures.", - stats.UnitNone, + stats.UnitDimensionless, ), MCacheSys: stats.Int64( "go_mcache_sys", "The number of bytes of memory obtained from the OS for mcache structures.", - stats.UnitNone, + stats.UnitDimensionless, ), BuckHashSys: stats.Int64( "go_bucket_hash_sys", "The number of bytes of memory in profiling bucket hash tables.", - stats.UnitNone, + stats.UnitDimensionless, ), GCSys: stats.Int64( "go_gc_sys", "The number of bytes of memory in garbage collection metadata.", - stats.UnitNone, + stats.UnitDimensionless, ), OtherSys: stats.Int64( "go_other_sys", "The number of bytes of memory in miscellaneous off-heap runtime allocations.", - stats.UnitNone, + stats.UnitDimensionless, ), NextGC: stats.Int64( "go_next_gc", "The target heap size of the next GC cycle.", - stats.UnitNone, + stats.UnitDimensionless, ), LastGC: stats.Int64( "go_last_gc", @@ -153,17 +153,17 @@ func NewMemStatsAll() *MemStatsProvider { NumGC: stats.Int64( "go_num_gc", "The number of completed GC cycles.", - stats.UnitNone, + stats.UnitDimensionless, ), NumForcedGC: stats.Int64( "go_num_forced_gc", "The number of GC cycles that were forced by the application calling the GC function.", - stats.UnitNone, + stats.UnitDimensionless, ), GCCPUFraction: stats.Float64( "go_gc_cpu_fraction", "The fraction of this program's available CPU time used by the GC since the program started.", - stats.UnitNone, + stats.UnitDimensionless, ), } } diff --git a/vendor/knative.dev/pkg/metrics/metrics_worker.go b/vendor/knative.dev/pkg/metrics/metrics_worker.go new file mode 100644 index 00000000000..0b7753acb27 --- /dev/null +++ b/vendor/knative.dev/pkg/metrics/metrics_worker.go @@ -0,0 +1,111 @@ +/* +Copyright 2021 The Knative 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 metrics + +import ( + "context" + + "go.opencensus.io/stats/view" + "go.uber.org/zap" + "knative.dev/pkg/logging" +) + +type metricsWorker struct { + c chan command +} + +func newMetricsWorker() *metricsWorker { + return &metricsWorker{c: make(chan command)} +} + +type command interface { + handleCommand(w *metricsWorker) +} + +type readExporter struct { + done chan *view.Exporter +} + +type setExporter struct { + newExporter *view.Exporter + done chan struct{} +} + +type readMetricsConfig struct { + done chan *metricsConfig +} + +type updateMetricsConfigWithExporter struct { + ctx context.Context + newConfig *metricsConfig + done chan error +} + +type setMetricsConfig struct { + newConfig *metricsConfig + done chan struct{} +} + +func (cmd *readMetricsConfig) handleCommand(w *metricsWorker) { + cmd.done <- curMetricsConfig +} + +func (cmd *setMetricsConfig) handleCommand(w *metricsWorker) { + setCurMetricsConfigUnlocked(cmd.newConfig) + cmd.done <- struct{}{} +} + +func (cmd *updateMetricsConfigWithExporter) handleCommand(w *metricsWorker) { + ctx := cmd.ctx + logger := logging.FromContext(ctx) + if isNewExporterRequired(cmd.newConfig) { + logger.Info("Flushing the existing exporter before setting up the new exporter.") + flushGivenExporter(curMetricsExporter) + e, f, err := newMetricsExporter(cmd.newConfig, logger) + if err != nil { + logger.Errorw("Failed to update a new metrics exporter based on metric config", zap.Error(err), "config", cmd.newConfig) + cmd.done <- err + return + } + existingConfig := curMetricsConfig + curMetricsExporter = e + if err := setFactory(f); err != nil { + logger.Errorw("Failed to update metrics factory when loading metric config", zap.Error(err), "config", cmd.newConfig) + cmd.done <- err + return + } + logger.Infof("Successfully updated the metrics exporter; old config: %v; new config %v", existingConfig, cmd.newConfig) + } + setCurMetricsConfigUnlocked(cmd.newConfig) + cmd.done <- nil +} + +func (w *metricsWorker) start() { + for { + cmd := <-w.c + cmd.handleCommand(w) + } +} + +func (cmd *setExporter) handleCommand(w *metricsWorker) { + curMetricsExporter = *cmd.newExporter + cmd.done <- struct{}{} +} + +func (cmd *readExporter) handleCommand(w *metricsWorker) { + cmd.done <- &curMetricsExporter +} diff --git a/vendor/knative.dev/pkg/metrics/reflector.go b/vendor/knative.dev/pkg/metrics/reflector.go deleted file mode 100644 index 548b811b602..00000000000 --- a/vendor/knative.dev/pkg/metrics/reflector.go +++ /dev/null @@ -1,176 +0,0 @@ -/* -Copyright 2019 The Knative 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 metrics - -import ( - "go.opencensus.io/stats" - "go.opencensus.io/stats/view" - "go.opencensus.io/tag" - "k8s.io/client-go/tools/cache" -) - -// ReflectorProvider implements reflector.MetricsProvider and may be used with -// reflector.SetProvider to have metrics exported to the provided metrics. -type ReflectorProvider struct { - ItemsInList *stats.Float64Measure - // TODO(mattmoor): This is not in the latest version, so it will - // be removed in a future version. - ItemsInMatch *stats.Float64Measure - ItemsInWatch *stats.Float64Measure - LastResourceVersion *stats.Float64Measure - ListDuration *stats.Float64Measure - Lists *stats.Int64Measure - ShortWatches *stats.Int64Measure - WatchDuration *stats.Float64Measure - Watches *stats.Int64Measure -} - -var ( - _ cache.MetricsProvider = (*ReflectorProvider)(nil) -) - -// NewItemsInListMetric implements MetricsProvider -func (rp *ReflectorProvider) NewItemsInListMetric(name string) cache.SummaryMetric { - return floatMetric{ - mutators: []tag.Mutator{tag.Insert(tagName, name)}, - measure: rp.ItemsInList, - } -} - -// ItemsInListView returns a view of the ItemsInList metric. -func (rp *ReflectorProvider) ItemsInListView() *view.View { - return measureView(rp.ItemsInList, view.Distribution(BucketsNBy10(0.1, 6)...)) -} - -// NewItemsInMatchMetric implements MetricsProvider -func (rp *ReflectorProvider) NewItemsInMatchMetric(name string) cache.SummaryMetric { - return floatMetric{ - mutators: []tag.Mutator{tag.Insert(tagName, name)}, - measure: rp.ItemsInMatch, - } -} - -// ItemsInMatchView returns a view of the ItemsInMatch metric. -func (rp *ReflectorProvider) ItemsInMatchView() *view.View { - return measureView(rp.ItemsInMatch, view.Distribution(BucketsNBy10(0.1, 6)...)) -} - -// NewItemsInWatchMetric implements MetricsProvider -func (rp *ReflectorProvider) NewItemsInWatchMetric(name string) cache.SummaryMetric { - return floatMetric{ - mutators: []tag.Mutator{tag.Insert(tagName, name)}, - measure: rp.ItemsInWatch, - } -} - -// ItemsInWatchView returns a view of the ItemsInWatch metric. -func (rp *ReflectorProvider) ItemsInWatchView() *view.View { - return measureView(rp.ItemsInWatch, view.Distribution(BucketsNBy10(0.1, 6)...)) -} - -// NewLastResourceVersionMetric implements MetricsProvider -func (rp *ReflectorProvider) NewLastResourceVersionMetric(name string) cache.GaugeMetric { - return floatMetric{ - mutators: []tag.Mutator{tag.Insert(tagName, name)}, - measure: rp.LastResourceVersion, - } -} - -// LastResourceVersionView returns a view of the LastResourceVersion metric. -func (rp *ReflectorProvider) LastResourceVersionView() *view.View { - return measureView(rp.LastResourceVersion, view.LastValue()) -} - -// NewListDurationMetric implements MetricsProvider -func (rp *ReflectorProvider) NewListDurationMetric(name string) cache.SummaryMetric { - return floatMetric{ - mutators: []tag.Mutator{tag.Insert(tagName, name)}, - measure: rp.ListDuration, - } -} - -// ListDurationView returns a view of the ListDuration metric. -func (rp *ReflectorProvider) ListDurationView() *view.View { - return measureView(rp.ListDuration, view.Distribution(BucketsNBy10(0.1, 6)...)) -} - -// NewListsMetric implements MetricsProvider -func (rp *ReflectorProvider) NewListsMetric(name string) cache.CounterMetric { - return counterMetric{ - mutators: []tag.Mutator{tag.Insert(tagName, name)}, - measure: rp.Lists, - } -} - -// ListsView returns a view of the Lists metric. -func (rp *ReflectorProvider) ListsView() *view.View { - return measureView(rp.Lists, view.Count()) -} - -// NewShortWatchesMetric implements MetricsProvider -func (rp *ReflectorProvider) NewShortWatchesMetric(name string) cache.CounterMetric { - return counterMetric{ - mutators: []tag.Mutator{tag.Insert(tagName, name)}, - measure: rp.ShortWatches, - } -} - -// ShortWatchesView returns a view of the ShortWatches metric. -func (rp *ReflectorProvider) ShortWatchesView() *view.View { - return measureView(rp.ShortWatches, view.Count()) -} - -// NewWatchDurationMetric implements MetricsProvider -func (rp *ReflectorProvider) NewWatchDurationMetric(name string) cache.SummaryMetric { - return floatMetric{ - mutators: []tag.Mutator{tag.Insert(tagName, name)}, - measure: rp.WatchDuration, - } -} - -// WatchDurationView returns a view of the WatchDuration metric. -func (rp *ReflectorProvider) WatchDurationView() *view.View { - return measureView(rp.WatchDuration, view.Distribution(BucketsNBy10(0.1, 6)...)) -} - -// NewWatchesMetric implements MetricsProvider -func (rp *ReflectorProvider) NewWatchesMetric(name string) cache.CounterMetric { - return counterMetric{ - mutators: []tag.Mutator{tag.Insert(tagName, name)}, - measure: rp.Watches, - } -} - -// WatchesView returns a view of the Watches metric. -func (rp *ReflectorProvider) WatchesView() *view.View { - return measureView(rp.Watches, view.Count()) -} - -// DefaultViews returns a list of views suitable for passing to view.Register -func (rp *ReflectorProvider) DefaultViews() []*view.View { - return []*view.View{ - rp.ItemsInListView(), - rp.ItemsInMatchView(), - rp.ItemsInWatchView(), - rp.LastResourceVersionView(), - rp.ListDurationView(), - rp.ListsView(), - rp.ShortWatchesView(), - rp.WatchDurationView(), - rp.WatchesView(), - } -} diff --git a/vendor/knative.dev/pkg/metrics/resource_view.go b/vendor/knative.dev/pkg/metrics/resource_view.go index 7135af70aa8..236fd588baf 100644 --- a/vendor/knative.dev/pkg/metrics/resource_view.go +++ b/vendor/knative.dev/pkg/metrics/resource_view.go @@ -82,10 +82,16 @@ func cleanup() { expiryCutoff := allMeters.clock.Now().Add(-1 * maxMeterExporterAge) allMeters.lock.Lock() defer allMeters.lock.Unlock() + resourceViews.lock.Lock() + defer resourceViews.lock.Unlock() for key, meter := range allMeters.meters { if key != "" && meter.t.Before(expiryCutoff) { flushGivenExporter(meter.e) + // Make a copy of views to avoid data races + viewsCopy := copyViews(resourceViews.views) + meter.m.Unregister(viewsCopy...) delete(allMeters.meters, key) + meter.m.Stop() } } } @@ -139,7 +145,7 @@ func RegisterResourceView(views ...*view.View) error { return nil } -// UnregisterResourceView is similar to view.Unregiste(), except that it will +// UnregisterResourceView is similar to view.Unregister(), except that it will // unregister the view across all Resources tracked byt he system, rather than // simply the default view. func UnregisterResourceView(views ...*view.View) { diff --git a/vendor/knative.dev/pkg/network/h2c.go b/vendor/knative.dev/pkg/network/h2c.go index 73fabee977d..f950b9c34fc 100644 --- a/vendor/knative.dev/pkg/network/h2c.go +++ b/vendor/knative.dev/pkg/network/h2c.go @@ -41,8 +41,13 @@ func NewServer(addr string, h http.Handler) *http.Server { // to explicitly allow h2c (http2 without TLS) transport. // See https://github.com/golang/go/issues/14141 for more details. func NewH2CTransport() http.RoundTripper { + return newH2CTransport(false) +} + +func newH2CTransport(disableCompression bool) http.RoundTripper { return &http2.Transport{ - AllowHTTP: true, + AllowHTTP: true, + DisableCompression: disableCompression, DialTLS: func(netw, addr string, _ *tls.Config) (net.Conn, error) { return DialWithBackOff(context.Background(), netw, addr) diff --git a/vendor/knative.dev/pkg/network/handlers/drain.go b/vendor/knative.dev/pkg/network/handlers/drain.go index 0ed37ba6dd1..b8dc6ff1b44 100644 --- a/vendor/knative.dev/pkg/network/handlers/drain.go +++ b/vendor/knative.dev/pkg/network/handlers/drain.go @@ -17,6 +17,7 @@ limitations under the License. package handlers import ( + "fmt" "net/http" "sync" "time" @@ -90,11 +91,11 @@ func (d *Drainer) ServeHTTP(w http.ResponseWriter, r *http.Request) { } return } - if network.IsKProbe(r) { + if isKProbe(r) { if d.draining() { http.Error(w, "shutting down", http.StatusServiceUnavailable) } else { - network.ServeKProbe(w, r) + serveKProbe(w, r) } return } @@ -146,3 +147,21 @@ func (d *Drainer) draining() bool { defer d.RUnlock() return d.timer != nil } + +// isKProbe returns true if the request is a knatvie probe. +func isKProbe(r *http.Request) bool { + return r.Header.Get(network.ProbeHeaderName) == network.ProbeHeaderValue +} + +// serveKProbe serve KProbe requests. +func serveKProbe(w http.ResponseWriter, r *http.Request) { + hh := r.Header.Get(network.HashHeaderName) + if hh == "" { + http.Error(w, + fmt.Sprintf("a probe request must contain a non-empty %q header", network.HashHeaderName), + http.StatusBadRequest) + return + } + w.Header().Set(network.HashHeaderName, hh) + w.WriteHeader(http.StatusOK) +} diff --git a/vendor/knative.dev/pkg/network/network.go b/vendor/knative.dev/pkg/network/network.go index b2ac63ce77a..cf5feaa8fa7 100644 --- a/vendor/knative.dev/pkg/network/network.go +++ b/vendor/knative.dev/pkg/network/network.go @@ -17,7 +17,6 @@ limitations under the License. package network import ( - "fmt" "net/http" "strings" "time" @@ -52,33 +51,19 @@ const ( // uses to find out which version of the networking config is deployed. HashHeaderName = "K-Network-Hash" + // KubeProbeUAPrefix is the prefix for the User-Agent header. // Since K8s 1.8, prober requests have // User-Agent = "kube-probe/{major-version}.{minor-version}". KubeProbeUAPrefix = "kube-probe/" + // KubeletProbeHeaderName is the header name to augment the probes, because // Istio with mTLS rewrites probes, but their probes pass a different - // user-agent. So we augment the probes with this header. + // user-agent. KubeletProbeHeaderName = "K-Kubelet-Probe" ) // IsKubeletProbe returns true if the request is a Kubernetes probe. func IsKubeletProbe(r *http.Request) bool { - return strings.HasPrefix(r.Header.Get("User-Agent"), KubeProbeUAPrefix) || + return strings.HasPrefix(r.Header.Get(UserAgentKey), KubeProbeUAPrefix) || r.Header.Get(KubeletProbeHeaderName) != "" } - -// IsKProbe returns true if the request is a knatvie probe. -func IsKProbe(r *http.Request) bool { - return r.Header.Get(ProbeHeaderName) == ProbeHeaderValue -} - -// ServeKProbe serve KProbe requests. -func ServeKProbe(w http.ResponseWriter, r *http.Request) { - hh := r.Header.Get(HashHeaderName) - if hh == "" { - http.Error(w, fmt.Sprintf("a probe request must contain a non-empty %q header", HashHeaderName), http.StatusBadRequest) - return - } - w.Header().Set(HashHeaderName, hh) - w.WriteHeader(http.StatusOK) -} diff --git a/vendor/knative.dev/pkg/network/transports.go b/vendor/knative.dev/pkg/network/transports.go index c37b99d5781..26ce8239576 100644 --- a/vendor/knative.dev/pkg/network/transports.go +++ b/vendor/knative.dev/pkg/network/transports.go @@ -94,13 +94,14 @@ func dialBackOffHelper(ctx context.Context, network, address string, bo wait.Bac return nil, fmt.Errorf("timed out dialing after %.2fs", elapsed.Seconds()) } -func newHTTPTransport(disableKeepAlives bool, maxIdle, maxIdlePerHost int) http.RoundTripper { +func newHTTPTransport(disableKeepAlives, disableCompression bool, maxIdle, maxIdlePerHost int) http.RoundTripper { transport := http.DefaultTransport.(*http.Transport).Clone() transport.DialContext = DialWithBackOff transport.DisableKeepAlives = disableKeepAlives transport.MaxIdleConns = maxIdle transport.MaxIdleConnsPerHost = maxIdlePerHost transport.ForceAttemptHTTP2 = false + transport.DisableCompression = disableCompression return transport } @@ -108,7 +109,7 @@ func newHTTPTransport(disableKeepAlives bool, maxIdle, maxIdlePerHost int) http. // since it will not cache connections. func NewProberTransport() http.RoundTripper { return newAutoTransport( - newHTTPTransport(true /*disable keep-alives*/, 0, 0 /*no caching*/), + newHTTPTransport(true /*disable keep-alives*/, false /*disable auto-compression*/, 0, 0 /*no caching*/), NewH2CTransport()) } @@ -116,8 +117,17 @@ func NewProberTransport() http.RoundTripper { // based on the request's HTTP version. func NewAutoTransport(maxIdle, maxIdlePerHost int) http.RoundTripper { return newAutoTransport( - newHTTPTransport(false /*disable keep-alives*/, maxIdle, maxIdlePerHost), - NewH2CTransport()) + newHTTPTransport(false /*disable keep-alives*/, false /*disable auto-compression*/, maxIdle, maxIdlePerHost), + newH2CTransport(false /*disable auto-compression*/)) +} + +// NewProxyAutoTransport creates a RoundTripper suitable for use by a reverse +// proxy. The returned transport uses HTTP or H2C based on the request's HTTP +// version. The transport has DisableCompression set to true. +func NewProxyAutoTransport(maxIdle, maxIdlePerHost int) http.RoundTripper { + return newAutoTransport( + newHTTPTransport(false /*disable keep-alives*/, true /*disable auto-compression*/, maxIdle, maxIdlePerHost), + newH2CTransport(true /*disable auto-compression*/)) } // AutoTransport uses h2c for HTTP2 requests and falls back to `http.DefaultTransport` for all others diff --git a/vendor/knative.dev/pkg/reconciler/testing/clock.go b/vendor/knative.dev/pkg/reconciler/testing/clock.go deleted file mode 100644 index 44ba77cdb60..00000000000 --- a/vendor/knative.dev/pkg/reconciler/testing/clock.go +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright 2019 The Knative 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 testing - -import ( - "time" -) - -type FakeClock struct { - Time time.Time -} - -func (c FakeClock) Now() time.Time { - return c.Time -} diff --git a/vendor/knative.dev/pkg/reconciler/testing/context.go b/vendor/knative.dev/pkg/reconciler/testing/context.go index 7c36d8ed701..e14aa2ade08 100644 --- a/vendor/knative.dev/pkg/reconciler/testing/context.go +++ b/vendor/knative.dev/pkg/reconciler/testing/context.go @@ -18,10 +18,19 @@ package testing import ( "context" + "testing" + "time" - "go.uber.org/zap/zaptest" + "go.uber.org/atomic" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/runtime/serializer" + "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/rest" + clientgotesting "k8s.io/client-go/testing" "k8s.io/client-go/tools/record" "knative.dev/pkg/controller" @@ -30,16 +39,86 @@ import ( ) // SetupFakeContext sets up the the Context and the fake informers for the tests. -func SetupFakeContext(t zaptest.TestingT) (context.Context, []controller.Informer) { +func SetupFakeContext(t testing.TB) (context.Context, []controller.Informer) { c, _, is := SetupFakeContextWithCancel(t) return c, is } // SetupFakeContextWithCancel sets up the the Context and the fake informers for the tests // The provided context can be canceled using provided callback. -func SetupFakeContextWithCancel(t zaptest.TestingT) (context.Context, context.CancelFunc, []controller.Informer) { +func SetupFakeContextWithCancel(t testing.TB) (context.Context, context.CancelFunc, []controller.Informer) { ctx, c := context.WithCancel(logtesting.TestContextWithLogger(t)) ctx = controller.WithEventRecorder(ctx, record.NewFakeRecorder(1000)) ctx, is := injection.Fake.SetupInformers(ctx, &rest.Config{}) return ctx, c, is } + +// fakeClient is an interface capturing the two functions we need from fake clients. +type fakeClient interface { + PrependWatchReactor(resource string, reaction clientgotesting.WatchReactionFunc) + PrependReactor(verb, resource string, reaction clientgotesting.ReactionFunc) +} + +// withTracker is an interface capturing only the Tracker function. The dynamic client +// currently does not have that, so we need to special-case it. +type withTracker interface { + Tracker() clientgotesting.ObjectTracker +} + +// RunAndSyncInformers runs the given informers, then makes sure their caches are all +// synced and in addition makes sure that all the Watch calls have been properly setup. +// See https://github.com/kubernetes/kubernetes/issues/95372 for background on the Watch +// calls tragedy. +func RunAndSyncInformers(ctx context.Context, informers ...controller.Informer) (func(), error) { + var watchesPending atomic.Int32 + + for _, client := range injection.Fake.FetchAllClients(ctx) { + c := client.(fakeClient) + + var tracker clientgotesting.ObjectTracker + if withTracker, ok := c.(withTracker); ok { + tracker = withTracker.Tracker() + } else { + // Required setup for the dynamic client as it doesn't define a Tracker() function. + // TODO(markusthoemmes): Drop this if https://github.com/kubernetes/kubernetes/pull/100085 lands. + scheme := runtime.NewScheme() + scheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "fake-dynamic-client-group", Version: "v1", Kind: "List"}, &unstructured.UnstructuredList{}) + codecs := serializer.NewCodecFactory(scheme) + tracker = clientgotesting.NewObjectTracker(scheme, codecs.UniversalDecoder()) + } + + c.PrependReactor("list", "*", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { + // Every list (before actual informer usage) is going to be followed by a Watch call. + watchesPending.Inc() + return false, nil, nil + }) + + c.PrependWatchReactor("*", func(action clientgotesting.Action) (handled bool, ret watch.Interface, err error) { + // The actual Watch call. This is a reimplementation of the default Watch + // calls in fakes to guarantee we have actually **done** the work. + gvr := action.GetResource() + ns := action.GetNamespace() + watch, err := tracker.Watch(gvr, ns) + if err != nil { + return false, nil, err + } + + watchesPending.Dec() + + return true, watch, nil + }) + } + + wf, err := controller.RunInformers(ctx.Done(), informers...) + if err != nil { + return wf, err + } + + err = wait.PollImmediate(time.Microsecond, wait.ForeverTestTimeout, func() (bool, error) { + if watchesPending.Load() == 0 { + return true, nil + } + return false, nil + }) + return wf, err +} diff --git a/vendor/knative.dev/pkg/system/clock.go b/vendor/knative.dev/pkg/system/clock.go deleted file mode 100644 index 7d99d9b5cdf..00000000000 --- a/vendor/knative.dev/pkg/system/clock.go +++ /dev/null @@ -1,32 +0,0 @@ -/* -Copyright 2019 The Knative 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 system - -import ( - "time" -) - -// Mockable interface for time based testing -type Clock interface { - Now() time.Time -} - -type RealClock struct{} - -func (RealClock) Now() time.Time { - return time.Now() -} diff --git a/vendor/knative.dev/pkg/test/README.md b/vendor/knative.dev/pkg/test/README.md index d106ffec96c..c56070878b7 100644 --- a/vendor/knative.dev/pkg/test/README.md +++ b/vendor/knative.dev/pkg/test/README.md @@ -28,7 +28,7 @@ You can use the test library in this dir to: These flags are useful for running against an existing cluster, making use of your existing -[environment setup](https://github.com/knative/serving/blob/master/DEVELOPMENT.md#environment-setup). +[environment setup](https://github.com/knative/serving/blob/main/DEVELOPMENT.md#environment-setup). By importing `knative.dev/pkg/test` you get access to a global variable called `test.Flags` which holds the values of @@ -46,7 +46,7 @@ _See [e2e_flags.go](./e2e_flags.go)._ debug logs will be emitted to stdout. We are using a generic -[FormatLogger](https://github.com/knative/pkg/blob/master/test/logging/logging.go#L49) +[FormatLogger](https://github.com/knative/pkg/blob/main/test/logging/logging.go#L49) that can be passed in any existing logger that satisfies it. Test can use the generic [logging methods](https://golang.org/pkg/testing/#T) to log info and error logs. All the common methods accept generic FormatLogger as a parameter @@ -64,7 +64,7 @@ _See [logging.go](./logging/logging.go)._ ### Check Knative Serving resources _WARNING: this code also exists in -[`knative/serving`](https://github.com/knative/serving/blob/master/test/adding_tests.md#make-requests-against-deployed-services)._ +[`knative/serving`](https://github.com/knative/serving/blob/main/test/adding_tests.md#make-requests-against-deployed-services)._ After creating Knative Serving resources or making changes to them, you will need to wait for the system to realize those changes. You can use the Knative diff --git a/vendor/knative.dev/pkg/test/logstream/README.md b/vendor/knative.dev/pkg/test/logstream/README.md index 18577b8552c..7c7886bd504 100644 --- a/vendor/knative.dev/pkg/test/logstream/README.md +++ b/vendor/knative.dev/pkg/test/logstream/README.md @@ -8,7 +8,7 @@ This is a guide to start using `logstream` in your e2e testing. knative test scripts already define this, and in some places (e.g. serving) randomize it. However, to facilitate usage outside of CI, you should consider including a package like - [this](https://github.com/knative/serving/blob/master/test/defaultsystem/system.go) + [this](https://github.com/knative/serving/blob/main/test/defaultsystem/system.go) and linking it like [this](https://github.com/knative/serving/blob/e797247322b5aa35001152d2a2715dbc20a86cc4/test/conformance.go#L20-L23) @@ -49,4 +49,4 @@ Now, any log statements that the library prints through this logger will appear in the logstream! For an example of this pattern, see -[the knative/networking prober library](https://github.com/knative/networking/blob/master/pkg/status/status.go). +[the knative/networking prober library](https://github.com/knative/networking/blob/main/pkg/status/status.go). diff --git a/vendor/knative.dev/pkg/test/zipkin/util.go b/vendor/knative.dev/pkg/test/zipkin/util.go index 95659c3b4f1..5e9cb5feb42 100644 --- a/vendor/knative.dev/pkg/test/zipkin/util.go +++ b/vendor/knative.dev/pkg/test/zipkin/util.go @@ -46,7 +46,7 @@ const ( ZipkinTraceIDHeader = "ZIPKIN_TRACE_ID" // ZipkinPort is port exposed by the Zipkin Pod - // https://github.com/knative/serving/blob/master/config/monitoring/200-common/100-zipkin.yaml#L25 configures the Zipkin Port on the cluster. + // https://github.com/knative/serving/blob/main/config/monitoring/200-common/100-zipkin.yaml#L25 configures the Zipkin Port on the cluster. ZipkinPort = 9411 // ZipkinTraceEndpoint port-forwarded zipkin endpoint diff --git a/vendor/knative.dev/pkg/version/version.go b/vendor/knative.dev/pkg/version/version.go index 34504debf4b..e14cbb1b37b 100644 --- a/vendor/knative.dev/pkg/version/version.go +++ b/vendor/knative.dev/pkg/version/version.go @@ -32,8 +32,9 @@ const ( // NOTE: If you are changing this line, please also update the minimum kubernetes // version listed here: - // https://github.com/knative/docs/blob/master/docs/install/any-kubernetes-cluster.md#before-you-begin - defaultMinimumVersion = "v1.17.0" + // https://github.com/knative/docs/blob/main/docs/install/any-kubernetes-cluster.md#before-you-begin + // https://github.com/knative/docs/blob/main/docs/install/knative-with-operators.md#prerequisites + defaultMinimumVersion = "v1.18.0" ) func getMinimumVersion() string { diff --git a/vendor/knative.dev/pkg/webhook/README.md b/vendor/knative.dev/pkg/webhook/README.md index 18ca37ce180..cac4fb664cb 100644 --- a/vendor/knative.dev/pkg/webhook/README.md +++ b/vendor/knative.dev/pkg/webhook/README.md @@ -25,7 +25,7 @@ The code to stand up such a webhook looks roughly like this: ```go // Create a function matching this signature to pass into sharedmain. func NewResourceAdmissionController(ctx context.Context, cmw configmap.Watcher) *controller.Impl { - return resourcesemantics.NewAdmissionController(ctx, + return validation.NewAdmissionController(ctx, // Name of the resource webhook (created via yaml) fmt.Sprintf("resources.webhook.%s.knative.dev", system.Namespace()), diff --git a/vendor/knative.dev/pkg/webhook/resourcesemantics/defaulting/defaulting.go b/vendor/knative.dev/pkg/webhook/resourcesemantics/defaulting/defaulting.go index d148b88b01d..d57cc41f19b 100644 --- a/vendor/knative.dev/pkg/webhook/resourcesemantics/defaulting/defaulting.go +++ b/vendor/knative.dev/pkg/webhook/resourcesemantics/defaulting/defaulting.go @@ -25,7 +25,7 @@ import ( "sort" "strings" - "github.com/markbates/inflect" + "github.com/gobuffalo/flect" "go.uber.org/zap" jsonpatch "gomodules.xyz/jsonpatch/v2" admissionv1 "k8s.io/api/admission/v1" @@ -138,7 +138,7 @@ func (ac *reconciler) reconcileMutatingWebhook(ctx context.Context, caCert []byt rules := make([]admissionregistrationv1.RuleWithOperations, 0, len(ac.handlers)) for gvk := range ac.handlers { - plural := strings.ToLower(inflect.Pluralize(gvk.Kind)) + plural := strings.ToLower(flect.Pluralize(gvk.Kind)) rules = append(rules, admissionregistrationv1.RuleWithOperations{ Operations: []admissionregistrationv1.OperationType{ diff --git a/vendor/knative.dev/pkg/webhook/resourcesemantics/validation/reconcile_config.go b/vendor/knative.dev/pkg/webhook/resourcesemantics/validation/reconcile_config.go index 4e30f6c441b..7d1a7adcf54 100644 --- a/vendor/knative.dev/pkg/webhook/resourcesemantics/validation/reconcile_config.go +++ b/vendor/knative.dev/pkg/webhook/resourcesemantics/validation/reconcile_config.go @@ -22,7 +22,7 @@ import ( "sort" "strings" - "github.com/markbates/inflect" + "github.com/gobuffalo/flect" "go.uber.org/zap" admissionregistrationv1 "k8s.io/api/admissionregistration/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -100,7 +100,7 @@ func (ac *reconciler) reconcileValidatingWebhook(ctx context.Context, caCert []b rules := make([]admissionregistrationv1.RuleWithOperations, 0, len(ac.handlers)) for gvk := range ac.handlers { - plural := strings.ToLower(inflect.Pluralize(gvk.Kind)) + plural := strings.ToLower(flect.Pluralize(gvk.Kind)) rules = append(rules, admissionregistrationv1.RuleWithOperations{ Operations: []admissionregistrationv1.OperationType{ diff --git a/vendor/knative.dev/pkg/webhook/webhook.go b/vendor/knative.dev/pkg/webhook/webhook.go index ef578c4ee2a..ab54e36b549 100644 --- a/vendor/knative.dev/pkg/webhook/webhook.go +++ b/vendor/knative.dev/pkg/webhook/webhook.go @@ -21,6 +21,7 @@ import ( "crypto/tls" "errors" "fmt" + "html" "net/http" "time" @@ -140,7 +141,7 @@ func New( } webhook.mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - http.Error(w, fmt.Sprint("no controller registered for: ", r.URL.Path), http.StatusBadRequest) + http.Error(w, fmt.Sprint("no controller registered for: ", html.EscapeString(r.URL.Path)), http.StatusBadRequest) }) for _, controller := range controllers { diff --git a/vendor/modules.txt b/vendor/modules.txt index cc421bc239b..45c225dc2a9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ cloud.google.com/go/trace/apiv2 contrib.go.opencensus.io/exporter/ocagent # contrib.go.opencensus.io/exporter/prometheus v0.2.1-0.20200609204449-6bcf6f8577f0 contrib.go.opencensus.io/exporter/prometheus -# contrib.go.opencensus.io/exporter/stackdriver v0.13.4 => contrib.go.opencensus.io/exporter/stackdriver v0.13.4 +# contrib.go.opencensus.io/exporter/stackdriver v0.13.5 => contrib.go.opencensus.io/exporter/stackdriver v0.13.4 contrib.go.opencensus.io/exporter/stackdriver contrib.go.opencensus.io/exporter/stackdriver/monitoredresource contrib.go.opencensus.io/exporter/stackdriver/monitoredresource/aws @@ -147,8 +147,8 @@ github.com/go-openapi/jsonreference github.com/go-openapi/spec # github.com/go-openapi/swag v0.19.13 github.com/go-openapi/swag -# github.com/gobuffalo/envy v1.7.1 -github.com/gobuffalo/envy +# github.com/gobuffalo/flect v0.2.2 +github.com/gobuffalo/flect # github.com/gogo/protobuf v1.3.2 github.com/gogo/protobuf/proto github.com/gogo/protobuf/sortkeys @@ -164,7 +164,7 @@ github.com/golang/protobuf/ptypes/any github.com/golang/protobuf/ptypes/duration github.com/golang/protobuf/ptypes/timestamp github.com/golang/protobuf/ptypes/wrappers -# github.com/google/go-cmp v0.5.4 +# github.com/google/go-cmp v0.5.5 github.com/google/go-cmp/cmp github.com/google/go-cmp/cmp/cmpopts github.com/google/go-cmp/cmp/internal/diff @@ -201,7 +201,7 @@ github.com/google/go-containerregistry/pkg/authn/k8schain # github.com/google/gofuzz v1.2.0 github.com/google/gofuzz github.com/google/gofuzz/bytesource -# github.com/google/uuid v1.1.2 +# github.com/google/uuid v1.2.0 github.com/google/uuid # github.com/googleapis/gax-go/v2 v2.0.5 github.com/googleapis/gax-go/v2 @@ -232,8 +232,6 @@ github.com/jenkins-x/go-scm/scm/driver/gitlab github.com/jenkins-x/go-scm/scm/driver/internal/null # github.com/jmespath/go-jmespath v0.3.0 github.com/jmespath/go-jmespath -# github.com/joho/godotenv v1.3.0 -github.com/joho/godotenv # github.com/josharian/intern v1.0.0 github.com/josharian/intern # github.com/json-iterator/go v1.1.10 @@ -247,8 +245,6 @@ github.com/lightstep/tracecontext.go/tracestate github.com/mailru/easyjson/buffer github.com/mailru/easyjson/jlexer github.com/mailru/easyjson/jwriter -# github.com/markbates/inflect v1.0.4 -github.com/markbates/inflect # github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 github.com/matttproud/golang_protobuf_extensions/pbutil # github.com/mitchellh/go-homedir v1.1.0 @@ -266,13 +262,13 @@ github.com/opencontainers/image-spec/specs-go/v1 github.com/openzipkin/zipkin-go/model # github.com/pkg/errors v0.9.1 github.com/pkg/errors -# github.com/prometheus/client_golang v1.8.0 +# github.com/prometheus/client_golang v1.9.0 github.com/prometheus/client_golang/prometheus github.com/prometheus/client_golang/prometheus/internal github.com/prometheus/client_golang/prometheus/promhttp # github.com/prometheus/client_model v0.2.0 github.com/prometheus/client_model/go -# github.com/prometheus/common v0.15.0 +# github.com/prometheus/common v0.19.0 github.com/prometheus/common/expfmt github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg github.com/prometheus/common/log @@ -284,10 +280,6 @@ github.com/prometheus/procfs/internal/util # github.com/prometheus/statsd_exporter v0.15.0 github.com/prometheus/statsd_exporter/pkg/mapper github.com/prometheus/statsd_exporter/pkg/mapper/fsm -# github.com/rogpeppe/go-internal v1.5.2 -github.com/rogpeppe/go-internal/modfile -github.com/rogpeppe/go-internal/module -github.com/rogpeppe/go-internal/semver # github.com/shurcooL/githubv4 v0.0.0-20190718010115-4ba037080260 github.com/shurcooL/githubv4 # github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f @@ -307,7 +299,7 @@ github.com/vdemeester/k8s-pkg-credentialprovider/aws github.com/vdemeester/k8s-pkg-credentialprovider/azure github.com/vdemeester/k8s-pkg-credentialprovider/gcp github.com/vdemeester/k8s-pkg-credentialprovider/secrets -# go.opencensus.io v0.22.5 +# go.opencensus.io v0.23.0 go.opencensus.io go.opencensus.io/internal go.opencensus.io/internal/tagencoding @@ -330,7 +322,7 @@ go.opencensus.io/trace/propagation go.opencensus.io/trace/tracestate # go.uber.org/atomic v1.7.0 go.uber.org/atomic -# go.uber.org/automaxprocs v1.3.0 +# go.uber.org/automaxprocs v1.4.0 go.uber.org/automaxprocs/internal/cgroups go.uber.org/automaxprocs/internal/runtime go.uber.org/automaxprocs/maxprocs @@ -430,7 +422,7 @@ google.golang.org/appengine/internal/socket google.golang.org/appengine/internal/urlfetch google.golang.org/appengine/socket google.golang.org/appengine/urlfetch -# google.golang.org/genproto v0.0.0-20201211151036-40ec1c210f7a +# google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d google.golang.org/genproto/googleapis/api google.golang.org/genproto/googleapis/api/annotations google.golang.org/genproto/googleapis/api/distribution @@ -444,7 +436,7 @@ google.golang.org/genproto/googleapis/monitoring/v3 google.golang.org/genproto/googleapis/rpc/status google.golang.org/genproto/googleapis/type/calendarperiod google.golang.org/genproto/protobuf/field_mask -# google.golang.org/grpc v1.34.0 +# google.golang.org/grpc v1.36.0 google.golang.org/grpc google.golang.org/grpc/attributes google.golang.org/grpc/backoff @@ -482,6 +474,7 @@ google.golang.org/grpc/internal/grpclog google.golang.org/grpc/internal/grpcrand google.golang.org/grpc/internal/grpcsync google.golang.org/grpc/internal/grpcutil +google.golang.org/grpc/internal/metadata google.golang.org/grpc/internal/resolver google.golang.org/grpc/internal/resolver/dns google.golang.org/grpc/internal/resolver/passthrough @@ -921,7 +914,7 @@ k8s.io/utils/buffer k8s.io/utils/integer k8s.io/utils/pointer k8s.io/utils/trace -# knative.dev/pkg v0.0.0-20210127163530-0d31134d5f4e +# knative.dev/pkg v0.0.0-20210331065221-952fdd90dbb0 knative.dev/pkg/apis knative.dev/pkg/apis/duck knative.dev/pkg/apis/duck/ducktypes