From 517fc1e05b86a9dcc2553cbcc2fec279516a0cbc Mon Sep 17 00:00:00 2001 From: James Shubin Date: Thu, 28 Nov 2024 16:29:33 -0500 Subject: [PATCH] lang: gapi: Remap the module path correctly If we've set the --module-path arg, then we expect to rebase that path out of the deploy, and instead it should show up as /modules/ which is the standard. Handle this scenario. --- lang/gapi/gapi.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lang/gapi/gapi.go b/lang/gapi/gapi.go index b8bacc19..1cb85f15 100644 --- a/lang/gapi/gapi.go +++ b/lang/gapi/gapi.go @@ -424,6 +424,16 @@ func (obj *GAPI) Cli(info *gapi.Info) (*gapi.Deploy, error) { logf("base:\n%s", m) return nil, errwrap.Wrapf(err, "malformed source module path: `%s`", src) } + } else if modules != "" && strings.HasPrefix(src, modules) { + // Here we've succeeded in the above rebase, but before + // we accept it completely, let's first check if it's + // actually a MODULE_PATH situation. If so, let's rebase + // it only the `/modules/` directory which is used in + // the deploy. + dst, err = util.Rebase(src, modules, "/"+interfaces.ModuleDirectory) + if err != nil { + return nil, errwrap.Wrapf(err, "malformed src path: `%s`", src) + } } if strings.HasSuffix(src, "/") { // it's a dir