Skip to content

Commit

Permalink
Look for secrets in keyring too
Browse files Browse the repository at this point in the history
* [ ] Update vignette

Fixes #346
  • Loading branch information
hadley committed Dec 24, 2024
1 parent e6f425e commit 99bd6b9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Suggests:
httpuv,
jose,
jsonlite,
keyring,
knitr,
later (>= 1.4.0),
paws.common,
Expand Down
7 changes: 7 additions & 0 deletions R/secret.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ secret_has_key <- function(key) {
}

secret_get_key <- function(envvar, call = caller_env()) {
if (is_installed("keyring")) {
key <- tryCatch(keyring::key_get(envvar), error = function(e) NULL)
if (!is.null(key)) {
return(key)

Check warning on line 166 in R/secret.R

View check run for this annotation

Codecov / codecov/patch

R/secret.R#L166

Added line #L166 was not covered by tests
}
}

key <- Sys.getenv(envvar)

if (identical(key, "")) {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-curl.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ test_that("can translate data", {

expect_snapshot({
curl_translate("curl http://example.com --data abcdef")
curl_translate("curl http://example.com --data abcdef -H Content-Type:text/plain")
curl_translate("curl http://example.com --data abcdef -H Content-Type:text/plain") |>
})
})

Expand Down

0 comments on commit 99bd6b9

Please sign in to comment.