From 9a2c9647eeda20482873afccfe7f86a76f803a71 Mon Sep 17 00:00:00 2001 From: Todd Treece <360020+toddtreece@users.noreply.github.com> Date: Mon, 5 Aug 2024 10:30:14 -0400 Subject: [PATCH] Chore: Add storage submodule to lint & test config (#91529) --- .github/workflows/go_lint.yml | 2 +- Makefile | 2 +- pkg/storage/unified/resource/cdk_backend.go | 5 +++-- pkg/storage/unified/resource/grpc/authenticator.go | 2 +- pkg/storage/unified/resource/server.go | 6 ++++-- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/go_lint.yml b/.github/workflows/go_lint.yml index 50493a86db8..fb2f2d7225a 100644 --- a/.github/workflows/go_lint.yml +++ b/.github/workflows/go_lint.yml @@ -27,6 +27,6 @@ jobs: with: version: v1.59.1 args: | - --config .golangci.toml --max-same-issues=0 --max-issues-per-linter=0 --verbose ./pkg/... ./pkg/apiserver/... ./pkg/apimachinery/... ./pkg/promlib/... ./pkg/semconv/... + --config .golangci.toml --max-same-issues=0 --max-issues-per-linter=0 --verbose ./pkg/... ./pkg/apiserver/... ./pkg/apimachinery/... ./pkg/promlib/... ./pkg/semconv/... ./pkg/storage/unified/resource/... skip-cache: true install-mode: binary diff --git a/Makefile b/Makefile index 662c41e164c..f38407bccea 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ include .bingo/Variables.mk GO = go GO_VERSION = 1.22.4 -GO_FILES ?= ./pkg/... ./pkg/apiserver/... ./pkg/apimachinery/... ./pkg/promlib/... ./pkg/semconv/... +GO_FILES ?= ./pkg/... ./pkg/apiserver/... ./pkg/apimachinery/... ./pkg/promlib/... ./pkg/semconv/... ./pkg/storage/unified/resource/... SH_FILES ?= $(shell find ./scripts -name *.sh) GO_RACE := $(shell [ -n "$(GO_RACE)" -o -e ".go-race-enabled-locally" ] && echo 1 ) GO_RACE_FLAG := $(if $(GO_RACE),-race) diff --git a/pkg/storage/unified/resource/cdk_backend.go b/pkg/storage/unified/resource/cdk_backend.go index 11f28870e2c..f82a3d5dddb 100644 --- a/pkg/storage/unified/resource/cdk_backend.go +++ b/pkg/storage/unified/resource/cdk_backend.go @@ -3,6 +3,7 @@ package resource import ( "bytes" context "context" + "errors" "fmt" "io" "net/http" @@ -141,7 +142,7 @@ func (s *cdkBackend) ReadResource(ctx context.Context, req *ReadRequest) *ReadRe iter := s.bucket.List(&blob.ListOptions{Prefix: path + "/", Delimiter: "/"}) for { obj, err := iter.Next(ctx) - if err == io.EOF { + if errors.Is(err, io.EOF) { break } if strings.HasSuffix(obj.Key, ".json") { @@ -325,7 +326,7 @@ func buildTree(ctx context.Context, s *cdkBackend, key *ResourceKey) (*cdkListIt iter := s.bucket.List(&blob.ListOptions{Prefix: path, Delimiter: ""}) // "" is recursive for { obj, err := iter.Next(ctx) - if err == io.EOF { + if errors.Is(err, io.EOF) { break } if strings.HasSuffix(obj.Key, ".json") { diff --git a/pkg/storage/unified/resource/grpc/authenticator.go b/pkg/storage/unified/resource/grpc/authenticator.go index 1720f73dca2..ad0efe0a46f 100644 --- a/pkg/storage/unified/resource/grpc/authenticator.go +++ b/pkg/storage/unified/resource/grpc/authenticator.go @@ -72,7 +72,7 @@ func (f *Authenticator) decodeMetadata(ctx context.Context, meta metadata.MD) (i return nil, fmt.Errorf("no login found in grpc metadata") } - // The namespaced verisons have a "-" in the key + // The namespaced versions have a "-" in the key // TODO, remove after this has been deployed to unified storage if getter(mdUserID) == "" { var err error diff --git a/pkg/storage/unified/resource/server.go b/pkg/storage/unified/resource/server.go index a1190e061fb..ac2c02cb947 100644 --- a/pkg/storage/unified/resource/server.go +++ b/pkg/storage/unified/resource/server.go @@ -585,7 +585,7 @@ func (s *server) Watch(req *WatchRequest, srv ResourceStore_WatchServer) error { // } // TODO: return values that match either the old or the new - srv.Send(&WatchEvent{ + if err := srv.Send(&WatchEvent{ Timestamp: event.Timestamp, Type: event.Type, Resource: &WatchEvent_Resource{ @@ -593,7 +593,9 @@ func (s *server) Watch(req *WatchRequest, srv ResourceStore_WatchServer) error { Version: event.ResourceVersion, }, // TODO... previous??? - }) + }); err != nil { + return err + } } } }