From aa8888d88dae5afbd0ce51cfbccef6034608812b Mon Sep 17 00:00:00 2001 From: Mike Cobbett <77053+techcobweb@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:07:40 +0000 Subject: [PATCH 1/3] download a re-run folder, and it gets rendered images too. Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com> --- pkg/cmd/runsDownload.go | 20 ----------------- pkg/runs/runsDownload.go | 48 +++++++++++++++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 25 deletions(-) diff --git a/pkg/cmd/runsDownload.go b/pkg/cmd/runsDownload.go index 2c6ef6a7..7dbcaa10 100644 --- a/pkg/cmd/runsDownload.go +++ b/pkg/cmd/runsDownload.go @@ -6,14 +6,10 @@ package cmd import ( - "fmt" "log" "github.com/galasa-dev/cli/pkg/api" "github.com/galasa-dev/cli/pkg/auth" - "github.com/galasa-dev/cli/pkg/embedded" - galasaErrors "github.com/galasa-dev/cli/pkg/errors" - "github.com/galasa-dev/cli/pkg/images" "github.com/galasa-dev/cli/pkg/runs" "github.com/galasa-dev/cli/pkg/utils" "github.com/spf13/cobra" @@ -154,22 +150,6 @@ func (cmd *RunsDownloadCommand) executeRunsDownload( apiClient, cmd.values.runDownloadTargetFolder, ) - - if err == nil { - // No error, so try to expand the files. - embeddedFileSystem := embedded.GetReadOnlyFileSystem() - renderer := images.NewImageRenderer(embeddedFileSystem) - expander := images.NewImageExpander(fileSystem, renderer) - - err = expander.ExpandImages(cmd.values.runDownloadTargetFolder) - if err == nil { - - // Write out a status string to the console about how many files were rendered. - count := expander.GetExpandedImageFileCount() - message := fmt.Sprintf(galasaErrors.GALASA_INFO_RENDERED_IMAGE_COUNT.Template, count) - console.WriteString(message) - } - } } } } diff --git a/pkg/runs/runsDownload.go b/pkg/runs/runsDownload.go index 79efca0b..8e7a2f37 100644 --- a/pkg/runs/runsDownload.go +++ b/pkg/runs/runsDownload.go @@ -22,6 +22,7 @@ import ( galasaErrors "github.com/galasa-dev/cli/pkg/errors" "github.com/galasa-dev/cli/pkg/files" "github.com/galasa-dev/cli/pkg/galasaapi" + "github.com/galasa-dev/cli/pkg/images" "github.com/galasa-dev/cli/pkg/utils" ) @@ -70,7 +71,7 @@ func DownloadArtifacts( var folderName string folderName, err = nameDownloadFolder(runs[0], runName, timeService) if err == nil { - err = downloadArtifactsToDirectory(apiClient, folderName, runs[0], fileSystem, forceDownload, console, runDownloadTargetFolder) + err = downloadArtifactsAndRenderImagesToDirectory(apiClient, folderName, runs[0], fileSystem, forceDownload, console, runDownloadTargetFolder) } } else { log.Printf("No artifacts to download for run: '%s'", runName) @@ -97,7 +98,7 @@ func downloadReRunArtfifacts( for reRunIndex, reRun := range reRunsList { if err == nil { directoryName := nameReRunArtifactDownloadDirectory(reRun, reRunIndex, timeService) - err = downloadArtifactsToDirectory( + err = downloadArtifactsAndRenderImagesToDirectory( apiClient, directoryName, reRun, @@ -158,7 +159,26 @@ func nameDownloadFolder(run galasaapi.Run, runName string, timeService utils.Tim return directoryName, err } -func downloadArtifactsToDirectory(apiClient *galasaapi.APIClient, +func renderImagesInFolder(fileSystem files.FileSystem, folderName string, console utils.Console) error { + var err error + + // No error, so try to expand the files. + embeddedFileSystem := embedded.GetReadOnlyFileSystem() + renderer := images.NewImageRenderer(embeddedFileSystem) + expander := images.NewImageExpander(fileSystem, renderer) + + err = expander.ExpandImages(folderName) + if err == nil { + + // Write out a status string to the console about how many files were rendered. + count := expander.GetExpandedImageFileCount() + message := fmt.Sprintf(galasaErrors.GALASA_INFO_RENDERED_IMAGE_COUNT.Template, count) + console.WriteString(message) + } + return err +} + +func downloadArtifactsAndRenderImagesToDirectory(apiClient *galasaapi.APIClient, directoryName string, run galasaapi.Run, fileSystem files.FileSystem, @@ -166,8 +186,7 @@ func downloadArtifactsToDirectory(apiClient *galasaapi.APIClient, console utils.Console, runDownloadTargetFolder string, ) error { - - runId := run.GetRunId() + var err error // We want to base the directory we download to on the destination folder. // If the destination folder is "." (current folder/relative) @@ -177,6 +196,25 @@ func downloadArtifactsToDirectory(apiClient *galasaapi.APIClient, directoryName = filepath.Join(runDownloadTargetFolder, directoryName) } + err = downloadArtifactsToDirectory(apiClient, directoryName, run, fileSystem, forceDownload, console) + + if err == nil { + err = renderImagesInFolder(fileSystem, directoryName, console) + } + + return err +} + +func downloadArtifactsToDirectory(apiClient *galasaapi.APIClient, + directoryName string, + run galasaapi.Run, + fileSystem files.FileSystem, + forceDownload bool, + console utils.Console, +) error { + + runId := run.GetRunId() + filesWrittenOkCount := 0 artifactPaths, err := GetArtifactPathsFromRestApi(runId, apiClient) From c68953f6d704f92540a0653f41e2bbdfd2edc9a1 Mon Sep 17 00:00:00 2001 From: Mike Cobbett <77053+techcobweb@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:17:45 +0000 Subject: [PATCH 2/3] better image render info msg Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com> --- pkg/errors/errorMessage.go | 2 +- pkg/images/imageExpander.go | 2 ++ pkg/runs/runsDownload.go | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/errors/errorMessage.go b/pkg/errors/errorMessage.go index aae18c46..aba0112a 100644 --- a/pkg/errors/errorMessage.go +++ b/pkg/errors/errorMessage.go @@ -221,5 +221,5 @@ var ( GALASA_WARNING_MAVEN_NO_GALASA_OBR_REPO = NewMessageType("GAL2000W: Warning: Maven configuration file settings.xml should contain a reference to a Galasa repository so that the galasa OBR can be resolved. The official release repository is '%s', and 'pre-release' repository is '%s'", 2000, STACK_TRACE_WANTED) // Information messages... GALASA_INFO_FOLDER_DOWNLOADED_TO = NewMessageType("GAL2501I: Downloaded %d artifacts to folder '%s'\n", 2501, STACK_TRACE_NOT_WANTED) - GALASA_INFO_RENDERED_IMAGE_COUNT = NewMessageType("GAL2502I: Rendered %d image files.\n", 2502, STACK_TRACE_NOT_WANTED) + GALASA_INFO_RENDERED_IMAGE_COUNT = NewMessageType("GAL2502I: Rendered %d image files in folder '%s'\n", 2502, STACK_TRACE_NOT_WANTED) ) diff --git a/pkg/images/imageExpander.go b/pkg/images/imageExpander.go index 9e771812..229ca8d2 100644 --- a/pkg/images/imageExpander.go +++ b/pkg/images/imageExpander.go @@ -40,6 +40,8 @@ func (expander *ImageExpanderImpl) GetExpandedImageFileCount() int { func (expander *ImageExpanderImpl) ExpandImages(rootFolderPath string) error { var err error + log.Printf("Expanding any 3270 image descriptions we have into images. Folder scanned: %s\n", rootFolderPath) + var paths []string paths, err = expander.fs.GetAllFilePaths(rootFolderPath) diff --git a/pkg/runs/runsDownload.go b/pkg/runs/runsDownload.go index 8e7a2f37..927ee429 100644 --- a/pkg/runs/runsDownload.go +++ b/pkg/runs/runsDownload.go @@ -172,7 +172,7 @@ func renderImagesInFolder(fileSystem files.FileSystem, folderName string, consol // Write out a status string to the console about how many files were rendered. count := expander.GetExpandedImageFileCount() - message := fmt.Sprintf(galasaErrors.GALASA_INFO_RENDERED_IMAGE_COUNT.Template, count) + message := fmt.Sprintf(galasaErrors.GALASA_INFO_RENDERED_IMAGE_COUNT.Template, count, folderName) console.WriteString(message) } return err From 8957596dbd935ab955c57f22d64f2de020116e34 Mon Sep 17 00:00:00 2001 From: Mike Cobbett <77053+techcobweb@users.noreply.github.com> Date: Wed, 21 Feb 2024 15:52:49 +0000 Subject: [PATCH 3/3] empty to force a build Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>