-
-
Notifications
You must be signed in to change notification settings - Fork 511
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
feat: support creating compose Stacks from Readers #466
feat: support creating compose Stacks from Readers #466
Conversation
testcontainers#285 add constructor that takes []io.Reader
Hi @goforbroke1006 , thanks for your first contribution to TC-go. We are currently reviewing #463, which could cause this PR to be updated. If you agree, I'd like to have your PR after the other one. |
Hi @mdelapenya , |
Hi @goforbroke1006 we have merged #476, which adds native support for docker compose. Would you mind revisiting this PR and update to that code? I can assist if needed, or we can even ping @baez90 for that. Thanks in advance |
…ader # Conflicts: # compose.go # compose_test.go
testcontainers#285 add constructor that takes []io.Reader
Hi @mdelapenya , |
compose.go
Outdated
@@ -175,3 +179,41 @@ func NewLocalDockerCompose(filePaths []string, identifier string, opts ...LocalD | |||
|
|||
return dc | |||
} | |||
|
|||
func NewDockerComposeWithReaders(readers []io.Reader) (*dockerCompose, error) { |
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.
Thanks for the change, at first sight LGTM.
Wdyt if we create a WithReaders
function, as in https://github.com/testcontainers/testcontainers-go/pull/466/files#diff-4c4f2f19edfc5e047aef7e584ae2608724405f66563c6ee3b9957a19febada2bR95, implementing what you did, that can be directly called by the NewDockerComposeWith
func?
We could even refactor the NewDockerCompose
constructor to directly accept ComposeOptions, being possible to pass WithStackFiles
or WithStackReaders
I'd also like to check with @baez90, as he contributed the new compose API
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.
Yeah, it's great idea.
I created WithStackReaders
helper function. And it can be used with NewDockerComposeWith
contructor.
And of course I remove NewDockerComposeWithReaders
.
Unit test is updated.
But in ComposeStackOption.applyToComposeStack
implementation for ComposeStackReaders I did not find another way process errors, so use panic(err). I'm not sure it's good idea, but don't know how to do better.
testcontainers#285 add WithReaders helper function
testcontainers#285 disable tmp files dir cleaning
testcontainers#285 change to avoid filepath collision on parallel tests running
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.
I've tested your PR locally, and this LGTM 👍 Thanks for your patience while reviewing it
I'm going to rename the issue for the changelog, to:
feat: support creating compose stacks from Readers
@baez90, as contributor of the compose code, would you mind giving a quick look at this PR? 🙏 |
Sorry I gave it a quick look but haven't had time to review it properly. But what came to my mind is: if tc-go should support type NamedReader interface {
io.Reader
Name() string
} (by default implemented e.g. by to be able to create a Regarding the option interface we're currently using: it'd be possible to extend the signature to be able to return an error if necessary because the interface should not be implemented outside of tc-go therefore changing the signature shouldn't be a breaking change although I'm not sure if this is necessary considering the alternative to create the Generally I'm wondering what kind of use case you have for this feature 😅 are you generating stack files or downloading them? |
Thanks @baez90 for your assistance, I wonder if we could tackle your comments in a follow-up PR of in this one, so that we can see progress on it. What would it be your preference? @goforbroke1006 and yours? |
If you'd prefer to split it I'd probably not update the signature of the options interface because ideally we don't need an IMHO options should not include (much) logic but should only influence logic when they are applied hence the requirement of returning an error indicates a design issue for an option. I'm still curious what the use case of the whole PR is and if this is actually within the scope of tc-go. |
I would definitely second @baez90 in asking for the context of the PR. Like this, it is unclear to me why it should be added, besides adding a technical capability. |
@baez90 Hi
|
|
Guys, I see. About light-weight options - I agree. |
@goforbroke1006 sorry but I missed your comment as I went on parental leave on Dec 10th. If you agree, let's close this PR so you could work on a brand new PR with the compose examples. Thanks for your time! |
#285
add constructor that takes []io.Reader