mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 18:02:01 +00:00
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
This commit is contained in:
parent
bd1e7dc3cb
commit
11b3a18cca
4
go.mod
4
go.mod
@ -122,7 +122,7 @@ require (
|
||||
k8s.io/klog/v2 v2.60.1
|
||||
k8s.io/kube-aggregator v0.0.0
|
||||
k8s.io/kube-controller-manager v0.0.0
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05
|
||||
k8s.io/kube-proxy v0.0.0
|
||||
k8s.io/kube-scheduler v0.0.0
|
||||
k8s.io/kubectl v0.0.0
|
||||
@ -461,7 +461,7 @@ replace (
|
||||
k8s.io/klog/v2 => k8s.io/klog/v2 v2.60.1
|
||||
k8s.io/kube-aggregator => ./staging/src/k8s.io/kube-aggregator
|
||||
k8s.io/kube-controller-manager => ./staging/src/k8s.io/kube-controller-manager
|
||||
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18
|
||||
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05
|
||||
k8s.io/kube-proxy => ./staging/src/k8s.io/kube-proxy
|
||||
k8s.io/kube-scheduler => ./staging/src/k8s.io/kube-scheduler
|
||||
k8s.io/kubectl => ./staging/src/k8s.io/kubectl
|
||||
|
4
go.sum
4
go.sum
@ -545,8 +545,8 @@ k8s.io/gengo v0.0.0-20211129171323-c02415ce4185 h1:TT1WdmqqXareKxZ/oNXEUSwKlLiHz
|
||||
k8s.io/gengo v0.0.0-20211129171323-c02415ce4185/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/system-validators v1.6.0 h1:21qaPNdZ+mQrm4qc5shU0T5Eh49t/miFqZsn4sW8Hr0=
|
||||
k8s.io/system-validators v1.6.0/go.mod h1:bPldcLgkIUK22ALflnsXk8pvkTEndYdNuaHH6gRrl0Q=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
|
@ -107,7 +107,7 @@ mkdir -p "${OPENAPI_ROOT_DIR}/v3"
|
||||
# ".well-known__openid-configuration_openapi.json"
|
||||
rm -r "${OPENAPI_ROOT_DIR}"/v3/{*,.*} || true
|
||||
|
||||
curl -w "\n" -kfsS -H 'Authorization: Bearer dummy_token' "https://${API_HOST}:${API_PORT}/openapi/v3" | jq '.Paths' | jq -r '.[]' | while read -r group; do
|
||||
curl -w "\n" -kfsS -H 'Authorization: Bearer dummy_token' "https://${API_HOST}:${API_PORT}/openapi/v3" | jq -r '.paths | to_entries | .[].key' | while read -r group; do
|
||||
kube::log::status "Updating OpenAPI spec for group ${group}"
|
||||
OPENAPI_FILENAME="${group}_openapi.json"
|
||||
OPENAPI_FILENAME_ESCAPED="${OPENAPI_FILENAME//\//__}"
|
||||
|
2
staging/src/k8s.io/api/go.sum
generated
2
staging/src/k8s.io/api/go.sum
generated
@ -226,7 +226,7 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
@ -29,7 +29,7 @@ require (
|
||||
k8s.io/code-generator v0.0.0
|
||||
k8s.io/component-base v0.0.0
|
||||
k8s.io/klog/v2 v2.60.1
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
|
||||
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1
|
||||
|
@ -982,8 +982,8 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
@ -31,7 +31,7 @@ require (
|
||||
gopkg.in/inf.v0 v0.9.1
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
k8s.io/klog/v2 v2.60.1
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
|
||||
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1
|
||||
|
4
staging/src/k8s.io/apimachinery/go.sum
generated
4
staging/src/k8s.io/apimachinery/go.sum
generated
@ -247,8 +247,8 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
@ -49,7 +49,7 @@ require (
|
||||
k8s.io/client-go v0.0.0
|
||||
k8s.io/component-base v0.0.0
|
||||
k8s.io/klog/v2 v2.60.1
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
|
||||
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.30
|
||||
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2
|
||||
|
4
staging/src/k8s.io/apiserver/go.sum
generated
4
staging/src/k8s.io/apiserver/go.sum
generated
@ -961,8 +961,8 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
@ -20,7 +20,7 @@ require (
|
||||
k8s.io/api v0.0.0
|
||||
k8s.io/apimachinery v0.0.0
|
||||
k8s.io/client-go v0.0.0
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
|
||||
sigs.k8s.io/kustomize/api v0.10.1
|
||||
sigs.k8s.io/kustomize/kyaml v0.13.0
|
||||
|
4
staging/src/k8s.io/cli-runtime/go.sum
generated
4
staging/src/k8s.io/cli-runtime/go.sum
generated
@ -722,8 +722,8 @@ k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
@ -33,7 +33,7 @@ require (
|
||||
k8s.io/api v0.0.0
|
||||
k8s.io/apimachinery v0.0.0
|
||||
k8s.io/klog/v2 v2.60.1
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1
|
||||
sigs.k8s.io/yaml v1.2.0
|
||||
|
4
staging/src/k8s.io/client-go/go.sum
generated
4
staging/src/k8s.io/client-go/go.sum
generated
@ -618,8 +618,8 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
4
staging/src/k8s.io/cloud-provider/go.sum
generated
4
staging/src/k8s.io/cloud-provider/go.sum
generated
@ -956,8 +956,8 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
2
staging/src/k8s.io/cluster-bootstrap/go.sum
generated
2
staging/src/k8s.io/cluster-bootstrap/go.sum
generated
@ -231,7 +231,7 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
@ -8,7 +8,7 @@ require (
|
||||
k8s.io/api v0.0.0
|
||||
k8s.io/apimachinery v0.0.0
|
||||
k8s.io/client-go v0.0.0
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05
|
||||
)
|
||||
|
||||
replace (
|
||||
|
@ -609,8 +609,8 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
@ -21,7 +21,7 @@ require (
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
k8s.io/gengo v0.0.0-20211129171323-c02415ce4185
|
||||
k8s.io/klog/v2 v2.60.1
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
|
||||
)
|
||||
|
||||
|
4
staging/src/k8s.io/code-generator/go.sum
generated
4
staging/src/k8s.io/code-generator/go.sum
generated
@ -251,8 +251,8 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 h1:bKCqE9GvQ5tiVHn5rfn1r+yao3aLQEaLzkkmAkf+A6Y=
|
||||
|
4
staging/src/k8s.io/component-base/go.sum
generated
4
staging/src/k8s.io/component-base/go.sum
generated
@ -765,8 +765,8 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
4
staging/src/k8s.io/component-helpers/go.sum
generated
4
staging/src/k8s.io/component-helpers/go.sum
generated
@ -600,8 +600,8 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
4
staging/src/k8s.io/controller-manager/go.sum
generated
4
staging/src/k8s.io/controller-manager/go.sum
generated
@ -1063,8 +1063,8 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
2
staging/src/k8s.io/csi-translation-lib/go.sum
generated
2
staging/src/k8s.io/csi-translation-lib/go.sum
generated
@ -225,7 +225,7 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
@ -19,7 +19,7 @@ require (
|
||||
k8s.io/code-generator v0.0.0
|
||||
k8s.io/component-base v0.0.0
|
||||
k8s.io/klog/v2 v2.60.1
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1
|
||||
)
|
||||
|
4
staging/src/k8s.io/kube-aggregator/go.sum
generated
4
staging/src/k8s.io/kube-aggregator/go.sum
generated
@ -956,8 +956,8 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
@ -21,14 +21,15 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"k8s.io/apiserver/pkg/server"
|
||||
"k8s.io/klog/v2"
|
||||
v1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
|
||||
"k8s.io/kube-openapi/pkg/common"
|
||||
"k8s.io/kube-openapi/pkg/handler3"
|
||||
)
|
||||
|
||||
// SpecProxier proxies OpenAPI V3 requests to their respective APIService
|
||||
@ -121,7 +122,7 @@ func (s *specProxier) UpdateAPIServiceSpec(apiServiceName string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.apiServiceInfo[apiServiceName].gvList = gv
|
||||
s.apiServiceInfo[apiServiceName].discovery = gv
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -141,7 +142,7 @@ var _ SpecProxier = &specProxier{}
|
||||
type openAPIV3APIServiceInfo struct {
|
||||
apiService v1.APIService
|
||||
handler http.Handler
|
||||
gvList []string
|
||||
discovery *handler3.OpenAPIV3Discovery
|
||||
}
|
||||
|
||||
// RemoveAPIServiceSpec removes an api service from the OpenAPI map. If it does not exist, no error is returned.
|
||||
@ -149,32 +150,32 @@ type openAPIV3APIServiceInfo struct {
|
||||
func (s *specProxier) RemoveAPIServiceSpec(apiServiceName string) {
|
||||
s.rwMutex.Lock()
|
||||
defer s.rwMutex.Unlock()
|
||||
if _, ok := s.apiServiceInfo[apiServiceName]; ok {
|
||||
delete(s.apiServiceInfo, apiServiceName)
|
||||
}
|
||||
}
|
||||
|
||||
// handleDiscovery is the handler for OpenAPI V3 Discovery
|
||||
func (s *specProxier) handleDiscovery(w http.ResponseWriter, r *http.Request) {
|
||||
s.rwMutex.RLock()
|
||||
defer s.rwMutex.RUnlock()
|
||||
|
||||
gvList := make(map[string]bool)
|
||||
merged := handler3.OpenAPIV3Discovery{
|
||||
Paths: make(map[string]handler3.OpenAPIV3DiscoveryGroupVersion),
|
||||
}
|
||||
|
||||
for _, apiServiceInfo := range s.apiServiceInfo {
|
||||
for _, gv := range apiServiceInfo.gvList {
|
||||
gvList[gv] = true
|
||||
if apiServiceInfo.discovery == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for key, item := range apiServiceInfo.discovery.Paths {
|
||||
merged.Paths[key] = item
|
||||
}
|
||||
}
|
||||
|
||||
keys := make([]string, 0, len(gvList))
|
||||
for k := range gvList {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
|
||||
sort.Strings(keys)
|
||||
output := map[string][]string{"Paths": keys}
|
||||
j, err := json.Marshal(output)
|
||||
j, err := json.Marshal(&merged)
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
klog.Errorf("failed to created merged OpenAPIv3 discovery response: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@ -193,8 +194,12 @@ func (s *specProxier) handleGroupVersion(w http.ResponseWriter, r *http.Request)
|
||||
targetGV := url[3]
|
||||
|
||||
for _, apiServiceInfo := range s.apiServiceInfo {
|
||||
for _, gv := range apiServiceInfo.gvList {
|
||||
if targetGV == gv {
|
||||
if apiServiceInfo.discovery == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for key := range apiServiceInfo.discovery.Paths {
|
||||
if targetGV == key {
|
||||
apiServiceInfo.handler.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import (
|
||||
"k8s.io/apiserver/pkg/authentication/user"
|
||||
"k8s.io/apiserver/pkg/endpoints/request"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/kube-openapi/pkg/handler3"
|
||||
"k8s.io/kube-openapi/pkg/spec3"
|
||||
)
|
||||
|
||||
@ -43,11 +44,6 @@ func (s *Downloader) handlerWithUser(handler http.Handler, info user.Info) http.
|
||||
})
|
||||
}
|
||||
|
||||
// gvList is a struct for the response of the /openapi/v3 endpoint to unmarshal into
|
||||
type gvList struct {
|
||||
Paths []string `json:"Paths"`
|
||||
}
|
||||
|
||||
// SpecETag is a OpenAPI v3 spec and etag pair for the endpoint of each OpenAPI group/version
|
||||
type SpecETag struct {
|
||||
spec *spec3.OpenAPI
|
||||
@ -55,7 +51,7 @@ type SpecETag struct {
|
||||
}
|
||||
|
||||
// OpenAPIV3Root downloads the OpenAPI V3 root document from an APIService
|
||||
func (s *Downloader) OpenAPIV3Root(handler http.Handler) ([]string, error) {
|
||||
func (s *Downloader) OpenAPIV3Root(handler http.Handler) (*handler3.OpenAPIV3Discovery, error) {
|
||||
handler = s.handlerWithUser(handler, &user.DefaultInfo{Name: aggregatorUser})
|
||||
handler = http.TimeoutHandler(handler, specDownloadTimeout, "request timed out")
|
||||
|
||||
@ -73,11 +69,11 @@ func (s *Downloader) OpenAPIV3Root(handler http.Handler) ([]string, error) {
|
||||
// TODO: For APIServices, download the V2 spec and convert to V3
|
||||
return nil, nil
|
||||
case http.StatusOK:
|
||||
groups := gvList{}
|
||||
groups := handler3.OpenAPIV3Discovery{}
|
||||
if err := json.Unmarshal(writer.data, &groups); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return groups.Paths, nil
|
||||
return &groups, nil
|
||||
}
|
||||
return nil, fmt.Errorf("Error, could not get list of group versions for APIService")
|
||||
}
|
||||
@ -103,14 +99,14 @@ func (s *Downloader) Download(handler http.Handler, etagList map[string]string)
|
||||
// Gracefully skip 404, assuming the server won't provide any spec
|
||||
return nil, nil
|
||||
case http.StatusOK:
|
||||
groups := gvList{}
|
||||
groups := handler3.OpenAPIV3Discovery{}
|
||||
aggregated := make(map[string]*SpecETag)
|
||||
|
||||
if err := json.Unmarshal(writer.data, &groups); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, path := range groups.Paths {
|
||||
reqPath := fmt.Sprintf("/openapi/v3/%s", path)
|
||||
for path, item := range groups.Paths {
|
||||
reqPath := item.ServerRelativeURL
|
||||
req, err := http.NewRequest("GET", reqPath, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -23,6 +23,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"k8s.io/kube-openapi/pkg/handler3"
|
||||
)
|
||||
|
||||
type handlerTest struct {
|
||||
@ -32,14 +34,18 @@ type handlerTest struct {
|
||||
|
||||
var _ http.Handler = handlerTest{}
|
||||
|
||||
var groupList = []string{"apis/group/version"}
|
||||
|
||||
func (h handlerTest) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// Create an APIService with a handler for one group/version
|
||||
group := make(map[string][]string)
|
||||
group["Paths"] = groupList
|
||||
j, _ := json.Marshal(group)
|
||||
if r.URL.Path == "/openapi/v3" {
|
||||
group := &handler3.OpenAPIV3Discovery{
|
||||
Paths: map[string]handler3.OpenAPIV3DiscoveryGroupVersion{
|
||||
"apis/group/version": {
|
||||
ServerRelativeURL: "/openapi/v3/apis/group/version?hash=" + h.etag,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
j, _ := json.Marshal(group)
|
||||
w.Write(j)
|
||||
return
|
||||
}
|
||||
@ -90,7 +96,12 @@ func TestDownloadOpenAPISpec(t *testing.T) {
|
||||
groups, err := s.OpenAPIV3Root(
|
||||
handlerTest{data: []byte(""), etag: ""})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, groups, groupList)
|
||||
if assert.NotNil(t, groups) {
|
||||
assert.Equal(t, len(groups.Paths), 1)
|
||||
if assert.Contains(t, groups.Paths, "apis/group/version") {
|
||||
assert.NotEmpty(t, groups.Paths["apis/group/version"].ServerRelativeURL)
|
||||
}
|
||||
}
|
||||
|
||||
// Test with eTag
|
||||
gvSpec, err := s.Download(
|
||||
|
@ -862,7 +862,7 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
2
staging/src/k8s.io/kube-proxy/go.sum
generated
2
staging/src/k8s.io/kube-proxy/go.sum
generated
@ -712,7 +712,7 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
2
staging/src/k8s.io/kube-scheduler/go.sum
generated
2
staging/src/k8s.io/kube-scheduler/go.sum
generated
@ -712,7 +712,7 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
@ -38,7 +38,7 @@ require (
|
||||
k8s.io/component-base v0.0.0
|
||||
k8s.io/component-helpers v0.0.0
|
||||
k8s.io/klog/v2 v2.60.1
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05
|
||||
k8s.io/metrics v0.0.0
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
|
||||
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2
|
||||
|
4
staging/src/k8s.io/kubectl/go.sum
generated
4
staging/src/k8s.io/kubectl/go.sum
generated
@ -858,8 +858,8 @@ k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
2
staging/src/k8s.io/kubelet/go.sum
generated
2
staging/src/k8s.io/kubelet/go.sum
generated
@ -716,7 +716,7 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
4
staging/src/k8s.io/legacy-cloud-providers/go.sum
generated
4
staging/src/k8s.io/legacy-cloud-providers/go.sum
generated
@ -943,8 +943,8 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
4
staging/src/k8s.io/metrics/go.sum
generated
4
staging/src/k8s.io/metrics/go.sum
generated
@ -622,8 +622,8 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
4
staging/src/k8s.io/pod-security-admission/go.sum
generated
4
staging/src/k8s.io/pod-security-admission/go.sum
generated
@ -952,8 +952,8 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
@ -12,7 +12,7 @@ require (
|
||||
k8s.io/client-go v0.0.0
|
||||
k8s.io/code-generator v0.0.0
|
||||
k8s.io/component-base v0.0.0
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
|
||||
)
|
||||
|
||||
|
4
staging/src/k8s.io/sample-apiserver/go.sum
generated
4
staging/src/k8s.io/sample-apiserver/go.sum
generated
@ -955,8 +955,8 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
4
staging/src/k8s.io/sample-cli-plugin/go.sum
generated
4
staging/src/k8s.io/sample-cli-plugin/go.sum
generated
@ -722,8 +722,8 @@ k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
4
staging/src/k8s.io/sample-controller/go.sum
generated
4
staging/src/k8s.io/sample-controller/go.sum
generated
@ -625,8 +625,8 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
|
||||
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 h1:M0Korml79JW27ndc6lxLxkNP8QVqdpBj0MIEZliKy8A=
|
||||
k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18/go.mod h1:p8bjuqy9+BWvBDEBjdeVYtX6kMWWg6OhY1V1jhC9MPI=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 h1:HC/IqdsYa2juhSDWUEO/MGxGcyUMSMX+aynZ5WcJZeg=
|
||||
k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05/go.mod h1:Z/45zLw8lUo4wdiUkI+v/ImEGAvu3WatcZl3lPMR4Rk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
|
@ -37,6 +37,7 @@ import (
|
||||
kubernetes "k8s.io/client-go/kubernetes"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||
"k8s.io/kube-openapi/pkg/handler3"
|
||||
"k8s.io/kube-openapi/pkg/spec3"
|
||||
apiservertesting "k8s.io/kubernetes/cmd/kube-apiserver/app/testing"
|
||||
"k8s.io/kubernetes/test/integration/framework"
|
||||
@ -135,19 +136,13 @@ func TestAddRemoveGroupVersion(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
openAPIv3GV := make(map[string][]string)
|
||||
openAPIv3GV := handler3.OpenAPIV3Discovery{}
|
||||
err = json.Unmarshal(jsonData, &openAPIv3GV)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
paths, ok := openAPIv3GV["Paths"]
|
||||
if !ok {
|
||||
t.Fatal("OpenAPI v3 format error")
|
||||
}
|
||||
|
||||
foundPath := false
|
||||
for _, path := range paths {
|
||||
for path := range openAPIv3GV.Paths {
|
||||
if strings.Contains(path, "mygroup.example.com/v1beta1") {
|
||||
foundPath = true
|
||||
}
|
||||
@ -177,17 +172,13 @@ func TestAddRemoveGroupVersion(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
openAPIv3GV = handler3.OpenAPIV3Discovery{}
|
||||
err = json.Unmarshal(jsonData, &openAPIv3GV)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
paths, ok = openAPIv3GV["Paths"]
|
||||
if !ok {
|
||||
t.Fatal("OpenAPI v3 format error")
|
||||
}
|
||||
|
||||
for _, path := range paths {
|
||||
for path := range openAPIv3GV.Paths {
|
||||
if strings.Contains(path, "mygroup.example.com") {
|
||||
t.Fatal("Unexpected group version mygroup.example.com in OpenAPI v3 discovery")
|
||||
}
|
||||
|
8
vendor/k8s.io/kube-openapi/pkg/builder3/openapi.go
generated
vendored
8
vendor/k8s.io/kube-openapi/pkg/builder3/openapi.go
generated
vendored
@ -19,14 +19,16 @@ package builder3
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
restful "github.com/emicklei/go-restful"
|
||||
|
||||
"k8s.io/kube-openapi/pkg/common"
|
||||
"k8s.io/kube-openapi/pkg/common/restfuladapter"
|
||||
"k8s.io/kube-openapi/pkg/spec3"
|
||||
"k8s.io/kube-openapi/pkg/util"
|
||||
"k8s.io/kube-openapi/pkg/validation/spec"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -392,6 +394,8 @@ func (o *openAPI) buildDefinitionRecursively(name string) error {
|
||||
schema.Extensions[k] = v
|
||||
}
|
||||
}
|
||||
// delete the embedded v2 schema if exists, otherwise no-op
|
||||
delete(schema.VendorExtensible.Extensions, common.ExtensionV2Schema)
|
||||
o.spec.Components.Schemas[uniqueName] = schema
|
||||
for _, v := range item.Dependencies {
|
||||
if err := o.buildDefinitionRecursively(v); err != nil {
|
||||
|
8
vendor/k8s.io/kube-openapi/pkg/common/common.go
generated
vendored
8
vendor/k8s.io/kube-openapi/pkg/common/common.go
generated
vendored
@ -218,3 +218,11 @@ func EmbedOpenAPIDefinitionIntoV2Extension(main OpenAPIDefinition, embedded Open
|
||||
main.Schema.Extensions[ExtensionV2Schema] = embedded.Schema
|
||||
return main
|
||||
}
|
||||
|
||||
// GenerateOpenAPIV3OneOfSchema generate the set of schemas that MUST be assigned to SchemaProps.OneOf
|
||||
func GenerateOpenAPIV3OneOfSchema(types []string) (oneOf []spec.Schema) {
|
||||
for _, t := range types {
|
||||
oneOf = append(oneOf, spec.Schema{SchemaProps: spec.SchemaProps{Type: []string{t}}})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
36
vendor/k8s.io/kube-openapi/pkg/generators/openapi.go
generated
vendored
36
vendor/k8s.io/kube-openapi/pkg/generators/openapi.go
generated
vendored
@ -279,6 +279,16 @@ func hasOpenAPIDefinitionMethods(t *types.Type) bool {
|
||||
return hasSchemaTypeMethod && hasOpenAPISchemaFormat
|
||||
}
|
||||
|
||||
func hasOpenAPIV3OneOfMethod(t *types.Type) bool {
|
||||
for mn, mt := range t.Methods {
|
||||
if mn != "OpenAPIV3OneOfTypes" {
|
||||
continue
|
||||
}
|
||||
return methodReturnsValue(mt, "", "[]string")
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// typeShortName returns short package name (e.g. the name x appears in package x definition) dot type name.
|
||||
func typeShortName(t *types.Type) string {
|
||||
return filepath.Base(t.Name.Package) + "." + t.Name.Name
|
||||
@ -348,6 +358,7 @@ func (g openAPITypeWriter) generate(t *types.Type) error {
|
||||
case types.Struct:
|
||||
hasV2Definition := hasOpenAPIDefinitionMethod(t)
|
||||
hasV2DefinitionTypeAndFormat := hasOpenAPIDefinitionMethods(t)
|
||||
hasV3OneOfTypes := hasOpenAPIV3OneOfMethod(t)
|
||||
hasV3Definition := hasOpenAPIV3DefinitionMethod(t)
|
||||
|
||||
if hasV2Definition || (hasV3Definition && !hasV2DefinitionTypeAndFormat) {
|
||||
@ -369,6 +380,28 @@ func (g openAPITypeWriter) generate(t *types.Type) error {
|
||||
"},\n"+
|
||||
"})\n}\n\n", args)
|
||||
return nil
|
||||
case hasV2DefinitionTypeAndFormat && hasV3OneOfTypes:
|
||||
// generate v3 def.
|
||||
g.Do("return common.EmbedOpenAPIDefinitionIntoV2Extension($.OpenAPIDefinition|raw${\n"+
|
||||
"Schema: spec.Schema{\n"+
|
||||
"SchemaProps: spec.SchemaProps{\n", args)
|
||||
g.generateDescription(t.CommentLines)
|
||||
g.Do("OneOf:common.GenerateOpenAPIV3OneOfSchema($.type|raw${}.OpenAPIV3OneOfTypes()),\n"+
|
||||
"Format:$.type|raw${}.OpenAPISchemaFormat(),\n"+
|
||||
"},\n"+
|
||||
"},\n"+
|
||||
"},", args)
|
||||
// generate v2 def.
|
||||
g.Do("$.OpenAPIDefinition|raw${\n"+
|
||||
"Schema: spec.Schema{\n"+
|
||||
"SchemaProps: spec.SchemaProps{\n", args)
|
||||
g.generateDescription(t.CommentLines)
|
||||
g.Do("Type:$.type|raw${}.OpenAPISchemaType(),\n"+
|
||||
"Format:$.type|raw${}.OpenAPISchemaFormat(),\n"+
|
||||
"},\n"+
|
||||
"},\n"+
|
||||
"})\n}\n\n", args)
|
||||
return nil
|
||||
case hasV2DefinitionTypeAndFormat:
|
||||
g.Do("return $.OpenAPIDefinition|raw${\n"+
|
||||
"Schema: spec.Schema{\n"+
|
||||
@ -380,6 +413,9 @@ func (g openAPITypeWriter) generate(t *types.Type) error {
|
||||
"},\n"+
|
||||
"}\n}\n\n", args)
|
||||
return nil
|
||||
case hasV3OneOfTypes:
|
||||
// having v3 oneOf types without custom v2 type or format does not make sense.
|
||||
return fmt.Errorf("type %q has v3 one of types but not v2 type or format", t.Name)
|
||||
}
|
||||
g.Do("return $.OpenAPIDefinition|raw${\nSchema: spec.Schema{\nSchemaProps: spec.SchemaProps{\n", args)
|
||||
g.generateDescription(t.CommentLines)
|
||||
|
39
vendor/k8s.io/kube-openapi/pkg/handler/handler.go
generated
vendored
39
vendor/k8s.io/kube-openapi/pkg/handler/handler.go
generated
vendored
@ -19,9 +19,12 @@ package handler
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"crypto/sha512"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mime"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -48,6 +51,13 @@ const (
|
||||
mimePbGz = "application/x-gzip"
|
||||
)
|
||||
|
||||
func computeETag(data []byte) string {
|
||||
if data == nil {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("%X", sha512.Sum512(data))
|
||||
}
|
||||
|
||||
// OpenAPIService is the service responsible for serving OpenAPI spec. It has
|
||||
// the ability to safely change the spec while serving it.
|
||||
type OpenAPIService struct {
|
||||
@ -58,6 +68,7 @@ type OpenAPIService struct {
|
||||
|
||||
jsonCache handler.HandlerCache
|
||||
protoCache handler.HandlerCache
|
||||
etagCache handler.HandlerCache
|
||||
}
|
||||
|
||||
func init() {
|
||||
@ -78,21 +89,29 @@ func NewOpenAPIService(spec *spec.Swagger) (*OpenAPIService, error) {
|
||||
func (o *OpenAPIService) getSwaggerBytes() ([]byte, string, time.Time, error) {
|
||||
o.rwMutex.RLock()
|
||||
defer o.rwMutex.RUnlock()
|
||||
specBytes, etag, err := o.jsonCache.Get()
|
||||
specBytes, err := o.jsonCache.Get()
|
||||
if err != nil {
|
||||
return nil, "", time.Time{}, err
|
||||
}
|
||||
return specBytes, etag, o.lastModified, nil
|
||||
etagBytes, err := o.etagCache.Get()
|
||||
if err != nil {
|
||||
return nil, "", time.Time{}, err
|
||||
}
|
||||
return specBytes, string(etagBytes), o.lastModified, nil
|
||||
}
|
||||
|
||||
func (o *OpenAPIService) getSwaggerPbBytes() ([]byte, string, time.Time, error) {
|
||||
o.rwMutex.RLock()
|
||||
defer o.rwMutex.RUnlock()
|
||||
specPb, etag, err := o.protoCache.Get()
|
||||
specPb, err := o.protoCache.Get()
|
||||
if err != nil {
|
||||
return nil, "", time.Time{}, err
|
||||
}
|
||||
return specPb, etag, o.lastModified, nil
|
||||
etagBytes, err := o.etagCache.Get()
|
||||
if err != nil {
|
||||
return nil, "", time.Time{}, err
|
||||
}
|
||||
return specPb, string(etagBytes), o.lastModified, nil
|
||||
}
|
||||
|
||||
func (o *OpenAPIService) UpdateSpec(openapiSpec *spec.Swagger) (err error) {
|
||||
@ -102,12 +121,19 @@ func (o *OpenAPIService) UpdateSpec(openapiSpec *spec.Swagger) (err error) {
|
||||
return json.Marshal(openapiSpec)
|
||||
})
|
||||
o.protoCache = o.protoCache.New(func() ([]byte, error) {
|
||||
json, _, err := o.jsonCache.Get()
|
||||
json, err := o.jsonCache.Get()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ToProtoBinary(json)
|
||||
})
|
||||
o.etagCache = o.etagCache.New(func() ([]byte, error) {
|
||||
json, err := o.jsonCache.Get()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return []byte(computeETag(json)), nil
|
||||
})
|
||||
o.lastModified = time.Now()
|
||||
|
||||
return nil
|
||||
@ -220,7 +246,8 @@ func (o *OpenAPIService) RegisterOpenAPIVersionedService(servePath string, handl
|
||||
return
|
||||
}
|
||||
}
|
||||
w.Header().Set("Etag", etag)
|
||||
// ETag must be enclosed in double quotes: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag
|
||||
w.Header().Set("Etag", strconv.Quote(etag))
|
||||
// ServeContent will take care of caching using eTag.
|
||||
http.ServeContent(w, r, servePath, lastModified, bytes.NewReader(data))
|
||||
return
|
||||
|
114
vendor/k8s.io/kube-openapi/pkg/handler3/handler.go
generated
vendored
114
vendor/k8s.io/kube-openapi/pkg/handler3/handler.go
generated
vendored
@ -23,7 +23,10 @@ import (
|
||||
"fmt"
|
||||
"mime"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@ -49,9 +52,21 @@ const (
|
||||
subTypeJSON = "json"
|
||||
)
|
||||
|
||||
// OpenAPIV3Discovery is the format of the Discovery document for OpenAPI V3
|
||||
// It maps Discovery paths to their corresponding URLs with a hash parameter included
|
||||
type OpenAPIV3Discovery struct {
|
||||
Paths map[string]OpenAPIV3DiscoveryGroupVersion `json:"paths"`
|
||||
}
|
||||
|
||||
// OpenAPIV3DiscoveryGroupVersion includes information about a group version and URL
|
||||
// for accessing the OpenAPI. The URL includes a hash parameter to support client side caching
|
||||
type OpenAPIV3DiscoveryGroupVersion struct {
|
||||
// Path is an absolute path of an OpenAPI V3 document in the form of /openapi/v3/apis/apps/v1?hash=014fbff9a07c
|
||||
ServerRelativeURL string `json:"serverRelativeURL"`
|
||||
}
|
||||
|
||||
// OpenAPIService is the service responsible for serving OpenAPI spec. It has
|
||||
// the ability to safely change the spec while serving it.
|
||||
// OpenAPI V3 currently does not use the lazy marshaling strategy that OpenAPI V2 is using
|
||||
type OpenAPIService struct {
|
||||
// rwMutex protects All members of this service.
|
||||
rwMutex sync.RWMutex
|
||||
@ -66,6 +81,7 @@ type OpenAPIV3Group struct {
|
||||
|
||||
pbCache handler.HandlerCache
|
||||
jsonCache handler.HandlerCache
|
||||
etagCache handler.HandlerCache
|
||||
}
|
||||
|
||||
func init() {
|
||||
@ -75,7 +91,18 @@ func init() {
|
||||
}
|
||||
|
||||
func computeETag(data []byte) string {
|
||||
return fmt.Sprintf("\"%X\"", sha512.Sum512(data))
|
||||
if data == nil {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("%X", sha512.Sum512(data))
|
||||
}
|
||||
|
||||
func constructServerRelativeURL(gvString, etag string) string {
|
||||
u := url.URL{Path: path.Join("/openapi/v3", gvString)}
|
||||
query := url.Values{}
|
||||
query.Set("hash", etag)
|
||||
u.RawQuery = query.Encode()
|
||||
return u.String()
|
||||
}
|
||||
|
||||
// NewOpenAPIService builds an OpenAPIService starting with the given spec.
|
||||
@ -96,10 +123,17 @@ func (o *OpenAPIService) getGroupBytes() ([]byte, error) {
|
||||
}
|
||||
|
||||
sort.Strings(keys)
|
||||
group := make(map[string][]string)
|
||||
group["Paths"] = keys
|
||||
|
||||
j, err := json.Marshal(group)
|
||||
discovery := &OpenAPIV3Discovery{Paths: make(map[string]OpenAPIV3DiscoveryGroupVersion)}
|
||||
for gvString, groupVersion := range o.v3Schema {
|
||||
etagBytes, err := groupVersion.etagCache.Get()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
discovery.Paths[gvString] = OpenAPIV3DiscoveryGroupVersion{
|
||||
ServerRelativeURL: constructServerRelativeURL(gvString, string(etagBytes)),
|
||||
}
|
||||
}
|
||||
j, err := json.Marshal(discovery)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -114,11 +148,19 @@ func (o *OpenAPIService) getSingleGroupBytes(getType string, group string) ([]by
|
||||
return nil, "", time.Now(), fmt.Errorf("Cannot find CRD group %s", group)
|
||||
}
|
||||
if getType == subTypeJSON {
|
||||
specBytes, etag, err := v.jsonCache.Get()
|
||||
return specBytes, etag, v.lastModified, err
|
||||
specBytes, err := v.jsonCache.Get()
|
||||
if err != nil {
|
||||
return nil, "", v.lastModified, err
|
||||
}
|
||||
etagBytes, err := v.etagCache.Get()
|
||||
return specBytes, string(etagBytes), v.lastModified, err
|
||||
} else if getType == subTypeProtobuf {
|
||||
specPb, etag, err := v.pbCache.Get()
|
||||
return specPb, etag, v.lastModified, err
|
||||
specPb, err := v.pbCache.Get()
|
||||
if err != nil {
|
||||
return nil, "", v.lastModified, err
|
||||
}
|
||||
etagBytes, err := v.etagCache.Get()
|
||||
return specPb, string(etagBytes), v.lastModified, err
|
||||
}
|
||||
return nil, "", time.Now(), fmt.Errorf("Invalid accept clause %s", getType)
|
||||
}
|
||||
@ -127,15 +169,10 @@ func (o *OpenAPIService) UpdateGroupVersion(group string, openapi *spec3.OpenAPI
|
||||
o.rwMutex.Lock()
|
||||
defer o.rwMutex.Unlock()
|
||||
|
||||
specBytes, err := json.Marshal(openapi)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, ok := o.v3Schema[group]; !ok {
|
||||
o.v3Schema[group] = &OpenAPIV3Group{}
|
||||
}
|
||||
return o.v3Schema[group].UpdateSpec(specBytes)
|
||||
return o.v3Schema[group].UpdateSpec(openapi)
|
||||
}
|
||||
|
||||
func (o *OpenAPIService) DeleteGroupVersion(group string) {
|
||||
@ -192,7 +229,26 @@ func (o *OpenAPIService) HandleGroupVersion(w http.ResponseWriter, r *http.Reque
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
w.Header().Set("Etag", etag)
|
||||
// ETag must be enclosed in double quotes: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag
|
||||
w.Header().Set("Etag", strconv.Quote(etag))
|
||||
|
||||
if hash := r.URL.Query().Get("hash"); hash != "" {
|
||||
if hash != etag {
|
||||
u := constructServerRelativeURL(group, etag)
|
||||
http.Redirect(w, r, u, 301)
|
||||
return
|
||||
}
|
||||
// The Vary header is required because the Accept header can
|
||||
// change the contents returned. This prevents clients from caching
|
||||
// protobuf as JSON and vice versa.
|
||||
w.Header().Set("Vary", "Accept")
|
||||
|
||||
// Only set these headers when a hash is given.
|
||||
w.Header().Set("Cache-Control", "public, immutable")
|
||||
// Set the Expires directive to the maximum value of one year from the request,
|
||||
// effectively indicating that the cache never expires.
|
||||
w.Header().Set("Expires", time.Now().AddDate(1, 0, 0).Format(time.RFC1123))
|
||||
}
|
||||
http.ServeContent(w, r, "", lastModified, bytes.NewReader(data))
|
||||
return
|
||||
}
|
||||
@ -207,16 +263,28 @@ func (o *OpenAPIService) RegisterOpenAPIV3VersionedService(servePath string, han
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *OpenAPIV3Group) UpdateSpec(specBytes []byte) (err error) {
|
||||
func (o *OpenAPIV3Group) UpdateSpec(openapi *spec3.OpenAPI) (err error) {
|
||||
o.rwMutex.Lock()
|
||||
defer o.rwMutex.Unlock()
|
||||
|
||||
o.pbCache = o.pbCache.New(func() ([]byte, error) {
|
||||
return ToV3ProtoBinary(specBytes)
|
||||
})
|
||||
|
||||
o.jsonCache = o.jsonCache.New(func() ([]byte, error) {
|
||||
return specBytes, nil
|
||||
return json.Marshal(openapi)
|
||||
})
|
||||
o.pbCache = o.pbCache.New(func() ([]byte, error) {
|
||||
json, err := o.jsonCache.Get()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ToV3ProtoBinary(json)
|
||||
})
|
||||
// TODO: This forces a json marshal of corresponding group-versions.
|
||||
// We should look to replace this with a faster hashing mechanism.
|
||||
o.etagCache = o.etagCache.New(func() ([]byte, error) {
|
||||
json, err := o.jsonCache.Get()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return []byte(computeETag(json)), nil
|
||||
})
|
||||
o.lastModified = time.Now()
|
||||
return nil
|
||||
|
19
vendor/k8s.io/kube-openapi/pkg/internal/handler/handler_cache.go
generated
vendored
19
vendor/k8s.io/kube-openapi/pkg/internal/handler/handler_cache.go
generated
vendored
@ -17,31 +17,22 @@ limitations under the License.
|
||||
package handler
|
||||
|
||||
import (
|
||||
"crypto/sha512"
|
||||
"fmt"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func computeETag(data []byte) string {
|
||||
if data == nil {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("\"%X\"", sha512.Sum512(data))
|
||||
}
|
||||
|
||||
// HandlerCache represents an OpenAPI v2/v3 marshaling cache.
|
||||
// HandlerCache represents a lazy cache for generating a byte array
|
||||
// It is used to lazily marshal OpenAPI v2/v3 and lazily generate the ETag
|
||||
type HandlerCache struct {
|
||||
BuildCache func() ([]byte, error)
|
||||
once sync.Once
|
||||
bytes []byte
|
||||
etag string
|
||||
err error
|
||||
}
|
||||
|
||||
// Get either returns the cached value or calls BuildCache() once before caching and returning
|
||||
// its results. If BuildCache returns an error, the last valid value for the cache (from prior
|
||||
// calls to New()) is used instead if possible.
|
||||
func (c *HandlerCache) Get() ([]byte, string, error) {
|
||||
func (c *HandlerCache) Get() ([]byte, error) {
|
||||
c.once.Do(func() {
|
||||
bytes, err := c.BuildCache()
|
||||
// if there is an error updating the cache, there can be situations where
|
||||
@ -51,10 +42,9 @@ func (c *HandlerCache) Get() ([]byte, string, error) {
|
||||
if c.err == nil {
|
||||
// don't override previous spec if we had an error
|
||||
c.bytes = bytes
|
||||
c.etag = computeETag(c.bytes)
|
||||
}
|
||||
})
|
||||
return c.bytes, c.etag, c.err
|
||||
return c.bytes, c.err
|
||||
}
|
||||
|
||||
// New creates a new HandlerCache for situations where a cache refresh is needed.
|
||||
@ -62,7 +52,6 @@ func (c *HandlerCache) Get() ([]byte, string, error) {
|
||||
func (c *HandlerCache) New(cacheBuilder func() ([]byte, error)) HandlerCache {
|
||||
return HandlerCache{
|
||||
bytes: c.bytes,
|
||||
etag: c.etag,
|
||||
BuildCache: cacheBuilder,
|
||||
}
|
||||
}
|
||||
|
324
vendor/k8s.io/kube-openapi/pkg/util/proto/document_v3.go
generated
vendored
Normal file
324
vendor/k8s.io/kube-openapi/pkg/util/proto/document_v3.go
generated
vendored
Normal file
@ -0,0 +1,324 @@
|
||||
/*
|
||||
Copyright 2022 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.
|
||||
*/
|
||||
|
||||
package proto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
openapi_v3 "github.com/google/gnostic/openapiv3"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// Temporary parse implementation to be used until gnostic->kube-openapi conversion
|
||||
// is possible.
|
||||
func NewOpenAPIV3Data(doc *openapi_v3.Document) (Models, error) {
|
||||
definitions := Definitions{
|
||||
models: map[string]Schema{},
|
||||
}
|
||||
|
||||
schemas := doc.GetComponents().GetSchemas()
|
||||
if schemas == nil {
|
||||
return &definitions, nil
|
||||
}
|
||||
|
||||
// Save the list of all models first. This will allow us to
|
||||
// validate that we don't have any dangling reference.
|
||||
for _, namedSchema := range schemas.GetAdditionalProperties() {
|
||||
definitions.models[namedSchema.GetName()] = nil
|
||||
}
|
||||
|
||||
// Now, parse each model. We can validate that references exists.
|
||||
for _, namedSchema := range schemas.GetAdditionalProperties() {
|
||||
path := NewPath(namedSchema.GetName())
|
||||
val := namedSchema.GetValue()
|
||||
|
||||
if val == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if schema, err := definitions.ParseV3SchemaOrReference(namedSchema.GetValue(), &path); err != nil {
|
||||
return nil, err
|
||||
} else if schema != nil {
|
||||
// Schema may be nil if we hit incompleteness in the conversion,
|
||||
// but not a fatal error
|
||||
definitions.models[namedSchema.GetName()] = schema
|
||||
}
|
||||
}
|
||||
|
||||
return &definitions, nil
|
||||
}
|
||||
|
||||
func (d *Definitions) ParseV3SchemaReference(s *openapi_v3.Reference, path *Path) (Schema, error) {
|
||||
base := &BaseSchema{
|
||||
Description: s.Description,
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(s.GetXRef(), "#/components/schemas") {
|
||||
// Only resolve references to components/schemas. We may add support
|
||||
// later for other in-spec paths, but otherwise treat unrecognized
|
||||
// refs as arbitrary/unknown values.
|
||||
return &Arbitrary{
|
||||
BaseSchema: *base,
|
||||
}, nil
|
||||
}
|
||||
|
||||
reference := strings.TrimPrefix(s.GetXRef(), "#/components/schemas/")
|
||||
if _, ok := d.models[reference]; !ok {
|
||||
return nil, newSchemaError(path, "unknown model in reference: %q", reference)
|
||||
}
|
||||
|
||||
return &Ref{
|
||||
BaseSchema: BaseSchema{
|
||||
Description: s.Description,
|
||||
},
|
||||
reference: reference,
|
||||
definitions: d,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (d *Definitions) ParseV3SchemaOrReference(s *openapi_v3.SchemaOrReference, path *Path) (Schema, error) {
|
||||
var schema Schema
|
||||
var err error
|
||||
|
||||
switch v := s.GetOneof().(type) {
|
||||
case *openapi_v3.SchemaOrReference_Reference:
|
||||
// Any references stored in #!/components/... are bound to refer
|
||||
// to external documents. This API does not support such a
|
||||
// feature.
|
||||
//
|
||||
// In the weird case that this is a reference to a schema that is
|
||||
// not external, we attempt to parse anyway
|
||||
schema, err = d.ParseV3SchemaReference(v.Reference, path)
|
||||
case *openapi_v3.SchemaOrReference_Schema:
|
||||
schema, err = d.ParseSchemaV3(v.Schema, path)
|
||||
default:
|
||||
panic("unexpected type")
|
||||
}
|
||||
|
||||
return schema, err
|
||||
}
|
||||
|
||||
// ParseSchema creates a walkable Schema from an openapi v3 schema. While
|
||||
// this function is public, it doesn't leak through the interface.
|
||||
func (d *Definitions) ParseSchemaV3(s *openapi_v3.Schema, path *Path) (Schema, error) {
|
||||
switch s.GetType() {
|
||||
case object:
|
||||
for _, extension := range s.GetSpecificationExtension() {
|
||||
if extension.Name == "x-kuberentes-group-version-kind" {
|
||||
// Objects with x-kubernetes-group-version-kind are always top
|
||||
// level types.
|
||||
return d.parseV3Kind(s, path)
|
||||
}
|
||||
}
|
||||
|
||||
if len(s.GetProperties().GetAdditionalProperties()) > 0 {
|
||||
return d.parseV3Kind(s, path)
|
||||
}
|
||||
return d.parseV3Map(s, path)
|
||||
case array:
|
||||
return d.parseV3Array(s, path)
|
||||
case String, Number, Integer, Boolean:
|
||||
return d.parseV3Primitive(s, path)
|
||||
default:
|
||||
return d.parseV3Arbitrary(s, path)
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Definitions) parseV3Kind(s *openapi_v3.Schema, path *Path) (Schema, error) {
|
||||
if s.GetType() != object {
|
||||
return nil, newSchemaError(path, "invalid object type")
|
||||
} else if s.GetProperties() == nil {
|
||||
return nil, newSchemaError(path, "object doesn't have properties")
|
||||
}
|
||||
|
||||
fields := map[string]Schema{}
|
||||
fieldOrder := []string{}
|
||||
|
||||
for _, namedSchema := range s.GetProperties().GetAdditionalProperties() {
|
||||
var err error
|
||||
name := namedSchema.GetName()
|
||||
path := path.FieldPath(name)
|
||||
fields[name], err = d.ParseV3SchemaOrReference(namedSchema.GetValue(), &path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fieldOrder = append(fieldOrder, name)
|
||||
}
|
||||
|
||||
base, err := d.parseV3BaseSchema(s, path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Kind{
|
||||
BaseSchema: *base,
|
||||
RequiredFields: s.GetRequired(),
|
||||
Fields: fields,
|
||||
FieldOrder: fieldOrder,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (d *Definitions) parseV3Arbitrary(s *openapi_v3.Schema, path *Path) (Schema, error) {
|
||||
base, err := d.parseV3BaseSchema(s, path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Arbitrary{
|
||||
BaseSchema: *base,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (d *Definitions) parseV3Primitive(s *openapi_v3.Schema, path *Path) (Schema, error) {
|
||||
switch s.GetType() {
|
||||
case String: // do nothing
|
||||
case Number: // do nothing
|
||||
case Integer: // do nothing
|
||||
case Boolean: // do nothing
|
||||
default:
|
||||
// Unsupported primitive type. Treat as arbitrary type
|
||||
return d.parseV3Arbitrary(s, path)
|
||||
}
|
||||
|
||||
base, err := d.parseV3BaseSchema(s, path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Primitive{
|
||||
BaseSchema: *base,
|
||||
Type: s.GetType(),
|
||||
Format: s.GetFormat(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (d *Definitions) parseV3Array(s *openapi_v3.Schema, path *Path) (Schema, error) {
|
||||
if s.GetType() != array {
|
||||
return nil, newSchemaError(path, `array should have type "array"`)
|
||||
} else if len(s.GetItems().GetSchemaOrReference()) != 1 {
|
||||
// This array can have multiple types in it (or no types at all)
|
||||
// This is not supported by this conversion.
|
||||
// Just return an arbitrary type
|
||||
return d.parseV3Arbitrary(s, path)
|
||||
}
|
||||
|
||||
sub, err := d.ParseV3SchemaOrReference(s.GetItems().GetSchemaOrReference()[0], path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base, err := d.parseV3BaseSchema(s, path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Array{
|
||||
BaseSchema: *base,
|
||||
SubType: sub,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// We believe the schema is a map, verify and return a new schema
|
||||
func (d *Definitions) parseV3Map(s *openapi_v3.Schema, path *Path) (Schema, error) {
|
||||
if s.GetType() != object {
|
||||
return nil, newSchemaError(path, "invalid object type")
|
||||
}
|
||||
var sub Schema
|
||||
|
||||
switch p := s.GetAdditionalProperties().GetOneof().(type) {
|
||||
case *openapi_v3.AdditionalPropertiesItem_Boolean:
|
||||
// What does this boolean even mean?
|
||||
base, err := d.parseV3BaseSchema(s, path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sub = &Arbitrary{
|
||||
BaseSchema: *base,
|
||||
}
|
||||
case *openapi_v3.AdditionalPropertiesItem_SchemaOrReference:
|
||||
if schema, err := d.ParseV3SchemaOrReference(p.SchemaOrReference, path); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
sub = schema
|
||||
}
|
||||
case nil:
|
||||
// no subtype?
|
||||
sub = &Arbitrary{}
|
||||
default:
|
||||
panic("unrecognized type " + reflect.TypeOf(p).Name())
|
||||
}
|
||||
|
||||
base, err := d.parseV3BaseSchema(s, path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Map{
|
||||
BaseSchema: *base,
|
||||
SubType: sub,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func parseV3Interface(def *yaml.Node) (interface{}, error) {
|
||||
if def == nil {
|
||||
return nil, nil
|
||||
}
|
||||
var i interface{}
|
||||
if err := def.Decode(&i); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (d *Definitions) parseV3BaseSchema(s *openapi_v3.Schema, path *Path) (*BaseSchema, error) {
|
||||
if s == nil {
|
||||
return nil, fmt.Errorf("cannot initializae BaseSchema from nil")
|
||||
}
|
||||
|
||||
def, err := parseV3Interface(s.GetDefault().ToRawInfo())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &BaseSchema{
|
||||
Description: s.GetDescription(),
|
||||
Default: def,
|
||||
Extensions: SpecificationExtensionToMap(s.GetSpecificationExtension()),
|
||||
Path: *path,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func SpecificationExtensionToMap(e []*openapi_v3.NamedAny) map[string]interface{} {
|
||||
values := map[string]interface{}{}
|
||||
|
||||
for _, na := range e {
|
||||
if na.GetName() == "" || na.GetValue() == nil {
|
||||
continue
|
||||
}
|
||||
if na.GetValue().GetYaml() == "" {
|
||||
continue
|
||||
}
|
||||
var value interface{}
|
||||
err := yaml.Unmarshal([]byte(na.GetValue().GetYaml()), &value)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
values[na.GetName()] = value
|
||||
}
|
||||
|
||||
return values
|
||||
}
|
71
vendor/k8s.io/kube-openapi/pkg/util/proto/testing/openapi_v3.go
generated
vendored
Normal file
71
vendor/k8s.io/kube-openapi/pkg/util/proto/testing/openapi_v3.go
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
Copyright 2022 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.
|
||||
*/
|
||||
|
||||
package testing
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
openapi_v3 "github.com/google/gnostic/openapiv3"
|
||||
)
|
||||
|
||||
type FakeV3 struct {
|
||||
Path string
|
||||
|
||||
lock sync.Mutex
|
||||
documents map[string]*openapi_v3.Document
|
||||
errors map[string]error
|
||||
}
|
||||
|
||||
func (f *FakeV3) OpenAPIV3Schema(groupVersion string) (*openapi_v3.Document, error) {
|
||||
f.lock.Lock()
|
||||
defer f.lock.Unlock()
|
||||
|
||||
if existing, ok := f.documents[groupVersion]; ok {
|
||||
return existing, nil
|
||||
} else if existingError, ok := f.errors[groupVersion]; ok {
|
||||
return nil, existingError
|
||||
}
|
||||
|
||||
_, err := os.Stat(f.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
spec, err := ioutil.ReadFile(filepath.Join(f.Path, groupVersion+".json"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if f.documents == nil {
|
||||
f.documents = make(map[string]*openapi_v3.Document)
|
||||
}
|
||||
|
||||
if f.errors == nil {
|
||||
f.errors = make(map[string]error)
|
||||
}
|
||||
|
||||
result, err := openapi_v3.ParseDocument(spec)
|
||||
if err != nil {
|
||||
f.errors[groupVersion] = err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
f.documents[groupVersion] = result
|
||||
return result, nil
|
||||
}
|
4
vendor/modules.txt
vendored
4
vendor/modules.txt
vendored
@ -2051,7 +2051,7 @@ k8s.io/kube-aggregator/pkg/registry/apiservice/rest
|
||||
# k8s.io/kube-controller-manager v0.0.0 => ./staging/src/k8s.io/kube-controller-manager
|
||||
## explicit
|
||||
k8s.io/kube-controller-manager/config/v1alpha1
|
||||
# k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18 => k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18
|
||||
# k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05 => k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05
|
||||
## explicit
|
||||
k8s.io/kube-openapi/cmd/openapi-gen
|
||||
k8s.io/kube-openapi/cmd/openapi-gen/args
|
||||
@ -2736,7 +2736,7 @@ sigs.k8s.io/yaml
|
||||
# k8s.io/klog/v2 => k8s.io/klog/v2 v2.60.1
|
||||
# k8s.io/kube-aggregator => ./staging/src/k8s.io/kube-aggregator
|
||||
# k8s.io/kube-controller-manager => ./staging/src/k8s.io/kube-controller-manager
|
||||
# k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20220316025549-ddc66922ab18
|
||||
# k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20220323210520-29d726468e05
|
||||
# k8s.io/kube-proxy => ./staging/src/k8s.io/kube-proxy
|
||||
# k8s.io/kube-scheduler => ./staging/src/k8s.io/kube-scheduler
|
||||
# k8s.io/kubectl => ./staging/src/k8s.io/kubectl
|
||||
|
Loading…
Reference in New Issue
Block a user