diff --git a/go.mod b/go.mod index 494f96a7..9b87b2bc 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,10 @@ module github.com/gardener/apiserver-proxy go 1.21 require ( - github.com/gardener/gardener v1.83.0 + github.com/gardener/gardener v1.84.0 github.com/golang/mock v1.6.0 github.com/onsi/ginkgo v1.16.5 - github.com/onsi/gomega v1.27.10 + github.com/onsi/gomega v1.29.0 github.com/spf13/pflag v1.0.5 github.com/vishvananda/netlink v1.0.0 golang.org/x/sys v0.13.0 @@ -34,10 +34,11 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/gnostic-models v0.6.8 // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/ironcore-dev/vgopath v0.1.3 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/mailru/easyjson v0.7.7 // indirect @@ -46,7 +47,7 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/nxadm/tail v1.4.8 // indirect - github.com/onsi/ginkgo/v2 v2.12.1 // indirect + github.com/onsi/ginkgo/v2 v2.13.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/spf13/afero v1.9.5 // indirect diff --git a/go.sum b/go.sum index cb18a008..0734f775 100644 --- a/go.sum +++ b/go.sum @@ -70,8 +70,8 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/gardener/gardener v1.83.0 h1:lszriM/fi9A+TOKPOdQR93qAIhysBMFa4q2wpIU2S/8= -github.com/gardener/gardener v1.83.0/go.mod h1:WbCEy0CuG3fk1QFDeQeagwvWRtA7FaiuP9ska9EA7Xc= +github.com/gardener/gardener v1.84.0 h1:sfW8RljFT6vaShlHV04RW/99GkTdyiwfsoUDEehVNVE= +github.com/gardener/gardener v1.84.0/go.mod h1:3XZ+Yn5iHl0acqUIVZ0K78p1OYWp52sRBQOJW6sCRR8= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -139,8 +139,8 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= @@ -172,6 +172,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/ironcore-dev/vgopath v0.1.3 h1:/g3QJ29VrUkYEy52kcUhtvQ3mxfbMIlI1uvEbmt6S4E= +github.com/ironcore-dev/vgopath v0.1.3/go.mod h1:edfsCmU2M4r2N+t4RebSluq//tF3vzogyiDDhcf7MXs= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -209,12 +211,12 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.12.1 h1:uHNEO1RP2SpuZApSkel9nEh1/Mu+hmQe7Q+Pepg5OYA= -github.com/onsi/ginkgo/v2 v2.12.1/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= +github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= +github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= +github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= +github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/vendor/github.com/gardener/gardener/hack/LICENSE_BOILERPLATE.txt b/vendor/github.com/gardener/gardener/hack/LICENSE_BOILERPLATE.txt old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/add-license-header.sh b/vendor/github.com/gardener/gardener/hack/add-license-header.sh old mode 100755 new mode 100644 index dd5b9ab0..28f2b8ed --- a/vendor/github.com/gardener/gardener/hack/add-license-header.sh +++ b/vendor/github.com/gardener/gardener/hack/add-license-header.sh @@ -24,12 +24,10 @@ addlicense \ -ignore ".idea/**" \ -ignore ".vscode/**" \ -ignore "dev/**" \ - -ignore "vendor/**" \ -ignore "**/*.md" \ -ignore "**/*.html" \ -ignore "**/*.yaml" \ -ignore "**/Dockerfile" \ - -ignore "hack/tools/gomegacheck/**" \ -ignore "pkg/component/**/*.sh" \ -ignore "third_party/gopkg.in/yaml.v2/**" \ . diff --git a/vendor/github.com/gardener/gardener/hack/check-apidiff.sh b/vendor/github.com/gardener/gardener/hack/check-apidiff.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/check-charts.sh b/vendor/github.com/gardener/gardener/hack/check-charts.sh old mode 100755 new mode 100644 index 8371b5aa..499990cd --- a/vendor/github.com/gardener/gardener/hack/check-charts.sh +++ b/vendor/github.com/gardener/gardener/hack/check-charts.sh @@ -29,7 +29,7 @@ if [[ -d "$1" ]]; then echo "Checking whether all charts can be rendered" for chart_dir in $(find charts -type d -exec test -f '{}'/Chart.yaml \; -print -prune | sort); do [ -f "$chart_dir/values-test.yaml" ] && values_files="-f $chart_dir/values-test.yaml" || unset values_files - helm template $values_files "$chart_dir" 3>&1 1>/dev/null 2>&3 | (grep -v "found symbolic link in path" || true) + helm template $values_files "$chart_dir" > /dev/null 2> >(sed '/found symbolic link in path/d' >&2) done fi diff --git a/vendor/github.com/gardener/gardener/hack/check-generate.sh b/vendor/github.com/gardener/gardener/hack/check-generate.sh old mode 100755 new mode 100644 index 59679519..c966f785 --- a/vendor/github.com/gardener/gardener/hack/check-generate.sh +++ b/vendor/github.com/gardener/gardener/hack/check-generate.sh @@ -16,7 +16,7 @@ set -e -echo "> Generate / Vendor Check" +echo "> Generate" makefile="$1/Makefile" check_branch="__check" @@ -24,14 +24,13 @@ initialized_git=false stashed=false checked_out=false generated=false -vendored=false function delete-check-branch { git rev-parse --verify "$check_branch" &>/dev/null && git branch -q -D "$check_branch" || : } function cleanup { - if [[ "$generated" == true ]] || [[ "$vendored" == true ]]; then + if [[ "$generated" == true ]]; then if ! clean_err="$(make -f "$makefile" clean && git reset --hard -q && git clean -qdf)"; then echo "Could not clean: $clean_err" fi @@ -107,20 +106,19 @@ if which git &>/dev/null; then exit 1 fi - echo ">> make revendor" - vendored=true - if ! out=$(make -f "$makefile" revendor 2>&1); then - echo "Error during calling make revendor: $out" + echo ">> make tidy" + if ! out=$(make -f "$makefile" tidy 2>&1); then + echo "Error during calling make tidy: $out" exit 1 fi new_status="$(git status -s)" if [[ "$old_status" != "$new_status" ]]; then - echo "make revendor needs to be run:" + echo "make tidy needs to be run:" echo "$new_status" exit 1 fi else - echo "No git detected, cannot run vendor check" + echo "No git detected, cannot run make check-generate" fi exit 0 diff --git a/vendor/github.com/gardener/gardener/hack/check-imports.sh b/vendor/github.com/gardener/gardener/hack/check-imports.sh old mode 100755 new mode 100644 index c42828a7..2ea80cd2 --- a/vendor/github.com/gardener/gardener/hack/check-imports.sh +++ b/vendor/github.com/gardener/gardener/hack/check-imports.sh @@ -31,6 +31,24 @@ echo "> Check Imports" this_module=$(go list -m) +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +VGOPATH="$VGOPATH" + +# Ensure that if GOPATH is set, the GOPATH/{bin,pkg} directory exists. This seems to be not always +# the case in certain environments like Prow. As we will create a symlink against the bin folder we +# need to make sure that the bin directory is present in the GOPATH. +if [ -n "$GOPATH" ] && [ ! -d "$GOPATH/bin" ]; then mkdir -p "$GOPATH/bin"; fi +if [ -n "$GOPATH" ] && [ ! -d "$GOPATH/pkg" ]; then mkdir -p "$GOPATH/pkg"; fi + +VIRTUAL_GOPATH="$(mktemp -d)" +trap 'rm -rf "$VIRTUAL_GOPATH"' EXIT + +# Setup virtual GOPATH so the codegen tools work as expected. +(cd "$SCRIPT_DIR/.."; go mod download && "$VGOPATH" -o "$VIRTUAL_GOPATH") + +export GOROOT="${GOROOT:-"$(go env GOROOT)"}" +export GOPATH="$VIRTUAL_GOPATH" + # We need to explicitly pass GO111MODULE=off to import-boss as it is significantly slower otherwise, # see https://github.com/kubernetes/code-generator/issues/100. export GO111MODULE=off diff --git a/vendor/github.com/gardener/gardener/hack/check-license-header.sh b/vendor/github.com/gardener/gardener/hack/check-license-header.sh old mode 100755 new mode 100644 index 84e3fb3c..26724f58 --- a/vendor/github.com/gardener/gardener/hack/check-license-header.sh +++ b/vendor/github.com/gardener/gardener/hack/check-license-header.sh @@ -22,13 +22,11 @@ missing_license_header_files="$(addlicense \ -ignore ".idea/**" \ -ignore ".vscode/**" \ -ignore "dev/**" \ - -ignore "vendor/**" \ -ignore "**/*.md" \ -ignore "**/*.html" \ -ignore "**/*.yaml" \ -ignore "**/Dockerfile" \ - -ignore "hack/tools/gomegacheck/**" \ - -ignore "pkg/component/**/*.sh" \ + -ignore "pkg/**/*.sh" \ -ignore "third_party/gopkg.in/yaml.v2/**" \ .)" || true diff --git a/vendor/github.com/gardener/gardener/hack/check-plutono-dashboards.sh b/vendor/github.com/gardener/gardener/hack/check-plutono-dashboards.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/check-skaffold-deps-for-binary.sh b/vendor/github.com/gardener/gardener/hack/check-skaffold-deps-for-binary.sh old mode 100755 new mode 100644 index 5b24d93c..eb8b7536 --- a/vendor/github.com/gardener/gardener/hack/check-skaffold-deps-for-binary.sh +++ b/vendor/github.com/gardener/gardener/hack/check-skaffold-deps-for-binary.sh @@ -21,7 +21,10 @@ binary_name="" skaffold_config_name="" parse_flags() { - while test $# -gt 0; do + operation="$1" + shift + + while test $# -gt 1; do case "$1" in --skaffold-file) shift; skaffold_file="$1" @@ -57,7 +60,7 @@ path_actual_dependencies="${out_dir}/actual-$skaffold_file-deps-$binary_name.txt echo "$skaffold_yaml" |\ yq eval "select(.metadata.name == \"$skaffold_config_name\") | .build.artifacts[] | select(.ko.main == \"./cmd/$binary_name\") | .ko.dependencies.paths[]?" - |\ - sort |\ + sort -f |\ uniq > "$path_current_skaffold_dependencies" module_name=$(go list -m) @@ -65,28 +68,55 @@ module_prefix="$module_name/" go list -f '{{ join .Deps "\n" }}' "./cmd/$binary_name" |\ grep "$module_prefix" |\ sed "s@$module_prefix@@g" |\ - sort |\ + sort -f |\ uniq > "$path_actual_dependencies" -# always add vendor directory and VERSION file -echo "vendor" >> "$path_actual_dependencies" +# always add VERSION file echo "VERSION" >> "$path_actual_dependencies" # sort dependencies -sort -o $path_current_skaffold_dependencies{,} -sort -o $path_actual_dependencies{,} - -echo -n ">> Checking defined dependencies in Skaffold config '$skaffold_config_name' for '$binary_name' in '$skaffold_file'..." -if ! diff="$(diff "$path_current_skaffold_dependencies" "$path_actual_dependencies")"; then - echo - echo ">>> The following actual dependencies are missing in $skaffold_file (need to be added):" - echo "$diff" | grep '>' | awk '{print $2}' - echo - echo ">>> The following dependencies defined in $skaffold_file are not needed actually (need to be removed):" - echo "$diff" | grep '<' | awk '{print $2}' - echo - - exit 1 -else - echo " success." -fi +sort -fo "$path_current_skaffold_dependencies"{,} +sort -fo "$path_actual_dependencies"{,} + +case "$operation" in + check) + echo -n ">> Checking defined dependencies in Skaffold config '$skaffold_config_name' for '$binary_name' in '$skaffold_file'..." + if ! diff="$(diff "$path_current_skaffold_dependencies" "$path_actual_dependencies")"; then + echo + echo ">>> The following actual dependencies are missing (need to be added):" + echo "$diff" | grep '>' | awk '{print $2}' + echo + echo ">>> The following dependencies are not needed actually (need to be removed):" + echo "$diff" | grep '<' | awk '{print $2}' + echo + echo ">>> Run './hack/update-skaffold-deps.sh' to fix." + + exit 1 + else + echo " success." + fi + ;; + update) + echo -n ">> Updating dependencies in Skaffold config '$skaffold_config_name' for '$binary_name' in '$skaffold_file'..." + + yq eval -i "select(.metadata.name == \"$skaffold_config_name\") |= .build.artifacts[] |= select(.ko.main == \"./cmd/$binary_name\") |= .ko.dependencies.paths |= [$(cat "$path_actual_dependencies" | sed -e 's/^/"/' -e 's/$/"/' | tr '\n' ',' | sed 's/,$//')]" "$skaffold_file" + + if ! diff="$(diff "$path_current_skaffold_dependencies" "$path_actual_dependencies")"; then + echo + echo ">>> Added the following dependencies:" + echo "$diff" | grep '>' | awk '{print $2}' + echo + echo ">>> Removed the following dependencies:" + echo "$diff" | grep '<' | awk '{print $2}' + echo + + exit 1 + else + echo " already up to date." + fi + ;; + *) + echo "Unknown operation: $operation" + exit 1 + ;; +esac diff --git a/vendor/github.com/gardener/gardener/hack/check-skaffold-deps.sh b/vendor/github.com/gardener/gardener/hack/check-skaffold-deps.sh old mode 100755 new mode 100644 index 03411ada..48cf864e --- a/vendor/github.com/gardener/gardener/hack/check-skaffold-deps.sh +++ b/vendor/github.com/gardener/gardener/hack/check-skaffold-deps.sh @@ -16,34 +16,36 @@ set -e -echo "> Check Skaffold Dependencies" +operation="${1:-check}" -check_successful=true +echo "> ${operation^} Skaffold Dependencies" + +success=true repo_root="$(git rev-parse --show-toplevel)" -function check() { - if ! $repo_root/hack/check-skaffold-deps-for-binary.sh --skaffold-file $1 --binary $2 --skaffold-config $3; then - check_successful=false +function run() { + if ! "$repo_root"/hack/check-skaffold-deps-for-binary.sh "$operation" --skaffold-file "$1" --binary "$2" --skaffold-config "$3"; then + success=false fi } # skaffold.yaml -check "skaffold.yaml" "gardener-admission-controller" "controlplane" -check "skaffold.yaml" "gardener-apiserver" "controlplane" -check "skaffold.yaml" "gardener-controller-manager" "controlplane" -check "skaffold.yaml" "gardener-extension-provider-local" "provider-local" -check "skaffold.yaml" "gardener-resource-manager" "gardenlet" -check "skaffold.yaml" "gardener-scheduler" "controlplane" -check "skaffold.yaml" "gardenlet" "gardenlet" +run "skaffold.yaml" "gardener-admission-controller" "controlplane" +run "skaffold.yaml" "gardener-apiserver" "controlplane" +run "skaffold.yaml" "gardener-controller-manager" "controlplane" +run "skaffold.yaml" "gardener-extension-provider-local" "provider-local" +run "skaffold.yaml" "gardener-resource-manager" "gardenlet" +run "skaffold.yaml" "gardener-scheduler" "controlplane" +run "skaffold.yaml" "gardenlet" "gardenlet" # skaffold-operator.yaml -check "skaffold-operator.yaml" "gardener-operator" "gardener-operator" -check "skaffold-operator.yaml" "gardener-resource-manager" "gardener-operator" -check "skaffold-operator.yaml" "gardener-admission-controller" "gardener-operator" -check "skaffold-operator.yaml" "gardener-apiserver" "gardener-operator" -check "skaffold-operator.yaml" "gardener-controller-manager" "gardener-operator" -check "skaffold-operator.yaml" "gardener-scheduler" "gardener-operator" - -if [ "$check_successful" = false ] ; then +run "skaffold-operator.yaml" "gardener-operator" "gardener-operator" +run "skaffold-operator.yaml" "gardener-resource-manager" "gardener-operator" +run "skaffold-operator.yaml" "gardener-admission-controller" "gardener-operator" +run "skaffold-operator.yaml" "gardener-apiserver" "gardener-operator" +run "skaffold-operator.yaml" "gardener-controller-manager" "gardener-operator" +run "skaffold-operator.yaml" "gardener-scheduler" "gardener-operator" + +if ! $success ; then exit 1 fi diff --git a/vendor/github.com/gardener/gardener/hack/check.sh b/vendor/github.com/gardener/gardener/hack/check.sh old mode 100755 new mode 100644 index 2753e371..2925af16 --- a/vendor/github.com/gardener/gardener/hack/check.sh +++ b/vendor/github.com/gardener/gardener/hack/check.sh @@ -34,7 +34,7 @@ golangci-lint run $GOLANGCI_LINT_CONFIG_FILE --timeout 10m $@ echo "Executing gofmt/goimports" folders=() -for f in $@; do +for f in "$@"; do folders+=( "$(echo $f | sed 's/\.\.\.//')" ) done unformatted_files="$(goimports -l ${folders[*]})" diff --git a/vendor/github.com/gardener/gardener/hack/cherry-pick-pull.sh b/vendor/github.com/gardener/gardener/hack/cherry-pick-pull.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/ci-common.sh b/vendor/github.com/gardener/gardener/hack/ci-common.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/ci-e2e-kind-ha-multi-zone.sh b/vendor/github.com/gardener/gardener/hack/ci-e2e-kind-ha-multi-zone.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/ci-e2e-kind-ha-single-zone.sh b/vendor/github.com/gardener/gardener/hack/ci-e2e-kind-ha-single-zone.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/ci-e2e-kind-migration-ha-single-zone.sh b/vendor/github.com/gardener/gardener/hack/ci-e2e-kind-migration-ha-single-zone.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/ci-e2e-kind-migration.sh b/vendor/github.com/gardener/gardener/hack/ci-e2e-kind-migration.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/ci-e2e-kind-operator.sh b/vendor/github.com/gardener/gardener/hack/ci-e2e-kind-operator.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/ci-e2e-kind-upgrade.sh b/vendor/github.com/gardener/gardener/hack/ci-e2e-kind-upgrade.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/ci-e2e-kind.sh b/vendor/github.com/gardener/gardener/hack/ci-e2e-kind.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/clean.sh b/vendor/github.com/gardener/gardener/hack/clean.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/compare-k8s-admission-plugins.sh b/vendor/github.com/gardener/gardener/hack/compare-k8s-admission-plugins.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/compare-k8s-api-groups.sh b/vendor/github.com/gardener/gardener/hack/compare-k8s-api-groups.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/compare-k8s-controllers.sh b/vendor/github.com/gardener/gardener/hack/compare-k8s-controllers.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/compare-k8s-feature-gates.sh b/vendor/github.com/gardener/gardener/hack/compare-k8s-feature-gates.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/compute-k8s-controllers.sh b/vendor/github.com/gardener/gardener/hack/compute-k8s-controllers.sh new file mode 100644 index 00000000..559a136c --- /dev/null +++ b/vendor/github.com/gardener/gardener/hack/compute-k8s-controllers.sh @@ -0,0 +1,175 @@ +#!/usr/bin/env bash +# +# Copyright 2023 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file. +# +# 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 -e + +usage() { + echo "Usage:" + echo "> compute-k8s-controllers.sh [ -h | ]" + echo + echo ">> For example: compute-k8s-controllers.sh 1.26 1.27" + + exit 0 +} + +if [ "$1" == "-h" ] || [ "$#" -ne 2 ]; then + usage +fi + +versions=("$1" "$2") + +out_dir=$(mktemp -d) +function cleanup_output { + rm -rf "$out_dir" +} +trap cleanup_output EXIT + +# Define the path map +declare -A path_map=( + ["attachdetach"]="pkg/controller/volume/attachdetach/attach_detach_controller.go" + ["bootstrapsigner"]="pkg/controller/bootstrap/bootstrapsigner.go" + ["cloud-node-lifecycle"]="staging/src/k8s.io/cloud-provider/controllers/nodelifecycle/node_lifecycle_controller.go" + ["clusterrole-aggregation"]="pkg/controller/clusterroleaggregation/clusterroleaggregation_controller.go" + ["cronjob"]="pkg/controller/cronjob/cronjob_controllerv2.go" + ["csrapproving"]="pkg/controller/certificates/approver/sarapprove.go" + ["csrcleaner"]="pkg/controller/certificates/cleaner/cleaner.go" + ["csrsigning"]="pkg/controller/certificates/signer/signer.go" + ["daemonset"]="pkg/controller/daemon/daemon_controller.go" + ["deployment"]="pkg/controller/deployment/deployment_controller.go" + ["disruption"]="pkg/controller/disruption/disruption.go" + ["endpoint"]="pkg/controller/endpoint/endpoints_controller.go" + ["endpointslice"]="pkg/controller/endpointslice/endpointslice_controller.go" + ["endpointslicemirroring"]="pkg/controller/endpointslicemirroring/endpointslicemirroring_controller.go" + ["ephemeral-volume"]="pkg/controller/volume/ephemeral/controller.go" + ["garbagecollector"]="pkg/controller/garbagecollector/garbagecollector.go" + ["horizontalpodautoscaling"]="pkg/controller/podautoscaler/horizontal.go" + ["job"]="pkg/controller/job/job_controller.go" + ["legacy-service-account-token-cleaner"]="pkg/controller/serviceaccount/legacy_serviceaccount_token_cleaner.go" + ["namespace"]="pkg/controller/namespace/namespace_controller.go" + ["nodeipam"]="pkg/controller/nodeipam/node_ipam_controller.go" + ["nodelifecycle"]="pkg/controller/nodelifecycle/node_lifecycle_controller.go" + ["persistentvolume-binder"]="pkg/controller/volume/persistentvolume/pv_controller_base.go" + ["persistentvolume-expander"]="pkg/controller/volume/expand/expand_controller.go" + ["podgc"]="pkg/controller/podgc/gc_controller.go" + ["pv-protection"]="pkg/controller/volume/pvprotection/pv_protection_controller.go" + ["pvc-protection"]="pkg/controller/volume/pvcprotection/pvc_protection_controller.go" + ["replicaset"]="pkg/controller/replicaset/replica_set.go" + ["replicationcontroller"]="pkg/controller/replication/replication_controller.go" + ["resource-claim-controller"]="pkg/controller/resourceclaim/controller.go" + ["resourcequota"]="pkg/controller/resourcequota/resource_quota_controller.go" + ["root-ca-cert-publisher"]="pkg/controller/certificates/rootcacertpublisher/publisher.go" + ["route"]="staging/src/k8s.io/cloud-provider/controllers/route/route_controller.go" + ["service"]="staging/src/k8s.io/cloud-provider/controllers/service/controller.go" + ["serviceaccount"]="pkg/controller/serviceaccount/serviceaccounts_controller.go" + ["serviceaccount-token"]="pkg/controller/serviceaccount/tokens_controller.go" + ["statefulset"]="pkg/controller/statefulset/stateful_set.go" + ["storage-version-gc"]="pkg/controller/storageversiongc/gc_controller.go" + ["tokencleaner"]="pkg/controller/bootstrap/tokencleaner.go" + ["ttl"]="pkg/controller/ttl/ttl_controller.go" + ["ttl-after-finished"]="pkg/controller/ttlafterfinished/ttlafterfinished_controller.go" +) + +for version in "${versions[@]}"; do + rm -rf "${out_dir}/kubernetes-${version}" + rm -f "${out_dir}/k8s-controllers-${version}.txt" + + git clone --depth 1 --filter=blob:none --sparse https://github.com/kubernetes/kubernetes -b "release-${version}" "${out_dir}/kubernetes-${version}" + pushd "${out_dir}/kubernetes-${version}" > /dev/null + git sparse-checkout set "cmd/kube-controller-manager" "pkg/controller" "staging/src/k8s.io/cloud-provider/controllers" + popd > /dev/null + + if [ "$version" \< "1.26" ]; then + names=$(grep -o 'controllers\["[^"]*' "${out_dir}/kubernetes-${version}/cmd/kube-controller-manager/app/controllermanager.go" | awk -F '"' '{print $2}') + # This is a special controller which is not initialized normally, see https://github.com/kubernetes/kubernetes/blob/99151c39b7d4595632f7745ba7fb4dea4356f7fd/cmd/kube-controller-manager/app/controllermanager.go#L405-L411 + names+=" serviceaccount-token" + elif [ "$version" \< "1.28" ]; then + names=$(grep -o 'register("[^"]*' "${out_dir}/kubernetes-${version}/cmd/kube-controller-manager/app/controllermanager.go" | awk -F '"' '{print $2}') + # This is a special controller which is not initialized normally, see https://github.com/kubernetes/kubernetes/blob/99151c39b7d4595632f7745ba7fb4dea4356f7fd/cmd/kube-controller-manager/app/controllermanager.go#L405-L411 + names+=" serviceaccount-token" + else + names=$(grep -E 'func KCMControllerAliases\(\) map\[string\]string \{' "${out_dir}/kubernetes-${version}/cmd/kube-controller-manager/names/controller_names.go" -A 200 | awk -F '[" :]+' '/^ \"[a-zA-Z0-9-]+\"/ {print $2}') + fi + + for name in $names; do + if [ ! "${path_map[$name]}" ]; then + echo "No path mapping found for $name", The controller could have been removed or the path might have changed. + echo "Please enhance the map in the script with the path for this controller." + exit 1 + fi + done + + unset api_group_controllers + declare -A api_group_controllers + + for controller in $names; do + file_path="${out_dir}/kubernetes-${version}/${path_map[$controller]}" + if [ -f "$file_path" ]; then + # Find lines containing 'k8s.io/api/' in the file, and extract content after 'k8s.io/api/' up to + # the next double quote. This will be the API groups used for this controller. + api_groups=$(grep -o 'k8s\.io/api/[^"]*' "$file_path" | awk -F 'k8s.io/api/' '{print $2}') + for api_group in $api_groups + do + api_group=$(echo "$api_group" | tr -d '[:space:]' | sed 's/^core\/v1$/v1/' | sed 's/apiserverinternal/internal/') + if [ -n "$api_group" ]; then + api_group_controllers["$api_group"]+="$controller " + fi + done + else + echo "The file $file_path cannot be found. Please enhance the map in the script with the correct path for this controller." + exit 1 + fi + done + + for api_group in "${!api_group_controllers[@]}"; do + echo "$api_group:$(echo "${api_group_controllers[$api_group]}" | tr ' ' '\n' | sort | tr '\n' ' ')" >> "${out_dir}/k8s-controllers-${version}.txt" + done + + sort -o "${out_dir}/k8s-controllers-${version}.txt" "${out_dir}/k8s-controllers-${version}.txt" +done + +echo +echo "kube-controller-manager controllers added in $2 compared to $1:" +IFS=$'\n' read -r -d '' -a added_lines < <(diff "${out_dir}/k8s-controllers-$1.txt" "${out_dir}/k8s-controllers-$2.txt" | grep '^>' | sed 's/^> //' && printf '\0') +for added_line in "${added_lines[@]}"; do + api_group=$(echo "$added_line" | awk -F ': ' '{print $1}') + controllers=$(echo "$added_line" | awk -F ': ' '{print $2}' | tr ' ' '\n') + + # Find the corresponding line in the other file + old_line=$(grep "^$api_group: " "${out_dir}/k8s-controllers-$1.txt" | awk -F ': ' '{print $2}' | tr ' ' '\n') + + added_controllers=$(comm -23 <(echo "$controllers" | sort) <(echo "$old_line" | sort) | tr '\n' ' ') + + if [ -n "$added_controllers" ]; then + echo "Added Controllers for API Group [$api_group]: $added_controllers" + fi +done + +echo +echo "kube-controller-manager controllers removed in $2 compared to $1:" +IFS=$'\n' read -r -d '' -a removed_lines < <(diff "${out_dir}/k8s-controllers-$1.txt" "${out_dir}/k8s-controllers-$2.txt" | grep '^<' | sed 's/^< //' && printf '\0') +for removed_line in "${removed_lines[@]}"; do + api_group=$(echo "$removed_line" | awk -F ': ' '{print $1}') + controllers=$(echo "$removed_line" | awk -F ': ' '{print $2}' | tr ' ' '\n') + + # Find the corresponding line in the other file + new_line=$(grep "^$api_group: " "${out_dir}/k8s-controllers-$2.txt" | awk -F ': ' '{print $2}' | tr ' ' '\n') + + removed_controllers=$(comm -23 <(echo "$controllers" | sort) <(echo "$new_line" | sort) | tr '\n' ' ') + + if [ -n "$removed_controllers" ]; then + echo "Removed Controllers for API Group [$api_group]: $removed_controllers" + fi +done diff --git a/vendor/github.com/gardener/gardener/hack/download_gardener_source_code.sh b/vendor/github.com/gardener/gardener/hack/download_gardener_source_code.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/format.sh b/vendor/github.com/gardener/gardener/hack/format.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/gardener-down.sh b/vendor/github.com/gardener/gardener/hack/gardener-down.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/gardener-extensions-down.sh b/vendor/github.com/gardener/gardener/hack/gardener-extensions-down.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/gardener-extensions-up.sh b/vendor/github.com/gardener/gardener/hack/gardener-extensions-up.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/generate-controller-registration.sh b/vendor/github.com/gardener/gardener/hack/generate-controller-registration.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/generate-crds.sh b/vendor/github.com/gardener/gardener/hack/generate-crds.sh old mode 100755 new mode 100644 index 179994a5..1655ef6e --- a/vendor/github.com/gardener/gardener/hack/generate-crds.sh +++ b/vendor/github.com/gardener/gardener/hack/generate-crds.sh @@ -42,6 +42,25 @@ add_keep_object_annotation=false k8s_io_api_approval_reason="unapproved, temporarily squatting" crd_options="" +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +VGOPATH="$VGOPATH" + +# Ensure that if GOPATH is set, the GOPATH/{bin,pkg} directory exists. This seems to be not always +# the case in certain environments like Prow. As we will create a symlink against the bin folder we +# need to make sure that the bin directory is present in the GOPATH. +if [ -n "$GOPATH" ] && [ ! -d "$GOPATH/bin" ]; then mkdir -p "$GOPATH/bin"; fi +if [ -n "$GOPATH" ] && [ ! -d "$GOPATH/pkg" ]; then mkdir -p "$GOPATH/pkg"; fi + +VIRTUAL_GOPATH="$(mktemp -d)" +trap 'rm -rf "$VIRTUAL_GOPATH"' EXIT + +# Setup virtual GOPATH so the codegen tools work as expected. +(cd "$SCRIPT_DIR/.."; go mod download && "$VGOPATH" -o "$VIRTUAL_GOPATH") + +export GOROOT="${GOROOT:-"$(go env GOROOT)"}" +export GOPATH="$VIRTUAL_GOPATH" +export GO111MODULE=off + get_group_package () { case "$1" in "extensions.gardener.cloud") @@ -63,7 +82,7 @@ get_group_package () { echo "github.com/fluent/fluent-operator/v2/apis/fluentbit/v1alpha2" ;; "autoscaling.k8s.io") - echo "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/..." + echo "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1" ;; "machine.sapcloud.io") echo "github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1" @@ -93,7 +112,7 @@ generate_group () { if [ -z "$package" ] ; then exit 1 fi - local package_path="$(go list -f '{{ .Dir }}' "$package" | tr '\n' ';')" + local package_path="$(go list -f '{{ .Dir }}' "$package")" if [ -z "$package_path" ] ; then exit 1 fi @@ -105,13 +124,22 @@ generate_group () { # etcd-druid, due to adverse interaction with VPA. # See https://github.com/gardener/gardener/pull/6850 and https://github.com/gardener/gardener/pull/8560#discussion_r1347470394 # TODO(shreyas-s-rao): Remove this workaround as soon as the scale subresource is supported properly. - etcd_api_types_file="$(dirname "$0")/../vendor/github.com/gardener/etcd-druid/api/v1alpha1/types_etcd.go" + etcd_druid_dir="$(go list -f '{{ .Dir }}' "github.com/gardener/etcd-druid")" + etcd_api_types_file="${etcd_druid_dir}/api/v1alpha1/types_etcd.go" + # Create a local copy outside the mod cache path in order to patch the types file via sed. + etcd_api_types_backup="$(mktemp -d)/types_etcd.go" + cp "$etcd_api_types_file" "$etcd_api_types_backup" + chmod +w "$etcd_api_types_file" "$etcd_druid_dir/api/v1alpha1/" + trap 'cp "$etcd_api_types_backup" "$etcd_api_types_file" && chmod -w "$etcd_druid_dir/api/v1alpha1/"' EXIT sed -i '/\/\/ +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.labelSelector/d' "$etcd_api_types_file" $generate - git checkout "$etcd_api_types_file" elif [[ "$group" == "autoscaling.k8s.io" ]]; then # See https://github.com/kubernetes/autoscaler/blame/master/vertical-pod-autoscaler/hack/generate-crd-yaml.sh#L43-L45 generator_output="$(mktemp -d)/controller-gen.log" + # As go list does not work with symlinks we need to manually construct the package paths to correctly + # generate v1beta2 CRDs. + package_path="${package_path};${package_path}beta2;" + generate="controller-gen crd"$crd_options" paths="$package_path" output:crd:dir="$output_dir_temp" output:stdout" $generate &> "$generator_output" ||: grep -v -e 'map keys must be strings, not int' -e 'not all generators ran successfully' -e 'usage' "$generator_output" && { echo "Failed to generate CRD YAMLs."; exit 1; } else diff --git a/vendor/github.com/gardener/gardener/hack/generate-groups.sh b/vendor/github.com/gardener/gardener/hack/generate-groups.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/generate-imagename-constants.sh b/vendor/github.com/gardener/gardener/hack/generate-imagename-constants.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/generate-internal-groups.sh b/vendor/github.com/gardener/gardener/hack/generate-internal-groups.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/generate-logcheck-symlinks.sh b/vendor/github.com/gardener/gardener/hack/generate-logcheck-symlinks.sh new file mode 100644 index 00000000..e079f03c --- /dev/null +++ b/vendor/github.com/gardener/gardener/hack/generate-logcheck-symlinks.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# Copyright 2023 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +# +# 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 + +# Create symlinks to local mod chache for logr and controller-runtime log. + +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +LOGCHECK_DIR="$LOGCHECK_DIR" + +cd "$SCRIPT_DIR"/.. +echo $LOGCHECK_DIR +LOGR_DIR=$(go list -f '{{ .Dir }}' github.com/go-logr/logr) +CONTROLLER_RUNTIME_LOGR_DIR=$(go list -f '{{ .Dir }}' sigs.k8s.io/controller-runtime/pkg/log) + +if [ ! -h "./$LOGCHECK_DIR/pkg/logcheck/testdata/src/github.com/go-logr/logr" ]; then + ln -s "$LOGR_DIR" "./$LOGCHECK_DIR/pkg/logcheck/testdata/src/github.com/go-logr/logr" +fi +if [ ! -h "./$LOGCHECK_DIR/pkg/logcheck/testdata/src/sigs.k8s.io/controller-runtime/pkg/log" ]; then + ln -s "$CONTROLLER_RUNTIME_LOGR_DIR" "./$LOGCHECK_DIR/pkg/logcheck/testdata/src/sigs.k8s.io/controller-runtime/pkg/log" +fi diff --git a/vendor/github.com/gardener/gardener/hack/generate-monitoring-docs.sh b/vendor/github.com/gardener/gardener/hack/generate-monitoring-docs.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/generate-parallel.sh b/vendor/github.com/gardener/gardener/hack/generate-parallel.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/generate-sequential.sh b/vendor/github.com/gardener/gardener/hack/generate-sequential.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/generate.sh b/vendor/github.com/gardener/gardener/hack/generate.sh old mode 100755 new mode 100644 index bfd431d3..d236964c --- a/vendor/github.com/gardener/gardener/hack/generate.sh +++ b/vendor/github.com/gardener/gardener/hack/generate.sh @@ -16,7 +16,7 @@ set -e -WHAT="protobuf codegen manifests logcheck gomegacheck monitoring-docs" +WHAT="protobuf codegen manifests logcheck monitoring-docs" CODEGEN_GROUPS="" MANIFESTS_DIRS="" MODE="" @@ -78,12 +78,12 @@ run_target() { $REPO_ROOT/hack/update-protobuf.sh ;; codegen) - local mode="${MODE:-sequential}" + local mode="${MODE:-sequential}" $REPO_ROOT/hack/update-codegen.sh --groups "$CODEGEN_GROUPS" --mode "$mode" ;; manifests) local which=() - local mode="${MODE:-parallel}" + local mode="${MODE:-parallel}" if [[ -z "$MANIFESTS_DIRS" ]]; then which=("${DEFAULT_MANIFESTS_DIRS[@]}") @@ -105,14 +105,11 @@ run_target() { logcheck) cd "$REPO_ROOT/$LOGCHECK_DIR" && go generate ./... ;; - gomegacheck) - cd "$REPO_ROOT/$GOMEGACHECK_DIR" && go generate ./... - ;; monitoring-docs) $REPO_ROOT/hack/generate-monitoring-docs.sh ;; *) - printf "ERROR: Unknown target: $target. Available targets are 'protobuf', 'codegen', 'manifests', 'logcheck', 'gomegacheck', 'monitoring-docs'.\n\n" + printf "ERROR: Unknown target: $target. Available targets are 'protobuf', 'codegen', 'manifests', 'logcheck', 'monitoring-docs'.\n\n" ;; esac } diff --git a/vendor/github.com/gardener/gardener/hack/get-build-ld-flags.sh b/vendor/github.com/gardener/gardener/hack/get-build-ld-flags.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/hook-me.sh b/vendor/github.com/gardener/gardener/hack/hook-me.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/install.sh b/vendor/github.com/gardener/gardener/hack/install.sh old mode 100755 new mode 100644 index 718d1bfd..25282b2e --- a/vendor/github.com/gardener/gardener/hack/install.sh +++ b/vendor/github.com/gardener/gardener/hack/install.sh @@ -21,5 +21,5 @@ echo "> Install" LD_FLAGS="${LD_FLAGS:-$($(dirname $0)/get-build-ld-flags.sh)}" CGO_ENABLED=0 GOOS=$(go env GOOS) GOARCH=$(go env GOARCH) GO111MODULE=on \ - go install -mod=vendor -ldflags "$LD_FLAGS" \ + go install -ldflags "$LD_FLAGS" \ $@ diff --git a/vendor/github.com/gardener/gardener/hack/kind-down.sh b/vendor/github.com/gardener/gardener/hack/kind-down.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/kind-extensions-up.sh b/vendor/github.com/gardener/gardener/hack/kind-extensions-up.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/kind-up.sh b/vendor/github.com/gardener/gardener/hack/kind-up.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/prepare-envtest.sh b/vendor/github.com/gardener/gardener/hack/prepare-envtest.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/start-envtest.sh b/vendor/github.com/gardener/gardener/hack/start-envtest.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/test-cover-clean.sh b/vendor/github.com/gardener/gardener/hack/test-cover-clean.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/test-cover.sh b/vendor/github.com/gardener/gardener/hack/test-cover.sh old mode 100755 new mode 100644 index bbe19d0e..c67df801 --- a/vendor/github.com/gardener/gardener/hack/test-cover.sh +++ b/vendor/github.com/gardener/gardener/hack/test-cover.sh @@ -27,7 +27,7 @@ COVERPROFILE_HTML="$REPO_ROOT/test.coverage.html" trap "rm -rf \"$COVERPROFILE_TMP\"" EXIT ERR INT TERM -GO111MODULE=on go test -cover -coverprofile "$COVERPROFILE_TMP" -race -timeout=2m -mod=vendor $@ | grep -v 'no test files' +GO111MODULE=on go test -cover -coverprofile "$COVERPROFILE_TMP" -race -timeout=2m $@ | grep -v 'no test files' cat "$COVERPROFILE_TMP" | grep -vE "\.pb\.go|zz_generated" > "$COVERPROFILE" go tool cover -html="$COVERPROFILE" -o="$COVERPROFILE_HTML" diff --git a/vendor/github.com/gardener/gardener/hack/test-e2e-local.env b/vendor/github.com/gardener/gardener/hack/test-e2e-local.env old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/test-e2e-local.sh b/vendor/github.com/gardener/gardener/hack/test-e2e-local.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/test-integration.env b/vendor/github.com/gardener/gardener/hack/test-integration.env old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/test-integration.sh b/vendor/github.com/gardener/gardener/hack/test-integration.sh old mode 100755 new mode 100644 index 5e3b7075..c36566f4 --- a/vendor/github.com/gardener/gardener/hack/test-integration.sh +++ b/vendor/github.com/gardener/gardener/hack/test-integration.sh @@ -36,4 +36,4 @@ else timeout_flag=-timeout=5m fi -GO111MODULE=on go test ${timeout_flag:-} -mod=vendor $@ $test_flags | grep -v 'no test files' +GO111MODULE=on go test ${timeout_flag:-} $@ $test_flags | grep -v 'no test files' diff --git a/vendor/github.com/gardener/gardener/hack/test-prometheus.sh b/vendor/github.com/gardener/gardener/hack/test-prometheus.sh old mode 100755 new mode 100644 diff --git a/vendor/github.com/gardener/gardener/hack/test.sh b/vendor/github.com/gardener/gardener/hack/test.sh old mode 100755 new mode 100644 index fd194f28..9daa5e27 --- a/vendor/github.com/gardener/gardener/hack/test.sh +++ b/vendor/github.com/gardener/gardener/hack/test.sh @@ -38,4 +38,4 @@ else timeout_flag=-timeout=2m fi -GO111MODULE=on go test -race ${timeout_flag:-} -mod=vendor $@ $test_flags | grep -v 'no test files' +GO111MODULE=on go test -race ${timeout_flag:-} "$@" $test_flags | grep -v 'no test files' diff --git a/vendor/github.com/gardener/gardener/hack/tools.go b/vendor/github.com/gardener/gardener/hack/tools.go old mode 100755 new mode 100644 index 45fdc98d..677963f8 --- a/vendor/github.com/gardener/gardener/hack/tools.go +++ b/vendor/github.com/gardener/gardener/hack/tools.go @@ -21,6 +21,7 @@ package tools import ( _ "github.com/ahmetb/gen-crd-api-reference-docs" _ "github.com/bronze1man/yaml2json" + _ "github.com/ironcore-dev/vgopath" _ "github.com/onsi/ginkgo/v2/ginkgo" _ "go.uber.org/mock/mockgen" _ "golang.org/x/tools/cmd/goimports" diff --git a/vendor/github.com/gardener/gardener/hack/tools.mk b/vendor/github.com/gardener/gardener/hack/tools.mk old mode 100755 new mode 100644 index e896b417..b699684a --- a/vendor/github.com/gardener/gardener/hack/tools.mk +++ b/vendor/github.com/gardener/gardener/hack/tools.mk @@ -23,7 +23,7 @@ ifeq ($(strip $(shell go list -m 2>/dev/null)),github.com/gardener/gardener) TOOLS_PKG_PATH := ./hack/tools else # dependency on github.com/gardener/gardener/hack/tools is optional and only needed if other projects want to reuse -# install-promtool.sh, logcheck, or gomegacheck. If they don't use it and the project doesn't depend on the package, +# install-promtool.sh, or logcheck. If they don't use it and the project doesn't depend on the package, # silence the error to minimize confusion. TOOLS_PKG_PATH := $(shell go list -tags tools -f '{{ .Dir }}' github.com/gardener/gardener/hack/tools 2>/dev/null) endif @@ -35,7 +35,6 @@ GINKGO := $(TOOLS_BIN_DIR)/ginkgo GOIMPORTS := $(TOOLS_BIN_DIR)/goimports GOIMPORTSREVISER := $(TOOLS_BIN_DIR)/goimports-reviser GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint -GOMEGACHECK := $(TOOLS_BIN_DIR)/gomegacheck.so # plugin binary GO_ADD_LICENSE := $(TOOLS_BIN_DIR)/addlicense GO_APIDIFF := $(TOOLS_BIN_DIR)/go-apidiff GO_VULN_CHECK := $(TOOLS_BIN_DIR)/govulncheck @@ -55,6 +54,7 @@ SETUP_ENVTEST := $(TOOLS_BIN_DIR)/setup-envtest SKAFFOLD := $(TOOLS_BIN_DIR)/skaffold YAML2JSON := $(TOOLS_BIN_DIR)/yaml2json YQ := $(TOOLS_BIN_DIR)/yq +VGOPATH := $(TOOLS_BIN_DIR)/vgopath # default tool versions GOLANGCI_LINT_VERSION ?= v1.55.1 @@ -69,6 +69,7 @@ PROMTOOL_VERSION ?= 2.47.2 PROTOC_VERSION ?= 24.4 SKAFFOLD_VERSION ?= v2.8.0 YQ_VERSION ?= v4.35.2 +VGOPATH_VERSION ?= v0.1.3 # tool versions from go.mod CONTROLLER_GEN_VERSION ?= $(call version_gomod,sigs.k8s.io/controller-tools) @@ -122,7 +123,7 @@ ifeq ($(shell if [ -d $(TOOLS_BIN_SOURCE_DIR) ]; then echo "found"; fi),found) endif .PHONY: create-tools-bin -create-tools-bin: $(CONTROLLER_GEN) $(GEN_CRD_API_REFERENCE_DOCS) $(GINKGO) $(GOIMPORTS) $(GOIMPORTSREVISER) $(GO_ADD_LICENSE) $(GO_APIDIFF) $(GO_VULN_CHECK) $(GO_TO_PROTOBUF) $(HELM) $(IMPORT_BOSS) $(KIND) $(KUBECTL) $(MOCKGEN) $(OPENAPI_GEN) $(PROMTOOL) $(PROTOC) $(PROTOC_GEN_GOGO) $(SETUP_ENVTEST) $(SKAFFOLD) $(YAML2JSON) $(YQ) +create-tools-bin: $(CONTROLLER_GEN) $(GEN_CRD_API_REFERENCE_DOCS) $(GINKGO) $(GOIMPORTS) $(GOIMPORTSREVISER) $(GO_ADD_LICENSE) $(GO_APIDIFF) $(GO_VULN_CHECK) $(GO_TO_PROTOBUF) $(HELM) $(IMPORT_BOSS) $(KIND) $(KUBECTL) $(MOCKGEN) $(OPENAPI_GEN) $(PROMTOOL) $(PROTOC) $(PROTOC_GEN_GOGO) $(SETUP_ENVTEST) $(SKAFFOLD) $(YAML2JSON) $(YQ) $(VGOPATH) ######################################### # Tools # @@ -148,14 +149,6 @@ $(GOLANGCI_LINT): $(call tool_version_file,$(GOLANGCI_LINT),$(GOLANGCI_LINT_VERS @# see https://github.com/golangci/golangci-lint/issues/1276 GOBIN=$(abspath $(TOOLS_BIN_DIR)) CGO_ENABLED=1 go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) -ifeq ($(strip $(shell go list -m 2>/dev/null)),github.com/gardener/gardener) -$(GOMEGACHECK): $(TOOLS_PKG_PATH)/gomegacheck/go.* $(shell find $(TOOLS_PKG_PATH)/gomegacheck -type f -name '*.go') - cd $(TOOLS_PKG_PATH)/gomegacheck; CGO_ENABLED=1 go build -o $(abspath $(GOMEGACHECK)) -buildmode=plugin ./plugin -else -$(GOMEGACHECK): go.mod - CGO_ENABLED=1 go build -o $(GOMEGACHECK) -buildmode=plugin github.com/gardener/gardener/hack/tools/gomegacheck/plugin -endif - $(GO_ADD_LICENSE): $(call tool_version_file,$(GO_ADD_LICENSE),$(GO_ADD_LICENSE_VERSION)) GOBIN=$(abspath $(TOOLS_BIN_DIR)) go install github.com/google/addlicense@$(GO_ADD_LICENSE_VERSION) @@ -226,3 +219,6 @@ $(YAML2JSON): $(call tool_version_file,$(YAML2JSON),$(YAML2JSON_VERSION)) $(YQ): $(call tool_version_file,$(YQ),$(YQ_VERSION)) curl -L -o $(YQ) https://github.com/mikefarah/yq/releases/download/$(YQ_VERSION)/yq_$(shell uname -s | tr '[:upper:]' '[:lower:]')_$(shell uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/') chmod +x $(YQ) + +$(VGOPATH): $(call tool_version_file,$(VGOPATH),$(VGOPATH_VERSION)) + go build -o $(VGOPATH) github.com/ironcore-dev/vgopath diff --git a/vendor/github.com/gardener/gardener/hack/update-codegen.sh b/vendor/github.com/gardener/gardener/hack/update-codegen.sh old mode 100755 new mode 100644 index 98d3ff31..4d404a19 --- a/vendor/github.com/gardener/gardener/hack/update-codegen.sh +++ b/vendor/github.com/gardener/gardener/hack/update-codegen.sh @@ -42,13 +42,23 @@ AVAILABLE_CODEGEN_OPTIONS=( "nodeagent_groups" ) -# Friendly reminder if workspace location is not in $GOPATH -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -if [ "${SCRIPT_DIR}" != "$(realpath $GOPATH)/src/github.com/gardener/gardener/hack" ]; then - echo "'hack/update-codegen.sh' script does not work correctly if your workspace is outside GOPATH" - echo "Please check https://github.com/gardener/gardener/blob/master/docs/development/local_setup.md#get-the-sources" - exit 1 -fi +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +VGOPATH="$VGOPATH" + +# Ensure that if GOPATH is set, the GOPATH/{bin,pkg} directory exists. This seems to be not always +# the case in certain environments like Prow. As we will create a symlink against the bin folder we +# need to make sure that the bin directory is present in the GOPATH. +if [ -n "$GOPATH" ] && [ ! -d "$GOPATH/bin" ]; then mkdir -p "$GOPATH/bin"; fi +if [ -n "$GOPATH" ] && [ ! -d "$GOPATH/pkg" ]; then mkdir -p "$GOPATH/pkg"; fi + +VIRTUAL_GOPATH="$(mktemp -d)" +trap 'rm -rf "$VIRTUAL_GOPATH"' EXIT + +# Setup virtual GOPATH so the codegen tools work as expected. +(cd "$SCRIPT_DIR/.."; go mod download && "$VGOPATH" -o "$VIRTUAL_GOPATH") + +export GOROOT="${GOROOT:-"$(go env GOROOT)"}" +export GOPATH="$VIRTUAL_GOPATH" # We need to explicitly pass GO111MODULE=off to k8s.io/code-generator as it is significantly slower otherwise, # see https://github.com/kubernetes/code-generator/issues/100. @@ -536,7 +546,7 @@ else break fi done - + if $valid; then valid_options+=("$option") else diff --git a/vendor/github.com/gardener/gardener/hack/update-protobuf.sh b/vendor/github.com/gardener/gardener/hack/update-protobuf.sh old mode 100755 new mode 100644 index c81a5ac1..e0583c30 --- a/vendor/github.com/gardener/gardener/hack/update-protobuf.sh +++ b/vendor/github.com/gardener/gardener/hack/update-protobuf.sh @@ -18,13 +18,23 @@ set -o errexit set -o nounset set -o pipefail -# Friendly reminder if workspace location is not in $GOPATH -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -if [ "${SCRIPT_DIR}" != "$(realpath $GOPATH)/src/github.com/gardener/gardener/hack" ]; then - echo "'hack/update-protobuf.sh' script does not work correctly if your workspace is outside GOPATH" - echo "Please check https://github.com/gardener/gardener/blob/master/docs/development/local_setup.md#get-the-sources" - exit 1 -fi +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +VGOPATH="$VGOPATH" + +# Ensure that if GOPATH is set, the GOPATH/{bin,pkg} directory exists. This seems to be not always +# the case in certain environments like Prow. As we will create a symlink against the bin folder we +# need to make sure that the bin directory is present in the GOPATH. +if [ -n "$GOPATH" ] && [ ! -d "$GOPATH/bin" ]; then mkdir -p "$GOPATH/bin"; fi +if [ -n "$GOPATH" ] && [ ! -d "$GOPATH/pkg" ]; then mkdir -p "$GOPATH/pkg"; fi + +VIRTUAL_GOPATH="$(mktemp -d)" +trap 'rm -rf "$VIRTUAL_GOPATH"' EXIT + +# Setup virtual GOPATH so the codegen tools work as expected. +(cd "$SCRIPT_DIR/.."; go mod download && "$VGOPATH" -o "$VIRTUAL_GOPATH") + +export GOROOT="${GOROOT:-"$(go env GOROOT)"}" +export GOPATH="$VIRTUAL_GOPATH" # We need to explicitly pass GO111MODULE=off to k8s.io/code-generator as it is significantly slower otherwise, # see https://github.com/kubernetes/code-generator/issues/100. @@ -53,5 +63,4 @@ read -ra PACKAGES <<< $(echo ${APIROOTS}) go-to-protobuf \ --packages="$(IFS=, ; echo "${PACKAGES[*]}")" \ --apimachinery-packages='-k8s.io/apimachinery/pkg/util/intstr,-k8s.io/apimachinery/pkg/api/resource,-k8s.io/apimachinery/pkg/runtime/schema,-k8s.io/apimachinery/pkg/runtime,-k8s.io/apimachinery/pkg/apis/meta/v1,-k8s.io/apimachinery/pkg/apis/meta/v1beta1,-k8s.io/api/core/v1,-k8s.io/api/rbac/v1,-k8s.io/api/autoscaling/v1,-k8s.io/api/networking/v1' \ - --go-header-file=${PROJECT_ROOT}/hack/LICENSE_BOILERPLATE.txt \ - --proto-import=${PROJECT_ROOT}/vendor + --go-header-file=${PROJECT_ROOT}/hack/LICENSE_BOILERPLATE.txt diff --git a/vendor/github.com/gardener/gardener/hack/update-skaffold-deps.sh b/vendor/github.com/gardener/gardener/hack/update-skaffold-deps.sh new file mode 100644 index 00000000..ec09bfd3 --- /dev/null +++ b/vendor/github.com/gardener/gardener/hack/update-skaffold-deps.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# +# Copyright 2023 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +# +# 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 -e + +repo_root="$(git rev-parse --show-toplevel)" +$repo_root/hack/check-skaffold-deps.sh update diff --git a/vendor/github.com/google/go-cmp/cmp/compare.go b/vendor/github.com/google/go-cmp/cmp/compare.go index 087320da..0f5b8a48 100644 --- a/vendor/github.com/google/go-cmp/cmp/compare.go +++ b/vendor/github.com/google/go-cmp/cmp/compare.go @@ -5,7 +5,7 @@ // Package cmp determines equality of values. // // This package is intended to be a more powerful and safer alternative to -// reflect.DeepEqual for comparing whether two values are semantically equal. +// [reflect.DeepEqual] for comparing whether two values are semantically equal. // It is intended to only be used in tests, as performance is not a goal and // it may panic if it cannot compare the values. Its propensity towards // panicking means that its unsuitable for production environments where a @@ -18,16 +18,17 @@ // For example, an equality function may report floats as equal so long as // they are within some tolerance of each other. // -// - Types with an Equal method may use that method to determine equality. -// This allows package authors to determine the equality operation -// for the types that they define. +// - Types with an Equal method (e.g., [time.Time.Equal]) may use that method +// to determine equality. This allows package authors to determine +// the equality operation for the types that they define. // // - If no custom equality functions are used and no Equal method is defined, // equality is determined by recursively comparing the primitive kinds on -// both values, much like reflect.DeepEqual. Unlike reflect.DeepEqual, +// both values, much like [reflect.DeepEqual]. Unlike [reflect.DeepEqual], // unexported fields are not compared by default; they result in panics -// unless suppressed by using an Ignore option (see cmpopts.IgnoreUnexported) -// or explicitly compared using the Exporter option. +// unless suppressed by using an [Ignore] option +// (see [github.com/google/go-cmp/cmp/cmpopts.IgnoreUnexported]) +// or explicitly compared using the [Exporter] option. package cmp import ( @@ -45,14 +46,14 @@ import ( // Equal reports whether x and y are equal by recursively applying the // following rules in the given order to x and y and all of their sub-values: // -// - Let S be the set of all Ignore, Transformer, and Comparer options that +// - Let S be the set of all [Ignore], [Transformer], and [Comparer] options that // remain after applying all path filters, value filters, and type filters. -// If at least one Ignore exists in S, then the comparison is ignored. -// If the number of Transformer and Comparer options in S is non-zero, +// If at least one [Ignore] exists in S, then the comparison is ignored. +// If the number of [Transformer] and [Comparer] options in S is non-zero, // then Equal panics because it is ambiguous which option to use. -// If S contains a single Transformer, then use that to transform +// If S contains a single [Transformer], then use that to transform // the current values and recursively call Equal on the output values. -// If S contains a single Comparer, then use that to compare the current values. +// If S contains a single [Comparer], then use that to compare the current values. // Otherwise, evaluation proceeds to the next rule. // // - If the values have an Equal method of the form "(T) Equal(T) bool" or @@ -66,21 +67,22 @@ import ( // Functions are only equal if they are both nil, otherwise they are unequal. // // Structs are equal if recursively calling Equal on all fields report equal. -// If a struct contains unexported fields, Equal panics unless an Ignore option -// (e.g., cmpopts.IgnoreUnexported) ignores that field or the Exporter option -// explicitly permits comparing the unexported field. +// If a struct contains unexported fields, Equal panics unless an [Ignore] option +// (e.g., [github.com/google/go-cmp/cmp/cmpopts.IgnoreUnexported]) ignores that field +// or the [Exporter] option explicitly permits comparing the unexported field. // // Slices are equal if they are both nil or both non-nil, where recursively // calling Equal on all non-ignored slice or array elements report equal. // Empty non-nil slices and nil slices are not equal; to equate empty slices, -// consider using cmpopts.EquateEmpty. +// consider using [github.com/google/go-cmp/cmp/cmpopts.EquateEmpty]. // // Maps are equal if they are both nil or both non-nil, where recursively // calling Equal on all non-ignored map entries report equal. // Map keys are equal according to the == operator. -// To use custom comparisons for map keys, consider using cmpopts.SortMaps. +// To use custom comparisons for map keys, consider using +// [github.com/google/go-cmp/cmp/cmpopts.SortMaps]. // Empty non-nil maps and nil maps are not equal; to equate empty maps, -// consider using cmpopts.EquateEmpty. +// consider using [github.com/google/go-cmp/cmp/cmpopts.EquateEmpty]. // // Pointers and interfaces are equal if they are both nil or both non-nil, // where they have the same underlying concrete type and recursively diff --git a/vendor/github.com/google/go-cmp/cmp/export_unsafe.go b/vendor/github.com/google/go-cmp/cmp/export.go similarity index 94% rename from vendor/github.com/google/go-cmp/cmp/export_unsafe.go rename to vendor/github.com/google/go-cmp/cmp/export.go index e2c0f74e..29f82fe6 100644 --- a/vendor/github.com/google/go-cmp/cmp/export_unsafe.go +++ b/vendor/github.com/google/go-cmp/cmp/export.go @@ -2,9 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !purego -// +build !purego - package cmp import ( @@ -12,8 +9,6 @@ import ( "unsafe" ) -const supportExporters = true - // retrieveUnexportedField uses unsafe to forcibly retrieve any field from // a struct such that the value has read-write permissions. // diff --git a/vendor/github.com/google/go-cmp/cmp/export_panic.go b/vendor/github.com/google/go-cmp/cmp/export_panic.go deleted file mode 100644 index ae851fe5..00000000 --- a/vendor/github.com/google/go-cmp/cmp/export_panic.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2017, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build purego -// +build purego - -package cmp - -import "reflect" - -const supportExporters = false - -func retrieveUnexportedField(reflect.Value, reflect.StructField, bool) reflect.Value { - panic("no support for forcibly accessing unexported fields") -} diff --git a/vendor/github.com/google/go-cmp/cmp/internal/value/pointer_unsafe.go b/vendor/github.com/google/go-cmp/cmp/internal/value/pointer.go similarity index 95% rename from vendor/github.com/google/go-cmp/cmp/internal/value/pointer_unsafe.go rename to vendor/github.com/google/go-cmp/cmp/internal/value/pointer.go index 16e6860a..e5dfff69 100644 --- a/vendor/github.com/google/go-cmp/cmp/internal/value/pointer_unsafe.go +++ b/vendor/github.com/google/go-cmp/cmp/internal/value/pointer.go @@ -2,9 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build !purego -// +build !purego - package value import ( diff --git a/vendor/github.com/google/go-cmp/cmp/internal/value/pointer_purego.go b/vendor/github.com/google/go-cmp/cmp/internal/value/pointer_purego.go deleted file mode 100644 index 1a71bfcb..00000000 --- a/vendor/github.com/google/go-cmp/cmp/internal/value/pointer_purego.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2018, The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build purego -// +build purego - -package value - -import "reflect" - -// Pointer is an opaque typed pointer and is guaranteed to be comparable. -type Pointer struct { - p uintptr - t reflect.Type -} - -// PointerOf returns a Pointer from v, which must be a -// reflect.Ptr, reflect.Slice, or reflect.Map. -func PointerOf(v reflect.Value) Pointer { - // NOTE: Storing a pointer as an uintptr is technically incorrect as it - // assumes that the GC implementation does not use a moving collector. - return Pointer{v.Pointer(), v.Type()} -} - -// IsNil reports whether the pointer is nil. -func (p Pointer) IsNil() bool { - return p.p == 0 -} - -// Uintptr returns the pointer as a uintptr. -func (p Pointer) Uintptr() uintptr { - return p.p -} diff --git a/vendor/github.com/google/go-cmp/cmp/options.go b/vendor/github.com/google/go-cmp/cmp/options.go index 1f9ca9c4..754496f3 100644 --- a/vendor/github.com/google/go-cmp/cmp/options.go +++ b/vendor/github.com/google/go-cmp/cmp/options.go @@ -13,15 +13,15 @@ import ( "github.com/google/go-cmp/cmp/internal/function" ) -// Option configures for specific behavior of Equal and Diff. In particular, -// the fundamental Option functions (Ignore, Transformer, and Comparer), +// Option configures for specific behavior of [Equal] and [Diff]. In particular, +// the fundamental Option functions ([Ignore], [Transformer], and [Comparer]), // configure how equality is determined. // -// The fundamental options may be composed with filters (FilterPath and -// FilterValues) to control the scope over which they are applied. +// The fundamental options may be composed with filters ([FilterPath] and +// [FilterValues]) to control the scope over which they are applied. // -// The cmp/cmpopts package provides helper functions for creating options that -// may be used with Equal and Diff. +// The [github.com/google/go-cmp/cmp/cmpopts] package provides helper functions +// for creating options that may be used with [Equal] and [Diff]. type Option interface { // filter applies all filters and returns the option that remains. // Each option may only read s.curPath and call s.callTTBFunc. @@ -56,9 +56,9 @@ type core struct{} func (core) isCore() {} -// Options is a list of Option values that also satisfies the Option interface. +// Options is a list of [Option] values that also satisfies the [Option] interface. // Helper comparison packages may return an Options value when packing multiple -// Option values into a single Option. When this package processes an Options, +// [Option] values into a single [Option]. When this package processes an Options, // it will be implicitly expanded into a flat list. // // Applying a filter on an Options is equivalent to applying that same filter @@ -105,16 +105,16 @@ func (opts Options) String() string { return fmt.Sprintf("Options{%s}", strings.Join(ss, ", ")) } -// FilterPath returns a new Option where opt is only evaluated if filter f -// returns true for the current Path in the value tree. +// FilterPath returns a new [Option] where opt is only evaluated if filter f +// returns true for the current [Path] in the value tree. // // This filter is called even if a slice element or map entry is missing and // provides an opportunity to ignore such cases. The filter function must be // symmetric such that the filter result is identical regardless of whether the // missing value is from x or y. // -// The option passed in may be an Ignore, Transformer, Comparer, Options, or -// a previously filtered Option. +// The option passed in may be an [Ignore], [Transformer], [Comparer], [Options], or +// a previously filtered [Option]. func FilterPath(f func(Path) bool, opt Option) Option { if f == nil { panic("invalid path filter function") @@ -142,7 +142,7 @@ func (f pathFilter) String() string { return fmt.Sprintf("FilterPath(%s, %v)", function.NameOf(reflect.ValueOf(f.fnc)), f.opt) } -// FilterValues returns a new Option where opt is only evaluated if filter f, +// FilterValues returns a new [Option] where opt is only evaluated if filter f, // which is a function of the form "func(T, T) bool", returns true for the // current pair of values being compared. If either value is invalid or // the type of the values is not assignable to T, then this filter implicitly @@ -154,8 +154,8 @@ func (f pathFilter) String() string { // If T is an interface, it is possible that f is called with two values with // different concrete types that both implement T. // -// The option passed in may be an Ignore, Transformer, Comparer, Options, or -// a previously filtered Option. +// The option passed in may be an [Ignore], [Transformer], [Comparer], [Options], or +// a previously filtered [Option]. func FilterValues(f interface{}, opt Option) Option { v := reflect.ValueOf(f) if !function.IsType(v.Type(), function.ValueFilter) || v.IsNil() { @@ -192,9 +192,9 @@ func (f valuesFilter) String() string { return fmt.Sprintf("FilterValues(%s, %v)", function.NameOf(f.fnc), f.opt) } -// Ignore is an Option that causes all comparisons to be ignored. -// This value is intended to be combined with FilterPath or FilterValues. -// It is an error to pass an unfiltered Ignore option to Equal. +// Ignore is an [Option] that causes all comparisons to be ignored. +// This value is intended to be combined with [FilterPath] or [FilterValues]. +// It is an error to pass an unfiltered Ignore option to [Equal]. func Ignore() Option { return ignore{} } type ignore struct{ core } @@ -234,6 +234,8 @@ func (validator) apply(s *state, vx, vy reflect.Value) { name = fmt.Sprintf("%q.%v", t.PkgPath(), t.Name()) // e.g., "path/to/package".MyType if _, ok := reflect.New(t).Interface().(error); ok { help = "consider using cmpopts.EquateErrors to compare error values" + } else if t.Comparable() { + help = "consider using cmpopts.EquateComparable to compare comparable Go types" } } else { // Unnamed type with unexported fields. Derive PkgPath from field. @@ -254,7 +256,7 @@ const identRx = `[_\p{L}][_\p{L}\p{N}]*` var identsRx = regexp.MustCompile(`^` + identRx + `(\.` + identRx + `)*$`) -// Transformer returns an Option that applies a transformation function that +// Transformer returns an [Option] that applies a transformation function that // converts values of a certain type into that of another. // // The transformer f must be a function "func(T) R" that converts values of @@ -265,13 +267,14 @@ var identsRx = regexp.MustCompile(`^` + identRx + `(\.` + identRx + `)*$`) // same transform to the output of itself (e.g., in the case where the // input and output types are the same), an implicit filter is added such that // a transformer is applicable only if that exact transformer is not already -// in the tail of the Path since the last non-Transform step. +// in the tail of the [Path] since the last non-[Transform] step. // For situations where the implicit filter is still insufficient, -// consider using cmpopts.AcyclicTransformer, which adds a filter -// to prevent the transformer from being recursively applied upon itself. +// consider using [github.com/google/go-cmp/cmp/cmpopts.AcyclicTransformer], +// which adds a filter to prevent the transformer from +// being recursively applied upon itself. // -// The name is a user provided label that is used as the Transform.Name in the -// transformation PathStep (and eventually shown in the Diff output). +// The name is a user provided label that is used as the [Transform.Name] in the +// transformation [PathStep] (and eventually shown in the [Diff] output). // The name must be a valid identifier or qualified identifier in Go syntax. // If empty, an arbitrary name is used. func Transformer(name string, f interface{}) Option { @@ -329,7 +332,7 @@ func (tr transformer) String() string { return fmt.Sprintf("Transformer(%s, %s)", tr.name, function.NameOf(tr.fnc)) } -// Comparer returns an Option that determines whether two values are equal +// Comparer returns an [Option] that determines whether two values are equal // to each other. // // The comparer f must be a function "func(T, T) bool" and is implicitly @@ -377,35 +380,32 @@ func (cm comparer) String() string { return fmt.Sprintf("Comparer(%s)", function.NameOf(cm.fnc)) } -// Exporter returns an Option that specifies whether Equal is allowed to +// Exporter returns an [Option] that specifies whether [Equal] is allowed to // introspect into the unexported fields of certain struct types. // // Users of this option must understand that comparing on unexported fields // from external packages is not safe since changes in the internal -// implementation of some external package may cause the result of Equal +// implementation of some external package may cause the result of [Equal] // to unexpectedly change. However, it may be valid to use this option on types // defined in an internal package where the semantic meaning of an unexported // field is in the control of the user. // -// In many cases, a custom Comparer should be used instead that defines +// In many cases, a custom [Comparer] should be used instead that defines // equality as a function of the public API of a type rather than the underlying // unexported implementation. // -// For example, the reflect.Type documentation defines equality to be determined +// For example, the [reflect.Type] documentation defines equality to be determined // by the == operator on the interface (essentially performing a shallow pointer -// comparison) and most attempts to compare *regexp.Regexp types are interested +// comparison) and most attempts to compare *[regexp.Regexp] types are interested // in only checking that the regular expression strings are equal. -// Both of these are accomplished using Comparers: +// Both of these are accomplished using [Comparer] options: // // Comparer(func(x, y reflect.Type) bool { return x == y }) // Comparer(func(x, y *regexp.Regexp) bool { return x.String() == y.String() }) // -// In other cases, the cmpopts.IgnoreUnexported option can be used to ignore -// all unexported fields on specified struct types. +// In other cases, the [github.com/google/go-cmp/cmp/cmpopts.IgnoreUnexported] +// option can be used to ignore all unexported fields on specified struct types. func Exporter(f func(reflect.Type) bool) Option { - if !supportExporters { - panic("Exporter is not supported on purego builds") - } return exporter(f) } @@ -415,10 +415,10 @@ func (exporter) filter(_ *state, _ reflect.Type, _, _ reflect.Value) applicableO panic("not implemented") } -// AllowUnexported returns an Options that allows Equal to forcibly introspect +// AllowUnexported returns an [Option] that allows [Equal] to forcibly introspect // unexported fields of the specified struct types. // -// See Exporter for the proper use of this option. +// See [Exporter] for the proper use of this option. func AllowUnexported(types ...interface{}) Option { m := make(map[reflect.Type]bool) for _, typ := range types { @@ -432,7 +432,7 @@ func AllowUnexported(types ...interface{}) Option { } // Result represents the comparison result for a single node and -// is provided by cmp when calling Report (see Reporter). +// is provided by cmp when calling Report (see [Reporter]). type Result struct { _ [0]func() // Make Result incomparable flags resultFlags @@ -445,7 +445,7 @@ func (r Result) Equal() bool { } // ByIgnore reports whether the node is equal because it was ignored. -// This never reports true if Equal reports false. +// This never reports true if [Result.Equal] reports false. func (r Result) ByIgnore() bool { return r.flags&reportByIgnore != 0 } @@ -455,7 +455,7 @@ func (r Result) ByMethod() bool { return r.flags&reportByMethod != 0 } -// ByFunc reports whether a Comparer function determined equality. +// ByFunc reports whether a [Comparer] function determined equality. func (r Result) ByFunc() bool { return r.flags&reportByFunc != 0 } @@ -478,7 +478,7 @@ const ( reportByCycle ) -// Reporter is an Option that can be passed to Equal. When Equal traverses +// Reporter is an [Option] that can be passed to [Equal]. When [Equal] traverses // the value trees, it calls PushStep as it descends into each node in the // tree and PopStep as it ascend out of the node. The leaves of the tree are // either compared (determined to be equal or not equal) or ignored and reported diff --git a/vendor/github.com/google/go-cmp/cmp/path.go b/vendor/github.com/google/go-cmp/cmp/path.go index a0a58850..c3c14564 100644 --- a/vendor/github.com/google/go-cmp/cmp/path.go +++ b/vendor/github.com/google/go-cmp/cmp/path.go @@ -14,9 +14,9 @@ import ( "github.com/google/go-cmp/cmp/internal/value" ) -// Path is a list of PathSteps describing the sequence of operations to get +// Path is a list of [PathStep] describing the sequence of operations to get // from some root type to the current position in the value tree. -// The first Path element is always an operation-less PathStep that exists +// The first Path element is always an operation-less [PathStep] that exists // simply to identify the initial type. // // When traversing structs with embedded structs, the embedded struct will @@ -29,8 +29,13 @@ type Path []PathStep // a value's tree structure. Users of this package never need to implement // these types as values of this type will be returned by this package. // -// Implementations of this interface are -// StructField, SliceIndex, MapIndex, Indirect, TypeAssertion, and Transform. +// Implementations of this interface: +// - [StructField] +// - [SliceIndex] +// - [MapIndex] +// - [Indirect] +// - [TypeAssertion] +// - [Transform] type PathStep interface { String() string @@ -70,8 +75,9 @@ func (pa *Path) pop() { *pa = (*pa)[:len(*pa)-1] } -// Last returns the last PathStep in the Path. -// If the path is empty, this returns a non-nil PathStep that reports a nil Type. +// Last returns the last [PathStep] in the Path. +// If the path is empty, this returns a non-nil [PathStep] +// that reports a nil [PathStep.Type]. func (pa Path) Last() PathStep { return pa.Index(-1) } @@ -79,7 +85,8 @@ func (pa Path) Last() PathStep { // Index returns the ith step in the Path and supports negative indexing. // A negative index starts counting from the tail of the Path such that -1 // refers to the last step, -2 refers to the second-to-last step, and so on. -// If index is invalid, this returns a non-nil PathStep that reports a nil Type. +// If index is invalid, this returns a non-nil [PathStep] +// that reports a nil [PathStep.Type]. func (pa Path) Index(i int) PathStep { if i < 0 { i = len(pa) + i @@ -168,7 +175,8 @@ func (ps pathStep) String() string { return fmt.Sprintf("{%s}", s) } -// StructField represents a struct field access on a field called Name. +// StructField is a [PathStep] that represents a struct field access +// on a field called [StructField.Name]. type StructField struct{ *structField } type structField struct { pathStep @@ -204,10 +212,11 @@ func (sf StructField) String() string { return fmt.Sprintf(".%s", sf.name) } func (sf StructField) Name() string { return sf.name } // Index is the index of the field in the parent struct type. -// See reflect.Type.Field. +// See [reflect.Type.Field]. func (sf StructField) Index() int { return sf.idx } -// SliceIndex is an index operation on a slice or array at some index Key. +// SliceIndex is a [PathStep] that represents an index operation on +// a slice or array at some index [SliceIndex.Key]. type SliceIndex struct{ *sliceIndex } type sliceIndex struct { pathStep @@ -247,12 +256,12 @@ func (si SliceIndex) Key() int { // all of the indexes to be shifted. If an index is -1, then that // indicates that the element does not exist in the associated slice. // -// Key is guaranteed to return -1 if and only if the indexes returned -// by SplitKeys are not the same. SplitKeys will never return -1 for +// [SliceIndex.Key] is guaranteed to return -1 if and only if the indexes +// returned by SplitKeys are not the same. SplitKeys will never return -1 for // both indexes. func (si SliceIndex) SplitKeys() (ix, iy int) { return si.xkey, si.ykey } -// MapIndex is an index operation on a map at some index Key. +// MapIndex is a [PathStep] that represents an index operation on a map at some index Key. type MapIndex struct{ *mapIndex } type mapIndex struct { pathStep @@ -266,7 +275,7 @@ func (mi MapIndex) String() string { return fmt.Sprintf("[%#v]", // Key is the value of the map key. func (mi MapIndex) Key() reflect.Value { return mi.key } -// Indirect represents pointer indirection on the parent type. +// Indirect is a [PathStep] that represents pointer indirection on the parent type. type Indirect struct{ *indirect } type indirect struct { pathStep @@ -276,7 +285,7 @@ func (in Indirect) Type() reflect.Type { return in.typ } func (in Indirect) Values() (vx, vy reflect.Value) { return in.vx, in.vy } func (in Indirect) String() string { return "*" } -// TypeAssertion represents a type assertion on an interface. +// TypeAssertion is a [PathStep] that represents a type assertion on an interface. type TypeAssertion struct{ *typeAssertion } type typeAssertion struct { pathStep @@ -286,7 +295,8 @@ func (ta TypeAssertion) Type() reflect.Type { return ta.typ } func (ta TypeAssertion) Values() (vx, vy reflect.Value) { return ta.vx, ta.vy } func (ta TypeAssertion) String() string { return fmt.Sprintf(".(%v)", value.TypeString(ta.typ, false)) } -// Transform is a transformation from the parent type to the current type. +// Transform is a [PathStep] that represents a transformation +// from the parent type to the current type. type Transform struct{ *transform } type transform struct { pathStep @@ -297,13 +307,13 @@ func (tf Transform) Type() reflect.Type { return tf.typ } func (tf Transform) Values() (vx, vy reflect.Value) { return tf.vx, tf.vy } func (tf Transform) String() string { return fmt.Sprintf("%s()", tf.trans.name) } -// Name is the name of the Transformer. +// Name is the name of the [Transformer]. func (tf Transform) Name() string { return tf.trans.name } // Func is the function pointer to the transformer function. func (tf Transform) Func() reflect.Value { return tf.trans.fnc } -// Option returns the originally constructed Transformer option. +// Option returns the originally constructed [Transformer] option. // The == operator can be used to detect the exact option used. func (tf Transform) Option() Option { return tf.trans } diff --git a/vendor/github.com/google/go-cmp/cmp/report_reflect.go b/vendor/github.com/google/go-cmp/cmp/report_reflect.go index 2ab41fad..e39f4228 100644 --- a/vendor/github.com/google/go-cmp/cmp/report_reflect.go +++ b/vendor/github.com/google/go-cmp/cmp/report_reflect.go @@ -199,7 +199,7 @@ func (opts formatOptions) FormatValue(v reflect.Value, parentKind reflect.Kind, break } sf := t.Field(i) - if supportExporters && !isExported(sf.Name) { + if !isExported(sf.Name) { vv = retrieveUnexportedField(v, sf, true) } s := opts.WithTypeMode(autoType).FormatValue(vv, t.Kind(), ptrs) diff --git a/vendor/github.com/ironcore-dev/vgopath/.gitignore b/vendor/github.com/ironcore-dev/vgopath/.gitignore new file mode 100644 index 00000000..c8a6a5a5 --- /dev/null +++ b/vendor/github.com/ironcore-dev/vgopath/.gitignore @@ -0,0 +1,33 @@ + +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib +bin/ + +# Test binary, build with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Kubernetes Generated files - skip generated files, except for vendored files + +!vendor/**/zz_generated.* +vendor/ + +# editor and IDE paraphernalia +.idea +*.swp +*.swo +*~ +.vscode/ + +# Utilities +testbin/ + +# Goreleaser +dist/ + diff --git a/vendor/github.com/ironcore-dev/vgopath/.golangci.yaml b/vendor/github.com/ironcore-dev/vgopath/.golangci.yaml new file mode 100644 index 00000000..8bf42207 --- /dev/null +++ b/vendor/github.com/ironcore-dev/vgopath/.golangci.yaml @@ -0,0 +1,20 @@ +run: + timeout: 3m + +linters: + enable: + - revive + - ineffassign + - misspell + - goimports + +severity: + default-severity: error + +linters-settings: + revive: + severity: error + rules: + - name: exported + - name: if-return + disabled: true diff --git a/vendor/github.com/ironcore-dev/vgopath/CODEOWNERS b/vendor/github.com/ironcore-dev/vgopath/CODEOWNERS new file mode 100644 index 00000000..6eede224 --- /dev/null +++ b/vendor/github.com/ironcore-dev/vgopath/CODEOWNERS @@ -0,0 +1,2 @@ +# ironcore-dev core maintainers +* @ironcore-dev/core diff --git a/vendor/github.com/ironcore-dev/vgopath/CODE_OF_CONDUCT.md b/vendor/github.com/ironcore-dev/vgopath/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..57aa8414 --- /dev/null +++ b/vendor/github.com/ironcore-dev/vgopath/CODE_OF_CONDUCT.md @@ -0,0 +1 @@ +Please refer to the [Gardener on Metal code of conduct](https://ironcore-dev.github.io/documentation/contribute/overview/#code-of-conduct). diff --git a/vendor/github.com/ironcore-dev/vgopath/LICENSE b/vendor/github.com/ironcore-dev/vgopath/LICENSE new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/vendor/github.com/ironcore-dev/vgopath/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/vendor/github.com/ironcore-dev/vgopath/Makefile b/vendor/github.com/ironcore-dev/vgopath/Makefile new file mode 100644 index 00000000..6a1a7080 --- /dev/null +++ b/vendor/github.com/ironcore-dev/vgopath/Makefile @@ -0,0 +1,105 @@ +# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) +ifeq (,$(shell go env GOBIN)) +GOBIN=$(shell go env GOPATH)/bin +else +GOBIN=$(shell go env GOBIN) +endif + +# Setting SHELL to bash allows bash commands to be executed by recipes. +# This is a requirement for 'setup-envtest.sh' in the test target. +# Options are set to exit when a recipe line exits non-zero or a piped command fails. +SHELL = /usr/bin/env bash -o pipefail +.SHELLFLAGS = -ec + +all: build + +##@ General + +# The help target prints out all targets with their descriptions organized +# beneath their categories. The categories are represented by '##@' and the +# target descriptions by '##'. The awk commands is responsible for reading the +# entire set of makefiles included in this invocation, looking for lines of the +# file as xyz: ## something, and then pretty-format the target and help. Then, +# if there's a line with ##@ something, that gets pretty-printed as a category. +# More info on the usage of ANSI control characters for terminal formatting: +# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters +# More info on the awk command: +# http://linuxcommand.org/lc3_adv_awk.php + +help: ## Display this help. + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +##@ Development + +.PHONY: fmt +fmt: goimports ## Run goimports against code. + $(GOIMPORTS) -w . + +.PHONY: vet +vet: ## Run go vet against code. + go vet ./... + +.PHONY: lint +lint: ## Run golangci-lint on the code. + $(GOLANGCILINT) run ./... + +.PHONY: add-license +add-license: addlicense ## Add license headers to all go files. + find . -name '*.go' -exec $(ADDLICENSE) -c 'IronCore authors' {} + + +.PHONY: check-license +check-license: addlicense ## Check that every file has a license header present. + find . -name '*.go' -exec $(ADDLICENSE) -check -c 'IronCore authors' {} + + +.PHONY: check +check: add-license fmt lint test golangci-lint # Generate manifests, code, lint, add licenses, test + +.PHONY: test +test: fmt vet ## Run tests. + go test ./... -coverprofile cover.out + +##@ Build + +.PHONY: build +build: fmt vet ## Build manager binary. + go build -o bin/vgopath main.go + +.PHONY: install +install: ## Install vgopath into GOBIN. + go install . + +.PHONY: run +run: fmt lint ## Run a controller from your host. + go run ./main.go + +##@ Tools + +## Location to install dependencies to +LOCALBIN ?= $(shell pwd)/bin +$(LOCALBIN): + mkdir -p $(LOCALBIN) + +## Tool Binaries +ADDLICENSE ?= $(LOCALBIN)/addlicense +GOIMPORTS ?= $(LOCALBIN)/goimports +GOLANGCILINT ?= $(LOCALBIN)/golangci-lint + +## Tool Versions +ADDLICENSE_VERSION ?= v1.1.1 +GOIMPORTS_VERSION ?= v0.14.0 +GOLANGCILINT_VERSION ?= v1.55.1 + +.PHONY: addlicense +addlicense: $(ADDLICENSE) ## Download addlicense locally if necessary. +$(ADDLICENSE): $(LOCALBIN) + test -s $(LOCALBIN)/addlicense || GOBIN=$(LOCALBIN) go install github.com/google/addlicense@$(ADDLICENSE_VERSION) + +.PHONY: goimports +goimports: $(GOIMPORTS) ## Download goimports locally if necessary. +$(GOIMPORTS): $(LOCALBIN) + test -s $(LOCALBIN)/goimports || GOBIN=$(LOCALBIN) go install golang.org/x/tools/cmd/goimports@$(GOIMPORTS_VERSION) + +.PHONY: goimports +golangci-lint: $(GOLANGCILINT) ## Download golangci-lint locally if necessary. +$(GOLANGCILINT): $(LOCALBIN) + test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCILINT_VERSION) diff --git a/vendor/github.com/ironcore-dev/vgopath/README.md b/vendor/github.com/ironcore-dev/vgopath/README.md new file mode 100644 index 00000000..a15fab90 --- /dev/null +++ b/vendor/github.com/ironcore-dev/vgopath/README.md @@ -0,0 +1,36 @@ +# vgopath + +`vgopath` is a tool for module-enabled projects to set up a 'virtual' GOPATH for +legacy tools to run with (`kubernetes/code-generator` I'm looking at you...). + +## Installation + +The simplest way to install `vgopath` is by running + +```shell +go install github.com/ironcore-dev/vgopath@latest +``` + +## Usage + +`vgopath` has to be run from the module-enabled project root. It requires a +target directory to construct the virtual GOPATH. + +Example usage could look like this: + +```shell +# Create the target directory +mkdir -p my-vgopath + +# Do the linking in my-vgopath +vgopath my-vgopath +``` + +Once done, the structure will look something like + +``` +my-vgopath +├── bin -> /bin +├── pkg -> /pkg +└── src -> various subdirectories +``` diff --git a/vendor/github.com/ironcore-dev/vgopath/internal/cmd/version/version.go b/vendor/github.com/ironcore-dev/vgopath/internal/cmd/version/version.go new file mode 100644 index 00000000..949c7f24 --- /dev/null +++ b/vendor/github.com/ironcore-dev/vgopath/internal/cmd/version/version.go @@ -0,0 +1,40 @@ +// Copyright 2023 IronCore 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 version + +import ( + "io" + + "github.com/ironcore-dev/vgopath/internal/version" + "github.com/spf13/cobra" +) + +func Command(out io.Writer) *cobra.Command { + cmd := &cobra.Command{ + Use: "version", + Short: "Prints version information.", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + return Run(out) + }, + } + + return cmd +} + +func Run(out io.Writer) error { + version.FPrint(out) + return nil +} diff --git a/vendor/github.com/ironcore-dev/vgopath/internal/cmd/vgopath/exec/exec.go b/vendor/github.com/ironcore-dev/vgopath/internal/cmd/vgopath/exec/exec.go new file mode 100644 index 00000000..bb08522a --- /dev/null +++ b/vendor/github.com/ironcore-dev/vgopath/internal/cmd/vgopath/exec/exec.go @@ -0,0 +1,109 @@ +// Copyright 2023 IronCore 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 exec + +import ( + "fmt" + "os" + "os/exec" + "regexp" + + "github.com/ironcore-dev/vgopath/internal/link" + "github.com/spf13/cobra" +) + +func Command() *cobra.Command { + var ( + opts link.Options + dstDir string + shell bool + ) + + cmd := &cobra.Command{ + Use: "exec -- command [args...]", + Short: "Run an executable in a virtual GOPATH.", + Args: func(cmd *cobra.Command, args []string) error { + if !shell { + return cobra.MinimumNArgs(1)(cmd, args) + } + return cobra.ExactArgs(1)(cmd, args) + }, + RunE: func(cmd *cobra.Command, args []string) error { + executable, executableArgs := executableAndArgs(args, shell) + return Run(dstDir, executable, opts, executableArgs) + }, + } + + opts.AddFlags(cmd.Flags()) + cmd.Flags().StringVarP(&dstDir, "dst-dir", "o", "", "Destination directory. If empty, a temporary directory will be created.") + cmd.Flags().BoolVarP(&shell, "shell", "s", false, "Whether to run the command in a shell.") + + return cmd +} + +func executableAndArgs(args []string, doShell bool) (string, []string) { + if !doShell { + return args[0], args[1:] + } + + shell := os.Getenv("SHELL") + if shell == "" { + shell = "/bin/sh" + } + + return shell, []string{"-c", args[0]} +} + +func Run(dstDir, executable string, opts link.Options, args []string) error { + if dstDir == "" { + var err error + dstDir, err = os.MkdirTemp("", "vgopath") + if err != nil { + return fmt.Errorf("error creating temp directory: %w", err) + } + defer func() { _ = os.RemoveAll(dstDir) }() + } + + if err := link.Link(dstDir, opts); err != nil { + return err + } + + cmd := exec.Command(executable, args...) + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Dir = dstDir + + cmd.Env = mkEnv(dstDir) + return cmd.Run() +} + +var filterEnvRegexp = regexp.MustCompile(`^(GOPATH|GO111MODULE)=`) + +func mkEnv(gopath string) []string { + env := os.Environ() + res := make([]string, 0, len(env)+2) + + for _, kv := range env { + if !filterEnvRegexp.MatchString(kv) { + res = append(res, kv) + } + } + + return append(res, + fmt.Sprintf("GOPATH=%s", gopath), + "GO111MODULE=off", + ) +} diff --git a/vendor/github.com/ironcore-dev/vgopath/internal/cmd/vgopath/vgopath.go b/vendor/github.com/ironcore-dev/vgopath/internal/cmd/vgopath/vgopath.go new file mode 100644 index 00000000..06583b42 --- /dev/null +++ b/vendor/github.com/ironcore-dev/vgopath/internal/cmd/vgopath/vgopath.go @@ -0,0 +1,63 @@ +// Copyright 2023 IronCore 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 vgopath + +import ( + "os" + + "github.com/ironcore-dev/vgopath/internal/cmd/version" + "github.com/ironcore-dev/vgopath/internal/cmd/vgopath/exec" + "github.com/ironcore-dev/vgopath/internal/link" + "github.com/spf13/cobra" +) + +func Command() *cobra.Command { + var ( + opts link.Options + dstDir string + ) + + cmd := &cobra.Command{ + Use: "vgopath", + Short: "Create and operate on virtual GOPATHs", + Long: `Create a 'virtual' GOPATH at the specified directory. + +vgopath will setup a GOPATH folder structure, ensuring that any tool used +to the traditional setup will function as normal. + +The target module will be mirrored to where its go.mod path (the line +after 'module') points at. +`, + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + return Run(dstDir, opts) + }, + } + + opts.AddFlags(cmd.Flags()) + cmd.Flags().StringVarP(&dstDir, "dst-dir", "o", "", "Destination directory.") + _ = cmd.MarkFlagRequired("dst-dir") + + cmd.AddCommand( + exec.Command(), + version.Command(os.Stdout), + ) + + return cmd +} + +func Run(dstDir string, opts link.Options) error { + return link.Link(dstDir, opts) +} diff --git a/vendor/github.com/ironcore-dev/vgopath/internal/link/link.go b/vendor/github.com/ironcore-dev/vgopath/internal/link/link.go new file mode 100644 index 00000000..8a58b0ae --- /dev/null +++ b/vendor/github.com/ironcore-dev/vgopath/internal/link/link.go @@ -0,0 +1,284 @@ +// Copyright 2022 IronCore 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 link + +import ( + "fmt" + "go/build" + "os" + "path" + "path/filepath" + "sort" + "strings" + + "github.com/ironcore-dev/vgopath/internal/module" + "github.com/spf13/pflag" +) + +type Node struct { + Segment string + Module *module.Module + Children []Node +} + +func insertModuleInNode(node *Node, mod module.Module, relativeSegments []string) error { + if len(relativeSegments) == 0 { + if node.Module != nil { + return fmt.Errorf("cannot insert module %s into node %s: module %s already exists", mod.Path, node.Segment, node.Module.Path) + } + + node.Module = &mod + return nil + } + + var ( + idx = -1 + segment = relativeSegments[0] + ) + for i, child := range node.Children { + if child.Segment == segment { + idx = i + break + } + } + + var child *Node + if idx == -1 { + child = &Node{Segment: segment} + } else { + child = &node.Children[idx] + } + + if err := insertModuleInNode(child, mod, relativeSegments[1:]); err != nil { + return err + } + + if idx == -1 { + node.Children = append(node.Children, *child) + } + + return nil +} + +func BuildModuleNodes(modules []module.Module) ([]Node, error) { + sort.Slice(modules, func(i, j int) bool { return modules[i].Path < modules[j].Path }) + nodeByRootSegment := make(map[string]*Node) + + for _, mod := range modules { + if mod.Path == "" { + return nil, fmt.Errorf("invalid empty module path") + } + + segments := strings.Split(mod.Path, "/") + + rootSegment := segments[0] + node, ok := nodeByRootSegment[rootSegment] + if !ok { + node = &Node{Segment: rootSegment} + nodeByRootSegment[rootSegment] = node + } + + if err := insertModuleInNode(node, mod, segments[1:]); err != nil { + return nil, err + } + } + + res := make([]Node, 0, len(nodeByRootSegment)) + for _, node := range nodeByRootSegment { + res = append(res, *node) + } + return res, nil +} + +func FilterModulesWithoutDir(modules []module.Module) []module.Module { + var res []module.Module + for _, mod := range modules { + // Don't vendor modules without backing directory. + if mod.Dir == "" { + continue + } + + res = append(res, mod) + } + + return res +} + +type Options struct { + SrcDir string + SkipGoBin bool + SkipGoSrc bool + SkipGoPkg bool +} + +func (o *Options) AddFlags(fs *pflag.FlagSet) { + fs.StringVar(&o.SrcDir, "src-dir", o.SrcDir, "Source directory for linking. Empty string indicates current directory.") + fs.BoolVar(&o.SkipGoPkg, "skip-go-pkg", o.SkipGoPkg, "Whether to skip mirroring $GOPATH/pkg") + fs.BoolVar(&o.SkipGoBin, "skip-go-bin", o.SkipGoBin, "Whether to skip mirroring $GOBIN") + fs.BoolVar(&o.SkipGoSrc, "skip-go-src", o.SkipGoSrc, "Whether to skip mirroring modules as src") +} + +func Link(dstDir string, opts Options) error { + if opts.SrcDir == "" { + opts.SrcDir = "." + } + + if !opts.SkipGoSrc { + if err := GoSrc(dstDir, opts.SrcDir); err != nil { + return fmt.Errorf("error linking GOPATH/src: %w", err) + } + } + + if !opts.SkipGoBin { + if err := GoBin(dstDir); err != nil { + return fmt.Errorf("error linking GOPATH/bin: %w", err) + } + } + + if !opts.SkipGoPkg { + if err := GoPkg(dstDir); err != nil { + return fmt.Errorf("error linking GOPATH/pkg: %w", err) + } + } + + return nil +} + +func GoBin(dstDir string) error { + dstGoBinDir := filepath.Join(dstDir, "bin") + if err := os.RemoveAll(dstGoBinDir); err != nil { + return err + } + + srcGoBinDir := os.Getenv("GOBIN") + if srcGoBinDir == "" { + srcGoBinDir = filepath.Join(build.Default.GOPATH, "bin") + } + + if err := os.Symlink(srcGoBinDir, dstGoBinDir); err != nil { + return err + } + return nil +} + +func GoPkg(dstDir string) error { + dstGoPkgDir := filepath.Join(dstDir, "pkg") + if err := os.RemoveAll(dstGoPkgDir); err != nil { + return err + } + + if err := os.Symlink(filepath.Join(build.Default.GOPATH, "pkg"), dstGoPkgDir); err != nil { + return err + } + return nil +} + +func GoSrc(dstDir, srcDir string) error { + mods, err := module.ReadAllGoListModules(module.InDir(srcDir)) + if err != nil { + return fmt.Errorf("error reading modules: %w", err) + } + + mods = FilterModulesWithoutDir(mods) + + nodes, err := BuildModuleNodes(mods) + if err != nil { + return fmt.Errorf("error building module tree: %w", err) + } + + dstGoSrcDir := filepath.Join(dstDir, "src") + if err := os.RemoveAll(dstGoSrcDir); err != nil { + return err + } + + if err := os.Mkdir(dstGoSrcDir, 0777); err != nil { + return err + } + + if err := Nodes(dstGoSrcDir, nodes); err != nil { + return err + } + return nil +} + +type linkNodeError struct { + path string + err error +} + +func (l *linkNodeError) Error() string { + return fmt.Sprintf("[path %s]: %v", l.path, l.err) +} + +func joinLinkNodeError(node Node, err error) error { + if linkNodeErr, ok := err.(*linkNodeError); ok { + return &linkNodeError{ + path: path.Join(node.Segment, linkNodeErr.path), + err: linkNodeErr.err, + } + } + return &linkNodeError{ + path: node.Segment, + err: err, + } +} + +func Nodes(dir string, nodes []Node) error { + for _, node := range nodes { + if err := linkNode(dir, node); err != nil { + return joinLinkNodeError(node, err) + } + } + return nil +} + +func linkNode(dir string, node Node) error { + dstDir := filepath.Join(dir, node.Segment) + + // If the node specifies a module and no children are present, we can take optimize and directly + // symlink the module directory to the destination directory. + if node.Module != nil && len(node.Children) == 0 { + srcDir := node.Module.Dir + + if err := os.Symlink(srcDir, dstDir); err != nil { + return fmt.Errorf("error symlinking node: %w", err) + } + } + + if err := os.RemoveAll(dstDir); err != nil { + return err + } + + if err := os.Mkdir(dstDir, 0777); err != nil { + return err + } + + if node.Module != nil { + srcDir := node.Module.Dir + entries, err := os.ReadDir(srcDir) + if err != nil { + return err + } + + for _, entry := range entries { + srcPath := filepath.Join(srcDir, entry.Name()) + dstPath := filepath.Join(dstDir, entry.Name()) + if err := os.Symlink(srcPath, dstPath); err != nil { + return fmt.Errorf("error symlinking entry %s to %s: %w", srcPath, dstPath, err) + } + } + } + return Nodes(dstDir, node.Children) +} diff --git a/vendor/github.com/ironcore-dev/vgopath/internal/module/module.go b/vendor/github.com/ironcore-dev/vgopath/internal/module/module.go new file mode 100644 index 00000000..c5dc27c7 --- /dev/null +++ b/vendor/github.com/ironcore-dev/vgopath/internal/module/module.go @@ -0,0 +1,184 @@ +// Copyright 2023 IronCore 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 module + +import ( + "encoding/json" + "errors" + "fmt" + "io" + "os/exec" + "sync" + "syscall" + "time" +) + +type Module struct { + Path string + Dir string + Version string + Main bool +} + +type Reader interface { + Read(data []Module) (int, error) +} + +type ReadCloser interface { + Reader + io.Closer +} + +type readCloser struct { + mu sync.Mutex + + cmd *exec.Cmd + dec *json.Decoder + + closed bool + closeErr error +} + +type OpenGoListOptions struct { + Dir string + Command func() *exec.Cmd +} + +func (o *OpenGoListOptions) ApplyToOpenGoList(o2 *OpenGoListOptions) { + if o.Dir != "" { + o2.Dir = o.Dir + } + if o.Command != nil { + o2.Command = o.Command + } +} + +func (o *OpenGoListOptions) ApplyOptions(opts []OpenGoListOption) { + for _, opt := range opts { + opt.ApplyToOpenGoList(o) + } +} + +type OpenGoListOption interface { + ApplyToOpenGoList(o *OpenGoListOptions) +} + +type InDir string + +func (d InDir) ApplyToOpenGoList(o *OpenGoListOptions) { + o.Dir = string(d) +} + +func setOpenGoListDefaults(o *OpenGoListOptions) { + if o.Dir == "" { + o.Dir = "." + } + if o.Command == nil { + o.Command = func() *exec.Cmd { + return exec.Command("go", "list", "-m", "-json", "all") + } + } +} + +func OpenGoList(opts ...OpenGoListOption) (ReadCloser, error) { + o := &OpenGoListOptions{} + o.ApplyOptions(opts) + setOpenGoListDefaults(o) + + cmd := o.Command() + cmd.Dir = o.Dir + stdout, err := cmd.StdoutPipe() + if err != nil { + return nil, err + } + + if err := cmd.Start(); err != nil { + return nil, err + } + + dec := json.NewDecoder(stdout) + + return &readCloser{ + cmd: cmd, + dec: dec, + }, nil +} + +func (r *readCloser) Read(data []Module) (n int, err error) { + for i := 0; i < len(data); i++ { + mod := &data[i] + if err := r.dec.Decode(mod); err != nil { + return i, err + } + } + return len(data), nil +} + +func (r *readCloser) Close() error { + r.mu.Lock() + defer r.mu.Unlock() + + if r.closed { + return r.closeErr + } + + defer func() { r.closed = true }() + + waitDone := make(chan struct{}) + go func() { + defer close(waitDone) + _ = r.cmd.Wait() + }() + + _ = r.cmd.Process.Signal(syscall.SIGTERM) + + timer := time.NewTimer(3 * time.Second) + defer timer.Stop() + + select { + case <-timer.C: + r.closeErr = fmt.Errorf("error waiting for command to be completed") + case <-waitDone: + } + return r.closeErr +} + +func ReadAll(r Reader) ([]Module, error) { + b := make([]Module, 0, 128) + for { + if len(b) == cap(b) { + // Add more capacity (let append pick how much). + b = append(b, Module{})[:len(b)] + } + n, err := r.Read(b[len(b):cap(b)]) + b = b[:len(b)+n] + if err != nil { + if errors.Is(err, io.EOF) { + err = nil + } + return b, err + } + } +} + +func ReadAllGoListModules(opts ...OpenGoListOption) ([]Module, error) { + rc, err := OpenGoList(opts...) + if err != nil { + return nil, err + } + defer func() { _ = rc.Close() }() + + return ReadAll(rc) +} diff --git a/vendor/github.com/ironcore-dev/vgopath/internal/version/version.go b/vendor/github.com/ironcore-dev/vgopath/internal/version/version.go new file mode 100644 index 00000000..6e4ea243 --- /dev/null +++ b/vendor/github.com/ironcore-dev/vgopath/internal/version/version.go @@ -0,0 +1,38 @@ +// Copyright 2023 IronCore 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 version + +import ( + "fmt" + "io" + "os" + "runtime/debug" +) + +func Version() string { + info, ok := debug.ReadBuildInfo() + if !ok || info == nil || info.Main.Version == "" { + return "(unknown)" + } + return info.Main.Version +} + +func FPrint(w io.Writer) { + _, _ = fmt.Fprintf(w, "Version: %s\n", Version()) +} + +func Print() { + FPrint(os.Stdout) +} diff --git a/vendor/github.com/ironcore-dev/vgopath/main.go b/vendor/github.com/ironcore-dev/vgopath/main.go new file mode 100644 index 00000000..62826886 --- /dev/null +++ b/vendor/github.com/ironcore-dev/vgopath/main.go @@ -0,0 +1,27 @@ +// Copyright 2022 IronCore 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 ( + "log" + + "github.com/ironcore-dev/vgopath/internal/cmd/vgopath" +) + +func main() { + if err := vgopath.Command().Execute(); err != nil { + log.Fatalln(err.Error()) + } +} diff --git a/vendor/github.com/onsi/ginkgo/v2/types/version.go b/vendor/github.com/onsi/ginkgo/v2/types/version.go index 04545630..a37f3082 100644 --- a/vendor/github.com/onsi/ginkgo/v2/types/version.go +++ b/vendor/github.com/onsi/ginkgo/v2/types/version.go @@ -1,3 +1,3 @@ package types -const VERSION = "2.12.1" +const VERSION = "2.13.0" diff --git a/vendor/github.com/onsi/gomega/CHANGELOG.md b/vendor/github.com/onsi/gomega/CHANGELOG.md index 1526497b..4fc45f29 100644 --- a/vendor/github.com/onsi/gomega/CHANGELOG.md +++ b/vendor/github.com/onsi/gomega/CHANGELOG.md @@ -1,3 +1,32 @@ +## 1.29.0 + +### Features +- MatchError can now take an optional func(error) bool + description [2b39142] + +## 1.28.1 + +### Maintenance +- Bump github.com/onsi/ginkgo/v2 from 2.12.0 to 2.13.0 [635d196] +- Bump github.com/google/go-cmp from 0.5.9 to 0.6.0 [14f8859] +- Bump golang.org/x/net from 0.14.0 to 0.17.0 [d8a6508] +- #703 doc(matchers): HaveEach() doc comment updated [2705bdb] +- Minor typos (#699) [375648c] + +## 1.28.0 + +### Features +- Add VerifyHost handler to ghttp (#698) [0b03b36] + +### Fixes +- Read Body for Newer Responses in HaveHTTPBodyMatcher (#686) [18d6673] + +### Maintenance +- Bump github.com/onsi/ginkgo/v2 from 2.11.0 to 2.12.0 (#693) [55a33f3] +- Typo in matchers.go (#691) [de68e8f] +- Bump commonmarker from 0.23.9 to 0.23.10 in /docs (#690) [ab17f5e] +- chore: update test matrix for Go 1.21 (#689) [5069017] +- Bump golang.org/x/net from 0.12.0 to 0.14.0 (#688) [babe25f] + ## 1.27.10 ### Fixes diff --git a/vendor/github.com/onsi/gomega/gomega_dsl.go b/vendor/github.com/onsi/gomega/gomega_dsl.go index 1fd1803a..ba082146 100644 --- a/vendor/github.com/onsi/gomega/gomega_dsl.go +++ b/vendor/github.com/onsi/gomega/gomega_dsl.go @@ -22,7 +22,7 @@ import ( "github.com/onsi/gomega/types" ) -const GOMEGA_VERSION = "1.27.10" +const GOMEGA_VERSION = "1.29.0" const nilGomegaPanic = `You are trying to make an assertion, but haven't registered Gomega's fail handler. If you're using Ginkgo then you probably forgot to put your assertion in an It(). @@ -242,7 +242,7 @@ func ExpectWithOffset(offset int, actual interface{}, extra ...interface{}) Asse Eventually enables making assertions on asynchronous behavior. Eventually checks that an assertion *eventually* passes. Eventually blocks when called and attempts an assertion periodically until it passes or a timeout occurs. Both the timeout and polling interval are configurable as optional arguments. -The first optional argument is the timeout (which defaults to 1s), the second is the polling interval (which defaults to 10ms). Both intervals can be specified as time.Duration, parsable duration strings or floats/integers (in which case they are interpreted as seconds). In addition an optional context.Context can be passed in - Eventually will keep trying until either the timeout epxires or the context is cancelled, whichever comes first. +The first optional argument is the timeout (which defaults to 1s), the second is the polling interval (which defaults to 10ms). Both intervals can be specified as time.Duration, parsable duration strings or floats/integers (in which case they are interpreted as seconds). In addition an optional context.Context can be passed in - Eventually will keep trying until either the timeout expires or the context is cancelled, whichever comes first. Eventually works with any Gomega compatible matcher and supports making assertions against three categories of actual value: @@ -313,13 +313,13 @@ It is important to note that the function passed into Eventually is invoked *syn }).Should(BeNumerically(">=", 17)) }, SpecTimeout(time.Second)) -you an also use Eventually().WithContext(ctx) to pass in the context. Passed-in contexts play nicely with paseed-in arguments as long as the context appears first. You can rewrite the above example as: +you an also use Eventually().WithContext(ctx) to pass in the context. Passed-in contexts play nicely with passed-in arguments as long as the context appears first. You can rewrite the above example as: It("fetches the correct count", func(ctx SpecContext) { Eventually(client.FetchCount).WithContext(ctx).WithArguments("/users").Should(BeNumerically(">=", 17)) }, SpecTimeout(time.Second)) -Either way the context passd to Eventually is also passed to the underlying funciton. Now, when Ginkgo cancels the context both the FetchCount client and Gomega will be informed and can exit. +Either way the context passd to Eventually is also passed to the underlying function. Now, when Ginkgo cancels the context both the FetchCount client and Gomega will be informed and can exit. **Category 3: Making assertions _in_ the function passed into Eventually** @@ -349,7 +349,7 @@ For example: will rerun the function until all assertions pass. -You can also pass additional arugments to functions that take a Gomega. The only rule is that the Gomega argument must be first. If you also want to pass the context attached to Eventually you must ensure that is the second argument. For example: +You can also pass additional arguments to functions that take a Gomega. The only rule is that the Gomega argument must be first. If you also want to pass the context attached to Eventually you must ensure that is the second argument. For example: Eventually(func(g Gomega, ctx context.Context, path string, expected ...string){ tok, err := client.GetToken(ctx) diff --git a/vendor/github.com/onsi/gomega/matchers.go b/vendor/github.com/onsi/gomega/matchers.go index bdaf62b5..cd3f431d 100644 --- a/vendor/github.com/onsi/gomega/matchers.go +++ b/vendor/github.com/onsi/gomega/matchers.go @@ -88,19 +88,44 @@ func Succeed() types.GomegaMatcher { } // MatchError succeeds if actual is a non-nil error that matches the passed in -// string, error, or matcher. +// string, error, function, or matcher. // // These are valid use-cases: // -// Expect(err).Should(MatchError("an error")) //asserts that err.Error() == "an error" -// Expect(err).Should(MatchError(SomeError)) //asserts that err == SomeError (via reflect.DeepEqual) -// Expect(err).Should(MatchError(ContainSubstring("sprocket not found"))) // asserts that edrr.Error() contains substring "sprocket not found" +// When passed a string: +// +// Expect(err).To(MatchError("an error")) +// +// asserts that err.Error() == "an error" +// +// When passed an error: +// +// Expect(err).To(MatchError(SomeError)) +// +// First checks if errors.Is(err, SomeError). +// If that fails then it checks if reflect.DeepEqual(err, SomeError) repeatedly for err and any errors wrapped by err +// +// When passed a matcher: +// +// Expect(err).To(MatchError(ContainSubstring("sprocket not found"))) +// +// the matcher is passed err.Error(). In this case it asserts that err.Error() contains substring "sprocket not found" +// +// When passed a func(err) bool and a description: +// +// Expect(err).To(MatchError(os.IsNotExist, "IsNotExist")) +// +// the function is passed err and matches if the return value is true. The description is required to allow Gomega +// to print a useful error message. // // It is an error for err to be nil or an object that does not implement the // Error interface -func MatchError(expected interface{}) types.GomegaMatcher { +// +// The optional second argument is a description of the error function, if used. This is required when passing a function but is ignored in all other cases. +func MatchError(expected interface{}, functionErrorDescription ...any) types.GomegaMatcher { return &matchers.MatchErrorMatcher{ - Expected: expected, + Expected: expected, + FuncErrDescription: functionErrorDescription, } } @@ -381,7 +406,7 @@ func ContainElements(elements ...interface{}) types.GomegaMatcher { } // HaveEach succeeds if actual solely contains elements that match the passed in element. -// Please note that if actual is empty, HaveEach always will succeed. +// Please note that if actual is empty, HaveEach always will fail. // By default HaveEach() uses Equal() to perform the match, however a // matcher can be passed in instead: // diff --git a/vendor/github.com/onsi/gomega/matchers/have_http_body_matcher.go b/vendor/github.com/onsi/gomega/matchers/have_http_body_matcher.go index 6a3dcdc3..d14d9e5f 100644 --- a/vendor/github.com/onsi/gomega/matchers/have_http_body_matcher.go +++ b/vendor/github.com/onsi/gomega/matchers/have_http_body_matcher.go @@ -11,8 +11,9 @@ import ( ) type HaveHTTPBodyMatcher struct { - Expected interface{} - cachedBody []byte + Expected interface{} + cachedResponse interface{} + cachedBody []byte } func (matcher *HaveHTTPBodyMatcher) Match(actual interface{}) (bool, error) { @@ -73,7 +74,7 @@ func (matcher *HaveHTTPBodyMatcher) NegatedFailureMessage(actual interface{}) (m // the Reader is closed and it is not readable again in FailureMessage() // or NegatedFailureMessage() func (matcher *HaveHTTPBodyMatcher) body(actual interface{}) ([]byte, error) { - if matcher.cachedBody != nil { + if matcher.cachedResponse == actual && matcher.cachedBody != nil { return matcher.cachedBody, nil } @@ -91,8 +92,10 @@ func (matcher *HaveHTTPBodyMatcher) body(actual interface{}) ([]byte, error) { switch a := actual.(type) { case *http.Response: + matcher.cachedResponse = a return body(a) case *httptest.ResponseRecorder: + matcher.cachedResponse = a return body(a.Result()) default: return nil, fmt.Errorf("HaveHTTPBody matcher expects *http.Response or *httptest.ResponseRecorder. Got:\n%s", format.Object(actual, 1)) diff --git a/vendor/github.com/onsi/gomega/matchers/match_error_matcher.go b/vendor/github.com/onsi/gomega/matchers/match_error_matcher.go index 827475ea..c539dd38 100644 --- a/vendor/github.com/onsi/gomega/matchers/match_error_matcher.go +++ b/vendor/github.com/onsi/gomega/matchers/match_error_matcher.go @@ -9,10 +9,14 @@ import ( ) type MatchErrorMatcher struct { - Expected interface{} + Expected any + FuncErrDescription []any + isFunc bool } -func (matcher *MatchErrorMatcher) Match(actual interface{}) (success bool, err error) { +func (matcher *MatchErrorMatcher) Match(actual any) (success bool, err error) { + matcher.isFunc = false + if isNil(actual) { return false, fmt.Errorf("Expected an error, got nil") } @@ -42,6 +46,17 @@ func (matcher *MatchErrorMatcher) Match(actual interface{}) (success bool, err e return actualErr.Error() == expected, nil } + v := reflect.ValueOf(expected) + t := v.Type() + errorInterface := reflect.TypeOf((*error)(nil)).Elem() + if t.Kind() == reflect.Func && t.NumIn() == 1 && t.In(0).Implements(errorInterface) && t.NumOut() == 1 && t.Out(0).Kind() == reflect.Bool { + if len(matcher.FuncErrDescription) == 0 { + return false, fmt.Errorf("MatchError requires an additional description when passed a function") + } + matcher.isFunc = true + return v.Call([]reflect.Value{reflect.ValueOf(actualErr)})[0].Bool(), nil + } + var subMatcher omegaMatcher var hasSubMatcher bool if expected != nil { @@ -57,9 +72,15 @@ func (matcher *MatchErrorMatcher) Match(actual interface{}) (success bool, err e } func (matcher *MatchErrorMatcher) FailureMessage(actual interface{}) (message string) { + if matcher.isFunc { + return format.Message(actual, fmt.Sprintf("to match error function %s", matcher.FuncErrDescription[0])) + } return format.Message(actual, "to match error", matcher.Expected) } func (matcher *MatchErrorMatcher) NegatedFailureMessage(actual interface{}) (message string) { + if matcher.isFunc { + return format.Message(actual, fmt.Sprintf("not to match error function %s", matcher.FuncErrDescription[0])) + } return format.Message(actual, "not to match error", matcher.Expected) } diff --git a/vendor/modules.txt b/vendor/modules.txt index e310439d..487f18bf 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -15,7 +15,7 @@ github.com/fatih/color # github.com/fsnotify/fsnotify v1.6.0 ## explicit; go 1.16 github.com/fsnotify/fsnotify -# github.com/gardener/gardener v1.83.0 +# github.com/gardener/gardener v1.84.0 ## explicit; go 1.21 github.com/gardener/gardener/hack # github.com/go-logr/logr v1.2.4 @@ -85,7 +85,7 @@ github.com/google/gnostic-models/extensions github.com/google/gnostic-models/jsonschema github.com/google/gnostic-models/openapiv2 github.com/google/gnostic-models/openapiv3 -# github.com/google/go-cmp v0.5.9 +# github.com/google/go-cmp v0.6.0 ## explicit; go 1.13 github.com/google/go-cmp/cmp github.com/google/go-cmp/cmp/internal/diff @@ -102,6 +102,15 @@ github.com/google/pprof/profile # github.com/inconshreveable/mousetrap v1.1.0 ## explicit; go 1.18 github.com/inconshreveable/mousetrap +# github.com/ironcore-dev/vgopath v0.1.3 +## explicit; go 1.20 +github.com/ironcore-dev/vgopath +github.com/ironcore-dev/vgopath/internal/cmd/version +github.com/ironcore-dev/vgopath/internal/cmd/vgopath +github.com/ironcore-dev/vgopath/internal/cmd/vgopath/exec +github.com/ironcore-dev/vgopath/internal/link +github.com/ironcore-dev/vgopath/internal/module +github.com/ironcore-dev/vgopath/internal/version # github.com/josharian/intern v1.0.0 ## explicit; go 1.5 github.com/josharian/intern @@ -154,7 +163,7 @@ github.com/onsi/ginkgo/reporters/stenographer github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty github.com/onsi/ginkgo/types -# github.com/onsi/ginkgo/v2 v2.12.1 +# github.com/onsi/ginkgo/v2 v2.13.0 ## explicit; go 1.18 github.com/onsi/ginkgo/v2/config github.com/onsi/ginkgo/v2/formatter @@ -172,7 +181,7 @@ github.com/onsi/ginkgo/v2/internal/interrupt_handler github.com/onsi/ginkgo/v2/internal/parallel_support github.com/onsi/ginkgo/v2/reporters github.com/onsi/ginkgo/v2/types -# github.com/onsi/gomega v1.27.10 +# github.com/onsi/gomega v1.29.0 ## explicit; go 1.18 github.com/onsi/gomega github.com/onsi/gomega/format