mirror of https://github.com/knative/caching.git
[master] Auto-update dependencies (#269)
Produced via: `./hack/update-deps.sh --upgrade && ./hack/update-codegen.sh` /assign n3wscott vagababov /cc n3wscott vagababov
This commit is contained in:
parent
f613680e15
commit
bed5ab4ba6
4
go.mod
4
go.mod
|
@ -16,8 +16,8 @@ require (
|
||||||
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
|
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
|
||||||
k8s.io/code-generator v0.18.0
|
k8s.io/code-generator v0.18.0
|
||||||
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a
|
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a
|
||||||
knative.dev/pkg v0.0.0-20200507011344-2581370e4a37
|
knative.dev/pkg v0.0.0-20200508041145-19b1d7b64df3
|
||||||
knative.dev/test-infra v0.0.0-20200506231144-c8dd15bb7f0b
|
knative.dev/test-infra v0.0.0-20200508015845-8d7d46a46176
|
||||||
)
|
)
|
||||||
|
|
||||||
replace (
|
replace (
|
||||||
|
|
8
go.sum
8
go.sum
|
@ -1371,15 +1371,15 @@ knative.dev/pkg v0.0.0-20191111150521-6d806b998379/go.mod h1:pgODObA1dTyhNoFxPZT
|
||||||
knative.dev/pkg v0.0.0-20200428194351-90fc61bae7f7/go.mod h1:o+e8OVEJKIuvXPsGVPIautjXgs05xbos7G+QMRjuUps=
|
knative.dev/pkg v0.0.0-20200428194351-90fc61bae7f7/go.mod h1:o+e8OVEJKIuvXPsGVPIautjXgs05xbos7G+QMRjuUps=
|
||||||
knative.dev/pkg v0.0.0-20200505191044-3da93ebb24c2 h1:Qu2NlOHb9p3g+CSL/ok9+FySowN60URFEKRSXfWtDv4=
|
knative.dev/pkg v0.0.0-20200505191044-3da93ebb24c2 h1:Qu2NlOHb9p3g+CSL/ok9+FySowN60URFEKRSXfWtDv4=
|
||||||
knative.dev/pkg v0.0.0-20200505191044-3da93ebb24c2/go.mod h1:Q6sL35DdGs8hIQZKdaCXJGgY8f90BmNBKSb8z6d/BTM=
|
knative.dev/pkg v0.0.0-20200505191044-3da93ebb24c2/go.mod h1:Q6sL35DdGs8hIQZKdaCXJGgY8f90BmNBKSb8z6d/BTM=
|
||||||
knative.dev/pkg v0.0.0-20200507011344-2581370e4a37 h1:1YJwMfDREOHhMFtNEOSDqGO4DvPwihfZmXldSUvXGU0=
|
knative.dev/pkg v0.0.0-20200508041145-19b1d7b64df3 h1:qNt1XRLZriXPA6JLZvticQCWnNvJGiRaBPX34xlI2y8=
|
||||||
knative.dev/pkg v0.0.0-20200507011344-2581370e4a37/go.mod h1:MUQe/bW75GmlVeyHmdKag77FJWQrNH3rxt2Q9E1JZJs=
|
knative.dev/pkg v0.0.0-20200508041145-19b1d7b64df3/go.mod h1:MUQe/bW75GmlVeyHmdKag77FJWQrNH3rxt2Q9E1JZJs=
|
||||||
knative.dev/test-infra v0.0.0-20200407185800-1b88cb3b45a5/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ=
|
knative.dev/test-infra v0.0.0-20200407185800-1b88cb3b45a5/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ=
|
||||||
knative.dev/test-infra v0.0.0-20200505052144-5ea2f705bb55 h1:Ajn44+eHHjPQL/BQicj8LMy8VTD2ypMCfHJuZVGEtew=
|
knative.dev/test-infra v0.0.0-20200505052144-5ea2f705bb55 h1:Ajn44+eHHjPQL/BQicj8LMy8VTD2ypMCfHJuZVGEtew=
|
||||||
knative.dev/test-infra v0.0.0-20200505052144-5ea2f705bb55/go.mod h1:WqF1Azka+FxPZ20keR2zCNtiQA1MP9ZB4BH4HuI+SIU=
|
knative.dev/test-infra v0.0.0-20200505052144-5ea2f705bb55/go.mod h1:WqF1Azka+FxPZ20keR2zCNtiQA1MP9ZB4BH4HuI+SIU=
|
||||||
knative.dev/test-infra v0.0.0-20200506045344-e71b1288c15c h1:GfRICwJBY2VmbzFzu/se73+gsfKEkc83qlTBcohJvN0=
|
knative.dev/test-infra v0.0.0-20200506045344-e71b1288c15c h1:GfRICwJBY2VmbzFzu/se73+gsfKEkc83qlTBcohJvN0=
|
||||||
knative.dev/test-infra v0.0.0-20200506045344-e71b1288c15c/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE=
|
knative.dev/test-infra v0.0.0-20200506045344-e71b1288c15c/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE=
|
||||||
knative.dev/test-infra v0.0.0-20200506231144-c8dd15bb7f0b h1:7TSH69HYINRP6BE9pb0FLm37WwMZ1ukxh0ySSLBd8ac=
|
knative.dev/test-infra v0.0.0-20200508015845-8d7d46a46176 h1:Uab7/fRKm5lujDe+DorXGTA1v5ACzZ1wUwhcIvqcNjI=
|
||||||
knative.dev/test-infra v0.0.0-20200506231144-c8dd15bb7f0b/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE=
|
knative.dev/test-infra v0.0.0-20200508015845-8d7d46a46176/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE=
|
||||||
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
|
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
|
||||||
modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
|
modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
|
||||||
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=
|
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=
|
||||||
|
|
|
@ -145,6 +145,10 @@ func (g *reconcilerReconcilerGenerator) GenerateType(c *generator.Context, t *ty
|
||||||
Package: "context",
|
Package: "context",
|
||||||
Name: "Context",
|
Name: "Context",
|
||||||
}),
|
}),
|
||||||
|
"reflectDeepEqual": c.Universe.Package("reflect").Function("DeepEqual"),
|
||||||
|
"equalitySemantic": c.Universe.Package("k8s.io/apimachinery/pkg/api/equality").Variable("Semantic"),
|
||||||
|
"jsonMarshal": c.Universe.Package("encoding/json").Function("Marshal"),
|
||||||
|
"typesMergePatchType": c.Universe.Package("k8s.io/apimachinery/pkg/types").Constant("MergePatchType"),
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.Do(reconcilerInterfaceFactory, m)
|
sw.Do(reconcilerInterfaceFactory, m)
|
||||||
|
@ -321,7 +325,7 @@ func (r *reconcilerImpl) Reconcile(ctx {{.contextContext|raw}}, key string) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synchronize the status.
|
// Synchronize the status.
|
||||||
if equality.Semantic.DeepEqual(original.Status, resource.Status) {
|
if {{.equalitySemantic|raw}}.DeepEqual(original.Status, resource.Status) {
|
||||||
// If we didn't change anything then don't call updateStatus.
|
// If we didn't change anything then don't call updateStatus.
|
||||||
// This is important because the copy we loaded from the injectionInformer's
|
// This is important because the copy we loaded from the injectionInformer's
|
||||||
// cache may be stale and we don't want to overwrite a prior update
|
// cache may be stale and we don't want to overwrite a prior update
|
||||||
|
@ -368,7 +372,7 @@ func (r *reconcilerImpl) updateStatus(existing *{{.type|raw}}, desired *{{.type|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there's nothing to update, just return.
|
// If there's nothing to update, just return.
|
||||||
if reflect.DeepEqual(existing.Status, desired.Status) {
|
if {{.reflectDeepEqual|raw}}(existing.Status, desired.Status) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,7 +437,7 @@ func (r *reconcilerImpl) updateFinalizersFiltered(ctx {{.contextContext|raw}}, r
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
patch, err := json.Marshal(mergePatch)
|
patch, err := {{.jsonMarshal|raw}}(mergePatch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return resource, err
|
return resource, err
|
||||||
}
|
}
|
||||||
|
@ -443,7 +447,7 @@ func (r *reconcilerImpl) updateFinalizersFiltered(ctx {{.contextContext|raw}}, r
|
||||||
{{else}}
|
{{else}}
|
||||||
patcher := r.Client.{{.group}}{{.version}}().{{.type|apiGroup}}(resource.Namespace)
|
patcher := r.Client.{{.group}}{{.version}}().{{.type|apiGroup}}(resource.Namespace)
|
||||||
{{end}}
|
{{end}}
|
||||||
resource, err = patcher.Patch(resource.Name, types.MergePatchType, patch)
|
resource, err = patcher.Patch(resource.Name, {{.typesMergePatchType|raw}}, patch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.Recorder.Eventf(resource, {{.corev1EventTypeWarning|raw}}, "FinalizerUpdateFailed",
|
r.Recorder.Eventf(resource, {{.corev1EventTypeWarning|raw}}, "FinalizerUpdateFailed",
|
||||||
"Failed to update finalizers for %q: %v", resource.Name, err)
|
"Failed to update finalizers for %q: %v", resource.Name, err)
|
||||||
|
|
|
@ -427,20 +427,20 @@ func (c *Impl) processNextWorkItem() bool {
|
||||||
// Embed the key into the logger and attach that to the context we pass
|
// Embed the key into the logger and attach that to the context we pass
|
||||||
// to the Reconciler.
|
// to the Reconciler.
|
||||||
logger := c.logger.With(zap.String(logkey.TraceId, uuid.New().String()), zap.String(logkey.Key, keyStr))
|
logger := c.logger.With(zap.String(logkey.TraceId, uuid.New().String()), zap.String(logkey.Key, keyStr))
|
||||||
ctx := logging.WithLogger(context.TODO(), logger)
|
ctx := logging.WithLogger(context.Background(), logger)
|
||||||
|
|
||||||
// Run Reconcile, passing it the namespace/name string of the
|
// Run Reconcile, passing it the namespace/name string of the
|
||||||
// resource to be synced.
|
// resource to be synced.
|
||||||
if err = c.Reconciler.Reconcile(ctx, keyStr); err != nil {
|
if err = c.Reconciler.Reconcile(ctx, keyStr); err != nil {
|
||||||
c.handleErr(err, key)
|
c.handleErr(err, key)
|
||||||
logger.Infof("Reconcile failed. Time taken: %v.", time.Since(startTime))
|
logger.Info("Reconcile failed. Time taken: ", time.Since(startTime))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, if no error occurs we Forget this item so it does not
|
// Finally, if no error occurs we Forget this item so it does not
|
||||||
// have any delay when another change happens.
|
// have any delay when another change happens.
|
||||||
c.WorkQueue.Forget(key)
|
c.WorkQueue.Forget(key)
|
||||||
logger.Infof("Reconcile succeeded. Time taken: %v.", time.Since(startTime))
|
logger.Info("Reconcile succeeded. Time taken: ", time.Since(startTime))
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ var (
|
||||||
func NewLogger(configJSON string, levelOverride string, opts ...zap.Option) (*zap.SugaredLogger, zap.AtomicLevel) {
|
func NewLogger(configJSON string, levelOverride string, opts ...zap.Option) (*zap.SugaredLogger, zap.AtomicLevel) {
|
||||||
logger, atomicLevel, err := newLoggerFromConfig(configJSON, levelOverride, opts)
|
logger, atomicLevel, err := newLoggerFromConfig(configJSON, levelOverride, opts)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return enrichLoggerWithCommitID(logger.Sugar()), atomicLevel
|
return enrichLoggerWithCommitID(logger), atomicLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
loggingCfg := zap.NewProductionConfig()
|
loggingCfg := zap.NewProductionConfig()
|
||||||
|
@ -66,18 +66,18 @@ func NewLogger(configJSON string, levelOverride string, opts ...zap.Option) (*za
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
panic(err2)
|
panic(err2)
|
||||||
}
|
}
|
||||||
return enrichLoggerWithCommitID(logger.Named(fallbackLoggerName).Sugar()), loggingCfg.Level
|
return enrichLoggerWithCommitID(logger.Named(fallbackLoggerName)), loggingCfg.Level
|
||||||
}
|
}
|
||||||
|
|
||||||
func enrichLoggerWithCommitID(logger *zap.SugaredLogger) *zap.SugaredLogger {
|
func enrichLoggerWithCommitID(logger *zap.Logger) *zap.SugaredLogger {
|
||||||
commmitID, err := changeset.Get()
|
commmitID, err := changeset.Get()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// Enrich logs with GitHub commit ID.
|
// Enrich logs with GitHub commit ID.
|
||||||
return logger.With(zap.String(logkey.GitHubCommitID, commmitID))
|
return logger.With(zap.String(logkey.GitHubCommitID, commmitID)).Sugar()
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Infof("Fetch GitHub commit ID from kodata failed: %v", err)
|
logger.Info("Fetch GitHub commit ID from kodata failed", zap.Error(err))
|
||||||
return logger
|
return logger.Sugar()
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLoggerFromConfig creates a logger using the provided Config
|
// NewLoggerFromConfig creates a logger using the provided Config
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
Copyright 2020 The Knative 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 metrics
|
||||||
|
|
||||||
|
// InitForTesting initialize the necessary global variables for unit tests.
|
||||||
|
func InitForTesting() {
|
||||||
|
setCurMetricsConfig(&metricsConfig{
|
||||||
|
backendDestination: Prometheus,
|
||||||
|
component: "test",
|
||||||
|
domain: "test",
|
||||||
|
})
|
||||||
|
}
|
|
@ -26,7 +26,7 @@ readonly SERVING_GKE_VERSION=gke-latest
|
||||||
readonly SERVING_GKE_IMAGE=cos
|
readonly SERVING_GKE_IMAGE=cos
|
||||||
|
|
||||||
# Conveniently set GOPATH if unset
|
# Conveniently set GOPATH if unset
|
||||||
if [[ -z "${GOPATH:-}" ]]; then
|
if [[ ! -v GOPATH ]]; then
|
||||||
export GOPATH="$(go env GOPATH)"
|
export GOPATH="$(go env GOPATH)"
|
||||||
if [[ -z "${GOPATH}" ]]; then
|
if [[ -z "${GOPATH}" ]]; then
|
||||||
echo "WARNING: GOPATH not set and go binary unable to provide it"
|
echo "WARNING: GOPATH not set and go binary unable to provide it"
|
||||||
|
@ -34,9 +34,9 @@ if [[ -z "${GOPATH:-}" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Useful environment variables
|
# Useful environment variables
|
||||||
[[ -n "${PROW_JOB_ID:-}" ]] && IS_PROW=1 || IS_PROW=0
|
[[ -v PROW_JOB_ID ]] && IS_PROW=1 || IS_PROW=0
|
||||||
readonly IS_PROW
|
readonly IS_PROW
|
||||||
[[ -z "${REPO_ROOT_DIR:-}" ]] && REPO_ROOT_DIR="$(git rev-parse --show-toplevel)"
|
[[ ! -v REPO_ROOT_DIR ]] && REPO_ROOT_DIR="$(git rev-parse --show-toplevel)"
|
||||||
readonly REPO_ROOT_DIR
|
readonly REPO_ROOT_DIR
|
||||||
readonly REPO_NAME="$(basename ${REPO_ROOT_DIR})"
|
readonly REPO_NAME="$(basename ${REPO_ROOT_DIR})"
|
||||||
|
|
||||||
|
@ -389,8 +389,25 @@ function mktemp_with_extension() {
|
||||||
# $2 - check name as an identifier (e.g., GoBuild)
|
# $2 - check name as an identifier (e.g., GoBuild)
|
||||||
# $3 - failure message (can contain newlines), optional (means success)
|
# $3 - failure message (can contain newlines), optional (means success)
|
||||||
function create_junit_xml() {
|
function create_junit_xml() {
|
||||||
local xml="$(mktemp_with_extension "${ARTIFACTS}"/junit_XXXXXXXX xml)"
|
local xml="$(mktemp_with_extension ${ARTIFACTS}/junit_XXXXXXXX xml)"
|
||||||
run_kntest junit --suite="$1" --name="$2" --err-msg="$3" --dest="${xml}" || return 1
|
local failure=""
|
||||||
|
if [[ "$3" != "" ]]; then
|
||||||
|
# Transform newlines into HTML code.
|
||||||
|
# Also escape `<` and `>` as here: https://github.com/golang/go/blob/50bd1c4d4eb4fac8ddeb5f063c099daccfb71b26/src/encoding/json/encode.go#L48,
|
||||||
|
# this is temporary solution for fixing https://github.com/knative/test-infra/issues/1204,
|
||||||
|
# which should be obsolete once Test-infra 2.0 is in place
|
||||||
|
local msg="$(echo -n "$3" | sed 's/$/\
/g' | sed 's/</\\u003c/' | sed 's/>/\\u003e/' | sed 's/&/\\u0026/' | tr -d '\n')"
|
||||||
|
failure="<failure message=\"Failed\" type=\"\">${msg}</failure>"
|
||||||
|
fi
|
||||||
|
cat << EOF > "${xml}"
|
||||||
|
<testsuites>
|
||||||
|
<testsuite tests="1" failures="1" time="0.000" name="$1">
|
||||||
|
<testcase classname="" name="$2" time="0.0">
|
||||||
|
${failure}
|
||||||
|
</testcase>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# Runs a go test and generate a junit summary.
|
# Runs a go test and generate a junit summary.
|
||||||
|
@ -499,24 +516,19 @@ function start_latest_knative_eventing() {
|
||||||
function run_go_tool() {
|
function run_go_tool() {
|
||||||
local tool=$2
|
local tool=$2
|
||||||
local install_failed=0
|
local install_failed=0
|
||||||
local action="get"
|
if [[ -z "$(which ${tool})" ]]; then
|
||||||
[[ $1 =~ ^[\./].* ]] && action="install"
|
local action=get
|
||||||
# Install the tool in the following situations:
|
[[ $1 =~ ^[\./].* ]] && action=install
|
||||||
# - The tool does not exist.
|
|
||||||
# - The tool needs to be installed from a local path.
|
|
||||||
# - Version of the tool is specificied in the given tool path.
|
|
||||||
# TODO(chizhg): derive a better versioning story for the tools being used.
|
|
||||||
if [[ -z "$(which "${tool}")" || "${action}" == "install" || "${tool}" =~ "@" ]]; then
|
|
||||||
# Avoid running `go get` from root dir of the repository, as it can change go.sum and go.mod files.
|
# Avoid running `go get` from root dir of the repository, as it can change go.sum and go.mod files.
|
||||||
# See discussions in https://github.com/golang/go/issues/27643.
|
# See discussions in https://github.com/golang/go/issues/27643.
|
||||||
if [[ ${action} == "get" && $(pwd) == "${REPO_ROOT_DIR}" ]]; then
|
if [[ ${action} == "get" && $(pwd) == "${REPO_ROOT_DIR}" ]]; then
|
||||||
local temp_dir="$(mktemp -d)"
|
local temp_dir="$(mktemp -d)"
|
||||||
# Swallow the output as we are returning the stdout in the end.
|
# Swallow the output as we are returning the stdout in the end.
|
||||||
pushd "${temp_dir}" > /dev/null 2>&1
|
pushd "${temp_dir}" > /dev/null 2>&1
|
||||||
GOFLAGS="" go ${action} $1 || install_failed=1
|
GOFLAGS="" go ${action} "$1" || install_failed=1
|
||||||
popd > /dev/null 2>&1
|
popd > /dev/null 2>&1
|
||||||
else
|
else
|
||||||
GOFLAGS="" go ${action} $1 || install_failed=1
|
GOFLAGS="" go ${action} "$1" || install_failed=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
(( install_failed )) && return ${install_failed}
|
(( install_failed )) && return ${install_failed}
|
||||||
|
@ -524,17 +536,6 @@ function run_go_tool() {
|
||||||
${tool} "$@"
|
${tool} "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run "kntest" tool
|
|
||||||
# Parameters: $1..$n - parameters passed to the tool
|
|
||||||
function run_kntest() {
|
|
||||||
if [[ "${REPO_NAME}" == "test-infra" ]]; then
|
|
||||||
go run "${REPO_ROOT_DIR}"/kntest/cmd/kntest "$@"
|
|
||||||
else
|
|
||||||
# Always run the latest version.
|
|
||||||
run_go_tool knative.dev/test-infra/kntest/cmd/kntest@master "$@"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Run go-licenses to update licenses.
|
# Run go-licenses to update licenses.
|
||||||
# Parameters: $1 - output file, relative to repo root dir.
|
# Parameters: $1 - output file, relative to repo root dir.
|
||||||
# $2 - directory to inspect.
|
# $2 - directory to inspect.
|
||||||
|
@ -652,6 +653,21 @@ function get_canonical_path() {
|
||||||
echo "$(cd ${path%/*} && echo $PWD/${path##*/})"
|
echo "$(cd ${path%/*} && echo $PWD/${path##*/})"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# List changed files in the current PR.
|
||||||
|
# This is implemented as a function so it can be mocked in unit tests.
|
||||||
|
# It will fail if a file name ever contained a newline character (which is bad practice anyway)
|
||||||
|
function list_changed_files() {
|
||||||
|
if [[ -v PULL_BASE_SHA ]] && [[ -v PULL_PULL_SHA ]]; then
|
||||||
|
# Avoid warning when there are more than 1085 files renamed:
|
||||||
|
# https://stackoverflow.com/questions/7830728/warning-on-diff-renamelimit-variable-when-doing-git-push
|
||||||
|
git config diff.renames 0
|
||||||
|
git --no-pager diff --name-only ${PULL_BASE_SHA}..${PULL_PULL_SHA}
|
||||||
|
else
|
||||||
|
# Do our best if not running in Prow
|
||||||
|
git diff --name-only HEAD^
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Returns the current branch.
|
# Returns the current branch.
|
||||||
function current_branch() {
|
function current_branch() {
|
||||||
local branch_name=""
|
local branch_name=""
|
||||||
|
@ -694,6 +710,29 @@ function get_latest_knative_yaml_source() {
|
||||||
echo "https://storage.googleapis.com/knative-nightly/${repo_name}/latest/${yaml_name}.yaml"
|
echo "https://storage.googleapis.com/knative-nightly/${repo_name}/latest/${yaml_name}.yaml"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shellcheck_new_files() {
|
||||||
|
declare -a array_of_files
|
||||||
|
local failed=0
|
||||||
|
readarray -t -d '\n' array_of_files < <(list_changed_files)
|
||||||
|
for filename in "${array_of_files[@]}"; do
|
||||||
|
if echo "${filename}" | grep -q "^vendor/"; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if file "${filename}" | grep -q "shell script"; then
|
||||||
|
# SC1090 is "Can't follow non-constant source"; we will scan files individually
|
||||||
|
if shellcheck -e SC1090 "${filename}"; then
|
||||||
|
echo "--- PASS: shellcheck on ${filename}"
|
||||||
|
else
|
||||||
|
echo "--- FAIL: shellcheck on ${filename}"
|
||||||
|
failed=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ ${failed} -eq 1 ]]; then
|
||||||
|
fail_script "shellcheck failures"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Initializations that depend on previous functions.
|
# Initializations that depend on previous functions.
|
||||||
# These MUST come last.
|
# These MUST come last.
|
||||||
|
|
||||||
|
|
|
@ -46,15 +46,6 @@ function pr_only_contains() {
|
||||||
[[ -z "$(echo "${CHANGED_FILES}" | grep -v "\(${1// /\\|}\)$")" ]]
|
[[ -z "$(echo "${CHANGED_FILES}" | grep -v "\(${1// /\\|}\)$")" ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
# List changed files in the current PR.
|
|
||||||
# This is implemented as a function so it can be mocked in unit tests.
|
|
||||||
function list_changed_files() {
|
|
||||||
# Avoid warning when there are more than 1085 files renamed:
|
|
||||||
# https://stackoverflow.com/questions/7830728/warning-on-diff-renamelimit-variable-when-doing-git-push
|
|
||||||
git config diff.renames 0
|
|
||||||
git --no-pager diff --name-only ${PULL_BASE_SHA}..${PULL_SHA}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Initialize flags and context for presubmit tests:
|
# Initialize flags and context for presubmit tests:
|
||||||
# CHANGED_FILES, IS_PRESUBMIT_EXEMPT_PR and IS_DOCUMENTATION_PR.
|
# CHANGED_FILES, IS_PRESUBMIT_EXEMPT_PR and IS_DOCUMENTATION_PR.
|
||||||
function initialize_environment() {
|
function initialize_environment() {
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
source "$(dirname "${BASH_SOURCE[0]}")/library.sh"
|
||||||
|
|
||||||
|
if (( ! IS_PROW )); then
|
||||||
|
echo "Local run of shellcheck-presubmit detected"
|
||||||
|
echo "This notably DOES NOT ACT LIKE THE GITHUB PRESUBMIT"
|
||||||
|
echo "The Github presubmit job only runs shellcheck on files you touch"
|
||||||
|
echo "There's no way to locally determine which files you touched:"
|
||||||
|
echo " as git is a distributed VCS, there is no notion of parent until merge"
|
||||||
|
echo " is attempted."
|
||||||
|
echo "So it checks the current content of all files changed in the previous commit"
|
||||||
|
echo " and/or currently staged."
|
||||||
|
fi
|
||||||
|
|
||||||
|
shellcheck_new_files
|
|
@ -656,7 +656,7 @@ k8s.io/kube-openapi/pkg/util/sets
|
||||||
k8s.io/utils/buffer
|
k8s.io/utils/buffer
|
||||||
k8s.io/utils/integer
|
k8s.io/utils/integer
|
||||||
k8s.io/utils/trace
|
k8s.io/utils/trace
|
||||||
# knative.dev/pkg v0.0.0-20200507011344-2581370e4a37
|
# knative.dev/pkg v0.0.0-20200508041145-19b1d7b64df3
|
||||||
knative.dev/pkg/apis
|
knative.dev/pkg/apis
|
||||||
knative.dev/pkg/apis/duck
|
knative.dev/pkg/apis/duck
|
||||||
knative.dev/pkg/apis/duck/v1
|
knative.dev/pkg/apis/duck/v1
|
||||||
|
@ -676,7 +676,7 @@ knative.dev/pkg/metrics
|
||||||
knative.dev/pkg/metrics/metricskey
|
knative.dev/pkg/metrics/metricskey
|
||||||
knative.dev/pkg/reconciler
|
knative.dev/pkg/reconciler
|
||||||
knative.dev/pkg/tracker
|
knative.dev/pkg/tracker
|
||||||
# knative.dev/test-infra v0.0.0-20200506231144-c8dd15bb7f0b
|
# knative.dev/test-infra v0.0.0-20200508015845-8d7d46a46176
|
||||||
knative.dev/test-infra/scripts
|
knative.dev/test-infra/scripts
|
||||||
knative.dev/test-infra/tools/dep-collector
|
knative.dev/test-infra/tools/dep-collector
|
||||||
# sigs.k8s.io/yaml v1.1.0
|
# sigs.k8s.io/yaml v1.1.0
|
||||||
|
|
Loading…
Reference in New Issue