From ad72dbf9e02d43a498589a13b044ba4504289b6b Mon Sep 17 00:00:00 2001 From: Abhay Krishna Arunachalam Date: Mon, 16 Oct 2023 19:54:35 -0700 Subject: [PATCH] Revert changes to CloudStack output glob --- projects/aws/image-builder/builder/builder.go | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/projects/aws/image-builder/builder/builder.go b/projects/aws/image-builder/builder/builder.go index cf1a547e49..6677dbe0e3 100644 --- a/projects/aws/image-builder/builder/builder.go +++ b/projects/aws/image-builder/builder/builder.go @@ -87,6 +87,7 @@ func (b *BuildOptions) BuildImage() { commandEnvVars = append(commandEnvVars, fmt.Sprintf("%s=%s", packerAdditionalFilesConfigFileEnvVar, additionalFilesConfigFile)) } + var outputImageGlobPattern string if b.Hypervisor == VSphere { // Set proxy on RHSM if available if b.Os == RedHat && b.VsphereConfig.HttpProxy != "" { @@ -128,11 +129,7 @@ func (b *BuildOptions) BuildImage() { log.Fatalf("Error executing image-builder for vsphere hypervisor: %v", err) } - // Move the output ova to cwd - outputImageGlob, err = filepath.Glob(filepath.Join(upstreamImageBuilderProjectPath, "output/*.ova")) - if err != nil { - log.Fatalf("Error getting glob for output files: %v", err) - } + outputImageGlobPattern = "output/*.ova" outputArtifactPath = filepath.Join(cwd, fmt.Sprintf("%s.ova", b.Os)) log.Printf("Image Build Successful\n Please find the output artifact at %s\n", outputArtifactPath) @@ -178,12 +175,10 @@ func (b *BuildOptions) BuildImage() { log.Fatalf("Error executing image-builder for raw hypervisor: %v", err) } - outputImageGlob, err = filepath.Glob(filepath.Join(upstreamImageBuilderProjectPath, "output/*.gz")) - if err != nil { - log.Fatalf("Error getting glob for output files: %v", err) - } - + outputImageGlobPattern = "output/*.gz" outputArtifactPath = filepath.Join(cwd, fmt.Sprintf("%s.gz", b.Os)) + + log.Printf("Image Build Successful\n Please find the output artifact at %s\n", outputArtifactPath) } else if b.Hypervisor == Nutanix { // Patch firmware config for tool upstreamPatchCommand := fmt.Sprintf("make -C %s patch-repo", imageBuilderProjectPath) @@ -233,10 +228,9 @@ func (b *BuildOptions) BuildImage() { } var buildCommand string - var outputImageGlobPattern string switch b.Os { case RedHat: - outputImageGlobPattern = "output/rhel-*" + outputImageGlobPattern = "output/rhel-*/rhel-*" buildCommand = fmt.Sprintf("make -C %s local-build-cloudstack-redhat-%s", imageBuilderProjectPath, b.OsVersion) commandEnvVars = append(commandEnvVars, fmt.Sprintf("%s=%s", rhelUsernameEnvVar, b.CloudstackConfig.RhelUsername), @@ -254,11 +248,6 @@ func (b *BuildOptions) BuildImage() { log.Fatalf("Error executing image-builder for raw hypervisor: %v", err) } - outputImageGlob, err = filepath.Glob(filepath.Join(upstreamImageBuilderProjectPath, outputImageGlobPattern)) - if err != nil { - log.Fatalf("Error getting glob for output files: %v", err) - } - outputArtifactPath = filepath.Join(cwd, fmt.Sprintf("%s.qcow2", b.Os)) log.Printf("Image Build Successful\n Please find the output artifact at %s\n", outputArtifactPath) @@ -293,6 +282,11 @@ func (b *BuildOptions) BuildImage() { } if outputArtifactPath != "" { + outputImageGlob, err = filepath.Glob(filepath.Join(upstreamImageBuilderProjectPath, outputImageGlobPattern)) + if err != nil { + log.Fatalf("Error getting glob for output files: %v", err) + } + // Moving artifacts from upstream directory to cwd log.Println("Moving artifacts from build directory to current working directory") err = os.Rename(outputImageGlob[0], outputArtifactPath)