Skip to content

Commit

Permalink
Disable local file system access when not uploading data.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cedric BAIL committed Apr 13, 2022
1 parent 0b9e0f3 commit 3d20573
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
7 changes: 4 additions & 3 deletions internal/command/android.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
28 changes: 15 additions & 13 deletions internal/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
3 changes: 3 additions & 0 deletions internal/command/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3d20573

Please sign in to comment.