Many thanks for piggyback... it is super-handy for many of our data-keeping needs.
It would be very useful if this worked with Github Enterprise deployments, i.e. Github API servers other than https://api.github.com.
At the moment, it almost works... I can get some functions to play along by setting the environment variable GITHUB_API_URL to the desired Enterprise server location:
This works because many piggyback functions are using gh::gh() and gh::gh_token(), which to allow for the Github API URL to be specified...either explicitly in the arguments, or through the environment variable (if neither is specified, it will default to https://api.github.com).
However, the environment variable trick does not work in functions where https://api.github.com is hard-coded, such as pb_release_create() and pb_release_delete().
Sys.setenv("GITHUB_API_URL" = "https://hostname/api/v3")
pb_release_create("enterprise_owner/enterprise_repo",tag="v0.0.5")
#> $message
#> [1] "Bad credentials"
#>
#> $documentation_url
#> [1] "https://docs.github.com/rest"
#>
#> Warning message:
#> ! Failed to create release: HTTP error 401.
#> See returned error messages for more details
I found that I can get it to work if I modify these package functions to check the environment, similar to what gh is doing. For example, in pb_release_create(), add the line api_url <- Sys.getenv("GITHUB_API_URL", unset = "https://api.github.com"), and change ...url = glue::glue("https://api.github.com/repos/{r[[1]]}/{r[[2]]}/releases")... to ...url = glue::glue("{api_url}/repos/{r[[1]]}/{r[[2]]}/releases")....
See if you think this is worthwhile... not sure if I am missing important considerations but this seems to do the trick for my purposes. I suppose the other way would be to add a .api_url parameter to all the pertinent functions, and make sure the token is appropriately matching.
Many thanks for
piggyback
... it is super-handy for many of our data-keeping needs.It would be very useful if this worked with Github Enterprise deployments, i.e. Github API servers other than
https://api.github.com
.At the moment, it almost works... I can get some functions to play along by setting the environment variable
GITHUB_API_URL
to the desired Enterprise server location:This works because many
piggyback
functions are usinggh::gh()
andgh::gh_token()
, which to allow for the Github API URL to be specified...either explicitly in the arguments, or through the environment variable (if neither is specified, it will default tohttps://api.github.com
).However, the environment variable trick does not work in functions where
https://api.github.com
is hard-coded, such aspb_release_create()
andpb_release_delete()
.I found that I can get it to work if I modify these package functions to check the environment, similar to what
gh
is doing. For example, inpb_release_create()
, add the lineapi_url <- Sys.getenv("GITHUB_API_URL", unset = "https://api.github.com")
, and change...url = glue::glue("https://api.github.com/repos/{r[[1]]}/{r[[2]]}/releases")...
to...url = glue::glue("{api_url}/repos/{r[[1]]}/{r[[2]]}/releases")...
.See if you think this is worthwhile... not sure if I am missing important considerations but this seems to do the trick for my purposes. I suppose the other way would be to add a
.api_url
parameter to all the pertinent functions, and make sure the token is appropriately matching.