Skip to content

Conversation

@linus345
Copy link
Contributor

This PR is an attempt to implement support for docker load.

Related issue #253.

It first makes a small refactor by moving out the run command code into its own file and making the hooks/command file only the entry point. This is the same structure that buildkite-plugins/docker-compose-buildkite-plugin uses. It then introduces a new file for the docker load command.

@linus345
Copy link
Contributor Author

The example added in the README file is the use case that I was thinking of and that we need. I'm not sure if it makes sense to use load without running a container afterwards though.

Copy link
Contributor

@toote toote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great PR! I really appreciate your splitting the huge command hook into separate files.

That said, I don't see the use-case for loading an image without actually running anything on it. The very example you show of using the load configuration also contains an image tag. And if it didn't, I'm not sure using the plugin would make sense in the first place as the docker daemon running that load step may very well not be used for anything else so making the run portion of the plugin inconditional anyways.

I would suggest that the load.sh is executed conditionally as it is now, but the run should always run no matter what.

What do you think?

@linus345
Copy link
Contributor Author

Yes I agree with that in the current state, I'll make the run required. Although I do think it can make sense in the future if other commands like push are implemented.

@linus345 linus345 force-pushed the issue-253/docker-load branch 2 times, most recently from ec6083c to b24a21c Compare July 5, 2023 20:28
Copy link
Contributor

@toote toote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor corrections. While I was at it, I also noticed that you added a load example to the plugin but did not document the configuration itself in the Optional section of README.md (make sure to keep the alphabetical order of them when you add it)

@linus345 linus345 force-pushed the issue-253/docker-load branch 5 times, most recently from 896db83 to bea8101 Compare July 6, 2023 20:59
@linus345
Copy link
Contributor Author

linus345 commented Jul 6, 2023

Thanks for the feedback. Fixed the comments now.

@linus345 linus345 requested a review from toote July 7, 2023 20:33
Copy link
Contributor

@toote toote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch with the shellcheck plugin not including all the new files! 👏

I tend to avoid disabling checks so I provided alternatives for all such instances (plus found that the additional options are not necessary due to a typo)

- libs/**
options:
- "--color=always"
- "--external-sources"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After correcting the typo above, this is no longer necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the testing I did it seems that this is still needed. Shellcheck won't follow the source directives if --external-sources is not used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is really weird, I ran the pipeline without the option and shellcheck did not fail. Can you try removing it so that we can further debug the issue seeing an actual run?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @linus345! thanks again for this! are you able to try toote's suggestions so we can see the issue? thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely missed that this comment was made.

Sure I'll try it out tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for taking such a long time, pushed it without this commit now.

@toote toote linked an issue Jul 18, 2023 that may be closed by this pull request
linus345 added 4 commits July 25, 2023 01:16
This refactor is done to make it easier to introduce additional commands
like `docker load`.
This adds support for providing a `load` argument to load a docker image
before running a command.
Two new directories, `commands` and `lib`, were added and they should
also be shellchecked.
@linus345 linus345 force-pushed the issue-253/docker-load branch from 6f1c21f to 71464d5 Compare July 24, 2023 23:45
@linus345
Copy link
Contributor Author

Finally got around to fixing the comments.

@linus345 linus345 requested a review from toote July 24, 2023 23:49
Sourcing the shared lib script allows shellcheck to see variables that
are defined which is needed to prevent shellcheck from complaining about
referencing unassigned variables.

[SC2154](https://www.shellcheck.net/wiki/SC2154).
`result is referenced but not assigned`
@linus345 linus345 force-pushed the issue-253/docker-load branch from 71464d5 to 4a4d2fb Compare September 26, 2023 19:10
Copy link
Contributor

@toote toote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 sorry for the delay in getting back around to this

@pzeballos pzeballos merged commit 22bed6e into buildkite-plugins:master Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for other docker commands than docker run

3 participants