Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions dynamic/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,20 @@ import (
"github.com/pulumi/pulumi-terraform-bridge/v3/dynamic/version"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/proto"
"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"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
)

func providerInfo(ctx context.Context, p run.Provider, value parameterize.Value) (tfbridge.ProviderInfo, error) {
func providerInfo(ctx context.Context, p run.Provider, value parameterize.Value) (info.Provider, error) {
provider := proto.New(ctx, p)

providerName := p.Name()
if value.ProviderName != "" {
providerName = value.ProviderName
}

prov := tfbridge.ProviderInfo{
prov := info.Provider{
P: provider,
Name: providerName,
Version: p.Version(),
Expand All @@ -50,20 +51,20 @@ func providerInfo(ctx context.Context, p run.Provider, value parameterize.Value)
Path: "", Data: tfbridge.ProviderMetadata(nil),
},

Python: &tfbridge.PythonInfo{
Python: &info.Python{
PyProject: struct{ Enabled bool }{true},
RespectSchemaVersion: true,
},
JavaScript: &tfbridge.JavaScriptInfo{
JavaScript: &info.JavaScript{
LiftSingleValueMethodReturns: true,
RespectSchemaVersion: true,
},
CSharp: &tfbridge.CSharpInfo{
CSharp: &info.CSharp{
LiftSingleValueMethodReturns: true,
RespectSchemaVersion: true,
},
Java: &tfbridge.JavaInfo{ /* Java does not have a RespectSchemaVersion flag */ },
Golang: &tfbridge.GolangInfo{
Java: &info.Java{ /* Java does not have a RespectSchemaVersion flag */ },
Golang: &info.Golang{
ImportBasePath: path.Join(
"github.com/pulumi/pulumi-terraform-provider/sdks/go",
providerName,
Expand Down
6 changes: 3 additions & 3 deletions internal/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,21 +254,21 @@ var _ io.Writer = &logSinkWriter{}
func (w *logSinkWriter) Write(p []byte) (n int, err error) {
n = len(p)
if w.sink == nil {
return
return n, err
}

raw := strings.TrimSuffix(string(p), "\n")
level, raw := parseLevelFromRawString(raw)

if level < w.desiredLevel {
return
return n, err
}

urn, raw := parseUrnFromRawString(raw)
severity := logLevelToSeverity(level)

err = w.sink.Log(w.ctx, severity, urn, raw)
return
return n, err
Comment on lines -257 to +271
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few other changes like this to fix local lint errors. CI must be using a less strict lint config?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've seen this in pulumi/pulumi upgrading to golangci-lint 2.5.0. This is because of a newer version of gofumpt, which requires these return values now.

}

func parseTfLogEnvVar() hclog.Level {
Expand Down
2 changes: 1 addition & 1 deletion internal/testing/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func AssertEqualsJSONFile[T any](

unmarshalT := func(r io.Reader) (s T, err error) {
err = json.NewDecoder(r).Decode(&s)
return
return s, err
}

readTFromFile := func(file string) (T, error) {
Expand Down
7 changes: 4 additions & 3 deletions internal/testprovider_invalid_schema/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"

"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
sdkv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2"
)

func ProviderInfo() tfbridge.ProviderInfo {
prov := tfbridge.ProviderInfo{
func ProviderInfo() info.Provider {
prov := info.Provider{
P: sdkv2.NewProvider(Provider()),
Name: "tpinvschema",

PreConfigureCallback: func(vars resource.PropertyMap, config shim.ResourceConfig) error {
return nil
},
Resources: map[string]*tfbridge.ResourceInfo{
Resources: map[string]*info.Resource{
"invalid_res": {
Tok: tfbridge.MakeResource("tpinvschema", "index", "invalid_res"),
},
Expand Down
6 changes: 3 additions & 3 deletions internal/testprovider_sdkv2/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ package tpsdkv2
import (
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"

"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/tfshim"
sdkv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2"
)

func ProviderInfo() tfbridge.ProviderInfo {
return tfbridge.ProviderInfo{
func ProviderInfo() info.Provider {
return info.Provider{
P: sdkv2.NewProvider(Provider()),
Name: "tpsdkv2",

Expand Down
7 changes: 4 additions & 3 deletions pkg/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"

"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
"github.com/pulumi/pulumi-terraform-bridge/v3/unstable/propertyvalue"
)
Expand Down Expand Up @@ -54,9 +55,9 @@ type Encoder interface {

// Schema information that is needed to construct Encoder or Decoder instances.
type ObjectSchema struct {
SchemaMap shim.SchemaMap // required
SchemaInfos map[string]*tfbridge.SchemaInfo // optional
Object *tftypes.Object // optional, if not given will be inferred from SchemaMap
SchemaMap shim.SchemaMap // required
SchemaInfos map[string]*info.Schema // optional
Object *tftypes.Object // optional, if not given will be inferred from SchemaMap
}

func (os ObjectSchema) objectType() tftypes.Object {
Expand Down
8 changes: 4 additions & 4 deletions pkg/convert/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ import (

"github.com/hashicorp/terraform-plugin-go/tftypes"

"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
)

type encoding struct {
SchemaOnlyProvider shim.Provider
ProviderInfo *tfbridge.ProviderInfo // only SchemaInfo for fields is required
ProviderInfo *info.Provider // only SchemaInfo for fields is required
}

var _ Encoding = (*encoding)(nil)

func NewEncoding(schemaOnlyProvider shim.Provider, providerInfo *tfbridge.ProviderInfo) Encoding {
func NewEncoding(schemaOnlyProvider shim.Provider, providerInfo *info.Provider) Encoding {
return &encoding{
SchemaOnlyProvider: schemaOnlyProvider,
ProviderInfo: providerInfo,
Expand All @@ -38,7 +38,7 @@ func NewEncoding(schemaOnlyProvider shim.Provider, providerInfo *tfbridge.Provid

func (e *encoding) NewConfigEncoder(configType tftypes.Object) (Encoder, error) {
schema := e.SchemaOnlyProvider.Schema()
var schemaInfos map[string]*tfbridge.SchemaInfo
var schemaInfos map[string]*info.Schema
if e.ProviderInfo != nil {
schemaInfos = e.ProviderInfo.Config
}
Expand Down
18 changes: 9 additions & 9 deletions pkg/convert/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/schema"
)
Expand All @@ -37,7 +37,7 @@ func TestResourceDecoder(t *testing.T) {
type testCase struct {
testName string
schema *schema.SchemaMap
info *tfbridge.ProviderInfo
info *info.Provider
typ tftypes.Object
val tftypes.Value
expect autogold.Value
Expand Down Expand Up @@ -188,7 +188,7 @@ func TestResourceEncoder(t *testing.T) {
type testCase struct {
testName string
schema *schema.SchemaMap
info *tfbridge.ProviderInfo
info *info.Provider
typ tftypes.Object
val resource.PropertyMap
expect autogold.Value
Expand Down Expand Up @@ -254,7 +254,7 @@ func TestDataSourceDecoder(t *testing.T) {
type testCase struct {
testName string
schema *schema.SchemaMap
info *tfbridge.ProviderInfo
info *info.Provider
typ tftypes.Object
val tftypes.Value
expect autogold.Value
Expand Down Expand Up @@ -306,10 +306,10 @@ func TestDataSourceDecoder(t *testing.T) {
Optional: true,
}).Shim(),
},
info: &tfbridge.ProviderInfo{
DataSources: map[string]*tfbridge.DataSourceInfo{
info: &info.Provider{
DataSources: map[string]*info.DataSource{
myDataSource: {
Fields: map[string]*tfbridge.SchemaInfo{
Fields: map[string]*info.Schema{
"foo": {
Name: "renamedFoo",
},
Expand Down Expand Up @@ -357,7 +357,7 @@ func TestDataSourceEncoder(t *testing.T) {
type testCase struct {
testName string
schema *schema.SchemaMap
info *tfbridge.ProviderInfo
info *info.Provider
typ tftypes.Object
val resource.PropertyMap
expect autogold.Value
Expand Down Expand Up @@ -415,7 +415,7 @@ func TestConfigEncoder(t *testing.T) {
type testCase struct {
testName string
schema *schema.SchemaMap
info *tfbridge.ProviderInfo
info *info.Provider
typ tftypes.Object
val resource.PropertyMap
expect autogold.Value
Expand Down
4 changes: 2 additions & 2 deletions pkg/convert/flattened_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
shimschema "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/schema"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/walk"
Expand Down Expand Up @@ -177,7 +177,7 @@ func maxItemsOneCollectionPropContext(propName string, collectionType shim.Value
Optional: true,
}).Shim(),
}).Shim(),
schemaInfo: &tfbridge.SchemaInfo{
schemaInfo: &info.Schema{
MaxItemsOne: &yes,
},
}
Expand Down
19 changes: 10 additions & 9 deletions pkg/convert/schema_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,20 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"

"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/walk"
)

type schemaMapContext struct {
schemaPath walk.SchemaPath
schemaMap shim.SchemaMap
schemaInfos map[string]*tfbridge.SchemaInfo
schemaInfos map[string]*info.Schema
}

var _ localPropertyNames = &schemaMapContext{}

func newSchemaMapContext(schemaMap shim.SchemaMap, schemaInfos map[string]*tfbridge.SchemaInfo) *schemaMapContext {
func newSchemaMapContext(schemaMap shim.SchemaMap, schemaInfos map[string]*info.Schema) *schemaMapContext {
return &schemaMapContext{
schemaPath: walk.NewSchemaPath(),
schemaMap: schemaMap,
Expand All @@ -46,12 +47,12 @@ func newSchemaMapContext(schemaMap shim.SchemaMap, schemaInfos map[string]*tfbri
func newResourceSchemaMapContext(
resource string,
schemaOnlyProvider shim.Provider,
providerInfo *tfbridge.ProviderInfo,
providerInfo *info.Provider,
) *schemaMapContext {
r := schemaOnlyProvider.ResourcesMap().Get(resource)
contract.Assertf(r != nil, "no resource %q found in ResourceMap", resource)
sm := r.Schema()
var fields map[string]*tfbridge.SchemaInfo
var fields map[string]*info.Schema
if providerInfo != nil {
fields = providerInfo.Resources[resource].GetFields()
}
Expand All @@ -61,12 +62,12 @@ func newResourceSchemaMapContext(
func newDataSourceSchemaMapContext(
dataSource string,
schemaOnlyProvider shim.Provider,
providerInfo *tfbridge.ProviderInfo,
providerInfo *info.Provider,
) *schemaMapContext {
r := schemaOnlyProvider.DataSourcesMap().Get(dataSource)
contract.Assertf(r != nil, "no data source %q found in DataSourcesMap", dataSource)
sm := r.Schema()
var fields map[string]*tfbridge.SchemaInfo
var fields map[string]*info.Schema
if providerInfo != nil {
fields = providerInfo.DataSources[dataSource].GetFields()
}
Expand Down Expand Up @@ -99,7 +100,7 @@ func (sc *schemaMapContext) GetAttr(tfname terraformPropertyName) (*schemaPropCo
type schemaPropContext struct {
schemaPath walk.SchemaPath
schema shim.Schema
schemaInfo *tfbridge.SchemaInfo
schemaInfo *info.Schema
}

func (pc *schemaPropContext) Secret() bool {
Expand Down Expand Up @@ -149,7 +150,7 @@ func (pc *schemaPropContext) Object() (*schemaMapContext, error) {
if pc.schema != nil {
switch elem := pc.schema.Elem().(type) {
case shim.Resource:
var fields map[string]*tfbridge.SchemaInfo
var fields map[string]*info.Schema
if pc.schemaInfo != nil {
fields = pc.schemaInfo.Fields
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/convert/secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/schema"
)
Expand All @@ -33,7 +34,7 @@ func TestSecretDecoderInjectsSchemaSecrets(t *testing.T) {
type testCase struct {
name string
schemaMap schema.SchemaMap
schemaInfos map[string]*tfbridge.SchemaInfo
schemaInfos map[string]*info.Schema
val tftypes.Value
expect autogold.Value
}
Expand Down Expand Up @@ -66,7 +67,7 @@ func TestSecretDecoderInjectsSchemaSecrets(t *testing.T) {
Type: shim.TypeString,
}).Shim(),
},
schemaInfos: map[string]*tfbridge.SchemaInfo{
schemaInfos: map[string]*info.Schema{
"secret_value": {
Type: "string",
Secret: tfbridge.True(),
Expand All @@ -93,7 +94,7 @@ func TestSecretDecoderInjectsSchemaSecrets(t *testing.T) {
Sensitive: true,
}).Shim(),
},
schemaInfos: map[string]*tfbridge.SchemaInfo{
schemaInfos: map[string]*info.Schema{
"secret_value": {
Type: "string",
Secret: tfbridge.False(),
Expand Down
6 changes: 3 additions & 3 deletions pkg/internal/tests/pulcheck/pulcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func WithValidProvider(t T, tfp *schema.Provider) *schema.Provider {
}

func ProviderServerFromInfo(
ctx context.Context, providerInfo tfbridge.ProviderInfo,
ctx context.Context, providerInfo info.Provider,
) (pulumirpc.ResourceProviderServer, error) {
sink := pulumidiag.DefaultSink(io.Discard, io.Discard, pulumidiag.FormatOptions{
Color: colors.Never,
Expand All @@ -158,7 +158,7 @@ func ProviderServerFromInfo(
}

// This is an experimental API.
func StartPulumiProvider(ctx context.Context, providerInfo tfbridge.ProviderInfo) (*rpcutil.ServeHandle, error) {
func StartPulumiProvider(ctx context.Context, providerInfo info.Provider) (*rpcutil.ServeHandle, error) {
prov, err := ProviderServerFromInfo(ctx, providerInfo)
if err != nil {
return nil, fmt.Errorf("ProviderServerFromInfo failed: %w", err)
Expand Down Expand Up @@ -231,7 +231,7 @@ func BridgedProvider(t T, providerName string, tfp *schema.Provider, opts ...Bri
shimv2.WithPlanStateEdit(options.StateEdit),
)

provider := tfbridge.ProviderInfo{
provider := info.Provider{
P: shimProvider,
Name: providerName,
Version: "0.0.1",
Expand Down
Loading
Loading