diff --git a/glide.lock b/glide.lock index 96b1799e3dbb..4a255c15c66d 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: 8888b17d17b9c04e3620a7b2e2a93737074f29b879871aec3d3564f3b9500213 -updated: 2019-09-06T11:10:45.874620622-04:00 +hash: 46a0b475f0430496b8a4b06cb19ba9d24fde3f30c59a4ea55fa308caa79a2ebe +updated: 2019-09-25T14:19:31.213384475-05:00 imports: - name: bitbucket.org/ww/goautoneg version: 2ae31c8b6b30d2f4c8100c20d527b571e9c433bb @@ -10,7 +10,7 @@ imports: - compute/metadata - internal - name: github.com/apparentlymart/go-cidr - version: b1115bf8e14a60131a196f908223e4506b0ddc35 + version: c0fb5fbe0acb592411e2db59add389a43260ad44 subpackages: - cidr - name: github.com/armon/circbuf @@ -377,7 +377,7 @@ imports: - ipamutils - ipvs - name: github.com/docker/libtrust - version: 9cbd2a1374f46905c68a4eb3694a130610adc62a + version: aabc10ec26b754e797f9028f4589c5b7bd90dc20 - name: github.com/docker/spdystream version: 449fdfce4d962303d702fec724ef0ad181c92528 subpackages: @@ -422,7 +422,7 @@ imports: - name: github.com/go-openapi/jsonreference version: 8483a886a90412cd6858df4ea3483dce9c8e35a3 - name: github.com/go-openapi/loads - version: a80dea3052f00e5f032e860dd7355cd0cc67e24d + version: 150d36912387ec2f607be674c5be309ddccc0eed - name: github.com/go-openapi/runtime version: 231d7876b7019dbcbfc97a7ba764379497b67c1d - name: github.com/go-openapi/spec @@ -492,13 +492,13 @@ imports: - ptypes/timestamp - ptypes/wrappers - name: github.com/gonum/blas - version: 37e82626499e1df7c54aeaba0959fd6e7e8dc1e4 + version: f22b278b28ac9805aadd613a754a60c35b24ae69 subpackages: - blas64 - native - native/internal/math32 - name: github.com/gonum/floats - version: f74b330d45c56584a6ea7a27f5c64ea2900631e9 + version: c233463c7e827fd71a8cdb62dfda0e98f7c39ad5 - name: github.com/gonum/graph version: 50b27dea7ebbfb052dfaf91681afc6fde28d8796 subpackages: @@ -515,17 +515,17 @@ imports: - path - simple - name: github.com/gonum/internal - version: e57e4534cf9b3b00ef6c0175f59d8d2d34f60914 + version: f884aa71402950fb2796dbea0d5aa9ef9cfad8ca subpackages: - asm/f32 - asm/f64 - name: github.com/gonum/lapack - version: 5ed4b826becd1807e09377508f51756586d1a98c + version: e4cdc5a0bff924bb10be88482e635bd40429f65e subpackages: - lapack64 - native - name: github.com/gonum/matrix - version: dd6034299e4242c9f0ea36735e6d4264dfcb3f9f + version: c518dec07be9a636c38a4650e217be059b5952ec subpackages: - mat64 - name: github.com/google/btree @@ -687,16 +687,24 @@ imports: version: 2de2192f9e35ce981c152a873ed943b93b79ced4 - name: github.com/kr/fs version: 2788f0dbd16903de03cb8186e5c7d97b69ad387b +- name: github.com/lestrrat-go/jspointer + version: 82fadba7561c3a8d78133c2b957263c0963bb79d +- name: github.com/lestrrat-go/jsref + version: 1b590508f37d3af76c77c8328e16978d2889b486 + subpackages: + - provider +- name: github.com/lestrrat-go/pdebug + version: 39f9a71bcabe9432cbdfe4d3d33f41988acd2ce6 +- name: github.com/lestrrat-go/structinfo + version: acd51874663bf3297433cb1f1015075c3cbe6130 - name: github.com/lestrrat/go-jspointer - version: f4881e611bdbe9fb413a7780721ef8400a1f2341 + version: 82fadba7561c3a8d78133c2b957263c0963bb79d repo: https://github.com/lestrrat/go-jspointer.git - name: github.com/lestrrat/go-jsref version: 50df7b2d07d799426a9ac43fa24bdb4785f72a54 repo: https://github.com/lestrrat/go-jsref.git - subpackages: - - provider - name: github.com/lestrrat/go-jsschema - version: a6a42341b50d8d7e2a733db922eefaa756321021 + version: 5c81c58ffcc359c4390d440b45f5462edb0107cb - name: github.com/lestrrat/go-pdebug version: 569c97477ae8837e053e5a50bc739e15172b8ebe repo: https://github.com/lestrrat/go-pdebug.git @@ -849,7 +857,7 @@ imports: - specs-go - specs-go/v1 - name: github.com/opencontainers/runc - version: 7c7775178c25e952571573f44a8df281824cf8e1 + version: a7f8722a9c79bf82b30f93f7f86a3768dbcd1424 repo: https://github.com/openshift/opencontainers-runc.git subpackages: - libcontainer @@ -878,7 +886,7 @@ imports: - go-selinux - go-selinux/label - name: github.com/openshift/api - version: a25bb2adc83e68c68e3696332ff1d21694a34bb0 + version: cdbe64fb0c9184ffe47d24d0ea490705a92d9fd8 subpackages: - annotations - apps @@ -1049,7 +1057,7 @@ imports: - user/informers/externalversions/user/v1 - user/listers/user/v1 - name: github.com/openshift/library-go - version: 7d4acc018c610623ee1413b1e7aebe2ac675d35f + version: 27b03247913b2f6a0abcea95cb9b6c896adc2531 subpackages: - pkg/apiserver/admission/admissionrestconfig - pkg/apiserver/admission/admissiontimeout @@ -1413,7 +1421,7 @@ imports: - pubsub/v1 - tpu/v1 - name: google.golang.org/appengine - version: 54a98f90d1c46b7731eb8fb305d2a321c30ef610 + version: c71d63e301d75423acb410203c747cad31e9a5e7 subpackages: - internal - internal/app_identity @@ -2097,7 +2105,7 @@ imports: subpackages: - config/v1beta1 - name: k8s.io/kubernetes - version: 3198cd02079fbba5fa9fecbec4391adb307e10ad + version: 910ed37794970984599792084da6031e2353f43b repo: https://github.com/openshift/kubernetes.git subpackages: - cmd/cloud-controller-manager/app diff --git a/glide.yaml b/glide.yaml index d68bf7ce48b2..b9a10b532eec 100644 --- a/glide.yaml +++ b/glide.yaml @@ -87,13 +87,13 @@ import: # openshift second - package: github.com/openshift/api - version: master + version: release-4.2 - package: github.com/openshift/client-go - version: master + version: release-4.2 - package: github.com/openshift/library-go - version: master + version: release-4.2 - package: github.com/openshift/apiserver-library-go - version: master + version: 4d81e8c49306fab396f2ad574beb87e10203d578 # forks third # master @@ -104,7 +104,7 @@ import: # origin-3.11-runc-871ba2e - package: github.com/opencontainers/runc repo: https://github.com/openshift/opencontainers-runc.git - version: 7c7775178c25e952571573f44a8df281824cf8e1 + version: a7f8722a9c79bf82b30f93f7f86a3768dbcd1424 # pod - sjenning # openshift-4.1-cadvisor-v0.32.0 - package: github.com/google/cadvisor diff --git a/vendor/github.com/apparentlymart/go-cidr/cidr/cidr.go b/vendor/github.com/apparentlymart/go-cidr/cidr/cidr.go index c292db0ce07e..ed749d4c51cf 100644 --- a/vendor/github.com/apparentlymart/go-cidr/cidr/cidr.go +++ b/vendor/github.com/apparentlymart/go-cidr/cidr/cidr.go @@ -44,7 +44,7 @@ func Subnet(base *net.IPNet, newBits int, num int) (*net.IPNet, error) { } return &net.IPNet{ - IP: insertNumIntoIP(ip, num, newPrefixLen), + IP: insertNumIntoIP(ip, big.NewInt(int64(num)), newPrefixLen), Mask: net.CIDRMask(newPrefixLen, addrLen), }, nil } @@ -56,19 +56,23 @@ func Subnet(base *net.IPNet, newBits int, num int) (*net.IPNet, error) { func Host(base *net.IPNet, num int) (net.IP, error) { ip := base.IP mask := base.Mask + bigNum := big.NewInt(int64(num)) parentLen, addrLen := mask.Size() hostLen := addrLen - parentLen - maxHostNum := uint64(1< maxHostNum { + if numUint64.Cmp(maxHostNum) == 1 { return nil, fmt.Errorf("prefix of %d does not accommodate a host numbered %d", parentLen, num) } var bitlength int @@ -77,7 +81,7 @@ func Host(base *net.IPNet, num int) (net.IP, error) { } else { bitlength = 128 } - return insertNumIntoIP(ip, num, bitlength), nil + return insertNumIntoIP(ip, bigNum, bitlength), nil } // AddressRange returns the first and last addresses in the given CIDR range. @@ -129,7 +133,11 @@ func VerifyNoOverlap(subnets []*net.IPNet, CIDRBlock *net.IPNet) error { if !CIDRBlock.Contains(firstLastIP[i][0]) || !CIDRBlock.Contains(firstLastIP[i][1]) { return fmt.Errorf("%s does not fully contain %s", CIDRBlock.String(), s.String()) } - for j := i + 1; j < len(subnets); j++ { + for j := 0; j < len(subnets); j++ { + if i == j { + continue + } + first := firstLastIP[j][0] last := firstLastIP[j][1] if s.Contains(first) || s.Contains(last) { diff --git a/vendor/github.com/apparentlymart/go-cidr/cidr/cidr_test.go b/vendor/github.com/apparentlymart/go-cidr/cidr/cidr_test.go index 64fdce8e1d13..98ede1f9c883 100644 --- a/vendor/github.com/apparentlymart/go-cidr/cidr/cidr_test.go +++ b/vendor/github.com/apparentlymart/go-cidr/cidr/cidr_test.go @@ -139,6 +139,16 @@ func TestHost(t *testing.T) { Num: -5, Error: true, // 4 address (0-3) in 2 bits; cannot accomodate 5 }, + Case{ + Range: "fd9d:bc11:4020::/64", + Num: 2, + Output: "fd9d:bc11:4020::2", + }, + Case{ + Range: "fd9d:bc11:4020::/64", + Num: -2, + Output: "fd9d:bc11:4020:0:ffff:ffff:ffff:fffe", + }, } for _, testCase := range cases { @@ -397,6 +407,15 @@ func TestVerifyNetowrk(t *testing.T) { "192.168.12.128/26", }, }, + &testVerifyNetwork{ + CIDRBlock: "10.42.0.0/24", + CIDRList: []string{ + + "10.42.0.16/28", + "10.42.0.32/28", + "10.42.0.0/24", + }, + }, } for _, tc := range testCases { diff --git a/vendor/github.com/apparentlymart/go-cidr/cidr/wrangling.go b/vendor/github.com/apparentlymart/go-cidr/cidr/wrangling.go index 861a5f623d73..e5e6a2cf91a1 100644 --- a/vendor/github.com/apparentlymart/go-cidr/cidr/wrangling.go +++ b/vendor/github.com/apparentlymart/go-cidr/cidr/wrangling.go @@ -29,9 +29,8 @@ func intToIP(ipInt *big.Int, bits int) net.IP { return net.IP(ret) } -func insertNumIntoIP(ip net.IP, num int, prefixLen int) net.IP { +func insertNumIntoIP(ip net.IP, bigNum *big.Int, prefixLen int) net.IP { ipInt, totalBits := ipToInt(ip) - bigNum := big.NewInt(int64(num)) bigNum.Lsh(bigNum, uint(totalBits-prefixLen)) ipInt.Or(ipInt, bigNum) return intToIP(ipInt, totalBits) diff --git a/vendor/github.com/docker/libtrust/README.md b/vendor/github.com/docker/libtrust/README.md index 8e7db38186e6..dcffb31ae4a7 100644 --- a/vendor/github.com/docker/libtrust/README.md +++ b/vendor/github.com/docker/libtrust/README.md @@ -1,5 +1,9 @@ # libtrust +> **WARNING** this library is no longer actively developed, and will be integrated +> in the [docker/distribution][https://www.github.com/docker/distribution] +> repository in future. + Libtrust is library for managing authentication and authorization using public key cryptography. Authentication is handled using the identity attached to the public key. diff --git a/vendor/github.com/docker/libtrust/util.go b/vendor/github.com/docker/libtrust/util.go index d88176cc3d59..a5a101d3f117 100644 --- a/vendor/github.com/docker/libtrust/util.go +++ b/vendor/github.com/docker/libtrust/util.go @@ -152,7 +152,7 @@ func NewIdentityAuthTLSClientConfig(dockerUrl string, trustUnknownHosts bool, ro } // joseBase64UrlEncode encodes the given data using the standard base64 url -// encoding format but with all trailing '=' characters ommitted in accordance +// encoding format but with all trailing '=' characters omitted in accordance // with the jose specification. // http://tools.ietf.org/html/draft-ietf-jose-json-web-signature-31#section-2 func joseBase64UrlEncode(b []byte) string { diff --git a/vendor/github.com/go-openapi/loads/.travis.yml b/vendor/github.com/go-openapi/loads/.travis.yml index b0d357e659f9..1555a03559c9 100644 --- a/vendor/github.com/go-openapi/loads/.travis.yml +++ b/vendor/github.com/go-openapi/loads/.travis.yml @@ -1,16 +1,18 @@ -language: go +after_success: +- bash <(curl -s https://codecov.io/bash) go: -- 1.8 +- '1.9' +- 1.10.x +- 1.11.x install: - go get -u github.com/stretchr/testify - go get -u github.com/go-openapi/analysis - go get -u github.com/go-openapi/spec - go get -u github.com/go-openapi/swag - go get -u gopkg.in/yaml.v2 -script: -- ./hack/coverage -after_success: -- bash <(curl -s https://codecov.io/bash) +language: go notifications: slack: secure: OxkPwVp35qBTUilgWC8xykSj+sGMcj0h8IIOKD+Rflx2schZVlFfdYdyVBM+s9OqeOfvtuvnR9v1Ye2rPKAvcjWdC4LpRGUsgmItZaI6Um8Aj6+K9udCw5qrtZVfOVmRu8LieH//XznWWKdOultUuniW0MLqw5+II87Gd00RWbCGi0hk0PykHe7uK+PDA2BEbqyZ2WKKYCvfB3j+0nrFOHScXqnh0V05l2E83J4+Sgy1fsPy+1WdX58ZlNBG333ibaC1FS79XvKSmTgKRkx3+YBo97u6ZtUmJa5WZjf2OdLG3KIckGWAv6R5xgxeU31N0Ng8L332w/Edpp2O/M2bZwdnKJ8hJQikXIAQbICbr+lTDzsoNzMdEIYcHpJ5hjPbiUl3Bmd+Jnsjf5McgAZDiWIfpCKZ29tPCEkVwRsOCqkyPRMNMzHHmoja495P5jR+ODS7+J8RFg5xgcnOgpP9D4Wlhztlf5WyZMpkLxTUD+bZq2SRf50HfHFXTkfq22zPl3d1eq0yrLwh/Z/fWKkfb6SyysROL8y6s8u3dpFX1YHSg0BR6i913h4aoZw9B2BG27cafLLTwKYsp2dFo1PWl4O6u9giFJIeqwloZHLKKrwh0cBFhB7RH0I58asxkZpCH6uWjJierahmHe7iS+E6i+9oCHkOZ59hmCYNimIs3hM= +script: +- ./hack/coverage diff --git a/vendor/github.com/go-openapi/loads/fixtures/yaml/swagger/1/2/3/4/swagger.yaml b/vendor/github.com/go-openapi/loads/fixtures/yaml/swagger/1/2/3/4/swagger.yaml new file mode 100644 index 000000000000..dcaf3ff80617 --- /dev/null +++ b/vendor/github.com/go-openapi/loads/fixtures/yaml/swagger/1/2/3/4/swagger.yaml @@ -0,0 +1,42 @@ +swagger: '2.0' +info: + title: Something + contact: + name: Somebody + url: https://url.com + email: email@url.com + description: Something + version: v1 +host: security.sonusnet.com +schemes: +- https +- http +basePath: /api +produces: +- application/json +- plain/text + +paths: + /whatnot: + get: + description: Get something + responses: + 200: + description: The something + schema: + $ref: '#/definitions/Something' + 500: + description: Oops + +definitions: + Something: + description: A collection of service events + type: object + properties: + page: + $ref: '../../../../shared/definitions/page.yaml#/definitions/Page' + something: + #type: array + #description: An array of something + #items: + $ref: '../../../../shared/something.yaml#/definitions/Something' diff --git a/vendor/github.com/go-openapi/loads/fixtures/yaml/swagger/shared/definitions/page.yaml b/vendor/github.com/go-openapi/loads/fixtures/yaml/swagger/shared/definitions/page.yaml new file mode 100644 index 000000000000..29355d42d163 --- /dev/null +++ b/vendor/github.com/go-openapi/loads/fixtures/yaml/swagger/shared/definitions/page.yaml @@ -0,0 +1,18 @@ +definitions: + Page: + description: A description of a paged result + type: object + properties: + page: + type: integer + description: the page that was requested + pages: + type: integer + description: the total number of pages available + total_items: + type: integer + description: the total number of items available + format: int64 + page_items: + type: integer + description: the number of items per page requested diff --git a/vendor/github.com/go-openapi/loads/fixtures/yaml/swagger/shared/something.yaml b/vendor/github.com/go-openapi/loads/fixtures/yaml/swagger/shared/something.yaml new file mode 100644 index 000000000000..f5f2e391976c --- /dev/null +++ b/vendor/github.com/go-openapi/loads/fixtures/yaml/swagger/shared/something.yaml @@ -0,0 +1,44 @@ +swagger: '2.0' +info: + title: Something definitions + contact: + name: Somebody + url: https://url.com + email: email@url.com + description: Something + version: v1 +host: security.sonusnet.com +schemes: +- https +- http +basePath: /api/something/definitions +produces: +- application/json +- plain/text + +paths: + /shared: + get: + operationId: Get + tags: + - Shared + responses: + 200: + description: OK + schema: + properties: + name: + type: string + +definitions: + Something: + description: Something + type: object + properties: + p1: + type: string + description: A string + p2: + type: integer + description: An integer + diff --git a/vendor/github.com/go-openapi/loads/fixtures/yaml/swagger/spec.yml b/vendor/github.com/go-openapi/loads/fixtures/yaml/swagger/spec.yml new file mode 100644 index 000000000000..7e6b1331ae0c --- /dev/null +++ b/vendor/github.com/go-openapi/loads/fixtures/yaml/swagger/spec.yml @@ -0,0 +1,38 @@ +swagger: "2.0" +info: + version: 0.1.1 + title: test 1 + description: recursively following JSON references + contact: + name: Fred + +schemes: + - http + +consumes: + - application/json +produces: + - application/json + +paths: + /getAll: + get: + operationId: getAll + parameters: + - name: a + in: body + description: max number of results + required: false + schema: + $ref: '#/definitions/a' + responses: + '200': + description: Success + schema: + $ref: '#/definitions/b' + +definitions: + a: + type: string + b: + $ref: './test3-ter-model-schema.json#/definitions/b' \ No newline at end of file diff --git a/vendor/github.com/go-openapi/loads/fixtures/yaml/swagger/test3-ter-model-schema.json b/vendor/github.com/go-openapi/loads/fixtures/yaml/swagger/test3-ter-model-schema.json new file mode 100644 index 000000000000..eb446c76202a --- /dev/null +++ b/vendor/github.com/go-openapi/loads/fixtures/yaml/swagger/test3-ter-model-schema.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "./test3-model-schema.json", + "title": "test3-model-schema", + "description": "Test schema responses", + "definitions": { + "b": { + "type": "array", + "items": { + "type": "string" + } + } + } +} \ No newline at end of file diff --git a/vendor/github.com/go-openapi/loads/go.mod b/vendor/github.com/go-openapi/loads/go.mod new file mode 100644 index 000000000000..10ea8d267b77 --- /dev/null +++ b/vendor/github.com/go-openapi/loads/go.mod @@ -0,0 +1,23 @@ +module github.com/go-openapi/loads + +require ( + github.com/PuerkitoBio/purell v1.1.0 // indirect + github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect + github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb // indirect + github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277 + github.com/go-openapi/errors v0.17.0 // indirect + github.com/go-openapi/jsonpointer v0.17.0 // indirect + github.com/go-openapi/jsonreference v0.17.0 // indirect + github.com/go-openapi/spec v0.17.0 + github.com/go-openapi/strfmt v0.17.0 // indirect + github.com/go-openapi/swag v0.17.0 + github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 // indirect + github.com/mitchellh/mapstructure v1.1.2 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/testify v1.2.2 + golang.org/x/net v0.0.0-20181005035420-146acd28ed58 // indirect + golang.org/x/text v0.3.0 // indirect + gopkg.in/yaml.v2 v2.2.1 +) diff --git a/vendor/github.com/go-openapi/loads/go.sum b/vendor/github.com/go-openapi/loads/go.sum new file mode 100644 index 000000000000..ef1195399ae8 --- /dev/null +++ b/vendor/github.com/go-openapi/loads/go.sum @@ -0,0 +1,36 @@ +github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4= +github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf h1:eg0MeVzsP1G42dRafH3vf+al2vQIJU0YHX+1Tw87oco= +github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= +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/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb h1:D4uzjWwKYQ5XnAvUbuvHW93esHg7F8N/OYeBBcJoTr0= +github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277 h1:Cjl5yf/RidkszNOmV0+rf35yjOocQ1UTTVwEmxnr6Ls= +github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= +github.com/go-openapi/errors v0.17.0 h1:47T+LqPrQUxFXQnB22aLBfsTRFSqWp5y4OiFgQm+/Lw= +github.com/go-openapi/errors v0.17.0/go.mod h1:La0D2x9HoXenv7MDEiAv6vWoe84CXFo0PQRk/jdQlww= +github.com/go-openapi/jsonpointer v0.17.0 h1:Bpl2DtZ6k7wKqfFs7e+4P08+M9I3FQgn09a1UsRUQbk= +github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= +github.com/go-openapi/jsonreference v0.17.0 h1:d/o7/fsLWWQZACbihvZxcyLQ59jfUVs7WOJv/ak7T7A= +github.com/go-openapi/jsonreference v0.17.0/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= +github.com/go-openapi/spec v0.17.0 h1:MM5YaXBdBOEcjGHW5WayrAY5Ze2ydNyy71JHeTi7xUc= +github.com/go-openapi/spec v0.17.0/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= +github.com/go-openapi/strfmt v0.17.0 h1:79+bCyGHowS3rkr6z8RcG5jVzdKpeKXlDuW6yqE50TM= +github.com/go-openapi/strfmt v0.17.0/go.mod h1:/bCWipNKhC9QMhD8HRe2EGbU8G0D4Yvh0G6X4k1Xwvg= +github.com/go-openapi/swag v0.17.0 h1:7wu+dZ5k83kvUWeAb+WUkFiUhDzwGqzTR/NhWzeo1JU= +github.com/go-openapi/swag v0.17.0/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= +github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic= +github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +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= +golang.org/x/net v0.0.0-20181005035420-146acd28ed58 h1:otZG8yDCO4LVps5+9bxOeNiCvgmOyt96J3roHTYs7oE= +golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/go-openapi/loads/spec.go b/vendor/github.com/go-openapi/loads/spec.go index 6d967389b11a..649ca06e666e 100644 --- a/vendor/github.com/go-openapi/loads/spec.go +++ b/vendor/github.com/go-openapi/loads/spec.go @@ -20,8 +20,6 @@ import ( "fmt" "net/url" - "path/filepath" - "github.com/go-openapi/analysis" "github.com/go-openapi/spec" "github.com/go-openapi/swag" @@ -92,6 +90,22 @@ type Document struct { raw json.RawMessage } +// Embedded returns a Document based on embedded specs. No analysis is required +func Embedded(orig, flat json.RawMessage) (*Document, error) { + var origSpec, flatSpec spec.Swagger + if err := json.Unmarshal(orig, &origSpec); err != nil { + return nil, err + } + if err := json.Unmarshal(flat, &flatSpec); err != nil { + return nil, err + } + return &Document{ + raw: orig, + origSpec: &origSpec, + spec: &flatSpec, + }, nil +} + // Spec loads a new spec document func Spec(path string) (*Document, error) { specURL, err := url.Parse(path) @@ -186,10 +200,10 @@ func (d *Document) Expanded(options ...*spec.ExpandOptions) (*Document, error) { var expandOptions *spec.ExpandOptions if len(options) > 0 { - expandOptions = options[1] + expandOptions = options[0] } else { expandOptions = &spec.ExpandOptions{ - RelativeBase: filepath.Dir(d.specFilePath), + RelativeBase: d.specFilePath, } } @@ -198,11 +212,12 @@ func (d *Document) Expanded(options ...*spec.ExpandOptions) (*Document, error) { } dd := &Document{ - Analyzer: analysis.New(swspec), - spec: swspec, - schema: spec.MustLoadSwagger20Schema(), - raw: d.raw, - origSpec: d.origSpec, + Analyzer: analysis.New(swspec), + spec: swspec, + specFilePath: d.specFilePath, + schema: spec.MustLoadSwagger20Schema(), + raw: d.raw, + origSpec: d.origSpec, } return dd, nil } diff --git a/vendor/github.com/go-openapi/loads/spec_test.go b/vendor/github.com/go-openapi/loads/spec_test.go index 5c5e7ca4e22c..a07694d33fbf 100644 --- a/vendor/github.com/go-openapi/loads/spec_test.go +++ b/vendor/github.com/go-openapi/loads/spec_test.go @@ -32,6 +32,31 @@ func TestLoadsYAMLContent(t *testing.T) { } } +// for issue 11 +func TestRegressionExpand(t *testing.T) { + swaggerFile := "fixtures/yaml/swagger/1/2/3/4/swagger.yaml" + document, err := Spec(swaggerFile) + assert.NoError(t, err) + assert.NotNil(t, document) + d, err := document.Expanded() + assert.NoError(t, err) + assert.NotNil(t, d) + b, _ := d.Spec().MarshalJSON() + assert.JSONEq(t, expectedExpanded, string(b)) +} + +func TestCascadingRefExpand(t *testing.T) { + swaggerFile := "fixtures/yaml/swagger/spec.yml" + document, err := Spec(swaggerFile) + assert.NoError(t, err) + assert.NotNil(t, document) + d, err := document.Expanded() + assert.NoError(t, err) + assert.NotNil(t, d) + b, _ := d.Spec().MarshalJSON() + assert.JSONEq(t, cascadeRefExpanded, string(b)) +} + func TestFailsInvalidJSON(t *testing.T) { _, err := Analyzed(json.RawMessage([]byte("{]")), "") @@ -499,3 +524,194 @@ const PetStore20 = `{ } } ` + +const expectedExpanded = ` +{ + "produces":[ + "application/json", + "plain/text" + ], + "schemes":[ + "https", + "http" + ], + "swagger":"2.0", + "info":{ + "description":"Something", + "title":"Something", + "contact":{ + "name":"Somebody", + "url":"https://url.com", + "email":"email@url.com" + }, + "version":"v1" + }, + "host":"security.sonusnet.com", + "basePath":"/api", + "paths":{ + "/whatnot":{ + "get":{ + "description":"Get something", + "responses":{ + "200":{ + "description":"The something", + "schema":{ + "description":"A collection of service events", + "type":"object", + "properties":{ + "page":{ + "description":"A description of a paged result", + "type":"object", + "properties":{ + "page":{ + "description":"the page that was requested", + "type":"integer" + }, + "page_items":{ + "description":"the number of items per page requested", + "type":"integer" + }, + "pages":{ + "description":"the total number of pages available", + "type":"integer" + }, + "total_items":{ + "description":"the total number of items available", + "type":"integer", + "format":"int64" + } + } + }, + "something":{ + "description":"Something", + "type":"object", + "properties":{ + "p1":{ + "description":"A string", + "type":"string" + }, + "p2":{ + "description":"An integer", + "type":"integer" + } + } + } + } + } + }, + "500":{ + "description":"Oops" + } + } + } + } + }, + "definitions":{ + "Something":{ + "description":"A collection of service events", + "type":"object", + "properties":{ + "page":{ + "description":"A description of a paged result", + "type":"object", + "properties":{ + "page":{ + "description":"the page that was requested", + "type":"integer" + }, + "page_items":{ + "description":"the number of items per page requested", + "type":"integer" + }, + "pages":{ + "description":"the total number of pages available", + "type":"integer" + }, + "total_items":{ + "description":"the total number of items available", + "type":"integer", + "format":"int64" + } + } + }, + "something":{ + "description":"Something", + "type":"object", + "properties":{ + "p1":{ + "description":"A string", + "type":"string" + }, + "p2":{ + "description":"An integer", + "type":"integer" + } + } + } + } + } + } +} +` + +const cascadeRefExpanded = ` +{ + "swagger": "2.0", + "consumes":[ + "application/json" + ], + "produces":[ + "application/json" + ], + "schemes":[ + "http" + ], + "info":{ + "description":"recursively following JSON references", + "title":"test 1", + "contact":{ + "name":"Fred" + }, + "version":"0.1.1" + }, + "paths":{ + "/getAll":{ + "get":{ + "operationId":"getAll", + "parameters":[ + { + "description":"max number of results", + "name":"a", + "in":"body", + "schema":{ + "type":"string" + } + } + ], + "responses":{ + "200":{ + "description":"Success", + "schema":{ + "type":"array", + "items":{ + "type":"string" + } + } + } + } + } + } + }, + "definitions":{ + "a":{ + "type":"string" + }, + "b":{ + "type":"array", + "items":{ + "type":"string" + } + } + } +} +` diff --git a/vendor/github.com/gonum/blas/README.md b/vendor/github.com/gonum/blas/README.md index 34ef3c53da3a..86e8971d75cc 100644 --- a/vendor/github.com/gonum/blas/README.md +++ b/vendor/github.com/gonum/blas/README.md @@ -88,9 +88,9 @@ Currently blas/cblas64 and blas/cblas128 require blas/cgo. ## Issues -If you find any bugs, feel free to file an issue on the github issue tracker. -Discussions on API changes, added features, code review, or similar requests -are preferred on the [gonum-dev Google Group](https://groups.google.com/forum/#!forum/gonum-dev). +If you find any bugs, feel free to file an issue on the github [issue tracker for gonum/gonum](https://github.com/gonum/gonum/issues) or [gonum/netlib for the CGO implementation](https://github.com/gonum/netlib/issues) if the bug exists in that reposity; no code changes will be made to this repository. Other discussions should be taken to the gonum-dev Google Group. + +https://groups.google.com/forum/#!forum/gonum-dev ## License diff --git a/vendor/github.com/gonum/blas/blas.go b/vendor/github.com/gonum/blas/blas.go index 6c14aac42e87..0ea4960da804 100644 --- a/vendor/github.com/gonum/blas/blas.go +++ b/vendor/github.com/gonum/blas/blas.go @@ -3,6 +3,9 @@ // license that can be found in the LICENSE file. /* +This repository is no longer maintained. +Development has moved to https://github.com/gonum/gonum. + Package blas provides interfaces for the BLAS linear algebra standard. All methods must perform appropriate parameter checking and panic if diff --git a/vendor/github.com/gonum/blas/blas32/blas32.go b/vendor/github.com/gonum/blas/blas32/blas32.go index 82971ea13436..746a2fa8fc02 100644 --- a/vendor/github.com/gonum/blas/blas32/blas32.go +++ b/vendor/github.com/gonum/blas/blas32/blas32.go @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package blas32 provides a simple interface to the float32 BLAS API. package blas32 diff --git a/vendor/github.com/gonum/blas/blas64/blas64.go b/vendor/github.com/gonum/blas/blas64/blas64.go index 088c30e97d0f..40841f5eca05 100644 --- a/vendor/github.com/gonum/blas/blas64/blas64.go +++ b/vendor/github.com/gonum/blas/blas64/blas64.go @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package blas64 provides a simple interface to the float64 BLAS API. package blas64 diff --git a/vendor/github.com/gonum/blas/cblas128/cblas128.go b/vendor/github.com/gonum/blas/cblas128/cblas128.go index 60be9dd76c21..ca5d4cbbb19a 100644 --- a/vendor/github.com/gonum/blas/cblas128/cblas128.go +++ b/vendor/github.com/gonum/blas/cblas128/cblas128.go @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package cblas128 provides a simple interface to the complex128 BLAS API. package cblas128 diff --git a/vendor/github.com/gonum/blas/cblas64/cblas64.go b/vendor/github.com/gonum/blas/cblas64/cblas64.go index 08c7738c1670..695a0ddc39cc 100644 --- a/vendor/github.com/gonum/blas/cblas64/cblas64.go +++ b/vendor/github.com/gonum/blas/cblas64/cblas64.go @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package cblas64 provides a simple interface to the complex64 BLAS API. package cblas64 diff --git a/vendor/github.com/gonum/blas/cgo/doc.go b/vendor/github.com/gonum/blas/cgo/doc.go index 4e3efcf24006..1cfb30d2ef5f 100644 --- a/vendor/github.com/gonum/blas/cgo/doc.go +++ b/vendor/github.com/gonum/blas/cgo/doc.go @@ -7,6 +7,9 @@ // Ensure changes made to blas/cgo are reflected in blas/native where relevant. /* +This repository is no longer maintained. +Development has moved to https://github.com/gonum/gonum. + Package cgo provides bindings to a C BLAS library. This wrapper interface panics when the input arguments are invalid as per the standard, for example if a vector increment is zero. Please note that the treatment of NaN values diff --git a/vendor/github.com/gonum/blas/native/doc.go b/vendor/github.com/gonum/blas/native/doc.go index cb63fe776e27..a4f971b5f938 100644 --- a/vendor/github.com/gonum/blas/native/doc.go +++ b/vendor/github.com/gonum/blas/native/doc.go @@ -5,6 +5,9 @@ // Ensure changes made to blas/native are reflected in blas/cgo where relevant. /* +This repository is no longer maintained. +Development has moved to https://github.com/gonum/gonum. + Package native is a Go implementation of the BLAS API. This implementation panics when the input arguments are invalid as per the standard, for example if a vector increment is zero. Please note that the treatment of NaN values diff --git a/vendor/github.com/gonum/blas/native/internal/math32/math.go b/vendor/github.com/gonum/blas/native/internal/math32/math.go index b33401b98268..09c38d72f717 100644 --- a/vendor/github.com/gonum/blas/native/internal/math32/math.go +++ b/vendor/github.com/gonum/blas/native/internal/math32/math.go @@ -6,6 +6,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package math32 provides float32 versions of standard library math package // routines used by gonum/blas/native. package math32 diff --git a/vendor/github.com/gonum/blas/testblas/level1double.go b/vendor/github.com/gonum/blas/testblas/level1double.go index 9e16059108c1..b13d2dfc4c27 100644 --- a/vendor/github.com/gonum/blas/testblas/level1double.go +++ b/vendor/github.com/gonum/blas/testblas/level1double.go @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package testblas provides tests for blas implementations. package testblas diff --git a/vendor/github.com/gonum/floats/README.md b/vendor/github.com/gonum/floats/README.md index c7a8eb28ad29..a01a4b15ff26 100644 --- a/vendor/github.com/gonum/floats/README.md +++ b/vendor/github.com/gonum/floats/README.md @@ -6,7 +6,7 @@ package floats provides a set of helper routines for dealing with slices of floa ## Issues -If you find any bugs, feel free to file an issue on the github issue tracker. Discussions on API changes, added features, code review, or similar requests are preferred on the gonum-dev Google Group. +If you find any bugs, feel free to file an issue on the github [issue tracker for gonum/gonum](https://github.com/gonum/gonum/issues) if the bug exists in that reposity; no code changes will be made to this repository. Other discussions should be taken to the gonum-dev Google Group. https://groups.google.com/forum/#!forum/gonum-dev diff --git a/vendor/github.com/gonum/floats/floats.go b/vendor/github.com/gonum/floats/floats.go index e1807d2a1bd7..601eb42b6eb3 100644 --- a/vendor/github.com/gonum/floats/floats.go +++ b/vendor/github.com/gonum/floats/floats.go @@ -2,6 +2,9 @@ // Use of this code is governed by a BSD-style // license that can be found in the LICENSE file +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package floats provides a set of helper routines for dealing with slices // of float64. The functions avoid allocations to allow for use within tight // loops without garbage collection overhead. diff --git a/vendor/github.com/gonum/internal/README.md b/vendor/github.com/gonum/internal/README.md index 84ec056b26ce..c89e61207731 100644 --- a/vendor/github.com/gonum/internal/README.md +++ b/vendor/github.com/gonum/internal/README.md @@ -6,7 +6,7 @@ This is the set of internal packages for the Gonum project. ## Issues -If you find any bugs, feel free to file an issue on the github issue tracker. Discussions on API changes, added features, code review, or similar requests are preferred on the gonum-dev Google Group. +If you find any bugs, feel free to file an issue on the github [issue tracker for gonum/gonum](https://github.com/gonum/gonum/issues) if the bug exists in that reposity; no code changes will be made to this repository. Other dicussions should be taken to the gonum-dev Google Group. https://groups.google.com/forum/#!forum/gonum-dev diff --git a/vendor/github.com/gonum/internal/asm/c128/doc.go b/vendor/github.com/gonum/internal/asm/c128/doc.go index 1a03f2b85e18..4987830a3253 100644 --- a/vendor/github.com/gonum/internal/asm/c128/doc.go +++ b/vendor/github.com/gonum/internal/asm/c128/doc.go @@ -2,5 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package c128 provides complex128 vector primitives. package c128 diff --git a/vendor/github.com/gonum/internal/asm/c64/doc.go b/vendor/github.com/gonum/internal/asm/c64/doc.go index 9e524a89b9f4..47f5c7a6f8b5 100644 --- a/vendor/github.com/gonum/internal/asm/c64/doc.go +++ b/vendor/github.com/gonum/internal/asm/c64/doc.go @@ -2,5 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package c64 provides complex64 vector primitives. package c64 diff --git a/vendor/github.com/gonum/internal/asm/f32/doc.go b/vendor/github.com/gonum/internal/asm/f32/doc.go index e7e1d9f89eb1..142f7dc65c28 100644 --- a/vendor/github.com/gonum/internal/asm/f32/doc.go +++ b/vendor/github.com/gonum/internal/asm/f32/doc.go @@ -2,5 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package f32 provides float32 vector primitives. package f32 diff --git a/vendor/github.com/gonum/internal/asm/f64/doc.go b/vendor/github.com/gonum/internal/asm/f64/doc.go index 7f1cc87c10a5..5a006cf5cff1 100644 --- a/vendor/github.com/gonum/internal/asm/f64/doc.go +++ b/vendor/github.com/gonum/internal/asm/f64/doc.go @@ -2,5 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package f64 provides float64 vector primitives. package f64 diff --git a/vendor/github.com/gonum/internal/binding/binding.go b/vendor/github.com/gonum/internal/binding/binding.go index 1b02a4bb3a9c..3b573948c5c8 100644 --- a/vendor/github.com/gonum/internal/binding/binding.go +++ b/vendor/github.com/gonum/internal/binding/binding.go @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package binding provides helpers for building autogenerated cgo bindings. package binding diff --git a/vendor/github.com/gonum/lapack/README.md b/vendor/github.com/gonum/lapack/README.md index ffc082412add..df63c74f73f4 100644 --- a/vendor/github.com/gonum/lapack/README.md +++ b/vendor/github.com/gonum/lapack/README.md @@ -51,7 +51,7 @@ The recommended (free) option for good performance on both linux and darwin is O ## Issues -If you find any bugs, feel free to file an issue on the github issue tracker. Discussions on API changes, added features, code review, or similar requests are preferred on the gonum-dev Google Group. +If you find any bugs, feel free to file an issue on the github [issue tracker for gonum/gonum](https://github.com/gonum/gonum/issues) or [gonum/netlib for the CGO implementation](https://github.com/gonum/netlib/issues) if the bug exists in that reposity; no code changes will be made to this repository. Other discussions should be taken to the gonum-dev Google Group. https://groups.google.com/forum/#!forum/gonum-dev diff --git a/vendor/github.com/gonum/lapack/cgo/lapack.go b/vendor/github.com/gonum/lapack/cgo/lapack.go index e99455bc60f7..f9f437aabacd 100644 --- a/vendor/github.com/gonum/lapack/cgo/lapack.go +++ b/vendor/github.com/gonum/lapack/cgo/lapack.go @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/netlib. +// // Package cgo provides an interface to bindings for a C LAPACK library. package cgo diff --git a/vendor/github.com/gonum/lapack/cgo/lapacke/generate_lapacke.go b/vendor/github.com/gonum/lapack/cgo/lapacke/generate_lapacke.go index 9d82f86a4d6b..7c99e90e3ab2 100644 --- a/vendor/github.com/gonum/lapack/cgo/lapacke/generate_lapacke.go +++ b/vendor/github.com/gonum/lapack/cgo/lapacke/generate_lapacke.go @@ -519,6 +519,9 @@ const handwritten = `// Code generated by "go generate github.com/gonum/lapack/c // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/netlib. +// // Package lapacke provides bindings to the LAPACKE C Interface to LAPACK. // // Links are provided to the NETLIB fortran implementation/dependencies for each function. diff --git a/vendor/github.com/gonum/lapack/cgo/lapacke/lapacke.go b/vendor/github.com/gonum/lapack/cgo/lapacke/lapacke.go index 31d6669d3347..dd40ab01f80f 100644 --- a/vendor/github.com/gonum/lapack/cgo/lapacke/lapacke.go +++ b/vendor/github.com/gonum/lapack/cgo/lapacke/lapacke.go @@ -4,6 +4,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/netlib. +// // Package lapacke provides bindings to the LAPACKE C Interface to LAPACK. // // Links are provided to the NETLIB fortran implementation/dependencies for each function. diff --git a/vendor/github.com/gonum/lapack/lapack.go b/vendor/github.com/gonum/lapack/lapack.go index 46b493df9e6d..7eb392271c03 100644 --- a/vendor/github.com/gonum/lapack/lapack.go +++ b/vendor/github.com/gonum/lapack/lapack.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. package lapack import "github.com/gonum/blas" diff --git a/vendor/github.com/gonum/lapack/lapack64/lapack64.go b/vendor/github.com/gonum/lapack/lapack64/lapack64.go index 619734fb1eb1..323ec94641af 100644 --- a/vendor/github.com/gonum/lapack/lapack64/lapack64.go +++ b/vendor/github.com/gonum/lapack/lapack64/lapack64.go @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package lapack64 provides a set of convenient wrapper functions for LAPACK // calls, as specified in the netlib standard (www.netlib.org). // diff --git a/vendor/github.com/gonum/lapack/native/doc.go b/vendor/github.com/gonum/lapack/native/doc.go index d622dc504a9b..6f28770b0632 100644 --- a/vendor/github.com/gonum/lapack/native/doc.go +++ b/vendor/github.com/gonum/lapack/native/doc.go @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package native is a pure-go implementation of the LAPACK API. The LAPACK API defines // a set of algorithms for advanced matrix operations. // diff --git a/vendor/github.com/gonum/lapack/testlapack/general.go b/vendor/github.com/gonum/lapack/testlapack/general.go index e9bf80b5a227..bcc0dca996f6 100644 --- a/vendor/github.com/gonum/lapack/testlapack/general.go +++ b/vendor/github.com/gonum/lapack/testlapack/general.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. package testlapack import ( diff --git a/vendor/github.com/gonum/matrix/README.md b/vendor/github.com/gonum/matrix/README.md index 980b7498b107..0c4b0c6425dd 100644 --- a/vendor/github.com/gonum/matrix/README.md +++ b/vendor/github.com/gonum/matrix/README.md @@ -6,10 +6,10 @@ This is a matrix package for the Go language. ## Issues -If you find any bugs, feel free to file an issue on the github issue tracker. Discussions on API changes, added features, code review, or similar requests are preferred on the gonum-dev Google Group. +If you find any bugs, feel free to file an issue on the github [issue tracker for gonum/gonum](https://github.com/gonum/gonum/issues) if the bug exists in that reposity; no code changes will be made to this repository. Other discussions should be taken to the gonum-dev Google Group. https://groups.google.com/forum/#!forum/gonum-dev ## License -Please see github.com/gonum/license for general license information, contributors, authors, etc on the Gonum suite of packages. +Please see github.com/gonum/gonum for general license information, contributors, authors, etc on the Gonum suite of packages. diff --git a/vendor/github.com/gonum/matrix/cmat128/doc.go b/vendor/github.com/gonum/matrix/cmat128/doc.go index c47b8ffd19c8..d14bfc03556f 100644 --- a/vendor/github.com/gonum/matrix/cmat128/doc.go +++ b/vendor/github.com/gonum/matrix/cmat128/doc.go @@ -6,6 +6,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package cmat128 provides implementations of complex128 matrix structures and // linear algebra operations on them. // diff --git a/vendor/github.com/gonum/matrix/conv/conv.go b/vendor/github.com/gonum/matrix/conv/conv.go index f3c85bf26c50..d7d9eb31b1f0 100644 --- a/vendor/github.com/gonum/matrix/conv/conv.go +++ b/vendor/github.com/gonum/matrix/conv/conv.go @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package conv provides matrix type interconversion utilities. package conv diff --git a/vendor/github.com/gonum/matrix/doc.go b/vendor/github.com/gonum/matrix/doc.go index c94f8df1e49f..65c296509869 100644 --- a/vendor/github.com/gonum/matrix/doc.go +++ b/vendor/github.com/gonum/matrix/doc.go @@ -6,6 +6,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package matrix provides common error handling mechanisms for matrix operations // in mat64 and cmat128. // diff --git a/vendor/github.com/gonum/matrix/gendoc.go b/vendor/github.com/gonum/matrix/gendoc.go index f82b6b20c10d..b0cd2dde8ed8 100644 --- a/vendor/github.com/gonum/matrix/gendoc.go +++ b/vendor/github.com/gonum/matrix/gendoc.go @@ -25,6 +25,9 @@ var docs = template.Must(template.New("docs").Funcs(funcs).Parse(`{{define "comm // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package {{.Name}} provides {{.Provides}} // // Overview diff --git a/vendor/github.com/gonum/matrix/mat64/doc.go b/vendor/github.com/gonum/matrix/mat64/doc.go index 61335708a980..323a8542c72c 100644 --- a/vendor/github.com/gonum/matrix/mat64/doc.go +++ b/vendor/github.com/gonum/matrix/mat64/doc.go @@ -6,6 +6,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// This repository is no longer maintained. +// Development has moved to https://github.com/gonum/gonum. +// // Package mat64 provides implementations of float64 matrix structures and // linear algebra operations on them. // diff --git a/vendor/github.com/lestrrat-go/jspointer/.gitignore b/vendor/github.com/lestrrat-go/jspointer/.gitignore new file mode 100644 index 000000000000..daf913b1b347 --- /dev/null +++ b/vendor/github.com/lestrrat-go/jspointer/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/vendor/github.com/lestrrat-go/jspointer/.travis.yml b/vendor/github.com/lestrrat-go/jspointer/.travis.yml new file mode 100644 index 000000000000..21e0a8e8d7c0 --- /dev/null +++ b/vendor/github.com/lestrrat-go/jspointer/.travis.yml @@ -0,0 +1,5 @@ +language: go +sudo: false +go: + - 1.11 + - tip diff --git a/vendor/github.com/lestrrat-go/jspointer/LICENSE b/vendor/github.com/lestrrat-go/jspointer/LICENSE new file mode 100644 index 000000000000..20054b15434d --- /dev/null +++ b/vendor/github.com/lestrrat-go/jspointer/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 lestrrat + +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/lestrrat-go/jspointer/README.md b/vendor/github.com/lestrrat-go/jspointer/README.md new file mode 100644 index 000000000000..e1a4fbcd01b0 --- /dev/null +++ b/vendor/github.com/lestrrat-go/jspointer/README.md @@ -0,0 +1,34 @@ +# go-jspointer + +[![Build Status](https://travis-ci.org/lestrrat-go/jspointer.svg?branch=master)](https://travis-ci.org/lestrrat-go/jspointer) + +[![GoDoc](https://godoc.org/github.com/lestrrat-go/jspointer?status.svg)](https://godoc.org/github.com/lestrrat-go/jspointer) + +JSON pointer for Go + +# Features + +* Compile and match against Maps, Slices, Structs (or pointers to those) +* Set values in each of those + +# Usage + +```go +p, _ := jspointer.New(`/foo/bar/baz`) +result, _ := p.Get(someStruct) +``` + +# Credits + +This is almost a fork of https://github.com/xeipuuv/gojsonpointer. + +# References + +| Name | Notes | +|:--------------------------------------------------------:|:---------------------------------| +| [go-jsval](https://github.com/lestrrat-go/jsval) | Validator generator | +| [go-jsschema](https://github.com/lestrrat-go/jsschema) | JSON Schema implementation | +| [go-jshschema](https://github.com/lestrrat-go/jshschema) | JSON Hyper Schema implementation | +| [go-jsref](https://github.com/lestrrat-go/jsref) | JSON Reference implementation | + + diff --git a/vendor/github.com/lestrrat-go/jspointer/bench/bench_test.go b/vendor/github.com/lestrrat-go/jspointer/bench/bench_test.go new file mode 100644 index 000000000000..3ffe29fb4ded --- /dev/null +++ b/vendor/github.com/lestrrat-go/jspointer/bench/bench_test.go @@ -0,0 +1,40 @@ +// +build bench + +package bench_test + +import ( + "encoding/json" + "testing" + + "github.com/lestrrat-go/jspointer" + "github.com/xeipuuv/gojsonpointer" +) + +const jsontxt = `{"a":[{"b": 1, "c": 2}], "d": 3}` + +var m map[string]interface{} + +func init() { + if err := json.Unmarshal([]byte(jsontxt), &m); err != nil { + panic(err) + } +} + +func BenchmarkGojsonpointer(b *testing.B) { + p, _ := gojsonpointer.NewJsonPointer(`/a/0/c`) + for i := 0; i < b.N; i++ { + res, kind, err := p.Get(m) + _ = res + _ = kind + _ = err + } +} + +func BenchmarkJspointer(b *testing.B) { + p, _ := jspointer.New(`/a/0/c`) + for i := 0; i < b.N; i++ { + res, err := p.Get(m) + _ = res + _ = err + } +} \ No newline at end of file diff --git a/vendor/github.com/lestrrat-go/jspointer/interface.go b/vendor/github.com/lestrrat-go/jspointer/interface.go new file mode 100644 index 000000000000..7fe800233bb2 --- /dev/null +++ b/vendor/github.com/lestrrat-go/jspointer/interface.go @@ -0,0 +1,27 @@ +package jspointer + +import "errors" + +// Errors used in jspointer package +var ( + ErrInvalidPointer = errors.New("invalid pointer") + ErrCanNotSet = errors.New("field cannot be set to") + ErrSliceIndexOutOfBounds = errors.New("slice index out of bounds") +) + +// Consntants used in jspointer package. Mostly for internal usage only +const ( + EncodedTilde = "~0" + EncodedSlash = "~1" + Separator = '/' +) + +type ErrNotFound struct { + Ptr string +} + +// JSPointer represents a JSON pointer +type JSPointer struct { + raw string + tokens tokens +} diff --git a/vendor/github.com/lestrrat-go/jspointer/jspointer.go b/vendor/github.com/lestrrat-go/jspointer/jspointer.go new file mode 100644 index 000000000000..c42b9613f9a3 --- /dev/null +++ b/vendor/github.com/lestrrat-go/jspointer/jspointer.go @@ -0,0 +1,262 @@ +package jspointer + +import ( + "bytes" + "encoding/json" + "errors" + "reflect" + "strconv" + + "github.com/lestrrat-go/structinfo" +) + +type tokens struct { + s string + positions [][2]int +} + +func (t *tokens) size() int { + return len(t.positions) +} + +func (t *tokens) get(i int) string { + p := t.positions[i] + return t.s[p[0]:p[1]] +} + +// New creates a new JSON pointer for given path spec. If the path fails +// to be parsed, an error is returned +func New(path string) (*JSPointer, error) { + var p JSPointer + + if err := p.parse(path); err != nil { + return nil, err + } + p.raw = path + return &p, nil +} + +func (p *JSPointer) parse(s string) error { + if s == "" { + return nil + } + + if s[0] != Separator { + return ErrInvalidPointer + } + + if len(s) < 2 { + return ErrInvalidPointer + } + + ntokens := 0 + for i := 0; i < len(s); i++ { + if s[i] == '/' { + ntokens++ + } + } + + positions := make([][2]int, 0, ntokens) + start := 1 + var buf bytes.Buffer + buf.WriteByte(s[0]) + for i := 1; i < len(s); i++ { + switch s[i] { + case Separator: + buf.WriteByte(s[i]) + positions = append(positions, [2]int{start, buf.Len() - 1}) + start = i + 1 + case '~': + if len(s) == 1 { + buf.WriteByte(s[i]) + } else { + switch s[1] { + case '0': + buf.WriteByte('~') + case '1': + buf.WriteByte('/') + default: + buf.WriteByte(s[i]) + } + } + default: + buf.WriteByte(s[i]) + } + } + + if start < buf.Len() { + positions = append(positions, [2]int{start, buf.Len()}) + } + + p.tokens.s = buf.String() + p.tokens.positions = positions + return nil +} + +// String returns the stringified version of this JSON pointer +func (p JSPointer) String() string { + return p.raw +} + +// Get applies the JSON pointer to the given item, and returns +// the result. +func (p JSPointer) Get(item interface{}) (interface{}, error) { + var ctx matchCtx + + ctx.raw = p.raw + ctx.tokens = &p.tokens + ctx.apply(item) + return ctx.result, ctx.err +} + +// Set applies the JSON pointer to the given item, and sets the +// value accordingly. +func (p JSPointer) Set(item interface{}, value interface{}) error { + var ctx matchCtx + + ctx.set = true + ctx.raw = p.raw + ctx.tokens = &p.tokens + ctx.setvalue = value + ctx.apply(item) + return ctx.err +} + +type matchCtx struct { + err error + raw string + result interface{} + set bool + setvalue interface{} + tokens *tokens +} + +func (e ErrNotFound) Error() string { + return "match to JSON pointer not found: " + e.Ptr +} + +type JSONGetter interface { + JSONGet(tok string) (interface{}, error) +} + +var strType = reflect.TypeOf("") +var zeroval reflect.Value + +func (c *matchCtx) apply(item interface{}) { + if c.tokens.size() == 0 { + c.result = item + return + } + + node := item + lastidx := c.tokens.size() - 1 + for i := 0; i < c.tokens.size(); i++ { + token := c.tokens.get(i) + + if getter, ok := node.(JSONGetter); ok { + x, err := getter.JSONGet(token) + if err != nil { + c.err = ErrNotFound{Ptr: c.raw} + return + } + if i == lastidx { + c.result = x + return + } + node = x + continue + } + v := reflect.ValueOf(node) + + // Does this thing implement a JSONGet? + + if v.Kind() == reflect.Ptr { + v = v.Elem() + } + + switch v.Kind() { + case reflect.Struct: + fn := structinfo.StructFieldFromJSONName(v, token) + if fn == "" { + c.err = ErrNotFound{Ptr: c.raw} + return + } + f := v.FieldByName(fn) + if i == lastidx { + if c.set { + if !f.CanSet() { + c.err = ErrCanNotSet + return + } + f.Set(reflect.ValueOf(c.setvalue)) + return + } + c.result = f.Interface() + return + } + node = f.Interface() + case reflect.Map: + var vt reflect.Value + // We shall try to inflate the token to its Go native + // type if it's not a string. In other words, try not to + // outdo yourselves. + if t := v.Type().Key(); t != strType { + vt = reflect.New(t).Elem() + if err := json.Unmarshal([]byte(token), vt.Addr().Interface()); err != nil { + name := t.PkgPath() + "." + t.Name() + if name == "" { + name = "(anonymous type)" + } + c.err = errors.New("unsupported conversion of string to " + name) + return + } + } else { + vt = reflect.ValueOf(token) + } + n := v.MapIndex(vt) + if zeroval == n { + c.err = ErrNotFound{Ptr: c.raw} + return + } + + if i == lastidx { + if c.set { + v.SetMapIndex(vt, reflect.ValueOf(c.setvalue)) + } else { + c.result = n.Interface() + } + return + } + + node = n.Interface() + case reflect.Slice: + m := node.([]interface{}) + wantidx, err := strconv.Atoi(token) + if err != nil { + c.err = err + return + } + + if wantidx < 0 || len(m) <= wantidx { + c.err = ErrSliceIndexOutOfBounds + return + } + + if i == lastidx { + if c.set { + m[wantidx] = c.setvalue + } else { + c.result = m[wantidx] + } + return + } + node = m[wantidx] + default: + c.err = ErrNotFound{Ptr: c.raw} + return + } + } + + // If you fell through here, there was a big problem + c.err = ErrNotFound{Ptr: c.raw} +} diff --git a/vendor/github.com/lestrrat-go/jspointer/jspointer_test.go b/vendor/github.com/lestrrat-go/jspointer/jspointer_test.go new file mode 100644 index 000000000000..50ba8e610d29 --- /dev/null +++ b/vendor/github.com/lestrrat-go/jspointer/jspointer_test.go @@ -0,0 +1,168 @@ +package jspointer_test + +import ( + "encoding/json" + "testing" + + "github.com/lestrrat-go/jspointer" + "github.com/stretchr/testify/assert" +) + +var src = `{ +"foo": ["bar", "baz"], +"obj": { "a":1, "b":2, "c":[3,4], "d":[ {"e":9}, {"f":[50,51]} ] }, +"": 0, +"a/b": 1, +"c%d": 2, +"e^f": 3, +"g|h": 4, +"i\\j": 5, +"k\"l": 6, +" ": 7, +"m~n": 8 +}` +var target map[string]interface{} + +func init() { + if err := json.Unmarshal([]byte(src), &target); err != nil { + panic(err) + } +} + +func TestEscaping(t *testing.T) { + data := []string{ + `/a~1b`, + `/m~0n`, + `/a~1b/m~0n`, + } + for _, pat := range data { + p, err := jspointer.New(pat) + if !assert.NoError(t, err, "jspointer.New should succeed for '%s'", pat) { + return + } + + if !assert.Equal(t, pat, p.String(), "input pattern and generated expression should match") { + return + } + } +} + +func runmatch(t *testing.T, pat string, m interface{}) (interface{}, error) { + p, err := jspointer.New(pat) + if !assert.NoError(t, err, "jspointer.New should succeed for '%s'", pat) { + return nil, err + } + + return p.Get(m) +} + +func TestFullDocument(t *testing.T) { + res, err := runmatch(t, ``, target) + if !assert.NoError(t, err, "jsonpointer.Get should succeed") { + return + } + if !assert.Equal(t, res, target, "res should be equal to target") { + return + } +} + +func TestGetObject(t *testing.T) { + pats := map[string]interface{}{ + `/obj/a`: float64(1), + `/obj/b`: float64(2), + `/obj/c/0`: float64(3), + `/obj/c/1`: float64(4), + `/obj/d/1/f/0`: float64(50), + } + for pat, expected := range pats { + res, err := runmatch(t, pat, target) + if !assert.NoError(t, err, "jsonpointer.Get should succeed") { + return + } + + if !assert.Equal(t, res, expected, "res should be equal to expected") { + return + } + } +} + +func TestGetArray(t *testing.T) { + foo := target["foo"].([]interface{}) + pats := map[string]interface{}{ + `/foo/0`: foo[0], + `/foo/1`: foo[1], + } + for pat, expected := range pats { + res, err := runmatch(t, pat, target) + if !assert.NoError(t, err, "jsonpointer.Get should succeed") { + return + } + + if !assert.Equal(t, res, expected, "res should be equal to expected") { + return + } + } +} + +func TestSet(t *testing.T) { + var m interface{} + json.Unmarshal([]byte(`{ +"a": [{"b": 1, "c": 2}], "d": 3 +}`), &m) + + p, err := jspointer.New(`/a/0/c`) + if !assert.NoError(t, err, "jspointer.New should succeed") { + return + } + + if !assert.NoError(t, p.Set(m, 999), "jspointer.Set should succeed") { + return + } + + res, err := runmatch(t, `/a/0/c`, m) + if !assert.NoError(t, err, "jsonpointer.Get should succeed") { + return + } + + if !assert.Equal(t, res, 999, "res should be equal to expected") { + return + } +} + +func TestStruct(t *testing.T) { + var s struct { + Foo string `json:"foo"` + Bar map[string]interface{} `json:"bar"` + Baz map[int]int `json:"baz"` + quux int + } + + s.Foo = "foooooo" + s.Bar = map[string]interface{}{ + "a": 0, + "b": 1, + } + s.Baz = map[int]int{ + 2: 3, + } + + res, err := runmatch(t, `/bar/b`, s) + if !assert.NoError(t, err, "jsonpointer.Get should succeed") { + return + } + + if !assert.Equal(t, res, 1, "res should be equal to expected value") { + return + } + + res, err = runmatch(t, `/baz/2`, s) + if !assert.NoError(t, err, "jsonpointer.Get should succeed") { + return + } + + if !assert.Equal(t, res, 3, "res should be equal to expected value") { + return + } +} + + diff --git a/vendor/github.com/lestrrat-go/jsref/.gitignore b/vendor/github.com/lestrrat-go/jsref/.gitignore new file mode 100644 index 000000000000..daf913b1b347 --- /dev/null +++ b/vendor/github.com/lestrrat-go/jsref/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/vendor/github.com/lestrrat-go/jsref/.travis.yml b/vendor/github.com/lestrrat-go/jsref/.travis.yml new file mode 100644 index 000000000000..2fbcb829a8e6 --- /dev/null +++ b/vendor/github.com/lestrrat-go/jsref/.travis.yml @@ -0,0 +1,5 @@ +language: go +sudo: false +go: + - 1.11.x + - tip diff --git a/vendor/github.com/lestrrat-go/jsref/LICENSE b/vendor/github.com/lestrrat-go/jsref/LICENSE new file mode 100644 index 000000000000..20054b15434d --- /dev/null +++ b/vendor/github.com/lestrrat-go/jsref/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 lestrrat + +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/lestrrat-go/jsref/README.md b/vendor/github.com/lestrrat-go/jsref/README.md new file mode 100644 index 000000000000..16a88c1aafa8 --- /dev/null +++ b/vendor/github.com/lestrrat-go/jsref/README.md @@ -0,0 +1,107 @@ +# go-jsref + +[![Build Status](https://travis-ci.org/lestrrat-go/jsref.svg?branch=master)](https://travis-ci.org/lestrrat-go/jsref) + +[![GoDoc](https://godoc.org/github.com/lestrrat-go/jsref?status.svg)](https://godoc.org/github.com/lestrrat-go/jsref) + +JSON Reference Implementation for Go + +# SYNOPSIS + +```go +package jsref_test + +import ( + "encoding/json" + "fmt" + "log" + + jsref "github.com/lestrrat-go/jsref" + "github.com/lestrrat-go/jsref/provider" +) + +func Example() { + var v interface{} + src := []byte(` +{ + "foo": ["bar", {"$ref": "#/sub"}, {"$ref": "obj2#/sub"}], + "sub": "baz" +}`) + if err := json.Unmarshal(src, &v); err != nil { + log.Printf("%s", err) + return + } + + // External reference + mp := provider.NewMap() + mp.Set("obj2", map[string]string{"sub": "quux"}) + + res := jsref.New() + res.AddProvider(mp) // Register the provider + + data := []struct { + Ptr string + Options []jsref.Option + }{ + { + Ptr: "#/foo/0", // "bar" + }, + { + Ptr: "#/foo/1", // "baz" + }, + { + Ptr: "#/foo/2", // "quux" (resolves via `mp`) + }, + { + Ptr: "#/foo", // ["bar",{"$ref":"#/sub"},{"$ref":"obj2#/sub"}] + }, + { + Ptr: "#/foo", // ["bar","baz","quux"] + // experimental option to resolve all resulting values + Options: []jsref.Option{ jsref.WithRecursiveResolution(true) }, + }, + } + for _, set := range data { + result, err := res.Resolve(v, set.Ptr, set.Options...) + if err != nil { // failed to resolve + fmt.Printf("err: %s\n", err) + continue + } + b, _ := json.Marshal(result) + fmt.Printf("%s -> %s\n", set.Ptr, string(b)) + } + + // OUTPUT: + // #/foo/0 -> "bar" + // #/foo/1 -> "baz" + // #/foo/2 -> "quux" + // #/foo -> ["bar",{"$ref":"#/sub"},{"$ref":"obj2#/sub"}] + // #/foo -> ["bar","baz","quux"] +} +``` + +# Providers + +The Resolver object by default does not know how to resolve *any* reference: +You must provide it one or more `Provider`s to look for and resolve external references. + +Currently available `Provider`s are: + +| Name | Description | +|:--------------|:------------| +| provider.FS | Resolve from local file system. References must start with a `file:///` prefix | +| provider.Map | Resolve from in memory map. | +| provider.HTTP | Resolve by making HTTP requests. References must start with a `http(s?)://` prefix | + +# References + +| Name | Notes | +|:--------------------------------------------------------:|:---------------------------------| +| [go-jsval](https://github.com/lestrrat-go/jsval) | Validator generator | +| [go-jshschema](https://github.com/lestrrat-go/jshschema) | JSON Hyper Schema implementation | +| [go-jsschema](https://github.com/lestrrat-go/jsschema) | JSON Schema implementation | +| [go-jspointer](https://github.com/lestrrat-go/jspointer) | JSON Pointer implementations | + +# Acknowledgements + +* Boris Burtin diff --git a/vendor/github.com/lestrrat-go/jsref/interface.go b/vendor/github.com/lestrrat-go/jsref/interface.go new file mode 100644 index 000000000000..905a8c313e45 --- /dev/null +++ b/vendor/github.com/lestrrat-go/jsref/interface.go @@ -0,0 +1,23 @@ +package jsref + +import ( + "errors" + "net/url" + "reflect" +) + +var zeroval = reflect.Value{} + +var ErrMaxRecursion = errors.New("reached max number of recursions") + +// Resolver is responsible for interpreting the provided JSON +// reference. +type Resolver struct { + providers []Provider + MaxRecursions int +} + +// Provider resolves a URL into a ... thing. +type Provider interface { + Get(*url.URL) (interface{}, error) +} diff --git a/vendor/github.com/lestrrat-go/jsref/jsref.go b/vendor/github.com/lestrrat-go/jsref/jsref.go new file mode 100644 index 000000000000..107473062bf2 --- /dev/null +++ b/vendor/github.com/lestrrat-go/jsref/jsref.go @@ -0,0 +1,396 @@ +package jsref + +import ( + "net/url" + "reflect" + + "github.com/lestrrat-go/jspointer" + "github.com/lestrrat-go/pdebug" + "github.com/lestrrat-go/structinfo" + "github.com/pkg/errors" +) + +const ref = "$ref" +var refrv = reflect.ValueOf(ref) + +type Option interface { + Name() string + Value() interface{} +} + +type option struct { + name string + value interface{} +} + +func (o option) Name() string { return o.name } +func (o option) Value() interface{} { return o.value } + +// WithRecursiveResolution allows ou to enable recursive resolution +// on the *result* data structure. This means that after resolving +// the JSON reference in the structure at hand, it does another +// pass at resolving the entire data structure. Depending on your +// structure and size, this may incur significant cost. +// +// Please note that recursive resolution of the result is still +// experimental. If you find problems, please submit a pull request +// with a failing test case. +func WithRecursiveResolution(b bool) Option { + return &option{ + name: "recursiveResolution", + value: b, + } +} + +var DefaultMaxRecursions = 10 + +// New creates a new Resolver +func New() *Resolver { + return &Resolver{MaxRecursions: DefaultMaxRecursions} +} + +// AddProvider adds a new Provider to be searched for in case +// a JSON pointer with more than just the URI fragment is given. +func (r *Resolver) AddProvider(p Provider) error { + r.providers = append(r.providers, p) + return nil +} + +type resolveCtx struct { + rlevel int // recurse level + maxrlevel int // max recurse level + object interface{} // the main object that was passed to `Resolve()` +} + +// Resolve takes a target `v`, and a JSON pointer `spec`. +// spec is expected to be in the form of +// +// [scheme://[userinfo@]host/path[?query]]#fragment +// [scheme:opaque[?query]]#fragment +// +// where everything except for `#fragment` is optional. +// If the fragment is empty, an error is returned. +// +// If `spec` is the empty string, `v` is returned +// This method handles recursive JSON references. +// +// If `WithRecursiveResolution` option is given and its value is true, +// an attempt to resolve all references within the resulting object +// is made by traversing the structure recursively. Default is false +func (r *Resolver) Resolve(v interface{}, ptr string, options ...Option) (ret interface{}, err error) { + if pdebug.Enabled { + g := pdebug.Marker("Resolver.Resolve(%s)", ptr).BindError(&err) + defer g.End() + } + var recursiveResolution bool + for _, opt := range options { + switch opt.Name() { + case "recursiveResolution": + recursiveResolution = opt.Value().(bool) + } + } + + ctx := resolveCtx{ + rlevel: 0, + maxrlevel: r.MaxRecursions, + object: v, + } + + // First, expand the target as much as we can + v, err = expandRefRecursive(&ctx, r, v) + if err != nil { + return nil, errors.Wrap(err, "recursive search failed") + } + + result, err := evalptr(&ctx, r, v, ptr) + if err != nil { + return nil, err + } + + if recursiveResolution { + rv, err := traverseExpandRefRecursive(&ctx, r, reflect.ValueOf(result)) + if err != nil { + return nil, errors.Wrap(err, `failed to resolve result`) + } + result = rv.Interface() + } + + return result, nil +} + +func setPtrOrInterface(container, value reflect.Value) bool { + switch container.Kind() { + case reflect.Ptr: + if !value.CanAddr() { + return false + } + container.Set(value.Addr()) + case reflect.Interface: + container.Set(value) + default: + return false + } + return true +} + +func traverseExpandRefRecursive(ctx *resolveCtx, r *Resolver, rv reflect.Value) (reflect.Value, error) { + if pdebug.Enabled { + g := pdebug.Marker("traverseExpandRefRecursive") + defer g.End() + } + + switch rv.Kind() { + case reflect.Ptr, reflect.Interface: + rv = rv.Elem() + } + + switch rv.Kind() { + case reflect.Array, reflect.Slice: + for i := 0; i < rv.Len(); i++ { + elem := rv.Index(i) + var elemcontainer reflect.Value + switch elem.Kind() { + case reflect.Ptr, reflect.Interface: + elemcontainer = elem + elem = elem.Elem() + } + + // Need to check for elem being Valid, otherwise the + // subsequent call to Interface() will fail + if !elem.IsValid() { + continue + } + + if elemcontainer.IsValid() { + if !elemcontainer.CanSet() { + continue + } + } + newv, err := expandRefRecursive(ctx, r, elem.Interface()) + if err != nil { + return zeroval, errors.Wrap(err, `failed to expand array/slice element`) + } + newrv, err := traverseExpandRefRecursive(ctx, r, reflect.ValueOf(newv)) + if err != nil { + return zeroval, errors.Wrap(err, `failed to recurse into array/slice element`) + } + + if elemcontainer.IsValid() { + setPtrOrInterface(elemcontainer, newrv) + } else { + elem.Set(newrv) + } + } + case reflect.Map: + // No refs found in the map keys, but there could be more + // in the values + if _, err := findRef(rv.Interface()); err != nil { + for _, key := range rv.MapKeys() { + value, err := traverseExpandRefRecursive(ctx, r, rv.MapIndex(key)) + if err != nil { + return zeroval, errors.Wrap(err, `failed to traverse map value`) + } + rv.SetMapIndex(key, value) + } + return rv, nil + } + newv, err := expandRefRecursive(ctx, r, rv.Interface()) + if err != nil { + return zeroval, errors.Wrap(err, `failed to expand map element`) + } + return traverseExpandRefRecursive(ctx, r, reflect.ValueOf(newv)) + case reflect.Struct: + // No refs found in the map keys, but there could be more + // in the values + if _, err := findRef(rv.Interface()); err != nil { + for i := 0; i < rv.NumField(); i++ { + field := rv.Field(i) + value, err := traverseExpandRefRecursive(ctx, r, field) + if err != nil { + return zeroval, errors.Wrap(err, `failed to traverse struct field value`) + } + field.Set(value) + } + return rv, nil + } + newv, err := expandRefRecursive(ctx, r, rv.Interface()) + if err != nil { + return zeroval, errors.Wrap(err, `failed to expand struct element`) + } + return traverseExpandRefRecursive(ctx, r, reflect.ValueOf(newv)) + } + return rv, nil +} + +// expands $ref with in v, until all $refs are expanded. +// note: DOES NOT recurse down into structures +func expandRefRecursive(ctx *resolveCtx, r *Resolver, v interface{}) (ret interface{}, err error) { + if pdebug.Enabled { + g := pdebug.Marker("expandRefRecursive") + defer g.End() + } + for { + ref, err := findRef(v) + if err != nil { + if pdebug.Enabled { + pdebug.Printf("No refs found. bailing out of loop") + } + break + } + + if pdebug.Enabled { + pdebug.Printf("Found ref '%s'", ref) + } + + newv, err := expandRef(ctx, r, v, ref) + if err != nil { + if pdebug.Enabled { + pdebug.Printf("Failed to expand ref '%s': %s", ref, err) + } + return nil, errors.Wrap(err, "failed to expand ref") + } + + v = newv + } + + return v, nil +} + +func expandRef(ctx *resolveCtx, r *Resolver, v interface{}, ref string) (ret interface{}, err error) { + ctx.rlevel++ + if ctx.rlevel > ctx.maxrlevel { + return nil, ErrMaxRecursion + } + + defer func() { ctx.rlevel-- }() + + u, err := url.Parse(ref) + if err != nil { + return nil, errors.Wrap(err, "failed to parse ref as URL") + } + + ptr := "#" + u.Fragment + if u.Host == "" && u.Path == "" { + if pdebug.Enabled { + pdebug.Printf("ptr doesn't contain any host/path part, apply json pointer directly to object") + } + return evalptr(ctx, r, ctx.object, ptr) + } + + u.Fragment = "" + for _, p := range r.providers { + pv, err := p.Get(u) + if err == nil { + if pdebug.Enabled { + pdebug.Printf("Found object matching %s", u) + } + + return evalptr(ctx, r, pv, ptr) + } + } + + return nil, errors.New("element pointed by $ref '" + ref + "' not found") +} + +func findRef(v interface{}) (ref string, err error) { + if pdebug.Enabled { + g := pdebug.Marker("findRef").BindError(&err) + defer g.End() + } + + rv := reflect.ValueOf(v) + switch rv.Kind() { + case reflect.Interface, reflect.Ptr: + rv = rv.Elem() + } + + if pdebug.Enabled { + pdebug.Printf("object is a '%s'", rv.Kind()) + } + + // Find if we have a "$ref" element + var refv reflect.Value + switch rv.Kind() { + case reflect.Map: + refv = rv.MapIndex(refrv) + case reflect.Struct: + if fn := structinfo.StructFieldFromJSONName(rv, ref); fn != "" { + refv = rv.FieldByName(fn) + } + default: + return "", errors.New("element is not a map-like container") + } + + if !refv.IsValid() { + return "", errors.New("$ref element not found") + } + + switch refv.Kind() { + case reflect.Interface, reflect.Ptr: + refv = refv.Elem() + } + + switch refv.Kind() { + case reflect.String: + // Empty string isn't a valid pointer + if refv.Len() <= 0 { + return "", errors.New("$ref element not found (empty)") + } + if pdebug.Enabled { + pdebug.Printf("Found ref '%s'", refv) + } + return refv.String(), nil + case reflect.Invalid: + return "", errors.New("$ref element not found") + default: + if pdebug.Enabled { + pdebug.Printf("'$ref' was found, but its kind is %s", refv.Kind()) + } + } + + return "", errors.New("$ref element must be a string") +} + +func evalptr(ctx *resolveCtx, r *Resolver, v interface{}, ptrspec string) (ret interface{}, err error) { + if pdebug.Enabled { + g := pdebug.Marker("evalptr(%s)", ptrspec).BindError(&err) + defer g.End() + } + + // If the reference is empty, return v + if ptrspec == "" || ptrspec == "#" { + if pdebug.Enabled { + pdebug.Printf("Empty pointer, return v itself") + } + return v, nil + } + + // Parse the spec. + u, err := url.Parse(ptrspec) + if err != nil { + return nil, errors.Wrap(err, "failed to parse reference spec") + } + + ptr := u.Fragment + + // We are evaluating the pointer part. That means if the + // Fragment portion is not set, there's no point in evaluating + if ptr == "" { + return nil, errors.Wrap(err, "empty json pointer") + } + + p, err := jspointer.New(ptr) + if err != nil { + return nil, errors.Wrap(err, "failed create a new JSON pointer") + } + x, err := p.Get(v) + if err != nil { + return nil, errors.Wrap(err, "failed to fetch value") + } + + if pdebug.Enabled { + pdebug.Printf("Evaulated JSON pointer, now checking if we can expand further") + } + // If this result contains more refs, expand that + return expandRefRecursive(ctx, r, x) +} diff --git a/vendor/github.com/lestrrat-go/jsref/jsref_example_test.go b/vendor/github.com/lestrrat-go/jsref/jsref_example_test.go new file mode 100644 index 000000000000..eeacd46da33d --- /dev/null +++ b/vendor/github.com/lestrrat-go/jsref/jsref_example_test.go @@ -0,0 +1,69 @@ +package jsref_test + +import ( + "encoding/json" + "fmt" + "log" + + jsref "github.com/lestrrat-go/jsref" + "github.com/lestrrat-go/jsref/provider" +) + +func Example() { + var v interface{} + src := []byte(` +{ + "foo": ["bar", {"$ref": "#/sub"}, {"$ref": "obj2#/sub"}], + "sub": "baz" +}`) + if err := json.Unmarshal(src, &v); err != nil { + log.Printf("%s", err) + return + } + + // External reference + mp := provider.NewMap() + mp.Set("obj2", map[string]string{"sub": "quux"}) + + res := jsref.New() + res.AddProvider(mp) // Register the provider + + data := []struct { + Ptr string + Options []jsref.Option + }{ + { + Ptr: "#/foo/0", // "bar" + }, + { + Ptr: "#/foo/1", // "baz" + }, + { + Ptr: "#/foo/2", // "quux" (resolves via `mp`) + }, + { + Ptr: "#/foo", // ["bar",{"$ref":"#/sub"},{"$ref":"obj2#/sub"}] + }, + { + Ptr: "#/foo", // ["bar","baz","quux"] + // experimental option to resolve all resulting values + Options: []jsref.Option{ jsref.WithRecursiveResolution(true) }, + }, + } + for _, set := range data { + result, err := res.Resolve(v, set.Ptr, set.Options...) + if err != nil { // failed to resolve + fmt.Printf("err: %s\n", err) + continue + } + b, _ := json.Marshal(result) + fmt.Printf("%s -> %s\n", set.Ptr, string(b)) + } + + // OUTPUT: + // #/foo/0 -> "bar" + // #/foo/1 -> "baz" + // #/foo/2 -> "quux" + // #/foo -> ["bar",{"$ref":"#/sub"},{"$ref":"obj2#/sub"}] + // #/foo -> ["bar","baz","quux"] +} diff --git a/vendor/github.com/lestrrat-go/jsref/jsref_test.go b/vendor/github.com/lestrrat-go/jsref/jsref_test.go new file mode 100644 index 000000000000..7c47688baff9 --- /dev/null +++ b/vendor/github.com/lestrrat-go/jsref/jsref_test.go @@ -0,0 +1,295 @@ +package jsref_test + +import ( + "encoding/json" + "io/ioutil" + "log" + "net" + "net/http" + "os" + "path/filepath" + "sort" + "strconv" + "strings" + "testing" + "time" + + "github.com/lestrrat-go/jsref" + "github.com/lestrrat-go/jsref/provider" + "github.com/stretchr/testify/assert" +) + +func TestResolveMemory(t *testing.T) { + m := map[string]interface{}{ + "foo": []interface{}{ + "bar", + map[string]interface{}{ + "$ref": "#/sub", + }, + map[string]interface{}{ + "$ref": "obj2#/sub", + }, + }, + "sub": "baz", + } + + data := map[string]string{ + "#/foo/0": "bar", + "#/foo/1": "baz", + "#/foo/2": "quux", + } + + res := jsref.New() + mp := provider.NewMap() + mp.Set("obj2", map[string]string{"sub": "quux"}) + res.AddProvider(mp) + + ptrlist := make([]string, 0, len(data)) + for ptr := range data { + ptrlist = append(ptrlist, ptr) + } + sort.Strings(ptrlist) + + for _, ptr := range ptrlist { + expected := data[ptr] + v, err := res.Resolve(m, ptr) + if !assert.NoError(t, err, "Resolve(%s) should succeed", ptr) { + return + } + if !assert.Equal(t, v, expected, "Resolve(%s) resolves to '%s'", ptr, expected) { + return + } + } + + // In this test we test if we can optionally recursively + // resolve references + v, err := res.Resolve(m, "#/foo", jsref.WithRecursiveResolution(true)) + if !assert.NoError(t, err, "Resolve(%s) should succeed", "#/foo") { + return + } + + if !assert.Equal(t, []interface{}{"bar", "baz", "quux"}, v) { + return + } +} + +func TestResolveFS(t *testing.T) { + dir, err := ioutil.TempDir("", "jsref-test-") + if !assert.NoError(t, err, "creating temporary directory should succeed") { + return + } + defer os.RemoveAll(dir) + + path := filepath.Join(dir, "obj2") + f, err := os.Create(path) + if !assert.NoError(t, err, "creating %s file should succeed", path) { + return + } + f.Write([]byte(`{"sub":"quux"}`)) + f.Close() + + m := map[string]interface{}{ + "foo": []interface{}{ + "bar", + map[string]interface{}{ + "$ref": "#/sub", + }, + map[string]interface{}{ + "$ref": "file:///obj2#/sub", + }, + }, + "sub": "baz", + } + + data := map[string]string{ + "#/foo/0": "bar", + "#/foo/1": "baz", + "#/foo/2": "quux", + } + + res := jsref.New() + res.AddProvider(provider.NewFS(dir)) + + ptrlist := make([]string, 0, len(data)) + for ptr := range data { + ptrlist = append(ptrlist, ptr) + } + sort.Strings(ptrlist) + + for _, ptr := range ptrlist { + expected := data[ptr] + v, err := res.Resolve(m, ptr) + if !assert.NoError(t, err, "Resolve(%s) should succeed", ptr) { + return + } + if !assert.Equal(t, v, expected, "Resolve(%s) resolves to '%s'", ptr, expected) { + return + } + } +} + +func TestResolveHTTP(t *testing.T) { + if b, _ := strconv.ParseBool(os.Getenv("JSREF_LIVE_TESTS")); !b { + t.Skip("JSREF_LIVE_TESTS is not available, skipping test") + } + + cl := http.Client{ + Transport: &http.Transport{ + Dial: func(n, a string) (net.Conn, error) { + return net.DialTimeout(n, a, 2*time.Second) + }, + }, + } + + const schemaURL = `http://json-schema.org/draft-04/schema#` + if _, err := cl.Get(schemaURL); err != nil { + t.Skip("JSON schema '" + schemaURL + "' unavailable, skipping test") + } + + res := jsref.New() + hp := provider.NewHTTP() + res.AddProvider(hp) + + m := map[string]interface{}{ + "fetch": map[string]string{ + "$ref": schemaURL, + }, + } + + ptr := "#/fetch" + v, err := res.Resolve(m, ptr) + if !assert.NoError(t, err, "Resolve(%s) should succeed", ptr) { + return + } + + switch v.(type) { + case map[string]interface{}: + mv := v.(map[string]interface{}) + if !assert.Equal(t, mv["id"], schemaURL, "Resolve("+schemaURL+") resolved to JSON schema") { + return + } + default: + t.Errorf("Expected map[string]interface{}") + } +} + +func TestResolveRecursive(t *testing.T) { + var v interface{} + src := []byte(` +{ + "foo": { + "type": "array", + "items": [{ "$ref": "#" }] + } +}`) + if err := json.Unmarshal(src, &v); err != nil { + log.Printf("%s", err) + return + } + + res := jsref.New() + _, err := res.Resolve(v, "#/foo") // "bar" + if !assert.NoError(t, err, "res.Resolve should succeed") { + return + } +} + +func TestGHPR12(t *testing.T) { + // https://github.com/lestrrat-go/jsref/pull/2 gave me an example + // using "foo" as the JS pointer (could've been a typo) + // but it gave me weird results, so this is where I'm testing it + var v interface{} + src := []byte(` +{ + "foo": "bar" +}`) + if err := json.Unmarshal(src, &v); err != nil { + log.Printf("%s", err) + return + } + + res := jsref.New() + _, err := res.Resolve(v, "foo") + if !assert.NoError(t, err, "res.Resolve should fail") { + return + } +} + +func TestHyperSchemaRecursive(t *testing.T) { + src := []byte(` +{ + "definitions": { + "virtual_machine": { + "type": "object" + } + }, + "links": [ + { + "schema": { + "type": "object" + }, + "targetSchema": { + "$ref": "#/definitions/virtual_machine" + } + }, + { + "targetSchema": { + "type": "array", + "items": { + "$ref": "#/definitions/virtual_machine" + } + } + } + ] +}`) + var v interface{} + err := json.Unmarshal(src, &v) + assert.Nil(t, err) + res := jsref.New() + + ptrs := []string{ + "#/links/0/schema", + "#/links/0/targetSchema", + "#/links/1/targetSchema", + } + for _, ptr := range ptrs { + result, err := res.Resolve(v, ptr, jsref.WithRecursiveResolution(true)) + assert.Nil(t, err) + b, err := json.Marshal(result) + if !assert.NoError(t, err, "json.Marshal should succeed") { + return + } + if !assert.False(t, strings.Contains(string(b), "$ref"), "%s did not recursively resolve", ptr) { + t.Logf("resolved to '%s'", b) + return + } + } +} + +func TestGHIssue7(t *testing.T) { + src := []byte(`{ + "status": { + "type": ["string", "null"], + "enum": [ + "sent", + "duplicate", + "error", + "invalid", + "rejected", + "unqueued", + "unsubscribed", + null + ] + } +}`) + + var v interface{} + if !assert.NoError(t, json.Unmarshal(src, &v), `Unmarshal should succeed`) { + return + } + + res := jsref.New() + result, err := res.Resolve(v, "", jsref.WithRecursiveResolution(true)) + t.Logf("%s", result) + t.Logf("%s", err) +} diff --git a/vendor/github.com/lestrrat-go/jsref/provider/fs.go b/vendor/github.com/lestrrat-go/jsref/provider/fs.go new file mode 100644 index 000000000000..21eab966d109 --- /dev/null +++ b/vendor/github.com/lestrrat-go/jsref/provider/fs.go @@ -0,0 +1,75 @@ +package provider + +import ( + "encoding/json" + "net/url" + "os" + "path/filepath" + "strings" + + "github.com/lestrrat-go/pdebug" + "github.com/pkg/errors" +) + +// NewFS creates a new Provider that looks for JSON documents +// from the local file system. Documents are only searched +// within `root` +func NewFS(root string) *FS { + return &FS{ + mp: NewMap(), + Root: root, + } +} + +// Get fetches the document specified by the `key` argument. +// Everything other than `.Path` is ignored. +// Note that once a document is read, it WILL be cached for the +// duration of this object, unless you call `Reset` +func (fp *FS) Get(key *url.URL) (out interface{}, err error) { + if pdebug.Enabled { + g := pdebug.Marker("provider.FS.Get(%s)", key.String()).BindError(&err) + defer g.End() + } + + if strings.ToLower(key.Scheme) != "file" { + return nil, errors.New("unsupported scheme '" + key.Scheme + "'") + } + + // Everything other than "Path" is ignored + path := filepath.Clean(filepath.Join(fp.Root, key.Path)) + + mpkey := &url.URL{Path: path} + if x, err := fp.mp.Get(mpkey); err == nil { + return x, nil + } + + fi, err := os.Stat(path) + if err != nil { + return nil, errors.Wrap(err, "failed to stat local resource") + } + + if fi.IsDir() { + return nil, errors.New("target is not a file") + } + + f, err := os.Open(path) + if err != nil { + return nil, errors.Wrap(err, "failed to open local resource") + } + defer f.Close() + + var x interface{} + dec := json.NewDecoder(f) + if err := dec.Decode(&x); err != nil { + return nil, errors.Wrap(err, "failed to parse JSON local resource") + } + + fp.mp.Set(path, x) + + return x, nil +} + +// Reset resets the in memory cache of JSON documents +func (fp *FS) Reset() error { + return fp.mp.Reset() +} diff --git a/vendor/github.com/lestrrat-go/jsref/provider/http.go b/vendor/github.com/lestrrat-go/jsref/provider/http.go new file mode 100644 index 000000000000..acb407b8850f --- /dev/null +++ b/vendor/github.com/lestrrat-go/jsref/provider/http.go @@ -0,0 +1,65 @@ +package provider + +import ( + "encoding/json" + "net/http" + "net/url" + "strings" + "time" + + "github.com/lestrrat-go/pdebug" + "github.com/pkg/errors" +) + +// NewFS creates a new Provider that looks for JSON documents +// from the internet over HTTP(s) +func NewHTTP() *HTTP { + return &HTTP{ + mp: NewMap(), + Client: &http.Client{ + Timeout: 5 * time.Second, + }, + } +} + +// Get fetches the document specified by the `key` argument, making +// a HTTP request if necessary. +// Note that once a document is read, it WILL be cached for the +// duration of this object, unless you call `Reset` +func (hp *HTTP) Get(key *url.URL) (interface{}, error) { + if pdebug.Enabled { + g := pdebug.Marker("HTTP.Get(%s)", key) + defer g.End() + } + + switch strings.ToLower(key.Scheme) { + case "http", "https": + default: + return nil, errors.New("key is not http/https URL") + } + + v, err := hp.mp.Get(key) + if err == nil { // Found! + return v, nil + } + + res, err := hp.Client.Get(key.String()) + if err != nil { + return nil, errors.Wrap(err, "failed to fetch HTTP resource") + } + defer res.Body.Close() + + dec := json.NewDecoder(res.Body) + + var x interface{} + if err := dec.Decode(&x); err != nil { + return nil, errors.Wrap(err, "failed to parse JSON from HTTP resource") + } + + return x, nil +} + +// Reset resets the in memory cache of JSON documents +func (hp *HTTP) Reset() error { + return hp.mp.Reset() +} diff --git a/vendor/github.com/lestrrat-go/jsref/provider/interface.go b/vendor/github.com/lestrrat-go/jsref/provider/interface.go new file mode 100644 index 000000000000..4eaf7190a28f --- /dev/null +++ b/vendor/github.com/lestrrat-go/jsref/provider/interface.go @@ -0,0 +1,21 @@ +package provider + +import ( + "net/http" + "sync" +) + +type FS struct { + mp *Map + Root string +} + +type HTTP struct { + mp *Map + Client *http.Client +} + +type Map struct { + lock sync.Mutex + mapping map[string]interface{} +} diff --git a/vendor/github.com/lestrrat-go/jsref/provider/map.go b/vendor/github.com/lestrrat-go/jsref/provider/map.go new file mode 100644 index 000000000000..48d65a6a4c48 --- /dev/null +++ b/vendor/github.com/lestrrat-go/jsref/provider/map.go @@ -0,0 +1,47 @@ +package provider + +import ( + "net/url" + + "github.com/lestrrat-go/pdebug" + "github.com/pkg/errors" +) + +func NewMap() *Map { + return &Map{ + mapping: make(map[string]interface{}), + } +} + +func (mp *Map) Set(key string, v interface{}) error { + mp.lock.Lock() + defer mp.lock.Unlock() + + mp.mapping[key] = v + return nil +} + +func (mp *Map) Get(key *url.URL) (res interface{}, err error) { + if pdebug.Enabled { + g := pdebug.Marker("Map.Get(%s)", key).BindError(&err) + defer g.End() + } + + mp.lock.Lock() + defer mp.lock.Unlock() + + v, ok := mp.mapping[key.String()] + if !ok { + return nil, errors.New("not found") + } + + return v, nil +} + +func (mp *Map) Reset() error { + mp.lock.Lock() + defer mp.lock.Unlock() + + mp.mapping = make(map[string]interface{}) + return nil +} diff --git a/vendor/github.com/lestrrat-go/pdebug/.gitignore b/vendor/github.com/lestrrat-go/pdebug/.gitignore new file mode 100644 index 000000000000..daf913b1b347 --- /dev/null +++ b/vendor/github.com/lestrrat-go/pdebug/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/vendor/github.com/lestrrat-go/pdebug/.travis.yml b/vendor/github.com/lestrrat-go/pdebug/.travis.yml new file mode 100644 index 000000000000..baecfce60a99 --- /dev/null +++ b/vendor/github.com/lestrrat-go/pdebug/.travis.yml @@ -0,0 +1,14 @@ +language: go +sudo: false +go: + - 1.6 + - 1.7 + - tip +install: + - go get -t -v ./... + - go get -t -tags debug0 -v ./... +script: + - go test -v ./... + - go test -tags debug ./... + - PDEBUG_TRACE=1 go test -tags debug ./... + - go test -tags debug0 ./... diff --git a/vendor/github.com/lestrrat-go/pdebug/LICENSE b/vendor/github.com/lestrrat-go/pdebug/LICENSE new file mode 100644 index 000000000000..20054b15434d --- /dev/null +++ b/vendor/github.com/lestrrat-go/pdebug/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 lestrrat + +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/lestrrat-go/pdebug/README.md b/vendor/github.com/lestrrat-go/pdebug/README.md new file mode 100644 index 000000000000..4f6d88959f8a --- /dev/null +++ b/vendor/github.com/lestrrat-go/pdebug/README.md @@ -0,0 +1,95 @@ +# go-pdebug + +[![Build Status](https://travis-ci.org/lestrrat-go/pdebug.svg?branch=master)](https://travis-ci.org/lestrrat-go/pdebug) + +[![GoDoc](https://godoc.org/github.com/lestrrat-go/pdebug?status.svg)](https://godoc.org/github.com/lestrrat-go/pdebug) + +Utilities for my print debugging fun. YMMV + +# Synopsis + +![optimized](https://pbs.twimg.com/media/CbiqhzLUUAIN_7o.png) + +# Description + +Building with `pdebug` declares a constant, `pdebug.Enabled` which you +can use to easily compile in/out depending on the presence of a build tag. + +```go +func Foo() { + // will only be available if you compile with `-tags debug` + if pdebug.Enabled { + pdebug.Printf("Starting Foo()! + } +} +``` + +Note that using `github.com/lestrrat-go/pdebug` and `-tags debug` only +compiles in the code. In order to actually show the debug trace, you need +to specify an environment variable: + +```shell +# For example, to show debug code during testing: +PDEBUG_TRACE=1 go test -tags debug +``` + +If you want to forcefully show the trace (which is handy when you're +debugging/testing), you can use the `debug0` tag instead: + +```shell +go test -tags debug0 +``` + +# Markers + +When you want to print debug a chain of function calls, you can use the +`Marker` functions: + +```go +func Foo() { + if pdebug.Enabled { + g := pdebug.Marker("Foo") + defer g.End() + } + + pdebug.Printf("Inside Foo()!") +} +``` + +This will cause all of the `Printf` calls to automatically indent +the output so it's visually easier to see where a certain trace log +is being generated. + +By default it will print something like: + +``` +|DEBUG| START Foo +|DEBUG| Inside Foo()! +|DEBUG| END Foo (1.23μs) +``` + +If you want to automatically show the error value you are returning +(but only if there is an error), you can use the `BindError` method: + +```go +func Foo() (err error) { + if pdebug.Enabled { + g := pdebug.Marker("Foo").BindError(&err) + defer g.End() + } + + pdebug.Printf("Inside Foo()!") + + return errors.New("boo") +} +``` + +This will print something like: + + +``` +|DEBUG| START Foo +|DEBUG| Inside Foo()! +|DEBUG| END Foo (1.23μs): ERROR boo +``` + diff --git a/vendor/github.com/lestrrat-go/pdebug/autoflag_off.go b/vendor/github.com/lestrrat-go/pdebug/autoflag_off.go new file mode 100644 index 000000000000..3ca774591fd0 --- /dev/null +++ b/vendor/github.com/lestrrat-go/pdebug/autoflag_off.go @@ -0,0 +1,15 @@ +// +build debug + +package pdebug + +import ( + "os" + "strconv" +) + +var Trace = false +func init() { + if b, err := strconv.ParseBool(os.Getenv("PDEBUG_TRACE")); err == nil && b { + Trace = true + } +} \ No newline at end of file diff --git a/vendor/github.com/lestrrat-go/pdebug/autoflag_on.go b/vendor/github.com/lestrrat-go/pdebug/autoflag_on.go new file mode 100644 index 000000000000..f5f674db5d05 --- /dev/null +++ b/vendor/github.com/lestrrat-go/pdebug/autoflag_on.go @@ -0,0 +1,6 @@ +// +build debug0 + +package pdebug + +var Trace = true + diff --git a/vendor/github.com/lestrrat-go/pdebug/common.go b/vendor/github.com/lestrrat-go/pdebug/common.go new file mode 100644 index 000000000000..95f11a007695 --- /dev/null +++ b/vendor/github.com/lestrrat-go/pdebug/common.go @@ -0,0 +1,43 @@ +package pdebug + +import ( + "io" + "os" + "sync" + "time" +) + +type pdctx struct { + mutex sync.Mutex + indentL int + LogTime bool + Prefix string + Writer io.Writer +} + +var emptyMarkerGuard = &markerg{} + +type markerg struct { + indentg guard + ctx *pdctx + f string + args []interface{} + start time.Time + errptr *error +} + +var DefaultCtx = &pdctx{ + LogTime: true, + Prefix: "|DEBUG| ", + Writer: os.Stdout, +} + +type guard struct { + cb func() +} + +func (g *guard) End() { + if cb := g.cb; cb != nil { + cb() + } +} diff --git a/vendor/github.com/lestrrat-go/pdebug/common_test.go b/vendor/github.com/lestrrat-go/pdebug/common_test.go new file mode 100644 index 000000000000..2589727304ce --- /dev/null +++ b/vendor/github.com/lestrrat-go/pdebug/common_test.go @@ -0,0 +1,112 @@ +package pdebug + +import ( + "bytes" + "errors" + "io" + "regexp" + "testing" + + "github.com/stretchr/testify/assert" +) + +func setw(ctx *pdctx, w io.Writer) func() { + oldw := ctx.Writer + ctx.Writer = w + return func() { ctx.Writer = oldw } +} + +func TestPrintf(t *testing.T) { + buf := &bytes.Buffer{} + wg := setw(DefaultCtx, buf) + defer wg() + + Printf("Hello, World!") + + if Enabled && Trace { + re := regexp.MustCompile(`\|DEBUG\| \d+\.\d+ Hello, World!\n`) + if !assert.True(t, re.MatchString(buf.String()), "Simple Printf works") { + return + } + } else { + if !assert.Equal(t, "", buf.String(), "Simple Printf should be suppressed") { + return + } + } +} + +func TestMarker(t *testing.T) { + buf := &bytes.Buffer{} + wg := setw(DefaultCtx, buf) + defer wg() + + f2 := func() (err error) { + g := Marker("f2").BindError(&err) + defer g.End() + Printf("Hello, World!") + return errors.New("dummy error") + } + + f1 := func() { + g := Marker("f1") + defer g.End() + f2() + } + + f1() + + if Enabled && Trace { + re := regexp.MustCompile(`\|DEBUG\| \d+\.\d+ START f1\n\|DEBUG\| \d+\.\d+ START f2\n\|DEBUG\| \d+\.\d+ Hello, World!\n\|DEBUG\| \d+\.\d+ END f2 \(`) + if !assert.True(t, re.MatchString(buf.String()), "Markers should work") { + t.Logf("Expected '%v'", re) + t.Logf("Actual '%v'", buf.String()) + return + } + } else { + if !assert.Equal(t, "", buf.String(), "Markers should work") { + return + } + } +} + +func TestLegacyMarker(t *testing.T) { + buf := &bytes.Buffer{} + wg := setw(DefaultCtx, buf) + defer wg() + + f2 := func() (err error) { + g := IPrintf("START f2") + defer func() { + if err == nil { + g.IRelease("END f2") + } else { + g.IRelease("END f2: %s", err) + } + }() + Printf("Hello, World!") + return errors.New("dummy error") + } + + f1 := func() { + g := IPrintf("START f1") + defer g.IRelease("END f1") + f2() + } + + f1() + + if Enabled && Trace { + re := regexp.MustCompile(`\|DEBUG\| \d+\.\d+ START f1\n\|DEBUG\| \d+\.\d+ START f2\n\|DEBUG\| \d+\.\d+ Hello, World!\n\|DEBUG\| \d+\.\d+ END f2`) + if !assert.True(t, re.MatchString(buf.String()), "Markers should work") { + t.Logf("Expected '%v'", re) + t.Logf("Actual '%v'", buf.String()) + return + } + + // TODO: check for error and timestamp + } else { + if !assert.Equal(t, "", buf.String(), "Markers should work") { + return + } + } +} diff --git a/vendor/github.com/lestrrat-go/pdebug/debug0_test.go b/vendor/github.com/lestrrat-go/pdebug/debug0_test.go new file mode 100644 index 000000000000..052fcca96231 --- /dev/null +++ b/vendor/github.com/lestrrat-go/pdebug/debug0_test.go @@ -0,0 +1,13 @@ +//+build debug0,!debug + +package pdebug + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestDebug0Enabled(t *testing.T) { + assert.True(t, Enabled, "Enable is true") +} diff --git a/vendor/github.com/lestrrat-go/pdebug/debug_off.go b/vendor/github.com/lestrrat-go/pdebug/debug_off.go new file mode 100644 index 000000000000..9f794b29747b --- /dev/null +++ b/vendor/github.com/lestrrat-go/pdebug/debug_off.go @@ -0,0 +1,39 @@ +//+build !debug,!debug0 + +package pdebug + +// Enabled is true if `-tags debug` or `-tags debug0` is used +// during compilation. Use this to "ifdef-out" debug blocks. +const Enabled = false + +// Trace is true if `-tags debug` is used AND the environment +// variable `PDEBUG_TRACE` is set to a `true` value (i.e., +// 1, true, etc), or `-tags debug0` is used. This allows you to +// compile-in the trace logs, but only show them when you +// set the environment variable +const Trace = false + +// IRelease is deprecated. Use Marker()/End() instead +func (g guard) IRelease(f string, args ...interface{}) {} + +// IPrintf is deprecated. Use Marker()/End() instead +func IPrintf(f string, args ...interface{}) guard { return guard{} } + +// Printf prints to standard out, just like a normal fmt.Printf, +// but respects the indentation level set by IPrintf/IRelease. +// Printf is no op unless you compile with the `debug` tag. +func Printf(f string, args ...interface{}) {} + +// Dump dumps the objects using go-spew. +// Dump is a no op unless you compile with the `debug` tag. +func Dump(v ...interface{}) {} + +// Marker marks the beginning of an indented block. The message +// you specify in the arguments is prefixed witha "START", and +// subsequent calls to Printf will be indented one level more. +// +// To reset this, you must call End() on the guard object that +// gets returned by Marker(). +func Marker(f string, args ...interface{}) *markerg { return emptyMarkerGuard } +func (g *markerg) BindError(_ *error) *markerg { return g } +func (g *markerg) End() {} diff --git a/vendor/github.com/lestrrat-go/pdebug/debug_on.go b/vendor/github.com/lestrrat-go/pdebug/debug_on.go new file mode 100644 index 000000000000..064f3420ca8b --- /dev/null +++ b/vendor/github.com/lestrrat-go/pdebug/debug_on.go @@ -0,0 +1,170 @@ +// +build debug OR debug0 + +package pdebug + +import ( + "bytes" + "fmt" + "strings" + "time" + + "github.com/davecgh/go-spew/spew" +) + +const Enabled = true + +type Guard interface { + End() +} + +var emptyGuard = &guard{} + +func (ctx *pdctx) Unindent() { + ctx.mutex.Lock() + defer ctx.mutex.Unlock() + ctx.indentL-- +} + +func (ctx *pdctx) Indent() guard { + ctx.mutex.Lock() + ctx.indentL++ + ctx.mutex.Unlock() + + return guard{cb: ctx.Unindent} +} + +func (ctx *pdctx) preamble(buf *bytes.Buffer) { + if p := ctx.Prefix; len(p) > 0 { + buf.WriteString(p) + } + if ctx.LogTime { + fmt.Fprintf(buf, "%0.5f ", float64(time.Now().UnixNano()) / 1000000.0) + } + + for i := 0; i < ctx.indentL; i++ { + buf.WriteString(" ") + } +} + +func (ctx *pdctx) Printf(f string, args ...interface{}) { + if !strings.HasSuffix(f, "\n") { + f = f + "\n" + } + buf := bytes.Buffer{} + ctx.preamble(&buf) + fmt.Fprintf(&buf, f, args...) + buf.WriteTo(ctx.Writer) +} + +func Marker(f string, args ...interface{}) *markerg { + return DefaultCtx.Marker(f, args...) +} + +func (ctx *pdctx) Marker(f string, args ...interface{}) *markerg { + if !Trace { + return emptyMarkerGuard + } + + buf := &bytes.Buffer{} + ctx.preamble(buf) + buf.WriteString("START ") + fmt.Fprintf(buf, f, args...) + if buf.Len() > 0 { + if b := buf.Bytes(); b[buf.Len()-1] != '\n' { + buf.WriteRune('\n') + } + } + + buf.WriteTo(ctx.Writer) + + g := ctx.Indent() + return &markerg{ + indentg: g, + ctx: ctx, + f: f, + args: args, + start: time.Now(), + errptr: nil, + } +} + +func (g *markerg) BindError(errptr *error) *markerg { + if g.ctx == nil { + return g + } + g.ctx.mutex.Lock() + defer g.ctx.mutex.Unlock() + + g.errptr = errptr + return g +} + +func (g *markerg) End() { + if g.ctx == nil { + return + } + + g.indentg.End() // unindent + buf := &bytes.Buffer{} + g.ctx.preamble(buf) + fmt.Fprint(buf, "END ") + fmt.Fprintf(buf, g.f, g.args...) + fmt.Fprintf(buf, " (%s)", time.Since(g.start)) + if errptr := g.errptr; errptr != nil && *errptr != nil { + fmt.Fprintf(buf, ": ERROR: %s", *errptr) + } + + if buf.Len() > 0 { + if b := buf.Bytes(); b[buf.Len()-1] != '\n' { + buf.WriteRune('\n') + } + } + + buf.WriteTo(g.ctx.Writer) +} + +type legacyg struct { + guard + start time.Time +} + +var emptylegacyg = legacyg{} + +func (g legacyg) IRelease(f string, args ...interface{}) { + if !Trace { + return + } + g.End() + dur := time.Since(g.start) + Printf("%s (%s)", fmt.Sprintf(f, args...), dur) +} + +// IPrintf indents and then prints debug messages. Execute the callback +// to undo the indent +func IPrintf(f string, args ...interface{}) legacyg { + if !Trace { + return emptylegacyg + } + + DefaultCtx.Printf(f, args...) + g := legacyg{ + guard: DefaultCtx.Indent(), + start: time.Now(), + } + return g +} + +// Printf prints debug messages. Only available if compiled with "debug" tag +func Printf(f string, args ...interface{}) { + if !Trace { + return + } + DefaultCtx.Printf(f, args...) +} + +func Dump(v ...interface{}) { + if !Trace { + return + } + spew.Dump(v...) +} diff --git a/vendor/github.com/lestrrat-go/pdebug/debug_test.go b/vendor/github.com/lestrrat-go/pdebug/debug_test.go new file mode 100644 index 000000000000..7e1077ee7596 --- /dev/null +++ b/vendor/github.com/lestrrat-go/pdebug/debug_test.go @@ -0,0 +1,30 @@ +//+build debug,!debug0 + +package pdebug + +import ( + "os" + "strconv" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestDebugEnabled(t *testing.T) { + if !assert.True(t, Enabled, "Enable is true") { + return + } + + b, err := strconv.ParseBool(os.Getenv("PDEBUG_TRACE")) + if err == nil && b { + if !assert.True(t, Trace, "Trace is true") { + return + } + t.Logf("Trace is enabled") + } else { + if !assert.False(t, Trace, "Trace is false") { + return + } + t.Logf("Trace is disabled") + } +} \ No newline at end of file diff --git a/vendor/github.com/lestrrat-go/pdebug/doc.go b/vendor/github.com/lestrrat-go/pdebug/doc.go new file mode 100644 index 000000000000..d0566de384ab --- /dev/null +++ b/vendor/github.com/lestrrat-go/pdebug/doc.go @@ -0,0 +1,15 @@ +// Package pdebug provides tools to produce debug logs the way the author +// (Daisuke Maki a.k.a. lestrrat) likes. All of the functions are no-ops +// unless you compile with the `-tags debug` option. +// +// When you compile your program with `-tags debug`, no trace is displayed, +// but the code enclosed within `if pdebug.Enabled { ... }` is compiled in. +// To show the debug trace, set the PDEBUG_TRACE environment variable to +// true (or 1, or whatever `strconv.ParseBool` parses to true) +// +// If you want to show the debug trace regardless of an environment variable, +// for example, perhaps while you are debugging or running tests, use the +// `-tags debug0` build tag instead. This will enable the debug trace +// forcefully +package pdebug + diff --git a/vendor/github.com/lestrrat-go/pdebug/nodebug_test.go b/vendor/github.com/lestrrat-go/pdebug/nodebug_test.go new file mode 100644 index 000000000000..ae09c76fa85c --- /dev/null +++ b/vendor/github.com/lestrrat-go/pdebug/nodebug_test.go @@ -0,0 +1,14 @@ +//+build !debug,!debug0 + +package pdebug + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestDisabled(t *testing.T) { + assert.False(t, Enabled, "Enable is false") + assert.False(t, Trace, "Trace is false") +} \ No newline at end of file diff --git a/vendor/github.com/lestrrat-go/structinfo/.gitignore b/vendor/github.com/lestrrat-go/structinfo/.gitignore new file mode 100644 index 000000000000..daf913b1b347 --- /dev/null +++ b/vendor/github.com/lestrrat-go/structinfo/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/vendor/github.com/lestrrat-go/structinfo/.travis.yml b/vendor/github.com/lestrrat-go/structinfo/.travis.yml new file mode 100644 index 000000000000..5b800297f00e --- /dev/null +++ b/vendor/github.com/lestrrat-go/structinfo/.travis.yml @@ -0,0 +1,5 @@ +language: go +sudo: false +go: + - 1.5 + - tip diff --git a/vendor/github.com/lestrrat-go/structinfo/LICENSE b/vendor/github.com/lestrrat-go/structinfo/LICENSE new file mode 100644 index 000000000000..20054b15434d --- /dev/null +++ b/vendor/github.com/lestrrat-go/structinfo/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 lestrrat + +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/lestrrat-go/structinfo/README.md b/vendor/github.com/lestrrat-go/structinfo/README.md new file mode 100644 index 000000000000..fbf6c877d683 --- /dev/null +++ b/vendor/github.com/lestrrat-go/structinfo/README.md @@ -0,0 +1,7 @@ +# structinfo + +[![Build Status](https://travis-ci.org/lestrrat-go/structinfo.svg?branch=master)](https://travis-ci.org/lestrrat-go/structinfo) + +[![GoDoc](https://godoc.org/github.com/lestrrat-go/structinfo?status.svg)](https://godoc.org/github.com/lestrrat-go/structinfo) + +Tools to inspect Go structs diff --git a/vendor/github.com/lestrrat-go/structinfo/structinfo.go b/vendor/github.com/lestrrat-go/structinfo/structinfo.go new file mode 100644 index 000000000000..0a283ca88897 --- /dev/null +++ b/vendor/github.com/lestrrat-go/structinfo/structinfo.go @@ -0,0 +1,118 @@ +// Package structinfo contains tools to inspect structs. + +package structinfo + +import ( + "reflect" + "sync" +) + +type jsonFieldMap struct { + lock sync.Mutex + fields map[string]string +} + +var type2jfm = map[reflect.Type]jsonFieldMap{} +var type2jfmMutex = sync.Mutex{} + +// JSONFieldsFromStruct returns the names of JSON fields associated +// with the given struct. Returns nil if v is not a struct +func JSONFieldsFromStruct(v reflect.Value) []string { + if v.Kind() != reflect.Struct { + return nil + } + + m := getType2jfm(v.Type()) + m.lock.Lock() + defer m.lock.Unlock() + + l := make([]string, 0, len(m.fields)) + for k := range m.fields { + l = append(l, k) + } + return l +} + +// StructFieldFromJSONName returns the struct field name on the +// given struct value. Empty value means the field is either not +// public, or does not exist. +// +// This can be used to map JSON field names to actual struct fields. +func StructFieldFromJSONName(v reflect.Value, name string) string { + if v.Kind() != reflect.Struct { + return "" + } + + m := getType2jfm(v.Type()) + m.lock.Lock() + defer m.lock.Unlock() + + s, ok := m.fields[name] + if !ok { + return "" + } + return s +} + +func getType2jfm(t reflect.Type) jsonFieldMap { + type2jfmMutex.Lock() + defer type2jfmMutex.Unlock() + + return getType2jfm_nolock(t) +} + +func getType2jfm_nolock(t reflect.Type) jsonFieldMap { + fm, ok := type2jfm[t] + if ok { + return fm + } + + fm = constructJfm(t) + type2jfm[t] = fm + return fm +} + +func constructJfm(t reflect.Type) jsonFieldMap { + if t.Kind() == reflect.Ptr { + t = t.Elem() + } + + fm := jsonFieldMap{ + fields: make(map[string]string), + } + for i := 0; i < t.NumField(); i++ { + sf := t.Field(i) + if sf.Anonymous { // embedded! got to recurse + fm2 := getType2jfm_nolock(sf.Type) + for k, v := range fm2.fields { + fm.fields[k] = v + } + continue + } + + if sf.PkgPath != "" { // unexported + continue + } + + tag := sf.Tag.Get("json") + if tag == "-" { + continue + } + + if tag == "" || tag[0] == ',' { + fm.fields[sf.Name] = sf.Name + continue + } + + flen := 0 + for j := 0; j < len(tag); j++ { + if tag[j] == ',' { + break + } + flen = j + } + fm.fields[tag[:flen+1]] = sf.Name + } + + return fm +} \ No newline at end of file diff --git a/vendor/github.com/lestrrat-go/structinfo/structinfo_test.go b/vendor/github.com/lestrrat-go/structinfo/structinfo_test.go new file mode 100644 index 000000000000..980c2654b7c3 --- /dev/null +++ b/vendor/github.com/lestrrat-go/structinfo/structinfo_test.go @@ -0,0 +1,63 @@ +package structinfo_test + +import ( + "reflect" + "testing" + + "github.com/lestrrat-go/structinfo" + "github.com/stretchr/testify/assert" +) + +type Quux struct { + Baz string `json:"baz"` +} + +type X struct { + private int + Quux + Foo string `json:"foo"` + Bar string `json:"bar,omitempty"` +} + +func TestStructFields(t *testing.T) { + fields := make(map[string]struct{}) + for _, name := range structinfo.JSONFieldsFromStruct(reflect.ValueOf(X{})) { + fields[name] = struct{}{} + } + + expected := map[string]struct{}{ + "foo": {}, + "bar": {}, + "baz": {}, + } + + if !assert.Equal(t, expected, fields, "expected fields match") { + return + } +} + +func TestLookupSructFieldFromJSONName(t *testing.T) { + rv := reflect.ValueOf(X{}) + + data := map[string]string{ + "foo": "Foo", + "bar": "Bar", + "baz": "Baz", + } + + for jsname, fname := range data { + fn := structinfo.StructFieldFromJSONName(rv, jsname) + if !assert.NotEqual(t, fn, "", "should find '%s'", jsname) { + return + } + + sf, ok := rv.Type().FieldByName(fn) + if !assert.True(t, ok, "should be able resolve '%s' (%s)", jsname, fn) { + return + } + + if !assert.Equal(t, sf.Name, fname, "'%s' should map to '%s'", jsname, fname) { + return + } + } +} diff --git a/vendor/github.com/lestrrat/go-jspointer/.travis.yml b/vendor/github.com/lestrrat/go-jspointer/.travis.yml index 5b800297f00e..21e0a8e8d7c0 100644 --- a/vendor/github.com/lestrrat/go-jspointer/.travis.yml +++ b/vendor/github.com/lestrrat/go-jspointer/.travis.yml @@ -1,5 +1,5 @@ language: go sudo: false go: - - 1.5 + - 1.11 - tip diff --git a/vendor/github.com/lestrrat/go-jspointer/README.md b/vendor/github.com/lestrrat/go-jspointer/README.md index 8bce21bcaff3..e1a4fbcd01b0 100644 --- a/vendor/github.com/lestrrat/go-jspointer/README.md +++ b/vendor/github.com/lestrrat/go-jspointer/README.md @@ -1,8 +1,8 @@ # go-jspointer -[![Build Status](https://travis-ci.org/lestrrat/go-jspointer.svg?branch=master)](https://travis-ci.org/lestrrat/go-jspointer) +[![Build Status](https://travis-ci.org/lestrrat-go/jspointer.svg?branch=master)](https://travis-ci.org/lestrrat-go/jspointer) -[![GoDoc](https://godoc.org/github.com/lestrrat/go-jspointer?status.svg)](https://godoc.org/github.com/lestrrat/go-jspointer) +[![GoDoc](https://godoc.org/github.com/lestrrat-go/jspointer?status.svg)](https://godoc.org/github.com/lestrrat-go/jspointer) JSON pointer for Go @@ -26,9 +26,9 @@ This is almost a fork of https://github.com/xeipuuv/gojsonpointer. | Name | Notes | |:--------------------------------------------------------:|:---------------------------------| -| [go-jsval](https://github.com/lestrrat/go-jsval) | Validator generator | -| [go-jsschema](https://github.com/lestrrat/go-jsschema) | JSON Schema implementation | -| [go-jshschema](https://github.com/lestrrat/go-jshschema) | JSON Hyper Schema implementation | -| [go-jsref](https://github.com/lestrrat/go-jsref) | JSON Reference implementation | +| [go-jsval](https://github.com/lestrrat-go/jsval) | Validator generator | +| [go-jsschema](https://github.com/lestrrat-go/jsschema) | JSON Schema implementation | +| [go-jshschema](https://github.com/lestrrat-go/jshschema) | JSON Hyper Schema implementation | +| [go-jsref](https://github.com/lestrrat-go/jsref) | JSON Reference implementation | diff --git a/vendor/github.com/lestrrat/go-jspointer/bench/bench_test.go b/vendor/github.com/lestrrat/go-jspointer/bench/bench_test.go index c0350b280b93..3ffe29fb4ded 100644 --- a/vendor/github.com/lestrrat/go-jspointer/bench/bench_test.go +++ b/vendor/github.com/lestrrat/go-jspointer/bench/bench_test.go @@ -6,7 +6,7 @@ import ( "encoding/json" "testing" - "github.com/lestrrat/go-jspointer" + "github.com/lestrrat-go/jspointer" "github.com/xeipuuv/gojsonpointer" ) diff --git a/vendor/github.com/lestrrat/go-jspointer/interface.go b/vendor/github.com/lestrrat/go-jspointer/interface.go index 1e83d599556e..7fe800233bb2 100644 --- a/vendor/github.com/lestrrat/go-jspointer/interface.go +++ b/vendor/github.com/lestrrat/go-jspointer/interface.go @@ -23,5 +23,5 @@ type ErrNotFound struct { // JSPointer represents a JSON pointer type JSPointer struct { raw string - tokens []string + tokens tokens } diff --git a/vendor/github.com/lestrrat/go-jspointer/jspointer.go b/vendor/github.com/lestrrat/go-jspointer/jspointer.go index 1c1f88fd2a53..c42b9613f9a3 100644 --- a/vendor/github.com/lestrrat/go-jspointer/jspointer.go +++ b/vendor/github.com/lestrrat/go-jspointer/jspointer.go @@ -1,79 +1,96 @@ package jspointer import ( + "bytes" "encoding/json" "errors" "reflect" "strconv" - "strings" - "sync" - "github.com/lestrrat/go-structinfo" + "github.com/lestrrat-go/structinfo" ) -var ctxPool = sync.Pool{ - New: moreCtx, +type tokens struct { + s string + positions [][2]int } -func moreCtx() interface{} { - return &matchCtx{} +func (t *tokens) size() int { + return len(t.positions) } -func getCtx() *matchCtx { - return ctxPool.Get().(*matchCtx) -} - -func releaseCtx(ctx *matchCtx) { - ctx.err = nil - ctx.set = false - ctx.tokens = nil - ctx.result = nil - ctxPool.Put(ctx) +func (t *tokens) get(i int) string { + p := t.positions[i] + return t.s[p[0]:p[1]] } // New creates a new JSON pointer for given path spec. If the path fails // to be parsed, an error is returned func New(path string) (*JSPointer, error) { var p JSPointer - dtokens, err := parse(path) - if err != nil { + + if err := p.parse(path); err != nil { return nil, err } p.raw = path - p.tokens = dtokens return &p, nil } -func parse(s string) ([]string, error) { +func (p *JSPointer) parse(s string) error { if s == "" { - return nil, nil + return nil } if s[0] != Separator { - return nil, ErrInvalidPointer + return ErrInvalidPointer } - prev := 0 - tokens := []string{} + if len(s) < 2 { + return ErrInvalidPointer + } + + ntokens := 0 + for i := 0; i < len(s); i++ { + if s[i] == '/' { + ntokens++ + } + } + + positions := make([][2]int, 0, ntokens) + start := 1 + var buf bytes.Buffer + buf.WriteByte(s[0]) for i := 1; i < len(s); i++ { switch s[i] { case Separator: - tokens = append(tokens, s[prev+1:i]) - prev = i + buf.WriteByte(s[i]) + positions = append(positions, [2]int{start, buf.Len() - 1}) + start = i + 1 + case '~': + if len(s) == 1 { + buf.WriteByte(s[i]) + } else { + switch s[1] { + case '0': + buf.WriteByte('~') + case '1': + buf.WriteByte('/') + default: + buf.WriteByte(s[i]) + } + } + default: + buf.WriteByte(s[i]) } } - if prev != len(s) { - tokens = append(tokens, s[prev+1:]) - } - - dtokens := make([]string, 0, len(tokens)) - for _, t := range tokens { - t = strings.Replace(strings.Replace(t, EncodedSlash, "/", -1), EncodedTilde, "~", -1) - dtokens = append(dtokens, t) + if start < buf.Len() { + positions = append(positions, [2]int{start, buf.Len()}) } - return dtokens, nil + p.tokens.s = buf.String() + p.tokens.positions = positions + return nil } // String returns the stringified version of this JSON pointer @@ -84,11 +101,10 @@ func (p JSPointer) String() string { // Get applies the JSON pointer to the given item, and returns // the result. func (p JSPointer) Get(item interface{}) (interface{}, error) { - ctx := getCtx() - defer releaseCtx(ctx) + var ctx matchCtx ctx.raw = p.raw - ctx.tokens = p.tokens + ctx.tokens = &p.tokens ctx.apply(item) return ctx.result, ctx.err } @@ -96,12 +112,11 @@ func (p JSPointer) Get(item interface{}) (interface{}, error) { // Set applies the JSON pointer to the given item, and sets the // value accordingly. func (p JSPointer) Set(item interface{}, value interface{}) error { - ctx := getCtx() - defer releaseCtx(ctx) + var ctx matchCtx ctx.set = true ctx.raw = p.raw - ctx.tokens = p.tokens + ctx.tokens = &p.tokens ctx.setvalue = value ctx.apply(item) return ctx.err @@ -113,25 +128,48 @@ type matchCtx struct { result interface{} set bool setvalue interface{} - tokens []string + tokens *tokens } func (e ErrNotFound) Error() string { return "match to JSON pointer not found: " + e.Ptr } +type JSONGetter interface { + JSONGet(tok string) (interface{}, error) +} + var strType = reflect.TypeOf("") +var zeroval reflect.Value func (c *matchCtx) apply(item interface{}) { - if len(c.tokens) == 0 { + if c.tokens.size() == 0 { c.result = item return } - lastidx := len(c.tokens) - 1 node := item - for tidx, token := range c.tokens { + lastidx := c.tokens.size() - 1 + for i := 0; i < c.tokens.size(); i++ { + token := c.tokens.get(i) + + if getter, ok := node.(JSONGetter); ok { + x, err := getter.JSONGet(token) + if err != nil { + c.err = ErrNotFound{Ptr: c.raw} + return + } + if i == lastidx { + c.result = x + return + } + node = x + continue + } v := reflect.ValueOf(node) + + // Does this thing implement a JSONGet? + if v.Kind() == reflect.Ptr { v = v.Elem() } @@ -144,7 +182,7 @@ func (c *matchCtx) apply(item interface{}) { return } f := v.FieldByName(fn) - if tidx == lastidx { + if i == lastidx { if c.set { if !f.CanSet() { c.err = ErrCanNotSet @@ -176,12 +214,12 @@ func (c *matchCtx) apply(item interface{}) { vt = reflect.ValueOf(token) } n := v.MapIndex(vt) - if (reflect.Value{}) == n { + if zeroval == n { c.err = ErrNotFound{Ptr: c.raw} return } - if tidx == lastidx { + if i == lastidx { if c.set { v.SetMapIndex(vt, reflect.ValueOf(c.setvalue)) } else { @@ -204,7 +242,7 @@ func (c *matchCtx) apply(item interface{}) { return } - if tidx == lastidx { + if i == lastidx { if c.set { m[wantidx] = c.setvalue } else { diff --git a/vendor/github.com/lestrrat/go-jspointer/jspointer_test.go b/vendor/github.com/lestrrat/go-jspointer/jspointer_test.go index 388c76261ee6..50ba8e610d29 100644 --- a/vendor/github.com/lestrrat/go-jspointer/jspointer_test.go +++ b/vendor/github.com/lestrrat/go-jspointer/jspointer_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/lestrrat/go-jspointer" + "github.com/lestrrat-go/jspointer" "github.com/stretchr/testify/assert" ) diff --git a/vendor/github.com/lestrrat/go-jsschema/.travis.yml b/vendor/github.com/lestrrat/go-jsschema/.travis.yml index ad9a6993d127..a20c62692f00 100644 --- a/vendor/github.com/lestrrat/go-jsschema/.travis.yml +++ b/vendor/github.com/lestrrat/go-jsschema/.travis.yml @@ -1,7 +1,7 @@ language: go sudo: false go: - - 1.7 + - 1.11.x - tip script: - go test -v ./... diff --git a/vendor/github.com/lestrrat/go-jsschema/README.md b/vendor/github.com/lestrrat/go-jsschema/README.md index c3f78a31e776..79031957e1dd 100644 --- a/vendor/github.com/lestrrat/go-jsschema/README.md +++ b/vendor/github.com/lestrrat/go-jsschema/README.md @@ -1,8 +1,8 @@ # go-jsschema -[![Build Status](https://travis-ci.org/lestrrat/go-jsschema.svg?branch=master)](https://travis-ci.org/lestrrat/go-jsschema) +[![Build Status](https://travis-ci.org/lestrrat-go/jsschema.svg?branch=master)](https://travis-ci.org/lestrrat-go/jsschema) -[![GoDoc](https://godoc.org/github.com/lestrrat/go-jsschema?status.svg)](https://godoc.org/github.com/lestrrat/go-jsschema) +[![GoDoc](https://godoc.org/github.com/lestrrat-go/jsschema?status.svg)](https://godoc.org/github.com/lestrrat-go/jsschema) JSON Schema for Go @@ -14,8 +14,8 @@ package schema_test import ( "log" - "github.com/lestrrat/go-jsschema" - "github.com/lestrrat/go-jsschema/validator" + "github.com/lestrrat-go/jsschema" + "github.com/lestrrat-go/jsschema/validator" ) func Example() { @@ -47,13 +47,13 @@ This packages parses a JSON Schema file, and allows you to inspect, modify the schema, but does nothing more. If you want to validate using the JSON Schema that you read using this package, -look at [go-jsval](https://github.com/lestrrat/go-jsval), which allows you to +look at [go-jsval](https://github.com/lestrrat-go/jsval), which allows you to generate validators, so that you don't have to dynamically read in the JSON schema for each instance of your program. In the same lines, this package does not really care about loading external schemas from various locations (it's just easier to just gather all the schemas -in your local system). It *is* possible to do this via [go-jsref](https://github.com/lestrrat/go-jsref) +in your local system). It *is* possible to do this via [go-jsref](https://github.com/lestrrat-go/jsref) if you really want to do it. # BENCHMARKS @@ -86,7 +86,7 @@ PASS | Name | Notes | |:--------------------------------------------------------:|:---------------------------------| -| [go-jsval](https://github.com/lestrrat/go-jsval) | Validator generator | -| [go-jshschema](https://github.com/lestrrat/go-jshschema) | JSON Hyper Schema implementation | -| [go-jsref](https://github.com/lestrrat/go-jsref) | JSON Reference implementation | -| [go-jspointer](https://github.com/lestrrat/go-jspointer) | JSON Pointer implementations | +| [go-jsval](https://github.com/lestrrat-go/jsval) | Validator generator | +| [go-jshschema](https://github.com/lestrrat-go/jshschema) | JSON Hyper Schema implementation | +| [go-jsref](https://github.com/lestrrat-go/jsref) | JSON Reference implementation | +| [go-jspointer](https://github.com/lestrrat-go/jspointer) | JSON Pointer implementations | diff --git a/vendor/github.com/lestrrat/go-jsschema/benchmark_test.go b/vendor/github.com/lestrrat/go-jsschema/benchmark_test.go index a774668f870a..df973b226d86 100644 --- a/vendor/github.com/lestrrat/go-jsschema/benchmark_test.go +++ b/vendor/github.com/lestrrat/go-jsschema/benchmark_test.go @@ -6,8 +6,8 @@ import ( "strings" "testing" - schema "github.com/lestrrat/go-jsschema" - "github.com/lestrrat/go-jsschema/validator" + schema "github.com/lestrrat-go/jsschema" + "github.com/lestrrat-go/jsschema/validator" "github.com/xeipuuv/gojsonschema" ) diff --git a/vendor/github.com/lestrrat/go-jsschema/cmd/jsschema/jsschema.go b/vendor/github.com/lestrrat/go-jsschema/cmd/jsschema/jsschema.go index e31a94aa335c..d1e39f97388f 100644 --- a/vendor/github.com/lestrrat/go-jsschema/cmd/jsschema/jsschema.go +++ b/vendor/github.com/lestrrat/go-jsschema/cmd/jsschema/jsschema.go @@ -7,8 +7,8 @@ import ( "log" "os" - "github.com/lestrrat/go-jsschema" - "github.com/lestrrat/go-jsschema/validator" + "github.com/lestrrat-go/jsschema" + "github.com/lestrrat-go/jsschema/validator" ) func main() { diff --git a/vendor/github.com/lestrrat/go-jsschema/interface.go b/vendor/github.com/lestrrat/go-jsschema/interface.go index 416cfa7a7b09..d47412b31531 100644 --- a/vendor/github.com/lestrrat/go-jsschema/interface.go +++ b/vendor/github.com/lestrrat/go-jsschema/interface.go @@ -5,7 +5,7 @@ import ( "regexp" "sync" - "github.com/lestrrat/go-jsref" + "github.com/lestrrat-go/jsref" ) const ( diff --git a/vendor/github.com/lestrrat/go-jsschema/marshal.go b/vendor/github.com/lestrrat/go-jsschema/marshal.go index b08bc1c7d618..7a409cfb58e1 100644 --- a/vendor/github.com/lestrrat/go-jsschema/marshal.go +++ b/vendor/github.com/lestrrat/go-jsschema/marshal.go @@ -5,7 +5,7 @@ import ( "regexp" "strconv" - "github.com/lestrrat/go-pdebug" + "github.com/lestrrat-go/pdebug" "github.com/pkg/errors" ) diff --git a/vendor/github.com/lestrrat/go-jsschema/marshal_test.go b/vendor/github.com/lestrrat/go-jsschema/marshal_test.go index fc811d131711..584928bfed30 100644 --- a/vendor/github.com/lestrrat/go-jsschema/marshal_test.go +++ b/vendor/github.com/lestrrat/go-jsschema/marshal_test.go @@ -5,8 +5,8 @@ import ( "strings" "testing" - "github.com/lestrrat/go-jsschema" - "github.com/lestrrat/go-jsschema/validator" + "github.com/lestrrat-go/jsschema" + "github.com/lestrrat-go/jsschema/validator" "github.com/stretchr/testify/assert" ) diff --git a/vendor/github.com/lestrrat/go-jsschema/schema.go b/vendor/github.com/lestrrat/go-jsschema/schema.go index 8d2b2f9f7f37..706ed7091292 100644 --- a/vendor/github.com/lestrrat/go-jsschema/schema.go +++ b/vendor/github.com/lestrrat/go-jsschema/schema.go @@ -8,9 +8,9 @@ import ( "reflect" "strconv" - "github.com/lestrrat/go-jsref" - "github.com/lestrrat/go-jsref/provider" - "github.com/lestrrat/go-pdebug" + "github.com/lestrrat-go/jsref" + "github.com/lestrrat-go/jsref/provider" + "github.com/lestrrat-go/pdebug" "github.com/pkg/errors" ) diff --git a/vendor/github.com/lestrrat/go-jsschema/schema_example_test.go b/vendor/github.com/lestrrat/go-jsschema/schema_example_test.go index 9f69f228035a..cd1dab975a18 100644 --- a/vendor/github.com/lestrrat/go-jsschema/schema_example_test.go +++ b/vendor/github.com/lestrrat/go-jsschema/schema_example_test.go @@ -3,8 +3,8 @@ package schema_test import ( "log" - "github.com/lestrrat/go-jsschema" - "github.com/lestrrat/go-jsschema/validator" + "github.com/lestrrat-go/jsschema" + "github.com/lestrrat-go/jsschema/validator" ) func Example() { diff --git a/vendor/github.com/lestrrat/go-jsschema/schema_test.go b/vendor/github.com/lestrrat/go-jsschema/schema_test.go index 8c55f728f739..499e8d11b26d 100644 --- a/vendor/github.com/lestrrat/go-jsschema/schema_test.go +++ b/vendor/github.com/lestrrat/go-jsschema/schema_test.go @@ -8,8 +8,8 @@ import ( "strings" "testing" - "github.com/lestrrat/go-jsschema" - "github.com/lestrrat/go-jsschema/validator" + "github.com/lestrrat-go/jsschema" + "github.com/lestrrat-go/jsschema/validator" "github.com/stretchr/testify/assert" ) diff --git a/vendor/github.com/lestrrat/go-jsschema/validator/validator.go b/vendor/github.com/lestrrat/go-jsschema/validator/validator.go index b1930617733d..365f01427593 100644 --- a/vendor/github.com/lestrrat/go-jsschema/validator/validator.go +++ b/vendor/github.com/lestrrat/go-jsschema/validator/validator.go @@ -3,9 +3,9 @@ package validator import ( "sync" - "github.com/lestrrat/go-jsschema" - "github.com/lestrrat/go-jsval" - "github.com/lestrrat/go-jsval/builder" + "github.com/lestrrat-go/jsschema" + "github.com/lestrrat-go/jsval" + "github.com/lestrrat-go/jsval/builder" "github.com/pkg/errors" ) diff --git a/vendor/github.com/opencontainers/runc/libcontainer/cgroups/systemd/apply_systemd.go b/vendor/github.com/opencontainers/runc/libcontainer/cgroups/systemd/apply_systemd.go index 0c625ba34166..64ca8097bd83 100644 --- a/vendor/github.com/opencontainers/runc/libcontainer/cgroups/systemd/apply_systemd.go +++ b/vendor/github.com/opencontainers/runc/libcontainer/cgroups/systemd/apply_systemd.go @@ -77,7 +77,6 @@ var ( hasStartTransientSliceUnit bool hasTransientDefaultDependencies bool hasDelegateScope bool - hasDelegateSlice bool ) func newProp(name string, units interface{}) systemdDbus.Property { @@ -192,19 +191,6 @@ func UseSystemd() bool { // Not critical because of the stop unit logic above. theConn.StopUnit(slice, "replace", nil) - // Assume StartTransientUnit on a slice allows Delegate - hasDelegateSlice = true - dlSlice := newProp("Delegate", true) - if _, err := theConn.StartTransientUnit(slice, "replace", []systemdDbus.Property{dlSlice}, nil); err != nil { - if dbusError, ok := err.(dbus.Error); ok { - // Starting with systemd v237, Delegate is not even a property of slices anymore, - // so the D-Bus call fails with "InvalidArgs" error. - if strings.Contains(dbusError.Name, "org.freedesktop.DBus.Error.PropertyReadOnly") || strings.Contains(dbusError.Name, "org.freedesktop.DBus.Error.InvalidArgs") { - hasDelegateSlice = false - } - } - } - // Not critical because of the stop unit logic above. theConn.StopUnit(scope, "replace", nil) theConn.StopUnit(slice, "replace", nil) @@ -261,12 +247,7 @@ func (m *Manager) Apply(pid int) error { } // Check if we can delegate. This is only supported on systemd versions 218 and above. - if strings.HasSuffix(unitName, ".slice") { - if hasDelegateSlice { - // systemd 237 and above no longer allows delegation on a slice - properties = append(properties, newProp("Delegate", true)) - } - } else { + if !strings.HasSuffix(unitName, ".slice") { if hasDelegateScope { properties = append(properties, newProp("Delegate", true)) } diff --git a/vendor/github.com/openshift/api/config/v1/types_network.go b/vendor/github.com/openshift/api/config/v1/types_network.go index 615a6a0d22c0..42ec977fd0de 100644 --- a/vendor/github.com/openshift/api/config/v1/types_network.go +++ b/vendor/github.com/openshift/api/config/v1/types_network.go @@ -6,8 +6,8 @@ import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" // +genclient:nonNamespaced // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// Network holds cluster-wide information about Network. The canonical name is `cluster`. It is used to configure the desired network configuration, such as: IP address pools for services/pod IPs, network plugin, etc. -// Please view network.spec for an explanation on what applies when configuring this resource. +// Network holds cluster-wide information about Network. The canonical name is `cluster`. It is used to configure the desired network configuration, such as: IP address pools for services/pod IPs, network plugin, etc. +// Please view network.spec for an explanation on what applies when configuring this resource. type Network struct { metav1.TypeMeta `json:",inline"` // Standard object's metadata. @@ -30,13 +30,13 @@ type Network struct { // consume the NetworkStatus, as it indicates the currently deployed configuration. // Currently, most spec fields are immutable after installation. Please view the individual ones for further details on each. type NetworkSpec struct { - // IP address pool to use for pod IPs. - // This field is immutable after installation. + // IP address pool to use for pod IPs. + // This field is immutable after installation. ClusterNetwork []ClusterNetworkEntry `json:"clusterNetwork"` // IP address pool for services. // Currently, we only support a single entry here. - // This field is immutable after installation. + // This field is immutable after installation. ServiceNetwork []string `json:"serviceNetwork"` // NetworkType is the plugin that is to be deployed (e.g. OpenShiftSDN). @@ -44,11 +44,12 @@ type NetworkSpec struct { // or else no networking will be installed. // Currently supported values are: // - OpenShiftSDN - // This field is immutable after installation. + // This field is immutable after installation. NetworkType string `json:"networkType"` // externalIP defines configuration for controllers that - // affect Service.ExternalIP + // affect Service.ExternalIP. If nil, then ExternalIP is + // not allowed to be set. // +optional ExternalIP *ExternalIPConfig `json:"externalIP,omitempty"` } @@ -83,8 +84,7 @@ type ClusterNetworkEntry struct { // of a Service resource. type ExternalIPConfig struct { // policy is a set of restrictions applied to the ExternalIP field. - // If nil, any value is allowed for an ExternalIP. If the empty/zero - // policy is supplied, then ExternalIP is not allowed to be set. + // If nil or empty, then ExternalIP is not allowed to be set. // +optional Policy *ExternalIPPolicy `json:"policy,omitempty"` 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 14eab8754ab6..7e0abdd9b656 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 @@ -866,7 +866,7 @@ func (ClusterNetworkEntry) SwaggerDoc() map[string]string { var map_ExternalIPConfig = map[string]string{ "": "ExternalIPConfig specifies some IP blocks relevant for the ExternalIP field of a Service resource.", - "policy": "policy is a set of restrictions applied to the ExternalIP field. If nil, any value is allowed for an ExternalIP. If the empty/zero policy is supplied, then ExternalIP is not allowed to be set.", + "policy": "policy is a set of restrictions applied to the ExternalIP field. If nil or empty, then ExternalIP is not allowed to be set.", "autoAssignCIDRs": "autoAssignCIDRs is a list of CIDRs from which to automatically assign Service.ExternalIP. These are assigned when the service is of type LoadBalancer. In general, this is only useful for bare-metal clusters. In Openshift 3.x, this was misleadingly called \"IngressIPs\". Automatically assigned External IPs are not affected by any ExternalIPPolicy rules. Currently, only one entry may be provided.", } @@ -908,7 +908,7 @@ var map_NetworkSpec = map[string]string{ "clusterNetwork": "IP address pool to use for pod IPs. This field is immutable after installation.", "serviceNetwork": "IP address pool for services. Currently, we only support a single entry here. This field is immutable after installation.", "networkType": "NetworkType is the plugin that is to be deployed (e.g. OpenShiftSDN). This should match a value that the cluster-network-operator understands, or else no networking will be installed. Currently supported values are: - OpenShiftSDN This field is immutable after installation.", - "externalIP": "externalIP defines configuration for controllers that affect Service.ExternalIP", + "externalIP": "externalIP defines configuration for controllers that affect Service.ExternalIP. If nil, then ExternalIP is not allowed to be set.", } func (NetworkSpec) SwaggerDoc() map[string]string { diff --git a/vendor/github.com/openshift/api/console/v1/register.go b/vendor/github.com/openshift/api/console/v1/register.go index 7b6e1e0b69f0..98363daa3ea2 100644 --- a/vendor/github.com/openshift/api/console/v1/register.go +++ b/vendor/github.com/openshift/api/console/v1/register.go @@ -32,9 +32,13 @@ func Resource(resource string) schema.GroupResource { func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(GroupVersion, &ConsoleLink{}, + &ConsoleLinkList{}, &ConsoleCLIDownload{}, + &ConsoleCLIDownloadList{}, &ConsoleNotification{}, + &ConsoleNotificationList{}, &ConsoleExternalLogLink{}, + &ConsoleExternalLogLinkList{}, ) metav1.AddToGroupVersion(scheme, GroupVersion) return nil diff --git a/vendor/github.com/openshift/api/console/v1/types_console_external_log_links.go b/vendor/github.com/openshift/api/console/v1/types_console_external_log_links.go index b6a1033d2642..c9c3317d510e 100644 --- a/vendor/github.com/openshift/api/console/v1/types_console_external_log_links.go +++ b/vendor/github.com/openshift/api/console/v1/types_console_external_log_links.go @@ -41,3 +41,12 @@ type ConsoleExternalLogLinkSpec struct { // + optional NamespaceFilter string `json:"namespaceFilter,omitempty"` } + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type ConsoleExternalLogLinkList struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + metav1.ListMeta `json:"metadata"` + Items []ConsoleExternalLogLink `json:"items"` +} diff --git a/vendor/github.com/openshift/api/console/v1/zz_generated.deepcopy.go b/vendor/github.com/openshift/api/console/v1/zz_generated.deepcopy.go index d61cfcd55d64..8c1b2694a66d 100644 --- a/vendor/github.com/openshift/api/console/v1/zz_generated.deepcopy.go +++ b/vendor/github.com/openshift/api/console/v1/zz_generated.deepcopy.go @@ -132,6 +132,39 @@ func (in *ConsoleExternalLogLink) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConsoleExternalLogLinkList) DeepCopyInto(out *ConsoleExternalLogLinkList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ConsoleExternalLogLink, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConsoleExternalLogLinkList. +func (in *ConsoleExternalLogLinkList) DeepCopy() *ConsoleExternalLogLinkList { + if in == nil { + return nil + } + out := new(ConsoleExternalLogLinkList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ConsoleExternalLogLinkList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ConsoleExternalLogLinkSpec) DeepCopyInto(out *ConsoleExternalLogLinkSpec) { *out = *in diff --git a/vendor/github.com/openshift/api/console/v1/zz_generated.swagger_doc_generated.go b/vendor/github.com/openshift/api/console/v1/zz_generated.swagger_doc_generated.go index 3e65772c7c94..4dbec77d0479 100644 --- a/vendor/github.com/openshift/api/console/v1/zz_generated.swagger_doc_generated.go +++ b/vendor/github.com/openshift/api/console/v1/zz_generated.swagger_doc_generated.go @@ -58,6 +58,14 @@ func (ConsoleExternalLogLink) SwaggerDoc() map[string]string { return map_ConsoleExternalLogLink } +var map_ConsoleExternalLogLinkList = map[string]string{ + "metadata": "Standard object's metadata.", +} + +func (ConsoleExternalLogLinkList) SwaggerDoc() map[string]string { + return map_ConsoleExternalLogLinkList +} + var map_ConsoleExternalLogLinkSpec = map[string]string{ "": "ConsoleExternalLogLinkSpec is the desired log link configuration. The log link will appear on the logs tab of the pod details page.", "text": "text is the display text for the link", diff --git a/vendor/github.com/openshift/api/operator/v1/types_ingress.go b/vendor/github.com/openshift/api/operator/v1/types_ingress.go index f5fa81ce852a..9223d55939e7 100644 --- a/vendor/github.com/openshift/api/operator/v1/types_ingress.go +++ b/vendor/github.com/openshift/api/operator/v1/types_ingress.go @@ -10,7 +10,7 @@ import ( // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +kubebuilder:object:root=true // +kubebuilder:subresource:status -// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.availableReplicas,selectorpath=.status.labelSelector +// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.availableReplicas,selectorpath=.status.selector // IngressController describes a managed ingress controller for the cluster. The // controller can service OpenShift Route and Kubernetes Ingress resources. diff --git a/vendor/github.com/openshift/api/route/v1/types.go b/vendor/github.com/openshift/api/route/v1/types.go index 768a8dee8f48..4ea1881950e6 100644 --- a/vendor/github.com/openshift/api/route/v1/types.go +++ b/vendor/github.com/openshift/api/route/v1/types.go @@ -84,7 +84,7 @@ type RouteSpec struct { // `apps.mycluster.com` to have a full hostname `frontend.apps.mycluster.com`. // // +optional - Subdomain string `json:"subdomain" protobuf:"bytes,8,opt,name=subdomain"` + Subdomain string `json:"subdomain,omitempty" protobuf:"bytes,8,opt,name=subdomain"` // path that the router watches for, to route traffic for to the service. Optional Path string `json:"path,omitempty" protobuf:"bytes,2,opt,name=path"` diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/Makefile b/vendor/github.com/openshift/library-go/alpha-build-machinery/Makefile index c9456fe64443..2ec73b08756c 100644 --- a/vendor/github.com/openshift/library-go/alpha-build-machinery/Makefile +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/Makefile @@ -11,11 +11,19 @@ examples :=$(wildcard ./make/examples/*/Makefile.test) # We need to change dir to the final makefile directory or relative paths won't match. # Dynamic values are replaced with "" so we can do diff against checkout versions. # Avoid comparing local paths by stripping the prefix. +# Delete lines referencing temporary files and directories +# Unify make error output between versions +# Ignore old cp errors on centos7 define update-makefile-log mkdir -p "$(3)" set -o pipefail; $(MAKE) -j 1 -C "$(dir $(1))" -f "$(notdir $(1))" --no-print-directory --warn-undefined-variables $(2) 2>&1 | \ sed 's/\.\(buildDate\|versionFromGit\|commitFromGit\|gitTreeState\)="[^"]*" /.\1="" /g' | \ sed -E 's~/.*/(github.com/openshift/library-go/alpha-build-machinery/.*)~/\1~g' | \ + sed '/\/tmp\/tmp./d' | \ + sed '/git checkout -b/d' | \ + sed -E 's~^[<> ]*((\+\+\+|\-\-\-) \./(testing/)?manifests/.*.yaml).*~\1~' | \ + sed -E 's/^(make\[2\]: \*\*\* \[).*: (.*\] Error 1)/\1\2/' | \ + grep -v 'are the same file' | \ tee "$(3)"/"$(notdir $(1))"$(subst ..,.,.$(2).log) endef diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/Makefile b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/Makefile index cf44849eef57..3ede7702efa2 100644 --- a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/Makefile +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/Makefile @@ -1,8 +1,13 @@ include $(addprefix ../../, \ golang.mk \ targets/openshift/rpm.mk \ + targets/openshift/crd-schema-gen.mk \ ) +# Set crd-schema-gen variables +CRD_SCHEMA_GEN_APIS :=$(addprefix ./pkg/apis/,v1 v1beta1) +CRD_SCHEMA_GEN_VERSION :=v0.2.1 + # rpm wants build-id set GO_LD_EXTRAFLAGS +=-B 0x$$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/Makefile.test b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/Makefile.test index f933ce024433..4d4754a63fd3 100644 --- a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/Makefile.test +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/Makefile.test @@ -1,22 +1,22 @@ SHELL :=/bin/bash -euo pipefail -test: | test-build test-cross-build test-rpm +test: | test-build test-cross-build test-rpm test-codegen .PHONY: test test-build: - $(MAKE) build + $(MAKE) build SOURCE_GIT_TAG=v42.43.44 SOURCE_GIT_COMMIT=aaa SOURCE_GIT_TREE_STATE=clean [[ -f ./openshift ]] [[ -f ./oc ]] # test version is set correctly when linking # majorFromGit, minorFromGit are deprecated upstream and set to empty value # we avoid comparing time to avoid flakes - # we avoid comparing git tree state - diff <( ./oc | grep -v -e 'clean' -e 'dirty' | sed '$$d' ) <( \ - echo ""; \ - echo ""; \ - git rev-parse --short "HEAD^{commit}" 2>/dev/null; \ - git describe --long --tags --abbrev=7 --match 'v[0-9]*' || echo 'v0.0.0-unknown'; \ + diff <( ./oc | sed '$$d' ) <( \ + echo '' && \ + echo '' && \ + echo 'aaa' && \ + echo 'v42.43.44' && \ + echo 'clean' \ ) $(MAKE) clean @@ -26,7 +26,7 @@ test-build: .PHONY: test-build test-cross-build: - [[ ! -d ./_output/ ]] + [[ ! -d ./_output/ ]] || (ls -l ./_output/ && false) $(MAKE) cross-build [[ ! -f ./openshift ]] [[ ! -f ./oc ]] @@ -36,18 +36,33 @@ test-cross-build: [[ -f ./_output/bin/windows_amd64/oc.exe ]] $(MAKE) clean - [[ ! -d ./_output/ ]] + [[ ! -d ./_output/ ]] || (ls -l ./_output/ && false) $(MAKE) clean .PHONY: test-cross-build test-rpm: - [[ ! -d ./_output/ ]] + [[ ! -d ./_output/ ]] || (ls -l ./_output/ && false) $(MAKE) rpm-build [[ -f ./_output/rpms/x86_64/openshift-2.42.0-6.el7.x86_64.rpm ]] [[ -f ./_output/srpms/openshift-2.42.0-6.el7.src.rpm ]] $(MAKE) clean - [[ ! -d ./_output/ ]] + [[ ! -d ./_output/ ]] || (ls -l ./_output/ && false) $(MAKE) clean .PHONY: test-rpm + +test-codegen: + cp -r ./testing/manifests/initial/* ./manifests/ + diff -Naup ./testing/manifests/initial/ ./manifests/ + ! $(MAKE) verify-codegen-crds + + $(MAKE) update-codegen-crds + $(MAKE) verify-codegen-crds + ! diff -Naup ./testing/manifests/initial/ ./manifests/ 2>/dev/null + diff -Naup ./testing/manifests/updated/ ./manifests/ 2>/dev/null + + $(MAKE) clean + [[ ! -d ./_output/ ]] || (ls -l ./_output/ && false) + $(MAKE) clean +.PHONY: test-codegen diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/Makefile.test.log b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/Makefile.test.log index e5acf191f45d..22359adfbdea 100644 --- a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/Makefile.test.log +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/Makefile.test.log @@ -1,6 +1,4 @@ -make build -fatal: No names found, cannot describe anything. -fatal: No names found, cannot describe anything. +make build SOURCE_GIT_TAG=v42.43.44 SOURCE_GIT_COMMIT=aaa SOURCE_GIT_TREE_STATE=clean go build -ldflags "-s -w -X github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/version.versionFromGit="" -X github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/version.commitFromGit="" -X github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/version.gitTreeState="" -X github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/version.buildDate="" -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n')" github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/cmd/oc go build -ldflags "-s -w -X github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/version.versionFromGit="" -X github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/version.commitFromGit="" -X github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/version.gitTreeState="" -X github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/version.buildDate="" -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n')" github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/cmd/openshift [[ -f ./openshift ]] @@ -8,18 +6,23 @@ go build -ldflags "-s -w -X github.com/openshift/library-go/alpha-build-machiner # test version is set correctly when linking # majorFromGit, minorFromGit are deprecated upstream and set to empty value # we avoid comparing time to avoid flakes -# we avoid comparing git tree state -diff <( ./oc | grep -v -e 'clean' -e 'dirty' | sed '$d' ) <( \ - echo ""; \ - echo ""; \ - git rev-parse --short "HEAD^{commit}" 2>/dev/null; \ - git describe --long --tags --abbrev=7 --match 'v[0-9]*' || echo 'v0.0.0-unknown'; \ +diff <( ./oc | sed '$d' ) <( \ + echo '' && \ + echo '' && \ + echo 'aaa' && \ + echo 'v42.43.44' && \ + echo 'clean' \ ) -fatal: No names found, cannot describe anything. make clean rm -f oc openshift rm -f -r '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/srpms' if [ -d '_output' ]; then rmdir --ignore-fail-on-non-empty '_output'; fi +if [ -d '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod'; fi +rm -f -r '_output/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod' +if [ -d '_output/tools/src/sigs.k8s.io/controller-tools' ]; then rmdir --ignore-fail-on-non-empty -p '_output/tools/src/sigs.k8s.io/controller-tools'; fi +if [ -d '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod'; fi +rm -f '_output/tools/bin/yq' +if [ -d '_output/tools/bin/' ]; then rmdir --ignore-fail-on-non-empty -p '_output/tools/bin/'; fi rm -f -r '_output/bin' if [ -d '_output' ]; then rmdir --ignore-fail-on-non-empty '_output'; fi [[ ! -f ./openshift ]] @@ -28,9 +31,15 @@ make clean rm -f oc openshift rm -f -r '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/srpms' if [ -d '_output' ]; then rmdir --ignore-fail-on-non-empty '_output'; fi +if [ -d '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod'; fi +rm -f -r '_output/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod' +if [ -d '_output/tools/src/sigs.k8s.io/controller-tools' ]; then rmdir --ignore-fail-on-non-empty -p '_output/tools/src/sigs.k8s.io/controller-tools'; fi +if [ -d '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod'; fi +rm -f '_output/tools/bin/yq' +if [ -d '_output/tools/bin/' ]; then rmdir --ignore-fail-on-non-empty -p '_output/tools/bin/'; fi rm -f -r '_output/bin' if [ -d '_output' ]; then rmdir --ignore-fail-on-non-empty '_output'; fi -[[ ! -d ./_output/ ]] +[[ ! -d ./_output/ ]] || (ls -l ./_output/ && false) make cross-build fatal: No names found, cannot describe anything. fatal: No names found, cannot describe anything. @@ -54,16 +63,28 @@ make clean rm -f oc openshift rm -f -r '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/srpms' if [ -d '_output' ]; then rmdir --ignore-fail-on-non-empty '_output'; fi +if [ -d '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod'; fi +rm -f -r '_output/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod' +if [ -d '_output/tools/src/sigs.k8s.io/controller-tools' ]; then rmdir --ignore-fail-on-non-empty -p '_output/tools/src/sigs.k8s.io/controller-tools'; fi +if [ -d '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod'; fi +rm -f '_output/tools/bin/yq' +if [ -d '_output/tools/bin/' ]; then rmdir --ignore-fail-on-non-empty -p '_output/tools/bin/'; fi rm -f -r '_output/bin' if [ -d '_output' ]; then rmdir --ignore-fail-on-non-empty '_output'; fi -[[ ! -d ./_output/ ]] +[[ ! -d ./_output/ ]] || (ls -l ./_output/ && false) make clean rm -f oc openshift rm -f -r '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/srpms' if [ -d '_output' ]; then rmdir --ignore-fail-on-non-empty '_output'; fi +if [ -d '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod'; fi +rm -f -r '_output/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod' +if [ -d '_output/tools/src/sigs.k8s.io/controller-tools' ]; then rmdir --ignore-fail-on-non-empty -p '_output/tools/src/sigs.k8s.io/controller-tools'; fi +if [ -d '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod'; fi +rm -f '_output/tools/bin/yq' +if [ -d '_output/tools/bin/' ]; then rmdir --ignore-fail-on-non-empty -p '_output/tools/bin/'; fi rm -f -r '_output/bin' if [ -d '_output' ]; then rmdir --ignore-fail-on-non-empty '_output'; fi -[[ ! -d ./_output/ ]] +[[ ! -d ./_output/ ]] || (ls -l ./_output/ && false) make rpm-build rpmbuild -ba --define "_topdir /github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries" --define "go_package github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries" --quiet --define 'version 2.42.0' --define 'dist .el7' --define 'release 6' ocp.spec fatal: No names found, cannot describe anything. @@ -74,12 +95,198 @@ make clean rm -f oc openshift rm -f -r '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/srpms' if [ -d '_output' ]; then rmdir --ignore-fail-on-non-empty '_output'; fi +if [ -d '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod'; fi +rm -f -r '_output/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod' +if [ -d '_output/tools/src/sigs.k8s.io/controller-tools' ]; then rmdir --ignore-fail-on-non-empty -p '_output/tools/src/sigs.k8s.io/controller-tools'; fi +if [ -d '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod'; fi +rm -f '_output/tools/bin/yq' +if [ -d '_output/tools/bin/' ]; then rmdir --ignore-fail-on-non-empty -p '_output/tools/bin/'; fi +rm -f -r '_output/bin' +if [ -d '_output' ]; then rmdir --ignore-fail-on-non-empty '_output'; fi +[[ ! -d ./_output/ ]] || (ls -l ./_output/ && false) +make clean +rm -f oc openshift +rm -f -r '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/srpms' +if [ -d '_output' ]; then rmdir --ignore-fail-on-non-empty '_output'; fi +if [ -d '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod'; fi +rm -f -r '_output/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod' +if [ -d '_output/tools/src/sigs.k8s.io/controller-tools' ]; then rmdir --ignore-fail-on-non-empty -p '_output/tools/src/sigs.k8s.io/controller-tools'; fi +if [ -d '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod'; fi +rm -f '_output/tools/bin/yq' +if [ -d '_output/tools/bin/' ]; then rmdir --ignore-fail-on-non-empty -p '_output/tools/bin/'; fi +rm -f -r '_output/bin' +if [ -d '_output' ]; then rmdir --ignore-fail-on-non-empty '_output'; fi +cp -r ./testing/manifests/initial/* ./manifests/ +diff -Naup ./testing/manifests/initial/ ./manifests/ +! make verify-codegen-crds +Installing controller-gen into "_output/tools/src/sigs.k8s.io/controller-tools/controller-gen" +mkdir -p '_output/tools/src/sigs.k8s.io/controller-tools' +git clone -b 'v0.2.1' --single-branch --depth=1 https://github.com/kubernetes-sigs/controller-tools.git '_output/tools/src/sigs.k8s.io/controller-tools' +Cloning into '_output/tools/src/sigs.k8s.io/controller-tools'... +Note: checking out 'ba11932048e4538f6e435f5ca0cdea19bf458338'. + +You are in 'detached HEAD' state. You can look around, make experimental +changes and commit them, and you can discard any commits you make in this +state without impacting any branches by performing another checkout. + +If you want to create a new branch to retain commits you create, you may +do so (now or later) by using -b with the checkout command again. Example: + + +_output/tools/src/sigs.k8s.io/controller-tools/../.. +cd '_output/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src' && go mod vendor 2>/dev/null && go build -mod=vendor ./cmd/controller-gen +Installing yq into '_output/tools/bin/yq' +mkdir -p '_output/tools/bin/' +curl -s -f -L https://github.com/mikefarah/yq/releases/download/2.4.0/yq_linux_amd64 -o '_output/tools/bin/yq' +chmod +x '_output/tools/bin/yq'; +'_output/tools/src/sigs.k8s.io/controller-tools/controller-gen' \ + schemapatch:manifests="./manifests" \ + paths="./pkg/apis/v1;./pkg/apis/v1beta1" \ +--- ./manifests/operator.openshift.io_myotheroperatorresources.crd.yaml +@@ -11,9 +11,39 @@ spec: + scope: "" + version: v1beta1 + versions: +- - name: v1beta1 +- served: true +- storage: true ++ - name: v1beta1 ++ served: true ++ storage: true ++ "validation": ++ "openAPIV3Schema": ++ description: MyOtherOperatorResource is an example operator configuration type ++ type: object ++ required: ++ - metadata ++ - spec ++ properties: ++ apiVersion: ++ description: 'APIVersion defines the versioned schema of this representation ++ of an object. Servers should convert recognized schemas to the latest ++ internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' ++ type: string ++ kind: ++ description: 'Kind is a string value representing the REST resource this ++ object represents. Servers may infer this from the endpoint the client ++ submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' ++ type: string ++ metadata: ++ type: object ++ spec: ++ type: object ++ required: ++ - deprecatedField ++ - name ++ properties: ++ deprecatedField: ++ type: string ++ name: ++ type: string + status: + acceptedNames: + kind: "" +make[2]: *** [verify-codegen-crds] Error 1 +make update-codegen-crds +Using existing controller-gen from "_output/tools/src/sigs.k8s.io/controller-tools/controller-gen" +Using existing yq from "_output/tools/bin/yq" +'_output/tools/src/sigs.k8s.io/controller-tools/controller-gen' \ + schemapatch:manifests="./manifests" \ + paths="./pkg/apis/v1;./pkg/apis/v1beta1" \ + output:dir="./manifests" +cp -n ./manifests/operator.openshift.io_myoperatorresources.crd.yaml-merge-patch './manifests/' || true # FIXME: centos +_output/tools/bin/yq m -i './manifests/operator.openshift.io_myoperatorresources.crd.yaml' './manifests/operator.openshift.io_myoperatorresources.crd.yaml-merge-patch' +make verify-codegen-crds +Using existing controller-gen from "_output/tools/src/sigs.k8s.io/controller-tools/controller-gen" +Using existing yq from "_output/tools/bin/yq" +'_output/tools/src/sigs.k8s.io/controller-tools/controller-gen' \ + schemapatch:manifests="./manifests" \ + paths="./pkg/apis/v1;./pkg/apis/v1beta1" \ +! diff -Naup ./testing/manifests/initial/ ./manifests/ 2>/dev/null +diff -Naup ./testing/manifests/initial/operator.openshift.io_myoperatorresources.crd.yaml ./manifests/operator.openshift.io_myoperatorresources.crd.yaml +--- ./testing/manifests/initial/operator.openshift.io_myoperatorresources.crd.yaml ++++ ./manifests/operator.openshift.io_myoperatorresources.crd.yaml +@@ -9,6 +9,11 @@ spec: + kind: MyOperatorResource + plural: myoperatorresources + scope: "" ++ validation: ++ openAPIV3Schema: ++ properties: ++ apiVersion: ++ pattern: ^(test|TEST)$ + status: + acceptedNames: + kind: "" +diff -Naup ./testing/manifests/initial/operator.openshift.io_myotheroperatorresources.crd.yaml ./manifests/operator.openshift.io_myotheroperatorresources.crd.yaml +--- ./testing/manifests/initial/operator.openshift.io_myotheroperatorresources.crd.yaml ++++ ./manifests/operator.openshift.io_myotheroperatorresources.crd.yaml +@@ -11,9 +11,39 @@ spec: + scope: "" + version: v1beta1 + versions: +- - name: v1beta1 +- served: true +- storage: true ++ - name: v1beta1 ++ served: true ++ storage: true ++ "validation": ++ "openAPIV3Schema": ++ description: MyOtherOperatorResource is an example operator configuration type ++ type: object ++ required: ++ - metadata ++ - spec ++ properties: ++ apiVersion: ++ description: 'APIVersion defines the versioned schema of this representation ++ of an object. Servers should convert recognized schemas to the latest ++ internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' ++ type: string ++ kind: ++ description: 'Kind is a string value representing the REST resource this ++ object represents. Servers may infer this from the endpoint the client ++ submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' ++ type: string ++ metadata: ++ type: object ++ spec: ++ type: object ++ required: ++ - deprecatedField ++ - name ++ properties: ++ deprecatedField: ++ type: string ++ name: ++ type: string + status: + acceptedNames: + kind: "" +diff -Naup ./testing/manifests/updated/ ./manifests/ 2>/dev/null +make clean +rm -f oc openshift +rm -f -r '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/srpms' +if [ -d '_output' ]; then rmdir --ignore-fail-on-non-empty '_output'; fi +if [ -d '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod'; fi +rm -f -r '_output/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod' +if [ -d '_output/tools/src/sigs.k8s.io/controller-tools' ]; then rmdir --ignore-fail-on-non-empty -p '_output/tools/src/sigs.k8s.io/controller-tools'; fi +if [ -d '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod'; fi +rm -f '_output/tools/bin/yq' +if [ -d '_output/tools/bin/' ]; then rmdir --ignore-fail-on-non-empty -p '_output/tools/bin/'; fi rm -f -r '_output/bin' if [ -d '_output' ]; then rmdir --ignore-fail-on-non-empty '_output'; fi -[[ ! -d ./_output/ ]] +[[ ! -d ./_output/ ]] || (ls -l ./_output/ && false) make clean rm -f oc openshift rm -f -r '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/srpms' if [ -d '_output' ]; then rmdir --ignore-fail-on-non-empty '_output'; fi +if [ -d '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod'; fi +rm -f -r '_output/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod' +if [ -d '_output/tools/src/sigs.k8s.io/controller-tools' ]; then rmdir --ignore-fail-on-non-empty -p '_output/tools/src/sigs.k8s.io/controller-tools'; fi +if [ -d '/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/_output/tools/src/pkg/mod'; fi +rm -f '_output/tools/bin/yq' +if [ -d '_output/tools/bin/' ]; then rmdir --ignore-fail-on-non-empty -p '_output/tools/bin/'; fi rm -f -r '_output/bin' if [ -d '_output' ]; then rmdir --ignore-fail-on-non-empty '_output'; fi diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/manifests/operator.openshift.io_myoperatorresources.crd.yaml b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/manifests/operator.openshift.io_myoperatorresources.crd.yaml new file mode 100644 index 000000000000..c1a07112552a --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/manifests/operator.openshift.io_myoperatorresources.crd.yaml @@ -0,0 +1,22 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: myoperatorresources.operator.openshift.io +spec: + group: operator.openshift.io + names: + kind: MyOperatorResource + plural: myoperatorresources + scope: "" + validation: + openAPIV3Schema: + properties: + apiVersion: + pattern: ^(test|TEST)$ +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/manifests/operator.openshift.io_myoperatorresources.crd.yaml-merge-patch b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/manifests/operator.openshift.io_myoperatorresources.crd.yaml-merge-patch new file mode 100644 index 000000000000..b9f37c6e29ab --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/manifests/operator.openshift.io_myoperatorresources.crd.yaml-merge-patch @@ -0,0 +1,6 @@ +spec: + validation: + openAPIV3Schema: + properties: + apiVersion: + pattern: "^(test|TEST)$" diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/manifests/operator.openshift.io_myotheroperatorresources.crd.yaml b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/manifests/operator.openshift.io_myotheroperatorresources.crd.yaml new file mode 100644 index 000000000000..e68fce424863 --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/manifests/operator.openshift.io_myotheroperatorresources.crd.yaml @@ -0,0 +1,52 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: myotheroperatorresources.operator.openshift.io +spec: + group: operator.openshift.io + names: + kind: MyOtherOperatorResource + plural: myotheroperatorresources + scope: "" + version: v1beta1 + versions: + - name: v1beta1 + served: true + storage: true + "validation": + "openAPIV3Schema": + description: MyOtherOperatorResource is an example operator configuration type + type: object + required: + - metadata + - spec + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + type: object + required: + - deprecatedField + - name + properties: + deprecatedField: + type: string + name: + type: string +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/apis/v1/doc.go b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/apis/v1/doc.go new file mode 100644 index 000000000000..fc32adfc73e9 --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/apis/v1/doc.go @@ -0,0 +1,5 @@ +// +k8s:defaulter-gen=TypeMeta +// +k8s:openapi-gen=true + +// +groupName=operator.openshift.io +package v1 diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/apis/v1/register.go b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/apis/v1/register.go new file mode 100644 index 000000000000..8b8850b14986 --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/apis/v1/register.go @@ -0,0 +1,39 @@ +package v1 + +import ( + configv1 "github.com/openshift/api/config/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ( + GroupName = "operator.openshift.io" + GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"} + schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes, configv1.Install) + // Install is a function which adds this version to a scheme + Install = schemeBuilder.AddToScheme + + // SchemeGroupVersion generated code relies on this name + // Deprecated + SchemeGroupVersion = GroupVersion + // AddToScheme exists solely to keep the old generators creating valid code + // DEPRECATED + AddToScheme = schemeBuilder.AddToScheme +) + +// Resource generated code relies on this being here, but it logically belongs to the group +// DEPRECATED +func Resource(resource string) schema.GroupResource { + return schema.GroupResource{Group: GroupName, Resource: resource} +} + +func addKnownTypes(scheme *runtime.Scheme) error { + metav1.AddToGroupVersion(scheme, GroupVersion) + + scheme.AddKnownTypes(GroupVersion, + &MyOperatorResource{}, + ) + + return nil +} diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/apis/v1/types.go b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/apis/v1/types.go new file mode 100644 index 000000000000..d5a51243686d --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/apis/v1/types.go @@ -0,0 +1,25 @@ +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true +// +kubebuilder:storageversion + +// MyOperatorResource is an example operator configuration type +type MyOperatorResource struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + // +kubebuilder:validation:Required + // +required + Spec MyOperatorResourceSpec `json:"spec"` +} + +type MyOperatorResourceSpec struct { + Name string `json:"name"` +} diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/apis/v1beta1/doc.go b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/apis/v1beta1/doc.go new file mode 100644 index 000000000000..ee7e1e723878 --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/apis/v1beta1/doc.go @@ -0,0 +1,5 @@ +// +k8s:defaulter-gen=TypeMeta +// +k8s:openapi-gen=true + +// +groupName=operator.openshift.io +package v1beta1 diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/apis/v1beta1/register.go b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/apis/v1beta1/register.go new file mode 100644 index 000000000000..3ee83634cea0 --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/apis/v1beta1/register.go @@ -0,0 +1,39 @@ +package v1beta1 + +import ( + configv1 "github.com/openshift/api/config/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ( + GroupName = "operator.openshift.io" + GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"} + schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes, configv1.Install) + // Install is a function which adds this version to a scheme + Install = schemeBuilder.AddToScheme + + // SchemeGroupVersion generated code relies on this name + // Deprecated + SchemeGroupVersion = GroupVersion + // AddToScheme exists solely to keep the old generators creating valid code + // DEPRECATED + AddToScheme = schemeBuilder.AddToScheme +) + +// Resource generated code relies on this being here, but it logically belongs to the group +// DEPRECATED +func Resource(resource string) schema.GroupResource { + return schema.GroupResource{Group: GroupName, Resource: resource} +} + +func addKnownTypes(scheme *runtime.Scheme) error { + metav1.AddToGroupVersion(scheme, GroupVersion) + + scheme.AddKnownTypes(GroupVersion, + &MyOtherOperatorResource{}, + ) + + return nil +} diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/apis/v1beta1/types.go b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/apis/v1beta1/types.go new file mode 100644 index 000000000000..5c1787309e73 --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/pkg/apis/v1beta1/types.go @@ -0,0 +1,25 @@ +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true + +// MyOtherOperatorResource is an example operator configuration type +type MyOtherOperatorResource struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + // +kubebuilder:validation:Required + // +required + Spec MyOtherOperatorResourceSpec `json:"spec"` +} + +type MyOtherOperatorResourceSpec struct { + Name string `json:"name"` + DeprecatedField string `json:"deprecatedField"` +} diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/testing/manifests/initial/operator.openshift.io_myoperatorresources.crd.yaml b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/testing/manifests/initial/operator.openshift.io_myoperatorresources.crd.yaml new file mode 100644 index 000000000000..f91f1f63e6b5 --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/testing/manifests/initial/operator.openshift.io_myoperatorresources.crd.yaml @@ -0,0 +1,17 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: myoperatorresources.operator.openshift.io +spec: + group: operator.openshift.io + names: + kind: MyOperatorResource + plural: myoperatorresources + scope: "" +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/testing/manifests/initial/operator.openshift.io_myoperatorresources.crd.yaml-merge-patch b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/testing/manifests/initial/operator.openshift.io_myoperatorresources.crd.yaml-merge-patch new file mode 100644 index 000000000000..b9f37c6e29ab --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/testing/manifests/initial/operator.openshift.io_myoperatorresources.crd.yaml-merge-patch @@ -0,0 +1,6 @@ +spec: + validation: + openAPIV3Schema: + properties: + apiVersion: + pattern: "^(test|TEST)$" diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/testing/manifests/initial/operator.openshift.io_myotheroperatorresources.crd.yaml b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/testing/manifests/initial/operator.openshift.io_myotheroperatorresources.crd.yaml new file mode 100644 index 000000000000..622a5279afc8 --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/testing/manifests/initial/operator.openshift.io_myotheroperatorresources.crd.yaml @@ -0,0 +1,22 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: myotheroperatorresources.operator.openshift.io +spec: + group: operator.openshift.io + names: + kind: MyOtherOperatorResource + plural: myotheroperatorresources + scope: "" + version: v1beta1 + versions: + - name: v1beta1 + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/testing/manifests/updated/operator.openshift.io_myoperatorresources.crd.yaml b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/testing/manifests/updated/operator.openshift.io_myoperatorresources.crd.yaml new file mode 100644 index 000000000000..c1a07112552a --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/testing/manifests/updated/operator.openshift.io_myoperatorresources.crd.yaml @@ -0,0 +1,22 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: myoperatorresources.operator.openshift.io +spec: + group: operator.openshift.io + names: + kind: MyOperatorResource + plural: myoperatorresources + scope: "" + validation: + openAPIV3Schema: + properties: + apiVersion: + pattern: ^(test|TEST)$ +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/testing/manifests/updated/operator.openshift.io_myoperatorresources.crd.yaml-merge-patch b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/testing/manifests/updated/operator.openshift.io_myoperatorresources.crd.yaml-merge-patch new file mode 100644 index 000000000000..b9f37c6e29ab --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/testing/manifests/updated/operator.openshift.io_myoperatorresources.crd.yaml-merge-patch @@ -0,0 +1,6 @@ +spec: + validation: + openAPIV3Schema: + properties: + apiVersion: + pattern: "^(test|TEST)$" diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/testing/manifests/updated/operator.openshift.io_myotheroperatorresources.crd.yaml b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/testing/manifests/updated/operator.openshift.io_myotheroperatorresources.crd.yaml new file mode 100644 index 000000000000..e68fce424863 --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/examples/multiple-binaries/testing/manifests/updated/operator.openshift.io_myotheroperatorresources.crd.yaml @@ -0,0 +1,52 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: myotheroperatorresources.operator.openshift.io +spec: + group: operator.openshift.io + names: + kind: MyOtherOperatorResource + plural: myotheroperatorresources + scope: "" + version: v1beta1 + versions: + - name: v1beta1 + served: true + storage: true + "validation": + "openAPIV3Schema": + description: MyOtherOperatorResource is an example operator configuration type + type: object + required: + - metadata + - spec + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + type: object + required: + - deprecatedField + - name + properties: + deprecatedField: + type: string + name: + type: string +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/lib/tmp.mk b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/lib/tmp.mk new file mode 100644 index 000000000000..a0fb655359ab --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/lib/tmp.mk @@ -0,0 +1,2 @@ +PERMANENT_TMP :=_output +PERMANENT_TMP_GOPATH :=$(PERMANENT_TMP)/tools diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/targets/golang/build.mk b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/targets/golang/build.mk index 1fe87b091396..9a71cb793acb 100644 --- a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/targets/golang/build.mk +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/targets/golang/build.mk @@ -17,6 +17,9 @@ clean-binaries: $(RM) $(go_build_binaries) .PHONY: clean-binaries +clean: clean-binaries +.PHONY: clean + # We need to be careful to expand all the paths before any include is done # or self_dir could be modified for the next include by the included file. # Also doing this at the end of the file allows us to user self_dir before it could be modified. diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/targets/openshift/controller-gen.mk b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/targets/openshift/controller-gen.mk new file mode 100644 index 000000000000..fd0ff401e80a --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/targets/openshift/controller-gen.mk @@ -0,0 +1,38 @@ +self_dir :=$(dir $(lastword $(MAKEFILE_LIST))) + +CONTROLLER_GEN_VERSION ?=v0.2.1 +CONTROLLER_GEN_TEMP ?=$(PERMANENT_TMP_GOPATH)/src/sigs.k8s.io/controller-tools +controller_gen_gopath =$(shell realpath -m $(CONTROLLER_GEN_TEMP)/../..) +CONTROLLER_GEN ?=$(CONTROLLER_GEN_TEMP)/controller-gen + +ensure-controller-gen: +ifeq "" "$(wildcard $(CONTROLLER_GEN))" + $(info Installing controller-gen into "$(CONTROLLER_GEN)") + mkdir -p '$(CONTROLLER_GEN_TEMP)' + git clone -b '$(CONTROLLER_GEN_VERSION)' --single-branch --depth=1 https://github.com/kubernetes-sigs/controller-tools.git '$(CONTROLLER_GEN_TEMP)' + @echo '$(CONTROLLER_GEN_TEMP)/../..' + cd '$(CONTROLLER_GEN_TEMP)' && export GO111MODULE=on GOPATH='$(controller_gen_gopath)' && $(GO) mod vendor 2>/dev/null && $(GO) build -mod=vendor ./cmd/controller-gen +else + $(info Using existing controller-gen from "$(CONTROLLER_GEN)") +endif +.PHONY: ensure-controller-gen + +clean-controller-gen: + if [ -d '$(controller_gen_gopath)/pkg/mod' ]; then chmod +w -R '$(controller_gen_gopath)/pkg/mod'; fi + $(RM) -r '$(CONTROLLER_GEN_TEMP)' '$(controller_gen_gopath)/pkg/mod' + @mkdir -p '$(CONTROLLER_GEN_TEMP)' # to make sure we can do the next step and to avoid using '/*' wildcard on the line above which could go crazy on wrong substitution + if [ -d '$(CONTROLLER_GEN_TEMP)' ]; then rmdir --ignore-fail-on-non-empty -p '$(CONTROLLER_GEN_TEMP)'; fi + @mkdir -p '$(controller_gen_gopath)/pkg/mod' # to make sure we can do the next step and to avoid using '/*' wildcard on the line above which could go crazy on wrong substitution + if [ -d '$(controller_gen_gopath)/pkg/mod' ]; then rmdir --ignore-fail-on-non-empty -p '$(controller_gen_gopath)/pkg/mod'; fi +.PHONY: clean-controller-gen + +clean: clean-controller-gen + + +# We need to be careful to expand all the paths before any include is done +# or self_dir could be modified for the next include by the included file. +# Also doing this at the end of the file allows us to user self_dir before it could be modified. +include $(addprefix $(self_dir), \ + ../../lib/golang.mk \ + ../../lib/tmp.mk \ +) diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/targets/openshift/crd-schema-gen.mk b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/targets/openshift/crd-schema-gen.mk new file mode 100644 index 000000000000..45a1e44ecf7d --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/targets/openshift/crd-schema-gen.mk @@ -0,0 +1,59 @@ +self_dir :=$(dir $(lastword $(MAKEFILE_LIST))) + +CRD_SCHEMA_GEN_APIS ?=$(error CRD_SCHEMA_GEN_APIS is required) +CRD_SCHEMA_GEN_MANIFESTS ?=./manifests +CRD_SCHEMA_GEN_OUTPUT ?=./manifests + +crd_patches =$(subst $(CRD_SCHEMA_GEN_MANIFESTS),$(CRD_SCHEMA_GEN_OUTPUT),$(wildcard $(CRD_SCHEMA_GEN_MANIFESTS)/*.crd.yaml-merge-patch)) + +# $1 - crd file +# $2 - patch file +define patch-crd + $(YQ) m -i '$(1)' '$(2)' + +endef + +empty := +update-codegen-crds: ensure-controller-gen ensure-yq + '$(CONTROLLER_GEN)' \ + schemapatch:manifests="$(CRD_SCHEMA_GEN_MANIFESTS)" \ + paths="$(subst $(empty) ,;,$(CRD_SCHEMA_GEN_APIS))" \ + output:dir="$(CRD_SCHEMA_GEN_OUTPUT)" + cp -n $(wildcard $(CRD_SCHEMA_GEN_MANIFESTS)/*.crd.yaml-merge-patch) '$(CRD_SCHEMA_GEN_OUTPUT)/' || true # FIXME: centos + $(foreach p,$(crd_patches),$(call patch-crd,$(basename $(p)).yaml,$(p))) +.PHONY: update-codegen-crds + +update-generated: update-codegen-crds +.PHONY: update-generated + +update: update-generated +.PHONY: update + +# $1 - manifest (actual) crd +# $2 - temp crd +define diff-crd + diff -Naup $(1) $(2) + +endef + +verify-codegen-crds: CRD_SCHEMA_GEN_OUTPUT :=$(shell mktemp -d) +verify-codegen-crds: update-codegen-crds + $(foreach p,$(wildcard $(CRD_SCHEMA_GEN_MANIFESTS)/*.crd.yaml),$(call diff-crd,$(p),$(subst $(CRD_SCHEMA_GEN_MANIFESTS),$(CRD_SCHEMA_GEN_OUTPUT),$(p)))) +.PHONY: verify-codegen-crds + +verify-generated: verify-codegen-crds +.PHONY: verify-generated + +verify: verify-generated +.PHONY: verify + + +# We need to be careful to expand all the paths before any include is done +# or self_dir could be modified for the next include by the included file. +# Also doing this at the end of the file allows us to user self_dir before it could be modified. +include $(addprefix $(self_dir), \ + ../../lib/golang.mk \ + ../../lib/tmp.mk \ + ../../targets/openshift/controller-gen.mk \ + ../../targets/openshift/yq.mk \ +) diff --git a/vendor/github.com/openshift/library-go/alpha-build-machinery/make/targets/openshift/yq.mk b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/targets/openshift/yq.mk new file mode 100644 index 000000000000..7dd556d40090 --- /dev/null +++ b/vendor/github.com/openshift/library-go/alpha-build-machinery/make/targets/openshift/yq.mk @@ -0,0 +1,32 @@ +self_dir :=$(dir $(lastword $(MAKEFILE_LIST))) + +YQ ?=$(PERMANENT_TMP_GOPATH)/bin/yq +yq_dir :=$(dir $(YQ)) + + +ensure-yq: +ifeq "" "$(wildcard $(YQ))" + $(info Installing yq into '$(YQ)') + mkdir -p '$(yq_dir)' + curl -s -f -L https://github.com/mikefarah/yq/releases/download/2.4.0/yq_$(GOHOSTOS)_$(GOHOSTARCH) -o '$(YQ)' + chmod +x '$(YQ)'; +else + $(info Using existing yq from "$(YQ)") +endif +.PHONY: ensure-yq + +clean-yq: + $(RM) '$(YQ)' + if [ -d '$(yq_dir)' ]; then rmdir --ignore-fail-on-non-empty -p '$(yq_dir)'; fi +.PHONY: clean-yq + +clean: clean-yq + + +# We need to be careful to expand all the paths before any include is done +# or self_dir could be modified for the next include by the included file. +# Also doing this at the end of the file allows us to user self_dir before it could be modified. +include $(addprefix $(self_dir), \ + ../../lib/golang.mk \ + ../../lib/tmp.mk \ +) 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 96e5277e65b4..2ce3bdef0d58 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 @@ -89,21 +89,32 @@ func (c *ControllerCommandConfig) NewCommandWithContext(ctx context.Context) *co klog.Fatal(err) } - // setup file observer to terminate when given files change - obs, err := fileobserver.NewObserver(10 * time.Second) - if err != nil { - klog.Fatal(err) - } ctx, terminate := context.WithCancel(shutdownCtx) - files := map[string][]byte{} - for _, fn := range c.basicFlags.TerminateOnFiles { - files[fn], _ = ioutil.ReadFile(fn) // intentionally ignore error + defer terminate() + + if len(c.basicFlags.TerminateOnFiles) > 0 { + // setup file observer to terminate when given files change + obs, err := fileobserver.NewObserver(10 * time.Second) + if err != nil { + klog.Fatal(err) + } + files := map[string][]byte{} + for _, fn := range c.basicFlags.TerminateOnFiles { + fileBytes, err := ioutil.ReadFile(fn) + if err != nil { + klog.Warningf("Unable to read initial content of %q: %v", fn, err) + continue // intentionally ignore errors + } + files[fn] = fileBytes + } + obs.AddReactor(func(filename string, action fileobserver.ActionType) error { + klog.Infof("exiting because %q changed", filename) + terminate() + return nil + }, files, c.basicFlags.TerminateOnFiles...) + + go obs.Run(shutdownHandler) } - obs.AddReactor(func(filename string, action fileobserver.ActionType) error { - klog.Infof("exiting because %q changed", filename) - terminate() - return nil - }, files, c.basicFlags.TerminateOnFiles...) if err := c.StartController(ctx); err != nil { klog.Fatal(err) diff --git a/vendor/github.com/openshift/library-go/pkg/controller/fileobserver/observer_polling.go b/vendor/github.com/openshift/library-go/pkg/controller/fileobserver/observer_polling.go index e15b981da278..341882e5f7a4 100644 --- a/vendor/github.com/openshift/library-go/pkg/controller/fileobserver/observer_polling.go +++ b/vendor/github.com/openshift/library-go/pkg/controller/fileobserver/observer_polling.go @@ -38,6 +38,16 @@ func (o *pollingObserver) AddReactor(reaction ReactorFn, startingFileContent map if startingContent, ok := startingFileContent[f]; ok { klog.V(3).Infof("Starting from specified content for file %q", f) + // if empty starting content is specified, do not hash the empty string but just return it the same + // way as calculateFileHash() does in that case. + // in case the file exists and is empty, we don't care about the initial content anyway, because we + // are only going to react when the file content change. + // in case the file does not exists but empty string is specified as initial content, without this + // the content will be hashed and reaction will trigger as if the content changed. + if len(startingContent) == 0 { + o.files[f] = "" + continue + } o.files[f], err = calculateHash(bytes.NewBuffer(startingContent)) if err != nil { panic(fmt.Sprintf("unexpected error while adding reactor for %#v: %v", files, err)) diff --git a/vendor/github.com/openshift/library-go/pkg/controller/fileobserver/observer_polling_test.go b/vendor/github.com/openshift/library-go/pkg/controller/fileobserver/observer_polling_test.go index b56176bc8be3..0b85b23b4f13 100644 --- a/vendor/github.com/openshift/library-go/pkg/controller/fileobserver/observer_polling_test.go +++ b/vendor/github.com/openshift/library-go/pkg/controller/fileobserver/observer_polling_test.go @@ -150,7 +150,7 @@ func TestObserverSimpleContentSpecified(t *testing.T) { o.AddReactor( testReaction, map[string][]byte{ - testFile: {}, + testFile: []byte("bar"), }, testFile) diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/client.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/client.go index fb48c59820b9..5e0faac7bd6c 100644 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/client.go +++ b/vendor/github.com/vmware/photon-controller-go-sdk/photon/client.go @@ -142,8 +142,8 @@ func NewClient(endpoint string, options *ClientOptions, logger *log.Logger) (c * } restClient := &restClient{ - httpClient: &http.Client{Transport: tr}, - logger: logger, + httpClient: &http.Client{Transport: tr}, + logger: logger, UpdateAccessTokenCallback: tokenCallback, } diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/deployments_test.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/deployments_test.go index cbbd5f681089..dbfc8f85da86 100644 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/deployments_test.go +++ b/vendor/github.com/vmware/photon-controller-go-sdk/photon/deployments_test.go @@ -32,7 +32,7 @@ var _ = Describe("Deployment", func() { deploymentSpec = &DeploymentCreateSpec{ ImageDatastores: []string{randomString(10, "go-sdk-deployment-")}, UseImageDatastoreForVms: true, - Auth: &AuthInfo{}, + Auth: &AuthInfo{}, } }) @@ -59,8 +59,8 @@ var _ = Describe("Deployment", func() { mockDeployment := Deployment{ ImageDatastores: deploymentSpec.ImageDatastores, UseImageDatastoreForVms: deploymentSpec.UseImageDatastoreForVms, - Auth: &AuthInfo{}, - NetworkConfiguration: &NetworkConfiguration{Enabled: false}, + Auth: &AuthInfo{}, + NetworkConfiguration: &NetworkConfiguration{Enabled: false}, } server.SetResponseJson(200, mockDeployment) deployment, err := client.Deployments.Get(task.Entity.ID) diff --git a/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/oidcclient_test.go b/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/oidcclient_test.go index 68bc89ad608f..976f6c7afb03 100644 --- a/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/oidcclient_test.go +++ b/vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/oidcclient_test.go @@ -66,7 +66,7 @@ var _ = Describe("OIDCClient", func() { Context("when server responds with valid certificate", func() { BeforeEach(func() { template := &x509.Certificate{ - IsCA: true, + IsCA: true, BasicConstraintsValid: true, SubjectKeyId: []byte{1, 2, 3}, SerialNumber: big.NewInt(1234), diff --git a/vendor/google.golang.org/appengine/README.md b/vendor/google.golang.org/appengine/README.md index d86768a2c665..9fdbacd3c601 100644 --- a/vendor/google.golang.org/appengine/README.md +++ b/vendor/google.golang.org/appengine/README.md @@ -71,3 +71,30 @@ A few APIs were cleaned up, and there are some differences: [blobstore package](https://google.golang.org/appengine/blobstore). * `appengine/socket` is not required on App Engine flexible environment / Managed VMs. Use the standard `net` package instead. + +## Key Encode/Decode compatibiltiy to help with datastore library migrations + +Key compatibility updates have been added to help customers transition from google.golang.org/appengine/datastore to cloud.google.com/go/datastore. +The `EnableKeyConversion` enables automatic conversion from a key encoded with cloud.google.com/go/datastore to google.golang.org/appengine/datastore key type. + +### Enabling key conversion + +Enable key conversion by calling `EnableKeyConversion(ctx)` in the `/_ah/start` handler for basic and manual scaling or any handler in automatic scaling. + +#### 1. Basic or manual scaling + +This start handler will enable key conversion for all handlers in the service. + +``` +http.HandleFunc("/_ah/start", func(w http.ResponseWriter, r *http.Request) { + datastore.EnableKeyConversion(appengine.NewContext(r)) +}) +``` + +#### 2. Automatic scaling + +`/_ah/start` is not supported for automatic scaling and `/_ah/warmup` is not guaranteed to run, so you must call `datastore.EnableKeyConversion(appengine.NewContext(r))` +before you use code that needs key conversion. + +You may want to add this to each of your handlers, or introduce middleware where it's called. +`EnableKeyConversion` is safe for concurrent use. Any call to it after the first is ignored. \ No newline at end of file diff --git a/vendor/google.golang.org/appengine/aetest/instance_vm.go b/vendor/google.golang.org/appengine/aetest/instance_vm.go index 820e1ef207c4..6396d5a5ba8b 100644 --- a/vendor/google.golang.org/appengine/aetest/instance_vm.go +++ b/vendor/google.golang.org/appengine/aetest/instance_vm.go @@ -215,9 +215,7 @@ func (i *instance) startChild() (err error) { if err != nil { return err } - if !(i.opts != nil && i.opts.SuppressDevAppServerLog) { - stderr = io.TeeReader(stderr, os.Stderr) - } + if err = i.child.Start(); err != nil { return err } @@ -227,6 +225,10 @@ func (i *instance) startChild() (err error) { go func() { s := bufio.NewScanner(stderr) for s.Scan() { + // Pass stderr along as we go so the user can see it. + if !(i.opts != nil && i.opts.SuppressDevAppServerLog) { + fmt.Fprintln(os.Stderr, s.Text()) + } if match := apiServerAddrRE.FindStringSubmatch(s.Text()); match != nil { u, err := url.Parse(match[1]) if err != nil { @@ -239,6 +241,10 @@ func (i *instance) startChild() (err error) { i.adminURL = match[1] } if i.adminURL != "" && i.apiURL != nil { + // Pass along stderr to the user after we're done with it. + if !(i.opts != nil && i.opts.SuppressDevAppServerLog) { + go io.Copy(os.Stderr, stderr) + } break } } diff --git a/vendor/google.golang.org/appengine/capability/capability.go b/vendor/google.golang.org/appengine/capability/capability.go index 3a60bd55fee8..35604d4a42fd 100644 --- a/vendor/google.golang.org/appengine/capability/capability.go +++ b/vendor/google.golang.org/appengine/capability/capability.go @@ -29,6 +29,11 @@ import ( // If the underlying RPC fails (if the package is unknown, for example), // false is returned and information is written to the application log. func Enabled(ctx context.Context, api, capability string) bool { + // For non datastore*/write requests always return ENABLED + if !(api == "datastore_v3" && capability == "write") { + return true + } + req := &pb.IsEnabledRequest{ Package: &api, Capability: []string{capability}, @@ -38,15 +43,5 @@ func Enabled(ctx context.Context, api, capability string) bool { log.Warningf(ctx, "capability.Enabled: RPC failed: %v", err) return false } - switch *res.SummaryStatus { - case pb.IsEnabledResponse_ENABLED, - pb.IsEnabledResponse_SCHEDULED_FUTURE, - pb.IsEnabledResponse_SCHEDULED_NOW: - return true - case pb.IsEnabledResponse_UNKNOWN: - log.Errorf(ctx, "capability.Enabled: unknown API capability %s/%s", api, capability) - return false - default: - return false - } + return *res.SummaryStatus == pb.IsEnabledResponse_ENABLED } diff --git a/vendor/google.golang.org/appengine/datastore/internal/cloudkey/cloudkey.go b/vendor/google.golang.org/appengine/datastore/internal/cloudkey/cloudkey.go new file mode 100644 index 000000000000..643d4049c6b3 --- /dev/null +++ b/vendor/google.golang.org/appengine/datastore/internal/cloudkey/cloudkey.go @@ -0,0 +1,120 @@ +// Copyright 2019 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// Package cloudpb is a subset of types and functions, copied from cloud.google.com/go/datastore. +// +// They are copied here to provide compatibility to decode keys generated by the cloud.google.com/go/datastore package. +package cloudkey + +import ( + "encoding/base64" + "errors" + "strings" + + "github.com/golang/protobuf/proto" + cloudpb "google.golang.org/appengine/datastore/internal/cloudpb" +) + +///////////////////////////////////////////////////////////////////// +// Code below is copied from https://github.com/googleapis/google-cloud-go/blob/master/datastore/datastore.go +///////////////////////////////////////////////////////////////////// + +var ( + // ErrInvalidKey is returned when an invalid key is presented. + ErrInvalidKey = errors.New("datastore: invalid key") +) + +///////////////////////////////////////////////////////////////////// +// Code below is copied from https://github.com/googleapis/google-cloud-go/blob/master/datastore/key.go +///////////////////////////////////////////////////////////////////// + +// Key represents the datastore key for a stored entity. +type Key struct { + // Kind cannot be empty. + Kind string + // Either ID or Name must be zero for the Key to be valid. + // If both are zero, the Key is incomplete. + ID int64 + Name string + // Parent must either be a complete Key or nil. + Parent *Key + + // Namespace provides the ability to partition your data for multiple + // tenants. In most cases, it is not necessary to specify a namespace. + // See docs on datastore multitenancy for details: + // https://cloud.google.com/datastore/docs/concepts/multitenancy + Namespace string +} + +// DecodeKey decodes a key from the opaque representation returned by Encode. +func DecodeKey(encoded string) (*Key, error) { + // Re-add padding. + if m := len(encoded) % 4; m != 0 { + encoded += strings.Repeat("=", 4-m) + } + + b, err := base64.URLEncoding.DecodeString(encoded) + if err != nil { + return nil, err + } + + pKey := new(cloudpb.Key) + if err := proto.Unmarshal(b, pKey); err != nil { + return nil, err + } + return protoToKey(pKey) +} + +// valid returns whether the key is valid. +func (k *Key) valid() bool { + if k == nil { + return false + } + for ; k != nil; k = k.Parent { + if k.Kind == "" { + return false + } + if k.Name != "" && k.ID != 0 { + return false + } + if k.Parent != nil { + if k.Parent.Incomplete() { + return false + } + if k.Parent.Namespace != k.Namespace { + return false + } + } + } + return true +} + +// Incomplete reports whether the key does not refer to a stored entity. +func (k *Key) Incomplete() bool { + return k.Name == "" && k.ID == 0 +} + +// protoToKey decodes a protocol buffer representation of a key into an +// equivalent *Key object. If the key is invalid, protoToKey will return the +// invalid key along with ErrInvalidKey. +func protoToKey(p *cloudpb.Key) (*Key, error) { + var key *Key + var namespace string + if partition := p.PartitionId; partition != nil { + namespace = partition.NamespaceId + } + for _, el := range p.Path { + key = &Key{ + Namespace: namespace, + Kind: el.Kind, + ID: el.GetId(), + Name: el.GetName(), + Parent: key, + } + } + if !key.valid() { // Also detects key == nil. + return key, ErrInvalidKey + } + return key, nil +} diff --git a/vendor/google.golang.org/appengine/datastore/internal/cloudpb/entity.pb.go b/vendor/google.golang.org/appengine/datastore/internal/cloudpb/entity.pb.go new file mode 100644 index 000000000000..af8195f3f8d2 --- /dev/null +++ b/vendor/google.golang.org/appengine/datastore/internal/cloudpb/entity.pb.go @@ -0,0 +1,344 @@ +// Copyright 2019 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// Package cloudpb is a subset of protobufs, copied from google.golang.org/genproto/googleapis/datastore/v1. +// +// They are copied here to provide compatibility to decode keys generated by the cloud.google.com/go/datastore package. +package cloudpb + +import ( + "fmt" + + "github.com/golang/protobuf/proto" +) + +// A partition ID identifies a grouping of entities. The grouping is always +// by project and namespace, however the namespace ID may be empty. +// +// A partition ID contains several dimensions: +// project ID and namespace ID. +// +// Partition dimensions: +// +// - May be `""`. +// - Must be valid UTF-8 bytes. +// - Must have values that match regex `[A-Za-z\d\.\-_]{1,100}` +// If the value of any dimension matches regex `__.*__`, the partition is +// reserved/read-only. +// A reserved/read-only partition ID is forbidden in certain documented +// contexts. +// +// Foreign partition IDs (in which the project ID does +// not match the context project ID ) are discouraged. +// Reads and writes of foreign partition IDs may fail if the project is not in +// an active state. +type PartitionId struct { + // The ID of the project to which the entities belong. + ProjectId string `protobuf:"bytes,2,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` + // If not empty, the ID of the namespace to which the entities belong. + NamespaceId string `protobuf:"bytes,4,opt,name=namespace_id,json=namespaceId,proto3" json:"namespace_id,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PartitionId) Reset() { *m = PartitionId{} } +func (m *PartitionId) String() string { return proto.CompactTextString(m) } +func (*PartitionId) ProtoMessage() {} +func (*PartitionId) Descriptor() ([]byte, []int) { + return fileDescriptor_entity_096a297364b049a5, []int{0} +} +func (m *PartitionId) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_PartitionId.Unmarshal(m, b) +} +func (m *PartitionId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_PartitionId.Marshal(b, m, deterministic) +} +func (dst *PartitionId) XXX_Merge(src proto.Message) { + xxx_messageInfo_PartitionId.Merge(dst, src) +} +func (m *PartitionId) XXX_Size() int { + return xxx_messageInfo_PartitionId.Size(m) +} +func (m *PartitionId) XXX_DiscardUnknown() { + xxx_messageInfo_PartitionId.DiscardUnknown(m) +} + +var xxx_messageInfo_PartitionId proto.InternalMessageInfo + +func (m *PartitionId) GetProjectId() string { + if m != nil { + return m.ProjectId + } + return "" +} + +func (m *PartitionId) GetNamespaceId() string { + if m != nil { + return m.NamespaceId + } + return "" +} + +// A unique identifier for an entity. +// If a key's partition ID or any of its path kinds or names are +// reserved/read-only, the key is reserved/read-only. +// A reserved/read-only key is forbidden in certain documented contexts. +type Key struct { + // Entities are partitioned into subsets, currently identified by a project + // ID and namespace ID. + // Queries are scoped to a single partition. + PartitionId *PartitionId `protobuf:"bytes,1,opt,name=partition_id,json=partitionId,proto3" json:"partition_id,omitempty"` + // The entity path. + // An entity path consists of one or more elements composed of a kind and a + // string or numerical identifier, which identify entities. The first + // element identifies a _root entity_, the second element identifies + // a _child_ of the root entity, the third element identifies a child of the + // second entity, and so forth. The entities identified by all prefixes of + // the path are called the element's _ancestors_. + // + // An entity path is always fully complete: *all* of the entity's ancestors + // are required to be in the path along with the entity identifier itself. + // The only exception is that in some documented cases, the identifier in the + // last path element (for the entity) itself may be omitted. For example, + // the last path element of the key of `Mutation.insert` may have no + // identifier. + // + // A path can never be empty, and a path can have at most 100 elements. + Path []*Key_PathElement `protobuf:"bytes,2,rep,name=path,proto3" json:"path,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Key) Reset() { *m = Key{} } +func (m *Key) String() string { return proto.CompactTextString(m) } +func (*Key) ProtoMessage() {} +func (*Key) Descriptor() ([]byte, []int) { + return fileDescriptor_entity_096a297364b049a5, []int{1} +} +func (m *Key) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Key.Unmarshal(m, b) +} +func (m *Key) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Key.Marshal(b, m, deterministic) +} +func (dst *Key) XXX_Merge(src proto.Message) { + xxx_messageInfo_Key.Merge(dst, src) +} +func (m *Key) XXX_Size() int { + return xxx_messageInfo_Key.Size(m) +} +func (m *Key) XXX_DiscardUnknown() { + xxx_messageInfo_Key.DiscardUnknown(m) +} + +// A (kind, ID/name) pair used to construct a key path. +// +// If either name or ID is set, the element is complete. +// If neither is set, the element is incomplete. +type Key_PathElement struct { + // The kind of the entity. + // A kind matching regex `__.*__` is reserved/read-only. + // A kind must not contain more than 1500 bytes when UTF-8 encoded. + // Cannot be `""`. + Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"` + // The type of ID. + // + // Types that are valid to be assigned to IdType: + // *Key_PathElement_Id + // *Key_PathElement_Name + IdType isKey_PathElement_IdType `protobuf_oneof:"id_type"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Key_PathElement) Reset() { *m = Key_PathElement{} } +func (m *Key_PathElement) String() string { return proto.CompactTextString(m) } +func (*Key_PathElement) ProtoMessage() {} +func (*Key_PathElement) Descriptor() ([]byte, []int) { + return fileDescriptor_entity_096a297364b049a5, []int{1, 0} +} +func (m *Key_PathElement) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Key_PathElement.Unmarshal(m, b) +} +func (m *Key_PathElement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Key_PathElement.Marshal(b, m, deterministic) +} +func (dst *Key_PathElement) XXX_Merge(src proto.Message) { + xxx_messageInfo_Key_PathElement.Merge(dst, src) +} +func (m *Key_PathElement) XXX_Size() int { + return xxx_messageInfo_Key_PathElement.Size(m) +} +func (m *Key_PathElement) XXX_DiscardUnknown() { + xxx_messageInfo_Key_PathElement.DiscardUnknown(m) +} + +var xxx_messageInfo_Key_PathElement proto.InternalMessageInfo + +func (m *Key_PathElement) GetKind() string { + if m != nil { + return m.Kind + } + return "" +} + +type isKey_PathElement_IdType interface { + isKey_PathElement_IdType() +} + +type Key_PathElement_Id struct { + Id int64 `protobuf:"varint,2,opt,name=id,proto3,oneof"` +} + +type Key_PathElement_Name struct { + Name string `protobuf:"bytes,3,opt,name=name,proto3,oneof"` +} + +func (*Key_PathElement_Id) isKey_PathElement_IdType() {} + +func (*Key_PathElement_Name) isKey_PathElement_IdType() {} + +func (m *Key_PathElement) GetIdType() isKey_PathElement_IdType { + if m != nil { + return m.IdType + } + return nil +} + +func (m *Key_PathElement) GetId() int64 { + if x, ok := m.GetIdType().(*Key_PathElement_Id); ok { + return x.Id + } + return 0 +} + +func (m *Key_PathElement) GetName() string { + if x, ok := m.GetIdType().(*Key_PathElement_Name); ok { + return x.Name + } + return "" +} + +// XXX_OneofFuncs is for the internal use of the proto package. +func (*Key_PathElement) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { + return _Key_PathElement_OneofMarshaler, _Key_PathElement_OneofUnmarshaler, _Key_PathElement_OneofSizer, []interface{}{ + (*Key_PathElement_Id)(nil), + (*Key_PathElement_Name)(nil), + } +} + +func _Key_PathElement_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { + m := msg.(*Key_PathElement) + // id_type + switch x := m.IdType.(type) { + case *Key_PathElement_Id: + b.EncodeVarint(2<<3 | proto.WireVarint) + b.EncodeVarint(uint64(x.Id)) + case *Key_PathElement_Name: + b.EncodeVarint(3<<3 | proto.WireBytes) + b.EncodeStringBytes(x.Name) + case nil: + default: + return fmt.Errorf("Key_PathElement.IdType has unexpected type %T", x) + } + return nil +} + +func _Key_PathElement_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { + m := msg.(*Key_PathElement) + switch tag { + case 2: // id_type.id + if wire != proto.WireVarint { + return true, proto.ErrInternalBadWireType + } + x, err := b.DecodeVarint() + m.IdType = &Key_PathElement_Id{int64(x)} + return true, err + case 3: // id_type.name + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + x, err := b.DecodeStringBytes() + m.IdType = &Key_PathElement_Name{x} + return true, err + default: + return false, nil + } +} + +func _Key_PathElement_OneofSizer(msg proto.Message) (n int) { + m := msg.(*Key_PathElement) + // id_type + switch x := m.IdType.(type) { + case *Key_PathElement_Id: + n += 1 // tag and wire + n += proto.SizeVarint(uint64(x.Id)) + case *Key_PathElement_Name: + n += 1 // tag and wire + n += proto.SizeVarint(uint64(len(x.Name))) + n += len(x.Name) + case nil: + default: + panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) + } + return n +} + +var fileDescriptor_entity_096a297364b049a5 = []byte{ + // 780 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x94, 0xff, 0x6e, 0xdc, 0x44, + 0x10, 0xc7, 0xed, 0xbb, 0x5c, 0x1a, 0x8f, 0xdd, 0xa4, 0x6c, 0x2a, 0x61, 0x02, 0x28, 0x26, 0x80, + 0x74, 0x02, 0xc9, 0x6e, 0xc2, 0x1f, 0x54, 0x14, 0xa4, 0x72, 0x25, 0xe0, 0x28, 0x15, 0x9c, 0x56, + 0x55, 0x24, 0x50, 0xa4, 0xd3, 0xde, 0x79, 0xeb, 0x2e, 0x67, 0xef, 0x5a, 0xf6, 0x3a, 0xaa, 0xdf, + 0x05, 0xf1, 0x00, 0x3c, 0x0a, 0x8f, 0x80, 0x78, 0x18, 0xb4, 0x3f, 0xec, 0x0b, 0xed, 0x35, 0xff, + 0x79, 0x67, 0x3e, 0xdf, 0xd9, 0xef, 0xec, 0xce, 0x1a, 0xa2, 0x5c, 0x88, 0xbc, 0xa0, 0x49, 0x46, + 0x24, 0x69, 0xa4, 0xa8, 0x69, 0x72, 0x73, 0x9a, 0x50, 0x2e, 0x99, 0xec, 0xe2, 0xaa, 0x16, 0x52, + 0xa0, 0x43, 0x43, 0xc4, 0x03, 0x11, 0xdf, 0x9c, 0x1e, 0x7d, 0x64, 0x65, 0xa4, 0x62, 0x09, 0xe1, + 0x5c, 0x48, 0x22, 0x99, 0xe0, 0x8d, 0x91, 0x0c, 0x59, 0xbd, 0x5a, 0xb6, 0x2f, 0x93, 0x46, 0xd6, + 0xed, 0x4a, 0xda, 0xec, 0xf1, 0x9b, 0x59, 0xc9, 0x4a, 0xda, 0x48, 0x52, 0x56, 0x16, 0x08, 0x2d, + 0x20, 0xbb, 0x8a, 0x26, 0x05, 0x91, 0x05, 0xcf, 0x4d, 0xe6, 0xe4, 0x17, 0xf0, 0xe7, 0xa4, 0x96, + 0x4c, 0x6d, 0x76, 0x91, 0xa1, 0x8f, 0x01, 0xaa, 0x5a, 0xfc, 0x4e, 0x57, 0x72, 0xc1, 0xb2, 0x70, + 0x14, 0xb9, 0x53, 0x0f, 0x7b, 0x36, 0x72, 0x91, 0xa1, 0x4f, 0x20, 0xe0, 0xa4, 0xa4, 0x4d, 0x45, + 0x56, 0x54, 0x01, 0x3b, 0x1a, 0xf0, 0x87, 0xd8, 0x45, 0x76, 0xf2, 0x8f, 0x0b, 0xe3, 0x4b, 0xda, + 0xa1, 0x67, 0x10, 0x54, 0x7d, 0x61, 0x85, 0xba, 0x91, 0x3b, 0xf5, 0xcf, 0xa2, 0x78, 0x4b, 0xef, + 0xf1, 0x2d, 0x07, 0xd8, 0xaf, 0x6e, 0xd9, 0x79, 0x0c, 0x3b, 0x15, 0x91, 0xaf, 0xc2, 0x51, 0x34, + 0x9e, 0xfa, 0x67, 0x9f, 0x6d, 0x15, 0x5f, 0xd2, 0x2e, 0x9e, 0x13, 0xf9, 0xea, 0xbc, 0xa0, 0x25, + 0xe5, 0x12, 0x6b, 0xc5, 0xd1, 0x0b, 0xd5, 0xd7, 0x10, 0x44, 0x08, 0x76, 0xd6, 0x8c, 0x1b, 0x17, + 0x1e, 0xd6, 0xdf, 0xe8, 0x01, 0x8c, 0x6c, 0x8f, 0xe3, 0xd4, 0xc1, 0x23, 0x96, 0xa1, 0x87, 0xb0, + 0xa3, 0x5a, 0x09, 0xc7, 0x8a, 0x4a, 0x1d, 0xac, 0x57, 0x33, 0x0f, 0xee, 0xb1, 0x6c, 0xa1, 0x8e, + 0xee, 0xe4, 0x29, 0xc0, 0xf7, 0x75, 0x4d, 0xba, 0x2b, 0x52, 0xb4, 0x14, 0x9d, 0xc1, 0xee, 0x8d, + 0xfa, 0x68, 0x42, 0x57, 0xfb, 0x3b, 0xda, 0xea, 0x4f, 0xb3, 0xd8, 0x92, 0x27, 0x7f, 0x4c, 0x60, + 0x62, 0xd4, 0x4f, 0x00, 0x78, 0x5b, 0x14, 0x0b, 0x9d, 0x08, 0xfd, 0xc8, 0x9d, 0xee, 0x6f, 0x2a, + 0xf4, 0x37, 0x19, 0xff, 0xdc, 0x16, 0x85, 0xe6, 0x53, 0x07, 0x7b, 0xbc, 0x5f, 0xa0, 0xcf, 0xe1, + 0xfe, 0x52, 0x88, 0x82, 0x12, 0x6e, 0xf5, 0xaa, 0xb1, 0xbd, 0xd4, 0xc1, 0x81, 0x0d, 0x0f, 0x18, + 0xe3, 0x92, 0xe6, 0xb4, 0xb6, 0x58, 0xdf, 0x6d, 0x60, 0xc3, 0x06, 0xfb, 0x14, 0x82, 0x4c, 0xb4, + 0xcb, 0x82, 0x5a, 0x4a, 0xf5, 0xef, 0xa6, 0x0e, 0xf6, 0x4d, 0xd4, 0x40, 0xe7, 0x70, 0x30, 0x8c, + 0x95, 0xe5, 0x40, 0xdf, 0xe9, 0xdb, 0xa6, 0x5f, 0xf4, 0x5c, 0xea, 0xe0, 0xfd, 0x41, 0x64, 0xca, + 0x7c, 0x0d, 0xde, 0x9a, 0x76, 0xb6, 0xc0, 0x44, 0x17, 0x08, 0xdf, 0x75, 0xaf, 0xa9, 0x83, 0xf7, + 0xd6, 0xb4, 0x1b, 0x4c, 0x36, 0xb2, 0x66, 0x3c, 0xb7, 0xda, 0xf7, 0xec, 0x25, 0xf9, 0x26, 0x6a, + 0xa0, 0x63, 0x80, 0x65, 0x21, 0x96, 0x16, 0x41, 0x91, 0x3b, 0x0d, 0xd4, 0xc1, 0xa9, 0x98, 0x01, + 0xbe, 0x83, 0x83, 0x9c, 0x8a, 0x45, 0x25, 0x18, 0x97, 0x96, 0xda, 0xd3, 0x26, 0x0e, 0x7b, 0x13, + 0xea, 0xa2, 0xe3, 0xe7, 0x44, 0x3e, 0xe7, 0x79, 0xea, 0xe0, 0xfb, 0x39, 0x15, 0x73, 0x05, 0x1b, + 0xf9, 0x53, 0x08, 0xcc, 0x53, 0xb6, 0xda, 0x5d, 0xad, 0xfd, 0x70, 0x6b, 0x03, 0xe7, 0x1a, 0x54, + 0x0e, 0x8d, 0xc4, 0x54, 0x98, 0x81, 0x4f, 0xd4, 0x08, 0xd9, 0x02, 0x9e, 0x2e, 0x70, 0xbc, 0xb5, + 0xc0, 0x66, 0xd4, 0x52, 0x07, 0x03, 0xd9, 0x0c, 0x5e, 0x08, 0xf7, 0x4a, 0x4a, 0x38, 0xe3, 0x79, + 0xb8, 0x1f, 0xb9, 0xd3, 0x09, 0xee, 0x97, 0xe8, 0x11, 0x3c, 0xa4, 0xaf, 0x57, 0x45, 0x9b, 0xd1, + 0xc5, 0xcb, 0x5a, 0x94, 0x0b, 0xc6, 0x33, 0xfa, 0x9a, 0x36, 0xe1, 0xa1, 0x1a, 0x0f, 0x8c, 0x6c, + 0xee, 0xc7, 0x5a, 0x94, 0x17, 0x26, 0x33, 0x0b, 0x00, 0xb4, 0x13, 0x33, 0xe0, 0xff, 0xba, 0xb0, + 0x6b, 0x7c, 0xa3, 0x2f, 0x60, 0xbc, 0xa6, 0x9d, 0x7d, 0xb7, 0xef, 0xbc, 0x22, 0xac, 0x20, 0x74, + 0xa9, 0x7f, 0x1b, 0x15, 0xad, 0x25, 0xa3, 0x4d, 0x38, 0xd6, 0xaf, 0xe1, 0xcb, 0x3b, 0x0e, 0x25, + 0x9e, 0x0f, 0xf4, 0x39, 0x97, 0x75, 0x87, 0x6f, 0xc9, 0x8f, 0x7e, 0x85, 0x83, 0x37, 0xd2, 0xe8, + 0xc1, 0xc6, 0x8b, 0x67, 0x76, 0x7c, 0x04, 0x93, 0xcd, 0x44, 0xdf, 0xfd, 0xf4, 0x0c, 0xf8, 0xcd, + 0xe8, 0xb1, 0x3b, 0xfb, 0xd3, 0x85, 0xf7, 0x57, 0xa2, 0xdc, 0x06, 0xcf, 0x7c, 0x63, 0x6d, 0xae, + 0x86, 0x78, 0xee, 0xfe, 0xf6, 0xad, 0x65, 0x72, 0x51, 0x10, 0x9e, 0xc7, 0xa2, 0xce, 0x93, 0x9c, + 0x72, 0x3d, 0xe2, 0x89, 0x49, 0x91, 0x8a, 0x35, 0xff, 0xfb, 0xcb, 0x3f, 0x19, 0x16, 0x7f, 0x8d, + 0x3e, 0xf8, 0xc9, 0xc8, 0x9f, 0x15, 0xa2, 0xcd, 0xe2, 0x1f, 0x86, 0x8d, 0xae, 0x4e, 0xff, 0xee, + 0x73, 0xd7, 0x3a, 0x77, 0x3d, 0xe4, 0xae, 0xaf, 0x4e, 0x97, 0xbb, 0x7a, 0x83, 0xaf, 0xfe, 0x0b, + 0x00, 0x00, 0xff, 0xff, 0xf3, 0xdd, 0x11, 0x96, 0x45, 0x06, 0x00, 0x00, +} + +var xxx_messageInfo_Key proto.InternalMessageInfo diff --git a/vendor/google.golang.org/appengine/datastore/key.go b/vendor/google.golang.org/appengine/datastore/key.go index 6ab83eaf657a..fd598dc9657f 100644 --- a/vendor/google.golang.org/appengine/datastore/key.go +++ b/vendor/google.golang.org/appengine/datastore/key.go @@ -254,6 +254,10 @@ func DecodeKey(encoded string) (*Key, error) { ref := new(pb.Reference) if err := proto.Unmarshal(b, ref); err != nil { + // Couldn't decode it as an App Engine key, try decoding it as a key encoded by cloud.google.com/go/datastore. + if k := decodeCloudKey(encoded); k != nil { + return k, nil + } return nil, err } diff --git a/vendor/google.golang.org/appengine/datastore/keycompat.go b/vendor/google.golang.org/appengine/datastore/keycompat.go new file mode 100644 index 000000000000..371a64eeefe8 --- /dev/null +++ b/vendor/google.golang.org/appengine/datastore/keycompat.go @@ -0,0 +1,89 @@ +// Copyright 2019 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package datastore + +import ( + "sync" + + "golang.org/x/net/context" + + "google.golang.org/appengine/datastore/internal/cloudkey" + "google.golang.org/appengine/internal" +) + +var keyConversion struct { + mu sync.RWMutex + appID string // read using getKeyConversionAppID +} + +// EnableKeyConversion enables encoded key compatibility with the Cloud +// Datastore client library (cloud.google.com/go/datastore). Encoded keys +// generated by the Cloud Datastore client library will be decoded into App +// Engine datastore keys. +// +// The context provided must be an App Engine context if running in App Engine +// first generation runtime. This can be called in the /_ah/start handler. It is +// safe to call multiple times, and is cheap to call, so can also be inserted as +// middleware. +// +// Enabling key compatibility does not affect the encoding format used by +// Key.Encode, it only expands the type of keys that are able to be decoded with +// DecodeKey. +func EnableKeyConversion(ctx context.Context) { + // Only attempt to set appID if it's unset. + // If already set, ignore. + if getKeyConversionAppID() != "" { + return + } + + keyConversion.mu.Lock() + // Check again to avoid race where another goroutine set appID between the call + // to getKeyConversionAppID above and taking the write lock. + if keyConversion.appID == "" { + keyConversion.appID = internal.FullyQualifiedAppID(ctx) + } + keyConversion.mu.Unlock() +} + +func getKeyConversionAppID() string { + keyConversion.mu.RLock() + appID := keyConversion.appID + keyConversion.mu.RUnlock() + return appID +} + +// decodeCloudKey attempts to decode the given encoded key generated by the +// Cloud Datastore client library (cloud.google.com/go/datastore), returning nil +// if the key couldn't be decoded. +func decodeCloudKey(encoded string) *Key { + appID := getKeyConversionAppID() + if appID == "" { + return nil + } + + k, err := cloudkey.DecodeKey(encoded) + if err != nil { + return nil + } + return convertCloudKey(k, appID) +} + +// convertCloudKey converts a Cloud Datastore key and converts it to an App +// Engine Datastore key. Cloud Datastore keys don't include the project/app ID, +// so we must add it back in. +func convertCloudKey(key *cloudkey.Key, appID string) *Key { + if key == nil { + return nil + } + k := &Key{ + intID: key.ID, + kind: key.Kind, + namespace: key.Namespace, + parent: convertCloudKey(key.Parent, appID), + stringID: key.Name, + appID: appID, + } + return k +} diff --git a/vendor/google.golang.org/appengine/datastore/keycompat_test.go b/vendor/google.golang.org/appengine/datastore/keycompat_test.go new file mode 100644 index 000000000000..923fdac9a767 --- /dev/null +++ b/vendor/google.golang.org/appengine/datastore/keycompat_test.go @@ -0,0 +1,89 @@ +// Copyright 2019 Google Inc. All Rights Reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package datastore + +import ( + "reflect" + "testing" +) + +func TestKeyConversion(t *testing.T) { + var tests = []struct { + desc string + key *Key + encodedKey string + }{ + { + desc: "A control test for legacy to legacy key conversion int as the key", + key: &Key{ + kind: "Person", + intID: 1, + appID: "glibrary", + }, + encodedKey: "aghnbGlicmFyeXIMCxIGUGVyc29uGAEM", + }, + { + desc: "A control test for legacy to legacy key conversion string as the key", + key: &Key{ + kind: "Graph", + stringID: "graph:7-day-active", + appID: "glibrary", + }, + encodedKey: "aghnbGlicmFyeXIdCxIFR3JhcGgiEmdyYXBoOjctZGF5LWFjdGl2ZQw", + }, + + // These are keys encoded with cloud.google.com/go/datastore + // Standard int as the key + { + desc: "Convert new key format to old key with int id", + key: &Key{ + kind: "WordIndex", + intID: 1033, + appID: "glibrary", + }, + encodedKey: "Eg4KCVdvcmRJbmRleBCJCA", + }, + // These are keys encoded with cloud.google.com/go/datastore + // Standard string + { + desc: "Convert new key format to old key with string id", + key: &Key{ + kind: "WordIndex", + stringID: "IAmAnID", + appID: "glibrary", + }, + encodedKey: "EhQKCVdvcmRJbmRleBoHSUFtQW5JRA", + }, + + // These are keys encoded with cloud.google.com/go/datastore + // ID String with parent as string + { + desc: "Convert new key format to old key with string id with a parent", + key: &Key{ + kind: "WordIndex", + stringID: "IAmAnID", + appID: "glibrary", + parent: &Key{ + kind: "LetterIndex", + stringID: "IAmAnotherID", + appID: "glibrary", + }, + }, + encodedKey: "EhsKC0xldHRlckluZGV4GgxJQW1Bbm90aGVySUQSFAoJV29yZEluZGV4GgdJQW1BbklE", + }, + } + + // Simulate the key converter enablement + keyConversion.appID = "glibrary" + for _, tc := range tests { + dk, err := DecodeKey(tc.encodedKey) + if err != nil { + t.Fatalf("DecodeKey: %v", err) + } + if !reflect.DeepEqual(dk, tc.key) { + t.Errorf("%s: got %+v, want %+v", tc.desc, dk, tc.key) + } + } +} diff --git a/vendor/google.golang.org/appengine/file/file.go b/vendor/google.golang.org/appengine/file/file.go index c3cd58baf075..e63a4aca97ff 100644 --- a/vendor/google.golang.org/appengine/file/file.go +++ b/vendor/google.golang.org/appengine/file/file.go @@ -22,7 +22,7 @@ func DefaultBucketName(c context.Context) (string, error) { err := internal.Call(c, "app_identity_service", "GetDefaultGcsBucketName", req, res) if err != nil { - return "", fmt.Errorf("file: no default bucket name returned in RPC response: %v", res) + return "", fmt.Errorf("file: no default bucket name returned in RPC response: %v", err) } return res.GetDefaultGcsBucketName(), nil } diff --git a/vendor/google.golang.org/appengine/go.mod b/vendor/google.golang.org/appengine/go.mod index f449359d2f85..45159279854b 100644 --- a/vendor/google.golang.org/appengine/go.mod +++ b/vendor/google.golang.org/appengine/go.mod @@ -1,7 +1,10 @@ module google.golang.org/appengine require ( - github.com/golang/protobuf v1.2.0 - golang.org/x/net v0.0.0-20180724234803-3673e40ba225 - golang.org/x/text v0.3.0 + github.com/golang/protobuf v1.3.1 + golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5 // indirect + golang.org/x/net v0.0.0-20190603091049-60506f45cf65 + golang.org/x/sys v0.0.0-20190606165138-5da285871e9c // indirect + golang.org/x/text v0.3.2 + golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b // indirect ) diff --git a/vendor/google.golang.org/appengine/go.sum b/vendor/google.golang.org/appengine/go.sum index 1a221c0896a5..cb3232556bf0 100644 --- a/vendor/google.golang.org/appengine/go.sum +++ b/vendor/google.golang.org/appengine/go.sum @@ -1,6 +1,22 @@ 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= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/net v0.0.0-20180724234803-3673e40ba225 h1:kNX+jCowfMYzvlSvJu5pQWEmyWFrBXJ3PBy10xKMXK8= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65 h1:+rhAzEzT3f4JtomfC371qB+0Ola2caSKcY69NUBZrRQ= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/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/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= diff --git a/vendor/google.golang.org/appengine/internal/net.go b/vendor/google.golang.org/appengine/internal/net.go index 3b94cf0c6a8b..fe429720e1f2 100644 --- a/vendor/google.golang.org/appengine/internal/net.go +++ b/vendor/google.golang.org/appengine/internal/net.go @@ -32,7 +32,7 @@ func limitDial(network, addr string) (net.Conn, error) { // Dial with a timeout in case the API host is MIA. // The connection should normally be very fast. - conn, err := net.DialTimeout(network, addr, 500*time.Millisecond) + conn, err := net.DialTimeout(network, addr, 10*time.Second) if err != nil { limitRelease() return nil, err