Skip to content

Commit

Permalink
fix partial init errors
Browse files Browse the repository at this point in the history
  • Loading branch information
VenelinMartinov committed Dec 6, 2024
1 parent 0852d64 commit 9be63d5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
2 changes: 2 additions & 0 deletions pkg/tfbridge/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"log"
"os"
"q"

Check failure on line 22 in pkg/tfbridge/provider.go

View workflow job for this annotation

GitHub Actions / Test and Lint / test (1.22.x, ubuntu-latest, PULUMI_TF_BRIDGE_ACCURATE_BRIDGE_PREVIEW)

package q is not in std (/home/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.2.linux-amd64/src/q)

Check failure on line 22 in pkg/tfbridge/provider.go

View workflow job for this annotation

GitHub Actions / Test and Lint / test (1.22.x, macos-latest, PULUMI_TF_BRIDGE_ACCURATE_BRIDGE_PREVIEW)

package q is not in std (/Users/runner/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.2.darwin-arm64/src/q)

Check failure on line 22 in pkg/tfbridge/provider.go

View workflow job for this annotation

GitHub Actions / Test and Lint / test (1.23.x, ubuntu-latest, DEFAULT)

package q is not in std (/opt/hostedtoolcache/go/1.23.3/x64/src/q)

Check failure on line 22 in pkg/tfbridge/provider.go

View workflow job for this annotation

GitHub Actions / Test and Lint / test (1.23.x, ubuntu-latest, PULUMI_TF_BRIDGE_ACCURATE_BRIDGE_PREVIEW)

package q is not in std (/opt/hostedtoolcache/go/1.23.3/x64/src/q)
"sort"
"strings"
"time"
Expand Down Expand Up @@ -1340,6 +1341,7 @@ func (p *Provider) Create(ctx context.Context, req *pulumirpc.CreateRequest) (*p
var reasons []string
if !req.GetPreview() {
newstate, err = p.tf.Apply(ctx, res.TFName, nil, diff)
q.Q(newstate, err)
if newstate == nil {
if err == nil {
return nil, fmt.Errorf("expected non-nil error with nil state during Create of %s", urn)
Expand Down
27 changes: 15 additions & 12 deletions pkg/tfshim/sdk-v2/provider2.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"maps"
"q"
"sort"
"strings"
"time"
Expand Down Expand Up @@ -348,8 +349,9 @@ func (p *planResourceChangeImpl) Apply(
}

resp, err := p.server.ApplyResourceChange(ctx, t, ty, cfg, st, pl, priv, meta)
q.Q(resp, err)
if err != nil {
return nil, err
return resp, err
}
return &v2InstanceState2{
resourceType: t,
Expand Down Expand Up @@ -662,25 +664,26 @@ func (s *grpcServer) ApplyResourceChange(
}
req.ProviderMeta = &tfprotov5.DynamicValue{MsgPack: providerMetaVal}
}
resp, err := s.gserver.ApplyResourceChange(ctx, req)
if err := handleDiagnostics(ctx, resp.Diagnostics, err); err != nil {
return nil, err
}
newState, err := msgpack.Unmarshal(resp.NewState.MsgPack, ty)
if err != nil {
return nil, err
}
resp, applyErr := s.gserver.ApplyResourceChange(ctx, req)
newState := cty.Value{}
var meta map[string]interface{}
if resp.Private != nil {
if err := json.Unmarshal(resp.Private, &meta); err != nil {
if resp != nil && resp.NewState != nil {
newState, err = msgpack.Unmarshal(resp.NewState.MsgPack, ty)
if err != nil {
return nil, err
}
if resp.Private != nil {
if err := json.Unmarshal(resp.Private, &meta); err != nil {
return nil, err
}
}
}
returnErr := handleDiagnostics(ctx, resp.Diagnostics, applyErr)
return &v2InstanceState2{
resourceType: typeName,
stateValue: newState,
meta: meta,
}, nil
}, returnErr
}

func (s *grpcServer) ReadResource(
Expand Down

0 comments on commit 9be63d5

Please sign in to comment.