Skip to content

Commit

Permalink
Filepath join should use separator of the target VM instead of runner
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinFairise2 committed Jan 10, 2025
1 parent 221bbc8 commit e889e4f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/command/osCommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type OSCommand interface {
user string) pulumi.StringInput

IsPathAbsolute(path string) bool
PathJoin(parts ...string) string

NewCopyFile(runner *Runner, name string, localPath, remotePath pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error)
}
Expand Down Expand Up @@ -64,7 +65,6 @@ func buildCommandString(
if command == nil {
return nil
}

envVarsStr := envVars.ToStringArrayOutput().ApplyT(func(inputs []string) string {
return strings.Join(inputs, " ")
}).(pulumi.StringOutput)
Expand Down
6 changes: 5 additions & 1 deletion components/command/unixOSCommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@ func (fs unixOSCommand) BuildCommandString(command pulumi.StringInput, env pulum
})
}

func (fs unixOSCommand) PathJoin(parts ...string) string {
return strings.Join(parts, "/")
}

func (fs unixOSCommand) IsPathAbsolute(path string) bool {
return strings.HasPrefix(path, "/")
}

func (fs unixOSCommand) NewCopyFile(runner *Runner, name string, localPath, remotePath pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error) {
tempRemotePath := localPath.ToStringOutput().ApplyT(func(path string) string {
return filepath.Join(runner.osCommand.GetTemporaryDirectory(), filepath.Base(path))
return fs.PathJoin(runner.osCommand.GetTemporaryDirectory(), filepath.Base(path))
}).(pulumi.StringOutput)

tempCopyFile, err := remote.NewCopyFile(runner.e.Ctx(), runner.namer.ResourceName("copy", name), &remote.CopyFileArgs{
Expand Down
4 changes: 4 additions & 0 deletions components/command/windowsOSCommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ func (fs windowsOSCommand) BuildCommandString(
})
}

func (fs windowsOSCommand) PathJoin(parts ...string) string {
return strings.Join(parts, "\\")
}

func (fs windowsOSCommand) IsPathAbsolute(path string) bool {
// valid absolute path prefixes: "x:\", "x:/", "\\", "//" ]
if len(path) < 2 {
Expand Down

0 comments on commit e889e4f

Please sign in to comment.