forked from r-lib/gargle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose service account info (r-lib#234)
* Make sure compat file is up-to-date * Export gce_instance_service_accounts() Refactor a bunch of other stuff * Add NEWS bullet; update vignette * Include new function in reference index * Don't insist on making "computeMetadata/v1/" part of the path It's not required to determine if the VM is on GCE, so this allows is_gce() to be more minimal and, perhaps, less likely to time out (that is pure speculation). * This should have always been `||`, not `%||%` * Hardening
- Loading branch information
Showing
11 changed files
with
141 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
test_that("GCE metadata server hostname is correct w.r.t. option and env var", { | ||
withr::local_options(list(gargle.gce.use_ip = NULL)) | ||
withr::local_envvar(c(GCE_METADATA_URL = NA)) | ||
expect_equal(gce_metadata_hostname(), "metadata.google.internal") | ||
|
||
withr::local_options(list(gargle.gce.use_ip = FALSE)) | ||
expect_equal(gce_metadata_hostname(), "metadata.google.internal") | ||
|
||
withr::local_envvar(GCE_METADATA_URL = "some.fake.hostname") | ||
expect_equal(gce_metadata_hostname(), "some.fake.hostname") | ||
}) | ||
|
||
test_that("GCE metadata server IP address is correct w.r.t. option and env var", { | ||
withr::local_options(list(gargle.gce.use_ip = TRUE)) | ||
withr::local_envvar(c(GCE_METADATA_IP = NA)) | ||
expect_equal(gce_metadata_hostname(), "169.254.169.254") | ||
|
||
withr::local_envvar(c(GCE_METADATA_IP = "1.2.3.4")) | ||
expect_equal(gce_metadata_hostname(), "1.2.3.4") | ||
}) | ||
|
||
test_that("GCE metadata detection fails not on GCE", { | ||
withr::local_envvar(GCE_METADATA_URL = "some.fake.hostname") | ||
expect_false(is_gce()) | ||
}) | ||
|
||
test_that("Can list service accounts", { | ||
skip_if_not(is_gce(), "Not on GCE") | ||
service_accounts <- gce_instance_service_accounts() | ||
expect_s3_class(service_accounts, class = "data.frame") | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters