Allow vault to work on Windows (elastic/elasticsearch#878)

Original commit: elastic/x-pack-elasticsearch@a404f4793a
This commit is contained in:
David Roberts 2017-02-07 14:59:55 +00:00 committed by GitHub
parent 15160e41a2
commit af10f880fb
1 changed files with 6 additions and 2 deletions

View File

@ -34,9 +34,13 @@ final String VAULT_SECRET_ID = System.env.VAULT_SECRET_ID
String authBody = null
URL vaultUrl = null
if (githubToken.exists()) {
Set<PosixFilePermission> perms = Files.getPosixFilePermissions(githubToken.toPath())
if (perms.equals(PosixFilePermissions.fromString("rw-------")) == false) {
try {
Set<PosixFilePermission> perms = Files.getPosixFilePermissions(githubToken.toPath())
if (perms.equals(PosixFilePermissions.fromString("rw-------")) == false) {
throw new GradleException('github.token must have 600 permissions')
}
} catch (UnsupportedOperationException e) {
// Assume not on a POSIX file system
}
vaultUrl = new URL(VAULT_URL + '/v1/auth/github/login')
authBody = "{\"token\": \"${githubToken.getText('UTF-8').trim()}\"}"