diff --git a/go.mod b/go.mod index 231a3adee..d10b2570b 100644 --- a/go.mod +++ b/go.mod @@ -5,21 +5,19 @@ go 1.13 require ( github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 // indirect - github.com/json-iterator/go v1.1.9 // indirect - github.com/jteeuwen/go-bindata v3.0.8-0.20151023091102-a0ff2567cfb7+incompatible - github.com/openshift/api v0.0.0-20200417173520-2ef3f20bd355 - github.com/openshift/build-machinery-go v0.0.0-20200211121458-5e3d6e570160 + github.com/go-bindata/go-bindata v3.1.2+incompatible + github.com/openshift/api v0.0.0-20200424083944-0422dc17083e + github.com/openshift/build-machinery-go v0.0.0-20200424080330-082bf86082cc github.com/openshift/client-go v0.0.0-20200326155132-2a6cd50aedd0 - github.com/openshift/library-go v0.0.0-20200414135834-ccc4bb27d032 + github.com/openshift/library-go v0.0.0-20200427130628-9b02543ac833 github.com/spf13/cobra v0.0.5 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.4.0 - golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect gopkg.in/gcfg.v1 v1.2.0 gopkg.in/warnings.v0 v0.1.1 // indirect - k8s.io/api v0.18.0 - k8s.io/apimachinery v0.18.0 - k8s.io/client-go v0.18.0 - k8s.io/component-base v0.18.0 + k8s.io/api v0.18.2 + k8s.io/apimachinery v0.18.2 + k8s.io/client-go v0.18.2 + k8s.io/component-base v0.18.2 k8s.io/klog v1.0.0 ) diff --git a/go.sum b/go.sum index aa899fb72..53178799e 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,3 @@ -bitbucket.org/ww/goautoneg v0.0.0-20120707110453-75cd24fc2f2c/go.mod h1:1vhO7Mn/FZMgOgDVGLy5X1mE6rq1HbkBdkF/yj8zkcg= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= @@ -98,6 +97,8 @@ github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 h1:Mn26/9ZMNWSw9C9ER github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I= github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/go-bindata/go-bindata v3.1.2+incompatible h1:5vjJMVhowQdPzjE1LdxyFF7YFTXg5IgGVW4gBr5IbvE= +github.com/go-bindata/go-bindata v3.1.2+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= @@ -228,8 +229,6 @@ github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jteeuwen/go-bindata v3.0.8-0.20151023091102-a0ff2567cfb7+incompatible h1:KTM14h3AKWWcPf5IWS/pcFTZosRmoqdIYzqi0mMG7es= -github.com/jteeuwen/go-bindata v3.0.8-0.20151023091102-a0ff2567cfb7+incompatible/go.mod h1:JVvhzYOiGBnFSYRyV00iY8q7/0PThjIYav1p9h5dmKs= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= @@ -283,15 +282,16 @@ github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQ github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/runc v0.0.0-20191031171055-b133feaeeb2e/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= github.com/openshift/api v0.0.0-20200326152221-912866ddb162/go.mod h1:RKMJ5CBnljLfnej+BJ/xnOWc3kZDvJUaIAEq2oKSPtE= -github.com/openshift/api v0.0.0-20200326160804-ecb9283fe820/go.mod h1:RKMJ5CBnljLfnej+BJ/xnOWc3kZDvJUaIAEq2oKSPtE= -github.com/openshift/api v0.0.0-20200417173520-2ef3f20bd355 h1:cExNZyla986tfJcgAHZhTcL4xYEi4p+fB43ib29WWRo= -github.com/openshift/api v0.0.0-20200417173520-2ef3f20bd355/go.mod h1:RKMJ5CBnljLfnej+BJ/xnOWc3kZDvJUaIAEq2oKSPtE= +github.com/openshift/api v0.0.0-20200424083944-0422dc17083e h1:VDcwVyMEVbLyekLmtob1TEf8GfP454Afc2hO3FkgBps= +github.com/openshift/api v0.0.0-20200424083944-0422dc17083e/go.mod h1:VnbEzX8SAaRj7Yfl836NykdQIlbEjfL6/CD+AaJQg5Q= github.com/openshift/build-machinery-go v0.0.0-20200211121458-5e3d6e570160 h1:V4E6yt4XWiBEPKnJbs/E8pgUq9AjZqzQfsL3eeT84Qs= github.com/openshift/build-machinery-go v0.0.0-20200211121458-5e3d6e570160/go.mod h1:1CkcsT3aVebzRBzVTSbiKSkJMsC/CASqxesfqEMfJEc= +github.com/openshift/build-machinery-go v0.0.0-20200424080330-082bf86082cc h1:Bu1p7+ItPqhJhmMve7sVluKCYV+o+x1Ede0WY2/BI8Q= +github.com/openshift/build-machinery-go v0.0.0-20200424080330-082bf86082cc/go.mod h1:1CkcsT3aVebzRBzVTSbiKSkJMsC/CASqxesfqEMfJEc= github.com/openshift/client-go v0.0.0-20200326155132-2a6cd50aedd0 h1:kMiuiZXH1GdfbiMwsuAQOqGaMxlo9NCUk0wT4XAdfNM= github.com/openshift/client-go v0.0.0-20200326155132-2a6cd50aedd0/go.mod h1:uUQ4LClRO+fg5MF/P6QxjMCb1C9f7Oh4RKepftDnEJE= -github.com/openshift/library-go v0.0.0-20200414135834-ccc4bb27d032 h1:DFlzobaf+Sy22sUz5oCoFcpzv4pLcjUgUEPLDSitnX0= -github.com/openshift/library-go v0.0.0-20200414135834-ccc4bb27d032/go.mod h1:CfydoH0B+RYs22uQZQ36A1mz5m5zhucpMGh8t5s71v4= +github.com/openshift/library-go v0.0.0-20200427130628-9b02543ac833 h1:glEuGTvwkQJXfCzVfosZ3oq73L8QltO6Xyxo1oTf5Ig= +github.com/openshift/library-go v0.0.0-20200427130628-9b02543ac833/go.mod h1:2kWwXTkpoQJUN3jZ3QW88EIY1hdRMqxgRs2hheEW/pg= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= @@ -409,9 +409,8 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200421231249-e086a090c8fd h1:QPwSajcTUrFriMF1nJ3XzgoqakqQEsnZf9LdXdi2nkI= +golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= @@ -514,25 +513,32 @@ honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= k8s.io/api v0.18.0 h1:lwYk8Vt7rsVTwjRU6pzEsa9YNhThbmbocQlKvNBB4EQ= k8s.io/api v0.18.0/go.mod h1:q2HRQkfDzHMBZL9l/y9rH63PkQl4vae0xRT+8prbrK8= -k8s.io/apiextensions-apiserver v0.18.0 h1:HN4/P8vpGZFvB5SOMuPPH2Wt9Y/ryX+KRvIyAkchu1Q= -k8s.io/apiextensions-apiserver v0.18.0/go.mod h1:18Cwn1Xws4xnWQNC00FLq1E350b9lUF+aOdIWDOZxgo= +k8s.io/api v0.18.2 h1:wG5g5ZmSVgm5B+eHMIbI9EGATS2L8Z72rda19RIEgY8= +k8s.io/api v0.18.2/go.mod h1:SJCWI7OLzhZSvbY7U8zwNl9UA4o1fizoug34OV/2r78= +k8s.io/apiextensions-apiserver v0.18.2 h1:I4v3/jAuQC+89L3Z7dDgAiN4EOjN6sbm6iBqQwHTah8= +k8s.io/apiextensions-apiserver v0.18.2/go.mod h1:q3faSnRGmYimiocj6cHQ1I3WpLqmDgJFlKL37fC4ZvY= k8s.io/apimachinery v0.18.0 h1:fuPfYpk3cs1Okp/515pAf0dNhL66+8zk8RLbSX+EgAE= k8s.io/apimachinery v0.18.0/go.mod h1:9SnR/e11v5IbyPCGbvJViimtJ0SwHG4nfZFjU77ftcA= -k8s.io/apiserver v0.18.0 h1:ELAWpGWC6XdbRLi5lwAbEbvksD7hkXxPdxaJsdpist4= -k8s.io/apiserver v0.18.0/go.mod h1:3S2O6FeBBd6XTo0njUrLxiqk8GNy6wWOftjhJcXYnjw= +k8s.io/apimachinery v0.18.2 h1:44CmtbmkzVDAhCpRVSiP2R5PPrC2RtlIv/MoB8xpdRA= +k8s.io/apimachinery v0.18.2/go.mod h1:9SnR/e11v5IbyPCGbvJViimtJ0SwHG4nfZFjU77ftcA= +k8s.io/apiserver v0.18.2 h1:fwKxdTWwwYhxvtjo0UUfX+/fsitsNtfErPNegH2x9ic= +k8s.io/apiserver v0.18.2/go.mod h1:Xbh066NqrZO8cbsoenCwyDJ1OSi8Ag8I2lezeHxzwzw= k8s.io/client-go v0.18.0 h1:yqKw4cTUQraZK3fcVCMeSa+lqKwcjZ5wtcOIPnxQno4= k8s.io/client-go v0.18.0/go.mod h1:uQSYDYs4WhVZ9i6AIoEZuwUggLVEF64HOD37boKAtF8= +k8s.io/client-go v0.18.2 h1:aLB0iaD4nmwh7arT2wIn+lMnAq7OswjaejkQ8p9bBYE= +k8s.io/client-go v0.18.2/go.mod h1:Xcm5wVGXX9HAA2JJ2sSBUn3tCJ+4SVlCbl2MNNv+CIU= k8s.io/code-generator v0.18.0/go.mod h1:+UHX5rSbxmR8kzS+FAv7um6dtYrZokQvjHpDSYRVkTc= -k8s.io/component-base v0.18.0 h1:I+lP0fNfsEdTDpHaL61bCAqTZLoiWjEEP304Mo5ZQgE= -k8s.io/component-base v0.18.0/go.mod h1:u3BCg0z1uskkzrnAKFzulmYaEpZF7XC9Pf/uFyb1v2c= +k8s.io/code-generator v0.18.2/go.mod h1:+UHX5rSbxmR8kzS+FAv7um6dtYrZokQvjHpDSYRVkTc= +k8s.io/component-base v0.18.2 h1:SJweNZAGcUvsypLGNPNGeJ9UgPZQ6+bW+gEHe8uyh/Y= +k8s.io/component-base v0.18.2/go.mod h1:kqLlMuhJNHQ9lz8Z7V5bxUUtjFZnrypArGl58gmDfUM= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20200114144118-36b2048a9120/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= -k8s.io/kube-aggregator v0.18.0 h1:J+wa9FDQ3SbgyA8wQBNg2m2FMSm+mMQfs2A58500hs0= -k8s.io/kube-aggregator v0.18.0/go.mod h1:ateewQ5QbjMZF/dihEFXwaEwoA4v/mayRvzfmvb6eqI= +k8s.io/kube-aggregator v0.18.2 h1:mgsze91nZC27HeJi8bLRyhLINQznEUy4SOTpbOhsZEM= +k8s.io/kube-aggregator v0.18.2/go.mod h1:ijq6FnNUoKinA6kKbkN6svdTacSoQVNtKqmQ1+XJEYQ= k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c h1:/KUFqjjqAcY4Us6luF5RDNZ16KJtb49HfR3ZHB9qYXM= k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E= k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 h1:d4vVOjXm687F1iLSP2q3lyPPuyvTUt3aVoBpi2DqRsU= diff --git a/pkg/dependencymagnet/doc.go b/pkg/dependencymagnet/doc.go index 249bd082a..64938e95e 100644 --- a/pkg/dependencymagnet/doc.go +++ b/pkg/dependencymagnet/doc.go @@ -5,7 +5,7 @@ package dependencymagnet import ( - _ "github.com/jteeuwen/go-bindata/go-bindata" + _ "github.com/go-bindata/go-bindata" _ "github.com/openshift/build-machinery-go" _ "github.com/openshift/api/authorization/v1" diff --git a/vendor/github.com/go-bindata/go-bindata/.gitignore b/vendor/github.com/go-bindata/go-bindata/.gitignore new file mode 100644 index 000000000..b9abe353d --- /dev/null +++ b/vendor/github.com/go-bindata/go-bindata/.gitignore @@ -0,0 +1,16 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, build with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Goland project files +.idea/ +*.iml diff --git a/vendor/github.com/jteeuwen/go-bindata/CONTRIBUTING.md b/vendor/github.com/go-bindata/go-bindata/CONTRIBUTING.md similarity index 100% rename from vendor/github.com/jteeuwen/go-bindata/CONTRIBUTING.md rename to vendor/github.com/go-bindata/go-bindata/CONTRIBUTING.md diff --git a/vendor/github.com/jteeuwen/go-bindata/LICENSE b/vendor/github.com/go-bindata/go-bindata/LICENSE similarity index 100% rename from vendor/github.com/jteeuwen/go-bindata/LICENSE rename to vendor/github.com/go-bindata/go-bindata/LICENSE diff --git a/vendor/github.com/jteeuwen/go-bindata/Makefile b/vendor/github.com/go-bindata/go-bindata/Makefile similarity index 100% rename from vendor/github.com/jteeuwen/go-bindata/Makefile rename to vendor/github.com/go-bindata/go-bindata/Makefile diff --git a/vendor/github.com/jteeuwen/go-bindata/README.md b/vendor/github.com/go-bindata/go-bindata/README.md similarity index 91% rename from vendor/github.com/jteeuwen/go-bindata/README.md rename to vendor/github.com/go-bindata/go-bindata/README.md index bca57f72d..155350532 100644 --- a/vendor/github.com/jteeuwen/go-bindata/README.md +++ b/vendor/github.com/go-bindata/go-bindata/README.md @@ -1,5 +1,7 @@ ## bindata +[![Go Report Card](https://goreportcard.com/badge/github.com/go-bindata/bindata)](https://goreportcard.com/report/github.com/go-bindata/bindata) + This package converts any file into managable Go source code. Useful for embedding binary data into a go program. The file data is optionally gzip compressed before being converted to a raw byte slice. @@ -13,7 +15,7 @@ output being generated. To install the library and command line program, use the following: - go get -u github.com/jteeuwen/go-bindata/... + go get -u github.com/go-bindata/go-bindata/... ### Usage @@ -182,8 +184,16 @@ format is specified at build time with the appropriate tags. The tags are appended to a `// +build` line in the beginning of the output file and must follow the build tags syntax specified by the go tool. -### Related projects +### Serve assets with `net/http` + +With the `-fs` flag, `go-bindata` will add an `AssetFile()` method returning an `http.FileSystem` interface: + + $ go-bindata -fs -prefix "static/" static/ -[go-bindata-assetfs](https://github.com/elazarl/go-bindata-assetfs#readme) - -implements `http.FileSystem` interface. Allows you to serve assets with `net/http`. +Use `-prefix` flag to strip first level dir, then in your `net/http` router, you can use `AssetFile()` with `http.FileServer()` like: +```go +mux := http.NewServeMux() +mux.Handle("/static", http.FileServer(AssetFile())) +http.ListenAndServe(":8080", mux) +``` diff --git a/vendor/github.com/go-bindata/go-bindata/_config.yml b/vendor/github.com/go-bindata/go-bindata/_config.yml new file mode 100644 index 000000000..c4192631f --- /dev/null +++ b/vendor/github.com/go-bindata/go-bindata/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman \ No newline at end of file diff --git a/vendor/github.com/jteeuwen/go-bindata/asset.go b/vendor/github.com/go-bindata/go-bindata/asset.go similarity index 100% rename from vendor/github.com/jteeuwen/go-bindata/asset.go rename to vendor/github.com/go-bindata/go-bindata/asset.go diff --git a/vendor/github.com/jteeuwen/go-bindata/bytewriter.go b/vendor/github.com/go-bindata/go-bindata/bytewriter.go similarity index 100% rename from vendor/github.com/jteeuwen/go-bindata/bytewriter.go rename to vendor/github.com/go-bindata/go-bindata/bytewriter.go diff --git a/vendor/github.com/jteeuwen/go-bindata/config.go b/vendor/github.com/go-bindata/go-bindata/config.go similarity index 97% rename from vendor/github.com/jteeuwen/go-bindata/config.go rename to vendor/github.com/go-bindata/go-bindata/config.go index 2bd0d56d8..471c32f1b 100644 --- a/vendor/github.com/jteeuwen/go-bindata/config.go +++ b/vendor/github.com/go-bindata/go-bindata/config.go @@ -106,6 +106,10 @@ type Config struct { // the file data when called. Defaults to false. NoCompress bool + // HttpFileSystem means whether generate return http.FileSystem interface + // instance's function.When true,will generate relate code. + HttpFileSystem bool + // Perform a debug build. This generates an asset file, which // loads the asset contents directly from disk at their original // location, instead of embedding the contents in the code. @@ -148,6 +152,7 @@ func NewConfig() *Config { c.Package = "main" c.NoMemCopy = false c.NoCompress = false + c.HttpFileSystem = false c.Debug = false c.Output = "./bindata.go" c.Ignore = make([]*regexp.Regexp, 0) diff --git a/vendor/github.com/jteeuwen/go-bindata/convert.go b/vendor/github.com/go-bindata/go-bindata/convert.go similarity index 95% rename from vendor/github.com/jteeuwen/go-bindata/convert.go rename to vendor/github.com/go-bindata/go-bindata/convert.go index cf0466edd..8660ee9f4 100644 --- a/vendor/github.com/jteeuwen/go-bindata/convert.go +++ b/vendor/github.com/go-bindata/go-bindata/convert.go @@ -50,7 +50,7 @@ func Translate(c *Config) error { defer bfd.Flush() // Write the header. This makes e.g. Github ignore diffs in generated files. - if _, err = fmt.Fprint(bfd, "// Code generated by go-bindata.\n"); err != nil { + if _, err = fmt.Fprintf(bfd, "// Code generated for package %s by go-bindata DO NOT EDIT. (@generated)\n", c.Package); err != nil { return err } if _, err = fmt.Fprint(bfd, "// sources:\n"); err != nil { @@ -68,9 +68,9 @@ func Translate(c *Config) error { return err } } - if _, err = fmt.Fprint(bfd, "// DO NOT EDIT!\n\n"); err != nil { - return err - } + //if _, err = fmt.Fprint(bfd, "// DO NOT EDIT!\n\n"); err != nil { + // return err + //} // Write build tags, if applicable. if len(c.Tags) > 0 { @@ -109,7 +109,7 @@ func Translate(c *Config) error { return writeRestore(bfd) } -// Implement sort.Interface for []os.FileInfo based on Name() +// ByName implements sort.Interface for []os.FileInfo based on Name() type ByName []os.FileInfo func (v ByName) Len() int { return len(v) } diff --git a/vendor/github.com/jteeuwen/go-bindata/debug.go b/vendor/github.com/go-bindata/go-bindata/debug.go similarity index 82% rename from vendor/github.com/jteeuwen/go-bindata/debug.go rename to vendor/github.com/go-bindata/go-bindata/debug.go index 09fee785d..edb3270d6 100644 --- a/vendor/github.com/jteeuwen/go-bindata/debug.go +++ b/vendor/github.com/go-bindata/go-bindata/debug.go @@ -11,7 +11,12 @@ import ( // writeDebug writes the debug code file. func writeDebug(w io.Writer, c *Config, toc []Asset) error { - err := writeDebugHeader(w) + err := writeDebugHeader(w, c) + if err != nil { + return err + } + + err = writeAssetFS(w, c) if err != nil { return err } @@ -28,13 +33,29 @@ func writeDebug(w io.Writer, c *Config, toc []Asset) error { // writeDebugHeader writes output file headers. // This targets debug builds. -func writeDebugHeader(w io.Writer) error { - _, err := fmt.Fprintf(w, `import ( +func writeDebugHeader(w io.Writer, c *Config) error { + var header string + + if c.HttpFileSystem { + header = `import ( + "bytes" + "net/http" "fmt" "io/ioutil" "os" "path/filepath" "strings" + "time"` + } else { + header = `import ( + "fmt" + "io/ioutil" + "os" + "path/filepath" + "strings"` + } + + _, err := fmt.Fprintf(w, `%s ) // bindataRead reads the given file from disk. It returns an error on failure. @@ -51,7 +72,7 @@ type asset struct { info os.FileInfo } -`) +`, header) return err } diff --git a/vendor/github.com/jteeuwen/go-bindata/doc.go b/vendor/github.com/go-bindata/go-bindata/doc.go similarity index 100% rename from vendor/github.com/jteeuwen/go-bindata/doc.go rename to vendor/github.com/go-bindata/go-bindata/doc.go diff --git a/vendor/github.com/go-bindata/go-bindata/file.go b/vendor/github.com/go-bindata/go-bindata/file.go new file mode 100644 index 000000000..8c83926c8 --- /dev/null +++ b/vendor/github.com/go-bindata/go-bindata/file.go @@ -0,0 +1,102 @@ +package bindata + +import ( + "fmt" + "io" +) + +func writeAssetFS(w io.Writer, c *Config) error { + if !c.HttpFileSystem { + return nil + } + + _, err := fmt.Fprintf(w, ` +type assetFile struct { + *bytes.Reader + name string + childInfos []os.FileInfo + childInfoOffset int +} + +type assetOperator struct{} + +// Open implement http.FileSystem interface +func (f *assetOperator) Open(name string) (http.File, error) { + var err error + if len(name) > 0 && name[0] == '/' { + name = name[1:] + } + content, err := Asset(name) + if err == nil { + return &assetFile{name: name, Reader: bytes.NewReader(content)}, nil + } + children, err := AssetDir(name) + if err == nil { + childInfos := make([]os.FileInfo, 0, len(children)) + for _, child := range children { + childPath := filepath.Join(name, child) + info, errInfo := AssetInfo(filepath.Join(name, child)) + if errInfo == nil { + childInfos = append(childInfos, info) + } else { + childInfos = append(childInfos, newDirFileInfo(childPath)) + } + } + return &assetFile{name: name, childInfos: childInfos}, nil + } else { + // If the error is not found, return an error that will + // result in a 404 error. Otherwise the server returns + // a 500 error for files not found. + if strings.Contains(err.Error(), "not found") { + return nil, os.ErrNotExist + } + return nil, err + } +} + +// Close no need do anything +func (f *assetFile) Close() error { + return nil +} + +// Readdir read dir's children file info +func (f *assetFile) Readdir(count int) ([]os.FileInfo, error) { + if len(f.childInfos) == 0 { + return nil, os.ErrNotExist + } + if count <= 0 { + return f.childInfos, nil + } + if f.childInfoOffset+count > len(f.childInfos) { + count = len(f.childInfos) - f.childInfoOffset + } + offset := f.childInfoOffset + f.childInfoOffset += count + return f.childInfos[offset : offset+count], nil +} + +// Stat read file info from asset item +func (f *assetFile) Stat() (os.FileInfo, error) { + if len(f.childInfos) != 0 { + return newDirFileInfo(f.name), nil + } + return AssetInfo(f.name) +} + +// newDirFileInfo return default dir file info +func newDirFileInfo(name string) os.FileInfo { + return &bindataFileInfo{ + name: name, + size: 0, + mode: os.FileMode(2147484068), // equal os.FileMode(0644)|os.ModeDir + modTime: time.Time{}} +} + +// AssetFile return a http.FileSystem instance that data backend by asset +func AssetFile() http.FileSystem { + return &assetOperator{} +} + +`) + return err +} diff --git a/vendor/github.com/jteeuwen/go-bindata/release.go b/vendor/github.com/go-bindata/go-bindata/release.go similarity index 79% rename from vendor/github.com/jteeuwen/go-bindata/release.go rename to vendor/github.com/go-bindata/go-bindata/release.go index 6aefeb28a..d1bef160f 100644 --- a/vendor/github.com/jteeuwen/go-bindata/release.go +++ b/vendor/github.com/go-bindata/go-bindata/release.go @@ -21,6 +21,11 @@ func writeRelease(w io.Writer, c *Config, toc []Asset) error { return err } + err = writeAssetFS(w, c) + if err != nil { + return err + } + for i := range toc { err = writeReleaseAsset(w, c, &toc[i]) if err != nil { @@ -37,15 +42,15 @@ func writeReleaseHeader(w io.Writer, c *Config) error { var err error if c.NoCompress { if c.NoMemCopy { - err = header_uncompressed_nomemcopy(w) + err = header_uncompressed_nomemcopy(w, c) } else { - err = header_uncompressed_memcopy(w) + err = header_uncompressed_memcopy(w, c) } } else { if c.NoMemCopy { - err = header_compressed_nomemcopy(w) + err = header_compressed_nomemcopy(w, c) } else { - err = header_compressed_memcopy(w) + err = header_compressed_memcopy(w, c) } } if err != nil { @@ -97,17 +102,35 @@ func sanitize(b []byte) []byte { return bytes.Replace(b, []byte("\xEF\xBB\xBF"), []byte("`+\"\\xEF\\xBB\\xBF\"+`"), -1) } -func header_compressed_nomemcopy(w io.Writer) error { - _, err := fmt.Fprintf(w, `import ( +func header_compressed_nomemcopy(w io.Writer, c *Config) error { + var header string + + if c.HttpFileSystem { + header = `import ( "bytes" "compress/gzip" "fmt" + "net/http" "io" "io/ioutil" "os" "path/filepath" "strings" - "time" + "time"` + } else { + header = `import ( + "bytes" + "compress/gzip" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + "strings" + "time"` + } + + _, err := fmt.Fprintf(w, `%s ) func bindataRead(data, name string) ([]byte, error) { @@ -130,21 +153,39 @@ func bindataRead(data, name string) ([]byte, error) { return buf.Bytes(), nil } -`) +`, header) return err } -func header_compressed_memcopy(w io.Writer) error { - _, err := fmt.Fprintf(w, `import ( +func header_compressed_memcopy(w io.Writer, c *Config) error { + var header string + + if c.HttpFileSystem { + header = `import ( "bytes" "compress/gzip" "fmt" + "net/http" "io" "io/ioutil" "os" "path/filepath" "strings" - "time" + "time"` + } else { + header = `import ( + "bytes" + "compress/gzip" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + "strings" + "time"` + } + + _, err := fmt.Fprintf(w, `%s ) func bindataRead(data []byte, name string) ([]byte, error) { @@ -167,12 +208,27 @@ func bindataRead(data []byte, name string) ([]byte, error) { return buf.Bytes(), nil } -`) +`, header) return err } -func header_uncompressed_nomemcopy(w io.Writer) error { - _, err := fmt.Fprintf(w, `import ( +func header_uncompressed_nomemcopy(w io.Writer, c *Config) error { + var header string + + if c.HttpFileSystem { + header = `import ( + "bytes" + "fmt" + "net/http" + "io/ioutil" + "os" + "path/filepath" + "reflect" + "strings" + "time" + "unsafe"` + } else { + header = `import ( "fmt" "io/ioutil" "os" @@ -180,7 +236,10 @@ func header_uncompressed_nomemcopy(w io.Writer) error { "reflect" "strings" "time" - "unsafe" + "unsafe"` + } + + _, err := fmt.Fprintf(w, `%s ) func bindataRead(data, name string) ([]byte, error) { @@ -194,20 +253,36 @@ func bindataRead(data, name string) ([]byte, error) { return b, nil } -`) +`, header) return err } -func header_uncompressed_memcopy(w io.Writer) error { - _, err := fmt.Fprintf(w, `import ( +func header_uncompressed_memcopy(w io.Writer, c *Config) error { + var header string + + if c.HttpFileSystem { + header = `import ( + "bytes" "fmt" + "net/http" "io/ioutil" "os" "path/filepath" "strings" - "time" + "time"` + } else { + header = `import ( + "fmt" + "io/ioutil" + "os" + "path/filepath" + "strings" + "time"` + } + + _, err := fmt.Fprintf(w, `%s ) -`) +`, header) return err } @@ -224,21 +299,32 @@ type bindataFileInfo struct { modTime time.Time } +// Name return file name func (fi bindataFileInfo) Name() string { return fi.name } + +// Size return file size func (fi bindataFileInfo) Size() int64 { return fi.size } + +// Mode return file mode func (fi bindataFileInfo) Mode() os.FileMode { return fi.mode } + +// Mode return file modify time func (fi bindataFileInfo) ModTime() time.Time { return fi.modTime } + +// IsDir return file whether a directory func (fi bindataFileInfo) IsDir() bool { - return false + return fi.mode&os.ModeDir != 0 } + +// Sys return file is sys mode func (fi bindataFileInfo) Sys() interface{} { return nil } diff --git a/vendor/github.com/jteeuwen/go-bindata/restore.go b/vendor/github.com/go-bindata/go-bindata/restore.go similarity index 99% rename from vendor/github.com/jteeuwen/go-bindata/restore.go rename to vendor/github.com/go-bindata/go-bindata/restore.go index 65db0e8f9..268ec7464 100644 --- a/vendor/github.com/jteeuwen/go-bindata/restore.go +++ b/vendor/github.com/go-bindata/go-bindata/restore.go @@ -57,7 +57,6 @@ func _filePath(dir, name string) string { cannonicalName := strings.Replace(name, "\\", "/", -1) return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) } - `) return err } diff --git a/vendor/github.com/jteeuwen/go-bindata/stringwriter.go b/vendor/github.com/go-bindata/go-bindata/stringwriter.go similarity index 100% rename from vendor/github.com/jteeuwen/go-bindata/stringwriter.go rename to vendor/github.com/go-bindata/go-bindata/stringwriter.go diff --git a/vendor/github.com/jteeuwen/go-bindata/toc.go b/vendor/github.com/go-bindata/go-bindata/toc.go similarity index 78% rename from vendor/github.com/jteeuwen/go-bindata/toc.go rename to vendor/github.com/go-bindata/go-bindata/toc.go index 9ec410b25..be4a01654 100644 --- a/vendor/github.com/jteeuwen/go-bindata/toc.go +++ b/vendor/github.com/go-bindata/go-bindata/toc.go @@ -52,6 +52,40 @@ func (root *assetTree) funcOrNil() string { } } +func getFillerSize(tokenIndex int, lengths []int, nident int) int { + var ( + curlen int = lengths[tokenIndex] + maxlen int = 0 + substart int = 0 + subend int = 0 + spacediff int = 0 + ) + + if curlen > 0 { + substart = tokenIndex + for (substart-1) >= 0 && lengths[substart-1] > 0 { + substart -= 1 + } + + subend = tokenIndex + for (subend+1) < len(lengths) && lengths[subend+1] > 0 { + subend += 1 + } + + var candidate int + for j := substart; j <= subend; j += 1 { + candidate = lengths[j] + if candidate > maxlen { + maxlen = candidate + } + } + + spacediff = maxlen - curlen + } + + return spacediff +} + func (root *assetTree) writeGoMap(w io.Writer, nident int) { fmt.Fprintf(w, "&bintree{%s, map[string]*bintree{", root.funcOrNil()) @@ -60,16 +94,28 @@ func (root *assetTree) writeGoMap(w io.Writer, nident int) { // Sort to make output stable between invocations filenames := make([]string, len(root.Children)) + hasChildren := make(map[string]bool) i := 0 - for filename, _ := range root.Children { + for filename, node := range root.Children { filenames[i] = filename + hasChildren[filename] = len(node.Children) > 0 i++ } sort.Strings(filenames) - for _, p := range filenames { + lengths := make([]int, len(root.Children)) + for i, filename := range filenames { + if hasChildren[filename] { + lengths[i] = 0 + } else { + lengths[i] = len(filename) + } + } + + for i, p := range filenames { ident(w, nident+1) - fmt.Fprintf(w, `"%s": `, p) + filler := strings.Repeat(" ", getFillerSize(i, lengths, nident)) + fmt.Fprintf(w, `"%s": %s`, p, filler) root.Children[p].writeGoMap(w, nident+1) } ident(w, nident) @@ -87,6 +133,7 @@ func (root *assetTree) WriteAsGoMap(w io.Writer) error { Func func() (*asset, error) Children map[string]*bintree } + var _bintree = `) root.writeGoMap(w, 0) return err @@ -147,8 +194,16 @@ func writeTOC(w io.Writer, toc []Asset) error { return err } + var maxlen = 0 for i := range toc { - err = writeTOCAsset(w, &toc[i]) + l := len(toc[i].Name) + if l > maxlen { + maxlen = l + } + } + + for i := range toc { + err = writeTOCAsset(w, &toc[i], maxlen) if err != nil { return err } @@ -216,8 +271,11 @@ var _bindata = map[string]func() (*asset, error){ } // writeTOCAsset write a TOC entry for the given asset. -func writeTOCAsset(w io.Writer, asset *Asset) error { - _, err := fmt.Fprintf(w, "\t%q: %s,\n", asset.Name, asset.Func) +func writeTOCAsset(w io.Writer, asset *Asset, maxlen int) error { + spacediff := maxlen - len(asset.Name) + filler := strings.Repeat(" ", spacediff) + + _, err := fmt.Fprintf(w, "\t%q: %s%s,\n", asset.Name, filler, asset.Func) return err } diff --git a/vendor/github.com/jteeuwen/go-bindata/go-bindata/AppendSliceValue.go b/vendor/github.com/jteeuwen/go-bindata/go-bindata/AppendSliceValue.go deleted file mode 100644 index f5da49596..000000000 --- a/vendor/github.com/jteeuwen/go-bindata/go-bindata/AppendSliceValue.go +++ /dev/null @@ -1,22 +0,0 @@ -package main - -import "strings" - -// borrowed from https://github.com/hashicorp/serf/blob/master/command/agent/flag_slice_value.go - -// AppendSliceValue implements the flag.Value interface and allows multiple -// calls to the same variable to append a list. -type AppendSliceValue []string - -func (s *AppendSliceValue) String() string { - return strings.Join(*s, ",") -} - -func (s *AppendSliceValue) Set(value string) error { - if *s == nil { - *s = make([]string, 0, 1) - } - - *s = append(*s, value) - return nil -} diff --git a/vendor/github.com/jteeuwen/go-bindata/go-bindata/main.go b/vendor/github.com/jteeuwen/go-bindata/go-bindata/main.go deleted file mode 100644 index 503a059e6..000000000 --- a/vendor/github.com/jteeuwen/go-bindata/go-bindata/main.go +++ /dev/null @@ -1,107 +0,0 @@ -// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication -// license. Its contents can be found at: -// http://creativecommons.org/publicdomain/zero/1.0/ - -package main - -import ( - "flag" - "fmt" - "os" - "path/filepath" - "regexp" - "strings" - - "github.com/jteeuwen/go-bindata" -) - -func main() { - cfg := parseArgs() - err := bindata.Translate(cfg) - - if err != nil { - fmt.Fprintf(os.Stderr, "bindata: %v\n", err) - os.Exit(1) - } -} - -// parseArgs create s a new, filled configuration instance -// by reading and parsing command line options. -// -// This function exits the program with an error, if -// any of the command line options are incorrect. -func parseArgs() *bindata.Config { - var version bool - - c := bindata.NewConfig() - - flag.Usage = func() { - fmt.Printf("Usage: %s [options] \n\n", os.Args[0]) - flag.PrintDefaults() - } - - flag.BoolVar(&c.Debug, "debug", c.Debug, "Do not embed the assets, but provide the embedding API. Contents will still be loaded from disk.") - flag.BoolVar(&c.Dev, "dev", c.Dev, "Similar to debug, but does not emit absolute paths. Expects a rootDir variable to already exist in the generated code's package.") - flag.StringVar(&c.Tags, "tags", c.Tags, "Optional set of build tags to include.") - flag.StringVar(&c.Prefix, "prefix", c.Prefix, "Optional path prefix to strip off asset names.") - flag.StringVar(&c.Package, "pkg", c.Package, "Package name to use in the generated code.") - flag.BoolVar(&c.NoMemCopy, "nomemcopy", c.NoMemCopy, "Use a .rodata hack to get rid of unnecessary memcopies. Refer to the documentation to see what implications this carries.") - flag.BoolVar(&c.NoCompress, "nocompress", c.NoCompress, "Assets will *not* be GZIP compressed when this flag is specified.") - flag.BoolVar(&c.NoMetadata, "nometadata", c.NoMetadata, "Assets will not preserve size, mode, and modtime info.") - flag.UintVar(&c.Mode, "mode", c.Mode, "Optional file mode override for all files.") - flag.Int64Var(&c.ModTime, "modtime", c.ModTime, "Optional modification unix timestamp override for all files.") - flag.StringVar(&c.Output, "o", c.Output, "Optional name of the output file to be generated.") - flag.BoolVar(&version, "version", false, "Displays version information.") - - ignore := make([]string, 0) - flag.Var((*AppendSliceValue)(&ignore), "ignore", "Regex pattern to ignore") - - flag.Parse() - - patterns := make([]*regexp.Regexp, 0) - for _, pattern := range ignore { - patterns = append(patterns, regexp.MustCompile(pattern)) - } - c.Ignore = patterns - - if version { - fmt.Printf("%s\n", Version()) - os.Exit(0) - } - - // Make sure we have input paths. - if flag.NArg() == 0 { - fmt.Fprintf(os.Stderr, "Missing \n\n") - flag.Usage() - os.Exit(1) - } - - // Create input configurations. - c.Input = make([]bindata.InputConfig, flag.NArg()) - for i := range c.Input { - c.Input[i] = parseInput(flag.Arg(i)) - } - - return c -} - -// parseRecursive determines whether the given path has a recrusive indicator and -// returns a new path with the recursive indicator chopped off if it does. -// -// ex: -// /path/to/foo/... -> (/path/to/foo, true) -// /path/to/bar -> (/path/to/bar, false) -func parseInput(path string) bindata.InputConfig { - if strings.HasSuffix(path, "/...") { - return bindata.InputConfig{ - Path: filepath.Clean(path[:len(path)-4]), - Recursive: true, - } - } else { - return bindata.InputConfig{ - Path: filepath.Clean(path), - Recursive: false, - } - } - -} diff --git a/vendor/github.com/jteeuwen/go-bindata/go-bindata/version.go b/vendor/github.com/jteeuwen/go-bindata/go-bindata/version.go deleted file mode 100644 index a12508ede..000000000 --- a/vendor/github.com/jteeuwen/go-bindata/go-bindata/version.go +++ /dev/null @@ -1,31 +0,0 @@ -// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication -// license. Its contents can be found at: -// http://creativecommons.org/publicdomain/zero/1.0/ - -package main - -import ( - "fmt" - "runtime" -) - -const ( - AppName = "go-bindata" - AppVersionMajor = 3 - AppVersionMinor = 1 -) - -// revision part of the program version. -// This will be set automatically at build time like so: -// -// go build -ldflags "-X main.AppVersionRev `date -u +%s`" -var AppVersionRev string - -func Version() string { - if len(AppVersionRev) == 0 { - AppVersionRev = "0" - } - - return fmt.Sprintf("%s %d.%d.%s (Go runtime %s).\nCopyright (c) 2010-2013, Jim Teeuwen.", - AppName, AppVersionMajor, AppVersionMinor, AppVersionRev, runtime.Version()) -} diff --git a/vendor/github.com/openshift/api/README.md b/vendor/github.com/openshift/api/README.md index aacb32bc0..60a7e0d7d 100644 --- a/vendor/github.com/openshift/api/README.md +++ b/vendor/github.com/openshift/api/README.md @@ -34,16 +34,16 @@ Then do the following with your openshift/origin pull request: Since Kubernetes 1.16, every CRD created in `apiextensions.k8s.io/v1` is required to have a [structural OpenAPIV3 schema](https://kubernetes.io/blog/2019/06/20/crd-structural-schema/). The schemas provide server-side validation for fields, as well as providing the descriptions for `oc explain`. Moreover, schemas ensure structural consistency of data in etcd. Without it anything can be stored in a resource which can have security implications. As we host many of our CRDs in this repo along with their corresponding Go types we also require them to have schemas. However, the following instructions apply for CRDs that are not hosted here as well. -These schemas are often very long and complex, and should not be written by hand. For OpenShift, we provide Makefile targets in [library-go's alpha-build-machinery](https://github.com/openshift/library-go/tree/master/alpha-build-machinery) which generate the schema, built on upstream's [controller-gen](https://github.com/kubernetes-sigs/controller-tools) tool. +These schemas are often very long and complex, and should not be written by hand. For OpenShift, we provide Makefile targets in [build-machinery-go](https://github.com/openshift/build-machinery-go/) which generate the schema, built on upstream's [controller-gen](https://github.com/kubernetes-sigs/controller-tools) tool. If you make a change to a CRD type in this repo, simply calling `make update-codegen-crds` should regenerate all CRDs and update the manifests. If yours is not updated, ensure that the path to its API is included in our [calls to the Makefile targets](https://github.com/openshift/api/blob/release-4.5/Makefile#L17-L29). To add this generator to another repo: -1. Vendor `github.com/openshift/library-go` (and ensure that the `alpha-build-machinery` subdirectory is also included in your `vendor`) +1. Vendor `github.com/openshift/build-machinery-go` 2. Update your `Makefile` to include the following: ``` -include $(addprefix ./vendor/github.com/openshift/library-go/alpha-build-machinery/make/, \ +include $(addprefix ./vendor/github.com/openshift/build-machinery-go/make/, \ targets/openshift/crd-schema-gen.mk \ ) diff --git a/vendor/github.com/openshift/api/build/v1/types.go b/vendor/github.com/openshift/api/build/v1/types.go index feb17f658..eeb29e9d0 100644 --- a/vendor/github.com/openshift/api/build/v1/types.go +++ b/vendor/github.com/openshift/api/build/v1/types.go @@ -35,7 +35,7 @@ type BuildSpec struct { // triggeredBy describes which triggers started the most recent update to the // build configuration and contains information about those triggers. - TriggeredBy []BuildTriggerCause `json:"triggeredBy" protobuf:"bytes,2,rep,name=triggeredBy"` + TriggeredBy []BuildTriggerCause `json:"triggeredBy,omitempty" protobuf:"bytes,2,rep,name=triggeredBy"` } // OptionalNodeSelector is a map that may also be left nil to distinguish between set and unset. @@ -464,13 +464,13 @@ type ImageSource struct { // does not reference an image source it is ignored. This field and paths may both be set, in which case // the contents will be used twice. // +optional - As []string `json:"as" protobuf:"bytes,4,rep,name=as"` + As []string `json:"as,omitempty" protobuf:"bytes,4,rep,name=as"` // paths is a list of source and destination paths to copy from the image. This content will be copied // into the build context prior to starting the build. If no paths are set, the build context will // not be altered. // +optional - Paths []ImageSourcePath `json:"paths" protobuf:"bytes,2,rep,name=paths"` + Paths []ImageSourcePath `json:"paths,omitempty" protobuf:"bytes,2,rep,name=paths"` // pullSecret is a reference to a secret to be used to pull the image from a registry // If the image is pulled from the OpenShift registry, this field does not need to be set. @@ -1165,7 +1165,7 @@ type BuildRequest struct { // triggeredBy describes which triggers started the most recent update to the // build configuration and contains information about those triggers. - TriggeredBy []BuildTriggerCause `json:"triggeredBy" protobuf:"bytes,8,rep,name=triggeredBy"` + TriggeredBy []BuildTriggerCause `json:"triggeredBy,omitempty" protobuf:"bytes,8,rep,name=triggeredBy"` // DockerStrategyOptions contains additional docker-strategy specific options for the build DockerStrategyOptions *DockerStrategyOptions `json:"dockerStrategyOptions,omitempty" protobuf:"bytes,9,opt,name=dockerStrategyOptions"` diff --git a/vendor/github.com/openshift/api/config/v1/0000_10_config-operator_01_infrastructure.crd.yaml b/vendor/github.com/openshift/api/config/v1/0000_10_config-operator_01_infrastructure.crd.yaml index 6bbcd97e0..35e38f103 100644 --- a/vendor/github.com/openshift/api/config/v1/0000_10_config-operator_01_infrastructure.crd.yaml +++ b/vendor/github.com/openshift/api/config/v1/0000_10_config-operator_01_infrastructure.crd.yaml @@ -42,11 +42,18 @@ spec: type: object properties: cloudConfig: - description: cloudConfig is a reference to a ConfigMap containing the + description: "cloudConfig is a reference to a ConfigMap containing the cloud provider configuration file. This configuration file is used to configure the Kubernetes cloud provider integration when using the built-in cloud provider integration or the external cloud controller - manager. The namespace for this config map is openshift-config. + manager. The namespace for this config map is openshift-config. \n + cloudConfig should only be consumed by the kube_cloud_config controller. + The controller is responsible for using the user configuration in + the spec for various platforms and combining that with the user provided + ConfigMap in this field to create a stitched kube cloud config. The + controller generates a ConfigMap `kube-cloud-config` in `openshift-config-managed` + namespace with the kube cloud config is stored in `cloud.conf` key. + All the clients are expected to use the generated ConfigMap only." type: object properties: key: diff --git a/vendor/github.com/openshift/api/config/v1/types_infrastructure.go b/vendor/github.com/openshift/api/config/v1/types_infrastructure.go index 5a8b51b59..baa5af379 100644 --- a/vendor/github.com/openshift/api/config/v1/types_infrastructure.go +++ b/vendor/github.com/openshift/api/config/v1/types_infrastructure.go @@ -27,6 +27,15 @@ type InfrastructureSpec struct { // This configuration file is used to configure the Kubernetes cloud provider integration // when using the built-in cloud provider integration or the external cloud controller manager. // The namespace for this config map is openshift-config. + // + // cloudConfig should only be consumed by the kube_cloud_config controller. + // The controller is responsible for using the user configuration in the spec + // for various platforms and combining that with the user provided ConfigMap in this field + // to create a stitched kube cloud config. + // The controller generates a ConfigMap `kube-cloud-config` in `openshift-config-managed` namespace + // with the kube cloud config is stored in `cloud.conf` key. + // All the clients are expected to use the generated ConfigMap only. + // // +optional CloudConfig ConfigMapFileReference `json:"cloudConfig"` diff --git a/vendor/github.com/openshift/api/config/v1/zz_generated.swagger_doc_generated.go b/vendor/github.com/openshift/api/config/v1/zz_generated.swagger_doc_generated.go index 6b485ab44..1b850ea5b 100644 --- a/vendor/github.com/openshift/api/config/v1/zz_generated.swagger_doc_generated.go +++ b/vendor/github.com/openshift/api/config/v1/zz_generated.swagger_doc_generated.go @@ -800,7 +800,7 @@ func (InfrastructureList) SwaggerDoc() map[string]string { var map_InfrastructureSpec = map[string]string{ "": "InfrastructureSpec contains settings that apply to the cluster infrastructure.", - "cloudConfig": "cloudConfig is a reference to a ConfigMap containing the cloud provider configuration file. This configuration file is used to configure the Kubernetes cloud provider integration when using the built-in cloud provider integration or the external cloud controller manager. The namespace for this config map is openshift-config.", + "cloudConfig": "cloudConfig is a reference to a ConfigMap containing the cloud provider configuration file. This configuration file is used to configure the Kubernetes cloud provider integration when using the built-in cloud provider integration or the external cloud controller manager. The namespace for this config map is openshift-config.\n\ncloudConfig should only be consumed by the kube_cloud_config controller. The controller is responsible for using the user configuration in the spec for various platforms and combining that with the user provided ConfigMap in this field to create a stitched kube cloud config. The controller generates a ConfigMap `kube-cloud-config` in `openshift-config-managed` namespace with the kube cloud config is stored in `cloud.conf` key. All the clients are expected to use the generated ConfigMap only.", "platformSpec": "platformSpec holds desired information specific to the underlying infrastructure provider.", } diff --git a/vendor/github.com/openshift/api/go.mod b/vendor/github.com/openshift/api/go.mod index 17212dd25..91dcfbaf5 100644 --- a/vendor/github.com/openshift/api/go.mod +++ b/vendor/github.com/openshift/api/go.mod @@ -4,12 +4,12 @@ go 1.13 require ( github.com/gogo/protobuf v1.3.1 - github.com/openshift/build-machinery-go v0.0.0-20200211121458-5e3d6e570160 + github.com/openshift/build-machinery-go v0.0.0-20200424080330-082bf86082cc github.com/spf13/pflag v1.0.5 golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 // indirect golang.org/x/tools v0.0.0-20200115044656-831fdb1e1868 // indirect - k8s.io/api v0.18.0 - k8s.io/apimachinery v0.18.0 - k8s.io/code-generator v0.18.0 + k8s.io/api v0.18.2 + k8s.io/apimachinery v0.18.2 + k8s.io/code-generator v0.18.2 k8s.io/klog v1.0.0 ) diff --git a/vendor/github.com/openshift/api/go.sum b/vendor/github.com/openshift/api/go.sum index 023a7789a..e4decb8e0 100644 --- a/vendor/github.com/openshift/api/go.sum +++ b/vendor/github.com/openshift/api/go.sum @@ -79,8 +79,8 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/openshift/build-machinery-go v0.0.0-20200211121458-5e3d6e570160 h1:V4E6yt4XWiBEPKnJbs/E8pgUq9AjZqzQfsL3eeT84Qs= -github.com/openshift/build-machinery-go v0.0.0-20200211121458-5e3d6e570160/go.mod h1:1CkcsT3aVebzRBzVTSbiKSkJMsC/CASqxesfqEMfJEc= +github.com/openshift/build-machinery-go v0.0.0-20200424080330-082bf86082cc h1:Bu1p7+ItPqhJhmMve7sVluKCYV+o+x1Ede0WY2/BI8Q= +github.com/openshift/build-machinery-go v0.0.0-20200424080330-082bf86082cc/go.mod h1:1CkcsT3aVebzRBzVTSbiKSkJMsC/CASqxesfqEMfJEc= 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/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -144,12 +144,12 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -k8s.io/api v0.18.0 h1:lwYk8Vt7rsVTwjRU6pzEsa9YNhThbmbocQlKvNBB4EQ= -k8s.io/api v0.18.0/go.mod h1:q2HRQkfDzHMBZL9l/y9rH63PkQl4vae0xRT+8prbrK8= -k8s.io/apimachinery v0.18.0 h1:fuPfYpk3cs1Okp/515pAf0dNhL66+8zk8RLbSX+EgAE= -k8s.io/apimachinery v0.18.0/go.mod h1:9SnR/e11v5IbyPCGbvJViimtJ0SwHG4nfZFjU77ftcA= -k8s.io/code-generator v0.18.0 h1:0xIRWzym+qMgVpGmLESDeMfz/orwgxwxFFAo1xfGNtQ= -k8s.io/code-generator v0.18.0/go.mod h1:+UHX5rSbxmR8kzS+FAv7um6dtYrZokQvjHpDSYRVkTc= +k8s.io/api v0.18.2 h1:wG5g5ZmSVgm5B+eHMIbI9EGATS2L8Z72rda19RIEgY8= +k8s.io/api v0.18.2/go.mod h1:SJCWI7OLzhZSvbY7U8zwNl9UA4o1fizoug34OV/2r78= +k8s.io/apimachinery v0.18.2 h1:44CmtbmkzVDAhCpRVSiP2R5PPrC2RtlIv/MoB8xpdRA= +k8s.io/apimachinery v0.18.2/go.mod h1:9SnR/e11v5IbyPCGbvJViimtJ0SwHG4nfZFjU77ftcA= +k8s.io/code-generator v0.18.2 h1:C1Nn2JiMf244CvBDKVPX0W2mZFJkVBg54T8OV7/Imso= +k8s.io/code-generator v0.18.2/go.mod h1:+UHX5rSbxmR8kzS+FAv7um6dtYrZokQvjHpDSYRVkTc= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20200114144118-36b2048a9120 h1:RPscN6KhmG54S33L+lr3GS+oD1jmchIU0ll519K6FA4= k8s.io/gengo v0.0.0-20200114144118-36b2048a9120/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= diff --git a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/bindata.mk b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/bindata.mk index 97b7bd36d..04b534ac2 100644 --- a/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/bindata.mk +++ b/vendor/github.com/openshift/build-machinery-go/make/targets/openshift/bindata.mk @@ -3,7 +3,7 @@ TMP_GOPATH :=$(shell mktemp -d) .ensure-go-bindata: ln -s $(abspath ./vendor) "$(TMP_GOPATH)/src" - export GO111MODULE=off && export GOPATH=$(TMP_GOPATH) && export GOBIN=$(TMP_GOPATH)/bin && go install "./vendor/github.com/jteeuwen/go-bindata/..." + export GO111MODULE=off && export GOPATH=$(TMP_GOPATH) && export GOBIN=$(TMP_GOPATH)/bin && go install "./vendor/github.com/go-bindata/go-bindata/..." # $1 - input dirs # $2 - prefix diff --git a/vendor/github.com/openshift/library-go/pkg/controller/controllercmd/builder.go b/vendor/github.com/openshift/library-go/pkg/controller/controllercmd/builder.go index bd128abaf..2fcf74c52 100644 --- a/vendor/github.com/openshift/library-go/pkg/controller/controllercmd/builder.go +++ b/vendor/github.com/openshift/library-go/pkg/controller/controllercmd/builder.go @@ -9,6 +9,7 @@ import ( "sync" "time" + "k8s.io/client-go/tools/record" "k8s.io/component-base/metrics" "k8s.io/component-base/metrics/legacyregistry" "k8s.io/klog" @@ -64,6 +65,7 @@ type ControllerBuilder struct { leaderElection *configv1.LeaderElection fileObserver fileobserver.Observer fileObserverReactorFn func(file string, action fileobserver.ActionType) error + eventRecorderOptions record.CorrelatorOptions startFunc StartFunc componentName string @@ -175,6 +177,14 @@ func (b *ControllerBuilder) WithInstanceIdentity(identity string) *ControllerBui return b } +// WithEventRecorderOptions allows to override the default Kubernetes event recorder correlator options. +// This is needed if the binary is sending a lot of events. +// Using events.DefaultOperatorEventRecorderOptions here makes a good default for normal operator binary. +func (b *ControllerBuilder) WithEventRecorderOptions(options record.CorrelatorOptions) *ControllerBuilder { + b.eventRecorderOptions = options + return b +} + // Run starts your controller for you. It uses leader election if you asked, otherwise it directly calls you func (b *ControllerBuilder) Run(ctx context.Context, config *unstructured.Unstructured) error { clientConfig, err := b.getClientConfig() @@ -195,7 +205,7 @@ func (b *ControllerBuilder) Run(ctx context.Context, config *unstructured.Unstru if err != nil { klog.Warningf("unable to get owner reference (falling back to namespace): %v", err) } - eventRecorder := events.NewKubeRecorder(kubeClient.CoreV1().Events(namespace), b.componentName, controllerRef) + eventRecorder := events.NewKubeRecorderWithOptions(kubeClient.CoreV1().Events(namespace), b.eventRecorderOptions, b.componentName, controllerRef) // if there is file observer defined for this command, add event into default reaction function. if b.fileObserverReactorFn != nil { @@ -210,7 +220,7 @@ func (b *ControllerBuilder) Run(ctx context.Context, config *unstructured.Unstru if b.versionInfo != nil { buildInfo := metrics.NewGaugeVec( &metrics.GaugeOpts{ - Name: strings.Replace(b.componentNamespace, "-", "_", -1) + "_build_info", + Name: strings.Replace(namespace, "-", "_", -1) + "_build_info", Help: "A metric with a constant '1' value labeled by major, minor, git version, git commit, git tree state, build date, Go version, " + "and compiler from which " + b.componentName + " was built, and platform on which it is running.", StabilityLevel: metrics.ALPHA, @@ -298,6 +308,7 @@ func (b ControllerBuilder) getOnStartedLeadingFunc(controllerContext *Controller select { case <-ctx.Done(): // context closed means the process likely received signal to terminate + controllerContext.EventRecorder.Shutdown() case <-stoppedCh: // if context was not cancelled (it is not "done"), but the startFunc terminated, it means it terminated prematurely // when this happen, it means the controllers terminated without error. diff --git a/vendor/github.com/openshift/library-go/pkg/controller/controllercmd/cmd.go b/vendor/github.com/openshift/library-go/pkg/controller/controllercmd/cmd.go index 1e603efe1..0e9d1201a 100644 --- a/vendor/github.com/openshift/library-go/pkg/controller/controllercmd/cmd.go +++ b/vendor/github.com/openshift/library-go/pkg/controller/controllercmd/cmd.go @@ -24,6 +24,7 @@ import ( "github.com/openshift/library-go/pkg/config/configdefaults" "github.com/openshift/library-go/pkg/controller/fileobserver" "github.com/openshift/library-go/pkg/crypto" + "github.com/openshift/library-go/pkg/operator/events" "github.com/openshift/library-go/pkg/serviceability" // for metrics @@ -267,6 +268,7 @@ func (c *ControllerCommandConfig) StartController(ctx context.Context) error { WithComponentNamespace(c.basicFlags.Namespace). WithLeaderElection(config.LeaderElection, c.basicFlags.Namespace, c.componentName+"-lock"). WithVersion(c.version). + WithEventRecorderOptions(events.RecommendedClusterSingletonCorrelatorOptions()). WithRestartOnChange(exitOnChangeReactorCh, startingFileContent, observedFiles...) if !c.DisableServing { diff --git a/vendor/github.com/openshift/library-go/pkg/operator/events/recorder.go b/vendor/github.com/openshift/library-go/pkg/operator/events/recorder.go index bb8e8ddaf..7139c1b69 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/events/recorder.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/events/recorder.go @@ -33,6 +33,8 @@ type Recorder interface { // ComponentName returns the current source component name for the event. // This allows to suffix the original component name with 'sub-component'. ComponentName() string + + Shutdown() } // podNameEnv is a name of environment variable inside container that specifies the name of the current replica set. @@ -159,6 +161,8 @@ func (r *recorder) ComponentName() string { return r.sourceComponent } +func (r *recorder) Shutdown() {} + func (r *recorder) ForComponent(componentName string) Recorder { newRecorderForComponent := *r newRecorderForComponent.sourceComponent = componentName diff --git a/vendor/github.com/openshift/library-go/pkg/operator/events/recorder_in_memory.go b/vendor/github.com/openshift/library-go/pkg/operator/events/recorder_in_memory.go index b64d9f6a9..27103cd70 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/events/recorder_in_memory.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/events/recorder_in_memory.go @@ -37,6 +37,8 @@ func (r *inMemoryEventRecorder) ComponentName() string { return r.source } +func (r *inMemoryEventRecorder) Shutdown() {} + func (r *inMemoryEventRecorder) ForComponent(component string) Recorder { r.Lock() defer r.Unlock() diff --git a/vendor/github.com/openshift/library-go/pkg/operator/events/recorder_logging.go b/vendor/github.com/openshift/library-go/pkg/operator/events/recorder_logging.go index 7f3b5cd8b..5a8ec765a 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/events/recorder_logging.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/events/recorder_logging.go @@ -26,6 +26,8 @@ func (r *LoggingEventRecorder) ForComponent(component string) Recorder { return &newRecorder } +func (r *LoggingEventRecorder) Shutdown() {} + func (r *LoggingEventRecorder) WithComponentSuffix(suffix string) Recorder { return r.ForComponent(fmt.Sprintf("%s-%s", r.ComponentName(), suffix)) } diff --git a/vendor/github.com/openshift/library-go/pkg/operator/events/recorder_upstream.go b/vendor/github.com/openshift/library-go/pkg/operator/events/recorder_upstream.go index 359d2eb81..3eb238753 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/events/recorder_upstream.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/events/recorder_upstream.go @@ -2,24 +2,34 @@ package events import ( "fmt" - - "k8s.io/klog" + "strings" + "sync" corev1 "k8s.io/api/core/v1" "k8s.io/client-go/kubernetes/scheme" corev1client "k8s.io/client-go/kubernetes/typed/core/v1" "k8s.io/client-go/tools/record" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" + "k8s.io/klog" ) -// NewKubeRecorder returns new event recorder. -func NewKubeRecorder(client corev1client.EventInterface, sourceComponentName string, involvedObjectRef *corev1.ObjectReference) Recorder { +// NewKubeRecorder returns new event recorder with tweaked correlator options. +func NewKubeRecorderWithOptions(client corev1client.EventInterface, options record.CorrelatorOptions, sourceComponentName string, involvedObjectRef *corev1.ObjectReference) Recorder { return (&upstreamRecorder{ client: client, component: sourceComponentName, involvedObjectRef: involvedObjectRef, + options: options, + fallbackRecorder: NewRecorder(client, sourceComponentName, involvedObjectRef), }).ForComponent(sourceComponentName) } +// NewKubeRecorder returns new event recorder with default correlator options. +func NewKubeRecorder(client corev1client.EventInterface, sourceComponentName string, involvedObjectRef *corev1.ObjectReference) Recorder { + return NewKubeRecorderWithOptions(client, record.CorrelatorOptions{}, sourceComponentName, involvedObjectRef) +} + // upstreamRecorder is an implementation of Recorder interface. type upstreamRecorder struct { client corev1client.EventInterface @@ -27,20 +37,85 @@ type upstreamRecorder struct { broadcaster record.EventBroadcaster eventRecorder record.EventRecorder involvedObjectRef *corev1.ObjectReference + options record.CorrelatorOptions + + // shuttingDown indicates that the broadcaster for this recorder is being shut down + shuttingDown bool + shutdownMutex sync.RWMutex + + // fallbackRecorder is used when the kube recorder is shutting down + // in that case we create the events directly. + fallbackRecorder Recorder +} + +// RecommendedClusterSingletonCorrelatorOptions provides recommended event correlator options for components that produce +// many events (like operators). +func RecommendedClusterSingletonCorrelatorOptions() record.CorrelatorOptions { + return record.CorrelatorOptions{ + BurstSize: 60, // default: 25 (change allows a single source to send 50 events about object per minute) + QPS: 1. / 1., // default: 1/300 (change allows refill rate to 1 new event every 1s) + KeyFunc: func(event *corev1.Event) (aggregateKey string, localKey string) { + return strings.Join([]string{ + event.Source.Component, + event.Source.Host, + event.InvolvedObject.Kind, + event.InvolvedObject.Namespace, + event.InvolvedObject.Name, + string(event.InvolvedObject.UID), + event.InvolvedObject.APIVersion, + event.Type, + event.Reason, + // By default, KeyFunc don't use message for aggregation, this cause events with different message, but same reason not be lost as "similar events". + event.Message, + }, ""), event.Message + }, + } +} + +var eventsCounterMetric = metrics.NewCounterVec(&metrics.CounterOpts{ + Subsystem: "event_recorder", + Name: "total_events_count", + Help: "Total count of events processed by this event recorder per involved object", + StabilityLevel: metrics.ALPHA, +}, []string{"severity"}) + +func init() { + (&sync.Once{}).Do(func() { + legacyregistry.MustRegister(eventsCounterMetric) + }) } func (r *upstreamRecorder) ForComponent(componentName string) Recorder { - newRecorderForComponent := *r - broadcaster := record.NewBroadcaster() + newRecorderForComponent := upstreamRecorder{ + client: r.client, + fallbackRecorder: r.fallbackRecorder.WithComponentSuffix(componentName), + options: r.options, + involvedObjectRef: r.involvedObjectRef, + shuttingDown: r.shuttingDown, + } + + // tweak the event correlator, so we don't loose important events. + broadcaster := record.NewBroadcasterWithCorrelatorOptions(r.options) broadcaster.StartLogging(klog.Infof) broadcaster.StartRecordingToSink(&corev1client.EventSinkImpl{Interface: newRecorderForComponent.client}) newRecorderForComponent.eventRecorder = broadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: componentName}) + newRecorderForComponent.broadcaster = broadcaster newRecorderForComponent.component = componentName return &newRecorderForComponent } +func (r *upstreamRecorder) Shutdown() { + r.shutdownMutex.Lock() + r.shuttingDown = true + r.shutdownMutex.Unlock() + // Wait for broadcaster to flush events (this is blocking) + // TODO: There is still race condition in upstream that might cause panic() on events recorded after the shutdown + // is called as the event recording is not-blocking (go routine based). + r.broadcaster.Shutdown() +} + func (r *upstreamRecorder) WithComponentSuffix(suffix string) Recorder { return r.ForComponent(fmt.Sprintf("%s-%s", r.ComponentName(), suffix)) } @@ -59,12 +134,33 @@ func (r *upstreamRecorder) Warningf(reason, messageFmt string, args ...interface r.Warning(reason, fmt.Sprintf(messageFmt, args...)) } +func (r *upstreamRecorder) incrementEventsCounter(severity string) { + if r.involvedObjectRef == nil { + return + } + eventsCounterMetric.WithLabelValues(severity).Inc() +} + // Event emits the normal type event. func (r *upstreamRecorder) Event(reason, message string) { + r.shutdownMutex.RLock() + defer r.shutdownMutex.RUnlock() + defer r.incrementEventsCounter(corev1.EventTypeNormal) + if r.shuttingDown { + r.fallbackRecorder.Event(reason, message) + return + } r.eventRecorder.Event(r.involvedObjectRef, corev1.EventTypeNormal, reason, message) } // Warning emits the warning type event. func (r *upstreamRecorder) Warning(reason, message string) { + r.shutdownMutex.RLock() + defer r.shutdownMutex.RUnlock() + defer r.incrementEventsCounter(corev1.EventTypeWarning) + if r.shuttingDown { + r.fallbackRecorder.Warning(reason, message) + return + } r.eventRecorder.Event(r.involvedObjectRef, corev1.EventTypeWarning, reason, message) } diff --git a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/apps.go b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/apps.go index 253b17ef1..537768818 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/apps.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/apps.go @@ -2,6 +2,9 @@ package resourceapply import ( "context" + "crypto/sha256" + "encoding/json" + "fmt" "k8s.io/klog" @@ -15,13 +18,103 @@ import ( "github.com/openshift/library-go/pkg/operator/resource/resourcemerge" ) -// ApplyDeployment merges objectmeta and requires matching generation. It returns the final Object, whether any change as made, and an error -func ApplyDeployment(client appsclientv1.DeploymentsGetter, recorder events.Recorder, required *appsv1.Deployment, expectedGeneration int64, +// The Apply methods in this file ensure that a resource is created or updated to match +// the form provided by the caller. +// +// If the resource does not yet exist, it will be created. +// +// If the resource exists, the metadata of the required resource will be merged with the +// existing resource and an update will be performed if the spec and metadata differ between +// the required and existing resources. To be reliable, the input of the required spec from +// the operator should be stable. It does not need to set all fields, since some fields are +// defaulted server-side. Detection of spec drift from intent by other actors is determined +// by generation, not by spec comparison. +// +// To ensure an update in response to state external to the resource spec, the caller should +// set an annotation representing that external state e.g. +// +// `myoperator.openshift.io/config-resource-version: ` +// +// An update will be performed if: +// +// - The required resource metadata differs from that of the existing resource. +// - The difference will be detected by comparing the name, namespace, labels and +// annotations of the 2 resources. +// +// - The generation expected by the operator differs from generation of the existing +// resource. +// - This is the likely result of an actor other than the operator updating a resource +// managed by the operator. +// +// - The spec of the required resource differs from the spec of the existing resource. +// - The difference will be detected via metadata comparison since the hash of the +// resource's spec will be set as an annotation prior to comparison. + +const specHashAnnotation = "operator.openshift.io/spec-hash" + +// SetSpecHashAnnotation computes the hash of the provided spec and sets an annotation of the +// hash on the provided ObjectMeta. This method is used internally by Apply methods, and +// is exposed to support testing with fake clients that need to know the mutated form of the +// resource resulting from an Apply call. +func SetSpecHashAnnotation(objMeta *metav1.ObjectMeta, spec interface{}) error { + jsonBytes, err := json.Marshal(spec) + if err != nil { + return err + } + specHash := fmt.Sprintf("%x", sha256.Sum256(jsonBytes)) + if objMeta.Annotations == nil { + objMeta.Annotations = map[string]string{} + } + objMeta.Annotations[specHashAnnotation] = specHash + return nil +} + +// ApplyDeployment ensures the form of the specified deployment is present in the API. If it +// does not exist, it will be created. If it does exist, the metadata of the required +// deployment will be merged with the existing deployment and an update performed if the +// deployment spec and metadata differ from the previously required spec and metadata. For +// further detail, check the top-level comment. +// +// NOTE: The previous implementation of this method was renamed to +// ApplyDeploymentWithForce. If are reading this in response to a compile error due to the +// change in signature, you have the following options: +// +// - Update the calling code to rely on the spec comparison provided by the new +// implementation. If the code in question was specifying the force parameter to ensure +// rollout in response to changes in resources external to the deployment, it will need to be +// revised to set that external state as an annotation e.g. +// +// myoperator.openshift.io/my-resource: +// +// - Update the call to use ApplyDeploymentWithForce. This is available as a temporary measure +// but the method is deprecated and will be removed in 4.6. +func ApplyDeployment(client appsclientv1.DeploymentsGetter, recorder events.Recorder, + requiredOriginal *appsv1.Deployment, expectedGeneration int64) (*appsv1.Deployment, bool, error) { + + required := requiredOriginal.DeepCopy() + err := SetSpecHashAnnotation(&required.ObjectMeta, required.Spec) + if err != nil { + return nil, false, err + } + + return ApplyDeploymentWithForce(client, recorder, required, expectedGeneration, false) +} + +// ApplyDeploymentWithForce merges objectmeta and requires matching generation. It returns the final Object, whether any change as made, and an error. +// +// DEPRECATED - This method will be removed in 4.6 and callers will need to migrate to ApplyDeployment before then. +func ApplyDeploymentWithForce(client appsclientv1.DeploymentsGetter, recorder events.Recorder, requiredOriginal *appsv1.Deployment, expectedGeneration int64, forceRollout bool) (*appsv1.Deployment, bool, error) { + + required := requiredOriginal.DeepCopy() if required.Annotations == nil { required.Annotations = map[string]string{} } - required.Annotations["operator.openshift.io/pull-spec"] = required.Spec.Template.Spec.Containers[0].Image + if _, ok := required.Annotations[specHashAnnotation]; !ok { + // If the spec hash annotation is not present, the caller expects the + // pull-spec annotation to be applied. + required.Annotations["operator.openshift.io/pull-spec"] = required.Spec.Template.Spec.Containers[0].Image + } existing, err := client.Deployments(required.Namespace).Get(context.TODO(), required.Name, metav1.GetOptions{}) if apierrors.IsNotFound(err) { actual, err := client.Deployments(required.Namespace).Create(context.TODO(), required, metav1.CreateOptions{}) @@ -66,12 +159,49 @@ func ApplyDeployment(client appsclientv1.DeploymentsGetter, recorder events.Reco return actual, true, err } -// ApplyDaemonSet merges objectmeta and requires matching generation. It returns the final Object, whether any change as made, and an error -func ApplyDaemonSet(client appsclientv1.DaemonSetsGetter, recorder events.Recorder, required *appsv1.DaemonSet, expectedGeneration int64, forceRollout bool) (*appsv1.DaemonSet, bool, error) { +// ApplyDaemonSet ensures the form of the specified daemonset is present in the API. If it +// does not exist, it will be created. If it does exist, the metadata of the required +// daemonset will be merged with the existing daemonset and an update performed if the +// daemonset spec and metadata differ from the previously required spec and metadata. For +// further detail, check the top-level comment. +// +// NOTE: The previous implementation of this method was renamed to ApplyDaemonSetWithForce. If +// are reading this in response to a compile error due to the change in signature, you have +// the following options: +// +// - Update the calling code to rely on the spec comparison provided by the new +// implementation. If the code in question was specifying the force parameter to ensure +// rollout in response to changes in resources external to the daemonset, it will need to be +// revised to set that external state as an annotation e.g. +// +// myoperator.openshift.io/my-resource: +// +// - Update the call to use ApplyDaemonSetWithForce. This is available as a temporary measure +// but the method is deprecated and will be removed in 4.6. +func ApplyDaemonSet(client appsclientv1.DaemonSetsGetter, recorder events.Recorder, + requiredOriginal *appsv1.DaemonSet, expectedGeneration int64) (*appsv1.DaemonSet, bool, error) { + + required := requiredOriginal.DeepCopy() + err := SetSpecHashAnnotation(&required.ObjectMeta, required.Spec) + if err != nil { + return nil, false, err + } + + return ApplyDaemonSetWithForce(client, recorder, required, expectedGeneration, false) +} + +// ApplyDaemonSetWithForce merges objectmeta and requires matching generation. It returns the final Object, whether any change as made, and an error +// DEPRECATED - This method will be removed in 4.6 and callers will need to migrate to ApplyDaemonSet before then. +func ApplyDaemonSetWithForce(client appsclientv1.DaemonSetsGetter, recorder events.Recorder, requiredOriginal *appsv1.DaemonSet, expectedGeneration int64, forceRollout bool) (*appsv1.DaemonSet, bool, error) { + required := requiredOriginal.DeepCopy() if required.Annotations == nil { required.Annotations = map[string]string{} } - required.Annotations["operator.openshift.io/pull-spec"] = required.Spec.Template.Spec.Containers[0].Image + if _, ok := required.Annotations[specHashAnnotation]; !ok { + // If the spec hash annotation is not present, the caller expects the + // pull-spec annotation to be applied. + required.Annotations["operator.openshift.io/pull-spec"] = required.Spec.Template.Spec.Containers[0].Image + } existing, err := client.DaemonSets(required.Namespace).Get(context.TODO(), required.Name, metav1.GetOptions{}) if apierrors.IsNotFound(err) { actual, err := client.DaemonSets(required.Namespace).Create(context.TODO(), required, metav1.CreateOptions{}) diff --git a/vendor/github.com/openshift/library-go/pkg/operator/status/status_controller.go b/vendor/github.com/openshift/library-go/pkg/operator/status/status_controller.go index 94eef82fd..2aec3b33e 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/status/status_controller.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/status/status_controller.go @@ -142,8 +142,8 @@ func (c StatusSyncer) Sync(ctx context.Context, syncCtx factory.SyncContext) err if equality.Semantic.DeepEqual(clusterOperatorObj, originalClusterOperatorObj) { return nil } - if _, updateErr := c.clusterOperatorClient.ClusterOperators().UpdateStatus(ctx, clusterOperatorObj, metav1.UpdateOptions{}); err != nil { - return updateErr + if _, err := c.clusterOperatorClient.ClusterOperators().UpdateStatus(ctx, clusterOperatorObj, metav1.UpdateOptions{}); err != nil { + return err } syncCtx.Recorder().Eventf("OperatorStatusChanged", "Status for operator %s changed: %s", c.clusterOperatorName, configv1helpers.GetStatusDiff(originalClusterOperatorObj.Status, clusterOperatorObj.Status)) return nil diff --git a/vendor/k8s.io/apimachinery/pkg/util/net/http.go b/vendor/k8s.io/apimachinery/pkg/util/net/http.go index 0ba586bfe..7449cbb0a 100644 --- a/vendor/k8s.io/apimachinery/pkg/util/net/http.go +++ b/vendor/k8s.io/apimachinery/pkg/util/net/http.go @@ -55,6 +55,12 @@ func JoinPreservingTrailingSlash(elem ...string) string { return result } +// IsTimeout returns true if the given error is a network timeout error +func IsTimeout(err error) bool { + neterr, ok := err.(net.Error) + return ok && neterr != nil && neterr.Timeout() +} + // IsProbableEOF returns true if the given error resembles a connection termination // scenario that would justify assuming that the watch is empty. // These errors are what the Go http stack returns back to us which are general diff --git a/vendor/k8s.io/apimachinery/pkg/watch/streamwatcher.go b/vendor/k8s.io/apimachinery/pkg/watch/streamwatcher.go index 8af256eb1..4269a836a 100644 --- a/vendor/k8s.io/apimachinery/pkg/watch/streamwatcher.go +++ b/vendor/k8s.io/apimachinery/pkg/watch/streamwatcher.go @@ -113,7 +113,7 @@ func (sw *StreamWatcher) receive() { case io.ErrUnexpectedEOF: klog.V(1).Infof("Unexpected EOF during watch stream event decoding: %v", err) default: - if net.IsProbableEOF(err) { + if net.IsProbableEOF(err) || net.IsTimeout(err) { klog.V(5).Infof("Unable to decode an event from the watch stream: %v", err) } else { sw.result <- Event{ diff --git a/vendor/k8s.io/client-go/rest/request.go b/vendor/k8s.io/client-go/rest/request.go index 1acd189ea..c5bc6a898 100644 --- a/vendor/k8s.io/client-go/rest/request.go +++ b/vendor/k8s.io/client-go/rest/request.go @@ -655,7 +655,7 @@ func (r *Request) Watch(ctx context.Context) (watch.Interface, error) { if err != nil { // The watch stream mechanism handles many common partial data errors, so closed // connections can be retried in many cases. - if net.IsProbableEOF(err) { + if net.IsProbableEOF(err) || net.IsTimeout(err) { return watch.NewEmptyWatch(), nil } return nil, err diff --git a/vendor/k8s.io/client-go/tools/cache/reflector.go b/vendor/k8s.io/client-go/tools/cache/reflector.go index dfdc2e738..99a7b284b 100644 --- a/vendor/k8s.io/client-go/tools/cache/reflector.go +++ b/vendor/k8s.io/client-go/tools/cache/reflector.go @@ -364,6 +364,8 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error { AllowWatchBookmarks: true, } + // start the clock before sending the request, since some proxies won't flush headers until after the first watch event is sent + start := r.clock.Now() w, err := r.listerWatcher.Watch(options) if err != nil { switch { @@ -390,7 +392,7 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error { return nil } - if err := r.watchHandler(w, &resourceVersion, resyncerrc, stopCh); err != nil { + if err := r.watchHandler(start, w, &resourceVersion, resyncerrc, stopCh); err != nil { if err != errorStopRequested { switch { case isExpiredError(err): @@ -417,8 +419,7 @@ func (r *Reflector) syncWith(items []runtime.Object, resourceVersion string) err } // watchHandler watches w and keeps *resourceVersion up to date. -func (r *Reflector) watchHandler(w watch.Interface, resourceVersion *string, errc chan error, stopCh <-chan struct{}) error { - start := r.clock.Now() +func (r *Reflector) watchHandler(start time.Time, w watch.Interface, resourceVersion *string, errc chan error, stopCh <-chan struct{}) error { eventCount := 0 // Stopping the watcher should be idempotent and if we return from this function there's no way diff --git a/vendor/modules.txt b/vendor/modules.txt index ace45787f..0b7d2e90e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -26,6 +26,8 @@ github.com/evanphx/json-patch github.com/getsentry/raven-go # github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 github.com/ghodss/yaml +# github.com/go-bindata/go-bindata v3.1.2+incompatible +github.com/go-bindata/go-bindata # github.com/go-openapi/jsonpointer v0.19.3 github.com/go-openapi/jsonpointer # github.com/go-openapi/jsonreference v0.19.3 @@ -72,9 +74,6 @@ github.com/imdario/mergo github.com/inconshreveable/mousetrap # github.com/json-iterator/go v1.1.9 github.com/json-iterator/go -# github.com/jteeuwen/go-bindata v3.0.8-0.20151023091102-a0ff2567cfb7+incompatible -github.com/jteeuwen/go-bindata -github.com/jteeuwen/go-bindata/go-bindata # github.com/konsorten/go-windows-terminal-sequences v1.0.1 github.com/konsorten/go-windows-terminal-sequences # github.com/mailru/easyjson v0.7.0 @@ -89,7 +88,7 @@ github.com/modern-go/concurrent github.com/modern-go/reflect2 # github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 github.com/munnerz/goautoneg -# github.com/openshift/api v0.0.0-20200417173520-2ef3f20bd355 +# github.com/openshift/api v0.0.0-20200424083944-0422dc17083e github.com/openshift/api github.com/openshift/api/apps github.com/openshift/api/apps/v1 @@ -136,7 +135,7 @@ github.com/openshift/api/template github.com/openshift/api/template/v1 github.com/openshift/api/user github.com/openshift/api/user/v1 -# github.com/openshift/build-machinery-go v0.0.0-20200211121458-5e3d6e570160 +# github.com/openshift/build-machinery-go v0.0.0-20200424080330-082bf86082cc github.com/openshift/build-machinery-go github.com/openshift/build-machinery-go/make github.com/openshift/build-machinery-go/make/lib @@ -156,7 +155,7 @@ github.com/openshift/client-go/config/informers/externalversions/config github.com/openshift/client-go/config/informers/externalversions/config/v1 github.com/openshift/client-go/config/informers/externalversions/internalinterfaces github.com/openshift/client-go/config/listers/config/v1 -# github.com/openshift/library-go v0.0.0-20200414135834-ccc4bb27d032 +# github.com/openshift/library-go v0.0.0-20200427130628-9b02543ac833 github.com/openshift/library-go/pkg/assets github.com/openshift/library-go/pkg/config/client github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers @@ -249,7 +248,7 @@ golang.org/x/crypto/nacl/secretbox golang.org/x/crypto/poly1305 golang.org/x/crypto/salsa20/salsa golang.org/x/crypto/ssh/terminal -# golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e +# golang.org/x/net v0.0.0-20200421231249-e086a090c8fd golang.org/x/net/context golang.org/x/net/context/ctxhttp golang.org/x/net/http/httpguts @@ -338,7 +337,7 @@ gopkg.in/natefinch/lumberjack.v2 gopkg.in/warnings.v0 # gopkg.in/yaml.v2 v2.2.8 gopkg.in/yaml.v2 -# k8s.io/api v0.18.0 +# k8s.io/api v0.18.2 k8s.io/api/admission/v1 k8s.io/api/admission/v1beta1 k8s.io/api/admissionregistration/v1 @@ -382,7 +381,7 @@ k8s.io/api/settings/v1alpha1 k8s.io/api/storage/v1 k8s.io/api/storage/v1alpha1 k8s.io/api/storage/v1beta1 -# k8s.io/apiextensions-apiserver v0.18.0 +# k8s.io/apiextensions-apiserver v0.18.2 k8s.io/apiextensions-apiserver/pkg/apis/apiextensions k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1 k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1 @@ -390,7 +389,7 @@ k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1 k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1 -# k8s.io/apimachinery v0.18.0 +# k8s.io/apimachinery v0.18.2 k8s.io/apimachinery/pkg/api/equality k8s.io/apimachinery/pkg/api/errors k8s.io/apimachinery/pkg/api/meta @@ -442,7 +441,7 @@ k8s.io/apimachinery/pkg/version k8s.io/apimachinery/pkg/watch k8s.io/apimachinery/third_party/forked/golang/json k8s.io/apimachinery/third_party/forked/golang/reflect -# k8s.io/apiserver v0.18.0 +# k8s.io/apiserver v0.18.2 k8s.io/apiserver/pkg/admission k8s.io/apiserver/pkg/admission/configuration k8s.io/apiserver/pkg/admission/initializer @@ -563,7 +562,7 @@ k8s.io/apiserver/plugin/pkg/audit/truncate k8s.io/apiserver/plugin/pkg/audit/webhook k8s.io/apiserver/plugin/pkg/authenticator/token/webhook k8s.io/apiserver/plugin/pkg/authorizer/webhook -# k8s.io/client-go v0.18.0 +# k8s.io/client-go v0.18.2 k8s.io/client-go/discovery k8s.io/client-go/discovery/fake k8s.io/client-go/dynamic @@ -775,7 +774,7 @@ k8s.io/client-go/util/homedir k8s.io/client-go/util/keyutil k8s.io/client-go/util/retry k8s.io/client-go/util/workqueue -# k8s.io/component-base v0.18.0 +# k8s.io/component-base v0.18.2 k8s.io/component-base/cli/flag k8s.io/component-base/featuregate k8s.io/component-base/logs @@ -785,7 +784,7 @@ k8s.io/component-base/metrics/testutil k8s.io/component-base/version # k8s.io/klog v1.0.0 k8s.io/klog -# k8s.io/kube-aggregator v0.18.0 +# k8s.io/kube-aggregator v0.18.2 k8s.io/kube-aggregator/pkg/apis/apiregistration k8s.io/kube-aggregator/pkg/apis/apiregistration/v1 k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1