Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Added github authentication package in pool installation (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
brnleehng committed Aug 13, 2019
1 parent 9e9b494 commit d206fd6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
13 changes: 11 additions & 2 deletions R/cluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,17 @@ makeCluster <-
if (!is.null(poolConfig$rPackages) &&
!is.null(poolConfig$rPackages$github) &&
length(poolConfig$rPackages$github) > 0) {
installGithubCommand <-
getPoolPackageInstallationCommand("github", poolConfig$rPackages$github)

if (!is.null(config$githubAuthenticationToken) &&
config$githubAuthenticationToken != "") {
installGithubCommand <-
getPoolPackageInstallationCommand("github", poolConfig$rPackages$github, config$githubAuthenticationToken)
}
else {
installGithubCommand <-
getPoolPackageInstallationCommand("github", poolConfig$rPackages$github)
}

packages <- c(packages, installGithubCommand)
}

Expand Down
19 changes: 18 additions & 1 deletion R/utility-commands.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ getJobPackageInstallationCommand <- function(type, packages) {
}
}

getPoolPackageInstallationCommand <- function(type, packages) {
getPoolPackageInstallationCommand <- function(type, packages, githubAuthenticationToken = "") {
sharedPackagesDirectory <- "/mnt/batch/tasks/shared/R/packages"

libPathsCommand <- paste0('\'.libPaths( c( \\\"',
Expand All @@ -41,6 +41,13 @@ getPoolPackageInstallationCommand <- function(type, packages) {
)
}
else if (type == "github") {
if (githubAuthenticationToken != "") {
installCommand <-
paste(installCommand,
sprintf("-e \'githubAuthToken <- \\\"%s\\\"\'", githubAuthenticationToken),
"-e \'Sys.setenv(GITHUB_PAT = githubAuthToken)\'")
}

poolInstallationCommand <-
paste(
installCommand,
Expand Down Expand Up @@ -130,6 +137,16 @@ dockerRunCommand <-
"-e AZ_BATCH_JOB_PREP_WORKING_DIR=$AZ_BATCH_JOB_PREP_WORKING_DIR",
"-e BLOBXFER_SASKEY=$BLOBXFER_SASKEY"
)

config <- getConfiguration()
if (!is.null(config$githubAuthenticationToken)
&& config$githubAuthenticationToken != "") {
dockerOptions <-
paste(
dockerOptions,
"-e GITHUB_PAT=$GITHUB_PAT"
)
}
}

dockerRunCommand <-
Expand Down

0 comments on commit d206fd6

Please sign in to comment.