diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 00502c6b7..8b850da2a 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -18,7 +18,7 @@ jobs: # The main gotchas with this action are that it _only_ supports merge commits, # and that PRs _must_ be labelled before they're merged to trigger a backport. open-pr: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 if: github.event.pull_request.merged steps: - name: Checkout diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0069af8b4..f72377c68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,19 +10,20 @@ on: env: # Common versions - GO_VERSION: '1.17' - GOLANGCI_VERSION: 'v1.31' - DOCKER_BUILDX_VERSION: 'v0.4.2' + GO_VERSION: '1.18' + GOLANGCI_VERSION: 'v1.47.1' + DOCKER_BUILDX_VERSION: 'v0.8.2' # Common users. We can't run a step 'if secrets.AWS_USR != ""' but we can run # a step 'if env.AWS_USR' != ""', so we copy these to succinctly test whether # credentials have been provided before trying to run steps that need them. DOCKER_USR: ${{ secrets.DOCKER_USR }} + XPKG_ACCESS_ID: ${{ secrets.XPKG_ACCESS_ID }} AWS_USR: ${{ secrets.AWS_USR }} jobs: detect-noop: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 outputs: noop: ${{ steps.noop.outputs.should_skip }} steps: @@ -36,7 +37,7 @@ jobs: lint: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 needs: detect-noop if: needs.detect-noop.outputs.noop != 'true' @@ -80,7 +81,7 @@ jobs: version: ${{ env.GOLANGCI_VERSION }} check-diff: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 needs: detect-noop if: needs.detect-noop.outputs.noop != 'true' @@ -120,7 +121,7 @@ jobs: run: make check-diff unit-tests: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 needs: detect-noop if: needs.detect-noop.outputs.noop != 'true' @@ -169,7 +170,7 @@ jobs: file: _output/tests/linux_amd64/coverage.txt e2e-tests: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 needs: detect-noop if: needs.detect-noop.outputs.noop != 'true' @@ -231,7 +232,7 @@ jobs: run: make e2e USE_HELM3=true publish-artifacts: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 needs: detect-noop if: needs.detect-noop.outputs.noop != 'true' @@ -301,6 +302,14 @@ jobs: username: ${{ secrets.DOCKER_USR }} password: ${{ secrets.DOCKER_PSW }} + - name: Login to Upbound + uses: docker/login-action@v1 + if: env.XPKG_ACCESS_ID != '' + with: + registry: xpkg.upbound.io + username: ${{ secrets.XPKG_ACCESS_ID }} + password: ${{ secrets.XPKG_TOKEN }} + - name: Publish Artifacts to S3 and Docker Hub run: make -j2 publish BRANCH_NAME=${GITHUB_REF##*/} if: env.AWS_USR != '' && env.DOCKER_USR != '' diff --git a/.github/workflows/commands.yml b/.github/workflows/commands.yml index b9c504c48..815838b54 100644 --- a/.github/workflows/commands.yml +++ b/.github/workflows/commands.yml @@ -4,7 +4,7 @@ on: issue_comment jobs: points: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 if: startsWith(github.event.comment.body, '/points') steps: @@ -65,7 +65,7 @@ jobs: # NOTE(negz): See also backport.yml, which is the variant that triggers on PR # merge rather than on comment. backport: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/backport') steps: - name: Extract Command diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.yml index 8e84d5a84..abd5acfff 100644 --- a/.github/workflows/promote.yml +++ b/.github/workflows/promote.yml @@ -20,7 +20,7 @@ env: jobs: promote-artifacts: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 steps: - name: Checkout diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 0d0a89ef3..3b272eaf3 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -12,7 +12,7 @@ on: jobs: create-tag: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 steps: - name: Checkout diff --git a/Makefile b/Makefile index 328fe740c..7f6eb4016 100644 --- a/Makefile +++ b/Makefile @@ -37,14 +37,29 @@ GO111MODULE = on # ==================================================================================== # Setup Kubernetes tools +UP_VERSION = v0.13.0 +UP_CHANNEL = stable -include build/makelib/k8s_tools.mk # ==================================================================================== # Setup Images -DOCKER_REGISTRY ?= crossplane -IMAGES = provider-gcp provider-gcp-controller --include build/makelib/image.mk +IMAGES = provider-gcp +-include build/makelib/imagelight.mk + +# ==================================================================================== +# Setup XPKG + +XPKG_REG_ORGS ?= xpkg.upbound.io/crossplane index.docker.io/crossplane +# NOTE(hasheddan): skip promoting on xpkg.upbound.io as channel tags are +# inferred. +XPKG_REG_ORGS_NO_PROMOTE ?= xpkg.upbound.io/crossplane +XPKGS = provider-gcp +-include build/makelib/xpkg.mk + +# NOTE(hasheddan): we force image building to happen prior to xpkg build so that +# we ensure image is present in daemon. +xpkg.build.provider-gcp: do.build.images # ==================================================================================== # Targets @@ -69,6 +84,11 @@ fallthrough: submodules go.cachedir: @go env GOCACHE +# NOTE(hasheddan): we must ensure up is installed in tool cache prior to build +# as including the k8s_tools machinery prior to the xpkg machinery sets UP to +# point to tool cache. +build.init: $(UP) + # Generate a coverage report for cobertura applying exclusions on # - generated file cobertura: diff --git a/apis/storage/v1alpha3/types.go b/apis/storage/v1alpha3/types.go index ec380c09c..03260b8b9 100644 --- a/apis/storage/v1alpha3/types.go +++ b/apis/storage/v1alpha3/types.go @@ -321,16 +321,14 @@ func NewRetentionPolicy(rp *storage.RetentionPolicy) *RetentionPolicy { // CopyToRetentionPolicy create a copy in storage format func CopyToRetentionPolicy(rp *RetentionPolicy) *storage.RetentionPolicy { - var d time.Duration + d := time.Duration(0) - if rp == nil { - d = time.Duration(0) - } else { + if rp != nil { d = time.Duration(rp.RetentionPeriodSeconds) } return &storage.RetentionPolicy{ - RetentionPeriod: d * time.Second, + RetentionPeriod: d * time.Second, //nolint:durationcheck } } diff --git a/build b/build index bd63a4167..2fc4678a4 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit bd63a4167ae20a71788537217b022fced8f2f854 +Subproject commit 2fc4678a45e227e73719a84dfe88dadce47efafb diff --git a/cluster/images/provider-gcp-controller/Dockerfile b/cluster/images/provider-gcp-controller/Dockerfile deleted file mode 100644 index cd302fe27..000000000 --- a/cluster/images/provider-gcp-controller/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM BASEIMAGE -RUN apk --no-cache add ca-certificates bash - -ARG ARCH -ARG TINI_VERSION - -ADD provider /usr/local/bin/crossplane-gcp-provider - -EXPOSE 8080 -USER 1001 -ENTRYPOINT ["crossplane-gcp-provider"] diff --git a/cluster/images/provider-gcp-controller/Makefile b/cluster/images/provider-gcp-controller/Makefile deleted file mode 100755 index a83e6bb96..000000000 --- a/cluster/images/provider-gcp-controller/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# ==================================================================================== -# Setup Project - -PLATFORMS := linux_amd64 linux_arm64 -include ../../../build/makelib/common.mk - -# ==================================================================================== -# Options -IMAGE = $(BUILD_REGISTRY)/provider-gcp-controller-$(ARCH) -include ../../../build/makelib/image.mk - -# ==================================================================================== -# Targets - -img.build: - @$(INFO) docker build $(IMAGE) - @cp Dockerfile $(IMAGE_TEMP_DIR) || $(FAIL) - @cp $(OUTPUT_DIR)/bin/$(OS)_$(ARCH)/provider $(IMAGE_TEMP_DIR) || $(FAIL) - @cd $(IMAGE_TEMP_DIR) && $(SED_CMD) 's|BASEIMAGE|$(OSBASEIMAGE)|g' Dockerfile || $(FAIL) - @docker build $(BUILD_ARGS) \ - --build-arg ARCH=$(ARCH) \ - --build-arg TINI_VERSION=$(TINI_VERSION) \ - -t $(IMAGE) \ - $(IMAGE_TEMP_DIR) || $(FAIL) - @$(OK) docker build $(IMAGE) diff --git a/cluster/images/provider-gcp/Dockerfile b/cluster/images/provider-gcp/Dockerfile index 332e75124..acf1fec55 100644 --- a/cluster/images/provider-gcp/Dockerfile +++ b/cluster/images/provider-gcp/Dockerfile @@ -1,3 +1,9 @@ -FROM BASEIMAGE +FROM gcr.io/distroless/static@sha256:1f580b0a1922c3e54ae15b0758b5747b260bd99d39d40c2edb3e7f6e2452298b -COPY package.yaml . +ARG TARGETOS +ARG TARGETARCH + +ADD bin/$TARGETOS\_$TARGETARCH/provider /usr/local/bin/crossplane-gcp-provider + +USER 65532 +ENTRYPOINT ["crossplane-gcp-provider"] \ No newline at end of file diff --git a/cluster/images/provider-gcp/Makefile b/cluster/images/provider-gcp/Makefile index 481fab102..cfe2c3a4c 100755 --- a/cluster/images/provider-gcp/Makefile +++ b/cluster/images/provider-gcp/Makefile @@ -1,30 +1,35 @@ # ==================================================================================== # Setup Project -PLATFORMS := linux_amd64 linux_arm64 include ../../../build/makelib/common.mk # ==================================================================================== # Options -DOCKER_REGISTRY ?= crossplane -IMAGE = $(BUILD_REGISTRY)/provider-gcp-$(ARCH) -OSBASEIMAGE = scratch -include ../../../build/makelib/image.mk + +include ../../../build/makelib/imagelight.mk # ==================================================================================== # Targets img.build: @$(INFO) docker build $(IMAGE) + @$(MAKE) BUILD_ARGS="--load" img.build.shared + @$(OK) docker build $(IMAGE) + +img.publish: + @$(INFO) Skipping image publish for $(IMAGE) + @echo Publish is deferred to xpkg machinery + @$(OK) Image publish skipped for $(IMAGE) + +img.build.shared: @cp Dockerfile $(IMAGE_TEMP_DIR) || $(FAIL) - @cp -R ../../../package $(IMAGE_TEMP_DIR) || $(FAIL) - @cd $(IMAGE_TEMP_DIR) && $(SED_CMD) 's|BASEIMAGE|$(OSBASEIMAGE)|g' Dockerfile || $(FAIL) - @cd $(IMAGE_TEMP_DIR) && $(SED_CMD) 's|VERSION|$(VERSION)|g' package/crossplane.yaml || $(FAIL) - @cd $(IMAGE_TEMP_DIR) && $(SED_CMD) 's|DOCKER_REGISTRY|$(DOCKER_REGISTRY)|g' package/crossplane.yaml || $(FAIL) - @cd $(IMAGE_TEMP_DIR) && find package -type f -name '*.yaml' -exec cat {} >> 'package.yaml' \; -exec printf '\n---\n' \; || $(FAIL) - @docker build $(BUILD_ARGS) \ - --build-arg ARCH=$(ARCH) \ - --build-arg TINI_VERSION=$(TINI_VERSION) \ + @cp -r $(OUTPUT_DIR)/bin/ $(IMAGE_TEMP_DIR)/bin || $(FAIL) + @docker buildx build $(BUILD_ARGS) \ + --platform $(IMAGE_PLATFORMS) \ -t $(IMAGE) \ $(IMAGE_TEMP_DIR) || $(FAIL) - @$(OK) docker build $(IMAGE) + +img.promote: + @$(INFO) Skipping image promotion from $(FROM_IMAGE) to $(TO_IMAGE) + @echo Promote is deferred to xpkg machinery + @$(OK) Image promotion skipped for $(FROM_IMAGE) to $(TO_IMAGE) diff --git a/cluster/local/integration_tests.sh b/cluster/local/integration_tests.sh index 6fa04650a..19baf8638 100755 --- a/cluster/local/integration_tests.sh +++ b/cluster/local/integration_tests.sh @@ -41,12 +41,10 @@ eval $(make --no-print-directory -C ${projectdir} build.vars) # ------------------------------ SAFEHOSTARCH="${SAFEHOSTARCH:-amd64}" -BUILD_IMAGE="${BUILD_REGISTRY}/${PROJECT_NAME}-${SAFEHOSTARCH}" -CONTROLLER_IMAGE="${BUILD_REGISTRY}/${PROJECT_NAME}-controller-${SAFEHOSTARCH}" +CONTROLLER_IMAGE="${BUILD_REGISTRY}/${PROJECT_NAME}-${SAFEHOSTARCH}" version_tag="$(cat ${projectdir}/_output/version)" # tag as latest version to load into kind cluster -PACKAGE_CONTROLLER_IMAGE="${DOCKER_REGISTRY}/${PROJECT_NAME}-controller:${VERSION}" K8S_CLUSTER="${K8S_CLUSTER:-${BUILD_REGISTRY}-inttests}" CROSSPLANE_NAMESPACE="crossplane-system" @@ -68,7 +66,7 @@ echo_step "setting up local package cache" CACHE_PATH="${projectdir}/.work/inttest-package-cache" mkdir -p "${CACHE_PATH}" echo "created cache dir at ${CACHE_PATH}" -docker save "${BUILD_IMAGE}" -o "${CACHE_PATH}/${PACKAGE_NAME}.xpkg" && chmod 644 "${CACHE_PATH}/${PACKAGE_NAME}.xpkg" +"${UP}" alpha xpkg xp-extract --from-xpkg "${OUTPUT_DIR}"/xpkg/"${HOSTOS}"_"${SAFEHOSTARCH}"/"${PACKAGE_NAME}"-"${VERSION}".xpkg -o "${CACHE_PATH}/${PACKAGE_NAME}.gz" && chmod 644 "${CACHE_PATH}/${PACKAGE_NAME}.gz" # create kind cluster with extra mounts echo_step "creating k8s cluster using kind" @@ -85,13 +83,8 @@ EOF echo "${KIND_CONFIG}" | "${KIND}" create cluster --name="${K8S_CLUSTER}" --wait=5m --config=- # tag controller image and load it into kind cluster -docker tag "${CONTROLLER_IMAGE}" "${PACKAGE_CONTROLLER_IMAGE}" -"${KIND}" load docker-image "${PACKAGE_CONTROLLER_IMAGE}" --name="${K8S_CLUSTER}" - -# files are not synced properly from host to kind node container on Jenkins, so -# we must manually copy image from host to node -echo_step "pre-cache package by copying to kind node" -docker cp "${CACHE_PATH}/${PACKAGE_NAME}.xpkg" "${K8S_CLUSTER}-control-plane":"/cache/${PACKAGE_NAME}.xpkg" +docker tag "${CONTROLLER_IMAGE}" "${PACKAGE_NAME}" +"${KIND}" load docker-image "${PACKAGE_NAME}" --name="${K8S_CLUSTER}" echo_step "create crossplane-system namespace" "${KUBECTL}" create ns crossplane-system @@ -142,7 +135,7 @@ echo_info "using crossplane version ${chart_version}" echo # we replace empty dir with our PVC so that the /cache dir in the kind node # container is exposed to the crossplane pod -"${HELM3}" install crossplane --namespace crossplane-system crossplane-stable/crossplane --version 1.6.4 --wait --set packageCache.pvc=package-cache +"${HELM3}" install crossplane --namespace crossplane-system crossplane-stable/crossplane --version ${chart_version} --wait --set packageCache.pvc=package-cache # ----------- integration tests echo_step "--- INTEGRATION TESTS ---" diff --git a/go.mod b/go.mod index 98806a7e2..151e00a06 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/crossplane-contrib/provider-gcp -go 1.17 +go 1.18 require ( cloud.google.com/go/storage v1.15.0 diff --git a/go.sum b/go.sum index 6f856f081..aa8c48580 100644 --- a/go.sum +++ b/go.sum @@ -112,7 +112,6 @@ github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= -github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -121,7 +120,6 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= @@ -139,12 +137,10 @@ github.com/cenkalti/backoff/v3 v3.0.0/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4r github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/checkpoint-restore/go-criu/v4 v4.1.0/go.mod h1:xUQBLp4RLc5zJtWY++yjOoMoB5lihDt7fai+75m+rGw= -github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -375,7 +371,6 @@ github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.14/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-test/deep v1.0.2 h1:onZX1rnHT3Wv6cqNgYyFOOlgVKJrksuCMCRvJStbMYw= github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gobuffalo/flect v0.2.3 h1:f/ZukRnSNA/DUpSNDadko7Qc0PhGvsew35p/2tu+CRY= @@ -516,7 +511,6 @@ github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtng github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-getter v1.4.0/go.mod h1:7qxyCd8rBfcShwsvxgIguu4KbS3l8bUCwg2Umn7RjeY= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v0.16.2 h1:K4ev2ib4LdQETX5cSZBG0DVLk1jwGqSPXBjdah3veNs= @@ -538,7 +532,6 @@ github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= github.com/hashicorp/go-secure-stdlib/base62 v0.1.1/go.mod h1:EdWO6czbmthiwZ3/PUsDV+UD1D5IRU4ActiaWGwt0Yw= github.com/hashicorp/go-secure-stdlib/mlock v0.1.1 h1:cCRo8gK7oq6A2L6LICkUZ+/a5rLiRXFMf1Qd4xSwxTc= github.com/hashicorp/go-secure-stdlib/mlock v0.1.1/go.mod h1:zq93CJChV6L9QTfGKtfBxKqD7BqqXx5O04A/ns2p5+I= @@ -556,7 +549,6 @@ github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= @@ -652,7 +644,6 @@ github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcME github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= @@ -706,7 +697,6 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWb github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= @@ -719,9 +709,7 @@ github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+ github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= 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/gomega v0.0.0-20151007035656-2152b45fa28a/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= @@ -729,7 +717,6 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= github.com/onsi/gomega v1.17.0 h1:9Luw4uT5HTjHTN8+aNcSThgH1vdXnmdJ8xIfZ4wyTRE= -github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= @@ -887,7 +874,6 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1 github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= @@ -955,7 +941,6 @@ go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= -go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= @@ -1072,7 +1057,6 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -1181,7 +1165,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201202213521-69691e467435/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1281,7 +1264,6 @@ golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82u golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -1454,7 +1436,6 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= -gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= diff --git a/package/crds/container.gcp.crossplane.io_clusters.yaml b/package/crds/container.gcp.crossplane.io_clusters.yaml index 21cbfbd61..88b7b0776 100644 --- a/package/crds/container.gcp.crossplane.io_clusters.yaml +++ b/package/crds/container.gcp.crossplane.io_clusters.yaml @@ -740,8 +740,8 @@ spec: - Default value. \"LEGACY_DATAPATH\" - Use the IPTables implementation based on kube-proxy. \"ADVANCED_DATAPATH\" - Use the eBPF based GKE Dataplane V2 with additional features. - See the [GKE Dataplane V2 documentation](https://cloud.google.com/kubernetes-engine/docs/how-to/ - dataplane-v2) for more." + See the [GKE Dataplane V2 documentation](https://cloud.google.com/kubernetes-engine/docs/how-to/dataplane-v2) + for more." type: string defaultSnatStatus: description: 'DefaultSnatStatus: Whether the cluster disables @@ -1122,11 +1122,11 @@ spec: format: int64 type: integer currentNodeVersion: - description: 'CurrentNodeVersion: Deprecated, use [NodePools.version](/kubernetes-engine/docs/reference/rest/v1/proj - ects.zones.clusters.nodePools) instead. The current version - of the node software components. If they are currently at multiple - versions because they''re in the process of being upgraded, - this reflects the minimum version of all nodes.' + description: 'CurrentNodeVersion: Deprecated, use [NodePools.version](/kubernetes-engine/docs/reference/rest/v1/projects.zones.clusters.nodePools) + instead. The current version of the node software components. + If they are currently at multiple versions because they''re + in the process of being upgraded, this reflects the minimum + version of all nodes.' type: string endpoint: description: "Endpoint: The IP address of this cluster's master diff --git a/package/crossplane.yaml b/package/crossplane.yaml index 640dfee28..5498ef29e 100644 --- a/package/crossplane.yaml +++ b/package/crossplane.yaml @@ -14,71 +14,7 @@ metadata: `provider-gcp` is the Crossplane infrastructure provider for the [Google Cloud Platform (GCP)](https://cloud.google.com/). - Available resources and their fields can be found in the [CRD - Docs](https://doc.crds.dev/github.com/crossplane/provider-gcp). - If you encounter an issue please reach out on [slack.crossplane.io](https://slack.crossplane.io) and create an issue in the [crossplane/provider-gcp](https://github.com/crossplane/provider-gcp) repo. - meta.crossplane.io/iconURI: data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNjUiIGhlaWdodD0iNjUiPjxkZWZzPjxwYXRoIGlkPSJhIiBkPSJNLjIwNTI5Mzk0LjY4MDM3NDI3SDIzLjA0MDMwNzdWMTEuMTU4NDcwNUguMjA1MjkzOTR6Ii8+PHBhdGggaWQ9ImMiIGQ9Ik0uNjg0MjgzNC4wNTc2NDU5aDE4LjgwNTIyNHYyNS42NzQ5MzE2SC42ODQyODM0eiIvPjxwYXRoIGlkPSJlIiBkPSJNMCAuNTIwNDEzNzloMTguMTcyMzUzOFYxOC45MTQ5NTg4SDB6Ii8+PC9kZWZzPjxnIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+PHJlY3Qgd2lkdGg9IjY0IiBoZWlnaHQ9IjY0IiB4PSIuNSIgeT0iLjUiIGZpbGw9IiNGQUZBRkEiIGZpbGwtcnVsZT0ibm9uemVybyIgc3Ryb2tlPSIjRDhEOERBIiByeD0iMTYiLz48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxOS4xMjggMTYuNDI4KSI+PG1hc2sgaWQ9ImIiIGZpbGw9IiNmZmYiPjx1c2UgeGxpbms6aHJlZj0iI2EiLz48L21hc2s+PHBhdGggZmlsbD0iI0VBNDMzNSIgZD0iTTE4LjY2ODM0NDkgOC43MzE3Mjg0aDEuMDk1NzNsMy4xMjI4MzA2LTMuMTU4MDg5MDYuMTUzNDAyMi0xLjM0MDgwMjcyQzE3LjIyODU1NTYtLjk1NTI5NDI0IDguMzU4NjIxMDctLjM5NTcwMzAyIDMuMjI4NDEzMDkgNS40ODE2NjY5MyAxLjgwMjg2ODMyIDcuMTE1MDA4NDIuNzY5NTk0OSA5LjA1NjQwMjEyLjIwNTI5Mzk0IDExLjE1ODQ3MDVjLjM0NzM0NjQyLS4xNDQwNTMyLjczMzA0MzM5LS4xNjczMjMzIDEuMDk1NzMwMDMtLjA2NjQ4NjFsNi4yNDU2NjExNS0xLjA0MTYxNTNzLjMxNzc2MTcxLS41MzE4ODg2OS40ODIxMjEyMi0uNDk4NjQ1NjVDMTAuODA2NDgyIDYuNDY1NjYwOTkgMTUuNDgxOTYyIDYuMTA2NjM2MTMgMTguNjkwMjU5NSA4LjczMTcyODRoLS4wMjE5MTQ2eiIgbWFzaz0idXJsKCNiKSIvPjwvZz48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgzMS40MzYgMjAuNjE0KSI+PG1hc2sgaWQ9ImQiIGZpbGw9IiNmZmYiPjx1c2UgeGxpbms6aHJlZj0iI2MiLz48L21hc2s+PHBhdGggZmlsbD0iIzQyODVGNCIgZD0iTTE1LjAyNzM4OTUgNi45NzIxOTg3N2MtLjcxNzcwMzItMi42NzM4NDg3My0yLjE5MTQ2MDEtNS4wNzYyMTI2MS00LjI0MDQ3NTItNi45MTQ1NTI4N0w2LjQwMzk5NDE1IDQuNDkwMDUxNTljMS44NTA2ODgwMSAxLjUyOTE3OTk2IDIuOTA0NzgwMyAzLjgzMjkyMjgyIDIuODU5ODU1MzcgNi4yNDk2OTIwMXYuNzg2NzUyYzIuMTU1MzAwOTggMCAzLjkwMDc5ODg4IDEuNzY2MzEzNyAzLjkwMDc5ODg4IDMuOTQzNzMzIDAgMi4xNzk2MzU1LTEuNzQ1NDk3OSAzLjk0NTk0OTEtMy45MDA3OTg4OCAzLjk0NTk0OTFoLTcuODAxNTk3OGwtLjc3Nzk2ODMyLjc5NzgzMzF2NC43MzE1OTNsLjc3Nzk2ODMyLjc4Njc1MjFoNy44MDE1OTc4YzUuNjAzNTYzMzguMDQzMjE1OSAxMC4xODE1MjMzOC00LjUxNDQwNTIgMTAuMjI1MzUyNTgtMTAuMTgwMTI3OC4wMjYyOTc2LTMuNDM1MTE0NC0xLjY0Nzk3NzktNi42NTYzNjUyNi00LjQ2MTgxMjYtOC41ODAwMjkzMyIgbWFzaz0idXJsKCNkKSIvPjwvZz48cGF0aCBmaWxsPSIjMzRBODUzIiBkPSJNMjUuMDg1ODY2MiA0Ni4zMDI0NzM5aDcuODAxNTk3OHYtNi4zMTYxNzgxaC03LjgwMTU5NzhjLS41NTU1MzUxNCAwLTEuMTA1NTkxNjEtLjEyMTg5MTEtMS42MTA3MjMxNi0uMzU1NzAwNWwtMS4wOTU3MzAwMi4zNDQ2MTk1LTMuMTQ0NzQ1MTggMy4xNTgwODkxLS4yNzM5MzI1MSAxLjEwODEwMTRjMS43NjQxMjUzNCAxLjM0NjM0MzIgMy45MTUwNDMzOSAyLjA3MTA0MTUgNi4xMjUxMzA4NyAyLjA2MTA2ODYiLz48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxNSAyNS4yOTMpIj48bWFzayBpZD0iZiIgZmlsbD0iI2ZmZiI+PHVzZSB4bGluazpocmVmPSIjZSIvPjwvbWFzaz48cGF0aCBmaWxsPSIjRkJCQzA1IiBkPSJNMTAuMDg1ODY2Mi41MjA0MTM4QzQuNDgyMzAyODIuNTU0ODI2MzctLjAzMzIwMDYyIDUuMTc1NjA5My0uMDAwNTA3MDYgMTAuODQyNDRjLjAxODgwNTc1IDMuMTY0NzM3NiAxLjQ4MDUwOTYxIDYuMTQzMzE0MyAzLjk2MTI0MjM5IDguMDcyNTE4OEw4LjQ4NjEwMDM0IDE0LjMzODVjLTEuOTYzNTQ4MjEtLjg5NzU2MjItMi44MzU3NDkzMS0zLjIzMzQ0LTEuOTQ4MjA3OTgtNS4yMTkxNTc3Mi44ODY0NDU1OS0xLjk4NTcxNzc1IDMuMTk3MzQwMjItMi44Njc3NjY0OSA1LjE2MDg4ODQ0LTEuOTcxMzEyNDMuODY0NTMxLjM5NTU5MjIgMS41NTgxMjgxIDEuMDk3MDIwNCAxLjk0ODIwOCAxLjk3MTMxMjQzbDQuNTI1MzY1LTQuNTc2NDU4ODhDMTYuMjQ3MTU2MSAxLjk5NzU3NDQzIDEzLjI1NDcxNzQuNTA5Mzk0MjIgMTAuMDg1ODY2Mi41MjA0MTM4IiBtYXNrPSJ1cmwoI2YpIi8+PC9nPjwvZz48L3N2Zz4= - friendly-name.meta.crossplane.io: Provider GCP - - friendly-group-name.meta.crossplane.io/cache.gcp.crossplane.io: "Caches" - friendly-group-name.meta.crossplane.io/compute.gcp.crossplane.io: "Compute" - friendly-group-name.meta.crossplane.io/container.gcp.crossplane.io: "Containers" - friendly-group-name.meta.crossplane.io/database.gcp.crossplane.io: "Databases" - friendly-group-name.meta.crossplane.io/iam.gcp.crossplane.io: "IAM" - friendly-group-name.meta.crossplane.io/kms.gcp.crossplane.io: "Key Managment" - friendly-group-name.meta.crossplane.io/pubsub.gcp.crossplane.io: "Pub/Sub" - friendly-group-name.meta.crossplane.io/servicenetworking.gcp.crossplane.io: "Service Networking" - friendly-group-name.meta.crossplane.io/storage.gcp.crossplane.io: "Storage" - - friendly-kind-name.meta.crossplane.io/bucketpolicy.storage.gcp.crossplane.io: Bucket Policy - friendly-kind-name.meta.crossplane.io/bucketpolicymember.storage.gcp.crossplane.io: Bucket Policy Member - friendly-kind-name.meta.crossplane.io/bucket.storage.gcp.crossplane.io: Bucket - friendly-kind-name.meta.crossplane.io/cloudmemorystoreinstance.cache.gcp.crossplane.io: Memorystore Instance - friendly-kind-name.meta.crossplane.io/cloudsqlinstance.database.gcp.crossplane.io: SQL Instance - friendly-kind-name.meta.crossplane.io/connection.servicenetworking.gcp.crossplane.io: Connection - friendly-kind-name.meta.crossplane.io/cryptokeypolicy.kms.gcp.crossplane.io: Crypto Key Policy - friendly-kind-name.meta.crossplane.io/cryptokey.kms.gcp.crossplane.io: Crypto Key - friendly-kind-name.meta.crossplane.io/gkecluster.container.gcp.crossplane.io: GKE Cluster - friendly-kind-name.meta.crossplane.io/globaladdress.compute.gcp.crossplane.io: Global Address - friendly-kind-name.meta.crossplane.io/keyring.kms.gcp.crossplane.io: Keyring - friendly-kind-name.meta.crossplane.io/network.compute.gcp.crossplane.io: Network - friendly-kind-name.meta.crossplane.io/nodepool.container.gcp.crossplane.io: GKE Node Pool - friendly-kind-name.meta.crossplane.io/serviceaccountpolicy.iam.gcp.crossplane.io: Service Account Policy - friendly-kind-name.meta.crossplane.io/serviceaccount.iam.gcp.crossplane.io: Service Account - friendly-kind-name.meta.crossplane.io/subnetwork.compute.gcp.crossplane.io: Subnetwork - friendly-kind-name.meta.crossplane.io/topic.pubsub.gcp.crossplane.io: Topic - - # TODO(negz): Remove the below metadata once we're two releases past v0.16, - # which should be enough time for consumers to update. - company: Crossplane - maintainer: Crossplane Maintainers - source: github.com/crossplane/provider-gcp - license: Apache-2.0 - descriptionShort: | - The GCP Crossplane provider enables infrastructure management for the - Google Cloud Platform. - - description: | - The Google Cloud Platform (GCP) Crossplane provider adds support for - managing GCP resources in Kubernetes. - - readme: | - `provider-gcp` is the Crossplane infrastructure provider for the [Google - Cloud Platform (GCP)](https://cloud.google.com/). - - Available resources and their fields can be found in the [CRD - Docs](https://doc.crds.dev/github.com/crossplane/provider-gcp). - - If you encounter an issue please reach out on - [slack.crossplane.io](https://slack.crossplane.io) and create an issue in - the [crossplane/provider-gcp](https://github.com/crossplane/provider-gcp) - repo. - iconData: PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNjUiIGhlaWdodD0iNjUiPjxkZWZzPjxwYXRoIGlkPSJhIiBkPSJNLjIwNTI5Mzk0LjY4MDM3NDI3SDIzLjA0MDMwNzdWMTEuMTU4NDcwNUguMjA1MjkzOTR6Ii8+PHBhdGggaWQ9ImMiIGQ9Ik0uNjg0MjgzNC4wNTc2NDU5aDE4LjgwNTIyNHYyNS42NzQ5MzE2SC42ODQyODM0eiIvPjxwYXRoIGlkPSJlIiBkPSJNMCAuNTIwNDEzNzloMTguMTcyMzUzOFYxOC45MTQ5NTg4SDB6Ii8+PC9kZWZzPjxnIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+PHJlY3Qgd2lkdGg9IjY0IiBoZWlnaHQ9IjY0IiB4PSIuNSIgeT0iLjUiIGZpbGw9IiNGQUZBRkEiIGZpbGwtcnVsZT0ibm9uemVybyIgc3Ryb2tlPSIjRDhEOERBIiByeD0iMTYiLz48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxOS4xMjggMTYuNDI4KSI+PG1hc2sgaWQ9ImIiIGZpbGw9IiNmZmYiPjx1c2UgeGxpbms6aHJlZj0iI2EiLz48L21hc2s+PHBhdGggZmlsbD0iI0VBNDMzNSIgZD0iTTE4LjY2ODM0NDkgOC43MzE3Mjg0aDEuMDk1NzNsMy4xMjI4MzA2LTMuMTU4MDg5MDYuMTUzNDAyMi0xLjM0MDgwMjcyQzE3LjIyODU1NTYtLjk1NTI5NDI0IDguMzU4NjIxMDctLjM5NTcwMzAyIDMuMjI4NDEzMDkgNS40ODE2NjY5MyAxLjgwMjg2ODMyIDcuMTE1MDA4NDIuNzY5NTk0OSA5LjA1NjQwMjEyLjIwNTI5Mzk0IDExLjE1ODQ3MDVjLjM0NzM0NjQyLS4xNDQwNTMyLjczMzA0MzM5LS4xNjczMjMzIDEuMDk1NzMwMDMtLjA2NjQ4NjFsNi4yNDU2NjExNS0xLjA0MTYxNTNzLjMxNzc2MTcxLS41MzE4ODg2OS40ODIxMjEyMi0uNDk4NjQ1NjVDMTAuODA2NDgyIDYuNDY1NjYwOTkgMTUuNDgxOTYyIDYuMTA2NjM2MTMgMTguNjkwMjU5NSA4LjczMTcyODRoLS4wMjE5MTQ2eiIgbWFzaz0idXJsKCNiKSIvPjwvZz48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgzMS40MzYgMjAuNjE0KSI+PG1hc2sgaWQ9ImQiIGZpbGw9IiNmZmYiPjx1c2UgeGxpbms6aHJlZj0iI2MiLz48L21hc2s+PHBhdGggZmlsbD0iIzQyODVGNCIgZD0iTTE1LjAyNzM4OTUgNi45NzIxOTg3N2MtLjcxNzcwMzItMi42NzM4NDg3My0yLjE5MTQ2MDEtNS4wNzYyMTI2MS00LjI0MDQ3NTItNi45MTQ1NTI4N0w2LjQwMzk5NDE1IDQuNDkwMDUxNTljMS44NTA2ODgwMSAxLjUyOTE3OTk2IDIuOTA0NzgwMyAzLjgzMjkyMjgyIDIuODU5ODU1MzcgNi4yNDk2OTIwMXYuNzg2NzUyYzIuMTU1MzAwOTggMCAzLjkwMDc5ODg4IDEuNzY2MzEzNyAzLjkwMDc5ODg4IDMuOTQzNzMzIDAgMi4xNzk2MzU1LTEuNzQ1NDk3OSAzLjk0NTk0OTEtMy45MDA3OTg4OCAzLjk0NTk0OTFoLTcuODAxNTk3OGwtLjc3Nzk2ODMyLjc5NzgzMzF2NC43MzE1OTNsLjc3Nzk2ODMyLjc4Njc1MjFoNy44MDE1OTc4YzUuNjAzNTYzMzguMDQzMjE1OSAxMC4xODE1MjMzOC00LjUxNDQwNTIgMTAuMjI1MzUyNTgtMTAuMTgwMTI3OC4wMjYyOTc2LTMuNDM1MTE0NC0xLjY0Nzk3NzktNi42NTYzNjUyNi00LjQ2MTgxMjYtOC41ODAwMjkzMyIgbWFzaz0idXJsKCNkKSIvPjwvZz48cGF0aCBmaWxsPSIjMzRBODUzIiBkPSJNMjUuMDg1ODY2MiA0Ni4zMDI0NzM5aDcuODAxNTk3OHYtNi4zMTYxNzgxaC03LjgwMTU5NzhjLS41NTU1MzUxNCAwLTEuMTA1NTkxNjEtLjEyMTg5MTEtMS42MTA3MjMxNi0uMzU1NzAwNWwtMS4wOTU3MzAwMi4zNDQ2MTk1LTMuMTQ0NzQ1MTggMy4xNTgwODkxLS4yNzM5MzI1MSAxLjEwODEwMTRjMS43NjQxMjUzNCAxLjM0NjM0MzIgMy45MTUwNDMzOSAyLjA3MTA0MTUgNi4xMjUxMzA4NyAyLjA2MTA2ODYiLz48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxNSAyNS4yOTMpIj48bWFzayBpZD0iZiIgZmlsbD0iI2ZmZiI+PHVzZSB4bGluazpocmVmPSIjZSIvPjwvbWFzaz48cGF0aCBmaWxsPSIjRkJCQzA1IiBkPSJNMTAuMDg1ODY2Mi41MjA0MTM4QzQuNDgyMzAyODIuNTU0ODI2MzctLjAzMzIwMDYyIDUuMTc1NjA5My0uMDAwNTA3MDYgMTAuODQyNDRjLjAxODgwNTc1IDMuMTY0NzM3NiAxLjQ4MDUwOTYxIDYuMTQzMzE0MyAzLjk2MTI0MjM5IDguMDcyNTE4OEw4LjQ4NjEwMDM0IDE0LjMzODVjLTEuOTYzNTQ4MjEtLjg5NzU2MjItMi44MzU3NDkzMS0zLjIzMzQ0LTEuOTQ4MjA3OTgtNS4yMTkxNTc3Mi44ODY0NDU1OS0xLjk4NTcxNzc1IDMuMTk3MzQwMjItMi44Njc3NjY0OSA1LjE2MDg4ODQ0LTEuOTcxMzEyNDMuODY0NTMxLjM5NTU5MjIgMS41NTgxMjgxIDEuMDk3MDIwNCAxLjk0ODIwOCAxLjk3MTMxMjQzbDQuNTI1MzY1LTQuNTc2NDU4ODhDMTYuMjQ3MTU2MSAxLjk5NzU3NDQzIDEzLjI1NDcxNzQuNTA5Mzk0MjIgMTAuMDg1ODY2Mi41MjA0MTM4IiBtYXNrPSJ1cmwoI2YpIi8+PC9nPjwvZz48L3N2Zz4= - -spec: - controller: - image: DOCKER_REGISTRY/provider-gcp-controller:VERSION diff --git a/pkg/clients/gcp.go b/pkg/clients/gcp.go index 276ce8959..d14b9613b 100644 --- a/pkg/clients/gcp.go +++ b/pkg/clients/gcp.go @@ -119,8 +119,8 @@ func IsErrorNotFoundGRPC(err error) bool { if err == nil { return false } - grpcErr, ok := err.(interface{ GRPCStatus() *status.Status }) - return ok && grpcErr.GRPCStatus().Code() == codes.NotFound + var gErr interface{ GRPCStatus() *status.Status } + return errors.As(err, &gErr) && gErr.GRPCStatus().Code() == codes.NotFound } // IsErrorNotFound gets a value indicating whether the given error represents a "not found" response from the Google API @@ -128,8 +128,8 @@ func IsErrorNotFound(err error) bool { if err == nil { return false } - googleapiErr, ok := err.(*googleapi.Error) - return ok && googleapiErr.Code == http.StatusNotFound + var gErr *googleapi.Error + return errors.As(err, &gErr) && gErr.Code == http.StatusNotFound } // IsErrorAlreadyExists gets a value indicating whether the given error @@ -138,8 +138,8 @@ func IsErrorAlreadyExists(err error) bool { if err == nil { return false } - googleapiErr, ok := err.(*googleapi.Error) - return ok && googleapiErr.Code == http.StatusConflict + var gErr *googleapi.Error + return errors.As(err, &gErr) && gErr.Code == http.StatusConflict } // IsErrorBadRequest gets a value indicating whether the given error represents @@ -148,8 +148,8 @@ func IsErrorBadRequest(err error) bool { if err == nil { return false } - googleapiErr, ok := err.(*googleapi.Error) - return ok && googleapiErr.Code == http.StatusBadRequest + var gErr *googleapi.Error + return errors.As(err, &gErr) && gErr.Code == http.StatusBadRequest } // IsErrorForbidden gets a value indicating whether the given error represents a @@ -158,8 +158,8 @@ func IsErrorForbidden(err error) bool { if err == nil { return false } - googleapiErr, ok := err.(*googleapi.Error) - return ok && googleapiErr.Code == http.StatusForbidden + var gErr *googleapi.Error + return errors.As(err, &gErr) && gErr.Code == http.StatusForbidden } // StringValue converts the supplied string pointer to a string, returning the diff --git a/pkg/controller/cache/managed_test.go b/pkg/controller/cache/managed_test.go index 74e01d011..9c4bbc8a9 100644 --- a/pkg/controller/cache/managed_test.go +++ b/pkg/controller/cache/managed_test.go @@ -157,13 +157,15 @@ func TestObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&redis.Instance{ + if err := json.NewEncoder(w).Encode(&redis.Instance{ State: cloudmemorystore.StateReady, Host: host, Port: port, Name: qualifiedName, AuthEnabled: authEnabled, - }) + }); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockUpdate: test.NewMockUpdateFn(nil), @@ -196,10 +198,12 @@ func TestObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&redis.Instance{ + if err := json.NewEncoder(w).Encode(&redis.Instance{ State: cloudmemorystore.StateCreating, Name: qualifiedName, - }) + }); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockUpdate: test.NewMockUpdateFn(nil), @@ -226,10 +230,12 @@ func TestObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&redis.Instance{ + if err := json.NewEncoder(w).Encode(&redis.Instance{ State: cloudmemorystore.StateDeleting, Name: qualifiedName, - }) + }); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockUpdate: test.NewMockUpdateFn(nil), @@ -352,9 +358,11 @@ func TestCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&redis.Instance{ + if err := json.NewEncoder(w).Encode(&redis.Instance{ Name: qualifiedName, - }) + }); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -451,9 +459,11 @@ func TestUpdate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&redis.Instance{ + if err := json.NewEncoder(w).Encode(&redis.Instance{ Name: qualifiedName, - }) + }); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -548,9 +558,11 @@ func TestDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&redis.Instance{ + if err := json.NewEncoder(w).Encode(&redis.Instance{ Name: qualifiedName, - }) + }); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), diff --git a/pkg/controller/compute/address_test.go b/pkg/controller/compute/address_test.go index 61a50c365..64f485d7c 100644 --- a/pkg/controller/compute/address_test.go +++ b/pkg/controller/compute/address_test.go @@ -112,7 +112,9 @@ func TestAddressObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&compute.Address{}) + if err := json.NewEncoder(w).Encode(&compute.Address{}); err != nil { + t.Error(err) + } }), args: args{ mg: addressObj(), @@ -129,7 +131,9 @@ func TestAddressObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Address{}) + if err := json.NewEncoder(w).Encode(&compute.Address{}); err != nil { + t.Error(err) + } }), args: args{ mg: addressObj(), @@ -149,7 +153,9 @@ func TestAddressObserve(t *testing.T) { c := &compute.Address{} address.GenerateAddress(testName, addressObj().Spec.ForProvider, c) c.Status = v1beta1.StatusReserving - _ = json.NewEncoder(w).Encode(c) + if err := json.NewEncoder(w).Encode(c); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockGet: test.NewMockGetFn(nil), @@ -178,7 +184,9 @@ func TestAddressObserve(t *testing.T) { c := &compute.Address{} address.GenerateAddress(testName, addressObj().Spec.ForProvider, c) c.Status = v1beta1.StatusReserved - _ = json.NewEncoder(w).Encode(c) + if err := json.NewEncoder(w).Encode(c); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockGet: test.NewMockGetFn(nil), @@ -266,7 +274,9 @@ func TestAddressCreate(t *testing.T) { } w.WriteHeader(http.StatusOK) _ = r.Body.Close() - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: addressObj(), @@ -284,7 +294,9 @@ func TestAddressCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusConflict) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: addressObj(), @@ -301,7 +313,9 @@ func TestAddressCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: addressObj(), @@ -366,7 +380,9 @@ func TestAddressDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: addressObj(), @@ -383,7 +399,9 @@ func TestAddressDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: addressObj(), @@ -400,7 +418,9 @@ func TestAddressDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: addressObj(), diff --git a/pkg/controller/compute/firewall_test.go b/pkg/controller/compute/firewall_test.go index 1caa1d925..9a669e63e 100644 --- a/pkg/controller/compute/firewall_test.go +++ b/pkg/controller/compute/firewall_test.go @@ -113,7 +113,9 @@ func TestFirewallObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&compute.Address{}) + if err := json.NewEncoder(w).Encode(&compute.Address{}); err != nil { + t.Error(err) + } }), args: args{ mg: firewallObj(), @@ -130,7 +132,9 @@ func TestFirewallObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Address{}) + if err := json.NewEncoder(w).Encode(&compute.Address{}); err != nil { + t.Error(err) + } }), args: args{ mg: firewallObj(), @@ -149,7 +153,9 @@ func TestFirewallObserve(t *testing.T) { w.WriteHeader(http.StatusOK) c := &compute.Firewall{} firewall.GenerateFirewall(testFirewallName, firewallObj().Spec.ForProvider, c) - _ = json.NewEncoder(w).Encode(c) + if err := json.NewEncoder(w).Encode(c); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockGet: test.NewMockGetFn(nil), @@ -234,7 +240,9 @@ func TestFirewallCreate(t *testing.T) { } w.WriteHeader(http.StatusOK) _ = r.Body.Close() - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: firewallObj(), @@ -252,7 +260,9 @@ func TestFirewallCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusConflict) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: firewallObj(), @@ -269,7 +279,9 @@ func TestFirewallCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: firewallObj(), @@ -334,7 +346,9 @@ func TestFirewallDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: firewallObj(), @@ -351,7 +365,9 @@ func TestFirewallDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: firewallObj(), @@ -368,7 +384,9 @@ func TestFirewallDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: firewallObj(), @@ -433,13 +451,19 @@ func TestFirewallUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Network{}) + if err := json.NewEncoder(w).Encode(&compute.Network{}); err != nil { + t.Error(err) + } case http.MethodPatch: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -459,13 +483,19 @@ func TestFirewallUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Firewall{}) + if err := json.NewEncoder(w).Encode(&compute.Firewall{}); err != nil { + t.Error(err) + } case http.MethodPatch: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ diff --git a/pkg/controller/compute/globaladdress_test.go b/pkg/controller/compute/globaladdress_test.go index 0452b4a93..60d837d4f 100644 --- a/pkg/controller/compute/globaladdress_test.go +++ b/pkg/controller/compute/globaladdress_test.go @@ -120,7 +120,9 @@ func TestGlobalAddressObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&compute.Address{}) + if err := json.NewEncoder(w).Encode(&compute.Address{}); err != nil { + t.Error(err) + } }), args: args{ mg: globalAddressObj(), @@ -137,7 +139,9 @@ func TestGlobalAddressObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Address{}) + if err := json.NewEncoder(w).Encode(&compute.Address{}); err != nil { + t.Error(err) + } }), args: args{ mg: globalAddressObj(), @@ -158,7 +162,9 @@ func TestGlobalAddressObserve(t *testing.T) { gn := &compute.Address{} globaladdress.GenerateGlobalAddress(testGAName, c.Spec.ForProvider, gn) gn.Description = "a very interesting testDescription" - _ = json.NewEncoder(w).Encode(gn) + if err := json.NewEncoder(w).Encode(gn); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockUpdate: test.NewMockUpdateFn(errBoom), @@ -185,7 +191,9 @@ func TestGlobalAddressObserve(t *testing.T) { c := &compute.Address{} globaladdress.GenerateGlobalAddress(testGAName, globalAddressObj().Spec.ForProvider, c) c.Status = v1beta1.StatusReserving - _ = json.NewEncoder(w).Encode(c) + if err := json.NewEncoder(w).Encode(c); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockGet: test.NewMockGetFn(nil), @@ -214,7 +222,9 @@ func TestGlobalAddressObserve(t *testing.T) { c := &compute.Address{} globaladdress.GenerateGlobalAddress(testGAName, globalAddressObj().Spec.ForProvider, c) c.Status = v1beta1.StatusReserved - _ = json.NewEncoder(w).Encode(c) + if err := json.NewEncoder(w).Encode(c); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockGet: test.NewMockGetFn(nil), @@ -302,7 +312,9 @@ func TestGlobalAddressCreate(t *testing.T) { } w.WriteHeader(http.StatusOK) _ = r.Body.Close() - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: globalAddressObj(), @@ -320,7 +332,9 @@ func TestGlobalAddressCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusConflict) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: globalAddressObj(), @@ -337,7 +351,9 @@ func TestGlobalAddressCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: globalAddressObj(), @@ -402,7 +418,9 @@ func TestGlobalAddressDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: globalAddressObj(), @@ -419,7 +437,9 @@ func TestGlobalAddressDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: globalAddressObj(), @@ -436,7 +456,9 @@ func TestGlobalAddressDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: globalAddressObj(), diff --git a/pkg/controller/compute/network_test.go b/pkg/controller/compute/network_test.go index cea91b3b4..eb068c12e 100644 --- a/pkg/controller/compute/network_test.go +++ b/pkg/controller/compute/network_test.go @@ -123,7 +123,9 @@ func TestNetworkObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&compute.Network{}) + if err := json.NewEncoder(w).Encode(&compute.Network{}); err != nil { + t.Error(err) + } }), args: args{ mg: networkObj(), @@ -140,7 +142,9 @@ func TestNetworkObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Network{}) + if err := json.NewEncoder(w).Encode(&compute.Network{}); err != nil { + t.Error(err) + } }), args: args{ mg: networkObj(), @@ -161,7 +165,9 @@ func TestNetworkObserve(t *testing.T) { gn := &compute.Network{} network.GenerateNetwork(testNetworkName, c.Spec.ForProvider, gn) gn.Description = "a very interesting description" - _ = json.NewEncoder(w).Encode(gn) + if err := json.NewEncoder(w).Encode(gn); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockUpdate: test.NewMockUpdateFn(errBoom), @@ -183,7 +189,9 @@ func TestNetworkObserve(t *testing.T) { w.WriteHeader(http.StatusOK) c := &compute.Network{} network.GenerateNetwork(testNetworkName, networkObj().Spec.ForProvider, c) - _ = json.NewEncoder(w).Encode(c) + if err := json.NewEncoder(w).Encode(c); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockGet: test.NewMockGetFn(nil), @@ -268,7 +276,9 @@ func TestNetworkCreate(t *testing.T) { } w.WriteHeader(http.StatusOK) _ = r.Body.Close() - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: networkObj(), @@ -286,7 +296,9 @@ func TestNetworkCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusConflict) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: networkObj(), @@ -303,7 +315,9 @@ func TestNetworkCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: networkObj(), @@ -368,7 +382,9 @@ func TestNetworkDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: networkObj(), @@ -385,7 +401,9 @@ func TestNetworkDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: networkObj(), @@ -402,7 +420,9 @@ func TestNetworkDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: networkObj(), @@ -469,13 +489,19 @@ func TestNetworkUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Network{}) + if err := json.NewEncoder(w).Encode(&compute.Network{}); err != nil { + t.Error(err) + } case http.MethodPatch: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -495,15 +521,21 @@ func TestNetworkUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Network{ + if err := json.NewEncoder(w).Encode(&compute.Network{ AutoCreateSubnetworks: true, - }) + }); err != nil { + t.Error(err) + } case http.MethodPost: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -527,13 +559,19 @@ func TestNetworkUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Subnetwork{}) + if err := json.NewEncoder(w).Encode(&compute.Subnetwork{}); err != nil { + t.Error(err) + } case http.MethodPatch: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -554,15 +592,21 @@ func TestNetworkUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Network{ + if err := json.NewEncoder(w).Encode(&compute.Network{ AutoCreateSubnetworks: true, - }) + }); err != nil { + t.Error(err) + } case http.MethodPost: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ diff --git a/pkg/controller/compute/router_test.go b/pkg/controller/compute/router_test.go index 58439988d..6ab4e2b5d 100644 --- a/pkg/controller/compute/router_test.go +++ b/pkg/controller/compute/router_test.go @@ -110,7 +110,9 @@ func TestRouterObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&compute.Address{}) + if err := json.NewEncoder(w).Encode(&compute.Address{}); err != nil { + t.Error(err) + } }), args: args{ mg: routerObj(), @@ -127,7 +129,9 @@ func TestRouterObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Address{}) + if err := json.NewEncoder(w).Encode(&compute.Address{}); err != nil { + t.Error(err) + } }), args: args{ mg: routerObj(), @@ -148,7 +152,9 @@ func TestRouterObserve(t *testing.T) { gn := &compute.Router{} router.GenerateRouter(testRouterName, c.Spec.ForProvider, gn) gn.Description = "a very interesting description" - _ = json.NewEncoder(w).Encode(gn) + if err := json.NewEncoder(w).Encode(gn); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockUpdate: test.NewMockUpdateFn(errBoom), @@ -170,7 +176,9 @@ func TestRouterObserve(t *testing.T) { w.WriteHeader(http.StatusOK) c := &compute.Router{} router.GenerateRouter(testRouterName, routerObj().Spec.ForProvider, c) - _ = json.NewEncoder(w).Encode(c) + if err := json.NewEncoder(w).Encode(c); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockGet: test.NewMockGetFn(nil), @@ -255,7 +263,9 @@ func TestRouterCreate(t *testing.T) { } w.WriteHeader(http.StatusOK) _ = r.Body.Close() - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: routerObj(), @@ -273,7 +283,9 @@ func TestRouterCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusConflict) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: routerObj(), @@ -290,7 +302,9 @@ func TestRouterCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: routerObj(), @@ -355,7 +369,9 @@ func TestRouterDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: routerObj(), @@ -372,7 +388,9 @@ func TestRouterDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: routerObj(), @@ -389,7 +407,9 @@ func TestRouterDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: routerObj(), @@ -454,13 +474,19 @@ func TestRouterUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Network{}) + if err := json.NewEncoder(w).Encode(&compute.Firewall{}); err != nil { + t.Error(err) + } case http.MethodPatch: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -480,13 +506,19 @@ func TestRouterUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Firewall{}) + if err := json.NewEncoder(w).Encode(&compute.Firewall{}); err != nil { + t.Error(err) + } case http.MethodPatch: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ diff --git a/pkg/controller/compute/subnetwork_test.go b/pkg/controller/compute/subnetwork_test.go index eadb74eaa..242becf9f 100644 --- a/pkg/controller/compute/subnetwork_test.go +++ b/pkg/controller/compute/subnetwork_test.go @@ -116,7 +116,9 @@ func TestSubnetworkObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&compute.Subnetwork{}) + if err := json.NewEncoder(w).Encode(&compute.Subnetwork{}); err != nil { + t.Error(err) + } }), args: args{ mg: subnetworkObj(), @@ -133,7 +135,9 @@ func TestSubnetworkObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Subnetwork{}) + if err := json.NewEncoder(w).Encode(&compute.Subnetwork{}); err != nil { + t.Error(err) + } }), args: args{ mg: subnetworkObj(), @@ -154,7 +158,9 @@ func TestSubnetworkObserve(t *testing.T) { gn := &compute.Subnetwork{} subnetwork.GenerateSubnetwork(testSubnetworkName, c.Spec.ForProvider, gn) gn.Description = "a very interesting description" - _ = json.NewEncoder(w).Encode(gn) + if err := json.NewEncoder(w).Encode(gn); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockUpdate: test.NewMockUpdateFn(errBoom), @@ -176,7 +182,9 @@ func TestSubnetworkObserve(t *testing.T) { w.WriteHeader(http.StatusOK) c := &compute.Subnetwork{} subnetwork.GenerateSubnetwork(testSubnetworkName, subnetworkObj().Spec.ForProvider, c) - _ = json.NewEncoder(w).Encode(c) + if err := json.NewEncoder(w).Encode(c); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockGet: test.NewMockGetFn(nil), @@ -261,7 +269,9 @@ func TestSubnetworkCreate(t *testing.T) { } w.WriteHeader(http.StatusOK) _ = r.Body.Close() - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: subnetworkObj(), @@ -279,7 +289,9 @@ func TestSubnetworkCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusConflict) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: subnetworkObj(), @@ -296,7 +308,9 @@ func TestSubnetworkCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: subnetworkObj(), @@ -361,7 +375,9 @@ func TestSubnetworkDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: subnetworkObj(), @@ -378,7 +394,9 @@ func TestSubnetworkDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: subnetworkObj(), @@ -395,7 +413,9 @@ func TestSubnetworkDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: subnetworkObj(), @@ -460,10 +480,14 @@ func TestSubnetworkUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Subnetwork{}) + if err := json.NewEncoder(w).Encode(&compute.Subnetwork{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -483,15 +507,21 @@ func TestSubnetworkUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Subnetwork{ + if err := json.NewEncoder(w).Encode(&compute.Subnetwork{ Description: "not the one I want", - }) + }); err != nil { + t.Error(err) + } case http.MethodPatch: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -511,15 +541,21 @@ func TestSubnetworkUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Subnetwork{ + if err := json.NewEncoder(w).Encode(&compute.Subnetwork{ PrivateIpGoogleAccess: false, - }) + }); err != nil { + t.Error(err) + } case http.MethodPost: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -539,13 +575,19 @@ func TestSubnetworkUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Subnetwork{}) + if err := json.NewEncoder(w).Encode(&compute.Subnetwork{}); err != nil { + t.Error(err) + } case http.MethodPatch: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -566,15 +608,21 @@ func TestSubnetworkUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Subnetwork{ + if err := json.NewEncoder(w).Encode(&compute.Subnetwork{ PrivateIpGoogleAccess: false, - }) + }); err != nil { + t.Error(err) + } case http.MethodPost: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ diff --git a/pkg/controller/container/cluster_test.go b/pkg/controller/container/cluster_test.go index 4db61688a..618a49f7d 100644 --- a/pkg/controller/container/cluster_test.go +++ b/pkg/controller/container/cluster_test.go @@ -130,7 +130,9 @@ func TestObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&container.Cluster{}) + if err := json.NewEncoder(w).Encode(&container.Cluster{}); err != nil { + t.Error(err) + } }), args: args{ mg: cluster(), @@ -147,7 +149,9 @@ func TestObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Cluster{}) + if err := json.NewEncoder(w).Encode(&container.Cluster{}); err != nil { + t.Error(err) + } }), args: args{ mg: cluster(), @@ -167,7 +171,9 @@ func TestObserve(t *testing.T) { gc := &container.Cluster{} gke.GenerateCluster(name, cluster().Spec.ForProvider, gc) gc.Locations = []string{"loc-1"} - _ = json.NewEncoder(w).Encode(gc) + if err := json.NewEncoder(w).Encode(gc); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockUpdate: test.NewMockUpdateFn(errBoom), @@ -194,7 +200,9 @@ func TestObserve(t *testing.T) { Username: "admin", Password: "admin", } - _ = json.NewEncoder(w).Encode(c) + if err := json.NewEncoder(w).Encode(c); err != nil { + t.Error(err) + } }), args: args{ mg: cluster(withUsername("admin")), @@ -224,7 +232,9 @@ func TestObserve(t *testing.T) { c := &container.Cluster{} gke.GenerateCluster(name, cluster().Spec.ForProvider, c) c.Status = v1beta2.ClusterStateError - _ = json.NewEncoder(w).Encode(c) + if err := json.NewEncoder(w).Encode(c); err != nil { + t.Error(err) + } }), args: args{ mg: cluster(), @@ -248,7 +258,9 @@ func TestObserve(t *testing.T) { c := &container.Cluster{} gke.GenerateCluster(name, cluster().Spec.ForProvider, c) c.Status = v1beta2.ClusterStateRunning - _ = json.NewEncoder(w).Encode(c) + if err := json.NewEncoder(w).Encode(c); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockGet: test.NewMockGetFn(nil), @@ -277,7 +289,9 @@ func TestObserve(t *testing.T) { c := &container.Cluster{} gke.GenerateCluster(name, cluster().Spec.ForProvider, c) c.Status = v1beta2.ClusterStateError - _ = json.NewEncoder(w).Encode(c) + if err := json.NewEncoder(w).Encode(c); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockGet: test.NewMockGetFn(nil), @@ -367,7 +381,9 @@ func TestCreate(t *testing.T) { } w.WriteHeader(http.StatusOK) _ = r.Body.Close() - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: cluster(), @@ -398,7 +414,9 @@ func TestCreate(t *testing.T) { // http call is never made. w.WriteHeader(http.StatusBadRequest) _ = r.Body.Close() - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: cluster(withProviderStatus(v1beta2.ClusterStateProvisioning)), @@ -419,7 +437,9 @@ func TestCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusConflict) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: cluster(), @@ -436,7 +456,9 @@ func TestCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: cluster(), @@ -498,7 +520,9 @@ func TestDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: cluster(), @@ -517,7 +541,9 @@ func TestDelete(t *testing.T) { // Return bad request for delete to demonstrate that // http call is never made. w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: cluster(withProviderStatus(v1beta2.ClusterStateStopping)), @@ -537,7 +563,9 @@ func TestDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: cluster(), @@ -554,7 +582,9 @@ func TestDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: cluster(), @@ -616,13 +646,19 @@ func TestUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&container.Cluster{}) + if err := json.NewEncoder(w).Encode(&container.Cluster{}); err != nil { + t.Error(err) + } case http.MethodPut: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -644,15 +680,21 @@ func TestUpdate(t *testing.T) { // Return bad request for get to demonstrate that // http call is never made. w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } case http.MethodPut: // Return bad request for put to demonstrate that // http call is never made. w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -680,15 +722,21 @@ func TestUpdate(t *testing.T) { // Return bad request for get to demonstrate that // http call is never made. w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } case http.MethodPut: // Return bad request for put to demonstrate that // http call is never made. w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -714,15 +762,21 @@ func TestUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&container.Cluster{}) + if err := json.NewEncoder(w).Encode(&container.Cluster{}); err != nil { + t.Error(err) + } case http.MethodPut: // Return bad request for update to demonstrate that // underlying update is not making any http call. w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -742,13 +796,19 @@ func TestUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Cluster{}) + if err := json.NewEncoder(w).Encode(&container.Cluster{}); err != nil { + t.Error(err) + } case http.MethodPut: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -770,13 +830,19 @@ func TestUpdate(t *testing.T) { case http.MethodGet: w.WriteHeader(http.StatusOK) // Must return successful get of cluster that does not match spec. - _ = json.NewEncoder(w).Encode(&container.Cluster{}) + if err := json.NewEncoder(w).Encode(&container.Cluster{}); err != nil { + t.Error(err) + } case http.MethodPut: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ diff --git a/pkg/controller/container/nodepool_test.go b/pkg/controller/container/nodepool_test.go index cfe33d10f..5bd171ffd 100644 --- a/pkg/controller/container/nodepool_test.go +++ b/pkg/controller/container/nodepool_test.go @@ -102,7 +102,9 @@ func TestNodePoolObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&container.NodePool{}) + if err := json.NewEncoder(w).Encode(&container.NodePool{}); err != nil { + t.Error(err) + } }), args: args{ mg: nodePool(), @@ -119,7 +121,9 @@ func TestNodePoolObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.NodePool{}) + if err := json.NewEncoder(w).Encode(&container.NodePool{}); err != nil { + t.Error(err) + } }), args: args{ mg: nodePool(), @@ -140,7 +144,9 @@ func TestNodePoolObserve(t *testing.T) { gn := &container.NodePool{} np.GenerateNodePool(name, n.Spec.ForProvider, gn) gn.Locations = []string{"loc-1"} - _ = json.NewEncoder(w).Encode(gn) + if err := json.NewEncoder(w).Encode(gn); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockUpdate: test.NewMockUpdateFn(errBoom), @@ -163,7 +169,9 @@ func TestNodePoolObserve(t *testing.T) { n := &container.NodePool{} np.GenerateNodePool(name, nodePool().Spec.ForProvider, n) n.Status = v1beta1.NodePoolStateProvisioning - _ = json.NewEncoder(w).Encode(n) + if err := json.NewEncoder(w).Encode(n); err != nil { + t.Error(err) + } }), args: args{ mg: nodePool(), @@ -186,7 +194,9 @@ func TestNodePoolObserve(t *testing.T) { c := &container.NodePool{} np.GenerateNodePool(name, nodePool().Spec.ForProvider, c) c.Status = v1beta1.NodePoolStateError - _ = json.NewEncoder(w).Encode(c) + if err := json.NewEncoder(w).Encode(c); err != nil { + t.Error(err) + } }), args: args{ mg: nodePool(), @@ -209,7 +219,9 @@ func TestNodePoolObserve(t *testing.T) { c := &container.NodePool{} np.GenerateNodePool(name, nodePool().Spec.ForProvider, c) c.Status = v1beta1.NodePoolStateRunning - _ = json.NewEncoder(w).Encode(c) + if err := json.NewEncoder(w).Encode(c); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockGet: test.NewMockGetFn(nil), @@ -237,7 +249,9 @@ func TestNodePoolObserve(t *testing.T) { n := &container.NodePool{} np.GenerateNodePool(name, nodePool().Spec.ForProvider, n) n.Status = v1beta1.NodePoolStateError - _ = json.NewEncoder(w).Encode(n) + if err := json.NewEncoder(w).Encode(n); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockGet: test.NewMockGetFn(nil), @@ -324,7 +338,9 @@ func TestNodePoolCreate(t *testing.T) { } w.WriteHeader(http.StatusOK) _ = r.Body.Close() - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: nodePool(), @@ -353,7 +369,9 @@ func TestNodePoolCreate(t *testing.T) { // http call is never made. w.WriteHeader(http.StatusBadRequest) _ = r.Body.Close() - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: nodePool(npWithProviderStatus(v1beta1.NodePoolStateProvisioning)), @@ -374,7 +392,9 @@ func TestNodePoolCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusConflict) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: nodePool(), @@ -391,7 +411,9 @@ func TestNodePoolCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: nodePool(), @@ -453,7 +475,9 @@ func TestNodePoolDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: nodePool(), @@ -472,7 +496,9 @@ func TestNodePoolDelete(t *testing.T) { // Return bad request for delete to demonstrate that // http call is never made. w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: nodePool(npWithProviderStatus(v1beta1.NodePoolStateStopping)), @@ -492,7 +518,9 @@ func TestNodePoolDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: nodePool(), @@ -509,7 +537,9 @@ func TestNodePoolDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: nodePool(), @@ -571,13 +601,19 @@ func TestNodePoolUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&container.NodePool{}) + if err := json.NewEncoder(w).Encode(&container.NodePool{}); err != nil { + t.Error(err) + } case http.MethodPut: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -599,15 +635,21 @@ func TestNodePoolUpdate(t *testing.T) { // Return bad request for get to demonstrate that // http call is never made. w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.NodePool{}) + if err := json.NewEncoder(w).Encode(&container.NodePool{}); err != nil { + t.Error(err) + } case http.MethodPut: // Return bad request for put to demonstrate that // http call is never made. w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -635,15 +677,21 @@ func TestNodePoolUpdate(t *testing.T) { // Return bad request for get to demonstrate that // http call is never made. w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.NodePool{}) + if err := json.NewEncoder(w).Encode(&container.NodePool{}); err != nil { + t.Error(err) + } case http.MethodPut: // Return bad request for put to demonstrate that // http call is never made. w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -669,17 +717,23 @@ func TestNodePoolUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&container.NodePool{ + if err := json.NewEncoder(w).Encode(&container.NodePool{ Name: name, - }) + }); err != nil { + t.Error(err) + } case http.MethodPut: // Return bad request for update to demonstrate that // underlying update is not making any http call. w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -699,13 +753,19 @@ func TestNodePoolUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.NodePool{}) + if err := json.NewEncoder(w).Encode(&container.NodePool{}); err != nil { + t.Error(err) + } case http.MethodPut: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ @@ -727,13 +787,19 @@ func TestNodePoolUpdate(t *testing.T) { case http.MethodGet: w.WriteHeader(http.StatusOK) // Must return successful get of node pool that does not match spec. - _ = json.NewEncoder(w).Encode(&container.NodePool{}) + if err := json.NewEncoder(w).Encode(&container.NodePool{}); err != nil { + t.Error(err) + } case http.MethodPut: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&container.Operation{}) + if err := json.NewEncoder(w).Encode(&container.Operation{}); err != nil { + t.Error(err) + } } }), kube: &test.MockClient{ diff --git a/pkg/controller/database/cloudsql_test.go b/pkg/controller/database/cloudsql_test.go index 01f9d57a0..49a28dab7 100644 --- a/pkg/controller/database/cloudsql_test.go +++ b/pkg/controller/database/cloudsql_test.go @@ -170,7 +170,9 @@ func TestObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&sqladmin.DatabaseInstance{}) + if err := json.NewEncoder(w).Encode(&sqladmin.DatabaseInstance{}); err != nil { + t.Error(err) + } }), args: args{ mg: instance(), @@ -187,7 +189,9 @@ func TestObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&sqladmin.DatabaseInstance{}) + if err := json.NewEncoder(w).Encode(&sqladmin.DatabaseInstance{}); err != nil { + t.Error(err) + } }), args: args{ mg: instance(), @@ -207,7 +211,9 @@ func TestObserve(t *testing.T) { instance := instance(withBackupConfigurationStartTime("22:00")) db := &sqladmin.DatabaseInstance{} cloudsql.GenerateDatabaseInstance(meta.GetExternalName(instance), instance.Spec.ForProvider, db) - _ = json.NewEncoder(w).Encode(db) + if err := json.NewEncoder(w).Encode(db); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockUpdate: test.NewMockUpdateFn(errBoom), @@ -231,7 +237,9 @@ func TestObserve(t *testing.T) { db := &sqladmin.DatabaseInstance{} cloudsql.GenerateDatabaseInstance(meta.GetExternalName(instance()), instance().Spec.ForProvider, db) db.State = v1beta1.StateCreating - _ = json.NewEncoder(w).Encode(db) + if err := json.NewEncoder(w).Encode(db); err != nil { + t.Error(err) + } }), args: args{ mg: instance(), @@ -255,7 +263,9 @@ func TestObserve(t *testing.T) { db := &sqladmin.DatabaseInstance{} cloudsql.GenerateDatabaseInstance(meta.GetExternalName(instance()), instance().Spec.ForProvider, db) db.State = v1beta1.StateMaintenance - _ = json.NewEncoder(w).Encode(db) + if err := json.NewEncoder(w).Encode(db); err != nil { + t.Error(err) + } }), args: args{ mg: instance(), @@ -280,7 +290,9 @@ func TestObserve(t *testing.T) { cloudsql.GenerateDatabaseInstance(meta.GetExternalName(instance()), instance().Spec.ForProvider, db) db.ConnectionName = connectionName db.State = v1beta1.StateRunnable - _ = json.NewEncoder(w).Encode(db) + if err := json.NewEncoder(w).Encode(db); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockGet: test.NewMockGetFn(nil), @@ -371,7 +383,9 @@ func TestCreate(t *testing.T) { } w.WriteHeader(http.StatusOK) _ = r.Body.Close() - _ = json.NewEncoder(w).Encode(&sqladmin.Operation{}) + if err := json.NewEncoder(w).Encode(&sqladmin.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: instance(), @@ -391,7 +405,9 @@ func TestCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusConflict) - _ = json.NewEncoder(w).Encode(&sqladmin.Operation{}) + if err := json.NewEncoder(w).Encode(&sqladmin.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: instance(), @@ -408,7 +424,9 @@ func TestCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&sqladmin.Operation{}) + if err := json.NewEncoder(w).Encode(&sqladmin.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: instance(), @@ -492,7 +510,9 @@ func TestDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&sqladmin.Operation{}) + if err := json.NewEncoder(w).Encode(&sqladmin.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: instance(), @@ -509,7 +529,9 @@ func TestDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&sqladmin.Operation{}) + if err := json.NewEncoder(w).Encode(&sqladmin.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: instance(), @@ -526,7 +548,9 @@ func TestDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&sqladmin.Operation{}) + if err := json.NewEncoder(w).Encode(&sqladmin.Operation{}); err != nil { + t.Error(err) + } }), args: args{ mg: instance(), @@ -589,7 +613,9 @@ func TestUpdate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&sqladmin.Operation{}) + if err := json.NewEncoder(w).Encode(&sqladmin.Operation{}); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockGet: test.NewMockGetFn(nil), @@ -618,7 +644,9 @@ func TestUpdate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&sqladmin.Operation{}) + if err := json.NewEncoder(w).Encode(&sqladmin.Operation{}); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockGet: test.NewMockGetFn(nil), diff --git a/pkg/controller/dns/resource_record_set_test.go b/pkg/controller/dns/resource_record_set_test.go index 3440e8e0a..6f7c9cecb 100644 --- a/pkg/controller/dns/resource_record_set_test.go +++ b/pkg/controller/dns/resource_record_set_test.go @@ -115,7 +115,9 @@ func TestObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}) + if err := json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}); err != nil { + t.Error(err) + } }), }, "InternalError": { @@ -133,7 +135,9 @@ func TestObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}) + if err := json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}); err != nil { + t.Error(err) + } }), }, "UpdateResourceSpecFail": { @@ -154,7 +158,9 @@ func TestObserve(t *testing.T) { cr := newRrs(withSignature("test")) rrs := &dns.ResourceRecordSet{} rrsClient.GenerateResourceRecordSet(meta.GetExternalName(cr), cr.Spec.ForProvider, rrs) - _ = json.NewEncoder(w).Encode(rrs) + if err := json.NewEncoder(w).Encode(rrs); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockUpdate: test.NewMockUpdateFn(errBoom), @@ -182,7 +188,9 @@ func TestObserve(t *testing.T) { cr := newRrs(withSignature("test")) rrs := &dns.ResourceRecordSet{} rrsClient.GenerateResourceRecordSet(meta.GetExternalName(cr), cr.Spec.ForProvider, rrs) - _ = json.NewEncoder(w).Encode(rrs) + if err := json.NewEncoder(w).Encode(rrs); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockUpdate: test.NewMockUpdateFn(nil), @@ -206,7 +214,9 @@ func TestObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&dns.ResourceRecordSet{Kind: "dns#resourceRecordSet"}) + if err := json.NewEncoder(w).Encode(&dns.ResourceRecordSet{Kind: "dns#resourceRecordSet"}); err != nil { + t.Error(err) + } }), }, "ResourceNotUpToDate": { @@ -227,7 +237,9 @@ func TestObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}) + if err := json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}); err != nil { + t.Error(err) + } }), }, } @@ -293,7 +305,9 @@ func TestCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}) + if err := json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}); err != nil { + t.Error(err) + } }), }, "Failed": { @@ -311,7 +325,9 @@ func TestCreate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}) + if err := json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}); err != nil { + t.Error(err) + } }), }, } @@ -376,7 +392,9 @@ func TestUpdate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}) + if err := json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}); err != nil { + t.Error(err) + } }), }, "Failed": { @@ -394,7 +412,9 @@ func TestUpdate(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}) + if err := json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}); err != nil { + t.Error(err) + } }), }, } @@ -456,7 +476,9 @@ func TestDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}) + if err := json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}); err != nil { + t.Error(err) + } }), }, "Failed": { @@ -473,7 +495,9 @@ func TestDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}) + if err := json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}); err != nil { + t.Error(err) + } }), }, "NotFound": { @@ -490,7 +514,9 @@ func TestDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusNotFound) - _ = json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}) + if err := json.NewEncoder(w).Encode(&dns.ResourceRecordSet{}); err != nil { + t.Error(err) + } }), }, } diff --git a/pkg/controller/iam/serviceaccount_test.go b/pkg/controller/iam/serviceaccount_test.go index 61c7a660d..77abe2d19 100644 --- a/pkg/controller/iam/serviceaccount_test.go +++ b/pkg/controller/iam/serviceaccount_test.go @@ -215,7 +215,9 @@ func TestObserve(t *testing.T) { Email: accountEmail, DisplayName: displayName, } - _ = json.NewEncoder(w).Encode(sa) + if err := json.NewEncoder(w).Encode(sa); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -364,7 +366,9 @@ func TestCreate(t *testing.T) { Disabled: false, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(sa) + if err := json.NewEncoder(w).Encode(sa); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -395,7 +399,9 @@ func TestCreate(t *testing.T) { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer r.Body.Close() w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&iamv1.Empty{}) + if err := json.NewEncoder(w).Encode(&iamv1.Empty{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -483,7 +489,9 @@ func TestUpdate(t *testing.T) { DisplayName: displayName, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(sa) + if err := json.NewEncoder(w).Encode(sa); err != nil { + t.Error(err) + } case http.MethodPatch: req := &updateRequest{} b, err := ioutil.ReadAll(r.Body) @@ -500,7 +508,9 @@ func TestUpdate(t *testing.T) { respondWith(w, http.StatusInternalServerError, &iamv1.ServiceAccount{}) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&iamv1.Empty{}) + if err := json.NewEncoder(w).Encode(&iamv1.Empty{}); err != nil { + t.Error(err) + } } }), args: args{ @@ -588,7 +598,9 @@ func TestDelete(t *testing.T) { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer r.Body.Close() w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&iamv1.Empty{}) + if err := json.NewEncoder(w).Encode(&iamv1.Empty{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), diff --git a/pkg/controller/iam/serviceaccountpolicy_test.go b/pkg/controller/iam/serviceaccountpolicy_test.go index 15cae0d3a..6fadfd9c4 100644 --- a/pkg/controller/iam/serviceaccountpolicy_test.go +++ b/pkg/controller/iam/serviceaccountpolicy_test.go @@ -129,7 +129,9 @@ func TestServiceAccountPolicyObserve(t *testing.T) { "FailedToObserve": { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&iamv1.Policy{}) + if err := json.NewEncoder(w).Encode(&iamv1.Policy{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -148,7 +150,9 @@ func TestServiceAccountPolicyObserve(t *testing.T) { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) sap := &iamv1.Policy{} - _ = json.NewEncoder(w).Encode(sap) + if err := json.NewEncoder(w).Encode(sap); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -173,7 +177,9 @@ func TestServiceAccountPolicyObserve(t *testing.T) { }, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(sap) + if err := json.NewEncoder(w).Encode(sap); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -209,7 +215,9 @@ func TestServiceAccountPolicyObserve(t *testing.T) { }, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(sap) + if err := json.NewEncoder(w).Encode(sap); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -321,7 +329,9 @@ func TestServiceAccountPolicyCreate(t *testing.T) { t.Errorf("policy in setIamPolicyRequest not equal to expected, diff: %s", cmp.Diff(exp, i.Policy, cmpopts.IgnoreFields(iamv1.Policy{}, "Version"))) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(exp) + if err := json.NewEncoder(w).Encode(exp); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -339,7 +349,9 @@ func TestServiceAccountPolicyCreate(t *testing.T) { "CreateFailed": { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&iamv1.Policy{}) + if err := json.NewEncoder(w).Encode(&iamv1.Policy{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -458,7 +470,9 @@ func TestServiceAccountPolicyUpdate(t *testing.T) { w.WriteHeader(http.StatusBadRequest) } - _ = json.NewEncoder(w).Encode(sap) + if err := json.NewEncoder(w).Encode(sap); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -485,7 +499,9 @@ func TestServiceAccountPolicyUpdate(t *testing.T) { "FailedToGet": { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&iamv1.Policy{}) + if err := json.NewEncoder(w).Encode(&iamv1.Policy{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -511,7 +527,9 @@ func TestServiceAccountPolicyUpdate(t *testing.T) { }, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(sap) + if err := json.NewEncoder(w).Encode(sap); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -549,7 +567,9 @@ func TestServiceAccountPolicyUpdate(t *testing.T) { w.WriteHeader(http.StatusBadRequest) } - _ = json.NewEncoder(w).Encode(sap) + if err := json.NewEncoder(w).Encode(sap); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -657,7 +677,9 @@ func TestServiceAccountPolicyDelete(t *testing.T) { t.Errorf("policy in setIamPolicyRequest not equal to expected, diff: %s", cmp.Diff(exp, i.Policy, cmpopts.IgnoreFields(iamv1.Policy{}, "Version"))) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(exp) + if err := json.NewEncoder(w).Encode(exp); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -674,7 +696,9 @@ func TestServiceAccountPolicyDelete(t *testing.T) { "CreateFailed": { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&iamv1.Policy{}) + if err := json.NewEncoder(w).Encode(&iamv1.Policy{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), diff --git a/pkg/controller/kms/cryptokey_test.go b/pkg/controller/kms/cryptokey_test.go index eabbab40e..bff28cc71 100644 --- a/pkg/controller/kms/cryptokey_test.go +++ b/pkg/controller/kms/cryptokey_test.go @@ -178,7 +178,9 @@ func TestCryptoKeyObserve(t *testing.T) { Name: keyRingRRN, Purpose: "ENCRYPT_DECRYPT", } - _ = json.NewEncoder(w).Encode(ck) + if err := json.NewEncoder(w).Encode(ck); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -209,7 +211,9 @@ func TestCryptoKeyObserve(t *testing.T) { sa := &kmsv1.CryptoKey{ Name: fqName, } - _ = json.NewEncoder(w).Encode(sa) + if err := json.NewEncoder(w).Encode(sa); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -318,7 +322,9 @@ func TestCryptoKeyCreate(t *testing.T) { Name: keyRingRRN, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(kr) + if err := json.NewEncoder(w).Encode(kr); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -347,7 +353,9 @@ func TestCryptoKeyCreate(t *testing.T) { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer r.Body.Close() w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&iamv1.Empty{}) + if err := json.NewEncoder(w).Encode(&iamv1.Empty{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -422,7 +430,9 @@ func TestCryptoKeyUpdate(t *testing.T) { Purpose: "ENCRYPT_DECRYPT", } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(kr) + if err := json.NewEncoder(w).Encode(kr); err != nil { + t.Error(err) + } case http.MethodPatch: // https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys/patch if !strings.HasSuffix(r.URL.Path, keyRingRRN) { @@ -439,10 +449,14 @@ func TestCryptoKeyUpdate(t *testing.T) { RotationPeriod: rotationPeriod, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(kr) + if err := json.NewEncoder(w).Encode(kr); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&kmsv1.CryptoKey{}) + if err := json.NewEncoder(w).Encode(&kmsv1.CryptoKey{}); err != nil { + t.Error(err) + } } }), args: args{ @@ -469,12 +483,16 @@ func TestCryptoKeyUpdate(t *testing.T) { Purpose: "ENCRYPT_DECRYPT", } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(kr) + if err := json.NewEncoder(w).Encode(kr); err != nil { + t.Error(err) + } case http.MethodPatch: t.Errorf("should not call patch when already up to date") default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&kmsv1.CryptoKey{}) + if err := json.NewEncoder(w).Encode(&kmsv1.CryptoKey{}); err != nil { + t.Error(err) + } } }), args: args{ @@ -495,10 +513,14 @@ func TestCryptoKeyUpdate(t *testing.T) { switch r.Method { case http.MethodGet: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&kmsv1.CryptoKey{}) + if err := json.NewEncoder(w).Encode(&kmsv1.CryptoKey{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&kmsv1.CryptoKey{}) + if err := json.NewEncoder(w).Encode(&kmsv1.CryptoKey{}); err != nil { + t.Error(err) + } } }), args: args{ @@ -524,13 +546,19 @@ func TestCryptoKeyUpdate(t *testing.T) { Purpose: "ENCRYPT_DECRYPT", } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(kr) + if err := json.NewEncoder(w).Encode(kr); err != nil { + t.Error(err) + } case http.MethodPatch: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&kmsv1.CryptoKey{}) + if err := json.NewEncoder(w).Encode(&kmsv1.CryptoKey{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&kmsv1.CryptoKey{}) + if err := json.NewEncoder(w).Encode(&kmsv1.CryptoKey{}); err != nil { + t.Error(err) + } } }), args: args{ diff --git a/pkg/controller/kms/cryptokeypolicy_test.go b/pkg/controller/kms/cryptokeypolicy_test.go index 443617416..a2a9c5617 100644 --- a/pkg/controller/kms/cryptokeypolicy_test.go +++ b/pkg/controller/kms/cryptokeypolicy_test.go @@ -118,7 +118,9 @@ func TestCryptoKeyPolicyObserve(t *testing.T) { "FailedToObserve": { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&kmsv1.Policy{}) + if err := json.NewEncoder(w).Encode(&kmsv1.Policy{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -137,7 +139,9 @@ func TestCryptoKeyPolicyObserve(t *testing.T) { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) ckp := &kmsv1.Policy{} - _ = json.NewEncoder(w).Encode(ckp) + if err := json.NewEncoder(w).Encode(ckp); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -162,7 +166,9 @@ func TestCryptoKeyPolicyObserve(t *testing.T) { }, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(ckp) + if err := json.NewEncoder(w).Encode(ckp); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -198,7 +204,9 @@ func TestCryptoKeyPolicyObserve(t *testing.T) { }, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(ckp) + if err := json.NewEncoder(w).Encode(ckp); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -310,7 +318,9 @@ func TestCryptoKeyPolicyCreate(t *testing.T) { t.Errorf("policy in setIamPolicyRequest not equal to expected, diff: %s", cmp.Diff(exp, i.Policy, cmpopts.IgnoreFields(kmsv1.Policy{}, "Version"))) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(exp) + if err := json.NewEncoder(w).Encode(exp); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -328,7 +338,9 @@ func TestCryptoKeyPolicyCreate(t *testing.T) { "CreateFailed": { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&kmsv1.Policy{}) + if err := json.NewEncoder(w).Encode(&kmsv1.Policy{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -447,7 +459,9 @@ func TestCryptoKeyPolicyUpdate(t *testing.T) { w.WriteHeader(http.StatusBadRequest) } - _ = json.NewEncoder(w).Encode(ckp) + if err := json.NewEncoder(w).Encode(ckp); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -474,7 +488,9 @@ func TestCryptoKeyPolicyUpdate(t *testing.T) { "FailedToGet": { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&kmsv1.Policy{}) + if err := json.NewEncoder(w).Encode(&kmsv1.Policy{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -500,7 +516,9 @@ func TestCryptoKeyPolicyUpdate(t *testing.T) { }, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(ckp) + if err := json.NewEncoder(w).Encode(ckp); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -538,7 +556,9 @@ func TestCryptoKeyPolicyUpdate(t *testing.T) { w.WriteHeader(http.StatusBadRequest) } - _ = json.NewEncoder(w).Encode(ckp) + if err := json.NewEncoder(w).Encode(ckp); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -646,7 +666,9 @@ func TestCryptoKeyPolicyDelete(t *testing.T) { t.Errorf("policy in setIamPolicyRequest not equal to expected, diff: %s", cmp.Diff(exp, i.Policy, cmpopts.IgnoreFields(kmsv1.Policy{}, "Version"))) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(exp) + if err := json.NewEncoder(w).Encode(exp); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -663,7 +685,9 @@ func TestCryptoKeyPolicyDelete(t *testing.T) { "CreateFailed": { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&kmsv1.Policy{}) + if err := json.NewEncoder(w).Encode(&kmsv1.Policy{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), diff --git a/pkg/controller/kms/keyring_test.go b/pkg/controller/kms/keyring_test.go index c5d0d602f..1461c3096 100644 --- a/pkg/controller/kms/keyring_test.go +++ b/pkg/controller/kms/keyring_test.go @@ -185,7 +185,9 @@ func TestObserve(t *testing.T) { sa := &kmsv1.KeyRing{ Name: fqName, } - _ = json.NewEncoder(w).Encode(sa) + if err := json.NewEncoder(w).Encode(sa); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -218,7 +220,9 @@ func TestObserve(t *testing.T) { sa := &kmsv1.KeyRing{ Name: fqName, } - _ = json.NewEncoder(w).Encode(sa) + if err := json.NewEncoder(w).Encode(sa); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -325,7 +329,9 @@ func TestCreate(t *testing.T) { Name: fqName, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(kr) + if err := json.NewEncoder(w).Encode(kr); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -356,7 +362,9 @@ func TestCreate(t *testing.T) { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer r.Body.Close() w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&iamv1.Empty{}) + if err := json.NewEncoder(w).Encode(&iamv1.Empty{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), diff --git a/pkg/controller/pubsub/subscription_test.go b/pkg/controller/pubsub/subscription_test.go index cae81dfae..406aa81c4 100644 --- a/pkg/controller/pubsub/subscription_test.go +++ b/pkg/controller/pubsub/subscription_test.go @@ -104,9 +104,11 @@ func TestSubscriptionObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&pubsub.Subscription{ + if err := json.NewEncoder(w).Encode(&pubsub.Subscription{ Topic: "my-topic", - }) + }); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockUpdate: test.NewMockUpdateFn(errBoom), @@ -126,7 +128,9 @@ func TestSubscriptionObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&pubsub.Subscription{}) + if err := json.NewEncoder(w).Encode(&pubsub.Subscription{}); err != nil { + t.Error(err) + } }), mg: newSubscription(), }, @@ -199,9 +203,11 @@ func TestSubscriptionCreate(t *testing.T) { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { _ = r.Body.Close() w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&pubsub.Subscription{ + if err := json.NewEncoder(w).Encode(&pubsub.Subscription{ Topic: "my-topic", - }) + }); err != nil { + t.Error(err) + } }), mg: newSubscription(), }, @@ -272,9 +278,11 @@ func TestSubscriptionUpdate(t *testing.T) { return } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&pubsub.Subscription{ + if err := json.NewEncoder(w).Encode(&pubsub.Subscription{ Topic: "my-topic", - }) + }); err != nil { + t.Error(err) + } }), mg: newSubscription(), }, @@ -288,9 +296,11 @@ func TestSubscriptionUpdate(t *testing.T) { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { _ = r.Body.Close() w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&pubsub.Subscription{ + if err := json.NewEncoder(w).Encode(&pubsub.Subscription{ Topic: "my-topic", - }) + }); err != nil { + t.Error(err) + } }), mg: newSubscription(), }, @@ -373,9 +383,11 @@ func TestSubscriptionDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&pubsub.Subscription{ + if err := json.NewEncoder(w).Encode(&pubsub.Subscription{ Name: "cool-name", - }) + }); err != nil { + t.Error(err) + } }), mg: newSubscription(), }, diff --git a/pkg/controller/pubsub/topic_test.go b/pkg/controller/pubsub/topic_test.go index 6ad94a04a..9d8ceadc7 100644 --- a/pkg/controller/pubsub/topic_test.go +++ b/pkg/controller/pubsub/topic_test.go @@ -120,9 +120,11 @@ func TestObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&pubsub.Topic{ + if err := json.NewEncoder(w).Encode(&pubsub.Topic{ KmsKeyName: "cool-key", - }) + }); err != nil { + t.Error(err) + } }), kube: &test.MockClient{ MockUpdate: test.NewMockUpdateFn(errBoom), @@ -142,7 +144,9 @@ func TestObserve(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&pubsub.Topic{}) + if err := json.NewEncoder(w).Encode(&pubsub.Topic{}); err != nil { + t.Error(err) + } }), mg: newTopic(), }, @@ -219,9 +223,11 @@ func TestCreate(t *testing.T) { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { _ = r.Body.Close() w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&pubsub.Topic{ + if err := json.NewEncoder(w).Encode(&pubsub.Topic{ KmsKeyName: "cool-key", - }) + }); err != nil { + t.Error(err) + } }), mg: newTopic(), }, @@ -292,9 +298,11 @@ func TestUpdate(t *testing.T) { return } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&pubsub.Topic{ + if err := json.NewEncoder(w).Encode(&pubsub.Topic{ KmsKeyName: "cool-key", - }) + }); err != nil { + t.Error(err) + } }), mg: newTopic(), }, @@ -308,9 +316,11 @@ func TestUpdate(t *testing.T) { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { _ = r.Body.Close() w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&pubsub.Topic{ + if err := json.NewEncoder(w).Encode(&pubsub.Topic{ KmsKeyName: "cool-key", - }) + }); err != nil { + t.Error(err) + } }), mg: newTopic(), }, @@ -393,9 +403,11 @@ func TestDelete(t *testing.T) { t.Errorf("r: -want, +got:\n%s", diff) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&pubsub.Topic{ + if err := json.NewEncoder(w).Encode(&pubsub.Topic{ Name: "cool-name", - }) + }); err != nil { + t.Error(err) + } }), mg: newTopic(), }, diff --git a/pkg/controller/servicenetworking/connection_test.go b/pkg/controller/servicenetworking/connection_test.go index 8255e8c30..4ac4c6726 100644 --- a/pkg/controller/servicenetworking/connection_test.go +++ b/pkg/controller/servicenetworking/connection_test.go @@ -384,11 +384,14 @@ func (s FakeComputeService) Serve(t *testing.T) *compute.Service { return } - if gae, ok := s.ReturnError.(*googleapi.Error); ok { - w.WriteHeader(gae.Code) - _ = json.NewEncoder(w).Encode(struct { + var gErr *googleapi.Error + if errors.As(s.ReturnError, &gErr) { + w.WriteHeader(gErr.Code) + if err := json.NewEncoder(w).Encode(struct { Error *googleapi.Error `json:"error"` - }{Error: gae}) + }{Error: gErr}); err != nil { + t.Error(err) + } return } @@ -398,7 +401,9 @@ func (s FakeComputeService) Serve(t *testing.T) *compute.Service { } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(&compute.Operation{}) + if err := json.NewEncoder(w).Encode(&compute.Operation{}); err != nil { + t.Error(err) + } })) c, err := compute.NewService(context.Background(), @@ -430,11 +435,14 @@ func (s FakeServiceNetworkingService) Serve(t *testing.T) *servicenetworking.API return } - if gae, ok := s.ReturnError.(*googleapi.Error); ok { - w.WriteHeader(gae.Code) - _ = json.NewEncoder(w).Encode(struct { + var gErr *googleapi.Error + if errors.As(s.ReturnError, &gErr) { + w.WriteHeader(gErr.Code) + if err := json.NewEncoder(w).Encode(struct { Error *googleapi.Error `json:"error"` - }{Error: gae}) + }{Error: gErr}); err != nil { + t.Error(err) + } return } @@ -444,7 +452,9 @@ func (s FakeServiceNetworkingService) Serve(t *testing.T) *servicenetworking.API } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(s.Return) + if err := json.NewEncoder(w).Encode(s.Return); err != nil { + t.Error(err) + } })) c, err := servicenetworking.NewService(context.Background(), diff --git a/pkg/controller/storage/bucket.go b/pkg/controller/storage/bucket.go index 9dd62f372..1d227184e 100644 --- a/pkg/controller/storage/bucket.go +++ b/pkg/controller/storage/bucket.go @@ -134,7 +134,7 @@ func (e *external) Observe(ctx context.Context, mg resource.Managed) (managed.Ex // NOTE(negz): The storage client appears to intercept the typical GCP API // error that we check for with gcp.IsErrorNotFound and return this error // instead, but only when getting bucket attributes. - if err == storage.ErrBucketNotExist { + if errors.Is(err, storage.ErrBucketNotExist) { return managed.ExternalObservation{ResourceExists: false}, nil } if err != nil { diff --git a/pkg/controller/storage/bucketpolicy_test.go b/pkg/controller/storage/bucketpolicy_test.go index b9783042f..2d6b4d6e5 100644 --- a/pkg/controller/storage/bucketpolicy_test.go +++ b/pkg/controller/storage/bucketpolicy_test.go @@ -131,7 +131,9 @@ func TestBucketPolicyObserve(t *testing.T) { "FailedToObserve": { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&storagev1.Policy{}) + if err := json.NewEncoder(w).Encode(&storagev1.Policy{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -150,7 +152,9 @@ func TestBucketPolicyObserve(t *testing.T) { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) bp := &storagev1.Policy{} - _ = json.NewEncoder(w).Encode(bp) + if err := json.NewEncoder(w).Encode(bp); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -175,7 +179,9 @@ func TestBucketPolicyObserve(t *testing.T) { }, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(bp) + if err := json.NewEncoder(w).Encode(bp); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -211,7 +217,9 @@ func TestBucketPolicyObserve(t *testing.T) { }, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(bp) + if err := json.NewEncoder(w).Encode(bp); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -323,7 +331,9 @@ func TestBucketPolicyCreate(t *testing.T) { t.Errorf("policy in setIamPolicyRequest not equal to expected, diff: %s", cmp.Diff(exp, i, cmpopts.IgnoreFields(storagev1.Policy{}, "Version"))) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(exp) + if err := json.NewEncoder(w).Encode(exp); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -341,7 +351,9 @@ func TestBucketPolicyCreate(t *testing.T) { "CreateFailed": { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&storagev1.Policy{}) + if err := json.NewEncoder(w).Encode(&storagev1.Policy{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -461,7 +473,9 @@ func TestBucketPolicyUpdate(t *testing.T) { w.WriteHeader(http.StatusBadRequest) } - _ = json.NewEncoder(w).Encode(bp) + if err := json.NewEncoder(w).Encode(bp); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -488,7 +502,9 @@ func TestBucketPolicyUpdate(t *testing.T) { "FailedToGet": { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&storagev1.Policy{}) + if err := json.NewEncoder(w).Encode(&storagev1.Policy{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -514,7 +530,9 @@ func TestBucketPolicyUpdate(t *testing.T) { }, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(bp) + if err := json.NewEncoder(w).Encode(bp); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -552,7 +570,9 @@ func TestBucketPolicyUpdate(t *testing.T) { w.WriteHeader(http.StatusBadRequest) } - _ = json.NewEncoder(w).Encode(bp) + if err := json.NewEncoder(w).Encode(bp); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -660,7 +680,9 @@ func TestBucketPolicyDelete(t *testing.T) { t.Errorf("policy in setIamPolicyRequest not equal to expected, diff: %s", cmp.Diff(exp, i, cmpopts.IgnoreFields(storagev1.Policy{}, "Version"))) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(exp) + if err := json.NewEncoder(w).Encode(exp); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -677,7 +699,9 @@ func TestBucketPolicyDelete(t *testing.T) { "CreateFailed": { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&storagev1.Policy{}) + if err := json.NewEncoder(w).Encode(&storagev1.Policy{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), diff --git a/pkg/controller/storage/bucketpolicymember_test.go b/pkg/controller/storage/bucketpolicymember_test.go index ae2d39fe7..36f5435c1 100644 --- a/pkg/controller/storage/bucketpolicymember_test.go +++ b/pkg/controller/storage/bucketpolicymember_test.go @@ -98,7 +98,9 @@ func TestBucketPolicyMemberObserve(t *testing.T) { "FailedToObserve": { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&storagev1.Policy{}) + if err := json.NewEncoder(w).Encode(&storagev1.Policy{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -134,7 +136,9 @@ func TestBucketPolicyMemberObserve(t *testing.T) { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) bpm := &storagev1.Policy{} - _ = json.NewEncoder(w).Encode(bpm) + if err := json.NewEncoder(w).Encode(bpm); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -159,7 +163,9 @@ func TestBucketPolicyMemberObserve(t *testing.T) { }, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(bpm) + if err := json.NewEncoder(w).Encode(bpm); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -193,7 +199,9 @@ func TestBucketPolicyMemberObserve(t *testing.T) { }, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(bpm) + if err := json.NewEncoder(w).Encode(bpm); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -317,7 +325,9 @@ func TestBucketPolicyMemberUpdate(t *testing.T) { w.WriteHeader(http.StatusBadRequest) } - _ = json.NewEncoder(w).Encode(bpm) + if err := json.NewEncoder(w).Encode(bpm); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -336,7 +346,9 @@ func TestBucketPolicyMemberUpdate(t *testing.T) { "FailedToGet": { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&storagev1.Policy{}) + if err := json.NewEncoder(w).Encode(&storagev1.Policy{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -362,7 +374,9 @@ func TestBucketPolicyMemberUpdate(t *testing.T) { }, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(bpm) + if err := json.NewEncoder(w).Encode(bpm); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -400,7 +414,9 @@ func TestBucketPolicyMemberUpdate(t *testing.T) { w.WriteHeader(http.StatusBadRequest) } - _ = json.NewEncoder(w).Encode(bpm) + if err := json.NewEncoder(w).Encode(bpm); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -488,7 +504,9 @@ func TestBucketPolicyMemberDelete(t *testing.T) { }, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(i) + if err := json.NewEncoder(w).Encode(i); err != nil { + t.Error(err) + } case http.MethodPut: i := &storagev1.Policy{} b, err := ioutil.ReadAll(r.Body) @@ -511,10 +529,14 @@ func TestBucketPolicyMemberDelete(t *testing.T) { t.Errorf("policy in setIamPolicyRequest not equal to expected, diff: %s", cmp.Diff(exp, i, cmpopts.IgnoreFields(storagev1.Policy{}, "Version"))) } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(exp) + if err := json.NewEncoder(w).Encode(exp); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&storagev1.Policy{}) + if err := json.NewEncoder(w).Encode(&storagev1.Policy{}); err != nil { + t.Error(err) + } } }), @@ -533,7 +555,9 @@ func TestBucketPolicyMemberDelete(t *testing.T) { "DeleteFailedWhileGetting": { handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&storagev1.Policy{}) + if err := json.NewEncoder(w).Encode(&storagev1.Policy{}); err != nil { + t.Error(err) + } }), args: args{ ctx: context.Background(), @@ -561,13 +585,19 @@ func TestBucketPolicyMemberDelete(t *testing.T) { }, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(p) + if err := json.NewEncoder(w).Encode(p); err != nil { + t.Error(err) + } case http.MethodPut: w.WriteHeader(http.StatusInternalServerError) - _ = json.NewEncoder(w).Encode(&storagev1.Policy{}) + if err := json.NewEncoder(w).Encode(&storagev1.Policy{}); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&storagev1.Policy{}) + if err := json.NewEncoder(w).Encode(&storagev1.Policy{}); err != nil { + t.Error(err) + } } }), @@ -597,10 +627,14 @@ func TestBucketPolicyMemberDelete(t *testing.T) { }, } w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(p) + if err := json.NewEncoder(w).Encode(p); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&storagev1.Policy{}) + if err := json.NewEncoder(w).Encode(&storagev1.Policy{}); err != nil { + t.Error(err) + } } }), @@ -622,10 +656,14 @@ func TestBucketPolicyMemberDelete(t *testing.T) { case http.MethodGet: p := &storagev1.Policy{} w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(p) + if err := json.NewEncoder(w).Encode(p); err != nil { + t.Error(err) + } default: w.WriteHeader(http.StatusBadRequest) - _ = json.NewEncoder(w).Encode(&storagev1.Policy{}) + if err := json.NewEncoder(w).Encode(&storagev1.Policy{}); err != nil { + t.Error(err) + } } }), diff --git a/pkg/util/googleapi/googleapi.go b/pkg/util/googleapi/googleapi.go deleted file mode 100644 index 7336e6415..000000000 --- a/pkg/util/googleapi/googleapi.go +++ /dev/null @@ -1,33 +0,0 @@ -/* -Copyright 2019 The Crossplane 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 googleapi - -import ( - "net/http" - - "google.golang.org/api/googleapi" -) - -// IsErrorNotFound returns true if error of type *googleapi.Error and -// error Code = 404 -func IsErrorNotFound(err error) bool { - apiErr, ok := err.(*googleapi.Error) - if !ok { - return false - } - return apiErr.Code == http.StatusNotFound -} diff --git a/pkg/util/googleapi/googleapi_test.go b/pkg/util/googleapi/googleapi_test.go deleted file mode 100644 index f660854b7..000000000 --- a/pkg/util/googleapi/googleapi_test.go +++ /dev/null @@ -1,45 +0,0 @@ -/* -Copyright 2019 The Crossplane 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 googleapi - -import ( - "net/http" - "testing" - - "google.golang.org/api/googleapi" - - "github.com/crossplane/crossplane-runtime/pkg/errors" -) - -func TestIsErrorNotFound(t *testing.T) { - tests := []struct { - name string - args error - want bool - }{ - {name: "Nil", args: nil, want: false}, - {name: "Other", args: errors.New("foo"), want: false}, - {name: "404", args: &googleapi.Error{Code: http.StatusNotFound}, want: true}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsErrorNotFound(tt.args); got != tt.want { - t.Errorf("IsErrorBucketNotFound() = %v, want %v", got, tt.want) - } - }) - } -}