Useful for editing existing buildsteps

cr_buildstep_edit(x, ...)

Arguments

x

A buildstep created previously

...

Arguments passed on to cr_buildstep

name

name of docker image to call appended to prefix

args

character vector of arguments

prefix

prefixed to name - set to "" to suppress. Will be suppressed if name starts with gcr.io or *-docker.pkg.dev

entrypoint

change the entrypoint for the docker container

dir

The directory to use, relative to /workspace e.g. /workspace/deploy/

id

Optional id for the step

env

Environment variables for this step. A character vector for each assignment

volumes

volumes to connect and write to

waitFor

Whether to wait for previous buildsteps to complete before running. Default it will wait for previous step.

secretEnv

A list of secrets stored in Secret Manager referred to in args via a $$var

Examples

package_build <- system.file("cloudbuild/cloudbuild.yaml",
  package = "googleCloudRunner"
)
build <- cr_build_make(package_build)
build
#> ==CloudBuildObject==
#> steps:
#> - name: gcr.io/cloud-builders/docker
#>   id: Docker Version
#>   args: version
#> - name: alpine
#>   id: Hello Cloud Build
#>   args:
#>   - echo
#>   - Hello Cloud Build
#> - name: rocker/r-base
#>   id: Hello R
#>   args:
#>   - Rscript
#>   - -e
#>   - paste0('1 + 1 = ', 1+1)
cr_buildstep_extract(build, step = 1)
#> [[1]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/docker
#> args:
#> - version
#> id: Docker Version
#> 
cr_buildstep_extract(build, step = 2)
#> [[1]]
#> ==cloudRunnerBuildStep==
#> name: alpine
#> args:
#> - echo
#> - Hello Cloud Build
#> id: Hello Cloud Build
#> 

edit_me <- cr_buildstep_extract(build, step = 2)
cr_buildstep_edit(edit_me, name = "blah")
#> [[1]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/blah
#> args:
#> - echo
#> - Hello Cloud Build
#> id: Hello Cloud Build
#> 
cr_buildstep_edit(edit_me, name = "gcr.io/blah")
#> [[1]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/blah
#> args:
#> - echo
#> - Hello Cloud Build
#> id: Hello Cloud Build
#> 
cr_buildstep_edit(edit_me, args = c("blah1", "blah2"), dir = "meh")
#> [[1]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/alpine
#> args:
#> - blah1
#> - blah2
#> id: Hello Cloud Build
#> dir: meh
#> 

# to edit multiple buildsteps at once
bs <- c(cr_buildstep_extract(build, 1), cr_buildstep_extract(build, 2))
lapply(bs, function(x) cr_buildstep_edit(list(x), dir = "blah")[[1]])
#> [[1]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/docker
#> args:
#> - version
#> id: Docker Version
#> dir: blah
#> 
#> [[2]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/alpine
#> args:
#> - echo
#> - Hello Cloud Build
#> id: Hello Cloud Build
#> dir: blah
#>