Bumping k8s dependencies to 1.13

This commit is contained in:
Cheng Xing
2018-11-16 14:08:25 -08:00
parent 305407125c
commit b4c0b68ec7
8002 changed files with 884099 additions and 276228 deletions

View File

@@ -1,13 +1,15 @@
cluster/images/etcd-version-monitor
cmd/cloud-controller-manager/app/apis/config/v1alpha1
cmd/hyperkube
cmd/kube-apiserver/app
cmd/kube-controller-manager/app
cmd/kube-proxy/app
cmd/kube-scheduler/app
cmd/kubeadm/app
cmd/kubeadm/app/apis/kubeadm/v1alpha2
cmd/kubeadm/app/apis/kubeadm/v1alpha3
cmd/kubeadm/app/util/config
cmd/kubeadm/app/util/system
cmd/kubelet/app
cmd/kubelet/app/options
cmd/kubemark
@@ -21,6 +23,8 @@ pkg/api/v1/pod
pkg/api/v1/resource
pkg/apis/abac
pkg/apis/abac/latest
pkg/apis/abac/v0
pkg/apis/abac/v1beta1
pkg/apis/admission
pkg/apis/admission/v1beta1
pkg/apis/admissionregistration
@@ -28,6 +32,9 @@ pkg/apis/admissionregistration/v1alpha1
pkg/apis/admissionregistration/v1beta1
pkg/apis/admissionregistration/validation
pkg/apis/apps
pkg/apis/apps/v1
pkg/apis/apps/v1beta1
pkg/apis/apps/v1beta2
pkg/apis/apps/validation
pkg/apis/authentication
pkg/apis/authentication/v1
@@ -37,17 +44,24 @@ pkg/apis/authorization/v1
pkg/apis/authorization/v1beta1
pkg/apis/authorization/validation
pkg/apis/autoscaling
pkg/apis/autoscaling/v1
pkg/apis/autoscaling/v2beta1
pkg/apis/autoscaling/v2beta2
pkg/apis/autoscaling/validation
pkg/apis/batch
pkg/apis/batch/v1
pkg/apis/batch/v1beta1
pkg/apis/batch/v2alpha1
pkg/apis/batch/validation
pkg/apis/certificates
pkg/apis/certificates/v1beta1
pkg/apis/certificates/validation
pkg/apis/componentconfig
pkg/apis/componentconfig/v1alpha1
pkg/apis/coordination
pkg/apis/coordination/v1beta1
pkg/apis/core
pkg/apis/core/helper
pkg/apis/core/helper/qos
pkg/apis/core/v1
pkg/apis/core/v1/helper
pkg/apis/core/v1/helper/qos
pkg/apis/core/v1/validation
@@ -55,14 +69,18 @@ pkg/apis/core/validation
pkg/apis/events
pkg/apis/events/v1beta1
pkg/apis/extensions
pkg/apis/extensions/v1beta1
pkg/apis/extensions/validation
pkg/apis/imagepolicy
pkg/apis/imagepolicy/v1alpha1
pkg/apis/networking
pkg/apis/networking/v1
pkg/apis/policy
pkg/apis/policy/v1beta1
pkg/apis/policy/validation
pkg/apis/rbac
pkg/apis/rbac/v1
pkg/apis/rbac/v1alpha1
pkg/apis/rbac/v1beta1
pkg/apis/rbac/validation
pkg/apis/scheduling
@@ -72,8 +90,10 @@ pkg/apis/settings
pkg/apis/settings/v1alpha1
pkg/apis/storage
pkg/apis/storage/util
pkg/apis/storage/v1
pkg/apis/storage/v1/util
pkg/apis/storage/v1alpha1
pkg/apis/storage/v1beta1
pkg/apis/storage/v1beta1/util
pkg/auth/authorizer/abac
pkg/capabilities
@@ -88,7 +108,9 @@ pkg/cloudprovider/providers/gce/cloud
pkg/cloudprovider/providers/ovirt
pkg/cloudprovider/providers/photon
pkg/cloudprovider/providers/vsphere
pkg/cloudprovider/providers/vsphere/vclib
pkg/controller
pkg/controller/apis/config/v1alpha1
pkg/controller/bootstrap
pkg/controller/certificates
pkg/controller/certificates/approver
@@ -136,6 +158,7 @@ pkg/kubeapiserver/authorizer/modes
pkg/kubeapiserver/options
pkg/kubeapiserver/server
pkg/kubectl
pkg/kubectl/apps
pkg/kubectl/cmd
pkg/kubectl/cmd/auth
pkg/kubectl/cmd/config
@@ -147,23 +170,22 @@ pkg/kubectl/cmd/templates
pkg/kubectl/cmd/testing
pkg/kubectl/cmd/util
pkg/kubectl/cmd/util/editor
pkg/kubectl/cmd/util/openapi
pkg/kubectl/cmd/util/sanity
pkg/kubectl/cmd/wait
pkg/kubectl/genericclioptions
pkg/kubectl/genericclioptions/printers
pkg/kubectl/genericclioptions/resource
pkg/kubectl/metricsutil
pkg/kubectl/util
pkg/kubectl/util/slice
pkg/kubelet
pkg/kubelet/apis
pkg/kubelet/apis/config
pkg/kubelet/apis/config/v1beta1
pkg/kubelet/apis/cri/runtime/v1alpha2
pkg/kubelet/apis/cri/testing
pkg/kubelet/apis/deviceplugin/v1alpha
pkg/kubelet/apis/deviceplugin/v1beta1
pkg/kubelet/apis/kubeletconfig
pkg/kubelet/apis/kubeletconfig/v1beta1
pkg/kubelet/apis/pluginregistration/v1alpha1
pkg/kubelet/apis/pluginregistration/v1beta1
pkg/kubelet/cadvisor
pkg/kubelet/cadvisor/testing
pkg/kubelet/checkpoint
@@ -175,6 +197,7 @@ pkg/kubelet/cm/devicemanager/checkpoint
pkg/kubelet/cm/util
pkg/kubelet/config
pkg/kubelet/configmap
pkg/kubelet/container
pkg/kubelet/container/testing
pkg/kubelet/custommetrics
pkg/kubelet/dockershim
@@ -232,8 +255,8 @@ pkg/probe/exec
pkg/probe/http
pkg/probe/tcp
pkg/proxy
pkg/proxy/apis/kubeproxyconfig
pkg/proxy/apis/kubeproxyconfig/v1alpha1
pkg/proxy/apis/config
pkg/proxy/apis/config/v1alpha1
pkg/proxy/iptables
pkg/proxy/userspace
pkg/proxy/util
@@ -270,6 +293,7 @@ pkg/registry/batch/rest
pkg/registry/certificates/certificates
pkg/registry/certificates/certificates/storage
pkg/registry/certificates/rest
pkg/registry/coordination/rest
pkg/registry/core/componentstatus
pkg/registry/core/endpoint/storage
pkg/registry/core/event
@@ -311,7 +335,6 @@ pkg/registry/networking/rest
pkg/registry/policy/poddisruptionbudget
pkg/registry/policy/poddisruptionbudget/storage
pkg/registry/policy/rest
pkg/registry/rbac
pkg/registry/rbac/clusterrole
pkg/registry/rbac/clusterrole/policybased
pkg/registry/rbac/clusterrolebinding
@@ -332,6 +355,7 @@ pkg/registry/storage/rest
pkg/registry/storage/storageclass
pkg/registry/storage/storageclass/storage
pkg/routes
pkg/scheduler/apis/config/v1alpha1
pkg/security/apparmor
pkg/security/podsecuritypolicy
pkg/security/podsecuritypolicy/group
@@ -340,6 +364,7 @@ pkg/security/podsecuritypolicy/selinux
pkg/security/podsecuritypolicy/user
pkg/security/podsecuritypolicy/util
pkg/securitycontext
pkg/serviceaccount
pkg/ssh
pkg/util/bandwidth
pkg/util/config
@@ -353,7 +378,6 @@ pkg/util/initsystem
pkg/util/ipconfig
pkg/util/iptables
pkg/util/iptables/testing
pkg/util/keymutex
pkg/util/labels
pkg/util/mount
pkg/util/netsh/testing
@@ -376,14 +400,13 @@ pkg/util/threading
pkg/util/tolerations
pkg/util/workqueue/prometheus
pkg/version/verflag
pkg/volume
pkg/volume/aws_ebs
pkg/volume/azure_dd
pkg/volume/azure_file
pkg/volume/cephfs
pkg/volume/configmap
pkg/volume/csi
pkg/volume/csi/fake
pkg/volume/csi/labelmanager
pkg/volume/empty_dir
pkg/volume/fc
pkg/volume/flexvolume
@@ -419,11 +442,13 @@ plugin/pkg/admission/podtolerationrestriction/apis/podtolerationrestriction/v1al
plugin/pkg/admission/resourcequota
plugin/pkg/admission/resourcequota/apis/resourcequota
plugin/pkg/admission/resourcequota/apis/resourcequota/v1alpha1
plugin/pkg/admission/resourcequota/apis/resourcequota/v1beta1
plugin/pkg/admission/security
plugin/pkg/admission/security/podsecuritypolicy
plugin/pkg/admission/serviceaccount
plugin/pkg/auth/authorizer/node
plugin/pkg/auth/authorizer/rbac
plugin/pkg/auth/authorizer/rbac/bootstrappolicy
staging/src/k8s.io/api/admission/v1beta1
staging/src/k8s.io/api/admissionregistration/v1alpha1
staging/src/k8s.io/api/admissionregistration/v1beta1
@@ -436,10 +461,12 @@ staging/src/k8s.io/api/authorization/v1
staging/src/k8s.io/api/authorization/v1beta1
staging/src/k8s.io/api/autoscaling/v1
staging/src/k8s.io/api/autoscaling/v2beta1
staging/src/k8s.io/api/autoscaling/v2beta2
staging/src/k8s.io/api/batch/v1
staging/src/k8s.io/api/batch/v1beta1
staging/src/k8s.io/api/batch/v2alpha1
staging/src/k8s.io/api/certificates/v1beta1
staging/src/k8s.io/api/coordination/v1beta1
staging/src/k8s.io/api/core/v1
staging/src/k8s.io/api/events/v1beta1
staging/src/k8s.io/api/extensions/v1beta1
@@ -464,15 +491,18 @@ staging/src/k8s.io/apiextensions-apiserver/pkg/cmd/server
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/finalizer
staging/src/k8s.io/apiextensions-apiserver/pkg/controller/status
staging/src/k8s.io/apiextensions-apiserver/pkg/features
staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresource
staging/src/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition
staging/src/k8s.io/apiextensions-apiserver/test/integration/testserver
staging/src/k8s.io/apimachinery/pkg/api/apitesting/fuzzer
staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip
staging/src/k8s.io/apimachinery/pkg/api/meta
staging/src/k8s.io/apimachinery/pkg/api/testing/fuzzer
staging/src/k8s.io/apimachinery/pkg/api/testing/roundtrip
staging/src/k8s.io/apimachinery/pkg/api/resource
staging/src/k8s.io/apimachinery/pkg/api/validation
staging/src/k8s.io/apimachinery/pkg/api/validation/path
staging/src/k8s.io/apimachinery/pkg/apis/config/v1alpha1
staging/src/k8s.io/apimachinery/pkg/apis/meta/fuzzer
staging/src/k8s.io/apimachinery/pkg/apis/meta/internalversion
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/validation
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1beta1
@@ -480,8 +510,10 @@ staging/src/k8s.io/apimachinery/pkg/apis/testapigroup
staging/src/k8s.io/apimachinery/pkg/apis/testapigroup/v1
staging/src/k8s.io/apimachinery/pkg/conversion
staging/src/k8s.io/apimachinery/pkg/labels
staging/src/k8s.io/apimachinery/pkg/runtime
staging/src/k8s.io/apimachinery/pkg/runtime/schema
staging/src/k8s.io/apimachinery/pkg/runtime/serializer
staging/src/k8s.io/apimachinery/pkg/runtime/serializer/json
staging/src/k8s.io/apimachinery/pkg/runtime/serializer/protobuf
staging/src/k8s.io/apimachinery/pkg/runtime/serializer/recognizer
staging/src/k8s.io/apimachinery/pkg/runtime/serializer/streaming
@@ -511,11 +543,12 @@ staging/src/k8s.io/apimachinery/pkg/util/uuid
staging/src/k8s.io/apimachinery/pkg/util/validation
staging/src/k8s.io/apimachinery/pkg/util/wait
staging/src/k8s.io/apimachinery/pkg/util/yaml
staging/src/k8s.io/apimachinery/pkg/watch
staging/src/k8s.io/apiserver/pkg/admission
staging/src/k8s.io/apiserver/pkg/admission/configuration
staging/src/k8s.io/apiserver/pkg/admission/initializer
staging/src/k8s.io/apiserver/pkg/admission/plugin/initialization
staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/config
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/config/apis/webhookadmission
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/config/apis/webhookadmission/v1alpha1
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/mutating
@@ -524,9 +557,11 @@ staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/validating
staging/src/k8s.io/apiserver/pkg/apis/apiserver
staging/src/k8s.io/apiserver/pkg/apis/apiserver/v1alpha1
staging/src/k8s.io/apiserver/pkg/apis/audit
staging/src/k8s.io/apiserver/pkg/apis/audit/v1
staging/src/k8s.io/apiserver/pkg/apis/audit/v1alpha1
staging/src/k8s.io/apiserver/pkg/apis/audit/v1beta1
staging/src/k8s.io/apiserver/pkg/apis/audit/validation
staging/src/k8s.io/apiserver/pkg/apis/config/v1alpha1
staging/src/k8s.io/apiserver/pkg/apis/example
staging/src/k8s.io/apiserver/pkg/apis/example/v1
staging/src/k8s.io/apiserver/pkg/apis/example2
@@ -591,8 +626,13 @@ staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/oidc
staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/tokentest
staging/src/k8s.io/apiserver/plugin/pkg/authenticator/token/webhook
staging/src/k8s.io/apiserver/plugin/pkg/authorizer/webhook
staging/src/k8s.io/cli-runtime/pkg/genericclioptions
staging/src/k8s.io/cli-runtime/pkg/genericclioptions/printers
staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource
staging/src/k8s.io/client-go/deprecated-dynamic
staging/src/k8s.io/client-go/discovery
staging/src/k8s.io/client-go/discovery/cached
staging/src/k8s.io/client-go/discovery/fake
staging/src/k8s.io/client-go/dynamic
staging/src/k8s.io/client-go/dynamic/fake
staging/src/k8s.io/client-go/examples/workqueue
@@ -613,6 +653,7 @@ staging/src/k8s.io/client-go/kubernetes/typed/policy/v1beta1/fake
staging/src/k8s.io/client-go/plugin/pkg/client/auth/oidc
staging/src/k8s.io/client-go/rest
staging/src/k8s.io/client-go/rest/fake
staging/src/k8s.io/client-go/rest/watch
staging/src/k8s.io/client-go/scale
staging/src/k8s.io/client-go/scale/fake
staging/src/k8s.io/client-go/scale/scheme
@@ -624,6 +665,7 @@ staging/src/k8s.io/client-go/scale/scheme/extensionsint
staging/src/k8s.io/client-go/scale/scheme/extensionsv1beta1
staging/src/k8s.io/client-go/scale/scheme/extensionsv1beta1
staging/src/k8s.io/client-go/testing
staging/src/k8s.io/client-go/tools/auth
staging/src/k8s.io/client-go/tools/cache
staging/src/k8s.io/client-go/tools/cache/testing
staging/src/k8s.io/client-go/tools/clientcmd
@@ -643,6 +685,7 @@ staging/src/k8s.io/client-go/util/integer
staging/src/k8s.io/client-go/util/jsonpath
staging/src/k8s.io/client-go/util/retry
staging/src/k8s.io/client-go/util/testing
staging/src/k8s.io/client-go/util/workqueue
staging/src/k8s.io/code-generator/cmd/client-gen/args
staging/src/k8s.io/code-generator/cmd/client-gen/generators/fake
staging/src/k8s.io/code-generator/cmd/client-gen/generators/scheme
@@ -660,8 +703,11 @@ staging/src/k8s.io/kube-aggregator/pkg/controllers/autoregister
staging/src/k8s.io/kube-aggregator/pkg/controllers/status
staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice
staging/src/k8s.io/kube-aggregator/pkg/registry/apiservice/etcd
staging/src/k8s.io/kube-proxy/config/v1alpha1
staging/src/k8s.io/kubelet/config/v1beta1
staging/src/k8s.io/metrics/pkg/apis/custom_metrics
staging/src/k8s.io/metrics/pkg/apis/custom_metrics/v1beta1
staging/src/k8s.io/metrics/pkg/apis/custom_metrics/v1beta2
staging/src/k8s.io/metrics/pkg/apis/external_metrics
staging/src/k8s.io/metrics/pkg/apis/external_metrics/v1beta1
staging/src/k8s.io/metrics/pkg/apis/metrics
@@ -669,8 +715,11 @@ staging/src/k8s.io/metrics/pkg/apis/metrics/v1alpha1
staging/src/k8s.io/metrics/pkg/apis/metrics/v1beta1
staging/src/k8s.io/metrics/pkg/client/custom_metrics
staging/src/k8s.io/metrics/pkg/client/custom_metrics/fake
staging/src/k8s.io/metrics/pkg/client/custom_metrics/scheme
staging/src/k8s.io/metrics/pkg/client/external_metrics
staging/src/k8s.io/metrics/pkg/client/external_metrics/fake
staging/src/k8s.io/sample-apiserver/pkg/admission/plugin/banflunder
staging/src/k8s.io/sample-apiserver/pkg/admission/wardleinitializer
staging/src/k8s.io/sample-apiserver/pkg/apis/wardle
staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1
staging/src/k8s.io/sample-apiserver/pkg/apiserver
@@ -701,6 +750,8 @@ test/e2e/scalability
test/e2e/scheduling
test/e2e/servicecatalog
test/e2e/storage
test/e2e/storage/drivers
test/e2e/storage/testsuites
test/e2e/storage/utils
test/e2e/storage/vsphere
test/e2e/ui
@@ -714,7 +765,6 @@ test/e2e_node/environment
test/e2e_node/remote
test/e2e_node/runner/remote
test/e2e_node/services
test/e2e_node/system
test/images/net/nat
test/images/netexec
test/images/nettest

View File

@@ -10,6 +10,7 @@ reviewers:
- sttts
- gmarek
- vishh
- spiffxp
approvers:
- cblecker
- deads2k
@@ -28,3 +29,4 @@ approvers:
- liggitt
- soltysh # for sig-cli related stuff
- dims # for local-up-cluster related files
- spiffxp

View File

@@ -93,13 +93,11 @@ def file_passes(filename, refs, regexs):
else:
ref = refs[basename]
# remove build tags from the top of Go files
if extension == "go" or extension =="generatego":
# remove extra content from the top of files
if extension == "go" or extension == "generatego":
p = regexs["go_build_constraints"]
(data, found) = p.subn("", data, 1)
# remove shebang from the top of shell files
if extension == "sh":
elif extension == "sh":
p = regexs["shebang"]
(data, found) = p.subn("", data, 1)

View File

@@ -59,8 +59,11 @@ REQUIRED_BINS=(
"github.com/jteeuwen/go-bindata/go-bindata"
"github.com/tools/godep"
"github.com/client9/misspell/cmd/misspell"
"github.com/cloudflare/cfssl/cmd/cfssl"
"github.com/cloudflare/cfssl/cmd/cfssljson"
"github.com/bazelbuild/bazel-gazelle/cmd/gazelle"
"github.com/kubernetes/repo-infra/kazel"
"k8s.io/kube-openapi/cmd/openapi-gen"
"./..."
)

View File

@@ -7,6 +7,7 @@
- k8s.io/kubernetes/pkg/fieldpath
- k8s.io/kubernetes/pkg/util
- k8s.io/api/core/v1
- k8s.io/utils/pointer
# the following are temporary and should go away. Think twice (or more) before adding anything here.
# Main goal: pkg/apis should be as self-contained as possible.
@@ -17,14 +18,14 @@
ignoredSubTrees:
- "./pkg/apis/core/validation"
- baseImportPath: "./pkg/kubectl/genericclioptions/"
- baseImportPath: "./vendor/k8s.io/cli-runtime/pkg/genericclioptions/"
allowedImports:
- k8s.io/apimachinery
- k8s.io/client-go
# TODO this one should be tightened. We depend on it for testing, but we should instead create our own scheme
- k8s.io/api/core/v1
- k8s.io/kubernetes/pkg/kubectl/genericclioptions/printers
- k8s.io/kubernetes/pkg/kubectl/genericclioptions/resource
- k8s.io/cli-runtime/pkg/genericclioptions/printers
- k8s.io/cli-runtime/pkg/genericclioptions/resource
- baseImportPath: "./vendor/k8s.io/apimachinery/"
allowedImports:
@@ -79,6 +80,7 @@
- k8s.io/apiserver
- k8s.io/client-go
- k8s.io/kube-openapi
- k8s.io/utils
- baseImportPath: "./vendor/k8s.io/metrics/"
allowedImports:
@@ -114,5 +116,34 @@
- baseImportPath: "./vendor/k8s.io/kube-openapi/"
allowedImports:
- k8s.io/apimachinery
- k8s.io/kube-openapi
- k8s.io/gengo
- baseImportPath: "./vendor/k8s.io/sample-cli-plugin/"
allowedImports:
- k8s.io/api
- k8s.io/cli-runtime
- k8s.io/client-go
- k8s.io/sample-cli-plugin
- baseImportPath: "./vendor/k8s.io/kube-controller-manager/"
allowedImports:
- k8s.io/apimachinery
- k8s.io/apiserver
- k8s.io/utils
- baseImportPath: "./vendor/k8s.io/kube-proxy/"
allowedImports:
- k8s.io/apimachinery
- baseImportPath: "./vendor/k8s.io/kube-scheduler/"
allowedImports:
- k8s.io/apimachinery
- k8s.io/apiserver
- k8s.io/utils
- baseImportPath: "./vendor/k8s.io/kubelet/"
allowedImports:
- k8s.io/api
- k8s.io/apimachinery

View File

@@ -16,14 +16,16 @@
# A set of helpers for starting/running etcd for tests
ETCD_VERSION=${ETCD_VERSION:-3.2.18}
ETCD_VERSION=${ETCD_VERSION:-3.2.24}
ETCD_HOST=${ETCD_HOST:-127.0.0.1}
ETCD_PORT=${ETCD_PORT:-2379}
export KUBE_INTEGRATION_ETCD_URL="http://${ETCD_HOST}:${ETCD_PORT}"
kube::etcd::validate() {
# validate if in path
command -v etcd >/dev/null || {
kube::log::usage "etcd must be in your PATH"
kube::log::info "You can use 'hack/install-etcd.sh' to install a copy in third_party/."
exit 1
}
@@ -71,15 +73,15 @@ kube::etcd::start() {
if [[ -d "${ARTIFACTS_DIR:-}" ]]; then
ETCD_LOGFILE="${ARTIFACTS_DIR}/etcd.$(uname -n).$(id -un).log.DEBUG.$(date +%Y%m%d-%H%M%S).$$"
else
ETCD_LOGFILE=/dev/null
ETCD_LOGFILE=${ETCD_LOGFILE:-"/dev/null"}
fi
kube::log::info "etcd --advertise-client-urls http://${ETCD_HOST}:${ETCD_PORT} --data-dir ${ETCD_DIR} --listen-client-urls http://${ETCD_HOST}:${ETCD_PORT} --debug > \"${ETCD_LOGFILE}\" 2>/dev/null"
etcd --advertise-client-urls http://${ETCD_HOST}:${ETCD_PORT} --data-dir ${ETCD_DIR} --listen-client-urls http://${ETCD_HOST}:${ETCD_PORT} --debug 2> "${ETCD_LOGFILE}" >/dev/null &
kube::log::info "etcd --advertise-client-urls ${KUBE_INTEGRATION_ETCD_URL} --data-dir ${ETCD_DIR} --listen-client-urls http://${ETCD_HOST}:${ETCD_PORT} --debug > \"${ETCD_LOGFILE}\" 2>/dev/null"
etcd --advertise-client-urls ${KUBE_INTEGRATION_ETCD_URL} --data-dir ${ETCD_DIR} --listen-client-urls ${KUBE_INTEGRATION_ETCD_URL} --debug 2> "${ETCD_LOGFILE}" >/dev/null &
ETCD_PID=$!
echo "Waiting for etcd to come up."
kube::util::wait_for_url "http://${ETCD_HOST}:${ETCD_PORT}/v2/machines" "etcd: " 0.25 80
curl -fs -X PUT "http://${ETCD_HOST}:${ETCD_PORT}/v2/keys/_test"
kube::util::wait_for_url "${KUBE_INTEGRATION_ETCD_URL}/v2/machines" "etcd: " 0.25 80
curl -fs -X PUT "${KUBE_INTEGRATION_ETCD_URL}/v2/keys/_test"
}
kube::etcd::stop() {
@@ -102,11 +104,13 @@ kube::etcd::cleanup() {
kube::etcd::install() {
(
local os
cd "${KUBE_ROOT}/third_party"
if [[ $(readlink etcd) == etcd-v${ETCD_VERSION}-* ]]; then
os=$(uname | tr "[:upper:]" "[:lower:]")
if [[ $(readlink etcd) == etcd-v${ETCD_VERSION}-${os}-* ]]; then
return # already installed
fi
if [[ $(uname) == "Darwin" ]]; then
if [[ ${os} == "darwin" ]]; then
download_file="etcd-v${ETCD_VERSION}-darwin-amd64.zip"
url="https://github.com/coreos/etcd/releases/download/v${ETCD_VERSION}/${download_file}"
kube::util::download_file "${url}" "${download_file}"
@@ -119,6 +123,7 @@ kube::etcd::install() {
kube::util::download_file "${url}" "${download_file}"
tar xzf "${download_file}"
ln -fns "etcd-v${ETCD_VERSION}-linux-amd64" etcd
rm "${download_file}"
fi
kube::log::info "etcd v${ETCD_VERSION} installed. To use:"
kube::log::info "export PATH=$(pwd)/etcd:\${PATH}"

View File

@@ -30,7 +30,6 @@ kube::golang::server_targets() {
cmd/kubeadm
cmd/hyperkube
cmd/kube-scheduler
vendor/k8s.io/kube-aggregator
vendor/k8s.io/apiextensions-apiserver
cluster/gce/gci/mounter
)
@@ -41,6 +40,23 @@ IFS=" " read -ra KUBE_SERVER_TARGETS <<< "$(kube::golang::server_targets)"
readonly KUBE_SERVER_TARGETS
readonly KUBE_SERVER_BINARIES=("${KUBE_SERVER_TARGETS[@]##*/}")
# The set of server targets we build docker images for
kube::golang::server_image_targets() {
# NOTE: this contains cmd targets for kube::build::get_docker_wrapped_binaries
local targets=(
cmd/cloud-controller-manager
cmd/kube-apiserver
cmd/kube-controller-manager
cmd/kube-scheduler
cmd/kube-proxy
)
echo "${targets[@]}"
}
IFS=" " read -ra KUBE_SERVER_IMAGE_TARGETS <<< "$(kube::golang::server_image_targets)"
readonly KUBE_SERVER_IMAGE_TARGETS
readonly KUBE_SERVER_IMAGE_BINARIES=("${KUBE_SERVER_IMAGE_TARGETS[@]##*/}")
# The set of server targets that we are only building for Kubernetes nodes
# If you update this list, please also update build/BUILD.
kube::golang::node_targets() {
@@ -208,11 +224,19 @@ readonly KUBE_STATIC_LIBRARIES=(
kube-controller-manager
kube-scheduler
kube-proxy
kube-aggregator
kubeadm
kubectl
)
# Fully-qualified package names that we want to instrument for coverage information.
readonly KUBE_COVERAGE_INSTRUMENTED_PACKAGES=(
k8s.io/kubernetes/cmd/kube-apiserver
k8s.io/kubernetes/cmd/kube-controller-manager
k8s.io/kubernetes/cmd/kube-scheduler
k8s.io/kubernetes/cmd/kube-proxy
k8s.io/kubernetes/cmd/kubelet
)
# KUBE_CGO_OVERRIDES is a space-separated list of binaries which should be built
# with CGO enabled, assuming CGO is supported on the target platform.
# This overrides any entry in KUBE_STATIC_LIBRARIES.
@@ -443,6 +467,100 @@ kube::golang::outfile_for_binary() {
echo "${output_path}/${bin}"
}
# Argument: the name of a Kubernetes package.
# Returns 0 if the binary can be built with coverage, 1 otherwise.
# NB: this ignores whether coverage is globally enabled or not.
kube::golang::is_instrumented_package() {
return $(kube::util::array_contains "$1" "${KUBE_COVERAGE_INSTRUMENTED_PACKAGES[@]}")
}
# Argument: the name of a Kubernetes package (e.g. k8s.io/kubernetes/cmd/kube-scheduler)
# Echos the path to a dummy test used for coverage information.
kube::golang::path_for_coverage_dummy_test() {
local package="$1"
local path="${KUBE_GOPATH}/src/${package}"
local name=$(basename "${package}")
echo "$path/zz_generated_${name}_test.go"
}
# Argument: the name of a Kubernetes package (e.g. k8s.io/kubernetes/cmd/kube-scheduler).
# Creates a dummy unit test on disk in the source directory for the given package.
# This unit test will invoke the package's standard entry point when run.
kube::golang::create_coverage_dummy_test() {
local package="$1"
local name="$(basename "${package}")"
cat <<EOF > $(kube::golang::path_for_coverage_dummy_test "${package}")
package main
import (
"testing"
"k8s.io/kubernetes/pkg/util/coverage"
)
func TestMain(m *testing.M) {
// Get coverage running
coverage.InitCoverage("${name}")
// Go!
main()
// Make sure we actually write the profiling information to disk, if we make it here.
// On long-running services, or anything that calls os.Exit(), this is insufficient,
// so we also flush periodically with a default period of five seconds (configurable by
// the KUBE_COVERAGE_FLUSH_INTERVAL environment variable).
coverage.FlushCoverage()
}
EOF
}
# Argument: the name of a Kubernetes package (e.g. k8s.io/kubernetes/cmd/kube-scheduler).
# Deletes a test generated by kube::golang::create_coverage_dummy_test.
# It is not an error to call this for a nonexistent test.
kube::golang::delete_coverage_dummy_test() {
local package="$1"
rm -f $(kube::golang::path_for_coverage_dummy_test "${package}")
}
# Arguments: a list of kubernetes packages to build.
# Expected variables: ${build_args} should be set to an array of Go build arguments.
# In addition, ${package} and ${platform} should have been set earlier, and if
# ${build_with_coverage} is set, coverage instrumentation will be enabled.
#
# Invokes Go to actually build some packages. If coverage is disabled, simply invokes
# go install. If coverage is enabled, builds covered binaries using go test, temporarily
# producing the required unit test files and then cleaning up after itself.
# Non-covered binaries are then built using go install as usual.
kube::golang::build_some_binaries() {
if [[ -n "${build_with_coverage:-}" ]]; then
local -a uncovered=()
for package in "$@"; do
if kube::golang::is_instrumented_package "${package}"; then
V=2 kube::log::info "Building ${package} with coverage..."
kube::golang::create_coverage_dummy_test "${package}"
kube::util::trap_add "kube::golang::delete_coverage_dummy_test \"${package}\"" EXIT
go test -c -o "$(kube::golang::outfile_for_binary "${package}" "${platform}")" \
-covermode count \
-coverpkg k8s.io/... \
"${build_args[@]}" \
-tags coverage \
"${package}"
else
uncovered+=("${package}")
fi
done
if [[ "${#uncovered[@]}" != 0 ]]; then
V=2 kube::log::info "Building ${uncovered[@]} without coverage..."
go install "${build_args[@]}" "${uncovered[@]}"
else
V=2 kube::log::info "Nothing to build without coverage."
fi
else
V=2 kube::log::info "Coverage is disabled."
go install "${build_args[@]}" "$@"
fi
}
kube::golang::build_binaries_for_platform() {
local platform=$1
@@ -462,18 +580,24 @@ kube::golang::build_binaries_for_platform() {
fi
done
local -a build_args
if [[ "${#statics[@]}" != 0 ]]; then
CGO_ENABLED=0 go install -installsuffix static "${goflags[@]:+${goflags[@]}}" \
-gcflags "${gogcflags}" \
-ldflags "${goldflags}" \
"${statics[@]:+${statics[@]}}"
build_args=(
-installsuffix static
${goflags:+"${goflags[@]}"}
-gcflags "${gogcflags:-}"
-ldflags "${goldflags:-}"
)
CGO_ENABLED=0 kube::golang::build_some_binaries "${statics[@]}"
fi
if [[ "${#nonstatics[@]}" != 0 ]]; then
go install "${goflags[@]:+${goflags[@]}}" \
-gcflags "${gogcflags}" \
-ldflags "${goldflags}" \
"${nonstatics[@]:+${nonstatics[@]}}"
build_args=(
${goflags:+"${goflags[@]}"}
-gcflags "${gogcflags:-}"
-ldflags "${goldflags:-}"
)
kube::golang::build_some_binaries "${nonstatics[@]}"
fi
for test in "${tests[@]:+${tests[@]}}"; do
@@ -482,9 +606,9 @@ kube::golang::build_binaries_for_platform() {
mkdir -p "$(dirname ${outfile})"
go test -c \
"${goflags[@]:+${goflags[@]}}" \
-gcflags "${gogcflags}" \
-ldflags "${goldflags}" \
${goflags:+"${goflags[@]}"} \
-gcflags "${gogcflags:-}" \
-ldflags "${goldflags:-}" \
-o "${outfile}" \
"${testpkg}"
done
@@ -537,10 +661,11 @@ kube::golang::build_binaries() {
host_platform=$(kube::golang::host_platform)
# Use eval to preserve embedded quoted strings.
local goflags goldflags gogcflags
local goflags goldflags gogcflags build_with_coverage
eval "goflags=(${GOFLAGS:-})"
goldflags="${GOLDFLAGS:-} $(kube::version::ldflags)"
gogcflags="${GOGCFLAGS:-}"
build_with_coverage="${KUBE_BUILD_WITH_COVERAGE:-}"
local -a targets=()
local arg

View File

@@ -68,10 +68,12 @@ authorization.k8s.io/v1 \
authorization.k8s.io/v1beta1 \
autoscaling/v1 \
autoscaling/v2beta1 \
autoscaling/v2beta2 \
batch/v1 \
batch/v1beta1 \
batch/v2alpha1 \
certificates.k8s.io/v1beta1 \
coordination.k8s.io/v1beta1 \
extensions/v1beta1 \
events.k8s.io/v1beta1 \
imagepolicy.k8s.io/v1alpha1 \
@@ -178,4 +180,3 @@ kube::realpath() {
fi
kube::readlinkdashf "$1"
}

View File

@@ -18,6 +18,20 @@ kube::util::sortable_date() {
date "+%Y%m%d-%H%M%S"
}
# arguments: target, item1, item2, item3, ...
# returns 0 if target is in the given items, 1 otherwise.
kube::util::array_contains() {
local search="$1"
local element
shift
for element; do
if [[ "${element}" == "${search}" ]]; then
return 0
fi
done
return 1
}
kube::util::wait_for_url() {
local url=$1
local prefix=${2:-}
@@ -308,7 +322,7 @@ kube::util::gv-to-swagger-name() {
# Assumed vars:
# SWAGGER_API_PATH: Base path for swaggerapi on apiserver. Ex:
# http://localhost:8080/swaggerapi.
# SWAGGER_ROOT_DIR: Root dir where we want to to save the fetched spec.
# SWAGGER_ROOT_DIR: Root dir where we want to save the fetched spec.
# VERSIONS: Array of group versions to include in swagger spec.
kube::util::fetch-swagger-spec() {
for ver in ${VERSIONS}; do
@@ -435,7 +449,7 @@ kube::util::ensure_godep_version() {
fi
kube::log::status "Installing godep version ${GODEP_VERSION}"
go install ./vendor/github.com/tools/godep/
go install k8s.io/kubernetes/vendor/github.com/tools/godep/
if ! which godep >/dev/null 2>&1; then
kube::log::error "Can't find godep - is your GOPATH 'bin' in your PATH?"
kube::log::error " GOPATH: ${GOPATH}"
@@ -540,6 +554,7 @@ function kube::util::test_openssl_installed {
echo "Failed to run openssl. Please ensure openssl is installed"
exit 1
fi
OPENSSL_BIN=$(command -v openssl)
}
@@ -787,6 +802,8 @@ if [[ -z "${color_start-}" ]]; then
declare -r color_red="${color_start}0;31m"
declare -r color_yellow="${color_start}0;33m"
declare -r color_green="${color_start}0;32m"
declare -r color_blue="${color_start}1;34m"
declare -r color_cyan="${color_start}1;36m"
declare -r color_norm="${color_start}0m"
fi

View File

@@ -84,9 +84,6 @@ ENABLE_POD_PRIORITY_PREEMPTION=${ENABLE_POD_PRIORITY_PREEMPTION:-""}
# enable kubernetes dashboard
ENABLE_CLUSTER_DASHBOARD=${KUBE_ENABLE_CLUSTER_DASHBOARD:-false}
# enable audit log
ENABLE_APISERVER_BASIC_AUDIT=${ENABLE_APISERVER_BASIC_AUDIT:-false}
# RBAC Mode options
AUTHORIZATION_MODE=${AUTHORIZATION_MODE:-"Node,RBAC"}
KUBECONFIG_TOKEN=${KUBECONFIG_TOKEN:-""}
@@ -126,16 +123,6 @@ if [ "${CLOUD_PROVIDER}" == "openstack" ]; then
fi
fi
# load required kernel modules if proxy mode is set to "ipvs".
if [ "${KUBE_PROXY_MODE}" == "ipvs" ]; then
# If required kernel modules are not available, fall back to iptables.
sudo modprobe -a ip_vs ip_vs_rr ip_vs_wrr ip_vs_sh nf_conntrack_ipv4
if [[ $? -ne 0 ]]; then
echo "Required kernel modules for ipvs not found. Falling back to iptables mode."
KUBE_PROXY_MODE=iptables
fi
fi
# set feature gates if enable Pod priority and preemption
if [ "${ENABLE_POD_PRIORITY_PREEMPTION}" == true ]; then
FEATURE_GATES="$FEATURE_GATES,PodPriority=true"
@@ -237,7 +224,6 @@ CPU_CFS_QUOTA=${CPU_CFS_QUOTA:-true}
ENABLE_HOSTPATH_PROVISIONER=${ENABLE_HOSTPATH_PROVISIONER:-"false"}
CLAIM_BINDER_SYNC_PERIOD=${CLAIM_BINDER_SYNC_PERIOD:-"15s"} # current k8s default
ENABLE_CONTROLLER_ATTACH_DETACH=${ENABLE_CONTROLLER_ATTACH_DETACH:-"true"} # current default
KEEP_TERMINATED_POD_VOLUMES=${KEEP_TERMINATED_POD_VOLUMES:-"true"}
# This is the default dir and filename where the apiserver will generate a self-signed cert
# which should be able to be used as the CA to verify itself
CERT_DIR=${CERT_DIR:-"/var/run/kubernetes"}
@@ -254,6 +240,9 @@ if [[ ${CONTAINER_RUNTIME} == "docker" ]]; then
CGROUP_DRIVER=$(docker info | grep "Cgroup Driver:" | cut -f3- -d' ')
echo "Kubelet cgroup driver defaulted to use: ${CGROUP_DRIVER}"
fi
if [[ -f /var/log/docker.log && ! -f ${LOG_DIR}/docker.log ]]; then
ln -s /var/log/docker.log ${LOG_DIR}/docker.log
fi
fi
@@ -398,12 +387,12 @@ cleanup()
# a process dies unexpectedly.
function healthcheck {
if [[ -n "${APISERVER_PID-}" ]] && ! sudo kill -0 ${APISERVER_PID} 2>/dev/null; then
warning "API server terminated unexpectedly, see ${APISERVER_LOG}"
warning_log "API server terminated unexpectedly, see ${APISERVER_LOG}"
APISERVER_PID=
fi
if [[ -n "${CTLRMGR_PID-}" ]] && ! sudo kill -0 ${CTLRMGR_PID} 2>/dev/null; then
warning "kube-controller-manager terminated unexpectedly, see ${CTLRMGR_LOG}"
warning_log "kube-controller-manager terminated unexpectedly, see ${CTLRMGR_LOG}"
CTLRMGR_PID=
fi
@@ -411,36 +400,42 @@ function healthcheck {
# TODO (https://github.com/kubernetes/kubernetes/issues/62474): check health also in this case
:
elif [[ -n "${KUBELET_PID-}" ]] && ! sudo kill -0 ${KUBELET_PID} 2>/dev/null; then
warning "kubelet terminated unexpectedly, see ${KUBELET_LOG}"
warning_log "kubelet terminated unexpectedly, see ${KUBELET_LOG}"
KUBELET_PID=
fi
if [[ -n "${PROXY_PID-}" ]] && ! sudo kill -0 ${PROXY_PID} 2>/dev/null; then
warning "kube-proxy terminated unexpectedly, see ${PROXY_LOG}"
warning_log "kube-proxy terminated unexpectedly, see ${PROXY_LOG}"
PROXY_PID=
fi
if [[ -n "${SCHEDULER_PID-}" ]] && ! sudo kill -0 ${SCHEDULER_PID} 2>/dev/null; then
warning "scheduler terminated unexpectedly, see ${SCHEDULER_LOG}"
warning_log "scheduler terminated unexpectedly, see ${SCHEDULER_LOG}"
SCHEDULER_PID=
fi
if [[ -n "${ETCD_PID-}" ]] && ! sudo kill -0 ${ETCD_PID} 2>/dev/null; then
warning "etcd terminated unexpectedly"
warning_log "etcd terminated unexpectedly"
ETCD_PID=
fi
}
function warning {
function print_color {
message=$1
prefix=${2:+$2: } # add colon only if defined
color=${3:-1} # default is red
echo -n $(tput bold)$(tput setaf ${color})
echo "${prefix}${message}"
echo -n $(tput sgr0)
}
echo $(tput bold)$(tput setaf 1)
echo "WARNING: ${message}"
echo $(tput sgr0)
function warning_log {
print_color "$1" "W$(date "+%m%d %H:%M:%S")]" 1
}
function start_etcd {
echo "Starting etcd"
ETCD_LOGFILE=${LOG_DIR}/etcd.log
kube::etcd::start
}
@@ -477,25 +472,7 @@ function start_apiserver {
# Admission Controllers to invoke prior to persisting objects in cluster
#
# The order defined here dose not matter.
ENABLE_ADMISSION_PLUGINS=Initializers,LimitRanger,ServiceAccount${security_admission},DefaultStorageClass,DefaultTolerationSeconds,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota,StorageObjectInUseProtection
audit_arg=""
APISERVER_BASIC_AUDIT_LOG=""
if [[ "${ENABLE_APISERVER_BASIC_AUDIT:-}" = true ]]; then
# We currently only support enabling with a fixed path and with built-in log
# rotation "disabled" (large value) so it behaves like kube-apiserver.log.
# External log rotation should be set up the same as for kube-apiserver.log.
APISERVER_BASIC_AUDIT_LOG=/tmp/kube-apiserver-audit.log
audit_arg=" --audit-log-path=${APISERVER_BASIC_AUDIT_LOG}"
audit_arg+=" --audit-log-maxage=0"
audit_arg+=" --audit-log-maxbackup=0"
# Lumberjack doesn't offer any way to disable size-based rotation. It also
# has an in-memory counter that doesn't notice if you truncate the file.
# 2000000000 (in MiB) is a large number that fits in 31 bits. If the log
# grows at 10MiB/s (~30K QPS), it will rotate after ~6 years if apiserver
# never restarts. Please manually restart apiserver before this time.
audit_arg+=" --audit-log-maxsize=2000000000"
fi
ENABLE_ADMISSION_PLUGINS=LimitRanger,ServiceAccount${security_admission},DefaultStorageClass,DefaultTolerationSeconds,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota,StorageObjectInUseProtection
swagger_arg=""
if [[ "${ENABLE_SWAGGER_UI}" = true ]]; then
@@ -574,7 +551,7 @@ function start_apiserver {
fi
APISERVER_LOG=${LOG_DIR}/kube-apiserver.log
${CONTROLPLANE_SUDO} "${GO_OUT}/hyperkube" apiserver ${swagger_arg} ${audit_arg} ${authorizer_arg} ${priv_arg} ${runtime_config} \
${CONTROLPLANE_SUDO} "${GO_OUT}/hyperkube" apiserver ${swagger_arg} ${authorizer_arg} ${priv_arg} ${runtime_config} \
${cloud_config_arg} \
${advertise_address} \
${node_port_range} \
@@ -661,6 +638,7 @@ function start_controller_manager {
--kubeconfig "$CERT_DIR"/controller.kubeconfig \
--use-service-account-credentials \
--controllers="${KUBE_CONTROLLERS}" \
--leader-elect=false \
--master="https://${API_HOST}:${API_SECURE_PORT}" >"${CTLRMGR_LOG}" 2>&1 &
CTLRMGR_PID=$!
}
@@ -690,6 +668,7 @@ function start_cloud_controller_manager {
--cloud-config=${CLOUD_CONFIG} \
--kubeconfig "$CERT_DIR"/controller.kubeconfig \
--use-service-account-credentials \
--leader-elect=false \
--master="https://${API_HOST}:${API_SECURE_PORT}" >"${CLOUD_CTLRMGR_LOG}" 2>&1 &
CLOUD_CTLRMGR_PID=$!
}
@@ -770,7 +749,6 @@ function start_kubelet {
--enable-controller-attach-detach="${ENABLE_CONTROLLER_ATTACH_DETACH}"
--cgroups-per-qos="${CGROUPS_PER_QOS}"
--cgroup-driver="${CGROUP_DRIVER}"
--keep-terminated-pod-volumes="${KEEP_TERMINATED_POD_VOLUMES}"
--eviction-hard="${EVICTION_HARD}"
--eviction-soft="${EVICTION_SOFT}"
--eviction-pressure-transition-period="${EVICTION_PRESSURE_TRANSITION_PERIOD}"
@@ -823,6 +801,7 @@ function start_kubelet {
--volume=/:/rootfs:ro,rslave \
--volume=/var/run:/var/run:rw \
--volume=/sys:/sys:ro \
--volume=/usr/libexec/kubernetes/kubelet-plugins/volume/exec:/usr/libexec/kubernetes/kubelet-plugins/volume/exec:rw \
--volume=/var/lib/docker/:/var/lib/docker:rslave \
--volume=/var/lib/kubelet/:/var/lib/kubelet:rslave \
--volume=/dev:/dev \
@@ -895,6 +874,7 @@ EOF
SCHEDULER_LOG=${LOG_DIR}/kube-scheduler.log
${CONTROLPLANE_SUDO} "${GO_OUT}/hyperkube" scheduler \
--v=${LOG_LEVEL} \
--leader-elect=false \
--kubeconfig "$CERT_DIR"/scheduler.kubeconfig \
--feature-gates="${FEATURE_GATES}" \
--master="https://${API_HOST}:${API_SECURE_PORT}" >"${SCHEDULER_LOG}" 2>&1 &
@@ -968,10 +948,6 @@ Logs:
EOF
fi
if [[ "${ENABLE_APISERVER_BASIC_AUDIT:-}" = true ]]; then
echo " ${APISERVER_BASIC_AUDIT_LOG}"
fi
if [[ "${START_MODE}" == "all" ]]; then
echo " ${KUBELET_LOG}"
elif [[ "${START_MODE}" == "nokubelet" ]]; then
@@ -1075,14 +1051,14 @@ if [[ "${START_MODE}" != "nokubelet" ]]; then
# Detect the OS name/arch and display appropriate error.
case "$(uname -s)" in
Darwin)
warning "kubelet is not currently supported in darwin, kubelet aborted."
print_color "kubelet is not currently supported in darwin, kubelet aborted."
KUBELET_LOG=""
;;
Linux)
start_kubelet
;;
*)
warning "Unsupported host OS. Must be Linux or Mac OS X, kubelet aborted."
print_color "Unsupported host OS. Must be Linux or Mac OS X, kubelet aborted."
;;
esac
fi

View File

@@ -20,8 +20,8 @@ sh_binary(
name = "test-cmd",
srcs = ["test-cmd.sh"],
deps = [
":test-cmd-util",
"//hack/lib",
"//test/cmd:legacy-script",
],
)
@@ -89,14 +89,6 @@ sh_binary(
],
)
sh_library(
name = "test-cmd-util",
srcs = [
"test-cmd-util.sh",
],
data = ["//pkg/kubectl/validation:testdata/v1/validPod.yaml"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
@@ -106,7 +98,10 @@ filegroup(
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
srcs = [
":package-srcs",
"//hack/make-rules/helpers/go2make:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -25,7 +25,6 @@ CLEAN_PATTERNS=(
"_tmp"
"doc_tmp"
".*/zz_generated.openapi.go"
"pkg/generated/bindata.go"
"test/e2e/generated/bindata.go"
)

View File

@@ -36,22 +36,23 @@ trap "rm -f '${CACHE}'" HUP INT TERM ERR
# Example:
# kfind -type f -name foobar.go
function kfind() {
# include the "special" vendor directories which are actually part
# of the Kubernetes source tree - generators will use these for
# including certain core API concepts.
find -H . ./vendor/k8s.io/apimachinery ./vendor/k8s.io/apiserver ./vendor/k8s.io/kube-aggregator ./vendor/k8s.io/apiextensions-apiserver ./vendor/k8s.io/metrics ./vendor/k8s.io/sample-apiserver ./vendor/k8s.io/api ./vendor/k8s.io/client-go ./vendor/k8s.io/code-generator ./vendor/k8s.io/sample-controller \
# We want to include the "special" vendor directories which are actually
# part of the Kubernetes source tree (./staging/*) but we need them to be
# named as their ./vendor/* equivalents. Also, we do not want all of
# ./vendor or even all of ./vendor/k8s.io.
find -H . \
\( \
-not \( \
\( \
-path ./vendor -o \
-path ./staging -o \
-path ./_\* -o \
-path ./.\* -o \
-path ./docs \
\) -prune \
\) \
\) \
"$@"
"$@" \
| sed 's|^./staging/src|vendor|'
}
NEED_FIND=true

View File

@@ -0,0 +1,41 @@
# gazelle:exclude testdata
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"go2make.go",
"pkgwalk.go",
],
importpath = "k8s.io/kubernetes/hack/make-rules/helpers/go2make",
visibility = ["//visibility:private"],
deps = ["//vendor/github.com/spf13/pflag:go_default_library"],
)
go_binary(
name = "go2make",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
go_test(
name = "go_default_test",
srcs = ["pkgwalk_test.go"],
data = glob(["testdata/**"]),
embed = [":go_default_library"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,215 @@
/*
Copyright 2017 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 main
import (
"bytes"
goflag "flag"
"fmt"
"go/build"
"io"
"os"
"sort"
"strings"
"github.com/spf13/pflag"
)
var flPrune = pflag.StringSlice("prune", nil, "sub-packages to prune (recursive, may be specified multiple times)")
var flDebug = pflag.BoolP("debug", "d", false, "enable debugging output")
var flHelp = pflag.BoolP("help", "h", false, "print help and exit")
func main() {
pflag.CommandLine.AddGoFlagSet(goflag.CommandLine)
pflag.Usage = func() { help(os.Stderr) }
pflag.Parse()
debug("PWD", getwd())
build.Default.BuildTags = []string{"ignore_autogenerated"}
build.Default.UseAllFiles = false
if *flHelp {
help(os.Stdout)
os.Exit(0)
}
if len(pflag.Args()) == 0 {
help(os.Stderr)
os.Exit(1)
}
for _, in := range pflag.Args() {
if strings.HasSuffix(in, "/...") {
// Recurse.
debug("starting", in)
pkgName := strings.TrimSuffix(in, "/...")
if err := WalkPkg(pkgName, visitPkg); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
} else {
// Import one package.
if err := saveImport(in); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(2)
}
}
}
}
func help(out io.Writer) {
fmt.Fprintf(out, "Usage: %s [FLAG...] <PKG...>\n", os.Args[0])
fmt.Fprintf(out, "\n")
fmt.Fprintf(out, "go2make calculates all of the dependencies of a set of Go packages and prints\n")
fmt.Fprintf(out, "them as variable definitions suitable for use as a Makefile.\n")
fmt.Fprintf(out, "\n")
fmt.Fprintf(out, "Package specifications may be simple (e.g. 'example.com/txt/color') or\n")
fmt.Fprintf(out, "recursive (e.g. 'example.com/txt/...')\n")
fmt.Fprintf(out, " Example:\n")
fmt.Fprintf(out, " $ %s ./example.com/pretty\n", os.Args[0])
fmt.Fprintf(out, " example.com/txt/split := \\\n")
fmt.Fprintf(out, " /go/src/example.com/txt/split/ \\\n")
fmt.Fprintf(out, " /go/src/example.com/txt/split/split.go \\\n")
fmt.Fprintf(out, " ./example.com/pretty := \\\n")
fmt.Fprintf(out, " /go/src/example.com/pretty/ \\\n")
fmt.Fprintf(out, " /go/src/example.com/pretty/print.go \\\n")
fmt.Fprintf(out, " /go/src/example.com/txt/split/ \\\n")
fmt.Fprintf(out, " /go/src/example.com/txt/split/split.go\n")
fmt.Fprintf(out, "\n")
fmt.Fprintf(out, " Flags:\n")
pflag.PrintDefaults()
}
func debug(items ...interface{}) {
if *flDebug {
x := []interface{}{"DBG:"}
x = append(x, items...)
fmt.Println(x...)
}
}
func visitPkg(importPath, absPath string) error {
debug("visit", importPath)
return saveImport(importPath)
}
func prune(pkgName string) bool {
for _, pr := range *flPrune {
if pr == pkgName {
return true
}
}
return false
}
// cache keeps track of which packages we have already loaded.
var cache = map[string]*build.Package{}
func saveImport(pkgName string) error {
if cache[pkgName] != nil {
return nil
}
if prune(pkgName) {
debug("prune", pkgName)
return ErrSkipPkg
}
pkg, err := loadPackage(pkgName)
if err != nil {
return err
}
debug("save", pkgName)
cache[pkgName] = pkg
debug("recurse", pkgName)
defer func() { debug("done ", pkgName) }()
if !pkg.Goroot && (len(pkg.GoFiles)+len(pkg.Imports) > 0) {
// Process deps of this package before the package itself.
for _, impName := range pkg.Imports {
if impName == "C" {
continue
}
debug("depends on", impName)
saveImport(impName)
}
// Emit a variable for each package.
var buf bytes.Buffer
buf.WriteString(pkgName)
buf.WriteString(" := ")
// Packages depend on their own directories, their own files, and
// transitive list of all deps' directories and files.
all := map[string]struct{}{}
all[pkg.Dir+"/"] = struct{}{}
filesForPkg(pkg, all)
for _, imp := range pkg.Imports {
pkg := cache[imp]
if pkg == nil || pkg.Goroot {
continue
}
all[pkg.Dir+"/"] = struct{}{}
filesForPkg(pkg, all)
}
// Sort and de-dup them.
files := flatten(all)
for _, f := range files {
buf.WriteString(" \\\n ")
buf.WriteString(f)
}
fmt.Println(buf.String())
}
return nil
}
func filesForPkg(pkg *build.Package, all map[string]struct{}) {
for _, file := range pkg.GoFiles {
if pkg.Dir != "." {
file = pkg.Dir + "/" + file
}
all[file] = struct{}{}
}
}
func flatten(all map[string]struct{}) []string {
list := make([]string, 0, len(all))
for k := range all {
list = append(list, k)
}
sort.Strings(list)
return list
}
func loadPackage(pkgName string) (*build.Package, error) {
debug("load", pkgName)
pkg, err := build.Import(pkgName, getwd(), 0)
if err != nil {
// We can ignore NoGoError. Anything else is real.
if _, ok := err.(*build.NoGoError); !ok {
return nil, err
}
}
return pkg, nil
}
func getwd() string {
pwd, err := os.Getwd()
if err != nil {
panic(fmt.Sprintf("can't get working directory: %v", err))
}
return pwd
}

View File

@@ -0,0 +1,117 @@
/*
Copyright 2017 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 main
import (
"fmt"
"go/build"
"os"
"path"
"sort"
)
// VisitFunc is a function called by WalkPkg to examine a single package.
type VisitFunc func(importPath string, absPath string) error
// ErrSkipPkg can be returned by a VisitFunc to indicate that the package in
// question should not be walked any further.
var ErrSkipPkg = fmt.Errorf("package skipped")
// WalkPkg recursively visits all packages under pkgName. This is similar
// to filepath.Walk, except that it follows symlinks. A package is always
// visited before the children of that package. If visit returns ErrSkipPkg,
// pkgName will not be walked.
func WalkPkg(pkgName string, visit VisitFunc) error {
// Visit the package itself.
pkg, err := findPackage(pkgName)
if err != nil {
return err
}
if err := visit(pkg.ImportPath, pkg.Dir); err == ErrSkipPkg {
return nil
} else if err != nil {
return err
}
// Read all of the child dirents and find sub-packages.
infos, err := readDirInfos(pkg.Dir)
if err != nil {
return err
}
for _, info := range infos {
if !info.IsDir() {
continue
}
name := info.Name()
if name[0] == '_' || (len(name) > 1 && name[0] == '.') || name == "testdata" {
continue
}
// Don't use path.Join() because it drops leading `./` via path.Clean().
err := WalkPkg(pkgName+"/"+name, visit)
if err != nil {
return err
}
}
return nil
}
// findPackage finds a Go package.
func findPackage(pkgName string) (*build.Package, error) {
debug("find", pkgName)
pkg, err := build.Import(pkgName, getwd(), build.FindOnly)
if err != nil {
return nil, err
}
return pkg, nil
}
// readDirInfos returns a list of os.FileInfo structures for the dirents under
// dirPath. The result list is sorted by name. This is very similar to
// ioutil.ReadDir, except that it follows symlinks.
func readDirInfos(dirPath string) ([]os.FileInfo, error) {
names, err := readDirNames(dirPath)
if err != nil {
return nil, err
}
sort.Strings(names)
infos := make([]os.FileInfo, 0, len(names))
for _, n := range names {
info, err := os.Stat(path.Join(dirPath, n))
if err != nil {
return nil, err
}
infos = append(infos, info)
}
return infos, nil
}
// readDirNames returns a list of all dirents in dirPath. The result list is
// not sorted or filtered.
func readDirNames(dirPath string) ([]string, error) {
d, err := os.Open(dirPath)
if err != nil {
return nil, err
}
defer d.Close()
names, err := d.Readdirnames(-1)
if err != nil {
return nil, err
}
return names, nil
}

View File

@@ -0,0 +1,222 @@
/*
Copyright 2017 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 main
import (
"path"
"reflect"
"sort"
"testing"
)
func Test_WalkPkg(t *testing.T) {
testCases := []struct {
pkg string
fail bool
expected []string
}{
{
pkg: "./testdata/nonexistent-dir",
fail: true,
},
{
pkg: "./testdata/dir-without-gofiles",
expected: []string{"./testdata/dir-without-gofiles"},
},
{
pkg: "./testdata/dir-with-gofiles",
expected: []string{"./testdata/dir-with-gofiles", "./testdata/dir-with-gofiles/subdir"},
},
}
for i, tc := range testCases {
visited := []string{}
err := WalkPkg(tc.pkg, func(imp, abs string) error {
if _, base := path.Split(imp); base == "skipme" {
return ErrSkipPkg
}
visited = append(visited, imp)
return nil
})
if err != nil && tc.fail {
continue
}
if err != nil {
t.Errorf("[%d] unexpected error: %v", i, err)
continue
}
if tc.fail {
t.Errorf("[%d] expected error", i)
continue
}
if !reflect.DeepEqual(visited, tc.expected) {
t.Errorf("[%d] unexpected results: %v", i, visited)
}
}
}
func Test_findPackage(t *testing.T) {
testCases := []struct {
pkg string
fail bool
}{
{
pkg: "./testdata/nonexistent-dir",
fail: true,
},
{
pkg: "./testdata/dir-without-gofiles",
},
{
pkg: "./testdata/dir-with-gofiles",
},
}
for i, tc := range testCases {
_, err := findPackage(tc.pkg)
if err != nil && tc.fail {
continue
}
if err != nil {
t.Errorf("[%d] unexpected error: %v", i, err)
continue
}
if tc.fail {
t.Errorf("[%d] expected error", i)
continue
}
}
}
func Test_readDirInfos(t *testing.T) {
testCases := []struct {
dir string
fail bool
expected map[string]bool
}{
{
dir: "./testdata/nonexistent-dir",
fail: true,
},
{
dir: "./testdata/dir-without-gofiles",
expected: map[string]bool{"README": true},
},
{
dir: "./testdata/dir-with-gofiles",
expected: map[string]bool{
"README": true,
"foo.go": true,
"bar.go": true,
"subdir": true,
"testdata": true,
"_underscore": true,
".dot": true,
"skipme": true,
},
},
}
for i, tc := range testCases {
infos, err := readDirInfos(tc.dir)
if err != nil && tc.fail {
continue
}
if err != nil {
t.Errorf("[%d] unexpected error: %v", i, err)
continue
}
if tc.fail {
t.Errorf("[%d] expected error", i)
continue
}
result := make([]string, len(infos))
sorted := make([]string, len(infos))
for i, inf := range infos {
result[i] = inf.Name()
sorted[i] = inf.Name()
}
sort.Strings(sorted)
if !reflect.DeepEqual(result, sorted) {
t.Errorf("[%d] result was not sorted: %v", i, result)
}
for _, r := range result {
if !tc.expected[r] {
t.Errorf("[%d] got unexpected result: %s", i, r)
} else {
delete(tc.expected, r)
}
}
for r := range tc.expected {
t.Errorf("[%d] missing expected result: %s", i, r)
}
}
}
func Test_readDirNames(t *testing.T) {
testCases := []struct {
dir string
fail bool
expected map[string]bool
}{
{
dir: "./testdata/nonexistent-dir",
fail: true,
},
{
dir: "./testdata/dir-without-gofiles",
expected: map[string]bool{"README": true},
},
{
dir: "./testdata/dir-with-gofiles",
expected: map[string]bool{
"README": true,
"foo.go": true,
"bar.go": true,
"subdir": true,
"testdata": true,
"_underscore": true,
".dot": true,
"skipme": true,
},
},
}
for i, tc := range testCases {
result, err := readDirNames(tc.dir)
if err != nil && tc.fail {
continue
}
if err != nil {
t.Errorf("[%d] unexpected error: %v", i, err)
continue
}
if tc.fail {
t.Errorf("[%d] expected error", i)
continue
}
for _, r := range result {
if !tc.expected[r] {
t.Errorf("[%d] got unexpected result: %s", i, r)
} else {
delete(tc.expected, r)
}
}
for r := range tc.expected {
t.Errorf("[%d] missing expected result: %s", i, r)
}
}
}

View File

@@ -0,0 +1 @@
README

View File

@@ -0,0 +1 @@
README

View File

@@ -0,0 +1,20 @@
/*
Copyright 2017 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 gofiles
func bar() {
}

View File

@@ -0,0 +1,20 @@
/*
Copyright 2017 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 gofiles
func foo() {
}

View File

@@ -0,0 +1 @@
README

View File

@@ -0,0 +1 @@
README

View File

@@ -0,0 +1 @@
README

View File

@@ -0,0 +1 @@
README

File diff suppressed because it is too large Load Diff

View File

@@ -24,7 +24,7 @@ set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source "${KUBE_ROOT}/hack/lib/init.sh"
source "${KUBE_ROOT}/hack/lib/test.sh"
source "${KUBE_ROOT}/hack/make-rules/test-cmd-util.sh"
source "${KUBE_ROOT}/test/cmd/legacy-script.sh"
function run_kube_apiserver() {
kube::log::status "Building kube-apiserver"
@@ -34,18 +34,22 @@ function run_kube_apiserver() {
kube::log::status "Starting kube-apiserver"
# Admission Controllers to invoke prior to persisting objects in cluster
ENABLE_ADMISSION_PLUGINS="Initializers,LimitRanger,ResourceQuota"
ENABLE_ADMISSION_PLUGINS="LimitRanger,ResourceQuota"
DISABLE_ADMISSION_PLUGINS="ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,DefaultTolerationSeconds,MutatingAdmissionWebhook,ValidatingAdmissionWebhook"
# Include RBAC (to exercise bootstrapping), and AlwaysAllow to allow all actions
AUTHORIZATION_MODE="RBAC,AlwaysAllow"
# Enable features
ENABLE_FEATURE_GATES="DryRun=true"
"${KUBE_OUTPUT_HOSTBIN}/kube-apiserver" \
--insecure-bind-address="127.0.0.1" \
--bind-address="127.0.0.1" \
--insecure-port="${API_PORT}" \
--authorization-mode="${AUTHORIZATION_MODE}" \
--secure-port="${SECURE_API_PORT}" \
--feature-gates="${ENABLE_FEATURE_GATES}" \
--enable-admission-plugins="${ENABLE_ADMISSION_PLUGINS}" \
--disable-admission-plugins="${DISABLE_ADMISSION_PLUGINS}" \
--etcd-servers="http://${ETCD_HOST}:${ETCD_PORT}" \

View File

@@ -69,7 +69,6 @@ kube::test::find_dirs() {
-path './_output' -prune \
-o -path './vendor/k8s.io/client-go/*' \
-o -path './vendor/k8s.io/apiserver/*' \
-o -path './test/e2e_node/system/*' \
-name '*_test.go' -print0 | xargs -0n1 dirname | sed "s|^\./|${KUBE_GO_PACKAGE}/|" | LC_ALL=C sort -u
# run tests for client-go

View File

@@ -40,7 +40,6 @@ QUICK_PATTERNS+=(
"verify-api-groups.sh"
"verify-bazel.sh"
"verify-boilerplate.sh"
"verify-generated-files-remake"
"verify-godep-licenses.sh"
"verify-gofmt.sh"
"verify-imports.sh"
@@ -48,6 +47,7 @@ QUICK_PATTERNS+=(
"verify-readonly-packages.sh"
"verify-spelling.sh"
"verify-staging-client-go.sh"
"verify-staging-meta-files.sh"
"verify-test-images.sh"
"verify-test-owners.sh"
)

View File

@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: a
spec:
selector:
app: test
clusterIP: None
ports:
- port: 80

View File

@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: a
spec:
selector:
app: test
clusterIP: 10.0.0.12
ports:
- port: 80

View File

@@ -2,9 +2,10 @@ apiVersion: v1
kind: Pod
metadata:
name: sorted-pod1
creationTimestamp: 2018-08-30T14:10:58Z
labels:
name: sorted-pod3-label
spec:
containers:
- name: kubernetes-pause
- name: kubernetes-pause2
image: k8s.gcr.io/pause:2.0

View File

@@ -2,9 +2,10 @@ apiVersion: v1
kind: Pod
metadata:
name: sorted-pod2
creationTimestamp: 2018-08-30T14:10:55Z
labels:
name: sorted-pod2-label
spec:
containers:
- name: kubernetes-pause
- name: kubernetes-pause1
image: k8s.gcr.io/pause:2.0

View File

@@ -2,9 +2,10 @@ apiVersion: v1
kind: Pod
metadata:
name: sorted-pod3
creationTimestamp: 2018-08-30T14:10:53Z
labels:
name: sorted-pod1-label
spec:
containers:
- name: kubernetes-pause
- name: kubernetes-pause3
image: k8s.gcr.io/pause:2.0

View File

@@ -20,8 +20,6 @@ set -o pipefail
export KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"
kube::util::ensure-gnu-sed
# Remove generated files prior to running kazel.
# TODO(spxtr): Remove this line once Bazel is the only way to build.
rm -f "${KUBE_ROOT}/pkg/generated/openapi/zz_generated.openapi.go"
@@ -31,22 +29,21 @@ export GOBIN="${KUBE_OUTPUT_BINPATH}"
PATH="${GOBIN}:${PATH}"
# Install tools we need, but only from vendor/...
go install ./vendor/github.com/bazelbuild/bazel-gazelle/cmd/gazelle
go install ./vendor/github.com/kubernetes/repo-infra/kazel
go install k8s.io/kubernetes/vendor/github.com/bazelbuild/bazel-gazelle/cmd/gazelle
go install k8s.io/kubernetes/vendor/github.com/kubernetes/repo-infra/kazel
touch "${KUBE_ROOT}/vendor/BUILD"
# Ensure that we use the correct importmap for all vendored dependencies.
# Probably not necessary in gazelle 0.13+
# (https://github.com/bazelbuild/bazel-gazelle/pull/207).
if ! grep -q "# gazelle:importmap_prefix" "${KUBE_ROOT}/vendor/BUILD"; then
echo "# gazelle:importmap_prefix k8s.io/kubernetes/vendor" >> "${KUBE_ROOT}/vendor/BUILD"
fi
gazelle fix \
-build_file_name=BUILD,BUILD.bazel \
-external=vendored \
-proto=legacy \
-mode=fix
# gazelle gets confused by our staging/ directory, prepending an extra
# "k8s.io/kubernetes/staging/src" to the import path.
# gazelle won't follow the symlinks in vendor/, so we can't just exclude
# staging/. Instead we just fix the bad paths with sed.
find staging -name BUILD -o -name BUILD.bazel | \
xargs ${SED} -i 's|\(importpath = "\)k8s.io/kubernetes/staging/src/\(.*\)|\1\2|'
-mode=fix \
-repo_root "${KUBE_ROOT}" \
"${KUBE_ROOT}"
kazel

View File

@@ -138,3 +138,4 @@ CODEGEN_PKG=./vendor/k8s.io/code-generator vendor/k8s.io/sample-controller/hack/
CODEGEN_PKG=./vendor/k8s.io/code-generator vendor/k8s.io/apiextensions-apiserver/hack/update-codegen.sh
CODEGEN_PKG=./vendor/k8s.io/code-generator vendor/k8s.io/metrics/hack/update-codegen.sh
CODEGEN_PKG=./vendor/k8s.io/code-generator vendor/k8s.io/apiextensions-apiserver/examples/client-go/hack/update-codegen.sh
CODEGEN_PKG=./vendor/k8s.io/code-generator vendor/k8s.io/csi-api/hack/update-codegen.sh

View File

@@ -19,11 +19,13 @@ set -o nounset
set -o pipefail
KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE}")/../" && pwd -P)"
KUBELET_PLUGIN_REGISTRATION_ROOT="${KUBE_ROOT}/pkg/kubelet/apis/pluginregistration/v1alpha1/"
KUBELET_PLUGIN_REGISTRATION_V1ALPHA="${KUBE_ROOT}/pkg/kubelet/apis/pluginregistration/v1alpha1/"
KUBELET_PLUGIN_REGISTRATION_V1BETA="${KUBE_ROOT}/pkg/kubelet/apis/pluginregistration/v1beta1/"
KUBELET_EXAMPLE_PLUGIN_V1BETA1="${KUBE_ROOT}/pkg/kubelet/util/pluginwatcher/example_plugin_apis/v1beta1/"
KUBELET_EXAMPLE_PLUGIN_V1BETA2="${KUBE_ROOT}/pkg/kubelet/util/pluginwatcher/example_plugin_apis/v1beta2/"
source "${KUBE_ROOT}/hack/lib/protoc.sh"
kube::protoc::generate_proto ${KUBELET_PLUGIN_REGISTRATION_ROOT}
kube::protoc::generate_proto ${KUBELET_PLUGIN_REGISTRATION_V1ALPHA}
kube::protoc::generate_proto ${KUBELET_PLUGIN_REGISTRATION_V1BETA}
kube::protoc::generate_proto ${KUBELET_EXAMPLE_PLUGIN_V1BETA1}
kube::protoc::generate_proto ${KUBELET_EXAMPLE_PLUGIN_V1BETA2}

View File

@@ -52,6 +52,7 @@ PACKAGES=(
k8s.io/api/autoscaling/v1
k8s.io/api/authorization/v1
k8s.io/api/autoscaling/v2beta1
k8s.io/api/autoscaling/v2beta2
k8s.io/api/authorization/v1beta1
k8s.io/api/batch/v1
k8s.io/api/batch/v1beta1
@@ -66,6 +67,7 @@ PACKAGES=(
k8s.io/api/rbac/v1beta1
k8s.io/api/rbac/v1
k8s.io/api/certificates/v1beta1
k8s.io/api/coordination/v1beta1
k8s.io/api/imagepolicy/v1alpha1
k8s.io/api/scheduling/v1alpha1
k8s.io/api/scheduling/v1beta1
@@ -80,9 +82,11 @@ PACKAGES=(
k8s.io/metrics/pkg/apis/metrics/v1alpha1
k8s.io/metrics/pkg/apis/metrics/v1beta1
k8s.io/metrics/pkg/apis/custom_metrics/v1beta1
k8s.io/metrics/pkg/apis/custom_metrics/v1beta2
k8s.io/metrics/pkg/apis/external_metrics/v1beta1
k8s.io/apiserver/pkg/apis/audit/v1alpha1
k8s.io/apiserver/pkg/apis/audit/v1beta1
k8s.io/apiserver/pkg/apis/audit/v1
k8s.io/apiserver/pkg/apis/example2/v1
)

View File

@@ -73,7 +73,7 @@ process_content () {
# Start search at package root
case ${package} in
github.com/*|golang.org/*|bitbucket.org/*)
github.com/*|golang.org/*|bitbucket.org/*|gonum.org/*)
package_root=$(echo "${package}" |awk -F/ '{ print $1"/"$2"/"$3 }')
;;
go4.org/*)
@@ -140,6 +140,7 @@ if ((${BASH_VERSINFO[0]}<4)); then
echo "$ brew install md5sha1sum bash jq"
fi
echo
exit 9
fi
# This variable can be injected, as in the verify script.

View File

@@ -46,13 +46,12 @@ trap cleanup EXIT SIGINT
kube::golang::setup_env
apiserver=$(kube::util::find-binary "kube-apiserver")
TMP_DIR=$(mktemp -d /tmp/update-openapi-spec.XXXX)
ETCD_HOST=${ETCD_HOST:-127.0.0.1}
ETCD_PORT=${ETCD_PORT:-2379}
API_PORT=${API_PORT:-8050}
API_HOST=${API_HOST:-127.0.0.1}
API_LOGFILE=${API_LOGFILE:-/tmp/openapi-api-server.log}
kube::etcd::start
@@ -71,10 +70,16 @@ kube::log::status "Starting kube-apiserver"
--token-auth-file=$TMP_DIR/tokenauth.csv \
--logtostderr \
--v=2 \
--service-cluster-ip-range="10.0.0.0/24" >/tmp/openapi-api-server.log 2>&1 &
--service-cluster-ip-range="10.0.0.0/24" >"${API_LOGFILE}" 2>&1 &
APISERVER_PID=$!
kube::util::wait_for_url "${API_HOST}:${API_PORT}/healthz" "apiserver: "
if ! kube::util::wait_for_url "${API_HOST}:${API_PORT}/healthz" "apiserver: "; then
kube::log::error "Here are the last 10 lines from kube-apiserver (${API_LOGFILE})"
kube::log::error "=== BEGIN OF LOG ==="
tail -10 "${API_LOGFILE}" || :
kube::log::error "=== END OF LOG ==="
exit 1
fi
kube::log::status "Updating " ${OPENAPI_ROOT_DIR}

View File

@@ -120,6 +120,7 @@ for repo in $(ls ${KUBE_ROOT}/staging/src/k8s.io); do
if [ "${DRY_RUN}" != true ]; then
cp "${TMP_GOPATH}/src/k8s.io/${repo}/Godeps/Godeps.json" "${KUBE_ROOT}/staging/src/k8s.io/${repo}/Godeps/Godeps.json"
cp "${KUBE_ROOT}/Godeps/OWNERS" "${KUBE_ROOT}/staging/src/k8s.io/${repo}/Godeps/OWNERS"
# Assume Godeps.json is not updated, as the working tree needs to be clean
# Without this, the script would pause after each staging repo to prompt the
# user to commit all changes (difficult inside a container). It's safe to

View File

@@ -58,7 +58,7 @@ ETCD_HOST=${ETCD_HOST:-127.0.0.1}
ETCD_PORT=${ETCD_PORT:-2379}
API_PORT=${API_PORT:-8050}
API_HOST=${API_HOST:-127.0.0.1}
API_LOGFILE=/tmp/swagger-api-server.log
API_LOGFILE=${API_LOGFILE:-/tmp/swagger-api-server.log}
kube::etcd::start

View File

@@ -94,6 +94,7 @@ done
packages_without_install=(
"k8s.io/kubernetes/pkg/apis/abac"
"k8s.io/kubernetes/pkg/apis/admission"
"k8s.io/kubernetes/pkg/apis/componentconfig" # TODO: Remove this package completely and from this list
)
known_version_files=(
"pkg/master/import_known_versions.go"

View File

@@ -33,5 +33,6 @@ CODEGEN_PKG=./vendor/k8s.io/code-generator vendor/k8s.io/sample-apiserver/hack/v
CODEGEN_PKG=./vendor/k8s.io/code-generator vendor/k8s.io/sample-controller/hack/verify-codegen.sh
CODEGEN_PKG=./vendor/k8s.io/code-generator vendor/k8s.io/apiextensions-apiserver/hack/verify-codegen.sh
CODEGEN_PKG=./vendor/k8s.io/code-generator vendor/k8s.io/metrics/hack/verify-codegen.sh
CODEGEN_PKG=./vendor/k8s.io/code-generator vendor/k8s.io/csi-api/hack/verify-codegen.sh
"${KUBE_ROOT}/hack/update-codegen.sh" --verify-only

View File

@@ -36,7 +36,7 @@ kube::util::ensure-temp-dir
kube::util::gen-docs "${KUBE_TEMP}"
# Verify the list matches the expected list (diff should be empty)
if [[ "$(diff ${KUBE_ROOT}/docs/.generated_docs ${KUBE_TEMP}/docs/.generated_docs)" != "" ]]; then
if ! diff "${KUBE_ROOT}/docs/.generated_docs" "${KUBE_TEMP}/docs/.generated_docs"; then
echo "List of generated docs doesn't match a freshly built list. Please run hack/update-generated-docs.sh"
exit 1
fi

303
vendor/k8s.io/kubernetes/hack/verify-generated-files-remake.sh generated vendored Normal file → Executable file
View File

@@ -21,10 +21,303 @@ set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"
make generated_files
X=$(make generated_files DBG_CODEGEN=1)
if [[ -n "${X}" ]]; then
echo "Back-to-back 'make' runs are not clean for codegen"
echo "${X}"
# $1 = filename pattern as in "zz_generated.$1.go"
function find_genfiles() {
find . \
\( \
-not \( \
\( \
-path ./_\* -o \
-path ./.\* \
\) -prune \
\) \
\) -name "zz_generated.$1.go"
}
# $1 = filename pattern as in "zz_generated.$1.go"
# $2 timestamp file
function newer() {
find_genfiles "$1" | while read F; do
if [[ "${F}" -nt "$2" ]]; then
echo "${F}"
fi
done
}
# $1 = filename pattern as in "zz_generated.$1.go"
# $2 timestamp file
function older() {
find_genfiles "$1" | while read F; do
if [[ "$2" -nt "${F}" ]]; then
echo "${F}"
fi
done
}
function assert_clean() {
make generated_files >/dev/null
touch "${STAMP}"
make generated_files >/dev/null
X=($(newer deepcopy "${STAMP}"))
if [[ "${#X[*]}" != 0 ]]; then
echo "Generated files changed on back-to-back 'make' runs:"
echo " ${X[@]:-(none)}"
return 1
fi
true
}
STAMP=/tmp/stamp.$RANDOM
#
# Test when we touch a file in a package that needs codegen.
#
assert_clean
DIR=staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1
touch "$DIR/types.go"
touch "${STAMP}"
make generated_files >/dev/null
X=($(newer deepcopy "${STAMP}"))
if [[ "${#X[*]}" != 1 || ! ( "${X[0]}" =~ "${DIR}/zz_generated.deepcopy.go" ) ]]; then
echo "Wrong generated deepcopy files changed after touching src file:"
echo " ${X[@]:-(none)}"
exit 1
fi
X=($(newer defaults "${STAMP}"))
if [[ "${#X[*]}" != 1 || ! ( "${X[0]}" =~ "${DIR}/zz_generated.defaults.go" ) ]]; then
echo "Wrong generated defaults files changed after touching src file:"
echo " ${X[@]:-(none)}"
exit 1
fi
X=($(newer conversion "${STAMP}"))
if [[ "${#X[*]}" != 1 || ! ( "${X[0]}" =~ "${DIR}/zz_generated.conversion.go" ) ]]; then
echo "Wrong generated conversion files changed after touching src file:"
echo " ${X[@]:-(none)}"
exit 1
fi
#
# Test when the codegen tool itself changes: deepcopy
#
assert_clean
touch staging/src/k8s.io/code-generator/cmd/deepcopy-gen/main.go
touch "${STAMP}"
make generated_files >/dev/null
X=($(older deepcopy "${STAMP}"))
if [[ "${#X[*]}" != 0 ]]; then
echo "Generated deepcopy files did not change after touching code-generator file:"
echo " ${X[@]:-(none)}"
exit 1
fi
assert_clean
touch staging/src/k8s.io/code-generator/cmd/deepcopy-gen/
touch "${STAMP}"
make generated_files >/dev/null
X=($(older deepcopy "${STAMP}"))
if [[ "${#X[*]}" != 0 ]]; then
echo "Generated deepcopy files did not change after touching code-generator dir:"
echo " ${X[@]:-(none)}"
exit 1
fi
assert_clean
touch vendor/k8s.io/gengo/examples/deepcopy-gen/generators/deepcopy.go
touch "${STAMP}"
make generated_files >/dev/null
X=($(older deepcopy "${STAMP}"))
if [[ "${#X[*]}" != 0 ]]; then
echo "Generated deepcopy files did not change after touching code-generator dep file:"
echo " ${X[@]:-(none)}"
exit 1
fi
assert_clean
touch vendor/k8s.io/gengo/examples/deepcopy-gen/generators/
touch "${STAMP}"
make generated_files >/dev/null
X=($(older deepcopy "${STAMP}"))
if [[ "${#X[*]}" != 0 ]]; then
echo "Generated deepcopy files did not change after touching code-generator dep dir:"
echo " ${X[@]:-(none)}"
exit 1
fi
#
# Test when the codegen tool itself changes: defaults
#
assert_clean
touch staging/src/k8s.io/code-generator/cmd/defaulter-gen/main.go
touch "${STAMP}"
make generated_files >/dev/null
X=($(older defaults "${STAMP}"))
if [[ "${#X[*]}" != 0 ]]; then
echo "Generated defaults files did not change after touching code-generator file:"
echo " ${X[@]:-(none)}"
exit 1
fi
assert_clean
touch staging/src/k8s.io/code-generator/cmd/defaulter-gen/
touch "${STAMP}"
make generated_files >/dev/null
X=($(older defaults "${STAMP}"))
if [[ "${#X[*]}" != 0 ]]; then
echo "Generated defaults files did not change after touching code-generator dir:"
echo " ${X[@]:-(none)}"
exit 1
fi
assert_clean
touch vendor/k8s.io/gengo/examples/defaulter-gen/generators/defaulter.go
touch "${STAMP}"
make generated_files >/dev/null
X=($(older defaults "${STAMP}"))
if [[ "${#X[*]}" != 0 ]]; then
echo "Generated defaults files did not change after touching code-generator dep file:"
echo " ${X[@]:-(none)}"
exit 1
fi
assert_clean
touch vendor/k8s.io/gengo/examples/defaulter-gen/generators/
touch "${STAMP}"
make generated_files >/dev/null
X=($(older defaults "${STAMP}"))
if [[ "${#X[*]}" != 0 ]]; then
echo "Generated defaults files did not change after touching code-generator dep dir:"
echo " ${X[@]:-(none)}"
exit 1
fi
#
# Test when the codegen tool itself changes: conversion
#
assert_clean
touch staging/src/k8s.io/code-generator/cmd/conversion-gen/main.go
touch "${STAMP}"
make generated_files >/dev/null
X=($(older conversion "${STAMP}"))
if [[ "${#X[*]}" != 0 ]]; then
echo "Generated conversion files did not change after touching code-generator file:"
echo " ${X[@]:-(none)}"
exit 1
fi
assert_clean
touch staging/src/k8s.io/code-generator/cmd/conversion-gen/
touch "${STAMP}"
make generated_files >/dev/null
X=($(older conversion "${STAMP}"))
if [[ "${#X[*]}" != 0 ]]; then
echo "Generated conversion files did not change after touching code-generator dir:"
echo " ${X[@]:-(none)}"
exit 1
fi
assert_clean
touch vendor/k8s.io/code-generator/cmd/conversion-gen/generators/conversion.go
touch "${STAMP}"
make generated_files >/dev/null
X=($(older conversion "${STAMP}"))
if [[ "${#X[*]}" != 0 ]]; then
echo "Generated conversion files did not change after touching code-generator dep file:"
echo " ${X[@]:-(none)}"
exit 1
fi
assert_clean
touch vendor/k8s.io/code-generator/cmd/conversion-gen/generators/
touch "${STAMP}"
make generated_files >/dev/null
X=($(older conversion "${STAMP}"))
if [[ "${#X[*]}" != 0 ]]; then
echo "Generated conversion files did not change after touching code-generator dep dir:"
echo " ${X[@]:-(none)}"
exit 1
fi
#
# Test when we touch a file in a package that needs codegen.
#
assert_clean
touch "staging/src/k8s.io/api/core/v1/types.go"
touch "${STAMP}"
make generated_files >/dev/null
X=($(newer openapi "${STAMP}"))
if [[ "${#X[*]}" != 1 || ! ( "${X[0]}" =~ "pkg/generated/openapi/zz_generated.openapi.go" ) ]]; then
echo "Wrong generated openapi files changed after touching src file:"
echo "${X[@]:-(none)}"
exit 1
fi
#
# Test when the codegen tool itself changes: openapi
#
assert_clean
touch vendor/k8s.io/kube-openapi/cmd/openapi-gen/openapi-gen.go
touch "${STAMP}"
make generated_files >/dev/null
X=($(older openapi "${STAMP}"))
if [[ "${#X[*]}" != 0 ]]; then
echo "Generated openapi files did not change after touching code-generator file:"
echo " ${X[@]:-(none)}"
exit 1
fi
assert_clean
touch vendor/k8s.io/kube-openapi/cmd/openapi-gen/
touch "${STAMP}"
make generated_files >/dev/null
X=($(older openapi "${STAMP}"))
if [[ "${#X[*]}" != 0 ]]; then
echo "Generated openapi files did not change after touching code-generator dir:"
echo " ${X[@]:-(none)}"
exit 1
fi
assert_clean
touch vendor/k8s.io/kube-openapi/pkg/generators/openapi.go
touch "${STAMP}"
make generated_files >/dev/null
X=($(older openapi "${STAMP}"))
if [[ "${#X[*]}" != 0 ]]; then
echo "Generated openapi files did not change after touching code-generator dep file:"
echo " ${X[@]:-(none)}"
exit 1
fi
assert_clean
touch vendor/k8s.io/kube-openapi/pkg/generators
touch "${STAMP}"
make generated_files >/dev/null
X=($(older openapi "${STAMP}"))
if [[ "${#X[*]}" != 0 ]]; then
echo "Generated openapi files did not change after touching code-generator dep dir:"
echo " ${X[@]:-(none)}"
exit 1
fi

49
vendor/k8s.io/kubernetes/hack/verify-generated-files.sh generated vendored Executable file
View File

@@ -0,0 +1,49 @@
#!/usr/bin/env bash
# Copyright 2018 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.
set -o errexit
set -o nounset
set -o pipefail
export KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"
kube::util::ensure_clean_working_dir
_tmpdir="$(kube::realpath $(mktemp -d -t verify-generated-files.XXXXXX))"
kube::util::trap_add "rm -rf ${_tmpdir}" EXIT
_tmp_gopath="${_tmpdir}/go"
_tmp_kuberoot="${_tmp_gopath}/src/k8s.io/kubernetes"
mkdir -p "${_tmp_kuberoot}/.."
cp -a "${KUBE_ROOT}" "${_tmp_kuberoot}/.."
cd "${_tmp_kuberoot}"
# clean out anything from the temp dir that's not checked in
git clean -ffxd
# regenerate any generated code
make generated_files
diff=$(git diff --name-only)
if [[ -n "${diff}" ]]; then
echo "!!! Generated code is out of date:" >&2
echo "${diff}" >&2
echo >&2
echo "Please run make generated_files." >&2
exit 1
fi

View File

@@ -20,20 +20,31 @@ set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
ERROR="Kubelet Plugin Registration api is out of date. Please run hack/update-generated-kubelet-plugin-registration.sh"
KUBELET_PLUGIN_REGISTRATION_ROOT="${KUBE_ROOT}/pkg/kubelet/apis/pluginregistration/v1alpha1/"
KUBELET_PLUGIN_REGISTRATION_V1ALPHA="${KUBE_ROOT}/pkg/kubelet/apis/pluginregistration/v1alpha1/"
KUBELET_PLUGIN_REGISTRATION_V1BETA="${KUBE_ROOT}/pkg/kubelet/apis/pluginregistration/v1beta1/"
source "${KUBE_ROOT}/hack/lib/protoc.sh"
kube::golang::setup_env
function cleanup {
rm -rf ${KUBELET_PLUGIN_REGISTRATION_ROOT}/_tmp/
rm -rf ${KUBELET_PLUGIN_REGISTRATION_V1ALPHA}/_tmp/
rm -rf ${KUBELET_PLUGIN_REGISTRATION_V1BETA}/_tmp/
}
trap cleanup EXIT
mkdir -p ${KUBELET_PLUGIN_REGISTRATION_ROOT}/_tmp
cp ${KUBELET_PLUGIN_REGISTRATION_ROOT}/api.pb.go ${KUBELET_PLUGIN_REGISTRATION_ROOT}/_tmp/
mkdir -p ${KUBELET_PLUGIN_REGISTRATION_V1ALPHA}/_tmp
mkdir -p ${KUBELET_PLUGIN_REGISTRATION_V1BETA}/_tmp
cp ${KUBELET_PLUGIN_REGISTRATION_V1ALPHA}/api.pb.go ${KUBELET_PLUGIN_REGISTRATION_V1ALPHA}/_tmp/
cp ${KUBELET_PLUGIN_REGISTRATION_V1BETA}/api.pb.go ${KUBELET_PLUGIN_REGISTRATION_V1BETA}/_tmp/
# Check V1Alpha
KUBE_VERBOSE=3 "${KUBE_ROOT}/hack/update-generated-kubelet-plugin-registration.sh"
kube::protoc::diff "${KUBELET_PLUGIN_REGISTRATION_ROOT}/api.pb.go" "${KUBELET_PLUGIN_REGISTRATION_ROOT}/_tmp/api.pb.go" ${ERROR}
kube::protoc::diff "${KUBELET_PLUGIN_REGISTRATION_V1ALPHA}/api.pb.go" "${KUBELET_PLUGIN_REGISTRATION_V1ALPHA}/_tmp/api.pb.go" ${ERROR}
echo "Generated Kubelet Plugin Registration api is up to date."
# Check V1Beta
KUBE_VERBOSE=3 "${KUBE_ROOT}/hack/update-generated-kubelet-plugin-registration.sh"
kube::protoc::diff "${KUBELET_PLUGIN_REGISTRATION_V1BETA}/api.pb.go" "${KUBELET_PLUGIN_REGISTRATION_V1BETA}/_tmp/api.pb.go" ${ERROR}
echo "Generated Kubelet Plugin Registration api is up to date."

View File

@@ -46,14 +46,14 @@ array_contains () {
# Check that the file is in alphabetical order
failure_file="${KUBE_ROOT}/hack/.golint_failures"
if ! diff -u "${failure_file}" <(LC_ALL=C sort "${failure_file}"); then
{
echo
echo "hack/.golint_failures is not in alphabetical order. Please sort it:"
echo
echo " LC_ALL=C sort -o hack/.golint_failures hack/.golint_failures"
echo
} >&2
false
{
echo
echo "hack/.golint_failures is not in alphabetical order. Please sort it:"
echo
echo " LC_ALL=C sort -o hack/.golint_failures hack/.golint_failures"
echo
} >&2
false
fi
export IFS=$'\n'
@@ -61,73 +61,78 @@ export IFS=$'\n'
# as the prefix, however if we run it outside it returns the full path of the file
# with a leading underscore. We'll need to support both scenarios for all_packages.
all_packages=(
$(go list -e ./... | egrep -v "/(third_party|vendor|staging/src/k8s.io/client-go/pkg|generated|clientset_generated)" | sed -e 's|^k8s.io/kubernetes/||' -e "s|^_${KUBE_ROOT}/\?||")
$(go list -e ./... | egrep -v "/(third_party|vendor|staging/src/k8s.io/client-go/pkg|generated|clientset_generated)" | sed -e 's|^k8s.io/kubernetes/||' -e "s|^_${KUBE_ROOT}/\?||")
)
failing_packages=(
$(cat $failure_file)
$(cat $failure_file)
)
unset IFS
errors=()
not_failing=()
for p in "${all_packages[@]}"; do
# Run golint on package/*.go file explicitly to validate all go files
# and not just the ones for the current platform.
# Packages with a corresponding foo_test package will make golint fail
# with a useless error. Just ignore that, see golang/lint#68.
failedLint=$(golint "$p"/*.go 2>/dev/null)
array_contains "$p" "${failing_packages[@]}" && in_failing=$? || in_failing=$?
if [[ -n "${failedLint}" ]] && [[ "${in_failing}" -ne "0" ]]; then
errors+=( "${failedLint}" )
fi
if [[ -z "${failedLint}" ]] && [[ "${in_failing}" -eq "0" ]]; then
not_failing+=( $p )
fi
# Run golint on package/*.go file explicitly to validate all go files
# and not just the ones for the current platform. This also will ensure that
# _test.go files are linted.
# Generated files are ignored, and each file is passed through golint
# individually, as if one file in the package contains a fatal error (such as
# a foo package with a corresponding foo_test package), golint seems to choke
# completely.
# Ref: https://github.com/kubernetes/kubernetes/pull/67675
# Ref: https://github.com/golang/lint/issues/68
failedLint=$(ls "$p"/*.go | egrep -v "(zz_generated.*.go|generated.pb.go|generated.proto|types_swagger_doc_generated.go)" | xargs -L1 golint 2>/dev/null)
array_contains "$p" "${failing_packages[@]}" && in_failing=$? || in_failing=$?
if [[ -n "${failedLint}" ]] && [[ "${in_failing}" -ne "0" ]]; then
errors+=( "${failedLint}" )
fi
if [[ -z "${failedLint}" ]] && [[ "${in_failing}" -eq "0" ]]; then
not_failing+=( $p )
fi
done
# Check that all failing_packages actually still exist
gone=()
for p in "${failing_packages[@]}"; do
array_contains "$p" "${all_packages[@]}" || gone+=( "$p" )
array_contains "$p" "${all_packages[@]}" || gone+=( "$p" )
done
# Check to be sure all the packages that should pass lint are.
if [ ${#errors[@]} -eq 0 ]; then
echo 'Congratulations! All Go source files have been linted.'
echo 'Congratulations! All Go source files have been linted.'
else
{
echo "Errors from golint:"
for err in "${errors[@]}"; do
echo "$err"
done
echo
echo 'Please review the above warnings. You can test via "golint" and commit the result.'
echo 'If the above warnings do not make sense, you can exempt this package from golint'
echo 'checking by adding it to hack/.golint_failures (if your reviewer is okay with it).'
echo
} >&2
false
{
echo "Errors from golint:"
for err in "${errors[@]}"; do
echo "$err"
done
echo
echo 'Please review the above warnings. You can test via "golint" and commit the result.'
echo 'If the above warnings do not make sense, you can exempt this package from golint'
echo 'checking by adding it to hack/.golint_failures (if your reviewer is okay with it).'
echo
} >&2
false
fi
if [[ ${#not_failing[@]} -gt 0 ]]; then
{
echo "Some packages in hack/.golint_failures are passing golint. Please remove them."
echo
for p in "${not_failing[@]}"; do
echo " $p"
done
echo
} >&2
false
{
echo "Some packages in hack/.golint_failures are passing golint. Please remove them."
echo
for p in "${not_failing[@]}"; do
echo " $p"
done
echo
} >&2
false
fi
if [[ ${#gone[@]} -gt 0 ]]; then
{
echo "Some packages in hack/.golint_failures do not exist anymore. Please remove them."
echo
for p in "${gone[@]}"; do
echo " $p"
done
echo
} >&2
false
{
echo "Some packages in hack/.golint_failures do not exist anymore. Please remove them."
echo
for p in "${gone[@]}"; do
echo " $p"
done
echo
} >&2
false
fi

View File

@@ -26,8 +26,6 @@ kube::etcd::install
make -C "${KUBE_ROOT}" WHAT=cmd/kube-apiserver
apiserver=$(kube::util::find-binary "kube-apiserver")
SPECROOT="${KUBE_ROOT}/api/openapi-spec"
TMP_SPECROOT="${KUBE_ROOT}/_tmp/openapi-spec"
_tmp="${KUBE_ROOT}/_tmp"

View File

@@ -26,7 +26,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
kube::golang::verify_go_version
cd "${KUBE_ROOT}"
if git --no-pager grep -E $'^(import |\t)[a-z]+[A-Z_][a-zA-Z]* "[^"]+"$' -- '**/*.go' ':(exclude)vendor/*' ':(exclude)staging/src/k8s.io/client-go/*vendor/*' ':(exclude)staging/src/k8s.io/metrics/*' ':(exclude)pkg/apis/admission/v1beta1/zz_generated.conversion.go' ':(exclude)staging/src/k8s.io/sample-apiserver/pkg/client/informers/*' ':(exclude)staging/src/k8s.io/code-generator/_examples/*informers/*'; then
if git --no-pager grep -E $'^(import |\t)[a-z]+[A-Z_][a-zA-Z]* "[^"]+"$' -- '**/*.go' ':(exclude)vendor/*'; then
echo "!!! Some package aliases break go conventions."
echo "To fix these errors, do not use capitalized or underlined characters"
echo "in pkg aliases. Refer to https://blog.golang.org/package-names for more info."

View File

@@ -25,7 +25,7 @@ export GOBIN="${KUBE_OUTPUT_BINPATH}"
PATH="${GOBIN}:${PATH}"
# Install tools we need, but only from vendor/...
go install ./vendor/github.com/client9/misspell/cmd/misspell
go install k8s.io/kubernetes/vendor/github.com/client9/misspell/cmd/misspell
# Spell checking
# All the skipping files are defined in hack/.spelling_failures

50
vendor/k8s.io/kubernetes/hack/verify-staging-meta-files.sh generated vendored Executable file
View File

@@ -0,0 +1,50 @@
#!/usr/bin/env bash
# Copyright 2018 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.
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
staging_repos=($(ls "${KUBE_ROOT}/staging/src/k8s.io/"))
expected_filenames=(
.github/PULL_REQUEST_TEMPLATE.md
code-of-conduct.md
LICENSE
OWNERS
README.md
SECURITY_CONTACTS
)
exceptions=(
client-go/README.md # client-go provides its own README
)
RESULT=0
for repo in ${staging_repos[@]}; do
for filename in ${expected_filenames[@]}; do
if echo " ${exceptions[*]} " | grep -F " ${repo}/${filename} " >/dev/null; then
continue
elif [ ! -f "${KUBE_ROOT}/staging/src/k8s.io/${repo}/${filename}" ]; then
echo "staging/src/k8s.io/${repo}/${filename} does not exist and must be created"
RESULT=1
fi
done
done
exit $RESULT