Skip to content

Instantly share code, notes, and snippets.

@nturaga
Created August 13, 2022 11:01
Show Gist options
  • Save nturaga/e29f4e6462993356cbe63a9b5af76542 to your computer and use it in GitHub Desktop.
Save nturaga/e29f4e6462993356cbe63a9b5af76542 to your computer and use it in GitHub Desktop.
setGeneric("cloud_cp", function(x, ...) standardGeneric("cloud_cp"))
cloud_rm <- function(x, ...)
UseMethod("cloud_rm")
cloud_rsync <- function(x, ...)
UseMethod("cloud_rsync")
## azure
setClass("Cloud")
AzureCloud <- setClass("AzureCloud", contains = "Cloud")
setMethod("cloud_cp", "AzureCloud", function(x, from, to, ...) {
## implement cp for Azure
}
## google
google_cloud <- function()
structure(list(), class = c("gcloud", "cloud"))
cloud_cp.google_cloud <- function(x, from, to, ...) {
AnVIL::gsutil_cp(from, to, ...)
}
## package code
kube_run <- function(cloud_id, ...) {
cloud <- switch(
cloud_id,
azure = azure_cloud(),
google = google_cloud()
)
...
cloud_cp(cloud, ....)
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment