Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADXT-815] [e2e] filepath.Join should be agnostic of the runner OS #1351

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/command/osCommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,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)
copyLocalFile(runner *LocalRunner, name string, src, dst pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error)
Expand Down Expand Up @@ -67,7 +68,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,6 +68,10 @@ 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, "/")
}
Expand Down Expand Up @@ -121,7 +125,7 @@ func (fs unixOSCommand) copyLocalFile(runner *LocalRunner, name string, src, dst

func (fs unixOSCommand) copyRemoteFile(runner *RemoteRunner, name string, src, dst pulumi.StringInput, opts ...pulumi.ResourceOption) (pulumi.Resource, error) {
tempRemotePath := src.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.Environment().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
Loading