From 3d2057322e6875c90cf9e3bfcc878c8f8ae70eb1 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Wed, 13 Apr 2022 12:39:13 -0600 Subject: [PATCH] Disable local file system access when not uploading data. --- internal/command/android.go | 7 ++++--- internal/command/command.go | 28 +++++++++++++++------------- internal/command/container.go | 3 +++ 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/internal/command/android.go b/internal/command/android.go index 0e10a17d..fd1957a4 100644 --- a/internal/command/android.go +++ b/internal/command/android.go @@ -176,9 +176,10 @@ func (cmd *Android) makeAndroidContainerImages(flags *androidFlags, args []strin return fmt.Errorf("keystore location must be relative to the project root: %s", ctx.Volume.WorkDirHost()) } - _, err = os.Stat(volume.JoinPathHost(ctx.Volume.WorkDirHost(), flags.Keystore)) - if err != nil { - return fmt.Errorf("keystore location must be under the project root: %s", ctx.Volume.WorkDirHost()) + if !ctx.NoProjectUpload { + if _, err := os.Stat(volume.JoinPathHost(ctx.Volume.WorkDirHost(), flags.Keystore)); err != nil { + return fmt.Errorf("keystore location must be under the project root: %s", ctx.Volume.WorkDirHost()) + } } cmd.defaultContext.Keystore = volume.JoinPathContainer(cmd.defaultContext.Volume.WorkDirContainer(), flags.Keystore) diff --git a/internal/command/command.go b/internal/command/command.go index 51a984fc..e475f34c 100644 --- a/internal/command/command.go +++ b/internal/command/command.go @@ -139,22 +139,24 @@ func cleanTargetDirs(ctx Context, image ContainerImage) error { // prepareIcon prepares the icon for packaging func prepareIcon(ctx Context, image ContainerImage) error { - if _, err := os.Stat(ctx.Icon); os.IsNotExist(err) { - defaultIcon, err := volume.DefaultIconHost() - if err != nil { - return err - } + if !ctx.NoProjectUpload { + if _, err := os.Stat(ctx.Icon); os.IsNotExist(err) { + defaultIcon, err := volume.DefaultIconHost() + if err != nil { + return err + } - if ctx.Icon != defaultIcon { - return fmt.Errorf("icon not found at %q", ctx.Icon) - } + if ctx.Icon != defaultIcon { + return fmt.Errorf("icon not found at %q", ctx.Icon) + } - log.Infof("[!] Default icon not found at %q", ctx.Icon) - err = ioutil.WriteFile(ctx.Icon, icon.FyneLogo, 0644) - if err != nil { - return fmt.Errorf("could not create the temporary icon: %s", err) + log.Infof("[!] Default icon not found at %q", ctx.Icon) + err = ioutil.WriteFile(ctx.Icon, icon.FyneLogo, 0644) + if err != nil { + return fmt.Errorf("could not create the temporary icon: %s", err) + } + log.Infof("[✓] Created a placeholder icon using Fyne logo for testing purpose") } - log.Infof("[✓] Created a placeholder icon using Fyne logo for testing purpose") } if image.GetOS() == "windows" { diff --git a/internal/command/container.go b/internal/command/container.go index e04268c6..7c5f9f8a 100644 --- a/internal/command/container.go +++ b/internal/command/container.go @@ -148,6 +148,9 @@ func (a *AllContainerImage) AppendTag(tag string) { // goModInit ensure a go.mod exists. If not try to generates a temporary one func goModInit(ctx Context, image ContainerImage) error { + if ctx.NoProjectUpload { + return nil + } goModPath := volume.JoinPathHost(ctx.WorkDirHost(), "go.mod") log.Infof("[i] Checking for go.mod: %s", goModPath)