Context
In Flogo, when we want to install a contribution (github.com/project-flogo/contrib/activity/log for instance) in an application we run:
flogo install github.com/project-flogo/contrib/activity/log
Currently, this command does a go get -u github.com/project-flogo/contrib/activity/log
(see https://github.com/project-flogo/cli/blob/99f31dabada136e9cddc2e5202d97011a7a315bc/util/mod.go#L80).
By design, go get
cannot fetch a specific revision (tag or branch), but only HEAD (master).
Hence we cannot do something like:
flogo install github.com/project-flogo/contrib/activity/[email protected]
Instead we could use go mod edit
in the flogo install
command instead of go get
:
go mod edit -require github.com/project-flogo/contrib/activity/[email protected]
as tried at https://github.com/square-it/cli/blob/1e044ca3c17e14913e3914700aa4210e55c4292d/util/mod.go#L82.
Issue
However this will lead to this error:
go: finding github.com/project-flogo/contrib/activity/log v0.9.0
go: errors parsing go.mod:
/workspaces/flogo/simple-app/src/go.mod:4: invalid module version "v0.9.0": missing github.com/project-flogo/contrib/activity/log/go.mod at revision 680ebf186e58
That's logic since the go.mod file for this contributions repository lives at github.com/project-flogo/contrib, not at github.com/project-flogo/contrib/activity/log
Solutions
1. use separate contribution import path and contribution module import path
Using a more verbose commands such as:
flogo install github.com/project-flogo/[email protected] github.com/project-flogo/contrib/activity/log
flogo install -module github.com/project-flogo/[email protected] -contrib github.com/project-flogo/contrib/activity/log
the Flogo CLI could use the module import in go.mod and the contribution import path in imports.go.
another more compact representation allowing multiple contributions installation at once
flogo install github.com/project-flogo/[email protected]/activity/log github.com/project-flogo/[email protected]/activity/rest
2. make all contribution (activities, triggers, ...) have their own go.mod file
If we don't want to modify the CLI behaviour, we can also require that any contribution must have its own go.mod file. For instance, go.mod for the github.com/project-flogo/contrib/activity/log activity would look like:
module github.com/project-flogo/contrib/activity/log
require (
...
)
3. Create a new syntax for Flogo imports
Described in PR project-flogo/cli#32
Depends on PRs: