Skip to content

Commit

Permalink
pass CRAN documentation checks
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkEdmondson1234 committed Oct 6, 2016
1 parent bda1971 commit c78efa4
Show file tree
Hide file tree
Showing 21 changed files with 164 additions and 30 deletions.
12 changes: 7 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ Package: harbor
Title: Control docker containers from R
Version: 0.0.1
Authors@R: "Winston Chang <winston@stdout.org> [aut, cre]"
Description: Control docker containers from R
Description: Control docker containers from R, for local of cloud based instances.
Depends:
R (>= 3.0)
Imports:
jsonlite (>= 0.9.12)
jsonlite (>= 0.9.12),
analogsea (>= 0.4.0),
googleComputeEngineR
License: GPL-2
LazyData: true
Suggests:
analogsea
Remotes: cloudyr/googleComputeEngineR
Remotes:
cloudyr/googleComputeEngineR
RoxygenNote: 5.0.1
6 changes: 5 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Generated by roxygen2 (4.0.2): do not edit by hand
# Generated by roxygen2: do not edit by hand

S3method(as.container,character)
S3method(as.container,container)
S3method(as.container,list)
S3method(docker_cmd,droplet)
S3method(docker_cmd,gce_instance)
S3method(docker_cmd,localhost)
S3method(print,container)
S3method(print,localhost)
Expand All @@ -18,3 +19,6 @@ export(docker_inspect)
export(docker_pull)
export(docker_run)
export(localhost)
importFrom(googleComputeEngineR,gce_ssh)
importFrom(stats,setNames)
importFrom(utils,capture.output)
8 changes: 5 additions & 3 deletions R/boot2docker.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# If we're on Mac and Windows, we're using boot2docker, and we need to run the
# equivalent of `$(boot2docker shellinit)`.
#' If we're on Mac and Windows, we're using boot2docker, and we need to run the
#' equivalent of `$(boot2docker shellinit)`.
#' @importFrom stats setNames
#' @keywords internal
boot2docker_shellinit <- function() {
if (!(Sys.info()["sysname"] %in% c("Darwin", "Windows")))
return()
Expand All @@ -15,7 +17,7 @@ boot2docker_shellinit <- function() {
if (length(envvars) != 0) {
envvars <- sub("^ +export +", "", envvars)
envvars <- strsplit(envvars, "=")
envvars <- setNames(pluck(envvars, 2), pluck(envvars, 1))
envvars <- stats::setNames(pluck(envvars, 2), pluck(envvars, 1))
do.call(Sys.setenv, envvars)
}
}
Expand Down
14 changes: 12 additions & 2 deletions R/container.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#' Coerce an object into a container object.
#'
#' @param x An object to coerce
#' @param host A docker host
#'
#' A container object represents a Docker container on a host.
#' @export
as.container <- function(x, host = localhost) UseMethod("as.container")
Expand Down Expand Up @@ -35,6 +38,7 @@ as.container.container <- function(x, host = localhost) {
}

#' @export
#' @importFrom utils capture.output
print.container <- function(x, ...) {
cat("<container>")
cat(
Expand All @@ -44,7 +48,7 @@ print.container <- function(x, ...) {
"\n Command: ", x$cmd,
"\n Host: ",
indent(
paste(capture.output(print(x$host)), collapse = "\n"),
paste(utils::capture.output(print(x$host)), collapse = "\n"),
indent = 2
)
)
Expand All @@ -57,6 +61,8 @@ print.container <- function(x, ...) {
#' This does not use reference semantics, so if you want to store the updated
#' information, you need to save the result.
#'
#' @param container A container object
#'
#' @examples
#' \dontrun{
#' con <- container_update_info(con)
Expand All @@ -69,6 +75,8 @@ container_update_info <- function(container) {

#' Report whether a container is currently running.
#'
#' @inheritParams container_update_info
#'
#' @examples
#' \dontrun{
#' container_running(con)
Expand All @@ -82,6 +90,7 @@ container_running <- function(container) {

#' Delete a container.
#'
#' @inheritParams container_update_info
#' @param force Force removal of a running container.
#' @examples
#' \dontrun{
Expand All @@ -96,8 +105,9 @@ container_rm <- function(container, force = FALSE) {

#' Retrieve logs for a container.
#'
#' @inheritParams container_update_info
#' @param follow Follow log output as it is happening.
#' @param timestamp Show timestamps.
#' @param timestamps Show timestamps.
#' @examples
#' \dontrun{
#' container_rm(con)
Expand Down
1 change: 1 addition & 0 deletions R/containers.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#' Get list of all containers on a host.
#' @inheritParams docker_cmd
#' @export
containers <- function(host = localhost, ...) {
ids <- docker_cmd(host, "ps", "-qa", capture_text = TRUE, ...)
Expand Down
7 changes: 7 additions & 0 deletions R/docker.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#' This is useful for chaining functions. If \code{TRUE}, capture the text
#' output from both stdout and stderr, and return that. Note that \code{TRUE}
#' may not be available on all types of hosts.
#' @param ... Other arguments passed to the SSH command for the host
#'
#' @examples
#' \dontrun{
#' docker_cmd(localhost, "ps", "-a")
Expand All @@ -23,6 +25,8 @@ docker_cmd <- function(host, cmd = NULL, args = NULL, docker_opts = NULL,

#' Pull a docker image onto a host.
#'
#' @inheritParams docker_cmd
#' @param image The docker image to pull e.g. \code{rocker/rstudio}
#' @examples
#' \dontrun{
#' docker_pull(localhost, "debian:testing")
Expand All @@ -37,6 +41,7 @@ docker_pull <- function(host = localhost, image, ...) {

#' Run a command in a new container on a host.
#'
#' @inheritParams docker_cmd
#' @param host An object representing the host where the container will be run.
#' @param image The name or ID of a docker image.
#' @param cmd A command to run in the container.
Expand Down Expand Up @@ -92,6 +97,8 @@ docker_run <- function(host = localhost, image = NULL, cmd = NULL,

#' Inspect one or more containers, given name(s) or ID(s).
#'
#' @inheritParams docker_cmd
#' @param names Names of the containers
#' @return A list of lists, where each sublist represents one container. This is
#' the output of `docker inspect` translated directly from raw JSON to an R
#' object.
Expand Down
1 change: 1 addition & 0 deletions R/googleComputeEngine.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#' @export
#' @importFrom googleComputeEngineR gce_ssh
docker_cmd.gce_instance <- function(host, cmd = NULL, args = NULL,
docker_opts = NULL, capture_text = FALSE, ...) {
cmd_string <- paste(c("docker", cmd, docker_opts, args), collapse = " ")
Expand Down
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ It presently works with:

* The local computer that R is running on (`localhost`)
* Remote virtual machines running on Digital Ocean, with the [analogsea](https://github.com/sckott/analogsea) package.

* Remote virtual machines running on Google Compute Engine, with the [googleComputeEngineR](https://github.com/cloudyr/googleComputeEngineR) package.

## Installation

Expand All @@ -17,6 +17,9 @@ devtools::install_github("wch/harbor")

# Optional
devtools::install_github("sckott/analogsea")

# Optional
devtools::install_github("cloudyr/googleComputeEngineR")
```


Expand Down Expand Up @@ -54,6 +57,8 @@ The same commands can be used with docker images on a remote host, using the ana

Note: you may need to configure ssh host keys on Digital Ocean for the following to work.

## DigitalOcean

```R
library(analogsea)

Expand Down Expand Up @@ -84,3 +89,38 @@ con
# Destroy the virtual machine from Digital Ocean
droplet_delete(dhost)
```

## Google Compute Engine

```R
library(googleComputeEngineR)

# Create a virtual machine on Digital Ocean
ghost <- gce_vm_create("demo",
image_project = "google-containers",
image_family = "gci-stable")

# Create and run a container in the virtual machine.
# This might take a while.
con <- docker_run(ghost, "debian", "echo foo")
#> Unable to find image 'debian' locally
#> debian:latest: The image you are pulling has been verified
#> Status: Downloaded newer image for debian:latest
#> foo

con
#> <container>
#> ID: 5aa987cef673
#> Name: harbor_8pfvgi
#> Image: busybox
#> Command: echo foo
#> Host: <droplet>dhost (2941098)
#> IP: 107.170.247.231
#> Status: active
#> Region: San Francisco 1
#> Image: Docker 1.3.0 on Ubuntu 14.04
#> Size: 512mb ($0.00744 / hr)

# Destroy the virtual machine from Google Compute Engine
gce_vm_delete(ghost)
```
2 changes: 1 addition & 1 deletion harbor.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
PackageRoxygenize: rd,collate,namespace,vignette
12 changes: 10 additions & 2 deletions man/as.container.Rd

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

15 changes: 15 additions & 0 deletions man/boot2docker_shellinit.Rd

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

9 changes: 6 additions & 3 deletions man/container_logs.Rd

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

5 changes: 4 additions & 1 deletion man/container_rm.Rd

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

6 changes: 5 additions & 1 deletion man/container_running.Rd

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

6 changes: 5 additions & 1 deletion man/container_update_info.Rd

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

8 changes: 7 additions & 1 deletion man/containers.Rd

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

5 changes: 4 additions & 1 deletion man/docker_cmd.Rd

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

Loading

0 comments on commit c78efa4

Please sign in to comment.