Skip to content

Add an optional default value to dock$ARG #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ Suggests:
rmarkdown
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.0
RoxygenNote: 7.1.0
VignetteBuilder: knitr
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# dockerfiler 0.1.3.9000

* Corrected bug in `rthis()`
* `add_arg` can now receive an optional default value (@antoine-sachet, #8)

# dockerfiler 0.1.3

Expand Down
5 changes: 3 additions & 2 deletions R/add.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ add_user <- function(user){
glue("USER {user}")
}

add_arg <- function(arg){
glue("ARG {arg}")
add_arg <- function(arg, default = NULL){
default <- if (!is.null(default)) glue('="{default}"') else ""
glue("ARG {arg}{default}")
}

add_onbuild <- function(cmd){
Expand Down
12 changes: 6 additions & 6 deletions R/dockerfile.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
#' @section Methods:
#' \describe{
#' \item{\code{RUN}}{add a RUN command}
#' \item{\code{ADD}}{add a ADD command}
#' \item{\code{ADD}}{add an ADD command with optional default value}
#' \item{\code{COPY}}{add a COPY command}
#' \item{\code{WORKDIR}}{add a WORKDIR command}
#' \item{\code{EXPOSE}}{add an EXPOSE command}
#' \item{\code{VOLUME}}{add a VOLUME command}
#' \item{\code{CMD}}{add a CMD command}
#' \item{\code{LABEL}}{add a LABEL command}
#' \item{\code{ENV}}{add a ENV command}
#' \item{\code{ENTRYPOINT}}{add a ENTRYPOINT command}
#' \item{\code{ENV}}{add an ENV command}
#' \item{\code{ENTRYPOINT}}{add an ENTRYPOINT command}
#' \item{\code{VOLUME}}{add a VOLUME command}
#' \item{\code{USER}}{add a USER command}
#' \item{\code{ARG}}{add an ARG command}
Expand Down Expand Up @@ -75,11 +75,11 @@ Dockerfile <- R6::R6Class("Dockerfile",
USER = function(user){
self$Dockerfile <- c(self$Dockerfile, add_user(user))
},
ARG = function(arg, ahead = FALSE){
ARG = function(arg, ahead = FALSE, default = NULL){
if (ahead) {
self$Dockerfile <- c(add_arg(arg), self$Dockerfile)
self$Dockerfile <- c(add_arg(arg, default = default), self$Dockerfile)
} else {
self$Dockerfile <- c(self$Dockerfile,add_arg(arg))
self$Dockerfile <- c(self$Dockerfile, add_arg(arg, default = default))
}
},
ONBUILD = function(cmd){
Expand Down
278 changes: 269 additions & 9 deletions man/Dockerfile.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/dock_from_desc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading