Skip to content
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

#446 'set permission when copying' #467

Closed
wants to merge 4 commits into from
Closed

#446 'set permission when copying' #467

wants to merge 4 commits into from

Conversation

glebsts
Copy link
Contributor

@glebsts glebsts commented Sep 30, 2017

  • added method overloads, logic for setting file mode, few tests, some javadoc

@@ -10,7 +10,11 @@
import org.jetbrains.annotations.NotNull;
import org.testcontainers.images.builder.Transferable;

import java.io.*;
import java.io.File;
Copy link
Contributor Author

@glebsts glebsts Oct 3, 2017

Choose a reason for hiding this comment

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

my intellij configured to not allow wildcard imports. Dunno what's your policy.

Copy link
Member

Choose a reason for hiding this comment

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

The policy is... clearly not well defined enough to be useful!
I've enabled a Codacy check to discourage wildcard imports and will check my IDE settings match for the future (I have no strong preference, but "shouldn't use" is easier to lint for than "should use").

@@ -68,4 +104,31 @@ public void simpleRecursiveClasspathResourceTest() throws TimeoutException {
// ExternalResource.class is known to exist in a subdirectory of /org/junit so should be successfully copied in
assertTrue("The container has a file that was copied in via a recursive copy from a JAR resource", results.contains("content.txt"));
}

public static <T> Matcher<Iterable<? super T>> exactlyNItems(final int n, Matcher<? super T> elementMatcher) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copied from stackoverflow. AssertJ has it built-in :\

Copy link
Member

Choose a reason for hiding this comment

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

😬 sorry!

private final String path;
private final int permissions;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I first made it Integer, with default value null, but 0-check still looks better than null-check. Wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

I was going to say I'm fine with this, but had a thought: if we do this, then it's not possible for people to deliberately assign an all-zeroes file mode. That would be an incredibly strange thing for someone to do, but the resulting behaviour would be quite confusing.

Just a thought on naming too: given that the concept is referred to as * mode throughout the class, would it make more sense to use something similar, e.g. forcedMode or overrideMode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. I am still for int type. Check for -1 may be?

Copy link
Member

Choose a reason for hiding this comment

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

Go for it. Since the primitive nature doesn't leak outside of the class, I think it's reasonable.

@@ -33,7 +37,11 @@
@Slf4j
public class MountableFile implements Transferable {

private static final int BASE_FILE_MODE = 0100000;
Copy link
Contributor Author

@glebsts glebsts Oct 3, 2017

Choose a reason for hiding this comment

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

Base taken from Transferable, probably could be some bit math on Transferable.DEFAULT_FILE_MODE with making last three digits to zero.

Copy link
Member

Choose a reason for hiding this comment

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

Probably unlikely to change, so 👍

Copy link
Member

@rnorth rnorth 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 taking so long to get around to reviewing. This change looks good, so thank you for submitting it!

private final String path;
private final int permissions;
Copy link
Member

Choose a reason for hiding this comment

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

I was going to say I'm fine with this, but had a thought: if we do this, then it's not possible for people to deliberately assign an all-zeroes file mode. That would be an incredibly strange thing for someone to do, but the resulting behaviour would be quite confusing.

Just a thought on naming too: given that the concept is referred to as * mode throughout the class, would it make more sense to use something similar, e.g. forcedMode or overrideMode?

@@ -10,7 +10,11 @@
import org.jetbrains.annotations.NotNull;
import org.testcontainers.images.builder.Transferable;

import java.io.*;
import java.io.File;
Copy link
Member

Choose a reason for hiding this comment

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

The policy is... clearly not well defined enough to be useful!
I've enabled a Codacy check to discourage wildcard imports and will check my IDE settings match for the future (I have no strong preference, but "shouldn't use" is easier to lint for than "should use").

@@ -33,7 +37,11 @@
@Slf4j
public class MountableFile implements Transferable {

private static final int BASE_FILE_MODE = 0100000;
Copy link
Member

Choose a reason for hiding this comment

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

Probably unlikely to change, so 👍

@@ -68,4 +104,31 @@ public void simpleRecursiveClasspathResourceTest() throws TimeoutException {
// ExternalResource.class is known to exist in a subdirectory of /org/junit so should be successfully copied in
assertTrue("The container has a file that was copied in via a recursive copy from a JAR resource", results.contains("content.txt"));
}

public static <T> Matcher<Iterable<? super T>> exactlyNItems(final int n, Matcher<? super T> elementMatcher) {
Copy link
Member

Choose a reason for hiding this comment

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

😬 sorry!

CHANGELOG.md Outdated
@@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
- Clarified wording of pre-flight check messages (#457, #436)
- Added caching of failure to find a docker daemon, so that subsequent tests fail fast. This is likely to be a significant improvement in situations where there is no docker daemon available, dramatically reducing run time and log output when further attempts to find the docker daemon cannot succeed.
- Allowing JDBC containers' username, password and DB name to be customized (#400, #354)
- Added support for explicitly setting file mode when copying file into container (#446)
Copy link
Member

Choose a reason for hiding this comment

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

As I've released 1.4.3 now, please could you shift up to the top of the changelog?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So it will get to 1.4.4?

Copy link
Member

Choose a reason for hiding this comment

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

Yes.

@glebsts
Copy link
Contributor Author

glebsts commented Oct 15, 2017

Sorry for taking so long to get around to reviewing. This change looks good, so thank you for submitting it!

Its ok. Just sad_panda because it was not reviewed, updated and merged before release. Now have to wait even more. Feels like lack of maintainers time :)
Despite of that still very happy of this library.

@rnorth
Copy link
Member

rnorth commented Oct 16, 2017

@glebsts thanks for your understanding, and sorry again. There was a big existing queue of merged-but-unreleased things, and I had to draw the line somewhere.
I'd like to make the next release be small, so hopefully you won't have to wait much more!

Gleb Stsenov added 2 commits November 9, 2017 10:21
# Conflicts:
#	CHANGELOG.md
…t can force 0 value; renamed field; updated changelog update
@glebsts
Copy link
Contributor Author

glebsts commented Nov 9, 2017

Sorry, also took a while to deal with testcontainers, had been busy with other projects. Updated PR based on your comments.

@glebsts
Copy link
Contributor Author

glebsts commented Nov 9, 2017

could smbd pls restart travis run?

@rnorth
Copy link
Member

rnorth commented Nov 11, 2017

@glebsts Github is complaining (unnecessarily?) about merge conflicts, so I'm doing a manual rebase myself. It's looking good to me, so I'll merge in a bit if you don't object.

@rnorth rnorth mentioned this pull request Nov 11, 2017
@rnorth rnorth closed this in #486 Nov 11, 2017
@glebsts glebsts deleted the 446-set-file-mode branch September 13, 2021 20:44
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.

None yet

2 participants