Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow connection to other github servers in `board_register_github() #163

Closed
cnolanminich opened this issue Jan 21, 2020 · 3 comments
Closed

Comments

@cnolanminich
Copy link

Love this package and am excited about evangelizing it without my team 🚀

It would be really useful to be able to connect to other GitHub servers (i.e. GitHub Enterprise Servers) with board_register_github().

I think if there were a server argument in the board_register_github() function, similar to the board_register_rsconnect() function, that would satisfy this request but not add much (any?) complexity to the function. Perhaps with a default argument of https://api.github.com/repos/.

I think this would require code changes here and here, and of course updating board_initialize.github() to include an argument for server.

Happy to send a PR your way if this is something you think makes sense in the package.

@javierluraschi
Copy link
Contributor

@cnolanminich don't have GitHub enterprise to properly test this change, but according to their docs, should be as simple as using a different host. Fix available at #181, which you can install as follows:

remotes::install_github("rstudio/pin", ref = "bugfix/github-enterprise-163")

Afterwards, should be possible to use your GitHub Enterprise instance as follows:

library(pins)
board_register_github(repo = "owner/repo", host = "https://yourhostname/api/v3")

@cnolanminich
Copy link
Author

Thanks @javierluraschi! Registering the board to my enterprise GitHub works 💯, and I was able to pin a dataset.

The major remaining problem is that {pins} uses a url pattern to download the data.txt file that is not present in GitHub Enterprise.

Here is the error I get:

pins::pin(mtcars, "test-pins", board = "github")

Error in pin_download(base_url, name, board$name, headers = github_headers(board)) :
Client error: (404) Not Found. Failed to download remote file: https://raw.githubusercontent.com/minichc/test-pins/master/test-pins/data.txt

pins::pin_get("test-pins", board = "github")

Error in pin_download(base_url, name, board$name, headers = github_headers(board)) :
Client error: (404) Not Found. Failed to download remote file: https://raw.githubusercontent.com/minichc/test-pins/master/test-pins/data.txt

I verified that the data is correctly posted to my GitHub enterprise
image

The githubusercontent url for accessing raw files on github.com does not apply in a GitHub Enterprise situation. This is referenced here: https://github.com/rstudio/pins/blob/9ad3006af709cb60d89dfb85a46070ac27f5e9c4/R/board_github.R#L372-L374

If you are open to continuing this, I might suggest using the github_content_url and remove the use of the github_raw_url entirely.

I took a pass at trying to do this, but it became apparent switching it out would involve more substantial changes to how the file is stored.

The error from my forked change:

Error in curl::curl_fetch_disk(url, x$path, handle = handle) :
Failed to open file C:\Users{minichc\AppData\Local\Temp\RtmpeyHyNB\file2fe8209dc2\data.txt?ref=master.
In addition: Warning message:
In named(list(...)) : restarting interrupted promise evaluation

@github-actions
Copy link

github-actions bot commented Sep 1, 2022

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants