From b3cf388215f964b331837c2f5acd60e915f530bc Mon Sep 17 00:00:00 2001 From: Ian Wahbe Date: Tue, 27 Aug 2024 09:12:03 -0700 Subject: [PATCH] Upgrade `golangci-lint` version to v1.60.x (#267) This commit includes changes needed to make the stricter linter pass. --- .github/workflows/stage-lint.yml | 2 +- middleware/rpc/provider.go | 11 +++++++++++ provider.go | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/stage-lint.yml b/.github/workflows/stage-lint.yml index 278bbae..8564f5b 100644 --- a/.github/workflows/stage-lint.yml +++ b/.github/workflows/stage-lint.yml @@ -10,7 +10,7 @@ env: jobs: lint: - container: golangci/golangci-lint:v1.59 + container: golangci/golangci-lint:v1.60 runs-on: ubuntu-latest steps: - name: Checkout Repo diff --git a/middleware/rpc/provider.go b/middleware/rpc/provider.go index d1a5ca6..d11db04 100644 --- a/middleware/rpc/provider.go +++ b/middleware/rpc/provider.go @@ -20,6 +20,8 @@ package rpc import ( "context" "errors" + "fmt" + "math" structpb "github.com/golang/protobuf/ptypes/struct" "github.com/pulumi/pulumi-go-provider/internal/key" @@ -42,7 +44,16 @@ func Provider(server rpc.ResourceProviderServer) p.Provider { var runtime runtime // the runtime configuration of the server return p.Provider{ GetSchema: func(ctx context.Context, req p.GetSchemaRequest) (p.GetSchemaResponse, error) { + if req.Version > math.MaxInt32 { + return p.GetSchemaResponse{}, fmt.Errorf("schema version overflow: %d", req.Version) + } + if req.Version < math.MinInt32 { + return p.GetSchemaResponse{}, fmt.Errorf("schema version underflow: %d", req.Version) + } s, err := server.GetSchema(ctx, &rpc.GetSchemaRequest{ + //cast validated above + // + //nolint:gosec Version: int32(req.Version), }) return p.GetSchemaResponse{ diff --git a/provider.go b/provider.go index abbca83..c986c89 100644 --- a/provider.go +++ b/provider.go @@ -453,7 +453,7 @@ type errCollectingContext struct { func (e *errCollectingContext) Log(severity diag.Severity, msg string) { if severity == diag.Error { - e.errs.Errors = append(e.errs.Errors, fmt.Errorf(msg)) + e.errs.Errors = append(e.errs.Errors, errors.New(msg)) } _, err := fmt.Fprintf(e.stderr, "Log(%s): %s\n", severity, msg) contract.IgnoreError(err) @@ -465,7 +465,7 @@ func (e *errCollectingContext) Logf(severity diag.Severity, msg string, args ... func (e *errCollectingContext) LogStatus(severity diag.Severity, msg string) { if severity == diag.Error { - e.errs.Errors = append(e.errs.Errors, fmt.Errorf(msg)) + e.errs.Errors = append(e.errs.Errors, errors.New(msg)) } _, err := fmt.Fprintf(e.stderr, "LogStatus(%s): %s\n", severity, msg) contract.IgnoreError(err)