Test script:
#!/bin/bash
rev1="foo"
rev2="\"bar\""
rev3="'bar'"
newrev1="${rev1//[\'\"]}"
newrev2="${rev2//[\'\"]}"
newrev3="${rev3//[\'\"]}"
oldrev1=$(echo "${rev1}" | sed "s/['\"]//g")
oldrev2=$(echo "${rev2}" | sed "s/['\"]//g")
oldrev3=$(echo "${rev3}" | sed "s/['\"]//g")
echo "$newrev1 vs. $oldrev1"
echo "$newrev2 vs. $oldrev2"
echo "$newrev3 vs. $oldrev3"
expected output:
foo vs. foo
bar vs. bar
bar vs. bar
Also fix array item comparison. Test script for the comparison change:
#!/bin/bash
staging_apis=(extensions/v1beta1 extensions/v1 extensions/v1alpha)
group_versions=(v1 extensions/v1beta1 extensions/v1 extensions.k8s.io/v1)
for group_version in ${group_versions[@]}; do
# original code
if [[ " ${staging_apis[@]} " =~ " ${group_version/.*k8s.io/} " ]]; then
echo "orig: vendor/k8s.io/api/${group_version/.*k8s.io/}"
fi
# new code
for api in ${staging_apis[@]}; do
if [[ "${api}" = "${group_version/.*k8s.io/}" ]]; then
echo "new: vendor/k8s.io/api/${group_version/.*k8s.io/}"
fi
done
done
Expected output:
orig: vendor/k8s.io/api/extensions/v1beta1
new: vendor/k8s.io/api/extensions/v1beta1
orig: vendor/k8s.io/api/extensions/v1
new: vendor/k8s.io/api/extensions/v1
orig: vendor/k8s.io/api/extensions/v1
new: vendor/k8s.io/api/extensions/v1
"Decorate" the variables with a no-op function to prevent shellcheck
from complaining that they are not being used. This method provides
visibility to which variables are supposed to be used in a sourcing
script compared to just disabling the warning.
Use "command -v" instead of "which". Also remove the redirections,
since "command -v" does not return an error message if the command isn't
found. Also use "read -r" instead of "read" and quote variables
properly. Do some error handling if "pushd" or "popd" fail. Read values
properly into arrays.
However, one shellcheck error is ignored in trap mechanism. The logic
in trap_add function requires the trap command to be expanded when run.
Just storing the variable into trap doesn't work. Add a shellcheck
disable directive to ignore the error.
An alternative to ignoring could be tricking shellcheck with:
trap ''"${new_cmd}" "${trap_add_name}"
Both verify-golint.sh and verify-shellcheck.sh have the same logic
which checks failure_file in alphabetical order.
In addition, we'd like to add another script which requires the
same logic. So this add a common function for cleanup.
The placeholder documentation introduces a couple of problems:
- it complicates the contributor-experience (forces the CI to run
N times before the contributor finds out that they need to call an .sh
script and include certain files from docs/)
- it forces CLI related pull requests for tools like kubeadm and kubectl
to require top level approval from docs/OWNERS as such PRs still need
to touch the .generated_docs file
Stop tracking the placeholder documentation by applying the
following actions:
- remove the utility set-placeholder-gen-docs()
- make verify-generated-docs.sh only generate in a temporary folder
and not match .generated_docs
- mark generate-docs.sh as an alias for update-generated-docs.sh
- remove all current placeholder files in docs folders admin, man,
user-guide, yaml
- ignore the above folders and .generated_docs in a .gitignore file
Otherwise, calling make followed by bazel might fail, requiring one to
run make clean first.
Additionally, add comments explaining why we must do this.
In go 1.11, go commands will use `GOFLAGS` as default flags, see
https://golang.org/doc/go1.11#go_command.
There is no need to pass GOFLAGS to $goflags, and if we do, go commands
will fail with "duplicate flags" error, e.g.
```
$ make test-integration WHAT=./test/integration/scheduler GOFLAGS="-v"
...
go test: v flag may be set only once
run "go help test" or "go help testflag" for more information
...
```
Pick up some code from https://github.com/heptio/kube-conformance
Fix up build scripts for the new conformance image
Fix Header template and Copyright to make verify job go green
update README and add execute permissions for script
Change-Id: Ib6509acd816cc2fb3a516bfb8e0ff9e32bff8f79