osubild-worker: don't use job token as aws key

The job token will be deprecated in favor of URLs.

If a key is not set, use a new random UUID. Also, don't overwrite the
options struct with that new key.
This commit is contained in:
Lars Karlitski 2020-09-08 10:37:38 +02:00 committed by Tom Gundersen
parent ccebfb014c
commit 901d724622

View file

@ -120,18 +120,19 @@ func RunJob(token uuid.UUID, manifest distro.Manifest, targets []*target.Target,
continue
}
if options.Key == "" {
options.Key = token.String()
key := options.Key
if key == "" {
key = uuid.New().String()
}
_, err = a.Upload(path.Join(outputDirectory, options.Filename), options.Bucket, options.Key)
_, err = a.Upload(path.Join(outputDirectory, options.Filename), options.Bucket, key)
if err != nil {
r = append(r, err)
continue
}
/* TODO: communicate back the AMI */
_, err = a.Register(t.ImageName, options.Bucket, options.Key)
_, err = a.Register(t.ImageName, options.Bucket, key)
if err != nil {
r = append(r, err)
continue