diff --git a/.golangci.yml b/.golangci.yml index cbb1b404c..02332f385 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -28,6 +28,20 @@ linters: - wastedassign - whitespace issues: + exclude-rules: + # Exclude some linters from running on tests files. + - path: pkg/pf/tests + linters: + - lll + - paralleltest + - path: pkg/tests + linters: + - lll + - paralleltest + - path: pkg/pf/tests + linters: + - lll + - paralleltest exclude: - "unused-parameter: parameter" - "redefines-builtin-id:" @@ -38,13 +52,6 @@ issues: - pkg/tf2pulumi/internal/configs - pkg/vendored # TODO(https://github.com/pulumi/pulumi-terraform-bridge/issues/2474) - - pkg/pf/tests - - pkg/tests - - pkg/x/testing - - pkg/x/muxer/tests - - pf - - x/muxer - - testing linters-settings: gci: sections: diff --git a/pkg/pf/internal/check/check_test.go b/pkg/pf/internal/check/check_test.go index 65fa6a8bb..b7a4b78cd 100644 --- a/pkg/pf/internal/check/check_test.go +++ b/pkg/pf/internal/check/check_test.go @@ -60,7 +60,7 @@ func (m *mockSchema) Computed() bool { } func TestIsInputProperty(t *testing.T) { - t.Parallel() + t.Parallel() tests := []struct { name string schema shim.Schema @@ -96,7 +96,7 @@ func TestIsInputProperty(t *testing.T) { } func TestMissingIDProperty(t *testing.T) { - t.Parallel() + t.Parallel() stderr, err := test(t, tfbridge.ProviderInfo{ P: pfbridge.ShimProvider(testProvider{missingID: true}), }) @@ -108,7 +108,7 @@ func TestMissingIDProperty(t *testing.T) { } func TestMissingIDWithOverride(t *testing.T) { - t.Parallel() + t.Parallel() stderr, err := test(t, tfbridge.ProviderInfo{ P: pfbridge.ShimProvider(testProvider{missingID: true}), Resources: map[string]*tfbridge.ResourceInfo{ @@ -123,7 +123,7 @@ func TestMissingIDWithOverride(t *testing.T) { } func TestMissingIDUnmapped(t *testing.T) { - t.Parallel() + t.Parallel() stderr, err := test(t, tfbridge.ProviderInfo{ P: pfbridge.ShimProvider(testProvider{missingID: true}), IgnoreMappings: []string{"test_res"}, @@ -134,7 +134,7 @@ func TestMissingIDUnmapped(t *testing.T) { } func TestSensitiveID(t *testing.T) { - t.Parallel() + t.Parallel() stderr, err := test(t, tfbridge.ProviderInfo{ P: pfbridge.ShimProvider(testProvider{sensitiveID: true}), }) @@ -145,7 +145,7 @@ func TestSensitiveID(t *testing.T) { } func TestSensitiveIDWithOverride(t *testing.T) { - t.Parallel() + t.Parallel() t.Run("false", func(t *testing.T) { stderr, err := test(t, tfbridge.ProviderInfo{ P: pfbridge.ShimProvider(testProvider{sensitiveID: true}), @@ -173,7 +173,7 @@ func TestSensitiveIDWithOverride(t *testing.T) { } func TestInvalidInputID(t *testing.T) { - t.Parallel() + t.Parallel() tests := []struct { name string idSchema idSchema @@ -267,7 +267,7 @@ func TestInvalidInputID(t *testing.T) { } func TestMuxedProvider(t *testing.T) { - t.Parallel() + t.Parallel() stderr, err := test(t, tfbridge.ProviderInfo{ P: pfbridge.MuxShimWithPF(context.Background(), sdkv2.NewProvider(testSDKv2Provider()), diff --git a/pkg/pf/internal/check/checks.go b/pkg/pf/internal/check/checks.go index 9a54a6f6a..f0161fac1 100644 --- a/pkg/pf/internal/check/checks.go +++ b/pkg/pf/internal/check/checks.go @@ -126,6 +126,7 @@ func (err errWrongIDType) Error() string { type errMissingIDAttribute struct{} func (errMissingIDAttribute) Error() string { + //nolint:lll return `no "id" attribute. To map this resource consider specifying ResourceInfo.ComputeID to a valid field on the upstream resource` } diff --git a/pkg/pf/internal/check/not_supported.go b/pkg/pf/internal/check/not_supported.go index 50b9d30bb..a5298c623 100644 --- a/pkg/pf/internal/check/not_supported.go +++ b/pkg/pf/internal/check/not_supported.go @@ -45,7 +45,7 @@ func notSupported(sink diag.Sink, prov tfbridge.ProviderInfo, isPFResource, isPF " pf/tfbridge.ShimProvider or pf/tfbridge.ShimProviderWithContext.\nMuxed SDK and" + " Plugin Framework based providers must have ProviderInfo.P be created from" + " pf/tfbridge.MuxShimWithPF or pf/tfbridgepf/tfbridge.MuxShimWithDisjointgPF." - u.warn(warning) + u.warnf(warning) } if prov.Resources != nil { @@ -83,7 +83,7 @@ type notSupportedUtil struct { sink diag.Sink } -func (u *notSupportedUtil) warn(format string, arg ...interface{}) { +func (u *notSupportedUtil) warnf(format string, arg ...interface{}) { u.sink.Warningf(&diag.Diag{Message: format}, arg...) } @@ -92,7 +92,7 @@ func (u *notSupportedUtil) assertIsZero(path string, shouldBeZero interface{}) { if va.IsZero() { return } - u.warn("%s received a non-zero custom value %v that is being ignored."+ + u.warnf("%s received a non-zero custom value %v that is being ignored."+ " Plugin Framework based providers do not yet support this feature.", path, shouldBeZero) } diff --git a/pkg/pf/internal/check/not_supported_test.go b/pkg/pf/internal/check/not_supported_test.go index 3c3ee7026..9a4a343c3 100644 --- a/pkg/pf/internal/check/not_supported_test.go +++ b/pkg/pf/internal/check/not_supported_test.go @@ -24,7 +24,7 @@ import ( ) func TestZeroRecognizer(t *testing.T) { - t.Parallel() + t.Parallel() var stdout bytes.Buffer var stderr bytes.Buffer u := ¬SupportedUtil{ diff --git a/pkg/pf/internal/configencoding/provider.go b/pkg/pf/internal/configencoding/provider.go index c62138c4f..d25dc854c 100644 --- a/pkg/pf/internal/configencoding/provider.go +++ b/pkg/pf/internal/configencoding/provider.go @@ -85,7 +85,8 @@ func (p *provider[T]) CheckConfigWithContext( func (p *provider[T]) DiffConfigWithContext( ctx context.Context, urn resource.URN, oldInputs, olds, news resource.PropertyMap, - allowUnknowns bool, ignoreChanges []string) (plugin.DiffResult, error) { + allowUnknowns bool, ignoreChanges []string, +) (plugin.DiffResult, error) { encoding := p.GetConfigEncoding(ctx) oldInputs, err := encoding.UnfoldProperties(oldInputs) if err != nil { diff --git a/pkg/pf/internal/defaults/defaults.go b/pkg/pf/internal/defaults/defaults.go index d4419f05a..1dde80e5d 100644 --- a/pkg/pf/internal/defaults/defaults.go +++ b/pkg/pf/internal/defaults/defaults.go @@ -92,7 +92,6 @@ func getDefaultValue( for _, n := range defaultInfo.EnvVars { // Following code in v3/tfbridge, ignoring set but empty env vars. if str, ok := os.LookupEnv(n); ok && str != "" { - v, err := parseValueFromEnv(fieldSchema, str) if err != nil { msg := fmt.Errorf("Cannot parse the value of environment variable '%s'"+ diff --git a/pkg/pf/internal/defaults/defaults_test.go b/pkg/pf/internal/defaults/defaults_test.go index d32db4b48..db8e06c84 100644 --- a/pkg/pf/internal/defaults/defaults_test.go +++ b/pkg/pf/internal/defaults/defaults_test.go @@ -355,5 +355,4 @@ func TestApplyDefaultInfoValues(t *testing.T) { assert.Equal(t, tc.expected, actual) }) } - } diff --git a/pkg/pf/internal/muxer/muxer.go b/pkg/pf/internal/muxer/muxer.go index a871526c6..fb237fd34 100644 --- a/pkg/pf/internal/muxer/muxer.go +++ b/pkg/pf/internal/muxer/muxer.go @@ -99,7 +99,6 @@ func (m *ProviderShim) ResourceIsPF(token string) bool { } _, ok := p.(pf.ShimProvider) return ok - } return false } @@ -114,7 +113,6 @@ func (m *ProviderShim) DataSourceIsPF(token string) bool { } _, ok := p.(pf.ShimProvider) return ok - } return false } diff --git a/pkg/pf/internal/muxer/union_test.go b/pkg/pf/internal/muxer/union_test.go index f0e9fb47b..96ef8aeae 100644 --- a/pkg/pf/internal/muxer/union_test.go +++ b/pkg/pf/internal/muxer/union_test.go @@ -22,7 +22,7 @@ import ( ) func TestUnionMap(t *testing.T) { - t.Parallel() + t.Parallel() m1 := testMap{ "one": "n1", "two": "n2", diff --git a/pkg/pf/internal/pfutils/eq.go b/pkg/pf/internal/pfutils/eq.go index 695b73a54..543c09a0f 100644 --- a/pkg/pf/internal/pfutils/eq.go +++ b/pkg/pf/internal/pfutils/eq.go @@ -54,7 +54,8 @@ func NonComputedEq(schema tftypes.AttributePathStepper) Eq { } func replaceComputedAttributesWithNull(schema tftypes.AttributePathStepper, - offset *tftypes.AttributePath, val tftypes.Value) (tftypes.Value, error) { + offset *tftypes.AttributePath, val tftypes.Value, +) (tftypes.Value, error) { return tftypes.Transform(val, func(p *tftypes.AttributePath, v tftypes.Value) (tftypes.Value, error) { realPath := joinPaths(offset, p) if ab, err := LookupTerraformPath(schema, realPath); err == nil && ab.IsAttr && ab.Attr.IsComputed() { diff --git a/pkg/pf/internal/pfutils/proposed_new_test.go b/pkg/pf/internal/pfutils/proposed_new_test.go index 7bf2ab61a..08b03b473 100644 --- a/pkg/pf/internal/pfutils/proposed_new_test.go +++ b/pkg/pf/internal/pfutils/proposed_new_test.go @@ -40,7 +40,7 @@ type runtimeSchemaAdapter struct{ Schema } func (runtimeSchemaAdapter) Shim() shim.SchemaMap { panic("UNIMPLEMENTED") } func TestComputedOptionalBecomingUnknown(t *testing.T) { - t.Parallel() + t.Parallel() schema := rschema.Schema{Attributes: map[string]rschema.Attribute{ "foo": rschema.SingleNestedAttribute{ Attributes: map[string]rschema.Attribute{ @@ -65,7 +65,7 @@ func TestComputedOptionalBecomingUnknown(t *testing.T) { // // https://github.com/hashicorp/terraform/blob/v1.3.6/internal/plans/objchange/objchange.go func TestProposedNewBaseCases(t *testing.T) { - t.Parallel() + t.Parallel() schema := rschema.Schema{Attributes: map[string]rschema.Attribute{ "foo": rschema.StringAttribute{ Optional: true, @@ -223,7 +223,7 @@ func TestProposedNewBaseCases(t *testing.T) { // // https://github.com/hashicorp/terraform/blob/v1.3.6/internal/plans/objchange/objchange_test.go#L12 func TestProposedNewWithPortedCases(t *testing.T) { - t.Parallel() + t.Parallel() testAttributes := map[string]rschema.Attribute{ "optional": rschema.StringAttribute{ Optional: true, @@ -241,7 +241,6 @@ func TestProposedNewWithPortedCases(t *testing.T) { } tests := map[string]testcase{ - "empty": { runtimeSchemaAdapter{ FromResourceSchema(rschema.Schema{Attributes: map[string]rschema.Attribute{}}), diff --git a/pkg/pf/internal/plugin/provider_context.go b/pkg/pf/internal/plugin/provider_context.go index 6293dfa72..1d5c63b37 100644 --- a/pkg/pf/internal/plugin/provider_context.go +++ b/pkg/pf/internal/plugin/provider_context.go @@ -195,7 +195,6 @@ func (prov *provider) Invoke( ) (plugin.InvokeResponse, error) { p, f, err := prov.ProviderWithContext.InvokeWithContext(ctx, req.Tok, req.Args) return plugin.InvokeResponse{Properties: p, Failures: f}, err - } func (prov *provider) StreamInvoke( diff --git a/pkg/pf/internal/schemashim/attr_schema.go b/pkg/pf/internal/schemashim/attr_schema.go index ca066a9ab..b5c9c5d5e 100644 --- a/pkg/pf/internal/schemashim/attr_schema.go +++ b/pkg/pf/internal/schemashim/attr_schema.go @@ -50,9 +50,11 @@ func (s *attrSchema) Required() bool { func (*attrSchema) Default() interface{} { panic("Default() should not be called during schema generation") } + func (*attrSchema) DefaultFunc() shim.SchemaDefaultFunc { panic("DefaultFunc() should not be called during schema generation") } + func (*attrSchema) DefaultValue() (interface{}, error) { // DefaultValue() should not be called by tfgen, but it currently may be called by ExtractInputsFromOutputs, so // returning nil is better than a panic. @@ -118,8 +120,8 @@ func (*attrSchema) MinItems() int { func (*attrSchema) ConflictsWith() []string { panic("ConflictsWith() should not be called during schema generation") - } + func (*attrSchema) ExactlyOneOf() []string { panic("ExactlyOneOf() should not be called during schema generation") } diff --git a/pkg/pf/internal/schemashim/block_schema.go b/pkg/pf/internal/schemashim/block_schema.go index 870d882f2..84a7719ff 100644 --- a/pkg/pf/internal/schemashim/block_schema.go +++ b/pkg/pf/internal/schemashim/block_schema.go @@ -54,7 +54,6 @@ func (s *blockSchema) Description() string { // Needs to return a shim.Schema, a shim.Resource, or nil. See docstring on shim.Schema.Elem(). func (s *blockSchema) Elem() interface{} { - asObjectType := func(typ any) (shim.Resource, bool) { if tt, ok := typ.(basetypes.ObjectTypable); ok { var res shim.Resource = newObjectPseudoResource(tt, diff --git a/pkg/pf/internal/schemashim/custom_object_type_test.go b/pkg/pf/internal/schemashim/custom_object_type_test.go index d06df5ad0..8356960c0 100644 --- a/pkg/pf/internal/schemashim/custom_object_type_test.go +++ b/pkg/pf/internal/schemashim/custom_object_type_test.go @@ -30,7 +30,7 @@ import ( ) func TestCustomObject(t *testing.T) { - t.Parallel() + t.Parallel() ctx := context.Background() obj := newObjectPseudoResource(NewObjectTypeOf[SomeType](ctx), nil, nil) @@ -105,7 +105,6 @@ func (t objectTypeOf[T]) ValueFromObject( func (t objectTypeOf[T]) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { attrValue, err := t.ObjectType.ValueFromTerraform(ctx, in) - if err != nil { return nil, err } diff --git a/pkg/pf/internal/schemashim/custom_type_test.go b/pkg/pf/internal/schemashim/custom_type_test.go index 776a4d81c..5062be497 100644 --- a/pkg/pf/internal/schemashim/custom_type_test.go +++ b/pkg/pf/internal/schemashim/custom_type_test.go @@ -29,7 +29,7 @@ import ( // This example is taken from aws:resourceexplorer/index:Index "timeouts" property. func TestCustomTypeEmbeddingObjectType(t *testing.T) { - t.Parallel() + t.Parallel() type timeoutsType struct { basetypes.ObjectType } @@ -62,7 +62,7 @@ func TestCustomTypeEmbeddingObjectType(t *testing.T) { } func TestCustomListType(t *testing.T) { - t.Parallel() + t.Parallel() ctx := context.Background() raw := schema.ListNestedBlock{ @@ -91,7 +91,7 @@ func TestCustomListType(t *testing.T) { } func TestCustomListAttribute(t *testing.T) { - t.Parallel() + t.Parallel() ctx := context.Background() raw := schema.ListNestedAttribute{ @@ -120,7 +120,7 @@ func TestCustomListAttribute(t *testing.T) { } func TestCustomSetType(t *testing.T) { - t.Parallel() + t.Parallel() ctx := context.Background() raw := schema.SetNestedBlock{ @@ -160,9 +160,7 @@ type setNestedObjectTypeOf[T any] struct { basetypes.SetType } -var ( - _ basetypes.ListTypable = (*listNestedObjectTypeOf[struct{}])(nil) -) +var _ basetypes.ListTypable = (*listNestedObjectTypeOf[struct{}])(nil) func newListNestedObjectTypeOf[T any](ctx context.Context, elemType attr.Type) listNestedObjectTypeOf[T] { return listNestedObjectTypeOf[T]{basetypes.ListType{ElemType: elemType}} diff --git a/pkg/pf/internal/schemashim/datasource.go b/pkg/pf/internal/schemashim/datasource.go index c24645367..584c2b04d 100644 --- a/pkg/pf/internal/schemashim/datasource.go +++ b/pkg/pf/internal/schemashim/datasource.go @@ -46,11 +46,13 @@ func (*schemaOnlyDataSource) Timeouts() *shim.ResourceTimeout { } func (*schemaOnlyDataSource) InstanceState(id string, object, - meta map[string]interface{}) (shim.InstanceState, error) { + meta map[string]interface{}, +) (shim.InstanceState, error) { panic("schemaOnlyDataSource does not implement runtime operation InstanceState") } func (*schemaOnlyDataSource) DecodeTimeouts( - config shim.ResourceConfig) (*shim.ResourceTimeout, error) { + config shim.ResourceConfig, +) (*shim.ResourceTimeout, error) { panic("schemaOnlyDataSource does not implement runtime operation DecodeTimeouts") } diff --git a/pkg/pf/internal/schemashim/object_pseudoresource.go b/pkg/pf/internal/schemashim/object_pseudoresource.go index 7456a99b1..2c706279e 100644 --- a/pkg/pf/internal/schemashim/object_pseudoresource.go +++ b/pkg/pf/internal/schemashim/object_pseudoresource.go @@ -42,7 +42,8 @@ type objectPseudoResource struct { func newObjectPseudoResource(t basetypes.ObjectTypable, nestedAttrs map[string]pfutils.Attr, - nestedBlocks map[string]pfutils.Block) *objectPseudoResource { + nestedBlocks map[string]pfutils.Block, +) *objectPseudoResource { lowerType := t.TerraformType(context.Background()) objType, ok := lowerType.(tftypes.Object) contract.Assertf(ok, "t basetypes.ObjectTypable should produce a tftypes.Object "+ @@ -61,8 +62,10 @@ func newObjectPseudoResource(t basetypes.ObjectTypable, } } -var _ shim.Resource = (*objectPseudoResource)(nil) -var _ shim.SchemaMap = (*objectPseudoResource)(nil) +var ( + _ shim.Resource = (*objectPseudoResource)(nil) + _ shim.SchemaMap = (*objectPseudoResource)(nil) +) func (r *objectPseudoResource) Validate() error { return nil @@ -92,13 +95,15 @@ func (*objectPseudoResource) Timeouts() *shim.ResourceTimeout { } func (*objectPseudoResource) InstanceState(id string, object, - meta map[string]interface{}) (shim.InstanceState, error) { + meta map[string]interface{}, +) (shim.InstanceState, error) { panic("This is an Object type encoded as a shim.Resource, and " + "InstanceState() should not be called on this entity during schema generation") } func (*objectPseudoResource) DecodeTimeouts( - config shim.ResourceConfig) (*shim.ResourceTimeout, error) { + config shim.ResourceConfig, +) (*shim.ResourceTimeout, error) { panic("This is an Object type encoded as a shim.Resource, and " + "DecodeTimeouts() should not be called on this entity during schema generation") } @@ -187,7 +192,8 @@ func newTuplePseudoResource(t attr.TypeWithElementTypes) shim.Resource { return &tuplePseudoResource{ schemaOnly: schemaOnly{"tuplePseudoResource"}, attrs: attrs, - tuple: t} + tuple: t, + } } func (*tuplePseudoResource) SchemaVersion() int { panic("TODO") } @@ -236,7 +242,7 @@ type schemaOnly struct{ typ string } func (s *schemaOnly) Importer() shim.ImportFunc { m := "type" - if s != nil || s.typ != "" { + if s != nil && s.typ != "" { m = s.typ } panic(m + " does not implement runtime operation ImporterFunc") @@ -244,25 +250,27 @@ func (s *schemaOnly) Importer() shim.ImportFunc { func (s *schemaOnly) Timeouts() *shim.ResourceTimeout { m := "type" - if s != nil || s.typ != "" { + if s != nil && s.typ != "" { m = s.typ } panic(m + " does not implement runtime operation Timeouts") } func (s *schemaOnly) InstanceState(id string, object, - meta map[string]interface{}) (shim.InstanceState, error) { + meta map[string]interface{}, +) (shim.InstanceState, error) { m := "type" - if s != nil || s.typ != "" { + if s != nil && s.typ != "" { m = s.typ } panic(m + " does not implement runtime operation InstanceState") } func (s *schemaOnly) DecodeTimeouts( - config shim.ResourceConfig) (*shim.ResourceTimeout, error) { + config shim.ResourceConfig, +) (*shim.ResourceTimeout, error) { m := "type" - if s != nil || s.typ != "" { + if s != nil && s.typ != "" { m = s.typ } panic(m + " does not implement runtime operation DecodeTimeouts") diff --git a/pkg/pf/internal/schemashim/object_type_test.go b/pkg/pf/internal/schemashim/object_type_test.go index 1bc41b4af..1a9b358fb 100644 --- a/pkg/pf/internal/schemashim/object_type_test.go +++ b/pkg/pf/internal/schemashim/object_type_test.go @@ -31,7 +31,7 @@ import ( ) func TestObjectAttribute(t *testing.T) { - t.Parallel() + t.Parallel() objectAttr := schema.ObjectAttribute{ AttributeTypes: map[string]attr.Type{ "s": basetypes.StringType{}, @@ -44,7 +44,7 @@ func TestObjectAttribute(t *testing.T) { } func TestTypeSchemaDescriptionIsEmpty(t *testing.T) { - t.Parallel() + t.Parallel() shimmedType := &typeSchema{ t: basetypes.StringType{}, nested: nil, @@ -53,7 +53,7 @@ func TestTypeSchemaDescriptionIsEmpty(t *testing.T) { } func TestSingleNestedBlock(t *testing.T) { - t.Parallel() + t.Parallel() b := schema.SingleNestedBlock{ Attributes: simpleObjectAttributes(), } @@ -66,7 +66,7 @@ func TestSingleNestedBlock(t *testing.T) { } func TestListNestedBlock(t *testing.T) { - t.Parallel() + t.Parallel() b := schema.ListNestedBlock{ NestedObject: schema.NestedBlockObject{ Attributes: simpleObjectAttributes(), @@ -80,7 +80,7 @@ func TestListNestedBlock(t *testing.T) { } func TestSetNestedBlock(t *testing.T) { - t.Parallel() + t.Parallel() b := schema.SetNestedBlock{ NestedObject: schema.NestedBlockObject{ Attributes: simpleObjectAttributes(), @@ -94,7 +94,7 @@ func TestSetNestedBlock(t *testing.T) { } func TestDeeplyNestedBlock(t *testing.T) { - t.Parallel() + t.Parallel() b := schema.ListNestedBlock{ NestedObject: schema.NestedBlockObject{ Blocks: map[string]schema.Block{ diff --git a/pkg/pf/internal/schemashim/provider.go b/pkg/pf/internal/schemashim/provider.go index 8b96f2881..a4471ee00 100644 --- a/pkg/pf/internal/schemashim/provider.go +++ b/pkg/pf/internal/schemashim/provider.go @@ -32,9 +32,9 @@ import ( var _ = pf.ShimProvider(&SchemaOnlyProvider{}) type SchemaOnlyProvider struct { - ctx context.Context - tf pfprovider.Provider - resourceMap shim.ResourceMap + ctx context.Context + tf pfprovider.Provider + resourceMap shim.ResourceMap dataSourceMap shim.ResourceMap } @@ -106,7 +106,8 @@ func (p *SchemaOnlyProvider) ValidateResource( } func (p *SchemaOnlyProvider) ValidateDataSource( - context.Context, string, shim.ResourceConfig) ([]string, []error) { + context.Context, string, shim.ResourceConfig, +) ([]string, []error) { panic("schemaOnlyProvider does not implement runtime operation ValidateDataSource") } @@ -167,6 +168,7 @@ func (p *SchemaOnlyProvider) NewResourceConfig(context.Context, map[string]inter func (p *SchemaOnlyProvider) NewProviderConfig(context.Context, map[string]interface{}) shim.ResourceConfig { panic("schemaOnlyProvider does not implement runtime operation ProviderConfig") } + func (p *SchemaOnlyProvider) IsSet(context.Context, interface{}) ([]interface{}, bool) { panic("schemaOnlyProvider does not implement runtime operation IsSet") } diff --git a/pkg/pf/internal/schemashim/resource.go b/pkg/pf/internal/schemashim/resource.go index bdb869da0..a8520e49a 100644 --- a/pkg/pf/internal/schemashim/resource.go +++ b/pkg/pf/internal/schemashim/resource.go @@ -46,11 +46,13 @@ func (*schemaOnlyResource) Timeouts() *shim.ResourceTimeout { } func (*schemaOnlyResource) InstanceState(id string, object, - meta map[string]interface{}) (shim.InstanceState, error) { + meta map[string]interface{}, +) (shim.InstanceState, error) { panic("schemaOnlyResource does not implement runtime operation InstanceState") } func (*schemaOnlyResource) DecodeTimeouts( - config shim.ResourceConfig) (*shim.ResourceTimeout, error) { + config shim.ResourceConfig, +) (*shim.ResourceTimeout, error) { panic("schemaOnlyResource does not implement runtime operation DecodeTimeouts") } diff --git a/pkg/pf/internal/schemashim/type_schema_test.go b/pkg/pf/internal/schemashim/type_schema_test.go index 56e6f1ff0..7cb6e85b2 100644 --- a/pkg/pf/internal/schemashim/type_schema_test.go +++ b/pkg/pf/internal/schemashim/type_schema_test.go @@ -11,7 +11,7 @@ import ( ) func TestMapAttribute(t *testing.T) { - t.Parallel() + t.Parallel() mapAttr := schema.MapAttribute{ Optional: true, ElementType: basetypes.StringType{}, diff --git a/pkg/pf/proto/attribute.go b/pkg/pf/proto/attribute.go index 99a5946a5..f4354ca8f 100644 --- a/pkg/pf/proto/attribute.go +++ b/pkg/pf/proto/attribute.go @@ -82,7 +82,6 @@ func (a attribute) Elem() interface{} { } } return element{a.attr.ValueType(), a.Optional()}.Elem() - } // Defaults are applied in the provider binary, not here diff --git a/pkg/pf/proto/element.go b/pkg/pf/proto/element.go index 95eb517ba..07ff5c5f0 100644 --- a/pkg/pf/proto/element.go +++ b/pkg/pf/proto/element.go @@ -20,8 +20,10 @@ import ( shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim" ) -var _ = shim.Schema(element{}) -var _ = shim.Resource(elementObject{}) +var ( + _ = shim.Schema(element{}) + _ = shim.Resource(elementObject{}) +) type element struct { typ tftypes.Type @@ -55,7 +57,6 @@ func (e element) Type() shim.ValueType { default: return shim.TypeInvalid } - } func (e element) Elem() interface{} { diff --git a/pkg/pf/proto/protov6_test.go b/pkg/pf/proto/protov6_test.go index 5f4336ace..1d4aaea94 100644 --- a/pkg/pf/proto/protov6_test.go +++ b/pkg/pf/proto/protov6_test.go @@ -46,12 +46,12 @@ func marshalProviderShim(t *testing.T, p shim.Provider) []byte { } func TestShimSchema(t *testing.T) { - t.Parallel() + t.Parallel() autogold.Expect("{}\n").Equal(t, string(marshalProviderShim(t, proto.Empty()))) } func TestDynamicType(t *testing.T) { - t.Parallel() + t.Parallel() b := marshalProviderShim(t, proto.New(context.Background(), providerServer{ SchemaResponse: &tfprotov6.GetProviderSchemaResponse{ @@ -78,7 +78,7 @@ func TestDynamicType(t *testing.T) { } func TestBlockSchemaGeneration(t *testing.T) { - t.Parallel() + t.Parallel() p := proto.New(context.Background(), providerServer{ SchemaResponse: &tfprotov6.GetProviderSchemaResponse{ ResourceSchemas: map[string]*tfprotov6.Schema{ diff --git a/pkg/pf/proto/resource.go b/pkg/pf/proto/resource.go index 33c4fd056..da8b2991f 100644 --- a/pkg/pf/proto/resource.go +++ b/pkg/pf/proto/resource.go @@ -81,6 +81,7 @@ func (r resource) Timeouts() *shim.ResourceTimeout { func (r resource) InstanceState(id string, object, meta map[string]interface{}) (shim.InstanceState, error) { panic("Cannot call InstanceState for a schema only resource") } + func (r resource) DecodeTimeouts(config shim.ResourceConfig) (*shim.ResourceTimeout, error) { panic("Cannot call DecodeTimeouts for a schema only resource") } diff --git a/pkg/pf/proto/schema.go b/pkg/pf/proto/schema.go index c9be2237a..576f7c607 100644 --- a/pkg/pf/proto/schema.go +++ b/pkg/pf/proto/schema.go @@ -29,13 +29,15 @@ func (pseudoResource) Timeouts() *shim.ResourceTimeout { return nil } func (pseudoResource) InstanceState(id string, object, meta map[string]interface{}) (shim.InstanceState, error) { panic("Cannot invoke InstanceState on a pseudoResource") } + func (pseudoResource) DecodeTimeouts(config shim.ResourceConfig) (*shim.ResourceTimeout, error) { panic("Cannot invoke DecodeTimeouts on a pseudoResource") } func getSchemaMap[T any](m interface { GetOk(string) (T, bool) -}, key string) T { +}, key string, +) T { v, _ := m.GetOk(key) // Some functions (such as terraformToPulumiName; link: [1]) do not correctly use // GetOk, so we can't panic on Get for a missing value, even though that is the diff --git a/pkg/pf/proto/unsupported.go b/pkg/pf/proto/unsupported.go index ce2d2c6b3..0ca3e5e86 100644 --- a/pkg/pf/proto/unsupported.go +++ b/pkg/pf/proto/unsupported.go @@ -24,9 +24,11 @@ func (Provider) InternalValidate() error { panic("Unimplemented") } func (Provider) Validate(ctx context.Context, c shim.ResourceConfig) ([]string, []error) { panic("Unimplemented") } + func (Provider) ValidateResource(ctx context.Context, t string, c shim.ResourceConfig) ([]string, []error) { panic("Unimplemented") } + func (Provider) ValidateDataSource(ctx context.Context, t string, c shim.ResourceConfig) ([]string, []error) { panic("Unimplemented") } @@ -60,6 +62,7 @@ func (Provider) Refresh( func (Provider) ReadDataDiff(ctx context.Context, t string, c shim.ResourceConfig) (shim.InstanceDiff, error) { panic("Unimplemented") } + func (Provider) ReadDataApply(ctx context.Context, t string, d shim.InstanceDiff) (shim.InstanceState, error) { panic("Unimplemented") } diff --git a/pkg/pf/tests/diff_list_test.go b/pkg/pf/tests/diff_list_test.go index cfb9d3396..520223dbe 100644 --- a/pkg/pf/tests/diff_list_test.go +++ b/pkg/pf/tests/diff_list_test.go @@ -9,9 +9,10 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hexops/autogold/v2" + "github.com/zclconf/go-cty/cty" + crosstests "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/cross-tests" pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" - "github.com/zclconf/go-cty/cty" ) func TestDetailedDiffList(t *testing.T) { diff --git a/pkg/pf/tests/diff_map_test.go b/pkg/pf/tests/diff_map_test.go index 56a38579b..ea911a280 100644 --- a/pkg/pf/tests/diff_map_test.go +++ b/pkg/pf/tests/diff_map_test.go @@ -9,9 +9,10 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hexops/autogold/v2" + "github.com/zclconf/go-cty/cty" + crosstests "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/cross-tests" pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" - "github.com/zclconf/go-cty/cty" ) func TestDetailedDiffMap(t *testing.T) { diff --git a/pkg/pf/tests/diff_object_test.go b/pkg/pf/tests/diff_object_test.go index 9ef66dae2..65c89dab8 100644 --- a/pkg/pf/tests/diff_object_test.go +++ b/pkg/pf/tests/diff_object_test.go @@ -14,9 +14,10 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hexops/autogold/v2" + "github.com/zclconf/go-cty/cty" + crosstests "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/cross-tests" pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" - "github.com/zclconf/go-cty/cty" ) type objectDefault basetypes.ObjectValue diff --git a/pkg/pf/tests/diff_set_test.go b/pkg/pf/tests/diff_set_test.go index 3d77bbc6e..a7c3f1708 100644 --- a/pkg/pf/tests/diff_set_test.go +++ b/pkg/pf/tests/diff_set_test.go @@ -9,9 +9,10 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hexops/autogold/v2" + "github.com/zclconf/go-cty/cty" + crosstests "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/cross-tests" pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" - "github.com/zclconf/go-cty/cty" ) func TestDetailedDiffSet(t *testing.T) { diff --git a/pkg/pf/tests/diff_test.go b/pkg/pf/tests/diff_test.go index 085a4258e..4562d9ce1 100644 --- a/pkg/pf/tests/diff_test.go +++ b/pkg/pf/tests/diff_test.go @@ -10,9 +10,10 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hexops/autogold/v2" + "github.com/zclconf/go-cty/cty" + crosstests "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/cross-tests" pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" - "github.com/zclconf/go-cty/cty" ) func ref[T any](t T) *T { return &t } diff --git a/pkg/pf/tests/dynamic_types_test.go b/pkg/pf/tests/dynamic_types_test.go index 0d8ebcccd..e00e8642a 100644 --- a/pkg/pf/tests/dynamic_types_test.go +++ b/pkg/pf/tests/dynamic_types_test.go @@ -16,26 +16,26 @@ package tfbridgetests import ( "context" + "encoding/json" "math/big" "testing" - "encoding/json" - "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hashicorp/terraform-plugin-go/tftypes" - pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" "github.com/pulumi/pulumi/sdk/v3/go/common/apitype" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gopkg.in/yaml.v3" + + pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" ) func TestCreateResourceWithDynamicAttribute(t *testing.T) { - t.Parallel() + t.Parallel() type testCase struct { name string // test case name manifestToSend any // assumes a Pulumi YAML expression diff --git a/pkg/pf/tests/extract_inputs_test.go b/pkg/pf/tests/extract_inputs_test.go index 12e4dd215..940543b3c 100644 --- a/pkg/pf/tests/extract_inputs_test.go +++ b/pkg/pf/tests/extract_inputs_test.go @@ -11,15 +11,16 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hexops/autogold/v2" + "github.com/pulumi/pulumi/sdk/v3/go/common/resource" + "github.com/stretchr/testify/require" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/internal/schemashim" pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" - "github.com/pulumi/pulumi/sdk/v3/go/common/resource" - "github.com/stretchr/testify/require" ) func TestExtractInputsFromOutputsPF(t *testing.T) { - t.Parallel() + t.Parallel() type testCase struct { name string props resource.PropertyMap diff --git a/pkg/pf/tests/genrandom_test.go b/pkg/pf/tests/genrandom_test.go index e59abf8db..2f012782f 100644 --- a/pkg/pf/tests/genrandom_test.go +++ b/pkg/pf/tests/genrandom_test.go @@ -18,8 +18,9 @@ import ( "testing" testutils "github.com/pulumi/providertest/replay" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" "github.com/stretchr/testify/require" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" ) // These tests replay gRPC logs from a well-behaved test program in testdatagen/genrandom to verify @@ -28,7 +29,7 @@ import ( // // See testdatagen/genrandom/generate.sh for regenerating the test data. func TestGenRandom(t *testing.T) { - t.Parallel() + t.Parallel() traces := []string{ // TODO enable once Configure replay is implemented. // "testdata/genrandom/random-delete-preview.json", diff --git a/pkg/pf/tests/genupdate_test.go b/pkg/pf/tests/genupdate_test.go index b32e736a9..518e2347b 100644 --- a/pkg/pf/tests/genupdate_test.go +++ b/pkg/pf/tests/genupdate_test.go @@ -18,8 +18,9 @@ import ( "testing" testutils "github.com/pulumi/providertest/replay" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" "github.com/stretchr/testify/require" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" ) // These tests replay Update gRPC logs to get some unit test coverage for Update. @@ -30,7 +31,7 @@ import ( // PULUMI_DEBUG_GPRC=$PWD/grpc.json go test -run TestUpdateProgram // jq -s . grpc.json func TestGenUpdates(t *testing.T) { - t.Parallel() + t.Parallel() trace := "testdata/updateprogram.json" server, err := newProviderServer(t, testprovider.SyntheticTestBridgeProvider()) diff --git a/pkg/pf/tests/integration/attach_test.go b/pkg/pf/tests/integration/attach_test.go index 8cc6d43f4..7de984f78 100644 --- a/pkg/pf/tests/integration/attach_test.go +++ b/pkg/pf/tests/integration/attach_test.go @@ -25,7 +25,7 @@ import ( ) func TestAttach(t *testing.T) { - t.Parallel() + t.Parallel() if testing.Short() { t.Skip() } @@ -42,7 +42,7 @@ func TestAttach(t *testing.T) { } func TestAttachMuxed(t *testing.T) { - t.Parallel() + t.Parallel() if testing.Short() { t.Skip() } diff --git a/pkg/pf/tests/integration/program_test.go b/pkg/pf/tests/integration/program_test.go index 6d92ce301..63513cbb9 100644 --- a/pkg/pf/tests/integration/program_test.go +++ b/pkg/pf/tests/integration/program_test.go @@ -231,7 +231,6 @@ func TestTracePropagation(t *testing.T) { return prepareStateFolder(info.Root) }, }) - } // Note that random_bytes is an interesting resource that does not specify an ID where Pulumi requires it. Add a test @@ -255,7 +254,7 @@ func TestResourceWithoutID(t *testing.T) { } func prepareStateFolder(root string) error { - err := os.Mkdir(filepath.Join(root, "state"), 0777) + err := os.Mkdir(filepath.Join(root, "state"), 0o777) if os.IsExist(err) { return nil } @@ -274,7 +273,6 @@ func ensureTestBridgeProviderCompiled(wd string) error { return err } return ensure("pulumi-resource-muxedrandom") - } // Stacks may define tests inline by a simple convention of providing diff --git a/pkg/pf/tests/internal/cross-tests/configure.go b/pkg/pf/tests/internal/cross-tests/configure.go index 0dc135e5b..0bfe617b5 100644 --- a/pkg/pf/tests/internal/cross-tests/configure.go +++ b/pkg/pf/tests/internal/cross-tests/configure.go @@ -27,6 +27,14 @@ import ( "github.com/pulumi/providertest/providers" "github.com/pulumi/providertest/pulumitest" "github.com/pulumi/providertest/pulumitest/opttest" + "github.com/pulumi/pulumi/sdk/v3/go/common/resource" + "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" + pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/zclconf/go-cty/cty" + "gopkg.in/yaml.v3" + crosstests "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests" crosstestsimpl "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests/impl" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests/impl/hclwrite" @@ -36,13 +44,6 @@ import ( "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/tfcheck" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/tokens" - "github.com/pulumi/pulumi/sdk/v3/go/common/resource" - "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" - pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/zclconf/go-cty/cty" - "gopkg.in/yaml.v3" ) // MakeConfigure returns a [testing] subtest of [Configure]. diff --git a/pkg/pf/tests/internal/cross-tests/diff.go b/pkg/pf/tests/internal/cross-tests/diff.go index 519e15323..e8b2c1ec0 100644 --- a/pkg/pf/tests/internal/cross-tests/diff.go +++ b/pkg/pf/tests/internal/cross-tests/diff.go @@ -17,6 +17,12 @@ package crosstests import ( "bytes" + "github.com/pulumi/pulumi/sdk/v3/go/auto/optpreview" + "github.com/pulumi/pulumi/sdk/v3/go/common/resource" + "github.com/stretchr/testify/require" + "github.com/zclconf/go-cty/cty" + "gopkg.in/yaml.v3" + crosstests "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests" crosstestsimpl "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests/impl" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests/impl/hclwrite" @@ -25,11 +31,6 @@ import ( "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/tfcheck" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info" - "github.com/pulumi/pulumi/sdk/v3/go/auto/optpreview" - "github.com/pulumi/pulumi/sdk/v3/go/common/resource" - "github.com/stretchr/testify/require" - "github.com/zclconf/go-cty/cty" - "gopkg.in/yaml.v3" ) func yamlResource(t T, properties resource.PropertyMap) map[string]any { diff --git a/pkg/pf/tests/internal/cross-tests/tfwrite.go b/pkg/pf/tests/internal/cross-tests/tfwrite.go index 5c3efe122..44bda93a7 100644 --- a/pkg/pf/tests/internal/cross-tests/tfwrite.go +++ b/pkg/pf/tests/internal/cross-tests/tfwrite.go @@ -3,8 +3,9 @@ package crosstests import ( pschema "github.com/hashicorp/terraform-plugin-framework/provider/schema" rschema "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests/impl/hclwrite" "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests/impl/hclwrite" ) // This is a copy of the BlockNestingMode enum in the Terraform Plugin Framework. diff --git a/pkg/pf/tests/internal/cross-tests/tfwrite_test.go b/pkg/pf/tests/internal/cross-tests/tfwrite_test.go index cfc4095f1..77c77d7dc 100644 --- a/pkg/pf/tests/internal/cross-tests/tfwrite_test.go +++ b/pkg/pf/tests/internal/cross-tests/tfwrite_test.go @@ -7,9 +7,10 @@ import ( pschema "github.com/hashicorp/terraform-plugin-framework/provider/schema" rschema "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hexops/autogold/v2" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests/impl/hclwrite" "github.com/stretchr/testify/require" "github.com/zclconf/go-cty/cty" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests/impl/hclwrite" ) func TestWritePFHCLProvider(t *testing.T) { diff --git a/pkg/pf/tests/internal/cross-tests/util.go b/pkg/pf/tests/internal/cross-tests/util.go index f67544b21..c8f0295f7 100644 --- a/pkg/pf/tests/internal/cross-tests/util.go +++ b/pkg/pf/tests/internal/cross-tests/util.go @@ -20,14 +20,15 @@ import ( "runtime" "strings" + "github.com/pulumi/pulumi/sdk/v3/go/common/diag" + "github.com/pulumi/pulumi/sdk/v3/go/common/resource" + crosstestsimpl "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests/impl" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" tfbridge0 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/tokens" - "github.com/pulumi/pulumi/sdk/v3/go/common/diag" - "github.com/pulumi/pulumi/sdk/v3/go/common/resource" ) type T = crosstestsimpl.T diff --git a/pkg/pf/tests/internal/pftfcheck/pftf_test.go b/pkg/pf/tests/internal/pftfcheck/pftf_test.go index fbe545163..5e756d14b 100644 --- a/pkg/pf/tests/internal/pftfcheck/pftf_test.go +++ b/pkg/pf/tests/internal/pftfcheck/pftf_test.go @@ -5,13 +5,14 @@ import ( rschema "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/stretchr/testify/require" + pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/tfcheck" - "github.com/stretchr/testify/require" ) func TestBasic(t *testing.T) { - t.Parallel() + t.Parallel() prov := pb.NewProvider(pb.NewProviderArgs{ AllResources: []pb.Resource{ pb.NewResource(pb.NewResourceArgs{ @@ -45,7 +46,7 @@ output "s_val" { } func TestDefaults(t *testing.T) { - t.Parallel() + t.Parallel() prov := pb.NewProvider(pb.NewProviderArgs{ AllResources: []pb.Resource{ pb.NewResource(pb.NewResourceArgs{ diff --git a/pkg/pf/tests/internal/testprovider/assert_provider.go b/pkg/pf/tests/internal/testprovider/assert_provider.go index 64bd5e199..c5123b362 100644 --- a/pkg/pf/tests/internal/testprovider/assert_provider.go +++ b/pkg/pf/tests/internal/testprovider/assert_provider.go @@ -103,6 +103,7 @@ func (e *assertRes) Schema(_ context.Context, _ resource.SchemaRequest, resp *re }, } } + func (e *assertRes) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = req.ProviderTypeName + "_echo" } diff --git a/pkg/pf/tests/internal/testprovider/cmd/pulumi-resource-testbridge/main.go b/pkg/pf/tests/internal/testprovider/cmd/pulumi-resource-testbridge/main.go index 0780c7a2a..e5e65ad2b 100644 --- a/pkg/pf/tests/internal/testprovider/cmd/pulumi-resource-testbridge/main.go +++ b/pkg/pf/tests/internal/testprovider/cmd/pulumi-resource-testbridge/main.go @@ -18,6 +18,7 @@ package main import ( "context" _ "embed" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" ) diff --git a/pkg/pf/tests/internal/testprovider/cmd/pulumi-resource-tls/main.go b/pkg/pf/tests/internal/testprovider/cmd/pulumi-resource-tls/main.go index a3b14241a..db33f8a54 100644 --- a/pkg/pf/tests/internal/testprovider/cmd/pulumi-resource-tls/main.go +++ b/pkg/pf/tests/internal/testprovider/cmd/pulumi-resource-tls/main.go @@ -18,6 +18,7 @@ package main import ( "context" _ "embed" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" ) diff --git a/pkg/pf/tests/internal/testprovider/plan_modifiers.go b/pkg/pf/tests/internal/testprovider/plan_modifiers.go index 44acc2bb7..d5df90304 100644 --- a/pkg/pf/tests/internal/testprovider/plan_modifiers.go +++ b/pkg/pf/tests/internal/testprovider/plan_modifiers.go @@ -28,11 +28,13 @@ type PropagatesNullFrom struct { AnotherAttribute string } -var _ planmodifier.String = PropagatesNullFrom{} -var _ planmodifier.Number = PropagatesNullFrom{} -var _ planmodifier.Bool = PropagatesNullFrom{} -var _ planmodifier.List = PropagatesNullFrom{} -var _ planmodifier.Map = PropagatesNullFrom{} +var ( + _ planmodifier.String = PropagatesNullFrom{} + _ planmodifier.Number = PropagatesNullFrom{} + _ planmodifier.Bool = PropagatesNullFrom{} + _ planmodifier.List = PropagatesNullFrom{} + _ planmodifier.Map = PropagatesNullFrom{} +) func (mod PropagatesNullFrom) Description(_ context.Context) string { return "Sets plan to null if AnotherAttribute is null in config" @@ -43,35 +45,40 @@ func (mod PropagatesNullFrom) MarkdownDescription(ctx context.Context) string { } func (mod PropagatesNullFrom) PlanModifyNumber(ctx context.Context, req planmodifier.NumberRequest, - resp *planmodifier.NumberResponse) { + resp *planmodifier.NumberResponse, +) { if mod.anotherAttributeIsNull(req.Config) { resp.PlanValue = types.NumberNull() } } func (mod PropagatesNullFrom) PlanModifyString(ctx context.Context, req planmodifier.StringRequest, - resp *planmodifier.StringResponse) { + resp *planmodifier.StringResponse, +) { if mod.anotherAttributeIsNull(req.Config) { resp.PlanValue = types.StringNull() } } func (mod PropagatesNullFrom) PlanModifyBool(ctx context.Context, req planmodifier.BoolRequest, - resp *planmodifier.BoolResponse) { + resp *planmodifier.BoolResponse, +) { if mod.anotherAttributeIsNull(req.Config) { resp.PlanValue = types.BoolNull() } } func (mod PropagatesNullFrom) PlanModifyList(ctx context.Context, req planmodifier.ListRequest, - resp *planmodifier.ListResponse) { + resp *planmodifier.ListResponse, +) { if mod.anotherAttributeIsNull(req.Config) { resp.PlanValue = types.ListNull(req.PlanValue.ElementType(ctx)) } } func (mod PropagatesNullFrom) PlanModifyMap(ctx context.Context, req planmodifier.MapRequest, - resp *planmodifier.MapResponse) { + resp *planmodifier.MapResponse, +) { if mod.anotherAttributeIsNull(req.Config) { resp.PlanValue = types.MapNull(req.PlanValue.ElementType(ctx)) } diff --git a/pkg/pf/tests/internal/testprovider/random.go b/pkg/pf/tests/internal/testprovider/random.go index 9a198243a..c427ac3fe 100644 --- a/pkg/pf/tests/internal/testprovider/random.go +++ b/pkg/pf/tests/internal/testprovider/random.go @@ -22,14 +22,12 @@ import ( "strings" "unicode" + sdk2schema "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/pulumi/pulumi/sdk/v3/go/common/resource" "github.com/pulumi/pulumi/sdk/v3/go/common/tokens" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/randomshim" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider/sdkv2randomprovider" - - sdk2schema "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - tfpf "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" sdkv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2" diff --git a/pkg/pf/tests/internal/testprovider/testbridge.go b/pkg/pf/tests/internal/testprovider/testbridge.go index 86d1f6901..2ea8ba431 100644 --- a/pkg/pf/tests/internal/testprovider/testbridge.go +++ b/pkg/pf/tests/internal/testprovider/testbridge.go @@ -232,7 +232,6 @@ func validateNested( req provider.ConfigureRequest, resp *provider.ConfigureResponse, ) { - check := func(path path.Path, expected, actual any) { if !reflect.DeepEqual(expected, actual) { resp.Diagnostics.AddAttributeError(path, "mismatched expectations", diff --git a/pkg/pf/tests/internal/testprovider/testbridge_datasource_echo.go b/pkg/pf/tests/internal/testprovider/testbridge_datasource_echo.go index be0e25b81..3ce60405d 100644 --- a/pkg/pf/tests/internal/testprovider/testbridge_datasource_echo.go +++ b/pkg/pf/tests/internal/testprovider/testbridge_datasource_echo.go @@ -29,7 +29,8 @@ func newEchoDataSource() datasource.DataSource { type echoDataSource struct{} func (*echoDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, - resp *datasource.MetadataResponse) { + resp *datasource.MetadataResponse, +) { resp.TypeName = req.ProviderTypeName + "_echo" } diff --git a/pkg/pf/tests/internal/testprovider/testbridge_datasource_smac.go b/pkg/pf/tests/internal/testprovider/testbridge_datasource_smac.go index 708193df2..3eca0a1d2 100644 --- a/pkg/pf/tests/internal/testprovider/testbridge_datasource_smac.go +++ b/pkg/pf/tests/internal/testprovider/testbridge_datasource_smac.go @@ -47,8 +47,8 @@ func (*smacDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, res func (ds *smacDataSource) Configure( _ context.Context, rq datasource.ConfigureRequest, - re *datasource.ConfigureResponse) { - + re *datasource.ConfigureResponse, +) { data, ok := rq.ProviderData.(resourceData) if ok { ds.smac = data.skipMetadataAPICheck diff --git a/pkg/pf/tests/internal/testprovider/testbridge_datasource_test_defaultinfo.go b/pkg/pf/tests/internal/testprovider/testbridge_datasource_test_defaultinfo.go index a542ec30e..b0fe5895d 100644 --- a/pkg/pf/tests/internal/testprovider/testbridge_datasource_test_defaultinfo.go +++ b/pkg/pf/tests/internal/testprovider/testbridge_datasource_test_defaultinfo.go @@ -29,7 +29,8 @@ func newTestDefaultInfoDataSource() datasource.DataSource { type testDefaultInfoDataSource struct{} func (*testDefaultInfoDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, - resp *datasource.MetadataResponse) { + resp *datasource.MetadataResponse, +) { resp.TypeName = req.ProviderTypeName + "_test_defaultinfo" } diff --git a/pkg/pf/tests/internal/testprovider/testbridge_resouce_testconfigres.go b/pkg/pf/tests/internal/testprovider/testbridge_resouce_testconfigres.go index e846ad4f6..160335c3e 100644 --- a/pkg/pf/tests/internal/testprovider/testbridge_resouce_testconfigres.go +++ b/pkg/pf/tests/internal/testprovider/testbridge_resouce_testconfigres.go @@ -26,8 +26,10 @@ type testconfigres struct { config string } -var _ resource.Resource = (*testconfigres)(nil) -var _ resource.ResourceWithConfigure = (*testconfigres)(nil) +var ( + _ resource.Resource = (*testconfigres)(nil) + _ resource.ResourceWithConfigure = (*testconfigres)(nil) +) func newTestConfigRes() resource.Resource { return &testconfigres{} diff --git a/pkg/pf/tests/internal/testprovider/testbridge_resource_testnest.go b/pkg/pf/tests/internal/testprovider/testbridge_resource_testnest.go index 61680fd74..a80562a73 100644 --- a/pkg/pf/tests/internal/testprovider/testbridge_resource_testnest.go +++ b/pkg/pf/tests/internal/testprovider/testbridge_resource_testnest.go @@ -28,8 +28,10 @@ import ( type testnest struct{} -var _ resource.Resource = &testnest{} -var _ resource.ResourceWithImportState = &testnest{} +var ( + _ resource.Resource = &testnest{} + _ resource.ResourceWithImportState = &testnest{} +) func newTestnest() resource.Resource { return &testnest{} diff --git a/pkg/pf/tests/internal/testprovider/testbridge_resource_testnestattr.go b/pkg/pf/tests/internal/testprovider/testbridge_resource_testnestattr.go index d592acebd..4ef6820e3 100644 --- a/pkg/pf/tests/internal/testprovider/testbridge_resource_testnestattr.go +++ b/pkg/pf/tests/internal/testprovider/testbridge_resource_testnestattr.go @@ -16,11 +16,11 @@ package testprovider import ( "context" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" rschema "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" @@ -28,8 +28,10 @@ import ( type testnestattr struct{} -var _ resource.Resource = &testnestattr{} -var _ resource.ResourceWithImportState = &testnestattr{} +var ( + _ resource.Resource = &testnestattr{} + _ resource.ResourceWithImportState = &testnestattr{} +) func newTestnestattr() resource.Resource { return &testnestattr{} @@ -117,7 +119,6 @@ func (e *testnestattr) Delete(ctx context.Context, req resource.DeleteRequest, r // If setting an attribute with the import identifier, it is recommended to use the ImportStatePassthroughID() call in // this method. func (e *testnestattr) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - type model struct { ID types.String `tfsdk:"id"` Services []ServiceModel `tfsdk:"services"` diff --git a/pkg/pf/tests/internal/testprovider/testbridge_resource_testres.go b/pkg/pf/tests/internal/testprovider/testbridge_resource_testres.go index 1daee64bb..e0dab381f 100644 --- a/pkg/pf/tests/internal/testprovider/testbridge_resource_testres.go +++ b/pkg/pf/tests/internal/testprovider/testbridge_resource_testres.go @@ -39,7 +39,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-go/tftypes" - "github.com/pulumi/pulumi/sdk/v3/go/common/util/fsutil" ) @@ -539,7 +538,7 @@ func (e *testres) freshID(statedir string) (string, error) { } } - if err := os.WriteFile(cF, []byte(fmt.Sprintf("%d", i+1)), 0600); err != nil { + if err := os.WriteFile(cF, []byte(fmt.Sprintf("%d", i+1)), 0o600); err != nil { return "", err } @@ -574,7 +573,7 @@ func (e *testres) writeCloudState(ctx context.Context, file string, state tfsdk. if err != nil { return err } - return os.WriteFile(file, stateBytes, 0600) + return os.WriteFile(file, stateBytes, 0o600) } func (*testres) stateToBytes(ctx context.Context, state tfsdk.State) ([]byte, error) { diff --git a/pkg/pf/tests/internal/testprovider/tls.go b/pkg/pf/tests/internal/testprovider/tls.go index ddfe0269c..21328d5b0 100644 --- a/pkg/pf/tests/internal/testprovider/tls.go +++ b/pkg/pf/tests/internal/testprovider/tls.go @@ -20,10 +20,11 @@ import ( "path/filepath" "unicode" + "github.com/pulumi/pulumi/sdk/v3/go/common/tokens" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/tlsshim" tfpf "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" - "github.com/pulumi/pulumi/sdk/v3/go/common/tokens" ) //go:embed cmd/pulumi-resource-tls/bridge-metadata.json diff --git a/pkg/pf/tests/internal/testprovider/tuple_type.go b/pkg/pf/tests/internal/testprovider/tuple_type.go index dc2e3c85c..aacffb840 100644 --- a/pkg/pf/tests/internal/testprovider/tuple_type.go +++ b/pkg/pf/tests/internal/testprovider/tuple_type.go @@ -62,8 +62,10 @@ func (c TupleType) ApplyTerraform5AttributePathStep(step tftypes.AttributePathSt return c.attr(int(i)), nil } -var _ attr.TypeWithElementTypes = ((*TupleType)(nil)) -var _ pfutils.BlockLike = ((*TupleType)(nil)) +var ( + _ attr.TypeWithElementTypes = ((*TupleType)(nil)) + _ pfutils.BlockLike = ((*TupleType)(nil)) +) func (c TupleType) GetDeprecationMessage() string { return "" } func (c TupleType) GetDescription() string { return "" } diff --git a/pkg/pf/tests/muxwith_test.go b/pkg/pf/tests/muxwith_test.go index ad6dde61e..734f3dc5d 100644 --- a/pkg/pf/tests/muxwith_test.go +++ b/pkg/pf/tests/muxwith_test.go @@ -21,13 +21,14 @@ import ( "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" - pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" "github.com/stretchr/testify/require" + + pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" ) // Add coverage for pf.NewMuxProvider. func TestNewMuxProvider(t *testing.T) { - t.Parallel() + t.Parallel() createCallCount := 0 r := pb.NewResource(pb.NewResourceArgs{ diff --git a/pkg/pf/tests/nested_attr_test.go b/pkg/pf/tests/nested_attr_test.go index 1cac50837..d6cc66729 100644 --- a/pkg/pf/tests/nested_attr_test.go +++ b/pkg/pf/tests/nested_attr_test.go @@ -28,7 +28,7 @@ import ( ) func TestNestedType(t *testing.T) { - t.Parallel() + t.Parallel() ctx := context.Background() info := testprovider.SyntheticTestBridgeProvider() res, err := info.P.(pf.ShimProvider).Resources(ctx) diff --git a/pkg/pf/tests/prestateupgradehook_test.go b/pkg/pf/tests/prestateupgradehook_test.go index d1451c14b..bec8b3e84 100644 --- a/pkg/pf/tests/prestateupgradehook_test.go +++ b/pkg/pf/tests/prestateupgradehook_test.go @@ -18,14 +18,15 @@ import ( "testing" testutils "github.com/pulumi/providertest/replay" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" - tfbridge "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" "github.com/pulumi/pulumi/sdk/v3/go/common/resource" "github.com/stretchr/testify/require" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" + tfbridge "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" ) func TestPreStateUpgradeHook(t *testing.T) { - t.Parallel() + t.Parallel() info := testprovider.RandomProvider() info.Resources["random_string"].PreStateUpgradeHook = func(args tfbridge.PreStateUpgradeHookArgs) (int64, resource.PropertyMap, error) { // Assume that if prior state is missing a schema version marker, it really is a corrupt state at version 2. diff --git a/pkg/pf/tests/provider_check_test.go b/pkg/pf/tests/provider_check_test.go index a768b9826..30fc24d8d 100644 --- a/pkg/pf/tests/provider_check_test.go +++ b/pkg/pf/tests/provider_check_test.go @@ -23,11 +23,11 @@ import ( pschema "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/schema/validator" + testutils "github.com/pulumi/providertest/replay" "github.com/pulumi/pulumi/sdk/v3/go/common/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - testutils "github.com/pulumi/providertest/replay" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" @@ -36,7 +36,7 @@ import ( ) func TestCheck(t *testing.T) { - t.Parallel() + t.Parallel() type testCase struct { name string schema schema.Schema @@ -359,7 +359,7 @@ func TestCheck(t *testing.T) { } func TestCheckWithIntID(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.SyntheticTestBridgeProvider()) require.NoError(t, err) testCase := ` diff --git a/pkg/pf/tests/provider_checkconfig_test.go b/pkg/pf/tests/provider_checkconfig_test.go index a7c2651be..455ae0170 100644 --- a/pkg/pf/tests/provider_checkconfig_test.go +++ b/pkg/pf/tests/provider_checkconfig_test.go @@ -20,22 +20,20 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/provider/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hexops/autogold/v2" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "google.golang.org/protobuf/types/known/structpb" - + testutils "github.com/pulumi/providertest/replay" hostclient "github.com/pulumi/pulumi/pkg/v3/resource/provider" "github.com/pulumi/pulumi/sdk/v3/go/common/resource" "github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin" pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/types/known/structpb" - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" - testutils "github.com/pulumi/providertest/replay" pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" tfbridge0 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" @@ -43,7 +41,7 @@ import ( ) func TestCheckConfig(t *testing.T) { - t.Parallel() + t.Parallel() t.Run("minimal", func(t *testing.T) { schema := schema.Schema{} testutils.Replay(t, makeProviderServer(t, schema), ` @@ -215,7 +213,7 @@ func TestCheckConfig(t *testing.T) { require.NoError(t, err) require.NoError(t, err) require.Equal(t, 1, len(resp.Failures)) - //nolint:lll + autogold.Expect("`testprovider:cofnigValue` is not a valid configuration key for the testprovider provider. Did you mean `testprovider:configValue`? If the referenced key is not intended for the provider, please choose a different namespace from `testprovider:`.").Equal(t, resp.Failures[0].Reason) }) @@ -469,7 +467,7 @@ func TestCheckConfig(t *testing.T) { } func TestPreConfigureCallback(t *testing.T) { - t.Parallel() + t.Parallel() t.Run("PreConfigureCallback called by CheckConfig", func(t *testing.T) { schema := schema.Schema{ Attributes: map[string]schema.Attribute{ diff --git a/pkg/pf/tests/provider_configure_test.go b/pkg/pf/tests/provider_configure_test.go index 0bbdec3b2..c294f2e66 100644 --- a/pkg/pf/tests/provider_configure_test.go +++ b/pkg/pf/tests/provider_configure_test.go @@ -23,14 +23,15 @@ import ( "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/pulumi/providertest/replay" + "github.com/pulumi/pulumi/sdk/v3/go/common/resource" + "github.com/stretchr/testify/require" + "github.com/zclconf/go-cty/cty" + crosstests "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/cross-tests" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" tfpf "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info" - "github.com/pulumi/pulumi/sdk/v3/go/common/resource" - "github.com/stretchr/testify/require" - "github.com/zclconf/go-cty/cty" ) func TestConfigure(t *testing.T) { diff --git a/pkg/pf/tests/provider_create_test.go b/pkg/pf/tests/provider_create_test.go index 6190fa86a..d43305e2e 100644 --- a/pkg/pf/tests/provider_create_test.go +++ b/pkg/pf/tests/provider_create_test.go @@ -20,13 +20,14 @@ import ( "testing" testutils "github.com/pulumi/providertest/replay" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" "github.com/pulumi/pulumi/sdk/v3/go/common/resource" "github.com/stretchr/testify/require" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" ) func TestCreateWithComputedOptionals(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.SyntheticTestBridgeProvider()) require.NoError(t, err) testCase := ` @@ -52,7 +53,7 @@ func TestCreateWithComputedOptionals(t *testing.T) { } func TestCreateWithIntID(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.SyntheticTestBridgeProvider()) require.NoError(t, err) testCase := ` @@ -75,7 +76,7 @@ func TestCreateWithIntID(t *testing.T) { } func TestCreateWritesSchemaVersion(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.RandomProvider()) require.NoError(t, err) @@ -111,7 +112,7 @@ func TestCreateWritesSchemaVersion(t *testing.T) { } func TestPreviewCreate(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.RandomProvider()) require.NoError(t, err) @@ -145,7 +146,7 @@ func TestPreviewCreate(t *testing.T) { } func TestMuxedAliasCreate(t *testing.T) { - t.Parallel() + t.Parallel() server := newMuxedProviderServer(t, testprovider.MuxedRandomProvider()) testCase := func(typ string) string { @@ -185,7 +186,7 @@ func TestMuxedAliasCreate(t *testing.T) { } func TestCreateWithFirstClassSecrets(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.RandomProvider()) require.NoError(t, err) testCase := ` @@ -213,7 +214,7 @@ func TestCreateWithFirstClassSecrets(t *testing.T) { } func TestCreateWithSchemaBasedSecrets(t *testing.T) { - t.Parallel() + t.Parallel() // Ensure that resources that mark output properties as secret in the schema return them as secrets. // RandomPassword is a good example. Surprisingly this test requires a Configure call first, otherwise the // plubming is confused about secrets bits and retursn the wrong result. The test represents production use. @@ -269,7 +270,7 @@ func TestCreateWithSchemaBasedSecrets(t *testing.T) { } func TestCreateSupportsCustomID(t *testing.T) { - t.Parallel() + t.Parallel() p := testprovider.RandomProvider() p.Resources["random_pet"].ComputeID = func( ctx context.Context, state resource.PropertyMap, diff --git a/pkg/pf/tests/provider_diff_test.go b/pkg/pf/tests/provider_diff_test.go index 104011fc3..57537f595 100644 --- a/pkg/pf/tests/provider_diff_test.go +++ b/pkg/pf/tests/provider_diff_test.go @@ -18,13 +18,14 @@ import ( "testing" testutils "github.com/pulumi/providertest/replay" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" "github.com/stretchr/testify/require" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" ) // Test that preview diff in presence of computed attributes results in an empty diff. func TestEmptyTestresDiff(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.SyntheticTestBridgeProvider()) require.NoError(t, err) testCase := ` @@ -54,7 +55,7 @@ func TestEmptyTestresDiff(t *testing.T) { // Test removing an optional input. func TestOptionRemovalTestresDiff(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.SyntheticTestBridgeProvider()) require.NoError(t, err) testCase := ` @@ -88,7 +89,7 @@ func TestOptionRemovalTestresDiff(t *testing.T) { // Make sure optionalInputBoolCopy does not cause non-empty diff when not actually changing. func TestEmptyTestresDiffWithOptionalComputed(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.SyntheticTestBridgeProvider()) require.NoError(t, err) testCase := ` @@ -119,7 +120,7 @@ func TestEmptyTestresDiffWithOptionalComputed(t *testing.T) { } func TestDiffWithSecrets(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.RandomProvider()) require.NoError(t, err) @@ -163,7 +164,7 @@ func TestDiffWithSecrets(t *testing.T) { // See https://github.com/pulumi/pulumi-random/issues/258 func TestDiffVersionUpgrade(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.RandomProvider()) require.NoError(t, err) testCase := ` @@ -208,7 +209,7 @@ func TestDiffVersionUpgrade(t *testing.T) { } func TestSetNestedObjectAdded(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.SyntheticTestBridgeProvider()) require.NoError(t, err) testCase := ` @@ -259,7 +260,7 @@ func TestSetNestedObjectAdded(t *testing.T) { } func TestSetNestedObjectAddedOtherDiff(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.SyntheticTestBridgeProvider()) require.NoError(t, err) testCase := ` diff --git a/pkg/pf/tests/provider_get_mapping_test.go b/pkg/pf/tests/provider_get_mapping_test.go index d92977c98..39d8dfd96 100644 --- a/pkg/pf/tests/provider_get_mapping_test.go +++ b/pkg/pf/tests/provider_get_mapping_test.go @@ -19,6 +19,7 @@ import ( "encoding/json" "testing" + "github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin" pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -26,11 +27,10 @@ import ( "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" tfbridge0 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" - "github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin" ) func TestGetMapping(t *testing.T) { - t.Parallel() + t.Parallel() ctx := context.Background() info := testprovider.RandomProvider() @@ -88,7 +88,7 @@ func TestGetMapping(t *testing.T) { } func TestMuxedGetMapping(t *testing.T) { - t.Parallel() + t.Parallel() ctx := context.Background() info := testprovider.MuxedRandomProvider() diff --git a/pkg/pf/tests/provider_init_benchmark_test.go b/pkg/pf/tests/provider_init_benchmark_test.go index 22b0d690a..337807f9f 100644 --- a/pkg/pf/tests/provider_init_benchmark_test.go +++ b/pkg/pf/tests/provider_init_benchmark_test.go @@ -2,10 +2,11 @@ package tfbridgetests import ( "fmt" + "testing" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider/sdkv2randomprovider" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" - "testing" ) // Benchmark tests based on init of an example large provider diff --git a/pkg/pf/tests/provider_invoke_test.go b/pkg/pf/tests/provider_invoke_test.go index 32b625484..4a1114992 100644 --- a/pkg/pf/tests/provider_invoke_test.go +++ b/pkg/pf/tests/provider_invoke_test.go @@ -18,12 +18,13 @@ import ( "testing" testutils "github.com/pulumi/providertest/replay" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" "github.com/stretchr/testify/require" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" ) func TestBasicInvoke(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.TLSProvider()) require.NoError(t, err) @@ -64,7 +65,7 @@ func TestBasicInvoke(t *testing.T) { } func TestInvokeWithInvalidData(t *testing.T) { - t.Parallel() + t.Parallel() p := testprovider.TLSProvider() server, err := newProviderServer(t, p) require.NoError(t, err) diff --git a/pkg/pf/tests/provider_nested_custom_types_test.go b/pkg/pf/tests/provider_nested_custom_types_test.go index f35b96e34..01ab4307a 100644 --- a/pkg/pf/tests/provider_nested_custom_types_test.go +++ b/pkg/pf/tests/provider_nested_custom_types_test.go @@ -14,16 +14,17 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/stretchr/testify/assert" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/convert" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" tfbridge0 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" - "github.com/stretchr/testify/assert" ) func TestNestedCustomTypeEncoding(t *testing.T) { - t.Parallel() + t.Parallel() testProvider := pb.NewProvider(pb.NewProviderArgs{ // This resource is modified from AWS Bedrockagent. @@ -31,23 +32,23 @@ func TestNestedCustomTypeEncoding(t *testing.T) { pb.NewResource(pb.NewResourceArgs{ Name: "bedrockagent", ResourceSchema: schema.Schema{ - Attributes: map[string]schema.Attribute{ - "prompt_override_configuration": schema.ListAttribute{ // proto5 Optional+Computed nested block. - CustomType: NewListNestedObjectTypeOf[promptOverrideConfigurationModel](context.Background()), - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.List{ - listplanmodifier.UseStateForUnknown(), - }, - Validators: []validator.List{ - listvalidator.SizeAtMost(1), - }, - ElementType: basetypes.ObjectType{ - AttrTypes: AttributeTypesMust[promptOverrideConfigurationModel](context.Background()), + Attributes: map[string]schema.Attribute{ + "prompt_override_configuration": schema.ListAttribute{ // proto5 Optional+Computed nested block. + CustomType: NewListNestedObjectTypeOf[promptOverrideConfigurationModel](context.Background()), + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.List{ + listplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.List{ + listvalidator.SizeAtMost(1), + }, + ElementType: basetypes.ObjectType{ + AttrTypes: AttributeTypesMust[promptOverrideConfigurationModel](context.Background()), + }, }, }, }, - }, }), }, }) @@ -150,6 +151,7 @@ func (setNested SetNestedObjectValueOf[T]) Equal(o attr.Value) bool { func (setNested SetNestedObjectValueOf[T]) Type(ctx context.Context) attr.Type { return NewSetNestedObjectTypeOf[T](ctx) } + func NewSetNestedObjectTypeOf[T any](ctx context.Context) SetNestedObjectTypeOf[T] { return SetNestedObjectTypeOf[T]{basetypes.SetType{ElemType: NewObjectTypeOf[T](ctx)}} } diff --git a/pkg/pf/tests/provider_read_test.go b/pkg/pf/tests/provider_read_test.go index a99d80c24..6012f9b91 100644 --- a/pkg/pf/tests/provider_read_test.go +++ b/pkg/pf/tests/provider_read_test.go @@ -22,17 +22,18 @@ import ( fwres "github.com/hashicorp/terraform-plugin-framework/resource" fwsch "github.com/hashicorp/terraform-plugin-framework/resource/schema" testutils "github.com/pulumi/providertest/replay" + "github.com/pulumi/pulumi/sdk/v3/go/common/resource" + "github.com/stretchr/testify/require" + pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" tfpf "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info" - "github.com/pulumi/pulumi/sdk/v3/go/common/resource" - "github.com/stretchr/testify/require" ) func TestReadFromRefresh(t *testing.T) { - t.Parallel() + t.Parallel() // This test case was obtained by running `pulumi refresh` on a simple stack with one RandomPassword. // // Specifically testing for: @@ -151,7 +152,7 @@ func TestReadFromRefresh(t *testing.T) { } func TestImportRandomPassword(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.RandomProvider()) require.NoError(t, err) testCase := ` @@ -194,7 +195,7 @@ func TestImportRandomPassword(t *testing.T) { } func TestImportingResourcesWithBlocks(t *testing.T) { - t.Parallel() + t.Parallel() // Importing a resource that has blocks such as Testnest resource used to panic. Ensure that it minimally // succeeds. server, err := newProviderServer(t, testprovider.SyntheticTestBridgeProvider()) @@ -225,7 +226,7 @@ func TestImportingResourcesWithBlocks(t *testing.T) { } func TestImportingResourcesWithoutDefaults(t *testing.T) { - t.Parallel() + t.Parallel() // Importing a resource that has blocks used to add a `__defaults: []` entry to the `response.inputs` // ensure that it no longer does so server, err := newProviderServer(t, testprovider.SyntheticTestBridgeProvider()) @@ -264,7 +265,7 @@ func TestImportingResourcesWithoutDefaults(t *testing.T) { // Check that importing a resource that does not exist returns an empty property bag and // no ID. func TestImportingMissingResources(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.SyntheticTestBridgeProvider()) require.NoError(t, err) testCase := ` @@ -284,7 +285,7 @@ func TestImportingMissingResources(t *testing.T) { } func TestImportingResourcesWithNestedAttributes(t *testing.T) { - t.Parallel() + t.Parallel() // Importing a resource that has attribute blocks such as Testnest resource used to panic. Ensure that it minimally // succeeds. server, err := newProviderServer(t, testprovider.SyntheticTestBridgeProvider()) @@ -312,7 +313,7 @@ func TestImportingResourcesWithNestedAttributes(t *testing.T) { // Check that refreshing a resource that does not exist returns an empty property bag and // no ID. func TestRefreshMissingResources(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.SyntheticTestBridgeProvider()) require.NoError(t, err) testCase := ` @@ -343,7 +344,7 @@ func TestRefreshMissingResources(t *testing.T) { // // See https://github.com/pulumi/pulumi-terraform-bridge/issues/1919 func TestRefreshResourceNotFound(t *testing.T) { - t.Parallel() + t.Parallel() r := pb.NewResource(pb.NewResourceArgs{ Name: "resource", ResourceSchema: fwsch.Schema{ @@ -408,7 +409,7 @@ func TestRefreshResourceNotFound(t *testing.T) { } func TestRefreshSupportsCustomID(t *testing.T) { - t.Parallel() + t.Parallel() p := testprovider.RandomProvider() server, err := newProviderServer(t, p) require.NoError(t, err) @@ -510,7 +511,7 @@ func TestRefreshSupportsCustomID(t *testing.T) { } func TestImportSupportsCustomID(t *testing.T) { - t.Parallel() + t.Parallel() p := testprovider.RandomProvider() p.Resources["random_password"].ComputeID = func( ctx context.Context, state resource.PropertyMap, diff --git a/pkg/pf/tests/provider_transform_outputs_test.go b/pkg/pf/tests/provider_transform_outputs_test.go index 18f529b20..ecaa463f6 100644 --- a/pkg/pf/tests/provider_transform_outputs_test.go +++ b/pkg/pf/tests/provider_transform_outputs_test.go @@ -20,18 +20,18 @@ import ( "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/tfsdk" + testutils "github.com/pulumi/providertest/replay" "github.com/pulumi/pulumi/sdk/v3/go/common/resource" pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - testutils "github.com/pulumi/providertest/replay" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" ) func TestTransformOutputs(t *testing.T) { - t.Parallel() + t.Parallel() p := testprovider.SyntheticTestBridgeProvider() p.Resources["testbridge_testcompres"].TransformOutputs = func( @@ -152,7 +152,7 @@ func TestTransformOutputs(t *testing.T) { } func TestTransformFromState(t *testing.T) { - t.Parallel() + t.Parallel() provider := func(t *testing.T) pulumirpc.ResourceProviderServer { p := testprovider.AssertProvider(func(config tfsdk.Config, old, new *tfsdk.State) { // GetRawState is not available during deletes. diff --git a/pkg/pf/tests/provider_update_test.go b/pkg/pf/tests/provider_update_test.go index 2d1562328..09c3e6161 100644 --- a/pkg/pf/tests/provider_update_test.go +++ b/pkg/pf/tests/provider_update_test.go @@ -18,12 +18,13 @@ import ( "testing" testutils "github.com/pulumi/providertest/replay" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" "github.com/stretchr/testify/require" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" ) func TestUpdateWritesSchemaVersion(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.RandomProvider()) require.NoError(t, err) testutils.Replay(t, server, ` @@ -63,7 +64,7 @@ func TestUpdateWritesSchemaVersion(t *testing.T) { } func TestUpdateWithIntID(t *testing.T) { - t.Parallel() + t.Parallel() server, err := newProviderServer(t, testprovider.SyntheticTestBridgeProvider()) require.NoError(t, err) testCase := ` diff --git a/pkg/pf/tests/pulcheck/pulcheck.go b/pkg/pf/tests/pulcheck/pulcheck.go index cfbcc3f43..e7b785832 100644 --- a/pkg/pf/tests/pulcheck/pulcheck.go +++ b/pkg/pf/tests/pulcheck/pulcheck.go @@ -11,17 +11,18 @@ import ( "github.com/pulumi/providertest/providers" "github.com/pulumi/providertest/pulumitest" "github.com/pulumi/providertest/pulumitest/opttest" - crosstestsimpl "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests/impl" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfgen" - tfbridge0 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info" "github.com/pulumi/pulumi/sdk/v3/go/common/diag" "github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors" "github.com/pulumi/pulumi/sdk/v3/go/common/util/rpcutil" pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go" "github.com/stretchr/testify/require" "google.golang.org/grpc" + + crosstestsimpl "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests/impl" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfgen" + tfbridge0 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info" ) type T = crosstestsimpl.T diff --git a/pkg/pf/tests/pulumi_test.go b/pkg/pf/tests/pulumi_test.go index b21b61a2e..f014b8452 100644 --- a/pkg/pf/tests/pulumi_test.go +++ b/pkg/pf/tests/pulumi_test.go @@ -21,12 +21,13 @@ import ( "github.com/hashicorp/terraform-plugin-framework/provider" sdkv2schema "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/pulumi/providertest/pulumitest" + "github.com/stretchr/testify/require" + pf "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/tokens" sdkv2shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2" - "github.com/stretchr/testify/require" ) // Quick setup for integration-testing PF-based providers. diff --git a/pkg/pf/tests/schema_and_program_test.go b/pkg/pf/tests/schema_and_program_test.go index f43b9dcad..5b1022ab7 100644 --- a/pkg/pf/tests/schema_and_program_test.go +++ b/pkg/pf/tests/schema_and_program_test.go @@ -17,15 +17,16 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/pulumi/pulumi/sdk/v3/go/auto/optpreview" + presource "github.com/pulumi/pulumi/sdk/v3/go/common/resource" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/pulcheck" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info" - "github.com/pulumi/pulumi/sdk/v3/go/auto/optpreview" - presource "github.com/pulumi/pulumi/sdk/v3/go/common/resource" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestBasic(t *testing.T) { diff --git a/pkg/pf/tests/schema_test.go b/pkg/pf/tests/schema_test.go index 9c2b0ba41..998dfcb24 100644 --- a/pkg/pf/tests/schema_test.go +++ b/pkg/pf/tests/schema_test.go @@ -17,22 +17,20 @@ package tfbridgetests import ( "encoding/json" "os" + "runtime" "testing" + "github.com/pulumi/pulumi/pkg/v3/codegen/schema" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/pulumi/pulumi/pkg/v3/codegen/schema" - - "runtime" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/testprovider" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen" ) func TestSchemaGen(t *testing.T) { - t.Parallel() + t.Parallel() t.Run("random", func(t *testing.T) { _, err := genMetadata(t, testprovider.RandomProvider()) require.NoError(t, err) @@ -71,7 +69,7 @@ func TestSchemaGen(t *testing.T) { } func TestSchemaGenInSync(t *testing.T) { - t.Parallel() + t.Parallel() if runtime.GOOS == "windows" { t.Skip("Skipping on Windows due to a minor path discrepancy in actual vs generated schema") } @@ -149,5 +147,4 @@ func TestSchemaGenInSync(t *testing.T) { tc.name) }) } - } diff --git a/pkg/pf/tests/schemas.go b/pkg/pf/tests/schemas.go index bad241e89..52bcb5cec 100644 --- a/pkg/pf/tests/schemas.go +++ b/pkg/pf/tests/schemas.go @@ -21,10 +21,9 @@ import ( "strings" "testing" - "github.com/stretchr/testify/require" - "github.com/pulumi/pulumi/sdk/v3/go/common/diag" "github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors" + "github.com/stretchr/testify/require" tfpf "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfgen" diff --git a/pkg/pf/tests/schemashim_test.go b/pkg/pf/tests/schemashim_test.go index 6e3115c25..b1ec66b35 100644 --- a/pkg/pf/tests/schemashim_test.go +++ b/pkg/pf/tests/schemashim_test.go @@ -35,19 +35,20 @@ import ( "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hexops/autogold/v2" + "github.com/pulumi/pulumi/sdk/v3/go/common/diag" + "github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors" + "github.com/pulumi/pulumi/sdk/v3/go/common/tokens" + "github.com/stretchr/testify/require" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/internal/schemashim" pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen" - "github.com/pulumi/pulumi/sdk/v3/go/common/diag" - "github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors" - "github.com/pulumi/pulumi/sdk/v3/go/common/tokens" - "github.com/stretchr/testify/require" ) func TestShimBoolAttr(t *testing.T) { - t.Parallel() + t.Parallel() checkShim(t, shimTestCase{ stdProvider(schema.Schema{ Attributes: map[string]schema.Attribute{ @@ -92,7 +93,7 @@ func TestShimBoolAttr(t *testing.T) { } func TestShimStringAttr(t *testing.T) { - t.Parallel() + t.Parallel() checkShim(t, shimTestCase{ stdProvider(schema.Schema{ Attributes: map[string]schema.Attribute{ @@ -137,7 +138,7 @@ func TestShimStringAttr(t *testing.T) { } func TestShimNumberAttr(t *testing.T) { - t.Parallel() + t.Parallel() checkShim(t, shimTestCase{ stdProvider(schema.Schema{ Attributes: map[string]schema.Attribute{ @@ -182,7 +183,7 @@ func TestShimNumberAttr(t *testing.T) { } func TestShimListOfStringAttr(t *testing.T) { - t.Parallel() + t.Parallel() checkShim(t, shimTestCase{ stdProvider(schema.Schema{ Attributes: map[string]schema.Attribute{ @@ -244,7 +245,7 @@ func TestShimListOfStringAttr(t *testing.T) { } func TestShimMapOfStringAttr(t *testing.T) { - t.Parallel() + t.Parallel() checkShim(t, shimTestCase{ stdProvider(schema.Schema{ Attributes: map[string]schema.Attribute{ @@ -306,7 +307,7 @@ func TestShimMapOfStringAttr(t *testing.T) { } func TestShimSetOfStringAttr(t *testing.T) { - t.Parallel() + t.Parallel() checkShim(t, shimTestCase{ stdProvider(schema.Schema{ Attributes: map[string]schema.Attribute{ @@ -368,7 +369,7 @@ func TestShimSetOfStringAttr(t *testing.T) { } func TestShimListNestedAttr(t *testing.T) { - t.Parallel() + t.Parallel() checkShim(t, shimTestCase{ stdProvider(schema.Schema{ Attributes: map[string]schema.Attribute{ @@ -451,7 +452,7 @@ func TestShimListNestedAttr(t *testing.T) { } func TestShimSetNestedAttr(t *testing.T) { - t.Parallel() + t.Parallel() checkShim(t, shimTestCase{ stdProvider(schema.Schema{ Attributes: map[string]schema.Attribute{ @@ -534,7 +535,7 @@ func TestShimSetNestedAttr(t *testing.T) { } func TestShimMapNestedAttr(t *testing.T) { - t.Parallel() + t.Parallel() checkShim(t, shimTestCase{ stdProvider(schema.Schema{ Attributes: map[string]schema.Attribute{ @@ -617,7 +618,7 @@ func TestShimMapNestedAttr(t *testing.T) { } func TestShimSingleNestedAttr(t *testing.T) { - t.Parallel() + t.Parallel() checkShim(t, shimTestCase{ stdProvider(schema.Schema{ Attributes: map[string]schema.Attribute{ @@ -684,7 +685,7 @@ func TestShimSingleNestedAttr(t *testing.T) { } func TestShimObjectAttr(t *testing.T) { - t.Parallel() + t.Parallel() checkShim(t, shimTestCase{ stdProvider(schema.Schema{ Attributes: map[string]schema.Attribute{ @@ -753,7 +754,7 @@ func TestShimObjectAttr(t *testing.T) { } func TestShimDynamicAttr(t *testing.T) { - t.Parallel() + t.Parallel() checkShim(t, shimTestCase{ stdProvider(schema.Schema{ Attributes: map[string]schema.Attribute{ @@ -800,7 +801,7 @@ func TestShimDynamicAttr(t *testing.T) { } func TestShimSingleNestedBlock(t *testing.T) { - t.Parallel() + t.Parallel() checkShim(t, shimTestCase{ stdProvider(schema.Schema{ Blocks: map[string]schema.Block{ @@ -866,7 +867,7 @@ func TestShimSingleNestedBlock(t *testing.T) { } func TestShimListNestedBlock(t *testing.T) { - t.Parallel() + t.Parallel() checkShim(t, shimTestCase{ stdProvider(schema.Schema{ Blocks: map[string]schema.Block{ @@ -945,7 +946,7 @@ func TestShimListNestedBlock(t *testing.T) { // The bridge attempts some heuristics to infer listvalidator.SizeAtMost(1) and apply flattening. It is unclear how // often it is used but there are non-0 actual examples, such as data_storage on elasticache serverless_cache in AWS. func TestShimListNestedFlattenedBlock(t *testing.T) { - t.Parallel() + t.Parallel() checkShim(t, shimTestCase{ stdProvider(schema.Schema{ Blocks: map[string]schema.Block{ @@ -1017,7 +1018,7 @@ func TestShimListNestedFlattenedBlock(t *testing.T) { } func TestShimSetNestedBlock(t *testing.T) { - t.Parallel() + t.Parallel() checkShim(t, shimTestCase{ stdProvider(schema.Schema{ Blocks: map[string]schema.Block{ diff --git a/pkg/pf/tests/tfgen_test.go b/pkg/pf/tests/tfgen_test.go index db6fb20f4..e89784f9c 100644 --- a/pkg/pf/tests/tfgen_test.go +++ b/pkg/pf/tests/tfgen_test.go @@ -20,16 +20,17 @@ import ( "os" "testing" + "github.com/pulumi/pulumi/sdk/v3/go/common/diag" + "github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors" + "github.com/pulumi/pulumi/sdk/v3/go/common/tokens" + "github.com/stretchr/testify/require" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/internal/muxer" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen" helper "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/schema" - "github.com/pulumi/pulumi/sdk/v3/go/common/diag" - "github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors" - "github.com/pulumi/pulumi/sdk/v3/go/common/tokens" - "github.com/stretchr/testify/require" ) func TestRenameResourceWithAliasInAugmentedProvider(t *testing.T) { diff --git a/pkg/pf/tests/util.go b/pkg/pf/tests/util.go index 967084135..044c662b4 100644 --- a/pkg/pf/tests/util.go +++ b/pkg/pf/tests/util.go @@ -18,9 +18,8 @@ import ( "context" "testing" - "github.com/stretchr/testify/require" - pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go" + "github.com/stretchr/testify/require" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" diff --git a/pkg/pf/tfbridge/detect_check_failures.go b/pkg/pf/tfbridge/detect_check_failures.go index 024bca459..4e4ce39fd 100644 --- a/pkg/pf/tfbridge/detect_check_failures.go +++ b/pkg/pf/tfbridge/detect_check_failures.go @@ -86,7 +86,6 @@ func formatAttributePathAsPropertyPath( } p := tfbridge.NewCheckFailurePath(schemaMap, schemaInfos, string(n)) for _, s := range steps[1:] { - switch s := s.(type) { case tftypes.AttributeName: p = p.Attribute(string(s)) @@ -99,7 +98,6 @@ func formatAttributePathAsPropertyPath( default: contract.Failf("Unhandled match case for tftypes.AttributePathStep") } - } return p, nil } diff --git a/pkg/pf/tfbridge/detect_check_failures_test.go b/pkg/pf/tfbridge/detect_check_failures_test.go index 33872ae6c..3f007c10e 100644 --- a/pkg/pf/tfbridge/detect_check_failures_test.go +++ b/pkg/pf/tfbridge/detect_check_failures_test.go @@ -25,7 +25,7 @@ import ( ) func TestDetectCheckFailures(t *testing.T) { - t.Parallel() + t.Parallel() ctx := context.Background() p := &provider{} urn := resource.NewURN("stack", "project", "", "typ", "name") diff --git a/pkg/pf/tfbridge/main.go b/pkg/pf/tfbridge/main.go index b6b011c70..372588ce2 100644 --- a/pkg/pf/tfbridge/main.go +++ b/pkg/pf/tfbridge/main.go @@ -127,7 +127,6 @@ func MainWithMuxer(ctx context.Context, pkg string, info tfbridge.ProviderInfo, func MakeMuxedServer( ctx context.Context, pkg string, info tfbridge.ProviderInfo, schema []byte, ) func(host *rprovider.HostClient) (pulumirpc.ResourceProviderServer, error) { - shim, ok := info.P.(*pfmuxer.ProviderShim) contract.Assertf(ok, "MainWithMuxer must have a ProviderInfo.P created with AugmentShimWithPF") _, err := shim.ResolveDispatch(&info) @@ -175,12 +174,14 @@ func MakeMuxedServer( infoCopy.P = prov return NewProviderServer(ctx, host, infoCopy, ProviderMetadata{PackageSchema: schema}) - }}) + }, + }) default: m.Servers = append(m.Servers, muxer.Endpoint{ Server: func(host *rprovider.HostClient) (pulumirpc.ResourceProviderServer, error) { return tfbridge.NewProvider(ctx, host, pkg, version, prov, info, schema), nil - }}) + }, + }) } } return m.Server(host, pkg, version) diff --git a/pkg/pf/tfbridge/provider.go b/pkg/pf/tfbridge/provider.go index bed8dcd5c..1e51ee815 100644 --- a/pkg/pf/tfbridge/provider.go +++ b/pkg/pf/tfbridge/provider.go @@ -93,7 +93,8 @@ func ShimProviderWithContext(ctx context.Context, p pfprovider.Provider) shim.Pr } func newProviderWithContext(ctx context.Context, info tfbridge.ProviderInfo, - meta ProviderMetadata) (configencoding.Provider[*provider], error) { + meta ProviderMetadata, +) (configencoding.Provider[*provider], error) { const infoPErrMSg string = "info.P must be constructed with ShimProvider or ShimProviderWithContext" if info.P == nil { @@ -273,7 +274,8 @@ func (p *provider) terraformDatasourceName(functionToken tokens.ModuleMember) (s // NOT IMPLEMENTED: Call dynamically executes a method in the provider associated with a component resource. func (p *provider) CallWithContext(_ context.Context, tok tokens.ModuleMember, args resource.PropertyMap, info plugin.CallInfo, - options plugin.CallOptions) (plugin.CallResult, error) { + options plugin.CallOptions, +) (plugin.CallResult, error) { return plugin.CallResult{}, fmt.Errorf("Call is not implemented for Terraform Plugin Framework bridged providers") } @@ -281,7 +283,8 @@ func (p *provider) CallWithContext(_ context.Context, // NOT IMPLEMENTED: Construct creates a new component resource. func (p *provider) ConstructWithContext(_ context.Context, info plugin.ConstructInfo, typ tokens.Type, name tokens.QName, parent resource.URN, - inputs resource.PropertyMap, options plugin.ConstructOptions) (plugin.ConstructResult, error) { + inputs resource.PropertyMap, options plugin.ConstructOptions, +) (plugin.ConstructResult, error) { return plugin.ConstructResult{}, fmt.Errorf("Construct is not implemented for Terraform Plugin Framework bridged providers") } diff --git a/pkg/pf/tfbridge/provider_check.go b/pkg/pf/tfbridge/provider_check.go index 5012aa507..77cae635a 100644 --- a/pkg/pf/tfbridge/provider_check.go +++ b/pkg/pf/tfbridge/provider_check.go @@ -95,7 +95,6 @@ func (p *provider) validateResourceConfig( rh resourceHandle, inputs resource.PropertyMap, ) ([]plugin.CheckFailure, error) { - tfType := rh.schema.Type(ctx).(tftypes.Object) encodedInputs, err := convert.EncodePropertyMapToDynamic(rh.encoder, tfType, inputs) diff --git a/pkg/pf/tfbridge/provider_delete.go b/pkg/pf/tfbridge/provider_delete.go index f114abc65..7994ebdd9 100644 --- a/pkg/pf/tfbridge/provider_delete.go +++ b/pkg/pf/tfbridge/provider_delete.go @@ -33,7 +33,6 @@ func (p *provider) DeleteWithContext( outputs resource.PropertyMap, timeout float64, ) (resource.Status, error) { - ctx = p.initLogging(ctx, p.logSink, urn) rh, err := p.resourceHandle(ctx, urn) diff --git a/pkg/pf/tfbridge/provider_diff_test.go b/pkg/pf/tfbridge/provider_diff_test.go index 913d5c8bb..6c7301e8d 100644 --- a/pkg/pf/tfbridge/provider_diff_test.go +++ b/pkg/pf/tfbridge/provider_diff_test.go @@ -26,7 +26,7 @@ import ( ) func TestTopLevelPropertyKeySet(t *testing.T) { - t.Parallel() + t.Parallel() str := (&schema.Schema{ Type: shim.TypeString, }).Shim() diff --git a/pkg/pf/tfbridge/provider_get_mapping.go b/pkg/pf/tfbridge/provider_get_mapping.go index 6374a5f81..965a318a2 100644 --- a/pkg/pf/tfbridge/provider_get_mapping.go +++ b/pkg/pf/tfbridge/provider_get_mapping.go @@ -33,7 +33,6 @@ func (p *provider) GetMappingWithContext(ctx context.Context, key, provider stri // The prototype converter uses the key "tf", but the new plugin converter uses "terraform". For now support // both, eventually we can remove the "tf" key. if key == "tf" || key == "terraform" { - // The provider key should either be empty (old engines) or the name of the provider we support (new engines) if provider != "" && provider != mapped { return nil, "", fmt.Errorf("unknown provider %q", provider) diff --git a/pkg/pf/tfbridge/provider_info_test.go b/pkg/pf/tfbridge/provider_info_test.go index 51cdcbf1f..e9b9e13ad 100644 --- a/pkg/pf/tfbridge/provider_info_test.go +++ b/pkg/pf/tfbridge/provider_info_test.go @@ -21,7 +21,7 @@ import ( ) func TestSetAutoNamingDoesNotPanic(t *testing.T) { - t.Parallel() + t.Parallel() prov := tfbridge.ProviderInfo{ P: nil, Resources: map[string]*tfbridge.ResourceInfo{ diff --git a/pkg/pf/tfbridge/provider_invoke.go b/pkg/pf/tfbridge/provider_invoke.go index 74c55f972..01257be7c 100644 --- a/pkg/pf/tfbridge/provider_invoke.go +++ b/pkg/pf/tfbridge/provider_invoke.go @@ -68,7 +68,8 @@ func (p *provider) InvokeWithContext( } func (p *provider) validateDataResourceConfig(ctx context.Context, handle datasourceHandle, - config *tfprotov6.DynamicValue) ([]plugin.CheckFailure, error) { + config *tfprotov6.DynamicValue, +) ([]plugin.CheckFailure, error) { req := &tfprotov6.ValidateDataResourceConfigRequest{ TypeName: handle.terraformDataSourceName, Config: config, @@ -81,8 +82,8 @@ func (p *provider) validateDataResourceConfig(ctx context.Context, handle dataso } func (p *provider) readDataSource(ctx context.Context, handle datasourceHandle, - config *tfprotov6.DynamicValue) (resource.PropertyMap, []plugin.CheckFailure, error) { - + config *tfprotov6.DynamicValue, +) (resource.PropertyMap, []plugin.CheckFailure, error) { typ := handle.schema.Type(ctx).(tftypes.Object) req := &tfprotov6.ReadDataSourceRequest{ @@ -126,7 +127,8 @@ func (p *provider) readDataSource(ctx context.Context, handle datasourceHandle, } func (p *provider) processInvokeDiagnostics(ds datasourceHandle, - diags []*tfprotov6.Diagnostic) ([]plugin.CheckFailure, error) { + diags []*tfprotov6.Diagnostic, +) ([]plugin.CheckFailure, error) { failures, rest := p.parseInvokePropertyCheckFailures(ds, diags) return failures, p.processDiagnostics(rest) } @@ -134,7 +136,8 @@ func (p *provider) processInvokeDiagnostics(ds datasourceHandle, // Some of the diagnostics pertain to an individual property and should be returned as plugin.CheckFailure for an // optimal rendering by Pulumi CLI. func (p *provider) parseInvokePropertyCheckFailures(ds datasourceHandle, diags []*tfprotov6.Diagnostic) ( - []plugin.CheckFailure, []*tfprotov6.Diagnostic) { + []plugin.CheckFailure, []*tfprotov6.Diagnostic, +) { rest := []*tfprotov6.Diagnostic{} failures := []plugin.CheckFailure{} diff --git a/pkg/pf/tfbridge/provider_read.go b/pkg/pf/tfbridge/provider_read.go index abe8ff491..16e9e9d99 100644 --- a/pkg/pf/tfbridge/provider_read.go +++ b/pkg/pf/tfbridge/provider_read.go @@ -125,7 +125,6 @@ func (p *provider) readResource( rh *resourceHandle, currentStateMap resource.PropertyMap, ) (plugin.ReadResult, error) { - currentStateRaw, err := parseResourceState(rh, currentStateMap) if err != nil { return plugin.ReadResult{}, fmt.Errorf("failed to get current raw state: %w", err) diff --git a/pkg/pf/tfbridge/provider_read_test.go b/pkg/pf/tfbridge/provider_read_test.go index 787637829..fc4069179 100644 --- a/pkg/pf/tfbridge/provider_read_test.go +++ b/pkg/pf/tfbridge/provider_read_test.go @@ -8,7 +8,7 @@ import ( ) func TestDeleteNestedDefaults(t *testing.T) { - t.Parallel() + t.Parallel() tests := []struct { name string inputs resource.PropertyMap diff --git a/pkg/pf/tfbridge/provider_streaminvoke.go b/pkg/pf/tfbridge/provider_streaminvoke.go index 6a619b82f..97146556b 100644 --- a/pkg/pf/tfbridge/provider_streaminvoke.go +++ b/pkg/pf/tfbridge/provider_streaminvoke.go @@ -24,6 +24,7 @@ import ( func (p *provider) StreamInvokeWithContext(_ context.Context, tok tokens.ModuleMember, args resource.PropertyMap, - onNext func(resource.PropertyMap) error) ([]plugin.CheckFailure, error) { + onNext func(resource.PropertyMap) error, +) ([]plugin.CheckFailure, error) { panic("StreamInvoke() should not be called for bridged providers") } diff --git a/pkg/pf/tfbridge/provider_test.go b/pkg/pf/tfbridge/provider_test.go index 6d2cd0ed4..27889dd99 100644 --- a/pkg/pf/tfbridge/provider_test.go +++ b/pkg/pf/tfbridge/provider_test.go @@ -24,7 +24,7 @@ import ( ) func TestTerraformResourceName(t *testing.T) { - t.Parallel() + t.Parallel() urn := resource.URN("urn:pulumi:dev::stack1::random:index/randomInteger:RandomInteger::priority") p := &provider{ info: tfbridge.ProviderInfo{ diff --git a/pkg/pf/tfbridge/resource_state_test.go b/pkg/pf/tfbridge/resource_state_test.go index ce85c4d33..45fc60dbe 100644 --- a/pkg/pf/tfbridge/resource_state_test.go +++ b/pkg/pf/tfbridge/resource_state_test.go @@ -23,7 +23,7 @@ import ( ) func TestParseResourceStateFromTFInner(t *testing.T) { - t.Parallel() + t.Parallel() ctx := context.Background() ty := tftypes.Object{ diff --git a/pkg/pf/tfgen/tfgen_test.go b/pkg/pf/tfgen/tfgen_test.go index 7dcb5be69..413ebd7fb 100644 --- a/pkg/pf/tfgen/tfgen_test.go +++ b/pkg/pf/tfgen/tfgen_test.go @@ -41,7 +41,7 @@ import ( // Regressing an issue with AWS provider not recognizing that assume_role config setting is singular via // listvalidator.SizeAtMost(1). func TestMaxItemsOne(t *testing.T) { - t.Parallel() + t.Parallel() ctx := context.Background() s := pschema.Schema{ Blocks: map[string]pschema.Block{ diff --git a/pkg/tests/acc_secrets_test.go b/pkg/tests/acc_secrets_test.go index e83280eb2..e82fedafa 100644 --- a/pkg/tests/acc_secrets_test.go +++ b/pkg/tests/acc_secrets_test.go @@ -15,9 +15,8 @@ package tests import ( - "testing" - "encoding/json" + "testing" "github.com/pulumi/pulumi/pkg/v3/testing/integration" "github.com/stretchr/testify/assert" diff --git a/pkg/tests/configure_test.go b/pkg/tests/configure_test.go index e6a1397bb..f8a0efbf8 100644 --- a/pkg/tests/configure_test.go +++ b/pkg/tests/configure_test.go @@ -7,9 +7,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/stretchr/testify/require" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/tfcheck" - "github.com/stretchr/testify/require" ) func TestConfigureGetRawConfigDoesNotPanic(t *testing.T) { diff --git a/pkg/tests/custom_timeout_test.go b/pkg/tests/custom_timeout_test.go index 40b94ae27..98f1d252c 100644 --- a/pkg/tests/custom_timeout_test.go +++ b/pkg/tests/custom_timeout_test.go @@ -8,12 +8,12 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/tfcheck" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" -) + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/tfcheck" +) func TestCreateCustomTimeoutsCrossTest(t *testing.T) { t.Parallel() @@ -149,4 +149,4 @@ resource "prov_test" "mainRes" { test(t, tc.schemaCreateTimeout, tc.programTimeout, tc.expected, tc.expectFail) }) } -} \ No newline at end of file +} diff --git a/pkg/tests/detailed_diff_set_test.go b/pkg/tests/detailed_diff_set_test.go index 3566b7c7d..d5d3521aa 100644 --- a/pkg/tests/detailed_diff_set_test.go +++ b/pkg/tests/detailed_diff_set_test.go @@ -12,10 +12,11 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hexops/autogold/v2" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/tfcheck" "github.com/pulumi/pulumi/sdk/v3/go/auto/optpreview" "github.com/stretchr/testify/require" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/tfcheck" ) func runDetailedDiffTest( diff --git a/pkg/tests/detailed_diff_test.go b/pkg/tests/detailed_diff_test.go index 5d29af76c..02ec3d26d 100644 --- a/pkg/tests/detailed_diff_test.go +++ b/pkg/tests/detailed_diff_test.go @@ -12,10 +12,11 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hexops/autogold/v2" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info" "github.com/pulumi/pulumi/sdk/v3/go/auto/optpreview" "github.com/stretchr/testify/require" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info" ) func TestUnknownHandling(t *testing.T) { diff --git a/pkg/tests/import_test.go b/pkg/tests/import_test.go index c12c9d637..0fef78674 100644 --- a/pkg/tests/import_test.go +++ b/pkg/tests/import_test.go @@ -10,11 +10,12 @@ import ( "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" "github.com/pulumi/pulumi/sdk/v3/go/auto/optpreview" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gopkg.in/yaml.v3" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" ) func TestFullyComputedNestedAttribute(t *testing.T) { diff --git a/pkg/tests/internal/webaclschema/schemas.go b/pkg/tests/internal/webaclschema/schemas.go index 5c83152ae..b59ef38f7 100644 --- a/pkg/tests/internal/webaclschema/schemas.go +++ b/pkg/tests/internal/webaclschema/schemas.go @@ -12,7 +12,6 @@ import ( "github.com/aws/aws-sdk-go/service/wafv2" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - // "github.com/hashicorp/terraform-provider-aws/internal/verify" ) var listOfEmptyObjectSchema *schema.Schema = &schema.Schema{ @@ -161,7 +160,7 @@ func ipSetReferenceStatementSchema() *schema.Schema { "arn": { Type: schema.TypeString, Required: true, - //ValidateFunc: verify.ValidARN, + // ValidateFunc: verify.ValidARN, }, "ip_set_forwarded_ip_config": { Type: schema.TypeList, @@ -1050,7 +1049,7 @@ func ruleGroupReferenceStatementSchema() *schema.Schema { "arn": { Type: schema.TypeString, Required: true, - //ValidateFunc: verify.ValidARN, + // ValidateFunc: verify.ValidARN, }, "rule_action_override": ruleActionOverrideSchema(), }, diff --git a/pkg/tests/internal/webaclschema/webacl.go b/pkg/tests/internal/webaclschema/webacl.go index bfa60e1b5..f2a1ae9c4 100644 --- a/pkg/tests/internal/webaclschema/webacl.go +++ b/pkg/tests/internal/webaclschema/webacl.go @@ -144,7 +144,7 @@ func ResourceWebACL() *schema.Resource { // before := "action:(;);" // after := "action:(;);" s := buf.String() - //s = strings.ReplaceAll(s, before, after) + // s = strings.ReplaceAll(s, before, after) n := hashcodeString(s) if 1+2 == 18 { fmt.Printf("PRE-HASH:\n%s\n\n", s) @@ -159,7 +159,7 @@ func ResourceWebACL() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - //ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + // ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), }, // names.AttrTags: tftags.TagsSchema(), // names.AttrTagsAll: tftags.TagsSchemaTrulyComputed(), @@ -180,7 +180,7 @@ func ResourceWebACL() *schema.Resource { } }, - //CustomizeDiff: verify.SetTagsDiff, + // CustomizeDiff: verify.SetTagsDiff, } } diff --git a/pkg/tests/invoke_raw_config_test.go b/pkg/tests/invoke_raw_config_test.go index c8de492f0..7f9504c28 100644 --- a/pkg/tests/invoke_raw_config_test.go +++ b/pkg/tests/invoke_raw_config_test.go @@ -16,18 +16,18 @@ package tests import ( "context" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - testutils "github.com/pulumi/providertest/replay" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" shimv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2" ) func TestInvokeRawConfigDoesNotPanic(t *testing.T) { - t.Parallel() + t.Parallel() ctx := context.Background() resource := &schema.Resource{ diff --git a/pkg/tests/mux_with_test.go b/pkg/tests/mux_with_test.go index 0f4e35c91..96eaa0c53 100644 --- a/pkg/tests/mux_with_test.go +++ b/pkg/tests/mux_with_test.go @@ -23,9 +23,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" testutils "github.com/pulumi/providertest/replay" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen" - shimv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2" pschema "github.com/pulumi/pulumi/pkg/v3/codegen/schema" "github.com/pulumi/pulumi/pkg/v3/resource/provider" "github.com/pulumi/pulumi/sdk/v3/go/common/diag" @@ -35,6 +32,10 @@ import ( pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go" "github.com/stretchr/testify/assert" "google.golang.org/protobuf/types/known/structpb" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen" + shimv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2" ) func newTFProvider() *schema.Provider { @@ -116,7 +117,7 @@ func newProviderServer(info tfbridge.ProviderInfo) (server pulumirpc.ResourcePro } func TestMuxWithProvider(t *testing.T) { - t.Parallel() + t.Parallel() info := tfbridge.ProviderInfo{ P: shimv2.NewProvider(newTFProvider()), Name: "random", diff --git a/pkg/tests/plan_state_edit_test.go b/pkg/tests/plan_state_edit_test.go index 1e55a8c51..7e1686b9b 100644 --- a/pkg/tests/plan_state_edit_test.go +++ b/pkg/tests/plan_state_edit_test.go @@ -7,11 +7,12 @@ import ( "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/pulumi/pulumi/sdk/v3/go/common/resource" + "github.com/stretchr/testify/assert" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" shimv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2" - "github.com/pulumi/pulumi/sdk/v3/go/common/resource" - "github.com/stretchr/testify/assert" ) // TestPlanStateEdit tests that [shimv2.WithPlanStateEdit] can be used to effectively edit diff --git a/pkg/tests/pulcheck/pulcheck.go b/pkg/tests/pulcheck/pulcheck.go index 188769cf9..7cb6b45b8 100644 --- a/pkg/tests/pulcheck/pulcheck.go +++ b/pkg/tests/pulcheck/pulcheck.go @@ -15,11 +15,6 @@ import ( "github.com/pulumi/providertest/providers" "github.com/pulumi/providertest/pulumitest" "github.com/pulumi/providertest/pulumitest/opttest" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/tokens" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen" - shimv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2" pulumidiag "github.com/pulumi/pulumi/sdk/v3/go/common/diag" "github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors" "github.com/pulumi/pulumi/sdk/v3/go/common/util/rpcutil" @@ -27,6 +22,12 @@ import ( "github.com/stretchr/testify/require" "google.golang.org/grpc" "gotest.tools/assert" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/tokens" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen" + shimv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2" ) func propNeedsUpdate(prop *schema.Schema) bool { diff --git a/pkg/tests/refresh_test.go b/pkg/tests/refresh_test.go index 7a3fc2d88..d90079180 100644 --- a/pkg/tests/refresh_test.go +++ b/pkg/tests/refresh_test.go @@ -7,20 +7,20 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" "github.com/pulumi/pulumi/sdk/v3/go/auto/optpreview" "github.com/pulumi/pulumi/sdk/v3/go/auto/optrefresh" "github.com/stretchr/testify/require" -) + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" +) func TestCollectionsNullEmptyRefreshClean(t *testing.T) { t.Parallel() for _, tc := range []struct { - name string - schemaType schema.ValueType - cloudVal interface{} - programVal string + name string + schemaType schema.ValueType + cloudVal interface{} + programVal string // If true, the cloud value will be set in the CreateContext // This is behaviour observed in both AWS and GCP providers, as well as a few others // where the provider returns an empty collections when a nil one was specified in inputs. @@ -378,4 +378,4 @@ outputs: }) }) } -} \ No newline at end of file +} diff --git a/pkg/tests/regress_1020_test.go b/pkg/tests/regress_1020_test.go index 4d1c69f03..ed5ce44d0 100644 --- a/pkg/tests/regress_1020_test.go +++ b/pkg/tests/regress_1020_test.go @@ -20,10 +20,9 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - + testutils "github.com/pulumi/providertest/replay" pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go" - testutils "github.com/pulumi/providertest/replay" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim" shimv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2" @@ -31,7 +30,7 @@ import ( // See https://github.com/pulumi/pulumi-terraform-bridge/issues/1020 func TestRegress1020(t *testing.T) { - t.Parallel() + t.Parallel() ctx := context.Background() CIDRBlocksEqual := func(cidr1, cidr2 string) bool { diff --git a/pkg/tests/regress_923_test.go b/pkg/tests/regress_923_test.go index 996d30a29..854780084 100644 --- a/pkg/tests/regress_923_test.go +++ b/pkg/tests/regress_923_test.go @@ -22,12 +22,13 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" testutils "github.com/pulumi/providertest/replay" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" shimv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2" ) func TestRegress923(t *testing.T) { - t.Parallel() + t.Parallel() ctx := context.Background() resource := &schema.Resource{ diff --git a/pkg/tests/regress_aws_2352_test.go b/pkg/tests/regress_aws_2352_test.go index c3eb20e7c..b8f294ee9 100644 --- a/pkg/tests/regress_aws_2352_test.go +++ b/pkg/tests/regress_aws_2352_test.go @@ -22,14 +22,14 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - testutils "github.com/pulumi/providertest/replay" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" shimv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2" ) func TestRegressAws2352(t *testing.T) { - t.Parallel() + t.Parallel() ctx := context.Background() createDotStringHashcode := func(s string) int { diff --git a/pkg/tests/regress_hcloud_175_test.go b/pkg/tests/regress_hcloud_175_test.go index 0818726b9..766ec8842 100644 --- a/pkg/tests/regress_hcloud_175_test.go +++ b/pkg/tests/regress_hcloud_175_test.go @@ -20,12 +20,13 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" testutils "github.com/pulumi/providertest/replay" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" shimv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2" ) func TestRegressHCloud175(t *testing.T) { - t.Parallel() + t.Parallel() ctx := context.Background() subnetResource := func() *schema.Resource { diff --git a/pkg/tests/schema_pulumi_test.go b/pkg/tests/schema_pulumi_test.go index a634ed95e..903d48476 100644 --- a/pkg/tests/schema_pulumi_test.go +++ b/pkg/tests/schema_pulumi_test.go @@ -10,11 +10,12 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" "github.com/pulumi/pulumi/sdk/v3/go/common/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" ) func TestBasic(t *testing.T) { diff --git a/pkg/tests/state_func_test.go b/pkg/tests/state_func_test.go index 393d5f550..2e73b0954 100644 --- a/pkg/tests/state_func_test.go +++ b/pkg/tests/state_func_test.go @@ -6,12 +6,12 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" "github.com/pulumi/pulumi/sdk/v3/go/auto/optpreview" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" -) + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" +) func TestStateFunc(t *testing.T) { t.Parallel() @@ -56,4 +56,4 @@ outputs: res := pt.Up(t) require.Equal(t, "hello world", res.Outputs["testOut"].Value) pt.Preview(t, optpreview.ExpectNoChanges()) -} \ No newline at end of file +} diff --git a/pkg/tests/tfcheck/exec.go b/pkg/tests/tfcheck/exec.go index a723f441b..15b008377 100644 --- a/pkg/tests/tfcheck/exec.go +++ b/pkg/tests/tfcheck/exec.go @@ -19,8 +19,9 @@ import ( "os" "os/exec" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" "github.com/stretchr/testify/require" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" ) func (d *TFDriver) execTf(t pulcheck.T, args ...string) ([]byte, error) { diff --git a/pkg/tests/tfcheck/tf_test.go b/pkg/tests/tfcheck/tf_test.go index 0ce6b2719..46c7e0b5d 100644 --- a/pkg/tests/tfcheck/tf_test.go +++ b/pkg/tests/tfcheck/tf_test.go @@ -11,7 +11,7 @@ import ( ) func TestTfComputed(t *testing.T) { - t.Parallel() + t.Parallel() prov := schema.Provider{ ResourcesMap: map[string]*schema.Resource{ "test_resource": { @@ -69,7 +69,7 @@ resource "test_resource" "test" { // // - https://github.com/pulumi/pulumi-nomad/issues/389 func TestTfMapMissingElem(t *testing.T) { - t.Parallel() + t.Parallel() prov := schema.Provider{ ResourcesMap: map[string]*schema.Resource{ "test_resource": { @@ -128,7 +128,7 @@ resource "test_resource" "test" { } func TestTfUnknownObjects(t *testing.T) { - t.Parallel() + t.Parallel() prov := schema.Provider{ ResourcesMap: map[string]*schema.Resource{ "test_resource": { diff --git a/pkg/tests/tfcheck/tfcheck.go b/pkg/tests/tfcheck/tfcheck.go index bca4b1e39..7fdaea58f 100644 --- a/pkg/tests/tfcheck/tfcheck.go +++ b/pkg/tests/tfcheck/tfcheck.go @@ -20,9 +20,10 @@ import ( "github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server" "github.com/hashicorp/terraform-plugin-mux/tf5to6server" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" "github.com/stretchr/testify/require" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" ) type TFDriver struct { diff --git a/pkg/tests/type_checker_test.go b/pkg/tests/type_checker_test.go index 792d3d5b5..be680f183 100644 --- a/pkg/tests/type_checker_test.go +++ b/pkg/tests/type_checker_test.go @@ -7,8 +7,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/pulumi/providertest/pulumitest/opttest" - "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" "github.com/stretchr/testify/require" + + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tests/pulcheck" ) func TestTypeChecker(t *testing.T) { @@ -185,4 +186,4 @@ resources: }) runTest(t, resMap, map[string]interface{}{"network_configuration": map[string]interface{}{"assign_public_ip": map[string]any{"val": true}}}, "expected array type, got") }) -} \ No newline at end of file +} diff --git a/pkg/x/muxer/main.go b/pkg/x/muxer/main.go index 2bf500eab..bd17d5364 100644 --- a/pkg/x/muxer/main.go +++ b/pkg/x/muxer/main.go @@ -21,7 +21,7 @@ import ( "github.com/pulumi/pulumi/pkg/v3/codegen/schema" "github.com/pulumi/pulumi/pkg/v3/resource/provider" "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" - rpc "github.com/pulumi/pulumi/sdk/v3/proto/go" + pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go" ) // Mux multiple rpc servers into a single server by routing based on request type and urn. @@ -96,8 +96,8 @@ type Main struct { GetMappingHandler map[string]MultiMappingHandler } -func (m Main) Server(host *provider.HostClient, module, version string) (rpc.ResourceProviderServer, error) { - servers := make([]rpc.ResourceProviderServer, len(m.Servers)) +func (m Main) Server(host *provider.HostClient, module, version string) (pulumirpc.ResourceProviderServer, error) { + servers := make([]pulumirpc.ResourceProviderServer, len(m.Servers)) for i, s := range m.Servers { var err error servers[i], err = s.Server(host) @@ -108,7 +108,7 @@ func (m Main) Server(host *provider.HostClient, module, version string) (rpc.Res dispatchTable, pulumiSchema := m.DispatchTable.dispatchTable, m.Schema if dispatchTable.isEmpty() || len(pulumiSchema) == 0 { - req := &rpc.GetSchemaRequest{Version: SchemaVersion} + req := &pulumirpc.GetSchemaRequest{Version: SchemaVersion} primary, err := servers[0].GetSchema(context.Background(), req) contract.AssertNoErrorf(err, "Muxing requires GetSchema for dispatch") targetSchema := new(schema.PackageSpec) @@ -139,5 +139,5 @@ func (m Main) Server(host *provider.HostClient, module, version string) (rpc.Res } type Endpoint struct { - Server func(*provider.HostClient) (rpc.ResourceProviderServer, error) + Server func(*provider.HostClient) (pulumirpc.ResourceProviderServer, error) } diff --git a/pkg/x/muxer/mapping_test.go b/pkg/x/muxer/mapping_test.go index bb5ef58b1..b58d26950 100644 --- a/pkg/x/muxer/mapping_test.go +++ b/pkg/x/muxer/mapping_test.go @@ -23,7 +23,7 @@ import ( ) func TestMergeSchemasAndComputeDispatchTable(t *testing.T) { - t.Parallel() + t.Parallel() s1 := schema.PackageSpec{ Name: "pkg", Resources: map[string]schema.ResourceSpec{ diff --git a/pkg/x/muxer/muxer.go b/pkg/x/muxer/muxer.go index a4a942b6a..bdf760952 100644 --- a/pkg/x/muxer/muxer.go +++ b/pkg/x/muxer/muxer.go @@ -28,7 +28,7 @@ import ( "github.com/pulumi/pulumi/sdk/v3/go/common/diag" urn "github.com/pulumi/pulumi/sdk/v3/go/common/resource" "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" - rpc "github.com/pulumi/pulumi/sdk/v3/proto/go" + pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/encoding/protojson" @@ -45,7 +45,7 @@ func mux( dispatchTable dispatchTable, pulumiSchema []byte, getMappingHandlers getMappingHandler, - servers ...rpc.ResourceProviderServer, + servers ...pulumirpc.ResourceProviderServer, ) *muxer { contract.Assertf(len(servers) > 0, "Cannot instantiate an empty muxer") return &muxer{ @@ -57,12 +57,12 @@ func mux( } } -var _ rpc.ResourceProviderServer = ((*muxer)(nil)) +var _ pulumirpc.ResourceProviderServer = ((*muxer)(nil)) -type server = rpc.ResourceProviderServer +type server = pulumirpc.ResourceProviderServer type muxer struct { - rpc.UnimplementedResourceProviderServer + pulumirpc.UnimplementedResourceProviderServer host hostClient @@ -111,26 +111,26 @@ func (m *muxer) getResource(token string) server { return m.servers[i] } -func (m *muxer) GetSchema(ctx context.Context, req *rpc.GetSchemaRequest) (*rpc.GetSchemaResponse, error) { +func (m *muxer) GetSchema(ctx context.Context, req *pulumirpc.GetSchemaRequest) (*pulumirpc.GetSchemaResponse, error) { if req.Version != SchemaVersion { return nil, fmt.Errorf("Expected schema version %d, got %d", SchemaVersion, req.GetVersion()) } - return &rpc.GetSchemaResponse{Schema: string(m.schema)}, nil + return &pulumirpc.GetSchemaResponse{Schema: string(m.schema)}, nil } -func (m *muxer) CheckConfig(ctx context.Context, req *rpc.CheckRequest) (*rpc.CheckResponse, error) { - subs := make([]func() tuple[*rpc.CheckResponse, error], len(m.servers)) +func (m *muxer) CheckConfig(ctx context.Context, req *pulumirpc.CheckRequest) (*pulumirpc.CheckResponse, error) { + subs := make([]func() tuple[*pulumirpc.CheckResponse, error], len(m.servers)) for i, s := range m.servers { i, s := i, s - subs[i] = func() tuple[*rpc.CheckResponse, error] { - req := proto.Clone(req).(*rpc.CheckRequest) + subs[i] = func() tuple[*pulumirpc.CheckResponse, error] { + req := proto.Clone(req).(*pulumirpc.CheckRequest) return newTuple(s.CheckConfig(ctx, req)) } } inputs := &structpb.Struct{Fields: map[string]*structpb.Value{}} - failures := []*rpc.CheckFailure{} + failures := []*pulumirpc.CheckFailure{} uniqueFailures := map[string]struct{}{} var errs multierror.Error uniqueErrors := map[string]struct{}{} @@ -172,7 +172,7 @@ func (m *muxer) CheckConfig(ctx context.Context, req *rpc.CheckRequest) (*rpc.Ch } } - return &rpc.CheckResponse{ + return &pulumirpc.CheckResponse{ Inputs: inputs, Failures: failures, }, m.muxedErrors(&errs) @@ -206,12 +206,12 @@ func (m *muxer) muxedErrors(errs *multierror.Error) error { return validErrors.ErrorOrNil() } -func (m *muxer) DiffConfig(ctx context.Context, req *rpc.DiffRequest) (*rpc.DiffResponse, error) { - subs := make([]func() tuple[*rpc.DiffResponse, error], len(m.servers)) +func (m *muxer) DiffConfig(ctx context.Context, req *pulumirpc.DiffRequest) (*pulumirpc.DiffResponse, error) { + subs := make([]func() tuple[*pulumirpc.DiffResponse, error], len(m.servers)) for i, s := range m.servers { i, s := i, s - subs[i] = func() tuple[*rpc.DiffResponse, error] { - req := proto.Clone(req).(*rpc.DiffRequest) + subs[i] = func() tuple[*pulumirpc.DiffResponse, error] { + req := proto.Clone(req).(*pulumirpc.DiffRequest) return newTuple(s.DiffConfig(ctx, req)) } } @@ -228,13 +228,13 @@ func (m *muxer) DiffConfig(ctx context.Context, req *rpc.DiffRequest) (*rpc.Diff diffs = make(set[string]) // The AND of each server, sans replaces stables = make(set[string]) // The AND of each server, sans replaces and diffs - changes rpc.DiffResponse_DiffChanges = rpc.DiffResponse_DIFF_NONE + changes pulumirpc.DiffResponse_DiffChanges = pulumirpc.DiffResponse_DIFF_NONE errs = new(multierror.Error) ) var ( - detailedDiff = map[string]*rpc.PropertyDiff{} + detailedDiff = map[string]*pulumirpc.PropertyDiff{} hasDetailedDiff = true ) @@ -250,7 +250,7 @@ func (m *muxer) DiffConfig(ctx context.Context, req *rpc.DiffRequest) (*rpc.Diff deleteBeforeReplace = true } - if changes == rpc.DiffResponse_DIFF_NONE { + if changes == pulumirpc.DiffResponse_DIFF_NONE { changes = resp.GetChanges() } @@ -276,7 +276,7 @@ func (m *muxer) DiffConfig(ctx context.Context, req *rpc.DiffRequest) (*rpc.Diff diffs = diffs.setMinus(replaces) stables = stables.setMinus(replaces).setMinus(diffs) - return &rpc.DiffResponse{ + return &pulumirpc.DiffResponse{ Replaces: replaces.elements(), Stables: stables.elements(), DeleteBeforeReplace: deleteBeforeReplace, @@ -288,18 +288,18 @@ func (m *muxer) DiffConfig(ctx context.Context, req *rpc.DiffRequest) (*rpc.Diff }, m.muxedErrors(errs) } -func (m *muxer) Configure(ctx context.Context, req *rpc.ConfigureRequest) (*rpc.ConfigureResponse, error) { +func (m *muxer) Configure(ctx context.Context, req *pulumirpc.ConfigureRequest) (*pulumirpc.ConfigureResponse, error) { // Configure determines what the values the provider understands. We take the // `and` of configure values. - subs := make([]func() tuple[*rpc.ConfigureResponse, error], len(m.servers)) + subs := make([]func() tuple[*pulumirpc.ConfigureResponse, error], len(m.servers)) for i, s := range m.servers { i, s := i, s - subs[i] = func() tuple[*rpc.ConfigureResponse, error] { - req := proto.Clone(req).(*rpc.ConfigureRequest) + subs[i] = func() tuple[*pulumirpc.ConfigureResponse, error] { + req := proto.Clone(req).(*pulumirpc.ConfigureRequest) return newTuple(s.Configure(ctx, req)) } } - response := &rpc.ConfigureResponse{ + response := &pulumirpc.ConfigureResponse{ AcceptSecrets: true, SupportsPreview: true, AcceptResources: true, @@ -335,7 +335,7 @@ func resourceMethod[T resourceRequest, R any](m *muxer, req T, f func(m server) return f(server) } -func (m *muxer) Invoke(ctx context.Context, req *rpc.InvokeRequest) (*rpc.InvokeResponse, error) { +func (m *muxer) Invoke(ctx context.Context, req *pulumirpc.InvokeRequest) (*pulumirpc.InvokeResponse, error) { server := m.getFunction(req.GetTok()) if server == nil { return nil, status.Errorf(codes.NotFound, "Invoke '%s' not found.", req.GetTok()) @@ -343,7 +343,7 @@ func (m *muxer) Invoke(ctx context.Context, req *rpc.InvokeRequest) (*rpc.Invoke return server.Invoke(ctx, req) } -func (m *muxer) StreamInvoke(req *rpc.InvokeRequest, s rpc.ResourceProvider_StreamInvokeServer) error { +func (m *muxer) StreamInvoke(req *pulumirpc.InvokeRequest, s pulumirpc.ResourceProvider_StreamInvokeServer) error { server := m.getFunction(req.GetTok()) if server == nil { return status.Errorf(codes.NotFound, "Invoke '%s' not found.", req.GetTok()) @@ -351,7 +351,7 @@ func (m *muxer) StreamInvoke(req *rpc.InvokeRequest, s rpc.ResourceProvider_Stre return server.StreamInvoke(req, s) } -func (m *muxer) Call(ctx context.Context, req *rpc.CallRequest) (*rpc.CallResponse, error) { +func (m *muxer) Call(ctx context.Context, req *pulumirpc.CallRequest) (*pulumirpc.CallResponse, error) { server := m.getFunction(req.GetTok()) if server == nil { return nil, status.Errorf(codes.NotFound, "Resource Method '%s' not found.", req.GetTok()) @@ -359,43 +359,43 @@ func (m *muxer) Call(ctx context.Context, req *rpc.CallRequest) (*rpc.CallRespon return server.Call(ctx, req) } -func (m *muxer) Check(ctx context.Context, req *rpc.CheckRequest) (*rpc.CheckResponse, error) { - return resourceMethod(m, req, func(m server) (*rpc.CheckResponse, error) { +func (m *muxer) Check(ctx context.Context, req *pulumirpc.CheckRequest) (*pulumirpc.CheckResponse, error) { + return resourceMethod(m, req, func(m server) (*pulumirpc.CheckResponse, error) { return m.Check(ctx, req) }) } -func (m *muxer) Diff(ctx context.Context, req *rpc.DiffRequest) (*rpc.DiffResponse, error) { - return resourceMethod(m, req, func(m server) (*rpc.DiffResponse, error) { +func (m *muxer) Diff(ctx context.Context, req *pulumirpc.DiffRequest) (*pulumirpc.DiffResponse, error) { + return resourceMethod(m, req, func(m server) (*pulumirpc.DiffResponse, error) { return m.Diff(ctx, req) }) } -func (m *muxer) Create(ctx context.Context, req *rpc.CreateRequest) (*rpc.CreateResponse, error) { - return resourceMethod(m, req, func(m server) (*rpc.CreateResponse, error) { +func (m *muxer) Create(ctx context.Context, req *pulumirpc.CreateRequest) (*pulumirpc.CreateResponse, error) { + return resourceMethod(m, req, func(m server) (*pulumirpc.CreateResponse, error) { return m.Create(ctx, req) }) } -func (m *muxer) Read(ctx context.Context, req *rpc.ReadRequest) (*rpc.ReadResponse, error) { - return resourceMethod(m, req, func(m server) (*rpc.ReadResponse, error) { +func (m *muxer) Read(ctx context.Context, req *pulumirpc.ReadRequest) (*pulumirpc.ReadResponse, error) { + return resourceMethod(m, req, func(m server) (*pulumirpc.ReadResponse, error) { return m.Read(ctx, req) }) } -func (m *muxer) Update(ctx context.Context, req *rpc.UpdateRequest) (*rpc.UpdateResponse, error) { - return resourceMethod(m, req, func(m server) (*rpc.UpdateResponse, error) { +func (m *muxer) Update(ctx context.Context, req *pulumirpc.UpdateRequest) (*pulumirpc.UpdateResponse, error) { + return resourceMethod(m, req, func(m server) (*pulumirpc.UpdateResponse, error) { return m.Update(ctx, req) }) } -func (m *muxer) Delete(ctx context.Context, req *rpc.DeleteRequest) (*emptypb.Empty, error) { +func (m *muxer) Delete(ctx context.Context, req *pulumirpc.DeleteRequest) (*emptypb.Empty, error) { return resourceMethod(m, req, func(m server) (*emptypb.Empty, error) { return m.Delete(ctx, req) }) } -func (m *muxer) Construct(ctx context.Context, req *rpc.ConstructRequest) (*rpc.ConstructResponse, error) { +func (m *muxer) Construct(ctx context.Context, req *pulumirpc.ConstructRequest) (*pulumirpc.ConstructResponse, error) { server := m.getResource(req.GetType()) if server == nil { return nil, status.Errorf(codes.NotFound, "Component Resource type '%s' does not exist.", req.GetType()) @@ -418,13 +418,13 @@ func (m *muxer) Cancel(ctx context.Context, e *emptypb.Empty) (*emptypb.Empty, e return e, m.muxedErrors(errs) } -func (m *muxer) GetPluginInfo(ctx context.Context, e *emptypb.Empty) (*rpc.PluginInfo, error) { +func (m *muxer) GetPluginInfo(ctx context.Context, e *emptypb.Empty) (*pulumirpc.PluginInfo, error) { // rpc.PluginInfo only returns the version. We just return the version // of the most prominent plugin. return m.servers[0].GetPluginInfo(ctx, e) } -func (m *muxer) Attach(ctx context.Context, req *rpc.PluginAttach) (*emptypb.Empty, error) { +func (m *muxer) Attach(ctx context.Context, req *pulumirpc.PluginAttach) (*emptypb.Empty, error) { attach := make([]func() error, len(m.servers)) for i, s := range m.servers { s := s @@ -436,7 +436,7 @@ func (m *muxer) Attach(ctx context.Context, req *rpc.PluginAttach) (*emptypb.Emp var closeErr error // Because in Go, an interface type is not nil even when its underlying value is nil, the nil check here - //must test the underlying type. + // must test the underlying type. if !reflect.ValueOf(m.host).IsNil() { closeErr = m.host.Close() } @@ -448,7 +448,7 @@ func (m *muxer) Attach(ctx context.Context, req *rpc.PluginAttach) (*emptypb.Emp type getMappingArgs struct { m *muxer - req *rpc.GetMappingRequest + req *pulumirpc.GetMappingRequest ctx context.Context err error @@ -460,7 +460,9 @@ func (a *getMappingArgs) Fetch() []GetMappingResponse { return resp } -func (m *muxer) GetMapping(ctx context.Context, req *rpc.GetMappingRequest) (*rpc.GetMappingResponse, error) { +func (m *muxer) GetMapping( + ctx context.Context, req *pulumirpc.GetMappingRequest, +) (*pulumirpc.GetMappingResponse, error) { // We need to merge multiple mappings combineMapping, found := m.getMappingByKey[req.Key] if !found { @@ -474,11 +476,11 @@ func (m *muxer) GetMapping(ctx context.Context, req *rpc.GetMappingRequest) (*rp // There are no results and some sub-providers implemented the // method. This means that no provider responded to this key. We return an // empty response. - return &rpc.GetMappingResponse{}, nil + return &pulumirpc.GetMappingResponse{}, nil case 1: // We don't need to worry about merging GetMapping data if there is only one // server with valid data. - return &rpc.GetMappingResponse{ + return &pulumirpc.GetMappingResponse{ Provider: results[0].Provider, Data: results[0].Data, }, nil @@ -494,20 +496,20 @@ func (m *muxer) GetMapping(ctx context.Context, req *rpc.GetMappingRequest) (*rp } return nil, err } - return &rpc.GetMappingResponse{ + return &pulumirpc.GetMappingResponse{ Provider: result.Provider, Data: result.Data, }, nil } func (m *muxer) getMappingRaw( - ctx context.Context, req *rpc.GetMappingRequest, strict bool, + ctx context.Context, req *pulumirpc.GetMappingRequest, strict bool, ) ([]GetMappingResponse, error) { - subs := make([]func() tuple[*rpc.GetMappingResponse, error], len(m.servers)) + subs := make([]func() tuple[*pulumirpc.GetMappingResponse, error], len(m.servers)) for i, s := range m.servers { i, s := i, s - subs[i] = func() tuple[*rpc.GetMappingResponse, error] { - return newTuple(s.GetMapping(ctx, proto.Clone(req).(*rpc.GetMappingRequest))) + subs[i] = func() tuple[*pulumirpc.GetMappingResponse, error] { + return newTuple(s.GetMapping(ctx, proto.Clone(req).(*pulumirpc.GetMappingRequest))) } } errs := new(multierror.Error) @@ -555,7 +557,7 @@ func (m *muxer) Warnf(ctx context.Context, method, msg string, a ...any) error { // `mergeDetailedDiff` copies values from `src` to `dst`. // // A returned err indicates a conflict between src and dst. -func mergeDetailedDiff(dst map[string]*rpc.PropertyDiff, src map[string]*rpc.PropertyDiff) error { +func mergeDetailedDiff(dst map[string]*pulumirpc.PropertyDiff, src map[string]*pulumirpc.PropertyDiff) error { var errs []error for k, v := range src { existing, ok := dst[k] @@ -653,10 +655,10 @@ func showStruct(value *structpb.Value) string { return string(j) } -func dominatingDiffResponse(responses []tuple[*rpc.DiffResponse, error]) *rpc.DiffResponse { +func dominatingDiffResponse(responses []tuple[*pulumirpc.DiffResponse, error]) *pulumirpc.DiffResponse { unimplemented := 0 errors := 0 - var resp *rpc.DiffResponse + var resp *pulumirpc.DiffResponse for _, r := range responses { if r.B != nil { errors++ diff --git a/pkg/x/muxer/muxer_test.go b/pkg/x/muxer/muxer_test.go index 704cf35e9..e6c2bb60f 100644 --- a/pkg/x/muxer/muxer_test.go +++ b/pkg/x/muxer/muxer_test.go @@ -29,7 +29,7 @@ import ( ) func TestAttach(t *testing.T) { - t.Parallel() + t.Parallel() req := &pulumirpc.PluginAttach{Address: "test"} ctx := context.Background() @@ -49,7 +49,8 @@ func TestAttach(t *testing.T) { servers: []server{ &attach{t: t, expected: "test"}, &attach{t: t, expected: "test"}, - }} + }, + } _, err := m.Attach(ctx, req) assert.NoError(t, err) for i, s := range m.servers { @@ -92,7 +93,7 @@ func (h *host) Log(context.Context, diag.Severity, urn.URN, string) error { } func TestDiffConfig(t *testing.T) { - t.Parallel() + t.Parallel() type testCase struct { name string request *pulumirpc.DiffRequest diff --git a/pkg/x/muxer/tests/muxer_test.go b/pkg/x/muxer/tests/muxer_test.go index 5f16390f6..ba2edce7e 100644 --- a/pkg/x/muxer/tests/muxer_test.go +++ b/pkg/x/muxer/tests/muxer_test.go @@ -24,7 +24,7 @@ import ( testutils "github.com/pulumi/providertest/replay" "github.com/pulumi/pulumi/pkg/v3/resource/provider" - rpc "github.com/pulumi/pulumi/sdk/v3/proto/go" + pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "google.golang.org/protobuf/encoding/protojson" @@ -35,7 +35,7 @@ import ( ) func TestSimpleDispatch(t *testing.T) { - t.Parallel() + t.Parallel() var m muxer.DispatchTable m.Resources = map[string]int{ "test:mod:A": 0, @@ -70,7 +70,7 @@ func TestSimpleDispatch(t *testing.T) { } func TestCheckConfigErrorNotDuplicated(t *testing.T) { - t.Parallel() + t.Parallel() var m muxer.DispatchTable m.Resources = map[string]int{ "test:mod:A": 0, @@ -85,7 +85,7 @@ func TestCheckConfigErrorNotDuplicated(t *testing.T) { } func TestCheckConfigDifferentErrorsNotDropped(t *testing.T) { - t.Parallel() + t.Parallel() var m muxer.DispatchTable m.Resources = map[string]int{ "test:mod:A": 0, @@ -106,7 +106,7 @@ func TestCheckConfigDifferentErrorsNotDropped(t *testing.T) { } func TestCheckConfigOneErrorReturned(t *testing.T) { - t.Parallel() + t.Parallel() var m muxer.DispatchTable m.Resources = map[string]int{ "test:mod:A": 0, @@ -121,7 +121,7 @@ func TestCheckConfigOneErrorReturned(t *testing.T) { } func TestConfigure(t *testing.T) { - t.Parallel() + t.Parallel() var m muxer.DispatchTable m.Resources = map[string]int{ "test:mod:A": 0, @@ -162,7 +162,7 @@ func TestConfigure(t *testing.T) { } func TestDivergentCheckConfig(t *testing.T) { - t.Parallel() + t.Parallel() // Early versions of muxer failed hard on divergent responses from CheckConfig. This test ensures that it can // tolerate such responses (with logging or warning). The practical case is divergent handling of secret markers // where pf and v3 based providers respond with the same value but do not agree on the secret markers. @@ -203,7 +203,7 @@ func TestDivergentCheckConfig(t *testing.T) { } func TestGetMapping(t *testing.T) { - t.Parallel() + t.Parallel() t.Run("single-responding-server", func(t *testing.T) { var m muxer.DispatchTable m.Resources = map[string]int{ @@ -301,7 +301,7 @@ func (m testMuxer) replay(exchanges ...Exchange) { }) } } - servers := make([]rpc.ResourceProviderServer, len(serverBehavior)) + servers := make([]pulumirpc.ResourceProviderServer, len(serverBehavior)) for i, s := range serverBehavior { servers[i] = &server{t: m.t, calls: s} } @@ -365,17 +365,16 @@ func part(provider int, request, response string, errors []string) ExchangePart func buildMux( t *testing.T, mapping muxer.DispatchTable, getMappings map[string]muxer.MultiMappingHandler, - servers ...rpc.ResourceProviderServer, -) rpc.ResourceProviderServer { + servers ...pulumirpc.ResourceProviderServer, +) pulumirpc.ResourceProviderServer { endpoints := make([]muxer.Endpoint, len(servers)) for i, s := range servers { i, s := i, s endpoints[i] = muxer.Endpoint{ - Server: func(*provider.HostClient) (rpc.ResourceProviderServer, error) { + Server: func(*provider.HostClient) (pulumirpc.ResourceProviderServer, error) { return s, nil }, } - } s, err := muxer.Main{ Servers: endpoints, @@ -387,10 +386,10 @@ func buildMux( return s } -var _ rpc.ResourceProviderServer = ((*server)(nil)) +var _ pulumirpc.ResourceProviderServer = ((*server)(nil)) type server struct { - rpc.UnimplementedResourceProviderServer + pulumirpc.UnimplementedResourceProviderServer t *testing.T @@ -431,75 +430,77 @@ func handleMethod[T proto.Message, R proto.Message](m *server, req T) (R, error) return r, err } -func (m *server) GetSchema(ctx context.Context, req *rpc.GetSchemaRequest) (*rpc.GetSchemaResponse, error) { - return handleMethod[*rpc.GetSchemaRequest, *rpc.GetSchemaResponse](m, req) +func (m *server) GetSchema(ctx context.Context, req *pulumirpc.GetSchemaRequest) (*pulumirpc.GetSchemaResponse, error) { + return handleMethod[*pulumirpc.GetSchemaRequest, *pulumirpc.GetSchemaResponse](m, req) } -func (m *server) CheckConfig(ctx context.Context, req *rpc.CheckRequest) (*rpc.CheckResponse, error) { - return handleMethod[*rpc.CheckRequest, *rpc.CheckResponse](m, req) +func (m *server) CheckConfig(ctx context.Context, req *pulumirpc.CheckRequest) (*pulumirpc.CheckResponse, error) { + return handleMethod[*pulumirpc.CheckRequest, *pulumirpc.CheckResponse](m, req) } -func (m *server) DiffConfig(ctx context.Context, req *rpc.DiffRequest) (*rpc.DiffResponse, error) { - return handleMethod[*rpc.DiffRequest, *rpc.DiffResponse](m, req) +func (m *server) DiffConfig(ctx context.Context, req *pulumirpc.DiffRequest) (*pulumirpc.DiffResponse, error) { + return handleMethod[*pulumirpc.DiffRequest, *pulumirpc.DiffResponse](m, req) } -func (m *server) Configure(ctx context.Context, req *rpc.ConfigureRequest) (*rpc.ConfigureResponse, error) { - return handleMethod[*rpc.ConfigureRequest, *rpc.ConfigureResponse](m, req) +func (m *server) Configure(ctx context.Context, req *pulumirpc.ConfigureRequest) (*pulumirpc.ConfigureResponse, error) { + return handleMethod[*pulumirpc.ConfigureRequest, *pulumirpc.ConfigureResponse](m, req) } -func (m *server) Invoke(ctx context.Context, req *rpc.InvokeRequest) (*rpc.InvokeResponse, error) { - return handleMethod[*rpc.InvokeRequest, *rpc.InvokeResponse](m, req) +func (m *server) Invoke(ctx context.Context, req *pulumirpc.InvokeRequest) (*pulumirpc.InvokeResponse, error) { + return handleMethod[*pulumirpc.InvokeRequest, *pulumirpc.InvokeResponse](m, req) } -func (m *server) StreamInvoke(req *rpc.InvokeRequest, s rpc.ResourceProvider_StreamInvokeServer) error { +func (m *server) StreamInvoke(req *pulumirpc.InvokeRequest, s pulumirpc.ResourceProvider_StreamInvokeServer) error { assert.Fail(m.t, "StreamInvoke not implemented on `server`") return fmt.Errorf("UNIMPLEMENTED") } -func (m *server) Call(ctx context.Context, req *rpc.CallRequest) (*rpc.CallResponse, error) { - return handleMethod[*rpc.CallRequest, *rpc.CallResponse](m, req) +func (m *server) Call(ctx context.Context, req *pulumirpc.CallRequest) (*pulumirpc.CallResponse, error) { + return handleMethod[*pulumirpc.CallRequest, *pulumirpc.CallResponse](m, req) } -func (m *server) Check(ctx context.Context, req *rpc.CheckRequest) (*rpc.CheckResponse, error) { - return handleMethod[*rpc.CheckRequest, *rpc.CheckResponse](m, req) +func (m *server) Check(ctx context.Context, req *pulumirpc.CheckRequest) (*pulumirpc.CheckResponse, error) { + return handleMethod[*pulumirpc.CheckRequest, *pulumirpc.CheckResponse](m, req) } -func (m *server) Diff(ctx context.Context, req *rpc.DiffRequest) (*rpc.DiffResponse, error) { - return handleMethod[*rpc.DiffRequest, *rpc.DiffResponse](m, req) +func (m *server) Diff(ctx context.Context, req *pulumirpc.DiffRequest) (*pulumirpc.DiffResponse, error) { + return handleMethod[*pulumirpc.DiffRequest, *pulumirpc.DiffResponse](m, req) } -func (m *server) Create(ctx context.Context, req *rpc.CreateRequest) (*rpc.CreateResponse, error) { - return handleMethod[*rpc.CreateRequest, *rpc.CreateResponse](m, req) +func (m *server) Create(ctx context.Context, req *pulumirpc.CreateRequest) (*pulumirpc.CreateResponse, error) { + return handleMethod[*pulumirpc.CreateRequest, *pulumirpc.CreateResponse](m, req) } -func (m *server) Read(ctx context.Context, req *rpc.ReadRequest) (*rpc.ReadResponse, error) { - return handleMethod[*rpc.ReadRequest, *rpc.ReadResponse](m, req) +func (m *server) Read(ctx context.Context, req *pulumirpc.ReadRequest) (*pulumirpc.ReadResponse, error) { + return handleMethod[*pulumirpc.ReadRequest, *pulumirpc.ReadResponse](m, req) } -func (m *server) Update(ctx context.Context, req *rpc.UpdateRequest) (*rpc.UpdateResponse, error) { - return handleMethod[*rpc.UpdateRequest, *rpc.UpdateResponse](m, req) +func (m *server) Update(ctx context.Context, req *pulumirpc.UpdateRequest) (*pulumirpc.UpdateResponse, error) { + return handleMethod[*pulumirpc.UpdateRequest, *pulumirpc.UpdateResponse](m, req) } -func (m *server) Delete(ctx context.Context, req *rpc.DeleteRequest) (*emptypb.Empty, error) { - return handleMethod[*rpc.DeleteRequest, *emptypb.Empty](m, req) +func (m *server) Delete(ctx context.Context, req *pulumirpc.DeleteRequest) (*emptypb.Empty, error) { + return handleMethod[*pulumirpc.DeleteRequest, *emptypb.Empty](m, req) } -func (m *server) Construct(ctx context.Context, req *rpc.ConstructRequest) (*rpc.ConstructResponse, error) { - return handleMethod[*rpc.ConstructRequest, *rpc.ConstructResponse](m, req) +func (m *server) Construct(ctx context.Context, req *pulumirpc.ConstructRequest) (*pulumirpc.ConstructResponse, error) { + return handleMethod[*pulumirpc.ConstructRequest, *pulumirpc.ConstructResponse](m, req) } func (m *server) Cancel(ctx context.Context, e *emptypb.Empty) (*emptypb.Empty, error) { return handleMethod[*emptypb.Empty, *emptypb.Empty](m, e) } -func (m *server) GetPluginInfo(ctx context.Context, e *emptypb.Empty) (*rpc.PluginInfo, error) { - return handleMethod[*emptypb.Empty, *rpc.PluginInfo](m, e) +func (m *server) GetPluginInfo(ctx context.Context, e *emptypb.Empty) (*pulumirpc.PluginInfo, error) { + return handleMethod[*emptypb.Empty, *pulumirpc.PluginInfo](m, e) } -func (m *server) Attach(ctx context.Context, req *rpc.PluginAttach) (*emptypb.Empty, error) { - return handleMethod[*rpc.PluginAttach, *emptypb.Empty](m, req) +func (m *server) Attach(ctx context.Context, req *pulumirpc.PluginAttach) (*emptypb.Empty, error) { + return handleMethod[*pulumirpc.PluginAttach, *emptypb.Empty](m, req) } -func (m *server) GetMapping(ctx context.Context, req *rpc.GetMappingRequest) (*rpc.GetMappingResponse, error) { - return handleMethod[*rpc.GetMappingRequest, *rpc.GetMappingResponse](m, req) +func (m *server) GetMapping( + ctx context.Context, req *pulumirpc.GetMappingRequest, +) (*pulumirpc.GetMappingResponse, error) { + return handleMethod[*pulumirpc.GetMappingRequest, *pulumirpc.GetMappingResponse](m, req) } diff --git a/pkg/x/testing/json_match_test.go b/pkg/x/testing/json_match_test.go index 7895ad4f7..28fca5d06 100644 --- a/pkg/x/testing/json_match_test.go +++ b/pkg/x/testing/json_match_test.go @@ -19,7 +19,7 @@ import ( ) func TestJsonMatch(t *testing.T) { - t.Parallel() + t.Parallel() AssertJSONMatchesPattern(t, []byte(`1`), []byte(`1`)) AssertJSONMatchesPattern(t, []byte(`"*"`), []byte(`1`)) AssertJSONMatchesPattern(t, []byte(`"*"`), []byte(`2`)) diff --git a/pkg/x/testing/replay.go b/pkg/x/testing/replay.go index 98e0770d5..f489783c9 100644 --- a/pkg/x/testing/replay.go +++ b/pkg/x/testing/replay.go @@ -90,7 +90,6 @@ func Replay(t *testing.T, server pulumirpc.ResourceProviderServer, jsonLog strin assert.NoError(t, err) switch entry.Method { - case "/pulumirpc.ResourceProvider/GetSchema": replay(t, entry, new(pulumirpc.GetSchemaRequest), server.GetSchema)