R/startup-scripts.R

Defines functions setup_shell_metadata read_shell_startup_file

Documented in read_shell_startup_file

#' create the shell file to upload
#' @keywords internal
#' @import assertthat
read_shell_startup_file <- function(template){
  
  the_file <- get_template_file(template, "startupscripts")
  
  read_and_indent(the_file, indent = 4)

}

setup_shell_metadata <- function(dots,
                                 template, 
                                 username, 
                                 password,
                                 dynamic_image = NULL){
  
  if(!is.null(dynamic_image)){
    assert_that(is.string(dynamic_image))
    the_image <- dynamic_image
  } else {
    the_image <- switch(template,
      "rstudio" = "rocker/tidyverse",
      "rstudio-noauth" = "rocker/verse",
      "rstudio-gpu" = "rocker/ml",
      "rstudio-shiny" = "rocker/tidyverse",
      "shiny" = "rocker/shiny",
      "opencpu" = "opencpu/base",
      "r-base" = "rocker/r-base",
      "r-parallel" = "rocker/r-parallel"
    )
  }
  
  modify_metadata(dots,
                  list(rstudio_user = username,
                       rstudio_pw   = password,
                       gcer_docker_image = the_image))
  
}
cloudyr/googleComputeEngineR documentation built on Jan. 23, 2022, 8:30 a.m.