Skip to content

Commit

Permalink
check gcloud version to increase robustness of gcloud_exists
Browse files Browse the repository at this point in the history
  • Loading branch information
LiNk-NY committed Oct 25, 2024
1 parent fc05d4b commit a1deb68
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
15 changes: 12 additions & 3 deletions R/gcloud.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@
#' for details on how `gcloud` is located.
NULL

gcloud_runs <- function() {
tryCatch({
.gcloud_do("version")[1L] |>
startsWith("Google Cloud SDK")
}, error = function(...) FALSE)
}

#' @rdname gcloud-deprecated
#'
#' @description `gcloud_exists()` tests whether the `gcloud()` command
#' can be found on this system. See 'Details' section of `gsutil`
#' for where the application is searched.
#' can be found on this system. After finding the binary location,
#' it runs `gcloud version` to identify potentially misconfigured
#' installations. See 'Details' section of `gsutil` for where the
#' application is searched.
#'
#' @return `gcloud_exists()` returns `TRUE` when the `gcloud`
#' application can be found, FALSE otherwise.
Expand All @@ -39,7 +48,7 @@ gcloud_exists <-
result <- tryCatch({
.gcloud_sdk_find_binary("gcloud")
}, error = function(...) "")
nchar(result) > 0L
nzchar(result) && gcloud_runs()
}

#' @importFrom utils tail
Expand Down
6 changes: 4 additions & 2 deletions man/gcloud-deprecated.Rd

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

0 comments on commit a1deb68

Please sign in to comment.