R/secret.R

Defines functions github_token gitsecret

gitsecret <- function(){
  tryCatch({
    secretfile <- "/etc/opencpu/secret.conf";
    as.list(fromJSON(secretfile));
  }, error=function(e){
    return(NULL)
  })
}

github_token <- function(){
  # Method 1: secret file
  token <- gitsecret()$auth_token
  if(length(token) && nchar(token)){
    return(token)
  }
  # Method 2: env var
  pat <- Sys.getenv("GITHUB_PAT")
  if(nchar(pat))
    return(pat)
  NULL
}
jeroen/opencpu documentation built on Aug. 20, 2018, 9:06 a.m.