-
Notifications
You must be signed in to change notification settings - Fork 391
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
Add support for github gists #306
Conversation
binderhub/repoproviders.py
Outdated
parts = self.spec.split('/') | ||
self.user, self.gist_id, *_ = parts | ||
if len(parts) > 2: | ||
self.unresolved_ref = parts[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this usecase? A versioned gist? And just double-checking that here unresolved_ref
would be set to gist_id
...is that correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gists are just git repositories, and so we should version them the same too!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that should be parts[2]
doh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
w00t, this is awesome. Some comments about enforcing versioning, but that's about it.
binderhub/repoproviders.py
Outdated
parts = self.spec.split('/') | ||
self.user, self.gist_id, *_ = parts | ||
if len(parts) > 2: | ||
self.unresolved_ref = parts[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gists are just git repositories, and so we should version them the same too!
|
||
Users must provide a spec that matches the following form (similar to github) | ||
|
||
<username>/<gist-id>[/<ref>] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean the ref is optional? I'd ideally like it to not be optional in the URL (we can ofc construct it in the JS). Git cloning says the default branch is master, so we should require a ref and go through the usual process of resolving it in the backend IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so there is no branch called master
as far as the upstream gist repo is concerned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can use master
as a sentinal value meaning latest in the history chain if we want
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, hmm. I did a git clone and got to 'master'. Perhaps that's git clone's behavior? Am unsure. Am +1 using master as sentinel if that's not the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is nothing in the gist api it seems to resolve branch names, probably doesn't really have any of them. Going to treat ''
and 'master'
as just meaning latest
return self.resolved_ref | ||
|
||
def get_build_slug(self): | ||
return self.gist_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will coalesce multiple revisions of gists building at the same time, which isn't what we want. It should involve both the id and the resolved ref IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we dont use the resolved ref for any of the other build slugs, that gets added later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, whoops. Sorry about that.
binderhub/app.py
Outdated
@@ -19,7 +19,7 @@ | |||
from .launcher import Launcher | |||
from .registry import DockerRegistry | |||
from .main import MainHandler, ParameterizedMainHandler, LegacyRedirectHandler | |||
from .repoproviders import GitHubRepoProvider, GitRepoProvider, GitLabRepoProvider | |||
from .repoproviders import GitHubRepoProvider, GitRepoProvider, GitLabRepoProvider, GitHubGistRepoProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: can this be GitHubGistProvider
or even GistProvider
? I don't know anywhere except GitHub that has Gists.
We should add a flag that lets the owner of the binderhub enable/disable private gist support. |
@betatim done |
binderhub/repoproviders.py
Outdated
ref_info = json.loads(resp.body.decode('utf-8')) | ||
|
||
if (not self.allow_secret_gist) and (not ref_info['public']): | ||
raise ValueError("gist is marked as secret, this is unsupported") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> "Gist is marked as secret, to enable secret Gist support set GistRepoProvider.allow_secret_gist = True"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a comment above line 382 or in the docstring that calls out the default behavior too.
For ValueError message:
You seem to want to use a secret Gist, but do not have permission to do so. To enable secret Gist support, set (or have an administrator set) 'GistRepoProvider.allow_secret_gist = True'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. One suggestion about commenting and one about error message.
binderhub/repoproviders.py
Outdated
ref_info = json.loads(resp.body.decode('utf-8')) | ||
|
||
if (not self.allow_secret_gist) and (not ref_info['public']): | ||
raise ValueError("gist is marked as secret, this is unsupported") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a comment above line 382 or in the docstring that calls out the default behavior too.
For ValueError message:
You seem to want to use a secret Gist, but do not have permission to do so. To enable secret Gist support, set (or have an administrator set) 'GistRepoProvider.allow_secret_gist = True'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mariusvniekerk for making the changes I suggested.
Sorry about the delay in merging! TYVM for the PR! |
Congrats on the PR being merged @mariusvniekerk. We appreciate the contribution. 👍 |
🎉 Should we deploy (and enable) this to mybinder.org? |
I think we should deploy this, test it out a bit, and open an issue to write documentation for it (+ gitlab + raw git repos) |
Note that users can't actually use any of this yet since we don't have any UI for it. |
yeah I know, but to me that's a feature rather than a bug :-) IMO we should
plan to document and/or add UI around it in a couple of weeks once we've
had time to see the feature in action, WDYT?
…On Mon, Dec 4, 2017 at 9:19 AM Yuvi Panda ***@***.***> wrote:
Note that users can't actually use any of this yet since we don't have any
UI for it.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#306 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABwSHacflR5l0GpXZXvSgkSkf_213oC5ks5s9CmTgaJpZM4Qt1B7>
.
|
what do you mean by see the feature in action? :) The only way to use them right now is to write your own JavaScript... |
oops - maybe I was mistaken, I thought this PR adds the URL entrypoint for gists, does it not? |
Nope, we don't have URL endpoints for gist nor gitlab :) |
@yuvipanda does #322 cover the remaining work needed for gist, gitlab, and other support? |
@@ -165,6 +165,7 @@ def _add_slash(self, proposal): | |||
repo_providers = Dict( | |||
{ | |||
'gh': GitHubRepoProvider, | |||
'gist': GistRepoProvider, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this add the endpoint? If not could someone point me to the bit of code that would need editing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only for the API. If you look at main.py's ParameterizedMainHandler and templates/index.html, you'll see that the code simply dumps it into the appropriate textboxes and triggers 'launch' by fake-clicking the launch button. And if you look at index.js it's hardcoded to use gh....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! I hadn't read the code closely enough and assumed that the ParametrizedMainHandler
kicks off the build :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not that smart yet :)
Since this work needs to touch the js, should we finish up and deploy #252 first?
No description provided.