Compare commits

...

1190 Commits

Author SHA1 Message Date
Kubernetes Publisher
50434c6a06 Merge pull request #136362 from dims/update-opentelemetry-v1.39.0
Update OpenTelemetry dependencies to latest versions

Kubernetes-commit: 69eb15ee58c9cb20b90007e9b064dfb78b66a867
2026-01-21 22:14:22 +00:00
Davanum Srinivas
a2aea51475 Update OpenTelemetry dependencies to latest versions
Core packages (opentelemetry-go):
- go.opentelemetry.io/otel: v1.38.0 → v1.39.0
- go.opentelemetry.io/otel/metric: v1.38.0 → v1.39.0
- go.opentelemetry.io/otel/trace: v1.38.0 → v1.39.0
- go.opentelemetry.io/otel/sdk: v1.38.0 → v1.39.0

Exporters:
- go.opentelemetry.io/otel/exporters/otlp/otlptrace: v1.34.0 → v1.39.0
- go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc: v1.34.0 → v1.39.0

Contrib instrumentation (opentelemetry-go-contrib):
- go.opentelemetry.io/contrib/.../otelhttp: v0.61.0 → v0.64.0
- go.opentelemetry.io/contrib/.../otelrestful: v0.44.0 → v0.64.0

Protocol definitions (opentelemetry-proto-go):
- go.opentelemetry.io/proto/otlp: v1.5.0 → v1.9.0

Notable changes:
- Go 1.24 is now the minimum required version (Go 1.23 support dropped) for OTEL components
- Performance: ~4x improvement in histogram concurrent operations; xxhash
  replaces fnv for attribute hashing
- Fixed goroutine leak in span processors when context is canceled
- otelrestful migrated semantic conventions from v1.20.0 to v1.34.0
  (e.g., http.method → http.request.method)
- Partial OTLP export errors now surfaced instead of being silently dropped
- otelrestful no longer depends on json-iterator/go, modern-go/concurrent,
  or modern-go/reflect2; unwanted-dependencies.json updated accordingly

Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: c40ea60b9f193fbead586f9fd6cc26f7b77312ff
2026-01-20 17:20:21 -05:00
Kubernetes Publisher
2a236a856d Merge pull request #136212 from dims/update-security-deps-jan2026-v2
Update security and stability dependencies

Kubernetes-commit: a94970c0c5de0fa56b0ed82823850db7e0257685
2026-01-16 14:04:42 +00:00
Davanum Srinivas
5594bf5680 Update security and stability dependencies
This PR updates several dependencies addressing security vulnerabilities,
stability fixes, and authentication improvements.

- golang.org/x/crypto: v0.46.0 -> v0.47.0
  - Includes latest X509 root certificate bundle updates
  - Security hardening for cryptographic operations
  - Foundation dependency for TLS and authentication

- github.com/golang-jwt/jwt/v5: v5.2.2 -> v5.3.0
  - IMPORTANT: v5.2.2 patched vulnerability GHSA-mh63-6h87-95cp (token
    validation security issue) - this update ensures we have the fix
  - Adds multiple audience validation support for JWT tokens
  - Go 1.21 minimum requirement (code modernization)
  - Replaced legacy interface{} with modern any keyword

- golang.org/x/net: v0.48.0 -> v0.49.0
  - HTTP/2 priority scheduler improvements (RFC 9218)
  - WebSocket security enhancements
  - Network layer stability fixes

- go.uber.org/zap: v1.27.0 -> v1.27.1
  - Fix: Prevent Object from panicking on nils (PR #1501)
  - Fix: Race condition in WithLazy (PR #1511)
  - Both fixes improve logging stability in concurrent scenarios

- github.com/godbus/dbus/v5: v5.2.0 -> v5.2.2
  - Security: Disabled SHA1 authentication by default on non-Windows
    platforms (v5.2.0 change now inherited)
  - Performance: Multiple optimizations reducing memory allocations
  - Fix: Alignment issues in decoder operations
  - Fix: Allow more than 32 containers/struct fields in a signature

Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 5b478645cdb3be5ed92a21d2f7b417b6328cfa6e
2026-01-13 23:08:03 -05:00
Kubernetes Publisher
16cd5dbcd7 Merge pull request #136162 from dims/update-security-deps-jan2026
Update security-critical authentication and protobuf dependencies

Kubernetes-commit: c29a5d73a6fd04896033fe615c259f2949c5e94f
2026-01-14 02:05:02 +00:00
Davanum Srinivas
1aa4a38e16 Update security-critical authentication and protobuf dependencies
This PR updates security-critical dependencies addressing authentication
and data parsing vulnerabilities.

**Authentication Security:**
- github.com/coreos/go-oidc: v2.3.0 -> v2.5.0
  - Security fix: Now verifies token signature BEFORE validating payload
  - Prevents potential processing of tampered tokens before cryptographic
    verification

- github.com/cyphar/filepath-securejoin: v0.6.0 -> v0.6.1
  - Security fix: Fixed seccomp fallback logic - library now properly falls
    back to safer O_PATH resolver when openat2(2) is denied by seccomp-bpf
  - Fixed file descriptor leak in openat2 wrapper during RESOLVE_IN_ROOT

- cyphar.com/go-pathrs: v0.2.1 -> v0.2.2
  - Companion update to filepath-securejoin

**Protobuf Security:**
- google.golang.org/protobuf: v1.36.8 -> v1.36.11
  - Security fix: Added recursion limit check in lazy decoding validation
  - Prevents potential stack exhaustion attacks via maliciously crafted
    protobuf messages
  - Also adds support for URL chars in type URLs in text-format

These updates are critical for:
- OIDC authentication in kube-apiserver
- Container filesystem path resolution (used by container runtimes)
- Protobuf message parsing throughout the codebase

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: c825d80bbf2c82666192c329478a686fa3a1d5dc
2026-01-11 16:50:37 -05:00
Kubernetes Publisher
81ae50c183 Merge pull request #136161 from dims/update-golang-x-deps-jan2026
Update golang.org/x dependencies to latest versions

Kubernetes-commit: 1c894014ebe25e0b042efa91698284f527493d90
2026-01-13 02:28:31 +00:00
Davanum Srinivas
17baec1178 Update golang.org/x dependencies to latest versions
updates the golang.org/x package family to newer releases:

- golang.org/x/crypto: v0.45.0 -> v0.46.0
- golang.org/x/net: v0.47.0 -> v0.48.0
- golang.org/x/sys: v0.38.0 -> v0.40.0
- golang.org/x/time: v0.9.0 -> v0.14.0
- golang.org/x/oauth2: v0.30.0 -> v0.34.0
- golang.org/x/text: v0.31.0 -> v0.33.0
- golang.org/x/term: v0.37.0 -> v0.39.0
- golang.org/x/sync: v0.18.0 -> v0.19.0
- golang.org/x/mod: v0.29.0 -> v0.32.0
- golang.org/x/tools: v0.38.0 -> v0.40.0
- golang.org/x/exp: 8a7402abbf56 -> 944ab1f22d93

Security & Stability:
- x/crypto: Updated X509 root certificate bundle
- x/net: HTTP/2 PING optimization to reduce DoS detection triggers,
  data race fix in trace RenderEvents
- x/sys: Fixed out-of-bounds memory access in sockaddrIUCVToAny
- x/time: Fixed rate limiter overflow when using very low rates that
  could cause the limiter to jam open

Performance:
- x/time: ~19% improvement in Sometimes.Do when no interval configured

Maintenance:
- Various vet diagnostic fixes for Go 1.26 compatibility
- Dependency updates across the golang.org/x ecosystem

Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 0e67c56a8f26ace2889fd24e098b78e13f9bbffe
2026-01-11 16:25:45 -05:00
Kubernetes Publisher
c5a510e1f3 Merge pull request #136108 from pohly/ginkgo-gomega-update
dependencies: ginkgo v2.27.4, gomega v1.39.0

Kubernetes-commit: 758ef0ffbce5cbca7a893d839dde892d79c2738f
2026-01-08 23:41:35 +00:00
Patrick Ohly
268a6a7700 dependencies: ginkgo v2.27.4, gomega v1.39.0
Latest release of both. The CurrentTreeConstructionNodeReport fix
is needed before being able to use it in the E2E framework.

Kubernetes-commit: f8a0c80ed81711f6add7a765d22b56d2d41ac522
2026-01-08 16:53:03 +01:00
Kubernetes Publisher
6cb24270b0 Merge pull request #135391 from jpbetz/smd-6_3_1
Bump structured-merge-diff to pick up flake fix and bug fixes

Kubernetes-commit: 6f92c01979b7666f6631a556a8626e21b88d1f2a
2025-12-23 15:00:23 +00:00
Kubernetes Publisher
1d34da02ca Merge pull request #135867 from dims/pin-versions-of-dbus-and-otelgrpc-to-avoid-breakage
Pin versions of dbus and otelgrpc to avoid breakage

Kubernetes-commit: dce2e8cef737ebce3a4d13d74654c50bcb244846
2025-12-21 02:58:32 +00:00
Davanum Srinivas
5eb3267611 updated to last known good dependencies for otelgrpc and dbus
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 60cce0abd05d31f74ece404e584f53c915a7f3d5
2025-12-20 15:27:53 -05:00
Kubernetes Publisher
af6ed48cf6 Merge pull request #135836 from pohly/ginkgo-gomega-update
dependencies: ginkgo v2.27.3 + gomega v1.38.3

Kubernetes-commit: 268bdbe214ac64b5a31a59cfae6b96f3a1585bd3
2025-12-19 18:59:06 +00:00
Kubernetes Publisher
7eea9581c5 Merge pull request #135845 from skitt/drop-armon-circbuf
Replace armon/circbuf with k8s.io/utils/buffer

Kubernetes-commit: 0ea38248603ce745956d779787874cfd91ca29ae
2025-12-19 18:59:04 +00:00
Stephen Kitt
061bfb601d Replace armon/circbuf with k8s.io/utils/buffer
This uses the new generic fixed ring implementation in k8s.io/utils.

Signed-off-by: Stephen Kitt <skitt@redhat.com>

Kubernetes-commit: 3653ae2b9a7768da89e47ef84d503ae9cf0b910b
2025-12-19 09:59:41 +01:00
Kubernetes Publisher
15740c5a3c Merge pull request #135531 from pohly/golangci-lint-bump
golangci-lint: bump to v2.7.1

Kubernetes-commit: 430fef557f34c6145d4607f9d65d46ac5f7a7b66
2025-12-18 18:57:39 +00:00
Kubernetes Publisher
937ea5acb4 Merge pull request #135539 from dims/move-httpcache-to-third_party/forked
move httpcache to third_party/forked

Kubernetes-commit: 04d866b37de3aefac063b2b6e12f11b30701c9ff
2025-12-18 18:57:38 +00:00
Patrick Ohly
afeb98a2bf dependencies: ginkgo v2.27.3 + gomega v1.38.3
This fixes some issues found in Kubernetes (data race in ginkgo CLI, gomega
formatting) and helps with diagnosing OOM killing in CI jobs (exit status of
processes).

The modified gomega formatting shows up in some of the output tests for the E2E
framework. They get updated accordingly.

Kubernetes-commit: db841afdbb193ea7d612472c7cc4c7b3f58eb676
2025-12-16 14:32:00 +01:00
Davanum Srinivas
3b66c2e73c move httpcache to third_party/forked
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: ab1ffaf12e243798df20a5c98192b8d108ba9a9b
2025-12-01 21:58:55 -05:00
Kubernetes Publisher
adad5a9caa Merge pull request #133828 from dims/drop-unnecessary-usegocmp-build-tag
Drop unnecessary `usegocmp` build tag

Kubernetes-commit: 09e71afb4bc834cf08106517a528d9320c2cc94f
2025-12-18 02:55:39 +00:00
Kubernetes Publisher
625de3544c Merge pull request #135536 from dims/bump-x/crypto-to-v0.45.0
Bump golang.org/x/crypto to v0.45.0

Kubernetes-commit: de61f598953ccd3e3950cdeda02740af2881048f
2025-12-04 23:32:36 +00:00
Davanum Srinivas
aa36c89596 Bump golang.org/x/crypto to v0.45.0
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 5302b929ae55e86ad40b57d74c326529792d0439
2025-12-01 14:11:01 -05:00
Patrick Ohly
aa6ab0a1a5 build: remove deprecated '// +build' tag
This has been replaced by `//build:...` for a long time now.

Removal of the old build tag was automated with:

    for i in $(git grep -l '^// +build' | grep -v -e '^vendor/'); do if ! grep -q '^// Code generated' "$i"; then sed -i -e '/^\/\/ +build/d' "$i"; fi; done

Kubernetes-commit: ad79e479c2314d1de91e54bc5630c52027f12e21
2025-12-01 15:54:18 +01:00
Kubernetes Publisher
23982ca363 Merge pull request #135131 from Dev1622/sig-storage/mock-expand-flake-fix
e2e/storage: deflake CSI Mock volume expansion quota validation

Kubernetes-commit: 4c04786f746e349a34042a0d59ec432a8a46ddcc
2025-11-26 21:17:49 +00:00
Joe Betz
c443aac8ce hack/pin-dependency.sh sigs.k8s.io/structured-merge-diff/v6 v6.3.1
Kubernetes-commit: 5129fa152b3628ee65c060d3e2f59f69d271f7a6
2025-11-21 08:53:57 -05:00
Dev1622
65dd5388bc vendor: update vendor and license metadata after replacing BeTrue usage in csi tests
Kubernetes-commit: 216aaf76cba4b0cba05f0901d759dc017f833cd3
2025-11-13 05:11:59 +00:00
Surya Dev
ec2a1c8e82 Resolve lint restriction on BeTrue by introducing Succeed() with contextual error messages
Kubernetes-commit: cee5b837da96f16536e048905bfe5be7103b21d2
2025-11-12 22:38:33 +05:30
Surya
b1d566f6ff Update vendored dependencies
Kubernetes-commit: c68b35c4c75cb5d4c016799a966808dff3d9a9a5
2025-11-12 16:17:46 +00:00
Kubernetes Publisher
2464cd88ce Merge pull request #134881 from pohly/e2e-slow-priority
E2E: run slow tests first, using new Ginkgo

Kubernetes-commit: cd0ddec139502081c2edf73c0329bcc07b5048f4
2025-11-01 15:56:41 +00:00
Patrick Ohly
85b7780cbf dependencies: ginkgo v2.27.2, gomega v1.38.2
Specifically the new AddTreeConstructionNodeArgsTransformer and SpecPriority in
Ginkgo will be useful.

Gomega gets updated to keep up-to-date.

Kubernetes-commit: 6034321603be95409028f0173e0c372515008dbb
2025-10-24 20:53:04 +02:00
Kubernetes Publisher
42bbeb6d6e Merge pull request #135004 from pohly/dependencies-x-repos
dependencies: various minor updates

Kubernetes-commit: 02398258b15ff894a7c73acdeb9270b32f6d02a9
2025-10-31 15:59:49 +00:00
Patrick Ohly
6913650eb2 dependencies: various minor updates
This is a collection of updating several unversioned modules. Those updates are
eventually going to reach Kubernetes, doing them together now makes PRs for
future major updates smaller.

Kubernetes-commit: 5993782d6537bab9edf95590c123f96ea39ca185
2025-10-31 11:30:26 +01:00
Kubernetes Publisher
176c776474 Merge pull request #134780 from joshjms/bump-etcd-sdk-v3.6.5
etcd: Bump etcd sdk to v3.6.5

Kubernetes-commit: 4415f00294cff245a9594055aed29abcd4e4a0c1
2025-10-22 23:58:14 +00:00
joshjms
db0c6eaf0d etcd: bump etcd sdk to v3.6.5
Signed-off-by: joshjms <joshjms1607@gmail.com>

Kubernetes-commit: 7f99d6672f75d9f757953745bdabf598139b4c30
2025-10-22 21:36:06 +08:00
Kubernetes Publisher
3e1e304730 Merge pull request #134714 from p0lyn0mial/upstream-watchlist-unsupported-wl-semantics-typed-inf
client-go/typed/informers: wrap the LW with WatchList semantics

Kubernetes-commit: 350481c4747da5c2ad4f24e71e7edaabbd4cfe2e
2025-10-21 15:56:52 +00:00
Lukasz Szaszkiewicz
f2b8c99eff ./hack/update-codegen.sh
Kubernetes-commit: 5594d94e6716599981948d21599700d6dfe43b11
2025-10-17 14:35:36 +02:00
Kubernetes Publisher
f5fbdf257a Merge pull request #134663 from p0lyn0mial/upstream-watchlist-unsupported-wl-semantics-typed
client-go/typed/fake: expose IsWatchListSemanticsUnSupported

Kubernetes-commit: f794aa12d78f5b1f9579ce8a991a116a99a2c43c
2025-10-17 09:37:09 +00:00
Lukasz Szaszkiewicz
c98bec5cec ./hack/update-codegen.sh
Kubernetes-commit: d15b2893341854ce69e58c18f0899e9c0cf61f33
2025-10-16 22:40:29 +02:00
Kubernetes Publisher
f3f7a3c99d Merge pull request #134256 from liggitt/protoc-gogo-poc
KEP-5589 - drop gogo runtime dependencies

Kubernetes-commit: 6bc4914b841f5bf032490cf105f57dc5bfe475ba
2025-10-08 21:55:06 +00:00
Jordan Liggitt
e4ddf454da Regenerate vendor
Kubernetes-commit: 7f58bb9abdf23c37e5e201054db5adab6eee60cd
2025-09-24 23:37:55 -04:00
Kubernetes Publisher
5c91de7283 Merge pull request #134209 from Jefftree/gengo-bmp
Bump gengo

Kubernetes-commit: 1b5fb46b720484a19951198165494c98691a513d
2025-09-22 23:50:48 +00:00
Jefftree
440bb4f1ae bump gengo
Kubernetes-commit: 37592a026be32e3eb8ff19e1f934110bbff42975
2025-09-22 18:54:58 +00:00
Kubernetes Publisher
e02734125f Merge pull request #134145 from dims/update-to-latest-sigs.k8s.io/json
update to latest sigs.k8s.io/json

Kubernetes-commit: 6070f5a92918020b8c792ca1219a5fbbfa53a556
2025-09-19 04:01:13 +00:00
Davanum Srinivas
1ef8f222ca update to latest sigs.k8s.io/json
Kubernetes-commit: 736f7b9a1b514237c78e28885198f6c2e6a0a0b0
2025-09-18 20:55:31 -04:00
Kubernetes Publisher
b2f0de72cf Merge pull request #134120 from BenTheElder/golang-language-125
Upgrade go language version to 1.25

Kubernetes-commit: 0ca861d5ed67d944285ee5ea80cf520d11e8b755
2025-09-18 00:59:49 +00:00
Benjamin Elder
6b8a1e7cb9 bump go language version to 1.25
Kubernetes-commit: 563d4d651ca2905e3ed4d643021295fb19f871fb
2025-09-17 13:32:42 -07:00
Kubernetes Publisher
2468fb7ad7 Merge pull request #131755 from jpbetz/openapi-type-name-gen
Allow OpenAPI model package names to be declared by APIs

Kubernetes-commit: 69e637f24c23764973e30491afab202c0d083399
2025-09-11 20:23:54 +00:00
Kubernetes Publisher
878e68684d Merge pull request #133191 from Jefftree/rev
Add jefftree to OWNERS

Kubernetes-commit: 26b246ae667f5f9b0f90e1a2abd9fc2a50f4d0d3
2025-09-11 16:13:35 +00:00
Joe Betz
37e6640aaa Bump kube-openapi
Signed-off-by: Joe Betz <jpbetz@google.com>

Kubernetes-commit: 8b63ace66c5b21a886aa7d3803c0f70bd2a51c8e
2025-09-10 15:52:57 -04:00
Kubernetes Publisher
16fa12aec0 Merge pull request #133921 from dims/update-prometheus-client-golang-and-common-packages
update prometheus' client_golang and common packages

Kubernetes-commit: bbd859808d0cef566fbfc89639926b7cc50d9bd5
2025-09-10 16:28:33 +00:00
Davanum Srinivas
7600c7f5af update prometheus' client_golang and common packages
Kubernetes-commit: bdfca587f48e816a667b1b1e5766200746b90e3a
2025-09-07 17:20:43 -04:00
Kubernetes Publisher
fff7accdf4 Merge pull request #133769 from thockin/kk_bump_gengo
Bump gengo

Kubernetes-commit: 86d0607011e11ce579e9e2e5754068b4ecfdd57c
2025-09-03 21:19:09 +00:00
Tim Hockin
c4a1185e35 Bump gengo
Kubernetes-commit: 5f4b4a682499ecb996a45a1e2c48dd545003f22a
2025-09-03 08:24:17 -07:00
Davanum Srinivas
0e6064b565 Drop unnecessary usegocmp build tag
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 1f1d197701de6deb3641dd8df5bc4452a2949361
2025-09-01 17:59:52 -04:00
Kubernetes Publisher
7fcd40c46f Merge pull request #133823 from dims/update-to-spf13/pflag-to-prevent-CI-break
Update to spf13/pflag to prevent CI break

Kubernetes-commit: 80b8c7b40657efbf68c1687bc7c749d4fafd827d
2025-09-01 21:14:09 +00:00
Davanum Srinivas
effb759d0a Update to spf13/pflag to prevent CI break
Kubernetes-commit: 6ddf6261d445564dd287b2e95019910cb9c4a662
2025-09-01 08:21:12 -04:00
Kubernetes Publisher
b3a0c47cf0 Merge pull request #133430 from liggitt/json-patch-v4-errors
bump gopkg.in/evanphx/json-patch.v4

Kubernetes-commit: d5065bdf192b2ebb723657b3432c66ce3ea15b23
2025-08-30 17:11:37 +00:00
Jordan Liggitt
6786a432ea bump gopkg.in/evanphx/json-patch.v4
Kubernetes-commit: 9f8d9432e2067bc8b0e0ea5362b00559846ca54b
2025-08-07 16:02:03 -04:00
Kubernetes Publisher
7a8cd09145 Merge pull request #132128 from skitt/cadvisor-0.53
Bump cadvisor to 0.53

Kubernetes-commit: aead71c1c2e1846f554d21a257ff577b65f8493a
2025-08-28 17:15:12 +00:00
Jefftree
413484445c Add jefftree to OWNERS
Kubernetes-commit: 7242ddd93702fc7b0c5a3f01304be901e5942155
2025-07-24 21:26:52 +00:00
Stephen Kitt
c18c454598 Bump cadvisor to 0.53
This brings a few fixes, drops github.com/pkg/errors (as a direct
dependency), and bumps many transitive dependencies. The
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp bump to
v0.61.0 breaks "k8s.io/kubernetes/test/integration/apiserver: tracing"
consistently, so it's held back for now.

github.com/containerd/containerd/api pulls in gopkg.in/yaml.v3 so that
needs to be added to the exceptions in unwanted-dependencies.json.

Signed-off-by: Stephen Kitt <skitt@redhat.com>

Kubernetes-commit: 684473af6232a5d68a5585837837d1a96f009414
2025-06-05 17:17:56 +02:00
Kubernetes Publisher
827d117dc9 Merge pull request #131340 from anshuman-agarwala/sample-controller-doc
Added contribution info to sample-controller README

Kubernetes-commit: 45ac66e390bcce2ba0bc599700d5f7ee44988a02
2025-08-28 08:16:14 +00:00
Kubernetes Publisher
64ffad130b Merge pull request #133572 from HadrienPatte/ctx
Update `sharedInformerFactoryInterface` context initialization example

Kubernetes-commit: 9700dcde33f745cad8d53a583d1705bf9b1c7df1
2025-08-28 08:16:13 +00:00
Kubernetes Publisher
456925b454 Merge pull request #133571 from BenTheElder/deprecated-missing-oh-no
fix many incorrect deprecation warnings in godoc, enable deprecatedComment linter

Kubernetes-commit: 22a567ac31df68929f4cfb6e87a18d2399e37efe
2025-08-28 04:25:07 +00:00
Kubernetes Publisher
b1966cd259 Merge pull request #132686 from qiujian16/typo-fix
Fix a typo in fake clientset generator

Kubernetes-commit: e48518837fd6a17255fd81443c6b26b7adf24ef8
2025-08-28 00:27:30 +00:00
Kubernetes Publisher
8f7053dca9 Merge pull request #133570 from BenTheElder/pr131351
Clarify staging repository READMEs

Kubernetes-commit: 8082e9ab157b280c740a623ae9d73679b9ee95a4
2025-08-16 07:02:16 +00:00
Benjamin Elder
53010c2664 clarify that staging repos are automatically published
Kubernetes-commit: e49f6116f9eec5d48f2c8913e598fef496644d01
2025-08-15 14:33:07 -07:00
Benjamin Elder
aa8cf6d69c update-codegen
Kubernetes-commit: 668b3fe4afc17c8726e9520e1392a32eb09c70d9
2025-08-15 11:18:52 -07:00
Hadrien Patte
e0c4511c56 Update sharedInformerFactoryInterface context initialization example
Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>

Kubernetes-commit: ef1878c6013f44a4b5a8800033c73551ea77c91f
2025-08-15 20:15:36 +02:00
Benjamin Elder
df7a600266 update-codegen
Kubernetes-commit: 30f4fc9ca3852d8dcaa2a1c85a09b10ede3be96e
2025-08-15 10:42:51 -07:00
Benjamin Elder
50976229df add pointer to CONTRIBUTING.md for more details on contributing, clarify read-only
Kubernetes-commit: ada2ed8487708056ff11bd2413da1073558e6d7c
2025-08-15 10:13:18 -07:00
Benjamin Elder
2562806e6b link to what a staging repository is
Kubernetes-commit: 011d50019758a7405c6ff37f0fdbd44dacb607b5
2025-08-15 10:10:26 -07:00
Jian Qiu
103b36ee82 Fix a typo in fake clientset generator
Signed-off-by: Jian Qiu <jqiu@redhat.com>

Kubernetes-commit: ad47298caa65fd20386aeb453cf74964963c47c8
2025-07-02 23:50:04 +08:00
sAchin-680
eb03be131a docs: clarify that this is a staging repository and not for direct contributions
Signed-off-by: sAchin-680 <mrmister680@gmail.com>

Kubernetes-commit: 7c43e6d2fdbf88f8d92559dac3cabb23da2a2957
2025-04-17 17:51:45 +05:30
Kubernetes Publisher
8f92f95c74 Merge pull request #132942 from thockin/kyaml
Add KYAML support to kubectl

Kubernetes-commit: 1451dd1b0873e801e082f3a06a52685bcd68dcac
2025-07-25 03:16:22 +00:00
Kubernetes Publisher
288d79bffe Merge pull request #132935 from benluddy/cbor-bump-custom-marshalers
KEP-4222: Adopt text and JSON transcoding support for CBOR.

Kubernetes-commit: dfc0998baa4d6c2cd630aa3c5b8def4e9b1fcd8e
2025-07-24 23:15:52 +00:00
Tim Hockin
fa0a6b3a67 Re-vendor sigs.k8s.io/yaml @ v1.6.0
Kubernetes-commit: 8182a27f3b0769cefe1bcebfb938a7bafd51c88e
2025-07-24 11:46:03 -07:00
Ben Luddy
a1c561acfd Bump to github.com/fxamacker/cbor/v2 v2.9.0.
Kubernetes-commit: 917659269af60f8ca960deeb0991df93e5ad1635
2025-06-24 14:25:43 -04:00
Kubernetes Publisher
29730b0b8d Merge pull request #133020 from pohly/apimachinery-list-map-keys
support optional listMapKeys in server-side apply

Kubernetes-commit: d33af7f7efc7ff5d8813a85290189883167a5226
2025-07-17 17:39:12 +00:00
Jordan Liggitt
397d68980c sigs.k8s.io/structured-merge-diff/v6 v6.3.0
Kubernetes-commit: 4d34975a46658efd90274c5fe05d46732e04ca67
2025-07-16 16:57:41 -04:00
Kubernetes Publisher
2841a17108 Merge pull request #132871 from dims/bump-k8s.io/kube-openapi-to-latest-SHA-f3f2b991d03b
Bump k8s.io/kube-openapi to latest SHA (f3f2b991d03b) and sigs.k8s.io/structured-merge-diff/{v4 => v6}

Kubernetes-commit: 48e04d0d6c43cfc4729857775252b89b68d65b87
2025-07-15 09:40:29 +00:00
Davanum Srinivas
e6c15d6208 Bump k8s.io/kube-openapi to latest SHA (f3f2b991d03b)
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: ebc1ccc491c944fa0633f147698e0dc02675051d
2025-07-10 09:21:52 -04:00
Kubernetes Publisher
05a4c344f6 Merge pull request #132878 from ylink-lfs/chore/int32ptr_removal
chore: replace int32Ptr usage with ptr.To

Kubernetes-commit: 20114b2090791e191eff4417dfd56f50252fd714
2025-07-13 05:36:03 +00:00
ylink-lfs
64ae4a258c chore: replace int32Ptr usage with ptr.To
Kubernetes-commit: e0f9914ef726bd5bcafcdadf5a6a0a6e92d9a885
2025-07-11 09:11:04 +08:00
Kubernetes Publisher
346d1ccd4e Merge pull request #132675 from dims/bump-sigs-k8s-io-json-no-code-changes
Bump sigs.k8s.io/json to latest - no code changes

Kubernetes-commit: e47ac3eb6faa97874658dc281c72b5623f994801
2025-07-03 01:40:35 +00:00
Kubernetes Publisher
7df010cedd Merge pull request #132677 from dims/update-github.com/emicklei/go-restful/v3-to-v3.12.2
Update github.com/emicklei/go-restful/v3 to v3.12.2

Kubernetes-commit: 305c0e06c99ff9df013edd804294217a04e4dd31
2025-07-02 21:36:28 +00:00
Kubernetes Publisher
7bc04dd332 Merge pull request #132676 from dims/bump-go.yaml.in/yaml/v3-to-v3.0.4
Bump go.yaml.in/yaml/v3 to v3.0.4

Kubernetes-commit: 01c03ae9cf7b1371c8bc2bdf12d9244e63e83750
2025-07-02 17:40:53 +00:00
Davanum Srinivas
5a10d4d90a Update github.com/emicklei/go-restful/v3 to v3.12.2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: b44b0fbf1299c6821033076352b91914d2efef67
2025-07-02 08:00:43 -04:00
Davanum Srinivas
ed87332e7a Bump go.yaml.in/yaml/v3 to v3.0.4
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 58e620cc4403d30f9fb6aab245cfb47db17957de
2025-07-02 07:37:06 -04:00
Davanum Srinivas
b9998714de Bump sigs.k8s.io/json to latest - no code changes
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 00f8cbae6b8fd3799a1a044abcefdbb572d35b27
2025-07-02 07:32:24 -04:00
Kubernetes Publisher
0e57214ad6 Merge pull request #132654 from Jefftree/b-openapi
Bump kube-openapi

Kubernetes-commit: db49c25956df36c777213251c4a47d6d9ee1c5ea
2025-07-01 21:41:12 +00:00
Jefftree
7d0c13ceb8 Update vendor
Kubernetes-commit: d04ee27c98ba91680ac6c6a8ade9e33d7ee44569
2025-07-01 15:23:58 +00:00
Jefftree
03d7ae6902 pin kube-openapi to v0.0.0-20250628140032-d90c4fd18f59
Kubernetes-commit: b41d375b8881f25ff5fe7775b4dedaba1eaa3f02
2025-07-01 15:21:22 +00:00
Kubernetes Publisher
4c471f217d Merge pull request #132357 from dims/drop-usage-of-forked-copies-of-goyaml.v2-and-goyaml.v3
Drop usage of forked copies of goyaml.v2 and goyaml.v3

Kubernetes-commit: c1afec6a0b15ca1ed853c1321ac2c972488bf5b8
2025-06-25 18:00:15 +00:00
Kubernetes Publisher
e429018fdc Merge pull request #132504 from jpbetz/name-formats
Introduce OpenAPI format support for k8s-short-name and k8s-long-name

Kubernetes-commit: 1d932bd6cc951b9182d07d701946aebaf667df94
2025-06-25 18:00:14 +00:00
Davanum Srinivas
5441fec88d switch to latest sigs.k8s.io/yaml v1.5.0 (run update-gofmt.sh as well)
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: c5b4b133ce3252ee19b7167eb69a99d88fdefda8
2025-06-25 08:03:06 -04:00
Joe Betz
0b02bccc33 Bump to latest kube-openapi
Kubernetes-commit: dc323756cea2d1ebe32d7acb5a14a1769c14486f
2025-06-24 09:24:27 -04:00
Davanum Srinivas
f30b9055e0 Drop usage of forked copies of goyaml.v2 and goyaml.v3
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 3827d3bc4f1c17ac816b37422dbd449c276e9ff0
2025-06-17 11:00:27 -04:00
Kubernetes Publisher
8f25d454c9 Merge pull request #132221 from dims/new-cmp-diff-impl
New implementation for `Diff` (drop in replacement for `cmp.Diff`)

Kubernetes-commit: 3e39d1074fc717a883aaf57b966dd7a06dfca2ec
2025-06-17 04:00:30 +00:00
Davanum Srinivas
543dc0a2ff Add a replacement for cmp.Diff using json+go-difflib
Co-authored-by: Jordan Liggitt <jordan@liggitt.net>
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 03afe6471bdbf6462b7035fdaae5aa0dd9545396
2025-06-10 23:08:41 -04:00
Kubernetes Publisher
3ec97ed863 Merge pull request #132269 from dims/update-to-latest-github.com/modern-go/reflect2
Update to latest github.com/modern-go/reflect2

Kubernetes-commit: d55b119d34883bbad2a3436dcb6c62339d963031
2025-06-12 20:34:01 +00:00
Davanum Srinivas
d74cb14408 Update to latest github.com/modern-go/reflect2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 3908550c0dc189cfa9de38a84bee508fa0659463
2025-06-12 11:20:39 -04:00
Kubernetes Publisher
ba279de7b0 Merge pull request #132103 from nojnhuh/typed-ring-buffer
Replace queue.FIFOs with k8s.io/utils/buffer.Ring

Kubernetes-commit: 5090812df4fb6cf09a9181635d90c2e154eab8cc
2025-06-06 20:40:04 +00:00
Kubernetes Publisher
51b8e5bb91 Merge pull request #132110 from jpbetz/gengo-bump
Bump gengo/v2 to latest, pick up related validation-gen fixes

Kubernetes-commit: 4fff091ce7c8b22e6a511231e400adb865a7b300
2025-06-05 20:51:07 +00:00
Joe Betz
691b6a2532 Bump gengo/v2 to latest
Kubernetes-commit: ac5cb23000f57b7b034fa98e5cc4f6e8fb6e8a9c
2025-06-04 22:39:08 -04:00
Jon Huhn
87203eaf5b Update k8s.io/utils for new generic ring buffer
Kubernetes-commit: 8cdbbf5cdaef7e37cfd432e9044aa52f4d42adcd
2025-06-04 12:09:53 -05:00
Kubernetes Publisher
099b2a3118 Merge pull request #128419 from liggitt/etcd-3.6
etcd 3.6 client update

Kubernetes-commit: 09ca440a450e9103a8f835f598c09237dba6ecbb
2025-05-16 04:11:49 +00:00
Jordan Liggitt
2a669316dc bump etcd client to 3.6
hack/pin-dependency.sh go.etcd.io/etcd/api/v3 v3.6.0
hack/pin-dependency.sh go.etcd.io/etcd/client/pkg/v3 v3.6.0
hack/pin-dependency.sh go.etcd.io/etcd/client/v3 v3.6.0
hack/pin-dependency.sh go.etcd.io/etcd/pkg/v3 v3.6.0
hack/pin-dependency.sh go.etcd.io/etcd/server/v3 v3.6.0

hack/pin-dependency.sh github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.0

hack/update-vendor.sh

Kubernetes-commit: cf0bbf1171e918d5d7ba1d3c83b5f347fc8333b0
2025-05-15 21:19:11 -04:00
Kubernetes Publisher
f1c34d2ae3 Merge pull request #131777 from BenTheElder/exit-codes
verify scripts: preserve exit code

Kubernetes-commit: 4786e6e8e00adba3577e86f6b2dc1c17702cb562
2025-05-15 21:09:29 +00:00
Benjamin Elder
938de50954 verify scripts: preserve exit code
these scripts used the result variable pattern but then explicitly exited early with a hardcoded value ....

Kubernetes-commit: ef0547741db55186218fe6368de5fc88314b9355
2025-05-14 21:19:45 -07:00
Kubernetes Publisher
e3aa220283 Merge pull request #131595 from aojea/utils_fake_clock
update k8s.io/utils to bring fakeClock.Waiters()

Kubernetes-commit: e3e1f80c0110c847acf4381b1790c1c667395010
2025-05-03 03:54:20 +00:00
Antonio Ojea
e22232106c update k8s.io/utils to bring fakeClock.Waiters()
Change-Id: I7e25338df225c2c27457403fbc2f158d08638f87

Kubernetes-commit: c2c003a71fc52fa79c2fff0109afad58573d0216
2025-05-02 11:21:11 +00:00
Kubernetes Publisher
dfc5de248a Merge pull request #130989 from liggitt/creationTimestamp-omitzero
Omit null creationTimestamp

Kubernetes-commit: 01899a7c86337b05a16a4155c9351cf947beaee9
2025-05-02 23:57:19 +00:00
Anshuman
8ad5ef3731 Added contribution info to sample-controller README
Kubernetes-commit: a79865c00162af4a7220bbc09405769da58c36ce
2025-04-17 11:17:35 +05:30
Jordan Liggitt
6400995a81 bump cbor to add omitzero support
Kubernetes-commit: bc6051717137cef288b82305588e675de4a32c0d
2025-03-25 12:27:43 -04:00
Jordan Liggitt
5639212f69 bump structured-merge-diff to add omitzero support
Kubernetes-commit: 06b0784062f68566daa8eed83c475b738dcf620c
2025-03-24 16:34:01 -04:00
Kubernetes Publisher
bf17c5e1fa Merge pull request #130995 from xigang/utils
bump k8s.io/utils for improvements

Kubernetes-commit: 43a7d3be12425cc80ca6ad3599809a19728c5566
2025-04-23 23:53:01 +00:00
Kubernetes Publisher
51cafa0f09 Merge pull request #131103 from ahrtr/etcd_sdk_20250328
Bump etcd 3.5.21 sdk

Kubernetes-commit: f4d1686120d2367dd4c00df53e93dad51c414435
2025-04-01 11:09:48 +00:00
Benjamin Wang
e62ea3dcf7 bump etcd 3.5.21 sdk
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>

Kubernetes-commit: f3b80a858225178e3f7a3ae07bd1b9894e7b3456
2025-03-28 14:30:47 +00:00
xigang
af47c26918 bump k8s.io/utils
Kubernetes-commit: fe14689f221a968806b771b226581efb834654cd
2025-03-22 10:14:01 +08:00
Kubernetes Publisher
693639fcd1 Merge pull request #129872 from seans3/websocket-https-proxy
WebSocket HTTPS Proxy support

Kubernetes-commit: 6f13ba03dac1865174b4edf2b43f6a0f453a8ac7
2025-03-21 06:26:12 +00:00
Sean Sullivan
e4ff57e343 Websocket HTTPS proxy support
Kubernetes-commit: f73945aae56b51078318199ff2f0ecae91bc489e
2025-01-29 03:56:55 +00:00
Kubernetes Publisher
89e0121302 Merge pull request #130906 from serathius/streaming-validation
Update kube-openapi and integrate streaming tags validation

Kubernetes-commit: 32b1819423de505da855cf7544e871a04e63d6ed
2025-03-19 06:03:04 +00:00
Marek Siarkowicz
ce8d686b7b Update kube-openapi and integrate streaming tags validation
Kubernetes-commit: 75a4d136abac241f728407515e3d0d8305594675
2025-03-18 21:26:22 +01:00
Kubernetes Publisher
8d0ea34df0 Merge pull request #130555 from thockin/k_k_randfill
Use randfill in k/k

Kubernetes-commit: 0f2bde7745f3b4eadcf317bc5056dfeb96859bd3
2025-03-09 14:05:04 +00:00
Tim Hockin
7fab776bfd Vendor randfill
Kubernetes-commit: 0ce4268b1fe4f78d77249e329b0349b9d2dd2c65
2025-03-03 23:46:48 -08:00
Kubernetes Publisher
07399a2cd2 Merge pull request #130569 from dims/update-to-latest-cadvisor-v0.52.0
Update to latest cadvisor @ v0.52.1 and new opencontainer/cgroups and drops opencontainers/runc

Kubernetes-commit: 0eaee48ecb8669dc65bfdf9a3583326ab88fc39d
2025-03-08 02:02:54 +00:00
Davanum Srinivas
4aa60993eb update to v1.22.0-rc.0
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 97a54dc4b04b7d2938d11c5ae9a6233348e854ef
2025-03-07 13:45:34 -05:00
Kubernetes Publisher
a1ba45bdc7 Merge pull request #130489 from p0lyn0mial/upstream-fake-client-pass-opts
client-gen/fake: pass ListOptions to Watch method

Kubernetes-commit: ea49618a749b84c3cb5bd781380891eb51289950
2025-03-07 17:59:51 +00:00
Davanum Srinivas
39601acdc4 update to latest cadvisor @ v0.52.0
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 5ecddb65715af7e2afc4f3cbb1abe393bfb4346a
2025-03-04 14:29:08 -05:00
Kubernetes Publisher
66fc52bd52 Merge pull request #130349 from jpbetz/validation-gen-pr1
KEP-5073: Declarative Validation: Add validation generator

Kubernetes-commit: a5dda5d879cdae6562134ca7881ddf7f672f595d
2025-03-03 22:19:07 +00:00
Joe Betz
58de05657d Bump gengo/v2 to latest
Co-authored-by: Tim Hockin <thockin@google.com>
Co-authored-by: Aaron Prindle <aprindle@google.com>
Co-authored-by: Yongrui Lin <yongrlin@google.com>
# Conflicts:
#	vendor/modules.txt

Kubernetes-commit: 7f5e1baeeea7382e45cfba7676b69459fbce8b12
2025-03-03 09:49:50 -05:00
Kubernetes Publisher
d8ed379c1e Merge pull request #128919 from dashpole/update_otel
Update go.opentelemetry.io dependencies to v1.33.0/v0.58.0

Kubernetes-commit: eea2f78e61fe91bb8fcd3c4a357ea3a10d1389db
2025-03-02 00:33:21 +00:00
David Ashpole
12d8f68b34 update go.opentelemetry.io dependencies to v1.33.0/v0.58.0
Kubernetes-commit: 29c219dcebe30be99d6917623f8d8707a47194c1
2025-03-01 19:17:16 +00:00
Kubernetes Publisher
6c961d433b Merge pull request #130474 from dims/bump-x/crypto-and-x/oauth2
Bump x/oauth2 and x/crypto

Kubernetes-commit: 01ed8ed4ff0a0cbea99370c7a268019829d19e82
2025-02-28 20:34:51 +00:00
Lukasz Szaszkiewicz
6e82beaa11 ./hack/update-codegen.sh
Kubernetes-commit: 325a54f73dcdc5fc7a7d47bd78791abcba93456a
2025-02-28 09:43:58 +01:00
Kubernetes Publisher
07ef4900ff Merge pull request #129688 from cpanato/update-main-go124
[go] Bump images, dependencies and versions to go 1.24.0

Kubernetes-commit: b8c95e1954ef222988c0dfe5b45d5cc96c09bcb8
2025-02-27 20:36:45 +00:00
Davanum Srinivas
b6fb84a750 Bump x/oauth2 and x/crypto
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 0fede7b8a2fb4c7f120876c9ef1e826f8ef28da2
2025-02-27 10:59:37 -05:00
cpanato
672c3e0618 bump go.mod to set min go1.24
Signed-off-by: cpanato <ctadeu@gmail.com>

Kubernetes-commit: 88300c406b9199ed017e1bada29951fc18e66ae1
2025-02-25 13:21:52 +01:00
Kubernetes Publisher
a60690ab78 Merge pull request #130187 from mansikulkarni96/129084
fix:  Sweep and fix stat, lstat, evalsymlink usage for go1.23 on Windows

Kubernetes-commit: ef54ac803b712137871c1a1f8d635d50e69ffa6c
2025-02-23 00:17:26 +00:00
Jordan Liggitt
4c308b3993 Drop winsymlink go 1.23 workaround
(cherry picked from commit 3990b6324d0427eaf9ff970da2be02711567ef5f)

Kubernetes-commit: 1f642c79c3192994e76bbe8e7360fd661cd21ab4
2025-02-06 12:45:52 -05:00
Kubernetes Publisher
a8afb009bc Merge pull request #130249 from seans3/bump-websockets-version
Update gorilla/websockets library from 1.5.0 to latest 1.5.3

Kubernetes-commit: 728dc0d8c7a4d68157b2106330b65abcd5faac87
2025-02-19 04:20:29 +00:00
Sean Sullivan
e0cdd5a973 Update gorilla/websockets library from 1.5.0 to latest 1.5.3
Kubernetes-commit: 3100bbab2f7f013b08910f28d8a3debc28a57ea9
2025-02-19 00:26:21 +00:00
Kubernetes Publisher
8ab9f14766 Merge pull request #129341 from pohly/log-client-go-watch
client-go watch: context support

Kubernetes-commit: a02fe24385a36f43e96844e19c438cc4097704ef
2025-02-07 13:34:27 +00:00
Patrick Ohly
144c6b454a client-go informers: provide ListWatch *WithContext variants
For compatibility reasons, the old functions without the ctx parameter still
get generated, now with context.Background instead of context.TODO. In practice
that code won't be used by the client-go reflector code because it prefers
the *WithContext functions, but it cannot be ruled out that some other code
only supports the old fields.

Kubernetes-commit: 8cc74e8a266e1042be1c60adfa3091852036f48a
2024-12-09 16:04:52 +01:00
Kubernetes Publisher
f94f578f4c Merge pull request #127709 from pohly/log-client-go-rest
client-go/rest: finish context support

Kubernetes-commit: 427cd18f726be3e3c4f657258dc17a97beca92d5
2025-01-22 21:17:06 +00:00
Patrick Ohly
ec76c5d4a5 client-go/rest: backoff with context support
The BackoffManager interface sleeps without considering the caller's context,
i.e. cancellation is not supported. This alone is reason enough to deprecate it
and to replace it with an interface that supports a context parameter.

The other reason is that contextual logging needs that parameter.

Kubernetes-commit: b15a1943d51adfb8c5e0185d58d25e038c3d6ade
2024-09-02 20:18:47 +02:00
Kubernetes Publisher
02ac61a70f Merge pull request #129633 from skitt/revert-go-difflib-go-spew
Revert to go-difflib and go-spew releases

Kubernetes-commit: 6d570c923f66a1f214d0c3ba3eddd9a0cd0fae68
2025-01-15 20:53:06 +00:00
Stephen Kitt
22f128b893 Revert to go-difflib and go-spew releases
The last dependency pulling in the tips of go-difflib and go-spew has
reverted to the last release of both projects, so k/k can revert to
the releases too. As can be seen from the contents of vendor, this
doesn't result in any actual change in the code.

Signed-off-by: Stephen Kitt <skitt@redhat.com>

Kubernetes-commit: 3986472b3c7202716f92e586ccfaa4b4fe573dc5
2025-01-15 09:07:27 +01:00
Kubernetes Publisher
9595b8e4ba Merge pull request #129139 from tklauser/client-setconfigdefaults-noerror
Remove always-`nil` `setConfigDefaults` error return value in generated clients

Kubernetes-commit: 2331c028c2000f7d31efeeb405d8151a78a9de9c
2025-01-09 17:25:50 +00:00
Kubernetes Publisher
a3e089d3f3 Merge pull request #129349 from dims/bump-x/net-to-v0.33.0
Bump x/net to v0.33.0

Kubernetes-commit: b7ef173c59065f9a5f68eb514ef0483c6f3887ae
2025-01-06 20:50:56 +00:00
Kubernetes Publisher
60444d9524 Merge pull request #128872 from alvaroaleman/generics
Use generic btree in watchcache

Kubernetes-commit: 8f8c94a04d00e59d286fe4387197bc62c6a4f374
2025-01-03 16:50:43 +00:00
Alvaro Aleman
899bfac2d1 Update github.com/google/btree
Kubernetes-commit: a97ed3c98bcd2c520260aa04c516a24e975e7d69
2025-01-02 19:44:07 -05:00
Kubernetes Publisher
7318a64a21 Merge pull request #129000 from RogerTaylor130/fix-log-info-in-sample-controller
Fix the log for current and desired number of replicas in sample controller

Kubernetes-commit: e85c72d4177fba224cb1baa1b5abfb5980e6d867
2024-12-23 12:38:47 +00:00
Davanum Srinivas
b7ee1c7ec2 Bump x/net to v0.33.0
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 0b6e3718340fa7e3846cf9b7d5a0f7a684a6fa5a
2024-12-20 14:30:57 -05:00
Tobias Klauser
399ae99195 Update generated clients after removing always-nil setConfigDefaults error return value
Kubernetes-commit: 2c24a12804ca0020e57592a6844f7c5874dffcfe
2024-12-15 23:19:18 +01:00
Kubernetes Publisher
79f2fa75d9 Merge pull request #129213 from Jefftree/k-openapi
Bump kube-openapi

Kubernetes-commit: 13eb074ddd231d127709f0410185eeca68a69c8a
2024-12-14 02:19:04 +00:00
Jefftree
b61d994667 bump kube-openapi
Kubernetes-commit: 3269f4bb94c58dfe577621c42f88ea06fbdd79a7
2024-12-13 20:50:49 +00:00
Kubernetes Publisher
4ad644936e Merge pull request #129195 from dims/update-x/crypto/ssh-dependency
Update x/crypto/ssh dependency to v0.31.0

Kubernetes-commit: b21ab179c74a270cd276d2dbb5f4b55730838096
2024-12-13 10:19:35 +00:00
Davanum Srinivas
896025e7d4 Update x/crypto/ssh dependency
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 80735180ab2c61232dcc4646e693ddcaeaf96ca3
2024-12-12 20:46:15 -05:00
Kubernetes Publisher
83aeffcb58 Merge pull request #129054 from pohly/remove-import-name
remove import doc comments

Kubernetes-commit: e8615e27125518f0ed0ba06244b7ecee21451bb0
2024-12-12 10:15:54 +00:00
Kubernetes Publisher
ea0e0b7498 Merge pull request #129103 from liggitt/drop-winreadlinkvolume
Drop use of winreadlinkvolume godebug option

Kubernetes-commit: bfe431b53e600c9a36c46eef0f6ecfcf37265d60
2024-12-06 19:17:53 +00:00
Jordan Liggitt
75f87df755 Drop use of winreadlinkvolume godebug option
Kubernetes-commit: 3046fe23d4fe4ba86713ffd61bf0e07156b2b7c3
2024-12-06 02:40:53 -05:00
Kubernetes Publisher
514a781e50 Merge pull request #129083 from liggitt/go1.23windows
Revert to go1.22 windows filesystem stdlib behavior

Kubernetes-commit: 6fc64a261c1dca857a5a7fd1bc87fae38dbe1c8a
2024-12-04 22:51:54 +00:00
Jordan Liggitt
7fd85f78b1 Revert to go1.22 windows filesystem stdlib behavior
Kubernetes-commit: 3878a3a6de64660e356a35f70471c27a09698090
2024-12-04 09:52:56 -05:00
Patrick Ohly
15280d852f remove import doc comments
The "// import <path>" comment has been superseded by Go modules.
We don't have to remove them, but doing so has some advantages:

- They are used inconsistently, which is confusing.
- We can then also remove the (currently broken) hack/update-vanity-imports.sh.
- Last but not least, it would be a first step towards avoiding the k8s.io domain.

This commit was generated with
   sed -i -e 's;^package \(.*\) // import.*;package \1;' $(git grep -l '^package.*// import' | grep -v 'vendor/')

Everything was included, except for
   package labels // import k8s.io/kubernetes/pkg/util/labels
because that package is marked as "read-only".

Kubernetes-commit: 8a908e0c0bd96a3455edf7e3b5f5af90564e65b0
2024-12-02 14:43:58 +01:00
LongKang Fan
8c25b57bd0 change current and desired
Kubernetes-commit: 79d62d8bb3b07abbcae099b7d41b9481c1c33ba0
2024-11-27 18:02:53 +08:00
Kubernetes Publisher
07e95b8efb Merge pull request #126503 from skitt/generic-fake-client
Use generics to share code in fake client-go implementations

Kubernetes-commit: 31970d418ccae80c9c7e25e8c503035a79a53763
2024-11-08 21:31:45 +00:00
Stephen Kitt
4b0986096a Run codegen
Signed-off-by: Stephen Kitt <skitt@redhat.com>

Kubernetes-commit: be03bcf3244e6c280b8aaf7a638d1926f0960eab
2024-08-01 12:10:10 +02:00
Kubernetes Publisher
5f8b8a4994 Merge pull request #128580 from jpbetz/bump-kube-openapi
Bump kube-openapi to latest

Kubernetes-commit: 9a2a7537f035969a68e432b4cc276dbce8ce1735
2024-11-05 23:33:54 +00:00
Joe Betz
95ef55ca90 hack/pin-dependency.sh k8s.io/kube-openapi 32ad38e42d3faf1ce94eb29f4ea6d763339b258e
Kubernetes-commit: f2157ff73e3c9b7c2a36bf371e388e8976d93975
2024-11-05 10:18:57 -05:00
Kubernetes Publisher
29c40aa213 Merge pull request #128507 from dims/use-k8s.io/utils/lru-instead-of-github.com/golang/groupcache/lru
Use k8s.io/utils/lru instead of github.com/golang/groupcache/lru

Kubernetes-commit: 7a4d755644e83dfade7bbc4c240c204a9e54d9c0
2024-11-04 23:34:05 +00:00
Davanum Srinivas
b444f70d3d Use k8s.io/utils/lru instead of github.com/golang/groupcache/lru
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 2b0592ee77d0a0bb3017df042066ecb8c83d2fb3
2024-11-01 22:19:11 -04:00
Kubernetes Publisher
bcb163000a Merge pull request #128481 from carlory/dependencies-ginkgo-gomega
dependencies: ginkgo v2.21.0, gomega v1.35.1

Kubernetes-commit: 88a997ac01cd8a386df9318d81b89257307f53fb
2024-11-01 19:34:21 +00:00
carlory
f76befa4d9 dependencies: ginkgo v2.21.0, gomega v1.35.1
Kubernetes-commit: 80b1a297865500891bd823005ace761becae5dbf
2024-11-01 11:35:24 +08:00
Kubernetes Publisher
eda94daae5 Merge pull request #128416 from jpbetz/reset-filter
Add optional ResetFieldsFilterStrategy interface for storage

Kubernetes-commit: b831df733e5cf244331f61fffb0ba86787b27236
2024-11-01 04:26:44 +00:00
Joe Betz
8cdea63f4a hack/pin-dependency.sh sigs.k8s.io/structured-merge-diff/v4 v4.4.2
Kubernetes-commit: 6fe51403665f1b6e820226004817b92e3118cabc
2024-10-31 21:19:15 -04:00
Kubernetes Publisher
f601947988 Merge pull request #128323 from benluddy/cbor-client-gen
KEP-4222: Support CBOR for generated clients based on client-go feature gating.

Kubernetes-commit: 30ee35516b10120590bcc35ee8b4d8113493ddee
2024-10-29 19:37:44 +00:00
Ben Luddy
cbb61c01d5 Update generated clients.
Kubernetes-commit: 8fb9622b882496dad1e91103dd15fff7fc2658e0
2024-10-24 16:50:48 -04:00
Kubernetes Publisher
a603ed3924 Merge pull request #125314 from enj/enj/i/proto_for_core
Use protobuf for core clients

Kubernetes-commit: 7b7a7968d4c90c4430b1009546e13ce78bcde134
2024-10-24 18:25:28 +00:00
Monis Khan
e5ade25dbd Generated
Signed-off-by: Monis Khan <mok@microsoft.com>

Kubernetes-commit: 032e7f1556c74dbc25b5ed9368b2e86e26ba774f
2024-10-23 15:33:57 +00:00
Kubernetes Publisher
62f962e925 Merge pull request #128165 from liggitt/prune-self-require
Drop self-referencing replace directives

Kubernetes-commit: a8fc7ae761c19ab436cf513c9eed877f08961cf7
2024-10-18 04:58:44 +00:00
Jordan Liggitt
7090da4eb4 Drop self-referencing replace directives
Kubernetes-commit: 3be1109829d4b0921972bb8b5f66a4d179ff6255
2024-10-17 15:51:15 -04:00
Kubernetes Publisher
8ca14959e1 Merge pull request #128064 from dims/update-to-last-versions-of-some-very-infrequently-updated-repos
Update to last versions of some very infrequently updated repos

Kubernetes-commit: 07e73682b9a5259cacac978346ed4567588e4165
2024-10-16 06:27:23 +00:00
Davanum Srinivas
7c17071caf Update to last versions of some very infrequently updated repos
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 7f8210e33f8cd626d1fb86cd7d12d077ec3047d5
2024-10-14 17:23:16 -04:00
Kubernetes Publisher
88c297c7c7 Merge pull request #127998 from skitt/golang-x-oct-2024
October 2024 golang.org/x bump

Kubernetes-commit: 8cbb11519c54c120e2dc120a4799e53abbfea4a4
2024-10-11 14:44:49 +00:00
Kubernetes Publisher
a32610b600 Merge pull request #127985 from dims/update-moby-runc-dependencies-oct-10
Update moby/runc dependencies

Kubernetes-commit: 6e5e8f374e834fa8dab341bde5c522704ed55ba6
2024-10-11 14:44:48 +00:00
Stephen Kitt
0a64d8f2b7 October 2024 golang.org/x bump
Nothing major here, but nothing liable to cause pain to downstreams
either.

* https://github.com/golang/crypto/compare/v0.26.0...v0.28.0 (there’s
  a SHA3 fix there but it’s only relevant for 32-bit platforms)
* https://github.com/golang/net/compare/v0.28.0...v0.30.0 (mostly
  http2; route address parsing fix on Darwin)
* https://github.com/golang/oauth2/compare/v0.21.0...v0.23.0 (Google
  license fix)
* https://github.com/golang/sys/compare/v0.23.0...v0.26.0 (faster
  getrandom() on Linux through the vDSO; improved RISC-V support)
* https://github.com/golang/term/compare/v0.23.0...v0.25.0
* https://github.com/golang/time/compare/v0.3.0...v0.7.0 (0-limit
  handling fix in x/time/rate; Google license fix)
* https://github.com/golang/tools/compare/v0.24.0...v0.26.0

This doesn’t include golang.org/x/exp; that doesn’t have any relevant
changes. There’s an apidiff fix but we always pull in the latest
apidiff anyway.

Signed-off-by: Stephen Kitt <skitt@redhat.com>

Kubernetes-commit: 6c5a528727c30803d4426b29c06ae5d350619877
2024-10-11 10:22:13 +02:00
Davanum Srinivas
e4fea64fd2 Update moby/runc dependencies
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 521f2d106b9c5744ce57a8ec03124bcdadbca986
2024-10-10 11:58:22 -04:00
Kubernetes Publisher
d34add311b Merge pull request #127942 from liggitt/json123
sigs.k8s.io/json go 1.23 bump

Kubernetes-commit: fc318e3ba4cb1db822d7f802993059846f64179d
2024-10-10 22:25:14 +00:00
Jordan Liggitt
378e4ba36b Update sigs.k8s.io/json to go1.23
Kubernetes-commit: 8eff759b6ac7c3bb0c6a8823c751f5a578d6f721
2024-10-10 11:00:11 -04:00
Kubernetes Publisher
0baada3a93 Merge pull request #126764 from liggitt/mergo
reimplement merge to drop mergo dependency

Kubernetes-commit: ee74baec6e05afde972f1a8705d4f8efe066f120
2024-09-28 08:52:17 +00:00
Jordan Liggitt
05c2b2776c Update vendor
Kubernetes-commit: 745ae75a15cad2f1c5da5518c00f2eb366ffb786
2024-08-17 21:42:00 -04:00
Kubernetes Publisher
ebd9b61e65 Merge pull request #127579 from chrishenzie/context
Propagate existing ctx instead of context.TODO() in sample-controller

Kubernetes-commit: f3a54b68f9aaae9176a8be412bf5f9548c25175b
2024-09-25 04:44:29 +00:00
Chris Henzie
25ce433e5c Propagate existing ctx instead of context.TODO()
Kubernetes-commit: 3f1c41d53ebfcda5b5d39230426a095c135463af
2024-09-23 14:40:07 -07:00
Kubernetes Publisher
17d15174a7 Merge pull request #127271 from liggitt/go1.23
Update go.mod for go 1.23

Kubernetes-commit: c775fb2238e1ed48f62f02898bbb3ecee993e044
2024-09-12 04:46:12 +00:00
Jordan Liggitt
7a42685324 Update k8s.io/gengo/v2
Kubernetes-commit: e7957232cfcfaad1da50252653dea94ac22dc681
2024-09-11 15:38:38 -04:00
Jordan Liggitt
a3f963c7ef Pin godebug default to go1.23
Kubernetes-commit: 102a9dbab1764e8793d0237b25143fa49cd96831
2024-09-10 12:22:40 -04:00
Jordan Liggitt
521120ea29 Update go.mod to go 1.23
Kubernetes-commit: 65ef53139012dee36c08f558604dea48af170e11
2024-09-10 12:07:06 -04:00
Kubernetes Publisher
b47e2d4b30 Merge pull request #127011 from jpbetz/format-only-imports
gengo performance: Speed up update-codegen.sh by switching to FormatOnly in gengo

Kubernetes-commit: 95956671d8da7783a726133709b8085f56dda052
2024-09-04 04:00:32 +00:00
Joe Betz
47cd9c2a21 generate
Kubernetes-commit: 2595aa13098355414a558b2d97c58d505ca7b6c2
2024-09-03 14:25:56 -04:00
Joe Betz
7a10b052b6 Bump gengo/v2 to pick up FormatOnly setting for imports
Co-authored-by: Tim Hockin <thockin@google.com>

Kubernetes-commit: d5555af62bf25ba9ff0b979fe048b992596cf2cc
2024-09-03 11:32:09 -04:00
Kubernetes Publisher
b373ef5a9b Merge pull request #126787 from Jefftree/update-kube-openapi
Bump k8s.io/kube-openapi and k8s.io/gengo

Kubernetes-commit: f1a922c8e6f951381450ee3c2922ca018f14a82e
2024-08-27 23:59:20 +00:00
Jefftree
d182b5befa re-vendor k8s.io/kube-openapi
Kubernetes-commit: ea2bdb6334ec1a2821a96163d83480d5fdb1861b
2024-08-27 01:58:39 +00:00
Jefftree
97b3fc5823 re-vendor k8s.io/gengo/v2
Kubernetes-commit: 6dc87bf173642ff5c8183eb2717377e787e713a9
2024-08-27 01:56:06 +00:00
Kubernetes Publisher
292cd01e3a Merge pull request #126405 from sttts/sttts-sync-informerfactory-start
Call non-blocking informerFactory.Start synchronously to avoid races

Kubernetes-commit: ba6141a1457cf8dad08fb08724b390f9dfd84489
2024-07-27 21:29:51 +00:00
Jefftree
6b8701f30b informers: add comment that Start does not block
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>

Kubernetes-commit: cd69335542fd961b69b4e83b6433d1b40d2f4439
2024-07-27 15:47:24 +00:00
Kubernetes Publisher
bbe19029d1 Merge pull request #126018 from aroradaman/bump-k8s-utils
bump k8s.io/utils

Kubernetes-commit: 46aa8959a0659e22c924bb52b38385d441715b2b
2024-07-13 18:59:14 +00:00
Daman Arora
16c4c69f34 bump k8s.io/utils
Signed-off-by: Daman Arora <aroradaman@gmail.com>

Kubernetes-commit: c6a129b715646163ef83f94245c3756cbc191c42
2024-07-12 14:40:22 +05:30
Kubernetes Publisher
8973d9a480 Merge pull request #125922 from dims/update_otel_27
Update opentelemetry dependencies to the latest release (Take 2)

Kubernetes-commit: 07cc20a7509e7322e6ebb04e60d8274f27d6fdd7
2024-07-07 03:00:46 +00:00
Kubernetes Publisher
71e75ebdff Merge pull request #123099 from MikeSpreitzer/update-sample-controller
Update the sample controller

Kubernetes-commit: 08e1ceaa0d0e145378ab4cf8cad9123364169cd5
2024-07-06 23:10:06 +00:00
Davanum Srinivas
9498624163 update OpenTelemetry dependencies and grpc
This update dropped the otelgrpc → cloud.google.com/go/compute dependency,
among others. This dropped out because genproto cleaned up it's dependencies
on google cloud libraries, and otel updated - details in #113366.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
Co-Authored-By: David Ashpole <dashpole@google.com>

Kubernetes-commit: ff7942be83ed0c0aaa8c258e8e2b9965d383935c
2024-07-05 12:10:07 -04:00
Mike Spreitzer
cd970a4c9d Finish switching to utilruntime.HandleErrorWithContext
Signed-off-by: Mike Spreitzer <mspreitz@us.ibm.com>

Kubernetes-commit: fdbf0bbb2d85c3095fdc9625620648fb861fce6a
2024-07-03 10:36:51 -04:00
Kubernetes Publisher
9b42874209 Merge pull request #125759 from dims/bump-prometheus/common-v0.55.0
Bump `prometheus/common` to v0.55.0

Kubernetes-commit: 4c44efe81c9a26d66cdf88e917aeee75dad12299
2024-06-28 06:51:54 +00:00
Kubernetes Publisher
6e7ada25b3 Merge pull request #125766 from dims/update-moby/spdystream-to-v0.4.0
Update moby/spdystream to v0.4.0

Kubernetes-commit: 742b2f70b9e5c1ec03682ad25dc76fdcc7109310
2024-06-27 22:51:23 +00:00
Davanum Srinivas
c479647ba6 Update moby/spdystream to v0.4.0
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 377a3f7ec4dc2b5e09e0aadb651999d400c31538
2024-06-27 13:07:47 -04:00
Davanum Srinivas
83655e1a22 Bump prometheus/common to v0.55.0
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 35ccdc8b35f1c4346071d4ff0efecdd7a6bcdecc
2024-06-27 07:58:24 -04:00
Kubernetes Publisher
f0104a4756 Merge pull request #125745 from BenTheElder/ping-ping
bump  github.com/moby/spdystream to v0.3.0

Kubernetes-commit: 11446a394fb851d3496d31d96a67f8fcba6348e3
2024-06-26 22:53:16 +00:00
Benjamin Elder
1459600839 bump github.com/moby/spdystream to v0.3.0
picks up fix for data-race in Ping

Kubernetes-commit: c5aa8fdc711982dd589a9ac940b05297cc46b4a5
2024-06-26 12:27:14 -07:00
Kubernetes Publisher
1ed62253c3 Merge pull request #125731 from dashpole/revert_otel
Revert "Update opentelemetry dependencies to the latest release."

Kubernetes-commit: a4b8d0faa8e7d3227cbdda39241998d38f1c294e
2024-06-26 18:52:32 +00:00
David Ashpole
d3ccb2d8bf Revert "update OpenTelemetry dependencies"
This reverts commit 82e9ce79c763f1028f542b1246114082430e6b20.

Kubernetes-commit: e94047c9002c17a3b76513c3cde2d53aed39b7fb
2024-06-26 14:13:33 +00:00
Kubernetes Publisher
9120d4aad9 Merge pull request #125669 from benluddy/cbor-bump-v2.7.0
KEP-4222: Bump github.com/fxamacker/cbor/v2 to v2.7.0.

Kubernetes-commit: beb48b7f5df83cd56275f471e52ef588ba845093
2024-06-26 07:22:25 +00:00
Ben Luddy
c3ea129d32 Bump github.com/fxamacker/cbor/v2 to v2.7.0.
Kubernetes-commit: dbe4c093d9f5b85fa509042556edf61fb6503b22
2024-06-24 09:49:40 -04:00
Kubernetes Publisher
1fd110d244 Merge pull request #125575 from dashpole/update_otel_27
Update opentelemetry dependencies to the latest release.

Kubernetes-commit: 535e833aef9718d1a19a8f71b3a4639fc92aa855
2024-06-26 07:22:24 +00:00
Kubernetes Publisher
f646ff804f Merge pull request #125560 from jpbetz/apply-gen-fake
Add field management support to fake client-go typed client

Kubernetes-commit: d236a9127fe36317bb35854d63b275d7efdb399e
2024-06-26 07:22:23 +00:00
Joe Betz
28a761e479 Generate code
Kubernetes-commit: 7772769d19a82a26aa91181e0804ff2ccbdd843c
2024-06-24 15:58:35 -04:00
Kubernetes Publisher
37d10893a3 Merge pull request #125672 from jpbetz/patch-5
Add jpbetz to sampler-controller OWNERS

Kubernetes-commit: 09af6a3b94fa1db4cb036a95c3a89edcd9c7f88a
2024-06-24 18:27:20 +00:00
Joe Betz
f34cbee1a6 Add jpbetz to sampler-controller OWNERS
Per api-machinery SIG TL responsibilities

Kubernetes-commit: ef4cd4fdb597786359cc068c9c5f06d27b55b91b
2024-06-24 15:42:34 +00:00
Kubernetes Publisher
1fcc6fd2d4 Merge pull request #125531 from pohly/klog-update
dependencies: klog v2.130.1

Kubernetes-commit: 44446e1c9c2e7f50061f2a998c76f6f55f3ca737
2024-06-20 18:35:19 +00:00
David Ashpole
2324248baf update OpenTelemetry dependencies
Kubernetes-commit: 82e9ce79c763f1028f542b1246114082430e6b20
2024-06-19 00:43:16 +00:00
Patrick Ohly
096d125900 dependencies: klog v2.130.1
Kubernetes-commit: f98e5d1dfcaa37fee2c394436583038cf3ff1e72
2024-06-16 14:04:43 +02:00
Kubernetes Publisher
22a6452ee0 Merge pull request #121439 from skitt/generic-client-go
Use generics to share code in client-go implementations

Kubernetes-commit: 33829b68b5040f23e04ba5e68ed76792d68d698f
2024-06-19 22:34:11 +00:00
Stephen Kitt
82812541d9 Run codegen
Signed-off-by: Stephen Kitt <skitt@redhat.com>

Kubernetes-commit: 08dfd59305dbd1032b1afb49738259d688dda5e3
2024-05-10 16:56:52 +02:00
Kubernetes Publisher
963dc5786f Merge pull request #124509 from p0lyn0mial/upstream-watch-list-code-gen
client-go: add support for API streaming

Kubernetes-commit: 6ac60160c5729ade462b041b170ec8ac0f1eb3bc
2024-06-14 14:34:00 +00:00
Lukasz Szaszkiewicz
2c1742bca0 make update
Kubernetes-commit: f62c80f965934eeeb2e028497bede7bcc632995d
2024-06-13 10:25:56 +02:00
Kubernetes Publisher
0fe75b774b Merge pull request #125408 from benluddy/bump-cbor-v2.7.0
KEP-4222: Bump github.com/fxamacker/cbor/v2.

Kubernetes-commit: 6346b9d1327c4b8be2398d9715bdae5475e27569
2024-06-11 01:12:23 +00:00
Ben Luddy
f0d68f3bbc Bump fxamacker/cbor/v2 to v2.7.0-beta.
This library release makes a number of behaviors configurable in ways that are required for CBOR
support in Kubernetes.

Kubernetes-commit: c4279660cad039bc15495311cf7863640b6308f9
2024-05-09 14:30:58 -04:00
Kubernetes Publisher
23f32a186f Merge pull request #124963 from p0lyn0mial/upstream-data-consistency-checker-for-list-requests
client-go: data consistency checker for list requests

Kubernetes-commit: 3532601ad8c7249be13cd8187f8124fc68da4c4b
2024-06-07 09:06:21 +00:00
Lukasz Szaszkiewicz
436de8270b make update
Kubernetes-commit: 448180db60fc1d62174a18d1dd995d8deb081428
2024-05-27 15:31:15 +02:00
Kubernetes Publisher
2792b3cf00 Merge pull request #125078 from Jefftree/patch-1
Ignore sample-controller binary

Kubernetes-commit: a2911e06a7cd393f7cce088b8399f889527b517f
2024-06-05 17:02:46 +00:00
Kubernetes Publisher
3bbd1b7ee2 Merge pull request #125154 from alvaroaleman/rename
Sample Controller: Use one variable for key throughout

Kubernetes-commit: a080057dabef91bdb185448ee4ffee2dd2400a21
2024-06-04 20:58:54 +00:00
Kubernetes Publisher
5af544b659 Merge pull request #122832 from benluddy/cbor-fuzz-native-to-unstructured-via
KEP-4222: Add roundtrip tests to Unstructured via CBOR and JSON.

Kubernetes-commit: f30a87d517c538f22e1d84b4d7c497f57f7b760a
2024-05-31 01:05:38 +00:00
Alvaro Aleman
f356e5a163 Sample Controller: Use one variable for key throughout
After changing it to use a typed workqueue, the differentiation between
the key we get from the workqueue and they key we use down the line is
no longer useful as they are the same, so use one variable for it
throughout.

Kubernetes-commit: 6e2e7f7c26d0c4908180180a85a53d2ca408f3b0
2024-05-27 21:29:48 -04:00
Jeffrey Ying
903405076c Add gitignore to sample-controller
Kubernetes-commit: 4506f0542a369668531e60b7898de5af84c61c5e
2024-05-23 11:22:53 +09:00
Ben Luddy
3fce947933 Update indirect dependencies with ./hack/update-vendor.sh.
Implementing custom marshaling on several API types for CBOR makes the upstream CBOR library an
indirect dependency of several staging modules.

Kubernetes-commit: d7cccf3e792ad08d9ab2e7aac394f8e6ddcf3466
2024-05-17 13:02:26 -04:00
Kubernetes Publisher
307b861e46 Merge pull request #123339 from skitt/canonical-json-patch
Update kustomize, use canonical json-patch v4 import

Kubernetes-commit: da02fdb2aef1b7102526963c91df4992ee5b6a05
2024-05-29 21:05:41 +00:00
Stephen Kitt
442b538325 Use canonical json-patch v4 import
The canonical import for json-patch v4 is
gopkg.in/evanphx/json-patch.v4 (see
https://github.com/evanphx/json-patch/blob/master/README.md#get-it for
reference).

Using the v4-specific path should also reduce the risk of unwanted v5
upgrade attempts, because they won't be offered as automated upgrades
by dependency upgrade management tools, and they won't happen through
indirect dependencies (see
https://github.com/kubernetes/kubernetes/pull/120327 for context).

Signed-off-by: Stephen Kitt <skitt@redhat.com>

Kubernetes-commit: 5300466a5c8988b479a151ceb77f49dd00065c83
2024-02-16 13:57:24 +01:00
Stephen Kitt
17dc7e29b9 Update kubectl kustomize to kyaml/v0.17.1, cmd/config/v0.14.1, api/v0.17.2, kustomize/v5.4.2
Signed-off-by: Stephen Kitt <skitt@redhat.com>

Kubernetes-commit: 33c6f6bc65395aa514c9cf17115a1c63564c22e7
2024-05-27 17:42:29 +02:00
Kubernetes Publisher
e6b6554e2a Merge pull request #125045 from pohly/ginkgo-gomega-update
dependencies: ginkgo v2.19.0, gomega v1.33.1

Kubernetes-commit: 1c84623028b496e22d8401100ef6f59325e092e0
2024-05-28 09:05:58 +00:00
Patrick Ohly
2f76b5aca2 dependencies: ginkgo v2.19.0, gomega v1.33.1
Ginkgo v2.18.0 allows tweaking the output so that
it's easier to follow while a job runs in
Prow (https://github.com/onsi/ginkgo/issues/1347). Using this in
hack/ginkgo-e2e.sh will follow in a separate commit.

Gomega gets bumped to the latest release to keep it up-to-date.

Ginkgo v1.19.0 adds support for --label-filter with labels that represent
sets (like our Feature:<Foo>).

Kubernetes-commit: 37e2dd6857084a172ef5210caee1fefa8dd8159a
2024-05-22 10:22:09 +02:00
Kubernetes Publisher
5d9319e2a8 Merge pull request #124757 from dims/update-to-latest-golang.org/x/oauth2-v0.20.0
Update to latest golang.org/x/oauth2 v0.20.0

Kubernetes-commit: 22578c545ffc04a505a7a64c9b8f6c78fefa07ef
2024-05-09 00:59:35 +00:00
Davanum Srinivas
ac5db4895a Update to latest golang.org/x/oauth2 v0.20.0
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 04c40ac96134d7f7bf697d0a58caf0f8b0380075
2024-05-08 11:04:34 -04:00
Kubernetes Publisher
892f8f87bf Merge pull request #124600 from alvaroaleman/typed-wq
Use the generic/typed workqueue throughout

Kubernetes-commit: 1dc30bf90fd6a729d226b4e942118110b0a73e65
2024-05-07 00:53:55 +00:00
Alvaro Aleman
3272c300d3 Use the generic/typed workqueue throughout
This change makes us use the generic workqueue throughout the project in
order to improve type safety and readability of the code.

Kubernetes-commit: 6d0ac8c561a7ac66c21e4ee7bd1976c2ecedbf32
2024-04-28 18:26:18 +02:00
Kubernetes Publisher
77cf3aaeee Merge pull request #122148 from pohly/controllers-context-support
controllers + apiserver: enhance context support

Kubernetes-commit: d0fddf143b3ebea8df94a9c66e5aa833031a8682
2024-04-30 09:50:49 +00:00
Kubernetes Publisher
21ead8f55c Merge pull request #124562 from sbueringer/pr-bump-sigs-yaml
Bump sigs.k8s.io/yaml to v1.4.0

Kubernetes-commit: c1ef6c44f5d7b582bf19669c6dbf2ff9552b9d6c
2024-04-29 21:55:07 +00:00
Stefan Bueringer
edded6aeb3 Bump sigs.k8s.io/yaml to v1.4.0
Kubernetes-commit: 04cc45b4adda1b19d5067d45ed246c0f84fed966
2024-04-26 15:28:17 +02:00
Kubernetes Publisher
9db8293ba5 Merge pull request #124469 from serathius/etcd-3.5.13
Upgrade etcd libraries to v3.5.13

Kubernetes-commit: 0f063280964b09e0e21c8cc457a181c20c68da61
2024-04-24 17:53:40 +00:00
Marek Siarkowicz
abe5dbaa6d Upgrade etcd libraries to v3.5.13
Add otelgrpc.WithMessageEvents(otelgrpc.ReceivedEvents, otelgrpc.SentEvents) to tracing options due to https://github.com/open-telemetry/opentelemetry-go-contrib/pull/3964

Kubernetes-commit: 3e5b03eb433ee359782f5aa6e9368ab2a0d0370c
2024-04-23 11:10:37 +02:00
Kubernetes Publisher
9569fd3386 Merge pull request #124328 from jiahuif-forks/deps/cel-go
bump cel-go to v0.20.1 and refit CEL libraries

Kubernetes-commit: 16a594f907d0d4a6224dab2d0704793d5e7898f6
2024-04-23 01:54:37 +00:00
Kubernetes Publisher
9a8a7c6f1c Merge pull request #121574 from skitt/generic-lister-gen
Generify lister-gen

Kubernetes-commit: 6b260382a1b5e461c39289892b1d3a3b335ecc67
2024-04-23 01:54:37 +00:00
Jiahui Feng
7b28a54be9 generated: ./hack/update-vendor.sh
Kubernetes-commit: 350fcf957e90501f0b224b7ccf771b29d4d5c6b6
2024-04-22 10:54:32 -07:00
Kubernetes Publisher
6f2758eb37 Merge pull request #124346 from jwcesign/master
upgrade: upgrade dependencies github.com/prometheus/common to the newest version

Kubernetes-commit: 76de052680da0b7a59b35fb79db7ab322faf2854
2024-04-22 17:54:24 +00:00
jwcesign
2c02470156 upgrade: upgrade dependencies github.com/prometheus/common to the newest version
Signed-off-by: jwcesign <jwcesign@gmail.com>

Kubernetes-commit: f0aa62bc96d6e734249adfa3e094a52e45c8fb6d
2024-04-17 18:15:27 +08:00
Kubernetes Publisher
b66b03fd2d Merge pull request #122892 from danwinship/codegen-nil
Fix generated fake clients to have same semantics as real clients on error

Kubernetes-commit: 573832a42f03af912a5611eb4e81a0e812a5ddf2
2024-04-18 17:54:22 +00:00
Jiahui Feng
eba1eb7f56 generated: ./hack/pin-dependency.sh github.com/google/cel-go v0.20.1
Kubernetes-commit: 94997c6fefa2791192d0a7ab68b02bf5d8b6c2c5
2024-04-15 13:33:10 -07:00
Mike Spreitzer
6e60f3495c Brush up the sample controller
Signed-off-by: Mike Spreitzer <mspreitz@us.ibm.com>

Kubernetes-commit: 7848612de8d0f6e4ac67c180184ee4bed1ac7691
2024-02-02 14:30:25 -05:00
Dan Winship
9f76e9e638 Regenerate fake clients
Kubernetes-commit: 17ab25b121d05355700f39628d5d45ab3da446f8
2024-01-20 10:20:43 -05:00
Kubernetes Publisher
cf98144093 Merge pull request #124174 from dims/update-x/net-for-CVE-2023-45288
Update x/net for CVE-2023-45288

Kubernetes-commit: d9c54f69d4bb7ae1bb655e1a2a50297d615025b5
2024-04-04 04:13:05 +00:00
Davanum Srinivas
5034defc64 Update x/net for CVE-2023-45288
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 99fac38d2864e6bc9bb7cd1743d658caa1360c0c
2024-04-03 16:37:18 -04:00
Kubernetes Publisher
674edd983a sync: update go.mod 2024-03-18 12:24:01 +00:00
Kubernetes Publisher
f53405abe7 Merge pull request #123758 from liggitt/protobump
[CVE-2024-24786] Bump github.com/golang/protobuf v1.5.4, google.golang.org/protobuf v1.33.0

Kubernetes-commit: a5f5f44157c49fdfb6384862c7cb34c2ddbd4cce
2024-03-06 17:38:35 +00:00
Jordan Liggitt
c86e5dc12f Bump github.com/golang/protobuf v1.5.4, google.golang.org/protobuf v1.33.0
Kubernetes-commit: c6673d2346c814ddb4629c569bdc659ffa0c583f
2024-03-06 09:47:28 -05:00
Kubernetes Publisher
59106b762c Merge pull request #123529 from thockin/go-workspaces
Go workspaces for k/k and k/staging/*

Kubernetes-commit: df366107d16aa2e2cdd620be41e592184f379da4
2024-03-01 21:41:22 +00:00
Tim Hockin
39f7ea823a Fix up go.mod files after reviews
Because of how the previous 100+ commits were done, so changes snuck
thru that properly belong in earlier commits but it's not really
possible to do that without a lot of effort.

We agreed it was OK to "spackle" these cracks with a final commit.

Kubernetes-commit: 21715e6bbd19c932576ff268843d8ead3edb05e4
2024-02-28 16:50:55 -08:00
Tim Hockin
2ad4028b7b Remove old gengo detritus
Kubernetes-commit: 812d5fff4011df4693dcdace516feec30ebff8ba
2024-02-26 23:31:41 -08:00
Tim Hockin
28c803d620 Get rid of most references to GOPATH
Kubernetes-commit: 10c32b3e2f4345dab582270b1a202dcd92dabd34
2024-01-03 17:14:38 -08:00
Tim Hockin
7e70e35059 Make code-gen subprojects work on gengo/v2
Kubernetes-commit: f772410082b2bf4e93cfabcf5d9c60f213e88cc7
2023-12-28 15:58:26 -08:00
Tim Hockin
9ac16f811f Re-vendor latest kube-openapi and gengo/v2
./hack/pin-dependency.sh k8s.io/kube-openapi latest
./hack/pin-dependency.sh k8s.io/gengo/v2 latest
./hack/update-vendor.sh

Kubernetes-commit: 6f2f3735e04df5e4822176a2784069634c3c74a3
2024-02-26 17:02:22 -08:00
Patrick Ohly
2c4684fa27 sample controller: enhance context support
27a68aee3a4834 introduced context support for events. Creating an event
broadcaster with context makes tests more resilient against leaking goroutines
when that context gets canceled at the end of a test and enables per-test
output via ktesting.

The New method already had a context, therefore no API changes are needed.

Kubernetes-commit: 591855966c1d136c8fca299db2c6ba949bef4493
2023-12-01 09:00:59 +01:00
Stephen Kitt
6dc1b5cec5 Regenerate all listers
Signed-off-by: Stephen Kitt <skitt@redhat.com>

Kubernetes-commit: e6f44957cdb961d1ada2ae570d331c6bc0ecc8e2
2023-11-09 17:39:39 +01:00
Patrick Ohly
0c74dd65ff Generate go.work files
This creates go.work and enables Go Workspaces.  This is a file that
includes info on k/k and all the staging modules.

This depends on go 1.22 and setting FORCE_HOST_GO=true (for kube
scripts, which try to be hermetic).

Make this part of the normal update/verify sequence.

The top-level go.work file contains no replace statements. Instead, the
replace statements in the individual go.mod files are used. For this to
work, replace statements in the individual go.mod files have to be
consistent.

hack/tools has different dependencies and can't be in the main
workspace, so this adds a go.work just for that.  Without this, go tries
to consider all deps in all modules and pick one that works for all.
This is problematic because there are so many of them that it is
difficult to manage.

Likewise for k8s.io/code-generator/examples and
k8s.io/kms/internal/plugins/_mock - add trivial go.work files.

For example k/k depends on an older version of a lib that gloangci-lint
needs (transitively) and it breaks.

This also updates vendor (needed to make go happy), and removes
vendor'ed symlinks.  This breaks a LOT of our build tools, which will be
fixed subsequently.

Result: `go` commands work across modules:

Before:
```
$ go list ./pkg/proxy/iptables/ ./staging/src/k8s.io/api/core/v1/
main module (k8s.io/kubernetes) does not contain package k8s.io/kubernetes/staging/src/k8s.io/api/core/v1

$ go build ./pkg/proxy/iptables/ ./staging/src/k8s.io/api
main module (k8s.io/kubernetes) does not contain package k8s.io/kubernetes/staging/src/k8s.io/api

$ go test ./pkg/proxy/iptables/ ./staging/src/k8s.io/api
main module (k8s.io/kubernetes) does not contain package k8s.io/kubernetes/staging/src/k8s.io/api
```

After:
```
$ go list ./pkg/proxy/iptables/ ./staging/src/k8s.io/api/core/v1/
k8s.io/kubernetes/pkg/proxy/iptables
k8s.io/api/core/v1

$ go build ./pkg/proxy/iptables/ ./staging/src/k8s.io/api

$ go test ./pkg/proxy/iptables/ ./staging/src/k8s.io/api
ok  	k8s.io/kubernetes/pkg/proxy/iptables	0.360s
ok  	k8s.io/api	2.302s
```

Result: `make` fails:

```
$ make
go version go1.22rc1 linux/amd64
+++ [0106 12:11:03] Building go targets for linux/amd64
    k8s.io/kubernetes/cmd/kube-proxy (static)
    k8s.io/kubernetes/cmd/kube-apiserver (static)
    k8s.io/kubernetes/cmd/kube-controller-manager (static)
    k8s.io/kubernetes/cmd/kubelet (non-static)
    k8s.io/kubernetes/cmd/kubeadm (static)
    k8s.io/kubernetes/cmd/kube-scheduler (static)
    k8s.io/component-base/logs/kube-log-runner (static)
    k8s.io/kube-aggregator (static)
    k8s.io/apiextensions-apiserver (static)
    k8s.io/kubernetes/cluster/gce/gci/mounter (static)
    k8s.io/kubernetes/cmd/kubectl (static)
    k8s.io/kubernetes/cmd/kubectl-convert (static)
    github.com/onsi/ginkgo/v2/ginkgo (non-static)
    k8s.io/kubernetes/test/e2e/e2e.test (test)
    k8s.io/kubernetes/test/conformance/image/go-runner (non-static)
    k8s.io/kubernetes/cmd/kubemark (static)
    github.com/onsi/ginkgo/v2/ginkgo (non-static)
    k8s.io/kubernetes/test/e2e_node/e2e_node.test (test)
test/e2e/e2e.go:35:2: cannot find package "k8s.io/api/apps/v1" in any of:
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/api/apps/v1 (vendor tree)
	/home/thockin/src/kubernetes/_output/local/.gimme/versions/go1.22rc1.linux.amd64/src/k8s.io/api/apps/v1 (from $GOROOT)
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/api/apps/v1 (from $GOPATH)
	... more ...
	... more ...
	... more ...
!!! [0106 12:13:41] Call tree:
!!! [0106 12:13:41]  1: /home/thockin/src/kubernetes/hack/lib/golang.sh:948 kube::golang::build_binaries_for_platform(...)
!!! [0106 12:13:41]  2: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [0106 12:13:41] Call tree:
!!! [0106 12:13:41]  1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [0106 12:13:41] Call tree:
!!! [0106 12:13:41]  1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
make: *** [Makefile:96: all] Error 1
```

Again, this requires go 1.22 (e.g. gotip), as go 1.21.x does not have
`go work vendor` support.

TO REPEAT:
    ( \
      ./hack/update-go-workspace.sh; \
      ./hack/update-vendor.sh; \
      ./hack/update-go-workspace.sh; \
    )

Kubernetes-commit: 65b841c077e0d3282d28b9199aec72d23d045104
2022-06-08 12:12:42 +02:00
Kubernetes Publisher
353b889843 Merge pull request #123348 from hoskeri/update-go-x-crypto-19
Update x/crypto to 0.19.

Kubernetes-commit: 9a9028983806af26e7b48223f3a92922e94725df
2024-02-21 20:46:48 +00:00
Abhijit Hoskeri
bff64b2794 Update x/crypto to 0.19.
Main reason is to pick up updated CA roots.

Full diff: https://github.com/golang/crypto/compare/v0.16.0...v0.19.0

Kubernetes-commit: d3a0e296defbb0b55e591e273004e79e7ebfb1fd
2024-02-16 20:18:14 +00:00
Kubernetes Publisher
200d240b36 Merge pull request #123250 from benluddy/dep-bump-cbor-v2.6.0
Bump github.com/fxamacker/cbor/v2 to v2.6.0.

Kubernetes-commit: e305e773bbfe8c5bdf9c57881a875e168b004b8c
2024-02-15 01:47:49 +00:00
Ben Luddy
32cb29a1a3 Bump github.com/fxamacker/cbor/v2 to v2.6.0.
Kubernetes-commit: aac43dc96f2b679f0ab030fd3512c7e03b0f2df4
2024-02-12 15:46:17 -05:00
Kubernetes Publisher
315cd21730 Merge pull request #121486 from benluddy/cbor-stub
KEP-4222: Add stub CBOR serializer.

Kubernetes-commit: 48228bf9dbac308f43abd59a53fdc069fbddee0f
2024-02-10 02:02:58 +00:00
Ben Luddy
dba177fad7 Update vendoring to take new CBOR library dependency.
Kubernetes-commit: 09a1abda998fc37e2e29a120a82be7c6271656e0
2023-10-17 16:51:52 -04:00
Kubernetes Publisher
9bb37d5ced Merge pull request #122842 from pohly/klog-update
dependencies: klog v2.120.1

Kubernetes-commit: b27b56a46c4c1e6be0dc2b1a0230d86223a7e903
2024-01-18 21:42:36 +00:00
Kubernetes Publisher
f375b712ca Merge pull request #122839 from pohly/ginkgo-gomega-update
dependencies: ginkgo v2.15.0, gomega v1.31.0

Kubernetes-commit: c82da711b0e2184f851675aac4596bbd0f74763f
2024-01-18 21:42:36 +00:00
Patrick Ohly
a579cef3c1 dependencies: klog v2.120.1
Kubernetes-commit: e2222f1e304831cbbc57b61afa373612297055fb
2024-01-18 16:58:40 +01:00
Patrick Ohly
e5c197b380 dependencies: ginkgo v2.15.0, gomega v1.31.0
The main reason for updating is support for reporting the cause of context
cancellation: Ginkgo provides that information when canceling a context and
Gomega polling code includes that when generating a failure message.

Kubernetes-commit: 18f0af1f000f95749ca1ea075d62ca89e86bb7da
2024-01-18 12:45:55 +01:00
Kubernetes Publisher
f426aee07f Merge pull request #122706 from pacoxu/klog-upgrade
bump klog to  v2.120.0

Kubernetes-commit: 823ecb58f68fbe0a4b37b32e11e75c6f2e0f467c
2024-01-11 21:43:20 +00:00
Paco Xu
18b55ad464 bump klog to v2.120.0
Kubernetes-commit: 3c86d21316c25b52a1cf3f9703a0bc2cbe97131c
2024-01-11 17:35:07 +08:00
Kubernetes Publisher
d7f638a293 Merge pull request #122412 from MadhavJivrajani/bump-go-tools
[go1.22] .*: bump golang.org/x/tools to v0.16.1

Kubernetes-commit: 8a4403a9e5127d2ec3f596c4ce75663e5392cb18
2023-12-20 18:15:33 +00:00
Madhav Jivrajani
97f9d4e3b7 .*: bump golang.org/x/tools to v0.16.1
Bumping tools to include the fix for a nil pointer
deref error in go/types. See golang/go#64812
for more details.

This fix is needed for when we bump to go1.22.

Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>

Kubernetes-commit: a8da4202c0ac785d57b545e6e310fd754888b50e
2023-12-20 14:31:31 +05:30
Kubernetes Publisher
dee12ed18a Merge pull request #122395 from pohly/ginkgo-gomega-update
dependencies: gomega v1.30.0 + ginkgo v2.13.2

Kubernetes-commit: 7897910469aa091ebf6576740d055a7137fa147c
2023-12-20 09:43:44 +00:00
Patrick Ohly
c09cde94d2 dependencies: gomega v1.30.0 + ginkgo v2.13.2
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for https://github.com/kubernetes/kubernetes/issues/105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
2023-12-19 16:16:02 +01:00
Kubernetes Publisher
f5d24a1fa7 Merge pull request #121759 from thockin/fix_api_violations
Fix "list_type_missing" API violations in meta/v1

Kubernetes-commit: 8a22571ebb7628b2dd2c2faf453293040b7efaef
2023-12-14 01:41:24 +00:00
Tim Hockin
f12150e5c0 Re-vendor k8s.io/kube-openapi
./hack/pin-dependency.sh k8s.io/kube-openapi 778a5567bc1edaed92a4de9c07f90199c67953fa

./hack/update-vendor.sh

Kubernetes-commit: 1f55357d9937f076f532a2c1aa104593b9f6c49a
2023-11-13 10:59:57 -08:00
Kubernetes Publisher
679aa015c5 Merge pull request #121808 from cpanato/go-update-main
[go] Bump images, dependencies and versions to go 1.21.4

Kubernetes-commit: 6ba7258a0f3f73629560fc30016b2e35c8e7ae9c
2023-11-13 17:40:37 +00:00
cpanato
044a7c34a0 update go.mod
Signed-off-by: cpanato <ctadeu@gmail.com>

Kubernetes-commit: 9e5b8402bb95eb82541099e77c3a8b0ccd31297f
2023-11-08 08:46:15 -06:00
Kubernetes Publisher
30d50a7421 Merge pull request #121552 from pohly/klog-update
klog v2.110.1 update

Kubernetes-commit: da61382068671c3e16782a9b45e7f2159ac0feb9
2023-11-01 17:37:05 +00:00
Patrick Ohly
87402bd907 dependencies: klog v2.110.1
Dropping a newline at the end of the message when using klog calls is an
intentional improvement (https://github.com/kubernetes/klog/pull/378)

Kubernetes-commit: 878d037d3ba8fc4f11bf45a6cf5a66301ba89d82
2023-10-16 10:03:54 +02:00
Kubernetes Publisher
1b62458621 Merge pull request #121575 from apelisse/update-smd
Update sigs.k8s.io/structured-merge-diff to v4.4.0

Kubernetes-commit: 593a17d3b6381bfdbf3bc3b36f56cad30d1531df
2023-11-01 01:40:04 +00:00
Antoine Pelisse
9d2bb0a8e8 Update sigs.k8s.io/structured-merge-diff to v4.4.1
Kubernetes-commit: dec443b305a0240f2a9d7726c6a0c46beec19a1a
2023-10-27 10:21:06 -07:00
Kubernetes Publisher
87fe50acc2 Merge pull request #121524 from carlory/gomega
bump gomega to 1.29.0

Kubernetes-commit: ec297aa13a03f53f04023cd897af50dbfed31e0f
2023-10-27 18:20:49 +00:00
carlory
0513d76781 bump gomega to 1.29.0
Kubernetes-commit: 760abc2a82130d45607eeead4011afa8b0f81e6d
2023-10-26 09:47:49 +08:00
Kubernetes Publisher
f0143dd486 Merge pull request #121338 from dims/working-otel-bump
Bump otel and other dependencies for CVE-2023-45142

Kubernetes-commit: d0084356b3cabdafcfc140d19ad8d544b2fc9b5d
2023-10-26 09:34:21 +00:00
Kubernetes Publisher
c035987383 Merge pull request #121306 from dims/drop-usage-of-deprecated-method-NewNamedRateLimitingQueue
[sample-controller] Drop usage of deprecated method NewNamedRateLimitingQueue

Kubernetes-commit: 2dc35c28bfeb8841c3ed8d6cec6da5a87ec45936
2023-10-26 09:34:21 +00:00
Kubernetes Publisher
ee241d53d3 Merge pull request #120757 from alexzielenski/apiserver/openapi/invalid-default
Update `kube-openapi` to Remove invalid defaults from fields with custom marshalling

Kubernetes-commit: 31c679f65cbf62efec7597133e6d8e78d8473c4d
2023-10-21 00:46:07 +00:00
Davanum Srinivas
8602fe35ba working-config-otel
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 702d911e22604aa69b42f77804c27caaab7e4def
2023-10-18 18:47:37 -04:00
Alexander Zielenski
80d7e69c55 pin openapi
Kubernetes-commit: 4d21a23be35a03852e0e7b188de11d9f8dc6bc57
2023-10-17 16:48:10 -07:00
Davanum Srinivas
362a7851c1 Drop usage of deprecated method NewNamedRateLimitingQueue
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: c8b65422e582e4d6703b03cfea0aff0ac5e48ce2
2023-10-17 14:46:13 -04:00
Kubernetes Publisher
61b24c8606 Merge pull request #121010 from Jefftree/decouple-openapi-v2v3-config
Decouple openapi v2v3 config

Kubernetes-commit: ac66f3d466caee27bcc0f66a04ceec9bf63750bd
2023-10-16 23:34:07 +00:00
Jefftree
f3799a3b56 bump kube-openapi
Kubernetes-commit: e3098225eaf7b5bb9d5de1f259c2dbdc2062faa8
2023-10-12 18:22:05 -04:00
Kubernetes Publisher
abf9770cc1 Merge pull request #120735 from Jefftree/request-body
Bump kube-openapi with v3 marshal and requestBody required marking

Kubernetes-commit: e93e8eac0ef1b26384e5481b67c7d04fe211a243
2023-10-12 23:51:31 +00:00
Jefftree
af98de65cf bump kube-openapi
Kubernetes-commit: 555c1b8091c2312e7b3f9002fc8a4787e759ef31
2023-09-27 14:02:53 -04:00
Kubernetes Publisher
1dc3585d42 Merge pull request #121111 from dashpole/update_otel_deps
Update OpenTelemetry Dependencies

Kubernetes-commit: eafebcc9e368d6aeaab0ce5ec4fd56b94174d0c4
2023-10-11 07:34:14 +00:00
John Howard
46d0ffe08b dependencies: update otel-go dependencies
Kubernetes-commit: dc334b953d99f233b56ec2cd78bff218a00152a0
2023-10-05 12:52:33 -07:00
Kubernetes Publisher
603b1fdb1d Merge pull request #121117 from MadhavJivrajani/bump-x-net
[CVE-2023-39325] .: bump golang.org/x/net to v0.17.0

Kubernetes-commit: 7ee2af5cc5fee6a6f837975a70a35ce681a8e9d4
2023-10-10 19:34:58 +00:00
Madhav Jivrajani
ba16920ba5 .: bump golang.org/x/net to v0.17.0
Bumping golang.org/x/net in light of CVE-2023-39325 and CVE-2023-44487.

Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>

Kubernetes-commit: fc7c951d5a5b8b75dfa105e3bea7bbddaf4c792e
2023-10-10 23:07:19 +05:30
Kubernetes Publisher
af3feae5eb Merge pull request #121082 from pohly/ginkgo-gomega-update
dependencies: ginkgo v2.13.0, gomega v1.28.0

Kubernetes-commit: 755644a169ad495a34bc5e1db502962fc6dd3750
2023-10-10 15:35:29 +00:00
Patrick Ohly
7fc9fc7be5 dependencies: ginkgo v2.13.0, gomega v1.28.0
Besides simply staying up-to-date, ginkgo v2.13.0 adds a `PreviewSpecs` which
will be used for introspection of the E2E test suites.

Kubernetes-commit: 79355caa565cc34e8726c427562c9f109ebe0e34
2023-10-09 19:27:06 +02:00
Kubernetes Publisher
5db59e1107 Merge pull request #119865 from charles-chenzz/bump_deps
bump github.com/emicklei/go-restful/v3 to v3.11.0

Kubernetes-commit: bf1fa0c6691bb3bc6c5c03f900c53ed609e580a4
2023-09-28 15:19:58 +00:00
charles-chenzz
b6feba8451 bump github.com/emicklei/go-restful/v3 to v3.11.0.
Kubernetes-commit: 409b46576ff7848bf51b9d70165b693018173ebc
2023-08-09 23:31:06 +08:00
Kubernetes Publisher
03b4c764dc Merge pull request #119526 from sttts/sttts-idiomatic-cached
kube-openapi/cached: bump and adapt to more go-idiomatic caching library

Kubernetes-commit: f551940626532e790c05094293e0d8bb5b76e3d5
2023-09-15 22:51:23 +00:00
Dr. Stefan Schimanski
0f3e01542a hack/update-vendor.sh
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>

Kubernetes-commit: 6c59e8be5e2bc97c8e850070ffb3025199c05df2
2023-09-13 08:23:06 +02:00
Kubernetes Publisher
49998ddad6 Merge pull request #120506 from alexzielenski/import-restrictions
Update e2e import restrictions

Kubernetes-commit: a68093a3ffb5525b01c0deec9d34c25595c7400a
2023-09-14 06:38:58 +00:00
Kubernetes Publisher
6498c292a2 Merge pull request #120008 from skitt/drop-intstr-ptr-wrappers
Use ptr.To to retrieve intstr addresses

Kubernetes-commit: 33c5bd631d990f907f89f66cdf8088d252ab251b
2023-09-09 18:50:06 +00:00
Kubernetes Publisher
7b39a306e6 Merge pull request #120499 from tukwila/gorilla/websocket_v1.5.0
bump: upgrade gorilla/websocket from v1.4.2 to v1.5.0

Kubernetes-commit: f6a87aebe6f83336b1dc7d4ca6e69b19ca55cd94
2023-09-08 18:58:10 +00:00
Alexander Zielenski
e65905c27d pin gengo
Kubernetes-commit: 8451c80b601c36ece898fcd996efc370d4e806c3
2023-09-07 09:49:30 -07:00
guangli.bao
612d7a0877 bump: upgrade gorilla/websocket from v1.4.2 to v1.5.0
Kubernetes-commit: 93d93258b19ff3d2e85b5dc60e89df1ebdc689ca
2023-09-07 22:27:58 +08:00
Kubernetes Publisher
698876da2b Merge pull request #119334 from kmala/serverapply
update the dependency sigs.k8s.io/structured-merge-diff/v4 to latest tag

Kubernetes-commit: cf8f9a8d07770352ec0e976ebac77dffa92f0b04
2023-09-07 03:56:42 +00:00
Kubernetes Publisher
b247f4aa03 Merge pull request #119157 from seans3/websocket-executor
WebSocket Client and V5 RemoteCommand Subprotocol

Kubernetes-commit: 6013381508d2d37961c95fd49d91642bfeffaf74
2023-09-06 02:44:15 +00:00
Stephen Kitt
c1002799ad Use ptr.To to retrieve intstr addresses
This uses the generic ptr.To in k8s.io/utils to replace functions and
code constructs which only serve to return pointers to intstr
values. Other uses of the deprecated pointer package are updated in
modified files.

Signed-off-by: Stephen Kitt <skitt@redhat.com>

Kubernetes-commit: aa89e6dc978bf88653d893284248039b776aed54
2023-08-17 12:12:12 +02:00
Keerthan Reddy Mala
784978cdd3 update the dependency sigs.k8s.io/structured-merge-diff/v4 to latest tag
Kubernetes-commit: d2df65ba6c91c1337e07373c254c2118aec3700a
2023-07-14 09:47:59 -07:00
Sean Sullivan
4b5402c669 WebSocket Client and V5 RemoteCommand Subprotocol
Kubernetes-commit: a0d6a815fcc02cbfea1bb22d13a8e896ecbe116c
2023-07-06 21:22:07 -07:00
Kubernetes Publisher
45f365e46d Merge pull request #120327 from liggitt/json-patch
Revert to json-patch 4.12.0

Kubernetes-commit: 34aaf2b972c95c7a3591d8d49c798dba348ee5c9
2023-09-01 06:34:50 +00:00
Jordan Liggitt
31ab5f1654 Revert to json-patch 4.12.0
Kubernetes-commit: 741f1461571007fcf4cf3edbd121d6ef0c596c72
2023-08-31 19:01:37 -04:00
Kubernetes Publisher
5bfd50e9d9 Merge pull request #120218 from rakshitgondwal/feat/protobuf-version-update
feat: update google.golang.org/protobuf to v1.31.0

Kubernetes-commit: 8b4f5bb54b3c2f0e671e87f5038bf3257109edd4
2023-08-29 16:23:34 +00:00
Rakshit Gondwal
e0ba4c3c69 feat: update google.golang.org/protobuf to v1.31.0
Signed-off-by: Rakshit Gondwal <rakshitgondwal3@gmail.com>

Kubernetes-commit: 709721e0df1940f0316f6b81e8ceaeb493634400
2023-08-28 23:38:32 +05:30
Kubernetes Publisher
e6c6a2fcf2 Merge pull request #118455 from linxiulei/managedFields
Trim managedFields in controller-manager

Kubernetes-commit: 1acd489dca47a4be0301330cbfcf4e8f9d98f7c0
2023-08-16 00:42:24 +00:00
Kubernetes Publisher
c29829f9e6 Merge pull request #119725 from MadhavJivrajani/bump-net-dep
[CVE-2023-3978] .*: bump golang.org/x/net to v0.13.0

Kubernetes-commit: 1620473a9a01dd6bbef3398c0acb2e581d0a13c3
2023-08-07 21:48:22 +00:00
Madhav Jivrajani
06d6ebadcc .*: bump golang.org/x/net to v0.13.0
Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>

Kubernetes-commit: 1b90dff5276f3cb37236b446f1821175dad802c4
2023-08-02 11:11:22 +05:30
Kubernetes Publisher
b44473be81 Merge pull request #118204 from sttts/sttts-openapi-v2-parameter-refs
openapi: reference shared parameters

Kubernetes-commit: f42ff8687026f8e12fb3d3b0da0760525d8d8ab2
2023-07-18 06:22:48 +00:00
Kubernetes Publisher
c3e8520444 Merge pull request #119312 from pacoxu/prometheus/common-v0.44
upgrade prometheus common to v0.44.0

Kubernetes-commit: d627c4b41cdd9ef08b13604ce1c460eca26684f8
2023-07-18 02:28:27 +00:00
Paco Xu
97403156a4 upgrade prometheus common to v0.44.0
Kubernetes-commit: 9b6af80a631f5659ea62d552d595b3dd137525a0
2023-07-14 11:05:46 +08:00
Kubernetes Publisher
80dad25802 Merge pull request #119330 from bertinatto/fix-conn-reuse-test
Proactively bump golang.org/x/net to v0.12.0

Kubernetes-commit: c79be34fba3ad20532c9648216924afaa8434e06
2023-07-14 21:52:32 +00:00
Fabio Bertinatto
c2c7e5f799 Proactively bump golang.org/x/net to v0.12.0
Proactively bump to v0.12.0 to avoid v0.10.0 and v0.11.0, which contain
a regression added by commit
82780d606d.
This commit was later reverted in v0.12.0.

Generated with:

hack/pin-dependency.sh golang.org/x/net v0.12.0 && hack/update-vendor.sh

Kubernetes-commit: d9bd413f991958492602c4bf51c43d6edca0e5cd
2023-07-14 10:25:23 -03:00
Dr. Stefan Schimanski
42ac12ab2a Bump kube-openapi
Kubernetes-commit: 961c1503b5bd2b0f83d6b6b98e0c8f29525ca9cb
2023-06-26 13:09:30 +02:00
Kubernetes Publisher
48ec76a559 Merge pull request #118689 from bzsuni/clean
[dependencies] update prometheus/client_golang v1.14.0 to v1.16.0

Kubernetes-commit: 0004ce8684bd9c6be0af4ad8fc9b076f4a04e23e
2023-06-19 01:29:11 +00:00
bzsuni
197d3cd950 update prometheus/client_golang v1.14.0 to v1.16.0
Signed-off-by: bzsuni <bingzhe.sun@daocloud.io>

Kubernetes-commit: 5aa5f1abc9c9d83ccc34382ae2a8e0241ec1d866
2023-06-15 11:24:32 +00:00
Kubernetes Publisher
2bddf7e437 Merge pull request #118507 from jeremyrickard/go1205
[go] Bump images, versions and deps to use Go 1.20.5

Kubernetes-commit: c042d6956f70566a81bc29c9af6896fefbf89aae
2023-06-07 18:42:24 +00:00
Jeremy Rickard
4894a66ce6 Update vendor with hack/update-vendor.sh
Signed-off-by: Jeremy Rickard <jeremyrrickard@gmail.com>

Kubernetes-commit: b1da721bdd711d9f75a57d782c5a33eea7ac35a4
2023-06-07 08:26:14 -06:00
Eric Lin
bb27c732c3 Run hack/update-codegen.sh informers subprojects
Signed-off-by: Eric Lin <exlin@google.com>

Kubernetes-commit: c86f562f29b6b7498ea962d2ac596e6d26ecd723
2023-06-04 20:33:01 +00:00
Kubernetes Publisher
13e8c25a3d Merge pull request #118384 from Jefftree/gnostic-models-branch
Update gnostic library to point to gnostic-models

Kubernetes-commit: bd0ac4cba33f40195b4ffab5463f2b5397216400
2023-06-02 18:39:11 +00:00
Jefftree
6490f816a0 vendor
Kubernetes-commit: 1993a4cb3798d818ff05db0e0c7c9c87d8b41dd2
2023-06-01 18:25:30 +00:00
Kubernetes Publisher
a60b43365d Merge pull request #118269 from liggitt/genproto
Update google.golang.org/genproto

Kubernetes-commit: d05b79c836c9db35ef0a60f0175b3a6bbeedfa7e
2023-05-26 22:38:50 +00:00
Jordan Liggitt
872ce1a4f8 Update google.golang.org/genproto
Kubernetes-commit: a045fedd025c08ad6cb116a9beb3042b6be39fd1
2023-05-25 21:10:02 -04:00
Kubernetes Publisher
14a9782ef4 Merge pull request #118240 from Jefftree/bump-kube-openapi
Bump kube openapi

Kubernetes-commit: f99589b4f52a39a73a0a15449f9adb817a8865b8
2023-05-24 22:38:55 +00:00
Jefftree
db4d6c724f Update vendor
Kubernetes-commit: 4373ae05f345b5d85672bdeefe26e1f69d185086
2023-05-24 18:55:36 +00:00
Kubernetes Publisher
d954208418 Merge pull request #117985 from howardjohn/patch-2
Fix comments on InformerFor

Kubernetes-commit: 54d2ced4d6e6e03f6e411f3c77f33bcc9ff809e1
2023-05-16 17:28:47 +00:00
Kubernetes Publisher
5c11b11d81 Merge pull request #118014 from liggitt/mapstructure
Update kube-openapi, drop mapstructure

Kubernetes-commit: ea4cc84cf7c47d2bc45730ea2563bc320dfe5ff1
2023-05-16 01:41:43 +00:00
Jordan Liggitt
7ef924f4a2 Update kube-openapi, drop mapstructure
Kubernetes-commit: d6d1dbdd82a412a06cdf458ca40836a018670131
2023-05-15 16:42:00 -04:00
Kubernetes Publisher
143db8aeca Merge pull request #117645 from humblec/etcd-2
dependencies: update etcd dependencies to v3.5.9

Kubernetes-commit: 3a65b989e3db450029e796b370d103fe2c43006b
2023-05-15 17:36:10 +00:00
Kubernetes Publisher
11bb012099 Merge pull request #117139 from pohly/test-integration-race-detection-update-utils
dependencies: bump k8s.io/utils

Kubernetes-commit: 87d8c4ed0ab58c5d19a4f2513fb49b920fdef346
2023-05-15 17:36:07 +00:00
John Howard
fb642e3a1d codegen
Kubernetes-commit: 3867569ae275b056e7f25b2228a5887dd9fa422b
2023-05-15 10:16:18 -07:00
Humble Chirammal
26f2bd113a update vendor dependencies for the change
Signed-off-by: Humble Chirammal <humble.devassy@gmail.com>

Kubernetes-commit: dcefc42b35acb229fcf95a172bfd635ee615d1be
2023-05-11 21:58:39 +05:30
Humble Chirammal
d87282c104 etcd depdencies are updated to v3.5.9
Signed-off-by: Humble Chirammal <humble.devassy@gmail.com>

Kubernetes-commit: ae749238786f0c7b32a5291dd52ca31ea7c4fd18
2023-05-11 21:25:46 +05:30
Patrick Ohly
6daf394dc5 dependencies: bump k8s.io/utils
This includes a fix for a race condition.

Kubernetes-commit: 83fb5a50bc97cb58705084c0750f5a6b16fdf219
2023-04-06 13:11:47 +02:00
Kubernetes Publisher
8a746f938a Merge pull request #117961 from humblec/ginkgo
ginkgo update to v2.9.4 and gomega to 1.27.6

Kubernetes-commit: 84c8abfb8bf900ce36f7ebfbc52794bad972d8cc
2023-05-12 17:38:58 +00:00
Kubernetes Publisher
0cc5122f9c Merge pull request #116761 from iancoolidge/devel-cpuset-revendor
Complete cpuset export to k/utils by revendoring

Kubernetes-commit: 8f9c18569616eb65666a9271c3dd4d87b46ccece
2023-05-12 17:38:54 +00:00
Humble Chirammal
44b887cb97 ginkgo update to v2.9.4 and gomega to 1.27.6
https://github.com/onsi/ginkgo/v2/compare/v2.9.1...v2.9.4
 https://github.com/onsi/gomega/compare/v1.27.4...v1.27.6

Signed-off-by: Humble Chirammal <humble.devassy@gmail.com>

Kubernetes-commit: cbe825b2b6cde3ae6e13b75e459227c71ea7e1f7
2023-05-12 09:33:31 +05:30
Kubernetes Publisher
758d61ecc4 Merge pull request #117262 from thockin/codegen_new_script_for_subprojects
Codegen: a new script for subprojects to use

Kubernetes-commit: 7cdf67ebf86a55e3ca105f706d15b3cde259dc52
2023-05-09 22:17:10 +00:00
Ian K. Coolidge
58b38f1af9 Update k8s.io/utils version to v0.0.0-20230313181309-38a27ef9d749
Steps:
1) Manualy update go.mod with new version string
2) ./hack/update-vendor.sh
3) Fixup go.sum with new package hash
4) ./hack/update-vendor.sh

Kubernetes-commit: 9f46cbc6fa475c420af3ccd654d4e59606375836
2023-03-18 14:52:37 +00:00
Tim Hockin
b0e4f83017 Convert sample-controller to new codegen
Kubernetes-commit: e368f1b25bf52f4f48946b8a93ecad63b4bca3ad
2023-03-12 17:15:35 -07:00
Kubernetes Publisher
8ba49a017a Merge pull request #117687 from pohly/klog-update
dependencies: klog v2.100.1

Kubernetes-commit: a6825c8542ee1e5e9d570ba1c267458a09287015
2023-05-03 19:48:18 +00:00
Patrick Ohly
512fe56e8f dependencies: klog v2.100.1
Kubernetes-commit: 5fff8cae749cefbac63173f176831ea007b95b3a
2023-04-29 20:47:44 +02:00
Kubernetes Publisher
4af62c5403 Merge pull request #117705 from Jefftree/update-openapi-fix-race
Update kube-openapi to fix race

Kubernetes-commit: 3f8c4794eadf8aadd8a5bcb0b875bf0af5c2020b
2023-05-01 22:40:01 +00:00
Jefftree
f3ee0b1c12 Update kube-openapi to fix race
Kubernetes-commit: de34540248a6cd4335a6aedd3f1d24c608d59c86
2023-05-01 17:19:03 +00:00
Kubernetes Publisher
99b408a863 Merge pull request #117253 from akhilerm/update-containerd-dependencies
dependencies: update cgroups, ttrpc, ebpf versions

Kubernetes-commit: d33853edcfdb521c80cd9a659ed02b7fe52b40f4
2023-05-01 18:47:32 +00:00
Akhil Mohan
b2336068c2 chore: update cgroups and ttrpc versions
- update github.com/containerd/cgroups to v1.1.0
- update github.com/containerd/ttrpc to v1.2.1

Signed-off-by: Akhil Mohan <akhilerm@gmail.com>

Kubernetes-commit: 76fe41a996ec78d9774e1f1ca9d1d7ec40522f98
2023-04-23 22:23:42 -07:00
Kubernetes Publisher
04b5dc634c Merge pull request #117350 from mohitsharma-in/update/google-golang-protobuf
Dependencies: Update google.golang.org/protobuf v1.30.0

Kubernetes-commit: b925ce244638187dbf0f502ecb6e02db149970aa
2023-04-25 18:48:35 +00:00
Kubernetes Publisher
7bd785abf5 Merge pull request #117483 from ArkaSaha30/bump-gofuzz
dependencies:update `github.com/google/gofuzz` to v1.2.0

Kubernetes-commit: 7fbe3cba41915cad69f376eb6b3d3a326d51cd11
2023-04-24 22:59:34 +00:00
Kubernetes Publisher
8be6d42a41 Merge pull request #117482 from ArkaSaha30/bump-go-logr
dependencies:update `github.com/go-logr/logr` to v1.2.4

Kubernetes-commit: f77e570fbadbf91c05840a1f6f9b6aec860de400
2023-04-24 22:59:30 +00:00
Kubernetes Publisher
6091424065 Merge pull request #117352 from mohitsharma-in/update/golang_x_tools
dependencies: Update golang.org/x/tools to v0.8.0

Kubernetes-commit: bda7e8979088614c60ee21fd2602d00786e2ea78
2023-04-20 10:27:34 +00:00
ArkaSaha30
7b1e1ee6a4 update gofuzz dependency
Signed-off-by: ArkaSaha30 <arkasaha30@gmail.com>

Kubernetes-commit: 1d15354ccb56b2e367cc403777255125ef65b7df
2023-04-19 21:08:16 +05:30
ArkaSaha30
a84f26fbf7 Update go-logr dependencies
Signed-off-by: ArkaSaha30 <arkasaha30@gmail.com>

Kubernetes-commit: 2cd23c8b17c93f75a30cf3f651369d7a932aef2d
2023-04-19 21:01:55 +05:30
Mohit Sharma
bf22836255 Dependencies Update golang.org/x/tools v0.7.0 to v0.8.0
Kubernetes-commit: 6f90c5363301c9417a3a806cac69f3e79e66a66c
2023-04-14 04:39:43 -07:00
Kubernetes Publisher
0c639881e7 Merge pull request #117399 from mohitsharma-in/update/golang_time
dependencies : Update golang.org/x/time v0.3.0

Kubernetes-commit: cf89189ca3a3e5d280ba1cb09998c4b88dc1e127
2023-04-19 14:19:06 +00:00
Mohit Sharma
97e5f2f250 Dependencies Update golang.org/x/timet 90d013bbcef8 to v0.3.0
Kubernetes-commit: 4d73864026cde02f4a1cdf9e889a124174d38e38
2023-04-16 22:18:35 -07:00
Mohit Sharma
041b3547e0 Dependencies Update google.golang.org/protobuf v1.28.1 to v1.30.0
Kubernetes-commit: 8efeb5afcfd006a48d6e1263a5cf8de3284797df
2023-04-14 04:28:47 -07:00
Kubernetes Publisher
34e8e46e12 Merge pull request #117285 from humblec/azure-go-autorest
dependencies: update gh/Azure/auto-test/{adal,validation}

Kubernetes-commit: ba0a8f9cceb513bc36bd803e9bf8f9a8c3912ff2
2023-04-13 22:49:56 +00:00
Humble Chirammal
0ad20aad6d dependencies: update gh/Azure/auto-test/{adal,validation}
Signed-off-by: Humble Chirammal <humble.devassy@gmail.com>

Kubernetes-commit: 6d13cad2cf56d0bad77a6410a0c36b2cf8f0df57
2023-04-13 23:25:48 +05:30
Kubernetes Publisher
8d86290f18 Merge pull request #116916 from mhuxtable/mhuxtable/update-signals-documentation
Fix sample-controller docs after moving to context-based cancellation

Kubernetes-commit: ab4ce0e9b8702c47fff1087eb676f77528783473
2023-04-12 04:41:09 +00:00
Kubernetes Publisher
7b42b3ac51 Merge pull request #116948 from MadhavJivrajani/fix-verify-vendor
.*: update vendor dir and cleanup

Kubernetes-commit: 3a46f2611503b4d8a8ab557bf2541ac9c1be695a
2023-03-27 19:03:35 +00:00
Madhav Jivrajani
b3ac4b7d35 .*: update vendor dir and cleanup
Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>

Kubernetes-commit: 63b5ca69f1f481b2b4b2ee967f5b8b7b58937211
2023-03-27 19:18:05 +05:30
Matthew Huxtable
7f56985485 Fix sample-controller docs after moving to context-based cancellation
Since the stop channels were replaced in e346475, the commentary is
incorrect and confusing.

Kubernetes-commit: 03be789851db6e0606b2d58c220d0cb40f127168
2023-03-24 15:39:19 +00:00
Kubernetes Publisher
67d596f803 Merge pull request #116539 from pohly/ginkgo-gomega-update
dependencies: ginkgo v2.9.1, gomega v1.27.3

Kubernetes-commit: f22504a9bafd5e34d86853a816d10578376aadc2
2023-03-15 08:34:47 +00:00
Patrick Ohly
bc38f4007a dependencies: ginkgo v2.9.1, gomega v1.27.4
They contain some nice-to-have improvements (for example, better printing of
errors with gomega/format.Object) but nothing that is critical right now.

"go mod tidy" was run manually in
staging/src/k8s.io/kms/internal/plugins/mock (https://github.com/kubernetes/kubernetes/pull/116613
not merged yet).

Kubernetes-commit: fe59e091eb3331db54cff2351f16eabfe0cb681d
2023-03-13 16:06:20 +01:00
Kubernetes Publisher
975f3288b1 Merge pull request #116542 from enj/enj/f/go1.20
Explicit bump to go 1.20

Kubernetes-commit: de9ce03f19e8b1ace1e79fae17119820c4232b67
2023-03-13 21:56:16 +00:00
Monis Khan
7d3b90bd08 Explicit bump to go 1.20
Signed-off-by: Monis Khan <mok@microsoft.com>

Kubernetes-commit: ba471884fba92246e1547ce4a27f9d5e735afc60
2023-03-13 12:47:36 -04:00
Kubernetes Publisher
afd209191c Merge pull request #116349 from apelisse/use-smarter-cache
Update kube-openapi to 15aac26d736a

Kubernetes-commit: a034962173e2b481d59e81178e3897870511ec7d
2023-03-10 09:27:01 +00:00
Antoine Pelisse
3184b86c93 Update kube-openapi to 15aac26d736a
Kubernetes-commit: 9bbdb9f130516a14a73914d0b41396ddb72a88ea
2023-03-07 16:14:54 -08:00
Kubernetes Publisher
1a5bb6be7e Merge pull request #113879 from pchan/contextual_logging_sample_controller
Migrate sample-controller to contextual logging

Kubernetes-commit: 1af56548af167d836eff33a5f57552fa417cbc0b
2023-03-07 16:08:36 +00:00
Kubernetes Publisher
32a619188a Merge pull request #116284 from thockin/codegen_subprojects_cleanup_verify
Codegen: subprojects: clean up verify scripts

Kubernetes-commit: 931e07de169c8c9a1b4a640a15cc87156942966b
2023-03-06 12:14:01 +00:00
Tim Hockin
04f11f30c4 Codegen: subprojects: clean up verify scripts
They all run successfully.

Kubernetes-commit: 357bfbc43643c956782e1ca5b7923a20338fba29
2023-03-05 11:33:45 -08:00
Kubernetes Publisher
09020756b4 Merge pull request #116162 from apelisse/update-openapi
Update kube-openapi to afdc3dddf62d31f5e3868d699379c571a6007920

Kubernetes-commit: 253ab3eda71f250ad6692bb16f035cebaf0651c9
2023-03-04 00:42:37 +00:00
Antoine Pelisse
63d5fc26a5 Update kube-openapi to afdc3dddf62d31f5e3868d699379c571a6007920
Kubernetes-commit: 736123f447219375219a23b9acc9d550fe8ec4c4
2023-03-03 08:43:44 -08:00
Kubernetes Publisher
fdf82b3f5d Merge pull request #115277 from pohly/klog-update
klog update

Kubernetes-commit: 51dedff4f3efd407ebf47de11d0db521274471a3
2023-03-02 02:10:59 +00:00
Patrick Ohly
6c2b3ebdb2 dependencies: update klog v2.90.1
This improves performance of the text formatting and ktesting.

Because ktesting no longer buffers messages by default, one unit
test needs to ask for that explicitly.

Kubernetes-commit: 961819a4d09488e20931103e0c36d2bed588fdcb
2023-01-23 18:19:54 +01:00
Kubernetes Publisher
0f89ce00cc Merge pull request #115786 from liggitt/net-0.7.0-master
Update golang.org/x/net to v0.7.0

Kubernetes-commit: b3d8ac8496a23d65a907f9333d906bcd5463764e
2023-02-15 13:15:35 +00:00
Jordan Liggitt
0f98dd227c Update golang.org/x/net to v0.7.0
Kubernetes-commit: f8e00778ddca11c08117ccf1d1c410641c70c428
2023-02-14 23:14:30 -05:00
Kubernetes Publisher
3748ca3c60 Merge pull request #115665 from aramase/aramase/f/update_vendor_k8s_utils
Update k8s.io/utils to `a36077c30491`

Kubernetes-commit: 9a51625ebebcc8345c851afc2b5cc98eb19ac193
2023-02-10 01:31:31 +00:00
Anish Ramasekar
75e2193f1d Update k8s.io/utils to a36077c30491
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>

Kubernetes-commit: 09e02052fdf3d248368b3d05d5c922d616528c4c
2023-02-09 20:09:41 +00:00
Kubernetes Publisher
52f4ee6cbf Merge pull request #115379 from artemvmin/serial-mkfs
Add an option to limit the number of concurrent mkfs calls

Kubernetes-commit: 6eb008620cd0ee3501326ee003d47fbaf1fa5b52
2023-02-07 05:31:20 +00:00
Artem Minyaylov
0841032366 Update k8s.io/utils to latest version
Update all usages of FakeExec to pointer to avoid copying the mutex

Kubernetes-commit: f573e149423dc578284789fdff8eeb3c195b5ccf
2023-02-03 14:51:25 -08:00
Kubernetes Publisher
65c705af60 Merge pull request #115266 from pohly/gomega-update
dependencies: update gomega to v1.26.0

Kubernetes-commit: 6d17cb2051b3a9958ed3353df242312d85e75d43
2023-01-30 21:27:30 +00:00
Patrick Ohly
3dceda812c dependencies: update gomega to v1.26.0
If gomega.Eventually/Consistently run into a situation where it observes some
state of e.g. a pod which does not satisfy the condition and then further
polling fails with API server errors, gomega will report both the most recent
pod state and API error instead of just the API error.

Kubernetes-commit: aa1279b5eb79177f5351368d8d9159982b1bfb5e
2023-01-23 15:19:38 +01:00
Kubernetes Publisher
5fbae435f7 Merge pull request #114550 from alexzielenski/apiserver/smd/update-kube-openapi
update kube-openapi dependency

Kubernetes-commit: df03edaf755f71a61f4f817ca374ebe3b6416270
2023-01-25 05:28:44 +00:00
Alexander Zielenski
a948f2840e update kube-openapi
Kubernetes-commit: 7641ff75412c1d8b547c4fa388d3901aeeda6948
2023-01-23 15:32:33 -08:00
Kubernetes Publisher
878acb8a93 Merge pull request #115184 from thockin/codegen-1-clientset-doc-go
Don't generate clientset/doc.go in client-gen

Kubernetes-commit: c2d18a6d14974b123d09c4ce40ea0dd79184787d
2023-01-19 05:09:38 +00:00
Tim Hockin
1b4a2aca3e Don't generate clientset/doc.go in client-gen
It seems valuable to be able to provide hand-written docs for these
first-level directories, and if don't want them, the generated doc.go
files are not actually very helpful.

This commit also adds new doc.go files for client-go listers/ and
informers/.

Kubernetes-commit: 95bf7b0afe9dd6a0f00125b1d290514a23e778e2
2023-01-12 09:51:33 -08:00
Kubernetes Publisher
7ae189db92 Merge pull request #114766 from MadhavJivrajani/prepare-for-go1.20
[Prepare for go1.20] *: Bump versions and fix tests

Kubernetes-commit: 4802d7bb62c2623be8e4f940f6b5c1fcddd6c744
2023-01-12 20:28:53 +00:00
Madhav Jivrajani
60953c4e06 *: Bump version of vmware/govmomi
Bumping version to include changes that
better handle TLS errors. Bump nescessary
to prepare for when the version of Go is
bumped to 1.20

Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>

Kubernetes-commit: 8b064fa4be71b5f1b498fabb5caade3c57f5d434
2023-01-02 20:56:02 +05:30
Kubernetes Publisher
be06c35fc0 Merge pull request #114879 from olivierlemasle/bump-kube-openapi
Bump kube-openapi

Kubernetes-commit: 8fdaac238e4f7f560066ea3a324cdbcaae564ac9
2023-01-12 03:48:37 +00:00
Olivier Lemasle
5567b5e953 Bump kube-openapi
Kubernetes-commit: 8b8e20fcdbbeeb4520995e4f7c6a003a33062dd2
2023-01-09 20:41:41 +01:00
Kubernetes Publisher
26f436b29b Merge pull request #114859 from pohly/e2e-ginkgo-spec-ordering
dependencies: update ginkgo to v2.7.0

Kubernetes-commit: a11ad04564f05e5d7e2d5a3f421ec5a45b6807c5
2023-01-11 01:46:34 +00:00
Patrick Ohly
d3935a19e6 dependencies: update ginkgo to v2.7.0
The new ginkgo release adds sorting of specs. This was triggered by
the observation that parallel test execution of Kubernetes E2E tests
sometimes ran the same spec twice and (presumably) other specs not at all
because spec order was random due to iteration over a map.

Sorting should avoid that problem.

Kubernetes-commit: baf832d80d798d53ceb7d4de3a39330c6eda5c6a
2023-01-05 21:19:14 +01:00
Kubernetes Publisher
d9f6a9457d Merge pull request #114869 from liggitt/kube-openapi
bump kube-openapi

Kubernetes-commit: 0e49c542d7a73dd056f8f32f33939207dd009b14
2023-01-07 08:43:53 +00:00
Jordan Liggitt
6a34462b5a bump kube-openapi
Kubernetes-commit: d78de56d769ee9bd2193ccadbac5621d4a0ae89d
2023-01-06 12:21:58 -05:00
Kubernetes Publisher
ff45eb4316 Merge pull request #114867 from deads2k/app
add deads2k to approvers for code-generator and sample-controller

Kubernetes-commit: 3d67e162a03d0d724dc5a15a0617c5e8572c7b4a
2023-01-07 08:43:51 +00:00
David Eads
a2179cb81e add deads2k to approvers for code-generator and sample-controller
Kubernetes-commit: 01a5c23dc1186b5a3ae0d07326f65bd6ab3f189c
2023-01-05 17:16:22 -05:00
Kubernetes Publisher
2307facf35 Merge pull request #114786 from CatherineF-dev/update-doc
Update doc about json tag is needed to generate informer externalversion package

Kubernetes-commit: 7fd0ff5761103ae3b3f9335cbca270ff3b052a6c
2023-01-07 08:43:50 +00:00
Kubernetes Publisher
f642284f7b Merge pull request #113654 from stevekuznetsov/skuznets/fake-group-name-registration
code-generator: refer to the API package for GV{R,K}

Kubernetes-commit: c97dbd1afb815731cbebf9cb0d888a29c39e2b76
2023-01-07 08:43:48 +00:00
Kubernetes Publisher
720872638d Merge pull request #114829 from liggitt/oauth-revert
Revert "bump golang.org/x/oauth2"

Kubernetes-commit: 293bf70916de8ef61d5f868f53959f1e15b3e091
2023-01-07 08:43:46 +00:00
Jordan Liggitt
75990915ef Revert "bump golang.org/x/oauth2"
This reverts commit fc9a140badf29382c1396b7de4813849d6f3e3c9.

Kubernetes-commit: 9f07c8e346fef454942d205f2702885475c7fc9a
2023-01-04 17:58:08 -05:00
Kubernetes Publisher
364b905d29 Merge pull request #114822 from liggitt/oauth2
bump golang.org/x/oauth2

Kubernetes-commit: 4e785dc7e3ac1d01cedd23a0ed9c4a67dc9c214f
2023-01-07 08:43:43 +00:00
Jordan Liggitt
67476c54bc bump golang.org/x/oauth2
Kubernetes-commit: fc9a140badf29382c1396b7de4813849d6f3e3c9
2023-01-04 11:16:43 -05:00
CatherineF-dev
c1519a0932 Update staging/src/k8s.io/sample-controller/README.md
Co-authored-by: Joel Speed <Joel.speed@hotmail.co.uk>

Kubernetes-commit: 2d4eefe9396fc71c9900992371c35a17f3647932
2023-01-04 08:01:48 -05:00
Catherine Fang
66316083a5 Update doc about json tag is needed to generate informer externalverion package
Kubernetes-commit: e98a28e5c78e9d6bf428ecd614ddf62083b0ea9a
2023-01-03 14:08:57 -05:00
Kubernetes Publisher
b416d508ca Merge pull request #114705 from thockin/codegen_subproject_cleanup
Cleanup codegen subproject scripts

Kubernetes-commit: 136eb9c203dab04e9647a1a32f3b1245a734ce43
2022-12-27 17:42:34 +00:00
Prasad Chandrasekaran
ab7425d650 Migrate sample-controller to contextual logging
Kubernetes-commit: e346475822604fc41bd38e24a331fc7a8314876a
2022-11-14 09:16:04 +05:30
Steve Kuznetsov
e293c67c9f code-generator: refer to the API package for GV{R,K}
There should only be one source of truth for the API group's name and
version.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>

Kubernetes-commit: e13198ec6f52c4a6405388e90053954dc7656a31
2022-11-06 07:05:42 -07:00
Tim Hockin
d823e38114 Cleanup codegen subproject scripts
Mostly really small things like linewraps and quoting.

Kubernetes-commit: 0cba4a197d07fc86292f3c029a8419e358cf0271
2022-10-09 11:56:03 -07:00
Kubernetes Publisher
65090b4041 Merge pull request #113538 from pohly/e2e-ginkgo-timeline
e2e: ginkgo timeline

Kubernetes-commit: 020fb2eb776c0affad3a9ff7dd21ba231e6c646d
2022-12-23 05:12:57 +00:00
Patrick Ohly
6f25217104 dependencies: update to ginkgo v2.6.1, gomega v1.24.2
Ginkgo v2.5.0 adds support for a "timeline": a full description of what happened
while a specific test ran, including failures, timeouts, and log output.

Ginkgo v2.6.0 adds ReportBeforeSuite which we need for
https://github.com/kubernetes/kubernetes/issues/114313.

Kubernetes-commit: f3ef4004317c1a12d84021be29dd5f92badc8eff
2022-11-02 09:07:12 +01:00
Kubernetes Publisher
9c14d5f01b Merge pull request #114319 from liggitt/net-master
Update golang.org/x/net 1e63c2f

Kubernetes-commit: 72acaad83924360960e21915aa94cd1db8d0196c
2022-12-07 03:08:21 +00:00
Jordan Liggitt
dbcb959ea1 Update golang.org/x/net 1e63c2f
Includes fix for CVE-2022-41717

Kubernetes-commit: afe5378db9d17b1e16ea0028ecfab432475f8e25
2022-12-06 17:29:11 -05:00
Kubernetes Publisher
d64be4b2ac Merge pull request #113688 from dashpole/update_utils
Update k8s.io/utils to fix util tracing panic

Kubernetes-commit: fa2e203a6bde89a84443ee9813e1f27aa31326a9
2022-11-08 07:04:08 +00:00
David Ashpole
30ac52541e update k8s.io/utils to fix util tracing panic
Kubernetes-commit: 3f1511c8e9a64cf60821036aa1fc3ec9d58a2931
2022-11-07 19:30:21 +00:00
Kubernetes Publisher
e01c4e0640 Merge pull request #113367 from pohly/dep-ginkgo-gomega
dependencies: update to gomega v1.23.0 and ginkgo v2.4.0

Kubernetes-commit: 9e8558158478f622104afd0328883577756bff9f
2022-10-28 16:16:50 +00:00
Patrick Ohly
ca1d102a24 dependencies: update to gomega v1.23.0 and ginkgo v2.4.0 and dependencies
Gomega adds support for formatting extensions and StopTrying in matchers.
Ginkgo enhances DeferCleanup.

This also triggered an update of other dependencies.

Kubernetes-commit: e6ad2f2f23449c9d24606b864c4737dc66a7427e
2022-10-24 13:43:15 +02:00
Kubernetes Publisher
cac70dfe3a Merge pull request #112693 from aimuz/fix-GO-2022-0969
Fixed CVE-2022-27664 Bump golang.org/x/net to v0.1.1-0.20221027164007-c63010009c80

Kubernetes-commit: 6cb473b6c4f1239d411e0a50a1cdf9c4c092c42a
2022-10-28 08:18:06 +00:00
aimuz
dbc4c2daf1 Fixed (CVE-2022-27664) Bump golang.org/x/net to v0.1.1-0.20221027164007-c63010009c80
Fixed https://pkg.go.dev/vuln/GO-2022-0969

Signed-off-by: aimuz <mr.imuz@gmail.com>

Kubernetes-commit: 78c704d4f60d54996d483d49c23c6aac82f28dc9
2022-10-28 10:07:56 +08:00
Kubernetes Publisher
0c9c744bef Merge pull request #113106 from pohly/dep-ginkgo-gomega
dependencies: update to gomega v1.22.1 and ginkgo v2.3.1

Kubernetes-commit: 4216ad3542ff5defcfdb303945772a8e1663a7f6
2022-10-17 20:15:18 +00:00
Patrick Ohly
422351c0de dependencies: update to gomega v1.22.1 and ginkgo v2.3.1
This adds support for timeouts and intermediate reports in Eventually and
Consistently.

Kubernetes-commit: d1dbf7ae3e223d5d93d0b3d875e4f03ff38e6de0
2022-10-07 17:19:09 +02:00
Kubernetes Publisher
e5cd07ddac Merge pull request #112988 from alexzielenski/update-kube-openapi
update kube-openapi

Kubernetes-commit: 353e00796ef4c1e8fcea1cb51bcc62fc3acac3c8
2022-10-15 04:12:51 +00:00
Kubernetes Publisher
2adaafedd8 Merge pull request #113037 from pacoxu/fsnotify-v1.6.0
update fsnotify to v1.6.0

Kubernetes-commit: 542ec977054c16c7981606cb1590cc39154ddf01
2022-10-14 08:20:32 +00:00
Alexander Zielenski
2d02fd155b update kube-openapi
hack/pin-dependency.sh k8s.io/kube-openapi 172d655c2280350c77cf05962948fc67ff043492
hack/update-vendor.sh

Kubernetes-commit: f622dd918ab5d3bc902a8c625a0a89b21e8afe43
2022-10-13 19:51:22 -07:00
Paco Xu
8263c46353 update fsnotify to v1.6.0
Kubernetes-commit: 3fee9d27355afe64dec7fa264e1faf209712f169
2022-10-13 13:14:43 +08:00
Kubernetes Publisher
cfaf8d4d6a Merge pull request #112989 from ameukam/bump-golang.org/x/text-to-v0.3.8
Bump golang.org/x/text to v0.3.8

Kubernetes-commit: 054d86feb42b67bb13608d9aa9a7c986750da753
2022-10-12 04:11:21 +00:00
Arnaud Meukam
44c75ac514 Bump golang.org/x/text to v0.3.8
Signed-off-by: Arnaud Meukam <ameukam@gmail.com>

Kubernetes-commit: 0d19690a54e480923e8222ce79566e6879667a1f
2022-10-11 23:30:39 +02:00
Kubernetes Publisher
39017128b4 Merge pull request #112875 from pohly/update-yaml
dependencies: update to sigs.k8s.io/yaml v1.3.0

Kubernetes-commit: 93d1c43b491a39740297cf1e76782b99d8739865
2022-10-06 16:13:11 +00:00
Patrick Ohly
1b52687cfc dependencies: update to sigs.k8s.io/yaml v1.3.0
No particular benefit and no relevant changes, it's just to stay up-to-date and
to avoid having to pull that in when merging
https://github.com/kubernetes/kubernetes/pull/111023 which indirectly depends
on the newer release.

Kubernetes-commit: 9b93cc663a102b6e36f07eecc7b6e32225f39295
2022-10-05 11:14:23 +02:00
Kubernetes Publisher
6d1d76794e Merge pull request #112705 from stevekuznetsov/skuznets/fix-comment
clients: clarify a misleading comment

Kubernetes-commit: bc6e801aa0e0cf17d22652ff881ebc3540b7af55
2022-09-26 17:02:08 +00:00
Steve Kuznetsov
14777496a1 clients: clarify a misleading comment
It's clear that client-sets contain many versions of one group, so this
comment just seems to be out-dated.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>

Kubernetes-commit: 588f016c3bc04ea2da85d7077643677028a8cb1b
2022-09-23 12:25:52 -06:00
Kubernetes Publisher
06ffc51d9b Merge pull request #112673 from dims/update-to-latest-k8s.io/utils-sep-22
Update to latest k8s.io/utils to pick up changes

Kubernetes-commit: 722e02408ed1d0d1fc5b7304e2ad8c23125aa2b4
2022-09-22 19:27:15 +00:00
Davanum Srinivas
400ced2a78 Update to latest k8s.io/utils to pick up changes
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 4e7e7cdd3ce7cd0cec806298c2b7705ea240369c
2022-09-22 07:14:21 -04:00
Kubernetes Publisher
014c98bd26 Merge pull request #112613 from dims/update-github.com/go-openapi/jsonreference-to-drop-github.com/PuerkitoBio/purell
Update github.com/go-openapi/jsonreference to drop github.com/PuerkitoBio/purell

Kubernetes-commit: 299e65cdc5799b982b6af69858c14bfe41463540
2022-09-21 15:00:24 +00:00
Davanum Srinivas
8eacdd497f update github.com/go-openapi/jsonreference to drop github.com/PuerkitoBio/purell
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 005a5ca08173b080193ecb01421e2513f32d045b
2022-09-20 20:49:55 -04:00
Kubernetes Publisher
6cb90e3e17 Merge pull request #112545 from dims/update-etcd-3.5.5-and-all-otel-related-to-latest
Update etcd 3.5.5 and all otel related libraries to newer versions

Kubernetes-commit: 6820a383be4a1bbb5cd526eb3aeb9e6ade351498
2022-09-20 03:00:36 +00:00
Kubernetes Publisher
2689857760 Merge pull request #112352 from pohly/e2e-ginkgo-progress
e2e: better ginkgo progress reports

Kubernetes-commit: 25b93a607a3edd28b0c720701ab7b6ebf1252148
2022-09-19 11:44:06 +00:00
Davanum Srinivas
ad2b0ad297 updated etcd to v3.5.5 and newer otel libraries as well
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 5be80c05c423daf4bd2a4eb1cabf61fae9a03629
2022-09-17 14:04:16 -04:00
Patrick Ohly
e572372395 e2e: bump ginkgo to v2.2.0
The new release adds support for intermediate progress reports.

Kubernetes-commit: 1e4edaf2fe0a7bedd7e54725b489f62c20c92954
2022-09-09 15:47:46 +02:00
Kubernetes Publisher
2180d334f0 Merge pull request #112200 from pohly/client-go-shared-informer-factory-shutdown
client-go: support waiting for SharedInformerFactory shutdown

Kubernetes-commit: 084a412e03816ef3ea57da928ae8fd332d17ab59
2022-09-13 18:51:17 +00:00
Kubernetes Publisher
17031b84be Merge pull request #112349 from pohly/klog-update
build: update to klog v2.80.1

Kubernetes-commit: b48b0eac6ad3556b343f54c26b49ed74cac276e3
2022-09-09 23:16:25 +00:00
Patrick Ohly
e28fbcec00 build: update to klog v2.80.1
The fix for https://github.com/kubernetes/klog/issues/348 is required before
https://github.com/kubernetes/kubernetes/pull/111998 can be merged because the
way how a unit test in that PR uses klog triggers the data race.

Kubernetes-commit: 60d92dd96a4ba3873dd9e061c3e332c16c213e30
2022-09-09 13:11:55 +02:00
Kubernetes Publisher
9fde59ebf7 Merge pull request #111768 from weilaaa/feature_add_symmetric_difference_in_sets_string
add method symmetric difference in sets.String

Kubernetes-commit: c9c3d2e9d90fbad2d0f6031ee40b6c9b5e31253e
2022-09-09 06:52:01 +00:00
weilaaa
76eab7bb36 add symmetric difference in sets
Kubernetes-commit: 2b55c94e37bf7a995eb9a03271191e67b100dc0b
2022-09-07 20:25:44 +08:00
Kubernetes Publisher
b6ded8f0b8 Merge pull request #112199 from pohly/klog-update
dependencies: update to klog v2.80.0

Kubernetes-commit: bacd6029b3bac1dbc468b0cc2bc5770bef671af2
2022-09-02 18:53:51 +00:00
Patrick Ohly
01aa5bae31 dependencies: update to klog v2.80.0
Contains one bug fix in the code path for formatting of objects that support
LogMarshal.

Kubernetes-commit: 1bc3bde128463cdc6d55d5d222f489e8eda5eeb7
2022-09-02 08:05:47 +02:00
Patrick Ohly
17c7f29b31 client-go: support waiting for SharedInformerFactory shutdown
SharedInformerFactory starts goroutines in Start and those can be stopped by
closing the stop channel. However, there was no API that waits for the
goroutines.

This is a problem for unit testing. A test has to return while the informers
are still running, which may get flagged by tools like
https://github.com/uber-go/goleak or by klog/ktesting when those informers
lead to log output.

While at it, more documentation gets added to address
https://github.com/kubernetes/kubernetes/issues/65036.

Kubernetes-commit: e89d1d47e8365cad31600b17dab662d3c8a359dd
2022-09-01 13:46:08 +02:00
Kubernetes Publisher
d6f91791de Merge pull request #112129 from pohly/e2e-ginkgo-report-after-each
e2e: suppress too verbose output

Kubernetes-commit: d0e413e86d150e0d4638ce306ca3fd437fe0b763
2022-08-31 18:53:29 +00:00
Patrick Ohly
8ae24ebf32 dependencies: update to ginkgo v2.1.6 and gomega v1.20.1
Ginkgo v2.1.6 adds ginkgo.SuppressProgressReporting which is needed
to suppress too verbose output each time the ReportAfterEach of the custom
progress reporter is invoked.

Kubernetes-commit: 311144fb3e61dabdbcd48d164dc80716b5ba5a73
2022-08-30 19:33:50 +02:00
Kubernetes Publisher
f07c1231eb Merge pull request #112052 from tosi3k/bump-client-golang
Bump prometheus/client_golang to v1.13.0

Kubernetes-commit: 8ccd03226f81573b91550f21c6b8d63f65e7c2f1
2022-08-26 10:52:53 +00:00
Antoni Zawodny
9311b76fe7 Bump prometheus/client_golang to v1.13.0
Kubernetes-commit: f78e7a2b19fe275b7cb43c01099366c52545e4d1
2022-08-26 05:40:17 +02:00
Kubernetes Publisher
50026bca24 Merge pull request #111696 from liggitt/go119mod
Update go.mod to go1.19

Kubernetes-commit: 897cdea783916023f269e32003a9a3cdb98e4b46
2022-08-04 20:34:21 +00:00
Jordan Liggitt
43e201d522 Update go.mod to go1.19
Kubernetes-commit: 00db9f02293a6e0325330b575bffb9e466406dfe
2022-08-04 10:03:05 -04:00
Kubernetes Publisher
e2a3b9d8fd Merge pull request #111677 from dims/stop-panic-in-govet-levee
Stop panic in govet levee under golang 1.19

Kubernetes-commit: ef7fc1046059b7cbf93a7a7f5481ed200783ff21
2022-08-04 08:33:15 +00:00
Davanum Srinivas
46d98a3b66 run lint-dependencies and follow directions
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 34742f2d2eebfc3ced8442f8579581705dcba38d
2022-08-03 21:56:02 -04:00
Davanum Srinivas
2f083d1ba7 Stop panic in govet-levee CI job
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 30e2fcd041cdf00d91fb7876f28165f532950213
2022-08-03 21:47:28 -04:00
Kubernetes Publisher
653c2c40b1 Merge pull request #110495 from alexzielenski/atomic-objectreference
make ObjectReference field ownership granular

Kubernetes-commit: a0e702763e01d246ce13a5d7608407204094748a
2022-08-04 00:58:10 +00:00
Alexander Zielenski
4e08ccb08b update kube-openapi
Kubernetes-commit: 133c26553020409b26de0c1487c804250b528e71
2022-08-03 09:46:39 -07:00
Natasha Sarkar
d7bef87a24 Update kubectl kustomize to kyaml/v0.13.9, cmd/config/v0.10.9, api/v0.12.1, kustomize/v4.5.7 (#111606)
Kubernetes-commit: 83c3c37a879c6d14cce2465161f88d3c6881de8b
2022-08-03 04:31:01 +00:00
Kubernetes Publisher
73bb41c0ad Merge pull request #111557 from alexzielenski/update-smd-422
update smd to 4.2.3

Kubernetes-commit: 22eab136f6c85f83e56ff71ec6346ffd7cc5e977
2022-08-02 20:33:53 +00:00
Alexander Zielenski
f9b3f9837d update smd to 4.2.3
Kubernetes-commit: e77ed0bc2e3a807f4aca9360ec20933a03869716
2022-08-02 10:07:50 -07:00
Kubernetes Publisher
b352fb50dd Merge pull request #111587 from ialidzhikov/k8s-utils@ee6ede2d64
Update `k8s.io/utils` to `ee6ede2d64ed`

Kubernetes-commit: 9af9947230633823ffa94e1fd11c58d7af986d8b
2022-08-01 04:31:22 +00:00
ialidzhikov
b09b22b2a0 Update k8s.io/utils to ee6ede2d64ed
Kubernetes-commit: 6aa5efb1bdc2d0dcccca67c6a9cc20820380a366
2022-07-31 16:33:14 +03:00
Kubernetes Publisher
6916c10bed Merge pull request #111442 from ialidzhikov/k8s-utils@56c0de1e6f
Update `k8s.io/utils` to `9bab9ef40391`

Kubernetes-commit: e092b6d27bff004171b71fffa45f111fdcd6e81b
2022-07-27 20:22:39 +00:00
ialidzhikov
9841c504d2 Update k8s.io/utils to 9bab9ef40391
Kubernetes-commit: 168fef6845f50f0460e7bdc0280da480cc92b787
2022-07-26 18:43:20 +03:00
Kubernetes Publisher
89a3f6e8a6 Merge pull request #111254 from dims/update-to-golang-1.19-rc2
[golang] Update to 1.19rc2 (from 1.18.3)

Kubernetes-commit: 3ffdfbe286ebcea5d75617da6accaf67f815e0cf
2022-07-27 00:23:49 +00:00
Davanum Srinivas
c7dba53ab8 Generate and format files
- Run hack/update-codegen.sh
- Run hack/update-generated-device-plugin.sh
- Run hack/update-generated-protobuf.sh
- Run hack/update-generated-runtime.sh
- Run hack/update-generated-swagger-docs.sh
- Run hack/update-openapi-spec.sh
- Run hack/update-gofmt.sh

Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: a9593d634c6a053848413e600dadbf974627515f
2022-07-19 20:54:13 -04:00
Kubernetes Publisher
f30c3c1682 Merge pull request #110178 from kevindelgado/validation-beta-1-25
Graduate server side validation to beta

Kubernetes-commit: eeb12bb3af3361c9ac652be071c3b9cf49aa5e58
2022-07-22 17:28:43 +00:00
Kevin Delgado
42b46bfebc update kjson
Kubernetes-commit: c210483cf02768c3f2eaf42e13844c5d821831ba
2022-07-13 16:05:45 +00:00
Kubernetes Publisher
a7650c76f8 Merge pull request #111008 from cici37/bumpCEL
Bump cel-go to v0.12.3

Kubernetes-commit: 19a22f763770d1208dca2b8d50513ac805f7fe14
2022-07-14 13:29:15 +00:00
Cici Huang
ef20871795 Bump cel-go to v0.12.0
Kubernetes-commit: 772a252b06da86955d30d7b935dc4dba84fdc328
2022-07-07 17:13:57 +00:00
Kubernetes Publisher
ba34703c1c Merge pull request #111001 from pohly/klog-update
build: update to klog v2.70.1

Kubernetes-commit: 8e62fd24b073296c4cfd8f8d966d5922b6d9022c
2022-07-08 01:40:48 +00:00
Patrick Ohly
c2bcb8aedb build: update to klog v2.70.1
This makes ktesting more resilient against logging from leaked goroutines,
which is a problem that came up in kubelet node shutdown
tests (https://github.com/kubernetes/kubernetes/issues/110854).

Kubernetes-commit: 3581e308835c69b11b2c9437db44073129e0e2bf
2022-07-07 12:54:08 +02:00
Kubernetes Publisher
44915722b0 Merge pull request #110831 from chendave/openapi
Bump `kube-openapi` to the latest

Kubernetes-commit: 8a7eda4f610f7003bf096d870531c7583751674e
2022-06-30 20:22:48 +00:00
Dave Chen
7bfa87551b Bump kube-openapi to the latest
This will help us to get rid of `Ginkgo` v1 dep.

Signed-off-by: Dave Chen <dave.chen@arm.com>

Kubernetes-commit: 597071af17377f5ab4de03804b0d8b41f73fe7ce
2022-06-28 15:59:50 +08:00
Kubernetes Publisher
e920b7fdcb Merge pull request #110724 from pohly/klog-update
build: update to klog v2.70.0

Kubernetes-commit: ddfbb5bdbef1febda92fdc4ee4666f5339d1f729
2022-06-23 04:12:24 +00:00
Patrick Ohly
72e1fe6bab build: update to klog v2.70.0
The main practical advantage is that klog.Fatal no longer dumps the backtrace
of all goroutines.

Kubernetes-commit: f05e327ca611c23469ef41310d1d59b384cedc27
2022-06-22 16:29:51 +02:00
Kubernetes Publisher
e12a3f20b6 Merge pull request #110378 from lucacome/bump-grpc
Bump grpc to v1.47.0

Kubernetes-commit: de5982637aebe17b0fa4a814ec1e6675c0132ddd
2022-06-14 20:10:32 +00:00
Luca Comellini
2d441957ff Bump grpc to v1.47.0
Signed-off-by: Luca Comellini <luca.com@gmail.com>

Kubernetes-commit: 51fafd7de3e0d71d98a1f9e10d3801f157472ae3
2022-06-13 22:08:47 -07:00
Kubernetes Publisher
ca084eb7f5 Merge pull request #110518 from dims/switch-to-released-version-of-v3.8.0-github.com/emicklei/go-restful/v3
Switch to released version of v3.8.0 - github.com/emicklei/go-restful/v3

Kubernetes-commit: 0fe0dbf3fb8cf501c24c87f4113a3819cb86a550
2022-06-13 20:06:51 +00:00
Kubernetes Publisher
b459376f89 Merge pull request #110520 from dims/update-gopkg.in/yaml.v3-to-v3.0.1
Update gopkg.in/yaml.v3 to v3.0.1

Kubernetes-commit: 3375f5773b4371bc4975879521002b16ed8f0f56
2022-06-13 08:08:40 +00:00
Davanum Srinivas
069a69b377 Update gopkg.in/yaml.v3 to v3.0.1
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 68b414764bfa32c3232df7c7455b77e8e8c8ecd7
2022-06-11 20:39:40 -04:00
Davanum Srinivas
fb9e9623db Switch to released version of v3.8.0 - github.com/emicklei/go-restful/v3
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 6f2889718fb0bab46558fcd4a11b6858d5fc2149
2022-06-11 11:27:08 -04:00
Kubernetes Publisher
048cd7e7e0 Merge pull request #110351 from dims/switch-to-v3-of-github.com/emicklei/go-restful
Switch to v3 of github.com/emicklei/go-restful by updating kube-openapi

Kubernetes-commit: 7e66aa3cfb6cdac3508c04017fa3b7cdcdf9238f
2022-06-11 00:08:56 +00:00
Davanum Srinivas
a81237539e Switch to v3 of github.com/emicklei/go-restful
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: ab690750df1d27409d31fd270d77b4390bac4431
2022-06-02 10:03:29 -04:00
Kubernetes Publisher
f42769d51c Merge pull request #109891 from pohly/log-dependency-update
dependencies: logr and zapr v1.2.3

Kubernetes-commit: bf52c1fd46a6773b9d653ef97d94502c6e0564e5
2022-05-09 19:08:46 +00:00
Patrick Ohly
f6abbe189b dependencies: logr and zapr v1.2.3
The updated zapr is more resilient against MarshalLog crashing. Not a known
problem in Kubernetes, though.

Kubernetes-commit: 3e6974e0ba67a8f598e7bc4ccedfdab928935551
2022-03-31 11:26:57 +02:00
Kubernetes Publisher
387d9d13c0 Merge pull request #109804 from cici37/celUpdate
Bump cel-go to v0.11.2

Kubernetes-commit: b7c4d243de12a30bba02e23777c8ff1627263f89
2022-05-05 10:52:21 +00:00
cici37
30e6be3f8f Update go-control-plane, cncf/xds/go, cncf/udpa/go and remove unused versions
Kubernetes-commit: a3587c12da7f8c87e6676f472dba39f1acbae28f
2022-05-04 18:45:22 -07:00
cici37
11163f2bee Update GRPC
Kubernetes-commit: 334d8fb7a2e85d58513c2d3fae113995c8165a4b
2022-05-04 18:41:20 -07:00
cici37
b0f212501e Update genproto and antlr.
Kubernetes-commit: e8f6184d8682bd4510d4e18c7c04b5799367ac51
2022-05-04 18:37:30 -07:00
cici37
4367300a27 Bump cel-go to v0.11.2
Kubernetes-commit: a86dd2915771f280ff095409fc2ee917cee3c2e3
2022-05-04 18:32:06 -07:00
Kubernetes Publisher
3fbdfb3076 Merge pull request #109440 from liggitt/gomod-1.18
update go.mod files to go 1.18

Kubernetes-commit: cb7beb591216de93bef22525a6c5f0e435e21789
2022-05-05 02:51:48 +00:00
Jordan Liggitt
0e66fd34b1 Regenerate vendor
Kubernetes-commit: 9e1064a26bfdc18b3272c3d9031d729793725392
2022-05-04 10:27:41 -04:00
Kubernetes Publisher
f8bb5e22aa Merge pull request #109031 from Jefftree/openapiv3beta
OpenAPI V3 Enable Beta

Kubernetes-commit: 904c30562a9a34d26ff3e76db29d00daea2e0f60
2022-03-30 05:30:36 +00:00
Jefftree
e4abcaa647 generated: Update kube-openapi and vendor
Kubernetes-commit: 550d6383b5219ac43b8c86cf57807c47b82919aa
2022-03-28 13:20:46 -07:00
Kubernetes Publisher
c8c9b11047 Merge pull request #108992 from alexzielenski/cache-busting-client-go
client-go: OpenAPI v3 support

Kubernetes-commit: 656dc213ce43f1ecfa7f54eb1f01864468f8f0e2
2022-03-29 05:25:54 +00:00
Alexander Zielenski
14252063f0 update vendor
client-go depends on more of kube-openapi v3 now

Kubernetes-commit: bb799d97066bbae4eaacd2ecc2a57f7fd42fa142
2022-03-28 10:07:56 -07:00
Kubernetes Publisher
7f0799ebb8 Merge pull request #108996 from cici37/errUpdate
Bump kube-openapi and update err handling

Kubernetes-commit: 898443f40583cd0fd864e9b11c8156faf64b680a
2022-03-27 01:28:50 +00:00
cici37
614750a622 Bump kube-openapi
Kubernetes-commit: 383eb99bebdd5746732b7f6789907ea3598ee98e
2022-03-24 15:11:08 -07:00
Alex Zielenski
81678c7fe5 Update kube-openapi (#108895)
* upgrade k8s.io/kube-openapi

* fix open-api v3 blank aggregator output

* use keys as API group

in ./hack/update-openapi-spec.sh

* fix import grouping

* update openapiv3 integration tests

Kubernetes-commit: 11b3a18cca745485e1033be8d62a1d0cde5a1d1d
2022-03-24 21:28:00 +00:00
Kubernetes Publisher
528c934a26 Merge pull request #108725 from pohly/klog-flush-and-exit
klog v2.60.1

Kubernetes-commit: 56f45c5c811ba23934915b1a1330d87c58bddf07
2022-03-24 09:29:18 +00:00
Patrick Ohly
d34d891782 klog v2.60.1
The new release supports FlushAndExit and contextual logging.

Kubernetes-commit: 09aa1071cdde5ebc2c931c994fbb1e974c2a1515
2022-03-16 09:03:45 +01:00
Kubernetes Publisher
449c63c848 Merge pull request #108772 from aojea/user_agent
client-go: default user agent if empty

Kubernetes-commit: b0c435c8c48587edaeade94937525e03ccff9167
2022-03-19 18:21:05 +00:00
Antonio Ojea
7b89639d54 client-go: update generated
Kubernetes-commit: 1d5ad2264cbebe2ce33e288451c2757fa16a1956
2022-03-17 16:03:10 +01:00
Kubernetes Publisher
69f0c9d288 Merge pull request #108644 from Jefftree/googleapis-gnostic
googleapis/gnostic -> google/gnostic and update kube-openapi

Kubernetes-commit: b195a64d45e1880878a22d178055f1b4220dcb43
2022-03-19 18:21:02 +00:00
Jefftree
18468ba95a googleapis/gnostic -> google/gnostic
Kubernetes-commit: 8a1d5947ad34ba275192341baa4e5fef8e6c7f24
2022-03-15 20:36:21 -07:00
Kubernetes Publisher
db76aada04 Merge pull request #107105 from justaugustus/go118
golang: Update to go1.18rc1

Kubernetes-commit: bda996e6a7cd115d76ebf1e0c127bee68e06269a
2022-02-21 18:21:53 +00:00
Stephen Augustus
ad4f2eda06 generated: Run hack/lint-dependencies.sh and hack/update-vendor.sh
Also runs:
hack/pin-dependency.sh golang.org/x/mod \
  v0.6.0-dev.0.20220106191415-9b9b3d81d5e3

Signed-off-by: Stephen Augustus <foo@auggie.dev>

Kubernetes-commit: 4b1bd548bbe4d71609c65b050b69f63af1ca81d1
2021-12-18 15:55:39 -05:00
Kubernetes Publisher
55e96f8636 Merge pull request #107527 from wojtek-t/remove_selflink_ga
Graduate RemoveSelfLink to Stable

Kubernetes-commit: e42e2e877f01d28d886ebe5b855ff0f16ffca680
2022-02-15 06:21:41 +00:00
Wojciech Tyczyński
735d680475 Couple remaining SelfLink references cleanup
Kubernetes-commit: b62774f2f7907e0d519026e8fc3cfaf50eaa5d31
2022-01-19 21:19:25 +01:00
Kubernetes Publisher
f4ac6eb892 Merge pull request #108059 from RaghavRoy145/k8s-utils-update
Vendor in k8s.io/utils Changes

Kubernetes-commit: 8bae9bea45de30cc8eb3a3da604abd01376ffbd8
2022-02-11 18:19:58 +00:00
Raghav Roy
91b177d91c Updated k8s.io/utils dependency
Signed-off-by: Raghav Roy <raghavroy145@gmail.com>

Kubernetes-commit: e167d44a173991422b748afe1b9ed9a82bf6efa4
2022-02-11 13:03:54 +05:30
Kubernetes Publisher
76c5360f8c Merge pull request #105632 from xens/fix/kubectl-socks5-proxy2
Add SOCKS5 proxy support for kubectl exec

Kubernetes-commit: d10161b45b751df45701e343599476e27d533d58
2022-01-22 01:36:57 +00:00
Romain Aviolat
773efeedc3 feat: add missing SOCKS5 features
Goal of this commit is to add some missing features when the
Kubernetes API is accessed through a SOCKS5 proxy. That's for
example the case when port-forwarding is used (`kubectl port-forward`)
or when exec'ing inside a container (`kubectl exec`), with this
commit it'll now be possible to use both.

Signed-off-by: Romain Aviolat <romain.aviolat@kudelskisecurity.com>
Signed-off-by: Romain Jufer <romain.jufer@kudelskisecurity.com>

Kubernetes-commit: 0a98875e9572d998fbdf3bcdaef4961715b8bc06
2022-01-17 15:28:44 +01:00
Kubernetes Publisher
5fca79ec5f Merge pull request #105142 from pacoxu/cespare-2.1.2
upgrade github.com/cespare/xxhash/v2 to v2.1.2

Kubernetes-commit: 8d0d428ddd1cdc5f7ec9ead400921fb697aced95
2022-01-21 01:38:18 +00:00
Kubernetes Publisher
911b89b731 Merge pull request #107588 from discordianfish/fix-readme
Include applying subresource in Running section

Kubernetes-commit: 9c3a0e63a71c0890a5ab1aa0a267e91a81e5c441
2022-01-20 17:32:47 +00:00
-e
7828d16f05 upgrade prometheus/client_golang to v1.12.0(common to v0.32.1)
Kubernetes-commit: 8a4e66049edd6ade4e9107b4ea092580b626545a
2022-01-19 22:30:33 +08:00
Johannes 'fish' Ziemke
53ab9c39dc Include applying subresource in Running section
Signed-off-by: Johannes 'fish' Ziemke <github@freigeist.org>

Kubernetes-commit: 19bfbfd3632b66d65575c0e2be8f3aa229cc3eaa
2022-01-16 13:14:09 +01:00
Kubernetes Publisher
2308bba01c Merge pull request #107565 from jiahuif-forks/deps/structured-merged-diff
upgrade sigs.k8s.io/structured-merge-diff/v4 to v4.2.1

Kubernetes-commit: cf18d80d035780739575b8cc889e8f26bf36779f
2022-01-14 21:49:17 +00:00
Jiahui Feng
2eae75b07f generated: ./hack/update-vendor.sh
Kubernetes-commit: 31205dc7d9b271ede68ef90d09f416588ea3afdd
2022-01-14 10:31:44 -08:00
Kubernetes Publisher
9c6cef5573 Merge pull request #107293 from dims/jan-1-owners-cleanup
Cleanup OWNERS files - Jan 2021 Week 1

Kubernetes-commit: 3bd422dc76559c1e03e8aea894c6143d32ebd644
2022-01-13 21:35:44 +00:00
Davanum Srinivas
a741d1efde run update-yamlfmt.sh
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 3b2839f563c30101ebf7b3cbe69bb49c63976e14
2022-01-09 14:42:48 -05:00
Davanum Srinivas
1d596ac112 add munnerz back
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: ada4b7364808c7debf2e14e231ba05f528560458
2022-01-07 14:52:19 -05:00
Davanum Srinivas
f75fa2674c OWNERS cleanup - Jan 2021 Week 1
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 9682b7248fb69733c2a0ee53618856e87b067f16
2022-01-03 10:59:47 -05:00
Kubernetes Publisher
b2959da2dd Merge pull request #107103 from pohly/log-klog-update
dependencies: update klog to v2.40.1

Kubernetes-commit: 38ec822b46853acfb3c3dc7e386a8d4636c67e03
2021-12-22 01:35:32 +00:00
Patrick Ohly
4e507a157e dependencies: update klog to v2.40.1
The new release adds support for multi-line string output (required for
contextual logging) and Verbose.InfoSDepth (required to properly attach
verbosity to some log messages in helper code).

Kubernetes-commit: cb17b76d4d0a1c8021b427cd15b5d504bb468ee6
2021-12-17 14:23:59 +01:00
Kubernetes Publisher
0da864e270 Merge pull request #106601 from liggitt/gomodule-gengo-normalize
bump k8s.io/gengo

Kubernetes-commit: 2ae44bd74a64da2c4061f7675cb1e6cb20bbd5b3
2021-12-13 22:20:03 +00:00
Kubernetes Publisher
9426077e42 Merge pull request #106568 from liggitt/json-fieldpath
include field paths in unknown/duplicate errors

Kubernetes-commit: 66ca4b0a70a3d43c45603ba441b2a368dcb38722
2021-12-13 17:35:12 +00:00
Jordan Liggitt
3124341e37 bump k8s.io/gengo
Kubernetes-commit: 6e628f99706f6eadd0e7b7d2bfc2c11e410f7ca7
2021-12-13 10:05:29 -05:00
Jordan Liggitt
f2de7245d9 bump sigs.k8s.io/json
Kubernetes-commit: 0c5ed62c792826a547dd5a55639de150080c355b
2021-12-13 09:38:11 -05:00
Kubernetes Publisher
0468bacd33 Merge pull request #106964 from ncdc/portable-code-generation
Code generation outside GOPATH

Kubernetes-commit: 8b9e1d78f65ca83f877f043d1f4c5682626ebddb
2021-12-11 05:31:13 +00:00
Andy Goldstein
2ba1b364c3 Bump k8s.io/gengo to v0.0.0-20211115164449-b448ea381d54
Signed-off-by: Andy Goldstein <andy.goldstein@redhat.com>

Kubernetes-commit: 60d2481b8862833093f68c45f95b32943abf269f
2021-12-10 14:30:53 -05:00
Kubernetes Publisher
5fcbd521b7 Merge pull request #106949 from cpanato/update-golang-xnet
dependencies: Update golang.org/x/net to v0.0.0-20211209124913-491a49abca63

Kubernetes-commit: b0eb3e1ec2d4268604d9a2c3403f0580a3bda2ec
2021-12-10 17:49:19 +00:00
Kubernetes Publisher
5d6139a4c5 Merge pull request #106458 from dims/lint-yaml-in-owners-files
Lint/Beautify yaml in OWNERS files

Kubernetes-commit: 1d66302c42eb2ecf53b29cafb0c9f751bfbd1cd3
2021-12-10 17:49:18 +00:00
Carlos Panato
08cccf2873 dependencies: Update golang.org/x/net to v0.0.0-20211209124913-491a49abca63
Signed-off-by: Carlos Panato <ctadeu@gmail.com>

Kubernetes-commit: 37dda91186924fc29acc16c1c0743ed747cf6d6c
2021-12-10 12:54:55 +01:00
Kubernetes Publisher
88c19a2c95 Merge pull request #106921 from dims/update-x/tools-to-v0.1.8
Update golang.org/x/tools to a specific tag (v0.1.8) and avoid SHA

Kubernetes-commit: cc6f12583f2b611e9469a6b2e0247f028aae246b
2021-12-10 10:14:03 +00:00
Davanum Srinivas
a1376d09a0 Check in OWNERS modified by update-yamlfmt.sh
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 9405e9b55ebcd461f161859a698b949ea3bde31d
2021-12-09 21:31:26 -05:00
Davanum Srinivas
95611f4824 Update golang.org/x/tools to a specific tag and avoid SHA
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 627c50661e988ad8ac0708b1d94fdfc385e88449
2021-12-09 14:20:03 -05:00
Kubernetes Publisher
18eb16787c Merge pull request #106850 from MadhavJivrajani/deprecate-clock-pkg
Deprecate types in k8s.io/apimachinery/util/clock

Kubernetes-commit: c16b2afc1d3c32462f068ea08cdc4791bd97b947
2021-12-09 17:24:25 +00:00
Madhav Jivrajani
d1766c8511 Bump k8s.io/utils
Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>

Kubernetes-commit: 4ca13e6f0ee3ee66d863203cb2d042842dc88cd7
2021-12-09 16:16:27 +05:30
Kubernetes Publisher
049a50202f Merge pull request #106473 from Dingshujie/fix_inotify_memory_leak
update k/utils to v0.0.0-20211116205334-6203023598ed to fix inotify memory leak

Kubernetes-commit: a8e06cf2bfd2ecdde0f2f49af4df29f70e07f20e
2021-12-09 05:27:09 +00:00
Kubernetes Publisher
b08776b53a Merge pull request #106530 from FrankYang0529/sample-controller/use-update-status
feat(sample-controller): use UpdateStatus

Kubernetes-commit: d4c57acbb7bf9526455998e1ac9db09810604898
2021-12-08 09:15:57 +00:00
Davanum Srinivas
44e50f65ab staging: add dummy commit to trigger gomod update (#106794)
add newline to all staging repos

Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Co-authored-by: Nikhita Raghunath <nikitaraghunath@gmail.com>

Kubernetes-commit: 555623c07eabf22864f6147736fa191e020cca25
2021-12-03 09:57:38 +00:00
DingShujie
b8322e101f update k/utils to v0.0.0-20211116205334-6203023598ed
Kubernetes-commit: 25cf49770c8a91a837aa7e791eb2b177305d9610
2021-11-25 09:29:03 +08:00
Kubernetes Publisher
ff730d68ab Merge pull request #106660 from liggitt/smd-merge
Revert sigs.k8s.io/structured-merge-diff/v4 to v4.1.2

Kubernetes-commit: aff056d8a197f6a404ad5e02210ca662d16c3dbe
2021-11-24 23:42:22 +00:00
Jordan Liggitt
d8df7de944 Revert sigs.k8s.io/structured-merge-diff/v4 to v4.1.2
Kubernetes-commit: ed68909177eca588731bc153d2f69dd235e8fe10
2021-11-24 10:32:24 -05:00
Frank Yang
0edb970c17 feat(sample-controller): use update status
Signed-off-by: Frank Yang <yangpoan@gmail.com>

Kubernetes-commit: 01e9c80d90c5a6da8278d0785ef583e01f901c1e
2021-11-18 22:00:54 +08:00
Kubernetes Publisher
40fdcfd798 Merge pull request #105057 from jiahuif-forks/feature/enum-types-feature-enablement
Add Support for OpenAPIEnum in OpenAPI v2

Kubernetes-commit: e14bdbaa1c4ed2b31dbce1b03160402483d26889
2021-11-17 03:42:38 +00:00
Jiahui (Jared) Feng
239a43ba47 generated: ./hack/update-vendor.sh
Kubernetes-commit: 73ffb492032896c1c87edfa1d85de5fc74bb526c
2021-11-15 15:54:59 -08:00
Kubernetes Publisher
8f7ad79e7d Merge pull request #106234 from jpbetz/cel-libs
Add wired off code for Validation rules for Custom Resource Definitions using the CEL expression language

Kubernetes-commit: 6b41d75794381487ef7204b016faa75e350a32b7
2021-11-11 08:28:11 +00:00
Joe Betz
52aecd0de1 Pin new dependency: github.com/google/cel-go v0.9.0
Kubernetes-commit: d73403dc12ad1d9576d65b5c65e30a87d17ad314
2021-11-01 14:08:09 -04:00
Kubernetes Publisher
a36e4b5ab4 Merge pull request #106181 from ulucinar/aru/consume-kube-openapi
Bump k8s.io/kube-openapi to commit ee342a809c29

Kubernetes-commit: f59b0a56c6ebc1a1891435ba5b094b9afe8c1c3c
2021-11-10 11:50:53 +00:00
Alper Rifat Ulucinar
951b02f02f Bump k8s.io/kube-openapi to commit ee342a809c29
Updates to consume the aggregated OpenAPI spec lazy-marshaling behaviour
introduced with: https://github.com/kubernetes/kube-openapi/pull/251

Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>

Kubernetes-commit: 38f888bdd14b8eddb86ec8ca8461267fe7f8ded1
2021-11-05 14:10:09 +03:00
Kubernetes Publisher
793a99fc15 Merge pull request #105983 from jiahuif-forks/dep/bump-smd
Upgrade sigs.k8s.io/structured-merge-diff/v4 to v4.2.0

Kubernetes-commit: 8e2d7a3d64976eb23e1a4fdc8c068f5210014da6
2021-11-04 00:55:46 +00:00
Jiahui Feng
a51b6162e7 generated: ./hack/update-vendor.sh
Kubernetes-commit: a4f6152743af5201fdbb48bda6730797d3c8f572
2021-11-01 10:00:00 -07:00
Kubernetes Publisher
ced05b3c02 Merge pull request #102945 from chenchun/fake
Pass DeleteOptions down to the Reactor

Kubernetes-commit: 9be67806cdecc18a07750eacd796f7885644def1
2021-11-02 16:52:53 +00:00
Chun Chen
8931f092d2 Auto generated
Kubernetes-commit: 888c049df636712baadd46ead20194c437d3b6e6
2021-10-28 20:10:49 +08:00
Kubernetes Publisher
db6e7e1069 Merge pull request #105896 from zqzten/upgrade-json-patch
upgrade json-patch to v4.12.0

Kubernetes-commit: 18cb34ebb2b64a7607057c7dea80427e2af387f3
2021-10-27 00:54:26 +00:00
Kubernetes Publisher
6e885d6331 Merge pull request #105719 from yuanhh/master
sample-controller/docs: Use italics font on package name

Kubernetes-commit: e1f62e406d6026449eed1b1e57e1c07d8a02b440
2021-10-26 04:45:58 +00:00
Zach Zhu
402c1b4455 upgrade github.com/evanphx/json-patch to v4.12.0
Fix partial negative indice support in json patch

Kubernetes-commit: 20cc72344e653ab90c1a851816bb206b715fd231
2021-10-26 11:20:45 +08:00
Kubernetes Publisher
3927bee026 Merge pull request #104877 from pohly/json-kobj
component-base: test and fix JSON output for KObj

Kubernetes-commit: a5cd438b9fbf49e013453f4d6c9b2e935a78071c
2021-10-22 20:55:35 +00:00
Patrick Ohly
58e1087cbd klog 2.30.0, logr 1.2.0, zapr 1.2.0
The new releases fix logging of KObj in JSON output: klog implements the new
logr.Marshaler interface and zapr uses it instead of Stringer when logging the
ObjectRef created by KObj.

Kubernetes-commit: 169e8b65a00b45ef8bbc7a14cd985df1c835953b
2021-10-22 15:13:47 +02:00
Kubernetes Publisher
f27793adf3 Merge pull request #105030 from liggitt/json-stdlib
switch from json-iterator to forked stdlib json decoder

Kubernetes-commit: cc25656b00baa33168b7a9bc574101a06788efea
2021-10-22 04:49:53 +00:00
Yuanhao Hsueh
a67d4807c7 sample-controller/docs/controller-client-go.md: Use italics font on package name
Kubernetes-commit: 79a7caeb76ea0b04bb02e250d05040ab0d8bc2c1
2021-10-21 15:38:28 +08:00
Kubernetes Publisher
75eecc5c67 Merge pull request #105490 from aojea/restclient-shared-transport
client-go: share the same transport for generated clientsets

Kubernetes-commit: 881980a5c67b7636fd983c481b2648bc4e00c242
2021-10-20 20:52:01 +00:00
Antonio Ojea
6b977ceb51 updated generated
Kubernetes-commit: 032d0d6ea944d0e1845cbdbd9b72ded017deaaed
2021-10-20 06:30:30 +02:00
Kubernetes Publisher
a21ce62a42 Merge pull request #105372 from MadhavJivrajani/vendor-clock-utils
Vendor in k8s.io/utils

Kubernetes-commit: eebeff9f7e0fccf1d220ce809eaea7f7f9248ce0
2021-10-01 00:53:48 +00:00
Madhav Jivrajani
f11c20d669 run hack/{pind-dependency.sh, update-vendor.sh}
Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>

Kubernetes-commit: a43fca76ea7ff6fb08153c9081f7858cd4d06dd8
2021-09-30 19:15:35 +05:30
Kubernetes Publisher
998c254efd Merge pull request #105247 from Jille/patch-1
Fix double formatting on error message

Kubernetes-commit: 49f9e227e985bcbf6fd4781db1788b78a8e140af
2021-09-29 12:47:55 +00:00
Jille Timmermans
2760f8658e Fix double formatting on error message
fmt.Errorf() was called with a message rather than a format string

Kubernetes-commit: 4c038d387c081c2a1a222adb76cbc2b0750fa520
2021-09-25 09:51:48 +02:00
Kubernetes Publisher
8b9d281313 Merge pull request #104949 from Karthik-K-N/json-iterator-version-update
Updated json-iterator version to 1.1.12 from 1.1.11

Kubernetes-commit: 6a49ed41eab79d745c53723ce7f134222279545e
2021-09-17 12:44:52 +00:00
Jordan Liggitt
f8f0c597ff vendor sigs.k8s.io/json
Kubernetes-commit: 434ce4336ab06b3c34208822d558c0432ada3ad3
2021-09-14 18:20:36 -04:00
Karthik K N
b435d69365 Updated vendor files and pinned versions
Kubernetes-commit: c5b4e05834d8edceac94ab1a91c3153581534393
2021-09-13 15:42:42 +05:30
Kubernetes Publisher
1334f73ce3 Merge pull request #104103 from pohly/logr-1.0
klog 2.20.0, logr v1.1.0, zapr v1.1.0

Kubernetes-commit: 5b49d125b76b4d92d5f782630b75b911fee75aaa
2021-09-09 23:49:37 +00:00
Patrick Ohly
ffddb2d87b klog 2.20.0, logr v1.1.0, zapr v1.1.0
This replaces the experimental logr v0.4 with the stable v1.1.0
release. This is a breaking API change for some users because:
- Comparing logr.Logger against nil is not possible anymore:
  it's now a struct instead of an interface. Code which
  allows a nil logger should switch to *logr.Logger as type.
- Logger implementations must be updated in lockstep.

Instead of updating the forked zapr code in json.go, directly using
the original go-logr/zapr is simpler and avoids duplication of effort.

The updated zapr supports logging of numeric verbosity. Error messages
don't have a verbosity (= always get logged), so "v" is not getting
added to them anymore.

Source code logging for panic messages got fixed so that it references
the code with the invalid log call, not the json.go implementation.

Finally, zapr includes additional information in its panic
messages ("zap field", "ignored key", "invalid key").

Kubernetes-commit: cb6a65377775110631bc865acc06c3f957592813
2021-08-03 17:31:39 +02:00
Kubernetes Publisher
547277a10d Merge pull request #104231 from astraw99/fix_unified_workers
Unify controller worker num param `threadiness` to `workers`

Kubernetes-commit: fca3175df7a453c24eec3c11b632090c49472c9d
2021-08-27 20:17:47 +00:00
Kubernetes Publisher
6e98cc2cc7 Merge pull request #103692 from justaugustus/go117
[go1.17] Update to go1.17

Kubernetes-commit: c1e69551be1a72f0f8db6778f20658199d3a686d
2021-08-25 04:24:51 +00:00
Stephen Augustus
acf6e5207b generated: Run hack/update-gofmt.sh
Signed-off-by: Stephen Augustus <foo@auggie.dev>

Kubernetes-commit: 481cf6fbe753b9eb2a47ced179211206b0a99540
2021-08-12 17:13:11 -04:00
Stephen Augustus
e78922e2c6 generated: Run hack/lint-dependencies.sh and hack/update-vendor.sh
Signed-off-by: Stephen Augustus <foo@auggie.dev>

Kubernetes-commit: 0be115722bf30f42c7a954d5cdd4b48efd70ae77
2021-08-11 18:03:39 -04:00
Kubernetes Publisher
907b08c0d4 Merge pull request #104466 from stbenjam/bump-utils
vendor: bump k8s.io/util to get fix for LRU cache

Kubernetes-commit: 7fcecc077dae36071901472d12fa26e5af99010c
2021-08-20 04:21:49 +00:00
Stephen Benjamin
f4606ab4ba vendor: bump k8s.io/util to get fix for LRU cache
This updates the k8s.io/util to pull in the fix for
https://github.com/kubernetes/kubernetes/issues/104452.

Commands run:

  ./hack/pin-dependency.sh k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a
  ./hack/update-vendor.sh

Kubernetes-commit: c2532351525c2822daab61303eb4f94942a017e6
2021-08-19 17:11:35 -04:00
Kubernetes Publisher
5b8a7d4557 Merge pull request #104413 from liggitt/openapi-ipvalidation
Bump k8s.io/kube-openapi

Kubernetes-commit: cde45fb161c5a4bfa7cfe45dfd814f6cc95433f7
2021-08-17 20:23:38 +00:00
Kubernetes Publisher
7738ec0d11 Merge pull request #104330 from liggitt/defaulter-package
Change defaulter-gen input to package import path

Kubernetes-commit: a779c58b1667a75736fe6c7dd28754c31c7bb0e0
2021-08-17 20:23:37 +00:00
Jordan Liggitt
12574113c2 Bump k8s.io/kube-openapi
Updates to preserve openapi ipv4 validation compatibility with pre-go1.17 behavior

Kubernetes-commit: b15c2130aad497add782820c415c59952b4e75a8
2021-08-17 10:13:40 -04:00
Jordan Liggitt
cb35b3e9a3 bump gengo to include defaulter-gen package support
Kubernetes-commit: a619be8e48f75a64a542f0e98a9acc696381f0a2
2021-08-12 11:08:20 -04:00
Kubernetes Publisher
e924582c45 Merge pull request #102913 from pacoxu/upgrade-promotheus-common
upgrade prometheus/common to v0.28.0

Kubernetes-commit: 4b4d12f8a68e224c78d00e8fd2bf3c87aff90a9a
2021-08-09 16:21:00 +00:00
astraw99
0bf5b5ab8f unify worker num to workers
Kubernetes-commit: e6df935fd30c56a8ece0da6152c60fc725d942b7
2021-08-09 10:48:53 +08:00
Tim Hockin
613e0d83ab Update golang.org/x/time/rate (#104014)
* Add failing test case

* Update golang.org/x/time/rate

* Call update-internal-modules from update-vendor

Kubernetes-commit: 09dc055984e9532f29f37acae7aea7a979ded764
2021-07-30 02:42:06 +00:00
Kubernetes Publisher
a40ea2cf90 Merge pull request #103548 from dims/drop-hashicorp-lru
Drop hashicorp lru - switch to the lru impl in k8s.io/utils

Kubernetes-commit: 9c4905e7af0d070d139c06638ab9868fd3521883
2021-07-08 10:00:05 +00:00
Davanum Srinivas
ae55805f2e update to new k8s.io/utils
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 3a221b3332464d7947aacee91e661880208ef901
2021-07-07 13:39:19 -04:00
pacoxu
f3bd8e9148 upgrade google.golang.org/api to v0.45.0
Signed-off-by: pacoxu <paco.xu@daocloud.io>

Kubernetes-commit: 2926b4572e687a761fe09a4dad2ee3579d330329
2021-07-02 11:34:32 +08:00
paco
ba949eb2e1 upgrade github.com/prometheus/common to v0.28.0
Kubernetes-commit: 18d583653c67dbfafc9c5b09d9d6189705fdde85
2021-07-07 16:22:05 +08:00
Kubernetes Publisher
efd6574cd5 Merge pull request #103176 from CaoDonghui123/updatemod
Update golang.org/x/net

Kubernetes-commit: c14017b270d21e6a7e79c0b8872a580f43a67220
2021-07-01 06:00:36 +00:00
Kubernetes Publisher
ea5dd9cff5 Merge pull request #103318 from jpbetz/fix-102749
Bump SMD to v4.1.2 to pick up #102749 fix

Kubernetes-commit: 0dad7d1c47c41f232b21cdd5c21be6683e545e9d
2021-06-30 22:01:31 +00:00
Kubernetes Publisher
8dc77e0316 Merge pull request #103281 from makusu2/patch-1
Fix grammar

Kubernetes-commit: b3cc522b53c11f989e4954cf6342593df54d3f1b
2021-06-30 13:54:47 +00:00
Joe Betz
e904aa0aa5 Bump SMD to v4.1.2 to pick up #102749 fix
Kubernetes-commit: b790cf388ce1fce140c80bb0f7f9669288408b7a
2021-06-29 19:33:00 -07:00
Steven Pitts
85830b19e9 Fix grammar
Original:

> This handler will lookup the owner of the given Deployment, and if it is owned by a Foo resource will enqueue that Foo resource for processing.

Fixed:

> This handler will lookup the owner of the given Deployment, and if it is owned by a Foo resource then the handler will enqueue that Foo resource for processing.

Kubernetes-commit: c21f9cb59d2bd23804959cf41dc0b2c349b66b9d
2021-06-28 19:18:22 -04:00
caodonghui
ef342cd729 Update golang.org/x/net to v0.0.0-20210520170846-37e1c6afe023
Kubernetes-commit: c1d5a3a99e120281c618d6573d7b424138dfb5a9
2021-06-25 15:25:52 +08:00
Kubernetes Publisher
db75202208 Merge pull request #95472 from ahmedtd/lru-remove-mpl
Remove MPL-licensed dep from lruexpirecache

Kubernetes-commit: 89ebe77aebf2b5f0c9526f474b003358655dbac5
2021-06-24 23:59:14 +00:00
Taahir Ahmed
0db76b0424 Remove MPL-licensed dep from lruexpirecache
github.com/hashicorp/golang-lru is MPL 2 licensed, which means that
anyone who distributes code or binaries that incorporates it needs to
include its source code, even if they haven't made any modifications.

Since lrucacheexpire is picked up as a dependency of using the shared
informers in client-go, that's potentially a lot of distributors.
Most other deps of client-go are Apache 2.0, MIT, or BSD-like
licensed, which only requires including the license.

Rather than reverting to groupcache/lru, I just reimplemented the
functionality we need, which isn't much.

Kubernetes-commit: ecc53182475a00a4a1dc8ca1e056b0deb6bd430c
2020-10-10 20:29:26 -07:00
Kubernetes Publisher
7831824e4c Merge pull request #103010 from BenTheElder/ansi-386-overflow
update Azure/go-ansiterm to v0.0.0-20210617225240-d185dfc1b5a1

Kubernetes-commit: 2ff70c77c98fdd3230ade470b319309f34909215
2021-06-19 07:33:04 +00:00
Benjamin Elder
1fcb4eb548 update Azure/go-ansiterm to v0.0.0-20210617225240-d185dfc1b5a1
fixes constant overflow on windows/386

Kubernetes-commit: 35e9d97f3e02a8757e5cc698142037c5a95487d9
2021-06-18 15:11:48 -07:00
Kubernetes Publisher
d16ed19834 Merge pull request #102783 from mcbenjemaa/update-dep-gnostic
Update gnostic to the latest version

Kubernetes-commit: e9c6ec639cc5ca93a3f6e01ff4215f6b68d6142d
2021-06-18 19:33:34 +00:00
Mohamed chiheb Ben jemaa
d4523cd21b update vendor
Kubernetes-commit: 9571b1f884480879de54d5ff993ca336d61874b2
2021-06-17 17:24:43 +01:00
Mohamed chiheb Ben jemaa
8021c2147c Update github.com/googleapis/gnostic to v0.5.5 and updating transitive dependencies go-cmp, protobuf,, to adapt the latest gnostic release which cosists of [Update protos for Go protoc plugin compatibility]
Kubernetes-commit: c691386fef727a5494e3ab02b99196d8f6418241
2021-06-13 17:25:55 +01:00
Kubernetes Publisher
e0f571e97f Merge pull request #102441 from feiskyer/update-vendor
Update Azure Go SDK to v55.0.0

Kubernetes-commit: 122d6352452f3f4a2d52bdb8b114b6e0ec49358e
2021-06-17 02:17:04 +00:00
Pengfei Ni
3ab56b8b9d Update Azure Go SDK to v55.0.0
Kubernetes-commit: b98824c55d95b8b3a1cf79adac44154bd1702e46
2021-06-01 01:30:43 +00:00
Kubernetes Publisher
bf4b140931 Merge pull request #102897 from liggitt/etcd-ga
Update to etcd v3.5.0 client

Kubernetes-commit: f5cf74ddff818236b8435370afa41a51f23dd532
2021-06-16 06:16:29 +00:00
Jordan Liggitt
410d883d6d Update to etcd v3.5.0 client
Kubernetes-commit: 6448181d95c8d6486ba8e9a2a92b4a8172ca1f8f
2021-06-15 19:01:32 -04:00
Kubernetes Publisher
65c1c32712 Merge pull request #100488 from liggitt/protobuf
update etcd, grpc, protobuf dependencies

Kubernetes-commit: 3a47ddccdfb09e73758cebb2690ad2a014f67e23
2021-06-15 22:16:12 +00:00
Jordan Liggitt
afde7019f6 Update protobuf,grpc,etcd dependencies
1. Updated etcd/protobuf/grpc dependencies:

echo "
hack/pin-dependency.sh github.com/golang/protobuf latest
hack/pin-dependency.sh google.golang.org/protobuf latest
hack/pin-dependency.sh go.etcd.io/etcd/api/v3 v3.5.0-rc.0
hack/pin-dependency.sh go.etcd.io/etcd/client/v3 v3.5.0-rc.0
hack/pin-dependency.sh go.etcd.io/etcd/client/pkg/v3 v3.5.0-rc.0
hack/pin-dependency.sh go.etcd.io/etcd/pkg/v3 v3.5.0-rc.0
hack/pin-dependency.sh go.etcd.io/etcd/server/v3 v3.5.0-rc.0
hack/pin-dependency.sh go.etcd.io/etcd/tests/v3 v3.5.0-rc.0
hack/pin-dependency.sh google.golang.org/grpc latest
" | bash

2. Linted transitive dependencies until versions are clean:

hack/lint-dependencies.sh  | grep "  hack/pin-dependency.sh" | bash

3. Linted dependencies until dropped versions are clean:

hack/lint-dependencies.sh  | grep "dropreplace" | bash

4. Updated vendor and internal modules:

hack/update-vendor.sh
hack/update-internal-modules.sh

Repeated steps 2-4 until clean

Kubernetes-commit: 5cfc39ef5e90002080ff1f2bc4b7ade674c225f1
2021-06-15 10:06:09 -04:00
Kubernetes Publisher
e9d83797a3 sync: remove Godeps/ 2021-06-09 12:50:12 +00:00
Kubernetes Publisher
50667af141 Merge pull request #102454 from wzshiming/clean/remove-godeps
Remove Godeps

Kubernetes-commit: 09a9e612947bb2d940224245890048d3e60d4c5d
2021-06-09 00:02:57 +00:00
Kubernetes Publisher
3f407ea648 Merge pull request #102467 from pacoxu/json-patch-5.5.0
upgrade json-patch to v4.11.0

Kubernetes-commit: 81b9789eaa7bc067f417b5e74d5695dd6dd88a46
2021-06-04 12:03:08 +00:00
Kubernetes Publisher
bbe195b64b Merge pull request #102059 from jsafrane/fix-consistentread
Retry reading /proc/mounts when unable to get a consistent read

Kubernetes-commit: 38783bfeb70f5d25262d195a779fbcfb72c73633
2021-06-04 08:01:57 +00:00
pacoxu
2b650544c0 upgrade gopkg.in/evanphx/json-patch to v4.11.0
Signed-off-by: pacoxu <paco.xu@daocloud.io>

Kubernetes-commit: 6e0650e3e132a5145a83b287fb90a30b5581bcac
2021-06-04 13:15:09 +08:00
Kubernetes Publisher
8ef11e40f8 Merge pull request #102409 from dims/bump-golang.org/x/text-to-v0.3.6
Bump golang.org/x/text to v0.3.6

Kubernetes-commit: e0cb30170415cc122226360f722126930b451f88
2021-06-01 20:03:45 +00:00
Shiming Zhang
87eb3a0cb8 Remove Godeps
Kubernetes-commit: 1431eab36d3e0468482aa234651ab878022a49e1
2021-05-31 17:44:41 +08:00
Davanum Srinivas
124b7724b8 Bump golang.org/x/text to v0.3.6
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: f924906173740342253bbae16fab695709d711ee
2021-05-28 11:07:25 -04:00
Kubernetes Publisher
82ea44f395 Merge pull request #102332 from pacoxu/klog-2.9.0
Bump klog to 2.9.0, fixing byte array display

Kubernetes-commit: 3726309bf9d59bccf28b9e22e1573764a5dd3fb5
2021-05-26 15:30:08 +00:00
pacoxu
3ff0c3f190 upgrade klog to v2.9.0
Signed-off-by: pacoxu <paco.xu@daocloud.io>

Kubernetes-commit: 876174125bc0e0dda67fbe3d7ec7c4eb41ac5f69
2021-05-26 19:16:06 +08:00
Jan Safranek
a4e5fecd5c Bump k8s.io/utils
To get io/ConsistentRead updates.

Kubernetes-commit: 1d16f934b9410496238b74b0664bd466f64277b3
2021-05-24 12:14:36 +02:00
Kubernetes Publisher
fc35830a8c Merge pull request #102147 from kolyshkin/update-runc-rc94-take-II
vendor: bump runc to rc95

Kubernetes-commit: 5de1a754c8f875cacfa49b9c5ed63c6c35b7e9e5
2021-05-21 07:30:05 +00:00
Kir Kolyshkin
edf47a1d89 vendor: bump runc to rc95
runc rc95 contains a fix for CVE-2021-30465.

runc rc94 provides fixes and improvements.

One notable change is cgroup manager's Set now accept Resources rather
than Cgroup (see https://github.com/opencontainers/runc/pull/2906).
Modify the code accordingly.

Also update runc dependencies (as hinted by hack/lint-depdendencies.sh):

        github.com/cilium/ebpf v0.5.0
        github.com/containerd/console v1.0.2
        github.com/coreos/go-systemd/v22 v22.3.1
        github.com/godbus/dbus/v5 v5.0.4
        github.com/moby/sys/mountinfo v0.4.1
        golang.org/x/sys v0.0.0-20210426230700-d19ff857e887
        github.com/google/go-cmp v0.5.4
        github.com/kr/pretty v0.2.1
        github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>

Kubernetes-commit: f3cdfc488e88714f2fe695e35ad0d3f8e45ddc25
2021-05-19 09:59:29 -07:00
Kubernetes Publisher
af5860b815 Merge pull request #102111 from dims/update-testing-related-deps-for-1.22
Update testing related dependencies (ginkgo|gomega|testify)

Kubernetes-commit: bacab40a9f9380e968406e91483bdc81f1b41bb0
2021-05-19 19:28:11 +00:00
Davanum Srinivas
2c4c061a9e update testing related dependencies
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 0803ea49b95579195fc55b4a64a6e859932dba7f
2021-05-18 19:31:47 -04:00
Kubernetes Publisher
390736d374 Merge pull request #102094 from liggitt/revert-runc
Revert "Merge pull request #101888 from kolyshkin/update-runc-rc94"

Kubernetes-commit: 1295b2c4b59b8bba58186294eb2d76a7ecb4987e
2021-05-18 20:05:45 +00:00
Jordan Liggitt
072b9c7723 Revert "Merge pull request 101888 from kolyshkin/update-runc-rc94"
This reverts commit b1b06fe0a4d80ac0fd67fae56f29a3710934a256, reversing
changes made to 382a33986b043f78a42d3d865d0ca383687bf171.

Kubernetes-commit: 4b45d0d921051627c43d5fc014e383a6cb872ade
2021-05-18 09:12:04 -04:00
Kubernetes Publisher
9187d051cb Merge pull request #101888 from kolyshkin/update-runc-rc94
vendor: bump runc to rc94

Kubernetes-commit: b1b06fe0a4d80ac0fd67fae56f29a3710934a256
2021-05-18 12:19:05 +00:00
Kubernetes Publisher
56ffbfbaee Merge pull request #101871 from MadhavJivrajani/master
Change apiversion of CRD from v1beta1 to v1

Kubernetes-commit: 8c8f79cd59fab32af7db2ae5aeeb4cd2ed4717e4
2021-05-18 12:19:03 +00:00
Kubernetes Publisher
53528ac7e4 Merge pull request #100940 from markusthoemmes/fake-client-interface
Implement a FakeClient interface

Kubernetes-commit: 8da9d2ff55ad98a685978dd690d66dfb4eb9c1fd
2021-05-18 12:18:59 +00:00
Kubernetes Publisher
d38519a7ab Merge pull request #101357 from feiskyer/update-vendor
Update Azure Go SDK version to v53.1.0

Kubernetes-commit: 253685779f15d2bf1ebf8354474761752edd8d6e
2021-05-18 12:18:57 +00:00
Kir Kolyshkin
4e42b6e4a8 vendor: bump runc to rc94
One notable change is cgroup manager's Set now accept Resources rather
than Cgroup (see https://github.com/opencontainers/runc/pull/2906).
Modify the code accordingly.

Also update runc dependencies (as hinted by hack/lint-depdendencies.sh):

	github.com/cilium/ebpf v0.5.0
	github.com/containerd/console v1.0.2
	github.com/coreos/go-systemd/v22 v22.3.1
	github.com/godbus/dbus/v5 v5.0.4
	github.com/moby/sys/mountinfo v0.4.1
	golang.org/x/sys v0.0.0-20210426230700-d19ff857e887
	github.com/google/go-cmp v0.5.4
	github.com/kr/pretty v0.2.1
	github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>

Kubernetes-commit: b49744f177087173d43d7771588d83b9df5a3c0b
2021-05-10 18:12:04 -07:00
Madhav Jivrajani
cba5d7c8c2 Change apiversion of CRD from v1beta1 to v1
- Update CRDs (crd.yaml, crd-status-subresource.yaml) to match requirements of current release
	- Add `versions` field and structures `schema` as made mandatory in apiextensions/v1
	- Add annotation for api-approved.kubernetes.io since CRD is under *k8s.io domain
- Delete crd-validation.yaml since structured schema is mandatory in v1
- Update README

Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>

Kubernetes-commit: fd0ac9c8d169169c8072639970565cda9fb9499a
2021-05-10 20:49:18 +05:30
Pengfei Ni
3270bd1970 Update Azure Go SDK version to v53.1.0
Kubernetes-commit: bee44da7a258bbe3996ad3cc38d905ae9a28271e
2021-04-22 11:45:39 +08:00
Kubernetes Publisher
d7993ed192 Merge pull request #101234 from gautierdelorme/rm-go-openapi-spec
eliminate dependency on go-openapi/spec

Kubernetes-commit: 565d5f456242fcc79b7540a4c4913c7577cbfc7d
2021-05-18 12:18:54 +00:00
Gautier Delorme
d3a409a6ff remove go-openapi/spec
Signed-off-by: Gautier Delorme <gautier.delorme@gmail.com>

Kubernetes-commit: 34b0fcef5fc47e3fcddf7f6ca1b3e6176b2a5323
2021-04-20 17:48:33 +02:00
Gautier Delorme
4d2696af14 bump k8s.io/kube-openapi
Signed-off-by: Gautier Delorme <gautier.delorme@gmail.com>

Kubernetes-commit: bcdde6bf75c7e177b44e58c5313e405c22d8d46d
2021-04-20 17:43:59 +02:00
Kubernetes Publisher
ac37919eca Merge pull request #100490 from howardjohn/gnostic-v051
Update kube-openapi and gnostic dependencies

Kubernetes-commit: c555b23f1c84bcdd1d87a7ae831675281f5c0c94
2021-05-18 12:18:51 +00:00
John Howard
5fab6f5d14 Update kube-openapi and gnostic dependencies
Pulling in https://github.com/kubernetes/kube-openapi/pull/220

Kubernetes-commit: a849c8998c1ed71f25387a560f8359596aec8bd3
2021-03-23 08:33:15 -07:00
Kubernetes Publisher
73e81dab82 sync: update go.mod 2021-04-17 04:04:16 +00:00
Kubernetes Publisher
1f33e4e759 Merge pull request #100784 from kevindelgado/smd-to-4-1-1
Update structured-merge-diff to v4.1.1

Kubernetes-commit: 442b3218b3d3eecdd9e55bffcb2c6b135f3084b7
2021-04-11 03:36:44 +00:00
Kevin Delgado
0a05b87535 Update structured-merge-diff to v4.1.1
Kubernetes-commit: 5f1b146852124e6c5ebfc2b69aee7dfa4fe6d158
2021-04-02 17:42:54 +00:00
Markus Thömmes
5033b36115 Implement a FakeClient interface
Kubernetes-commit: cf26825e3d9b89526e13bb53f74354593477205c
2021-03-15 14:47:24 +01:00
Kubernetes Publisher
b8d9e8c247 Merge pull request #100156 from ehashman/issue-100155
Upgrade klog to avoid panics crashing components

Kubernetes-commit: 998f218606a149048e7b564ef27478bacab0f90f
2021-03-13 03:39:54 +00:00
Elana Hashman
0a6d32e472 Bump klog to 2.8.0, fixing nil panics in KObj
Kubernetes-commit: 6b70c8bd8db844a5c2c26d2814b3306d83204a7a
2021-03-11 16:56:56 -08:00
Kubernetes Publisher
9599deb9c0 Merge pull request #99759 from jpbetz/apply-extract
Add Extract support to client-go apply builders

Kubernetes-commit: eb0c118a9d7a15801ec0389448a5e1bffdaa5e72
2021-03-11 11:01:05 +00:00
Joe Betz
f0bced5fe4 Bump SMD to v4.1.0
Kubernetes-commit: 5bc72f37a44fdfbf23ef1b29f2ec3a3efda2b5cc
2021-03-02 14:21:12 -08:00
Kubernetes Publisher
109fa65263 Merge pull request #98946 from monopole/upgradeKustomize
Upgrade kustomize-in-kubectl to v4.0.5

Kubernetes-commit: ff3ccc58cd926260731c5e6f4a9405d595916369
2021-03-09 11:51:48 +00:00
monopole
7dca3e55b3 until stable: pin-dependency, update-vendor, update-bazel, lint-dep
Kubernetes-commit: ba39d22e3976540d66fde0a650a7a463d75d5b17
2021-03-08 13:28:13 -08:00
Kubernetes Publisher
21cbf17cc2 Merge pull request #99817 from liggitt/zero-value
Fix zero-value custom resource validation with go1.16

Kubernetes-commit: feab32b220cd39699696d832020f8808a70bb412
2021-03-06 14:10:45 +00:00
Jordan Liggitt
292d7d1643 Update k8s.io/kube-openapi
Kubernetes-commit: 5515157f82ceb1a9f9a267f32629add6d8f522f7
2021-03-04 19:45:51 -05:00
Kubernetes Publisher
617557b2e3 Merge pull request #98572 from justaugustus/go116
[go1.16] Update to go1.16

Kubernetes-commit: e4e9c31218becac11f176cc824f5cc6b7a8036ac
2021-03-03 09:57:40 +00:00
Stephen Augustus
d6687d18b7 Fixup golang.org/x/term staticcheck warnings
Errors from staticcheck:
cmd/preferredimports/preferredimports.go:38:2:
  package golang.org/x/crypto/ssh/terminal is deprecated:
  this package moved to golang.org/x/term.  (SA1019)
vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go:36:2:
  package golang.org/x/crypto/ssh/terminal is deprecated:
  this package moved to golang.org/x/term.  (SA1019)
vendor/k8s.io/client-go/tools/clientcmd/auth_loaders.go:26:2:
  package golang.org/x/crypto/ssh/terminal is deprecated:
  this package moved to golang.org/x/term.  (SA1019)

Please review the above warnings. You can test via:
  hack/verify-staticcheck.sh <failing package>
If the above warnings do not make sense, you can exempt the line or
file. See:
  https://staticcheck.io/docs/#ignoring-problems

generated:
- hack/update-internal-modules.sh
- hack/lint-dependencies.sh
- hack/update-vendor.sh

Signed-off-by: Stephen Augustus <foo@auggie.dev>

Kubernetes-commit: d9435800b65d6787beaf061546599d757b8e87c9
2021-03-02 00:14:47 -05:00
Jordan Liggitt
5ca64b4872 [go1.16] bump golang.org/x/... dependencies
hack/pin-dependency.sh golang.org/x/crypto latest
hack/pin-dependency.sh golang.org/x/net latest
hack/pin-dependency.sh golang.org/x/exp latest
hack/pin-dependency.sh golang.org/x/sys latest
hack/pin-dependency.sh golang.org/x/time latest
hack/pin-dependency.sh golang.org/x/tools latest

hack/lint-dependencies.sh
hack/pin-dependency.sh dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037
hack/pin-dependency.sh golang.org/x/mobile v0.0.0-20201217150744-e6ae53a27f4f
hack/pin-dependency.sh golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449

hack/lint-dependencies.sh

hack/update-internal-modules.sh
hack/update-vendor.sh

Co-authored-by: Stephen Augustus <foo@auggie.dev>

Kubernetes-commit: ecef45df84a082c71dd3d96e6adb181a2c5b3790
2021-02-25 10:13:12 -05:00
Stephen Augustus
938e95f4af generated: Run hack/lint-dependencies.sh and hack/update-vendor.sh
Signed-off-by: Stephen Augustus <foo@auggie.dev>

Kubernetes-commit: 7216970cf25a39ad2e1208ad1eb5006599ca41ca
2021-02-25 09:25:53 -05:00
Stephen Augustus
e4f4e102e9 [go1.16] go.mod: update to go1.16
Signed-off-by: Stephen Augustus <foo@auggie.dev>

Kubernetes-commit: 3c2824e3dbed6069dabddac7816239de9cb2a6ee
2021-02-15 04:46:56 -05:00
Kubernetes Publisher
f248f1b506 Merge pull request #99561 from BenTheElder/remove-bazel
Remove Bazel

Kubernetes-commit: 5498ee641b3459a0da1d4b2d42d502a318194189
2021-03-01 21:34:42 +00:00
Benjamin Elder
6376e8bbbc hack/update-bazel.sh
Kubernetes-commit: 56e092e382038b01c61fff96efb5982a2cb137cb
2021-02-28 14:17:42 -08:00
Kubernetes Publisher
80a6a3c0f8 Merge pull request #99014 from apelisse/update-smd
Update sigs.k8s.io/structured-merge-diff to v4.0.3

Kubernetes-commit: 93252fa433214462e61495a63e792b756fd6777a
2021-02-17 01:37:41 +00:00
Antoine Pelisse
fd70eb81d6 Update sigs.k8s.io/structured-merge-diff to v4.0.3
Kubernetes-commit: 707612732a7b43aa12e329b0cd6308116ff4af4d
2021-02-11 17:01:23 -08:00
Kubernetes Publisher
fd052d0e08 Merge pull request #98790 from jkh52/master
Bump konnectivity-client to v0.0.15

Kubernetes-commit: 96a98e50afa7641d6f0e4fb324041126ff5a4ec2
2021-02-06 01:23:49 +00:00
Joseph Anttila Hall
0359e89e0a Bump konnectivity-client to v0.0.15
$ ./hack/pin-dependency.sh \
  sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15
$ ./hack/update-vendor.sh

Kubernetes-commit: 6499d4a730f8e6159da3e6c43f8ea6b13c5f46e5
2021-02-04 19:42:20 -08:00
Kubernetes Publisher
ec6375e594 Merge pull request #98477 from palnabarun/update-gogo/protobuf
Update gogo/protobuf to v1.3.2

Kubernetes-commit: 4d3ed163a0ed45e8790801d74503fe300d05daa0
2021-02-02 20:25:12 +00:00
Kubernetes Publisher
e694c01636 Merge pull request #98488 from pohly/klog-2.5.0
klog 2.5.0 + logr 0.4.0 update

Kubernetes-commit: 76ead99a5601d89ac83a6a633cd2f828145adbff
2021-01-30 04:23:52 +00:00
Kubernetes Publisher
e7be28cb81 Merge pull request #98565 from adisky/move-spdystream
Move dependency docker/spdystream to moby/spdystream

Kubernetes-commit: 64a6ee4321d37740b84a5c5c7aaa67e0bf6b6508
2021-01-29 20:26:18 +00:00
Aditi Sharma
b935b84a42 Update dependency docker/spdystream to moby/spdystream
docker/spdystream has been moved to moby/spdystream.

Signed-off-by: Aditi Sharma <adi.sky17@gmail.com>

Kubernetes-commit: c5c938a056abdf9961962554013632d6cfd3bbd4
2021-01-29 12:03:46 +05:30
Patrick Ohly
4a666dd4be logging: support call depth via logr, structured logging
The new releases of klog (via klogr) and logr expose support for call
traces via a new WithCallDepth API in logr.

The new klogr can be configured to pass structured log entries into
klog instead of turning them into a single text message.

Kubernetes-commit: 562a39a2e1e26854c06ac2b317f6f8a4ebb23ac1
2021-01-27 20:36:56 +01:00
Nabarun Pal
a109899c00 update gogo/protobuf to v1.3.2
gogo/protobuf@v1.3.2 fixes https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-3121

Ref: https://github.com/kubernetes/client-go/issues/927

Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>

Kubernetes-commit: 9cada2ec3ba793597606a1df1375ff8e8311ccf3
2021-01-27 18:01:27 +05:30
Kubernetes Publisher
9b83a171da Merge pull request #96960 from Jefftree/defaulter-diff
Update defaulter gen to not use reflect

Kubernetes-commit: 5e9b43eab6db27017fe128edf07fa85eb438618b
2021-01-16 05:15:28 +00:00
Kubernetes Publisher
2797372efd Merge pull request #97033 from patrickshan/pshan/bump/Azure/go-autorest/autorest
Bump github.com/Azure/go-autorest/autorest to v0.11.12

Kubernetes-commit: e11e9d4c6c3f522ed398748a11cc5dd1f8949c2b
2020-12-17 09:11:45 +00:00
Patrick Shan
8a0afa8b19 update dependencies
Kubernetes-commit: ed7ca850fab4a8bd5bde1b0708e4606a9ede4af7
2020-12-04 09:50:39 +11:00
Jefftree
882e772b0d Update generator to not use reflect
Kubernetes-commit: 6addd69529b39f16069b6d603f5e101934162e2e
2020-11-30 10:41:04 -08:00
Kubernetes Publisher
7644cdf6ad Merge pull request #96317 from Jefftree/test-ssa
Integrate defaults marker to defaulter-gen

Kubernetes-commit: 05d1b94a701d807666b40665f5728e0cc5f92054
2020-11-14 09:10:33 +00:00
Jefftree
e43b45bf1b Integrate defaults marker and remove ContainerPort defaulter
Kubernetes-commit: 50e7aa49aa8f05c12ee72da92d1dc61900f86cac
2020-11-13 17:27:40 -08:00
Antoine Pelisse
d03e668bf2 Update kube-openapi
Kubernetes-commit: 8cce122e7b6506b361032869f7115635f13ca96a
2020-11-10 15:09:03 -08:00
Kubernetes Publisher
8b4aa59c0e Merge pull request #96425 from bobbypage/vendor-cadvisor-v0.38
Vendor cadvisor v0.38.4

Kubernetes-commit: 41533ecec8966636554faba44368a36d5d6c5347
2020-11-14 01:11:52 +00:00
David Porter
6e0942b51d vendor: cadvisor v0.38.4
Kubernetes-commit: 8af7405f1730c4913c48c6dc494e319cb3015f69
2020-11-13 19:52:57 +00:00
Kubernetes Publisher
801dc3d51c Merge pull request #96549 from caesarxuchao/net-sys-dep-update
update golang.org/x/net and golang.org/x/sys

Kubernetes-commit: 85cd7c530bf55cd369bdcb92a5a31d3d1547113f
2020-11-13 17:40:40 +00:00
Chao Xu
4b4d6684ad update golang.org/x/net and golang.org/x/sys
Kubernetes-commit: 7b26cff1740ecfb8e6ac184539d1cb5dd66991c2
2020-11-13 05:15:22 +00:00
Kubernetes Publisher
6d195120a8 sync: update go.mod 2020-11-13 13:34:13 +00:00
Kubernetes Publisher
255b847756 Merge pull request #95954 from sttts/sttts-go-openapi
apiextensions: replace go-openapi with kube-openapi fork for validation

Kubernetes-commit: 0cba30d891cb77e813d7f19dcc5ae422076fcfe3
2020-11-09 16:38:38 +00:00
Dr. Stefan Schimanski
2c055c8359 bump(k8s.io/kube-openapi)
Kubernetes-commit: dd1709ba46580af290712b0eca12acd00a78789d
2020-11-06 10:59:34 +01:00
Kubernetes Publisher
91f5438a81 Merge pull request #96279 from cmluciano/cml/netutilsipv4
dualstack: cleanup IsIPv4 duplicates in favor of k8s/utils functions

Kubernetes-commit: 151c2799d1d76ae6a9847b89bdf912604477c2d5
2020-11-07 12:35:50 +00:00
Christopher M. Luciano
837cce8fe3 dualstack: incorporate IsIPv4 updates from utils repo
This dependency bump will allow for cleanup of duplicate code in
the dualstack e2e tests.

Signed-off-by: Christopher M. Luciano <cmluciano@us.ibm.com>

Kubernetes-commit: 5303b3fbbd52f5092bdcbd3765347eb218485ca5
2020-11-05 14:25:23 -05:00
Kubernetes Publisher
09d30a42df Merge pull request #96154 from rf232/update_klog
Update Klog dependency

Kubernetes-commit: 3f6ec26eefcae1cdb4a43aa4e664a5f60fc7ca78
2020-11-04 16:37:46 +00:00
Rob Franken
4dc792569d Update Klog dependency
Updating Klog to pickup changes needed for log sanitization.

(https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/1753-logs-sanitization)

Kubernetes-commit: c6685436fdae6fbb8ac7083b85ecfd47b5871e68
2020-11-03 20:16:25 +01:00
Kubernetes Publisher
af1485fcb9 Merge pull request #96108 from liggitt/revert-sys
Revert "Updated golang/x/net. Also updated golang.org/x/sys"

Kubernetes-commit: 770525fd3d47a1ef86aab886b62b73b3557457d5
2020-11-02 20:37:21 +00:00
Jordan Liggitt
ca1337e8e2 Revert "Updated golang/x/net. Also updated golang.org/x/sys"
Kubernetes-commit: 4012fb005205a2f6dbd2534d600c4f784b5c0210
2020-11-02 08:28:24 -05:00
Kubernetes Publisher
dbceea7dc2 Merge pull request #96076 from caesarxuchao/update-deps
Updates golang/x/net and golang/x/sys

Kubernetes-commit: a0d23de0861d5a2fc446c417bf0c53fa1f51706e
2020-11-01 20:35:45 +00:00
Chao Xu
f89298b654 Updated golang/x/net. Also updated golang.org/x/sys, as required by
hack/lint-dependencies.sh.

Kubernetes-commit: ec6e2321261b900089183ac61f1ac0040be5fa9c
2020-10-31 16:21:08 -07:00
Kubernetes Publisher
86260d66c5 Merge pull request #95692 from markusthoemmes/bump-azure-adal
Bump github.com/Azure/go-autorest/autorest/adal to 0.9.5

Kubernetes-commit: af1c8935d9f1f42767c6f5211a668e44a15946b4
2020-10-20 20:20:58 +00:00
Markus Thömmes
07f3ecb8e4 Fix dependency linting
Kubernetes-commit: 34b9d115051a987442dfaf3bd12002c0843f8297
2020-10-19 11:33:30 +02:00
Markus Thömmes
3b3c10e33d Bump github.com/Azure/go-autorest/autorest/adal to 0.9.5
Kubernetes-commit: e1fd0bd0ebdfee973403a8eeb71a9ec0fc8a23de
2020-10-19 09:46:46 +02:00
Kubernetes Publisher
bc98db7fe4 Merge pull request #93901 from jpbetz/atomic-structs
Treat LabelSelectors as atomic by Server Side Apply to fix #92913

Kubernetes-commit: 90c9f7b3e198e82a756a68ffeac978a00d606e55
2020-10-04 00:15:01 +00:00
Joe Betz
6add9a7cfe Bump to latest kube-openapi and SMD to pick up structType=atomic support
Kubernetes-commit: f298d549f60c9342abcff1ad17d8455cd62b19fb
2020-09-30 11:49:13 -07:00
Kubernetes Publisher
369f5297d9 Merge pull request #93499 from ZeroMagic/azure-autorest
chore: upgrade Azure/go-autorest/autorest to v0.11.1

Kubernetes-commit: e695b40db85cddd2ff87b35ec978b2c76b11dd4c
2020-09-02 13:47:47 +00:00
Kubernetes Publisher
f7021f8129 Merge pull request #94147 from liggitt/json-patch
Update json-patch to v4.9.0 tagged release

Kubernetes-commit: ce3dd04c49067d0f7cb713d0b866b5b7eea04a18
2020-08-21 05:31:03 +00:00
Jordan Liggitt
5619c7157e Update json-patch to v4.9.0 tagged release
Kubernetes-commit: 245064a3518c7a42fe830316da2fbfd2667db01d
2020-08-20 17:05:24 -04:00
Kubernetes Publisher
1a8fae04de Merge pull request #93867 from apelisse/update-smd
Update SMD to v4.0.1 and kube-openapi

Kubernetes-commit: f4e9c3fd2745695308edd1fd725911fa564efe83
2020-08-13 01:39:49 +00:00
Antoine Pelisse
8877c11a87 Update SMD to v4.0.1 and kube-openapi
Kubernetes-commit: f4c145511a0bb62ea7ee1f2154945c84c17ffcd5
2020-08-10 13:02:25 -07:00
Kubernetes Publisher
4134843373 Merge pull request #93810 from liggitt/json-patch-4.8.0
Update to json-patch 4.8.0

Kubernetes-commit: 9b78bd59796d3937986934582230174606403780
2020-08-08 21:32:10 +00:00
Jordan Liggitt
6283983c53 Update to json-patch 4.8.0
Kubernetes-commit: cc6814f83ccad671c79570b44c84b280709b4c74
2020-08-08 09:53:56 -04:00
Kubernetes Publisher
3687e442e9 Merge pull request #93602 from liggitt/utils
Update k8s.io/utils

Kubernetes-commit: a5090a8ff253e1aa626cd5613329e23aaec27e88
2020-07-31 17:30:19 +00:00
Jordan Liggitt
d8d3c68a07 Update k8s.io/utils
Kubernetes-commit: c11e52f410603d2e8eaf6591b4c83ab19d233b17
2020-07-31 10:44:33 -04:00
ZeroMagic
a291341962 chore: upgrade Azure/go-autorest to v14.2.0
use autorest v0.11.1

Signed-off-by: ZeroMagic <jiliu8@microsoft.com>

Kubernetes-commit: 7b444eeff37234c329a0c2ccbd5195e434c22791
2020-07-28 07:25:04 +00:00
Kubernetes Publisher
3c855731f2 Merge pull request #93264 from justaugustus/go115
Update Golang to v1.15.0-rc.1

Kubernetes-commit: 9a20f30745477423e8776bb0d05316c00648f49b
2020-07-26 13:31:46 +00:00
Jordan Liggitt
318ff3f24c generated: hack/update-vendor.sh
Kubernetes-commit: 6c2d18369f688b7200cefdca71709bb698081e84
2020-07-25 15:27:12 -04:00
Jordan Liggitt
a916299ec3 [go1.15] go.mod: update to go1.15
Kubernetes-commit: 247fcdfda5311bfc446c61c7bda67803e3527fdd
2020-07-25 15:02:16 -04:00
Kubernetes Publisher
7b06a11a7e Merge pull request #93410 from nikhita/apimachinery-triage-labels
Don't apply triage/needs-information on apimachinery and instrumentation PRs

Kubernetes-commit: 54e20707225656d6f4eaa32236216b6830a5b107
2020-07-25 05:30:13 +00:00
Nikhita Raghunath
60dc3756ab Revert "Merge pull request #93156 from logicalhan/triage-api-machinery"
This reverts commit 32438cf26938091bea56e7ca7c3fcf4215652f9c, reversing
changes made to bb6a6aa3915cc9f7efaaf2291f6adac8333fd33c.

Kubernetes-commit: c00dae060731f6286ee3743db24782f09c33945a
2020-07-24 13:01:02 +05:30
Kubernetes Publisher
104d242395 Merge pull request #93156 from logicalhan/triage-api-machinery
automatically assign triage labels to api-machinery tagged PRs

Kubernetes-commit: 32438cf26938091bea56e7ca7c3fcf4215652f9c
2020-07-22 05:39:16 +00:00
Kubernetes Publisher
a130e1278f Merge pull request #93253 from liggitt/utils-trace
Update k8s.io/utils

Kubernetes-commit: bb079afdef2b36a9fc9d081411a1de18b91d1ae0
2020-07-21 05:29:05 +00:00
Jordan Liggitt
b600b9bc41 Update k8s.io/utils
Kubernetes-commit: 7aacbeac144a7772fa8eac5582bbd64bc52804a4
2020-07-20 11:12:29 -04:00
Kubernetes Publisher
bbcc970698 sync: update go.mod 2020-07-20 09:55:22 +00:00
Han Kang
b14978213b automatically assign triage labels to api-machinery tagged PRs
Change-Id: Ifcc8a85d190d6370423af27f6e6c4c90b8472981

Kubernetes-commit: 9129dbc98bd847be9d96b39733a3b28107c920a1
2020-07-16 13:13:59 -07:00
Kubernetes Publisher
76ca497efd Merge pull request #92919 from dashpole/update_cadvisor
Update cAdvisor to v0.37.0

Kubernetes-commit: 6b5dc3770851fdc1f356e36fd17810c744181fb1
2020-07-13 13:49:36 +00:00
Kubernetes Publisher
e58e6497fa Merge pull request #92768 from deads2k/security-contacts
update security contacts for apimachinery repos

Kubernetes-commit: 0cc96859473a21eb7d4f44f355d50881e12925ad
2020-07-11 01:38:06 +00:00
Kubernetes Publisher
78a9bef8d5 Merge pull request #92661 from jpbetz/smd-bump-field-unsetting
Bump to SMD PR#166 to pick up unsetting field changes and add integration tests

Kubernetes-commit: 49dced762da7bc9f74474e9f8f3efe198ff46767
2020-07-11 01:38:05 +00:00
David Ashpole
4b9cdb6278 update cAdvisor to v0.37.0
Kubernetes-commit: 1f70708f6cc85985725c11cd69c4965c1f97b314
2020-07-09 10:23:10 -07:00
David Eads
a3ac958d23 update security contacts for apimachinery repos
Kubernetes-commit: 29c4e858b0017f8aa328d487adbbe910b8205cf8
2020-07-02 16:00:53 -04:00
Joe Betz
9a2e3dc43f Bump to sigs.k8s.io/structured-merge-diff 43c19b to pick up unsetting fields changes PR#166
Kubernetes-commit: 11c38a9c703b825c61d6490e8da85202b760f3b1
2020-06-26 20:05:34 -07:00
Kubernetes Publisher
c86096c6f9 Merge pull request #92611 from liggitt/go1.13
Tolerate go 1.13 builds

Kubernetes-commit: 896da2253c77d15fc551843e515039c6e9c86c99
2020-07-09 13:45:41 +00:00
Jordan Liggitt
c5433de92c Generated files
Kubernetes-commit: ddfe1372549c57c36bb5c3077584d448f117e706
2020-06-29 12:46:44 -04:00
Kubernetes Publisher
1c2cb48dea Merge pull request #92554 from serathius/klog-upgrade
Update k8s.io/klog to v2.2.0

Kubernetes-commit: bd60f0787e2b6ba9ab82281879afa641677f0d3d
2020-07-02 09:22:12 +00:00
Marek Siarkowicz
b507884e0c Update k8s.io/klog to v2.2.0
Kubernetes-commit: e72521e1d7e2eef32e78828ab111670fe2f591ae
2020-06-26 19:09:04 +02:00
Kubernetes Publisher
ad1773f8a7 Merge pull request #91366 from giuseppe/cgroupfs-cgroupv2
vendor: update google/cadvisor and opencontainers/runc

Kubernetes-commit: a03db636daef0417218ef8c108c0a6530d2ef368
2020-06-26 13:22:35 +00:00
Giuseppe Scrivano
e2bc468186 vendor: update google/cadvisor and opencontainers/runc
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Kubernetes-commit: a6a3bf2eb4a0b7e9f86f991ffc24b72beafce2f4
2020-06-24 10:56:34 +02:00
Kubernetes Publisher
5fffb7b9d8 Merge pull request #92438 from liggitt/1.14
go1.14 fixup

Kubernetes-commit: 4de511a4cfdb8e49e804be18245911bf3270fb2f
2020-06-24 09:50:13 +00:00
Jordan Liggitt
9822f20a49 go1.14: run hack/update-vendor.sh
Kubernetes-commit: d9bb0b8ee18fe68654ef1a68611f905859b3b7bc
2020-06-23 17:01:33 -04:00
Kubernetes Publisher
9b21f64fec Merge pull request #91712 from KobayashiD27/structured-logging-in-event
Migrate log to klog.InfoS for staging/src/k8s.io/client-go

Kubernetes-commit: 00d6255f440f4513dfaafaf6c0d0206ab9e9bd22
2020-06-23 09:40:45 +00:00
Kubernetes Publisher
d59619acf1 Merge pull request #91634 from jpbetz/latest-utils
Bump k8s.io/utils to 6e3d28 to pick up nested trace

Kubernetes-commit: a7e4973cb9d163fa9df2ecc0955d156d507a9a71
2020-06-23 05:34:23 +00:00
Joe Betz
e6cc05cca9 Bump k8s.io/utils to 6e3d28 to pick up nested trace
Kubernetes-commit: 52838be7b22c53050d4e397c221f0b3c3842122c
2020-06-19 10:17:13 -07:00
Kubernetes Publisher
fa5f3f17a3 Merge pull request #92219 from voor/update-golang-text
[security] Vulnerability in golang.org/x/text/encoding/unicode v0.3.2

Kubernetes-commit: 08ab50d1a870d12044081f58c6f9fa18b989597f
2020-06-19 21:38:06 +00:00
Kubernetes Publisher
30f91c5735 Merge pull request #90523 from sttts/sttts-security-contacts
Add myself to staging repo SECURITY_CONTACTS

Kubernetes-commit: d8febccacfc9d51a017be9531247689e0e36df04
2020-06-18 09:35:35 +00:00
Robert Van Voorhees
c21e531b4a [security] Vulnerability in golang.org/x/text/encoding/unicode v0.3.2
Hello gophers,

Version v0.3.3 of golang.org/x/text fixes a vulnerability in the golang.org/x/text/encoding/unicode package which could lead to the UTF-16 decoder entering an infinite loop, causing the program to crash or run out of memory.

An attacker could provide a single byte to a UTF16 decoder instantiated with UseBOM or ExpectBOM to trigger an infinite loop if the String function on the Decoder is called, or the Decoder is passed to golang.org/x/text/transform.String.

transform.String has also been hardened not to enter an infinite loop if a Transformer keeps returning ErrShortSrc even if atEOF is true.

This issue was first filed as Issue 39491 by GitHub user abacabadabacaba and reported to the security team by Anton Gyllenberg. It is tracked as CVE-2020-14040.

Cheers,

Katie for the Go team

Kubernetes-commit: 3cef97e8b5f67b4a350ee7a51e68604732e46f58
2020-06-17 07:57:05 -04:00
Kubernetes Publisher
18821151a3 Merge pull request #92069 from tapih/update-json-patch
Update github.com/evanphx/json-patch to e83c0a1c26c884f8ec4fb743f6db9…

Kubernetes-commit: 81f84d3a1764e883441ff155a3c0fdc724a1b304
2020-06-17 05:20:30 +00:00
Hiroshi Muraoka
2e5bf63e77 Update github.com/evanphx/json-patch to e83c0a1c26c884f8ec4fb743f6db92a941f605f1
Signed-off-by: Hiroshi Muraoka <h.muraoka714@gmail.com>

Kubernetes-commit: 5b06aaa7ab7d8ecf3b0088de13b3df381409e88f
2020-06-12 11:11:08 +00:00
Kubernetes Publisher
2ad238d3b3 Merge pull request #91792 from serathius/klog2
Upgrade klog to v2.1.0

Kubernetes-commit: a36b9a992223a71d822f3a0680f6b5202d2687d8
2020-06-16 10:08:46 +00:00
Kobayashi Daisuke
36de02d179 Replace StartLogging(klog.Infof) with StartStructuredLogging(0)
Kubernetes-commit: 4ae11dac2e2cc8594c528a679db5861c0926b514
2020-06-09 12:01:45 +09:00
Marek Siarkowicz
94a4c41c8e Upgrade klog to v2.1.0
Update contains fixes required for Structured Logging Effort

Kubernetes-commit: 1e3918f1d0dd8809d3675caeb49a7c99b9941263
2020-06-04 23:18:01 +02:00
Kubernetes Publisher
a1a67935a6 Merge pull request #90582 from RainbowMango/pr_bump_client_golang_1_6
bump client_golang to v1.6.0

Kubernetes-commit: 78f2c8f70d66dd5c64697418d034429b3ebd9dce
2020-05-19 08:40:25 +00:00
RainbowMango
4f4e76c835 Pin transitive dependencies:
pin dependency github.com/beorn7/perks from v1.0.0 to v1.0.1
pin dependency github.com/golang/protobuf from v1.3.3 to v1.4.2
pin denpendency github.com/json-iterator/go from v1.1.8 to v1.1.9
pin dependency github.com/prometheus/common from v0.4.1 to v0.9.1
pin dependency github.com/prometheus/procfs from v0.0.5 to v0.0.11
pin dependency github.com/alecthomas/template from v0.0.0-20160405071501-a0175ee3bccc to v0.0.0-20190718012654-fb15b899a751
pin dependency github.com/alecthomas/units from v0.0.0-20151022065526-2efee857e7cf to v0.0.0-20190717042225-c3de453c63f4
pin dependency github.com/go-kit/kit from v0.8.0 to v0.9.0
pin dependency github.com/go-logfmt/logfmt from v0.3.0 to v0.4.0

Co-Authored-By: Jordan Liggitt <jordan@liggitt.net>

Kubernetes-commit: 283d9f7483d9a5b30746921a68e7a5e586c2c80e
2020-05-18 12:40:21 +08:00
RainbowMango
a322fb98b8 bump github.com/prometheus/client_golang to v1.6.0
Kubernetes-commit: d8062e076e76bdea573bd19d4e2d0074d1f3fdac
2020-05-18 12:37:08 +08:00
Kubernetes Publisher
1e2a482e68 Merge pull request #90183 from dims/update-kubernetes-to-klog-v2
Update kubernetes to klog v2

Kubernetes-commit: b170451caa083434ee7875c2708c6f85eb220a39
2020-05-17 04:40:15 +00:00
Davanum Srinivas
4fb60b350f Run hack/update-vendor.sh
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 07d88617e55b64c243956c7b2032430beb03b159
2020-05-14 19:00:57 -04:00
Dr. Stefan Schimanski
36d4ca40d7 Add myself to staging repo SECURITY_CONTACTS
Kubernetes-commit: d42ccdc690f617cd55da0e3f699194e1dc247895
2020-04-27 16:39:25 +02:00
Davanum Srinivas
b3876539af switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 442a69c3bdf6fe8e525b05887e57d89db1e2f3a5
2020-04-17 15:25:06 -04:00
Davanum Srinivas
874d8bd323 Updating dependency golang.org/x/mod to version v0.1.0
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 3992c8669fa28e6a2721a09d750345f28f21e5f2
2020-05-14 18:04:08 -04:00
Davanum Srinivas
9221f46706 Updating dependency golang.org/x/mobile to version v0.0.0-20190719004257-d2bd2a29d028
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: e3a1dde5a1b8f712320c9f898d184fe6cde1cc24
2020-05-14 18:01:55 -04:00
Davanum Srinivas
874749ccc1 Updating dependency golang.org/x/image to version v0.0.0-20190802002840-cff245a6509b
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 4fca8bba148d05123060f332b7c7a7add08031b5
2020-05-14 17:59:40 -04:00
Davanum Srinivas
ba2950f05c Updating dependency golang.org/x/oauth2 to version v0.0.0-20191202225959-858c2ad4c8b6
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 15fa9902e97edc3c13c0717c94210d7b613396e7
2020-05-14 17:57:35 -04:00
Davanum Srinivas
305f94b2ab Updating dependency golang.org/x/lint to version v0.0.0-20191125180803-fdd1cda4f05f
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: a31d23dce333ba0a171d9a3ddff8b97da460430b
2020-05-14 17:55:24 -04:00
Davanum Srinivas
f6ef8007bd Updating dependency golang.org/x/exp to version v0.0.0-20191227195350-da58074b4299
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: cd596c5bdfcbf1dfa00ddd9d02aecae360150eb3
2020-05-14 17:53:16 -04:00
Davanum Srinivas
2e5a6576c3 Updating dependency honnef.co/go/tools to version v0.0.1-2019.2.3
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 4335e46738e79a0ccf49ed098e1e8708d31b313a
2020-05-14 17:49:03 -04:00
Davanum Srinivas
f07b7c7141 Updating dependency google.golang.org/appengine to version v1.6.5
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: f541ac3139760349248a446fc269b4f31f4892a4
2020-05-14 17:46:56 -04:00
Davanum Srinivas
a9a4c8d2c9 Updating dependency go.opencensus.io to version v0.22.2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 3a44a2ab418ff00cd16b5118ce8626f579e19e32
2020-05-14 17:44:51 -04:00
Davanum Srinivas
52af17c198 Updating dependency github.com/jstemmer/go-junit-report to version v0.9.1
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: a185928a258eca745a2b3a2db9b41b3502eb9c0c
2020-05-14 17:42:44 -04:00
Davanum Srinivas
0d82c085ab Updating dependency github.com/google/pprof to version v0.0.0-20191218002539-d4f498aebedc
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 584cccad8b2516c911dfcc09b2479228bfc7f788
2020-05-14 17:40:37 -04:00
Davanum Srinivas
6a7edda908 Updating dependency github.com/golang/groupcache to version v0.0.0-20191227052852-215e87163ea7
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 9bdefa900ae13e237ace286eaa0ee22539ad4e9a
2020-05-14 17:38:28 -04:00
Davanum Srinivas
02904da0d6 Updating dependency cloud.google.com/go to version v0.51.0
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 8a9bbd691e229a0818fabdd2049129e408156869
2020-05-14 17:34:15 -04:00
Davanum Srinivas
ceac14efa5 Updating dependency k8s.io/utils to version 2df71eb
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 449810c7858cc84e98ff0c859f863a40b56710dc
2020-05-14 17:27:32 -04:00
Davanum Srinivas
06dde08b8b Updating dependency github.com/GoogleCloudPlatform/k8s-cloud-provider to version 7901bc8
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: ca8ec8a6239b2b33aa73fd1178a4015194e9ad5a
2020-05-14 17:25:25 -04:00
Davanum Srinivas
86077f2293 Updating dependency k8s.io/kube-openapi to version 656914f
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 815c6d4c90a7143d68bb4f7a509a244a26d6df01
2020-05-14 17:23:08 -04:00
Davanum Srinivas
5355bb13f1 Updating dependency k8s.io/gengo to version 8167cfd
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: b158354e8ad718800364da8fa4d517e0934b5419
2020-05-14 17:20:51 -04:00
Kubernetes Publisher
3e0e2046ea Merge pull request #91044 from gongguan/cobra-1.0.0
update spf13/cobra dependency to 1.0.0

Kubernetes-commit: 678415a8a711c875708b438d34022c40f3f3fca3
2020-05-15 12:41:14 +00:00
louisgong
9ca490939b update spf13/cobra dependency to 1.0.0
Kubernetes-commit: 205ded20da8676ada99786a3ca54b28217041d09
2020-05-13 15:27:34 +08:00
Kubernetes Publisher
bf5c061a20 Merge pull request #90196 from markusthoemmes/remove-unused-parameterCodec
Don't generate parameterCodec if it's never used.

Kubernetes-commit: 013413d859324e4870edae1ad0c54dd404f872be
2020-04-24 08:17:06 +00:00
Markus Thömmes
769d3774fd Run ./hack/update-codegen.sh.
Kubernetes-commit: b113638cc8f9f38f33f355ee0200e00a56703c6f
2020-04-16 10:53:36 +02:00
Kubernetes Publisher
ed44550e22 Merge pull request #89833 from liggitt/json-raw
preserve integers decoding raw JSON values

Kubernetes-commit: ec00b4fcc2d0ad494275558e780606b1d9b3e469
2020-04-10 03:07:35 +00:00
Kubernetes Publisher
b0c1cd9051 Merge pull request #89942 from dims/update-fsnotify-to-pick-up-bug-fixes
Updating dependency github.com/fsnotify/fsnotify to version v1.4.9

Kubernetes-commit: b3837f858adfc13952736fd076717ec525e96dc9
2020-04-09 02:29:38 +00:00
Davanum Srinivas
3c75b0bc1e Updating dependency github.com/fsnotify/fsnotify to version v1.4.9
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: eee5235d2509df063189e08e150cc2c8213b54ed
2020-04-07 20:50:27 -04:00
Kubernetes Publisher
1ff2c9c252 Merge pull request #89834 from spiffxp/update-gengo
Update k8s.io/gengo to e0e292d8aa12

Kubernetes-commit: 5ea2d69ccdec410a372d92d680f71911a9d0926e
2020-04-04 22:25:08 +00:00
Jordan Liggitt
f52e2c788f k8s.io/kube-openapi v0.0.0-20200403204345-e1beb1bd0f35
fix client-side validation to allow a value of 0 for a number field

Kubernetes-commit: 8b9165839f1f592262c6ac657649b0acff66d1e4
2020-04-03 14:10:50 -04:00
Aaron Crickenberger
84a3ed9a42 Update k8s.io/gengo to e0e292d8aa12
This is mainly to pick up the bugfix for reducing log noise while
running import-boss

Kubernetes-commit: f9538b118dc21e0edcda64526526cfd23c9420ca
2020-04-02 19:57:19 -07:00
Kubernetes Publisher
a39d605b86 Merge pull request #89704 from liggitt/gnostic
github.com/googleapis/gnostic v0.4.1

Kubernetes-commit: d911254debefb5b630498aa3552899ee2f99f22e
2020-04-03 22:19:30 +00:00
Jordan Liggitt
8648d29690 github.com/googleapis/gnostic v0.4.1
Kubernetes-commit: 93c7b24562d80959f45c308e7412456a410b9b25
2020-03-31 17:18:56 -04:00
Kubernetes Publisher
041853156b Merge pull request #86975 from dims/update-hcsshim-v0.8.7-and-containerd-v1.3.2
Update to latest cadvisor and containerd (v1.3.3)

Kubernetes-commit: 4ad32682f3605f8eb0c152e3139a42d756106831
2020-03-26 02:49:06 +00:00
Davanum Srinivas
7f0055f0c9 Updating dependency golang.org/x/xerrors to version v0.0.0-20191204190536-9bdfabe68543
Kubernetes-commit: d2755395517411cfcda6dee9c749a15e4aef5b3f
2020-03-24 13:44:55 -04:00
Davanum Srinivas
60f0f63219 Updating dependency golang.org/x/time to version v0.0.0-20191024005414-555d28b269f0
Kubernetes-commit: 2b8b3b4008bbf072d216049c48ba792f023d2de8
2020-03-24 13:43:14 -04:00
Davanum Srinivas
e3364ceff9 Updating dependency golang.org/x/net to version v0.0.0-20200202094626-16171245cfb2
Kubernetes-commit: 75ceb7baa8f0df1c5cbaf02211c1a74e2addf498
2020-03-24 13:41:31 -04:00
Davanum Srinivas
d9129d0a68 Updating dependency gopkg.in/check.v1 to version v1.0.0-20190902080502-41f04d3bba15
Kubernetes-commit: 9e91a7ddc1a8f90bccff134b77e043809d07f65c
2020-03-24 13:39:41 -04:00
Davanum Srinivas
f0d5ab4459 Updating dependency google.golang.org/genproto to version v0.0.0-20191230161307-f3c370f40bfb
Kubernetes-commit: 7555985346c48b20d2b6662ebbce93827b513be2
2020-03-24 13:37:58 -04:00
Davanum Srinivas
9d6c1af3ea Updating dependency github.com/kr/pretty to version v0.2.0
Kubernetes-commit: 54967fe39367c1ada4c9c4b5c2146263f85a41e4
2020-03-24 13:24:29 -04:00
Davanum Srinivas
38ecd7efc8 Updating dependency github.com/google/go-cmp to version v0.4.0
Kubernetes-commit: 0dd6bf625814ab6ef9f93fbee40cde6d6206d932
2020-03-24 13:19:44 -04:00
Davanum Srinivas
cae42cb96c Update cadvisor and containerd
Kubernetes-commit: 4274ea2c89dee24e4c188a71e8164b2a40d1e181
2020-03-24 13:11:42 -04:00
Kubernetes Publisher
cc4f140715 Merge pull request #89444 from gnufied/update-utils-dep
bump k8s.io/utils package

Kubernetes-commit: 044a4ce21de7e89308be6cedc59fbf1cbb6b30b9
2020-03-25 05:05:13 +00:00
Kubernetes Publisher
c32b5dc3cb Merge pull request #89339 from alvaroaleman/lister-clarify-read-only
Lister codegen: Clarify that returned objects are read-only

Kubernetes-commit: 0c9ba6b5d7c4c91e1edfdb230574b99ebc5d1027
2020-03-25 00:41:56 +00:00
Hemant Kumar
4980766862 bump k8s.io/utils package
This fixes bug with xfs mount failing because of xfs_repair
being called. Fixes https://github.com/kubernetes/utils/issues/141

Kubernetes-commit: a1ae67d691d514d859fce68299d7bd3830686b38
2020-03-24 17:21:19 -04:00
Kubernetes Publisher
7d53195909 Merge pull request #89341 from aojea/bumputils
bump k8s.io utils

Kubernetes-commit: 6273449fe06574b3b192b92fe487ddfbd16837af
2020-03-23 04:52:53 +00:00
Antonio Ojea
a19d6d79a0 bump k8s.io utils
Fix a bug in k8s.io/utils/net.GetIndexedIP() that wasn't working
with IPv6 addresses with leading zeros.

Kubernetes-commit: dc025534afb0c3106b3aab166f88b971102135d1
2020-03-22 22:21:47 +01:00
Alvaro Aleman
2419a0374b Re-generate all listers
Kubernetes-commit: be370ddebcb3785325385267cbe5bd7b372e6118
2020-03-22 12:43:02 -04:00
Kubernetes Publisher
3bff4f1e4d Merge pull request #89319 from mboersma/fix-mount-sensitive-windows-master
Update vendored MountSensitive code for Windows

Kubernetes-commit: ca82b3281f426add48421aa54114d8f54f7d4ce5
2020-03-21 16:40:43 +00:00
marosset
a471136fa4 Updating vendored files
Kubernetes-commit: e72714933004dd34170a7e70f006f2ddb8e968d0
2020-03-20 21:13:48 +00:00
Kubernetes Publisher
a4286795ca Merge pull request #89159 from dims/move-term-package-to-component-base
Move term package to component base and switch to moby/term

Kubernetes-commit: bd07a408c1f82858fd63164f3b2937fd5f6905ce
2020-03-19 20:41:14 +00:00
Davanum Srinivas
b5c00988a5 Updating dependency github.com/google/go-cmp to version v0.3.1
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 865fd484820bf473ac9aa36466baaca80403fa45
2020-03-16 17:01:25 -04:00
Davanum Srinivas
926fedac01 update vendor
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: ee4310280669153c8ed733ae05946af65cc817b5
2020-03-16 16:54:33 -04:00
Kubernetes Publisher
8a9bf52c5e Merge pull request #89105 from andyzhangx/upgrade-40.2
Upgrade to azure-sdk v40.2.0

Kubernetes-commit: de931d569e005d916f8f146fc27fdac1c713a0ea
2020-03-19 08:38:26 +00:00
Kubernetes Publisher
98ae5d8686 Merge pull request #89014 from enj/enj/i/drop_openstack_cred_plugin
client-go: remove openstack auth plugin

Kubernetes-commit: 05134da9b7b90f35fe716d156d823778db16f634
2020-03-19 08:38:25 +00:00
andyzhangx
56261ea59d chore: upgrade to azure-sdk v40.2.0
chore: use autorest v0.9.6

fix go module issue

fix go module error

Kubernetes-commit: da20cc202fe2c5594c578a85730578b2300c78a0
2020-03-11 14:46:29 +00:00
Monis Khan
132dad4627 client-go: drop github.com/gophercloud/gophercloud dep
Signed-off-by: Monis Khan <mok@vmware.com>

Kubernetes-commit: 7a7bc9bcfb556abd4ec22be634eaca9e3b3a132a
2020-03-10 16:49:30 -04:00
Kubernetes Publisher
cd9755a5c9 Merge pull request #88875 from apelisse/apply-no-op
SSA: Applying same object twice should be a no-op the second time

Kubernetes-commit: 71ad0a90205c12e8ebbe6872db30097026916659
2020-03-07 12:39:24 +00:00
Kubernetes Publisher
aa5891ad80 Merge pull request #88708 from mikedanese/deleteopts
Migrate clientset metav1.DeleteOpts to pass-by-value

Kubernetes-commit: 5708511499fe500ae3b4bbd40204cef382f652e8
2020-03-06 08:39:08 +00:00
Antoine Pelisse
636cb6ea26 Bump sigs.k8s.io/structured-merge-diff to v3
Kubernetes-commit: df41fd932bef1686b30a1abee477c5009ebabe80
2020-03-05 13:09:50 -08:00
Mike Danese
cba8e5b7f3 update clients
Kubernetes-commit: 86bd06c8820a785cb8d74ef29d4a6a80c08988c0
2020-03-01 08:54:33 -08:00
Kubernetes Publisher
a4d2d71ffa Merge pull request #88684 from saad-ali/updateMountLib
Update AzureFile and CephFS to use MountSensitive

Kubernetes-commit: cd23e78c3dc1a4161abb11523a8614b56b9c0928
2020-03-04 08:40:01 +00:00
saad-ali
8a42a9808f Update dep k8s.io/utils to 0a110f9eb7ab
Kubernetes-commit: 22e8189f40fc95b18bad2b59ba2ad20ae7c69ea9
2020-02-28 18:22:45 -08:00
Kubernetes Publisher
b5ec0e93d1 Merge pull request #88381 from BenTheElder/CVE-2020-9283
update golang.org/x/crypto to fix CVE-2020-9283

Kubernetes-commit: 056374d9c8b8e43745d8a97f82981f886702cef8
2020-02-21 17:12:08 +00:00
Benjamin Elder
ec544ac840 update golang.org/x/crypto
Kubernetes-commit: 86ead631585825725e39f9a5e99c169b892a338c
2020-02-20 13:17:51 -08:00
Kubernetes Publisher
300c93640f sync: update go.mod 2020-02-16 06:24:04 +00:00
Kubernetes Publisher
a2c492ddbe Merge pull request #85617 from andrewsykim/optimize-external-ips
proxier: only get local addresses once per sync loop

Kubernetes-commit: ed0d6ee3cec18a2b0cc213bd3833e5bd02b091d8
2020-02-14 09:01:33 +00:00
andrewsykim
0981c9f5b1 update vendor k8s.io/utils to 5f6fbceb4c31
Signed-off-by: andrewsykim <kim.andrewsy@gmail.com>

Kubernetes-commit: 9e5a06c3eddb135a33496e874477a3a64b2421d6
2020-01-17 22:06:08 -05:00
Kubernetes Publisher
05e054c7a4 Merge pull request #87952 from mikedanese/opts
add *Options to Create, Update, and Patch in generated clientsets

Kubernetes-commit: abe6321296123aaba8e83978f7d17951ab1b64fd
2020-02-09 07:14:57 +00:00
Kubernetes Publisher
18387238ee Merge pull request #87908 from jpbetz/enable-smd-reflector
Bump to latest SMD to pick up performance optimizations

Kubernetes-commit: 86fcb30e5391a5494c8d83586f0911772a6949aa
2020-02-09 07:14:56 +00:00
Kubernetes Publisher
950eb22709 Merge pull request #87299 from mikedanese/ctx
context in client-go

Kubernetes-commit: 334d788f081e3bd6bb5fbbb5130c7d0810afc91e
2020-02-08 15:12:50 +00:00
Joe Betz
92ba4d84d0 Bump to latest SMD to pick up performance optimizations
Kubernetes-commit: d9faaca64738a50455f38dd88845e8b4b5ca37e2
2020-02-06 15:10:25 -08:00
Mike Danese
6df6a8fc23 generated: update clients
Kubernetes-commit: 1dcd1fb3b7a4399bdfd1aeaa8d200ae899a30b27
2020-02-04 17:53:04 -08:00
Mike Danese
ef20aa3dd1 generated: run refactor
Kubernetes-commit: 25651408aeadf38c3df7ea8c760e7519fd37d625
2020-02-08 12:30:21 -05:00
Mike Danese
d83890112b generated: update clients
Kubernetes-commit: 9443a3814446ecca4905f7ac7059c67f120151b9
2020-02-04 10:13:30 -08:00
Mike Danese
297436d318 generated: run refactor
Kubernetes-commit: 3aa59f7f3077642592dc8a864fcef8ba98699894
2020-02-07 18:16:47 -08:00
Kubernetes Publisher
81e6fe3b90 Merge pull request #87830 from dims/update-sigs.k8s.io/yaml-to-v1.2.0
Updating dependency sigs.k8s.io/yaml to version v1.2.0

Kubernetes-commit: e4061baeac03793f300c2dd824cae5673d1c24cf
2020-02-07 03:14:28 +00:00
Davanum Srinivas
4e2b652898 Updating dependency sigs.k8s.io/yaml to version v1.2.0
Kubernetes-commit: 5bb1838c5c197dd06af5f37df6fdaf8093338f67
2020-02-04 15:45:47 -05:00
Kubernetes Publisher
d90ced32cf sync: update go.mod 2020-02-02 07:33:55 +00:00
Kubernetes Publisher
9d489c7b9d Merge pull request #87597 from mikedanese/rctx
Refactor context handling in rest.Request

Kubernetes-commit: 60dd5dbd8b2347284b7e9b87a5700f54c185034e
2020-01-30 07:38:37 +00:00
Kubernetes Publisher
edca37f8f5 Merge pull request #87431 from dprotaso/bump-gofuzz
bump github.com/google/gofuzz

Kubernetes-commit: fc3b7b6dcde835291bd2103d78df9391b20bba39
2020-01-30 07:38:36 +00:00
Kubernetes Publisher
c94d7696a4 Merge pull request #83526 from eloyekunle/feat/gengo-reverse-import
import-boss reverse import

Kubernetes-commit: f5a008746aeae60feafafb77a0f07bebfceb2d97
2020-01-29 03:34:53 +00:00
Elijah Oyekunle
ee78ef29b9 bump gengo version
Kubernetes-commit: cece51b9b0b8322401f17f0650af864b9867f12e
2020-01-28 10:51:37 +01:00
Mike Danese
964a347899 regenerate clients
Kubernetes-commit: 59e757afef07beb17e26c02eade097d031cb49c7
2020-01-27 18:12:12 -08:00
Kubernetes Publisher
960347feac Merge pull request #87138 from markusthoemmes/fix-capitalization-error
Fix error-string-capitalization in clientset generator.

Kubernetes-commit: 6ae7bfc691c8266fc253d45ecf55acac8877c6d2
2020-01-24 11:35:01 +00:00
Kubernetes Publisher
8c05e8c649 Merge pull request #87467 from cjcullen/yaml
Update gopkg.in/yaml.v2 to v2.2.8

Kubernetes-commit: 07b358b1904c3c16a40a93a18f95e9411d9a2789
2020-01-24 03:37:09 +00:00
Kubernetes Publisher
bd4ff3d8ad Merge pull request #87442 from jennybuckley/smd-3
Update structured-merge-diff dependency to v3

Kubernetes-commit: 03cb6afc1a7d43e8ea034279a19801d3d3fb17b3
2020-01-23 07:38:42 +00:00
CJ Cullen
4f28e14945 update gopkg.in/yaml.v2 to v2.2.8
Kubernetes-commit: b86df2bec4f377afc0ca03482ffad2f0a49a83b8
2020-01-22 11:32:39 -08:00
jennybuckley
5605e8990d Update Structured Merge Diff to V3
Kubernetes-commit: b33fbc84d9d6e7033c36fa3bc321b8fea28ceed6
2020-01-21 15:03:56 -08:00
Dave Protasowski
551d70ff44 bump github.com/google/gofuzz
This includes the ability for the fuzzer to skip certain struct fields

Kubernetes-commit: c8dbde86664170f479dd9a9a55de76d8f186754f
2020-01-21 13:11:34 -05:00
Kubernetes Publisher
f983218c80 Merge pull request #87081 from dims/updating-protobuf-and-grpc
Updating protobuf (v1.3.1) and grpc (v1.26.0)

Kubernetes-commit: f4b6b751cdf2d46940355359443b263cb883d006
2020-01-18 23:52:50 +00:00
Davanum Srinivas
ab1c547945 Updating dependency google.golang.org/genproto to version v0.0.0-20190819201941-24fa4b261c55
Kubernetes-commit: 2f78a9480f2f4eabb7698984371df25543312db4
2020-01-13 17:40:24 -05:00
Davanum Srinivas
bab5a99d15 Updating dependency google.golang.org/grpc to version v1.26.0
Kubernetes-commit: 3b29bcf52d3f6a73af9830cf55159893899c2b1b
2020-01-13 17:38:18 -05:00
Davanum Srinivas
59665bb9b6 Updating dependency github.com/gogo/protobuf to version v1.3.1
Kubernetes-commit: 9c78f05d06cb43dce4363cad03ff79f579c22eee
2020-01-13 17:36:07 -05:00
Kubernetes Publisher
de9f70c977 Merge pull request #87158 from dims/pick-closest-tags-for-a-few-packages
Pick closest tags for a few packages and avoid random SHA

Kubernetes-commit: 5d1c3016103d83df4ae91664639ba7e0a103c7ec
2020-01-16 03:54:08 +00:00
Kubernetes Publisher
2ddb023c08 Merge pull request #87226 from liggitt/simplify-code-generator
Simplify code generator dependencies

Kubernetes-commit: b95d571e32294047a5fb9ca93ee4e394f6765308
2020-01-15 19:50:53 +00:00
Jordan Liggitt
a23205f445 hack/update-vendor.sh
Kubernetes-commit: e8a8bdb4cac0c9299da7317d41bcb3e1320424e1
2020-01-14 21:56:32 -05:00
Kubernetes Publisher
f8d330e562 Merge pull request #87107 from dims/updating-googleapis/gnostic-to-v0.1.0
updating googleapis/gnostic to v0.1.0

Kubernetes-commit: d5145ffc10c7429f555134f44d5bf95cd7eda270
2020-01-13 23:51:10 +00:00
Kubernetes Publisher
ab780863f6 Merge pull request #87088 from dims/switch-to-newer-gonum
Drop random SHA and update gonum.org/v1/gonum to v0.6.2

Kubernetes-commit: bb3f8c7c899d7166c31934b80b39c7307ec85b7a
2020-01-13 23:51:09 +00:00
Davanum Srinivas
a9e1ddb708 Updating dependency github.com/elazarl/goproxy to version 947c36d
Kubernetes-commit: a6d72ab71323b01846b37fe896bae3e0886a86ba
2020-01-13 12:33:25 -05:00
Markus Thömmes
7002d8cfae Fix error-string-capitalization in clientset generator.
Kubernetes-commit: 14e0cac5e7a6b07c58e78b0daff48d098fdd2150
2020-01-13 11:17:05 +01:00
Davanum Srinivas
575eb3267b updating googleapis/gnostic to v0.1.0
per https://github.com/googleapis/gnostic/releases/tag/v0.1.0, the
v0.1.0 was made specifically for use by k8s, but we still seem to be
using a random SHA. Let's try to switch to a tagged version.

Kubernetes-commit: 420d5d10c4baad0aced31de382801fd999f2c94b
2020-01-11 22:38:36 -05:00
Kubernetes Publisher
7e92736cc3 Merge pull request #85458 from cjcullen/yaml
Update gopkg.in/yaml.v2 to v2.2.7

Kubernetes-commit: 7f2128757b1aa2e83320d1f635fe8b2e7028542a
2020-01-11 15:50:42 +00:00
Davanum Srinivas
55a37d4522 update gonum.org/v1/gonum to v0.6.2
Kubernetes-commit: f66ef23c1182e72db9cbb80f6df4186a326374c0
2020-01-10 15:26:48 -05:00
Kubernetes Publisher
7b12eff437 Merge pull request #86346 from SataQiu/bump-utils-20191217
Bump k8s.io/utils version

Kubernetes-commit: 2d310b13215110a9dcaabcebef65d62a1b3f0bdd
2019-12-22 11:49:42 +00:00
SataQiu
2b5783f346 bump k8s.io/utils version
Kubernetes-commit: 2497a1209bf96472bceabbc465b2370f1b66a4a7
2019-12-17 23:12:53 +08:00
Kubernetes Publisher
b60d4fc3c5 Merge pull request #86013 from carlosedp/ginkgo_bump
Bump Ginkgo to support building on riscv64 arch

Kubernetes-commit: 4ff692861908697c530b6b8ba48a5eb442bd7ed7
2019-12-20 23:50:14 +00:00
Carlos de Paula
93c2e44338 Bump Ginkgo module to release version
Kubernetes-commit: c71dd7e4ee6b6f8f624ffc12fc38d1c6dedc5739
2019-12-19 19:30:42 -03:00
Carlos de Paula
6976381688 Bump Ginkgo to support building on riscv64 arch
Kubernetes-commit: ecfd30d2517c52f158b099abcc303cce307c324d
2019-12-06 15:23:15 -05:00
Kubernetes Publisher
8ed8142b5c Merge pull request #86269 from odinuge/go-mod-version
Update go version in go.mod to 1.13

Kubernetes-commit: b96642aeaeefee838b5f0938e5d04765dd27d39b
2019-12-14 19:13:29 +00:00
Odin Ugedal
2c5619cf7a Update go version in go.mod
We now use go 1.13 and not 1.12

Kubernetes-commit: 4769cbedd5bdaf61e329b4e9687ec97a6c53b61a
2019-12-14 12:43:14 +01:00
Kubernetes Publisher
65e4a11739 Merge pull request #84327 from byteor/codereview
[k8s.io/sample-controller/controller.go]: fixup minor typo

Kubernetes-commit: 143f9dd7ccca34445f152722fe8ccbb21f5d3cc4
2019-11-23 02:10:55 +00:00
Kubernetes Publisher
d454fe8177 Merge pull request #85223 from sttts/sttts-crd-items-types
apiextensions: fix items+type logic in API due to broken go-openapi validation

Kubernetes-commit: 976712556e4bd22d5312a0af36b18127c709d54a
2019-11-21 02:12:13 +00:00
CJ Cullen
7fc9944bbb update gopkg.in/yaml.v2 to v2.2.7
Kubernetes-commit: aa278345fa55ee9f3e097da1b590fcabd85270f7
2019-11-19 09:39:27 -08:00
Dr. Stefan Schimanski
01bbecf3b2 hack/pin-dependency.sh github.com/go-openapi/validate v0.19.5
Kubernetes-commit: ef88c43c0296e6004d0e3407a1336074897b309d
2019-11-15 13:48:59 +01:00
Kubernetes Publisher
ef93e2e76a Merge pull request #85305 from codenrhoden/remove-mount-pkg
Remove pkg/util/mount (moved out of tree)

Kubernetes-commit: 45e0080fd5883e3355233c9c22fa5bf242d525dd
2019-11-15 22:10:02 +00:00
Travis Rhoden
b3ad0016ff Remove pkg/util/mount (moved out of tree)
This patch removes pkg/util/mount completely, and replaces it with the
mount package now located at k8s.io/utils/mount. The code found at
k8s.io/utils/mount was moved there from pkg/util/mount, so the code is
identical, just no longer in-tree to k/k.

Kubernetes-commit: 0c5c3d8bb97d18a2a25977e92b3f7a49074c2ecb
2019-11-14 13:30:00 -07:00
Kubernetes Publisher
055fb85f0a Merge pull request #84424 from mikedanese/expcache
Add an expiring cache for the caching token authenticator

Kubernetes-commit: 19b4017b5d5c5695403a9804f5ea3de11a436c04
2019-11-15 02:06:46 +00:00
Kubernetes Publisher
33e2132d1e Merge pull request #85175 from liggitt/golang-org-comments
Add comments to explain golang.org replace directives

Kubernetes-commit: 24334444b46371e26594e1f6e594195a761b53d3
2019-11-14 22:25:29 +00:00
Jordan Liggitt
424188e943 Add comments to explain golang.org replace directives
Kubernetes-commit: 9f40e19d7ac9e2203c23814701468a26eee1964f
2019-11-12 23:54:26 -05:00
Kubernetes Publisher
de0ba49f28 Merge pull request #83840 from liggitt/json-iter
bump json-iterator dependency

Kubernetes-commit: 3387d6cfc73235fd554e5039b85abb7700eaf126
2019-11-09 11:01:50 +00:00
Kubernetes Publisher
cb8e37036c Merge pull request #84911 from yue9944882/chore/bump-kube-openapi
Pin kube-openapi vendor to 30be4d16710a

Kubernetes-commit: dd6faa5da791c06fa23ff668e4463c3ad2b23340
2019-11-08 07:15:22 +00:00
yue9944882
7b8c63153b update k8s.io/kube-openapi to 30be4d16710a
Kubernetes-commit: 8e7606f32898b294fc25152ff8bd34f62d6221d3
2019-11-07 18:39:08 +08:00
Kubernetes Publisher
97ea7f1bbd Merge pull request #82809 from liggitt/go-1.13-no-modules
update to use go1.13.4

Kubernetes-commit: 695c3061dd92a6b6950f8adf0341ceb4a8dd44d7
2019-11-07 03:24:42 +00:00
Jordan Liggitt
fe7e76b7d4 hack/update-vendor.sh
Kubernetes-commit: 297570e06a88db23e16dbdbf6ce3173fe0ae376c
2019-11-05 14:11:10 -05:00
Kubernetes Publisher
472018681a Merge pull request #84604 from codenrhoden/update-utils-dep
Update k8s.io/utils dependency to latest

Kubernetes-commit: 97e28edb6620568d985f3b03b495a0a373aa8750
2019-11-01 23:13:24 +00:00
Travis Rhoden
09364c09e9 Update k8s.io/utils dependency to latest
Kubernetes-commit: 81f66ecbb5ff359ac765c7f332289dd8c1737c39
2019-10-31 08:35:01 -06:00
Mike Danese
326f8f2c88 Add an expiring cache for the caching token authenticator
And maybe the webhook authorizer cache.

This cache has two primary advantages over the LRU cache used currently:

- Cache hits don't acquire an exclusive lock.
- More importantly, performance doesn't fallover when the access pattern
  scans a key space larger than an arbitrary size (e.g. the LRU
  capacity).

The downside of using an expiring cache here is that it doesn't have a
maximum size so it's suspectible to DoS when the input is user
controlled. This is not the case for successful authentications, and
successful authentications have a natural expiry so it might be a good
fit here.

It has some a few differences compared to:

3d7318f29d/staging/src/k8s.io/client-go/tools/cache/expiration_cache.go

- Expiration is not entirely lazy so keys that are never accessed again
  are still released from the cache.
- It does not acquire an exclusive lock on cache hits.
- It supports per entry ttls specified on Set.

The expiring cache (without striping) does somewhere in between the
simple cache and striped cache in the very contrived contention test
where every iteration acquires a write lock:

```
$ benchstat simple.log expiring.log
name      old time/op    new time/op    delta
Cache-12    2.74µs ± 2%    2.02µs ± 3%  -26.37%  (p=0.000 n=9+9)
name      old alloc/op   new alloc/op   delta
Cache-12      182B ± 0%      107B ± 4%  -41.21%  (p=0.000 n=8+9)
name      old allocs/op  new allocs/op  delta
Cache-12      5.00 ± 0%      2.00 ± 0%  -60.00%  (p=0.000 n=10+10)

$ benchstat striped.log expiring.log
name      old time/op    new time/op    delta
Cache-12    1.58µs ± 5%    2.02µs ± 3%  +27.34%  (p=0.000 n=10+9)
name      old alloc/op   new alloc/op   delta
Cache-12      288B ± 0%      107B ± 4%  -62.85%  (p=0.000 n=10+9)
name      old allocs/op  new allocs/op  delta
Cache-12      9.00 ± 0%      2.00 ± 0%  -77.78%  (p=0.000 n=10+10)

$ benchstat simple.log striped.log expiring.log
name \ time/op    simple.log   striped.log  expiring.log
Cache-12          2.74µs ± 2%  1.58µs ± 5%   2.02µs ± 3%
name \ alloc/op   simple.log   striped.log  expiring.log
Cache-12            182B ± 0%    288B ± 0%     107B ± 4%
name \ allocs/op  simple.log   striped.log  expiring.log
Cache-12            5.00 ± 0%    9.00 ± 0%     2.00 ± 0%
```

I also naively replacemed the LRU cache with the expiring cache in the
more realisitc CachedTokenAuthenticator benchmarks:

https://gist.github.com/mikedanese/41192b6eb62106c0758a4f4885bdad53

For token counts that fit in the LRU, expiring cache does better because
it does not require acquiring an exclusive lock for cache hits.

For token counts that exceed the size of the LRU, the LRU has a massive
performance drop off. The LRU cache is around 5x slower (with lookups
taking 1 milisecond and throttled to max 40 lookups in flight).

```
$ benchstat before.log after.log
name                                                  old time/op    new time/op    delta
CachedTokenAuthenticator/tokens=100_threads=256-12      3.60µs ±22%    1.08µs ± 4%  -69.91%  (p=0.000 n=10+10)
CachedTokenAuthenticator/tokens=500_threads=256-12      3.94µs ±19%    1.20µs ± 3%  -69.57%  (p=0.000 n=10+10)
CachedTokenAuthenticator/tokens=2500_threads=256-12     3.07µs ± 6%    1.17µs ± 1%  -61.87%  (p=0.000 n=9+10)
CachedTokenAuthenticator/tokens=12500_threads=256-12    3.16µs ±17%    1.38µs ± 1%  -56.23%  (p=0.000 n=10+10)
CachedTokenAuthenticator/tokens=62500_threads=256-12    15.0µs ± 1%     2.9µs ± 3%  -80.71%  (p=0.000 n=10+10)

name                                                  old alloc/op   new alloc/op   delta
CachedTokenAuthenticator/tokens=100_threads=256-12        337B ± 1%      300B ± 0%  -11.06%  (p=0.000 n=10+8)
CachedTokenAuthenticator/tokens=500_threads=256-12        307B ± 1%      304B ± 0%   -0.96%  (p=0.000 n=9+10)
CachedTokenAuthenticator/tokens=2500_threads=256-12       337B ± 1%      304B ± 0%   -9.79%  (p=0.000 n=10+10)
CachedTokenAuthenticator/tokens=12500_threads=256-12      343B ± 1%      276B ± 0%  -19.58%  (p=0.000 n=10+10)
CachedTokenAuthenticator/tokens=62500_threads=256-12      493B ± 0%      334B ± 0%  -32.12%  (p=0.000 n=10+10)

name                                                  old allocs/op  new allocs/op  delta
CachedTokenAuthenticator/tokens=100_threads=256-12        13.0 ± 0%      11.0 ± 0%  -15.38%  (p=0.000 n=10+10)
CachedTokenAuthenticator/tokens=500_threads=256-12        12.0 ± 0%      11.0 ± 0%   -8.33%  (p=0.000 n=10+10)
CachedTokenAuthenticator/tokens=2500_threads=256-12       13.0 ± 0%      11.0 ± 0%  -15.38%  (p=0.000 n=10+10)
CachedTokenAuthenticator/tokens=12500_threads=256-12      13.0 ± 0%      10.0 ± 0%  -23.08%  (p=0.000 n=9+10)
CachedTokenAuthenticator/tokens=62500_threads=256-12      17.0 ± 0%      12.0 ± 0%  -29.41%  (p=0.000 n=10+10)
```

Benchmarked with changes in #84423

Bugs: #83259 #83375

Kubernetes-commit: 9167711fd18511ffc9c90ee306c462be9fc7999b
2019-10-26 12:19:07 -07:00
Kubernetes Publisher
d7b8b83029 Merge pull request #83987 from wenjiaswe/etcd_client_3_4_2
Update etcd client to v3.4.3 in k8s v1.17

Kubernetes-commit: 09f453ff8322979ed5a7611bc2e5528506c1fc7f
2019-10-25 23:13:05 +00:00
Zhou Peng
9dfda3fc9a [k8s.io/sample-controller/controller.go]: fixup minor typo
Signed-off-by: Zhou Peng <p@ctriple.cn>

Kubernetes-commit: 5616ce97622e25a90f89f56e5556e73e065ee012
2019-10-25 10:30:25 +08:00
Wenjia Zhang
2ea1ad4d72 Pin dependencies and update vendors
Kubernetes-commit: 660b17d0aeda96af94defd4c5110d9fef523d52b
2019-10-23 13:37:36 -07:00
Kubernetes Publisher
ab9e95689d Merge pull request #82455 from AdheipSingh/patch-1
Update comment for syncHandler

Kubernetes-commit: ad0274fb6e506fb573cc3237ada871ea6dfc66fe
2019-10-17 07:04:49 +00:00
Kubernetes Publisher
2b8cca0f69 Merge pull request #81952 from ialidzhikov/fix/broken-link
Fix broken link in sample-controller

Kubernetes-commit: d87403c2f5c4a49b15420985e7c6d5cbd1e9cd8b
2019-10-16 11:28:52 +00:00
Kubernetes Publisher
3abffa4165 Merge pull request #83855 from mrbobbytables/update-sample-controller-owners
Prune inactive owners from staging/src/k8s.io/sample-controller/OWNERS.

Kubernetes-commit: 3ec5fe500d7a56be6ff6c15f916987eaa48c2e94
2019-10-14 01:52:35 -07:00
Bob Killen
d593d06471 Prune inactive owners from staging/src/k8s.io/sample-controller/OWNERS.
Kubernetes-commit: 53137a6bf9fe09ac924b3087e3e3fb5e43b4bf8b
2019-10-12 20:15:46 -04:00
Kubernetes Publisher
8aa6dce7d6 Merge pull request #83785 from yastij/bump-utils-rangesize
bump k8s.io/utils to pickup bug fix for rangesize func

Kubernetes-commit: 677903edc6cfe1fb045a55b0734ee05ce8c3d03c
2019-10-14 07:34:41 +00:00
Jordan Liggitt
32837242dd bump github.com/json-iterator/go v1.1.8
Kubernetes-commit: e323279ab94e2434fa610a476ad6d7630228be0e
2019-10-12 10:10:03 -04:00
Yassine TIJANI
97f7067723 bump k8s.io/utils to pickup bug fix for rangesize
Signed-off-by: Yassine TIJANI <ytijani@vmware.com>

Kubernetes-commit: 5d49cbd3cae68d7aafdeac7f2ca08208118f09ad
2019-10-11 16:45:21 +02:00
Kubernetes Publisher
ac9726f261 Merge pull request #82176 from pohly/ginkgo-stack-fix
Ginkgo update + stack fix

Kubernetes-commit: b140b431073ae4d84ce9ef5e01a1f27058178ead
2019-10-05 12:09:43 +00:00
Kubernetes Publisher
9f91627dc6 Merge pull request #83261 from liggitt/yaml-limits
limit yaml/json decode size

Kubernetes-commit: 4afcba42bed2bb7c36e5209a90d87343f32a0efa
2019-10-03 04:11:42 +00:00
Jordan Liggitt
1be1e75737 bump gopkg.in/yaml.v2 v2.2.4
Kubernetes-commit: 8aeffa8716dcf986544df74444264ef639d61a7a
2019-10-02 14:46:08 -04:00
Patrick Ohly
71f7a8b74b vendor: update gomega to v1.7.0
Updated to keep both Ginkgo and Gomega at the latest releases.

Kubernetes-commit: 27b9a9c2381fab195f2db1bc709e46d0b83fc729
2019-10-01 20:25:05 +02:00
Kubernetes Publisher
a91ecd8a9f Merge pull request #83113 from yastij/bump-utils
bump k8s.io/utils to pickup ipallocator changes

Kubernetes-commit: 28bcf55accc52dfd4fde5f603a5784c40c485528
2019-09-26 00:08:56 +00:00
Yassine TIJANI
e6f28640db bump k8s.io/utils to pickup ipallocator changes
Signed-off-by: Yassine TIJANI <ytijani@vmware.com>

Kubernetes-commit: 16fe4d76271f6330c2837462a40edf95dde95942
2019-09-25 16:15:30 +02:00
Kubernetes Publisher
9776085a84 Merge pull request #83014 from danielqsj/bump-klog
Bump k8s.io/klog to v1.0.0

Kubernetes-commit: b7003211d5454982401c19705f73bf2820ede855
2019-09-23 16:09:22 +00:00
danielqsj
20bcce4d81 Bump k8s.io/klog to v1.0.0
Kubernetes-commit: c2a4906152e67a45308f988aa2cb8b76b4503855
2019-09-23 16:51:43 +08:00
Kubernetes Publisher
3b7fd8b5d4 Merge pull request #81944 from carlory/fix-vendor
fix static check failures in staging  pkg

Kubernetes-commit: 84d484bd2c6c69e9ccce1fe03b7621f151b1b042
2019-09-16 16:06:09 +00:00
Kubernetes Publisher
b2dd2e61ff Merge pull request #82161 from d-kuro/feature/fix-broken-link
Fix broken link.

Kubernetes-commit: 9c25981f359603333b3323b44e812b293887749b
2019-09-13 08:41:32 +00:00
AdheipSingh
1205a13b28 Update comment for syncHandler
```
// If the Deployment is not controlled by this Foo resource, we should log
// a warning to the event recorder and return error msg
```
For a clearer understanding of the comment.

Kubernetes-commit: db303bc2af859d48958e0b9c084a3b2983c1220f
2019-09-07 19:09:56 +05:30
Kubernetes Publisher
b17b22266f Merge pull request #77354 from jennybuckley/crd-apply
Use CRD validation field in server-side apply

Kubernetes-commit: ab162cd28c332d0ecfb4f918d5f91e9e57acdb61
2019-08-31 08:01:03 +00:00
Patrick Ohly
52badec515 e2e log: Ginkgo 1.10.1 fixes stack skip
Now Ginkgo properly skips the initial stack entry.

Kubernetes-commit: ecd7ae55bc3ceda761f4405764815f70d38e3b2c
2019-08-30 17:58:48 +02:00
d-kuro
dd65d88bb2 Fix broken link.
Kubernetes-commit: 4558dd407ac8e692dc41c47268e15ff692949ff2
2019-08-30 15:30:59 +09:00
jennybuckley
4696ad80ce Update generated
Kubernetes-commit: badd5b9a26026138e4fc44a643ec1c6b65a7891b
2019-08-29 19:10:28 -07:00
Kubernetes Publisher
25b34fa161 Merge pull request #81871 from prameshj/vendor-update
Update vendor k8s-cloud-provider and google API

Kubernetes-commit: 91bec13163b18238a8ed3d9b872cd27b1193077d
2019-08-28 12:01:28 +00:00
Patrick Ohly
63288e8e88 e2e log: fix full stacktrace with Ginkgo 1.10.0
Ginkgo 1.10.0 includes the relevant fix for dumping the full stack
(https://github.com/onsi/ginkgo/pull/590), so when using that release
we can simplify the logging unit test.

By changing the skipping, we can avoid the rather volatile util.go
entries. However, that gomega is part of the stack trace still needs
to be fixed in Gingko.

Kubernetes-commit: 02ce619078b1a75e9fa258e101f81af899719e8e
2019-08-27 14:22:46 +02:00
ialidzhikov
133f0ccb02 Fix broken link in sample-controller
Signed-off-by: ialidzhikov <i.alidjikov@gmail.com>

Kubernetes-commit: 61c5f8d9079fc985c093d76161c8f35736de22ee
2019-08-26 18:19:17 +03:00
carlory
bf70b19355 fix static check failures in staging pkg
Kubernetes-commit: d3578f465d1e41f6fb022f64117f51cbed90fd9d
2019-08-26 21:23:40 +08:00
Pavithra Ramesh
da203f3b6d Update vendor k8s-cloud-provider and google API
Ran commands:
hack/pin-dependency.sh github.com/GoogleCloudPlatform/k8s-cloud-provider 27a4ced34534a6c32b63159b100ac0efaa1d37b3
hack/update-vendor.sh

hack/pin-dependency.sh google.golang.org/api 5213b809086156e6e2b262a41394993fcff97439
hack/update-vendor.sh

hack/verify-vendor.sh

merge conflicts

Kubernetes-commit: ce3b145e7369da6c1179346a4e6f4f9992d235b7
2019-08-23 15:51:45 -07:00
Kubernetes Publisher
8df6f90ea0 Merge pull request #81752 from dims/hack-pick-up-test-go-files-in-verify-import-boss
Pick up *_test.go in verify-import-boss

Kubernetes-commit: 448049927b7b66d3b539f228ed6eac59430ea70b
2019-08-26 12:18:44 +00:00
Davanum Srinivas
d374f88b72 hack/pin-dependency.sh k8s.io/gengo 26a664648505d962332bda642b27306bc10d1082
Kubernetes-commit: 96998c619714f254998e69c5bae3c3a1b03fa423
2019-08-22 12:15:10 -04:00
Kubernetes Publisher
4c955751ed sync: update go.mod 2019-08-22 06:19:52 +00:00
Kubernetes Publisher
ec1b9e1d84 Merge pull request #81189 from tallclair/staticcheck-verify
Add verify-staticcheck script

Kubernetes-commit: 39c10d1550d63a4a5c585600507ffd6a0f157267
2019-08-20 10:38:33 +00:00
Tim Allclair
44debde540 Bump golang.org/x/tools version for staticcheck compat
Kubernetes-commit: 9a02ef7fe5eb166a53131c52b59844179c4158e9
2019-08-08 11:04:56 -07:00
Kubernetes Publisher
87c4b6f0a4 Merge pull request #79574 from justaugustus/azure-sdk-bump
Azure SDK updates (6/30/19)

Kubernetes-commit: 1ff4525a29f1736fca19e10b49e42664b29010c2
2019-08-16 10:34:50 +00:00
Stephen Augustus
098a911418 Update Azure/azure-sdk-for-go and Azure/go-autorest modules
Signed-off-by: Stephen Augustus <saugustus@vmware.com>

Kubernetes-commit: db855f9ba0ced2303fbb3b9776dd2a0d78b31897
2019-08-15 17:57:49 -04:00
Kubernetes Publisher
f27ac7da6c Merge pull request #81335 from carlory/fix
add missing import required by build scripts

Kubernetes-commit: 8d925c7510820523665bdd5ce1916fa956b9c5fa
2019-08-14 14:19:25 +00:00
Kubernetes Publisher
a378495b96 Merge pull request #81394 from cblecker/golang-deps
Update golang/x/net dependency

Kubernetes-commit: 1f6cb3cb9def97320a5412dcbea1661edd95c29e
2019-08-14 10:44:47 +00:00
Christoph Blecker
ab1a85cb44 Update vendor
Kubernetes-commit: 5f971d6d8862de319edbd24a729a704292c560dc
2019-08-13 17:51:45 -07:00
Kubernetes Publisher
0ad63590ca Merge pull request #81372 from alvaroaleman/bump-sets
Bump gengo to have set insert|delete return the set

Kubernetes-commit: 125fb72850c4d1e7b25bd46a094633b9a0a76b9b
2019-08-14 02:18:20 +00:00
Alvaro Aleman
0b8b985912 Update k8s.io/gengo to 955ffa8fcfc983717cd9de5d2a1e9f5c465f4376
Kubernetes-commit: c4fd0d4f99b672f8c44ff72a155973fae4b32032
2019-08-13 23:49:12 +02:00
Kubernetes Publisher
20ed9a6dcb Merge pull request #81164 from dims/update-to-latest-klog-0.4.0
Update to latest klog 0.4.0

Kubernetes-commit: 461b2d8b9ae818b4b08a6c74d2ec6048fe7a52b6
2019-08-13 22:22:31 +00:00
carlory
5fae6ff24f run ./hack/update-vendor.sh
Kubernetes-commit: dc9bf6a9553d2381ae94e62ad5e49064d0de01e7
2019-08-13 20:20:38 +08:00
Kubernetes Publisher
a52d0d8c67 Merge pull request #81096 from roycaihw/update-vendor-json-iterator
Update github.com/json-iterator/go dependency to fix emtpy byte marshaling

Kubernetes-commit: 3030a9d92750173ed72ea9cd37286bf6a41c2dcb
2019-08-08 18:21:25 +00:00
Davanum Srinivas
49c7e07bcf Update to latest klog 0.4.0
47ffc4e Add test case for detecting data race
959d342 Prevent data race in SetOutput* methods
34123a4 Test with golang 1.12.x
bf4884f Fix the log duplication issue for --log-file
dc5546c Backfill integration tests for selecting log destinations
baef93d fix broken links
07b218b Add go modules files
b33ae69 Add flag to include file's dir in logs
7c58910 correct documentation
a4033db Code Hygene - glog to klog
941d47b Revert "Fix the log duplication issue for --log-file."
314f6c4 Update godoc for the default value of logtostderr
7eb35e2 Fix the log duplication issue for --log-file.

Kubernetes-commit: 9a2de95601641aa1077734c76fc24ebe7b6026db
2019-08-08 10:08:27 -04:00
Haowei Cai
3f68520957 generated
running hack/update-vendor.sh

Kubernetes-commit: 6bed35ebd2bfc8d0de1d5fe7a6db0fd15a7abace
2019-08-07 12:53:51 -07:00
Kubernetes Publisher
6d2a97f64c Merge pull request #78610 from jpbetz/admission-trace
Add trace to webhook invocations

Kubernetes-commit: a197cc61740be784b43c85c04bda9a2658da3a09
2019-08-07 06:29:12 +00:00
Joe Betz
dc57994a5b Upgrade to latest k8s.io/utils
Kubernetes-commit: 237b16d9d99d1eaf9ef762ddeb4ccec247b2ba8c
2019-08-03 00:10:36 -07:00
Kubernetes Publisher
6f8905ae4e Merge pull request #80732 from cblecker/fix-tag-protobuf
Fix tag for gogo/protobuf

Kubernetes-commit: d8900caac8aef61e79ca921a7922d95ae06b16f2
2019-07-31 14:43:49 +00:00
Christoph Blecker
a612d6a1c9 Fix tag for github.com/gogo/protobuf
Kubernetes-commit: 7471a1d35fe40eb01b7dc20b2ac09192741ef436
2019-07-30 18:38:34 -07:00
Kubernetes Publisher
fdfa0b050b Merge pull request #77355 from apelisse/test-new-protoc
Use new reverse protobuf marshalling

Kubernetes-commit: a172e197b165f60c215b4467175bdd61d8a15e0e
2019-07-26 02:42:44 +00:00
Antoine Pelisse
52e2df40b1 Regenerate
Kubernetes-commit: 6568325ca2bef519e5c8228cd33887660b5ed7b0
2019-07-24 15:21:55 -07:00
Kubernetes Publisher
c4dce8f814 Merge pull request #80252 from ajatprabha/patch-1
Update deprecated diff.ObjectGoPrintDiff method

Kubernetes-commit: 3f1cb97f9ad7b84176be30f85c7e10cc7bb1ff56
2019-07-19 02:36:55 +00:00
Ajat Prabha
1e56cadeb7 Update deprecated diff.ObjectGoPrintDiff method
Use `diff.ObjectGoPrintSideBySide` to print the difference.

Kubernetes-commit: 291c145bc567ca8ef82aee14098d0dda7c818300
2019-07-17 17:25:34 +05:30
Kubernetes Publisher
38d625004d Merge pull request #80123 from sttts/sttts-bump-kube-openapi2
Bump kube-openapi and structured-merge-diff

Kubernetes-commit: eee3a3749add92cd67b4c6f80567cd438a6c24e6
2019-07-17 02:43:00 +00:00
Dr. Stefan Schimanski
5335398820 Run update-vendor.sh
Kubernetes-commit: 91a3704938070b8b18dc39774d5acd8234c0c55c
2019-07-13 10:07:03 +02:00
Kubernetes Publisher
499fb3ff94 Merge pull request #79843 from sttts/sttts-sample-apiserver-openapi
apiserver: wire OpenAPI into sample-apiserver

Kubernetes-commit: 6cd0392ced5a14409c0dd074bdb8b9c33a433f06
2019-07-13 02:36:59 +00:00
Dr. Stefan Schimanski
7193bad8b3 Update vendor
Kubernetes-commit: 406fbf7d7e38aeaab429530e8ec14431012fe83d
2019-07-11 18:36:38 +02:00
Kubernetes Publisher
7e60a2b0fb Merge pull request #79081 from nikhita/generate-groups-executable
Fix update-codegen.sh for staging repos to not rely on scripts being executable

Kubernetes-commit: 1bf7103ea07f8fe0013e9dcc626dda0e01e26afd
2019-07-12 10:39:56 +00:00
Nikhita Raghunath
e6f1262c36 sample-controller: add note about fetching deps in README
Kubernetes-commit: f039c31a9ecc851d78511cf88101375bcab3671d
2019-06-16 23:23:03 +05:30
Nikhita Raghunath
4d46ec53ca Fix scripts to not rely on codegen scripts being executable
If someone doesn't have code-generator in their GOPATH, they'll need to
run `go mod vendor` to populate the vendor directory with the code-generator
repo (it is required by `hack/tools.go`).

However, `go mod vendor` does not mark scripts as executable which leads to a
`Permission denied` error while trying to run `update-codegen.sh` in staging repos.
So fix scripts to not rely on codegen scripts being executable.

Kubernetes-commit: 391da79abd7a7af1cfab04de35daba7cd58c4c80
2019-06-16 22:00:57 +05:30
Kubernetes Publisher
20cb8607d0 Merge pull request #79077 from yuyulei/remove-ratelimiter
add "burst" validation check to code-generator

Kubernetes-commit: c302da4f429f80b9857261bedc17a62069e5b09e
2019-07-12 02:39:28 +00:00
yaqi
d540cbe404 execute hack/update-codegen.sh, sync updates
Kubernetes-commit: aa71695be1006c843de836104006a724451fa9a0
2019-07-11 20:34:59 +08:00
Kubernetes Publisher
4da8e87d08 Merge pull request #78470 from nikhita/security-contacts-psc
Update SECURITY_CONTACTS with current PSC

Kubernetes-commit: 69c94671242c3d17bb32dcdc7ceb5d35535a8f34
2019-07-11 11:04:46 +00:00
Kubernetes Publisher
35c85454ec Merge pull request #79637 from toliu/toliu/update-gophercloud
Update gophercloud vendor dependency to v0.1.0

Kubernetes-commit: 886c5d261f67d74a9d4d5e5f2f31c88dd5c2666f
2019-07-04 05:04:29 +00:00
Kubernetes Publisher
d80646f20d Merge pull request #79306 from vllry/gogo-dep-tag
Updated github.com/gogo/protobuf from v0.5 SHA to v1.0.0 tag

Kubernetes-commit: 03aeab967abccc1da80ff2340f3bccf2131f63d8
2019-07-03 21:14:56 +00:00
Vallery Lancey
3da822eeea Updated github.com/gogo/protobuf from SHA to nearest-pinnable tag (v1.0.0), as part of dependency management cleanup: #79234
Kubernetes-commit: fe59ee8aaf8c7399476d286349caca9e3c05c522
2019-07-02 21:44:06 -07:00
Kubernetes Publisher
2c1d62ad0d Merge pull request #73977 from khenidak/ipv6dualstack
ipv6 dual stack (Phase 1 - ALPHA)

Kubernetes-commit: a33840e0232aaf2b5c14c1c754d9189d7e841ec1
2019-07-03 05:05:55 +00:00
liushi
956b97b782 Update gophercloud vendor dependency to v0.1.0
Kubernetes-commit: 094fed6598b5c5731dd936bb80a85816a24bda53
2019-07-01 02:22:54 -07:00
Khaled Henidak(Kal)
dee1c6a2d7 vendor updates
Kubernetes-commit: 2b776677183502cd2bcba530dbf03bff7d39c057
2019-06-28 20:46:52 +00:00
Kubernetes Publisher
42ee666e1e Merge pull request #79367 from sukeesh/sukeesh/updatedocsgo
Update doc.go in staging/src/k8s.io/

Kubernetes-commit: 583d83a13557fc4ceb68355fa590c194f23a1721
2019-06-29 13:04:47 +00:00
Kubernetes Publisher
d74557ff95 Merge pull request #76124 from tossmilestone/fix-crd-validate-items
Fix CRD validation error on 'items' field

Kubernetes-commit: 1a80962db6fc7138f4d2925a82d7e74cd5ec4fcd
2019-06-27 21:05:29 +00:00
He Xiaoxi
4b4a361452 Bump gopkg.in/check to v1.0.0-20180628173108-788fd7840127
Signed-off-by: He Xiaoxi <xxhe@alauda.io>

Kubernetes-commit: 17ff2eda575686d054ac38b4670be4b4d5a474a0
2019-06-27 11:40:31 +08:00
He Xiaoxi
3ae911415c Bump objx to v0.2.0
Signed-off-by: He Xiaoxi <xxhe@alauda.io>

Kubernetes-commit: fb03e0c46120e5f7505c9bcc2999f39a415ea167
2019-06-27 11:33:27 +08:00
He Xiaoxi
cc2384a2a5 Bump go-openapi dependencies to preferred version
Signed-off-by: He Xiaoxi <xxhe@alauda.io>

Kubernetes-commit: eb2a1c10fad8d1ec0db03283bb156a0e3232607f
2019-06-27 10:42:28 +08:00
He Xiaoxi
470d1589ab Fix CRD validation error for 'items' field
Signed-off-by: He Xiaoxi <xxhe@alauda.io>

Kubernetes-commit: 2e37a3bebe8c4a628e973e231d95c4ce5261c15f
2019-06-26 15:30:49 +08:00
Sukeesh
352bec995b Update doc.go in staging/src/k8s.io/
Kubernetes-commit: c8bd20d1b289eadb6abc20f0868f4a5a6a668035
2019-06-25 22:43:44 +09:00
Kubernetes Publisher
294bc0f668 Merge pull request #79219 from alvaroaleman/sample-controller-klog-init
Sample controller: Init flags

Kubernetes-commit: 9273ce771127c1cf3eb6e1aa4179d857b6522fdf
2019-06-25 13:00:54 +00:00
Kubernetes Publisher
891ba91009 Merge pull request #79303 from liggitt/preferred-deps
Use preferred dependency versions

Kubernetes-commit: dc764030c2cef7aced8dd1a9e3b5ca389223b8b6
2019-06-24 09:04:35 +00:00
Jordan Liggitt
1376d8e0e4 github.com/google/uuid v1.1.1
Kubernetes-commit: 29853a1976d4306593159d369cd8487eeed2b3d6
2019-06-22 11:40:22 -07:00
Alvaro Aleman
5d2271c191 Sample controller: Init flags
Without this, the flags to make klog log to stdout are not even shown.
Figuring out the `InitFlags()` is not very intuitive for ppl new to the
project, which is the target audience of the sample-controller.

Kubernetes-commit: 5f610cea1f30a81c2945d5b0f26210cccbd325d3
2019-06-20 13:18:45 +02:00
Kubernetes Publisher
d4d703847b Merge pull request #78187 from dims/update-vendored-dependencies-to-released-versions-2
Update vendored dependencies to released version

Kubernetes-commit: 00e13dbc12612bd838bc5b9000a64c08f6f8a828
2019-06-20 07:51:13 +00:00
Davanum Srinivas
8b6fa3109e updating gopkg.in/yaml.v2 to v2.2.2
Kubernetes-commit: 1c7bfba9160de8e2449d410bda6f289907136a71
2019-06-14 11:46:38 -04:00
Davanum Srinivas
a928bb1578 updating github.com/stretchr/testify to v1.3.0
Kubernetes-commit: 21fc7d283d900dda76d7f98c6a4b3632659ea6d7
2019-06-14 11:41:28 -04:00
Davanum Srinivas
9ef5c642e2 updating github.com/spf13/pflag to v1.0.3
Kubernetes-commit: 99d5aa759e409864652d11d5a603b4cd2d95ffc2
2019-06-14 11:38:01 -04:00
Davanum Srinivas
b23659240b updating github.com/spf13/cobra to v0.0.4
Kubernetes-commit: 1b401bdab7c2d9de86363adf6a490e35d2f3c832
2019-06-14 11:34:37 -04:00
Davanum Srinivas
1a720f0583 updating github.com/onsi/gomega to v1.5.0
Kubernetes-commit: 37479f975ea0383b771f99c308a762d2ded4b166
2019-06-14 11:20:57 -04:00
Davanum Srinivas
c2287d026f updating github.com/onsi/ginkgo to v1.8.0
Kubernetes-commit: 8629f7fa255d2c7c2d6de2a107a0fd1115b0c9fa
2019-06-14 11:19:15 -04:00
Davanum Srinivas
cabf10decb updating github.com/mholt/caddy to v1.0.0
Kubernetes-commit: a7c552be862234c55721d4a00e76b39500831986
2019-06-14 11:10:45 -04:00
Davanum Srinivas
ba857bede8 updating github.com/json-iterator/go to v1.1.6
Kubernetes-commit: c6b2b45fa98a230d0be5c96270db7058cfaa3b59
2019-06-14 11:04:03 -04:00
Davanum Srinivas
3ee74ca464 updating github.com/google/gofuzz to v1.0.0
Kubernetes-commit: d04014a2087f52d5263dfb7e48a4e223744e813d
2019-06-14 11:00:40 -04:00
Davanum Srinivas
54fabfad23 updating github.com/evanphx/json-patch to v4.2.0+incompatible
Kubernetes-commit: ad2fc6903ae93f77d7c96fc5bc7e7151e0757a2b
2019-06-14 10:51:52 -04:00
Kubernetes Publisher
16471592b1 Merge pull request #78931 from krzysied/revert-78465-bump-klog
Revert "Bump klog to v0.3.2"

Kubernetes-commit: 9b15a5b0700724d2ea1021ceafb72c378b638a0b
2019-06-12 13:08:06 +00:00
Krzysztof Siedlecki
1717e51f20 Revert "Bump klog to v0.3.2"
Kubernetes-commit: 7dcec919a2e5e8e23da3d0dd61276d86c9b0e4b6
2019-06-12 10:27:41 +02:00
Kubernetes Publisher
325dc0a18e Merge pull request #78465 from yuwenma/bump-klog
Bump klog to v0.3.2

Kubernetes-commit: b094dd9bc3a4617b587b04993931a6110691ddc0
2019-05-31 13:48:01 +00:00
Kubernetes Publisher
b2736eaf69 Merge pull request #78327 from caesarxuchao/pointer-remainingItemCount
Make RemainingItemCount a pointer

Kubernetes-commit: d8fd232ea1f8c91092fb5fabb7a0f3d557a2e8fb
2019-05-31 13:48:00 +00:00
Nikhita Raghunath
b7f1f706e4 Update SECURITY_CONTACTS with current PSC
Kubernetes-commit: 42ea492bfdab9fcfd67dd4ea621b8a1a40da550d
2019-05-29 15:22:35 +05:30
yuwenma
496ffc27b0 Bump klog to v0.3.2
Kubernetes-commit: 5cef37433e55827226f20981598ddfa2c6511809
2019-05-28 22:45:19 -07:00
Chao Xu
597a3c0528 generated
Kubernetes-commit: 369314959c1bf096c1d3502f10b28a00c3d12691
2019-05-24 17:46:39 -07:00
Kubernetes Publisher
ee0fa8a6f6 Merge pull request #78216 from mtaufen/update-klog
Update klog to v0.3.1

Kubernetes-commit: 25b0d2dbf4521bd1e7bae471d85c369eb89f9555
2019-05-28 16:05:00 +00:00
Michael Taufen
10ba054641 Update klog to v0.3.1
Includes recent fixes, notably https://github.com/kubernetes/klog/pull/66

Kubernetes-commit: ee7bcc53a206f669b057e38a477b51b3477aab23
2019-05-22 10:51:33 -07:00
Kubernetes Publisher
2407a19d13 Merge pull request #77751 from baasbank/fix-lint-errors-staging/src/k8s.io
Fix lint errors staging/src/k8s.io

Kubernetes-commit: 6a40ed1005f085365ada73ce7c5e00df5046a1ad
2019-05-15 14:42:05 +00:00
Kubernetes Publisher
567c0e89da Merge pull request #70929 from mikedanese/cmp
migrate everything to unify diff.Diff method using cmp

Kubernetes-commit: 1ae09a371faccfc193f9b8d82a9ef77bf3e7fb14
2019-05-15 02:44:42 +00:00
Baasbank
c0d85825ce fixes golint error in staging/src/k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1
fixes golint error in staging/src/k8s.io/sample-controller/pkg/apis/samplecontroller

fixes golint errors in staging/src/k8s.io/sample-apiserver/pkg/cmd/server

fixex golint errors in staging/src/k8s.io/sample-apiserver/pkg/apiserver

Kubernetes-commit: 55d45867e6a8b6336be0c56da0b4843dd552b1b0
2019-05-03 23:10:40 +01:00
Mike Danese
73417f1c72 vendor github.com/google/go-cmp
Kubernetes-commit: 76f683a8f3dc2977846e16b2ea14208a51c2cb6b
2019-04-22 21:41:46 -07:00
Kubernetes Publisher
0d5581c413 Merge pull request #77753 from liggitt/prune-replace
Prune matching replace directives in staging repos more effectively

Kubernetes-commit: 6f6890b09e2a8ae7eaaea0a5052d45c3960e1c76
2019-05-11 02:44:43 +00:00
Jordan Liggitt
aa060187a6 generated files
Kubernetes-commit: eb82dddfdd504c2956ec438b739e01230067e90f
2019-05-10 15:41:34 -04:00
Kubernetes Publisher
f9c23632fb Merge pull request #77070 from feiskyer/autorest-update
Upgrade go-autorest to v11.1.2

Kubernetes-commit: 9e29c3e39f916fe67654c9e06ada23e42217e532
2019-04-25 17:35:25 +00:00
Pengfei Ni
cb17f23e9b Upgrade go-autorest to v11.1.2
Kubernetes-commit: 7976402a8716fa269346f104dbf1fc91af56c7c8
2019-04-25 16:51:30 +08:00
Kubernetes Publisher
22e77cb295 Merge pull request #76888 from mrkm4ntr/using-with-kind
Create GroupVersionKind with simpler way

Kubernetes-commit: fbc60b29333abc92859bcc01a164fa956a2a2835
2019-04-24 13:32:03 +00:00
Kubernetes Publisher
db05ffadea Merge pull request #76914 from tsuna/master
vendor: update golang.org/x/oauth2

Kubernetes-commit: 219b166cb172344ee666a107161c07ba3805bd67
2019-04-24 05:35:40 +00:00
Benoit Sigoure
2b45d4a00f vendor: update golang.org/x/oauth2 and cloud.google.com/go
Pick up the bug fix for golang/oauth2#237
Bump up cloud.google.com/go as a result of updating the OAuth2 code.

This commit was generated by:
./hack/pin-dependency.sh golang.org/x/oauth2 9f3314589c9a
./hack/pin-dependency.sh cloud.google.com/go v0.34.0
./hack/update-vendor.sh
git add vendor
git add -u

Kubernetes-commit: ef492e2d70385c43c5f1dad203ce635b40699341
2019-04-22 16:07:52 -07:00
Shintaro Murakami
e3d37f6957 Create GroupVersionKind with simpler way
Kubernetes-commit: e9906dc36246889478db999b5b44c2df48176100
2019-04-22 15:01:05 +09:00
Kubernetes Publisher
fcf1ad8faf Merge pull request #76474 from vincepri/update-klog-030
Update klog to 0.3.0

Kubernetes-commit: 17fe18bd9cc5652a5dee688255323ce2d07538dd
2019-04-18 21:36:16 +00:00
Vince Prignano
976a1973f5 Update klog to 0.3.0
Signed-off-by: Vince Prignano <vincepri@vmware.com>

Kubernetes-commit: 3f552264ca28a4738c77ebed8414d0d2dc8e7063
2019-04-11 15:57:45 -07:00
Kubernetes Publisher
dc28f4c8a0 Merge pull request #76652 from liggitt/ginkgo
github.com/onsi/ginkgo v1.6.0

Kubernetes-commit: e4a43656074e36d1529d4ca0bc3db451f2cde257
2019-04-17 21:35:15 +00:00
Jordan Liggitt
68118d2e39 github.com/onsi/ginkgo v1.6.0
Kubernetes-commit: 56b19637052d58b57844f5dd579de3923f1c7d6a
2019-04-16 10:28:44 -04:00
Kubernetes Publisher
85928f7c36 Merge pull request #76610 from liggitt/bump-proto
github.com/gogo/protobuf v0.0.0-20171007142547-342cbe0a0415

Kubernetes-commit: 701e36bd5bc265174ac9c4ce983dcc044e5bad53
2019-04-16 05:34:38 +00:00
Kubernetes Publisher
8091df96ee Merge pull request #76550 from sttts/sttts-code-gen-tools-complete
code-generator: complete tools.go

Kubernetes-commit: ef8aa4fd7fbb1c06db1fc1059a077d7c0fc59cfe
2019-04-16 01:31:49 +00:00
Jordan Liggitt
93c4ff39a7 github.com/gogo/protobuf v0.0.0-20171007142547-342cbe0a0415
Kubernetes-commit: 7a6d64a3e930120dddc78ad0d12493ea70469ffa
2019-04-15 10:58:44 -04:00
Kubernetes Publisher
101b1d38d3 Merge pull request #76559 from liggitt/bump-prometheus
bump github.com/prometheus/client_model, github.com/prometheus/profcs to preferred versions

Kubernetes-commit: 117160a9e2282aeac36e8b31f655f070202e09c7
2019-04-15 13:35:09 +00:00
Dr. Stefan Schimanski
5e35b68365 Update vendor
Kubernetes-commit: 4d291aec7ebdcab77c91897a3082faf985a01066
2019-04-15 13:40:15 +02:00
Jordan Liggitt
f2b6a42afa github.com/golang/protobuf v1.2.0
Kubernetes-commit: 12d66f6d640e7480fadabcb552762879228ecf1f
2019-04-14 00:43:05 -04:00
Kubernetes Publisher
c3f29151fa Merge pull request #76522 from liggitt/prune-replace
Prune replace directives

Kubernetes-commit: e68888384bc3e6310a54d0a516419394bf6e9aba
2019-04-13 05:34:47 +00:00
Jordan Liggitt
0465cb5b31 generated: hack/update-vendor.sh
Kubernetes-commit: 498959accc060c81536101f7dd570289f4f8c0f2
2019-04-12 16:38:00 -04:00
Kubernetes Publisher
441cf4cebb Merge pull request #76384 from xichengliudui/update-readme
Update README.md files in sample-controller

Kubernetes-commit: 3088a3f2001b2159123b7748304e142ca693985c
2019-04-12 13:32:35 +00:00
aaa
3c6310ad91 Update README.md files in sample-controller
Kubernetes-commit: ba1d992ebdf36514ef65b76d23ecc2c587f8b0af
2019-04-09 08:52:57 -04:00
Kubernetes Publisher
ef739b027d Merge pull request #76215 from liggitt/update-vendored-dependencies
Update vendored dependencies

Kubernetes-commit: 1cca3f9d45a6aae62145b8630e36722bd316ef88
2019-04-09 09:35:16 +00:00
Jordan Liggitt
c186185446 golang.org/x/exp v0.0.0-20190312203227-4b39c73a6495
Kubernetes-commit: 27030079f3a224348315c2583f70bb71c30793da
2019-04-06 11:34:54 -04:00
Jordan Liggitt
3a6f42853f golang.org/x/tools v0.0.0-20190313210603-aa82965741a9 (release-branch.go1.12)
Kubernetes-commit: 389f76235cb8e2457d681d07c89d1342cee13b3b
2019-04-06 11:11:39 -04:00
Jordan Liggitt
d38db23448 golang.org/x/crypto v0.0.0-20181025213731-e84da0312774 (release-branch.go1.12)
Kubernetes-commit: 97c130b0560982556f54dc83d38d9e70e8be9320
2019-04-06 10:20:37 -04:00
Jordan Liggitt
e1c112e2dc golang.org/x/sys v0.0.0-20190209173611-3b5209105503 (release-branch.go1.12)
Kubernetes-commit: 921f3ea8da0a29cd9b06413439485b36ef6426b6
2019-04-05 14:20:21 -04:00
Jordan Liggitt
2266ddf697 golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db (release-branch.go1.12)
Kubernetes-commit: 55d52fd5c35351c221f055ab08f3855ab5782b0d
2019-04-05 11:18:45 -04:00
Jordan Liggitt
69a80d7213 gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485
Kubernetes-commit: 5af2cd6f26ce01294ceff8292fcc1b217c6978b0
2019-04-06 11:02:15 -04:00
Jordan Liggitt
596deb01cd github.com/stretchr/objx v0.1.1, github.com/stretchr/testify v1.2.2
Kubernetes-commit: e8e15acff61ee4e291396e37081c6137ec33ad5d
2019-04-06 10:39:05 -04:00
Jordan Liggitt
3998023e49 github.com/pmezard/go-difflib v1.0.0
Kubernetes-commit: 65a6613fe2c1094eba8c6e33d4df861e45af938d
2019-04-05 13:26:32 -04:00
Jordan Liggitt
d63b2b054d github.com/pborman/uuid v1.2.0
Kubernetes-commit: e2e1f497d09cc931c59ba5f9b20e3d912b4cb4fc
2019-04-05 11:51:23 -04:00
Jordan Liggitt
103e6c79fa github.com/davecgh/go-spew v1.1.1
Kubernetes-commit: 8ad7a9595a94593fed9570b7151ddaa858c2f499
2019-04-05 11:21:58 -04:00
Kubernetes Publisher
7f34571e04 Merge pull request #76197 from liggitt/generated-vendor
Mark staging go module files as generated, add script to lint dependencies

Kubernetes-commit: 8a2f8e69ed0cfaae38cf7a40cc40b71a36ff319b
2019-04-08 17:34:20 +00:00
Jordan Liggitt
b9ff0dd035 generated: hack/update-vendor.sh
Kubernetes-commit: ce3dad93f51b8c793661bf4c5cb9f7677d2bc7aa
2019-04-08 09:24:24 -04:00
Kubernetes Publisher
a78a0761c9 Merge pull request #76162 from nikhita/bump-gengo
Bump gengo to avoid large errors in verify logs

Kubernetes-commit: 223f355ba47e20affd41d035c7fc1e471f5a2acf
2019-04-05 17:34:27 +00:00
Kubernetes Publisher
7b50e7befb Merge pull request #76153 from liggitt/update-vendor-cleanup
Update vendor cleanup

Kubernetes-commit: 470bda42c382ff0c02ac9fd5cbfcd4ee5e081cb1
2019-04-05 09:34:19 +00:00
Kubernetes Publisher
53f75f7a62 Merge pull request #76098 from smarterclayton/move_direct_encoder
Move DirectEncoder to runtime, rename, add .WithoutConversion() on CodecFactory

Kubernetes-commit: 28295b0e784ab1f9f1a1aada5955bbf224cf59cc
2019-04-05 05:34:24 +00:00
Nikhita Raghunath
3cb4ddb060 bump(k8s.io/gengo): f8a0810f38afb8478882b3835a615aebfda39afa
Kubernetes-commit: 2095ac9b069ef9fec8e7c0dd4836357b0914124c
2019-04-04 23:50:06 +05:30
Kubernetes Publisher
caada51cd7 Merge pull request #71049 from booxter/expose-tracker-for-fake-simpleclientset
Expose object tracker for fake clientsets

Kubernetes-commit: 4da579b68abb7a5a737a7d4350006e5b13b03ddc
2019-04-04 17:32:30 +00:00
Jordan Liggitt
39cd2ae62a generated
Kubernetes-commit: f5ea2344ae69015f6970dd045ea6087e9cbe7121
2019-04-04 11:51:03 -04:00
Clayton Coleman
6a05ad71cc Use CodecFactory.WithoutConversion() everywhere
Clarifies that requesting no conversion is part of the codec factory, and
future refactors will make the codec factory less opionated about conversion.

Kubernetes-commit: 7f9dfe58f4cbe1e1b9e80f52addff70bac87bed4
2019-04-03 13:24:37 -04:00
Ihar Hrachyshka
5a81ef4b43 Expose object tracker for fake clientsets
Not every object kind can be registered via tracker .Add() called as
part of SimpleClientset initialization. This is because .Add() relies
on UnsafeGuessKindToResource to convert object kinds into resource
type names, which is broken for some resources. An example of an
affected kind is NetworkAttachmentDefinitions CRD that uses
network-attachment-definitions as its resource type name. When
UnsafeGuessKindToResource is called for this kind, it returns
networkattachmentdefinitions (without dashes).

As per the comment inside .Add, kinds affected by
UnsafeGuessKindToResource deficiencies should instead register objects
using tracker .Create() method.  Problem is, current SimpleClientset
struct definition doesn't expose the object tracker in any way, which
makes it impossible to properly register these kinds at all.

To address the issue, this change modifies the definition of
SimpleClientset struct to expose the object tracker used via Tracker()
method.

Kubernetes-commit: d68cd8a0c7e6137ca4219078a3d651ecff03c21f
2018-11-14 15:22:48 -08:00
Kubernetes Publisher
88ec96fa3c Merge pull request #74877 from liggitt/go-mod-cleanup
add go module support, manage vendor directory using go modules

Kubernetes-commit: d920430ce4a9140102d06664c6aa1cd6792cab05
2019-04-04 07:10:41 +00:00
Jordan Liggitt
c5f4c70a7e generated: hack/update-vendor.sh
Kubernetes-commit: d0261b10770210f83edbcfe379db24e1b82a9e86
2019-04-01 11:07:04 -04:00
Jordan Liggitt
5a1e099fb5 Add staging tools.go imports
Kubernetes-commit: 579c0560a280eae60d245cb3a30b8680270590d9
2019-03-22 17:55:40 -04:00
Kubernetes Publisher
b8f621986e Merge pull request #75657 from guilhermeoki/docs/sample-controller
sample-controller: update README

Kubernetes-commit: e7eb742c1907eb4f1c9e5412f6cd1d4e06f3c277
2019-03-26 03:06:54 +00:00
Guilherme Oki
59c098b8b3 sample-controller: update README
Kubernetes-commit: 54e3f0f8a936935459f9087c73ec09f1f3f2e02d
2019-03-25 00:12:53 -03:00
Kubernetes Publisher
0e5b089d85 Merge pull request #75577 from mars1024/bugfix/use_add_in_enqueue
replace AddRateLimited with Add in enqueue func

Kubernetes-commit: ab35bd06689744ee275fbec4d43cc7a30f5cca4d
2019-03-22 11:09:11 +00:00
Bruce Ma
7047ee6cec replace AddRateLimited with Add in enqueue func
Kubernetes-commit: 0335867b564f4791ccca56f20b8d06226f991d15
2019-03-22 11:40:23 +08:00
Kubernetes Publisher
77d4e190a1 Merge pull request #75289 from dims/update-http2-dep-go-1.12
Update golang.org/x/net/... dependencies to release-branch.go1.12

Kubernetes-commit: e7d09ceb5019153831b4921ff35a170e46f634d2
2019-03-13 12:21:06 +00:00
Davanum Srinivas
a9b00b7da9 Update to go 1.12 version of golang.org/x/net
Change-Id: I3f2fa5d7b6811c9eca58992318d19e44ec9131fd

Kubernetes-commit: 2aa1348e6cf4d51f91025c41d41bb7e3b9b9384d
2019-03-12 09:16:45 -04:00
Prasad Ghangal
966c42f959 Update golang.org/x/net/... dependencies to release-branch.go1.11
- latest grpc-ecosystem/go-grpc-middleware

Change-Id: Ida7d01e4606f6e0313e1355db6e85be0c0ef1dd1

Kubernetes-commit: 317ecf58cc706c8851834f3b669d80a8628148c6
2019-01-07 18:29:55 +05:30
Kubernetes Publisher
14de2034cd sync: update godeps 2019-03-11 16:24:17 +00:00
Kubernetes Publisher
d1d2c6e6c5 Merge pull request #75201 from joelsmith/secdoc
Update embargo doc link in SECURITY_OWNERS and change PST to PSC

Kubernetes-commit: 8bde75e63f9313fdc1d4f9a806b4b3a8ea128565
2019-03-09 00:05:20 +00:00
Joel Smith
0bc81f833b Also update SECURITY_CONTACTS from staging
Kubernetes-commit: 7fd6ea47e8fd53dd4e152e59094628ad794e7d4a
2019-03-08 11:23:24 -07:00
Kubernetes Publisher
5833ea29bd Merge pull request #74433 from tallclair/runtimeclass-internal
Migrate RuntimeClass from a CRD to an internal API

Kubernetes-commit: 183e6cc1902c2088a40e60cf4138bd829d4ad80f
2019-03-08 08:12:47 +00:00
Tim Allclair
4827b21b91 generated files
Kubernetes-commit: 428e9fa3299161be420fcfa7987d0e37aca3ea01
2019-03-06 14:36:30 -08:00
Kubernetes Publisher
19a01d911e Merge pull request #74837 from mtaufen/godep-klog
Update klog dependency

Kubernetes-commit: eb95c27a5574e6ac2b166f9a6942226087c351e0
2019-03-07 17:28:40 +00:00
Michael Taufen
899a75f5a2 Update klog dependency
Kubernetes-commit: 4a4c1a62390d3538dea9610a1af1e67903702a27
2019-03-01 16:39:39 -08:00
Kubernetes Publisher
0fe836eb81 Merge pull request #74795 from sttts/sttts-kube-openapi-149
kube-openapi: revendor to fix integer handling

Kubernetes-commit: 979bef156a8bfff112ab51292e38e036172d5f82
2019-03-01 17:48:42 +00:00
Dr. Stefan Schimanski
b65d928d55 Update staging godeps
Kubernetes-commit: b7f11084fa563f2b30315afd4fc69a52d2b2434f
2019-03-01 09:52:34 +01:00
Kubernetes Publisher
ae0b388779 Merge pull request #74422 from liggitt/client-version-methods
Remove deprecated versionless client interface methods

Kubernetes-commit: be8a9b96377973f0a956a11d55be4929bbf9ffd0
2019-02-26 21:59:33 +00:00
Jordan Liggitt
d4529fcb10 Regenerate clients
Kubernetes-commit: 93be54b28801dbffbc48fcb6018f99beadae51da
2019-02-21 13:50:12 -05:00
Kubernetes Publisher
034514e798 Merge pull request #74328 from daixiang0/delete-blank
delete all duplicate empty blanks

Kubernetes-commit: 8993fbc543c18e73668793b5d5e234c0a136735c
2019-02-23 13:58:28 +00:00
Kubernetes Publisher
1601268db2 Merge pull request #71896 from awly/client-go-keyutil
client-go: extract new keyutil package from util/cert

Kubernetes-commit: b5566c781843a1a8c19993632700e476708a9cee
2019-02-23 13:58:04 +00:00
Kubernetes Publisher
51178b03e7 Merge pull request #73555 from bsalamat/priority_to_ga
Graduate PriorityClass API to GA

Kubernetes-commit: 3afa003126ff50092954839efbe10d584c2511ff
2019-02-23 02:09:23 +00:00
Kubernetes Publisher
28ef9f29f9 Merge pull request #74348 from danielqsj/ku
update k8s.io/utils to fix keymutex issues

Kubernetes-commit: d9f3e96796e2d154b1d4caa156ba95ff9b01e5b2
2019-02-22 09:58:33 +00:00
danielqsj
92d2378754 Update k/utils dependency in staging
Kubernetes-commit: b9ef1dd50b8db18fa3a2558289caa4e75f116260
2019-02-22 10:30:38 +08:00
Xiang Dai
05b6c587ae delete all duplicate empty blanks
Signed-off-by: Xiang Dai <764524258@qq.com>

Kubernetes-commit: 36065c6dd717c14e0a90131041e20345a7e5e324
2019-02-22 09:43:51 +08:00
Kubernetes Publisher
2305ad46fc Merge pull request #74057 from liggitt/ingress-network-v1beta1
Ingress extensions/v1beta1 -> networking.k8s.io/v1beta1

Kubernetes-commit: 7d75b73e1d72cef7a0f0e2804f8e0a582ccb6b61
2019-02-21 10:03:40 +00:00
Kubernetes Publisher
0b3639eedf Merge pull request #74260 from stafot/update-vendor-dependencies
Update vendor package github.com/hashicorp/golang-lru

Kubernetes-commit: a2592364be3f4f9943f841182b27d0c62050a84a
2019-02-21 10:03:17 +00:00
Bobby (Babak) Salamat
be0c2ac54e generated files
Kubernetes-commit: 1dac6d03e3645ddcfdb00d84c158f7995cac94c8
2019-02-20 12:42:15 -08:00
Jordan Liggitt
261576c6dd generated files
Kubernetes-commit: f139218ac0711023a85db6ce43d59ad1775a9705
2019-02-14 00:28:24 -05:00
Andrew Lytvynov
37209aa01e Extract new keyutil package from client-go/util/cert
This package contains public/private key utilities copied directly from
client-go/util/cert. All imports were updated.

Future PRs will actually refactor the libraries.

Updates #71004

Kubernetes-commit: 18458392ca24c85c688e655aace1afd04f864cbd
2018-12-09 16:24:38 -08:00
Stavros Foteinopoulos
e124f1f28f Update vendor package github.com/hashicorp/golang-lru
Kubernetes-commit: df3fbf9295cb8d650d2e951ae46099d07e2130d2
2018-11-07 15:19:34 +02:00
Kubernetes Publisher
ce638bb1aa Merge pull request #74130 from sttts/sttts-sample-generated-pkg
sample-{apiserver,controller}: move generated file into pkg/generated

Kubernetes-commit: 4e54d7ba26a5404c5027297ae864e61012dd8eac
2019-02-16 01:51:19 +00:00
Kubernetes Publisher
1afb5d43d5 Merge pull request #73699 from pivotal-k8s/doc-links
Update deprecated and broken links

Kubernetes-commit: fbee96d733ad941e94cd2a4726c65ddb3c71a21d
2019-02-16 01:50:56 +00:00
Kubernetes Publisher
f232764143 Merge pull request #71512 from rkamudhan/patch-1
Update the go get to k8s.io/sample-controller

Kubernetes-commit: b0f65ca1cfd322128f7a3c1676f668acab551ffc
2019-02-15 17:44:40 +00:00
Dr. Stefan Schimanski
574892d56c Update generated code
Kubernetes-commit: 714b28cf22133d39bd637f8b0e6d5774a4eff415
2019-02-15 13:35:58 +01:00
Dr. Stefan Schimanski
84833d0138 sample-controller: adapt to package moves
Kubernetes-commit: b671a06e46ced532c76136474afa8e88a136e99f
2019-02-15 13:08:42 +01:00
Dr. Stefan Schimanski
8f7a02cc01 sample-controller: generate into pkg/generated package
Kubernetes-commit: 4f0e9467b96b88e8ec3b7bd8593700e99634d007
2019-02-15 13:09:16 +01:00
Kubernetes Publisher
2fb0948fde Merge pull request #73976 from jennybuckley/apply-errors
Make server-side apply's conflict errors more human readable

Kubernetes-commit: 62734d36705f3b0bb2a1a6fc9cf00b5206fede20
2019-02-15 04:20:42 +00:00
Kubernetes Publisher
347c2688d7 Merge pull request #72214 from caesarxuchao/move-discovery
Move cached discovery clients to their own packages

Kubernetes-commit: d8f014613865955b7e4ce6fefbf38a3c8fe97971
2019-02-14 07:56:42 +00:00
jennybuckley
fb0d8cffef Update generated
Kubernetes-commit: 7dba6fe90dde7724a0361a2a723c3255fdb23bcc
2019-02-12 15:16:43 -08:00
Ben Moss
ae6c030c2a Update deprecated links
Kubernetes-commit: 34ac4d9ee9fed65d770403fff4cb037253fc5d09
2019-02-04 13:28:31 -05:00
Chao Xu
e8f23bda6e generated
Kubernetes-commit: 1f2e2e61cf088cb0070fea4b88d9cefb7f8f2e3e
2018-12-19 13:52:12 -08:00
Kubernetes Publisher
713d159512 Merge pull request #71223 from sttts/sttts-openapi-aggreation-without-clone
openapi-aggregation: speed up merging from 1 sec to 50-100 ms

Kubernetes-commit: 6912bbb153ef53a0ece34e7dae74ca79bfc07b82
2019-02-11 21:33:01 +00:00
Dr. Stefan Schimanski
92637fbe63 Update staging godeps
Kubernetes-commit: 233178eec68573fc317523c8ce2b1409b9524e96
2019-02-09 17:49:59 +01:00
Kubernetes Publisher
717147646c Merge pull request #73540 from rlenferink/patch-5
Updated OWNERS files to include link to docs

Kubernetes-commit: b50c643be0cd528e438cd985384e229bd263d0e5
2019-02-08 17:30:43 +00:00
Kubernetes Publisher
765ad16233 Merge pull request #73713 from caesarxuchao/bump-json-patch-again
Importing the latest json patch and set the accumulated copy size limit

Kubernetes-commit: b00b5d4ac00cab50b50554ce2a9212e1cd689496
2019-02-07 09:31:55 +00:00
Kubernetes Publisher
cfd89cde21 Merge pull request #72947 from apelisse/wip-feature-serverside-apply-merge
Merge feature-serverside-apply back in master

Kubernetes-commit: 2a5a41a08b08075aa2960170c8342d974ccc2cd3
2019-02-05 05:30:45 +00:00
Chao Xu
e81d2102ff Importing latest json-patch.
Kubernetes-commit: b8911b8d79f7ca4030c6e2cdff9f873a47848021
2019-02-04 09:47:54 -08:00
Roy Lenferink
7a965bdb19 Updated OWNERS files to include link to docs
Kubernetes-commit: b43c04452f3b563473b5c2a765d4ac18cc0ff58f
2019-01-30 20:05:00 +01:00
Antoine Pelisse
3787f3c1f6 Run generation scripts
Kubernetes-commit: 5949154ec55e13be6877fb4aa17b89652b82c6f8
2019-01-29 14:26:39 -08:00
Kubernetes Publisher
192a614242 Merge pull request #73455 from danielqsj/keymutex
Migrate to k8s.io/utils/keymutex and k8s.io/utils/strings

Kubernetes-commit: 8f1082c6aff6df3cb5e103474d9d846b6f8ebf90
2019-01-31 09:56:19 -08:00
Kubernetes Publisher
6dfb0e8ec7 Merge branch 'master' into keymutex
Kubernetes-commit: e72b32558c8e9ed16690ef5a8e909c12fcc47f87
2019-02-01 15:25:31 +00:00
Kubernetes Prow Robot
f55470f1d9 sync: squashed up to merge 1f7e9fd9a2b31ee21babef2cbdd18caeb8c14cdc in e72b32558c8e9ed16690ef5a8e909c12fcc47f87 2019-02-01 15:25:01 +00:00
danielqsj
1fa7ebb984 Update vendor/k8s.io/utils
Kubernetes-commit: 257ae4da008964786bbc55e39cbd4c6121cebde6
2019-01-29 17:53:19 +08:00
Kubernetes Publisher
eb58fda54a Merge pull request #73212 from danielqsj/samplecontroller
fix shellcheck in sample-controller

Kubernetes-commit: 6ebe874d11dc04972d74904e0cf2b15506ea318a
2019-02-01 15:25:01 +00:00
Kubernetes Publisher
abcd26d668 Merge pull request #73308 from krzysied/reflector_trace2
Adding trace to reflector initialization

Kubernetes-commit: f5f5d9a54a6397012b780e1714abf7d8b4f5037c
2019-01-26 17:11:25 +00:00
Krzysztof Siedlecki
da16a67695 adding dependencies
Kubernetes-commit: 91d9f7f0c0052ee67253e7d1afe2a51a848cb5d6
2019-01-25 12:53:24 +01:00
Kubernetes Publisher
3095c2b11e Merge pull request #73243 from andrewsykim/update-utils-vendor
Update vendor k8s.io/utils and remove internal utils

Kubernetes-commit: 2cbb16bc8dd456c5db72c1667926abdbc87c32c7
2019-01-26 17:11:03 +00:00
Kubernetes Publisher
11d2fee50c Merge pull request #72972 from liggitt/remove-alpha-initializers
Remove use of alpha initializers

Kubernetes-commit: e28c757e8758638811130848abe7a47f760057c0
2019-01-26 17:10:41 +00:00
Kubernetes Publisher
955fe458eb Merge pull request #73217 from kubernetes/revert-73071-reflector_trace
Revert "Adding trace to reflector initialization"

Kubernetes-commit: a5d55f49b0f480b5bfe9fc40c9a07d9c04c117fd
2019-01-26 17:10:19 +00:00
Andrew Kim
5cd6257fee vendor k8s.io/utils to 8a87304934321b4b0ad72a7cb3cbc715d67d38c7
Kubernetes-commit: e321cdaee4bf22bce018011884af33ea16fa5b62
2019-01-23 21:19:50 -05:00
Wojciech Tyczynski
96c09e7697 Revert "Adding trace to reflector initialization"
Kubernetes-commit: c8d89b34cc692c4b477fe40ac4511be73a581629
2019-01-23 14:50:37 +01:00
danielqsj
7ec2c1043b fix shellcheck in sample-controller
Kubernetes-commit: 078115a604fb4e89123b4a4e12530fd823abeb88
2019-01-23 20:56:25 +08:00
Kubernetes Publisher
16271d1c70 Merge pull request #73071 from krzysied/reflector_trace
Adding trace to reflector initialization

Kubernetes-commit: fd0df59f5ba786cb25329e3a9d2793ad4227ed87
2019-01-22 05:15:55 -08:00
Krzysztof Siedlecki
bc3b41b4f2 adding dependency
Kubernetes-commit: e2a017327c1af628f4f0069cbd49865ad1e81975
2019-01-18 15:04:47 +01:00
Kubernetes Publisher
39f0f6c7c1 Merge pull request #73076 from yastij/refactor-events
refactor util functions for event recording

Kubernetes-commit: 193f659a1cd454b93cbe1e7b1f13b77c21783461
2019-01-19 02:39:10 +00:00
Kubernetes Publisher
59dd5ff32c Merge pull request #72138 from dims/switch-location-for-goautoneg
Switch location for goautoneg vendored code

Kubernetes-commit: ef2a5b948b0d6c422873a823755ee7d12284dcc3
2019-01-19 02:38:42 +00:00
Yassine TIJANI
049851c2f4 refactor util functions for event recording
Kubernetes-commit: 7296288928d347dfb1dcb990d779cdfce96ead1b
2019-01-18 15:28:37 +01:00
Jordan Liggitt
1c2764f53e Remove alpha InitializerConfiguration types, Initializers admission plugin
Kubernetes-commit: dc1fa870bff65c20f48a83ea3af54adb3f526e28
2019-01-16 10:19:44 -05:00
Kubernetes Publisher
c3a5aa93b2 Merge pull request #72239 from wojtek-t/v1_lease_api
Promote Lease API to v1

Kubernetes-commit: 5354f8bdfeeb14e52abb8bac4c24993f1addbfb1
2018-12-21 20:05:18 +00:00
wojtekt
994e8982d1 Autogenerated code
Kubernetes-commit: 9664779bdd99b84ff13b6dcd9d2dc72fd3831d7b
2018-12-20 11:56:54 +01:00
Kubernetes Publisher
9925b3e980 Merge pull request #72193 from kargakis/owners
Remove myself from OWNERS where I am not active

Kubernetes-commit: 544c49ab030a8930f3a6903de232473e0bf4e8e5
2018-12-19 19:16:19 +00:00
Michalis Kargakis
e029e15793 Remove myself from OWNERS where I am not active
Kubernetes-commit: c602a9ed4ffba92a229dcc45f1a9e3036596d90b
2018-12-19 10:19:22 +01:00
Davanum Srinivas
bc1f9127bf Switch location for goautoneg vendored code
Move to github.com/munnerz/goautoneg as bitbucket is flaky!

Change-Id: Iaa6e964ef0d6f308eea59bcc6f365ecd7dbf0784

Kubernetes-commit: 16fd72d6c91ba466a0e955a1d59a6c8d9e8791bc
2018-12-17 20:39:56 -05:00
Kubernetes Publisher
65d042cac5 Merge pull request #70995 from stewart-yu/stewart-sample-controller-redurabce-import
remove duplicated import

Kubernetes-commit: 163b54dc4d615bc34bf14c74e9230b733d8b4565
2018-11-29 23:25:01 +00:00
Kuralamudhan Ramakrishnan
bef4a2dcb7 Update the go get to k8s.io/sample-controller
Referring to the issue: https://github.com/kubernetes/sample-controller/issues/20#issuecomment-398716033

Kubernetes-commit: 6d631e32f281949e1b31e65e0cbd203be39a1c6f
2018-11-28 15:36:01 +00:00
Kubernetes Publisher
d17738308f Merge pull request #71296 from cblecker/json-iterator-bump
Update github.com/json-iterator/go to 1.1.4

Kubernetes-commit: 18619f0849b18944300cb22c224afe071d4317bd
2018-11-21 07:26:00 +00:00
Christoph Blecker
9cab99a527 Update github.com/json-iterator/go to 1.1.4
Kubernetes-commit: c7d39519279937693e654149eb6b67af46836135
2018-11-20 18:13:01 -08:00
Kubernetes Publisher
e943f6752e Merge pull request #70998 from deads2k/client-07-listwatchtimeout
update the client generator to set a client-side timeout

Kubernetes-commit: 9878253c3cb8fa4699615b41375578fe681b0f9a
2018-11-16 23:23:45 +00:00
David Eads
a5c672885d generated
Kubernetes-commit: 8f7edec615fb9cd722b7f8310dab3efa25351b7c
2018-11-16 08:38:57 -05:00
stewart-yu
4a9e8aba65 remove duplicated import
Kubernetes-commit: 217dbeafaf3293d193d6bdf3a8a220329d55dfe9
2018-11-13 20:08:39 +08:00
Kubernetes Publisher
ff6be62b4c Merge pull request #70889 from dims/update-cadvisor-and-other-repos-for-klog-take-2
Update cadvisor and other repos for klog

Kubernetes-commit: a3ccea9d8743f2ff82e41b6c2af6dc2c41dc7b10
2018-11-10 19:25:14 +00:00
Davanum Srinivas
ff201e3f3b Update all the staging Godeps.json
Change-Id: I64b30c68a606b4f5c095a66496a1e48c4d62ea88

Kubernetes-commit: 68ce375d0039738df5a2a837122215f3224f1fde
2018-11-09 16:41:26 -05:00
Davanum Srinivas
a508a6c07c Move from glog to klog
- Move from the old github.com/golang/glog to k8s.io/klog
- klog as explicit InitFlags() so we add them as necessary
- we update the other repositories that we vendor that made a similar
change from glog to klog
  * github.com/kubernetes/repo-infra
  * k8s.io/gengo/
  * k8s.io/kube-openapi/
  * github.com/google/cadvisor
- Entirely remove all references to glog
- Fix some tests by explicit InitFlags in their init() methods

Change-Id: I92db545ff36fcec83afe98f550c9e630098b3135

Kubernetes-commit: 954996e231074dc7429f7be1256a579bedd8344c
2018-11-09 13:49:10 -05:00
Kubernetes Publisher
af94dada8b Merge pull request #70598 from dims/switch-from-sigs.k8s.io/yaml-to-ghodss/yaml
Switch to sigs.k8s.io/yaml from ghodss/yaml

Kubernetes-commit: f212b9db236344d3121879e609d53b79f9f106f9
2018-11-08 20:14:56 +00:00
Kubernetes Publisher
a743781f59 Merge pull request #70718 from cblecker/godep-round-a-million
Fork godep to fix inconsistent abbreviation size

Kubernetes-commit: e998d6c2bc83385d98186a87e95a0f947e121ec1
2018-11-08 05:37:47 +00:00
Kubernetes Publisher
f0dafbb5a8 Merge pull request #70663 from wenjiaswe/gonet110
Upgrade golang.org/x/net image to release-branch.go1.10

Kubernetes-commit: 471aff6673ebe4ac9c9219a7579d23831e1146be
2018-11-07 21:46:35 +00:00
Christoph Blecker
b0de173bf4 Update godeps
Kubernetes-commit: d15da2c586ba27df895c22486b1b527852c6363d
2018-11-06 16:23:59 -08:00
Wenjia Zhang
fb81d7e3f2 update staging godeps for golang.org/x/net/... to release-branch.go1.10
Kubernetes-commit: adf155ee9f9dfa023069282ec195f9eb8d1ce0fe
2018-11-06 15:49:50 -08:00
Davanum Srinivas
c7ea123f93 Switch to sigs.k8s.io/yaml from ghodss/yaml
Change-Id: Ic72b5131bf441d159012d67a6a3d87088d0e6d31

Kubernetes-commit: 43f523d405b012fa8d90dd95b667f520e036f6bc
2018-11-02 16:41:57 -04:00
Kubernetes Publisher
8c6eeb11d7 Merge pull request #70260 from lavalamp/schema-fix
bump kube-openapi dep

Kubernetes-commit: 6f897af2daffd8cd3539f1ef279b9f9bc280d98f
2018-11-01 09:39:19 +00:00
Daniel Smith
a5ec744ada update generated deps
Kubernetes-commit: dcb10d81d18f4e8a58496ef61b62247ae93bbaef
2018-10-31 17:11:23 -07:00
Kubernetes Publisher
dcc8aa9d76 Merge pull request #70031 from nrfox/requeue-on-error
Sample Controller: requeue work item on syncHandler error

Kubernetes-commit: b7b0aae4358065b98a3db04411bec65a11eb166e
2018-10-27 10:54:09 +00:00
Kubernetes Publisher
7ee81ff4ae Merge pull request #69636 from p0lyn0mial/sample_controller_factory_start
fixes the way the informers are started in sample controller pkg

Kubernetes-commit: 8e7e226422aabc62f84a0e151c3cd73fa1da70d4
2018-10-26 15:32:11 +00:00
nrfox
94e9a85e76 Requeue work item on syncHandler error
Kubernetes-commit: 8f86654b8e23bbf960a286712df35c003f7389f8
2018-10-19 13:54:31 -04:00
Kubernetes Publisher
fe5d3e0825 Merge pull request #67547 from pbarker/audit-api
dynamic audit configuration api

Kubernetes-commit: 0652e098d03197aa4cc0a53440f62e425bf992c5
2018-10-18 01:54:19 +00:00
Kubernetes Publisher
f1200b1b60 Merge pull request #69269 from miguelbernadi/fix-golint-issues-68026
Fix undocumented golint errors

Kubernetes-commit: 31438712d6602ed16f0fd8311782178cec0bb774
2018-10-17 05:52:13 +00:00
Kubernetes Publisher
83a48d571f Merge pull request #69330 from vaikas-google/json-patch
Add support for JSON patch in fake client

Kubernetes-commit: 2f8b585d9c9815886e5563ed5ac75cd0bc94a8e8
2018-10-16 01:52:43 +00:00
Patrick Barker
eee7e4e176 adds dynamic audit api generated
Kubernetes-commit: b8e1250487f51bd27bd75f4bfb45c8635d6344ed
2018-10-16 00:20:30 +00:00
Kubernetes Publisher
e8109b7ca8 Merge pull request #69627 from dims/updating-ghodss-yaml-to-latest-version-2
Updating ghodss/yaml and gopkg.in/yaml.v2 to latest version 2

Kubernetes-commit: 3348f9ae23d6502218c6600bcee8d05e00ce5ee3
2018-10-13 01:29:34 +00:00
Kubernetes Publisher
76b83c1674 Merge pull request #69322 from jpbetz/etcd-client-3.3.9
Update etcd client to 3.3 for 1.13

Kubernetes-commit: a8c7a3fd5e707243af68b10a8a581c2c59248222
2018-10-11 07:15:43 +00:00
p0lyn0mial
3cc2958b99 fixes the way the informers are started in sample controller pkg
Kubernetes-commit: e55ca64dbd3b141f8a373d129b1a619db0e672f0
2018-10-10 20:54:36 +02:00
Davanum Srinivas
724b71bd9d Updating ghodss/yaml and gopkg.in/yaml.v2 to latest version
Change-Id: I1f1a10b68a2d3e796724c6ac26f0ed3260153588

Kubernetes-commit: 6364af128b0ca50e66501519f333e696a26801d9
2018-10-10 10:14:20 -04:00
Kubernetes Publisher
77db795851 sync: update godeps 2018-10-09 09:01:07 +00:00
Miguel Bernabeu
7bf6cd7d56 Fix golint errors when generating informer code
Kubernetes-commit: acf78cd6133de6faea9221d8c53b02ca6009b0bb
2018-10-03 21:39:26 +02:00
Ville Aikas
69ec0e4f12 Add support for JSON patch in fake client
Kubernetes-commit: a363b153851326ece7f81f4c1ae0a1ab8700a209
2018-10-02 13:30:52 +00:00
Joe Betz
bef5795b2d Update etcd client to 3.3.9
Kubernetes-commit: 4263c752115c3796ee5715c7de4cbc2e237809d3
2018-10-01 16:53:57 -07:00
Kubernetes Publisher
b8a1e69103 Merge pull request #68709 from krzyzacy/fix-sample-test
fix patch compare in sample-controller test

Kubernetes-commit: 1b2298cb75a1375083a275560c71f8a7479c43d0
2018-09-26 07:57:48 +00:00
Kubernetes Publisher
4f47c578d9 Merge pull request #68245 from jingyih/remove_tagName_in_goDoc
*: Remove comment tags in GoDoc

Kubernetes-commit: a67689dfcab0ed547e1d060c414eae7c81629cc9
2018-09-25 15:47:45 +00:00
Kubernetes Publisher
d71bd50edb Merge pull request #68238 from justinsb/update_reflect2_to_101
Update reflect2 to 1.0.1 (memory utilization fix)

Kubernetes-commit: a94ea824eb59e92188f166c302d7995ba9002667
2018-09-25 15:47:15 +00:00
Sen Lu
f98e21072d fix patch compare in test
Kubernetes-commit: 6e40cd846c1d68fed1315e37823ba600e9c761f2
2018-09-14 22:48:49 -07:00
Jingyi Hu
6d9191098e *: Remove comment tags in GoDoc
Adding blank line between comment tag and package name in doc.go. So
that the comment tags such as '+k8s:deepcopy-gen=package' do not show up
in GoDoc.

Kubernetes-commit: 61117761cd4a1b2e6ad9ff2d7eb915f3d2739dc6
2018-09-04 14:08:32 -07:00
Justin Santa Barbara
30a25c44dc Update reflect2 to 1.0.1 (memory utilization fix)
Picking up https://github.com/modern-go/reflect2/pull/2 which lazy
initializes a map of all types which we don't use in k8s, saving
memory & initialization time.

Kubernetes-commit: 970e4da4c6636b835175dc79a7492d22dc11ba33
2018-09-04 13:13:00 -04:00
Kubernetes Publisher
af8f21f6ee Merge pull request #67359 from mikedanese/reloadtoken
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here: https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md.

client: periodically reload InClusterConfig token

/sig auth
/sig api-machinery

```release-note
NONE
```

Kubernetes-commit: 7b6647a418c660f2c87f183f706b297f1cb573ca
2018-09-02 08:53:46 +00:00
Kubernetes Publisher
9bec8a6a53 Merge pull request #64097 from damemi/hpa-metrics-specificity
Automatic merge from submit-queue (batch tested with PRs 67894, 64097). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

HPA metrics specificity improvements

**What this PR does / why we need it**:
Improves available specificity for HPA metrics by adding metric selector fields for metrics of Pods and Objects.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Implements this KEP: https://github.com/kubernetes/community/pull/2055

**Special notes for your reviewer**:
Need to add/update tests?

**Release note**:

```release-note
Introduces autoscaling/v2beta2 and custom_metrics/v1beta2, which implement metric selectors for Object and Pods metrics, as well as allowing AverageValue targets on Objects, similar to External metrics.
```

/assign @DirectXMan12

Kubernetes-commit: fdb5707194d56cbbd0da11c5be3a2a5653e714c9
2018-08-28 00:29:15 +00:00
Kubernetes Publisher
a7ac24a6d0 Merge pull request #66971 from tnozicka/informer-watcher
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

#50102 Task 2: Add UntilWithSync

**What this PR does / why we need it**:
This is a split off from https://github.com/kubernetes/kubernetes/pull/50102 to go in smaller pieces.

Introduces UntilWithSync based on informer.

**Needs https://github.com/kubernetes/kubernetes/pull/66906 first**
/hold

**Release note**:
```release-note
NONE
```

/priority important-soon
/kind bug
(bug after the main PR which is this split from)

Kubernetes-commit: c4f355a2ad9692f5459541d4e4d94fcbc5f7d946
2018-08-23 16:44:54 +00:00
Kubernetes Publisher
be98dc6210 Merge pull request #67686 from imroc/update-sample-controller-readme
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

update sample-controller README

Kubernetes-commit: 405eecad6dde9ab24b770fe583da51b9fd7c6941
2018-08-22 12:50:00 +00:00
roc
5962ba9f56 update sample-controller README
remind that CustomResourceSubresources is beta in v1.11 and enabled by default

Kubernetes-commit: ac741a8412d3c73ba39224f2f2e849f9976acc5a
2018-08-22 13:42:47 +08:00
Kubernetes Publisher
8605b8ceff Merge pull request #67596 from nikhita/add-apimachinery-label-owners
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Add sig/api-machinery label to apimachinery OWNERS files

Inspired by https://github.com/kubernetes/kubernetes/pull/67548. List of OWNERS files taken from https://github.com/kubernetes/community/blob/master/sig-api-machinery/README.md#subprojects.

**Release note**:

```release-note
NONE
```

Kubernetes-commit: 8f4ab6fe7635983443ebef7fde5b9c8861bef5bb
2018-08-21 00:23:11 +00:00
Nikhita Raghunath
bc340e9483 Add sig/api-machinery label to apimachinery OWNERS files
Kubernetes-commit: 6e47ba1fded3dc9932bd62affb673d321089760f
2018-08-20 18:46:47 +05:30
Kubernetes Publisher
acc9f193ca Merge pull request #65779 from cblecker/mergo-update
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

update github.com/imdario/mergo to v0.3.5

**What this PR does / why we need it**:
Updates github.com/imdario/mergo library to v0.3.5. We were pinned because of a functionality change in the dependency, however, a new function was introduced with similar functionality to the old.

There is apparently some Debian packaging issues (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=878254) because of this. I'm still not clear what those are, unless they are forcing the library to update, as opposed to using our `vendor/`.

That said, this will allow for some of those vendor conflicts to resolve for anyone else who is using client-go, so that's at least worthwhile.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
fixes #27543, fixes https://github.com/kubernetes/client-go/issues/431

**Special notes for your reviewer**:

**Release note**:
```release-note
NONE
```

Kubernetes-commit: 6b4135267911b6c10ed536308d29d2a7c453eef6
2018-08-18 02:39:08 +00:00
Kubernetes Publisher
3e2e91bf31 Merge pull request #66906 from tnozicka/rename-until
Automatic merge from submit-queue (batch tested with PRs 67071, 66906, 66722, 67276, 67039). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

#50102 Task 1: Move apimachinery/pkg/watch.Until into client-go/tools/watch.UntilWithoutRetry

**What this PR does / why we need it**:
This is a split off from https://github.com/kubernetes/kubernetes/pull/50102 to go in smaller pieces.

Moves `apimachinery/pkg/watch.Until` into `client-go/tools/watch.UntilWithoutRetry` and adds context so it is cancelable.

**Release note**:
```release-note
NONE
```

**Dev release note**:
```dev-release-note
`apimachinery/pkg/watch.Until` has been moved to `client-go/tools/watch.UntilWithoutRetry`.
While switching please consider using the new `client-go/tools/watch.UntilWithSync` or `client-go/tools/watch.Until`.
```

/cc @smarterclayton @kubernetes/sig-api-machinery-pr-reviews
/milestone v1.12
/priority important-soon
/kind bug
(bug after the main PR which is this split from)

Kubernetes-commit: b6f0aed056ab94fef0b6f54e1ca1d66a5fc228b3
2018-08-16 15:23:25 +00:00
Kubernetes Publisher
b24841bd57 Merge pull request #67178 from cblecker/cfssl
Automatic merge from submit-queue (batch tested with PRs 66602, 67178, 67207, 67125, 66332). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Vendor cfssl/cfssljson utilities

**What this PR does / why we need it**:
Vendors the `cfssl` and `cfssljson` tools. Updates `kube::util::ensure-cfssl` to use them.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
fixes #66995, fixes #60070

**Special notes for your reviewer**:
1. Add cfssl/cfssljson ot the required bins for saving
2. Manually cloned/checked out the new dependencies to my gopath. `godep restore` doesn't pull them down because they aren't required or already in the `Godeps.json`. Used @BenTheElder's list here: https://github.com/kubernetes/kubernetes/issues/66995#issuecomment-410594532
3. `hack/godep-save.sh` to add the packages and dependencies to godep
4. Fixed two bugs when building:
  a. `golang.org/x/crypto` needed to be updated
  b. `github.com/cloudflare/cfssl` needed to be updated to 56268a613a so we can vendor their fork of `crypto/tls`, as we discard their modified vendored stdlib.
5. Update staging godeps
6. Update the `kube::util::ensure-cfssl` to install from vendor

**Release note**:
```release-note
NONE
```

Kubernetes-commit: 818e632c1fde5fb01bc8ccf9b9ee6201f33a28b4
2018-08-16 15:22:34 +00:00
Mike Danese
70ded76448 reload token file for InClusterConfig every 5 minutes
Kubernetes-commit: 287f6a564fb8c264f281056011f4a66f197b18f4
2018-08-13 16:47:17 -07:00
Tomas Nozicka
a4f7d75f32 Update Godeps
Kubernetes-commit: f6836df5dd104bde62d80be411582c5d08dcaa65
2018-08-07 20:15:14 +02:00
Tomas Nozicka
fb123e6c66 Update Godeps
Kubernetes-commit: 41f5c3dbf55c5b02a3067789b0b835c6eb6f3bd3
2018-08-06 14:49:19 +02:00
Christoph Blecker
72a1e10055 Update github.com/imdario/mergo to v0.3.5
Kubernetes-commit: 12b2e2c2b53ab987e956673bc778e040af22e304
2018-07-03 11:15:43 -07:00
Mike Dame
056e0354fd Generate files and modifications for autoscaling/v2beta2 and custom_metrics/v1beta2
Kubernetes-commit: 77d7f9cfa2b489b75b47fa1e1de5660139f83034
2018-06-28 14:35:50 -04:00
2381 changed files with 936 additions and 704192 deletions

View File

@@ -1,2 +1,2 @@
Sorry, we do not accept changes directly against this repository. Please see
Sorry, we do not accept changes directly against this repository. Please see
CONTRIBUTING.md for information on where and how to contribute instead.

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
sample-controller

View File

@@ -2,6 +2,6 @@
Do not open pull requests directly against this repository, they will be ignored. Instead, please open pull requests against [kubernetes/kubernetes](https://git.k8s.io/kubernetes/). Please follow the same [contributing guide](https://git.k8s.io/kubernetes/CONTRIBUTING.md) you would follow for any other pull request made to kubernetes/kubernetes.
This repository is published from [kubernetes/kubernetes/staging/src/k8s.io/sample-controller](https://git.k8s.io/kubernetes/staging/src/k8s.io/sample-controller) by the [kubernetes publishing-bot](https://git.k8s.io/publishing-bot).
This repository is published from [kubernetes/kubernetes/staging/src/k8s.io/sample-controller](https://git.k8s.io/kubernetes/staging/src/k8s.io/sample-controller) by the [kubernetes publishing-bot](https://git.k8s.io/publishing-bot).
Please see [Staging Directory and Publishing](https://git.k8s.io/community/contributors/devel/staging.md) for more information
Please see [Staging Directory and Publishing](https://git.k8s.io/community/contributors/devel/sig-architecture/staging.md) for more information

1110
Godeps/Godeps.json generated

File diff suppressed because it is too large Load Diff

2
Godeps/OWNERS generated
View File

@@ -1,2 +0,0 @@
approvers:
- dep-approvers

5
Godeps/Readme generated
View File

@@ -1,5 +0,0 @@
This directory tree is generated automatically by godep.
Please do not edit.
See https://github.com/tools/godep for more information.

20
OWNERS
View File

@@ -1,9 +1,15 @@
# See the OWNERS docs at https://go.k8s.io/owners
approvers:
- sttts
- munnerz
- deads2k
- jpbetz
- sttts
- munnerz
reviewers:
- gregory-m
- kargakis
- sttts
- munnerz
- nikhita
- deads2k
- sttts
- munnerz
- nikhita
- jefftree
labels:
- sig/api-machinery

View File

@@ -1,3 +1,8 @@
> ⚠️ **This is an automatically published [staged repository](https://git.k8s.io/kubernetes/staging#external-repository-staging-area) for Kubernetes**.
> Contributions, including issues and pull requests, should be made to the main Kubernetes repository: [https://github.com/kubernetes/kubernetes](https://github.com/kubernetes/kubernetes).
> This repository is read-only for importing, and not used for direct contributions.
> See [CONTRIBUTING.md](./CONTRIBUTING.md) for more details.
# sample-controller
This repository implements a simple controller for watching Foo resources as
@@ -19,7 +24,7 @@ The `update-codegen` script will automatically generate the following files &
directories:
* `pkg/apis/samplecontroller/v1alpha1/zz_generated.deepcopy.go`
* `pkg/client/`
* `pkg/generated/`
Changes should not be made to these files manually, and when creating your own
controller based off of this implementation you should not copy these files and
@@ -31,6 +36,30 @@ The sample controller uses [client-go library](https://github.com/kubernetes/cli
The details of interaction points of the sample controller with various mechanisms from this library are
explained [here](docs/controller-client-go.md).
## Fetch sample-controller and its dependencies
Issue the following commands --- starting in whatever working directory you
like.
```sh
git clone https://github.com/kubernetes/sample-controller
cd sample-controller
```
Note, however, that if you intend to
generate code then you will also need the
code-generator repo to exist in an old-style location. One easy way
to do this is to use the command `go mod vendor` to create and
populate the `vendor` directory.
### A Note on kubernetes/kubernetes
If you are developing Kubernetes according to
https://github.com/kubernetes/community/blob/master/contributors/guide/github-workflow.md
then you already have a copy of this demo in
`kubernetes/staging/src/k8s.io/sample-controller` and its dependencies
--- including the code generator --- are in usable locations
(valid for all Go versions).
## Purpose
@@ -42,17 +71,17 @@ This is an example of how to build a kube-like controller with a single type.
```sh
# assumes you have a working kubeconfig, not required if operating in-cluster
$ go build -o sample-controller .
$ ./sample-controller -kubeconfig=$HOME/.kube/config
go build -o sample-controller .
./sample-controller -kubeconfig=$HOME/.kube/config
# create a CustomResourceDefinition
$ kubectl create -f artifacts/examples/crd.yaml
kubectl create -f artifacts/examples/crd-status-subresource.yaml
# create a custom resource of type Foo
$ kubectl create -f artifacts/examples/example-foo.yaml
kubectl create -f artifacts/examples/example-foo.yaml
# check deployments created through the custom resource
$ kubectl get deployments
kubectl get deployments
```
## Use Cases
@@ -85,54 +114,44 @@ type User struct {
}
```
Note, the JSON tag `json:` is required on all user facing fields within your type. Typically API types contain only user facing fields. When the JSON tag is omitted from the field, Kubernetes generators consider the field to be internal and will not expose the field in their generated external output. For example, this means that the field would not be included in a generated CRD schema.
## Validation
To validate custom resources, use the [`CustomResourceValidation`](https://kubernetes.io/docs/tasks/access-kubernetes-api/extend-api-custom-resource-definitions/#validation) feature.
This feature is beta and enabled by default in v1.9.
To validate custom resources, use the [`CustomResourceValidation`](https://kubernetes.io/docs/tasks/access-kubernetes-api/extend-api-custom-resource-definitions/#validation) feature. Validation in the form of a [structured schema](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#specifying-a-structural-schema) is mandatory to be provided for `apiextensions.k8s.io/v1`.
### Example
The schema in [`crd-validation.yaml`](./artifacts/examples/crd-validation.yaml) applies the following validation on the custom resource:
The schema in [`crd.yaml`](./artifacts/examples/crd.yaml) applies the following validation on the custom resource:
`spec.replicas` must be an integer and must have a minimum value of 1 and a maximum value of 10.
In the above steps, use `crd-validation.yaml` to create the CRD:
```sh
# create a CustomResourceDefinition supporting validation
$ kubectl create -f artifacts/examples/crd-validation.yaml
```
## Subresources
Custom Resources support `/status` and `/scale` subresources as an
[alpha feature](https://kubernetes.io/docs/tasks/access-kubernetes-api/extend-api-custom-resource-definitions/#subresources) in v1.10.
Enable this feature using the `CustomResourceSubresources` feature gate on the [kube-apiserver](https://kubernetes.io/docs/admin/kube-apiserver):
```sh
--feature-gates=CustomResourceSubresources=true
```
Custom Resources support `/status` and `/scale` [subresources](https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#subresources). The `CustomResourceSubresources` feature is in GA from v1.16.
### Example
The CRD in [`crd-status-subresource.yaml`](./artifacts/examples/crd-status-subresource.yaml) enables the `/status` subresource
for custom resources.
This means that [`UpdateStatus`](./controller.go#L330) can be used by the controller to update only the status part of the custom resource.
The CRD in [`crd-status-subresource.yaml`](./artifacts/examples/crd-status-subresource.yaml) enables the `/status` subresource for custom resources.
This means that [`UpdateStatus`](./controller.go) can be used by the controller to update only the status part of the custom resource.
To understand why only the status part of the custom resource should be updated, please refer to the [Kubernetes API conventions](https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status).
To understand why only the status part of the custom resource should be updated, please refer to the [Kubernetes API conventions](https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status).
In the above steps, use `crd-status-subresource.yaml` to create the CRD:
```sh
# create a CustomResourceDefinition supporting the status subresource
$ kubectl create -f artifacts/examples/crd-status-subresource.yaml
kubectl create -f artifacts/examples/crd-status-subresource.yaml
```
## A Note on the API version
The [group](https://kubernetes.io/docs/reference/using-api/#api-groups) version of the custom resource in `crd.yaml` is `v1alpha`, this can be evolved to a stable API version, `v1`, using [CRD Versioning](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning/).
## Cleanup
You can clean up the created CustomResourceDefinition with:
$ kubectl delete crd foos.samplecontroller.k8s.io
```sh
kubectl delete crd foos.samplecontroller.k8s.io
```
## Compatibility
@@ -145,3 +164,7 @@ k8s.io/client-go.
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/sample-controller.
Code changes are made in that location, merged into k8s.io/kubernetes and
later synced here.
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md) for more information. Please note that [kubernetes/sample-controller](https://github.com/kubernetes/sample-controller/) is a readonly mirror repository, all development is done at [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes).

View File

@@ -1,17 +1,16 @@
# Defined below are the security contacts for this repo.
#
# They are the contact point for the Product Security Team to reach out
# They are the contact point for the Product Security Committee to reach out
# to for triaging and handling of incoming issues.
#
# The below names agree to abide by the
# [Embargo Policy](https://github.com/kubernetes/sig-release/blob/master/security-release-process-documentation/security-release-process.md#embargo-policy)
# [Embargo Policy](https://git.k8s.io/security/private-distributors-list.md#embargo-policy)
# and will be removed and replaced if they violate that agreement.
#
# DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE
# INSTRUCTIONS AT https://kubernetes.io/security/
cjcullen
jessfraz
liggitt
philips
tallclair
cheftako
deads2k
lavalamp
sttts

View File

@@ -1,13 +1,41 @@
apiVersion: apiextensions.k8s.io/v1beta1
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: foos.samplecontroller.k8s.io
# for more information on the below annotation, please see
# https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/2337-k8s.io-group-protection/README.md
annotations:
"api-approved.kubernetes.io": "unapproved, experimental-only; please get an approval from Kubernetes API reviewers if you're trying to develop a CRD in the *.k8s.io or *.kubernetes.io groups"
spec:
group: samplecontroller.k8s.io
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
schema:
# schema used for validation
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
deploymentName:
type: string
replicas:
type: integer
minimum: 1
maximum: 10
status:
type: object
properties:
availableReplicas:
type: integer
# subresources for the custom resource
subresources:
# enables the status subresource
status: {}
names:
kind: Foo
plural: foos
scope: Namespaced
subresources:
status: {}

View File

@@ -1,20 +0,0 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: foos.samplecontroller.k8s.io
spec:
group: samplecontroller.k8s.io
version: v1alpha1
names:
kind: Foo
plural: foos
scope: Namespaced
validation:
openAPIV3Schema:
properties:
spec:
properties:
replicas:
type: integer
minimum: 1
maximum: 10

View File

@@ -1,10 +1,36 @@
apiVersion: apiextensions.k8s.io/v1beta1
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: foos.samplecontroller.k8s.io
# for more information on the below annotation, please see
# https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/2337-k8s.io-group-protection/README.md
annotations:
"api-approved.kubernetes.io": "unapproved, experimental-only; please get an approval from Kubernetes API reviewers if you're trying to develop a CRD in the *.k8s.io or *.kubernetes.io groups"
spec:
group: samplecontroller.k8s.io
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
schema:
# schema used for validation
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
deploymentName:
type: string
replicas:
type: integer
minimum: 1
maximum: 10
status:
type: object
properties:
availableReplicas:
type: integer
names:
kind: Foo
plural: foos

View File

@@ -17,16 +17,16 @@ limitations under the License.
package main
import (
"context"
"fmt"
"time"
"github.com/golang/glog"
"golang.org/x/time/rate"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
appsinformers "k8s.io/client-go/informers/apps/v1"
@@ -37,12 +37,13 @@ import (
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog/v2"
samplev1alpha1 "k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1"
clientset "k8s.io/sample-controller/pkg/client/clientset/versioned"
samplescheme "k8s.io/sample-controller/pkg/client/clientset/versioned/scheme"
informers "k8s.io/sample-controller/pkg/client/informers/externalversions/samplecontroller/v1alpha1"
listers "k8s.io/sample-controller/pkg/client/listers/samplecontroller/v1alpha1"
clientset "k8s.io/sample-controller/pkg/generated/clientset/versioned"
samplescheme "k8s.io/sample-controller/pkg/generated/clientset/versioned/scheme"
informers "k8s.io/sample-controller/pkg/generated/informers/externalversions/samplecontroller/v1alpha1"
listers "k8s.io/sample-controller/pkg/generated/listers/samplecontroller/v1alpha1"
)
const controllerAgentName = "sample-controller"
@@ -60,6 +61,8 @@ const (
// MessageResourceSynced is the message used for an Event fired when a Foo
// is synced successfully
MessageResourceSynced = "Foo synced successfully"
// FieldManager distinguishes this controller from other things writing to API objects
FieldManager = controllerAgentName
)
// Controller is the controller implementation for Foo resources
@@ -79,7 +82,7 @@ type Controller struct {
// means we can ensure we only process a fixed amount of resources at a
// time, and makes it easy to ensure we are never processing the same item
// simultaneously in two different workers.
workqueue workqueue.RateLimitingInterface
workqueue workqueue.TypedRateLimitingInterface[cache.ObjectName]
// recorder is an event recorder for recording Event resources to the
// Kubernetes API.
recorder record.EventRecorder
@@ -87,20 +90,27 @@ type Controller struct {
// NewController returns a new sample controller
func NewController(
ctx context.Context,
kubeclientset kubernetes.Interface,
sampleclientset clientset.Interface,
deploymentInformer appsinformers.DeploymentInformer,
fooInformer informers.FooInformer) *Controller {
logger := klog.FromContext(ctx)
// Create event broadcaster
// Add sample-controller types to the default Kubernetes Scheme so Events can be
// logged for sample-controller types.
utilruntime.Must(samplescheme.AddToScheme(scheme.Scheme))
glog.V(4).Info("Creating event broadcaster")
eventBroadcaster := record.NewBroadcaster()
eventBroadcaster.StartLogging(glog.Infof)
logger.V(4).Info("Creating event broadcaster")
eventBroadcaster := record.NewBroadcaster(record.WithContext(ctx))
eventBroadcaster.StartStructuredLogging(0)
eventBroadcaster.StartRecordingToSink(&typedcorev1.EventSinkImpl{Interface: kubeclientset.CoreV1().Events("")})
recorder := eventBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: controllerAgentName})
ratelimiter := workqueue.NewTypedMaxOfRateLimiter(
workqueue.NewTypedItemExponentialFailureRateLimiter[cache.ObjectName](5*time.Millisecond, 1000*time.Second),
&workqueue.TypedBucketRateLimiter[cache.ObjectName]{Limiter: rate.NewLimiter(rate.Limit(50), 300)},
)
controller := &Controller{
kubeclientset: kubeclientset,
@@ -109,11 +119,11 @@ func NewController(
deploymentsSynced: deploymentInformer.Informer().HasSynced,
foosLister: fooInformer.Lister(),
foosSynced: fooInformer.Informer().HasSynced,
workqueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "Foos"),
workqueue: workqueue.NewTypedRateLimitingQueue(ratelimiter),
recorder: recorder,
}
glog.Info("Setting up event handlers")
logger.Info("Setting up event handlers")
// Set up an event handler for when Foo resources change
fooInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: controller.enqueueFoo,
@@ -123,7 +133,7 @@ func NewController(
})
// Set up an event handler for when Deployment resources change. This
// handler will lookup the owner of the given Deployment, and if it is
// owned by a Foo resource will enqueue that Foo resource for
// owned by a Foo resource then the handler will enqueue that Foo resource for
// processing. This way, we don't need to implement custom logic for
// handling Deployment resources. More info on this pattern:
// https://github.com/kubernetes/community/blob/8cafef897a22026d42f5e5bb3f104febe7e29830/contributors/devel/controllers.md
@@ -149,28 +159,30 @@ func NewController(
// as syncing informer caches and starting workers. It will block until stopCh
// is closed, at which point it will shutdown the workqueue and wait for
// workers to finish processing their current work items.
func (c *Controller) Run(threadiness int, stopCh <-chan struct{}) error {
defer runtime.HandleCrash()
func (c *Controller) Run(ctx context.Context, workers int) error {
defer utilruntime.HandleCrash()
defer c.workqueue.ShutDown()
logger := klog.FromContext(ctx)
// Start the informer factories to begin populating the informer caches
glog.Info("Starting Foo controller")
logger.Info("Starting Foo controller")
// Wait for the caches to be synced before starting workers
glog.Info("Waiting for informer caches to sync")
if ok := cache.WaitForCacheSync(stopCh, c.deploymentsSynced, c.foosSynced); !ok {
logger.Info("Waiting for informer caches to sync")
if ok := cache.WaitForCacheSync(ctx.Done(), c.deploymentsSynced, c.foosSynced); !ok {
return fmt.Errorf("failed to wait for caches to sync")
}
glog.Info("Starting workers")
logger.Info("Starting workers", "count", workers)
// Launch two workers to process Foo resources
for i := 0; i < threadiness; i++ {
go wait.Until(c.runWorker, time.Second, stopCh)
for i := 0; i < workers; i++ {
go wait.UntilWithContext(ctx, c.runWorker, time.Second)
}
glog.Info("Started workers")
<-stopCh
glog.Info("Shutting down workers")
logger.Info("Started workers")
<-ctx.Done()
logger.Info("Shutting down workers")
return nil
}
@@ -178,82 +190,64 @@ func (c *Controller) Run(threadiness int, stopCh <-chan struct{}) error {
// runWorker is a long-running function that will continually call the
// processNextWorkItem function in order to read and process a message on the
// workqueue.
func (c *Controller) runWorker() {
for c.processNextWorkItem() {
func (c *Controller) runWorker(ctx context.Context) {
for c.processNextWorkItem(ctx) {
}
}
// processNextWorkItem will read a single work item off the workqueue and
// attempt to process it, by calling the syncHandler.
func (c *Controller) processNextWorkItem() bool {
obj, shutdown := c.workqueue.Get()
func (c *Controller) processNextWorkItem(ctx context.Context) bool {
objRef, shutdown := c.workqueue.Get()
logger := klog.FromContext(ctx)
if shutdown {
return false
}
// We wrap this block in a func so we can defer c.workqueue.Done.
err := func(obj interface{}) error {
// We call Done here so the workqueue knows we have finished
// processing this item. We also must remember to call Forget if we
// do not want this work item being re-queued. For example, we do
// not call Forget if a transient error occurs, instead the item is
// put back on the workqueue and attempted again after a back-off
// period.
defer c.workqueue.Done(obj)
var key string
var ok bool
// We expect strings to come off the workqueue. These are of the
// form namespace/name. We do this as the delayed nature of the
// workqueue means the items in the informer cache may actually be
// more up to date that when the item was initially put onto the
// workqueue.
if key, ok = obj.(string); !ok {
// As the item in the workqueue is actually invalid, we call
// Forget here else we'd go into a loop of attempting to
// process a work item that is invalid.
c.workqueue.Forget(obj)
runtime.HandleError(fmt.Errorf("expected string in workqueue but got %#v", obj))
return nil
}
// Run the syncHandler, passing it the namespace/name string of the
// Foo resource to be synced.
if err := c.syncHandler(key); err != nil {
return fmt.Errorf("error syncing '%s': %s", key, err.Error())
}
// Finally, if no error occurs we Forget this item so it does not
// get queued again until another change happens.
c.workqueue.Forget(obj)
glog.Infof("Successfully synced '%s'", key)
return nil
}(obj)
// We call Done at the end of this func so the workqueue knows we have
// finished processing this item. We also must remember to call Forget
// if we do not want this work item being re-queued. For example, we do
// not call Forget if a transient error occurs, instead the item is
// put back on the workqueue and attempted again after a back-off
// period.
defer c.workqueue.Done(objRef)
if err != nil {
runtime.HandleError(err)
// Run the syncHandler, passing it the structured reference to the object to be synced.
err := c.syncHandler(ctx, objRef)
if err == nil {
// If no error occurs then we Forget this item so it does not
// get queued again until another change happens.
c.workqueue.Forget(objRef)
logger.Info("Successfully synced", "objectName", objRef)
return true
}
// there was a failure so be sure to report it. This method allows for
// pluggable error handling which can be used for things like
// cluster-monitoring.
utilruntime.HandleErrorWithContext(ctx, err, "Error syncing; requeuing for later retry", "objectReference", objRef)
// since we failed, we should requeue the item to work on later. This
// method will add a backoff to avoid hotlooping on particular items
// (they're probably still not going to work right away) and overall
// controller protection (everything I've done is broken, this controller
// needs to calm down or it can starve other useful work) cases.
c.workqueue.AddRateLimited(objRef)
return true
}
// syncHandler compares the actual state with the desired, and attempts to
// converge the two. It then updates the Status block of the Foo resource
// with the current status of the resource.
func (c *Controller) syncHandler(key string) error {
// Convert the namespace/name string into a distinct namespace and name
namespace, name, err := cache.SplitMetaNamespaceKey(key)
if err != nil {
runtime.HandleError(fmt.Errorf("invalid resource key: %s", key))
return nil
}
func (c *Controller) syncHandler(ctx context.Context, objectRef cache.ObjectName) error {
logger := klog.LoggerWithValues(klog.FromContext(ctx), "objectRef", objectRef)
// Get the Foo resource with this namespace/name
foo, err := c.foosLister.Foos(namespace).Get(name)
foo, err := c.foosLister.Foos(objectRef.Namespace).Get(objectRef.Name)
if err != nil {
// The Foo resource may no longer exist, in which case we stop
// processing.
if errors.IsNotFound(err) {
runtime.HandleError(fmt.Errorf("foo '%s' in work queue no longer exists", key))
utilruntime.HandleErrorWithContext(ctx, err, "Foo referenced by item in work queue no longer exists", "objectReference", objectRef)
return nil
}
@@ -265,7 +259,7 @@ func (c *Controller) syncHandler(key string) error {
// We choose to absorb the error here as the worker would requeue the
// resource otherwise. Instead, the next time the resource is updated
// the resource will be queued again.
runtime.HandleError(fmt.Errorf("%s: deployment name must be specified", key))
utilruntime.HandleErrorWithContext(ctx, nil, "Deployment name missing from object reference", "objectReference", objectRef)
return nil
}
@@ -273,7 +267,7 @@ func (c *Controller) syncHandler(key string) error {
deployment, err := c.deploymentsLister.Deployments(foo.Namespace).Get(deploymentName)
// If the resource doesn't exist, we'll create it
if errors.IsNotFound(err) {
deployment, err = c.kubeclientset.AppsV1().Deployments(foo.Namespace).Create(newDeployment(foo))
deployment, err = c.kubeclientset.AppsV1().Deployments(foo.Namespace).Create(ctx, newDeployment(foo), metav1.CreateOptions{FieldManager: FieldManager})
}
// If an error occurs during Get/Create, we'll requeue the item so we can
@@ -284,23 +278,23 @@ func (c *Controller) syncHandler(key string) error {
}
// If the Deployment is not controlled by this Foo resource, we should log
// a warning to the event recorder and ret
// a warning to the event recorder and return error msg.
if !metav1.IsControlledBy(deployment, foo) {
msg := fmt.Sprintf(MessageResourceExists, deployment.Name)
c.recorder.Event(foo, corev1.EventTypeWarning, ErrResourceExists, msg)
return fmt.Errorf(msg)
return fmt.Errorf("%s", msg)
}
// If this number of the replicas on the Foo resource is specified, and the
// number does not equal the current desired replicas on the Deployment, we
// should update the Deployment resource.
if foo.Spec.Replicas != nil && *foo.Spec.Replicas != *deployment.Spec.Replicas {
glog.V(4).Infof("Foo %s replicas: %d, deployment replicas: %d", name, *foo.Spec.Replicas, *deployment.Spec.Replicas)
deployment, err = c.kubeclientset.AppsV1().Deployments(foo.Namespace).Update(newDeployment(foo))
logger.V(4).Info("Update deployment resource", "currentReplicas", *deployment.Spec.Replicas, "desiredReplicas", *foo.Spec.Replicas)
deployment, err = c.kubeclientset.AppsV1().Deployments(foo.Namespace).Update(ctx, newDeployment(foo), metav1.UpdateOptions{FieldManager: FieldManager})
}
// If an error occurs during Update, we'll requeue the item so we can
// attempt processing again later. THis could have been caused by a
// attempt processing again later. This could have been caused by a
// temporary network failure, or any other transient reason.
if err != nil {
return err
@@ -308,7 +302,7 @@ func (c *Controller) syncHandler(key string) error {
// Finally, we update the status block of the Foo resource to reflect the
// current state of the world
err = c.updateFooStatus(foo, deployment)
err = c.updateFooStatus(ctx, foo, deployment)
if err != nil {
return err
}
@@ -317,7 +311,7 @@ func (c *Controller) syncHandler(key string) error {
return nil
}
func (c *Controller) updateFooStatus(foo *samplev1alpha1.Foo, deployment *appsv1.Deployment) error {
func (c *Controller) updateFooStatus(ctx context.Context, foo *samplev1alpha1.Foo, deployment *appsv1.Deployment) error {
// NEVER modify objects from the store. It's a read-only, local cache.
// You can use DeepCopy() to make a deep copy of original object and modify this copy
// Or create a copy manually for better performance
@@ -327,7 +321,7 @@ func (c *Controller) updateFooStatus(foo *samplev1alpha1.Foo, deployment *appsv1
// we must use Update instead of UpdateStatus to update the Status block of the Foo resource.
// UpdateStatus will not allow changes to the Spec of the resource,
// which is ideal for ensuring nothing other than resource status has been updated.
_, err := c.sampleclientset.SamplecontrollerV1alpha1().Foos(foo.Namespace).Update(fooCopy)
_, err := c.sampleclientset.SamplecontrollerV1alpha1().Foos(foo.Namespace).UpdateStatus(ctx, fooCopy, metav1.UpdateOptions{FieldManager: FieldManager})
return err
}
@@ -335,13 +329,12 @@ func (c *Controller) updateFooStatus(foo *samplev1alpha1.Foo, deployment *appsv1
// string which is then put onto the work queue. This method should *not* be
// passed resources of any type other than Foo.
func (c *Controller) enqueueFoo(obj interface{}) {
var key string
var err error
if key, err = cache.MetaNamespaceKeyFunc(obj); err != nil {
runtime.HandleError(err)
if objectRef, err := cache.ObjectToName(obj); err != nil {
utilruntime.HandleError(err)
return
} else {
c.workqueue.Add(objectRef)
}
c.workqueue.AddRateLimited(key)
}
// handleObject will take any resource implementing metav1.Object and attempt
@@ -352,20 +345,25 @@ func (c *Controller) enqueueFoo(obj interface{}) {
func (c *Controller) handleObject(obj interface{}) {
var object metav1.Object
var ok bool
logger := klog.FromContext(context.Background())
if object, ok = obj.(metav1.Object); !ok {
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
if !ok {
runtime.HandleError(fmt.Errorf("error decoding object, invalid type"))
// If the object value is not too big and does not contain sensitive information then
// it may be useful to include it.
utilruntime.HandleErrorWithContext(context.Background(), nil, "Error decoding object, invalid type", "type", fmt.Sprintf("%T", obj))
return
}
object, ok = tombstone.Obj.(metav1.Object)
if !ok {
runtime.HandleError(fmt.Errorf("error decoding object tombstone, invalid type"))
// If the object value is not too big and does not contain sensitive information then
// it may be useful to include it.
utilruntime.HandleErrorWithContext(context.Background(), nil, "Error decoding object tombstone, invalid type", "type", fmt.Sprintf("%T", tombstone.Obj))
return
}
glog.V(4).Infof("Recovered deleted object '%s' from tombstone", object.GetName())
logger.V(4).Info("Recovered deleted object", "resourceName", object.GetName())
}
glog.V(4).Infof("Processing object: %s", object.GetName())
logger.V(4).Info("Processing object", "object", klog.KObj(object))
if ownerRef := metav1.GetControllerOf(object); ownerRef != nil {
// If this object is not owned by a Foo, we should not do anything more
// with it.
@@ -375,7 +373,7 @@ func (c *Controller) handleObject(obj interface{}) {
foo, err := c.foosLister.Foos(object.GetNamespace()).Get(ownerRef.Name)
if err != nil {
glog.V(4).Infof("ignoring orphaned object '%s' of foo '%s'", object.GetSelfLink(), ownerRef.Name)
logger.V(4).Info("Ignore orphaned object", "object", klog.KObj(object), "foo", ownerRef.Name)
return
}
@@ -397,11 +395,7 @@ func newDeployment(foo *samplev1alpha1.Foo) *appsv1.Deployment {
Name: foo.Spec.DeploymentName,
Namespace: foo.Namespace,
OwnerReferences: []metav1.OwnerReference{
*metav1.NewControllerRef(foo, schema.GroupVersionKind{
Group: samplev1alpha1.SchemeGroupVersion.Group,
Version: samplev1alpha1.SchemeGroupVersion.Version,
Kind: "Foo",
}),
*metav1.NewControllerRef(foo, samplev1alpha1.SchemeGroupVersion.WithKind("Foo")),
},
},
Spec: appsv1.DeploymentSpec{

View File

@@ -17,6 +17,7 @@ limitations under the License.
package main
import (
"context"
"fmt"
"reflect"
"testing"
@@ -32,10 +33,12 @@ import (
core "k8s.io/client-go/testing"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/record"
"k8s.io/klog/v2/ktesting"
"k8s.io/utils/ptr"
samplecontroller "k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1"
"k8s.io/sample-controller/pkg/client/clientset/versioned/fake"
informers "k8s.io/sample-controller/pkg/client/informers/externalversions"
"k8s.io/sample-controller/pkg/generated/clientset/versioned/fake"
informers "k8s.io/sample-controller/pkg/generated/informers/externalversions"
)
var (
@@ -81,14 +84,14 @@ func newFoo(name string, replicas *int32) *samplecontroller.Foo {
}
}
func (f *fixture) newController() (*Controller, informers.SharedInformerFactory, kubeinformers.SharedInformerFactory) {
func (f *fixture) newController(ctx context.Context) (*Controller, informers.SharedInformerFactory, kubeinformers.SharedInformerFactory) {
f.client = fake.NewSimpleClientset(f.objects...)
f.kubeclient = k8sfake.NewSimpleClientset(f.kubeobjects...)
i := informers.NewSharedInformerFactory(f.client, noResyncPeriodFunc())
k8sI := kubeinformers.NewSharedInformerFactory(f.kubeclient, noResyncPeriodFunc())
c := NewController(f.kubeclient, f.client,
c := NewController(ctx, f.kubeclient, f.client,
k8sI.Apps().V1().Deployments(), i.Samplecontroller().V1alpha1().Foos())
c.foosSynced = alwaysReady
@@ -106,24 +109,22 @@ func (f *fixture) newController() (*Controller, informers.SharedInformerFactory,
return c, i, k8sI
}
func (f *fixture) run(fooName string) {
f.runController(fooName, true, false)
func (f *fixture) run(ctx context.Context, fooRef cache.ObjectName) {
f.runController(ctx, fooRef, true, false)
}
func (f *fixture) runExpectError(fooName string) {
f.runController(fooName, true, true)
func (f *fixture) runExpectError(ctx context.Context, fooRef cache.ObjectName) {
f.runController(ctx, fooRef, true, true)
}
func (f *fixture) runController(fooName string, startInformers bool, expectError bool) {
c, i, k8sI := f.newController()
func (f *fixture) runController(ctx context.Context, fooRef cache.ObjectName, startInformers bool, expectError bool) {
c, i, k8sI := f.newController(ctx)
if startInformers {
stopCh := make(chan struct{})
defer close(stopCh)
i.Start(stopCh)
k8sI.Start(stopCh)
i.Start(ctx.Done())
k8sI.Start(ctx.Done())
}
err := c.syncHandler(fooName)
err := c.syncHandler(ctx, fooRef)
if !expectError && err != nil {
f.t.Errorf("error syncing foo: %v", err)
} else if expectError && err == nil {
@@ -175,33 +176,36 @@ func checkAction(expected, actual core.Action, t *testing.T) {
}
switch a := actual.(type) {
case core.CreateAction:
e, _ := expected.(core.CreateAction)
case core.CreateActionImpl:
e, _ := expected.(core.CreateActionImpl)
expObject := e.GetObject()
object := a.GetObject()
if !reflect.DeepEqual(expObject, object) {
t.Errorf("Action %s %s has wrong object\nDiff:\n %s",
a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintDiff(expObject, object))
a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintSideBySide(expObject, object))
}
case core.UpdateAction:
e, _ := expected.(core.UpdateAction)
case core.UpdateActionImpl:
e, _ := expected.(core.UpdateActionImpl)
expObject := e.GetObject()
object := a.GetObject()
if !reflect.DeepEqual(expObject, object) {
t.Errorf("Action %s %s has wrong object\nDiff:\n %s",
a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintDiff(expObject, object))
a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintSideBySide(expObject, object))
}
case core.PatchAction:
e, _ := expected.(core.PatchAction)
case core.PatchActionImpl:
e, _ := expected.(core.PatchActionImpl)
expPatch := e.GetPatch()
patch := a.GetPatch()
if !reflect.DeepEqual(expPatch, expPatch) {
if !reflect.DeepEqual(expPatch, patch) {
t.Errorf("Action %s %s has wrong patch\nDiff:\n %s",
a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintDiff(expPatch, patch))
a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintSideBySide(expPatch, patch))
}
default:
t.Errorf("Uncaptured Action %s %s, you should explicitly add a case to capture it",
actual.GetVerb(), actual.GetResource().Resource)
}
}
@@ -233,24 +237,19 @@ func (f *fixture) expectUpdateDeploymentAction(d *apps.Deployment) {
}
func (f *fixture) expectUpdateFooStatusAction(foo *samplecontroller.Foo) {
action := core.NewUpdateAction(schema.GroupVersionResource{Resource: "foos"}, foo.Namespace, foo)
// TODO: Until #38113 is merged, we can't use Subresource
//action.Subresource = "status"
action := core.NewUpdateSubresourceAction(schema.GroupVersionResource{Resource: "foos"}, "status", foo.Namespace, foo)
f.actions = append(f.actions, action)
}
func getKey(foo *samplecontroller.Foo, t *testing.T) string {
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(foo)
if err != nil {
t.Errorf("Unexpected error getting key for foo %v: %v", foo.Name, err)
return ""
}
return key
func getRef(foo *samplecontroller.Foo, t *testing.T) cache.ObjectName {
ref := cache.MetaObjectToName(foo)
return ref
}
func TestCreatesDeployment(t *testing.T) {
f := newFixture(t)
foo := newFoo("test", int32Ptr(1))
foo := newFoo("test", ptr.To[int32](1))
_, ctx := ktesting.NewTestContext(t)
f.fooLister = append(f.fooLister, foo)
f.objects = append(f.objects, foo)
@@ -259,12 +258,14 @@ func TestCreatesDeployment(t *testing.T) {
f.expectCreateDeploymentAction(expDeployment)
f.expectUpdateFooStatusAction(foo)
f.run(getKey(foo, t))
f.run(ctx, getRef(foo, t))
}
func TestDoNothing(t *testing.T) {
f := newFixture(t)
foo := newFoo("test", int32Ptr(1))
foo := newFoo("test", ptr.To[int32](1))
_, ctx := ktesting.NewTestContext(t)
d := newDeployment(foo)
f.fooLister = append(f.fooLister, foo)
@@ -273,16 +274,18 @@ func TestDoNothing(t *testing.T) {
f.kubeobjects = append(f.kubeobjects, d)
f.expectUpdateFooStatusAction(foo)
f.run(getKey(foo, t))
f.run(ctx, getRef(foo, t))
}
func TestUpdateDeployment(t *testing.T) {
f := newFixture(t)
foo := newFoo("test", int32Ptr(1))
foo := newFoo("test", ptr.To[int32](1))
_, ctx := ktesting.NewTestContext(t)
d := newDeployment(foo)
// Update replicas
foo.Spec.Replicas = int32Ptr(2)
foo.Spec.Replicas = ptr.To[int32](2)
expDeployment := newDeployment(foo)
f.fooLister = append(f.fooLister, foo)
@@ -292,12 +295,14 @@ func TestUpdateDeployment(t *testing.T) {
f.expectUpdateFooStatusAction(foo)
f.expectUpdateDeploymentAction(expDeployment)
f.run(getKey(foo, t))
f.run(ctx, getRef(foo, t))
}
func TestNotControlledByUs(t *testing.T) {
f := newFixture(t)
foo := newFoo("test", int32Ptr(1))
foo := newFoo("test", ptr.To[int32](1))
_, ctx := ktesting.NewTestContext(t)
d := newDeployment(foo)
d.ObjectMeta.OwnerReferences = []metav1.OwnerReference{}
@@ -307,7 +312,5 @@ func TestNotControlledByUs(t *testing.T) {
f.deploymentLister = append(f.deploymentLister, d)
f.kubeobjects = append(f.kubeobjects, d)
f.runExpectError(getKey(foo, t))
f.runExpectError(ctx, getRef(foo, t))
}
func int32Ptr(i int32) *int32 { return &i }

View File

@@ -1,11 +1,11 @@
# client-go under the hood
The [client-go](https://github.com/kubernetes/client-go/) library contains various mechanisms that you can use when
developing your custom controllers. These mechanisms are defined in the
The [client-go](https://github.com/kubernetes/client-go/) library contains various mechanisms that you can use when
developing your custom controllers. These mechanisms are defined in the
[tools/cache folder](https://github.com/kubernetes/client-go/tree/master/tools/cache) of the library.
Here is a pictorial representation showing how the various components in
the client-go library work and their interaction points with the custom
Here is a pictorial representation showing how the various components in
the client-go library work and their interaction points with the custom
controller code that you will write.
<p align="center">
@@ -19,7 +19,7 @@ watches the Kubernetes API for the specified resource type (kind).
The function in which this is done is *ListAndWatch*.
The watch could be for an in-built resource or it could be for a custom resource.
When the reflector receives notification about existence of new
resource instance through the watch API, it gets the newly created object
resource instance through the watch API, it gets the newly created object
using the corresponding listing API and puts it in the Delta Fifo queue
inside the *watchHandler* function.
@@ -32,33 +32,33 @@ is to save the object for later retrieval, and to invoke our controller passing
It is defined in [type *Indexer* inside package *cache*](https://github.com/kubernetes/client-go/blob/master/tools/cache/index.go). A typical indexing use-case is to create an index based on object labels. Indexer can
maintain indexes based on several indexing functions.
Indexer uses a thread-safe data store to store objects and their keys.
There is a default function named *MetaNamespaceKeyFunc* defined in [type Store inside package cache](https://github.com/kubernetes/client-go/blob/master/tools/cache/store.go)
There is a default function named *MetaNamespaceKeyFunc* defined in [type *Store* inside package *cache*](https://github.com/kubernetes/client-go/blob/master/tools/cache/store.go)
that generates an objects key as `<namespace>/<name>` combination for that object.
## Custom Controller components
* Informer reference: This is the reference to the Informer instance that knows
how to work with your custom resource objects. Your custom controller code needs
* Informer reference: This is the reference to the Informer instance that knows
how to work with your custom resource objects. Your custom controller code needs
to create the appropriate Informer.
* Indexer reference: This is the reference to the Indexer instance that knows
how to work with your custom resource objects. Your custom controller code needs
to create this. You will be using this reference for retrieving objects for
* Indexer reference: This is the reference to the Indexer instance that knows
how to work with your custom resource objects. Your custom controller code needs
to create this. You will be using this reference for retrieving objects for
later processing.
The base controller in client-go provides the *NewIndexerInformer* function to create Informer and Indexer.
In your code you can either [directly invoke this function](https://github.com/kubernetes/client-go/blob/master/examples/workqueue/main.go#L174) or [use factory methods for creating an informer.](https://github.com/kubernetes/sample-controller/blob/master/main.go#L61)
* Resource Event Handlers: These are the callback functions which will be called by
the Informer when it wants to deliver an object to your controller. The typical
* Resource Event Handlers: These are the callback functions which will be called by
the Informer when it wants to deliver an object to your controller. The typical
pattern to write these functions is to obtain the dispatched objects key
and enqueue that key in a work queue for further processing.
* Work queue: This is the queue that you create in your controller code to decouple
delivery of an object from its processing. Resource event handler functions are written
* Work queue: This is the queue that you create in your controller code to decouple
delivery of an object from its processing. Resource event handler functions are written
to extract the delivered objects key and add that to the work queue.
* Process Item: This is the function that you create in your code which processes items
from the work queue. There can be one or more other functions that do the actual processing.
* Process Item: This is the function that you create in your code which processes items
from the work queue. There can be one or more other functions that do the actual processing.
These functions will typically use the [Indexer reference](https://github.com/kubernetes/client-go/blob/master/examples/workqueue/main.go#L73), or a Listing wrapper to retrieve the object corresponding to the key.

58
go.mod Normal file
View File

@@ -0,0 +1,58 @@
// This is a generated file. Do not edit directly.
module k8s.io/sample-controller
go 1.25.0
godebug default=go1.25
require (
golang.org/x/time v0.14.0
k8s.io/api v0.0.0-20260121173914-4f90c5e5fa65
k8s.io/apimachinery v0.0.0-20260116132332-7daad7080a68
k8s.io/client-go v0.0.0-20260121214359-511abf454ddf
k8s.io/code-generator v0.0.0-20260121215239-41a43eabae03
k8s.io/klog/v2 v2.130.1
k8s.io/utils v0.0.0-20251219084037-98d557b7f1e7
)
require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.13.0 // indirect
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/spf13/pflag v1.0.9 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/mod v0.32.0 // indirect
golang.org/x/net v0.49.0 // indirect
golang.org/x/oauth2 v0.34.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/term v0.39.0 // indirect
golang.org/x/text v0.33.0 // indirect
golang.org/x/tools v0.40.0 // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/gengo/v2 v2.0.0-20250922181213-ec3ebc5fd46b // indirect
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.1 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)

141
go.sum Normal file
View File

@@ -0,0 +1,141 @@
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/emicklei/go-restful/v3 v3.13.0 h1:C4Bl2xDndpU6nJ4bc1jXd+uTmYPVUwkD6bFY/oTyCes=
github.com/emicklei/go-restful/v3 v3.13.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM=
github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE=
github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k=
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo=
github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J0b1vyeLSOYI8bm5wbJM/8yDe8=
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee h1:W5t00kpgFdJifH4BDsTlE89Zl93FEloxaWZfGcifgq8=
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/onsi/ginkgo/v2 v2.27.4 h1:fcEcQW/A++6aZAZQNUmNjvA9PSOzefMJBerHJ4t8v8Y=
github.com/onsi/ginkgo/v2 v2.27.4/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo=
github.com/onsi/gomega v1.39.0 h1:y2ROC3hKFmQZJNFeGAMeHZKkjBL65mIZcvrLQBF9k6Q=
github.com/onsi/gomega v1.39.0/go.mod h1:ZCU1pkQcXDO5Sl9/VVEGlDyp+zm0m1cmeG5TOzLgdh4=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c=
golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU=
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw=
golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/term v0.39.0 h1:RclSuaJf32jOqZz74CkPA9qFuVTX7vhLlpfj/IGWlqY=
golang.org/x/term v0.39.0/go.mod h1:yxzUCTP/U+FzoxfdKmLaA0RV1WgE0VY7hXBwKtY/4ww=
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8=
golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA=
golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc=
golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM=
golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY=
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM=
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated/go.mod h1:RVAQXBGNv1ib0J382/DPCRS/BPnsGebyM1Gj5VSDpG8=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/evanphx/json-patch.v4 v4.13.0 h1:czT3CmqEaQ1aanPc5SdlgQrrEIb8w/wwCvWWnfEbYzo=
gopkg.in/evanphx/json-patch.v4 v4.13.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M=
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.0.0-20260121173914-4f90c5e5fa65 h1:sQVbR3zcjPhnrkpWG5M6Qh6uQsBNvz7O869vIpVCs+c=
k8s.io/api v0.0.0-20260121173914-4f90c5e5fa65/go.mod h1:lmMnF2Ji6ZiKusBzdQOW0tLYy+bzNudofBpUXjn0Wm4=
k8s.io/apimachinery v0.0.0-20260116132332-7daad7080a68 h1:Bu0nqDkpfRZ7fngY4VoyqtKhbqD4lnOU6ybw5SVGIEY=
k8s.io/apimachinery v0.0.0-20260116132332-7daad7080a68/go.mod h1:wAmXZO6lPjbtt+U0gil0pnpZcEaspEmhvj1KBBRrJpI=
k8s.io/client-go v0.0.0-20260121214359-511abf454ddf h1:VZX2W/OFQ2m88U9hVs3CZ1LFmS8u0CLwwcMrCS5ADF8=
k8s.io/client-go v0.0.0-20260121214359-511abf454ddf/go.mod h1:pdvr6B9BEfiVeGrGa2kMFrDb4ZT3WDge8/VdoAwqk8E=
k8s.io/code-generator v0.0.0-20260121215239-41a43eabae03 h1:SMCdPBoiuCxueyltX3auqIhIvdFjYwvZr0nFbjrt1cw=
k8s.io/code-generator v0.0.0-20260121215239-41a43eabae03/go.mod h1:tlu2MxD7hTgs7bX1ED+oF/Lt15ZIDomx+su3E+dhvSA=
k8s.io/gengo/v2 v2.0.0-20250922181213-ec3ebc5fd46b h1:gMplByicHV/TJBizHd9aVEsTYoJBnnUAT5MHlTkbjhQ=
k8s.io/gengo/v2 v2.0.0-20250922181213-ec3ebc5fd46b/go.mod h1:CgujABENc3KuTrcsdpGmrrASjtQsWCT7R99mEV4U/fM=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 h1:Y3gxNAuB0OBLImH611+UDZcmKS3g6CthxToOb37KgwE=
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912/go.mod h1:kdmbQkyfwUagLfXIad1y2TdrjPFWp2Q89B3qkRwf/pQ=
k8s.io/utils v0.0.0-20251219084037-98d557b7f1e7 h1:H6xtwB5tC+KFSHoEhA1o7DnOtHDEo+n9OBSHjlajVKc=
k8s.io/utils v0.0.0-20251219084037-98d557b7f1e7/go.mod h1:xDxuJ0whA3d0I4mf/C4ppKHxXynQ+fxnkmQH0vTHnuk=
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg=
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=
sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
sigs.k8s.io/structured-merge-diff/v6 v6.3.1 h1:JrhdFMqOd/+3ByqlP2I45kTOZmTRLBUm5pvRjeheg7E=
sigs.k8s.io/structured-merge-diff/v6 v6.3.1/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE=
sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs=
sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4=

View File

@@ -1,5 +1,7 @@
//go:build tools
/*
Copyright The Kubernetes Authors.
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,8 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
// This package imports things required by build scripts, to force `go mod` to see them as dependencies
package tools
package v1alpha1
type InitializerConfigurationExpansion interface{}
import _ "k8s.io/code-generator"

View File

@@ -18,18 +18,20 @@ set -o errexit
set -o nounset
set -o pipefail
SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/..
CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)}
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)}
# generate the code with:
# --output-base because this script should also be able to run inside the vendor dir of
# k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir
# instead of the $GOPATH directly. For normal projects this can be dropped.
${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \
k8s.io/sample-controller/pkg/client k8s.io/sample-controller/pkg/apis \
samplecontroller:v1alpha1 \
--output-base "$(dirname ${BASH_SOURCE})/../../.." \
--go-header-file ${SCRIPT_ROOT}/hack/boilerplate.go.txt
source "${CODEGEN_PKG}/kube_codegen.sh"
# To use your own boilerplate text use:
# --go-header-file ${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt
THIS_PKG="k8s.io/sample-controller"
kube::codegen::gen_helpers \
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
"${SCRIPT_ROOT}/pkg/apis"
kube::codegen::gen_client \
--with-watch \
--output-dir "${SCRIPT_ROOT}/pkg/generated" \
--output-pkg "${THIS_PKG}/pkg/generated" \
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
"${SCRIPT_ROOT}/pkg/apis"

View File

@@ -18,14 +18,12 @@ set -o errexit
set -o nounset
set -o pipefail
SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/..
SCRIPT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
DIFFROOT="${SCRIPT_ROOT}/pkg"
TMP_DIFFROOT="${SCRIPT_ROOT}/_tmp/pkg"
_tmp="${SCRIPT_ROOT}/_tmp"
TMP_DIFFROOT="$(mktemp -d -t "$(basename "$0").XXXXXX")/pkg"
cleanup() {
rm -rf "${_tmp}"
rm -rf "${TMP_DIFFROOT}"
}
trap "cleanup" EXIT SIGINT
@@ -38,11 +36,9 @@ cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}"
echo "diffing ${DIFFROOT} against freshly generated codegen"
ret=0
diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$?
cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}"
if [[ $ret -eq 0 ]]
then
if [[ $ret -eq 0 ]]; then
echo "${DIFFROOT} up to date."
else
echo "${DIFFROOT} is out of date. Please run hack/update-codegen.sh"
exit 1
fi
exit $ret

36
main.go
View File

@@ -20,16 +20,16 @@ import (
"flag"
"time"
"github.com/golang/glog"
kubeinformers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/klog/v2"
"k8s.io/sample-controller/pkg/signals"
// Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters).
// _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
clientset "k8s.io/sample-controller/pkg/client/clientset/versioned"
informers "k8s.io/sample-controller/pkg/client/informers/externalversions"
"k8s.io/sample-controller/pkg/signals"
clientset "k8s.io/sample-controller/pkg/generated/clientset/versioned"
informers "k8s.io/sample-controller/pkg/generated/informers/externalversions"
)
var (
@@ -38,38 +38,46 @@ var (
)
func main() {
klog.InitFlags(nil)
flag.Parse()
// set up signals so we handle the first shutdown signal gracefully
stopCh := signals.SetupSignalHandler()
// set up signals so we handle the shutdown signal gracefully
ctx := signals.SetupSignalHandler()
logger := klog.FromContext(ctx)
cfg, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfig)
if err != nil {
glog.Fatalf("Error building kubeconfig: %s", err.Error())
logger.Error(err, "Error building kubeconfig")
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
}
kubeClient, err := kubernetes.NewForConfig(cfg)
if err != nil {
glog.Fatalf("Error building kubernetes clientset: %s", err.Error())
logger.Error(err, "Error building kubernetes clientset")
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
}
exampleClient, err := clientset.NewForConfig(cfg)
if err != nil {
glog.Fatalf("Error building example clientset: %s", err.Error())
logger.Error(err, "Error building kubernetes clientset")
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
}
kubeInformerFactory := kubeinformers.NewSharedInformerFactory(kubeClient, time.Second*30)
exampleInformerFactory := informers.NewSharedInformerFactory(exampleClient, time.Second*30)
controller := NewController(kubeClient, exampleClient,
controller := NewController(ctx, kubeClient, exampleClient,
kubeInformerFactory.Apps().V1().Deployments(),
exampleInformerFactory.Samplecontroller().V1alpha1().Foos())
go kubeInformerFactory.Start(stopCh)
go exampleInformerFactory.Start(stopCh)
// notice that there is no need to run Start methods in a separate goroutine. (i.e. go kubeInformerFactory.Start(ctx.done())
// Start method is non-blocking and runs all registered informers in a dedicated goroutine.
kubeInformerFactory.Start(ctx.Done())
exampleInformerFactory.Start(ctx.Done())
if err = controller.Run(2, stopCh); err != nil {
glog.Fatalf("Error running controller: %s", err.Error())
if err = controller.Run(ctx, 2); err != nil {
logger.Error(err, "Error running controller")
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
}
}

View File

@@ -16,6 +16,7 @@ limitations under the License.
package samplecontroller
// GroupName is the group name used in this package
const (
GroupName = "samplecontroller.k8s.io"
)

View File

@@ -15,7 +15,7 @@ limitations under the License.
*/
// +k8s:deepcopy-gen=package
// +groupName=samplecontroller.k8s.io
// Package v1alpha1 is the v1alpha1 version of the API.
// +groupName=samplecontroller.k8s.io
package v1alpha1

View File

@@ -38,8 +38,10 @@ func Resource(resource string) schema.GroupResource {
}
var (
// SchemeBuilder initializes a scheme builder
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
// AddToScheme is a global function that registers this API group & version to a scheme
AddToScheme = SchemeBuilder.AddToScheme
)
// Adds the list of known types to Scheme.

View File

@@ -1,3 +1,4 @@
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
/*
@@ -56,7 +57,7 @@ func (in *Foo) DeepCopyObject() runtime.Object {
func (in *FooList) DeepCopyInto(out *FooList) {
*out = *in
out.TypeMeta = in.TypeMeta
out.ListMeta = in.ListMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]Foo, len(*in))

View File

@@ -1,20 +0,0 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
// This package has the automatically generated clientset.
package versioned

View File

@@ -1,140 +0,0 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
v1alpha1 "k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1"
)
// FakeFoos implements FooInterface
type FakeFoos struct {
Fake *FakeSamplecontrollerV1alpha1
ns string
}
var foosResource = schema.GroupVersionResource{Group: "samplecontroller.k8s.io", Version: "v1alpha1", Resource: "foos"}
var foosKind = schema.GroupVersionKind{Group: "samplecontroller.k8s.io", Version: "v1alpha1", Kind: "Foo"}
// Get takes name of the foo, and returns the corresponding foo object, and an error if there is any.
func (c *FakeFoos) Get(name string, options v1.GetOptions) (result *v1alpha1.Foo, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(foosResource, c.ns, name), &v1alpha1.Foo{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.Foo), err
}
// List takes label and field selectors, and returns the list of Foos that match those selectors.
func (c *FakeFoos) List(opts v1.ListOptions) (result *v1alpha1.FooList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(foosResource, foosKind, c.ns, opts), &v1alpha1.FooList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha1.FooList{ListMeta: obj.(*v1alpha1.FooList).ListMeta}
for _, item := range obj.(*v1alpha1.FooList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested foos.
func (c *FakeFoos) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(foosResource, c.ns, opts))
}
// Create takes the representation of a foo and creates it. Returns the server's representation of the foo, and an error, if there is any.
func (c *FakeFoos) Create(foo *v1alpha1.Foo) (result *v1alpha1.Foo, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(foosResource, c.ns, foo), &v1alpha1.Foo{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.Foo), err
}
// Update takes the representation of a foo and updates it. Returns the server's representation of the foo, and an error, if there is any.
func (c *FakeFoos) Update(foo *v1alpha1.Foo) (result *v1alpha1.Foo, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(foosResource, c.ns, foo), &v1alpha1.Foo{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.Foo), err
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *FakeFoos) UpdateStatus(foo *v1alpha1.Foo) (*v1alpha1.Foo, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(foosResource, "status", c.ns, foo), &v1alpha1.Foo{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.Foo), err
}
// Delete takes name of the foo and deletes it. Returns an error if one occurs.
func (c *FakeFoos) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(foosResource, c.ns, name), &v1alpha1.Foo{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeFoos) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(foosResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &v1alpha1.FooList{})
return err
}
// Patch applies the patch and returns the patched foo.
func (c *FakeFoos) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Foo, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(foosResource, c.ns, name, data, subresources...), &v1alpha1.Foo{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha1.Foo), err
}

View File

@@ -1,174 +0,0 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
rest "k8s.io/client-go/rest"
v1alpha1 "k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1"
scheme "k8s.io/sample-controller/pkg/client/clientset/versioned/scheme"
)
// FoosGetter has a method to return a FooInterface.
// A group's client should implement this interface.
type FoosGetter interface {
Foos(namespace string) FooInterface
}
// FooInterface has methods to work with Foo resources.
type FooInterface interface {
Create(*v1alpha1.Foo) (*v1alpha1.Foo, error)
Update(*v1alpha1.Foo) (*v1alpha1.Foo, error)
UpdateStatus(*v1alpha1.Foo) (*v1alpha1.Foo, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string, options v1.GetOptions) (*v1alpha1.Foo, error)
List(opts v1.ListOptions) (*v1alpha1.FooList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Foo, err error)
FooExpansion
}
// foos implements FooInterface
type foos struct {
client rest.Interface
ns string
}
// newFoos returns a Foos
func newFoos(c *SamplecontrollerV1alpha1Client, namespace string) *foos {
return &foos{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the foo, and returns the corresponding foo object, and an error if there is any.
func (c *foos) Get(name string, options v1.GetOptions) (result *v1alpha1.Foo, err error) {
result = &v1alpha1.Foo{}
err = c.client.Get().
Namespace(c.ns).
Resource("foos").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of Foos that match those selectors.
func (c *foos) List(opts v1.ListOptions) (result *v1alpha1.FooList, err error) {
result = &v1alpha1.FooList{}
err = c.client.Get().
Namespace(c.ns).
Resource("foos").
VersionedParams(&opts, scheme.ParameterCodec).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested foos.
func (c *foos) Watch(opts v1.ListOptions) (watch.Interface, error) {
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("foos").
VersionedParams(&opts, scheme.ParameterCodec).
Watch()
}
// Create takes the representation of a foo and creates it. Returns the server's representation of the foo, and an error, if there is any.
func (c *foos) Create(foo *v1alpha1.Foo) (result *v1alpha1.Foo, err error) {
result = &v1alpha1.Foo{}
err = c.client.Post().
Namespace(c.ns).
Resource("foos").
Body(foo).
Do().
Into(result)
return
}
// Update takes the representation of a foo and updates it. Returns the server's representation of the foo, and an error, if there is any.
func (c *foos) Update(foo *v1alpha1.Foo) (result *v1alpha1.Foo, err error) {
result = &v1alpha1.Foo{}
err = c.client.Put().
Namespace(c.ns).
Resource("foos").
Name(foo.Name).
Body(foo).
Do().
Into(result)
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
func (c *foos) UpdateStatus(foo *v1alpha1.Foo) (result *v1alpha1.Foo, err error) {
result = &v1alpha1.Foo{}
err = c.client.Put().
Namespace(c.ns).
Resource("foos").
Name(foo.Name).
SubResource("status").
Body(foo).
Do().
Into(result)
return
}
// Delete takes name of the foo and deletes it. Returns an error if one occurs.
func (c *foos) Delete(name string, options *v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("foos").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *foos) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("foos").
VersionedParams(&listOptions, scheme.ParameterCodec).
Body(options).
Do().
Error()
}
// Patch applies the patch and returns the patched foo.
func (c *foos) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Foo, err error) {
result = &v1alpha1.Foo{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("foos").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}

View File

@@ -1,38 +0,0 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by informer-gen. DO NOT EDIT.
package internalinterfaces
import (
time "time"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
cache "k8s.io/client-go/tools/cache"
versioned "k8s.io/sample-controller/pkg/client/clientset/versioned"
)
type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer
// SharedInformerFactory a small interface to allow for adding an informer without an import cycle
type SharedInformerFactory interface {
Start(stopCh <-chan struct{})
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
}
type TweakListOptionsFunc func(*v1.ListOptions)

View File

@@ -19,21 +19,21 @@ limitations under the License.
package versioned
import (
fmt "fmt"
http "net/http"
discovery "k8s.io/client-go/discovery"
rest "k8s.io/client-go/rest"
flowcontrol "k8s.io/client-go/util/flowcontrol"
samplecontrollerv1alpha1 "k8s.io/sample-controller/pkg/client/clientset/versioned/typed/samplecontroller/v1alpha1"
samplecontrollerv1alpha1 "k8s.io/sample-controller/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1"
)
type Interface interface {
Discovery() discovery.DiscoveryInterface
SamplecontrollerV1alpha1() samplecontrollerv1alpha1.SamplecontrollerV1alpha1Interface
// Deprecated: please explicitly pick a version if possible.
Samplecontroller() samplecontrollerv1alpha1.SamplecontrollerV1alpha1Interface
}
// Clientset contains the clients for groups. Each group has exactly one
// version included in a Clientset.
// Clientset contains the clients for groups.
type Clientset struct {
*discovery.DiscoveryClient
samplecontrollerV1alpha1 *samplecontrollerv1alpha1.SamplecontrollerV1alpha1Client
@@ -44,12 +44,6 @@ func (c *Clientset) SamplecontrollerV1alpha1() samplecontrollerv1alpha1.Sampleco
return c.samplecontrollerV1alpha1
}
// Deprecated: Samplecontroller retrieves the default version of SamplecontrollerClient.
// Please explicitly pick a version.
func (c *Clientset) Samplecontroller() samplecontrollerv1alpha1.SamplecontrollerV1alpha1Interface {
return c.samplecontrollerV1alpha1
}
// Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
if c == nil {
@@ -59,19 +53,47 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface {
}
// NewForConfig creates a new Clientset for the given config.
// If config's RateLimiter is not set and QPS and Burst are acceptable,
// NewForConfig will generate a rate-limiter in configShallowCopy.
// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
// where httpClient was generated with rest.HTTPClientFor(c).
func NewForConfig(c *rest.Config) (*Clientset, error) {
configShallowCopy := *c
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
if configShallowCopy.UserAgent == "" {
configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent()
}
var cs Clientset
var err error
cs.samplecontrollerV1alpha1, err = samplecontrollerv1alpha1.NewForConfig(&configShallowCopy)
// share the transport between all clients
httpClient, err := rest.HTTPClientFor(&configShallowCopy)
if err != nil {
return nil, err
}
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
return NewForConfigAndClient(&configShallowCopy, httpClient)
}
// NewForConfigAndClient creates a new Clientset for the given config and http client.
// Note the http client provided takes precedence over the configured transport values.
// If config's RateLimiter is not set and QPS and Burst are acceptable,
// NewForConfigAndClient will generate a rate-limiter in configShallowCopy.
func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) {
configShallowCopy := *c
if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
if configShallowCopy.Burst <= 0 {
return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0")
}
configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
}
var cs Clientset
var err error
cs.samplecontrollerV1alpha1, err = samplecontrollerv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient)
if err != nil {
return nil, err
}
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient)
if err != nil {
return nil, err
}
@@ -81,11 +103,11 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
// NewForConfigOrDie creates a new Clientset for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *Clientset {
var cs Clientset
cs.samplecontrollerV1alpha1 = samplecontrollerv1alpha1.NewForConfigOrDie(c)
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
return &cs
cs, err := NewForConfig(c)
if err != nil {
panic(err)
}
return cs
}
// New creates a new Clientset for the given RESTClient.

View File

@@ -19,20 +19,25 @@ limitations under the License.
package fake
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/discovery"
fakediscovery "k8s.io/client-go/discovery/fake"
"k8s.io/client-go/testing"
clientset "k8s.io/sample-controller/pkg/client/clientset/versioned"
samplecontrollerv1alpha1 "k8s.io/sample-controller/pkg/client/clientset/versioned/typed/samplecontroller/v1alpha1"
fakesamplecontrollerv1alpha1 "k8s.io/sample-controller/pkg/client/clientset/versioned/typed/samplecontroller/v1alpha1/fake"
clientset "k8s.io/sample-controller/pkg/generated/clientset/versioned"
samplecontrollerv1alpha1 "k8s.io/sample-controller/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1"
fakesamplecontrollerv1alpha1 "k8s.io/sample-controller/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake"
)
// NewSimpleClientset returns a clientset that will respond with the provided objects.
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
// without applying any validations and/or defaults. It shouldn't be considered a replacement
// without applying any field management, validations and/or defaults. It shouldn't be considered a replacement
// for a real clientset and is mostly useful in simple unit tests.
//
// Deprecated: NewClientset replaces this with support for field management, which significantly improves
// server side apply testing. NewClientset is only available when apply configurations are generated (e.g.
// via --with-applyconfig).
func NewSimpleClientset(objects ...runtime.Object) *Clientset {
o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
for _, obj := range objects {
@@ -41,13 +46,17 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
}
}
cs := &Clientset{}
cs := &Clientset{tracker: o}
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
cs.AddReactor("*", "*", testing.ObjectReaction(o))
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
var opts metav1.ListOptions
if watchAction, ok := action.(testing.WatchActionImpl); ok {
opts = watchAction.ListOptions
}
gvr := action.GetResource()
ns := action.GetNamespace()
watch, err := o.Watch(gvr, ns)
watch, err := o.Watch(gvr, ns, opts)
if err != nil {
return false, nil, err
}
@@ -63,20 +72,34 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
type Clientset struct {
testing.Fake
discovery *fakediscovery.FakeDiscovery
tracker testing.ObjectTracker
}
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
return c.discovery
}
var _ clientset.Interface = &Clientset{}
func (c *Clientset) Tracker() testing.ObjectTracker {
return c.tracker
}
// IsWatchListSemanticsSupported informs the reflector that this client
// doesn't support WatchList semantics.
//
// This is a synthetic method whose sole purpose is to satisfy the optional
// interface check performed by the reflector.
// Returning true signals that WatchList can NOT be used.
// No additional logic is implemented here.
func (c *Clientset) IsWatchListSemanticsUnSupported() bool {
return true
}
var (
_ clientset.Interface = &Clientset{}
_ testing.FakeClient = &Clientset{}
)
// SamplecontrollerV1alpha1 retrieves the SamplecontrollerV1alpha1Client
func (c *Clientset) SamplecontrollerV1alpha1() samplecontrollerv1alpha1.SamplecontrollerV1alpha1Interface {
return &fakesamplecontrollerv1alpha1.FakeSamplecontrollerV1alpha1{Fake: &c.Fake}
}
// Samplecontroller retrieves the SamplecontrollerV1alpha1Client
func (c *Clientset) Samplecontroller() samplecontrollerv1alpha1.SamplecontrollerV1alpha1Interface {
return &fakesamplecontrollerv1alpha1.FakeSamplecontrollerV1alpha1{Fake: &c.Fake}
}

View File

@@ -29,7 +29,7 @@ import (
var scheme = runtime.NewScheme()
var codecs = serializer.NewCodecFactory(scheme)
var parameterCodec = runtime.NewParameterCodec(scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
samplecontrollerv1alpha1.AddToScheme,
}
@@ -37,14 +37,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
// of clientsets, like in:
//
// import (
// "k8s.io/client-go/kubernetes"
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
// )
// import (
// "k8s.io/client-go/kubernetes"
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
// )
//
// kclientset, _ := kubernetes.NewForConfig(c)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
// kclientset, _ := kubernetes.NewForConfig(c)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
//
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.

View File

@@ -37,14 +37,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
// of clientsets, like in:
//
// import (
// "k8s.io/client-go/kubernetes"
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
// )
// import (
// "k8s.io/client-go/kubernetes"
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
// )
//
// kclientset, _ := kubernetes.NewForConfig(c)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
// kclientset, _ := kubernetes.NewForConfig(c)
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
//
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
// correctly.

View File

@@ -0,0 +1,48 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package fake
import (
gentype "k8s.io/client-go/gentype"
v1alpha1 "k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1"
samplecontrollerv1alpha1 "k8s.io/sample-controller/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1"
)
// fakeFoos implements FooInterface
type fakeFoos struct {
*gentype.FakeClientWithList[*v1alpha1.Foo, *v1alpha1.FooList]
Fake *FakeSamplecontrollerV1alpha1
}
func newFakeFoos(fake *FakeSamplecontrollerV1alpha1, namespace string) samplecontrollerv1alpha1.FooInterface {
return &fakeFoos{
gentype.NewFakeClientWithList[*v1alpha1.Foo, *v1alpha1.FooList](
fake.Fake,
namespace,
v1alpha1.SchemeGroupVersion.WithResource("foos"),
v1alpha1.SchemeGroupVersion.WithKind("Foo"),
func() *v1alpha1.Foo { return &v1alpha1.Foo{} },
func() *v1alpha1.FooList { return &v1alpha1.FooList{} },
func(dst, src *v1alpha1.FooList) { dst.ListMeta = src.ListMeta },
func(list *v1alpha1.FooList) []*v1alpha1.Foo { return gentype.ToPointerSlice(list.Items) },
func(list *v1alpha1.FooList, items []*v1alpha1.Foo) { list.Items = gentype.FromPointerSlice(items) },
),
fake,
}
}

View File

@@ -21,7 +21,7 @@ package fake
import (
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
v1alpha1 "k8s.io/sample-controller/pkg/client/clientset/versioned/typed/samplecontroller/v1alpha1"
v1alpha1 "k8s.io/sample-controller/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1"
)
type FakeSamplecontrollerV1alpha1 struct {
@@ -29,7 +29,7 @@ type FakeSamplecontrollerV1alpha1 struct {
}
func (c *FakeSamplecontrollerV1alpha1) Foos(namespace string) v1alpha1.FooInterface {
return &FakeFoos{c, namespace}
return newFakeFoos(c, namespace)
}
// RESTClient returns a RESTClient that is used to communicate

View File

@@ -0,0 +1,70 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
import (
context "context"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
gentype "k8s.io/client-go/gentype"
samplecontrollerv1alpha1 "k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1"
scheme "k8s.io/sample-controller/pkg/generated/clientset/versioned/scheme"
)
// FoosGetter has a method to return a FooInterface.
// A group's client should implement this interface.
type FoosGetter interface {
Foos(namespace string) FooInterface
}
// FooInterface has methods to work with Foo resources.
type FooInterface interface {
Create(ctx context.Context, foo *samplecontrollerv1alpha1.Foo, opts v1.CreateOptions) (*samplecontrollerv1alpha1.Foo, error)
Update(ctx context.Context, foo *samplecontrollerv1alpha1.Foo, opts v1.UpdateOptions) (*samplecontrollerv1alpha1.Foo, error)
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
UpdateStatus(ctx context.Context, foo *samplecontrollerv1alpha1.Foo, opts v1.UpdateOptions) (*samplecontrollerv1alpha1.Foo, error)
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
Get(ctx context.Context, name string, opts v1.GetOptions) (*samplecontrollerv1alpha1.Foo, error)
List(ctx context.Context, opts v1.ListOptions) (*samplecontrollerv1alpha1.FooList, error)
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *samplecontrollerv1alpha1.Foo, err error)
FooExpansion
}
// foos implements FooInterface
type foos struct {
*gentype.ClientWithList[*samplecontrollerv1alpha1.Foo, *samplecontrollerv1alpha1.FooList]
}
// newFoos returns a Foos
func newFoos(c *SamplecontrollerV1alpha1Client, namespace string) *foos {
return &foos{
gentype.NewClientWithList[*samplecontrollerv1alpha1.Foo, *samplecontrollerv1alpha1.FooList](
"foos",
c.RESTClient(),
scheme.ParameterCodec,
namespace,
func() *samplecontrollerv1alpha1.Foo { return &samplecontrollerv1alpha1.Foo{} },
func() *samplecontrollerv1alpha1.FooList { return &samplecontrollerv1alpha1.FooList{} },
),
}
}

View File

@@ -19,10 +19,11 @@ limitations under the License.
package v1alpha1
import (
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
http "net/http"
rest "k8s.io/client-go/rest"
v1alpha1 "k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1"
"k8s.io/sample-controller/pkg/client/clientset/versioned/scheme"
samplecontrollerv1alpha1 "k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1"
scheme "k8s.io/sample-controller/pkg/generated/clientset/versioned/scheme"
)
type SamplecontrollerV1alpha1Interface interface {
@@ -40,12 +41,24 @@ func (c *SamplecontrollerV1alpha1Client) Foos(namespace string) FooInterface {
}
// NewForConfig creates a new SamplecontrollerV1alpha1Client for the given config.
// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
// where httpClient was generated with rest.HTTPClientFor(c).
func NewForConfig(c *rest.Config) (*SamplecontrollerV1alpha1Client, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
setConfigDefaults(&config)
httpClient, err := rest.HTTPClientFor(&config)
if err != nil {
return nil, err
}
client, err := rest.RESTClientFor(&config)
return NewForConfigAndClient(&config, httpClient)
}
// NewForConfigAndClient creates a new SamplecontrollerV1alpha1Client for the given config and http client.
// Note the http client provided takes precedence over the configured transport values.
func NewForConfigAndClient(c *rest.Config, h *http.Client) (*SamplecontrollerV1alpha1Client, error) {
config := *c
setConfigDefaults(&config)
client, err := rest.RESTClientForConfigAndClient(&config, h)
if err != nil {
return nil, err
}
@@ -67,17 +80,15 @@ func New(c rest.Interface) *SamplecontrollerV1alpha1Client {
return &SamplecontrollerV1alpha1Client{c}
}
func setConfigDefaults(config *rest.Config) error {
gv := v1alpha1.SchemeGroupVersion
func setConfigDefaults(config *rest.Config) {
gv := samplecontrollerv1alpha1.SchemeGroupVersion
config.GroupVersion = &gv
config.APIPath = "/apis"
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs}
config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(scheme.Scheme, scheme.Codecs).WithoutConversion()
if config.UserAgent == "" {
config.UserAgent = rest.DefaultKubernetesUserAgent()
}
return nil
}
// RESTClient returns a RESTClient that is used to communicate

View File

@@ -27,9 +27,9 @@ import (
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"
versioned "k8s.io/sample-controller/pkg/client/clientset/versioned"
internalinterfaces "k8s.io/sample-controller/pkg/client/informers/externalversions/internalinterfaces"
samplecontroller "k8s.io/sample-controller/pkg/client/informers/externalversions/samplecontroller"
versioned "k8s.io/sample-controller/pkg/generated/clientset/versioned"
internalinterfaces "k8s.io/sample-controller/pkg/generated/informers/externalversions/internalinterfaces"
samplecontroller "k8s.io/sample-controller/pkg/generated/informers/externalversions/samplecontroller"
)
// SharedInformerOption defines the functional option type for SharedInformerFactory.
@@ -42,11 +42,17 @@ type sharedInformerFactory struct {
lock sync.Mutex
defaultResync time.Duration
customResync map[reflect.Type]time.Duration
transform cache.TransformFunc
informers map[reflect.Type]cache.SharedIndexInformer
// startedInformers is used for tracking which informers have been started.
// This allows Start() to be called multiple times safely.
startedInformers map[reflect.Type]bool
// wg tracks how many goroutines were started.
wg sync.WaitGroup
// shuttingDown is true when Shutdown has been called. It may still be running
// because it needs to wait for goroutines.
shuttingDown bool
}
// WithCustomResyncConfig sets a custom resync period for the specified informer types.
@@ -75,6 +81,14 @@ func WithNamespace(namespace string) SharedInformerOption {
}
}
// WithTransform sets a transform on all informers.
func WithTransform(transform cache.TransformFunc) SharedInformerOption {
return func(factory *sharedInformerFactory) *sharedInformerFactory {
factory.transform = transform
return factory
}
}
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces.
func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory {
return NewSharedInformerFactoryWithOptions(client, defaultResync)
@@ -83,6 +97,7 @@ func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Dur
// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory.
// Listers obtained via this SharedInformerFactory will be subject to the same filters
// as specified here.
//
// Deprecated: Please use NewSharedInformerFactoryWithOptions instead
func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory {
return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions))
@@ -107,20 +122,39 @@ func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResy
return factory
}
// Start initializes all requested informers.
func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) {
f.lock.Lock()
defer f.lock.Unlock()
if f.shuttingDown {
return
}
for informerType, informer := range f.informers {
if !f.startedInformers[informerType] {
go informer.Run(stopCh)
f.wg.Add(1)
// We need a new variable in each loop iteration,
// otherwise the goroutine would use the loop variable
// and that keeps changing.
informer := informer
go func() {
defer f.wg.Done()
informer.Run(stopCh)
}()
f.startedInformers[informerType] = true
}
}
}
// WaitForCacheSync waits for all started informers' cache were synced.
func (f *sharedInformerFactory) Shutdown() {
f.lock.Lock()
f.shuttingDown = true
f.lock.Unlock()
// Will return immediately if there is nothing to wait for.
f.wg.Wait()
}
func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool {
informers := func() map[reflect.Type]cache.SharedIndexInformer {
f.lock.Lock()
@@ -142,7 +176,7 @@ func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[ref
return res
}
// InternalInformerFor returns the SharedIndexInformer for obj using an internal
// InformerFor returns the SharedIndexInformer for obj using an internal
// client.
func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer {
f.lock.Lock()
@@ -160,6 +194,7 @@ func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internal
}
informer = newFunc(f.client, resyncPeriod)
informer.SetTransform(f.transform)
f.informers[informerType] = informer
return informer
@@ -167,11 +202,59 @@ func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internal
// SharedInformerFactory provides shared informers for resources in all known
// API group versions.
//
// It is typically used like this:
//
// ctx, cancel := context.WithCancel(context.Background())
// defer cancel()
// factory := NewSharedInformerFactory(client, resyncPeriod)
// defer factory.WaitForStop() // Returns immediately if nothing was started.
// genericInformer := factory.ForResource(resource)
// typedInformer := factory.SomeAPIGroup().V1().SomeType()
// factory.Start(ctx.Done()) // Start processing these informers.
// synced := factory.WaitForCacheSync(ctx.Done())
// for v, ok := range synced {
// if !ok {
// fmt.Fprintf(os.Stderr, "caches failed to sync: %v", v)
// return
// }
// }
//
// // Creating informers can also be created after Start, but then
// // Start must be called again:
// anotherGenericInformer := factory.ForResource(resource)
// factory.Start(ctx.Done())
type SharedInformerFactory interface {
internalinterfaces.SharedInformerFactory
ForResource(resource schema.GroupVersionResource) (GenericInformer, error)
// Start initializes all requested informers. They are handled in goroutines
// which run until the stop channel gets closed.
// Warning: Start does not block. When run in a go-routine, it will race with a later WaitForCacheSync.
Start(stopCh <-chan struct{})
// Shutdown marks a factory as shutting down. At that point no new
// informers can be started anymore and Start will return without
// doing anything.
//
// In addition, Shutdown blocks until all goroutines have terminated. For that
// to happen, the close channel(s) that they were started with must be closed,
// either before Shutdown gets called or while it is waiting.
//
// Shutdown may be called multiple times, even concurrently. All such calls will
// block until all goroutines have terminated.
Shutdown()
// WaitForCacheSync blocks until all started informers' caches were synced
// or the stop channel gets closed.
WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool
// ForResource gives generic access to a shared informer of the matching type.
ForResource(resource schema.GroupVersionResource) (GenericInformer, error)
// InformerFor returns the SharedIndexInformer for obj using an internal
// client.
InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer
Samplecontroller() samplecontroller.Interface
}

View File

@@ -19,7 +19,7 @@ limitations under the License.
package externalversions
import (
"fmt"
fmt "fmt"
schema "k8s.io/apimachinery/pkg/runtime/schema"
cache "k8s.io/client-go/tools/cache"

View File

@@ -24,9 +24,10 @@ import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
cache "k8s.io/client-go/tools/cache"
versioned "k8s.io/code-generator/_examples/crd/clientset/versioned"
versioned "k8s.io/sample-controller/pkg/generated/clientset/versioned"
)
// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer.
type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer
// SharedInformerFactory a small interface to allow for adding an informer without an import cycle
@@ -35,4 +36,5 @@ type SharedInformerFactory interface {
InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer
}
// TweakListOptionsFunc is a function that transforms a v1.ListOptions.
type TweakListOptionsFunc func(*v1.ListOptions)

View File

@@ -19,8 +19,8 @@ limitations under the License.
package samplecontroller
import (
internalinterfaces "k8s.io/sample-controller/pkg/client/informers/externalversions/internalinterfaces"
v1alpha1 "k8s.io/sample-controller/pkg/client/informers/externalversions/samplecontroller/v1alpha1"
internalinterfaces "k8s.io/sample-controller/pkg/generated/informers/externalversions/internalinterfaces"
v1alpha1 "k8s.io/sample-controller/pkg/generated/informers/externalversions/samplecontroller/v1alpha1"
)
// Interface provides access to each of this group's versions.

View File

@@ -19,23 +19,24 @@ limitations under the License.
package v1alpha1
import (
context "context"
time "time"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
samplecontrollerv1alpha1 "k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1"
versioned "k8s.io/sample-controller/pkg/client/clientset/versioned"
internalinterfaces "k8s.io/sample-controller/pkg/client/informers/externalversions/internalinterfaces"
v1alpha1 "k8s.io/sample-controller/pkg/client/listers/samplecontroller/v1alpha1"
apissamplecontrollerv1alpha1 "k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1"
versioned "k8s.io/sample-controller/pkg/generated/clientset/versioned"
internalinterfaces "k8s.io/sample-controller/pkg/generated/informers/externalversions/internalinterfaces"
samplecontrollerv1alpha1 "k8s.io/sample-controller/pkg/generated/listers/samplecontroller/v1alpha1"
)
// FooInformer provides access to a shared informer and lister for
// Foos.
type FooInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1alpha1.FooLister
Lister() samplecontrollerv1alpha1.FooLister
}
type fooInformer struct {
@@ -56,21 +57,33 @@ func NewFooInformer(client versioned.Interface, namespace string, resyncPeriod t
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredFooInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
cache.ToListWatcherWithWatchListSemantics(&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.SamplecontrollerV1alpha1().Foos(namespace).List(options)
return client.SamplecontrollerV1alpha1().Foos(namespace).List(context.Background(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.SamplecontrollerV1alpha1().Foos(namespace).Watch(options)
return client.SamplecontrollerV1alpha1().Foos(namespace).Watch(context.Background(), options)
},
},
&samplecontrollerv1alpha1.Foo{},
ListWithContextFunc: func(ctx context.Context, options v1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.SamplecontrollerV1alpha1().Foos(namespace).List(ctx, options)
},
WatchFuncWithContext: func(ctx context.Context, options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.SamplecontrollerV1alpha1().Foos(namespace).Watch(ctx, options)
},
}, client),
&apissamplecontrollerv1alpha1.Foo{},
resyncPeriod,
indexers,
)
@@ -81,9 +94,9 @@ func (f *fooInformer) defaultInformer(client versioned.Interface, resyncPeriod t
}
func (f *fooInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&samplecontrollerv1alpha1.Foo{}, f.defaultInformer)
return f.factory.InformerFor(&apissamplecontrollerv1alpha1.Foo{}, f.defaultInformer)
}
func (f *fooInformer) Lister() v1alpha1.FooLister {
return v1alpha1.NewFooLister(f.Informer().GetIndexer())
func (f *fooInformer) Lister() samplecontrollerv1alpha1.FooLister {
return samplecontrollerv1alpha1.NewFooLister(f.Informer().GetIndexer())
}

View File

@@ -19,7 +19,7 @@ limitations under the License.
package v1alpha1
import (
internalinterfaces "k8s.io/sample-controller/pkg/client/informers/externalversions/internalinterfaces"
internalinterfaces "k8s.io/sample-controller/pkg/generated/informers/externalversions/internalinterfaces"
)
// Interface provides access to all the informers in this group version.

View File

@@ -19,16 +19,18 @@ limitations under the License.
package v1alpha1
import (
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
v1alpha1 "k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1"
labels "k8s.io/apimachinery/pkg/labels"
listers "k8s.io/client-go/listers"
cache "k8s.io/client-go/tools/cache"
samplecontrollerv1alpha1 "k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1"
)
// FooLister helps list Foos.
// All objects returned here must be treated as read-only.
type FooLister interface {
// List lists all Foos in the indexer.
List(selector labels.Selector) (ret []*v1alpha1.Foo, err error)
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*samplecontrollerv1alpha1.Foo, err error)
// Foos returns an object that can list and get Foos.
Foos(namespace string) FooNamespaceLister
FooListerExpansion
@@ -36,59 +38,33 @@ type FooLister interface {
// fooLister implements the FooLister interface.
type fooLister struct {
indexer cache.Indexer
listers.ResourceIndexer[*samplecontrollerv1alpha1.Foo]
}
// NewFooLister returns a new FooLister.
func NewFooLister(indexer cache.Indexer) FooLister {
return &fooLister{indexer: indexer}
}
// List lists all Foos in the indexer.
func (s *fooLister) List(selector labels.Selector) (ret []*v1alpha1.Foo, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.Foo))
})
return ret, err
return &fooLister{listers.New[*samplecontrollerv1alpha1.Foo](indexer, samplecontrollerv1alpha1.Resource("foo"))}
}
// Foos returns an object that can list and get Foos.
func (s *fooLister) Foos(namespace string) FooNamespaceLister {
return fooNamespaceLister{indexer: s.indexer, namespace: namespace}
return fooNamespaceLister{listers.NewNamespaced[*samplecontrollerv1alpha1.Foo](s.ResourceIndexer, namespace)}
}
// FooNamespaceLister helps list and get Foos.
// All objects returned here must be treated as read-only.
type FooNamespaceLister interface {
// List lists all Foos in the indexer for a given namespace.
List(selector labels.Selector) (ret []*v1alpha1.Foo, err error)
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*samplecontrollerv1alpha1.Foo, err error)
// Get retrieves the Foo from the indexer for a given namespace and name.
Get(name string) (*v1alpha1.Foo, error)
// Objects returned here must be treated as read-only.
Get(name string) (*samplecontrollerv1alpha1.Foo, error)
FooNamespaceListerExpansion
}
// fooNamespaceLister implements the FooNamespaceLister
// interface.
type fooNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all Foos in the indexer for a given namespace.
func (s fooNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Foo, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha1.Foo))
})
return ret, err
}
// Get retrieves the Foo from the indexer for a given namespace and name.
func (s fooNamespaceLister) Get(name string) (*v1alpha1.Foo, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1alpha1.Resource("foo"), name)
}
return obj.(*v1alpha1.Foo), nil
listers.ResourceIndexer[*samplecontrollerv1alpha1.Foo]
}

View File

@@ -17,27 +17,28 @@ limitations under the License.
package signals
import (
"context"
"os"
"os/signal"
)
var onlyOneSignalHandler = make(chan struct{})
// SetupSignalHandler registered for SIGTERM and SIGINT. A stop channel is returned
// which is closed on one of these signals. If a second signal is caught, the program
// is terminated with exit code 1.
func SetupSignalHandler() (stopCh <-chan struct{}) {
// SetupSignalHandler registered for SIGTERM and SIGINT. A context is returned
// which is cancelled on one of these signals. If a second signal is caught,
// the program is terminated with exit code 1.
func SetupSignalHandler() context.Context {
close(onlyOneSignalHandler) // panics when called twice
stop := make(chan struct{})
c := make(chan os.Signal, 2)
ctx, cancel := context.WithCancel(context.Background())
signal.Notify(c, shutdownSignals...)
go func() {
<-c
close(stop)
cancel()
<-c
os.Exit(1) // second signal. Exit directly.
}()
return stop
return ctx
}

View File

@@ -1,4 +1,4 @@
// +build !windows
//go:build !windows
/*
Copyright 2017 The Kubernetes Authors.

View File

@@ -1,15 +0,0 @@
ISC License
Copyright (c) 2012-2016 Dave Collins <dave@davec.name>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View File

@@ -1,152 +0,0 @@
// Copyright (c) 2015-2016 Dave Collins <dave@davec.name>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
// NOTE: Due to the following build constraints, this file will only be compiled
// when the code is not running on Google App Engine, compiled by GopherJS, and
// "-tags safe" is not added to the go build command line. The "disableunsafe"
// tag is deprecated and thus should not be used.
// +build !js,!appengine,!safe,!disableunsafe
package spew
import (
"reflect"
"unsafe"
)
const (
// UnsafeDisabled is a build-time constant which specifies whether or
// not access to the unsafe package is available.
UnsafeDisabled = false
// ptrSize is the size of a pointer on the current arch.
ptrSize = unsafe.Sizeof((*byte)(nil))
)
var (
// offsetPtr, offsetScalar, and offsetFlag are the offsets for the
// internal reflect.Value fields. These values are valid before golang
// commit ecccf07e7f9d which changed the format. The are also valid
// after commit 82f48826c6c7 which changed the format again to mirror
// the original format. Code in the init function updates these offsets
// as necessary.
offsetPtr = uintptr(ptrSize)
offsetScalar = uintptr(0)
offsetFlag = uintptr(ptrSize * 2)
// flagKindWidth and flagKindShift indicate various bits that the
// reflect package uses internally to track kind information.
//
// flagRO indicates whether or not the value field of a reflect.Value is
// read-only.
//
// flagIndir indicates whether the value field of a reflect.Value is
// the actual data or a pointer to the data.
//
// These values are valid before golang commit 90a7c3c86944 which
// changed their positions. Code in the init function updates these
// flags as necessary.
flagKindWidth = uintptr(5)
flagKindShift = uintptr(flagKindWidth - 1)
flagRO = uintptr(1 << 0)
flagIndir = uintptr(1 << 1)
)
func init() {
// Older versions of reflect.Value stored small integers directly in the
// ptr field (which is named val in the older versions). Versions
// between commits ecccf07e7f9d and 82f48826c6c7 added a new field named
// scalar for this purpose which unfortunately came before the flag
// field, so the offset of the flag field is different for those
// versions.
//
// This code constructs a new reflect.Value from a known small integer
// and checks if the size of the reflect.Value struct indicates it has
// the scalar field. When it does, the offsets are updated accordingly.
vv := reflect.ValueOf(0xf00)
if unsafe.Sizeof(vv) == (ptrSize * 4) {
offsetScalar = ptrSize * 2
offsetFlag = ptrSize * 3
}
// Commit 90a7c3c86944 changed the flag positions such that the low
// order bits are the kind. This code extracts the kind from the flags
// field and ensures it's the correct type. When it's not, the flag
// order has been changed to the newer format, so the flags are updated
// accordingly.
upf := unsafe.Pointer(uintptr(unsafe.Pointer(&vv)) + offsetFlag)
upfv := *(*uintptr)(upf)
flagKindMask := uintptr((1<<flagKindWidth - 1) << flagKindShift)
if (upfv&flagKindMask)>>flagKindShift != uintptr(reflect.Int) {
flagKindShift = 0
flagRO = 1 << 5
flagIndir = 1 << 6
// Commit adf9b30e5594 modified the flags to separate the
// flagRO flag into two bits which specifies whether or not the
// field is embedded. This causes flagIndir to move over a bit
// and means that flagRO is the combination of either of the
// original flagRO bit and the new bit.
//
// This code detects the change by extracting what used to be
// the indirect bit to ensure it's set. When it's not, the flag
// order has been changed to the newer format, so the flags are
// updated accordingly.
if upfv&flagIndir == 0 {
flagRO = 3 << 5
flagIndir = 1 << 7
}
}
}
// unsafeReflectValue converts the passed reflect.Value into a one that bypasses
// the typical safety restrictions preventing access to unaddressable and
// unexported data. It works by digging the raw pointer to the underlying
// value out of the protected value and generating a new unprotected (unsafe)
// reflect.Value to it.
//
// This allows us to check for implementations of the Stringer and error
// interfaces to be used for pretty printing ordinarily unaddressable and
// inaccessible values such as unexported struct fields.
func unsafeReflectValue(v reflect.Value) (rv reflect.Value) {
indirects := 1
vt := v.Type()
upv := unsafe.Pointer(uintptr(unsafe.Pointer(&v)) + offsetPtr)
rvf := *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&v)) + offsetFlag))
if rvf&flagIndir != 0 {
vt = reflect.PtrTo(v.Type())
indirects++
} else if offsetScalar != 0 {
// The value is in the scalar field when it's not one of the
// reference types.
switch vt.Kind() {
case reflect.Uintptr:
case reflect.Chan:
case reflect.Func:
case reflect.Map:
case reflect.Ptr:
case reflect.UnsafePointer:
default:
upv = unsafe.Pointer(uintptr(unsafe.Pointer(&v)) +
offsetScalar)
}
}
pv := reflect.NewAt(vt, upv)
rv = pv
for i := 0; i < indirects; i++ {
rv = rv.Elem()
}
return rv
}

View File

@@ -1,38 +0,0 @@
// Copyright (c) 2015-2016 Dave Collins <dave@davec.name>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
// NOTE: Due to the following build constraints, this file will only be compiled
// when the code is running on Google App Engine, compiled by GopherJS, or
// "-tags safe" is added to the go build command line. The "disableunsafe"
// tag is deprecated and thus should not be used.
// +build js appengine safe disableunsafe
package spew
import "reflect"
const (
// UnsafeDisabled is a build-time constant which specifies whether or
// not access to the unsafe package is available.
UnsafeDisabled = true
)
// unsafeReflectValue typically converts the passed reflect.Value into a one
// that bypasses the typical safety restrictions preventing access to
// unaddressable and unexported data. However, doing this relies on access to
// the unsafe package. This is a stub version which simply returns the passed
// reflect.Value when the unsafe package is not available.
func unsafeReflectValue(v reflect.Value) reflect.Value {
return v
}

View File

@@ -1,341 +0,0 @@
/*
* Copyright (c) 2013-2016 Dave Collins <dave@davec.name>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package spew
import (
"bytes"
"fmt"
"io"
"reflect"
"sort"
"strconv"
)
// Some constants in the form of bytes to avoid string overhead. This mirrors
// the technique used in the fmt package.
var (
panicBytes = []byte("(PANIC=")
plusBytes = []byte("+")
iBytes = []byte("i")
trueBytes = []byte("true")
falseBytes = []byte("false")
interfaceBytes = []byte("(interface {})")
commaNewlineBytes = []byte(",\n")
newlineBytes = []byte("\n")
openBraceBytes = []byte("{")
openBraceNewlineBytes = []byte("{\n")
closeBraceBytes = []byte("}")
asteriskBytes = []byte("*")
colonBytes = []byte(":")
colonSpaceBytes = []byte(": ")
openParenBytes = []byte("(")
closeParenBytes = []byte(")")
spaceBytes = []byte(" ")
pointerChainBytes = []byte("->")
nilAngleBytes = []byte("<nil>")
maxNewlineBytes = []byte("<max depth reached>\n")
maxShortBytes = []byte("<max>")
circularBytes = []byte("<already shown>")
circularShortBytes = []byte("<shown>")
invalidAngleBytes = []byte("<invalid>")
openBracketBytes = []byte("[")
closeBracketBytes = []byte("]")
percentBytes = []byte("%")
precisionBytes = []byte(".")
openAngleBytes = []byte("<")
closeAngleBytes = []byte(">")
openMapBytes = []byte("map[")
closeMapBytes = []byte("]")
lenEqualsBytes = []byte("len=")
capEqualsBytes = []byte("cap=")
)
// hexDigits is used to map a decimal value to a hex digit.
var hexDigits = "0123456789abcdef"
// catchPanic handles any panics that might occur during the handleMethods
// calls.
func catchPanic(w io.Writer, v reflect.Value) {
if err := recover(); err != nil {
w.Write(panicBytes)
fmt.Fprintf(w, "%v", err)
w.Write(closeParenBytes)
}
}
// handleMethods attempts to call the Error and String methods on the underlying
// type the passed reflect.Value represents and outputes the result to Writer w.
//
// It handles panics in any called methods by catching and displaying the error
// as the formatted value.
func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool) {
// We need an interface to check if the type implements the error or
// Stringer interface. However, the reflect package won't give us an
// interface on certain things like unexported struct fields in order
// to enforce visibility rules. We use unsafe, when it's available,
// to bypass these restrictions since this package does not mutate the
// values.
if !v.CanInterface() {
if UnsafeDisabled {
return false
}
v = unsafeReflectValue(v)
}
// Choose whether or not to do error and Stringer interface lookups against
// the base type or a pointer to the base type depending on settings.
// Technically calling one of these methods with a pointer receiver can
// mutate the value, however, types which choose to satisify an error or
// Stringer interface with a pointer receiver should not be mutating their
// state inside these interface methods.
if !cs.DisablePointerMethods && !UnsafeDisabled && !v.CanAddr() {
v = unsafeReflectValue(v)
}
if v.CanAddr() {
v = v.Addr()
}
// Is it an error or Stringer?
switch iface := v.Interface().(type) {
case error:
defer catchPanic(w, v)
if cs.ContinueOnMethod {
w.Write(openParenBytes)
w.Write([]byte(iface.Error()))
w.Write(closeParenBytes)
w.Write(spaceBytes)
return false
}
w.Write([]byte(iface.Error()))
return true
case fmt.Stringer:
defer catchPanic(w, v)
if cs.ContinueOnMethod {
w.Write(openParenBytes)
w.Write([]byte(iface.String()))
w.Write(closeParenBytes)
w.Write(spaceBytes)
return false
}
w.Write([]byte(iface.String()))
return true
}
return false
}
// printBool outputs a boolean value as true or false to Writer w.
func printBool(w io.Writer, val bool) {
if val {
w.Write(trueBytes)
} else {
w.Write(falseBytes)
}
}
// printInt outputs a signed integer value to Writer w.
func printInt(w io.Writer, val int64, base int) {
w.Write([]byte(strconv.FormatInt(val, base)))
}
// printUint outputs an unsigned integer value to Writer w.
func printUint(w io.Writer, val uint64, base int) {
w.Write([]byte(strconv.FormatUint(val, base)))
}
// printFloat outputs a floating point value using the specified precision,
// which is expected to be 32 or 64bit, to Writer w.
func printFloat(w io.Writer, val float64, precision int) {
w.Write([]byte(strconv.FormatFloat(val, 'g', -1, precision)))
}
// printComplex outputs a complex value using the specified float precision
// for the real and imaginary parts to Writer w.
func printComplex(w io.Writer, c complex128, floatPrecision int) {
r := real(c)
w.Write(openParenBytes)
w.Write([]byte(strconv.FormatFloat(r, 'g', -1, floatPrecision)))
i := imag(c)
if i >= 0 {
w.Write(plusBytes)
}
w.Write([]byte(strconv.FormatFloat(i, 'g', -1, floatPrecision)))
w.Write(iBytes)
w.Write(closeParenBytes)
}
// printHexPtr outputs a uintptr formatted as hexadecimal with a leading '0x'
// prefix to Writer w.
func printHexPtr(w io.Writer, p uintptr) {
// Null pointer.
num := uint64(p)
if num == 0 {
w.Write(nilAngleBytes)
return
}
// Max uint64 is 16 bytes in hex + 2 bytes for '0x' prefix
buf := make([]byte, 18)
// It's simpler to construct the hex string right to left.
base := uint64(16)
i := len(buf) - 1
for num >= base {
buf[i] = hexDigits[num%base]
num /= base
i--
}
buf[i] = hexDigits[num]
// Add '0x' prefix.
i--
buf[i] = 'x'
i--
buf[i] = '0'
// Strip unused leading bytes.
buf = buf[i:]
w.Write(buf)
}
// valuesSorter implements sort.Interface to allow a slice of reflect.Value
// elements to be sorted.
type valuesSorter struct {
values []reflect.Value
strings []string // either nil or same len and values
cs *ConfigState
}
// newValuesSorter initializes a valuesSorter instance, which holds a set of
// surrogate keys on which the data should be sorted. It uses flags in
// ConfigState to decide if and how to populate those surrogate keys.
func newValuesSorter(values []reflect.Value, cs *ConfigState) sort.Interface {
vs := &valuesSorter{values: values, cs: cs}
if canSortSimply(vs.values[0].Kind()) {
return vs
}
if !cs.DisableMethods {
vs.strings = make([]string, len(values))
for i := range vs.values {
b := bytes.Buffer{}
if !handleMethods(cs, &b, vs.values[i]) {
vs.strings = nil
break
}
vs.strings[i] = b.String()
}
}
if vs.strings == nil && cs.SpewKeys {
vs.strings = make([]string, len(values))
for i := range vs.values {
vs.strings[i] = Sprintf("%#v", vs.values[i].Interface())
}
}
return vs
}
// canSortSimply tests whether a reflect.Kind is a primitive that can be sorted
// directly, or whether it should be considered for sorting by surrogate keys
// (if the ConfigState allows it).
func canSortSimply(kind reflect.Kind) bool {
// This switch parallels valueSortLess, except for the default case.
switch kind {
case reflect.Bool:
return true
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
return true
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
return true
case reflect.Float32, reflect.Float64:
return true
case reflect.String:
return true
case reflect.Uintptr:
return true
case reflect.Array:
return true
}
return false
}
// Len returns the number of values in the slice. It is part of the
// sort.Interface implementation.
func (s *valuesSorter) Len() int {
return len(s.values)
}
// Swap swaps the values at the passed indices. It is part of the
// sort.Interface implementation.
func (s *valuesSorter) Swap(i, j int) {
s.values[i], s.values[j] = s.values[j], s.values[i]
if s.strings != nil {
s.strings[i], s.strings[j] = s.strings[j], s.strings[i]
}
}
// valueSortLess returns whether the first value should sort before the second
// value. It is used by valueSorter.Less as part of the sort.Interface
// implementation.
func valueSortLess(a, b reflect.Value) bool {
switch a.Kind() {
case reflect.Bool:
return !a.Bool() && b.Bool()
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
return a.Int() < b.Int()
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
return a.Uint() < b.Uint()
case reflect.Float32, reflect.Float64:
return a.Float() < b.Float()
case reflect.String:
return a.String() < b.String()
case reflect.Uintptr:
return a.Uint() < b.Uint()
case reflect.Array:
// Compare the contents of both arrays.
l := a.Len()
for i := 0; i < l; i++ {
av := a.Index(i)
bv := b.Index(i)
if av.Interface() == bv.Interface() {
continue
}
return valueSortLess(av, bv)
}
}
return a.String() < b.String()
}
// Less returns whether the value at index i should sort before the
// value at index j. It is part of the sort.Interface implementation.
func (s *valuesSorter) Less(i, j int) bool {
if s.strings == nil {
return valueSortLess(s.values[i], s.values[j])
}
return s.strings[i] < s.strings[j]
}
// sortValues is a sort function that handles both native types and any type that
// can be converted to error or Stringer. Other inputs are sorted according to
// their Value.String() value to ensure display stability.
func sortValues(values []reflect.Value, cs *ConfigState) {
if len(values) == 0 {
return
}
sort.Sort(newValuesSorter(values, cs))
}

View File

@@ -1,306 +0,0 @@
/*
* Copyright (c) 2013-2016 Dave Collins <dave@davec.name>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package spew
import (
"bytes"
"fmt"
"io"
"os"
)
// ConfigState houses the configuration options used by spew to format and
// display values. There is a global instance, Config, that is used to control
// all top-level Formatter and Dump functionality. Each ConfigState instance
// provides methods equivalent to the top-level functions.
//
// The zero value for ConfigState provides no indentation. You would typically
// want to set it to a space or a tab.
//
// Alternatively, you can use NewDefaultConfig to get a ConfigState instance
// with default settings. See the documentation of NewDefaultConfig for default
// values.
type ConfigState struct {
// Indent specifies the string to use for each indentation level. The
// global config instance that all top-level functions use set this to a
// single space by default. If you would like more indentation, you might
// set this to a tab with "\t" or perhaps two spaces with " ".
Indent string
// MaxDepth controls the maximum number of levels to descend into nested
// data structures. The default, 0, means there is no limit.
//
// NOTE: Circular data structures are properly detected, so it is not
// necessary to set this value unless you specifically want to limit deeply
// nested data structures.
MaxDepth int
// DisableMethods specifies whether or not error and Stringer interfaces are
// invoked for types that implement them.
DisableMethods bool
// DisablePointerMethods specifies whether or not to check for and invoke
// error and Stringer interfaces on types which only accept a pointer
// receiver when the current type is not a pointer.
//
// NOTE: This might be an unsafe action since calling one of these methods
// with a pointer receiver could technically mutate the value, however,
// in practice, types which choose to satisify an error or Stringer
// interface with a pointer receiver should not be mutating their state
// inside these interface methods. As a result, this option relies on
// access to the unsafe package, so it will not have any effect when
// running in environments without access to the unsafe package such as
// Google App Engine or with the "safe" build tag specified.
DisablePointerMethods bool
// DisablePointerAddresses specifies whether to disable the printing of
// pointer addresses. This is useful when diffing data structures in tests.
DisablePointerAddresses bool
// DisableCapacities specifies whether to disable the printing of capacities
// for arrays, slices, maps and channels. This is useful when diffing
// data structures in tests.
DisableCapacities bool
// ContinueOnMethod specifies whether or not recursion should continue once
// a custom error or Stringer interface is invoked. The default, false,
// means it will print the results of invoking the custom error or Stringer
// interface and return immediately instead of continuing to recurse into
// the internals of the data type.
//
// NOTE: This flag does not have any effect if method invocation is disabled
// via the DisableMethods or DisablePointerMethods options.
ContinueOnMethod bool
// SortKeys specifies map keys should be sorted before being printed. Use
// this to have a more deterministic, diffable output. Note that only
// native types (bool, int, uint, floats, uintptr and string) and types
// that support the error or Stringer interfaces (if methods are
// enabled) are supported, with other types sorted according to the
// reflect.Value.String() output which guarantees display stability.
SortKeys bool
// SpewKeys specifies that, as a last resort attempt, map keys should
// be spewed to strings and sorted by those strings. This is only
// considered if SortKeys is true.
SpewKeys bool
}
// Config is the active configuration of the top-level functions.
// The configuration can be changed by modifying the contents of spew.Config.
var Config = ConfigState{Indent: " "}
// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were
// passed with a Formatter interface returned by c.NewFormatter. It returns
// the formatted string as a value that satisfies error. See NewFormatter
// for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Errorf(format, c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Errorf(format string, a ...interface{}) (err error) {
return fmt.Errorf(format, c.convertArgs(a)...)
}
// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were
// passed with a Formatter interface returned by c.NewFormatter. It returns
// the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Fprint(w, c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Fprint(w io.Writer, a ...interface{}) (n int, err error) {
return fmt.Fprint(w, c.convertArgs(a)...)
}
// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were
// passed with a Formatter interface returned by c.NewFormatter. It returns
// the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Fprintf(w, format, c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
return fmt.Fprintf(w, format, c.convertArgs(a)...)
}
// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it
// passed with a Formatter interface returned by c.NewFormatter. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Fprintln(w, c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Fprintln(w io.Writer, a ...interface{}) (n int, err error) {
return fmt.Fprintln(w, c.convertArgs(a)...)
}
// Print is a wrapper for fmt.Print that treats each argument as if it were
// passed with a Formatter interface returned by c.NewFormatter. It returns
// the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Print(c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Print(a ...interface{}) (n int, err error) {
return fmt.Print(c.convertArgs(a)...)
}
// Printf is a wrapper for fmt.Printf that treats each argument as if it were
// passed with a Formatter interface returned by c.NewFormatter. It returns
// the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Printf(format, c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Printf(format string, a ...interface{}) (n int, err error) {
return fmt.Printf(format, c.convertArgs(a)...)
}
// Println is a wrapper for fmt.Println that treats each argument as if it were
// passed with a Formatter interface returned by c.NewFormatter. It returns
// the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Println(c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Println(a ...interface{}) (n int, err error) {
return fmt.Println(c.convertArgs(a)...)
}
// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were
// passed with a Formatter interface returned by c.NewFormatter. It returns
// the resulting string. See NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Sprint(c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Sprint(a ...interface{}) string {
return fmt.Sprint(c.convertArgs(a)...)
}
// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were
// passed with a Formatter interface returned by c.NewFormatter. It returns
// the resulting string. See NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Sprintf(format, c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Sprintf(format string, a ...interface{}) string {
return fmt.Sprintf(format, c.convertArgs(a)...)
}
// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it
// were passed with a Formatter interface returned by c.NewFormatter. It
// returns the resulting string. See NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Sprintln(c.NewFormatter(a), c.NewFormatter(b))
func (c *ConfigState) Sprintln(a ...interface{}) string {
return fmt.Sprintln(c.convertArgs(a)...)
}
/*
NewFormatter returns a custom formatter that satisfies the fmt.Formatter
interface. As a result, it integrates cleanly with standard fmt package
printing functions. The formatter is useful for inline printing of smaller data
types similar to the standard %v format specifier.
The custom formatter only responds to the %v (most compact), %+v (adds pointer
addresses), %#v (adds types), and %#+v (adds types and pointer addresses) verb
combinations. Any other verbs such as %x and %q will be sent to the the
standard fmt package for formatting. In addition, the custom formatter ignores
the width and precision arguments (however they will still work on the format
specifiers not handled by the custom formatter).
Typically this function shouldn't be called directly. It is much easier to make
use of the custom formatter by calling one of the convenience functions such as
c.Printf, c.Println, or c.Printf.
*/
func (c *ConfigState) NewFormatter(v interface{}) fmt.Formatter {
return newFormatter(c, v)
}
// Fdump formats and displays the passed arguments to io.Writer w. It formats
// exactly the same as Dump.
func (c *ConfigState) Fdump(w io.Writer, a ...interface{}) {
fdump(c, w, a...)
}
/*
Dump displays the passed parameters to standard out with newlines, customizable
indentation, and additional debug information such as complete types and all
pointer addresses used to indirect to the final value. It provides the
following features over the built-in printing facilities provided by the fmt
package:
* Pointers are dereferenced and followed
* Circular data structures are detected and handled properly
* Custom Stringer/error interfaces are optionally invoked, including
on unexported types
* Custom types which only implement the Stringer/error interfaces via
a pointer receiver are optionally invoked when passing non-pointer
variables
* Byte arrays and slices are dumped like the hexdump -C command which
includes offsets, byte values in hex, and ASCII output
The configuration options are controlled by modifying the public members
of c. See ConfigState for options documentation.
See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to
get the formatted result as a string.
*/
func (c *ConfigState) Dump(a ...interface{}) {
fdump(c, os.Stdout, a...)
}
// Sdump returns a string with the passed arguments formatted exactly the same
// as Dump.
func (c *ConfigState) Sdump(a ...interface{}) string {
var buf bytes.Buffer
fdump(c, &buf, a...)
return buf.String()
}
// convertArgs accepts a slice of arguments and returns a slice of the same
// length with each argument converted to a spew Formatter interface using
// the ConfigState associated with s.
func (c *ConfigState) convertArgs(args []interface{}) (formatters []interface{}) {
formatters = make([]interface{}, len(args))
for index, arg := range args {
formatters[index] = newFormatter(c, arg)
}
return formatters
}
// NewDefaultConfig returns a ConfigState with the following default settings.
//
// Indent: " "
// MaxDepth: 0
// DisableMethods: false
// DisablePointerMethods: false
// ContinueOnMethod: false
// SortKeys: false
func NewDefaultConfig() *ConfigState {
return &ConfigState{Indent: " "}
}

View File

@@ -1,211 +0,0 @@
/*
* Copyright (c) 2013-2016 Dave Collins <dave@davec.name>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
Package spew implements a deep pretty printer for Go data structures to aid in
debugging.
A quick overview of the additional features spew provides over the built-in
printing facilities for Go data types are as follows:
* Pointers are dereferenced and followed
* Circular data structures are detected and handled properly
* Custom Stringer/error interfaces are optionally invoked, including
on unexported types
* Custom types which only implement the Stringer/error interfaces via
a pointer receiver are optionally invoked when passing non-pointer
variables
* Byte arrays and slices are dumped like the hexdump -C command which
includes offsets, byte values in hex, and ASCII output (only when using
Dump style)
There are two different approaches spew allows for dumping Go data structures:
* Dump style which prints with newlines, customizable indentation,
and additional debug information such as types and all pointer addresses
used to indirect to the final value
* A custom Formatter interface that integrates cleanly with the standard fmt
package and replaces %v, %+v, %#v, and %#+v to provide inline printing
similar to the default %v while providing the additional functionality
outlined above and passing unsupported format verbs such as %x and %q
along to fmt
Quick Start
This section demonstrates how to quickly get started with spew. See the
sections below for further details on formatting and configuration options.
To dump a variable with full newlines, indentation, type, and pointer
information use Dump, Fdump, or Sdump:
spew.Dump(myVar1, myVar2, ...)
spew.Fdump(someWriter, myVar1, myVar2, ...)
str := spew.Sdump(myVar1, myVar2, ...)
Alternatively, if you would prefer to use format strings with a compacted inline
printing style, use the convenience wrappers Printf, Fprintf, etc with
%v (most compact), %+v (adds pointer addresses), %#v (adds types), or
%#+v (adds types and pointer addresses):
spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2)
spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
spew.Fprintf(someWriter, "myVar1: %v -- myVar2: %+v", myVar1, myVar2)
spew.Fprintf(someWriter, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
Configuration Options
Configuration of spew is handled by fields in the ConfigState type. For
convenience, all of the top-level functions use a global state available
via the spew.Config global.
It is also possible to create a ConfigState instance that provides methods
equivalent to the top-level functions. This allows concurrent configuration
options. See the ConfigState documentation for more details.
The following configuration options are available:
* Indent
String to use for each indentation level for Dump functions.
It is a single space by default. A popular alternative is "\t".
* MaxDepth
Maximum number of levels to descend into nested data structures.
There is no limit by default.
* DisableMethods
Disables invocation of error and Stringer interface methods.
Method invocation is enabled by default.
* DisablePointerMethods
Disables invocation of error and Stringer interface methods on types
which only accept pointer receivers from non-pointer variables.
Pointer method invocation is enabled by default.
* DisablePointerAddresses
DisablePointerAddresses specifies whether to disable the printing of
pointer addresses. This is useful when diffing data structures in tests.
* DisableCapacities
DisableCapacities specifies whether to disable the printing of
capacities for arrays, slices, maps and channels. This is useful when
diffing data structures in tests.
* ContinueOnMethod
Enables recursion into types after invoking error and Stringer interface
methods. Recursion after method invocation is disabled by default.
* SortKeys
Specifies map keys should be sorted before being printed. Use
this to have a more deterministic, diffable output. Note that
only native types (bool, int, uint, floats, uintptr and string)
and types which implement error or Stringer interfaces are
supported with other types sorted according to the
reflect.Value.String() output which guarantees display
stability. Natural map order is used by default.
* SpewKeys
Specifies that, as a last resort attempt, map keys should be
spewed to strings and sorted by those strings. This is only
considered if SortKeys is true.
Dump Usage
Simply call spew.Dump with a list of variables you want to dump:
spew.Dump(myVar1, myVar2, ...)
You may also call spew.Fdump if you would prefer to output to an arbitrary
io.Writer. For example, to dump to standard error:
spew.Fdump(os.Stderr, myVar1, myVar2, ...)
A third option is to call spew.Sdump to get the formatted output as a string:
str := spew.Sdump(myVar1, myVar2, ...)
Sample Dump Output
See the Dump example for details on the setup of the types and variables being
shown here.
(main.Foo) {
unexportedField: (*main.Bar)(0xf84002e210)({
flag: (main.Flag) flagTwo,
data: (uintptr) <nil>
}),
ExportedField: (map[interface {}]interface {}) (len=1) {
(string) (len=3) "one": (bool) true
}
}
Byte (and uint8) arrays and slices are displayed uniquely like the hexdump -C
command as shown.
([]uint8) (len=32 cap=32) {
00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... |
00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0|
00000020 31 32 |12|
}
Custom Formatter
Spew provides a custom formatter that implements the fmt.Formatter interface
so that it integrates cleanly with standard fmt package printing functions. The
formatter is useful for inline printing of smaller data types similar to the
standard %v format specifier.
The custom formatter only responds to the %v (most compact), %+v (adds pointer
addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb
combinations. Any other verbs such as %x and %q will be sent to the the
standard fmt package for formatting. In addition, the custom formatter ignores
the width and precision arguments (however they will still work on the format
specifiers not handled by the custom formatter).
Custom Formatter Usage
The simplest way to make use of the spew custom formatter is to call one of the
convenience functions such as spew.Printf, spew.Println, or spew.Printf. The
functions have syntax you are most likely already familiar with:
spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2)
spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
spew.Println(myVar, myVar2)
spew.Fprintf(os.Stderr, "myVar1: %v -- myVar2: %+v", myVar1, myVar2)
spew.Fprintf(os.Stderr, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
See the Index for the full list convenience functions.
Sample Formatter Output
Double pointer to a uint8:
%v: <**>5
%+v: <**>(0xf8400420d0->0xf8400420c8)5
%#v: (**uint8)5
%#+v: (**uint8)(0xf8400420d0->0xf8400420c8)5
Pointer to circular struct with a uint8 field and a pointer to itself:
%v: <*>{1 <*><shown>}
%+v: <*>(0xf84003e260){ui8:1 c:<*>(0xf84003e260)<shown>}
%#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)<shown>}
%#+v: (*main.circular)(0xf84003e260){ui8:(uint8)1 c:(*main.circular)(0xf84003e260)<shown>}
See the Printf example for details on the setup of variables being shown
here.
Errors
Since it is possible for custom Stringer/error interfaces to panic, spew
detects them and handles them internally by printing the panic information
inline with the output. Since spew is intended to provide deep pretty printing
capabilities on structures, it intentionally does not return any errors.
*/
package spew

View File

@@ -1,509 +0,0 @@
/*
* Copyright (c) 2013-2016 Dave Collins <dave@davec.name>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package spew
import (
"bytes"
"encoding/hex"
"fmt"
"io"
"os"
"reflect"
"regexp"
"strconv"
"strings"
)
var (
// uint8Type is a reflect.Type representing a uint8. It is used to
// convert cgo types to uint8 slices for hexdumping.
uint8Type = reflect.TypeOf(uint8(0))
// cCharRE is a regular expression that matches a cgo char.
// It is used to detect character arrays to hexdump them.
cCharRE = regexp.MustCompile("^.*\\._Ctype_char$")
// cUnsignedCharRE is a regular expression that matches a cgo unsigned
// char. It is used to detect unsigned character arrays to hexdump
// them.
cUnsignedCharRE = regexp.MustCompile("^.*\\._Ctype_unsignedchar$")
// cUint8tCharRE is a regular expression that matches a cgo uint8_t.
// It is used to detect uint8_t arrays to hexdump them.
cUint8tCharRE = regexp.MustCompile("^.*\\._Ctype_uint8_t$")
)
// dumpState contains information about the state of a dump operation.
type dumpState struct {
w io.Writer
depth int
pointers map[uintptr]int
ignoreNextType bool
ignoreNextIndent bool
cs *ConfigState
}
// indent performs indentation according to the depth level and cs.Indent
// option.
func (d *dumpState) indent() {
if d.ignoreNextIndent {
d.ignoreNextIndent = false
return
}
d.w.Write(bytes.Repeat([]byte(d.cs.Indent), d.depth))
}
// unpackValue returns values inside of non-nil interfaces when possible.
// This is useful for data types like structs, arrays, slices, and maps which
// can contain varying types packed inside an interface.
func (d *dumpState) unpackValue(v reflect.Value) reflect.Value {
if v.Kind() == reflect.Interface && !v.IsNil() {
v = v.Elem()
}
return v
}
// dumpPtr handles formatting of pointers by indirecting them as necessary.
func (d *dumpState) dumpPtr(v reflect.Value) {
// Remove pointers at or below the current depth from map used to detect
// circular refs.
for k, depth := range d.pointers {
if depth >= d.depth {
delete(d.pointers, k)
}
}
// Keep list of all dereferenced pointers to show later.
pointerChain := make([]uintptr, 0)
// Figure out how many levels of indirection there are by dereferencing
// pointers and unpacking interfaces down the chain while detecting circular
// references.
nilFound := false
cycleFound := false
indirects := 0
ve := v
for ve.Kind() == reflect.Ptr {
if ve.IsNil() {
nilFound = true
break
}
indirects++
addr := ve.Pointer()
pointerChain = append(pointerChain, addr)
if pd, ok := d.pointers[addr]; ok && pd < d.depth {
cycleFound = true
indirects--
break
}
d.pointers[addr] = d.depth
ve = ve.Elem()
if ve.Kind() == reflect.Interface {
if ve.IsNil() {
nilFound = true
break
}
ve = ve.Elem()
}
}
// Display type information.
d.w.Write(openParenBytes)
d.w.Write(bytes.Repeat(asteriskBytes, indirects))
d.w.Write([]byte(ve.Type().String()))
d.w.Write(closeParenBytes)
// Display pointer information.
if !d.cs.DisablePointerAddresses && len(pointerChain) > 0 {
d.w.Write(openParenBytes)
for i, addr := range pointerChain {
if i > 0 {
d.w.Write(pointerChainBytes)
}
printHexPtr(d.w, addr)
}
d.w.Write(closeParenBytes)
}
// Display dereferenced value.
d.w.Write(openParenBytes)
switch {
case nilFound == true:
d.w.Write(nilAngleBytes)
case cycleFound == true:
d.w.Write(circularBytes)
default:
d.ignoreNextType = true
d.dump(ve)
}
d.w.Write(closeParenBytes)
}
// dumpSlice handles formatting of arrays and slices. Byte (uint8 under
// reflection) arrays and slices are dumped in hexdump -C fashion.
func (d *dumpState) dumpSlice(v reflect.Value) {
// Determine whether this type should be hex dumped or not. Also,
// for types which should be hexdumped, try to use the underlying data
// first, then fall back to trying to convert them to a uint8 slice.
var buf []uint8
doConvert := false
doHexDump := false
numEntries := v.Len()
if numEntries > 0 {
vt := v.Index(0).Type()
vts := vt.String()
switch {
// C types that need to be converted.
case cCharRE.MatchString(vts):
fallthrough
case cUnsignedCharRE.MatchString(vts):
fallthrough
case cUint8tCharRE.MatchString(vts):
doConvert = true
// Try to use existing uint8 slices and fall back to converting
// and copying if that fails.
case vt.Kind() == reflect.Uint8:
// We need an addressable interface to convert the type
// to a byte slice. However, the reflect package won't
// give us an interface on certain things like
// unexported struct fields in order to enforce
// visibility rules. We use unsafe, when available, to
// bypass these restrictions since this package does not
// mutate the values.
vs := v
if !vs.CanInterface() || !vs.CanAddr() {
vs = unsafeReflectValue(vs)
}
if !UnsafeDisabled {
vs = vs.Slice(0, numEntries)
// Use the existing uint8 slice if it can be
// type asserted.
iface := vs.Interface()
if slice, ok := iface.([]uint8); ok {
buf = slice
doHexDump = true
break
}
}
// The underlying data needs to be converted if it can't
// be type asserted to a uint8 slice.
doConvert = true
}
// Copy and convert the underlying type if needed.
if doConvert && vt.ConvertibleTo(uint8Type) {
// Convert and copy each element into a uint8 byte
// slice.
buf = make([]uint8, numEntries)
for i := 0; i < numEntries; i++ {
vv := v.Index(i)
buf[i] = uint8(vv.Convert(uint8Type).Uint())
}
doHexDump = true
}
}
// Hexdump the entire slice as needed.
if doHexDump {
indent := strings.Repeat(d.cs.Indent, d.depth)
str := indent + hex.Dump(buf)
str = strings.Replace(str, "\n", "\n"+indent, -1)
str = strings.TrimRight(str, d.cs.Indent)
d.w.Write([]byte(str))
return
}
// Recursively call dump for each item.
for i := 0; i < numEntries; i++ {
d.dump(d.unpackValue(v.Index(i)))
if i < (numEntries - 1) {
d.w.Write(commaNewlineBytes)
} else {
d.w.Write(newlineBytes)
}
}
}
// dump is the main workhorse for dumping a value. It uses the passed reflect
// value to figure out what kind of object we are dealing with and formats it
// appropriately. It is a recursive function, however circular data structures
// are detected and handled properly.
func (d *dumpState) dump(v reflect.Value) {
// Handle invalid reflect values immediately.
kind := v.Kind()
if kind == reflect.Invalid {
d.w.Write(invalidAngleBytes)
return
}
// Handle pointers specially.
if kind == reflect.Ptr {
d.indent()
d.dumpPtr(v)
return
}
// Print type information unless already handled elsewhere.
if !d.ignoreNextType {
d.indent()
d.w.Write(openParenBytes)
d.w.Write([]byte(v.Type().String()))
d.w.Write(closeParenBytes)
d.w.Write(spaceBytes)
}
d.ignoreNextType = false
// Display length and capacity if the built-in len and cap functions
// work with the value's kind and the len/cap itself is non-zero.
valueLen, valueCap := 0, 0
switch v.Kind() {
case reflect.Array, reflect.Slice, reflect.Chan:
valueLen, valueCap = v.Len(), v.Cap()
case reflect.Map, reflect.String:
valueLen = v.Len()
}
if valueLen != 0 || !d.cs.DisableCapacities && valueCap != 0 {
d.w.Write(openParenBytes)
if valueLen != 0 {
d.w.Write(lenEqualsBytes)
printInt(d.w, int64(valueLen), 10)
}
if !d.cs.DisableCapacities && valueCap != 0 {
if valueLen != 0 {
d.w.Write(spaceBytes)
}
d.w.Write(capEqualsBytes)
printInt(d.w, int64(valueCap), 10)
}
d.w.Write(closeParenBytes)
d.w.Write(spaceBytes)
}
// Call Stringer/error interfaces if they exist and the handle methods flag
// is enabled
if !d.cs.DisableMethods {
if (kind != reflect.Invalid) && (kind != reflect.Interface) {
if handled := handleMethods(d.cs, d.w, v); handled {
return
}
}
}
switch kind {
case reflect.Invalid:
// Do nothing. We should never get here since invalid has already
// been handled above.
case reflect.Bool:
printBool(d.w, v.Bool())
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
printInt(d.w, v.Int(), 10)
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
printUint(d.w, v.Uint(), 10)
case reflect.Float32:
printFloat(d.w, v.Float(), 32)
case reflect.Float64:
printFloat(d.w, v.Float(), 64)
case reflect.Complex64:
printComplex(d.w, v.Complex(), 32)
case reflect.Complex128:
printComplex(d.w, v.Complex(), 64)
case reflect.Slice:
if v.IsNil() {
d.w.Write(nilAngleBytes)
break
}
fallthrough
case reflect.Array:
d.w.Write(openBraceNewlineBytes)
d.depth++
if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) {
d.indent()
d.w.Write(maxNewlineBytes)
} else {
d.dumpSlice(v)
}
d.depth--
d.indent()
d.w.Write(closeBraceBytes)
case reflect.String:
d.w.Write([]byte(strconv.Quote(v.String())))
case reflect.Interface:
// The only time we should get here is for nil interfaces due to
// unpackValue calls.
if v.IsNil() {
d.w.Write(nilAngleBytes)
}
case reflect.Ptr:
// Do nothing. We should never get here since pointers have already
// been handled above.
case reflect.Map:
// nil maps should be indicated as different than empty maps
if v.IsNil() {
d.w.Write(nilAngleBytes)
break
}
d.w.Write(openBraceNewlineBytes)
d.depth++
if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) {
d.indent()
d.w.Write(maxNewlineBytes)
} else {
numEntries := v.Len()
keys := v.MapKeys()
if d.cs.SortKeys {
sortValues(keys, d.cs)
}
for i, key := range keys {
d.dump(d.unpackValue(key))
d.w.Write(colonSpaceBytes)
d.ignoreNextIndent = true
d.dump(d.unpackValue(v.MapIndex(key)))
if i < (numEntries - 1) {
d.w.Write(commaNewlineBytes)
} else {
d.w.Write(newlineBytes)
}
}
}
d.depth--
d.indent()
d.w.Write(closeBraceBytes)
case reflect.Struct:
d.w.Write(openBraceNewlineBytes)
d.depth++
if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) {
d.indent()
d.w.Write(maxNewlineBytes)
} else {
vt := v.Type()
numFields := v.NumField()
for i := 0; i < numFields; i++ {
d.indent()
vtf := vt.Field(i)
d.w.Write([]byte(vtf.Name))
d.w.Write(colonSpaceBytes)
d.ignoreNextIndent = true
d.dump(d.unpackValue(v.Field(i)))
if i < (numFields - 1) {
d.w.Write(commaNewlineBytes)
} else {
d.w.Write(newlineBytes)
}
}
}
d.depth--
d.indent()
d.w.Write(closeBraceBytes)
case reflect.Uintptr:
printHexPtr(d.w, uintptr(v.Uint()))
case reflect.UnsafePointer, reflect.Chan, reflect.Func:
printHexPtr(d.w, v.Pointer())
// There were not any other types at the time this code was written, but
// fall back to letting the default fmt package handle it in case any new
// types are added.
default:
if v.CanInterface() {
fmt.Fprintf(d.w, "%v", v.Interface())
} else {
fmt.Fprintf(d.w, "%v", v.String())
}
}
}
// fdump is a helper function to consolidate the logic from the various public
// methods which take varying writers and config states.
func fdump(cs *ConfigState, w io.Writer, a ...interface{}) {
for _, arg := range a {
if arg == nil {
w.Write(interfaceBytes)
w.Write(spaceBytes)
w.Write(nilAngleBytes)
w.Write(newlineBytes)
continue
}
d := dumpState{w: w, cs: cs}
d.pointers = make(map[uintptr]int)
d.dump(reflect.ValueOf(arg))
d.w.Write(newlineBytes)
}
}
// Fdump formats and displays the passed arguments to io.Writer w. It formats
// exactly the same as Dump.
func Fdump(w io.Writer, a ...interface{}) {
fdump(&Config, w, a...)
}
// Sdump returns a string with the passed arguments formatted exactly the same
// as Dump.
func Sdump(a ...interface{}) string {
var buf bytes.Buffer
fdump(&Config, &buf, a...)
return buf.String()
}
/*
Dump displays the passed parameters to standard out with newlines, customizable
indentation, and additional debug information such as complete types and all
pointer addresses used to indirect to the final value. It provides the
following features over the built-in printing facilities provided by the fmt
package:
* Pointers are dereferenced and followed
* Circular data structures are detected and handled properly
* Custom Stringer/error interfaces are optionally invoked, including
on unexported types
* Custom types which only implement the Stringer/error interfaces via
a pointer receiver are optionally invoked when passing non-pointer
variables
* Byte arrays and slices are dumped like the hexdump -C command which
includes offsets, byte values in hex, and ASCII output
The configuration options are controlled by an exported package global,
spew.Config. See ConfigState for options documentation.
See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to
get the formatted result as a string.
*/
func Dump(a ...interface{}) {
fdump(&Config, os.Stdout, a...)
}

View File

@@ -1,419 +0,0 @@
/*
* Copyright (c) 2013-2016 Dave Collins <dave@davec.name>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package spew
import (
"bytes"
"fmt"
"reflect"
"strconv"
"strings"
)
// supportedFlags is a list of all the character flags supported by fmt package.
const supportedFlags = "0-+# "
// formatState implements the fmt.Formatter interface and contains information
// about the state of a formatting operation. The NewFormatter function can
// be used to get a new Formatter which can be used directly as arguments
// in standard fmt package printing calls.
type formatState struct {
value interface{}
fs fmt.State
depth int
pointers map[uintptr]int
ignoreNextType bool
cs *ConfigState
}
// buildDefaultFormat recreates the original format string without precision
// and width information to pass in to fmt.Sprintf in the case of an
// unrecognized type. Unless new types are added to the language, this
// function won't ever be called.
func (f *formatState) buildDefaultFormat() (format string) {
buf := bytes.NewBuffer(percentBytes)
for _, flag := range supportedFlags {
if f.fs.Flag(int(flag)) {
buf.WriteRune(flag)
}
}
buf.WriteRune('v')
format = buf.String()
return format
}
// constructOrigFormat recreates the original format string including precision
// and width information to pass along to the standard fmt package. This allows
// automatic deferral of all format strings this package doesn't support.
func (f *formatState) constructOrigFormat(verb rune) (format string) {
buf := bytes.NewBuffer(percentBytes)
for _, flag := range supportedFlags {
if f.fs.Flag(int(flag)) {
buf.WriteRune(flag)
}
}
if width, ok := f.fs.Width(); ok {
buf.WriteString(strconv.Itoa(width))
}
if precision, ok := f.fs.Precision(); ok {
buf.Write(precisionBytes)
buf.WriteString(strconv.Itoa(precision))
}
buf.WriteRune(verb)
format = buf.String()
return format
}
// unpackValue returns values inside of non-nil interfaces when possible and
// ensures that types for values which have been unpacked from an interface
// are displayed when the show types flag is also set.
// This is useful for data types like structs, arrays, slices, and maps which
// can contain varying types packed inside an interface.
func (f *formatState) unpackValue(v reflect.Value) reflect.Value {
if v.Kind() == reflect.Interface {
f.ignoreNextType = false
if !v.IsNil() {
v = v.Elem()
}
}
return v
}
// formatPtr handles formatting of pointers by indirecting them as necessary.
func (f *formatState) formatPtr(v reflect.Value) {
// Display nil if top level pointer is nil.
showTypes := f.fs.Flag('#')
if v.IsNil() && (!showTypes || f.ignoreNextType) {
f.fs.Write(nilAngleBytes)
return
}
// Remove pointers at or below the current depth from map used to detect
// circular refs.
for k, depth := range f.pointers {
if depth >= f.depth {
delete(f.pointers, k)
}
}
// Keep list of all dereferenced pointers to possibly show later.
pointerChain := make([]uintptr, 0)
// Figure out how many levels of indirection there are by derferencing
// pointers and unpacking interfaces down the chain while detecting circular
// references.
nilFound := false
cycleFound := false
indirects := 0
ve := v
for ve.Kind() == reflect.Ptr {
if ve.IsNil() {
nilFound = true
break
}
indirects++
addr := ve.Pointer()
pointerChain = append(pointerChain, addr)
if pd, ok := f.pointers[addr]; ok && pd < f.depth {
cycleFound = true
indirects--
break
}
f.pointers[addr] = f.depth
ve = ve.Elem()
if ve.Kind() == reflect.Interface {
if ve.IsNil() {
nilFound = true
break
}
ve = ve.Elem()
}
}
// Display type or indirection level depending on flags.
if showTypes && !f.ignoreNextType {
f.fs.Write(openParenBytes)
f.fs.Write(bytes.Repeat(asteriskBytes, indirects))
f.fs.Write([]byte(ve.Type().String()))
f.fs.Write(closeParenBytes)
} else {
if nilFound || cycleFound {
indirects += strings.Count(ve.Type().String(), "*")
}
f.fs.Write(openAngleBytes)
f.fs.Write([]byte(strings.Repeat("*", indirects)))
f.fs.Write(closeAngleBytes)
}
// Display pointer information depending on flags.
if f.fs.Flag('+') && (len(pointerChain) > 0) {
f.fs.Write(openParenBytes)
for i, addr := range pointerChain {
if i > 0 {
f.fs.Write(pointerChainBytes)
}
printHexPtr(f.fs, addr)
}
f.fs.Write(closeParenBytes)
}
// Display dereferenced value.
switch {
case nilFound == true:
f.fs.Write(nilAngleBytes)
case cycleFound == true:
f.fs.Write(circularShortBytes)
default:
f.ignoreNextType = true
f.format(ve)
}
}
// format is the main workhorse for providing the Formatter interface. It
// uses the passed reflect value to figure out what kind of object we are
// dealing with and formats it appropriately. It is a recursive function,
// however circular data structures are detected and handled properly.
func (f *formatState) format(v reflect.Value) {
// Handle invalid reflect values immediately.
kind := v.Kind()
if kind == reflect.Invalid {
f.fs.Write(invalidAngleBytes)
return
}
// Handle pointers specially.
if kind == reflect.Ptr {
f.formatPtr(v)
return
}
// Print type information unless already handled elsewhere.
if !f.ignoreNextType && f.fs.Flag('#') {
f.fs.Write(openParenBytes)
f.fs.Write([]byte(v.Type().String()))
f.fs.Write(closeParenBytes)
}
f.ignoreNextType = false
// Call Stringer/error interfaces if they exist and the handle methods
// flag is enabled.
if !f.cs.DisableMethods {
if (kind != reflect.Invalid) && (kind != reflect.Interface) {
if handled := handleMethods(f.cs, f.fs, v); handled {
return
}
}
}
switch kind {
case reflect.Invalid:
// Do nothing. We should never get here since invalid has already
// been handled above.
case reflect.Bool:
printBool(f.fs, v.Bool())
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
printInt(f.fs, v.Int(), 10)
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
printUint(f.fs, v.Uint(), 10)
case reflect.Float32:
printFloat(f.fs, v.Float(), 32)
case reflect.Float64:
printFloat(f.fs, v.Float(), 64)
case reflect.Complex64:
printComplex(f.fs, v.Complex(), 32)
case reflect.Complex128:
printComplex(f.fs, v.Complex(), 64)
case reflect.Slice:
if v.IsNil() {
f.fs.Write(nilAngleBytes)
break
}
fallthrough
case reflect.Array:
f.fs.Write(openBracketBytes)
f.depth++
if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) {
f.fs.Write(maxShortBytes)
} else {
numEntries := v.Len()
for i := 0; i < numEntries; i++ {
if i > 0 {
f.fs.Write(spaceBytes)
}
f.ignoreNextType = true
f.format(f.unpackValue(v.Index(i)))
}
}
f.depth--
f.fs.Write(closeBracketBytes)
case reflect.String:
f.fs.Write([]byte(v.String()))
case reflect.Interface:
// The only time we should get here is for nil interfaces due to
// unpackValue calls.
if v.IsNil() {
f.fs.Write(nilAngleBytes)
}
case reflect.Ptr:
// Do nothing. We should never get here since pointers have already
// been handled above.
case reflect.Map:
// nil maps should be indicated as different than empty maps
if v.IsNil() {
f.fs.Write(nilAngleBytes)
break
}
f.fs.Write(openMapBytes)
f.depth++
if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) {
f.fs.Write(maxShortBytes)
} else {
keys := v.MapKeys()
if f.cs.SortKeys {
sortValues(keys, f.cs)
}
for i, key := range keys {
if i > 0 {
f.fs.Write(spaceBytes)
}
f.ignoreNextType = true
f.format(f.unpackValue(key))
f.fs.Write(colonBytes)
f.ignoreNextType = true
f.format(f.unpackValue(v.MapIndex(key)))
}
}
f.depth--
f.fs.Write(closeMapBytes)
case reflect.Struct:
numFields := v.NumField()
f.fs.Write(openBraceBytes)
f.depth++
if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) {
f.fs.Write(maxShortBytes)
} else {
vt := v.Type()
for i := 0; i < numFields; i++ {
if i > 0 {
f.fs.Write(spaceBytes)
}
vtf := vt.Field(i)
if f.fs.Flag('+') || f.fs.Flag('#') {
f.fs.Write([]byte(vtf.Name))
f.fs.Write(colonBytes)
}
f.format(f.unpackValue(v.Field(i)))
}
}
f.depth--
f.fs.Write(closeBraceBytes)
case reflect.Uintptr:
printHexPtr(f.fs, uintptr(v.Uint()))
case reflect.UnsafePointer, reflect.Chan, reflect.Func:
printHexPtr(f.fs, v.Pointer())
// There were not any other types at the time this code was written, but
// fall back to letting the default fmt package handle it if any get added.
default:
format := f.buildDefaultFormat()
if v.CanInterface() {
fmt.Fprintf(f.fs, format, v.Interface())
} else {
fmt.Fprintf(f.fs, format, v.String())
}
}
}
// Format satisfies the fmt.Formatter interface. See NewFormatter for usage
// details.
func (f *formatState) Format(fs fmt.State, verb rune) {
f.fs = fs
// Use standard formatting for verbs that are not v.
if verb != 'v' {
format := f.constructOrigFormat(verb)
fmt.Fprintf(fs, format, f.value)
return
}
if f.value == nil {
if fs.Flag('#') {
fs.Write(interfaceBytes)
}
fs.Write(nilAngleBytes)
return
}
f.format(reflect.ValueOf(f.value))
}
// newFormatter is a helper function to consolidate the logic from the various
// public methods which take varying config states.
func newFormatter(cs *ConfigState, v interface{}) fmt.Formatter {
fs := &formatState{value: v, cs: cs}
fs.pointers = make(map[uintptr]int)
return fs
}
/*
NewFormatter returns a custom formatter that satisfies the fmt.Formatter
interface. As a result, it integrates cleanly with standard fmt package
printing functions. The formatter is useful for inline printing of smaller data
types similar to the standard %v format specifier.
The custom formatter only responds to the %v (most compact), %+v (adds pointer
addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb
combinations. Any other verbs such as %x and %q will be sent to the the
standard fmt package for formatting. In addition, the custom formatter ignores
the width and precision arguments (however they will still work on the format
specifiers not handled by the custom formatter).
Typically this function shouldn't be called directly. It is much easier to make
use of the custom formatter by calling one of the convenience functions such as
Printf, Println, or Fprintf.
*/
func NewFormatter(v interface{}) fmt.Formatter {
return newFormatter(&Config, v)
}

View File

@@ -1,148 +0,0 @@
/*
* Copyright (c) 2013-2016 Dave Collins <dave@davec.name>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package spew
import (
"fmt"
"io"
)
// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were
// passed with a default Formatter interface returned by NewFormatter. It
// returns the formatted string as a value that satisfies error. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Errorf(format, spew.NewFormatter(a), spew.NewFormatter(b))
func Errorf(format string, a ...interface{}) (err error) {
return fmt.Errorf(format, convertArgs(a)...)
}
// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were
// passed with a default Formatter interface returned by NewFormatter. It
// returns the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Fprint(w, spew.NewFormatter(a), spew.NewFormatter(b))
func Fprint(w io.Writer, a ...interface{}) (n int, err error) {
return fmt.Fprint(w, convertArgs(a)...)
}
// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were
// passed with a default Formatter interface returned by NewFormatter. It
// returns the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Fprintf(w, format, spew.NewFormatter(a), spew.NewFormatter(b))
func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
return fmt.Fprintf(w, format, convertArgs(a)...)
}
// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it
// passed with a default Formatter interface returned by NewFormatter. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Fprintln(w, spew.NewFormatter(a), spew.NewFormatter(b))
func Fprintln(w io.Writer, a ...interface{}) (n int, err error) {
return fmt.Fprintln(w, convertArgs(a)...)
}
// Print is a wrapper for fmt.Print that treats each argument as if it were
// passed with a default Formatter interface returned by NewFormatter. It
// returns the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Print(spew.NewFormatter(a), spew.NewFormatter(b))
func Print(a ...interface{}) (n int, err error) {
return fmt.Print(convertArgs(a)...)
}
// Printf is a wrapper for fmt.Printf that treats each argument as if it were
// passed with a default Formatter interface returned by NewFormatter. It
// returns the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Printf(format, spew.NewFormatter(a), spew.NewFormatter(b))
func Printf(format string, a ...interface{}) (n int, err error) {
return fmt.Printf(format, convertArgs(a)...)
}
// Println is a wrapper for fmt.Println that treats each argument as if it were
// passed with a default Formatter interface returned by NewFormatter. It
// returns the number of bytes written and any write error encountered. See
// NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Println(spew.NewFormatter(a), spew.NewFormatter(b))
func Println(a ...interface{}) (n int, err error) {
return fmt.Println(convertArgs(a)...)
}
// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were
// passed with a default Formatter interface returned by NewFormatter. It
// returns the resulting string. See NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Sprint(spew.NewFormatter(a), spew.NewFormatter(b))
func Sprint(a ...interface{}) string {
return fmt.Sprint(convertArgs(a)...)
}
// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were
// passed with a default Formatter interface returned by NewFormatter. It
// returns the resulting string. See NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Sprintf(format, spew.NewFormatter(a), spew.NewFormatter(b))
func Sprintf(format string, a ...interface{}) string {
return fmt.Sprintf(format, convertArgs(a)...)
}
// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it
// were passed with a default Formatter interface returned by NewFormatter. It
// returns the resulting string. See NewFormatter for formatting details.
//
// This function is shorthand for the following syntax:
//
// fmt.Sprintln(spew.NewFormatter(a), spew.NewFormatter(b))
func Sprintln(a ...interface{}) string {
return fmt.Sprintln(convertArgs(a)...)
}
// convertArgs accepts a slice of arguments and returns a slice of the same
// length with each argument converted to a default spew Formatter interface.
func convertArgs(args []interface{}) (formatters []interface{}) {
formatters = make([]interface{}, len(args))
for index, arg := range args {
formatters[index] = NewFormatter(arg)
}
return formatters
}

View File

@@ -1,20 +0,0 @@
# OSX leaves these everywhere on SMB shares
._*
# Eclipse files
.classpath
.project
.settings/**
# Emacs save files
*~
# Vim-related files
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
# Go test binaries
*.test

View File

@@ -1,7 +0,0 @@
language: go
go:
- 1.3
- 1.4
script:
- go test
- go build

View File

@@ -1,50 +0,0 @@
The MIT License (MIT)
Copyright (c) 2014 Sam Ghods
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.
Copyright (c) 2012 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -1,116 +0,0 @@
# YAML marshaling and unmarshaling support for Go
[![Build Status](https://travis-ci.org/ghodss/yaml.svg)](https://travis-ci.org/ghodss/yaml)
## Introduction
A wrapper around [go-yaml](https://github.com/go-yaml/yaml) designed to enable a better way of handling YAML when marshaling to and from structs.
In short, this library first converts YAML to JSON using go-yaml and then uses `json.Marshal` and `json.Unmarshal` to convert to or from the struct. This means that it effectively reuses the JSON struct tags as well as the custom JSON methods `MarshalJSON` and `UnmarshalJSON` unlike go-yaml. For a detailed overview of the rationale behind this method, [see this blog post](http://ghodss.com/2014/the-right-way-to-handle-yaml-in-golang/).
## Compatibility
This package uses [go-yaml v2](https://github.com/go-yaml/yaml) and therefore supports [everything go-yaml supports](https://github.com/go-yaml/yaml#compatibility).
## Caveats
**Caveat #1:** When using `yaml.Marshal` and `yaml.Unmarshal`, binary data should NOT be preceded with the `!!binary` YAML tag. If you do, go-yaml will convert the binary data from base64 to native binary data, which is not compatible with JSON. You can still use binary in your YAML files though - just store them without the `!!binary` tag and decode the base64 in your code (e.g. in the custom JSON methods `MarshalJSON` and `UnmarshalJSON`). This also has the benefit that your YAML and your JSON binary data will be decoded exactly the same way. As an example:
```
BAD:
exampleKey: !!binary gIGC
GOOD:
exampleKey: gIGC
... and decode the base64 data in your code.
```
**Caveat #2:** When using `YAMLToJSON` directly, maps with keys that are maps will result in an error since this is not supported by JSON. This error will occur in `Unmarshal` as well since you can't unmarshal map keys anyways since struct fields can't be keys.
## Installation and usage
To install, run:
```
$ go get github.com/ghodss/yaml
```
And import using:
```
import "github.com/ghodss/yaml"
```
Usage is very similar to the JSON library:
```go
import (
"fmt"
"github.com/ghodss/yaml"
)
type Person struct {
Name string `json:"name"` // Affects YAML field names too.
Age int `json:"name"`
}
func main() {
// Marshal a Person struct to YAML.
p := Person{"John", 30}
y, err := yaml.Marshal(p)
if err != nil {
fmt.Printf("err: %v\n", err)
return
}
fmt.Println(string(y))
/* Output:
name: John
age: 30
*/
// Unmarshal the YAML back into a Person struct.
var p2 Person
err := yaml.Unmarshal(y, &p2)
if err != nil {
fmt.Printf("err: %v\n", err)
return
}
fmt.Println(p2)
/* Output:
{John 30}
*/
}
```
`yaml.YAMLToJSON` and `yaml.JSONToYAML` methods are also available:
```go
import (
"fmt"
"github.com/ghodss/yaml"
)
func main() {
j := []byte(`{"name": "John", "age": 30}`)
y, err := yaml.JSONToYAML(j)
if err != nil {
fmt.Printf("err: %v\n", err)
return
}
fmt.Println(string(y))
/* Output:
name: John
age: 30
*/
j2, err := yaml.YAMLToJSON(y)
if err != nil {
fmt.Printf("err: %v\n", err)
return
}
fmt.Println(string(j2))
/* Output:
{"age":30,"name":"John"}
*/
}
```

View File

@@ -1,497 +0,0 @@
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package yaml
import (
"bytes"
"encoding"
"encoding/json"
"reflect"
"sort"
"strings"
"sync"
"unicode"
"unicode/utf8"
)
// indirect walks down v allocating pointers as needed,
// until it gets to a non-pointer.
// if it encounters an Unmarshaler, indirect stops and returns that.
// if decodingNull is true, indirect stops at the last pointer so it can be set to nil.
func indirect(v reflect.Value, decodingNull bool) (json.Unmarshaler, encoding.TextUnmarshaler, reflect.Value) {
// If v is a named type and is addressable,
// start with its address, so that if the type has pointer methods,
// we find them.
if v.Kind() != reflect.Ptr && v.Type().Name() != "" && v.CanAddr() {
v = v.Addr()
}
for {
// Load value from interface, but only if the result will be
// usefully addressable.
if v.Kind() == reflect.Interface && !v.IsNil() {
e := v.Elem()
if e.Kind() == reflect.Ptr && !e.IsNil() && (!decodingNull || e.Elem().Kind() == reflect.Ptr) {
v = e
continue
}
}
if v.Kind() != reflect.Ptr {
break
}
if v.Elem().Kind() != reflect.Ptr && decodingNull && v.CanSet() {
break
}
if v.IsNil() {
v.Set(reflect.New(v.Type().Elem()))
}
if v.Type().NumMethod() > 0 {
if u, ok := v.Interface().(json.Unmarshaler); ok {
return u, nil, reflect.Value{}
}
if u, ok := v.Interface().(encoding.TextUnmarshaler); ok {
return nil, u, reflect.Value{}
}
}
v = v.Elem()
}
return nil, nil, v
}
// A field represents a single field found in a struct.
type field struct {
name string
nameBytes []byte // []byte(name)
equalFold func(s, t []byte) bool // bytes.EqualFold or equivalent
tag bool
index []int
typ reflect.Type
omitEmpty bool
quoted bool
}
func fillField(f field) field {
f.nameBytes = []byte(f.name)
f.equalFold = foldFunc(f.nameBytes)
return f
}
// byName sorts field by name, breaking ties with depth,
// then breaking ties with "name came from json tag", then
// breaking ties with index sequence.
type byName []field
func (x byName) Len() int { return len(x) }
func (x byName) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
func (x byName) Less(i, j int) bool {
if x[i].name != x[j].name {
return x[i].name < x[j].name
}
if len(x[i].index) != len(x[j].index) {
return len(x[i].index) < len(x[j].index)
}
if x[i].tag != x[j].tag {
return x[i].tag
}
return byIndex(x).Less(i, j)
}
// byIndex sorts field by index sequence.
type byIndex []field
func (x byIndex) Len() int { return len(x) }
func (x byIndex) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
func (x byIndex) Less(i, j int) bool {
for k, xik := range x[i].index {
if k >= len(x[j].index) {
return false
}
if xik != x[j].index[k] {
return xik < x[j].index[k]
}
}
return len(x[i].index) < len(x[j].index)
}
// typeFields returns a list of fields that JSON should recognize for the given type.
// The algorithm is breadth-first search over the set of structs to include - the top struct
// and then any reachable anonymous structs.
func typeFields(t reflect.Type) []field {
// Anonymous fields to explore at the current level and the next.
current := []field{}
next := []field{{typ: t}}
// Count of queued names for current level and the next.
count := map[reflect.Type]int{}
nextCount := map[reflect.Type]int{}
// Types already visited at an earlier level.
visited := map[reflect.Type]bool{}
// Fields found.
var fields []field
for len(next) > 0 {
current, next = next, current[:0]
count, nextCount = nextCount, map[reflect.Type]int{}
for _, f := range current {
if visited[f.typ] {
continue
}
visited[f.typ] = true
// Scan f.typ for fields to include.
for i := 0; i < f.typ.NumField(); i++ {
sf := f.typ.Field(i)
if sf.PkgPath != "" { // unexported
continue
}
tag := sf.Tag.Get("json")
if tag == "-" {
continue
}
name, opts := parseTag(tag)
if !isValidTag(name) {
name = ""
}
index := make([]int, len(f.index)+1)
copy(index, f.index)
index[len(f.index)] = i
ft := sf.Type
if ft.Name() == "" && ft.Kind() == reflect.Ptr {
// Follow pointer.
ft = ft.Elem()
}
// Record found field and index sequence.
if name != "" || !sf.Anonymous || ft.Kind() != reflect.Struct {
tagged := name != ""
if name == "" {
name = sf.Name
}
fields = append(fields, fillField(field{
name: name,
tag: tagged,
index: index,
typ: ft,
omitEmpty: opts.Contains("omitempty"),
quoted: opts.Contains("string"),
}))
if count[f.typ] > 1 {
// If there were multiple instances, add a second,
// so that the annihilation code will see a duplicate.
// It only cares about the distinction between 1 or 2,
// so don't bother generating any more copies.
fields = append(fields, fields[len(fields)-1])
}
continue
}
// Record new anonymous struct to explore in next round.
nextCount[ft]++
if nextCount[ft] == 1 {
next = append(next, fillField(field{name: ft.Name(), index: index, typ: ft}))
}
}
}
}
sort.Sort(byName(fields))
// Delete all fields that are hidden by the Go rules for embedded fields,
// except that fields with JSON tags are promoted.
// The fields are sorted in primary order of name, secondary order
// of field index length. Loop over names; for each name, delete
// hidden fields by choosing the one dominant field that survives.
out := fields[:0]
for advance, i := 0, 0; i < len(fields); i += advance {
// One iteration per name.
// Find the sequence of fields with the name of this first field.
fi := fields[i]
name := fi.name
for advance = 1; i+advance < len(fields); advance++ {
fj := fields[i+advance]
if fj.name != name {
break
}
}
if advance == 1 { // Only one field with this name
out = append(out, fi)
continue
}
dominant, ok := dominantField(fields[i : i+advance])
if ok {
out = append(out, dominant)
}
}
fields = out
sort.Sort(byIndex(fields))
return fields
}
// dominantField looks through the fields, all of which are known to
// have the same name, to find the single field that dominates the
// others using Go's embedding rules, modified by the presence of
// JSON tags. If there are multiple top-level fields, the boolean
// will be false: This condition is an error in Go and we skip all
// the fields.
func dominantField(fields []field) (field, bool) {
// The fields are sorted in increasing index-length order. The winner
// must therefore be one with the shortest index length. Drop all
// longer entries, which is easy: just truncate the slice.
length := len(fields[0].index)
tagged := -1 // Index of first tagged field.
for i, f := range fields {
if len(f.index) > length {
fields = fields[:i]
break
}
if f.tag {
if tagged >= 0 {
// Multiple tagged fields at the same level: conflict.
// Return no field.
return field{}, false
}
tagged = i
}
}
if tagged >= 0 {
return fields[tagged], true
}
// All remaining fields have the same length. If there's more than one,
// we have a conflict (two fields named "X" at the same level) and we
// return no field.
if len(fields) > 1 {
return field{}, false
}
return fields[0], true
}
var fieldCache struct {
sync.RWMutex
m map[reflect.Type][]field
}
// cachedTypeFields is like typeFields but uses a cache to avoid repeated work.
func cachedTypeFields(t reflect.Type) []field {
fieldCache.RLock()
f := fieldCache.m[t]
fieldCache.RUnlock()
if f != nil {
return f
}
// Compute fields without lock.
// Might duplicate effort but won't hold other computations back.
f = typeFields(t)
if f == nil {
f = []field{}
}
fieldCache.Lock()
if fieldCache.m == nil {
fieldCache.m = map[reflect.Type][]field{}
}
fieldCache.m[t] = f
fieldCache.Unlock()
return f
}
func isValidTag(s string) bool {
if s == "" {
return false
}
for _, c := range s {
switch {
case strings.ContainsRune("!#$%&()*+-./:<=>?@[]^_{|}~ ", c):
// Backslash and quote chars are reserved, but
// otherwise any punctuation chars are allowed
// in a tag name.
default:
if !unicode.IsLetter(c) && !unicode.IsDigit(c) {
return false
}
}
}
return true
}
const (
caseMask = ^byte(0x20) // Mask to ignore case in ASCII.
kelvin = '\u212a'
smallLongEss = '\u017f'
)
// foldFunc returns one of four different case folding equivalence
// functions, from most general (and slow) to fastest:
//
// 1) bytes.EqualFold, if the key s contains any non-ASCII UTF-8
// 2) equalFoldRight, if s contains special folding ASCII ('k', 'K', 's', 'S')
// 3) asciiEqualFold, no special, but includes non-letters (including _)
// 4) simpleLetterEqualFold, no specials, no non-letters.
//
// The letters S and K are special because they map to 3 runes, not just 2:
// * S maps to s and to U+017F 'ſ' Latin small letter long s
// * k maps to K and to U+212A '' Kelvin sign
// See http://play.golang.org/p/tTxjOc0OGo
//
// The returned function is specialized for matching against s and
// should only be given s. It's not curried for performance reasons.
func foldFunc(s []byte) func(s, t []byte) bool {
nonLetter := false
special := false // special letter
for _, b := range s {
if b >= utf8.RuneSelf {
return bytes.EqualFold
}
upper := b & caseMask
if upper < 'A' || upper > 'Z' {
nonLetter = true
} else if upper == 'K' || upper == 'S' {
// See above for why these letters are special.
special = true
}
}
if special {
return equalFoldRight
}
if nonLetter {
return asciiEqualFold
}
return simpleLetterEqualFold
}
// equalFoldRight is a specialization of bytes.EqualFold when s is
// known to be all ASCII (including punctuation), but contains an 's',
// 'S', 'k', or 'K', requiring a Unicode fold on the bytes in t.
// See comments on foldFunc.
func equalFoldRight(s, t []byte) bool {
for _, sb := range s {
if len(t) == 0 {
return false
}
tb := t[0]
if tb < utf8.RuneSelf {
if sb != tb {
sbUpper := sb & caseMask
if 'A' <= sbUpper && sbUpper <= 'Z' {
if sbUpper != tb&caseMask {
return false
}
} else {
return false
}
}
t = t[1:]
continue
}
// sb is ASCII and t is not. t must be either kelvin
// sign or long s; sb must be s, S, k, or K.
tr, size := utf8.DecodeRune(t)
switch sb {
case 's', 'S':
if tr != smallLongEss {
return false
}
case 'k', 'K':
if tr != kelvin {
return false
}
default:
return false
}
t = t[size:]
}
if len(t) > 0 {
return false
}
return true
}
// asciiEqualFold is a specialization of bytes.EqualFold for use when
// s is all ASCII (but may contain non-letters) and contains no
// special-folding letters.
// See comments on foldFunc.
func asciiEqualFold(s, t []byte) bool {
if len(s) != len(t) {
return false
}
for i, sb := range s {
tb := t[i]
if sb == tb {
continue
}
if ('a' <= sb && sb <= 'z') || ('A' <= sb && sb <= 'Z') {
if sb&caseMask != tb&caseMask {
return false
}
} else {
return false
}
}
return true
}
// simpleLetterEqualFold is a specialization of bytes.EqualFold for
// use when s is all ASCII letters (no underscores, etc) and also
// doesn't contain 'k', 'K', 's', or 'S'.
// See comments on foldFunc.
func simpleLetterEqualFold(s, t []byte) bool {
if len(s) != len(t) {
return false
}
for i, b := range s {
if b&caseMask != t[i]&caseMask {
return false
}
}
return true
}
// tagOptions is the string following a comma in a struct field's "json"
// tag, or the empty string. It does not include the leading comma.
type tagOptions string
// parseTag splits a struct field's json tag into its name and
// comma-separated options.
func parseTag(tag string) (string, tagOptions) {
if idx := strings.Index(tag, ","); idx != -1 {
return tag[:idx], tagOptions(tag[idx+1:])
}
return tag, tagOptions("")
}
// Contains reports whether a comma-separated list of options
// contains a particular substr flag. substr must be surrounded by a
// string boundary or commas.
func (o tagOptions) Contains(optionName string) bool {
if len(o) == 0 {
return false
}
s := string(o)
for s != "" {
var next string
i := strings.Index(s, ",")
if i >= 0 {
s, next = s[:i], s[i+1:]
}
if s == optionName {
return true
}
s = next
}
return false
}

277
vendor/github.com/ghodss/yaml/yaml.go generated vendored
View File

@@ -1,277 +0,0 @@
package yaml
import (
"bytes"
"encoding/json"
"fmt"
"reflect"
"strconv"
"gopkg.in/yaml.v2"
)
// Marshals the object into JSON then converts JSON to YAML and returns the
// YAML.
func Marshal(o interface{}) ([]byte, error) {
j, err := json.Marshal(o)
if err != nil {
return nil, fmt.Errorf("error marshaling into JSON: ", err)
}
y, err := JSONToYAML(j)
if err != nil {
return nil, fmt.Errorf("error converting JSON to YAML: ", err)
}
return y, nil
}
// Converts YAML to JSON then uses JSON to unmarshal into an object.
func Unmarshal(y []byte, o interface{}) error {
vo := reflect.ValueOf(o)
j, err := yamlToJSON(y, &vo)
if err != nil {
return fmt.Errorf("error converting YAML to JSON: %v", err)
}
err = json.Unmarshal(j, o)
if err != nil {
return fmt.Errorf("error unmarshaling JSON: %v", err)
}
return nil
}
// Convert JSON to YAML.
func JSONToYAML(j []byte) ([]byte, error) {
// Convert the JSON to an object.
var jsonObj interface{}
// We are using yaml.Unmarshal here (instead of json.Unmarshal) because the
// Go JSON library doesn't try to pick the right number type (int, float,
// etc.) when unmarshling to interface{}, it just picks float64
// universally. go-yaml does go through the effort of picking the right
// number type, so we can preserve number type throughout this process.
err := yaml.Unmarshal(j, &jsonObj)
if err != nil {
return nil, err
}
// Marshal this object into YAML.
return yaml.Marshal(jsonObj)
}
// Convert YAML to JSON. Since JSON is a subset of YAML, passing JSON through
// this method should be a no-op.
//
// Things YAML can do that are not supported by JSON:
// * In YAML you can have binary and null keys in your maps. These are invalid
// in JSON. (int and float keys are converted to strings.)
// * Binary data in YAML with the !!binary tag is not supported. If you want to
// use binary data with this library, encode the data as base64 as usual but do
// not use the !!binary tag in your YAML. This will ensure the original base64
// encoded data makes it all the way through to the JSON.
func YAMLToJSON(y []byte) ([]byte, error) {
return yamlToJSON(y, nil)
}
func yamlToJSON(y []byte, jsonTarget *reflect.Value) ([]byte, error) {
// Convert the YAML to an object.
var yamlObj interface{}
err := yaml.Unmarshal(y, &yamlObj)
if err != nil {
return nil, err
}
// YAML objects are not completely compatible with JSON objects (e.g. you
// can have non-string keys in YAML). So, convert the YAML-compatible object
// to a JSON-compatible object, failing with an error if irrecoverable
// incompatibilties happen along the way.
jsonObj, err := convertToJSONableObject(yamlObj, jsonTarget)
if err != nil {
return nil, err
}
// Convert this object to JSON and return the data.
return json.Marshal(jsonObj)
}
func convertToJSONableObject(yamlObj interface{}, jsonTarget *reflect.Value) (interface{}, error) {
var err error
// Resolve jsonTarget to a concrete value (i.e. not a pointer or an
// interface). We pass decodingNull as false because we're not actually
// decoding into the value, we're just checking if the ultimate target is a
// string.
if jsonTarget != nil {
ju, tu, pv := indirect(*jsonTarget, false)
// We have a JSON or Text Umarshaler at this level, so we can't be trying
// to decode into a string.
if ju != nil || tu != nil {
jsonTarget = nil
} else {
jsonTarget = &pv
}
}
// If yamlObj is a number or a boolean, check if jsonTarget is a string -
// if so, coerce. Else return normal.
// If yamlObj is a map or array, find the field that each key is
// unmarshaling to, and when you recurse pass the reflect.Value for that
// field back into this function.
switch typedYAMLObj := yamlObj.(type) {
case map[interface{}]interface{}:
// JSON does not support arbitrary keys in a map, so we must convert
// these keys to strings.
//
// From my reading of go-yaml v2 (specifically the resolve function),
// keys can only have the types string, int, int64, float64, binary
// (unsupported), or null (unsupported).
strMap := make(map[string]interface{})
for k, v := range typedYAMLObj {
// Resolve the key to a string first.
var keyString string
switch typedKey := k.(type) {
case string:
keyString = typedKey
case int:
keyString = strconv.Itoa(typedKey)
case int64:
// go-yaml will only return an int64 as a key if the system
// architecture is 32-bit and the key's value is between 32-bit
// and 64-bit. Otherwise the key type will simply be int.
keyString = strconv.FormatInt(typedKey, 10)
case float64:
// Stolen from go-yaml to use the same conversion to string as
// the go-yaml library uses to convert float to string when
// Marshaling.
s := strconv.FormatFloat(typedKey, 'g', -1, 32)
switch s {
case "+Inf":
s = ".inf"
case "-Inf":
s = "-.inf"
case "NaN":
s = ".nan"
}
keyString = s
case bool:
if typedKey {
keyString = "true"
} else {
keyString = "false"
}
default:
return nil, fmt.Errorf("Unsupported map key of type: %s, key: %+#v, value: %+#v",
reflect.TypeOf(k), k, v)
}
// jsonTarget should be a struct or a map. If it's a struct, find
// the field it's going to map to and pass its reflect.Value. If
// it's a map, find the element type of the map and pass the
// reflect.Value created from that type. If it's neither, just pass
// nil - JSON conversion will error for us if it's a real issue.
if jsonTarget != nil {
t := *jsonTarget
if t.Kind() == reflect.Struct {
keyBytes := []byte(keyString)
// Find the field that the JSON library would use.
var f *field
fields := cachedTypeFields(t.Type())
for i := range fields {
ff := &fields[i]
if bytes.Equal(ff.nameBytes, keyBytes) {
f = ff
break
}
// Do case-insensitive comparison.
if f == nil && ff.equalFold(ff.nameBytes, keyBytes) {
f = ff
}
}
if f != nil {
// Find the reflect.Value of the most preferential
// struct field.
jtf := t.Field(f.index[0])
strMap[keyString], err = convertToJSONableObject(v, &jtf)
if err != nil {
return nil, err
}
continue
}
} else if t.Kind() == reflect.Map {
// Create a zero value of the map's element type to use as
// the JSON target.
jtv := reflect.Zero(t.Type().Elem())
strMap[keyString], err = convertToJSONableObject(v, &jtv)
if err != nil {
return nil, err
}
continue
}
}
strMap[keyString], err = convertToJSONableObject(v, nil)
if err != nil {
return nil, err
}
}
return strMap, nil
case []interface{}:
// We need to recurse into arrays in case there are any
// map[interface{}]interface{}'s inside and to convert any
// numbers to strings.
// If jsonTarget is a slice (which it really should be), find the
// thing it's going to map to. If it's not a slice, just pass nil
// - JSON conversion will error for us if it's a real issue.
var jsonSliceElemValue *reflect.Value
if jsonTarget != nil {
t := *jsonTarget
if t.Kind() == reflect.Slice {
// By default slices point to nil, but we need a reflect.Value
// pointing to a value of the slice type, so we create one here.
ev := reflect.Indirect(reflect.New(t.Type().Elem()))
jsonSliceElemValue = &ev
}
}
// Make and use a new array.
arr := make([]interface{}, len(typedYAMLObj))
for i, v := range typedYAMLObj {
arr[i], err = convertToJSONableObject(v, jsonSliceElemValue)
if err != nil {
return nil, err
}
}
return arr, nil
default:
// If the target type is a string and the YAML type is a number,
// convert the YAML type to a string.
if jsonTarget != nil && (*jsonTarget).Kind() == reflect.String {
// Based on my reading of go-yaml, it may return int, int64,
// float64, or uint64.
var s string
switch typedVal := typedYAMLObj.(type) {
case int:
s = strconv.FormatInt(int64(typedVal), 10)
case int64:
s = strconv.FormatInt(typedVal, 10)
case float64:
s = strconv.FormatFloat(typedVal, 'g', -1, 32)
case uint64:
s = strconv.FormatUint(typedVal, 10)
case bool:
if typedVal {
s = "true"
} else {
s = "false"
}
}
if len(s) > 0 {
yamlObj = interface{}(s)
}
}
return yamlObj, nil
}
return nil, nil
}

View File

@@ -1,14 +0,0 @@
# This is the official list of GoGo authors for copyright purposes.
# This file is distinct from the CONTRIBUTORS file, which
# lists people. For example, employees are listed in CONTRIBUTORS,
# but not in AUTHORS, because the employer holds the copyright.
# Names should be added to this file as one of
# Organization's name
# Individual's name <submission email address>
# Individual's name <submission email address> <email2> <emailN>
# Please keep the list sorted.
Vastech SA (PTY) LTD
Walter Schulze <awalterschulze@gmail.com>

View File

@@ -1,18 +0,0 @@
Anton Povarov <anton.povarov@gmail.com>
Clayton Coleman <ccoleman@redhat.com>
Denis Smirnov <denis.smirnov.91@gmail.com>
DongYun Kang <ceram1000@gmail.com>
Dwayne Schultz <dschultz@pivotal.io>
Georg Apitz <gapitz@pivotal.io>
Gustav Paul <gustav.paul@gmail.com>
Johan Brandhorst <johan.brandhorst@gmail.com>
John Shahid <jvshahid@gmail.com>
John Tuley <john@tuley.org>
Laurent <laurent@adyoulike.com>
Patrick Lee <patrick@dropbox.com>
Sergio Arbeo <serabe@gmail.com>
Stephen J Day <stephen.day@docker.com>
Tamir Duberstein <tamird@gmail.com>
Todd Eisenberger <teisenberger@dropbox.com>
Tormod Erevik Lea <tormodlea@gmail.com>
Walter Schulze <awalterschulze@gmail.com>

View File

@@ -1,36 +0,0 @@
Protocol Buffers for Go with Gadgets
Copyright (c) 2013, The GoGo Authors. All rights reserved.
http://github.com/gogo/protobuf
Go support for Protocol Buffers - Google's data interchange format
Copyright 2010 The Go Authors. All rights reserved.
https://github.com/golang/protobuf
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -1,43 +0,0 @@
# Go support for Protocol Buffers - Google's data interchange format
#
# Copyright 2010 The Go Authors. All rights reserved.
# https://github.com/golang/protobuf
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
install:
go install
test: install generate-test-pbs
go test
generate-test-pbs:
make install
make -C testdata
protoc-min-version --version="3.0.0" --proto_path=.:../../../../:../protobuf --gogo_out=Mtestdata/test.proto=github.com/gogo/protobuf/proto/testdata,Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types:. proto3_proto/proto3.proto
make

View File

@@ -1,234 +0,0 @@
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2011 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Protocol buffer deep copy and merge.
// TODO: RawMessage.
package proto
import (
"log"
"reflect"
"strings"
)
// Clone returns a deep copy of a protocol buffer.
func Clone(pb Message) Message {
in := reflect.ValueOf(pb)
if in.IsNil() {
return pb
}
out := reflect.New(in.Type().Elem())
// out is empty so a merge is a deep copy.
mergeStruct(out.Elem(), in.Elem())
return out.Interface().(Message)
}
// Merge merges src into dst.
// Required and optional fields that are set in src will be set to that value in dst.
// Elements of repeated fields will be appended.
// Merge panics if src and dst are not the same type, or if dst is nil.
func Merge(dst, src Message) {
in := reflect.ValueOf(src)
out := reflect.ValueOf(dst)
if out.IsNil() {
panic("proto: nil destination")
}
if in.Type() != out.Type() {
// Explicit test prior to mergeStruct so that mistyped nils will fail
panic("proto: type mismatch")
}
if in.IsNil() {
// Merging nil into non-nil is a quiet no-op
return
}
mergeStruct(out.Elem(), in.Elem())
}
func mergeStruct(out, in reflect.Value) {
sprop := GetProperties(in.Type())
for i := 0; i < in.NumField(); i++ {
f := in.Type().Field(i)
if strings.HasPrefix(f.Name, "XXX_") {
continue
}
mergeAny(out.Field(i), in.Field(i), false, sprop.Prop[i])
}
if emIn, ok := in.Addr().Interface().(extensionsBytes); ok {
emOut := out.Addr().Interface().(extensionsBytes)
bIn := emIn.GetExtensions()
bOut := emOut.GetExtensions()
*bOut = append(*bOut, *bIn...)
} else if emIn, ok := extendable(in.Addr().Interface()); ok {
emOut, _ := extendable(out.Addr().Interface())
mIn, muIn := emIn.extensionsRead()
if mIn != nil {
mOut := emOut.extensionsWrite()
muIn.Lock()
mergeExtension(mOut, mIn)
muIn.Unlock()
}
}
uf := in.FieldByName("XXX_unrecognized")
if !uf.IsValid() {
return
}
uin := uf.Bytes()
if len(uin) > 0 {
out.FieldByName("XXX_unrecognized").SetBytes(append([]byte(nil), uin...))
}
}
// mergeAny performs a merge between two values of the same type.
// viaPtr indicates whether the values were indirected through a pointer (implying proto2).
// prop is set if this is a struct field (it may be nil).
func mergeAny(out, in reflect.Value, viaPtr bool, prop *Properties) {
if in.Type() == protoMessageType {
if !in.IsNil() {
if out.IsNil() {
out.Set(reflect.ValueOf(Clone(in.Interface().(Message))))
} else {
Merge(out.Interface().(Message), in.Interface().(Message))
}
}
return
}
switch in.Kind() {
case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64,
reflect.String, reflect.Uint32, reflect.Uint64:
if !viaPtr && isProto3Zero(in) {
return
}
out.Set(in)
case reflect.Interface:
// Probably a oneof field; copy non-nil values.
if in.IsNil() {
return
}
// Allocate destination if it is not set, or set to a different type.
// Otherwise we will merge as normal.
if out.IsNil() || out.Elem().Type() != in.Elem().Type() {
out.Set(reflect.New(in.Elem().Elem().Type())) // interface -> *T -> T -> new(T)
}
mergeAny(out.Elem(), in.Elem(), false, nil)
case reflect.Map:
if in.Len() == 0 {
return
}
if out.IsNil() {
out.Set(reflect.MakeMap(in.Type()))
}
// For maps with value types of *T or []byte we need to deep copy each value.
elemKind := in.Type().Elem().Kind()
for _, key := range in.MapKeys() {
var val reflect.Value
switch elemKind {
case reflect.Ptr:
val = reflect.New(in.Type().Elem().Elem())
mergeAny(val, in.MapIndex(key), false, nil)
case reflect.Slice:
val = in.MapIndex(key)
val = reflect.ValueOf(append([]byte{}, val.Bytes()...))
default:
val = in.MapIndex(key)
}
out.SetMapIndex(key, val)
}
case reflect.Ptr:
if in.IsNil() {
return
}
if out.IsNil() {
out.Set(reflect.New(in.Elem().Type()))
}
mergeAny(out.Elem(), in.Elem(), true, nil)
case reflect.Slice:
if in.IsNil() {
return
}
if in.Type().Elem().Kind() == reflect.Uint8 {
// []byte is a scalar bytes field, not a repeated field.
// Edge case: if this is in a proto3 message, a zero length
// bytes field is considered the zero value, and should not
// be merged.
if prop != nil && prop.proto3 && in.Len() == 0 {
return
}
// Make a deep copy.
// Append to []byte{} instead of []byte(nil) so that we never end up
// with a nil result.
out.SetBytes(append([]byte{}, in.Bytes()...))
return
}
n := in.Len()
if out.IsNil() {
out.Set(reflect.MakeSlice(in.Type(), 0, n))
}
switch in.Type().Elem().Kind() {
case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64,
reflect.String, reflect.Uint32, reflect.Uint64:
out.Set(reflect.AppendSlice(out, in))
default:
for i := 0; i < n; i++ {
x := reflect.Indirect(reflect.New(in.Type().Elem()))
mergeAny(x, in.Index(i), false, nil)
out.Set(reflect.Append(out, x))
}
}
case reflect.Struct:
mergeStruct(out, in)
default:
// unknown type, so not a protocol buffer
log.Printf("proto: don't know how to copy %v", in)
}
}
func mergeExtension(out, in map[int32]Extension) {
for extNum, eIn := range in {
eOut := Extension{desc: eIn.desc}
if eIn.value != nil {
v := reflect.New(reflect.TypeOf(eIn.value)).Elem()
mergeAny(v, reflect.ValueOf(eIn.value), false, nil)
eOut.value = v.Interface()
}
if eIn.enc != nil {
eOut.enc = make([]byte, len(eIn.enc))
copy(eOut.enc, eIn.enc)
}
out[extNum] = eOut
}
}

View File

@@ -1,978 +0,0 @@
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2010 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
/*
* Routines for decoding protocol buffer data to construct in-memory representations.
*/
import (
"errors"
"fmt"
"io"
"os"
"reflect"
)
// errOverflow is returned when an integer is too large to be represented.
var errOverflow = errors.New("proto: integer overflow")
// ErrInternalBadWireType is returned by generated code when an incorrect
// wire type is encountered. It does not get returned to user code.
var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for oneof")
// The fundamental decoders that interpret bytes on the wire.
// Those that take integer types all return uint64 and are
// therefore of type valueDecoder.
// DecodeVarint reads a varint-encoded integer from the slice.
// It returns the integer and the number of bytes consumed, or
// zero if there is not enough.
// This is the format for the
// int32, int64, uint32, uint64, bool, and enum
// protocol buffer types.
func DecodeVarint(buf []byte) (x uint64, n int) {
for shift := uint(0); shift < 64; shift += 7 {
if n >= len(buf) {
return 0, 0
}
b := uint64(buf[n])
n++
x |= (b & 0x7F) << shift
if (b & 0x80) == 0 {
return x, n
}
}
// The number is too large to represent in a 64-bit value.
return 0, 0
}
func (p *Buffer) decodeVarintSlow() (x uint64, err error) {
i := p.index
l := len(p.buf)
for shift := uint(0); shift < 64; shift += 7 {
if i >= l {
err = io.ErrUnexpectedEOF
return
}
b := p.buf[i]
i++
x |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
p.index = i
return
}
}
// The number is too large to represent in a 64-bit value.
err = errOverflow
return
}
// DecodeVarint reads a varint-encoded integer from the Buffer.
// This is the format for the
// int32, int64, uint32, uint64, bool, and enum
// protocol buffer types.
func (p *Buffer) DecodeVarint() (x uint64, err error) {
i := p.index
buf := p.buf
if i >= len(buf) {
return 0, io.ErrUnexpectedEOF
} else if buf[i] < 0x80 {
p.index++
return uint64(buf[i]), nil
} else if len(buf)-i < 10 {
return p.decodeVarintSlow()
}
var b uint64
// we already checked the first byte
x = uint64(buf[i]) - 0x80
i++
b = uint64(buf[i])
i++
x += b << 7
if b&0x80 == 0 {
goto done
}
x -= 0x80 << 7
b = uint64(buf[i])
i++
x += b << 14
if b&0x80 == 0 {
goto done
}
x -= 0x80 << 14
b = uint64(buf[i])
i++
x += b << 21
if b&0x80 == 0 {
goto done
}
x -= 0x80 << 21
b = uint64(buf[i])
i++
x += b << 28
if b&0x80 == 0 {
goto done
}
x -= 0x80 << 28
b = uint64(buf[i])
i++
x += b << 35
if b&0x80 == 0 {
goto done
}
x -= 0x80 << 35
b = uint64(buf[i])
i++
x += b << 42
if b&0x80 == 0 {
goto done
}
x -= 0x80 << 42
b = uint64(buf[i])
i++
x += b << 49
if b&0x80 == 0 {
goto done
}
x -= 0x80 << 49
b = uint64(buf[i])
i++
x += b << 56
if b&0x80 == 0 {
goto done
}
x -= 0x80 << 56
b = uint64(buf[i])
i++
x += b << 63
if b&0x80 == 0 {
goto done
}
// x -= 0x80 << 63 // Always zero.
return 0, errOverflow
done:
p.index = i
return x, nil
}
// DecodeFixed64 reads a 64-bit integer from the Buffer.
// This is the format for the
// fixed64, sfixed64, and double protocol buffer types.
func (p *Buffer) DecodeFixed64() (x uint64, err error) {
// x, err already 0
i := p.index + 8
if i < 0 || i > len(p.buf) {
err = io.ErrUnexpectedEOF
return
}
p.index = i
x = uint64(p.buf[i-8])
x |= uint64(p.buf[i-7]) << 8
x |= uint64(p.buf[i-6]) << 16
x |= uint64(p.buf[i-5]) << 24
x |= uint64(p.buf[i-4]) << 32
x |= uint64(p.buf[i-3]) << 40
x |= uint64(p.buf[i-2]) << 48
x |= uint64(p.buf[i-1]) << 56
return
}
// DecodeFixed32 reads a 32-bit integer from the Buffer.
// This is the format for the
// fixed32, sfixed32, and float protocol buffer types.
func (p *Buffer) DecodeFixed32() (x uint64, err error) {
// x, err already 0
i := p.index + 4
if i < 0 || i > len(p.buf) {
err = io.ErrUnexpectedEOF
return
}
p.index = i
x = uint64(p.buf[i-4])
x |= uint64(p.buf[i-3]) << 8
x |= uint64(p.buf[i-2]) << 16
x |= uint64(p.buf[i-1]) << 24
return
}
// DecodeZigzag64 reads a zigzag-encoded 64-bit integer
// from the Buffer.
// This is the format used for the sint64 protocol buffer type.
func (p *Buffer) DecodeZigzag64() (x uint64, err error) {
x, err = p.DecodeVarint()
if err != nil {
return
}
x = (x >> 1) ^ uint64((int64(x&1)<<63)>>63)
return
}
// DecodeZigzag32 reads a zigzag-encoded 32-bit integer
// from the Buffer.
// This is the format used for the sint32 protocol buffer type.
func (p *Buffer) DecodeZigzag32() (x uint64, err error) {
x, err = p.DecodeVarint()
if err != nil {
return
}
x = uint64((uint32(x) >> 1) ^ uint32((int32(x&1)<<31)>>31))
return
}
// These are not ValueDecoders: they produce an array of bytes or a string.
// bytes, embedded messages
// DecodeRawBytes reads a count-delimited byte buffer from the Buffer.
// This is the format used for the bytes protocol buffer
// type and for embedded messages.
func (p *Buffer) DecodeRawBytes(alloc bool) (buf []byte, err error) {
n, err := p.DecodeVarint()
if err != nil {
return nil, err
}
nb := int(n)
if nb < 0 {
return nil, fmt.Errorf("proto: bad byte length %d", nb)
}
end := p.index + nb
if end < p.index || end > len(p.buf) {
return nil, io.ErrUnexpectedEOF
}
if !alloc {
// todo: check if can get more uses of alloc=false
buf = p.buf[p.index:end]
p.index += nb
return
}
buf = make([]byte, nb)
copy(buf, p.buf[p.index:])
p.index += nb
return
}
// DecodeStringBytes reads an encoded string from the Buffer.
// This is the format used for the proto2 string type.
func (p *Buffer) DecodeStringBytes() (s string, err error) {
buf, err := p.DecodeRawBytes(false)
if err != nil {
return
}
return string(buf), nil
}
// Skip the next item in the buffer. Its wire type is decoded and presented as an argument.
// If the protocol buffer has extensions, and the field matches, add it as an extension.
// Otherwise, if the XXX_unrecognized field exists, append the skipped data there.
func (o *Buffer) skipAndSave(t reflect.Type, tag, wire int, base structPointer, unrecField field) error {
oi := o.index
err := o.skip(t, tag, wire)
if err != nil {
return err
}
if !unrecField.IsValid() {
return nil
}
ptr := structPointer_Bytes(base, unrecField)
// Add the skipped field to struct field
obuf := o.buf
o.buf = *ptr
o.EncodeVarint(uint64(tag<<3 | wire))
*ptr = append(o.buf, obuf[oi:o.index]...)
o.buf = obuf
return nil
}
// Skip the next item in the buffer. Its wire type is decoded and presented as an argument.
func (o *Buffer) skip(t reflect.Type, tag, wire int) error {
var u uint64
var err error
switch wire {
case WireVarint:
_, err = o.DecodeVarint()
case WireFixed64:
_, err = o.DecodeFixed64()
case WireBytes:
_, err = o.DecodeRawBytes(false)
case WireFixed32:
_, err = o.DecodeFixed32()
case WireStartGroup:
for {
u, err = o.DecodeVarint()
if err != nil {
break
}
fwire := int(u & 0x7)
if fwire == WireEndGroup {
break
}
ftag := int(u >> 3)
err = o.skip(t, ftag, fwire)
if err != nil {
break
}
}
default:
err = fmt.Errorf("proto: can't skip unknown wire type %d for %s", wire, t)
}
return err
}
// Unmarshaler is the interface representing objects that can
// unmarshal themselves. The method should reset the receiver before
// decoding starts. The argument points to data that may be
// overwritten, so implementations should not keep references to the
// buffer.
type Unmarshaler interface {
Unmarshal([]byte) error
}
// Unmarshal parses the protocol buffer representation in buf and places the
// decoded result in pb. If the struct underlying pb does not match
// the data in buf, the results can be unpredictable.
//
// Unmarshal resets pb before starting to unmarshal, so any
// existing data in pb is always removed. Use UnmarshalMerge
// to preserve and append to existing data.
func Unmarshal(buf []byte, pb Message) error {
pb.Reset()
return UnmarshalMerge(buf, pb)
}
// UnmarshalMerge parses the protocol buffer representation in buf and
// writes the decoded result to pb. If the struct underlying pb does not match
// the data in buf, the results can be unpredictable.
//
// UnmarshalMerge merges into existing data in pb.
// Most code should use Unmarshal instead.
func UnmarshalMerge(buf []byte, pb Message) error {
// If the object can unmarshal itself, let it.
if u, ok := pb.(Unmarshaler); ok {
return u.Unmarshal(buf)
}
return NewBuffer(buf).Unmarshal(pb)
}
// DecodeMessage reads a count-delimited message from the Buffer.
func (p *Buffer) DecodeMessage(pb Message) error {
enc, err := p.DecodeRawBytes(false)
if err != nil {
return err
}
return NewBuffer(enc).Unmarshal(pb)
}
// DecodeGroup reads a tag-delimited group from the Buffer.
func (p *Buffer) DecodeGroup(pb Message) error {
typ, base, err := getbase(pb)
if err != nil {
return err
}
return p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), true, base)
}
// Unmarshal parses the protocol buffer representation in the
// Buffer and places the decoded result in pb. If the struct
// underlying pb does not match the data in the buffer, the results can be
// unpredictable.
//
// Unlike proto.Unmarshal, this does not reset pb before starting to unmarshal.
func (p *Buffer) Unmarshal(pb Message) error {
// If the object can unmarshal itself, let it.
if u, ok := pb.(Unmarshaler); ok {
err := u.Unmarshal(p.buf[p.index:])
p.index = len(p.buf)
return err
}
typ, base, err := getbase(pb)
if err != nil {
return err
}
err = p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), false, base)
if collectStats {
stats.Decode++
}
return err
}
// unmarshalType does the work of unmarshaling a structure.
func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group bool, base structPointer) error {
var state errorState
required, reqFields := prop.reqCount, uint64(0)
var err error
for err == nil && o.index < len(o.buf) {
oi := o.index
var u uint64
u, err = o.DecodeVarint()
if err != nil {
break
}
wire := int(u & 0x7)
if wire == WireEndGroup {
if is_group {
if required > 0 {
// Not enough information to determine the exact field.
// (See below.)
return &RequiredNotSetError{"{Unknown}"}
}
return nil // input is satisfied
}
return fmt.Errorf("proto: %s: wiretype end group for non-group", st)
}
tag := int(u >> 3)
if tag <= 0 {
return fmt.Errorf("proto: %s: illegal tag %d (wire type %d)", st, tag, wire)
}
fieldnum, ok := prop.decoderTags.get(tag)
if !ok {
// Maybe it's an extension?
if prop.extendable {
if e, eok := structPointer_Interface(base, st).(extensionsBytes); eok {
if isExtensionField(e, int32(tag)) {
if err = o.skip(st, tag, wire); err == nil {
ext := e.GetExtensions()
*ext = append(*ext, o.buf[oi:o.index]...)
}
continue
}
} else if e, _ := extendable(structPointer_Interface(base, st)); isExtensionField(e, int32(tag)) {
if err = o.skip(st, tag, wire); err == nil {
extmap := e.extensionsWrite()
ext := extmap[int32(tag)] // may be missing
ext.enc = append(ext.enc, o.buf[oi:o.index]...)
extmap[int32(tag)] = ext
}
continue
}
}
// Maybe it's a oneof?
if prop.oneofUnmarshaler != nil {
m := structPointer_Interface(base, st).(Message)
// First return value indicates whether tag is a oneof field.
ok, err = prop.oneofUnmarshaler(m, tag, wire, o)
if err == ErrInternalBadWireType {
// Map the error to something more descriptive.
// Do the formatting here to save generated code space.
err = fmt.Errorf("bad wiretype for oneof field in %T", m)
}
if ok {
continue
}
}
err = o.skipAndSave(st, tag, wire, base, prop.unrecField)
continue
}
p := prop.Prop[fieldnum]
if p.dec == nil {
fmt.Fprintf(os.Stderr, "proto: no protobuf decoder for %s.%s\n", st, st.Field(fieldnum).Name)
continue
}
dec := p.dec
if wire != WireStartGroup && wire != p.WireType {
if wire == WireBytes && p.packedDec != nil {
// a packable field
dec = p.packedDec
} else {
err = fmt.Errorf("proto: bad wiretype for field %s.%s: got wiretype %d, want %d", st, st.Field(fieldnum).Name, wire, p.WireType)
continue
}
}
decErr := dec(o, p, base)
if decErr != nil && !state.shouldContinue(decErr, p) {
err = decErr
}
if err == nil && p.Required {
// Successfully decoded a required field.
if tag <= 64 {
// use bitmap for fields 1-64 to catch field reuse.
var mask uint64 = 1 << uint64(tag-1)
if reqFields&mask == 0 {
// new required field
reqFields |= mask
required--
}
} else {
// This is imprecise. It can be fooled by a required field
// with a tag > 64 that is encoded twice; that's very rare.
// A fully correct implementation would require allocating
// a data structure, which we would like to avoid.
required--
}
}
}
if err == nil {
if is_group {
return io.ErrUnexpectedEOF
}
if state.err != nil {
return state.err
}
if required > 0 {
// Not enough information to determine the exact field. If we use extra
// CPU, we could determine the field only if the missing required field
// has a tag <= 64 and we check reqFields.
return &RequiredNotSetError{"{Unknown}"}
}
}
return err
}
// Individual type decoders
// For each,
// u is the decoded value,
// v is a pointer to the field (pointer) in the struct
// Sizes of the pools to allocate inside the Buffer.
// The goal is modest amortization and allocation
// on at least 16-byte boundaries.
const (
boolPoolSize = 16
uint32PoolSize = 8
uint64PoolSize = 4
)
// Decode a bool.
func (o *Buffer) dec_bool(p *Properties, base structPointer) error {
u, err := p.valDec(o)
if err != nil {
return err
}
if len(o.bools) == 0 {
o.bools = make([]bool, boolPoolSize)
}
o.bools[0] = u != 0
*structPointer_Bool(base, p.field) = &o.bools[0]
o.bools = o.bools[1:]
return nil
}
func (o *Buffer) dec_proto3_bool(p *Properties, base structPointer) error {
u, err := p.valDec(o)
if err != nil {
return err
}
*structPointer_BoolVal(base, p.field) = u != 0
return nil
}
// Decode an int32.
func (o *Buffer) dec_int32(p *Properties, base structPointer) error {
u, err := p.valDec(o)
if err != nil {
return err
}
word32_Set(structPointer_Word32(base, p.field), o, uint32(u))
return nil
}
func (o *Buffer) dec_proto3_int32(p *Properties, base structPointer) error {
u, err := p.valDec(o)
if err != nil {
return err
}
word32Val_Set(structPointer_Word32Val(base, p.field), uint32(u))
return nil
}
// Decode an int64.
func (o *Buffer) dec_int64(p *Properties, base structPointer) error {
u, err := p.valDec(o)
if err != nil {
return err
}
word64_Set(structPointer_Word64(base, p.field), o, u)
return nil
}
func (o *Buffer) dec_proto3_int64(p *Properties, base structPointer) error {
u, err := p.valDec(o)
if err != nil {
return err
}
word64Val_Set(structPointer_Word64Val(base, p.field), o, u)
return nil
}
// Decode a string.
func (o *Buffer) dec_string(p *Properties, base structPointer) error {
s, err := o.DecodeStringBytes()
if err != nil {
return err
}
*structPointer_String(base, p.field) = &s
return nil
}
func (o *Buffer) dec_proto3_string(p *Properties, base structPointer) error {
s, err := o.DecodeStringBytes()
if err != nil {
return err
}
*structPointer_StringVal(base, p.field) = s
return nil
}
// Decode a slice of bytes ([]byte).
func (o *Buffer) dec_slice_byte(p *Properties, base structPointer) error {
b, err := o.DecodeRawBytes(true)
if err != nil {
return err
}
*structPointer_Bytes(base, p.field) = b
return nil
}
// Decode a slice of bools ([]bool).
func (o *Buffer) dec_slice_bool(p *Properties, base structPointer) error {
u, err := p.valDec(o)
if err != nil {
return err
}
v := structPointer_BoolSlice(base, p.field)
*v = append(*v, u != 0)
return nil
}
// Decode a slice of bools ([]bool) in packed format.
func (o *Buffer) dec_slice_packed_bool(p *Properties, base structPointer) error {
v := structPointer_BoolSlice(base, p.field)
nn, err := o.DecodeVarint()
if err != nil {
return err
}
nb := int(nn) // number of bytes of encoded bools
fin := o.index + nb
if fin < o.index {
return errOverflow
}
y := *v
for o.index < fin {
u, err := p.valDec(o)
if err != nil {
return err
}
y = append(y, u != 0)
}
*v = y
return nil
}
// Decode a slice of int32s ([]int32).
func (o *Buffer) dec_slice_int32(p *Properties, base structPointer) error {
u, err := p.valDec(o)
if err != nil {
return err
}
structPointer_Word32Slice(base, p.field).Append(uint32(u))
return nil
}
// Decode a slice of int32s ([]int32) in packed format.
func (o *Buffer) dec_slice_packed_int32(p *Properties, base structPointer) error {
v := structPointer_Word32Slice(base, p.field)
nn, err := o.DecodeVarint()
if err != nil {
return err
}
nb := int(nn) // number of bytes of encoded int32s
fin := o.index + nb
if fin < o.index {
return errOverflow
}
for o.index < fin {
u, err := p.valDec(o)
if err != nil {
return err
}
v.Append(uint32(u))
}
return nil
}
// Decode a slice of int64s ([]int64).
func (o *Buffer) dec_slice_int64(p *Properties, base structPointer) error {
u, err := p.valDec(o)
if err != nil {
return err
}
structPointer_Word64Slice(base, p.field).Append(u)
return nil
}
// Decode a slice of int64s ([]int64) in packed format.
func (o *Buffer) dec_slice_packed_int64(p *Properties, base structPointer) error {
v := structPointer_Word64Slice(base, p.field)
nn, err := o.DecodeVarint()
if err != nil {
return err
}
nb := int(nn) // number of bytes of encoded int64s
fin := o.index + nb
if fin < o.index {
return errOverflow
}
for o.index < fin {
u, err := p.valDec(o)
if err != nil {
return err
}
v.Append(u)
}
return nil
}
// Decode a slice of strings ([]string).
func (o *Buffer) dec_slice_string(p *Properties, base structPointer) error {
s, err := o.DecodeStringBytes()
if err != nil {
return err
}
v := structPointer_StringSlice(base, p.field)
*v = append(*v, s)
return nil
}
// Decode a slice of slice of bytes ([][]byte).
func (o *Buffer) dec_slice_slice_byte(p *Properties, base structPointer) error {
b, err := o.DecodeRawBytes(true)
if err != nil {
return err
}
v := structPointer_BytesSlice(base, p.field)
*v = append(*v, b)
return nil
}
// Decode a map field.
func (o *Buffer) dec_new_map(p *Properties, base structPointer) error {
raw, err := o.DecodeRawBytes(false)
if err != nil {
return err
}
oi := o.index // index at the end of this map entry
o.index -= len(raw) // move buffer back to start of map entry
mptr := structPointer_NewAt(base, p.field, p.mtype) // *map[K]V
if mptr.Elem().IsNil() {
mptr.Elem().Set(reflect.MakeMap(mptr.Type().Elem()))
}
v := mptr.Elem() // map[K]V
// Prepare addressable doubly-indirect placeholders for the key and value types.
// See enc_new_map for why.
keyptr := reflect.New(reflect.PtrTo(p.mtype.Key())).Elem() // addressable *K
keybase := toStructPointer(keyptr.Addr()) // **K
var valbase structPointer
var valptr reflect.Value
switch p.mtype.Elem().Kind() {
case reflect.Slice:
// []byte
var dummy []byte
valptr = reflect.ValueOf(&dummy) // *[]byte
valbase = toStructPointer(valptr) // *[]byte
case reflect.Ptr:
// message; valptr is **Msg; need to allocate the intermediate pointer
valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V
valptr.Set(reflect.New(valptr.Type().Elem()))
valbase = toStructPointer(valptr)
default:
// everything else
valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V
valbase = toStructPointer(valptr.Addr()) // **V
}
// Decode.
// This parses a restricted wire format, namely the encoding of a message
// with two fields. See enc_new_map for the format.
for o.index < oi {
// tagcode for key and value properties are always a single byte
// because they have tags 1 and 2.
tagcode := o.buf[o.index]
o.index++
switch tagcode {
case p.mkeyprop.tagcode[0]:
if err := p.mkeyprop.dec(o, p.mkeyprop, keybase); err != nil {
return err
}
case p.mvalprop.tagcode[0]:
if err := p.mvalprop.dec(o, p.mvalprop, valbase); err != nil {
return err
}
default:
// TODO: Should we silently skip this instead?
return fmt.Errorf("proto: bad map data tag %d", raw[0])
}
}
keyelem, valelem := keyptr.Elem(), valptr.Elem()
if !keyelem.IsValid() {
keyelem = reflect.Zero(p.mtype.Key())
}
if !valelem.IsValid() {
valelem = reflect.Zero(p.mtype.Elem())
}
v.SetMapIndex(keyelem, valelem)
return nil
}
// Decode a group.
func (o *Buffer) dec_struct_group(p *Properties, base structPointer) error {
bas := structPointer_GetStructPointer(base, p.field)
if structPointer_IsNil(bas) {
// allocate new nested message
bas = toStructPointer(reflect.New(p.stype))
structPointer_SetStructPointer(base, p.field, bas)
}
return o.unmarshalType(p.stype, p.sprop, true, bas)
}
// Decode an embedded message.
func (o *Buffer) dec_struct_message(p *Properties, base structPointer) (err error) {
raw, e := o.DecodeRawBytes(false)
if e != nil {
return e
}
bas := structPointer_GetStructPointer(base, p.field)
if structPointer_IsNil(bas) {
// allocate new nested message
bas = toStructPointer(reflect.New(p.stype))
structPointer_SetStructPointer(base, p.field, bas)
}
// If the object can unmarshal itself, let it.
if p.isUnmarshaler {
iv := structPointer_Interface(bas, p.stype)
return iv.(Unmarshaler).Unmarshal(raw)
}
obuf := o.buf
oi := o.index
o.buf = raw
o.index = 0
err = o.unmarshalType(p.stype, p.sprop, false, bas)
o.buf = obuf
o.index = oi
return err
}
// Decode a slice of embedded messages.
func (o *Buffer) dec_slice_struct_message(p *Properties, base structPointer) error {
return o.dec_slice_struct(p, false, base)
}
// Decode a slice of embedded groups.
func (o *Buffer) dec_slice_struct_group(p *Properties, base structPointer) error {
return o.dec_slice_struct(p, true, base)
}
// Decode a slice of structs ([]*struct).
func (o *Buffer) dec_slice_struct(p *Properties, is_group bool, base structPointer) error {
v := reflect.New(p.stype)
bas := toStructPointer(v)
structPointer_StructPointerSlice(base, p.field).Append(bas)
if is_group {
err := o.unmarshalType(p.stype, p.sprop, is_group, bas)
return err
}
raw, err := o.DecodeRawBytes(false)
if err != nil {
return err
}
// If the object can unmarshal itself, let it.
if p.isUnmarshaler {
iv := v.Interface()
return iv.(Unmarshaler).Unmarshal(raw)
}
obuf := o.buf
oi := o.index
o.buf = raw
o.index = 0
err = o.unmarshalType(p.stype, p.sprop, is_group, bas)
o.buf = obuf
o.index = oi
return err
}

View File

@@ -1,172 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"reflect"
)
// Decode a reference to a struct pointer.
func (o *Buffer) dec_ref_struct_message(p *Properties, base structPointer) (err error) {
raw, e := o.DecodeRawBytes(false)
if e != nil {
return e
}
// If the object can unmarshal itself, let it.
if p.isUnmarshaler {
panic("not supported, since this is a pointer receiver")
}
obuf := o.buf
oi := o.index
o.buf = raw
o.index = 0
bas := structPointer_FieldPointer(base, p.field)
err = o.unmarshalType(p.stype, p.sprop, false, bas)
o.buf = obuf
o.index = oi
return err
}
// Decode a slice of references to struct pointers ([]struct).
func (o *Buffer) dec_slice_ref_struct(p *Properties, is_group bool, base structPointer) error {
newBas := appendStructPointer(base, p.field, p.sstype)
if is_group {
panic("not supported, maybe in future, if requested.")
}
raw, err := o.DecodeRawBytes(false)
if err != nil {
return err
}
// If the object can unmarshal itself, let it.
if p.isUnmarshaler {
panic("not supported, since this is not a pointer receiver.")
}
obuf := o.buf
oi := o.index
o.buf = raw
o.index = 0
err = o.unmarshalType(p.stype, p.sprop, is_group, newBas)
o.buf = obuf
o.index = oi
return err
}
// Decode a slice of references to struct pointers.
func (o *Buffer) dec_slice_ref_struct_message(p *Properties, base structPointer) error {
return o.dec_slice_ref_struct(p, false, base)
}
func setPtrCustomType(base structPointer, f field, v interface{}) {
if v == nil {
return
}
structPointer_SetStructPointer(base, f, toStructPointer(reflect.ValueOf(v)))
}
func setCustomType(base structPointer, f field, value interface{}) {
if value == nil {
return
}
v := reflect.ValueOf(value).Elem()
t := reflect.TypeOf(value).Elem()
kind := t.Kind()
switch kind {
case reflect.Slice:
slice := reflect.MakeSlice(t, v.Len(), v.Cap())
reflect.Copy(slice, v)
oldHeader := structPointer_GetSliceHeader(base, f)
oldHeader.Data = slice.Pointer()
oldHeader.Len = v.Len()
oldHeader.Cap = v.Cap()
default:
size := reflect.TypeOf(value).Elem().Size()
structPointer_Copy(toStructPointer(reflect.ValueOf(value)), structPointer_Add(base, f), int(size))
}
}
func (o *Buffer) dec_custom_bytes(p *Properties, base structPointer) error {
b, err := o.DecodeRawBytes(true)
if err != nil {
return err
}
i := reflect.New(p.ctype.Elem()).Interface()
custom := (i).(Unmarshaler)
if err := custom.Unmarshal(b); err != nil {
return err
}
setPtrCustomType(base, p.field, custom)
return nil
}
func (o *Buffer) dec_custom_ref_bytes(p *Properties, base structPointer) error {
b, err := o.DecodeRawBytes(true)
if err != nil {
return err
}
i := reflect.New(p.ctype).Interface()
custom := (i).(Unmarshaler)
if err := custom.Unmarshal(b); err != nil {
return err
}
if custom != nil {
setCustomType(base, p.field, custom)
}
return nil
}
// Decode a slice of bytes ([]byte) into a slice of custom types.
func (o *Buffer) dec_custom_slice_bytes(p *Properties, base structPointer) error {
b, err := o.DecodeRawBytes(true)
if err != nil {
return err
}
i := reflect.New(p.ctype.Elem()).Interface()
custom := (i).(Unmarshaler)
if err := custom.Unmarshal(b); err != nil {
return err
}
newBas := appendStructPointer(base, p.field, p.ctype)
var zero field
setCustomType(newBas, zero, custom)
return nil
}

View File

@@ -1,100 +0,0 @@
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2016 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
// This file implements conversions between google.protobuf.Duration
// and time.Duration.
import (
"errors"
"fmt"
"time"
)
const (
// Range of a Duration in seconds, as specified in
// google/protobuf/duration.proto. This is about 10,000 years in seconds.
maxSeconds = int64(10000 * 365.25 * 24 * 60 * 60)
minSeconds = -maxSeconds
)
// validateDuration determines whether the Duration is valid according to the
// definition in google/protobuf/duration.proto. A valid Duration
// may still be too large to fit into a time.Duration (the range of Duration
// is about 10,000 years, and the range of time.Duration is about 290).
func validateDuration(d *duration) error {
if d == nil {
return errors.New("duration: nil Duration")
}
if d.Seconds < minSeconds || d.Seconds > maxSeconds {
return fmt.Errorf("duration: %#v: seconds out of range", d)
}
if d.Nanos <= -1e9 || d.Nanos >= 1e9 {
return fmt.Errorf("duration: %#v: nanos out of range", d)
}
// Seconds and Nanos must have the same sign, unless d.Nanos is zero.
if (d.Seconds < 0 && d.Nanos > 0) || (d.Seconds > 0 && d.Nanos < 0) {
return fmt.Errorf("duration: %#v: seconds and nanos have different signs", d)
}
return nil
}
// DurationFromProto converts a Duration to a time.Duration. DurationFromProto
// returns an error if the Duration is invalid or is too large to be
// represented in a time.Duration.
func durationFromProto(p *duration) (time.Duration, error) {
if err := validateDuration(p); err != nil {
return 0, err
}
d := time.Duration(p.Seconds) * time.Second
if int64(d/time.Second) != p.Seconds {
return 0, fmt.Errorf("duration: %#v is out of range for time.Duration", p)
}
if p.Nanos != 0 {
d += time.Duration(p.Nanos)
if (d < 0) != (p.Nanos < 0) {
return 0, fmt.Errorf("duration: %#v is out of range for time.Duration", p)
}
}
return d, nil
}
// DurationProto converts a time.Duration to a Duration.
func durationProto(d time.Duration) *duration {
nanos := d.Nanoseconds()
secs := nanos / 1e9
nanos -= secs * 1e9
return &duration{
Seconds: secs,
Nanos: int32(nanos),
}
}

View File

@@ -1,203 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2016, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"reflect"
"time"
)
var durationType = reflect.TypeOf((*time.Duration)(nil)).Elem()
type duration struct {
Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"`
Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
}
func (m *duration) Reset() { *m = duration{} }
func (*duration) ProtoMessage() {}
func (*duration) String() string { return "duration<string>" }
func init() {
RegisterType((*duration)(nil), "gogo.protobuf.proto.duration")
}
func (o *Buffer) decDuration() (time.Duration, error) {
b, err := o.DecodeRawBytes(true)
if err != nil {
return 0, err
}
dproto := &duration{}
if err := Unmarshal(b, dproto); err != nil {
return 0, err
}
return durationFromProto(dproto)
}
func (o *Buffer) dec_duration(p *Properties, base structPointer) error {
d, err := o.decDuration()
if err != nil {
return err
}
word64_Set(structPointer_Word64(base, p.field), o, uint64(d))
return nil
}
func (o *Buffer) dec_ref_duration(p *Properties, base structPointer) error {
d, err := o.decDuration()
if err != nil {
return err
}
word64Val_Set(structPointer_Word64Val(base, p.field), o, uint64(d))
return nil
}
func (o *Buffer) dec_slice_duration(p *Properties, base structPointer) error {
d, err := o.decDuration()
if err != nil {
return err
}
newBas := appendStructPointer(base, p.field, reflect.SliceOf(reflect.PtrTo(durationType)))
var zero field
setPtrCustomType(newBas, zero, &d)
return nil
}
func (o *Buffer) dec_slice_ref_duration(p *Properties, base structPointer) error {
d, err := o.decDuration()
if err != nil {
return err
}
structPointer_Word64Slice(base, p.field).Append(uint64(d))
return nil
}
func size_duration(p *Properties, base structPointer) (n int) {
structp := structPointer_GetStructPointer(base, p.field)
if structPointer_IsNil(structp) {
return 0
}
dur := structPointer_Interface(structp, durationType).(*time.Duration)
d := durationProto(*dur)
size := Size(d)
return size + sizeVarint(uint64(size)) + len(p.tagcode)
}
func (o *Buffer) enc_duration(p *Properties, base structPointer) error {
structp := structPointer_GetStructPointer(base, p.field)
if structPointer_IsNil(structp) {
return ErrNil
}
dur := structPointer_Interface(structp, durationType).(*time.Duration)
d := durationProto(*dur)
data, err := Marshal(d)
if err != nil {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
return nil
}
func size_ref_duration(p *Properties, base structPointer) (n int) {
dur := structPointer_InterfaceAt(base, p.field, durationType).(*time.Duration)
d := durationProto(*dur)
size := Size(d)
return size + sizeVarint(uint64(size)) + len(p.tagcode)
}
func (o *Buffer) enc_ref_duration(p *Properties, base structPointer) error {
dur := structPointer_InterfaceAt(base, p.field, durationType).(*time.Duration)
d := durationProto(*dur)
data, err := Marshal(d)
if err != nil {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
return nil
}
func size_slice_duration(p *Properties, base structPointer) (n int) {
pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(reflect.PtrTo(durationType))).(*[]*time.Duration)
durs := *pdurs
for i := 0; i < len(durs); i++ {
if durs[i] == nil {
return 0
}
dproto := durationProto(*durs[i])
size := Size(dproto)
n += len(p.tagcode) + size + sizeVarint(uint64(size))
}
return n
}
func (o *Buffer) enc_slice_duration(p *Properties, base structPointer) error {
pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(reflect.PtrTo(durationType))).(*[]*time.Duration)
durs := *pdurs
for i := 0; i < len(durs); i++ {
if durs[i] == nil {
return errRepeatedHasNil
}
dproto := durationProto(*durs[i])
data, err := Marshal(dproto)
if err != nil {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
}
return nil
}
func size_slice_ref_duration(p *Properties, base structPointer) (n int) {
pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(durationType)).(*[]time.Duration)
durs := *pdurs
for i := 0; i < len(durs); i++ {
dproto := durationProto(durs[i])
size := Size(dproto)
n += len(p.tagcode) + size + sizeVarint(uint64(size))
}
return n
}
func (o *Buffer) enc_slice_ref_duration(p *Properties, base structPointer) error {
pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(durationType)).(*[]time.Duration)
durs := *pdurs
for i := 0; i < len(durs); i++ {
dproto := durationProto(durs[i])
data, err := Marshal(dproto)
if err != nil {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
}
return nil
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,350 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2010 The Go Authors. All rights reserved.
// http://github.com/golang/protobuf/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"reflect"
)
func NewRequiredNotSetError(field string) *RequiredNotSetError {
return &RequiredNotSetError{field}
}
type Sizer interface {
Size() int
}
func (o *Buffer) enc_ext_slice_byte(p *Properties, base structPointer) error {
s := *structPointer_Bytes(base, p.field)
if s == nil {
return ErrNil
}
o.buf = append(o.buf, s...)
return nil
}
func size_ext_slice_byte(p *Properties, base structPointer) (n int) {
s := *structPointer_Bytes(base, p.field)
if s == nil {
return 0
}
n += len(s)
return
}
// Encode a reference to bool pointer.
func (o *Buffer) enc_ref_bool(p *Properties, base structPointer) error {
v := *structPointer_BoolVal(base, p.field)
x := 0
if v {
x = 1
}
o.buf = append(o.buf, p.tagcode...)
p.valEnc(o, uint64(x))
return nil
}
func size_ref_bool(p *Properties, base structPointer) int {
return len(p.tagcode) + 1 // each bool takes exactly one byte
}
// Encode a reference to int32 pointer.
func (o *Buffer) enc_ref_int32(p *Properties, base structPointer) error {
v := structPointer_Word32Val(base, p.field)
x := int32(word32Val_Get(v))
o.buf = append(o.buf, p.tagcode...)
p.valEnc(o, uint64(x))
return nil
}
func size_ref_int32(p *Properties, base structPointer) (n int) {
v := structPointer_Word32Val(base, p.field)
x := int32(word32Val_Get(v))
n += len(p.tagcode)
n += p.valSize(uint64(x))
return
}
func (o *Buffer) enc_ref_uint32(p *Properties, base structPointer) error {
v := structPointer_Word32Val(base, p.field)
x := word32Val_Get(v)
o.buf = append(o.buf, p.tagcode...)
p.valEnc(o, uint64(x))
return nil
}
func size_ref_uint32(p *Properties, base structPointer) (n int) {
v := structPointer_Word32Val(base, p.field)
x := word32Val_Get(v)
n += len(p.tagcode)
n += p.valSize(uint64(x))
return
}
// Encode a reference to an int64 pointer.
func (o *Buffer) enc_ref_int64(p *Properties, base structPointer) error {
v := structPointer_Word64Val(base, p.field)
x := word64Val_Get(v)
o.buf = append(o.buf, p.tagcode...)
p.valEnc(o, x)
return nil
}
func size_ref_int64(p *Properties, base structPointer) (n int) {
v := structPointer_Word64Val(base, p.field)
x := word64Val_Get(v)
n += len(p.tagcode)
n += p.valSize(x)
return
}
// Encode a reference to a string pointer.
func (o *Buffer) enc_ref_string(p *Properties, base structPointer) error {
v := *structPointer_StringVal(base, p.field)
o.buf = append(o.buf, p.tagcode...)
o.EncodeStringBytes(v)
return nil
}
func size_ref_string(p *Properties, base structPointer) (n int) {
v := *structPointer_StringVal(base, p.field)
n += len(p.tagcode)
n += sizeStringBytes(v)
return
}
// Encode a reference to a message struct.
func (o *Buffer) enc_ref_struct_message(p *Properties, base structPointer) error {
var state errorState
structp := structPointer_GetRefStructPointer(base, p.field)
if structPointer_IsNil(structp) {
return ErrNil
}
// Can the object marshal itself?
if p.isMarshaler {
m := structPointer_Interface(structp, p.stype).(Marshaler)
data, err := m.Marshal()
if err != nil && !state.shouldContinue(err, nil) {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
return nil
}
o.buf = append(o.buf, p.tagcode...)
return o.enc_len_struct(p.sprop, structp, &state)
}
//TODO this is only copied, please fix this
func size_ref_struct_message(p *Properties, base structPointer) int {
structp := structPointer_GetRefStructPointer(base, p.field)
if structPointer_IsNil(structp) {
return 0
}
// Can the object marshal itself?
if p.isMarshaler {
m := structPointer_Interface(structp, p.stype).(Marshaler)
data, _ := m.Marshal()
n0 := len(p.tagcode)
n1 := sizeRawBytes(data)
return n0 + n1
}
n0 := len(p.tagcode)
n1 := size_struct(p.sprop, structp)
n2 := sizeVarint(uint64(n1)) // size of encoded length
return n0 + n1 + n2
}
// Encode a slice of references to message struct pointers ([]struct).
func (o *Buffer) enc_slice_ref_struct_message(p *Properties, base structPointer) error {
var state errorState
ss := structPointer_StructRefSlice(base, p.field, p.stype.Size())
l := ss.Len()
for i := 0; i < l; i++ {
structp := ss.Index(i)
if structPointer_IsNil(structp) {
return errRepeatedHasNil
}
// Can the object marshal itself?
if p.isMarshaler {
m := structPointer_Interface(structp, p.stype).(Marshaler)
data, err := m.Marshal()
if err != nil && !state.shouldContinue(err, nil) {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
continue
}
o.buf = append(o.buf, p.tagcode...)
err := o.enc_len_struct(p.sprop, structp, &state)
if err != nil && !state.shouldContinue(err, nil) {
if err == ErrNil {
return errRepeatedHasNil
}
return err
}
}
return state.err
}
//TODO this is only copied, please fix this
func size_slice_ref_struct_message(p *Properties, base structPointer) (n int) {
ss := structPointer_StructRefSlice(base, p.field, p.stype.Size())
l := ss.Len()
n += l * len(p.tagcode)
for i := 0; i < l; i++ {
structp := ss.Index(i)
if structPointer_IsNil(structp) {
return // return the size up to this point
}
// Can the object marshal itself?
if p.isMarshaler {
m := structPointer_Interface(structp, p.stype).(Marshaler)
data, _ := m.Marshal()
n += len(p.tagcode)
n += sizeRawBytes(data)
continue
}
n0 := size_struct(p.sprop, structp)
n1 := sizeVarint(uint64(n0)) // size of encoded length
n += n0 + n1
}
return
}
func (o *Buffer) enc_custom_bytes(p *Properties, base structPointer) error {
i := structPointer_InterfaceRef(base, p.field, p.ctype)
if i == nil {
return ErrNil
}
custom := i.(Marshaler)
data, err := custom.Marshal()
if err != nil {
return err
}
if data == nil {
return ErrNil
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
return nil
}
func size_custom_bytes(p *Properties, base structPointer) (n int) {
n += len(p.tagcode)
i := structPointer_InterfaceRef(base, p.field, p.ctype)
if i == nil {
return 0
}
custom := i.(Marshaler)
data, _ := custom.Marshal()
n += sizeRawBytes(data)
return
}
func (o *Buffer) enc_custom_ref_bytes(p *Properties, base structPointer) error {
custom := structPointer_InterfaceAt(base, p.field, p.ctype).(Marshaler)
data, err := custom.Marshal()
if err != nil {
return err
}
if data == nil {
return ErrNil
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
return nil
}
func size_custom_ref_bytes(p *Properties, base structPointer) (n int) {
n += len(p.tagcode)
i := structPointer_InterfaceAt(base, p.field, p.ctype)
if i == nil {
return 0
}
custom := i.(Marshaler)
data, _ := custom.Marshal()
n += sizeRawBytes(data)
return
}
func (o *Buffer) enc_custom_slice_bytes(p *Properties, base structPointer) error {
inter := structPointer_InterfaceRef(base, p.field, p.ctype)
if inter == nil {
return ErrNil
}
slice := reflect.ValueOf(inter)
l := slice.Len()
for i := 0; i < l; i++ {
v := slice.Index(i)
custom := v.Interface().(Marshaler)
data, err := custom.Marshal()
if err != nil {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
}
return nil
}
func size_custom_slice_bytes(p *Properties, base structPointer) (n int) {
inter := structPointer_InterfaceRef(base, p.field, p.ctype)
if inter == nil {
return 0
}
slice := reflect.ValueOf(inter)
l := slice.Len()
n += l * len(p.tagcode)
for i := 0; i < l; i++ {
v := slice.Index(i)
custom := v.Interface().(Marshaler)
data, _ := custom.Marshal()
n += sizeRawBytes(data)
}
return
}

View File

@@ -1,300 +0,0 @@
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2011 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Protocol buffer comparison.
package proto
import (
"bytes"
"log"
"reflect"
"strings"
)
/*
Equal returns true iff protocol buffers a and b are equal.
The arguments must both be pointers to protocol buffer structs.
Equality is defined in this way:
- Two messages are equal iff they are the same type,
corresponding fields are equal, unknown field sets
are equal, and extensions sets are equal.
- Two set scalar fields are equal iff their values are equal.
If the fields are of a floating-point type, remember that
NaN != x for all x, including NaN. If the message is defined
in a proto3 .proto file, fields are not "set"; specifically,
zero length proto3 "bytes" fields are equal (nil == {}).
- Two repeated fields are equal iff their lengths are the same,
and their corresponding elements are equal. Note a "bytes" field,
although represented by []byte, is not a repeated field and the
rule for the scalar fields described above applies.
- Two unset fields are equal.
- Two unknown field sets are equal if their current
encoded state is equal.
- Two extension sets are equal iff they have corresponding
elements that are pairwise equal.
- Two map fields are equal iff their lengths are the same,
and they contain the same set of elements. Zero-length map
fields are equal.
- Every other combination of things are not equal.
The return value is undefined if a and b are not protocol buffers.
*/
func Equal(a, b Message) bool {
if a == nil || b == nil {
return a == b
}
v1, v2 := reflect.ValueOf(a), reflect.ValueOf(b)
if v1.Type() != v2.Type() {
return false
}
if v1.Kind() == reflect.Ptr {
if v1.IsNil() {
return v2.IsNil()
}
if v2.IsNil() {
return false
}
v1, v2 = v1.Elem(), v2.Elem()
}
if v1.Kind() != reflect.Struct {
return false
}
return equalStruct(v1, v2)
}
// v1 and v2 are known to have the same type.
func equalStruct(v1, v2 reflect.Value) bool {
sprop := GetProperties(v1.Type())
for i := 0; i < v1.NumField(); i++ {
f := v1.Type().Field(i)
if strings.HasPrefix(f.Name, "XXX_") {
continue
}
f1, f2 := v1.Field(i), v2.Field(i)
if f.Type.Kind() == reflect.Ptr {
if n1, n2 := f1.IsNil(), f2.IsNil(); n1 && n2 {
// both unset
continue
} else if n1 != n2 {
// set/unset mismatch
return false
}
b1, ok := f1.Interface().(raw)
if ok {
b2 := f2.Interface().(raw)
// RawMessage
if !bytes.Equal(b1.Bytes(), b2.Bytes()) {
return false
}
continue
}
f1, f2 = f1.Elem(), f2.Elem()
}
if !equalAny(f1, f2, sprop.Prop[i]) {
return false
}
}
if em1 := v1.FieldByName("XXX_InternalExtensions"); em1.IsValid() {
em2 := v2.FieldByName("XXX_InternalExtensions")
if !equalExtensions(v1.Type(), em1.Interface().(XXX_InternalExtensions), em2.Interface().(XXX_InternalExtensions)) {
return false
}
}
if em1 := v1.FieldByName("XXX_extensions"); em1.IsValid() {
em2 := v2.FieldByName("XXX_extensions")
if !equalExtMap(v1.Type(), em1.Interface().(map[int32]Extension), em2.Interface().(map[int32]Extension)) {
return false
}
}
uf := v1.FieldByName("XXX_unrecognized")
if !uf.IsValid() {
return true
}
u1 := uf.Bytes()
u2 := v2.FieldByName("XXX_unrecognized").Bytes()
if !bytes.Equal(u1, u2) {
return false
}
return true
}
// v1 and v2 are known to have the same type.
// prop may be nil.
func equalAny(v1, v2 reflect.Value, prop *Properties) bool {
if v1.Type() == protoMessageType {
m1, _ := v1.Interface().(Message)
m2, _ := v2.Interface().(Message)
return Equal(m1, m2)
}
switch v1.Kind() {
case reflect.Bool:
return v1.Bool() == v2.Bool()
case reflect.Float32, reflect.Float64:
return v1.Float() == v2.Float()
case reflect.Int32, reflect.Int64:
return v1.Int() == v2.Int()
case reflect.Interface:
// Probably a oneof field; compare the inner values.
n1, n2 := v1.IsNil(), v2.IsNil()
if n1 || n2 {
return n1 == n2
}
e1, e2 := v1.Elem(), v2.Elem()
if e1.Type() != e2.Type() {
return false
}
return equalAny(e1, e2, nil)
case reflect.Map:
if v1.Len() != v2.Len() {
return false
}
for _, key := range v1.MapKeys() {
val2 := v2.MapIndex(key)
if !val2.IsValid() {
// This key was not found in the second map.
return false
}
if !equalAny(v1.MapIndex(key), val2, nil) {
return false
}
}
return true
case reflect.Ptr:
// Maps may have nil values in them, so check for nil.
if v1.IsNil() && v2.IsNil() {
return true
}
if v1.IsNil() != v2.IsNil() {
return false
}
return equalAny(v1.Elem(), v2.Elem(), prop)
case reflect.Slice:
if v1.Type().Elem().Kind() == reflect.Uint8 {
// short circuit: []byte
// Edge case: if this is in a proto3 message, a zero length
// bytes field is considered the zero value.
if prop != nil && prop.proto3 && v1.Len() == 0 && v2.Len() == 0 {
return true
}
if v1.IsNil() != v2.IsNil() {
return false
}
return bytes.Equal(v1.Interface().([]byte), v2.Interface().([]byte))
}
if v1.Len() != v2.Len() {
return false
}
for i := 0; i < v1.Len(); i++ {
if !equalAny(v1.Index(i), v2.Index(i), prop) {
return false
}
}
return true
case reflect.String:
return v1.Interface().(string) == v2.Interface().(string)
case reflect.Struct:
return equalStruct(v1, v2)
case reflect.Uint32, reflect.Uint64:
return v1.Uint() == v2.Uint()
}
// unknown type, so not a protocol buffer
log.Printf("proto: don't know how to compare %v", v1)
return false
}
// base is the struct type that the extensions are based on.
// x1 and x2 are InternalExtensions.
func equalExtensions(base reflect.Type, x1, x2 XXX_InternalExtensions) bool {
em1, _ := x1.extensionsRead()
em2, _ := x2.extensionsRead()
return equalExtMap(base, em1, em2)
}
func equalExtMap(base reflect.Type, em1, em2 map[int32]Extension) bool {
if len(em1) != len(em2) {
return false
}
for extNum, e1 := range em1 {
e2, ok := em2[extNum]
if !ok {
return false
}
m1, m2 := e1.value, e2.value
if m1 != nil && m2 != nil {
// Both are unencoded.
if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) {
return false
}
continue
}
// At least one is encoded. To do a semantically correct comparison
// we need to unmarshal them first.
var desc *ExtensionDesc
if m := extensionMaps[base]; m != nil {
desc = m[extNum]
}
if desc == nil {
log.Printf("proto: don't know how to compare extension %d of %v", extNum, base)
continue
}
var err error
if m1 == nil {
m1, err = decodeExtension(e1.enc, desc)
}
if m2 == nil && err == nil {
m2, err = decodeExtension(e2.enc, desc)
}
if err != nil {
// The encoded form is invalid.
log.Printf("proto: badly encoded extension %d of %v: %v", extNum, base, err)
return false
}
if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) {
return false
}
}
return true
}

View File

@@ -1,693 +0,0 @@
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2010 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
/*
* Types and routines for supporting protocol buffer extensions.
*/
import (
"errors"
"fmt"
"reflect"
"strconv"
"sync"
)
// ErrMissingExtension is the error returned by GetExtension if the named extension is not in the message.
var ErrMissingExtension = errors.New("proto: missing extension")
// ExtensionRange represents a range of message extensions for a protocol buffer.
// Used in code generated by the protocol compiler.
type ExtensionRange struct {
Start, End int32 // both inclusive
}
// extendableProto is an interface implemented by any protocol buffer generated by the current
// proto compiler that may be extended.
type extendableProto interface {
Message
ExtensionRangeArray() []ExtensionRange
extensionsWrite() map[int32]Extension
extensionsRead() (map[int32]Extension, sync.Locker)
}
// extendableProtoV1 is an interface implemented by a protocol buffer generated by the previous
// version of the proto compiler that may be extended.
type extendableProtoV1 interface {
Message
ExtensionRangeArray() []ExtensionRange
ExtensionMap() map[int32]Extension
}
type extensionsBytes interface {
Message
ExtensionRangeArray() []ExtensionRange
GetExtensions() *[]byte
}
// extensionAdapter is a wrapper around extendableProtoV1 that implements extendableProto.
type extensionAdapter struct {
extendableProtoV1
}
func (e extensionAdapter) extensionsWrite() map[int32]Extension {
return e.ExtensionMap()
}
func (e extensionAdapter) extensionsRead() (map[int32]Extension, sync.Locker) {
return e.ExtensionMap(), notLocker{}
}
// notLocker is a sync.Locker whose Lock and Unlock methods are nops.
type notLocker struct{}
func (n notLocker) Lock() {}
func (n notLocker) Unlock() {}
// extendable returns the extendableProto interface for the given generated proto message.
// If the proto message has the old extension format, it returns a wrapper that implements
// the extendableProto interface.
func extendable(p interface{}) (extendableProto, bool) {
if ep, ok := p.(extendableProto); ok {
return ep, ok
}
if ep, ok := p.(extendableProtoV1); ok {
return extensionAdapter{ep}, ok
}
return nil, false
}
// XXX_InternalExtensions is an internal representation of proto extensions.
//
// Each generated message struct type embeds an anonymous XXX_InternalExtensions field,
// thus gaining the unexported 'extensions' method, which can be called only from the proto package.
//
// The methods of XXX_InternalExtensions are not concurrency safe in general,
// but calls to logically read-only methods such as has and get may be executed concurrently.
type XXX_InternalExtensions struct {
// The struct must be indirect so that if a user inadvertently copies a
// generated message and its embedded XXX_InternalExtensions, they
// avoid the mayhem of a copied mutex.
//
// The mutex serializes all logically read-only operations to p.extensionMap.
// It is up to the client to ensure that write operations to p.extensionMap are
// mutually exclusive with other accesses.
p *struct {
mu sync.Mutex
extensionMap map[int32]Extension
}
}
// extensionsWrite returns the extension map, creating it on first use.
func (e *XXX_InternalExtensions) extensionsWrite() map[int32]Extension {
if e.p == nil {
e.p = new(struct {
mu sync.Mutex
extensionMap map[int32]Extension
})
e.p.extensionMap = make(map[int32]Extension)
}
return e.p.extensionMap
}
// extensionsRead returns the extensions map for read-only use. It may be nil.
// The caller must hold the returned mutex's lock when accessing Elements within the map.
func (e *XXX_InternalExtensions) extensionsRead() (map[int32]Extension, sync.Locker) {
if e.p == nil {
return nil, nil
}
return e.p.extensionMap, &e.p.mu
}
type extensionRange interface {
Message
ExtensionRangeArray() []ExtensionRange
}
var extendableProtoType = reflect.TypeOf((*extendableProto)(nil)).Elem()
var extendableProtoV1Type = reflect.TypeOf((*extendableProtoV1)(nil)).Elem()
var extendableBytesType = reflect.TypeOf((*extensionsBytes)(nil)).Elem()
var extensionRangeType = reflect.TypeOf((*extensionRange)(nil)).Elem()
// ExtensionDesc represents an extension specification.
// Used in generated code from the protocol compiler.
type ExtensionDesc struct {
ExtendedType Message // nil pointer to the type that is being extended
ExtensionType interface{} // nil pointer to the extension type
Field int32 // field number
Name string // fully-qualified name of extension, for text formatting
Tag string // protobuf tag style
Filename string // name of the file in which the extension is defined
}
func (ed *ExtensionDesc) repeated() bool {
t := reflect.TypeOf(ed.ExtensionType)
return t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8
}
// Extension represents an extension in a message.
type Extension struct {
// When an extension is stored in a message using SetExtension
// only desc and value are set. When the message is marshaled
// enc will be set to the encoded form of the message.
//
// When a message is unmarshaled and contains extensions, each
// extension will have only enc set. When such an extension is
// accessed using GetExtension (or GetExtensions) desc and value
// will be set.
desc *ExtensionDesc
value interface{}
enc []byte
}
// SetRawExtension is for testing only.
func SetRawExtension(base Message, id int32, b []byte) {
if ebase, ok := base.(extensionsBytes); ok {
clearExtension(base, id)
ext := ebase.GetExtensions()
*ext = append(*ext, b...)
return
}
epb, ok := extendable(base)
if !ok {
return
}
extmap := epb.extensionsWrite()
extmap[id] = Extension{enc: b}
}
// isExtensionField returns true iff the given field number is in an extension range.
func isExtensionField(pb extensionRange, field int32) bool {
for _, er := range pb.ExtensionRangeArray() {
if er.Start <= field && field <= er.End {
return true
}
}
return false
}
// checkExtensionTypes checks that the given extension is valid for pb.
func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error {
var pbi interface{} = pb
// Check the extended type.
if ea, ok := pbi.(extensionAdapter); ok {
pbi = ea.extendableProtoV1
}
if a, b := reflect.TypeOf(pbi), reflect.TypeOf(extension.ExtendedType); a != b {
return errors.New("proto: bad extended type; " + b.String() + " does not extend " + a.String())
}
// Check the range.
if !isExtensionField(pb, extension.Field) {
return errors.New("proto: bad extension number; not in declared ranges")
}
return nil
}
// extPropKey is sufficient to uniquely identify an extension.
type extPropKey struct {
base reflect.Type
field int32
}
var extProp = struct {
sync.RWMutex
m map[extPropKey]*Properties
}{
m: make(map[extPropKey]*Properties),
}
func extensionProperties(ed *ExtensionDesc) *Properties {
key := extPropKey{base: reflect.TypeOf(ed.ExtendedType), field: ed.Field}
extProp.RLock()
if prop, ok := extProp.m[key]; ok {
extProp.RUnlock()
return prop
}
extProp.RUnlock()
extProp.Lock()
defer extProp.Unlock()
// Check again.
if prop, ok := extProp.m[key]; ok {
return prop
}
prop := new(Properties)
prop.Init(reflect.TypeOf(ed.ExtensionType), "unknown_name", ed.Tag, nil)
extProp.m[key] = prop
return prop
}
// encode encodes any unmarshaled (unencoded) extensions in e.
func encodeExtensions(e *XXX_InternalExtensions) error {
m, mu := e.extensionsRead()
if m == nil {
return nil // fast path
}
mu.Lock()
defer mu.Unlock()
return encodeExtensionsMap(m)
}
// encode encodes any unmarshaled (unencoded) extensions in e.
func encodeExtensionsMap(m map[int32]Extension) error {
for k, e := range m {
if e.value == nil || e.desc == nil {
// Extension is only in its encoded form.
continue
}
// We don't skip extensions that have an encoded form set,
// because the extension value may have been mutated after
// the last time this function was called.
et := reflect.TypeOf(e.desc.ExtensionType)
props := extensionProperties(e.desc)
p := NewBuffer(nil)
// If e.value has type T, the encoder expects a *struct{ X T }.
// Pass a *T with a zero field and hope it all works out.
x := reflect.New(et)
x.Elem().Set(reflect.ValueOf(e.value))
if err := props.enc(p, props, toStructPointer(x)); err != nil {
return err
}
e.enc = p.buf
m[k] = e
}
return nil
}
func extensionsSize(e *XXX_InternalExtensions) (n int) {
m, mu := e.extensionsRead()
if m == nil {
return 0
}
mu.Lock()
defer mu.Unlock()
return extensionsMapSize(m)
}
func extensionsMapSize(m map[int32]Extension) (n int) {
for _, e := range m {
if e.value == nil || e.desc == nil {
// Extension is only in its encoded form.
n += len(e.enc)
continue
}
// We don't skip extensions that have an encoded form set,
// because the extension value may have been mutated after
// the last time this function was called.
et := reflect.TypeOf(e.desc.ExtensionType)
props := extensionProperties(e.desc)
// If e.value has type T, the encoder expects a *struct{ X T }.
// Pass a *T with a zero field and hope it all works out.
x := reflect.New(et)
x.Elem().Set(reflect.ValueOf(e.value))
n += props.size(props, toStructPointer(x))
}
return
}
// HasExtension returns whether the given extension is present in pb.
func HasExtension(pb Message, extension *ExtensionDesc) bool {
if epb, doki := pb.(extensionsBytes); doki {
ext := epb.GetExtensions()
buf := *ext
o := 0
for o < len(buf) {
tag, n := DecodeVarint(buf[o:])
fieldNum := int32(tag >> 3)
if int32(fieldNum) == extension.Field {
return true
}
wireType := int(tag & 0x7)
o += n
l, err := size(buf[o:], wireType)
if err != nil {
return false
}
o += l
}
return false
}
// TODO: Check types, field numbers, etc.?
epb, ok := extendable(pb)
if !ok {
return false
}
extmap, mu := epb.extensionsRead()
if extmap == nil {
return false
}
mu.Lock()
_, ok = extmap[extension.Field]
mu.Unlock()
return ok
}
func deleteExtension(pb extensionsBytes, theFieldNum int32, offset int) int {
ext := pb.GetExtensions()
for offset < len(*ext) {
tag, n1 := DecodeVarint((*ext)[offset:])
fieldNum := int32(tag >> 3)
wireType := int(tag & 0x7)
n2, err := size((*ext)[offset+n1:], wireType)
if err != nil {
panic(err)
}
newOffset := offset + n1 + n2
if fieldNum == theFieldNum {
*ext = append((*ext)[:offset], (*ext)[newOffset:]...)
return offset
}
offset = newOffset
}
return -1
}
// ClearExtension removes the given extension from pb.
func ClearExtension(pb Message, extension *ExtensionDesc) {
clearExtension(pb, extension.Field)
}
func clearExtension(pb Message, fieldNum int32) {
if epb, doki := pb.(extensionsBytes); doki {
offset := 0
for offset != -1 {
offset = deleteExtension(epb, fieldNum, offset)
}
return
}
epb, ok := extendable(pb)
if !ok {
return
}
// TODO: Check types, field numbers, etc.?
extmap := epb.extensionsWrite()
delete(extmap, fieldNum)
}
// GetExtension parses and returns the given extension of pb.
// If the extension is not present and has no default value it returns ErrMissingExtension.
func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) {
if epb, doki := pb.(extensionsBytes); doki {
ext := epb.GetExtensions()
o := 0
for o < len(*ext) {
tag, n := DecodeVarint((*ext)[o:])
fieldNum := int32(tag >> 3)
wireType := int(tag & 0x7)
l, err := size((*ext)[o+n:], wireType)
if err != nil {
return nil, err
}
if int32(fieldNum) == extension.Field {
v, err := decodeExtension((*ext)[o:o+n+l], extension)
if err != nil {
return nil, err
}
return v, nil
}
o += n + l
}
return defaultExtensionValue(extension)
}
epb, ok := extendable(pb)
if !ok {
return nil, errors.New("proto: not an extendable proto")
}
if err := checkExtensionTypes(epb, extension); err != nil {
return nil, err
}
emap, mu := epb.extensionsRead()
if emap == nil {
return defaultExtensionValue(extension)
}
mu.Lock()
defer mu.Unlock()
e, ok := emap[extension.Field]
if !ok {
// defaultExtensionValue returns the default value or
// ErrMissingExtension if there is no default.
return defaultExtensionValue(extension)
}
if e.value != nil {
// Already decoded. Check the descriptor, though.
if e.desc != extension {
// This shouldn't happen. If it does, it means that
// GetExtension was called twice with two different
// descriptors with the same field number.
return nil, errors.New("proto: descriptor conflict")
}
return e.value, nil
}
v, err := decodeExtension(e.enc, extension)
if err != nil {
return nil, err
}
// Remember the decoded version and drop the encoded version.
// That way it is safe to mutate what we return.
e.value = v
e.desc = extension
e.enc = nil
emap[extension.Field] = e
return e.value, nil
}
// defaultExtensionValue returns the default value for extension.
// If no default for an extension is defined ErrMissingExtension is returned.
func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) {
t := reflect.TypeOf(extension.ExtensionType)
props := extensionProperties(extension)
sf, _, err := fieldDefault(t, props)
if err != nil {
return nil, err
}
if sf == nil || sf.value == nil {
// There is no default value.
return nil, ErrMissingExtension
}
if t.Kind() != reflect.Ptr {
// We do not need to return a Ptr, we can directly return sf.value.
return sf.value, nil
}
// We need to return an interface{} that is a pointer to sf.value.
value := reflect.New(t).Elem()
value.Set(reflect.New(value.Type().Elem()))
if sf.kind == reflect.Int32 {
// We may have an int32 or an enum, but the underlying data is int32.
// Since we can't set an int32 into a non int32 reflect.value directly
// set it as a int32.
value.Elem().SetInt(int64(sf.value.(int32)))
} else {
value.Elem().Set(reflect.ValueOf(sf.value))
}
return value.Interface(), nil
}
// decodeExtension decodes an extension encoded in b.
func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) {
o := NewBuffer(b)
t := reflect.TypeOf(extension.ExtensionType)
props := extensionProperties(extension)
// t is a pointer to a struct, pointer to basic type or a slice.
// Allocate a "field" to store the pointer/slice itself; the
// pointer/slice will be stored here. We pass
// the address of this field to props.dec.
// This passes a zero field and a *t and lets props.dec
// interpret it as a *struct{ x t }.
value := reflect.New(t).Elem()
for {
// Discard wire type and field number varint. It isn't needed.
if _, err := o.DecodeVarint(); err != nil {
return nil, err
}
if err := props.dec(o, props, toStructPointer(value.Addr())); err != nil {
return nil, err
}
if o.index >= len(o.buf) {
break
}
}
return value.Interface(), nil
}
// GetExtensions returns a slice of the extensions present in pb that are also listed in es.
// The returned slice has the same length as es; missing extensions will appear as nil elements.
func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) {
extensions = make([]interface{}, len(es))
for i, e := range es {
extensions[i], err = GetExtension(pb, e)
if err == ErrMissingExtension {
err = nil
}
if err != nil {
return
}
}
return
}
// ExtensionDescs returns a new slice containing pb's extension descriptors, in undefined order.
// For non-registered extensions, ExtensionDescs returns an incomplete descriptor containing
// just the Field field, which defines the extension's field number.
func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) {
epb, ok := extendable(pb)
if !ok {
return nil, fmt.Errorf("proto: %T is not an extendable proto.Message", pb)
}
registeredExtensions := RegisteredExtensions(pb)
emap, mu := epb.extensionsRead()
if emap == nil {
return nil, nil
}
mu.Lock()
defer mu.Unlock()
extensions := make([]*ExtensionDesc, 0, len(emap))
for extid, e := range emap {
desc := e.desc
if desc == nil {
desc = registeredExtensions[extid]
if desc == nil {
desc = &ExtensionDesc{Field: extid}
}
}
extensions = append(extensions, desc)
}
return extensions, nil
}
// SetExtension sets the specified extension of pb to the specified value.
func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error {
if epb, doki := pb.(extensionsBytes); doki {
ClearExtension(pb, extension)
ext := epb.GetExtensions()
et := reflect.TypeOf(extension.ExtensionType)
props := extensionProperties(extension)
p := NewBuffer(nil)
x := reflect.New(et)
x.Elem().Set(reflect.ValueOf(value))
if err := props.enc(p, props, toStructPointer(x)); err != nil {
return err
}
*ext = append(*ext, p.buf...)
return nil
}
epb, ok := extendable(pb)
if !ok {
return errors.New("proto: not an extendable proto")
}
if err := checkExtensionTypes(epb, extension); err != nil {
return err
}
typ := reflect.TypeOf(extension.ExtensionType)
if typ != reflect.TypeOf(value) {
return errors.New("proto: bad extension value type")
}
// nil extension values need to be caught early, because the
// encoder can't distinguish an ErrNil due to a nil extension
// from an ErrNil due to a missing field. Extensions are
// always optional, so the encoder would just swallow the error
// and drop all the extensions from the encoded message.
if reflect.ValueOf(value).IsNil() {
return fmt.Errorf("proto: SetExtension called with nil value of type %T", value)
}
extmap := epb.extensionsWrite()
extmap[extension.Field] = Extension{desc: extension, value: value}
return nil
}
// ClearAllExtensions clears all extensions from pb.
func ClearAllExtensions(pb Message) {
if epb, doki := pb.(extensionsBytes); doki {
ext := epb.GetExtensions()
*ext = []byte{}
return
}
epb, ok := extendable(pb)
if !ok {
return
}
m := epb.extensionsWrite()
for k := range m {
delete(m, k)
}
}
// A global registry of extensions.
// The generated code will register the generated descriptors by calling RegisterExtension.
var extensionMaps = make(map[reflect.Type]map[int32]*ExtensionDesc)
// RegisterExtension is called from the generated code.
func RegisterExtension(desc *ExtensionDesc) {
st := reflect.TypeOf(desc.ExtendedType).Elem()
m := extensionMaps[st]
if m == nil {
m = make(map[int32]*ExtensionDesc)
extensionMaps[st] = m
}
if _, ok := m[desc.Field]; ok {
panic("proto: duplicate extension registered: " + st.String() + " " + strconv.Itoa(int(desc.Field)))
}
m[desc.Field] = desc
}
// RegisteredExtensions returns a map of the registered extensions of a
// protocol buffer struct, indexed by the extension number.
// The argument pb should be a nil pointer to the struct type.
func RegisteredExtensions(pb Message) map[int32]*ExtensionDesc {
return extensionMaps[reflect.TypeOf(pb).Elem()]
}

View File

@@ -1,294 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"bytes"
"errors"
"fmt"
"reflect"
"sort"
"strings"
"sync"
)
func GetBoolExtension(pb Message, extension *ExtensionDesc, ifnotset bool) bool {
if reflect.ValueOf(pb).IsNil() {
return ifnotset
}
value, err := GetExtension(pb, extension)
if err != nil {
return ifnotset
}
if value == nil {
return ifnotset
}
if value.(*bool) == nil {
return ifnotset
}
return *(value.(*bool))
}
func (this *Extension) Equal(that *Extension) bool {
return bytes.Equal(this.enc, that.enc)
}
func (this *Extension) Compare(that *Extension) int {
return bytes.Compare(this.enc, that.enc)
}
func SizeOfInternalExtension(m extendableProto) (n int) {
return SizeOfExtensionMap(m.extensionsWrite())
}
func SizeOfExtensionMap(m map[int32]Extension) (n int) {
return extensionsMapSize(m)
}
type sortableMapElem struct {
field int32
ext Extension
}
func newSortableExtensionsFromMap(m map[int32]Extension) sortableExtensions {
s := make(sortableExtensions, 0, len(m))
for k, v := range m {
s = append(s, &sortableMapElem{field: k, ext: v})
}
return s
}
type sortableExtensions []*sortableMapElem
func (this sortableExtensions) Len() int { return len(this) }
func (this sortableExtensions) Swap(i, j int) { this[i], this[j] = this[j], this[i] }
func (this sortableExtensions) Less(i, j int) bool { return this[i].field < this[j].field }
func (this sortableExtensions) String() string {
sort.Sort(this)
ss := make([]string, len(this))
for i := range this {
ss[i] = fmt.Sprintf("%d: %v", this[i].field, this[i].ext)
}
return "map[" + strings.Join(ss, ",") + "]"
}
func StringFromInternalExtension(m extendableProto) string {
return StringFromExtensionsMap(m.extensionsWrite())
}
func StringFromExtensionsMap(m map[int32]Extension) string {
return newSortableExtensionsFromMap(m).String()
}
func StringFromExtensionsBytes(ext []byte) string {
m, err := BytesToExtensionsMap(ext)
if err != nil {
panic(err)
}
return StringFromExtensionsMap(m)
}
func EncodeInternalExtension(m extendableProto, data []byte) (n int, err error) {
return EncodeExtensionMap(m.extensionsWrite(), data)
}
func EncodeExtensionMap(m map[int32]Extension, data []byte) (n int, err error) {
if err := encodeExtensionsMap(m); err != nil {
return 0, err
}
keys := make([]int, 0, len(m))
for k := range m {
keys = append(keys, int(k))
}
sort.Ints(keys)
for _, k := range keys {
n += copy(data[n:], m[int32(k)].enc)
}
return n, nil
}
func GetRawExtension(m map[int32]Extension, id int32) ([]byte, error) {
if m[id].value == nil || m[id].desc == nil {
return m[id].enc, nil
}
if err := encodeExtensionsMap(m); err != nil {
return nil, err
}
return m[id].enc, nil
}
func size(buf []byte, wire int) (int, error) {
switch wire {
case WireVarint:
_, n := DecodeVarint(buf)
return n, nil
case WireFixed64:
return 8, nil
case WireBytes:
v, n := DecodeVarint(buf)
return int(v) + n, nil
case WireFixed32:
return 4, nil
case WireStartGroup:
offset := 0
for {
u, n := DecodeVarint(buf[offset:])
fwire := int(u & 0x7)
offset += n
if fwire == WireEndGroup {
return offset, nil
}
s, err := size(buf[offset:], wire)
if err != nil {
return 0, err
}
offset += s
}
}
return 0, fmt.Errorf("proto: can't get size for unknown wire type %d", wire)
}
func BytesToExtensionsMap(buf []byte) (map[int32]Extension, error) {
m := make(map[int32]Extension)
i := 0
for i < len(buf) {
tag, n := DecodeVarint(buf[i:])
if n <= 0 {
return nil, fmt.Errorf("unable to decode varint")
}
fieldNum := int32(tag >> 3)
wireType := int(tag & 0x7)
l, err := size(buf[i+n:], wireType)
if err != nil {
return nil, err
}
end := i + int(l) + n
m[int32(fieldNum)] = Extension{enc: buf[i:end]}
i = end
}
return m, nil
}
func NewExtension(e []byte) Extension {
ee := Extension{enc: make([]byte, len(e))}
copy(ee.enc, e)
return ee
}
func AppendExtension(e Message, tag int32, buf []byte) {
if ee, eok := e.(extensionsBytes); eok {
ext := ee.GetExtensions()
*ext = append(*ext, buf...)
return
}
if ee, eok := e.(extendableProto); eok {
m := ee.extensionsWrite()
ext := m[int32(tag)] // may be missing
ext.enc = append(ext.enc, buf...)
m[int32(tag)] = ext
}
}
func encodeExtension(e *Extension) error {
if e.value == nil || e.desc == nil {
// Extension is only in its encoded form.
return nil
}
// We don't skip extensions that have an encoded form set,
// because the extension value may have been mutated after
// the last time this function was called.
et := reflect.TypeOf(e.desc.ExtensionType)
props := extensionProperties(e.desc)
p := NewBuffer(nil)
// If e.value has type T, the encoder expects a *struct{ X T }.
// Pass a *T with a zero field and hope it all works out.
x := reflect.New(et)
x.Elem().Set(reflect.ValueOf(e.value))
if err := props.enc(p, props, toStructPointer(x)); err != nil {
return err
}
e.enc = p.buf
return nil
}
func (this Extension) GoString() string {
if this.enc == nil {
if err := encodeExtension(&this); err != nil {
panic(err)
}
}
return fmt.Sprintf("proto.NewExtension(%#v)", this.enc)
}
func SetUnsafeExtension(pb Message, fieldNum int32, value interface{}) error {
typ := reflect.TypeOf(pb).Elem()
ext, ok := extensionMaps[typ]
if !ok {
return fmt.Errorf("proto: bad extended type; %s is not extendable", typ.String())
}
desc, ok := ext[fieldNum]
if !ok {
return errors.New("proto: bad extension number; not in declared ranges")
}
return SetExtension(pb, desc, value)
}
func GetUnsafeExtension(pb Message, fieldNum int32) (interface{}, error) {
typ := reflect.TypeOf(pb).Elem()
ext, ok := extensionMaps[typ]
if !ok {
return nil, fmt.Errorf("proto: bad extended type; %s is not extendable", typ.String())
}
desc, ok := ext[fieldNum]
if !ok {
return nil, fmt.Errorf("unregistered field number %d", fieldNum)
}
return GetExtension(pb, desc)
}
func NewUnsafeXXX_InternalExtensions(m map[int32]Extension) XXX_InternalExtensions {
x := &XXX_InternalExtensions{
p: new(struct {
mu sync.Mutex
extensionMap map[int32]Extension
}),
}
x.p.extensionMap = m
return *x
}
func GetUnsafeExtensionsMap(extendable Message) map[int32]Extension {
pb := extendable.(extendableProto)
return pb.extensionsWrite()
}

View File

@@ -1,898 +0,0 @@
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2010 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/*
Package proto converts data structures to and from the wire format of
protocol buffers. It works in concert with the Go source code generated
for .proto files by the protocol compiler.
A summary of the properties of the protocol buffer interface
for a protocol buffer variable v:
- Names are turned from camel_case to CamelCase for export.
- There are no methods on v to set fields; just treat
them as structure fields.
- There are getters that return a field's value if set,
and return the field's default value if unset.
The getters work even if the receiver is a nil message.
- The zero value for a struct is its correct initialization state.
All desired fields must be set before marshaling.
- A Reset() method will restore a protobuf struct to its zero state.
- Non-repeated fields are pointers to the values; nil means unset.
That is, optional or required field int32 f becomes F *int32.
- Repeated fields are slices.
- Helper functions are available to aid the setting of fields.
msg.Foo = proto.String("hello") // set field
- Constants are defined to hold the default values of all fields that
have them. They have the form Default_StructName_FieldName.
Because the getter methods handle defaulted values,
direct use of these constants should be rare.
- Enums are given type names and maps from names to values.
Enum values are prefixed by the enclosing message's name, or by the
enum's type name if it is a top-level enum. Enum types have a String
method, and a Enum method to assist in message construction.
- Nested messages, groups and enums have type names prefixed with the name of
the surrounding message type.
- Extensions are given descriptor names that start with E_,
followed by an underscore-delimited list of the nested messages
that contain it (if any) followed by the CamelCased name of the
extension field itself. HasExtension, ClearExtension, GetExtension
and SetExtension are functions for manipulating extensions.
- Oneof field sets are given a single field in their message,
with distinguished wrapper types for each possible field value.
- Marshal and Unmarshal are functions to encode and decode the wire format.
When the .proto file specifies `syntax="proto3"`, there are some differences:
- Non-repeated fields of non-message type are values instead of pointers.
- Getters are only generated for message and oneof fields.
- Enum types do not get an Enum method.
The simplest way to describe this is to see an example.
Given file test.proto, containing
package example;
enum FOO { X = 17; }
message Test {
required string label = 1;
optional int32 type = 2 [default=77];
repeated int64 reps = 3;
optional group OptionalGroup = 4 {
required string RequiredField = 5;
}
oneof union {
int32 number = 6;
string name = 7;
}
}
The resulting file, test.pb.go, is:
package example
import proto "github.com/gogo/protobuf/proto"
import math "math"
type FOO int32
const (
FOO_X FOO = 17
)
var FOO_name = map[int32]string{
17: "X",
}
var FOO_value = map[string]int32{
"X": 17,
}
func (x FOO) Enum() *FOO {
p := new(FOO)
*p = x
return p
}
func (x FOO) String() string {
return proto.EnumName(FOO_name, int32(x))
}
func (x *FOO) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(FOO_value, data)
if err != nil {
return err
}
*x = FOO(value)
return nil
}
type Test struct {
Label *string `protobuf:"bytes,1,req,name=label" json:"label,omitempty"`
Type *int32 `protobuf:"varint,2,opt,name=type,def=77" json:"type,omitempty"`
Reps []int64 `protobuf:"varint,3,rep,name=reps" json:"reps,omitempty"`
Optionalgroup *Test_OptionalGroup `protobuf:"group,4,opt,name=OptionalGroup" json:"optionalgroup,omitempty"`
// Types that are valid to be assigned to Union:
// *Test_Number
// *Test_Name
Union isTest_Union `protobuf_oneof:"union"`
XXX_unrecognized []byte `json:"-"`
}
func (m *Test) Reset() { *m = Test{} }
func (m *Test) String() string { return proto.CompactTextString(m) }
func (*Test) ProtoMessage() {}
type isTest_Union interface {
isTest_Union()
}
type Test_Number struct {
Number int32 `protobuf:"varint,6,opt,name=number"`
}
type Test_Name struct {
Name string `protobuf:"bytes,7,opt,name=name"`
}
func (*Test_Number) isTest_Union() {}
func (*Test_Name) isTest_Union() {}
func (m *Test) GetUnion() isTest_Union {
if m != nil {
return m.Union
}
return nil
}
const Default_Test_Type int32 = 77
func (m *Test) GetLabel() string {
if m != nil && m.Label != nil {
return *m.Label
}
return ""
}
func (m *Test) GetType() int32 {
if m != nil && m.Type != nil {
return *m.Type
}
return Default_Test_Type
}
func (m *Test) GetOptionalgroup() *Test_OptionalGroup {
if m != nil {
return m.Optionalgroup
}
return nil
}
type Test_OptionalGroup struct {
RequiredField *string `protobuf:"bytes,5,req" json:"RequiredField,omitempty"`
}
func (m *Test_OptionalGroup) Reset() { *m = Test_OptionalGroup{} }
func (m *Test_OptionalGroup) String() string { return proto.CompactTextString(m) }
func (m *Test_OptionalGroup) GetRequiredField() string {
if m != nil && m.RequiredField != nil {
return *m.RequiredField
}
return ""
}
func (m *Test) GetNumber() int32 {
if x, ok := m.GetUnion().(*Test_Number); ok {
return x.Number
}
return 0
}
func (m *Test) GetName() string {
if x, ok := m.GetUnion().(*Test_Name); ok {
return x.Name
}
return ""
}
func init() {
proto.RegisterEnum("example.FOO", FOO_name, FOO_value)
}
To create and play with a Test object:
package main
import (
"log"
"github.com/gogo/protobuf/proto"
pb "./example.pb"
)
func main() {
test := &pb.Test{
Label: proto.String("hello"),
Type: proto.Int32(17),
Reps: []int64{1, 2, 3},
Optionalgroup: &pb.Test_OptionalGroup{
RequiredField: proto.String("good bye"),
},
Union: &pb.Test_Name{"fred"},
}
data, err := proto.Marshal(test)
if err != nil {
log.Fatal("marshaling error: ", err)
}
newTest := &pb.Test{}
err = proto.Unmarshal(data, newTest)
if err != nil {
log.Fatal("unmarshaling error: ", err)
}
// Now test and newTest contain the same data.
if test.GetLabel() != newTest.GetLabel() {
log.Fatalf("data mismatch %q != %q", test.GetLabel(), newTest.GetLabel())
}
// Use a type switch to determine which oneof was set.
switch u := test.Union.(type) {
case *pb.Test_Number: // u.Number contains the number.
case *pb.Test_Name: // u.Name contains the string.
}
// etc.
}
*/
package proto
import (
"encoding/json"
"fmt"
"log"
"reflect"
"sort"
"strconv"
"sync"
)
// Message is implemented by generated protocol buffer messages.
type Message interface {
Reset()
String() string
ProtoMessage()
}
// Stats records allocation details about the protocol buffer encoders
// and decoders. Useful for tuning the library itself.
type Stats struct {
Emalloc uint64 // mallocs in encode
Dmalloc uint64 // mallocs in decode
Encode uint64 // number of encodes
Decode uint64 // number of decodes
Chit uint64 // number of cache hits
Cmiss uint64 // number of cache misses
Size uint64 // number of sizes
}
// Set to true to enable stats collection.
const collectStats = false
var stats Stats
// GetStats returns a copy of the global Stats structure.
func GetStats() Stats { return stats }
// A Buffer is a buffer manager for marshaling and unmarshaling
// protocol buffers. It may be reused between invocations to
// reduce memory usage. It is not necessary to use a Buffer;
// the global functions Marshal and Unmarshal create a
// temporary Buffer and are fine for most applications.
type Buffer struct {
buf []byte // encode/decode byte stream
index int // read point
// pools of basic types to amortize allocation.
bools []bool
uint32s []uint32
uint64s []uint64
// extra pools, only used with pointer_reflect.go
int32s []int32
int64s []int64
float32s []float32
float64s []float64
}
// NewBuffer allocates a new Buffer and initializes its internal data to
// the contents of the argument slice.
func NewBuffer(e []byte) *Buffer {
return &Buffer{buf: e}
}
// Reset resets the Buffer, ready for marshaling a new protocol buffer.
func (p *Buffer) Reset() {
p.buf = p.buf[0:0] // for reading/writing
p.index = 0 // for reading
}
// SetBuf replaces the internal buffer with the slice,
// ready for unmarshaling the contents of the slice.
func (p *Buffer) SetBuf(s []byte) {
p.buf = s
p.index = 0
}
// Bytes returns the contents of the Buffer.
func (p *Buffer) Bytes() []byte { return p.buf }
/*
* Helper routines for simplifying the creation of optional fields of basic type.
*/
// Bool is a helper routine that allocates a new bool value
// to store v and returns a pointer to it.
func Bool(v bool) *bool {
return &v
}
// Int32 is a helper routine that allocates a new int32 value
// to store v and returns a pointer to it.
func Int32(v int32) *int32 {
return &v
}
// Int is a helper routine that allocates a new int32 value
// to store v and returns a pointer to it, but unlike Int32
// its argument value is an int.
func Int(v int) *int32 {
p := new(int32)
*p = int32(v)
return p
}
// Int64 is a helper routine that allocates a new int64 value
// to store v and returns a pointer to it.
func Int64(v int64) *int64 {
return &v
}
// Float32 is a helper routine that allocates a new float32 value
// to store v and returns a pointer to it.
func Float32(v float32) *float32 {
return &v
}
// Float64 is a helper routine that allocates a new float64 value
// to store v and returns a pointer to it.
func Float64(v float64) *float64 {
return &v
}
// Uint32 is a helper routine that allocates a new uint32 value
// to store v and returns a pointer to it.
func Uint32(v uint32) *uint32 {
return &v
}
// Uint64 is a helper routine that allocates a new uint64 value
// to store v and returns a pointer to it.
func Uint64(v uint64) *uint64 {
return &v
}
// String is a helper routine that allocates a new string value
// to store v and returns a pointer to it.
func String(v string) *string {
return &v
}
// EnumName is a helper function to simplify printing protocol buffer enums
// by name. Given an enum map and a value, it returns a useful string.
func EnumName(m map[int32]string, v int32) string {
s, ok := m[v]
if ok {
return s
}
return strconv.Itoa(int(v))
}
// UnmarshalJSONEnum is a helper function to simplify recovering enum int values
// from their JSON-encoded representation. Given a map from the enum's symbolic
// names to its int values, and a byte buffer containing the JSON-encoded
// value, it returns an int32 that can be cast to the enum type by the caller.
//
// The function can deal with both JSON representations, numeric and symbolic.
func UnmarshalJSONEnum(m map[string]int32, data []byte, enumName string) (int32, error) {
if data[0] == '"' {
// New style: enums are strings.
var repr string
if err := json.Unmarshal(data, &repr); err != nil {
return -1, err
}
val, ok := m[repr]
if !ok {
return 0, fmt.Errorf("unrecognized enum %s value %q", enumName, repr)
}
return val, nil
}
// Old style: enums are ints.
var val int32
if err := json.Unmarshal(data, &val); err != nil {
return 0, fmt.Errorf("cannot unmarshal %#q into enum %s", data, enumName)
}
return val, nil
}
// DebugPrint dumps the encoded data in b in a debugging format with a header
// including the string s. Used in testing but made available for general debugging.
func (p *Buffer) DebugPrint(s string, b []byte) {
var u uint64
obuf := p.buf
sindex := p.index
p.buf = b
p.index = 0
depth := 0
fmt.Printf("\n--- %s ---\n", s)
out:
for {
for i := 0; i < depth; i++ {
fmt.Print(" ")
}
index := p.index
if index == len(p.buf) {
break
}
op, err := p.DecodeVarint()
if err != nil {
fmt.Printf("%3d: fetching op err %v\n", index, err)
break out
}
tag := op >> 3
wire := op & 7
switch wire {
default:
fmt.Printf("%3d: t=%3d unknown wire=%d\n",
index, tag, wire)
break out
case WireBytes:
var r []byte
r, err = p.DecodeRawBytes(false)
if err != nil {
break out
}
fmt.Printf("%3d: t=%3d bytes [%d]", index, tag, len(r))
if len(r) <= 6 {
for i := 0; i < len(r); i++ {
fmt.Printf(" %.2x", r[i])
}
} else {
for i := 0; i < 3; i++ {
fmt.Printf(" %.2x", r[i])
}
fmt.Printf(" ..")
for i := len(r) - 3; i < len(r); i++ {
fmt.Printf(" %.2x", r[i])
}
}
fmt.Printf("\n")
case WireFixed32:
u, err = p.DecodeFixed32()
if err != nil {
fmt.Printf("%3d: t=%3d fix32 err %v\n", index, tag, err)
break out
}
fmt.Printf("%3d: t=%3d fix32 %d\n", index, tag, u)
case WireFixed64:
u, err = p.DecodeFixed64()
if err != nil {
fmt.Printf("%3d: t=%3d fix64 err %v\n", index, tag, err)
break out
}
fmt.Printf("%3d: t=%3d fix64 %d\n", index, tag, u)
case WireVarint:
u, err = p.DecodeVarint()
if err != nil {
fmt.Printf("%3d: t=%3d varint err %v\n", index, tag, err)
break out
}
fmt.Printf("%3d: t=%3d varint %d\n", index, tag, u)
case WireStartGroup:
fmt.Printf("%3d: t=%3d start\n", index, tag)
depth++
case WireEndGroup:
depth--
fmt.Printf("%3d: t=%3d end\n", index, tag)
}
}
if depth != 0 {
fmt.Printf("%3d: start-end not balanced %d\n", p.index, depth)
}
fmt.Printf("\n")
p.buf = obuf
p.index = sindex
}
// SetDefaults sets unset protocol buffer fields to their default values.
// It only modifies fields that are both unset and have defined defaults.
// It recursively sets default values in any non-nil sub-messages.
func SetDefaults(pb Message) {
setDefaults(reflect.ValueOf(pb), true, false)
}
// v is a pointer to a struct.
func setDefaults(v reflect.Value, recur, zeros bool) {
v = v.Elem()
defaultMu.RLock()
dm, ok := defaults[v.Type()]
defaultMu.RUnlock()
if !ok {
dm = buildDefaultMessage(v.Type())
defaultMu.Lock()
defaults[v.Type()] = dm
defaultMu.Unlock()
}
for _, sf := range dm.scalars {
f := v.Field(sf.index)
if !f.IsNil() {
// field already set
continue
}
dv := sf.value
if dv == nil && !zeros {
// no explicit default, and don't want to set zeros
continue
}
fptr := f.Addr().Interface() // **T
// TODO: Consider batching the allocations we do here.
switch sf.kind {
case reflect.Bool:
b := new(bool)
if dv != nil {
*b = dv.(bool)
}
*(fptr.(**bool)) = b
case reflect.Float32:
f := new(float32)
if dv != nil {
*f = dv.(float32)
}
*(fptr.(**float32)) = f
case reflect.Float64:
f := new(float64)
if dv != nil {
*f = dv.(float64)
}
*(fptr.(**float64)) = f
case reflect.Int32:
// might be an enum
if ft := f.Type(); ft != int32PtrType {
// enum
f.Set(reflect.New(ft.Elem()))
if dv != nil {
f.Elem().SetInt(int64(dv.(int32)))
}
} else {
// int32 field
i := new(int32)
if dv != nil {
*i = dv.(int32)
}
*(fptr.(**int32)) = i
}
case reflect.Int64:
i := new(int64)
if dv != nil {
*i = dv.(int64)
}
*(fptr.(**int64)) = i
case reflect.String:
s := new(string)
if dv != nil {
*s = dv.(string)
}
*(fptr.(**string)) = s
case reflect.Uint8:
// exceptional case: []byte
var b []byte
if dv != nil {
db := dv.([]byte)
b = make([]byte, len(db))
copy(b, db)
} else {
b = []byte{}
}
*(fptr.(*[]byte)) = b
case reflect.Uint32:
u := new(uint32)
if dv != nil {
*u = dv.(uint32)
}
*(fptr.(**uint32)) = u
case reflect.Uint64:
u := new(uint64)
if dv != nil {
*u = dv.(uint64)
}
*(fptr.(**uint64)) = u
default:
log.Printf("proto: can't set default for field %v (sf.kind=%v)", f, sf.kind)
}
}
for _, ni := range dm.nested {
f := v.Field(ni)
// f is *T or []*T or map[T]*T
switch f.Kind() {
case reflect.Ptr:
if f.IsNil() {
continue
}
setDefaults(f, recur, zeros)
case reflect.Slice:
for i := 0; i < f.Len(); i++ {
e := f.Index(i)
if e.IsNil() {
continue
}
setDefaults(e, recur, zeros)
}
case reflect.Map:
for _, k := range f.MapKeys() {
e := f.MapIndex(k)
if e.IsNil() {
continue
}
setDefaults(e, recur, zeros)
}
}
}
}
var (
// defaults maps a protocol buffer struct type to a slice of the fields,
// with its scalar fields set to their proto-declared non-zero default values.
defaultMu sync.RWMutex
defaults = make(map[reflect.Type]defaultMessage)
int32PtrType = reflect.TypeOf((*int32)(nil))
)
// defaultMessage represents information about the default values of a message.
type defaultMessage struct {
scalars []scalarField
nested []int // struct field index of nested messages
}
type scalarField struct {
index int // struct field index
kind reflect.Kind // element type (the T in *T or []T)
value interface{} // the proto-declared default value, or nil
}
// t is a struct type.
func buildDefaultMessage(t reflect.Type) (dm defaultMessage) {
sprop := GetProperties(t)
for _, prop := range sprop.Prop {
fi, ok := sprop.decoderTags.get(prop.Tag)
if !ok {
// XXX_unrecognized
continue
}
ft := t.Field(fi).Type
sf, nested, err := fieldDefault(ft, prop)
switch {
case err != nil:
log.Print(err)
case nested:
dm.nested = append(dm.nested, fi)
case sf != nil:
sf.index = fi
dm.scalars = append(dm.scalars, *sf)
}
}
return dm
}
// fieldDefault returns the scalarField for field type ft.
// sf will be nil if the field can not have a default.
// nestedMessage will be true if this is a nested message.
// Note that sf.index is not set on return.
func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMessage bool, err error) {
var canHaveDefault bool
switch ft.Kind() {
case reflect.Ptr:
if ft.Elem().Kind() == reflect.Struct {
nestedMessage = true
} else {
canHaveDefault = true // proto2 scalar field
}
case reflect.Slice:
switch ft.Elem().Kind() {
case reflect.Ptr:
nestedMessage = true // repeated message
case reflect.Uint8:
canHaveDefault = true // bytes field
}
case reflect.Map:
if ft.Elem().Kind() == reflect.Ptr {
nestedMessage = true // map with message values
}
}
if !canHaveDefault {
if nestedMessage {
return nil, true, nil
}
return nil, false, nil
}
// We now know that ft is a pointer or slice.
sf = &scalarField{kind: ft.Elem().Kind()}
// scalar fields without defaults
if !prop.HasDefault {
return sf, false, nil
}
// a scalar field: either *T or []byte
switch ft.Elem().Kind() {
case reflect.Bool:
x, err := strconv.ParseBool(prop.Default)
if err != nil {
return nil, false, fmt.Errorf("proto: bad default bool %q: %v", prop.Default, err)
}
sf.value = x
case reflect.Float32:
x, err := strconv.ParseFloat(prop.Default, 32)
if err != nil {
return nil, false, fmt.Errorf("proto: bad default float32 %q: %v", prop.Default, err)
}
sf.value = float32(x)
case reflect.Float64:
x, err := strconv.ParseFloat(prop.Default, 64)
if err != nil {
return nil, false, fmt.Errorf("proto: bad default float64 %q: %v", prop.Default, err)
}
sf.value = x
case reflect.Int32:
x, err := strconv.ParseInt(prop.Default, 10, 32)
if err != nil {
return nil, false, fmt.Errorf("proto: bad default int32 %q: %v", prop.Default, err)
}
sf.value = int32(x)
case reflect.Int64:
x, err := strconv.ParseInt(prop.Default, 10, 64)
if err != nil {
return nil, false, fmt.Errorf("proto: bad default int64 %q: %v", prop.Default, err)
}
sf.value = x
case reflect.String:
sf.value = prop.Default
case reflect.Uint8:
// []byte (not *uint8)
sf.value = []byte(prop.Default)
case reflect.Uint32:
x, err := strconv.ParseUint(prop.Default, 10, 32)
if err != nil {
return nil, false, fmt.Errorf("proto: bad default uint32 %q: %v", prop.Default, err)
}
sf.value = uint32(x)
case reflect.Uint64:
x, err := strconv.ParseUint(prop.Default, 10, 64)
if err != nil {
return nil, false, fmt.Errorf("proto: bad default uint64 %q: %v", prop.Default, err)
}
sf.value = x
default:
return nil, false, fmt.Errorf("proto: unhandled def kind %v", ft.Elem().Kind())
}
return sf, false, nil
}
// Map fields may have key types of non-float scalars, strings and enums.
// The easiest way to sort them in some deterministic order is to use fmt.
// If this turns out to be inefficient we can always consider other options,
// such as doing a Schwartzian transform.
func mapKeys(vs []reflect.Value) sort.Interface {
s := mapKeySorter{
vs: vs,
// default Less function: textual comparison
less: func(a, b reflect.Value) bool {
return fmt.Sprint(a.Interface()) < fmt.Sprint(b.Interface())
},
}
// Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps;
// numeric keys are sorted numerically.
if len(vs) == 0 {
return s
}
switch vs[0].Kind() {
case reflect.Int32, reflect.Int64:
s.less = func(a, b reflect.Value) bool { return a.Int() < b.Int() }
case reflect.Uint32, reflect.Uint64:
s.less = func(a, b reflect.Value) bool { return a.Uint() < b.Uint() }
}
return s
}
type mapKeySorter struct {
vs []reflect.Value
less func(a, b reflect.Value) bool
}
func (s mapKeySorter) Len() int { return len(s.vs) }
func (s mapKeySorter) Swap(i, j int) { s.vs[i], s.vs[j] = s.vs[j], s.vs[i] }
func (s mapKeySorter) Less(i, j int) bool {
return s.less(s.vs[i], s.vs[j])
}
// isProto3Zero reports whether v is a zero proto3 value.
func isProto3Zero(v reflect.Value) bool {
switch v.Kind() {
case reflect.Bool:
return !v.Bool()
case reflect.Int32, reflect.Int64:
return v.Int() == 0
case reflect.Uint32, reflect.Uint64:
return v.Uint() == 0
case reflect.Float32, reflect.Float64:
return v.Float() == 0
case reflect.String:
return v.String() == ""
}
return false
}
// ProtoPackageIsVersion2 is referenced from generated protocol buffer files
// to assert that that code is compatible with this version of the proto package.
const GoGoProtoPackageIsVersion2 = true
// ProtoPackageIsVersion1 is referenced from generated protocol buffer files
// to assert that that code is compatible with this version of the proto package.
const GoGoProtoPackageIsVersion1 = true

View File

@@ -1,42 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"encoding/json"
"strconv"
)
func MarshalJSONEnum(m map[int32]string, value int32) ([]byte, error) {
s, ok := m[value]
if !ok {
s = strconv.Itoa(int(value))
}
return json.Marshal(s)
}

View File

@@ -1,311 +0,0 @@
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2010 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
/*
* Support for message sets.
*/
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"reflect"
"sort"
)
// errNoMessageTypeID occurs when a protocol buffer does not have a message type ID.
// A message type ID is required for storing a protocol buffer in a message set.
var errNoMessageTypeID = errors.New("proto does not have a message type ID")
// The first two types (_MessageSet_Item and messageSet)
// model what the protocol compiler produces for the following protocol message:
// message MessageSet {
// repeated group Item = 1 {
// required int32 type_id = 2;
// required string message = 3;
// };
// }
// That is the MessageSet wire format. We can't use a proto to generate these
// because that would introduce a circular dependency between it and this package.
type _MessageSet_Item struct {
TypeId *int32 `protobuf:"varint,2,req,name=type_id"`
Message []byte `protobuf:"bytes,3,req,name=message"`
}
type messageSet struct {
Item []*_MessageSet_Item `protobuf:"group,1,rep"`
XXX_unrecognized []byte
// TODO: caching?
}
// Make sure messageSet is a Message.
var _ Message = (*messageSet)(nil)
// messageTypeIder is an interface satisfied by a protocol buffer type
// that may be stored in a MessageSet.
type messageTypeIder interface {
MessageTypeId() int32
}
func (ms *messageSet) find(pb Message) *_MessageSet_Item {
mti, ok := pb.(messageTypeIder)
if !ok {
return nil
}
id := mti.MessageTypeId()
for _, item := range ms.Item {
if *item.TypeId == id {
return item
}
}
return nil
}
func (ms *messageSet) Has(pb Message) bool {
if ms.find(pb) != nil {
return true
}
return false
}
func (ms *messageSet) Unmarshal(pb Message) error {
if item := ms.find(pb); item != nil {
return Unmarshal(item.Message, pb)
}
if _, ok := pb.(messageTypeIder); !ok {
return errNoMessageTypeID
}
return nil // TODO: return error instead?
}
func (ms *messageSet) Marshal(pb Message) error {
msg, err := Marshal(pb)
if err != nil {
return err
}
if item := ms.find(pb); item != nil {
// reuse existing item
item.Message = msg
return nil
}
mti, ok := pb.(messageTypeIder)
if !ok {
return errNoMessageTypeID
}
mtid := mti.MessageTypeId()
ms.Item = append(ms.Item, &_MessageSet_Item{
TypeId: &mtid,
Message: msg,
})
return nil
}
func (ms *messageSet) Reset() { *ms = messageSet{} }
func (ms *messageSet) String() string { return CompactTextString(ms) }
func (*messageSet) ProtoMessage() {}
// Support for the message_set_wire_format message option.
func skipVarint(buf []byte) []byte {
i := 0
for ; buf[i]&0x80 != 0; i++ {
}
return buf[i+1:]
}
// MarshalMessageSet encodes the extension map represented by m in the message set wire format.
// It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option.
func MarshalMessageSet(exts interface{}) ([]byte, error) {
var m map[int32]Extension
switch exts := exts.(type) {
case *XXX_InternalExtensions:
if err := encodeExtensions(exts); err != nil {
return nil, err
}
m, _ = exts.extensionsRead()
case map[int32]Extension:
if err := encodeExtensionsMap(exts); err != nil {
return nil, err
}
m = exts
default:
return nil, errors.New("proto: not an extension map")
}
// Sort extension IDs to provide a deterministic encoding.
// See also enc_map in encode.go.
ids := make([]int, 0, len(m))
for id := range m {
ids = append(ids, int(id))
}
sort.Ints(ids)
ms := &messageSet{Item: make([]*_MessageSet_Item, 0, len(m))}
for _, id := range ids {
e := m[int32(id)]
// Remove the wire type and field number varint, as well as the length varint.
msg := skipVarint(skipVarint(e.enc))
ms.Item = append(ms.Item, &_MessageSet_Item{
TypeId: Int32(int32(id)),
Message: msg,
})
}
return Marshal(ms)
}
// UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format.
// It is called by generated Unmarshal methods on protocol buffer messages with the message_set_wire_format option.
func UnmarshalMessageSet(buf []byte, exts interface{}) error {
var m map[int32]Extension
switch exts := exts.(type) {
case *XXX_InternalExtensions:
m = exts.extensionsWrite()
case map[int32]Extension:
m = exts
default:
return errors.New("proto: not an extension map")
}
ms := new(messageSet)
if err := Unmarshal(buf, ms); err != nil {
return err
}
for _, item := range ms.Item {
id := *item.TypeId
msg := item.Message
// Restore wire type and field number varint, plus length varint.
// Be careful to preserve duplicate items.
b := EncodeVarint(uint64(id)<<3 | WireBytes)
if ext, ok := m[id]; ok {
// Existing data; rip off the tag and length varint
// so we join the new data correctly.
// We can assume that ext.enc is set because we are unmarshaling.
o := ext.enc[len(b):] // skip wire type and field number
_, n := DecodeVarint(o) // calculate length of length varint
o = o[n:] // skip length varint
msg = append(o, msg...) // join old data and new data
}
b = append(b, EncodeVarint(uint64(len(msg)))...)
b = append(b, msg...)
m[id] = Extension{enc: b}
}
return nil
}
// MarshalMessageSetJSON encodes the extension map represented by m in JSON format.
// It is called by generated MarshalJSON methods on protocol buffer messages with the message_set_wire_format option.
func MarshalMessageSetJSON(exts interface{}) ([]byte, error) {
var m map[int32]Extension
switch exts := exts.(type) {
case *XXX_InternalExtensions:
m, _ = exts.extensionsRead()
case map[int32]Extension:
m = exts
default:
return nil, errors.New("proto: not an extension map")
}
var b bytes.Buffer
b.WriteByte('{')
// Process the map in key order for deterministic output.
ids := make([]int32, 0, len(m))
for id := range m {
ids = append(ids, id)
}
sort.Sort(int32Slice(ids)) // int32Slice defined in text.go
for i, id := range ids {
ext := m[id]
if i > 0 {
b.WriteByte(',')
}
msd, ok := messageSetMap[id]
if !ok {
// Unknown type; we can't render it, so skip it.
continue
}
fmt.Fprintf(&b, `"[%s]":`, msd.name)
x := ext.value
if x == nil {
x = reflect.New(msd.t.Elem()).Interface()
if err := Unmarshal(ext.enc, x.(Message)); err != nil {
return nil, err
}
}
d, err := json.Marshal(x)
if err != nil {
return nil, err
}
b.Write(d)
}
b.WriteByte('}')
return b.Bytes(), nil
}
// UnmarshalMessageSetJSON decodes the extension map encoded in buf in JSON format.
// It is called by generated UnmarshalJSON methods on protocol buffer messages with the message_set_wire_format option.
func UnmarshalMessageSetJSON(buf []byte, exts interface{}) error {
// Common-case fast path.
if len(buf) == 0 || bytes.Equal(buf, []byte("{}")) {
return nil
}
// This is fairly tricky, and it's not clear that it is needed.
return errors.New("TODO: UnmarshalMessageSetJSON not yet implemented")
}
// A global registry of types that can be used in a MessageSet.
var messageSetMap = make(map[int32]messageSetDesc)
type messageSetDesc struct {
t reflect.Type // pointer to struct
name string
}
// RegisterMessageSetType is called from the generated code.
func RegisterMessageSetType(m Message, fieldNum int32, name string) {
messageSetMap[fieldNum] = messageSetDesc{
t: reflect.TypeOf(m),
name: name,
}
}

View File

@@ -1,484 +0,0 @@
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2012 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// +build appengine js
// This file contains an implementation of proto field accesses using package reflect.
// It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can
// be used on App Engine.
package proto
import (
"math"
"reflect"
)
// A structPointer is a pointer to a struct.
type structPointer struct {
v reflect.Value
}
// toStructPointer returns a structPointer equivalent to the given reflect value.
// The reflect value must itself be a pointer to a struct.
func toStructPointer(v reflect.Value) structPointer {
return structPointer{v}
}
// IsNil reports whether p is nil.
func structPointer_IsNil(p structPointer) bool {
return p.v.IsNil()
}
// Interface returns the struct pointer as an interface value.
func structPointer_Interface(p structPointer, _ reflect.Type) interface{} {
return p.v.Interface()
}
// A field identifies a field in a struct, accessible from a structPointer.
// In this implementation, a field is identified by the sequence of field indices
// passed to reflect's FieldByIndex.
type field []int
// toField returns a field equivalent to the given reflect field.
func toField(f *reflect.StructField) field {
return f.Index
}
// invalidField is an invalid field identifier.
var invalidField = field(nil)
// IsValid reports whether the field identifier is valid.
func (f field) IsValid() bool { return f != nil }
// field returns the given field in the struct as a reflect value.
func structPointer_field(p structPointer, f field) reflect.Value {
// Special case: an extension map entry with a value of type T
// passes a *T to the struct-handling code with a zero field,
// expecting that it will be treated as equivalent to *struct{ X T },
// which has the same memory layout. We have to handle that case
// specially, because reflect will panic if we call FieldByIndex on a
// non-struct.
if f == nil {
return p.v.Elem()
}
return p.v.Elem().FieldByIndex(f)
}
// ifield returns the given field in the struct as an interface value.
func structPointer_ifield(p structPointer, f field) interface{} {
return structPointer_field(p, f).Addr().Interface()
}
// Bytes returns the address of a []byte field in the struct.
func structPointer_Bytes(p structPointer, f field) *[]byte {
return structPointer_ifield(p, f).(*[]byte)
}
// BytesSlice returns the address of a [][]byte field in the struct.
func structPointer_BytesSlice(p structPointer, f field) *[][]byte {
return structPointer_ifield(p, f).(*[][]byte)
}
// Bool returns the address of a *bool field in the struct.
func structPointer_Bool(p structPointer, f field) **bool {
return structPointer_ifield(p, f).(**bool)
}
// BoolVal returns the address of a bool field in the struct.
func structPointer_BoolVal(p structPointer, f field) *bool {
return structPointer_ifield(p, f).(*bool)
}
// BoolSlice returns the address of a []bool field in the struct.
func structPointer_BoolSlice(p structPointer, f field) *[]bool {
return structPointer_ifield(p, f).(*[]bool)
}
// String returns the address of a *string field in the struct.
func structPointer_String(p structPointer, f field) **string {
return structPointer_ifield(p, f).(**string)
}
// StringVal returns the address of a string field in the struct.
func structPointer_StringVal(p structPointer, f field) *string {
return structPointer_ifield(p, f).(*string)
}
// StringSlice returns the address of a []string field in the struct.
func structPointer_StringSlice(p structPointer, f field) *[]string {
return structPointer_ifield(p, f).(*[]string)
}
// Extensions returns the address of an extension map field in the struct.
func structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions {
return structPointer_ifield(p, f).(*XXX_InternalExtensions)
}
// ExtMap returns the address of an extension map field in the struct.
func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension {
return structPointer_ifield(p, f).(*map[int32]Extension)
}
// NewAt returns the reflect.Value for a pointer to a field in the struct.
func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value {
return structPointer_field(p, f).Addr()
}
// SetStructPointer writes a *struct field in the struct.
func structPointer_SetStructPointer(p structPointer, f field, q structPointer) {
structPointer_field(p, f).Set(q.v)
}
// GetStructPointer reads a *struct field in the struct.
func structPointer_GetStructPointer(p structPointer, f field) structPointer {
return structPointer{structPointer_field(p, f)}
}
// StructPointerSlice the address of a []*struct field in the struct.
func structPointer_StructPointerSlice(p structPointer, f field) structPointerSlice {
return structPointerSlice{structPointer_field(p, f)}
}
// A structPointerSlice represents the address of a slice of pointers to structs
// (themselves messages or groups). That is, v.Type() is *[]*struct{...}.
type structPointerSlice struct {
v reflect.Value
}
func (p structPointerSlice) Len() int { return p.v.Len() }
func (p structPointerSlice) Index(i int) structPointer { return structPointer{p.v.Index(i)} }
func (p structPointerSlice) Append(q structPointer) {
p.v.Set(reflect.Append(p.v, q.v))
}
var (
int32Type = reflect.TypeOf(int32(0))
uint32Type = reflect.TypeOf(uint32(0))
float32Type = reflect.TypeOf(float32(0))
int64Type = reflect.TypeOf(int64(0))
uint64Type = reflect.TypeOf(uint64(0))
float64Type = reflect.TypeOf(float64(0))
)
// A word32 represents a field of type *int32, *uint32, *float32, or *enum.
// That is, v.Type() is *int32, *uint32, *float32, or *enum and v is assignable.
type word32 struct {
v reflect.Value
}
// IsNil reports whether p is nil.
func word32_IsNil(p word32) bool {
return p.v.IsNil()
}
// Set sets p to point at a newly allocated word with bits set to x.
func word32_Set(p word32, o *Buffer, x uint32) {
t := p.v.Type().Elem()
switch t {
case int32Type:
if len(o.int32s) == 0 {
o.int32s = make([]int32, uint32PoolSize)
}
o.int32s[0] = int32(x)
p.v.Set(reflect.ValueOf(&o.int32s[0]))
o.int32s = o.int32s[1:]
return
case uint32Type:
if len(o.uint32s) == 0 {
o.uint32s = make([]uint32, uint32PoolSize)
}
o.uint32s[0] = x
p.v.Set(reflect.ValueOf(&o.uint32s[0]))
o.uint32s = o.uint32s[1:]
return
case float32Type:
if len(o.float32s) == 0 {
o.float32s = make([]float32, uint32PoolSize)
}
o.float32s[0] = math.Float32frombits(x)
p.v.Set(reflect.ValueOf(&o.float32s[0]))
o.float32s = o.float32s[1:]
return
}
// must be enum
p.v.Set(reflect.New(t))
p.v.Elem().SetInt(int64(int32(x)))
}
// Get gets the bits pointed at by p, as a uint32.
func word32_Get(p word32) uint32 {
elem := p.v.Elem()
switch elem.Kind() {
case reflect.Int32:
return uint32(elem.Int())
case reflect.Uint32:
return uint32(elem.Uint())
case reflect.Float32:
return math.Float32bits(float32(elem.Float()))
}
panic("unreachable")
}
// Word32 returns a reference to a *int32, *uint32, *float32, or *enum field in the struct.
func structPointer_Word32(p structPointer, f field) word32 {
return word32{structPointer_field(p, f)}
}
// A word32Val represents a field of type int32, uint32, float32, or enum.
// That is, v.Type() is int32, uint32, float32, or enum and v is assignable.
type word32Val struct {
v reflect.Value
}
// Set sets *p to x.
func word32Val_Set(p word32Val, x uint32) {
switch p.v.Type() {
case int32Type:
p.v.SetInt(int64(x))
return
case uint32Type:
p.v.SetUint(uint64(x))
return
case float32Type:
p.v.SetFloat(float64(math.Float32frombits(x)))
return
}
// must be enum
p.v.SetInt(int64(int32(x)))
}
// Get gets the bits pointed at by p, as a uint32.
func word32Val_Get(p word32Val) uint32 {
elem := p.v
switch elem.Kind() {
case reflect.Int32:
return uint32(elem.Int())
case reflect.Uint32:
return uint32(elem.Uint())
case reflect.Float32:
return math.Float32bits(float32(elem.Float()))
}
panic("unreachable")
}
// Word32Val returns a reference to a int32, uint32, float32, or enum field in the struct.
func structPointer_Word32Val(p structPointer, f field) word32Val {
return word32Val{structPointer_field(p, f)}
}
// A word32Slice is a slice of 32-bit values.
// That is, v.Type() is []int32, []uint32, []float32, or []enum.
type word32Slice struct {
v reflect.Value
}
func (p word32Slice) Append(x uint32) {
n, m := p.v.Len(), p.v.Cap()
if n < m {
p.v.SetLen(n + 1)
} else {
t := p.v.Type().Elem()
p.v.Set(reflect.Append(p.v, reflect.Zero(t)))
}
elem := p.v.Index(n)
switch elem.Kind() {
case reflect.Int32:
elem.SetInt(int64(int32(x)))
case reflect.Uint32:
elem.SetUint(uint64(x))
case reflect.Float32:
elem.SetFloat(float64(math.Float32frombits(x)))
}
}
func (p word32Slice) Len() int {
return p.v.Len()
}
func (p word32Slice) Index(i int) uint32 {
elem := p.v.Index(i)
switch elem.Kind() {
case reflect.Int32:
return uint32(elem.Int())
case reflect.Uint32:
return uint32(elem.Uint())
case reflect.Float32:
return math.Float32bits(float32(elem.Float()))
}
panic("unreachable")
}
// Word32Slice returns a reference to a []int32, []uint32, []float32, or []enum field in the struct.
func structPointer_Word32Slice(p structPointer, f field) word32Slice {
return word32Slice{structPointer_field(p, f)}
}
// word64 is like word32 but for 64-bit values.
type word64 struct {
v reflect.Value
}
func word64_Set(p word64, o *Buffer, x uint64) {
t := p.v.Type().Elem()
switch t {
case int64Type:
if len(o.int64s) == 0 {
o.int64s = make([]int64, uint64PoolSize)
}
o.int64s[0] = int64(x)
p.v.Set(reflect.ValueOf(&o.int64s[0]))
o.int64s = o.int64s[1:]
return
case uint64Type:
if len(o.uint64s) == 0 {
o.uint64s = make([]uint64, uint64PoolSize)
}
o.uint64s[0] = x
p.v.Set(reflect.ValueOf(&o.uint64s[0]))
o.uint64s = o.uint64s[1:]
return
case float64Type:
if len(o.float64s) == 0 {
o.float64s = make([]float64, uint64PoolSize)
}
o.float64s[0] = math.Float64frombits(x)
p.v.Set(reflect.ValueOf(&o.float64s[0]))
o.float64s = o.float64s[1:]
return
}
panic("unreachable")
}
func word64_IsNil(p word64) bool {
return p.v.IsNil()
}
func word64_Get(p word64) uint64 {
elem := p.v.Elem()
switch elem.Kind() {
case reflect.Int64:
return uint64(elem.Int())
case reflect.Uint64:
return elem.Uint()
case reflect.Float64:
return math.Float64bits(elem.Float())
}
panic("unreachable")
}
func structPointer_Word64(p structPointer, f field) word64 {
return word64{structPointer_field(p, f)}
}
// word64Val is like word32Val but for 64-bit values.
type word64Val struct {
v reflect.Value
}
func word64Val_Set(p word64Val, o *Buffer, x uint64) {
switch p.v.Type() {
case int64Type:
p.v.SetInt(int64(x))
return
case uint64Type:
p.v.SetUint(x)
return
case float64Type:
p.v.SetFloat(math.Float64frombits(x))
return
}
panic("unreachable")
}
func word64Val_Get(p word64Val) uint64 {
elem := p.v
switch elem.Kind() {
case reflect.Int64:
return uint64(elem.Int())
case reflect.Uint64:
return elem.Uint()
case reflect.Float64:
return math.Float64bits(elem.Float())
}
panic("unreachable")
}
func structPointer_Word64Val(p structPointer, f field) word64Val {
return word64Val{structPointer_field(p, f)}
}
type word64Slice struct {
v reflect.Value
}
func (p word64Slice) Append(x uint64) {
n, m := p.v.Len(), p.v.Cap()
if n < m {
p.v.SetLen(n + 1)
} else {
t := p.v.Type().Elem()
p.v.Set(reflect.Append(p.v, reflect.Zero(t)))
}
elem := p.v.Index(n)
switch elem.Kind() {
case reflect.Int64:
elem.SetInt(int64(int64(x)))
case reflect.Uint64:
elem.SetUint(uint64(x))
case reflect.Float64:
elem.SetFloat(float64(math.Float64frombits(x)))
}
}
func (p word64Slice) Len() int {
return p.v.Len()
}
func (p word64Slice) Index(i int) uint64 {
elem := p.v.Index(i)
switch elem.Kind() {
case reflect.Int64:
return uint64(elem.Int())
case reflect.Uint64:
return uint64(elem.Uint())
case reflect.Float64:
return math.Float64bits(float64(elem.Float()))
}
panic("unreachable")
}
func structPointer_Word64Slice(p structPointer, f field) word64Slice {
return word64Slice{structPointer_field(p, f)}
}

View File

@@ -1,85 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2016, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// +build appengine js
package proto
import (
"reflect"
)
func structPointer_FieldPointer(p structPointer, f field) structPointer {
panic("not implemented")
}
func appendStructPointer(base structPointer, f field, typ reflect.Type) structPointer {
panic("not implemented")
}
func structPointer_InterfaceAt(p structPointer, f field, t reflect.Type) interface{} {
panic("not implemented")
}
func structPointer_InterfaceRef(p structPointer, f field, t reflect.Type) interface{} {
panic("not implemented")
}
func structPointer_GetRefStructPointer(p structPointer, f field) structPointer {
panic("not implemented")
}
func structPointer_Add(p structPointer, size field) structPointer {
panic("not implemented")
}
func structPointer_Len(p structPointer, f field) int {
panic("not implemented")
}
func structPointer_GetSliceHeader(p structPointer, f field) *reflect.SliceHeader {
panic("not implemented")
}
func structPointer_Copy(oldptr structPointer, newptr structPointer, size int) {
panic("not implemented")
}
func structPointer_StructRefSlice(p structPointer, f field, size uintptr) *structRefSlice {
panic("not implemented")
}
type structRefSlice struct{}
func (v *structRefSlice) Len() int {
panic("not implemented")
}
func (v *structRefSlice) Index(i int) structPointer {
panic("not implemented")
}

View File

@@ -1,270 +0,0 @@
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2012 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// +build !appengine,!js
// This file contains the implementation of the proto field accesses using package unsafe.
package proto
import (
"reflect"
"unsafe"
)
// NOTE: These type_Foo functions would more idiomatically be methods,
// but Go does not allow methods on pointer types, and we must preserve
// some pointer type for the garbage collector. We use these
// funcs with clunky names as our poor approximation to methods.
//
// An alternative would be
// type structPointer struct { p unsafe.Pointer }
// but that does not registerize as well.
// A structPointer is a pointer to a struct.
type structPointer unsafe.Pointer
// toStructPointer returns a structPointer equivalent to the given reflect value.
func toStructPointer(v reflect.Value) structPointer {
return structPointer(unsafe.Pointer(v.Pointer()))
}
// IsNil reports whether p is nil.
func structPointer_IsNil(p structPointer) bool {
return p == nil
}
// Interface returns the struct pointer, assumed to have element type t,
// as an interface value.
func structPointer_Interface(p structPointer, t reflect.Type) interface{} {
return reflect.NewAt(t, unsafe.Pointer(p)).Interface()
}
// A field identifies a field in a struct, accessible from a structPointer.
// In this implementation, a field is identified by its byte offset from the start of the struct.
type field uintptr
// toField returns a field equivalent to the given reflect field.
func toField(f *reflect.StructField) field {
return field(f.Offset)
}
// invalidField is an invalid field identifier.
const invalidField = ^field(0)
// IsValid reports whether the field identifier is valid.
func (f field) IsValid() bool {
return f != ^field(0)
}
// Bytes returns the address of a []byte field in the struct.
func structPointer_Bytes(p structPointer, f field) *[]byte {
return (*[]byte)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// BytesSlice returns the address of a [][]byte field in the struct.
func structPointer_BytesSlice(p structPointer, f field) *[][]byte {
return (*[][]byte)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// Bool returns the address of a *bool field in the struct.
func structPointer_Bool(p structPointer, f field) **bool {
return (**bool)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// BoolVal returns the address of a bool field in the struct.
func structPointer_BoolVal(p structPointer, f field) *bool {
return (*bool)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// BoolSlice returns the address of a []bool field in the struct.
func structPointer_BoolSlice(p structPointer, f field) *[]bool {
return (*[]bool)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// String returns the address of a *string field in the struct.
func structPointer_String(p structPointer, f field) **string {
return (**string)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// StringVal returns the address of a string field in the struct.
func structPointer_StringVal(p structPointer, f field) *string {
return (*string)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// StringSlice returns the address of a []string field in the struct.
func structPointer_StringSlice(p structPointer, f field) *[]string {
return (*[]string)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// ExtMap returns the address of an extension map field in the struct.
func structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions {
return (*XXX_InternalExtensions)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension {
return (*map[int32]Extension)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// NewAt returns the reflect.Value for a pointer to a field in the struct.
func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value {
return reflect.NewAt(typ, unsafe.Pointer(uintptr(p)+uintptr(f)))
}
// SetStructPointer writes a *struct field in the struct.
func structPointer_SetStructPointer(p structPointer, f field, q structPointer) {
*(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) = q
}
// GetStructPointer reads a *struct field in the struct.
func structPointer_GetStructPointer(p structPointer, f field) structPointer {
return *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// StructPointerSlice the address of a []*struct field in the struct.
func structPointer_StructPointerSlice(p structPointer, f field) *structPointerSlice {
return (*structPointerSlice)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// A structPointerSlice represents a slice of pointers to structs (themselves submessages or groups).
type structPointerSlice []structPointer
func (v *structPointerSlice) Len() int { return len(*v) }
func (v *structPointerSlice) Index(i int) structPointer { return (*v)[i] }
func (v *structPointerSlice) Append(p structPointer) { *v = append(*v, p) }
// A word32 is the address of a "pointer to 32-bit value" field.
type word32 **uint32
// IsNil reports whether *v is nil.
func word32_IsNil(p word32) bool {
return *p == nil
}
// Set sets *v to point at a newly allocated word set to x.
func word32_Set(p word32, o *Buffer, x uint32) {
if len(o.uint32s) == 0 {
o.uint32s = make([]uint32, uint32PoolSize)
}
o.uint32s[0] = x
*p = &o.uint32s[0]
o.uint32s = o.uint32s[1:]
}
// Get gets the value pointed at by *v.
func word32_Get(p word32) uint32 {
return **p
}
// Word32 returns the address of a *int32, *uint32, *float32, or *enum field in the struct.
func structPointer_Word32(p structPointer, f field) word32 {
return word32((**uint32)(unsafe.Pointer(uintptr(p) + uintptr(f))))
}
// A word32Val is the address of a 32-bit value field.
type word32Val *uint32
// Set sets *p to x.
func word32Val_Set(p word32Val, x uint32) {
*p = x
}
// Get gets the value pointed at by p.
func word32Val_Get(p word32Val) uint32 {
return *p
}
// Word32Val returns the address of a *int32, *uint32, *float32, or *enum field in the struct.
func structPointer_Word32Val(p structPointer, f field) word32Val {
return word32Val((*uint32)(unsafe.Pointer(uintptr(p) + uintptr(f))))
}
// A word32Slice is a slice of 32-bit values.
type word32Slice []uint32
func (v *word32Slice) Append(x uint32) { *v = append(*v, x) }
func (v *word32Slice) Len() int { return len(*v) }
func (v *word32Slice) Index(i int) uint32 { return (*v)[i] }
// Word32Slice returns the address of a []int32, []uint32, []float32, or []enum field in the struct.
func structPointer_Word32Slice(p structPointer, f field) *word32Slice {
return (*word32Slice)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
// word64 is like word32 but for 64-bit values.
type word64 **uint64
func word64_Set(p word64, o *Buffer, x uint64) {
if len(o.uint64s) == 0 {
o.uint64s = make([]uint64, uint64PoolSize)
}
o.uint64s[0] = x
*p = &o.uint64s[0]
o.uint64s = o.uint64s[1:]
}
func word64_IsNil(p word64) bool {
return *p == nil
}
func word64_Get(p word64) uint64 {
return **p
}
func structPointer_Word64(p structPointer, f field) word64 {
return word64((**uint64)(unsafe.Pointer(uintptr(p) + uintptr(f))))
}
// word64Val is like word32Val but for 64-bit values.
type word64Val *uint64
func word64Val_Set(p word64Val, o *Buffer, x uint64) {
*p = x
}
func word64Val_Get(p word64Val) uint64 {
return *p
}
func structPointer_Word64Val(p structPointer, f field) word64Val {
return word64Val((*uint64)(unsafe.Pointer(uintptr(p) + uintptr(f))))
}
// word64Slice is like word32Slice but for 64-bit values.
type word64Slice []uint64
func (v *word64Slice) Append(x uint64) { *v = append(*v, x) }
func (v *word64Slice) Len() int { return len(*v) }
func (v *word64Slice) Index(i int) uint64 { return (*v)[i] }
func structPointer_Word64Slice(p structPointer, f field) *word64Slice {
return (*word64Slice)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}

View File

@@ -1,128 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// +build !appengine,!js
// This file contains the implementation of the proto field accesses using package unsafe.
package proto
import (
"reflect"
"unsafe"
)
func structPointer_InterfaceAt(p structPointer, f field, t reflect.Type) interface{} {
point := unsafe.Pointer(uintptr(p) + uintptr(f))
r := reflect.NewAt(t, point)
return r.Interface()
}
func structPointer_InterfaceRef(p structPointer, f field, t reflect.Type) interface{} {
point := unsafe.Pointer(uintptr(p) + uintptr(f))
r := reflect.NewAt(t, point)
if r.Elem().IsNil() {
return nil
}
return r.Elem().Interface()
}
func copyUintPtr(oldptr, newptr uintptr, size int) {
oldbytes := make([]byte, 0)
oldslice := (*reflect.SliceHeader)(unsafe.Pointer(&oldbytes))
oldslice.Data = oldptr
oldslice.Len = size
oldslice.Cap = size
newbytes := make([]byte, 0)
newslice := (*reflect.SliceHeader)(unsafe.Pointer(&newbytes))
newslice.Data = newptr
newslice.Len = size
newslice.Cap = size
copy(newbytes, oldbytes)
}
func structPointer_Copy(oldptr structPointer, newptr structPointer, size int) {
copyUintPtr(uintptr(oldptr), uintptr(newptr), size)
}
func appendStructPointer(base structPointer, f field, typ reflect.Type) structPointer {
size := typ.Elem().Size()
oldHeader := structPointer_GetSliceHeader(base, f)
oldSlice := reflect.NewAt(typ, unsafe.Pointer(oldHeader)).Elem()
newLen := oldHeader.Len + 1
newSlice := reflect.MakeSlice(typ, newLen, newLen)
reflect.Copy(newSlice, oldSlice)
bas := toStructPointer(newSlice)
oldHeader.Data = uintptr(bas)
oldHeader.Len = newLen
oldHeader.Cap = newLen
return structPointer(unsafe.Pointer(uintptr(unsafe.Pointer(bas)) + uintptr(uintptr(newLen-1)*size)))
}
func structPointer_FieldPointer(p structPointer, f field) structPointer {
return structPointer(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
func structPointer_GetRefStructPointer(p structPointer, f field) structPointer {
return structPointer((*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))))
}
func structPointer_GetSliceHeader(p structPointer, f field) *reflect.SliceHeader {
return (*reflect.SliceHeader)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
func structPointer_Add(p structPointer, size field) structPointer {
return structPointer(unsafe.Pointer(uintptr(p) + uintptr(size)))
}
func structPointer_Len(p structPointer, f field) int {
return len(*(*[]interface{})(unsafe.Pointer(structPointer_GetRefStructPointer(p, f))))
}
func structPointer_StructRefSlice(p structPointer, f field, size uintptr) *structRefSlice {
return &structRefSlice{p: p, f: f, size: size}
}
// A structRefSlice represents a slice of structs (themselves submessages or groups).
type structRefSlice struct {
p structPointer
f field
size uintptr
}
func (v *structRefSlice) Len() int {
return structPointer_Len(v.p, v.f)
}
func (v *structRefSlice) Index(i int) structPointer {
ss := structPointer_GetStructPointer(v.p, v.f)
ss1 := structPointer_GetRefStructPointer(ss, 0)
return structPointer_Add(ss1, field(uintptr(i)*v.size))
}

View File

@@ -1,968 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2010 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
/*
* Routines for encoding data into the wire format for protocol buffers.
*/
import (
"fmt"
"log"
"os"
"reflect"
"sort"
"strconv"
"strings"
"sync"
)
const debug bool = false
// Constants that identify the encoding of a value on the wire.
const (
WireVarint = 0
WireFixed64 = 1
WireBytes = 2
WireStartGroup = 3
WireEndGroup = 4
WireFixed32 = 5
)
const startSize = 10 // initial slice/string sizes
// Encoders are defined in encode.go
// An encoder outputs the full representation of a field, including its
// tag and encoder type.
type encoder func(p *Buffer, prop *Properties, base structPointer) error
// A valueEncoder encodes a single integer in a particular encoding.
type valueEncoder func(o *Buffer, x uint64) error
// Sizers are defined in encode.go
// A sizer returns the encoded size of a field, including its tag and encoder
// type.
type sizer func(prop *Properties, base structPointer) int
// A valueSizer returns the encoded size of a single integer in a particular
// encoding.
type valueSizer func(x uint64) int
// Decoders are defined in decode.go
// A decoder creates a value from its wire representation.
// Unrecognized subelements are saved in unrec.
type decoder func(p *Buffer, prop *Properties, base structPointer) error
// A valueDecoder decodes a single integer in a particular encoding.
type valueDecoder func(o *Buffer) (x uint64, err error)
// A oneofMarshaler does the marshaling for all oneof fields in a message.
type oneofMarshaler func(Message, *Buffer) error
// A oneofUnmarshaler does the unmarshaling for a oneof field in a message.
type oneofUnmarshaler func(Message, int, int, *Buffer) (bool, error)
// A oneofSizer does the sizing for all oneof fields in a message.
type oneofSizer func(Message) int
// tagMap is an optimization over map[int]int for typical protocol buffer
// use-cases. Encoded protocol buffers are often in tag order with small tag
// numbers.
type tagMap struct {
fastTags []int
slowTags map[int]int
}
// tagMapFastLimit is the upper bound on the tag number that will be stored in
// the tagMap slice rather than its map.
const tagMapFastLimit = 1024
func (p *tagMap) get(t int) (int, bool) {
if t > 0 && t < tagMapFastLimit {
if t >= len(p.fastTags) {
return 0, false
}
fi := p.fastTags[t]
return fi, fi >= 0
}
fi, ok := p.slowTags[t]
return fi, ok
}
func (p *tagMap) put(t int, fi int) {
if t > 0 && t < tagMapFastLimit {
for len(p.fastTags) < t+1 {
p.fastTags = append(p.fastTags, -1)
}
p.fastTags[t] = fi
return
}
if p.slowTags == nil {
p.slowTags = make(map[int]int)
}
p.slowTags[t] = fi
}
// StructProperties represents properties for all the fields of a struct.
// decoderTags and decoderOrigNames should only be used by the decoder.
type StructProperties struct {
Prop []*Properties // properties for each field
reqCount int // required count
decoderTags tagMap // map from proto tag to struct field number
decoderOrigNames map[string]int // map from original name to struct field number
order []int // list of struct field numbers in tag order
unrecField field // field id of the XXX_unrecognized []byte field
extendable bool // is this an extendable proto
oneofMarshaler oneofMarshaler
oneofUnmarshaler oneofUnmarshaler
oneofSizer oneofSizer
stype reflect.Type
// OneofTypes contains information about the oneof fields in this message.
// It is keyed by the original name of a field.
OneofTypes map[string]*OneofProperties
}
// OneofProperties represents information about a specific field in a oneof.
type OneofProperties struct {
Type reflect.Type // pointer to generated struct type for this oneof field
Field int // struct field number of the containing oneof in the message
Prop *Properties
}
// Implement the sorting interface so we can sort the fields in tag order, as recommended by the spec.
// See encode.go, (*Buffer).enc_struct.
func (sp *StructProperties) Len() int { return len(sp.order) }
func (sp *StructProperties) Less(i, j int) bool {
return sp.Prop[sp.order[i]].Tag < sp.Prop[sp.order[j]].Tag
}
func (sp *StructProperties) Swap(i, j int) { sp.order[i], sp.order[j] = sp.order[j], sp.order[i] }
// Properties represents the protocol-specific behavior of a single struct field.
type Properties struct {
Name string // name of the field, for error messages
OrigName string // original name before protocol compiler (always set)
JSONName string // name to use for JSON; determined by protoc
Wire string
WireType int
Tag int
Required bool
Optional bool
Repeated bool
Packed bool // relevant for repeated primitives only
Enum string // set for enum types only
proto3 bool // whether this is known to be a proto3 field; set for []byte only
oneof bool // whether this is a oneof field
Default string // default value
HasDefault bool // whether an explicit default was provided
CustomType string
StdTime bool
StdDuration bool
enc encoder
valEnc valueEncoder // set for bool and numeric types only
field field
tagcode []byte // encoding of EncodeVarint((Tag<<3)|WireType)
tagbuf [8]byte
stype reflect.Type // set for struct types only
sstype reflect.Type // set for slices of structs types only
ctype reflect.Type // set for custom types only
sprop *StructProperties // set for struct types only
isMarshaler bool
isUnmarshaler bool
mtype reflect.Type // set for map types only
mkeyprop *Properties // set for map types only
mvalprop *Properties // set for map types only
size sizer
valSize valueSizer // set for bool and numeric types only
dec decoder
valDec valueDecoder // set for bool and numeric types only
// If this is a packable field, this will be the decoder for the packed version of the field.
packedDec decoder
}
// String formats the properties in the protobuf struct field tag style.
func (p *Properties) String() string {
s := p.Wire
s = ","
s += strconv.Itoa(p.Tag)
if p.Required {
s += ",req"
}
if p.Optional {
s += ",opt"
}
if p.Repeated {
s += ",rep"
}
if p.Packed {
s += ",packed"
}
s += ",name=" + p.OrigName
if p.JSONName != p.OrigName {
s += ",json=" + p.JSONName
}
if p.proto3 {
s += ",proto3"
}
if p.oneof {
s += ",oneof"
}
if len(p.Enum) > 0 {
s += ",enum=" + p.Enum
}
if p.HasDefault {
s += ",def=" + p.Default
}
return s
}
// Parse populates p by parsing a string in the protobuf struct field tag style.
func (p *Properties) Parse(s string) {
// "bytes,49,opt,name=foo,def=hello!"
fields := strings.Split(s, ",") // breaks def=, but handled below.
if len(fields) < 2 {
fmt.Fprintf(os.Stderr, "proto: tag has too few fields: %q\n", s)
return
}
p.Wire = fields[0]
switch p.Wire {
case "varint":
p.WireType = WireVarint
p.valEnc = (*Buffer).EncodeVarint
p.valDec = (*Buffer).DecodeVarint
p.valSize = sizeVarint
case "fixed32":
p.WireType = WireFixed32
p.valEnc = (*Buffer).EncodeFixed32
p.valDec = (*Buffer).DecodeFixed32
p.valSize = sizeFixed32
case "fixed64":
p.WireType = WireFixed64
p.valEnc = (*Buffer).EncodeFixed64
p.valDec = (*Buffer).DecodeFixed64
p.valSize = sizeFixed64
case "zigzag32":
p.WireType = WireVarint
p.valEnc = (*Buffer).EncodeZigzag32
p.valDec = (*Buffer).DecodeZigzag32
p.valSize = sizeZigzag32
case "zigzag64":
p.WireType = WireVarint
p.valEnc = (*Buffer).EncodeZigzag64
p.valDec = (*Buffer).DecodeZigzag64
p.valSize = sizeZigzag64
case "bytes", "group":
p.WireType = WireBytes
// no numeric converter for non-numeric types
default:
fmt.Fprintf(os.Stderr, "proto: tag has unknown wire type: %q\n", s)
return
}
var err error
p.Tag, err = strconv.Atoi(fields[1])
if err != nil {
return
}
for i := 2; i < len(fields); i++ {
f := fields[i]
switch {
case f == "req":
p.Required = true
case f == "opt":
p.Optional = true
case f == "rep":
p.Repeated = true
case f == "packed":
p.Packed = true
case strings.HasPrefix(f, "name="):
p.OrigName = f[5:]
case strings.HasPrefix(f, "json="):
p.JSONName = f[5:]
case strings.HasPrefix(f, "enum="):
p.Enum = f[5:]
case f == "proto3":
p.proto3 = true
case f == "oneof":
p.oneof = true
case strings.HasPrefix(f, "def="):
p.HasDefault = true
p.Default = f[4:] // rest of string
if i+1 < len(fields) {
// Commas aren't escaped, and def is always last.
p.Default += "," + strings.Join(fields[i+1:], ",")
break
}
case strings.HasPrefix(f, "embedded="):
p.OrigName = strings.Split(f, "=")[1]
case strings.HasPrefix(f, "customtype="):
p.CustomType = strings.Split(f, "=")[1]
case f == "stdtime":
p.StdTime = true
case f == "stdduration":
p.StdDuration = true
}
}
}
func logNoSliceEnc(t1, t2 reflect.Type) {
fmt.Fprintf(os.Stderr, "proto: no slice oenc for %T = []%T\n", t1, t2)
}
var protoMessageType = reflect.TypeOf((*Message)(nil)).Elem()
// Initialize the fields for encoding and decoding.
func (p *Properties) setEncAndDec(typ reflect.Type, f *reflect.StructField, lockGetProp bool) {
p.enc = nil
p.dec = nil
p.size = nil
isMap := typ.Kind() == reflect.Map
if len(p.CustomType) > 0 && !isMap {
p.setCustomEncAndDec(typ)
p.setTag(lockGetProp)
return
}
if p.StdTime && !isMap {
p.setTimeEncAndDec(typ)
p.setTag(lockGetProp)
return
}
if p.StdDuration && !isMap {
p.setDurationEncAndDec(typ)
p.setTag(lockGetProp)
return
}
switch t1 := typ; t1.Kind() {
default:
fmt.Fprintf(os.Stderr, "proto: no coders for %v\n", t1)
// proto3 scalar types
case reflect.Bool:
if p.proto3 {
p.enc = (*Buffer).enc_proto3_bool
p.dec = (*Buffer).dec_proto3_bool
p.size = size_proto3_bool
} else {
p.enc = (*Buffer).enc_ref_bool
p.dec = (*Buffer).dec_proto3_bool
p.size = size_ref_bool
}
case reflect.Int32:
if p.proto3 {
p.enc = (*Buffer).enc_proto3_int32
p.dec = (*Buffer).dec_proto3_int32
p.size = size_proto3_int32
} else {
p.enc = (*Buffer).enc_ref_int32
p.dec = (*Buffer).dec_proto3_int32
p.size = size_ref_int32
}
case reflect.Uint32:
if p.proto3 {
p.enc = (*Buffer).enc_proto3_uint32
p.dec = (*Buffer).dec_proto3_int32 // can reuse
p.size = size_proto3_uint32
} else {
p.enc = (*Buffer).enc_ref_uint32
p.dec = (*Buffer).dec_proto3_int32 // can reuse
p.size = size_ref_uint32
}
case reflect.Int64, reflect.Uint64:
if p.proto3 {
p.enc = (*Buffer).enc_proto3_int64
p.dec = (*Buffer).dec_proto3_int64
p.size = size_proto3_int64
} else {
p.enc = (*Buffer).enc_ref_int64
p.dec = (*Buffer).dec_proto3_int64
p.size = size_ref_int64
}
case reflect.Float32:
if p.proto3 {
p.enc = (*Buffer).enc_proto3_uint32 // can just treat them as bits
p.dec = (*Buffer).dec_proto3_int32
p.size = size_proto3_uint32
} else {
p.enc = (*Buffer).enc_ref_uint32 // can just treat them as bits
p.dec = (*Buffer).dec_proto3_int32
p.size = size_ref_uint32
}
case reflect.Float64:
if p.proto3 {
p.enc = (*Buffer).enc_proto3_int64 // can just treat them as bits
p.dec = (*Buffer).dec_proto3_int64
p.size = size_proto3_int64
} else {
p.enc = (*Buffer).enc_ref_int64 // can just treat them as bits
p.dec = (*Buffer).dec_proto3_int64
p.size = size_ref_int64
}
case reflect.String:
if p.proto3 {
p.enc = (*Buffer).enc_proto3_string
p.dec = (*Buffer).dec_proto3_string
p.size = size_proto3_string
} else {
p.enc = (*Buffer).enc_ref_string
p.dec = (*Buffer).dec_proto3_string
p.size = size_ref_string
}
case reflect.Struct:
p.stype = typ
p.isMarshaler = isMarshaler(typ)
p.isUnmarshaler = isUnmarshaler(typ)
if p.Wire == "bytes" {
p.enc = (*Buffer).enc_ref_struct_message
p.dec = (*Buffer).dec_ref_struct_message
p.size = size_ref_struct_message
} else {
fmt.Fprintf(os.Stderr, "proto: no coders for struct %T\n", typ)
}
case reflect.Ptr:
switch t2 := t1.Elem(); t2.Kind() {
default:
fmt.Fprintf(os.Stderr, "proto: no encoder function for %v -> %v\n", t1, t2)
break
case reflect.Bool:
p.enc = (*Buffer).enc_bool
p.dec = (*Buffer).dec_bool
p.size = size_bool
case reflect.Int32:
p.enc = (*Buffer).enc_int32
p.dec = (*Buffer).dec_int32
p.size = size_int32
case reflect.Uint32:
p.enc = (*Buffer).enc_uint32
p.dec = (*Buffer).dec_int32 // can reuse
p.size = size_uint32
case reflect.Int64, reflect.Uint64:
p.enc = (*Buffer).enc_int64
p.dec = (*Buffer).dec_int64
p.size = size_int64
case reflect.Float32:
p.enc = (*Buffer).enc_uint32 // can just treat them as bits
p.dec = (*Buffer).dec_int32
p.size = size_uint32
case reflect.Float64:
p.enc = (*Buffer).enc_int64 // can just treat them as bits
p.dec = (*Buffer).dec_int64
p.size = size_int64
case reflect.String:
p.enc = (*Buffer).enc_string
p.dec = (*Buffer).dec_string
p.size = size_string
case reflect.Struct:
p.stype = t1.Elem()
p.isMarshaler = isMarshaler(t1)
p.isUnmarshaler = isUnmarshaler(t1)
if p.Wire == "bytes" {
p.enc = (*Buffer).enc_struct_message
p.dec = (*Buffer).dec_struct_message
p.size = size_struct_message
} else {
p.enc = (*Buffer).enc_struct_group
p.dec = (*Buffer).dec_struct_group
p.size = size_struct_group
}
}
case reflect.Slice:
switch t2 := t1.Elem(); t2.Kind() {
default:
logNoSliceEnc(t1, t2)
break
case reflect.Bool:
if p.Packed {
p.enc = (*Buffer).enc_slice_packed_bool
p.size = size_slice_packed_bool
} else {
p.enc = (*Buffer).enc_slice_bool
p.size = size_slice_bool
}
p.dec = (*Buffer).dec_slice_bool
p.packedDec = (*Buffer).dec_slice_packed_bool
case reflect.Int32:
if p.Packed {
p.enc = (*Buffer).enc_slice_packed_int32
p.size = size_slice_packed_int32
} else {
p.enc = (*Buffer).enc_slice_int32
p.size = size_slice_int32
}
p.dec = (*Buffer).dec_slice_int32
p.packedDec = (*Buffer).dec_slice_packed_int32
case reflect.Uint32:
if p.Packed {
p.enc = (*Buffer).enc_slice_packed_uint32
p.size = size_slice_packed_uint32
} else {
p.enc = (*Buffer).enc_slice_uint32
p.size = size_slice_uint32
}
p.dec = (*Buffer).dec_slice_int32
p.packedDec = (*Buffer).dec_slice_packed_int32
case reflect.Int64, reflect.Uint64:
if p.Packed {
p.enc = (*Buffer).enc_slice_packed_int64
p.size = size_slice_packed_int64
} else {
p.enc = (*Buffer).enc_slice_int64
p.size = size_slice_int64
}
p.dec = (*Buffer).dec_slice_int64
p.packedDec = (*Buffer).dec_slice_packed_int64
case reflect.Uint8:
p.dec = (*Buffer).dec_slice_byte
if p.proto3 {
p.enc = (*Buffer).enc_proto3_slice_byte
p.size = size_proto3_slice_byte
} else {
p.enc = (*Buffer).enc_slice_byte
p.size = size_slice_byte
}
case reflect.Float32, reflect.Float64:
switch t2.Bits() {
case 32:
// can just treat them as bits
if p.Packed {
p.enc = (*Buffer).enc_slice_packed_uint32
p.size = size_slice_packed_uint32
} else {
p.enc = (*Buffer).enc_slice_uint32
p.size = size_slice_uint32
}
p.dec = (*Buffer).dec_slice_int32
p.packedDec = (*Buffer).dec_slice_packed_int32
case 64:
// can just treat them as bits
if p.Packed {
p.enc = (*Buffer).enc_slice_packed_int64
p.size = size_slice_packed_int64
} else {
p.enc = (*Buffer).enc_slice_int64
p.size = size_slice_int64
}
p.dec = (*Buffer).dec_slice_int64
p.packedDec = (*Buffer).dec_slice_packed_int64
default:
logNoSliceEnc(t1, t2)
break
}
case reflect.String:
p.enc = (*Buffer).enc_slice_string
p.dec = (*Buffer).dec_slice_string
p.size = size_slice_string
case reflect.Ptr:
switch t3 := t2.Elem(); t3.Kind() {
default:
fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T -> %T\n", t1, t2, t3)
break
case reflect.Struct:
p.stype = t2.Elem()
p.isMarshaler = isMarshaler(t2)
p.isUnmarshaler = isUnmarshaler(t2)
if p.Wire == "bytes" {
p.enc = (*Buffer).enc_slice_struct_message
p.dec = (*Buffer).dec_slice_struct_message
p.size = size_slice_struct_message
} else {
p.enc = (*Buffer).enc_slice_struct_group
p.dec = (*Buffer).dec_slice_struct_group
p.size = size_slice_struct_group
}
}
case reflect.Slice:
switch t2.Elem().Kind() {
default:
fmt.Fprintf(os.Stderr, "proto: no slice elem oenc for %T -> %T -> %T\n", t1, t2, t2.Elem())
break
case reflect.Uint8:
p.enc = (*Buffer).enc_slice_slice_byte
p.dec = (*Buffer).dec_slice_slice_byte
p.size = size_slice_slice_byte
}
case reflect.Struct:
p.setSliceOfNonPointerStructs(t1)
}
case reflect.Map:
p.enc = (*Buffer).enc_new_map
p.dec = (*Buffer).dec_new_map
p.size = size_new_map
p.mtype = t1
p.mkeyprop = &Properties{}
p.mkeyprop.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp)
p.mvalprop = &Properties{}
vtype := p.mtype.Elem()
if vtype.Kind() != reflect.Ptr && vtype.Kind() != reflect.Slice {
// The value type is not a message (*T) or bytes ([]byte),
// so we need encoders for the pointer to this type.
vtype = reflect.PtrTo(vtype)
}
p.mvalprop.CustomType = p.CustomType
p.mvalprop.StdDuration = p.StdDuration
p.mvalprop.StdTime = p.StdTime
p.mvalprop.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp)
}
p.setTag(lockGetProp)
}
func (p *Properties) setTag(lockGetProp bool) {
// precalculate tag code
wire := p.WireType
if p.Packed {
wire = WireBytes
}
x := uint32(p.Tag)<<3 | uint32(wire)
i := 0
for i = 0; x > 127; i++ {
p.tagbuf[i] = 0x80 | uint8(x&0x7F)
x >>= 7
}
p.tagbuf[i] = uint8(x)
p.tagcode = p.tagbuf[0 : i+1]
if p.stype != nil {
if lockGetProp {
p.sprop = GetProperties(p.stype)
} else {
p.sprop = getPropertiesLocked(p.stype)
}
}
}
var (
marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem()
unmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem()
)
// isMarshaler reports whether type t implements Marshaler.
func isMarshaler(t reflect.Type) bool {
return t.Implements(marshalerType)
}
// isUnmarshaler reports whether type t implements Unmarshaler.
func isUnmarshaler(t reflect.Type) bool {
return t.Implements(unmarshalerType)
}
// Init populates the properties from a protocol buffer struct tag.
func (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField) {
p.init(typ, name, tag, f, true)
}
func (p *Properties) init(typ reflect.Type, name, tag string, f *reflect.StructField, lockGetProp bool) {
// "bytes,49,opt,def=hello!"
p.Name = name
p.OrigName = name
if f != nil {
p.field = toField(f)
}
if tag == "" {
return
}
p.Parse(tag)
p.setEncAndDec(typ, f, lockGetProp)
}
var (
propertiesMu sync.RWMutex
propertiesMap = make(map[reflect.Type]*StructProperties)
)
// GetProperties returns the list of properties for the type represented by t.
// t must represent a generated struct type of a protocol message.
func GetProperties(t reflect.Type) *StructProperties {
if t.Kind() != reflect.Struct {
panic("proto: type must have kind struct")
}
// Most calls to GetProperties in a long-running program will be
// retrieving details for types we have seen before.
propertiesMu.RLock()
sprop, ok := propertiesMap[t]
propertiesMu.RUnlock()
if ok {
if collectStats {
stats.Chit++
}
return sprop
}
propertiesMu.Lock()
sprop = getPropertiesLocked(t)
propertiesMu.Unlock()
return sprop
}
// getPropertiesLocked requires that propertiesMu is held.
func getPropertiesLocked(t reflect.Type) *StructProperties {
if prop, ok := propertiesMap[t]; ok {
if collectStats {
stats.Chit++
}
return prop
}
if collectStats {
stats.Cmiss++
}
prop := new(StructProperties)
// in case of recursive protos, fill this in now.
propertiesMap[t] = prop
// build properties
prop.extendable = reflect.PtrTo(t).Implements(extendableProtoType) ||
reflect.PtrTo(t).Implements(extendableProtoV1Type) ||
reflect.PtrTo(t).Implements(extendableBytesType)
prop.unrecField = invalidField
prop.Prop = make([]*Properties, t.NumField())
prop.order = make([]int, t.NumField())
isOneofMessage := false
for i := 0; i < t.NumField(); i++ {
f := t.Field(i)
p := new(Properties)
name := f.Name
p.init(f.Type, name, f.Tag.Get("protobuf"), &f, false)
if f.Name == "XXX_InternalExtensions" { // special case
p.enc = (*Buffer).enc_exts
p.dec = nil // not needed
p.size = size_exts
} else if f.Name == "XXX_extensions" { // special case
if len(f.Tag.Get("protobuf")) > 0 {
p.enc = (*Buffer).enc_ext_slice_byte
p.dec = nil // not needed
p.size = size_ext_slice_byte
} else {
p.enc = (*Buffer).enc_map
p.dec = nil // not needed
p.size = size_map
}
} else if f.Name == "XXX_unrecognized" { // special case
prop.unrecField = toField(&f)
}
oneof := f.Tag.Get("protobuf_oneof") // special case
if oneof != "" {
isOneofMessage = true
// Oneof fields don't use the traditional protobuf tag.
p.OrigName = oneof
}
prop.Prop[i] = p
prop.order[i] = i
if debug {
print(i, " ", f.Name, " ", t.String(), " ")
if p.Tag > 0 {
print(p.String())
}
print("\n")
}
if p.enc == nil && !strings.HasPrefix(f.Name, "XXX_") && oneof == "" {
fmt.Fprintln(os.Stderr, "proto: no encoder for", f.Name, f.Type.String(), "[GetProperties]")
}
}
// Re-order prop.order.
sort.Sort(prop)
type oneofMessage interface {
XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{})
}
if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); isOneofMessage && ok {
var oots []interface{}
prop.oneofMarshaler, prop.oneofUnmarshaler, prop.oneofSizer, oots = om.XXX_OneofFuncs()
prop.stype = t
// Interpret oneof metadata.
prop.OneofTypes = make(map[string]*OneofProperties)
for _, oot := range oots {
oop := &OneofProperties{
Type: reflect.ValueOf(oot).Type(), // *T
Prop: new(Properties),
}
sft := oop.Type.Elem().Field(0)
oop.Prop.Name = sft.Name
oop.Prop.Parse(sft.Tag.Get("protobuf"))
// There will be exactly one interface field that
// this new value is assignable to.
for i := 0; i < t.NumField(); i++ {
f := t.Field(i)
if f.Type.Kind() != reflect.Interface {
continue
}
if !oop.Type.AssignableTo(f.Type) {
continue
}
oop.Field = i
break
}
prop.OneofTypes[oop.Prop.OrigName] = oop
}
}
// build required counts
// build tags
reqCount := 0
prop.decoderOrigNames = make(map[string]int)
for i, p := range prop.Prop {
if strings.HasPrefix(p.Name, "XXX_") {
// Internal fields should not appear in tags/origNames maps.
// They are handled specially when encoding and decoding.
continue
}
if p.Required {
reqCount++
}
prop.decoderTags.put(p.Tag, i)
prop.decoderOrigNames[p.OrigName] = i
}
prop.reqCount = reqCount
return prop
}
// Return the Properties object for the x[0]'th field of the structure.
func propByIndex(t reflect.Type, x []int) *Properties {
if len(x) != 1 {
fmt.Fprintf(os.Stderr, "proto: field index dimension %d (not 1) for type %s\n", len(x), t)
return nil
}
prop := GetProperties(t)
return prop.Prop[x[0]]
}
// Get the address and type of a pointer to a struct from an interface.
func getbase(pb Message) (t reflect.Type, b structPointer, err error) {
if pb == nil {
err = ErrNil
return
}
// get the reflect type of the pointer to the struct.
t = reflect.TypeOf(pb)
// get the address of the struct.
value := reflect.ValueOf(pb)
b = toStructPointer(value)
return
}
// A global registry of enum types.
// The generated code will register the generated maps by calling RegisterEnum.
var enumValueMaps = make(map[string]map[string]int32)
var enumStringMaps = make(map[string]map[int32]string)
// RegisterEnum is called from the generated code to install the enum descriptor
// maps into the global table to aid parsing text format protocol buffers.
func RegisterEnum(typeName string, unusedNameMap map[int32]string, valueMap map[string]int32) {
if _, ok := enumValueMaps[typeName]; ok {
panic("proto: duplicate enum registered: " + typeName)
}
enumValueMaps[typeName] = valueMap
if _, ok := enumStringMaps[typeName]; ok {
panic("proto: duplicate enum registered: " + typeName)
}
enumStringMaps[typeName] = unusedNameMap
}
// EnumValueMap returns the mapping from names to integers of the
// enum type enumType, or a nil if not found.
func EnumValueMap(enumType string) map[string]int32 {
return enumValueMaps[enumType]
}
// A registry of all linked message types.
// The string is a fully-qualified proto name ("pkg.Message").
var (
protoTypes = make(map[string]reflect.Type)
revProtoTypes = make(map[reflect.Type]string)
)
// RegisterType is called from generated code and maps from the fully qualified
// proto name to the type (pointer to struct) of the protocol buffer.
func RegisterType(x Message, name string) {
if _, ok := protoTypes[name]; ok {
// TODO: Some day, make this a panic.
log.Printf("proto: duplicate proto type registered: %s", name)
return
}
t := reflect.TypeOf(x)
protoTypes[name] = t
revProtoTypes[t] = name
}
// MessageName returns the fully-qualified proto name for the given message type.
func MessageName(x Message) string {
type xname interface {
XXX_MessageName() string
}
if m, ok := x.(xname); ok {
return m.XXX_MessageName()
}
return revProtoTypes[reflect.TypeOf(x)]
}
// MessageType returns the message type (pointer to struct) for a named message.
func MessageType(name string) reflect.Type { return protoTypes[name] }
// A registry of all linked proto files.
var (
protoFiles = make(map[string][]byte) // file name => fileDescriptor
)
// RegisterFile is called from generated code and maps from the
// full file name of a .proto file to its compressed FileDescriptorProto.
func RegisterFile(filename string, fileDescriptor []byte) {
protoFiles[filename] = fileDescriptor
}
// FileDescriptor returns the compressed FileDescriptorProto for a .proto file.
func FileDescriptor(filename string) []byte { return protoFiles[filename] }

View File

@@ -1,111 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"fmt"
"os"
"reflect"
)
func (p *Properties) setCustomEncAndDec(typ reflect.Type) {
p.ctype = typ
if p.Repeated {
p.enc = (*Buffer).enc_custom_slice_bytes
p.dec = (*Buffer).dec_custom_slice_bytes
p.size = size_custom_slice_bytes
} else if typ.Kind() == reflect.Ptr {
p.enc = (*Buffer).enc_custom_bytes
p.dec = (*Buffer).dec_custom_bytes
p.size = size_custom_bytes
} else {
p.enc = (*Buffer).enc_custom_ref_bytes
p.dec = (*Buffer).dec_custom_ref_bytes
p.size = size_custom_ref_bytes
}
}
func (p *Properties) setDurationEncAndDec(typ reflect.Type) {
if p.Repeated {
if typ.Elem().Kind() == reflect.Ptr {
p.enc = (*Buffer).enc_slice_duration
p.dec = (*Buffer).dec_slice_duration
p.size = size_slice_duration
} else {
p.enc = (*Buffer).enc_slice_ref_duration
p.dec = (*Buffer).dec_slice_ref_duration
p.size = size_slice_ref_duration
}
} else if typ.Kind() == reflect.Ptr {
p.enc = (*Buffer).enc_duration
p.dec = (*Buffer).dec_duration
p.size = size_duration
} else {
p.enc = (*Buffer).enc_ref_duration
p.dec = (*Buffer).dec_ref_duration
p.size = size_ref_duration
}
}
func (p *Properties) setTimeEncAndDec(typ reflect.Type) {
if p.Repeated {
if typ.Elem().Kind() == reflect.Ptr {
p.enc = (*Buffer).enc_slice_time
p.dec = (*Buffer).dec_slice_time
p.size = size_slice_time
} else {
p.enc = (*Buffer).enc_slice_ref_time
p.dec = (*Buffer).dec_slice_ref_time
p.size = size_slice_ref_time
}
} else if typ.Kind() == reflect.Ptr {
p.enc = (*Buffer).enc_time
p.dec = (*Buffer).dec_time
p.size = size_time
} else {
p.enc = (*Buffer).enc_ref_time
p.dec = (*Buffer).dec_ref_time
p.size = size_ref_time
}
}
func (p *Properties) setSliceOfNonPointerStructs(typ reflect.Type) {
t2 := typ.Elem()
p.sstype = typ
p.stype = t2
p.isMarshaler = isMarshaler(t2)
p.isUnmarshaler = isUnmarshaler(t2)
p.enc = (*Buffer).enc_slice_ref_struct_message
p.dec = (*Buffer).dec_slice_ref_struct_message
p.size = size_slice_ref_struct_message
if p.Wire != "bytes" {
fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T \n", typ, t2)
}
}

View File

@@ -1,119 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"fmt"
"io"
)
func Skip(data []byte) (n int, err error) {
l := len(data)
index := 0
for index < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if index >= l {
return 0, io.ErrUnexpectedEOF
}
b := data[index]
index++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for {
if index >= l {
return 0, io.ErrUnexpectedEOF
}
index++
if data[index-1] < 0x80 {
break
}
}
return index, nil
case 1:
index += 8
return index, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if index >= l {
return 0, io.ErrUnexpectedEOF
}
b := data[index]
index++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
index += length
return index, nil
case 3:
for {
var innerWire uint64
var start int = index
for shift := uint(0); ; shift += 7 {
if index >= l {
return 0, io.ErrUnexpectedEOF
}
b := data[index]
index++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := Skip(data[start:])
if err != nil {
return 0, err
}
index = start + next
}
return index, nil
case 4:
return index, nil
case 5:
index += 4
return index, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}

View File

@@ -1,928 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2010 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
// Functions for writing the text protocol buffer format.
import (
"bufio"
"bytes"
"encoding"
"errors"
"fmt"
"io"
"log"
"math"
"reflect"
"sort"
"strings"
"sync"
"time"
)
var (
newline = []byte("\n")
spaces = []byte(" ")
gtNewline = []byte(">\n")
endBraceNewline = []byte("}\n")
backslashN = []byte{'\\', 'n'}
backslashR = []byte{'\\', 'r'}
backslashT = []byte{'\\', 't'}
backslashDQ = []byte{'\\', '"'}
backslashBS = []byte{'\\', '\\'}
posInf = []byte("inf")
negInf = []byte("-inf")
nan = []byte("nan")
)
type writer interface {
io.Writer
WriteByte(byte) error
}
// textWriter is an io.Writer that tracks its indentation level.
type textWriter struct {
ind int
complete bool // if the current position is a complete line
compact bool // whether to write out as a one-liner
w writer
}
func (w *textWriter) WriteString(s string) (n int, err error) {
if !strings.Contains(s, "\n") {
if !w.compact && w.complete {
w.writeIndent()
}
w.complete = false
return io.WriteString(w.w, s)
}
// WriteString is typically called without newlines, so this
// codepath and its copy are rare. We copy to avoid
// duplicating all of Write's logic here.
return w.Write([]byte(s))
}
func (w *textWriter) Write(p []byte) (n int, err error) {
newlines := bytes.Count(p, newline)
if newlines == 0 {
if !w.compact && w.complete {
w.writeIndent()
}
n, err = w.w.Write(p)
w.complete = false
return n, err
}
frags := bytes.SplitN(p, newline, newlines+1)
if w.compact {
for i, frag := range frags {
if i > 0 {
if err := w.w.WriteByte(' '); err != nil {
return n, err
}
n++
}
nn, err := w.w.Write(frag)
n += nn
if err != nil {
return n, err
}
}
return n, nil
}
for i, frag := range frags {
if w.complete {
w.writeIndent()
}
nn, err := w.w.Write(frag)
n += nn
if err != nil {
return n, err
}
if i+1 < len(frags) {
if err := w.w.WriteByte('\n'); err != nil {
return n, err
}
n++
}
}
w.complete = len(frags[len(frags)-1]) == 0
return n, nil
}
func (w *textWriter) WriteByte(c byte) error {
if w.compact && c == '\n' {
c = ' '
}
if !w.compact && w.complete {
w.writeIndent()
}
err := w.w.WriteByte(c)
w.complete = c == '\n'
return err
}
func (w *textWriter) indent() { w.ind++ }
func (w *textWriter) unindent() {
if w.ind == 0 {
log.Print("proto: textWriter unindented too far")
return
}
w.ind--
}
func writeName(w *textWriter, props *Properties) error {
if _, err := w.WriteString(props.OrigName); err != nil {
return err
}
if props.Wire != "group" {
return w.WriteByte(':')
}
return nil
}
// raw is the interface satisfied by RawMessage.
type raw interface {
Bytes() []byte
}
func requiresQuotes(u string) bool {
// When type URL contains any characters except [0-9A-Za-z./\-]*, it must be quoted.
for _, ch := range u {
switch {
case ch == '.' || ch == '/' || ch == '_':
continue
case '0' <= ch && ch <= '9':
continue
case 'A' <= ch && ch <= 'Z':
continue
case 'a' <= ch && ch <= 'z':
continue
default:
return true
}
}
return false
}
// isAny reports whether sv is a google.protobuf.Any message
func isAny(sv reflect.Value) bool {
type wkt interface {
XXX_WellKnownType() string
}
t, ok := sv.Addr().Interface().(wkt)
return ok && t.XXX_WellKnownType() == "Any"
}
// writeProto3Any writes an expanded google.protobuf.Any message.
//
// It returns (false, nil) if sv value can't be unmarshaled (e.g. because
// required messages are not linked in).
//
// It returns (true, error) when sv was written in expanded format or an error
// was encountered.
func (tm *TextMarshaler) writeProto3Any(w *textWriter, sv reflect.Value) (bool, error) {
turl := sv.FieldByName("TypeUrl")
val := sv.FieldByName("Value")
if !turl.IsValid() || !val.IsValid() {
return true, errors.New("proto: invalid google.protobuf.Any message")
}
b, ok := val.Interface().([]byte)
if !ok {
return true, errors.New("proto: invalid google.protobuf.Any message")
}
parts := strings.Split(turl.String(), "/")
mt := MessageType(parts[len(parts)-1])
if mt == nil {
return false, nil
}
m := reflect.New(mt.Elem())
if err := Unmarshal(b, m.Interface().(Message)); err != nil {
return false, nil
}
w.Write([]byte("["))
u := turl.String()
if requiresQuotes(u) {
writeString(w, u)
} else {
w.Write([]byte(u))
}
if w.compact {
w.Write([]byte("]:<"))
} else {
w.Write([]byte("]: <\n"))
w.ind++
}
if err := tm.writeStruct(w, m.Elem()); err != nil {
return true, err
}
if w.compact {
w.Write([]byte("> "))
} else {
w.ind--
w.Write([]byte(">\n"))
}
return true, nil
}
func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
if tm.ExpandAny && isAny(sv) {
if canExpand, err := tm.writeProto3Any(w, sv); canExpand {
return err
}
}
st := sv.Type()
sprops := GetProperties(st)
for i := 0; i < sv.NumField(); i++ {
fv := sv.Field(i)
props := sprops.Prop[i]
name := st.Field(i).Name
if strings.HasPrefix(name, "XXX_") {
// There are two XXX_ fields:
// XXX_unrecognized []byte
// XXX_extensions map[int32]proto.Extension
// The first is handled here;
// the second is handled at the bottom of this function.
if name == "XXX_unrecognized" && !fv.IsNil() {
if err := writeUnknownStruct(w, fv.Interface().([]byte)); err != nil {
return err
}
}
continue
}
if fv.Kind() == reflect.Ptr && fv.IsNil() {
// Field not filled in. This could be an optional field or
// a required field that wasn't filled in. Either way, there
// isn't anything we can show for it.
continue
}
if fv.Kind() == reflect.Slice && fv.IsNil() {
// Repeated field that is empty, or a bytes field that is unused.
continue
}
if props.Repeated && fv.Kind() == reflect.Slice {
// Repeated field.
for j := 0; j < fv.Len(); j++ {
if err := writeName(w, props); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte(' '); err != nil {
return err
}
}
v := fv.Index(j)
if v.Kind() == reflect.Ptr && v.IsNil() {
// A nil message in a repeated field is not valid,
// but we can handle that more gracefully than panicking.
if _, err := w.Write([]byte("<nil>\n")); err != nil {
return err
}
continue
}
if len(props.Enum) > 0 {
if err := tm.writeEnum(w, v, props); err != nil {
return err
}
} else if err := tm.writeAny(w, v, props); err != nil {
return err
}
if err := w.WriteByte('\n'); err != nil {
return err
}
}
continue
}
if fv.Kind() == reflect.Map {
// Map fields are rendered as a repeated struct with key/value fields.
keys := fv.MapKeys()
sort.Sort(mapKeys(keys))
for _, key := range keys {
val := fv.MapIndex(key)
if err := writeName(w, props); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte(' '); err != nil {
return err
}
}
// open struct
if err := w.WriteByte('<'); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte('\n'); err != nil {
return err
}
}
w.indent()
// key
if _, err := w.WriteString("key:"); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte(' '); err != nil {
return err
}
}
if err := tm.writeAny(w, key, props.mkeyprop); err != nil {
return err
}
if err := w.WriteByte('\n'); err != nil {
return err
}
// nil values aren't legal, but we can avoid panicking because of them.
if val.Kind() != reflect.Ptr || !val.IsNil() {
// value
if _, err := w.WriteString("value:"); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte(' '); err != nil {
return err
}
}
if err := tm.writeAny(w, val, props.mvalprop); err != nil {
return err
}
if err := w.WriteByte('\n'); err != nil {
return err
}
}
// close struct
w.unindent()
if err := w.WriteByte('>'); err != nil {
return err
}
if err := w.WriteByte('\n'); err != nil {
return err
}
}
continue
}
if props.proto3 && fv.Kind() == reflect.Slice && fv.Len() == 0 {
// empty bytes field
continue
}
if props.proto3 && fv.Kind() != reflect.Ptr && fv.Kind() != reflect.Slice {
// proto3 non-repeated scalar field; skip if zero value
if isProto3Zero(fv) {
continue
}
}
if fv.Kind() == reflect.Interface {
// Check if it is a oneof.
if st.Field(i).Tag.Get("protobuf_oneof") != "" {
// fv is nil, or holds a pointer to generated struct.
// That generated struct has exactly one field,
// which has a protobuf struct tag.
if fv.IsNil() {
continue
}
inner := fv.Elem().Elem() // interface -> *T -> T
tag := inner.Type().Field(0).Tag.Get("protobuf")
props = new(Properties) // Overwrite the outer props var, but not its pointee.
props.Parse(tag)
// Write the value in the oneof, not the oneof itself.
fv = inner.Field(0)
// Special case to cope with malformed messages gracefully:
// If the value in the oneof is a nil pointer, don't panic
// in writeAny.
if fv.Kind() == reflect.Ptr && fv.IsNil() {
// Use errors.New so writeAny won't render quotes.
msg := errors.New("/* nil */")
fv = reflect.ValueOf(&msg).Elem()
}
}
}
if err := writeName(w, props); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte(' '); err != nil {
return err
}
}
if b, ok := fv.Interface().(raw); ok {
if err := writeRaw(w, b.Bytes()); err != nil {
return err
}
continue
}
if len(props.Enum) > 0 {
if err := tm.writeEnum(w, fv, props); err != nil {
return err
}
} else if err := tm.writeAny(w, fv, props); err != nil {
return err
}
if err := w.WriteByte('\n'); err != nil {
return err
}
}
// Extensions (the XXX_extensions field).
pv := sv
if pv.CanAddr() {
pv = sv.Addr()
} else {
pv = reflect.New(sv.Type())
pv.Elem().Set(sv)
}
if pv.Type().Implements(extensionRangeType) {
if err := tm.writeExtensions(w, pv); err != nil {
return err
}
}
return nil
}
// writeRaw writes an uninterpreted raw message.
func writeRaw(w *textWriter, b []byte) error {
if err := w.WriteByte('<'); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte('\n'); err != nil {
return err
}
}
w.indent()
if err := writeUnknownStruct(w, b); err != nil {
return err
}
w.unindent()
if err := w.WriteByte('>'); err != nil {
return err
}
return nil
}
// writeAny writes an arbitrary field.
func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Properties) error {
v = reflect.Indirect(v)
if props != nil {
if len(props.CustomType) > 0 {
custom, ok := v.Interface().(Marshaler)
if ok {
data, err := custom.Marshal()
if err != nil {
return err
}
if err := writeString(w, string(data)); err != nil {
return err
}
return nil
}
} else if props.StdTime {
t, ok := v.Interface().(time.Time)
if !ok {
return fmt.Errorf("stdtime is not time.Time, but %T", v.Interface())
}
tproto, err := timestampProto(t)
if err != nil {
return err
}
props.StdTime = false
err = tm.writeAny(w, reflect.ValueOf(tproto), props)
props.StdTime = true
return err
} else if props.StdDuration {
d, ok := v.Interface().(time.Duration)
if !ok {
return fmt.Errorf("stdtime is not time.Duration, but %T", v.Interface())
}
dproto := durationProto(d)
props.StdDuration = false
err := tm.writeAny(w, reflect.ValueOf(dproto), props)
props.StdDuration = true
return err
}
}
// Floats have special cases.
if v.Kind() == reflect.Float32 || v.Kind() == reflect.Float64 {
x := v.Float()
var b []byte
switch {
case math.IsInf(x, 1):
b = posInf
case math.IsInf(x, -1):
b = negInf
case math.IsNaN(x):
b = nan
}
if b != nil {
_, err := w.Write(b)
return err
}
// Other values are handled below.
}
// We don't attempt to serialise every possible value type; only those
// that can occur in protocol buffers.
switch v.Kind() {
case reflect.Slice:
// Should only be a []byte; repeated fields are handled in writeStruct.
if err := writeString(w, string(v.Bytes())); err != nil {
return err
}
case reflect.String:
if err := writeString(w, v.String()); err != nil {
return err
}
case reflect.Struct:
// Required/optional group/message.
var bra, ket byte = '<', '>'
if props != nil && props.Wire == "group" {
bra, ket = '{', '}'
}
if err := w.WriteByte(bra); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte('\n'); err != nil {
return err
}
}
w.indent()
if etm, ok := v.Interface().(encoding.TextMarshaler); ok {
text, err := etm.MarshalText()
if err != nil {
return err
}
if _, err = w.Write(text); err != nil {
return err
}
} else if err := tm.writeStruct(w, v); err != nil {
return err
}
w.unindent()
if err := w.WriteByte(ket); err != nil {
return err
}
default:
_, err := fmt.Fprint(w, v.Interface())
return err
}
return nil
}
// equivalent to C's isprint.
func isprint(c byte) bool {
return c >= 0x20 && c < 0x7f
}
// writeString writes a string in the protocol buffer text format.
// It is similar to strconv.Quote except we don't use Go escape sequences,
// we treat the string as a byte sequence, and we use octal escapes.
// These differences are to maintain interoperability with the other
// languages' implementations of the text format.
func writeString(w *textWriter, s string) error {
// use WriteByte here to get any needed indent
if err := w.WriteByte('"'); err != nil {
return err
}
// Loop over the bytes, not the runes.
for i := 0; i < len(s); i++ {
var err error
// Divergence from C++: we don't escape apostrophes.
// There's no need to escape them, and the C++ parser
// copes with a naked apostrophe.
switch c := s[i]; c {
case '\n':
_, err = w.w.Write(backslashN)
case '\r':
_, err = w.w.Write(backslashR)
case '\t':
_, err = w.w.Write(backslashT)
case '"':
_, err = w.w.Write(backslashDQ)
case '\\':
_, err = w.w.Write(backslashBS)
default:
if isprint(c) {
err = w.w.WriteByte(c)
} else {
_, err = fmt.Fprintf(w.w, "\\%03o", c)
}
}
if err != nil {
return err
}
}
return w.WriteByte('"')
}
func writeUnknownStruct(w *textWriter, data []byte) (err error) {
if !w.compact {
if _, err := fmt.Fprintf(w, "/* %d unknown bytes */\n", len(data)); err != nil {
return err
}
}
b := NewBuffer(data)
for b.index < len(b.buf) {
x, err := b.DecodeVarint()
if err != nil {
_, ferr := fmt.Fprintf(w, "/* %v */\n", err)
return ferr
}
wire, tag := x&7, x>>3
if wire == WireEndGroup {
w.unindent()
if _, werr := w.Write(endBraceNewline); werr != nil {
return werr
}
continue
}
if _, ferr := fmt.Fprint(w, tag); ferr != nil {
return ferr
}
if wire != WireStartGroup {
if err = w.WriteByte(':'); err != nil {
return err
}
}
if !w.compact || wire == WireStartGroup {
if err = w.WriteByte(' '); err != nil {
return err
}
}
switch wire {
case WireBytes:
buf, e := b.DecodeRawBytes(false)
if e == nil {
_, err = fmt.Fprintf(w, "%q", buf)
} else {
_, err = fmt.Fprintf(w, "/* %v */", e)
}
case WireFixed32:
x, err = b.DecodeFixed32()
err = writeUnknownInt(w, x, err)
case WireFixed64:
x, err = b.DecodeFixed64()
err = writeUnknownInt(w, x, err)
case WireStartGroup:
err = w.WriteByte('{')
w.indent()
case WireVarint:
x, err = b.DecodeVarint()
err = writeUnknownInt(w, x, err)
default:
_, err = fmt.Fprintf(w, "/* unknown wire type %d */", wire)
}
if err != nil {
return err
}
if err := w.WriteByte('\n'); err != nil {
return err
}
}
return nil
}
func writeUnknownInt(w *textWriter, x uint64, err error) error {
if err == nil {
_, err = fmt.Fprint(w, x)
} else {
_, err = fmt.Fprintf(w, "/* %v */", err)
}
return err
}
type int32Slice []int32
func (s int32Slice) Len() int { return len(s) }
func (s int32Slice) Less(i, j int) bool { return s[i] < s[j] }
func (s int32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
// writeExtensions writes all the extensions in pv.
// pv is assumed to be a pointer to a protocol message struct that is extendable.
func (tm *TextMarshaler) writeExtensions(w *textWriter, pv reflect.Value) error {
emap := extensionMaps[pv.Type().Elem()]
e := pv.Interface().(Message)
var m map[int32]Extension
var mu sync.Locker
if em, ok := e.(extensionsBytes); ok {
eb := em.GetExtensions()
var err error
m, err = BytesToExtensionsMap(*eb)
if err != nil {
return err
}
mu = notLocker{}
} else if _, ok := e.(extendableProto); ok {
ep, _ := extendable(e)
m, mu = ep.extensionsRead()
if m == nil {
return nil
}
}
// Order the extensions by ID.
// This isn't strictly necessary, but it will give us
// canonical output, which will also make testing easier.
mu.Lock()
ids := make([]int32, 0, len(m))
for id := range m {
ids = append(ids, id)
}
sort.Sort(int32Slice(ids))
mu.Unlock()
for _, extNum := range ids {
ext := m[extNum]
var desc *ExtensionDesc
if emap != nil {
desc = emap[extNum]
}
if desc == nil {
// Unknown extension.
if err := writeUnknownStruct(w, ext.enc); err != nil {
return err
}
continue
}
pb, err := GetExtension(e, desc)
if err != nil {
return fmt.Errorf("failed getting extension: %v", err)
}
// Repeated extensions will appear as a slice.
if !desc.repeated() {
if err := tm.writeExtension(w, desc.Name, pb); err != nil {
return err
}
} else {
v := reflect.ValueOf(pb)
for i := 0; i < v.Len(); i++ {
if err := tm.writeExtension(w, desc.Name, v.Index(i).Interface()); err != nil {
return err
}
}
}
}
return nil
}
func (tm *TextMarshaler) writeExtension(w *textWriter, name string, pb interface{}) error {
if _, err := fmt.Fprintf(w, "[%s]:", name); err != nil {
return err
}
if !w.compact {
if err := w.WriteByte(' '); err != nil {
return err
}
}
if err := tm.writeAny(w, reflect.ValueOf(pb), nil); err != nil {
return err
}
if err := w.WriteByte('\n'); err != nil {
return err
}
return nil
}
func (w *textWriter) writeIndent() {
if !w.complete {
return
}
remain := w.ind * 2
for remain > 0 {
n := remain
if n > len(spaces) {
n = len(spaces)
}
w.w.Write(spaces[:n])
remain -= n
}
w.complete = false
}
// TextMarshaler is a configurable text format marshaler.
type TextMarshaler struct {
Compact bool // use compact text format (one line).
ExpandAny bool // expand google.protobuf.Any messages of known types
}
// Marshal writes a given protocol buffer in text format.
// The only errors returned are from w.
func (tm *TextMarshaler) Marshal(w io.Writer, pb Message) error {
val := reflect.ValueOf(pb)
if pb == nil || val.IsNil() {
w.Write([]byte("<nil>"))
return nil
}
var bw *bufio.Writer
ww, ok := w.(writer)
if !ok {
bw = bufio.NewWriter(w)
ww = bw
}
aw := &textWriter{
w: ww,
complete: true,
compact: tm.Compact,
}
if etm, ok := pb.(encoding.TextMarshaler); ok {
text, err := etm.MarshalText()
if err != nil {
return err
}
if _, err = aw.Write(text); err != nil {
return err
}
if bw != nil {
return bw.Flush()
}
return nil
}
// Dereference the received pointer so we don't have outer < and >.
v := reflect.Indirect(val)
if err := tm.writeStruct(aw, v); err != nil {
return err
}
if bw != nil {
return bw.Flush()
}
return nil
}
// Text is the same as Marshal, but returns the string directly.
func (tm *TextMarshaler) Text(pb Message) string {
var buf bytes.Buffer
tm.Marshal(&buf, pb)
return buf.String()
}
var (
defaultTextMarshaler = TextMarshaler{}
compactTextMarshaler = TextMarshaler{Compact: true}
)
// TODO: consider removing some of the Marshal functions below.
// MarshalText writes a given protocol buffer in text format.
// The only errors returned are from w.
func MarshalText(w io.Writer, pb Message) error { return defaultTextMarshaler.Marshal(w, pb) }
// MarshalTextString is the same as MarshalText, but returns the string directly.
func MarshalTextString(pb Message) string { return defaultTextMarshaler.Text(pb) }
// CompactText writes a given protocol buffer in compact text format (one line).
func CompactText(w io.Writer, pb Message) error { return compactTextMarshaler.Marshal(w, pb) }
// CompactTextString is the same as CompactText, but returns the string directly.
func CompactTextString(pb Message) string { return compactTextMarshaler.Text(pb) }

View File

@@ -1,57 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"fmt"
"reflect"
)
func (tm *TextMarshaler) writeEnum(w *textWriter, v reflect.Value, props *Properties) error {
m, ok := enumStringMaps[props.Enum]
if !ok {
if err := tm.writeAny(w, v, props); err != nil {
return err
}
}
key := int32(0)
if v.Kind() == reflect.Ptr {
key = int32(v.Elem().Int())
} else {
key = int32(v.Int())
}
s, ok := m[key]
if !ok {
if err := tm.writeAny(w, v, props); err != nil {
return err
}
}
_, err := fmt.Fprint(w, s)
return err
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,113 +0,0 @@
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2016 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
// This file implements operations on google.protobuf.Timestamp.
import (
"errors"
"fmt"
"time"
)
const (
// Seconds field of the earliest valid Timestamp.
// This is time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC).Unix().
minValidSeconds = -62135596800
// Seconds field just after the latest valid Timestamp.
// This is time.Date(10000, 1, 1, 0, 0, 0, 0, time.UTC).Unix().
maxValidSeconds = 253402300800
)
// validateTimestamp determines whether a Timestamp is valid.
// A valid timestamp represents a time in the range
// [0001-01-01, 10000-01-01) and has a Nanos field
// in the range [0, 1e9).
//
// If the Timestamp is valid, validateTimestamp returns nil.
// Otherwise, it returns an error that describes
// the problem.
//
// Every valid Timestamp can be represented by a time.Time, but the converse is not true.
func validateTimestamp(ts *timestamp) error {
if ts == nil {
return errors.New("timestamp: nil Timestamp")
}
if ts.Seconds < minValidSeconds {
return fmt.Errorf("timestamp: %#v before 0001-01-01", ts)
}
if ts.Seconds >= maxValidSeconds {
return fmt.Errorf("timestamp: %#v after 10000-01-01", ts)
}
if ts.Nanos < 0 || ts.Nanos >= 1e9 {
return fmt.Errorf("timestamp: %#v: nanos not in range [0, 1e9)", ts)
}
return nil
}
// TimestampFromProto converts a google.protobuf.Timestamp proto to a time.Time.
// It returns an error if the argument is invalid.
//
// Unlike most Go functions, if Timestamp returns an error, the first return value
// is not the zero time.Time. Instead, it is the value obtained from the
// time.Unix function when passed the contents of the Timestamp, in the UTC
// locale. This may or may not be a meaningful time; many invalid Timestamps
// do map to valid time.Times.
//
// A nil Timestamp returns an error. The first return value in that case is
// undefined.
func timestampFromProto(ts *timestamp) (time.Time, error) {
// Don't return the zero value on error, because corresponds to a valid
// timestamp. Instead return whatever time.Unix gives us.
var t time.Time
if ts == nil {
t = time.Unix(0, 0).UTC() // treat nil like the empty Timestamp
} else {
t = time.Unix(ts.Seconds, int64(ts.Nanos)).UTC()
}
return t, validateTimestamp(ts)
}
// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto.
// It returns an error if the resulting Timestamp is invalid.
func timestampProto(t time.Time) (*timestamp, error) {
seconds := t.Unix()
nanos := int32(t.Sub(time.Unix(seconds, 0)))
ts := &timestamp{
Seconds: seconds,
Nanos: nanos,
}
if err := validateTimestamp(ts); err != nil {
return nil, err
}
return ts, nil
}

View File

@@ -1,229 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2016, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"reflect"
"time"
)
var timeType = reflect.TypeOf((*time.Time)(nil)).Elem()
type timestamp struct {
Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"`
Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
}
func (m *timestamp) Reset() { *m = timestamp{} }
func (*timestamp) ProtoMessage() {}
func (*timestamp) String() string { return "timestamp<string>" }
func init() {
RegisterType((*timestamp)(nil), "gogo.protobuf.proto.timestamp")
}
func (o *Buffer) decTimestamp() (time.Time, error) {
b, err := o.DecodeRawBytes(true)
if err != nil {
return time.Time{}, err
}
tproto := &timestamp{}
if err := Unmarshal(b, tproto); err != nil {
return time.Time{}, err
}
return timestampFromProto(tproto)
}
func (o *Buffer) dec_time(p *Properties, base structPointer) error {
t, err := o.decTimestamp()
if err != nil {
return err
}
setPtrCustomType(base, p.field, &t)
return nil
}
func (o *Buffer) dec_ref_time(p *Properties, base structPointer) error {
t, err := o.decTimestamp()
if err != nil {
return err
}
setCustomType(base, p.field, &t)
return nil
}
func (o *Buffer) dec_slice_time(p *Properties, base structPointer) error {
t, err := o.decTimestamp()
if err != nil {
return err
}
newBas := appendStructPointer(base, p.field, reflect.SliceOf(reflect.PtrTo(timeType)))
var zero field
setPtrCustomType(newBas, zero, &t)
return nil
}
func (o *Buffer) dec_slice_ref_time(p *Properties, base structPointer) error {
t, err := o.decTimestamp()
if err != nil {
return err
}
newBas := appendStructPointer(base, p.field, reflect.SliceOf(timeType))
var zero field
setCustomType(newBas, zero, &t)
return nil
}
func size_time(p *Properties, base structPointer) (n int) {
structp := structPointer_GetStructPointer(base, p.field)
if structPointer_IsNil(structp) {
return 0
}
tim := structPointer_Interface(structp, timeType).(*time.Time)
t, err := timestampProto(*tim)
if err != nil {
return 0
}
size := Size(t)
return size + sizeVarint(uint64(size)) + len(p.tagcode)
}
func (o *Buffer) enc_time(p *Properties, base structPointer) error {
structp := structPointer_GetStructPointer(base, p.field)
if structPointer_IsNil(structp) {
return ErrNil
}
tim := structPointer_Interface(structp, timeType).(*time.Time)
t, err := timestampProto(*tim)
if err != nil {
return err
}
data, err := Marshal(t)
if err != nil {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
return nil
}
func size_ref_time(p *Properties, base structPointer) (n int) {
tim := structPointer_InterfaceAt(base, p.field, timeType).(*time.Time)
t, err := timestampProto(*tim)
if err != nil {
return 0
}
size := Size(t)
return size + sizeVarint(uint64(size)) + len(p.tagcode)
}
func (o *Buffer) enc_ref_time(p *Properties, base structPointer) error {
tim := structPointer_InterfaceAt(base, p.field, timeType).(*time.Time)
t, err := timestampProto(*tim)
if err != nil {
return err
}
data, err := Marshal(t)
if err != nil {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
return nil
}
func size_slice_time(p *Properties, base structPointer) (n int) {
ptims := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(reflect.PtrTo(timeType))).(*[]*time.Time)
tims := *ptims
for i := 0; i < len(tims); i++ {
if tims[i] == nil {
return 0
}
tproto, err := timestampProto(*tims[i])
if err != nil {
return 0
}
size := Size(tproto)
n += len(p.tagcode) + size + sizeVarint(uint64(size))
}
return n
}
func (o *Buffer) enc_slice_time(p *Properties, base structPointer) error {
ptims := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(reflect.PtrTo(timeType))).(*[]*time.Time)
tims := *ptims
for i := 0; i < len(tims); i++ {
if tims[i] == nil {
return errRepeatedHasNil
}
tproto, err := timestampProto(*tims[i])
if err != nil {
return err
}
data, err := Marshal(tproto)
if err != nil {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
}
return nil
}
func size_slice_ref_time(p *Properties, base structPointer) (n int) {
ptims := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(timeType)).(*[]time.Time)
tims := *ptims
for i := 0; i < len(tims); i++ {
tproto, err := timestampProto(tims[i])
if err != nil {
return 0
}
size := Size(tproto)
n += len(p.tagcode) + size + sizeVarint(uint64(size))
}
return n
}
func (o *Buffer) enc_slice_ref_time(p *Properties, base structPointer) error {
ptims := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(timeType)).(*[]time.Time)
tims := *ptims
for i := 0; i < len(tims); i++ {
tproto, err := timestampProto(tims[i])
if err != nil {
return err
}
data, err := Marshal(tproto)
if err != nil {
return err
}
o.buf = append(o.buf, p.tagcode...)
o.EncodeRawBytes(data)
}
return nil
}

View File

@@ -1,101 +0,0 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package sortkeys
import (
"sort"
)
func Strings(l []string) {
sort.Strings(l)
}
func Float64s(l []float64) {
sort.Float64s(l)
}
func Float32s(l []float32) {
sort.Sort(Float32Slice(l))
}
func Int64s(l []int64) {
sort.Sort(Int64Slice(l))
}
func Int32s(l []int32) {
sort.Sort(Int32Slice(l))
}
func Uint64s(l []uint64) {
sort.Sort(Uint64Slice(l))
}
func Uint32s(l []uint32) {
sort.Sort(Uint32Slice(l))
}
func Bools(l []bool) {
sort.Sort(BoolSlice(l))
}
type BoolSlice []bool
func (p BoolSlice) Len() int { return len(p) }
func (p BoolSlice) Less(i, j int) bool { return p[j] }
func (p BoolSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
type Int64Slice []int64
func (p Int64Slice) Len() int { return len(p) }
func (p Int64Slice) Less(i, j int) bool { return p[i] < p[j] }
func (p Int64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
type Int32Slice []int32
func (p Int32Slice) Len() int { return len(p) }
func (p Int32Slice) Less(i, j int) bool { return p[i] < p[j] }
func (p Int32Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
type Uint64Slice []uint64
func (p Uint64Slice) Len() int { return len(p) }
func (p Uint64Slice) Less(i, j int) bool { return p[i] < p[j] }
func (p Uint64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
type Uint32Slice []uint32
func (p Uint32Slice) Len() int { return len(p) }
func (p Uint32Slice) Less(i, j int) bool { return p[i] < p[j] }
func (p Uint32Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
type Float32Slice []float32
func (p Float32Slice) Len() int { return len(p) }
func (p Float32Slice) Less(i, j int) bool { return p[i] < p[j] }
func (p Float32Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }

191
vendor/github.com/golang/glog/LICENSE generated vendored
View File

@@ -1,191 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and
distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright
owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities
that control, are controlled by, or are under common control with that entity.
For the purposes of this definition, "control" means (i) the power, direct or
indirect, to cause the direction or management of such entity, whether by
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising
permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including
but not limited to software source code, documentation source, and configuration
files.
"Object" form shall mean any form resulting from mechanical transformation or
translation of a Source form, including but not limited to compiled object code,
generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made
available under the License, as indicated by a copyright notice that is included
in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that
is based on (or derived from) the Work and for which the editorial revisions,
annotations, elaborations, or other modifications represent, as a whole, an
original work of authorship. For the purposes of this License, Derivative Works
shall not include works that remain separable from, or merely link (or bind by
name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version
of the Work and any modifications or additions to that Work or Derivative Works
thereof, that is intentionally submitted to Licensor for inclusion in the Work
by the copyright owner or by an individual or Legal Entity authorized to submit
on behalf of the copyright owner. For the purposes of this definition,
"submitted" means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems, and
issue tracking systems that are managed by, or on behalf of, the Licensor for
the purpose of discussing and improving the Work, but excluding communication
that is conspicuously marked or otherwise designated in writing by the copyright
owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
of whom a Contribution has been received by Licensor and subsequently
incorporated within the Work.
2. Grant of Copyright License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the Work and such
Derivative Works in Source or Object form.
3. Grant of Patent License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to make, have
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
such license applies only to those patent claims licensable by such Contributor
that are necessarily infringed by their Contribution(s) alone or by combination
of their Contribution(s) with the Work to which such Contribution(s) was
submitted. If You institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
Contribution incorporated within the Work constitutes direct or contributory
patent infringement, then any patent licenses granted to You under this License
for that Work shall terminate as of the date such litigation is filed.
4. Redistribution.
You may reproduce and distribute copies of the Work or Derivative Works thereof
in any medium, with or without modifications, and in Source or Object form,
provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of
this License; and
You must cause any modified files to carry prominent notices stating that You
changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute,
all copyright, patent, trademark, and attribution notices from the Source form
of the Work, excluding those notices that do not pertain to any part of the
Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any
Derivative Works that You distribute must include a readable copy of the
attribution notices contained within such NOTICE file, excluding those notices
that do not pertain to any part of the Derivative Works, in at least one of the
following places: within a NOTICE text file distributed as part of the
Derivative Works; within the Source form or documentation, if provided along
with the Derivative Works; or, within a display generated by the Derivative
Works, if and wherever such third-party notices normally appear. The contents of
the NOTICE file are for informational purposes only and do not modify the
License. You may add Your own attribution notices within Derivative Works that
You distribute, alongside or as an addendum to the NOTICE text from the Work,
provided that such additional attribution notices cannot be construed as
modifying the License.
You may add Your own copyright statement to Your modifications and may provide
additional or different license terms and conditions for use, reproduction, or
distribution of Your modifications, or for any such Derivative Works as a whole,
provided Your use, reproduction, and distribution of the Work otherwise complies
with the conditions stated in this License.
5. Submission of Contributions.
Unless You explicitly state otherwise, any Contribution intentionally submitted
for inclusion in the Work by You to the Licensor shall be under the terms and
conditions of this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify the terms of
any separate license agreement you may have executed with Licensor regarding
such Contributions.
6. Trademarks.
This License does not grant permission to use the trade names, trademarks,
service marks, or product names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the NOTICE file.
7. Disclaimer of Warranty.
Unless required by applicable law or agreed to in writing, Licensor provides the
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
including, without limitation, any warranties or conditions of TITLE,
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
solely responsible for determining the appropriateness of using or
redistributing the Work and assume any risks associated with Your exercise of
permissions under this License.
8. Limitation of Liability.
In no event and under no legal theory, whether in tort (including negligence),
contract, or otherwise, unless required by applicable law (such as deliberate
and grossly negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special, incidental,
or consequential damages of any character arising as a result of this License or
out of the use or inability to use the Work (including but not limited to
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
any and all other commercial damages or losses), even if such Contributor has
been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability.
While redistributing the Work or Derivative Works thereof, You may choose to
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
other liability obligations and/or rights consistent with this License. However,
in accepting such obligations, You may act only on Your own behalf and on Your
sole responsibility, not on behalf of any other Contributor, and only if You
agree to indemnify, defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason of your
accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work
To apply the Apache License to your work, attach the following boilerplate
notice, with the fields enclosed by brackets "[]" replaced with your own
identifying information. (Don't include the brackets!) The text should be
enclosed in the appropriate comment syntax for the file format. We also
recommend that a file or class name and description of purpose be included on
the same "printed page" as the copyright notice for easier identification within
third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

44
vendor/github.com/golang/glog/README generated vendored
View File

@@ -1,44 +0,0 @@
glog
====
Leveled execution logs for Go.
This is an efficient pure Go implementation of leveled logs in the
manner of the open source C++ package
http://code.google.com/p/google-glog
By binding methods to booleans it is possible to use the log package
without paying the expense of evaluating the arguments to the log.
Through the -vmodule flag, the package also provides fine-grained
control over logging at the file level.
The comment from glog.go introduces the ideas:
Package glog implements logging analogous to the Google-internal
C++ INFO/ERROR/V setup. It provides functions Info, Warning,
Error, Fatal, plus formatting variants such as Infof. It
also provides V-style logging controlled by the -v and
-vmodule=file=2 flags.
Basic examples:
glog.Info("Prepare to repel boarders")
glog.Fatalf("Initialization failed: %s", err)
See the documentation for the V function for an explanation
of these examples:
if glog.V(2) {
glog.Info("Starting transaction...")
}
glog.V(2).Infoln("Processed", nItems, "elements")
The repository contains an open source version of the log package
used inside Google. The master copy of the source lives inside
Google, not here. The code in this repo is for export only and is not itself
under development. Feature requests will be ignored.
Send bug reports to golang-nuts@googlegroups.com.

1177
vendor/github.com/golang/glog/glog.go generated vendored

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More