From d6fa1beb73847b23802603fe230d744a26eed555 Mon Sep 17 00:00:00 2001 From: Thomas Kappler Date: Fri, 31 May 2024 15:19:18 +0200 Subject: [PATCH] Fix gosimple warnings in the code base --- infer/resource.go | 8 ++------ infer/types_test.go | 4 ---- middleware/schema/schema.go | 5 ----- provider.go | 5 ++--- 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/infer/resource.go b/infer/resource.go index f3f26126..f9c99e79 100644 --- a/infer/resource.go +++ b/infer/resource.go @@ -705,9 +705,7 @@ func (i *inputField) Computed() InputField { input.kind = inputComputed // Copy input fields input.fields = make([]introspect.FieldTag, len(i.fields)) - for i, f := range i.fields { - input.fields[i] = f - } + copy(input.fields, i.fields) return input } @@ -716,9 +714,7 @@ func (i *inputField) Secret() InputField { input.kind = inputSecret // Copy input fields input.fields = make([]introspect.FieldTag, len(i.fields)) - for i, f := range i.fields { - input.fields[i] = f - } + copy(input.fields, i.fields) return input } diff --git a/infer/types_test.go b/infer/types_test.go index 3c86998b..00ab58df 100644 --- a/infer/types_test.go +++ b/infer/types_test.go @@ -259,10 +259,6 @@ func TestInvalidOptionalProperty(t *testing.T) { type invalidContainsOptionalEnum struct { Foo MyEnum `pulumi:"name,optional"` } - type validContainsEnum struct { - Foo MyEnum `pulumi:"name"` - } - type testInner struct { Foo string `pulumi:"foo"` } diff --git a/middleware/schema/schema.go b/middleware/schema/schema.go index 57f6c2c2..33258013 100644 --- a/middleware/schema/schema.go +++ b/middleware/schema/schema.go @@ -92,11 +92,6 @@ type state struct { innerGetSchema func(ctx context.Context, req p.GetSchemaRequest) (p.GetSchemaResponse, error) } -func (s *state) invalidateCache() { - s.schema = nil - s.combinedSchema = nil -} - type Options struct { Metadata // Resources from which to derive the schema diff --git a/provider.go b/provider.go index 9673b4af..9b17ffb8 100644 --- a/provider.go +++ b/provider.go @@ -482,9 +482,8 @@ func GetSchema(ctx context.Context, name, version string, provider Provider) (sc if err != nil { errs.Errors = append(errs.Errors, err) } - for _, err := range collectingDiag.errs.Errors { - errs.Errors = append(errs.Errors, err) - } + errs.Errors = append(errs.Errors, collectingDiag.errs.Errors...) + spec := schema.PackageSpec{} if err := errs.ErrorOrNil(); err != nil { return spec, err