Allow github.token to work on Windows (elastic/elasticsearch#4925)

Original commit: elastic/x-pack-elasticsearch@95c8b79af1
This commit is contained in:
David Roberts 2017-02-09 14:09:51 +00:00 committed by GitHub
parent 8c2ce2c504
commit de5e65b687
1 changed files with 6 additions and 2 deletions

View File

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