From bbae190e995fbf7e9a5e5103ffb18305272673e7 Mon Sep 17 00:00:00 2001 From: Tomas Hozza Date: Tue, 9 Mar 2021 10:28:24 +0100 Subject: [PATCH] worker: share GCP image only if the accounts list is not empty Modify worker's job implementation to try to share GCP image only if the provided list of accounts is not empty. Signed-off-by: Tomas Hozza --- cmd/osbuild-worker/jobimpl-osbuild.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/osbuild-worker/jobimpl-osbuild.go b/cmd/osbuild-worker/jobimpl-osbuild.go index 4da2e4663..e42156d1d 100644 --- a/cmd/osbuild-worker/jobimpl-osbuild.go +++ b/cmd/osbuild-worker/jobimpl-osbuild.go @@ -315,11 +315,13 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error { } log.Printf("[GCP] 💿 Image URL: %s", g.ComputeImageURL(t.ImageName)) - log.Printf("[GCP] 🔗 Sharing the image with: %+v", options.ShareWithAccounts) - err = g.ComputeImageShare(t.ImageName, options.ShareWithAccounts) - if err != nil { - r = append(r, err) - continue + if len(options.ShareWithAccounts) > 0 { + log.Printf("[GCP] 🔗 Sharing the image with: %+v", options.ShareWithAccounts) + err = g.ComputeImageShare(t.ImageName, options.ShareWithAccounts) + if err != nil { + r = append(r, err) + continue + } } targetResults = append(targetResults, target.NewGCPTargetResult(&target.GCPTargetResultOptions{