-
Notifications
You must be signed in to change notification settings - Fork 26
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
Support for GitHub Enterprise closes #70 #160
Support for GitHub Enterprise closes #70 #160
Conversation
Quick note that I'm excited to see support for GitHub enterprise - thanks @mheiges! Have wanted this for a long time, but didn't have the ability to test. |
some sample queries run against GHE, mostly verifying that
|
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.
@mheiges Sorry for the slight delay in reviewing this PR, I've added a few questions/suggestions, can you please have a look when you get a chance? Also, can you please resolve the merge conflicts? Thanks!
} | ||
|
||
if token == "" { | ||
panic("'token' must be set in the connection configuration. Edit your connection configuration file and then restart Steampipe") | ||
panic("token must be configured") |
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.
Is there a specific reason you changed the panic message? This is a fairly standard message we use in other plugins as well.
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.
I did not make this change, this came from the github-enterprise-support branch
} | ||
|
||
if token == "" { | ||
panic("'token' must be set in the connection configuration. Edit your connection configuration file and then restart Steampipe") | ||
panic("token must be configured") | ||
//return nil, errors.New("token must be configured") |
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.
//return nil, errors.New("token must be configured") |
uv3.Path = uv3.Path + "api/v3/" | ||
} | ||
|
||
conn, err = github.NewEnterpriseClient(uv3.String(), "", tc) |
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.
Is there any future compatibility you're aware of that wouldn't work if we don't pass the upload URL when creating the client?
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.
I don't know. This came from the github-enterprise-support branch, I haven't explored the client requirements.
} | ||
|
||
if uv3.String() != "https://api.github.com/" { | ||
uv3.Path = uv3.Path + "api/v3/" |
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.
Do we need to include this, or does the go-github library automatically attach this suffix, per https://github.com/google/go-github/blob/a58d5f0adf74ef73aadaac476f7285afc77a3b43/github/github.go#L357-L364
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.
seems to be needed. It does seem like the library should handle the suffix but it's not doing so. I don't know why offhand. This came from the github-enterprise-support branch, I haven't explored the client code.
uv3.Path = uv3.Path + "api/v3/" | ||
} | ||
|
||
conn, err = github.NewEnterpriseClient(uv3.String(), "", tc) |
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.
If someone sets base_url
as https://github.com/api/v3`, does the enterprise client still work, or does it fail/have another behaviour?
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.
base_url = "https://api.github.com/
works.
base_url = https://github.com/api/v3
returns a 404
status for https://github.com/api/v3/api/v3/search/issues
rx := regexp.MustCompile(`(?s)` + regexp.QuoteMeta("github.com/") + `(.*?)` + regexp.QuoteMeta("/blob")) | ||
replacer := strings.NewReplacer("github.com/", "", "/blob", "") | ||
return replacer.Replace(rx.FindString(*code.HTMLURL)), nil | ||
rx := regexp.MustCompile(`https?://.+?/(.+?)/blob`) |
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.
Have you tested this change (along with other github_search_*
table changes) against a GitHub cloud instance for backward compatibility? I saw some query results in #160 (comment), but wasn't sure if those were for an enterprise or cloud instance.
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.
the tests were against github.com (base_url = "https://api.github.com/
) and GH Enterprise with custom hostname (base_url = "https://abc.xyz.gov/
. I guess our GHE is Server, not Cloud - I'm not clear on the difference.
@mheiges Thank you for testing out this branch and making improvements to it as well! We've just released v0.15.0 of this plugin, which includes this PR. If you see any issues, please let us know. |
Example query results
Results