diff --git a/docs/docs/100-reference/01-command-line/acorn_dev.md b/docs/docs/100-reference/01-command-line/acorn_dev.md index 75dde52f1..6c7b3c581 100644 --- a/docs/docs/100-reference/01-command-line/acorn_dev.md +++ b/docs/docs/100-reference/01-command-line/acorn_dev.md @@ -17,6 +17,7 @@ acorn dev acorn dev . acorn dev --name wandering-sound acorn dev --name wandering-sound +acorn dev --name wandering-sound --clone [acorn args] ``` @@ -26,7 +27,7 @@ acorn dev --name wandering-sound --args-file string Default args to apply to run/update command (default ".args.acorn") --auto-upgrade Enabled automatic upgrades. -b, --bidirectional-sync In interactive mode download changes in addition to uploading - --clone Clone the vcs repository for the given app + --clone Clone the vcs repository and infer the build context for the given app allowing for local development -f, --file string Name of the build file (default "DIRECTORY/Acornfile") -h, --help help for dev --help-advanced Show verbose help text diff --git a/pkg/cli/dev.go b/pkg/cli/dev.go index 183f45e4c..f261a0985 100644 --- a/pkg/cli/dev.go +++ b/pkg/cli/dev.go @@ -24,6 +24,7 @@ acorn dev acorn dev . acorn dev --name wandering-sound acorn dev --name wandering-sound +acorn dev --name wandering-sound --clone [acorn args] `}) // This will produce an error if the volume flag doesn't exist or a completion function has already @@ -46,7 +47,7 @@ type Dev struct { RunArgs BidirectionalSync bool `usage:"In interactive mode download changes in addition to uploading" short:"b"` Replace bool `usage:"Replace the app with only defined values, resetting undefined fields to default values" json:"replace,omitempty"` // Replace sets patchMode to false, resulting in a full update, resetting all undefined fields to their defaults - Clone bool `usage:"Clone the vcs repository for the given app"` + Clone bool `usage:"Clone the vcs repository and infer the build context for the given app allowing for local development"` HelpAdvanced bool `usage:"Show verbose help text"` out io.Writer client ClientFactory @@ -73,16 +74,14 @@ func (s *Dev) Run(cmd *cobra.Command, args []string) error { if err != nil { return err } - acornfile, buildContext, err := vcs.ImageInfoFromApp(cmd.Context(), app) if err != nil { return err } - bc := app.Status.Staged.AppImage.VCS.BuildContext - if bc != "" { - args = append(args, buildContext) - } + // We append the build context to the start of the args so that it gets set, and we can pass any args down to the running app + args = append([]string{buildContext}, args...) + imageSource = imagesource.NewImageSource(s.client.AcornConfigFile(), acornfile, s.ArgsFile, args, nil, z.Dereference(s.AutoUpgrade)) } diff --git a/pkg/vcs/vcs.go b/pkg/vcs/vcs.go index f27501c0c..f022b52a1 100644 --- a/pkg/vcs/vcs.go +++ b/pkg/vcs/vcs.go @@ -105,6 +105,7 @@ func ImageInfoFromApp(ctx context.Context, app *apiv1.App) (string, string, erro } for _, remote := range vcs.Remotes { + // Since we use ssh auth to clone the repo we need a git url but will sometimes get http urls var gitUrl string httpUrl, err := url.Parse(remote) if err == nil { @@ -113,6 +114,7 @@ func ImageInfoFromApp(ctx context.Context, app *apiv1.App) (string, string, erro gitUrl = remote } + // Determine the repository name from the repo url idx := strings.LastIndex(remote, "/") if idx < 0 || idx >= len(remote) { fmt.Printf("failed to determine repository name %q\n", remote) @@ -163,12 +165,7 @@ func ImageInfoFromApp(ctx context.Context, app *apiv1.App) (string, string, erro } // Get the build context - var buildContext string - if vcs.BuildContext == "." { - buildContext = workdir - } else { - buildContext = filepath.Join(workdir, vcs.BuildContext) - } + buildContext := filepath.Join(workdir, vcs.BuildContext) return acornfile, buildContext, nil }