-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
first draft for supporting docker-compose v2 #232
Conversation
Hey @ggessner! Thank you so much for contributing this! I will review it and leave some feedback. I definitely looked into supporting Docker Compose V2 quite a while ago, but if I recall correctly there was some fundamental feature that Docker itself no longer supported, but we relied on heavily. Let me look into this and get back to you. |
Okay, actually you can disregard my previous concern. That was an issue with the Compose Specification version (and going to V3), not the Docker Compose binary version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really great contribution, especially for a first contribution to the project! Thank you so much!
I think a couple of minor changes are needed, but after that, I would love to merge this and include it in the next release.
This looks great now! The one last thing is to make sure you have sign-off on your commits. There are some details on how to do that here: https://github.com/hyperledger/firefly-cli/pull/232/checks?check_run_id=10537046269 It may be easiest to squash merge with one new commit with sign off. Sorry for the trouble, but this is just a requirement for all Linux Foundation repos. |
ffd9a4f
to
ebe9faf
Compare
Hi @nguyer, thanks for the advice. I squashed the commits and signed the resulting one. |
Sorry, it's not a signed commit that we need, but rather sign off. You just need to add https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--s Here's a bit more info about it if you need it: https://wiki.linuxfoundation.org/dco |
Signed-off-by: Gernot Gessner <[email protected]>
ebe9faf
to
3f4da04
Compare
That felt like an unnecessary mistake from my side. |
Looks great now! Thank you for contributing this! |
Pull Request
Disclaimer
I'm not a golang developer, so any code presented here is a collection of educated guesses as how to solve the problem.
With that out of the way, let's present the pull request.
Problem
This pull request adresses Issue231: firefly fails check for docker compose v2. The problem arises due to docker changing the syntax for docker-compose from
docker-compose
in version 1 todocker compose
in version 2. There is always the workaround to require the standalone docker-compose in version 1.Fix
The fix is split into two parts, adressing the checking of the version and integrating the information into the stack manager that executes the docker commands via
RunDockerComposeCommand
. The information about which version syntax to use for the commands is carried via context.CheckDockerConfig
the function that checks for the prerequisites when executing docker-compose commands,
CheckDockerConfig
returns a tuple(DockerComposeVersion, error)
withDockerComposeVersion
as enum to differentiate betweenNone
,ComposeV1
andComposeV2
. This value is stored in a context that is later transferred into the stack manager.Unfortunately, cobra with version 1.4.0 does not provide the capability to allow context to be attached to a command.
Only from version 1.5.0, this feature has been merged, for reference: support for SetContext.
The solution using cobra 1.5.0 concerns all commands which use both
PreRunE
andRunE
while also requiring the docker compose version to be transferred as context between these two executions:The functions currently affected are defined in:
accounts_create.go
accounts_list.go
deploy_ethereum.go
deploy_fabric
No version update is required when simply combining both executions, similar to functions from:
info.go
logs.go
reset.go
start.go
RunDockerComposeCommand
The second part of the changes affects the way the stack manager runs docker-compose functions. By retrieving the docker-compose version, either
docker-compose
ordocker compose
can be executedPossible Tweaks
docker compose
is attached to the context withComposeCmd
as key. Consequently, theRunDockerComposeCommand
function simply executesexec.Command(ctx.Value(ComposeCmd{}), command...)
.Open Question
PreRunE
andRunE
necessary, because currently only docker checks are executed inPreRun
. Small commands do not even specifyPreRunE
at all.