diff --git a/Makefile b/Makefile index 3e8b83217..3b4074de1 100644 --- a/Makefile +++ b/Makefile @@ -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` diff --git a/pkg/database/schema/sample.sql b/pkg/database/schema/sample.sql index 594caaa3e..c19dbe4b9 100644 --- a/pkg/database/schema/sample.sql +++ b/pkg/database/schema/sample.sql @@ -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', 0); +insert into settings values (1,'','','github.com','https://api.github.com','','','','','','','','localhost:8080','http',0); -- add public & private keys to all repositories @@ -123,4 +123,4 @@ Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 10.849 sec Results : -Tests run: 7, Failures: 0, Errors: 0, Skipped: 0'; \ No newline at end of file +Tests run: 7, Failures: 0, Errors: 0, Skipped: 0'; diff --git a/pkg/database/schema/schema.go b/pkg/database/schema/schema.go index ec93774a8..5cbf89a62 100644 --- a/pkg/database/schema/schema.go +++ b/pkg/database/schema/schema.go @@ -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) diff --git a/pkg/database/schema/schema.sql b/pkg/database/schema/schema.sql index d0babf327..b5ed513ca 100644 --- a/pkg/database/schema/schema.sql +++ b/pkg/database/schema/schema.sql @@ -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) diff --git a/pkg/database/settings.go b/pkg/database/settings.go index 188ac3a5e..883b87d3d 100644 --- a/pkg/database/settings.go +++ b/pkg/database/settings.go @@ -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, open_invitations FROM settings WHERE id = 1 ` diff --git a/pkg/handler/admin.go b/pkg/handler/admin.go index 3d7fa8b5a..d7840c7fb 100644 --- a/pkg/handler/admin.go +++ b/pkg/handler/admin.go @@ -167,6 +167,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") @@ -243,6 +245,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 diff --git a/pkg/model/settings.go b/pkg/model/settings.go index 04db729f8..3112d1d4b 100644 --- a/pkg/model/settings.go +++ b/pkg/model/settings.go @@ -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"` diff --git a/pkg/template/pages/admin_settings.html b/pkg/template/pages/admin_settings.html index bc607fa5e..824015e5e 100644 --- a/pkg/template/pages/admin_settings.html +++ b/pkg/template/pages/admin_settings.html @@ -44,6 +44,11 @@ + +