@@ -12,7 +12,9 @@ import (
12
12
"net/http"
13
13
"os"
14
14
"os/exec"
15
+ "strconv"
15
16
"strings"
17
+ "time"
16
18
17
19
"github.com/google/go-github/v71/github"
18
20
"github.com/oracle/oci-go-sdk/v65/core"
@@ -52,7 +54,7 @@ func main() {
52
54
func run (cmd * cobra.Command , argv []string ) error {
53
55
filepath := "images/ubuntu/templates/"
54
56
sourceFile := fmt .Sprintf ("%s%s-%s.pkr.hcl" , filepath , args .os , args .osVersion )
55
- imageFile := fmt .Sprintf ("build/%s-%s/ image.raw" , args . os , args . osVersion )
57
+ imageFile := fmt .Sprintf ("build/image.raw" )
56
58
filename := ""
57
59
imageName := fmt .Sprintf ("%s-%s-%s-gha-image" , args .os , args .osVersion , args .arch )
58
60
@@ -123,15 +125,17 @@ func run(cmd *cobra.Command, argv []string) error {
123
125
}
124
126
log .Printf ("Packer build completed successfully.\n " )
125
127
126
- command = exec .Command ("oci" , "os" , "object" , "put" , "--parallel-upload-count" , "100" , "--bucket-name" , args .bucketName , "--name" , "ubuntu-gha-image" , "--file" , imageFile )
128
+ timestamp := strconv .FormatInt (time .Now ().UTC ().UnixNano (), 10 )
129
+
130
+ command = exec .Command ("oci" , "os" , "object" , "put" , "--parallel-upload-count" , "100" , "--bucket-name" , args .bucketName , "--name" , fmt .Sprintf ("ubuntu-gha-image-%s" , timestamp ), "--file" , imageFile )
127
131
128
132
command .Stdout = os .Stdout
129
133
if err := command .Run (); err != nil {
130
134
log .Print (command .String ())
131
135
log .Fatal ("could not run command: " , err )
132
136
}
133
137
134
- command = exec .Command ("oci" , "compute" , "image" , "import" , "from-object" , "--bucket-name" , args .bucketName , "--compartment-id" , args .compartmentId , "--namespace" , args .namespace , "--operating-system" , imageName , "--display-name" , imageName , "--name" , imageName , "--operating-system-version" , * selectedRelease .TagName )
138
+ command = exec .Command ("oci" , "compute" , "image" , "import" , "from-object" , "--bucket-name" , args .bucketName , "--compartment-id" , args .compartmentId , "--namespace" , args .namespace , "--operating-system" , imageName , "--display-name" , imageName , "--name" , fmt . Sprintf ( "ubuntu-gha-image-%s" , timestamp ) , "--operating-system-version" , * selectedRelease .TagName )
135
139
command .Stdout = os .Stdout
136
140
if err := command .Run (); err != nil {
137
141
log .Print (command .String ())
@@ -346,7 +350,7 @@ source "qemu" "img" {
346
350
iso_url = "%s"
347
351
iso_checksum = "%s"
348
352
memory = 12000
349
- cpus = 3
353
+ cpus = 6
350
354
output_directory = "build/"
351
355
accelerator = "kvm"
352
356
disk_size = "80G"
@@ -358,6 +362,7 @@ source "qemu" "img" {
358
362
ssh_username = "ubuntu"
359
363
ssh_password = "ubuntu"
360
364
ssh_timeout = "60m"
365
+ headless = true
361
366
}` , args .isoURL , args .isoChecksum )
362
367
363
368
replacements [`sources = ["source.azure-arm.build_image"]` ] = `sources = ["source.azure-arm.build_image", "source.qemu.img"]
0 commit comments