From 0a853fec930282ad180ca460b7f9b4eccee19f8e Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Sat, 10 Jun 2017 18:39:35 -0700 Subject: [PATCH] hack/lib/init.sh util.sh update-codegen.sh --- hack/lib/util.sh | 23 +++++++++++++--- hack/update-codegen.sh | 60 ++++++++++++++++++++++++++++-------------- 2 files changed, 60 insertions(+), 23 deletions(-) diff --git a/hack/lib/util.sh b/hack/lib/util.sh index 50f6b55572..c32f47c77f 100755 --- a/hack/lib/util.sh +++ b/hack/lib/util.sh @@ -313,7 +313,27 @@ kube::util::analytics-link() { # * Special handling for groups suffixed with ".k8s.io": foo.k8s.io/v1 -> apis/foo/v1 # * Very special handling for when both group and version are "": / -> api kube::util::group-version-to-pkg-path() { + staging_apis=( + $( + pushd ${KUBE_ROOT}/staging/src/k8s.io/api > /dev/null + find . -name types.go | xargs -n1 dirname | sed "s|\./||g" | sort + popd > /dev/null + ) + ) + local group_version="$1" + + if [[ " ${staging_apis[@]} " =~ " ${group_version/.*k8s.io/} " ]]; then + echo "vendor/k8s.io/api/${group_version/.*k8s.io/}" + return + fi + + # "v1" is the API GroupVersion + if [[ "${group_version}" == "v1" ]]; then + echo "vendor/k8s.io/api/core/v1" + return + fi + # Special cases first. # TODO(lavalamp): Simplify this by moving pkg/api/v1 and splitting pkg/api, # moving the results to pkg/apis/api. @@ -322,9 +342,6 @@ kube::util::group-version-to-pkg-path() { __internal) echo "pkg/api" ;; - v1) - echo "pkg/api/v1" - ;; federation/v1beta1) echo "federation/apis/federation/v1beta1" ;; diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 5a8e25be18..a9cef38cf1 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -44,6 +44,7 @@ for gv in "${GROUP_VERSIONS[@]}"; do # add items, but strip off any leading apis/ you find to match command expectations api_dir=$(kube::util::group-version-to-pkg-path "${gv}") nopkg_dir=${api_dir#pkg/} + nopkg_dir=${nopkg_dir#vendor/k8s.io/api/} pkg_dir=${nopkg_dir#apis/} # skip groups that aren't being served, clients for these don't matter @@ -60,37 +61,55 @@ GV_DIRS_CSV=$(IFS=',';echo "${GV_DIRS[*]// /,}";IFS=$) # update- and verify- scripts. ${clientgen} "$@" ${clientgen} -t "$@" -${clientgen} --clientset-name="clientset" --input="${GV_DIRS_CSV}" "$@" +${clientgen} --clientset-name="clientset" --input-base="k8s.io/kubernetes/vendor/k8s.io/api" --input="${GV_DIRS_CSV}" "$@" # Clientgen for federation clientset. ${clientgen} --clientset-name=federation_internalclientset --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --input="../../federation/apis/federation/","api/","extensions/","batch/","autoscaling/" --included-types-overrides="api/Service,api/Namespace,extensions/ReplicaSet,api/Secret,extensions/Ingress,extensions/Deployment,extensions/DaemonSet,api/ConfigMap,api/Event,batch/Job,autoscaling/HorizontalPodAutoscaler" "$@" -${clientgen} --clientset-name=federation_clientset --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --input="../../federation/apis/federation/v1beta1","api/v1","extensions/v1beta1","batch/v1","autoscaling/v1" --included-types-overrides="api/v1/Service,api/v1/Namespace,extensions/v1beta1/ReplicaSet,api/v1/Secret,extensions/v1beta1/Ingress,extensions/v1beta1/Deployment,extensions/v1beta1/DaemonSet,api/v1/ConfigMap,api/v1/Event,batch/v1/Job,autoscaling/v1/HorizontalPodAutoscaler" "$@" +${clientgen} --clientset-name=federation_clientset --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --input-base="k8s.io/kubernetes/vendor/k8s.io/api" --input="../../../federation/apis/federation/v1beta1","core/v1","extensions/v1beta1","batch/v1","autoscaling/v1" --included-types-overrides="core/v1/Service,core/v1/Namespace,extensions/v1beta1/ReplicaSet,core/v1/Secret,extensions/v1beta1/Ingress,extensions/v1beta1/Deployment,extensions/v1beta1/DaemonSet,core/v1/ConfigMap,core/v1/Event,batch/v1/Job,autoscaling/v1/HorizontalPodAutoscaler" "$@" -LISTERGEN_APIS=( +listergen_kubernetes_apis=( pkg/api -pkg/api/v1 -$( - cd ${KUBE_ROOT} - find pkg/apis -name types.go | xargs -n1 dirname | sort -) -) - -LISTERGEN_APIS=(${LISTERGEN_APIS[@]/#/k8s.io/kubernetes/}) -LISTERGEN_APIS=$(IFS=,; echo "${LISTERGEN_APIS[*]}") - -${listergen} --input-dirs "${LISTERGEN_APIS}" "$@" - -INFORMERGEN_APIS=( -pkg/api -pkg/api/v1 $( cd ${KUBE_ROOT} # because client-gen doesn't do policy/v1alpha1, we have to skip it too find pkg/apis -name types.go | xargs -n1 dirname | sort | grep -v pkg.apis.policy.v1alpha1 ) ) +listergen_kubernetes_apis=(${listergen_kubernetes_apis[@]/#/k8s.io/kubernetes/}) +listergen_staging_apis=( +$( + cd ${KUBE_ROOT}/staging/src + # because client-gen doesn't do policy/v1alpha1, we have to skip it too + find k8s.io/api -name types.go | xargs -n1 dirname | sort | grep -v pkg.apis.policy.v1alpha1 +) +) + +LISTERGEN_APIS=$(IFS=,; echo "${listergen_kubernetes_apis[*]}") +LISTERGEN_APIS+="," +LISTERGEN_APIS+=$(IFS=,; echo "${listergen_staging_apis[*]}") +${listergen} --input-dirs "${LISTERGEN_APIS}" "$@" + +informergen_kubernetes_apis=( +pkg/api +$( + cd ${KUBE_ROOT} + # because client-gen doesn't do policy/v1alpha1, we have to skip it too + find pkg/apis -name types.go | xargs -n1 dirname | sort | grep -v pkg.apis.policy.v1alpha1 +) +) +informergen_kubernetes_apis=(${informergen_kubernetes_apis[@]/#/k8s.io/kubernetes/}) +informergen_staging_apis=( +$( + cd ${KUBE_ROOT}/staging/src + # because client-gen doesn't do policy/v1alpha1, we have to skip it too + find k8s.io/api -name types.go | xargs -n1 dirname | sort | grep -v pkg.apis.policy.v1alpha1 +) +) + + +INFORMERGEN_APIS=$(IFS=,; echo "${informergen_kubernetes_apis[*]}") +INFORMERGEN_APIS+="," +INFORMERGEN_APIS+=$(IFS=,; echo "${informergen_staging_apis[*]}") -INFORMERGEN_APIS=(${INFORMERGEN_APIS[@]/#/k8s.io/kubernetes/}) -INFORMERGEN_APIS=$(IFS=,; echo "${INFORMERGEN_APIS[*]}") ${informergen} \ --input-dirs "${INFORMERGEN_APIS}" \ --versioned-clientset-package k8s.io/kubernetes/pkg/client/clientset_generated/clientset \ @@ -98,6 +117,7 @@ ${informergen} \ --listers-package k8s.io/kubernetes/pkg/client/listers \ "$@" + # You may add additional calls of code generators like set-gen above. # call generation on sub-project for now