Skip to content

Commit

Permalink
Fixed an issue with Docker secrets
Browse files Browse the repository at this point in the history
We need to remove leading and trailing whitespace and/or newlines when reading the secrets file. They get added when using secrets with docker-compose
  • Loading branch information
MadsNielsen committed Mar 27, 2018
1 parent 0b2b6a3 commit c83470c
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class DockerSecretSource extends SecretSource {
public Optional<String> reveal(String secret) throws IOException {
final File file = new File("/run/secrets/" + secret);
if (file.exists()) {
return Optional.of(FileUtils.readFileToString(file));
return Optional.of(FileUtils.readFileToString(file).trim());
}
return Optional.empty();
}
Expand Down

2 comments on commit c83470c

@buep
Copy link
Member

@buep buep commented on c83470c Apr 3, 2018

Choose a reason for hiding this comment

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

I would really like to see the reason for this change... it not obvious to me that we should trim the string here., I expect I'm allowed to use white-space for example in my passwords.

The changes was done as part of our demo project by Mads Praqma/praqma-jenkins-casc#1 and due to problems with reading the password.

We will need to look further into this issues before the above change make sense.

@buep
Copy link
Member

@buep buep commented on c83470c Apr 3, 2018

Choose a reason for hiding this comment

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

It could be the read file to string method that gives problems.

Please sign in to comment.