@@ -22,6 +22,7 @@ import (
22
22
galasaErrors "github.com/galasa-dev/cli/pkg/errors"
23
23
"github.com/galasa-dev/cli/pkg/files"
24
24
"github.com/galasa-dev/cli/pkg/galasaapi"
25
+ "github.com/galasa-dev/cli/pkg/images"
25
26
"github.com/galasa-dev/cli/pkg/utils"
26
27
)
27
28
@@ -70,7 +71,7 @@ func DownloadArtifacts(
70
71
var folderName string
71
72
folderName , err = nameDownloadFolder (runs [0 ], runName , timeService )
72
73
if err == nil {
73
- err = downloadArtifactsToDirectory (apiClient , folderName , runs [0 ], fileSystem , forceDownload , console , runDownloadTargetFolder )
74
+ err = downloadArtifactsAndRenderImagesToDirectory (apiClient , folderName , runs [0 ], fileSystem , forceDownload , console , runDownloadTargetFolder )
74
75
}
75
76
} else {
76
77
log .Printf ("No artifacts to download for run: '%s'" , runName )
@@ -97,7 +98,7 @@ func downloadReRunArtfifacts(
97
98
for reRunIndex , reRun := range reRunsList {
98
99
if err == nil {
99
100
directoryName := nameReRunArtifactDownloadDirectory (reRun , reRunIndex , timeService )
100
- err = downloadArtifactsToDirectory (
101
+ err = downloadArtifactsAndRenderImagesToDirectory (
101
102
apiClient ,
102
103
directoryName ,
103
104
reRun ,
@@ -158,16 +159,34 @@ func nameDownloadFolder(run galasaapi.Run, runName string, timeService utils.Tim
158
159
return directoryName , err
159
160
}
160
161
161
- func downloadArtifactsToDirectory (apiClient * galasaapi.APIClient ,
162
+ func renderImagesInFolder (fileSystem files.FileSystem , folderName string , console utils.Console ) error {
163
+ var err error
164
+
165
+ // No error, so try to expand the files.
166
+ embeddedFileSystem := embedded .GetReadOnlyFileSystem ()
167
+ renderer := images .NewImageRenderer (embeddedFileSystem )
168
+ expander := images .NewImageExpander (fileSystem , renderer )
169
+
170
+ err = expander .ExpandImages (folderName )
171
+ if err == nil {
172
+
173
+ // Write out a status string to the console about how many files were rendered.
174
+ count := expander .GetExpandedImageFileCount ()
175
+ message := fmt .Sprintf (galasaErrors .GALASA_INFO_RENDERED_IMAGE_COUNT .Template , count , folderName )
176
+ console .WriteString (message )
177
+ }
178
+ return err
179
+ }
180
+
181
+ func downloadArtifactsAndRenderImagesToDirectory (apiClient * galasaapi.APIClient ,
162
182
directoryName string ,
163
183
run galasaapi.Run ,
164
184
fileSystem files.FileSystem ,
165
185
forceDownload bool ,
166
186
console utils.Console ,
167
187
runDownloadTargetFolder string ,
168
188
) error {
169
-
170
- runId := run .GetRunId ()
189
+ var err error
171
190
172
191
// We want to base the directory we download to on the destination folder.
173
192
// If the destination folder is "." (current folder/relative)
@@ -177,6 +196,25 @@ func downloadArtifactsToDirectory(apiClient *galasaapi.APIClient,
177
196
directoryName = filepath .Join (runDownloadTargetFolder , directoryName )
178
197
}
179
198
199
+ err = downloadArtifactsToDirectory (apiClient , directoryName , run , fileSystem , forceDownload , console )
200
+
201
+ if err == nil {
202
+ err = renderImagesInFolder (fileSystem , directoryName , console )
203
+ }
204
+
205
+ return err
206
+ }
207
+
208
+ func downloadArtifactsToDirectory (apiClient * galasaapi.APIClient ,
209
+ directoryName string ,
210
+ run galasaapi.Run ,
211
+ fileSystem files.FileSystem ,
212
+ forceDownload bool ,
213
+ console utils.Console ,
214
+ ) error {
215
+
216
+ runId := run .GetRunId ()
217
+
180
218
filesWrittenOkCount := 0
181
219
182
220
artifactPaths , err := GetArtifactPathsFromRestApi (runId , apiClient )
0 commit comments