Skip to content

Commit f2b5a8e

Browse files
committed
profile: Fix issue finding workloads dir
For profiles started from a Git repository, the Config.RootDir was being initiated with a full path. Later in the workload run process, that full path was being joined to another full path, leading to an invalid workload dir. Signed-off-by: Paulo Gomes <[email protected]>
1 parent e4ac683 commit f2b5a8e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

internal/qubesome/run.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,13 @@ func runner(in WorkloadInfo) error {
147147
}
148148
}
149149

150-
workloadsDir, err := files.WorkloadsDir(in.Config.RootDir, profile.Path)
150+
var workloadsDir string
151+
rel, err := filepath.Rel(in.Config.RootDir, profile.Path)
152+
if err != nil {
153+
workloadsDir, err = files.WorkloadsDir(in.Config.RootDir, profile.Path)
154+
} else {
155+
workloadsDir, err = files.WorkloadsDir(in.Config.RootDir, rel)
156+
}
151157
if err != nil {
152158
return err
153159
}
@@ -172,6 +178,13 @@ func runner(in WorkloadInfo) error {
172178
return fmt.Errorf("cannot unmarshal workload config %q: %w", cfg, err)
173179
}
174180

181+
if filepath.IsAbs(profile.Path) {
182+
profile.Path, err = filepath.Rel(in.Config.RootDir, profile.Path)
183+
if err != nil {
184+
return fmt.Errorf("profile path must be relative to config rootdir: %w", err)
185+
}
186+
}
187+
175188
pp, err := securejoin.SecureJoin(in.Config.RootDir, profile.Path)
176189
if err != nil {
177190
return err

0 commit comments

Comments
 (0)