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

GitHub Enterprise Support #23

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Next Next commit
Added GitHubApiUrl and GitHubDomain to settings and template
  • Loading branch information
floatdrop committed Feb 14, 2014
commit 2f4802361cdc0d70be8be9225530043bf0791cd6
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ clean:
rm -rf usr/local/bin/drone
rm -rf usr/local/bin/droned
rm -rf drone.sqlite
rm -rf /tmp/drone.sqlite

# creates a debian package for drone
# to install `sudo dpkg -i drone.deb`
Expand Down
2 changes: 1 addition & 1 deletion pkg/database/schema/sample.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ insert into builds values (9, 3, 'node_0.80', 'Success', '2013-09-16 00:00:00','

-- insert default, dummy settings

insert into settings values (1,'','','','','','','','','','localhost:8080','http');
insert into settings values (1,'','','github.com','https://api.github.com','','','','','','','','localhost:8080','http');

-- add public & private keys to all repositories

Expand Down
2 changes: 2 additions & 0 deletions pkg/database/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ CREATE TABLE settings (
id INTEGER PRIMARY KEY
,github_key VARCHAR(255)
,github_secret VARCHAR(255)
,github_domain VARCHAR(255)
,github_apiurl VARCHAR(255)
,bitbucket_key VARCHAR(255)
,bitbucket_secret VARCHAR(255)
,smtp_server VARCHAR(1024)
Expand Down
2 changes: 2 additions & 0 deletions pkg/database/schema/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ CREATE TABLE settings (
id INTEGER PRIMARY KEY
,github_key VARCHAR(255)
,github_secret VARCHAR(255)
,github_domain VARCHAR(255)
,github_apiurl VARCHAR(255)
,bitbucket_key VARCHAR(255)
,bitbucket_secret VARCHAR(255)
,smtp_server VARCHAR(1024)
Expand Down
2 changes: 1 addition & 1 deletion pkg/database/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const settingsTable = "settings"

// SQL Queries to retrieve the system settings
const settingsStmt = `
SELECT id, github_key, github_secret, bitbucket_key, bitbucket_secret,
SELECT id, github_key, github_secret, github_domain, github_apiurl, bitbucket_key, bitbucket_secret,
smtp_server, smtp_port, smtp_address, smtp_username, smtp_password, hostname, scheme
FROM settings WHERE id = 1
`
Expand Down
4 changes: 4 additions & 0 deletions pkg/handler/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ func AdminSettingsUpdate(w http.ResponseWriter, r *http.Request, u *User) error
// update github settings
settings.GitHubKey = r.FormValue("GitHubKey")
settings.GitHubSecret = r.FormValue("GitHubSecret")
settings.GitHubDomain = r.FormValue("GitHubDomain")
settings.GitHubApiUrl = r.FormValue("GitHubApiUrl")

// update smtp settings
settings.SmtpServer = r.FormValue("SmtpServer")
Expand Down Expand Up @@ -242,6 +244,8 @@ func InstallPost(w http.ResponseWriter, r *http.Request) error {
settings := Settings{}
settings.Domain = r.FormValue("Domain")
settings.Scheme = r.FormValue("Scheme")
settings.GitHubApiUrl = "https://api.github.com";
settings.GitHubDomain = "github.com";
database.SaveSettings(&settings)

// add the user to the session object
Expand Down
2 changes: 2 additions & 0 deletions pkg/model/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type Settings struct {
// GitHub Consumer key and secret.
GitHubKey string `meddler:"github_key"`
GitHubSecret string `meddler:"github_secret"`
GitHubDomain string `meddler:"github_domain"`
GitHubApiUrl string `meddler:"github_apiurl"`

// Bitbucket Consumer Key and secret.
BitbucketKey string `meddler:"bitbucket_key"`
Expand Down
5 changes: 5 additions & 0 deletions pkg/template/pages/admin_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ <h1>Sysadmin</h1>
<input class="form-control form-control-large" type="text" name="GitHubKey" value="{{.Settings.GitHubKey}}" />
<input class="form-control form-control-large" type="password" name="GitHubSecret" value="{{.Settings.GitHubSecret}}" />
</div>
<label>GitHub Settings:</label>
<div>
<input class="form-control form-control-large" type="text" name="GitHubDomain" value="{{.Settings.GitHubDomain}}" />
<input class="form-control form-control-large" type="text" name="GitHubApiUrl" value="{{.Settings.GitHubApiUrl}}" />
</div>
</div>
<div class="form-group hide">
<div class="alert">Bitbucket OAuth Consumer Key and Secret.</div>
Expand Down