diff --git a/components/command/osCommand.go b/components/command/osCommand.go index 21e933abd..2165eec5e 100644 --- a/components/command/osCommand.go +++ b/components/command/osCommand.go @@ -18,7 +18,7 @@ type OSCommand interface { remotePath pulumi.StringInput, useSudo bool, opts ...pulumi.ResourceOption) (Command, error) - MoveRemoteFile(runner Runner, name string, source, destination pulumi.StringInput, sudo bool, opts ...pulumi.ResourceOption) (Command, error) + MoveFile(runner Runner, name string, source, destination pulumi.StringInput, sudo bool, opts ...pulumi.ResourceOption) (Command, error) BuildCommandString( command pulumi.StringInput, diff --git a/components/command/runner.go b/components/command/runner.go index ea1393a77..0ecc53a33 100644 --- a/components/command/runner.go +++ b/components/command/runner.go @@ -326,7 +326,7 @@ func (r *RemoteRunner) CopyUnixFile(name string, src, dst pulumi.StringInput, op return nil, err } - moveCommand, err := r.OsCommand().MoveRemoteFile(r, name, tempRemotePath, dst, true, utils.MergeOptions(opts, utils.PulumiDependsOn(tempCopyFile))...) + moveCommand, err := r.OsCommand().MoveFile(r, name, tempRemotePath, dst, true, utils.MergeOptions(opts, utils.PulumiDependsOn(tempCopyFile))...) if err != nil { return nil, err } diff --git a/components/command/unixOSCommand.go b/components/command/unixOSCommand.go index fbc40d8e2..7f80824f9 100644 --- a/components/command/unixOSCommand.go +++ b/components/command/unixOSCommand.go @@ -95,7 +95,7 @@ func formatCommandIfNeeded(command pulumi.StringInput, sudo bool, password bool, return formattedCommand } -func (fs unixOSCommand) MoveRemoteFile(runner Runner, name string, source, destination pulumi.StringInput, sudo bool, opts ...pulumi.ResourceOption) (Command, error) { +func (fs unixOSCommand) MoveFile(runner Runner, name string, source, destination pulumi.StringInput, sudo bool, opts ...pulumi.ResourceOption) (Command, error) { backupPath := pulumi.Sprintf("%v.%s", destination, backupExtension) copyCommand := pulumi.Sprintf(`cp "%v" "%v"`, source, destination) createCommand := pulumi.Sprintf(`bash -c 'if [ -f "%v" ]; then mv -f "%v" "%v"; fi; %v'`, destination, destination, backupPath, copyCommand) diff --git a/components/command/windowsOSCommand.go b/components/command/windowsOSCommand.go index bdbaaf09e..e4b227575 100644 --- a/components/command/windowsOSCommand.go +++ b/components/command/windowsOSCommand.go @@ -81,7 +81,7 @@ func (fs windowsOSCommand) NewCopyFile(runner Runner, name string, localPath, re return runner.CopyWindowsFile(name, localPath, remotePath, opts...) } -func (fs windowsOSCommand) MoveRemoteFile(runner Runner, name string, source, destination pulumi.StringInput, sudo bool, opts ...pulumi.ResourceOption) (Command, error) { +func (fs windowsOSCommand) MoveFile(runner Runner, name string, source, destination pulumi.StringInput, sudo bool, opts ...pulumi.ResourceOption) (Command, error) { backupPath := pulumi.Sprintf("%v.%s", destination, backupExtension) copyCommand := pulumi.Sprintf(`Copy-Item -Path '%v' -Destination '%v'`, source, destination) createCommand := pulumi.Sprintf(`if (Test-Path '%v') { Move-Item -Force -Path '%v' -Destination '%v' }; %v`, destination, destination, backupPath, copyCommand)