Skip to content

Commit

Permalink
[refactor-runner-adxt-783] copy*file are not exported anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
CelianR committed Dec 23, 2024
1 parent d1ef99f commit a6e0c8e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion components/command/filemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (fm *FileManager) HomeDirectory(folderName string, opts ...pulumi.ResourceO
}

func (fm *FileManager) CopyFile(name string, localPath, remotePath pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error) {
return fm.runner.NewCopyFile(name, localPath, remotePath, opts...)
return fm.runner.newCopyFile(name, localPath, remotePath, opts...)
}

func (fm *FileManager) CopyInlineFile(fileContent pulumi.StringInput, remotePath string, opts ...pulumi.ResourceOption) (pulumi.Resource, error) {
Expand Down
21 changes: 11 additions & 10 deletions components/command/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,13 @@ type Runner interface {
Namer() namer.Namer
Config() RunnerConfiguration
OsCommand() OSCommand
PulumiOptions() []pulumi.ResourceOption

Command(name string, args *Args, opts ...pulumi.ResourceOption) (Command, error)
NewCopyFile(name string, localPath, remotePath pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error)
CopyWindowsFile(name string, src, dst pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error)
CopyUnixFile(name string, src, dst pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error)
PulumiOptions() []pulumi.ResourceOption

newCopyFile(name string, localPath, remotePath pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error)
copyWindowsFile(name string, src, dst pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error)
copyUnixFile(name string, src, dst pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error)
}

var _ Runner = &RemoteRunner{}
Expand Down Expand Up @@ -200,7 +201,7 @@ func (r *RemoteRunner) Command(name string, args *Args, opts ...pulumi.ResourceO
return &RemoteCommand{cmd}, nil
}

func (r *RemoteRunner) NewCopyFile(name string, localPath, remotePath pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error) {
func (r *RemoteRunner) newCopyFile(name string, localPath, remotePath pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error) {
return r.osCommand.NewCopyFile(r, name, localPath, remotePath, opts...)
}

Expand Down Expand Up @@ -265,15 +266,15 @@ func (r *LocalRunner) Command(name string, args *Args, opts ...pulumi.ResourceOp
return &LocalCommand{cmd}, nil
}

func (r *LocalRunner) NewCopyFile(name string, localPath, remotePath pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error) {
func (r *LocalRunner) newCopyFile(name string, localPath, remotePath pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error) {
return r.osCommand.NewCopyFile(r, name, localPath, remotePath, opts...)
}

func (r *LocalRunner) PulumiOptions() []pulumi.ResourceOption {
return []pulumi.ResourceOption{}
}

func (r *LocalRunner) CopyWindowsFile(name string, src, dst pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error) {
func (r *LocalRunner) copyWindowsFile(name string, src, dst pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error) {
createCmd := pulumi.Sprintf("Copy-Item -Path '%v' -Destination '%v'", src, dst)
deleteCmd := pulumi.Sprintf("Remove-Item -Path '%v'", dst)
useSudo := false
Expand All @@ -287,7 +288,7 @@ func (r *LocalRunner) CopyWindowsFile(name string, src, dst pulumi.StringInput,
}, opts...)
}

func (r *LocalRunner) CopyUnixFile(name string, src, dst pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error) {
func (r *LocalRunner) copyUnixFile(name string, src, dst pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error) {
createCmd := pulumi.Sprintf("cp '%v' '%v'", src, dst)
deleteCmd := pulumi.Sprintf("rm '%v'", dst)
useSudo := false
Expand All @@ -301,7 +302,7 @@ func (r *LocalRunner) CopyUnixFile(name string, src, dst pulumi.StringInput, opt
}, opts...)
}

func (r *RemoteRunner) CopyWindowsFile(name string, src, dst pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error) {
func (r *RemoteRunner) copyWindowsFile(name string, src, dst pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error) {
return remote.NewCopyFile(r.Environment().Ctx(), r.Namer().ResourceName("copy", name), &remote.CopyFileArgs{
Connection: r.Config().connection,
LocalPath: src,
Expand All @@ -310,7 +311,7 @@ func (r *RemoteRunner) CopyWindowsFile(name string, src, dst pulumi.StringInput,
}, utils.MergeOptions(r.PulumiOptions(), opts...)...)
}

func (r *RemoteRunner) CopyUnixFile(name string, src, dst pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error) {
func (r *RemoteRunner) copyUnixFile(name string, src, dst pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error) {
tempRemotePath := src.ToStringOutput().ApplyT(func(path string) string {
return filepath.Join(r.OsCommand().GetTemporaryDirectory(), filepath.Base(path))
}).(pulumi.StringOutput)
Expand Down
2 changes: 1 addition & 1 deletion components/command/unixOSCommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (fs unixOSCommand) IsPathAbsolute(path string) bool {
}

func (fs unixOSCommand) NewCopyFile(runner Runner, name string, localPath, remotePath pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error) {
return runner.CopyUnixFile(name, localPath, remotePath, opts...)
return runner.copyUnixFile(name, localPath, remotePath, opts...)
}

func formatCommandIfNeeded(command pulumi.StringInput, sudo bool, password bool, user string) pulumi.StringInput {
Expand Down
2 changes: 1 addition & 1 deletion components/command/windowsOSCommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (fs windowsOSCommand) IsPathAbsolute(path string) bool {
}

func (fs windowsOSCommand) NewCopyFile(runner Runner, name string, localPath, remotePath pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error) {
return runner.CopyWindowsFile(name, localPath, remotePath, opts...)
return runner.copyWindowsFile(name, localPath, remotePath, opts...)
}

func (fs windowsOSCommand) MoveFile(runner Runner, name string, source, destination pulumi.StringInput, sudo bool, opts ...pulumi.ResourceOption) (Command, error) {
Expand Down

0 comments on commit a6e0c8e

Please sign in to comment.