Skip to content

Commit

Permalink
Add correct outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
iwahbe committed Dec 16, 2021
1 parent 827ea43 commit 4eee159
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
29 changes: 17 additions & 12 deletions provider/pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,21 @@ func (k *commandProvider) Diff(ctx context.Context, req *pulumirpc.DiffRequest)
return nil, err
}

d := olds.Diff(news)
changes := pulumirpc.DiffResponse_DIFF_NONE
var replaces []string
// TODO: Non-replace changes
for _, replaceKey := range []string{"environment", "dir", "interpreter", "create", "connection", "localPath", "remotePath"} {
i := sort.SearchStrings(req.IgnoreChanges, replaceKey)
if i < len(req.IgnoreChanges) && req.IgnoreChanges[i] == replaceKey {
continue
}
if d.Changed(resource.PropertyKey(replaceKey)) {
changes = pulumirpc.DiffResponse_DIFF_SOME
replaces = append(replaces, replaceKey)
replaces := []string{}
if d := olds.Diff(news); d != nil {
// TODO: Non-replace changes
for _, replaceKey := range []string{"environment", "dir", "interpreter", "create", "connection", "localPath", "remotePath"} {
i := sort.SearchStrings(req.IgnoreChanges, replaceKey)
if i < len(req.IgnoreChanges) && req.IgnoreChanges[i] == replaceKey {
continue
}
if d.Changed(resource.PropertyKey(replaceKey)) {
changes = pulumirpc.DiffResponse_DIFF_SOME
replaces = append(replaces, replaceKey)
}
}
}

// TODO: Detailed diffs

return &pulumirpc.DiffResponse{
Expand Down Expand Up @@ -215,6 +215,11 @@ func (k *commandProvider) Create(ctx context.Context, req *pulumirpc.CreateReque
if err != nil {
return nil, err
}

outputs, err = mapper.New(&mapper.Opts{IgnoreMissing: true, IgnoreUnrecognized: true}).Encode(cpf)
if err != nil {
return nil, err
}
}

outputProperties, err := plugin.MarshalProperties(
Expand Down
8 changes: 4 additions & 4 deletions provider/pkg/provider/remotecommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ import (
)

type remoteconnection struct {
User *string `pulumi:"user,optional"`
User string `pulumi:"user,optional"`
Password *string `pulumi:"password,optional"`
Host string `pulumi:"host"`
Port *int `pulumi:"port,optional"`
Port int `pulumi:"port,optional"`
PrivateKey *string `pulumi:"privateKey,optional"`
}

// Generate an ssh config from a connection specification.
func (con remoteconnection) SShConfig() (*ssh.ClientConfig, error) {
config := &ssh.ClientConfig{
User: *con.User,
User: con.User,
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
}
if con.PrivateKey != nil {
Expand Down Expand Up @@ -72,7 +72,7 @@ func (con remoteconnection) Dial(ctx context.Context, config *ssh.ClientConfig)
_, _, err = retry.Until(ctx, retry.Acceptor{
Accept: func(try int, nextRetryTime time.Duration) (bool, interface{}, error) {
client, err = ssh.Dial("tcp",
net.JoinHostPort(con.Host, fmt.Sprintf("%d", *con.Port)),
net.JoinHostPort(con.Host, fmt.Sprintf("%d", con.Port)),
config)
if err != nil {
if try > 10 {
Expand Down
5 changes: 3 additions & 2 deletions provider/pkg/provider/remotefilecopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ type remotefilecopy struct {
}

func (c *remotefilecopy) RunCreate(ctx context.Context, host *provider.HostClient, urn resource.URN) (string, error) {

host.Log(ctx, diag.Debug, urn,
fmt.Sprintf("Creating file: %s:%s from local file %s", c.Connection.Host, c.RemotePath, c.LocalPath))
inner := func() error {
src, err := os.Open(c.LocalPath)
if err != nil {
Expand Down Expand Up @@ -74,6 +75,6 @@ func (c *remotefilecopy) RunCreate(ctx context.Context, host *provider.HostClien
}

func (c *remotefilecopy) RunDelete(ctx context.Context, host *provider.HostClient, urn resource.URN) error {
host.Log(ctx, diag.Debug, urn, fmt.Sprintf("Delete called for %s", urn))
host.Log(ctx, diag.Debug, urn, fmt.Sprintf("CopyFile delete is a no-op", urn))
return nil
}

0 comments on commit 4eee159

Please sign in to comment.