diff --git a/bin/README b/bin/README
deleted file mode 100644
index a8783add4..000000000
--- a/bin/README
+++ /dev/null
@@ -1 +0,0 @@
-This is where Drone binaries go after running "make" in the root directory.
\ No newline at end of file
diff --git a/cmd/drone-server/drone.go b/cmd/drone-server/drone.go
deleted file mode 100644
index f22cd9eaf..000000000
--- a/cmd/drone-server/drone.go
+++ /dev/null
@@ -1,261 +0,0 @@
-package main
-
-import (
- "html/template"
- "net/http"
-
- "github.com/drone/drone/Godeps/_workspace/src/github.com/namsral/flag"
-
- "github.com/drone/drone/Godeps/_workspace/src/github.com/gin-gonic/gin"
-
- "github.com/drone/drone/Godeps/_workspace/src/github.com/elazarl/go-bindata-assetfs"
- "github.com/drone/drone/pkg/remote"
- "github.com/drone/drone/pkg/server"
-
- log "github.com/drone/drone/Godeps/_workspace/src/github.com/Sirupsen/logrus"
- eventbus "github.com/drone/drone/pkg/bus/builtin"
- queue "github.com/drone/drone/pkg/queue/builtin"
- runner "github.com/drone/drone/pkg/runner/builtin"
- "github.com/drone/drone/pkg/store"
-
- _ "github.com/drone/drone/pkg/remote/builtin/github"
- _ "github.com/drone/drone/pkg/remote/builtin/gitlab"
- _ "github.com/drone/drone/pkg/store/builtin"
-)
-
-var (
- // commit sha for the current build, set by
- // the compile process.
- version string
- revision string
-)
-
-var conf = struct {
- debug bool
-
- server struct {
- addr string
- cert string
- key string
- }
-
- docker struct {
- host string
- cert string
- key string
- ca string
- }
-
- remote struct {
- driver string
- config string
- }
-
- database struct {
- driver string
- config string
- }
-
- plugin struct {
- filter string
- }
-}{}
-
-func main() {
-
- flag.StringVar(&conf.docker.host, "docker-host", "unix:///var/run/docker.sock", "")
- flag.StringVar(&conf.docker.cert, "docker-cert", "", "")
- flag.StringVar(&conf.docker.key, "docker-key", "", "")
- flag.StringVar(&conf.docker.ca, "docker-ca", "", "")
- flag.StringVar(&conf.server.addr, "server-addr", ":8080", "")
- flag.StringVar(&conf.server.cert, "server-cert", "", "")
- flag.StringVar(&conf.server.key, "server-key", "", "")
- flag.StringVar(&conf.remote.driver, "remote-driver", "github", "")
- flag.StringVar(&conf.remote.config, "remote-config", "https://github.com", "")
- flag.StringVar(&conf.database.driver, "database-driver", "sqlite3", "")
- flag.StringVar(&conf.database.config, "database-config", "drone.sqlite", "")
- flag.StringVar(&conf.plugin.filter, "plugin-filter", "plugins/*", "")
- flag.BoolVar(&conf.debug, "debug", false, "")
-
- flag.String("config", "", "")
- flag.Parse()
-
- store, err := store.New(conf.database.driver, conf.database.config)
- if err != nil {
- panic(err)
- }
-
- remote, err := remote.New(conf.remote.driver, conf.remote.config)
- if err != nil {
- panic(err)
- }
-
- eventbus_ := eventbus.New()
- queue_ := queue.New()
- updater := runner.NewUpdater(eventbus_, store, remote)
- runner_ := runner.Runner{Updater: updater}
-
- // launch the local queue runner if the system
- // is not conifugred to run in agent mode
- go run(&runner_, queue_)
-
- r := gin.Default()
-
- api := r.Group("/api")
- api.Use(server.SetHeaders())
- api.Use(server.SetBus(eventbus_))
- api.Use(server.SetDatastore(store))
- api.Use(server.SetRemote(remote))
- api.Use(server.SetQueue(queue_))
- api.Use(server.SetUser())
- api.Use(server.SetRunner(&runner_))
- api.OPTIONS("/*path", func(c *gin.Context) {})
-
- user := api.Group("/user")
- {
- user.Use(server.MustUser())
-
- user.GET("", server.GetUserCurr)
- user.PATCH("", server.PutUserCurr)
- user.GET("/feed", server.GetUserFeed)
- user.GET("/repos", server.GetUserRepos)
- user.POST("/token", server.PostUserToken)
- }
-
- users := api.Group("/users")
- {
- users.Use(server.MustAdmin())
-
- users.GET("", server.GetUsers)
- users.GET("/:name", server.GetUser)
- users.POST("/:name", server.PostUser)
- users.PATCH("/:name", server.PutUser)
- users.DELETE("/:name", server.DeleteUser)
- }
-
- repos := api.Group("/repos/:owner/:name")
- {
- repos.POST("", server.PostRepo)
-
- repo := repos.Group("")
- {
- repo.Use(server.SetRepo())
- repo.Use(server.SetPerm())
- repo.Use(server.CheckPull())
- repo.Use(server.CheckPush())
-
- repo.GET("", server.GetRepo)
- repo.PATCH("", server.PutRepo)
- repo.DELETE("", server.DeleteRepo)
- repo.POST("/encrypt", server.Encrypt)
- repo.POST("/watch", server.Subscribe)
- repo.DELETE("/unwatch", server.Unsubscribe)
-
- repo.GET("/builds", server.GetBuilds)
- repo.GET("/builds/:number", server.GetBuild)
- repo.POST("/builds/:number", server.RunBuild)
- repo.DELETE("/builds/:number", server.KillBuild)
- repo.GET("/logs/:number/:task", server.GetLogs)
- // repo.POST("/status/:number", server.PostBuildStatus)
- }
- }
-
- badges := api.Group("/badges/:owner/:name")
- {
- badges.Use(server.SetRepo())
-
- badges.GET("/status.svg", server.GetBadge)
- badges.GET("/cc.xml", server.GetCC)
- }
-
- hooks := api.Group("/hook")
- {
- hooks.POST("", server.PostHook)
- }
-
- stream := api.Group("/stream")
- {
- stream.Use(server.SetRepo())
- stream.Use(server.SetPerm())
- stream.GET("/:owner/:name", server.GetRepoEvents)
- stream.GET("/:owner/:name/:build/:number", server.GetStream)
-
- }
-
- auth := r.Group("/authorize")
- {
- auth.Use(server.SetHeaders())
- auth.Use(server.SetDatastore(store))
- auth.Use(server.SetRemote(remote))
- auth.GET("", server.GetLogin)
- auth.POST("", server.GetLogin)
- }
-
- gitlab := r.Group("/gitlab/:owner/:name")
- {
- gitlab.Use(server.SetDatastore(store))
- gitlab.Use(server.SetRepo())
-
- gitlab.GET("/commits/:sha", server.GetCommit)
- gitlab.GET("/pulls/:number", server.GetPullRequest)
-
- redirects := gitlab.Group("/redirect")
- {
- redirects.GET("/commits/:sha", server.RedirectSha)
- redirects.GET("/pulls/:number", server.RedirectPullRequest)
- }
- }
-
- r.SetHTMLTemplate(index())
- r.NoRoute(func(c *gin.Context) {
- c.HTML(200, "index.html", nil)
- })
-
- http.Handle("/static/", static())
- http.Handle("/", r)
-
- if len(conf.server.cert) == 0 {
- err = http.ListenAndServe(conf.server.addr, nil)
- } else {
- err = http.ListenAndServeTLS(conf.server.addr, conf.server.cert, conf.server.key, nil)
- }
- if err != nil {
- log.Error("Cannot start server: ", err)
- }
-
-}
-
-// static is a helper function that will setup handlers
-// for serving static files.
-func static() http.Handler {
- // default file server is embedded
- var handler = http.FileServer(&assetfs.AssetFS{
- Asset: Asset,
- AssetDir: AssetDir,
- Prefix: "cmd/drone-server/static",
- })
- if conf.debug {
- handler = http.FileServer(
- http.Dir("cmd/drone-server/static"),
- )
- }
- return http.StripPrefix("/static/", handler)
-}
-
-// index is a helper function that will setup a template
-// for rendering the main angular index.html file.
-func index() *template.Template {
- file := MustAsset("cmd/drone-server/static/index.html")
- filestr := string(file)
- return template.Must(template.New("index.html").Parse(filestr))
-}
-
-// run is a helper function for initializing the
-// built-in build runner, if not running in remote
-// mode.
-func run(r *runner.Runner, q *queue.Queue) {
- defer func() {
- recover()
- }()
- r.Poll(q)
-}
diff --git a/cmd/drone-server/static/favicon.png b/cmd/drone-server/static/favicon.png
deleted file mode 100644
index c91951dc2..000000000
Binary files a/cmd/drone-server/static/favicon.png and /dev/null differ
diff --git a/cmd/drone-server/static/images/logo.svg b/cmd/drone-server/static/images/logo.svg
deleted file mode 100644
index 9b9374001..000000000
--- a/cmd/drone-server/static/images/logo.svg
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- image/svg+xml
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cmd/drone-server/static/index.html b/cmd/drone-server/static/index.html
deleted file mode 100644
index 2afe9dc62..000000000
--- a/cmd/drone-server/static/index.html
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cmd/drone-server/static/scripts/controllers/builds.js b/cmd/drone-server/static/scripts/controllers/builds.js
deleted file mode 100644
index b92bd8751..000000000
--- a/cmd/drone-server/static/scripts/controllers/builds.js
+++ /dev/null
@@ -1,245 +0,0 @@
-(function () {
-
- /**
- * BuildsCtrl responsible for rendering the repo's
- * recent build history.
- */
- function BuildsCtrl($scope, $stateParams, builds, repos, users, logs) {
- var owner = $stateParams.owner;
- var name = $stateParams.name;
- var fullName = owner + '/' + name;
-
- $scope.loading=true;
-
- // Gets the currently authenticated user
- // users.getCached().then(function (payload) {
- // $scope.user = payload.data;
- // });
-
- // Gets a repository
- repos.get(fullName).then(function (payload) {
- $scope.repo = payload.data;
- $scope.loading=false;
- }).catch(function (err) {
- $scope.error = err;
- });
-
- // Gets a list of builds
- builds.list(fullName).then(function (payload) {
- $scope.builds = angular.isArray(payload.data) ? payload.data : [];
- }).catch(function (err) {
- $scope.error = err;
- });
-
- $scope.watch = function (repo) {
- repos.watch(repo.full_name).then(function (payload) {
- $scope.repo.starred = true;
- });
- };
-
- $scope.unwatch = function (repo) {
- repos.unwatch(repo.full_name).then(function () {
- $scope.repo.starred = false;
- });
- };
-
- repos.subscribe(fullName, function (event) {
- var added = false;
- for (var i = 0; i < $scope.builds.length; i++) {
- var build = $scope.builds[i];
- if (event.number !== build.number) {
- continue; // ignore
- }
- // update the build status
- $scope.builds[i] = event;
- $scope.$apply();
- added = true;
- }
-
- if (!added) {
- $scope.builds.push(event);
- $scope.$apply();
- }
- });
- }
-
- /**
- * BuildCtrl responsible for rendering a build.
- */
- function BuildCtrl($scope, $stateParams, $window, logs, builds, repos, users) {
- var number = $stateParams.number;
- var owner = $stateParams.owner;
- var name = $stateParams.name;
- var fullName = owner + '/' + name;
- var step = parseInt($stateParams.step) || 1;
-
- // Gets the currently authenticated user
- users.getCached().then(function (payload) {
- $scope.user = payload.data;
- });
-
- // Gets a repository
- repos.get(fullName).then(function (payload) {
- $scope.repo = payload.data;
- }).catch(function (err) {
- $scope.error = err;
- });
-
- // Gets the build
- builds.get(fullName, number).then(function (payload) {
- $scope.step = step;
- $scope.build = payload.data;
- }).catch(function (err) {
- $scope.error = err;
- });
-
- repos.subscribe(fullName, function (event) {
- if (event.number !== parseInt(number)) {
- return; // ignore
- }
- // update the build
- $scope.build = event;
- $scope.$apply();
- });
-
- $scope.restart = function () {
- builds.restart(fullName, number).then(function (payload) {
- $scope.build = payload.data;
- }).catch(function (err) {
- $scope.error = err;
- });
- };
-
- $scope.cancel = function () {
- builds.cancel(fullName, number).then(function (payload) {
- $scope.build = payload.data;
- }).catch(function (err) {
- $scope.error = err;
- });
- };
-
- $scope.tail = function () {
- tail = !tail;
- };
- }
-
-
- /**
- * BuildOutCtrl responsible for rendering a build output.
- */
- function BuildOutCtrl($scope, $stateParams, $window, logs, builds, repos, users) {
-
- var step = parseInt($stateParams.step) || 1;
- var number = $stateParams.number;
- var owner = $stateParams.owner;
- var name = $stateParams.name;
- var fullName = owner + '/' + name;
- var streaming = false;
- var tail = false;
-
- // Initiates streaming a build.
- var stream = function () {
- if (streaming) {
- return;
- }
- streaming = true;
-
- var convert = new Filter({stream: true, newline: false});
- var term = document.getElementById("term");
- term.innerHTML = "";
-
- // subscribes to the build otuput.
- logs.subscribe(fullName, number, step, function (data) {
- term.innerHTML += convert.toHtml(data.replace("\\n", "\n"));
- if (tail) {
- // scrolls to the bottom of the page if enabled
- $window.scrollTo(0, $window.document.body.scrollHeight);
- }
- });
- };
-
- // Gets the currently authenticated user
- // users.getCached().then(function (payload) {
- // $scope.user = payload.data;
- // });
-
- // Gets a repository
- repos.get(fullName).then(function (payload) {
- $scope.repo = payload.data;
- }).catch(function (err) {
- $scope.error = err;
- });
-
- // Gets the build
- builds.get(fullName, number).then(function (payload) {
- $scope.build = payload.data;
- $scope.task = payload.data.jobs[step - 1];
- $scope.step = step;
-
- if (['pending', 'killed'].indexOf($scope.task.status) !== -1) {
- // do nothing
- } else if ($scope.task.status === 'running') {
- // stream the build
- stream();
- } else {
-
- // fetch the logs for the finished build.
- logs.get(fullName, number, step).then(function (payload) {
- var convert = new Filter({stream: false, newline: false});
- var term = document.getElementById("term")
- term.innerHTML = convert.toHtml(payload.data);
- }).catch(function (err) {
- $scope.error = err;
- });
- }
- }).catch(function (err) {
- $scope.error = err;
- });
-
- repos.subscribe(fullName, function (event) {
- if (event.number !== parseInt(number)) {
- return; // ignore
- }
- // update the build
- $scope.build = event;
- $scope.task = event.jobs[step - 1];
- $scope.$apply();
-
- // start streaming the current build
- if ($scope.task.status === 'running') {
- stream();
- } else {
- // resets our streaming state
- streaming = false;
- }
- });
-
- $scope.restart = function () {
- builds.restart(fullName, number).then(function (payload) {
- $scope.build = payload.data;
- $scope.task = payload.data.jobs[step - 1];
- }).catch(function (err) {
- $scope.error = err;
- });
- };
-
- $scope.cancel = function () {
- builds.cancel(fullName, number).then(function (payload) {
- $scope.build = payload.data;
- $scope.task = payload.data.builds[step - 1];
- }).catch(function (err) {
- $scope.error = err;
- });
- };
-
- $scope.tail = function () {
- tail = !tail;
- };
- }
-
- angular
- .module('drone')
- .controller('BuildOutCtrl', BuildOutCtrl)
- .controller('BuildCtrl', BuildCtrl)
- .controller('BuildsCtrl', BuildsCtrl);
-})();
diff --git a/cmd/drone-server/static/scripts/controllers/commits.js b/cmd/drone-server/static/scripts/controllers/commits.js
deleted file mode 100644
index b513cf5d9..000000000
--- a/cmd/drone-server/static/scripts/controllers/commits.js
+++ /dev/null
@@ -1,67 +0,0 @@
-(function () {
-
- /**
- * CommitsCtrl responsible for rendering the repo's
- * recent commit history.
- */
- function CommitsCtrl($scope, $stateParams, builds, repos, users, logs) {
-
- var owner = $stateParams.owner;
- var name = $stateParams.name;
- var fullName = owner+'/'+name;
-
- // Gets the currently authenticated user
- users.getCached().then(function(payload){
- $scope.user = payload.data;
- });
-
- // Gets a repository
- repos.get(fullName).then(function(payload){
- $scope.repo = payload.data;
- }).catch(function(err){
- $scope.error = err;
- });
-
- // Gets a list of commits
- builds.list(fullName).then(function(payload){
- $scope.builds = angular.isArray(payload.data) ? payload.data : [];
- }).catch(function(err){
- $scope.error = err;
- });
-
- $scope.watch = function(repo) {
- repos.watch(repo.full_name).then(function(payload) {
- $scope.repo.starred = true;
- });
- }
-
- $scope.unwatch = function(repo) {
- repos.unwatch(repo.full_name).then(function() {
- $scope.repo.starred = false;
- });
- }
-
- repos.subscribe(fullName, function(event) {
- var added = false;
- for (var i=0;i<$scope.builds.length;i++) {
- var build = $scope.builds[i];
- if (event.number !== build.number) {
- continue; // ignore
- }
- // update the build status
- $scope.builds[i] = event;
- $scope.$apply();
- added = true;
- }
-
- if (!added) {
- $scope.builds.push(event);
- $scope.$apply();
- }
- });
- }
-
- angular
- .module('drone')
- .controller('CommitsCtrl', CommitsCtrl)
-})();
diff --git a/cmd/drone-server/static/scripts/controllers/repos.js b/cmd/drone-server/static/scripts/controllers/repos.js
deleted file mode 100644
index f150faacc..000000000
--- a/cmd/drone-server/static/scripts/controllers/repos.js
+++ /dev/null
@@ -1,150 +0,0 @@
-(function () {
-
- /**
- * ReposCtrl responsible for rendering the user's
- * repository home screen.
- */
- function ReposCtrl($scope, $location, $stateParams, repos, users) {
- $scope.loading = true;
- $scope.waiting = false;
-
- // Gets the currently authenticated user
- users.getCached().then(function (payload) {
- $scope.user = payload.data;
- $scope.loading = false;
- });
-
- // Gets a list of repos to display in the
- // dropdown.
- repos.list().then(function (payload) {
- $scope.repos = angular.isArray(payload.data) ? payload.data : [];
- }).catch(function (err) {
- $scope.error = err;
- });
-
- // Adds a repository
- $scope.add = function (event, fullName) {
- $scope.error = undefined;
- if (event.which && event.which !== 13) {
- return;
- }
- $scope.waiting = true;
-
- repos.post(fullName).then(function (payload) {
- $location.path('/' + fullName);
- $scope.waiting = false;
- }).catch(function (err) {
- $scope.error = err;
- $scope.waiting = false;
- $scope.search_text = undefined;
- });
- }
- }
-
- /**
- * RepoAddCtrl responsible for activaing a new
- * repository.
- */
- function RepoAddCtrl($scope, $location, repos, users) {
-
- // Gets the currently authenticated user
- users.getCached().then(function (payload) {
- $scope.user = payload.data;
- });
-
- $scope.add = function (slug) {
- repos.post(slug).then(function (payload) {
- $location.path('/' + slug);
- }).catch(function (err) {
- $scope.error = err;
- });
- }
- }
-
- /**
- * RepoEditCtrl responsible for editing a repository.
- */
- function RepoEditCtrl($scope, $window, $location, $stateParams, repos, users) {
- var owner = $stateParams.owner;
- var name = $stateParams.name;
- var fullName = owner + '/' + name;
-
- // Inject window for composing url
- $scope.window = $window;
-
- // Gets the currently authenticated user
- users.getCached().then(function (payload) {
- $scope.user = payload.data;
- });
-
- // Gets a repository
- repos.get(fullName).then(function (payload) {
- $scope.repo = payload.data;
- }).catch(function (err) {
- $scope.error = err;
- });
-
- $scope.save = function (repo) {
- repo.timeout = parseInt(repo.timeout);
- repos.update(repo).then(function (payload) {
- $scope.repo = payload.data;
- }).catch(function (err) {
- $scope.error = err;
- });
- };
-
- $scope.delete = function (repo) {
- repos.delete(repo).then(function (payload) {
- $location.path('/');
- }).catch(function (err) {
- $scope.error = err;
- });
- };
-
- $scope.param = {};
- $scope.addParam = function (param) {
- if (!$scope.repo.params) {
- $scope.repo.params = {}
- }
- $scope.repo.params[param.key] = param.value;
- $scope.param = {};
-
- // auto-update
- repos.update($scope.repo).then(function (payload) {
- $scope.repo = payload.data;
- }).catch(function (err) {
- $scope.error = err;
- });
- };
-
-
- $scope.encrypt = function (plaintext) {
- repos.encrypt(fullName, plaintext).then(function (payload) {
- $scope.secure = payload.data;
- }).catch(function (err) {
- $scope.error = err;
- });
- };
-
- $scope.deleteParam = function (key) {
- delete $scope.repo.params[key];
-
- // auto-update
- repos.update($scope.repo).then(function (payload) {
- $scope.repo = payload.data;
- }).catch(function (err) {
- $scope.error = err;
- });
- }
- }
-
- function toSnakeCase(str) {
- return str.replace(/ /g, '_').replace(/([a-z0-9])([A-Z0-9])/g, '$1_$2').toLowerCase();
- }
-
- angular
- .module('drone')
- .controller('ReposCtrl', ReposCtrl)
- .controller('RepoAddCtrl', RepoAddCtrl)
- .controller('RepoEditCtrl', RepoEditCtrl);
-})();
diff --git a/cmd/drone-server/static/scripts/controllers/users.js b/cmd/drone-server/static/scripts/controllers/users.js
deleted file mode 100644
index d5447bfe3..000000000
--- a/cmd/drone-server/static/scripts/controllers/users.js
+++ /dev/null
@@ -1,119 +0,0 @@
-(function () {
-
- function UserHeaderCtrl($scope, $stateParams, users) {
- // Gets the currently authenticated user
- users.getCurrent().then(function(payload){
- $scope.user = payload.data;
- });
-
- $scope.number = $stateParams.number || undefined;
- $scope.owner = $stateParams.owner || undefined;
- $scope.name = $stateParams.name || undefined;
- $scope.full_name = $scope.owner + '/' + $scope.name;
- }
-
- function UserLoginCtrl($scope, $window) {
- // attempts to extract an error message from
- // the URL hash in format #error=?
- $scope.error = $window.location.hash.substr(7);
- }
-
- function UserLogoutCtrl($scope, $window, $state) {
- // Remove login information from the local
- // storage and redirect to login page
- if (localStorage.hasOwnProperty("access_token")) {
- localStorage.removeItem("access_token");
- }
-
- $state.go("login", {}, {
- location: "replace"
- });
- }
-
- /**
- * UserCtrl is responsible for managing user settings.
- */
- function UserCtrl($scope, users, tokens) {
-
- // Gets the currently authenticated user
- users.getCurrent().then(function(payload){
- $scope.user = payload.data;
- });
-
- $scope.showToken = function() {
- tokens.post().then(function(payload) {
- $scope.token = payload.data;
- });
- }
- }
-
- /**
- * UsersCtrl is responsible for managing user accounts.
- * This part of the site is for administrators only.
- */
- function UsersCtrl($scope, users) {
- $scope.loading = true;
- $scope.waiting = false;
-
- // Gets the currently authenticated user
- users.getCached().then(function(payload){
- $scope.user = payload.data;
- });
-
- // Gets the list of all system users
- users.list().then(function(payload){
- $scope.loading = true;
- $scope.users = payload.data;
- });
-
- $scope.add = function(event, login) {
- $scope.error = undefined;
- $scope.new_user = undefined;
- if (event.which && event.which !== 13) {
- return;
- }
- $scope.waiting = true;
-
- users.post(login).then(function(payload){
- $scope.users.push(payload.data);
- $scope.search_text=undefined;
- $scope.waiting = false;
- $scope.new_user = payload.data;
- }).catch(function (err) {
- $scope.error = err;
- $scope.waiting = false;
- $scope.search_text = undefined;
- });
- }
-
- $scope.toggle = function(user) {
- if (user.login === $scope.user.login) {
- // cannot revoke admin privilege for self
- $scope.error = {}; // todo display an actual error here
- return;
- }
- user.admin = !user.admin;
- users.put(user);
- }
-
- $scope.remove = function(user) {
- if (user.login === $scope.user.login) {
- // cannot delete self
- $scope.error = {}; // todo display an actual error here
- return;
- }
- users.delete(user).then(function(){
- var index = $scope.users.indexOf(user);
- $scope.users.splice(index, 1);
- });
- }
- }
-
- angular
- .module('drone')
- .controller('UserHeaderCtrl', UserHeaderCtrl)
- .controller('UserLoginCtrl', UserLoginCtrl)
- .controller('UserLogoutCtrl', UserLogoutCtrl)
- .controller('UserCtrl', UserCtrl)
- .controller('UsersCtrl', UsersCtrl);
-})();
diff --git a/cmd/drone-server/static/scripts/drone.js b/cmd/drone-server/static/scripts/drone.js
deleted file mode 100644
index c9582ecdb..000000000
--- a/cmd/drone-server/static/scripts/drone.js
+++ /dev/null
@@ -1,283 +0,0 @@
-'use strict';
-
-(function () {
-
- /**
- * Creates the angular application.
- */
- angular.module('drone', [
- 'ngRoute',
- 'ui.filters',
- 'ui.router'
- ]);
-
- /**
- * Bootstraps the application and retrieves the
- * token from the
- */
- function Authorize() {
- // First, parse the query string
- var params = {}, queryString = location.hash.substring(1),
- regex = /([^&=]+)=([^&]*)/g, m;
-
- // Loop through and retrieve the token
- while (m = regex.exec(queryString)) {
- params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
- }
-
- // if the user has just received an auth token we
- // should extract from the URL, save to local storage
- // and then remove from the URL for good measure.
- if (params.access_token) {
- localStorage.setItem("access_token", params.access_token);
- history.replaceState({}, document.title, location.pathname);
- }
- }
-
- /**
- * Defines the route configuration for the
- * main application.
- */
- function Config($stateProvider, $httpProvider, $locationProvider) {
-
- // Resolver that will attempt to load the currently
- // authenticated user prior to loading the page.
- var resolveUser = {
- user: function (users) {
- return users.getCached();
- }
- };
-
- $stateProvider
- .state('app', {
- abstract: true,
- views: {
- 'layout': {
- templateUrl: '/static/scripts/views/layout.html',
- controller: function ($scope, $routeParams, repos, users) {
- users.getCached().then(function (payload) {
- if (payload && payload.data) {
- $scope.user = payload.data;
- }
- });
- }
- }
- }
- })
- .state('app.index', {
- url: '/',
- views: {
- 'toolbar': {
- templateUrl: '/static/scripts/views/repos/index/toolbar.html'
- },
- 'content': {
- templateUrl: '/static/scripts/views/repos/index/content.html',
- controller: 'ReposCtrl',
- resolve: resolveUser
- }
- },
- title: 'Dashboard'
- })
- .state('login', {
- url: '/login',
- views: {
- 'layout': {
- templateUrl: '/static/scripts/views/login.html',
- controller: 'UserLoginCtrl',
- resolve: resolveUser
- }
- },
- title: 'Login'
- })
- .state('logout', {
- url: '/logout',
- views: {
- 'layout': {
- templateUrl: '/static/scripts/views/login.html',
- controller: 'UserLogoutCtrl',
- resolve: resolveUser
- }
- },
- title: 'Logout'
- })
- .state('app.profile', {
- url: '/profile',
- views: {
- 'toolbar': {templateUrl: '/static/scripts/views/profile/toolbar.html'},
- 'content': {
- templateUrl: '/static/scripts/views/profile/content.html',
- controller: 'UserCtrl',
- resolve: resolveUser
- }
- },
- title: 'Profile'
- })
- .state('app.users', {
- url: '/users',
- views: {
- 'toolbar': {templateUrl: '/static/scripts/views/users/toolbar.html'},
- 'content': {
- templateUrl: '/static/scripts/views/users/content.html',
- controller: 'UsersCtrl',
- resolve: resolveUser
- }
- },
- title: 'Users'
- })
- .state('app.builds', {
- url: '/:owner/:name',
- views: {
- 'toolbar': {
- templateUrl: '/static/scripts/views/builds/index/toolbar.html',
- controller: 'UserHeaderCtrl',
- resolve: resolveUser
- },
- 'content': {
- templateUrl: '/static/scripts/views/builds/index/content.html',
- controller: 'BuildsCtrl'
- }
- },
- title: 'Builds'
- })
- .state('app.repo_edit', {
- url: '/:owner/:name/edit',
- views: {
- 'toolbar': {
- templateUrl: '/static/scripts/views/repos/toolbar.html',
- controller: 'UserHeaderCtrl',
- resolve: resolveUser
- },
- 'content': {
- templateUrl: '/static/scripts/views/repos/edit.html',
- controller: 'RepoEditCtrl',
- resolve: resolveUser
- }
- },
- title: 'Edit Repository'
- })
- .state('app.repo_del', {
- url: '/:owner/:name/delete',
- views: {
- 'toolbar': {
- templateUrl: '/static/scripts/views/repos/toolbar.html',
- controller: 'UserHeaderCtrl',
- resolve: resolveUser
- },
- 'content': {
- templateUrl: '/static/scripts/views/repos/del.html',
- controller: 'RepoEditCtrl',
- resolve: resolveUser
- }
- },
- title: 'Delete Repository'
- })
- .state('app.repo_env', {
- url: '/:owner/:name/edit/env',
- views: {
- 'toolbar': {
- templateUrl: '/static/scripts/views/repos/toolbar.html',
- controller: 'UserHeaderCtrl',
- resolve: resolveUser
- },
- 'content': {
- templateUrl: '/static/scripts/views/repos/env.html',
- controller: 'RepoEditCtrl',
- resolve: resolveUser
- }
- },
- title: 'Private Vars'
- })
- .state('app.repo_secure', {
- url: '/:owner/:name/secure',
- views: {
- 'toolbar': {
- templateUrl: '/static/scripts/views/repos/toolbar.html',
- controller: 'UserHeaderCtrl',
- resolve: resolveUser
- },
- 'content': {
- templateUrl: '/static/scripts/views/repos/secure.html',
- controller: 'RepoEditCtrl',
- resolve: resolveUser
- }
- },
- title: 'Secure Variables'
- })
- .state('app.build', {
- url: '/:owner/:name/:number',
- views: {
- 'toolbar': {
- templateUrl: '/static/scripts/views/builds/show/toolbar.html',
- controller: 'UserHeaderCtrl',
- resolve: resolveUser
- },
- 'content': {
- templateUrl: '/static/scripts/views/builds/show/content.html',
- controller: 'BuildOutCtrl',
- resolve: resolveUser
- }
- },
- title: 'Build'
- })
- .state('app.job', {
- url: '/:owner/:name/:number/:step',
- views: {
- 'toolbar': {
- templateUrl: '/static/scripts/views/builds/show/toolbar.html',
- controller: 'UserHeaderCtrl',
- resolve: resolveUser
- },
- 'content': {
- templateUrl: '/static/scripts/views/builds/show/content.html',
- controller: 'BuildOutCtrl',
- resolve: resolveUser
- }
- },
- title: 'Build'
- });
-
- // Enables html5 mode
- $locationProvider.html5Mode(true);
-
- // Appends the Bearer token to authorize every
- // outbound http request.
- $httpProvider.defaults.headers.common.Authorization = 'Bearer ' + localStorage.getItem('access_token');
-
- // Intercepts every oubput http response and redirects
- // the user to the logic screen if the request was rejected.
- $httpProvider.interceptors.push(function ($q, $location) {
- return {
- 'responseError': function (rejection) {
- if (rejection.status === 401 && rejection.config.url !== "/api/user") {
- $location.path('/login');
- }
- if (rejection.status === 0) {
- // this happens when the app is down or
- // the browser loses internet connectivity.
- }
- return $q.reject(rejection);
- }
- };
- });
- }
-
- function RouteChange($rootScope, repos, logs) {
- $rootScope.$on('$stateChangeStart', function () {
- repos.unsubscribe();
- logs.unsubscribe();
- });
-
- $rootScope.$on('$stateChangeSuccess', function (event, current) {
- if (current.title) {
- document.title = current.title + ' ยท drone';
- }
- });
- }
-
- angular
- .module('drone')
- .config(Authorize)
- .config(Config)
- .run(RouteChange);
-
-})();
diff --git a/cmd/drone-server/static/scripts/filters/filter.js b/cmd/drone-server/static/scripts/filters/filter.js
deleted file mode 100644
index da6517f77..000000000
--- a/cmd/drone-server/static/scripts/filters/filter.js
+++ /dev/null
@@ -1,93 +0,0 @@
-'use strict';
-
-(function () {
-
- function trunc() {
- return function(str) {
- if (str && str.length > 10) {
- return str.substr(0, 10);
- }
- return str;
- }
- }
-
- /**
- * author is a helper function that return the builds
- * commit or pull request author.
- */
- function author() {
- return function(build) {
- if (!build) { return ""; }
- if (!build.head_commit && !build.pull_request) { return ""; }
- if (build.head_commit) { return build.head_commit.author.login || ""; }
- return build.pull_request.source.author.login;
- }
- }
-
- /**
- * sha is a helper function that return the builds sha.
- */
- function sha() {
- return function(build) {
- if (!build) { return ""; }
- if (!build.head_commit && !build.pull_request) { return ""; }
- if (build.head_commit) { return build.head_commit.sha || ""; }
- return build.pull_request.source.sha;
- }
- }
-
- /**
- * ref is a helper function that return the builds sha.
- */
- function ref() {
- return function(build) {
- if (!build) { return ""; }
- if (!build.head_commit && !build.pull_request) { return ""; }
- if (build.head_commit) { return build.head_commit.ref || ""; }
- return build.pull_request.source.ref;
- }
- }
-
- /**
- * message is a helper function that return the builds message.
- */
- function message() {
- return function(build) {
- if (!build) { return ""; }
- if (!build.head_commit && !build.pull_request) { return ""; }
- if (build.head_commit) { return build.head_commit.message || ""; }
- return build.pull_request.title || "";
- }
- }
-
- /**
- * message is a helper function that return the build icon.
- */
- function icon() {
- return function(status) {
- switch(status) {
- case "pending":
- case "running":
- return "refresh";
- case "failure":
- return "clear";
- case "success":
- return "check";
- case "killed":
- case "error":
- return "remove";
- }
- return "";
- }
- }
-
- angular
- .module('drone')
- .filter('trunc', trunc)
- .filter('author', author)
- .filter('message', message)
- .filter('sha', sha)
- .filter('icon', icon)
- .filter('ref', ref);
-
-})();
diff --git a/cmd/drone-server/static/scripts/filters/gravatar.js b/cmd/drone-server/static/scripts/filters/gravatar.js
deleted file mode 100644
index 73dfa1d9e..000000000
--- a/cmd/drone-server/static/scripts/filters/gravatar.js
+++ /dev/null
@@ -1,32 +0,0 @@
-'use strict';
-
-(function () {
-
- /**
- * gravatar is a helper function that return the user's gravatar
- * image URL given an email hash.
- */
- function gravatar() {
- return function(hash) {
- if (!hash) { return "http://www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&f=y"; }
- return "https://secure.gravatar.com/avatar/"+hash+"?s=48&d=mm";
- }
- }
-
- /**
- * gravatarLarge is a helper function that return the user's gravatar
- * image URL given an email hash.
- */
- function gravatarLarge() {
- return function(hash) {
- if (!hash) { return "http://www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&f=y"; }
- return "https://secure.gravatar.com/avatar/"+hash+"?s=128&d=mm";
- }
- }
-
- angular
- .module('drone')
- .filter('gravatar', gravatar)
- .filter('gravatarLarge', gravatarLarge)
-
-})();
diff --git a/cmd/drone-server/static/scripts/filters/time.js b/cmd/drone-server/static/scripts/filters/time.js
deleted file mode 100644
index 5404e497e..000000000
--- a/cmd/drone-server/static/scripts/filters/time.js
+++ /dev/null
@@ -1,45 +0,0 @@
-'use strict';
-
-(function () {
-
- /**
- * fromNow is a helper function that returns a human readable
- * string for the elapsed time between the given unix date and the
- * current time (ex. 10 minutes ago).
- */
- function fromNow() {
- return function(date) {
- if (!date) {
- return;
- }
- return moment(new Date(date*1000)).fromNow();
- }
- }
-
- /**
- * toDuration is a helper function that returns a human readable
- * string for the given duration in seconds (ex. 1 hour and 20 minutes).
- */
- function toDuration() {
- return function(seconds) {
- return moment.duration(seconds, "seconds").humanize();
- }
- }
-
- /**
- * toDate is a helper function that returns a human readable
- * string gor the given unix date.
- */
- function toDate() {
- return function(date) {
- return moment(new Date(date*1000)).format('ll');
- }
- }
-
- angular
- .module('drone')
- .filter('fromNow', fromNow)
- .filter('toDate', toDate)
- .filter('toDuration', toDuration)
-
-})();
diff --git a/cmd/drone-server/static/scripts/services/builds.js b/cmd/drone-server/static/scripts/services/builds.js
deleted file mode 100644
index 97826c416..000000000
--- a/cmd/drone-server/static/scripts/services/builds.js
+++ /dev/null
@@ -1,54 +0,0 @@
-'use strict';
-
-(function () {
-
- /**
- * The BuildsService provides access to build
- * data using REST API calls.
- */
- function BuildService($http, $window) {
-
- /**
- * Gets a list of builds.
- *
- * @param {string} Name of the repository.
- */
- this.list = function(repoName) {
- return $http.get('/api/repos/'+repoName+'/builds');
- };
-
- /**
- * Gets a build.
- *
- * @param {string} Name of the repository.
- * @param {number} Number of the build.
- */
- this.get = function(repoName, buildNumber) {
- return $http.get('/api/repos/'+repoName+'/builds/'+buildNumber);
- };
-
- /**
- * Restarts a build.
- *
- * @param {string} Name of the repository.
- * @param {number} Number of the build.
- */
- this.restart = function(repoName, buildNumber) {
- return $http.post('/api/repos/' + repoName+'/builds/'+buildNumber);
- };
-
- /**
- * Cancels a running build.
- *
- * @param {string} Name of the repository.
- * @param {number} Number of the build.
- */
- this.cancel = function(repoName, buildNumber) {
- return $http.delete('/api/repos/'+repoName+'/builds/'+buildNumber);
- };
- }
-
- angular
- .module('drone')
- .service('builds', BuildService);
-})();
diff --git a/cmd/drone-server/static/scripts/services/feed.js b/cmd/drone-server/static/scripts/services/feed.js
deleted file mode 100644
index d4a209cb2..000000000
--- a/cmd/drone-server/static/scripts/services/feed.js
+++ /dev/null
@@ -1,40 +0,0 @@
-'use strict';
-
-(function () {
-
- function FeedService($http, $window) {
-
- var callback,
- websocket,
- token = localStorage.getItem('access_token');
-
- this.subscribe = function(_callback) {
- callback = _callback;
-
- var proto = ($window.location.protocol === 'https:' ? 'wss' : 'ws'),
- route = [proto, "://", $window.location.host, '/api/stream/user?access_token=', token].join('');
-
- websocket = new WebSocket(route);
- websocket.onmessage = function (event) {
- if (callback !== undefined) {
- callback(angular.fromJson(event.data));
- }
- };
- websocket.onclose = function (event) {
- console.log('user websocket closed');
- };
- };
-
- this.unsubscribe = function() {
- callback = undefined;
- if (websocket !== undefined) {
- websocket.close();
- websocket = undefined;
- }
- };
- }
-
- angular
- .module('drone')
- .service('feed', FeedService);
-})();
diff --git a/cmd/drone-server/static/scripts/services/logs.js b/cmd/drone-server/static/scripts/services/logs.js
deleted file mode 100644
index 58893282f..000000000
--- a/cmd/drone-server/static/scripts/services/logs.js
+++ /dev/null
@@ -1,58 +0,0 @@
-'use strict';
-
-(function () {
-
- /**
- * The LogService provides access to build
- * log data using REST API calls.
- */
- function LogService($http, $window) {
-
- /**
- * Gets a task logs.
- *
- * @param {string} Name of the repository.
- * @param {number} Number of the build.
- * @param {number} Number of the task.
- */
- this.get = function(repoName, number, step) {
- return $http.get('/api/repos/'+repoName+'/logs/'+number+'/'+step);
- };
-
- var callback,
- events,
- token = localStorage.getItem('access_token');
-
- this.subscribe = function (repoName, number, step, _callback) {
- callback = _callback;
-
- var route = ['/api/stream/', repoName, '/', number, '/', step, '?access_token=', token].join('')
- events = new EventSource(route, { withCredentials: true });
- events.onmessage = function (event) {
- if (callback !== undefined) {
- callback(event.data);
- }
- };
- events.onerror = function (event) {
- callback = undefined;
- if (events !== undefined) {
- events.close();
- events = undefined;
- }
- console.log('user event stream closed due to error.', event);
- };
- };
-
- this.unsubscribe = function () {
- callback = undefined;
- if (events !== undefined) {
- events.close();
- events = undefined;
- }
- };
- }
-
- angular
- .module('drone')
- .service('logs', LogService);
-})();
diff --git a/cmd/drone-server/static/scripts/services/repos.js b/cmd/drone-server/static/scripts/services/repos.js
deleted file mode 100644
index c2fce6862..000000000
--- a/cmd/drone-server/static/scripts/services/repos.js
+++ /dev/null
@@ -1,132 +0,0 @@
-'use strict';
-
-(function () {
-
- /**
- * The RepoService provides access to repository
- * data using REST API calls.
- */
- function RepoService($http, $window) {
-
- var callback,
- websocket,
- token = localStorage.getItem('access_token');
-
- /**
- * Gets a list of all repositories.
- */
- this.list = function () {
- return $http.get('/api/user/repos');
- };
-
- /**
- * Gets a repository by name.
- *
- * @param {string} Name of the repository.
- */
- this.get = function (repoName) {
- return $http.get('/api/repos/' + repoName);
- };
-
- /**
- * Creates a new repository.
- *
- * @param {object} JSON representation of a repository.
- */
- this.post = function (repoName) {
- return $http.post('/api/repos/' + repoName);
- };
-
- /**
- * Updates an existing repository.
- *
- * @param {object} JSON representation of a repository.
- */
- this.update = function (repo) {
- return $http.patch('/api/repos/' + repo.full_name, repo);
- };
-
- /**
- * Deletes a repository.
- *
- * @param {string} Name of the repository.
- */
- this.delete = function (repoName) {
- return $http.delete('/api/repos/' + repoName);
- };
-
- /**
- * Watch a repository.
- *
- * @param {string} Name of the repository.
- */
- this.watch = function (repoName) {
- return $http.post('/api/repos/' + repoName + '/watch');
- };
-
- /**
- * Unwatch a repository.
- *
- * @param {string} Name of the repository.
- */
- this.unwatch = function (repoName) {
- return $http.delete('/api/repos/' + repoName + '/unwatch');
- };
-
- /**
- * Encrypt the set of parameters.
- *
- * @param {string} Name of the repository.
- * @param {string} Plaintext to encrypt.
- */
- this.encrypt = function (repoName, plaintext) {
- var conf = {
- headers: {
- 'Content-Type': 'text/plain; charset=UTF-8'
- }
- }
-
- return $http.post('/api/repos/' + repoName + '/encrypt', btoa(plaintext), conf);
- };
-
- var callback,
- events,
- token = localStorage.getItem('access_token');
-
- /**
- * Subscribes to a live update feed for a repository
- *
- * @param {string} Name of the repository.
- */
- this.subscribe = function (repo, _callback) {
- callback = _callback;
-
- events = new EventSource("/api/stream/" + repo + "?access_token=" + token, {withCredentials: true});
- events.onmessage = function (event) {
- if (callback !== undefined) {
- callback(angular.fromJson(event.data));
- }
- };
- events.onerror = function (event) {
- callback = undefined;
- if (events !== undefined) {
- events.close();
- events = undefined;
- }
- console.log('user event stream closed due to error.', event);
- };
- };
-
- this.unsubscribe = function () {
- callback = undefined;
- if (events !== undefined) {
- events.close();
- events = undefined;
- }
- };
- }
-
- angular
- .module('drone')
- .service('repos', RepoService);
-})();
diff --git a/cmd/drone-server/static/scripts/services/tokens.js b/cmd/drone-server/static/scripts/services/tokens.js
deleted file mode 100644
index 22ba77ccd..000000000
--- a/cmd/drone-server/static/scripts/services/tokens.js
+++ /dev/null
@@ -1,22 +0,0 @@
-'use strict';
-
-(function () {
-
- /**
- * The TokenService provides access to user token
- * data using REST API calls.
- */
- function TokenService($http, $window) {
-
- /**
- * Generates a user API token.
- */
- this.post = function(token) {
- return $http.post('/api/user/token');
- };
- }
-
- angular
- .module('drone')
- .service('tokens', TokenService);
-})();
\ No newline at end of file
diff --git a/cmd/drone-server/static/scripts/services/users.js b/cmd/drone-server/static/scripts/services/users.js
deleted file mode 100644
index 8ddb83289..000000000
--- a/cmd/drone-server/static/scripts/services/users.js
+++ /dev/null
@@ -1,88 +0,0 @@
-'use strict';
-
-(function () {
-
- /**
- * Cached user object.
- */
- var _user;
-
- /**
- * The UserService provides access to useer
- * data using REST API calls.
- */
- function UserService($http, $q) {
-
- /**
- * Gets a list of all users.
- */
- this.list = function() {
- return $http.get('/api/users');
- };
-
- /**
- * Gets a user by login.
- */
- this.get = function(login) {
- return $http.get('/api/users/'+login);
- };
-
- /**
- * Gets the currently authenticated user.
- */
- this.getCurrent = function() {
- return $http.get('/api/user');
- };
-
- /**
- * Updates an existing user
- */
- this.post = function(user) {
- return $http.post('/api/users/'+user);
- };
-
- /**
- * Updates an existing user
- */
- this.put = function(user) {
- return $http.patch('/api/users/'+user.login, user);
- };
-
- /**
- * Deletes a user.
- */
- this.delete = function(user) {
- return $http.delete('/api/users/'+user.login);
- };
-
- /**
- * Gets the currently authenticated user from
- * the local cache. If not exists, it will fetch
- * from the server.
- */
- this.getCached = function() {
- var defer = $q.defer();
-
- // if the user is already authenticated
- if (_user) {
- defer.resolve(_user);
- return defer.promise;
- }
-
- // else fetch the currently authenticated
- // user using the REST API.
- this.getCurrent().then(function(payload){
- _user=payload;
- defer.resolve(_user);
- }).catch(function(){
- defer.resolve(_user);
- });
-
- return defer.promise;
- }
- }
-
- angular
- .module('drone')
- .service('users', UserService);
-})();
diff --git a/cmd/drone-server/static/scripts/term.js b/cmd/drone-server/static/scripts/term.js
deleted file mode 100644
index 0e925abad..000000000
--- a/cmd/drone-server/static/scripts/term.js
+++ /dev/null
@@ -1,390 +0,0 @@
-var Filter, STYLES, defaults, entities, extend, toHexString, _i, _results,
- __slice = [].slice;
-
-STYLES = {
- 'ef0': 'color:#000',
- 'ef1': 'color:#A00',
- 'ef2': 'color:#0A0',
- 'ef3': 'color:#A50',
- 'ef4': 'color:#00A',
- 'ef5': 'color:#A0A',
- 'ef6': 'color:#0AA',
- 'ef7': 'color:#AAA',
- 'ef8': 'color:#555',
- 'ef9': 'color:#F55',
- 'ef10': 'color:#5F5',
- 'ef11': 'color:#FF5',
- 'ef12': 'color:#55F',
- 'ef13': 'color:#F5F',
- 'ef14': 'color:#5FF',
- 'ef15': 'color:#FFF',
- 'eb0': 'background-color:#000',
- 'eb1': 'background-color:#A00',
- 'eb2': 'background-color:#0A0',
- 'eb3': 'background-color:#A50',
- 'eb4': 'background-color:#00A',
- 'eb5': 'background-color:#A0A',
- 'eb6': 'background-color:#0AA',
- 'eb7': 'background-color:#AAA',
- 'eb8': 'background-color:#555',
- 'eb9': 'background-color:#F55',
- 'eb10': 'background-color:#5F5',
- 'eb11': 'background-color:#FF5',
- 'eb12': 'background-color:#55F',
- 'eb13': 'background-color:#F5F',
- 'eb14': 'background-color:#5FF',
- 'eb15': 'background-color:#FFF'
-};
-
-toHexString = function(num) {
- num = num.toString(16);
- while (num.length < 2) {
- num = "0" + num;
- }
- return num;
-};
-
-[0, 1, 2, 3, 4, 5].forEach(function(red) {
- return [0, 1, 2, 3, 4, 5].forEach(function(green) {
- return [0, 1, 2, 3, 4, 5].forEach(function(blue) {
- var b, c, g, n, r, rgb;
- c = 16 + (red * 36) + (green * 6) + blue;
- r = red > 0 ? red * 40 + 55 : 0;
- g = green > 0 ? green * 40 + 55 : 0;
- b = blue > 0 ? blue * 40 + 55 : 0;
- rgb = ((function() {
- var _i, _len, _ref, _results;
- _ref = [r, g, b];
- _results = [];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- n = _ref[_i];
- _results.push(toHexString(n));
- }
- return _results;
- })()).join('');
- STYLES["ef" + c] = "color:#" + rgb;
- return STYLES["eb" + c] = "background-color:#" + rgb;
- });
- });
-});
-
-(function() {
- _results = [];
- for (_i = 0; _i <= 23; _i++){ _results.push(_i); }
- return _results;
-}).apply(this).forEach(function(gray) {
- var c, l;
- c = gray + 232;
- l = toHexString(gray * 10 + 8);
- STYLES["ef" + c] = "color:#" + l + l + l;
- return STYLES["eb" + c] = "background-color:#" + l + l + l;
-});
-
-extend = function() {
- var dest, k, obj, objs, v, _j, _len;
- dest = arguments[0], objs = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
- for (_j = 0, _len = objs.length; _j < _len; _j++) {
- obj = objs[_j];
- for (k in obj) {
- v = obj[k];
- dest[k] = v;
- }
- }
- return dest;
-};
-
-defaults = {
- fg: '#FFF',
- bg: '#000',
- newline: false,
- escapeXML: false,
- stream: false
-};
-
-Filter = (function() {
- function Filter(options) {
- if (options == null) {
- options = {};
- }
- this.opts = extend({}, defaults, options);
- this.input = [];
- this.stack = [];
- this.stickyStack = [];
- }
-
- Filter.prototype.toHtml = function(input) {
- var buf;
- this.input = typeof input === 'string' ? [input] : input;
- buf = [];
- this.stickyStack.forEach((function(_this) {
- return function(element) {
- return _this.generateOutput(element.token, element.data, function(chunk) {
- return buf.push(chunk);
- });
- };
- })(this));
- this.forEach(function(chunk) {
- return buf.push(chunk);
- });
- this.input = [];
- return buf.join('');
- };
-
- Filter.prototype.forEach = function(callback) {
- var buf;
- buf = '';
- this.input.forEach((function(_this) {
- return function(chunk) {
- buf += chunk;
- return _this.tokenize(buf, function(token, data) {
- _this.generateOutput(token, data, callback);
- if (_this.opts.stream) {
- return _this.updateStickyStack(token, data);
- }
- });
- };
- })(this));
- if (this.stack.length) {
- return callback(this.resetStyles());
- }
- };
-
- Filter.prototype.generateOutput = function(token, data, callback) {
- switch (token) {
- case 'text':
- return callback(this.pushText(data));
- case 'display':
- return this.handleDisplay(data, callback);
- case 'xterm256':
- return callback(this.pushStyle("ef" + data));
- }
- };
-
- Filter.prototype.updateStickyStack = function(token, data) {
- var notCategory;
- notCategory = function(category) {
- return function(e) {
- return (category === null || e.category !== category) && category !== 'all';
- };
- };
- if (token !== 'text') {
- this.stickyStack = this.stickyStack.filter(notCategory(this.categoryForCode(data)));
- return this.stickyStack.push({
- token: token,
- data: data,
- category: this.categoryForCode(data)
- });
- }
- };
-
- Filter.prototype.handleDisplay = function(code, callback) {
- code = parseInt(code, 10);
- if (code === -1) {
- callback(' ');
- }
- if (code === 0) {
- if (this.stack.length) {
- callback(this.resetStyles());
- }
- }
- if (code === 1) {
- callback(this.pushTag('b'));
- }
- if (code === 2) {
-
- }
- if ((2 < code && code < 5)) {
- callback(this.pushTag('u'));
- }
- if ((4 < code && code < 7)) {
- callback(this.pushTag('blink'));
- }
- if (code === 7) {
-
- }
- if (code === 8) {
- callback(this.pushStyle('display:none'));
- }
- if (code === 9) {
- callback(this.pushTag('strike'));
- }
- if (code === 24) {
- callback(this.closeTag('u'));
- }
- if ((29 < code && code < 38)) {
- callback(this.pushStyle("ef" + (code - 30)));
- }
- if (code === 39) {
- callback(this.pushStyle("color:" + this.opts.fg));
- }
- if ((39 < code && code < 48)) {
- callback(this.pushStyle("eb" + (code - 40)));
- }
- if (code === 49) {
- callback(this.pushStyle("background-color:" + this.opts.bg));
- }
- if ((89 < code && code < 98)) {
- callback(this.pushStyle("ef" + (8 + (code - 90))));
- }
- if ((99 < code && code < 108)) {
- return callback(this.pushStyle("eb" + (8 + (code - 100))));
- }
- };
-
- Filter.prototype.categoryForCode = function(code) {
- code = parseInt(code, 10);
- if (code === 0) {
- return 'all';
- } else if (code === 1) {
- return 'bold';
- } else if ((2 < code && code < 5)) {
- return 'underline';
- } else if ((4 < code && code < 7)) {
- return 'blink';
- } else if (code === 8) {
- return 'hide';
- } else if (code === 9) {
- return 'strike';
- } else if ((29 < code && code < 38) || code === 39 || (89 < code && code < 98)) {
- return 'foreground-color';
- } else if ((39 < code && code < 48) || code === 49 || (99 < code && code < 108)) {
- return 'background-color';
- } else {
- return null;
- }
- };
-
- Filter.prototype.pushTag = function(tag, style) {
- if (style == null) {
- style = '';
- }
- if (style.length && style.indexOf(':') === -1) {
- style = STYLES[style];
- }
- this.stack.push(tag);
- return ["<" + tag, (style ? " style=\"" + style + "\"" : void 0), ">"].join('');
- };
-
- Filter.prototype.pushText = function(text) {
- if (this.opts.escapeXML) {
- return entities.encodeXML(text);
- } else {
- return text;
- }
- };
-
- Filter.prototype.pushStyle = function(style) {
- return this.pushTag("span", style);
- };
-
- Filter.prototype.closeTag = function(style) {
- var last;
- if (this.stack.slice(-1)[0] === style) {
- last = this.stack.pop();
- }
- if (last != null) {
- return "" + style + ">";
- }
- };
-
- Filter.prototype.resetStyles = function() {
- var stack, _ref;
- _ref = [this.stack, []], stack = _ref[0], this.stack = _ref[1];
- return stack.reverse().map(function(tag) {
- return "" + tag + ">";
- }).join('');
- };
-
- Filter.prototype.tokenize = function(text, callback) {
- var ansiHandler, ansiMatch, ansiMess, handler, i, length, newline, process, realText, remove, removeXterm256, tokens, _j, _len, _results1;
- ansiMatch = false;
- ansiHandler = 3;
- remove = function(m) {
- return '';
- };
- removeXterm256 = function(m, g1) {
- callback('xterm256', g1);
- return '';
- };
- newline = (function(_this) {
- return function(m) {
- if (_this.opts.newline) {
- callback('display', -1);
- } else {
- callback('text', m);
- }
- return '';
- };
- })(this);
- ansiMess = function(m, g1) {
- var code, _j, _len;
- ansiMatch = true;
- if (g1.trim().length === 0) {
- g1 = '0';
- }
- g1 = g1.trimRight(';').split(';');
- for (_j = 0, _len = g1.length; _j < _len; _j++) {
- code = g1[_j];
- callback('display', code);
- }
- return '';
- };
- realText = function(m) {
- callback('text', m);
- return '';
- };
- tokens = [
- {
- pattern: /^\x08+/,
- sub: remove
- }, {
- pattern: /^\x1b\[[012]?K/,
- sub: remove
- }, {
- pattern: /^\x1b\[38;5;(\d+)m/,
- sub: removeXterm256
- }, {
- pattern: /^\n+/,
- sub: newline
- }, {
- pattern: /^\x1b\[((?:\d{1,3};?)+|)m/,
- sub: ansiMess
- }, {
- pattern: /^\x1b\[?[\d;]{0,3}/,
- sub: remove
- }, {
- pattern: /^([^\x1b\x08\n]+)/,
- sub: realText
- }
- ];
- process = function(handler, i) {
- var matches;
- if (i > ansiHandler && ansiMatch) {
- return;
- } else {
- ansiMatch = false;
- }
- matches = text.match(handler.pattern);
- text = text.replace(handler.pattern, handler.sub);
- if (matches == null) {
-
- }
- };
- _results1 = [];
- while ((length = text.length) > 0) {
- for (i = _j = 0, _len = tokens.length; _j < _len; i = ++_j) {
- handler = tokens[i];
- process(handler, i);
- }
- if (text.length === length) {
- break;
- } else {
- _results1.push(void 0);
- }
- }
- return _results1;
- };
-
- return Filter;
-
-})();
diff --git a/cmd/drone-server/static/scripts/views/builds/index/content.html b/cmd/drone-server/static/scripts/views/builds/index/content.html
deleted file mode 100644
index 53bb78a94..000000000
--- a/cmd/drone-server/static/scripts/views/builds/index/content.html
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
-
- settings_ethernet
- Push code to execute your first build. Be sure to configure you build using the .drone.yml file.
-
-
-
- error_outline
- There was an error fetching the build history.
-
-
-
-
-
\ No newline at end of file
diff --git a/cmd/drone-server/static/scripts/views/builds/index/toolbar.html b/cmd/drone-server/static/scripts/views/builds/index/toolbar.html
deleted file mode 100644
index 83dbfa9d4..000000000
--- a/cmd/drone-server/static/scripts/views/builds/index/toolbar.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
- arrow_back
-
-
- {{owner}} / {{name}}
-
\ No newline at end of file
diff --git a/cmd/drone-server/static/scripts/views/builds/show/content.html b/cmd/drone-server/static/scripts/views/builds/show/content.html
deleted file mode 100644
index 5a17574a0..000000000
--- a/cmd/drone-server/static/scripts/views/builds/show/content.html
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
-
-
close
-
-
{{ build.status }} {{ build.head_commit.message }}
-
{{ build.head_commit.author.login }} pushed to {{ build.head_commit.branch }} {{ build.started_at | fromNow }}
-
-
-
-
- Restart
- Cancel
-
-
-
-
-
-
-
-
-
-
-
- expand_more
-
-
-
-
-
diff --git a/cmd/drone-server/static/scripts/views/builds/show/toolbar.html b/cmd/drone-server/static/scripts/views/builds/show/toolbar.html
deleted file mode 100644
index 9f9a18f2d..000000000
--- a/cmd/drone-server/static/scripts/views/builds/show/toolbar.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
- arrow_back
-
-
- {{owner}} / {{name}}
- chevron_right
- {{number}}
-
\ No newline at end of file
diff --git a/cmd/drone-server/static/scripts/views/builds/step/content.html b/cmd/drone-server/static/scripts/views/builds/step/content.html
deleted file mode 100644
index 3c3a578f5..000000000
--- a/cmd/drone-server/static/scripts/views/builds/step/content.html
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
{{ build.head_commit.message }}
-
-
{{ build.head_commit.author.login }} pushed to {{ build.head_commit.branch}} {{ build.started_at | fromNow }}
-
-
-
-
-
-
-
-
-
-
- {{ key.toUpperCase() }}={{ value }}
-
-
-
-
-
-
-
-
-
-
-
-
-Restart
-Cancel
\ No newline at end of file
diff --git a/cmd/drone-server/static/scripts/views/builds/step/toolbar.html b/cmd/drone-server/static/scripts/views/builds/step/toolbar.html
deleted file mode 100644
index 8fc3302cf..000000000
--- a/cmd/drone-server/static/scripts/views/builds/step/toolbar.html
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/cmd/drone-server/static/scripts/views/layout.html b/cmd/drone-server/static/scripts/views/layout.html
deleted file mode 100644
index e698428e7..000000000
--- a/cmd/drone-server/static/scripts/views/layout.html
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
-
-
-
diff --git a/cmd/drone-server/static/scripts/views/login.html b/cmd/drone-server/static/scripts/views/login.html
deleted file mode 100644
index 93702f51f..000000000
--- a/cmd/drone-server/static/scripts/views/login.html
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
-
-
-
Oops. There was an unexpected error. Please try again.
-
There was an error authorizing your account.
-
Login is restricted to approved organization members only
-
Self-registration is disabled. Please contact the system admin to grant
- access.
-
-
- Login
-
diff --git a/cmd/drone-server/static/scripts/views/profile/content.html b/cmd/drone-server/static/scripts/views/profile/content.html
deleted file mode 100644
index 2225e6646..000000000
--- a/cmd/drone-server/static/scripts/views/profile/content.html
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
Login
-
{{ user.login }}
-
-
-
Email
-
{{ user.email }}
-
-
-
Token
-
Click to Display Token
-
{{ token }}
-
-
-
-
-
\ No newline at end of file
diff --git a/cmd/drone-server/static/scripts/views/profile/toolbar.html b/cmd/drone-server/static/scripts/views/profile/toolbar.html
deleted file mode 100644
index 89e320a1c..000000000
--- a/cmd/drone-server/static/scripts/views/profile/toolbar.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
- arrow_back
-
-
- Profile
-
\ No newline at end of file
diff --git a/cmd/drone-server/static/scripts/views/repos/add/content.html b/cmd/drone-server/static/scripts/views/repos/add/content.html
deleted file mode 100644
index f16e1bda1..000000000
--- a/cmd/drone-server/static/scripts/views/repos/add/content.html
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
- Register your repository with Drone to enable automated testing. Note that Drone
- will attempt to add a post-commit hook to your repository. This may require administrative access.
-
-
- There was an error adding your repository. Please ensure the
- repository exists and you have admin privileges.
-
-
-
-
diff --git a/cmd/drone-server/static/scripts/views/repos/add/toolbar.html b/cmd/drone-server/static/scripts/views/repos/add/toolbar.html
deleted file mode 100644
index 1d8420982..000000000
--- a/cmd/drone-server/static/scripts/views/repos/add/toolbar.html
+++ /dev/null
@@ -1,6 +0,0 @@
-
\ No newline at end of file
diff --git a/cmd/drone-server/static/scripts/views/repos/del.html b/cmd/drone-server/static/scripts/views/repos/del.html
deleted file mode 100644
index a82c25c61..000000000
--- a/cmd/drone-server/static/scripts/views/repos/del.html
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
- Delete
-Warning: this action cannot be undone.
-
-
-
-
\ No newline at end of file
diff --git a/cmd/drone-server/static/scripts/views/repos/edit.html b/cmd/drone-server/static/scripts/views/repos/edit.html
deleted file mode 100644
index 425b416c9..000000000
--- a/cmd/drone-server/static/scripts/views/repos/edit.html
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cmd/drone-server/static/scripts/views/repos/env.html b/cmd/drone-server/static/scripts/views/repos/env.html
deleted file mode 100644
index b4913c42b..000000000
--- a/cmd/drone-server/static/scripts/views/repos/env.html
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
- Private variables
-
-
export {{ key }} =
-
{{ value }}
-
-
-
-
-
\ No newline at end of file
diff --git a/cmd/drone-server/static/scripts/views/repos/index/content.html b/cmd/drone-server/static/scripts/views/repos/index/content.html
deleted file mode 100644
index c60b7b9c6..000000000
--- a/cmd/drone-server/static/scripts/views/repos/index/content.html
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
- control_point_duplicate
- Get started by adding your repository. Just type the repository name in the text box above.
-
-
-
- control_point_duplicate
- refresh
- Press <enter> to add {{search_text}}
- Configuring repository {{search_text}}
-
-
-
- error_outline
- There was an error adding your repository. Please ensure the
- repository exists and you have admin privileges.
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cmd/drone-server/static/scripts/views/repos/index/toolbar.html b/cmd/drone-server/static/scripts/views/repos/index/toolbar.html
deleted file mode 100644
index 595c6f206..000000000
--- a/cmd/drone-server/static/scripts/views/repos/index/toolbar.html
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/cmd/drone-server/static/scripts/views/repos/secure.html b/cmd/drone-server/static/scripts/views/repos/secure.html
deleted file mode 100644
index 7bb7541f5..000000000
--- a/cmd/drone-server/static/scripts/views/repos/secure.html
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
- Encrypt and store secret variables in the .drone.sec
file
-
- Encrypt
-
-
-
{{secure}}
-
-
-
\ No newline at end of file
diff --git a/cmd/drone-server/static/scripts/views/repos/toolbar.html b/cmd/drone-server/static/scripts/views/repos/toolbar.html
deleted file mode 100644
index 0d8349650..000000000
--- a/cmd/drone-server/static/scripts/views/repos/toolbar.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
- arrow_back
-
-
- {{owner}} / {{name}}
-
diff --git a/cmd/drone-server/static/scripts/views/users/content.html b/cmd/drone-server/static/scripts/views/users/content.html
deleted file mode 100644
index 46d02d7ec..000000000
--- a/cmd/drone-server/static/scripts/views/users/content.html
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
- control_point_duplicate
- Get started by adding your team members. Just type the user login (ie octocat) in the text box above.
-
-
-
- control_point_duplicate
- sync
- Press <enter> to add {{search_text}}
-
-
-
- Successfully added user account {{new_user.login}} .
-
-
-
- error_outline
- There was an error adding the user account.
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cmd/drone-server/static/scripts/views/users/toolbar.html b/cmd/drone-server/static/scripts/views/users/toolbar.html
deleted file mode 100644
index af8cf68c6..000000000
--- a/cmd/drone-server/static/scripts/views/users/toolbar.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
- arrow_back
-
-
- Users
-
\ No newline at end of file
diff --git a/cmd/drone-server/static/styles/alert.css b/cmd/drone-server/static/styles/alert.css
deleted file mode 100644
index f9420d8eb..000000000
--- a/cmd/drone-server/static/styles/alert.css
+++ /dev/null
@@ -1,89 +0,0 @@
-.alert {
- padding: 40px;
- background-color: #F5F7F9;
- color: #4f5b66;
- text-align: center;
- font-size: 16px;
- border-radius:3px;
- margin-bottom:30px;
- position:relative;
-}
-.alert em {
- font-weight: bold;
- color: #2b303b;
-}
-.alert i.material-icons {
- font-size: 42px;
- display: block;
- text-align: center;
- width: 100%;
- margin-bottom: 20px;
-}
-.alert-error {
- background: #bf616a;
- color: #fff;
- line-height:24px;
-}
-.alert-success {
- background: #a3be8c;
- color: #fff;
- line-height:24px;
-}
-.alert-create-not-found {
- color: rgba(255,255,255,0.95);
- background:#59abe3;
- background: #8fa1b3;
- outline:none;
- border:none;
- width:100%;
- font-family: Roboto;
-}
-.alert-success em,
-.alert-error em,
-.alert-create-not-found em {
- font-weight: bold;
- color: #fff;
- font-size: 120%;
- margin-left:10px;
-}
-
-@-webkit-keyframes delayed-rotate {
- 0% {
- -webkit-transform: rotate(0deg);
- }
- 100% {
- -webkit-transform: rotate(360deg);
- }
-}
-@-moz-keyframes delayed-rotate {
- 0% {
- -moz-transform: rotate(0deg);
- }
- 100% {
- -moz-transform: rotate(360deg);
- }
-}
-@keyframes delayed-rotate {
- 0% {
- transform: rotate(0deg);
- }
- 100% {
- transform: rotate(360deg);
- }
-}
-.waiting {
- -webkit-animation-name: delayed-rotate;
- -webkit-animation-duration: 1s;
- -webkit-animation-iteration-count: infinite;
- -webkit-animation-timing-function: ease-in-out;
-
- -moz-animation-name: delayed-rotate;
- -moz-animation-duration: 1s;
- -moz-animation-iteration-count: infinite;
- -moz-animation-timing-function: ease-in-out;
-
- animation-name: delayed-rotate;
- animation-duration: 1s;
- animation-iteration-count: infinite;
- animation-timing-function: ease-in-out;
-}
diff --git a/cmd/drone-server/static/styles/blankslate.css b/cmd/drone-server/static/styles/blankslate.css
deleted file mode 100644
index 177a19f6d..000000000
--- a/cmd/drone-server/static/styles/blankslate.css
+++ /dev/null
@@ -1,23 +0,0 @@
-.blankslate {
- padding: 40px 20px;
- background-color: #59abe3;
- background-color: #8fa1b3;
- color: #fff;
- text-align: center;
- font-size: 18px;
- line-height:28px;
- margin-bottom:30px;
-}
-.blankslate.clean-background {
-
-}
-.blankslate.spacious {
-
-}
-.blankslate i.material-icons {
- font-size: 42px;
- display: block;
- text-align: center;
- width: 100%;
- margin-bottom: 20px;
-}
\ No newline at end of file
diff --git a/cmd/drone-server/static/styles/fonts.css b/cmd/drone-server/static/styles/fonts.css
deleted file mode 100644
index a450a5a26..000000000
--- a/cmd/drone-server/static/styles/fonts.css
+++ /dev/null
@@ -1,3 +0,0 @@
-@import url(//fonts.googleapis.com/css?family=Roboto:400,300,500,700);
-@import url(//fonts.googleapis.com/css?family=Roboto+Mono:300,400,500);
-@import url(//fonts.googleapis.com/icon?family=Material+Icons);
\ No newline at end of file
diff --git a/cmd/drone-server/static/styles/label.css b/cmd/drone-server/static/styles/label.css
deleted file mode 100644
index 199a432a6..000000000
--- a/cmd/drone-server/static/styles/label.css
+++ /dev/null
@@ -1,29 +0,0 @@
-.label {
- color: #FFF;
- background:#8fa1b3;
- font-size: 10px;
- text-transform: uppercase;
- padding: 4px 8px;
- vertical-align: middle;
- border-radius: 2px;
- margin-left: 15px;
- cursor:default;
- -webkit-user-select: none;
- -moz-user-select: none;
- user-select: none;
-}
-
-.label-success {
- color: #a3be8c;
- border: 1px solid #a3be8c;
- background: #fff;
-/*
- background: rgba(163, 190, 140, 0.25);
- border: none;
- font-size: 11px;*/
-}
-.label-failure {
- color: #bf616a;
- border: 1px solid #bf616a;
- background: #fff;
-}
\ No newline at end of file
diff --git a/cmd/drone-server/static/styles/list.css b/cmd/drone-server/static/styles/list.css
deleted file mode 100644
index ea74b19f7..000000000
--- a/cmd/drone-server/static/styles/list.css
+++ /dev/null
@@ -1,99 +0,0 @@
-.list > a,
-.list > li {
- display: flex;
- padding: 30px 0px;
- border-top: 1px solid #f0f4f7;
- color:#4c555a;
- text-decoration: none;
- position: relative;
-}
-.list > a:first-child,
-.list > li:first-child {
- border-top: none;
-}
-
-.list .column-avatar {
- width: 60px;
- min-width: 60px;
-}
-.list .column-status {
- width: 60px;
- min-width: 60px;
-}
-.list .column-fill {
- flex: 1 1 auto;
-}
-
-.comfortable > a,
-.comfortable > div,
-.comfortable > li {
- padding-top:30px;
- padding-bottom:30px;
-}
-
-.cozy > a,
-.cozy > div,
-.cozy > li {
- padding-top:15px;
- padding-bottom:15px;
-}
-
-.compact > a,
-.compact > div,
-.compact > li {
- padding-top:10px;
- padding-bottom:10px;
-}
-
-.list .column-avatar img {
- width:32px;
- height:32px;
- border-radius:4px;
- margin-left:5px;
-}
-.user-list .column-avatar img {
- width:32px;
- height:32px;
- border-radius:50%;
- margin-left:5px;
-}
-.list h2 {
- line-height:32px;
- font-size:18px;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- margin-bottom:1px;
-}
-.list p {
- color:#a7adba;
- margin-top:3px;
- font-size:14px;
- line-height:20px;
-}
-.list em,
-.list em {
- color:#65737e;
-}
-/*
-.matrix-list a.active {
- background-color: #eff1f5;
- margin-left: -10px;
- padding-left: 10px;
-}*/
-.matrix-list a.active:after {
- content:"chevron_right";
- font-family: "Material Icons";
- line-height:28px;
- color: #c0c5ce;
- font-weight: normal;
- font-style: normal;
- font-size: 24px;
- letter-spacing: normal;
- text-transform: none;
- display: inline-block;
- word-wrap: normal;
- -webkit-font-feature-settings: 'liga';
- -webkit-font-smoothing: antialiased;
- margin-right:-5px;
-}
diff --git a/cmd/drone-server/static/styles/main.css b/cmd/drone-server/static/styles/main.css
deleted file mode 100644
index 966356225..000000000
--- a/cmd/drone-server/static/styles/main.css
+++ /dev/null
@@ -1,769 +0,0 @@
-html, body {
- background:#fff;
- color:#4c555a;
- font-size:14px;
- font-family:"Roboto";
- min-height:100vh;
-}
-
-body > div {
- display: flex;
- flex-direction: column;
- min-height: 100vh;
-}
-
-/*
- * Header and Logo
- */
-
-.logo {
- float: left;
- height: 36px;
- width: 36px;
- opacity: 1;
- margin: 14px 0px 0px 14px;
- margin: 14px 0px 0px 18px;
- background: url(data:image/svg+xml;charset=utf-8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+DQo8IS0tIENyZWF0ZWQgd2l0aCBJbmtzY2FwZSAoaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvKSAtLT4NCg0KPHN2Zw0KICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIg0KICAgeG1sbnM6Y2M9Imh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL25zIyINCiAgIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyINCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciDQogICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciDQogICB4bWxuczpzb2RpcG9kaT0iaHR0cDovL3NvZGlwb2RpLnNvdXJjZWZvcmdlLm5ldC9EVEQvc29kaXBvZGktMC5kdGQiDQogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSINCiAgIHdpZHRoPSIzMiINCiAgIGhlaWdodD0iMzIiDQogICBpZD0ic3ZnMiINCiAgIHZlcnNpb249IjEuMSINCiAgIGlua3NjYXBlOnZlcnNpb249IjAuNDguMy4xIHI5ODg2Ig0KICAgc29kaXBvZGk6ZG9jbmFtZT0iZHJvbmVfMzIucG5nIj4NCiAgPGRlZnMNCiAgICAgaWQ9ImRlZnM0IiAvPg0KICA8c29kaXBvZGk6bmFtZWR2aWV3DQogICAgIGlkPSJiYXNlIg0KICAgICBwYWdlY29sb3I9IiNmZmZmZmYiDQogICAgIGJvcmRlcmNvbG9yPSIjNjY2NjY2Ig0KICAgICBib3JkZXJvcGFjaXR5PSIxLjAiDQogICAgIGlua3NjYXBlOnBhZ2VvcGFjaXR5PSIwLjAiDQogICAgIGlua3NjYXBlOnBhZ2VzaGFkb3c9IjIiDQogICAgIGlua3NjYXBlOnpvb209IjcuOTE5NTk1OSINCiAgICAgaW5rc2NhcGU6Y3g9IjkuNjYyNzY2NCINCiAgICAgaW5rc2NhcGU6Y3k9IjYuMzk3Njg2NCINCiAgICAgaW5rc2NhcGU6ZG9jdW1lbnQtdW5pdHM9InB4Ig0KICAgICBpbmtzY2FwZTpjdXJyZW50LWxheWVyPSJsYXllcjEiDQogICAgIHNob3dncmlkPSJ0cnVlIg0KICAgICBpbmtzY2FwZTpzbmFwLWdsb2JhbD0iZmFsc2UiDQogICAgIGlua3NjYXBlOndpbmRvdy13aWR0aD0iMTI5NSINCiAgICAgaW5rc2NhcGU6d2luZG93LWhlaWdodD0iNzQ0Ig0KICAgICBpbmtzY2FwZTp3aW5kb3cteD0iNjUiDQogICAgIGlua3NjYXBlOndpbmRvdy15PSIyNCINCiAgICAgaW5rc2NhcGU6d2luZG93LW1heGltaXplZD0iMSINCiAgICAgZml0LW1hcmdpbi10b3A9IjAiDQogICAgIGZpdC1tYXJnaW4tbGVmdD0iMCINCiAgICAgZml0LW1hcmdpbi1yaWdodD0iMCINCiAgICAgZml0LW1hcmdpbi1ib3R0b209IjAiPg0KICAgIDxpbmtzY2FwZTpncmlkDQogICAgICAgdHlwZT0ieHlncmlkIg0KICAgICAgIGlkPSJncmlkMjk5NiINCiAgICAgICBlbXBzcGFjaW5nPSI1Ig0KICAgICAgIHZpc2libGU9InRydWUiDQogICAgICAgZW5hYmxlZD0idHJ1ZSINCiAgICAgICBzbmFwdmlzaWJsZWdyaWRsaW5lc29ubHk9InRydWUiDQogICAgICAgb3JpZ2lueD0iLTIxLjcyMDc3OXB4Ig0KICAgICAgIG9yaWdpbnk9Ii05OTAuMzcxODhweCIgLz4NCiAgPC9zb2RpcG9kaTpuYW1lZHZpZXc+DQogIDxtZXRhZGF0YQ0KICAgICBpZD0ibWV0YWRhdGE3Ij4NCiAgICA8cmRmOlJERj4NCiAgICAgIDxjYzpXb3JrDQogICAgICAgICByZGY6YWJvdXQ9IiI+DQogICAgICAgIDxkYzpmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZGM6Zm9ybWF0Pg0KICAgICAgICA8ZGM6dHlwZQ0KICAgICAgICAgICByZGY6cmVzb3VyY2U9Imh0dHA6Ly9wdXJsLm9yZy9kYy9kY21pdHlwZS9TdGlsbEltYWdlIiAvPg0KICAgICAgICA8ZGM6dGl0bGU+PC9kYzp0aXRsZT4NCiAgICAgIDwvY2M6V29yaz4NCiAgICA8L3JkZjpSREY+DQogIDwvbWV0YWRhdGE+DQogIDxnDQogICAgIGlua3NjYXBlOmxhYmVsPSJMYXllciAxIg0KICAgICBpbmtzY2FwZTpncm91cG1vZGU9ImxheWVyIg0KICAgICBpZD0ibGF5ZXIxIg0KICAgICB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMjEuNzIwNzc5LC0yOS45OTAyODcpIj4NCiAgICA8cGF0aA0KICAgICAgIHNvZGlwb2RpOnR5cGU9ImFyYyINCiAgICAgICBzdHlsZT0iZmlsbDojMjQyNzI5O2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpldmVub2RkO3N0cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDowO3N0cm9rZS1saW5lY2FwOmJ1dHQ7c3Ryb2tlLWxpbmVqb2luOm1pdGVyO3N0cm9rZS1taXRlcmxpbWl0OjQ7c3Ryb2tlLW9wYWNpdHk6MTtzdHJva2UtZGFzaGFycmF5Om5vbmUiDQogICAgICAgaWQ9InBhdGgyOTk4Ig0KICAgICAgIHNvZGlwb2RpOmN4PSIxNzIuMTA0NzQiDQogICAgICAgc29kaXBvZGk6Y3k9IjQ1OC4zOTI0OSINCiAgICAgICBzb2RpcG9kaTpyeD0iNS40Mjk1Njk3Ig0KICAgICAgIHNvZGlwb2RpOnJ5PSI1LjA1MDc2MjciDQogICAgICAgZD0ibSAxNzcuNTM0MzEsNDU4LjM5MjQ5IGEgNS40Mjk1Njk3LDUuMDUwNzYyNyAwIDEgMSAtMTAuODU5MTQsMCA1LjQyOTU2OTcsNS4wNTA3NjI3IDAgMSAxIDEwLjg1OTE0LDAgeiINCiAgICAgICB0cmFuc2Zvcm09Im1hdHJpeCgwLjc1NDE4MzA2LDAsMCwwLjgxMDc0NjgxLC05Mi4wNzA0MDEsLTMyMy4wMDQpIiAvPg0KICAgIDxwYXRoDQogICAgICAgc3R5bGU9ImZpbGw6IzI0MjcyOTtmaWxsLW9wYWNpdHk6MTtzdHJva2Utd2lkdGg6MDtzdHJva2UtbWl0ZXJsaW1pdDo0Ig0KICAgICAgIGQ9Im0gMzcuNzI4MDc1LDMyLjkyNjc2MiBjIDcuMTQ4NjU3LDAuMDU1OTkgMTUuMjc2MDY3LDUuMDk1MzgzIDE2LjAwNzI5NSwxNC41OTI2OTggbCAtOS42Nzg4MywwIGMgMCwwIC0xLjI0Njg3MSwtNS4yNDY5MTYgLTYuMzI4NDY1LC01LjIxMTY3OCAtNS4wODE1OTUsMC4wMzUyMiAtNi4zMjg0NjYsNS4yMTE2NzggLTYuMzI4NDY2LDUuMjExNjc4IGwgLTkuNjc4ODMsMCBjIDAuNDcwMjUsLTkuMzI5NDQ3IDguNDYyMDk3LC0xNC42NTE3NzYgMTYuMDA3Mjk2LC0xNC41OTI2OTggeiINCiAgICAgICBpZD0icmVjdDM4MTAiDQogICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCINCiAgICAgICBzb2RpcG9kaTpub2RldHlwZXM9InNjY3pjY3MiIC8+DQogICAgPHBhdGgNCiAgICAgICBzdHlsZT0iZmlsbDojMjQyNzI5O2ZpbGwtb3BhY2l0eToxO3N0cm9rZS13aWR0aDowO3N0cm9rZS1taXRlcmxpbWl0OjQiDQogICAgICAgZD0iTSAzNy43OTQ1NTMsNTkuOTkwMjYgQyAzMi40NjQyMDIsNjAuMDA0NDQgMjcuNDg0NjczLDU1Ljk4MjIyMSAyNS40NDM0MDYsNDkuNzUzMDM2IGwgNS45NTYyMDMsMCBjIDAsMCAxLjI4NDg2NSw1LjE4NzcxOSA2LjM2NjQ1OSw1LjE1MjQ4IDUuMDgxNTk0LC0wLjAzNTIyIDYuMjkwNDcyLC01LjE1MjQ4IDYuMjkwNDcyLC01LjE1MjQ4IGwgNS45NTYyMDMsMCBjIC0xLjMyNzc1LDYuNTg5Nzc0IC02Ljg4NzgzOCwxMC4yMjMwMzggLTEyLjIxODE5LDEwLjIzNzIyNCB6Ig0KICAgICAgIGlkPSJyZWN0MzgxMC0xIg0KICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiDQogICAgICAgc29kaXBvZGk6bm9kZXR5cGVzPSJzY2N6Y2NzIiAvPg0KICA8L2c+DQo8L3N2Zz4=) no-repeat center center;
-}
-header {
- height:60px;
- min-height:60px;
- max-height:60px;
- /*border-bottom:1px solid #f2f2f2;*/
- box-sizing: border-box;
-}
-header ul {
- float:right;
- margin-right:20px;
-}
-header ul li span {
- margin-right:7px;
- margin-right:3px;
-}
-header li {
- display:inline-block;
-}
-header li a {
- line-height:60px;
- display:inline-block;
- vertical-align: middle;
- padding:0px 10px;
- text-transform: lowercase;
- color:#4c555a;
- text-decoration: none;
- font-size:15px;
-}
-header li i {
- vertical-align: middle;
-}
-header li.active a {
- color:#0099e5;
-}
-
-header li img {
- border-radius:50%;
- width:32px;
- height:32px;
- vertical-align: middle;
- margin-right:3px;
-}
-
-header ol {
- float:left;
- margin-left:15px;
-}
-header ol li {
- line-height:60px;
- display:inline-block;
- vertical-align: middle;
- font-size:21px;
-}
-header ol li:first-child {
- font-size:0px;
-}
-header ol li i {
- vertical-align: middle;
- font-size:28px;
-}
-header ol li a {
- line-height:inherit;
- vertical-align: middle;
- font-size:0px;
-}
-header ol li a i.material-icons {
- vertical-align: middle;
- font-size:25px;
-}
-header .private {
- color: #ebcb8b;
- opacity: 0.8;
- /*color: #000;
- opacity:0.25;*/
- padding-left:15px;
- margin-top:-5px;
- display:none;
-}
-header .private i {
- font-size:27px;
-}
-
-input[type="search"] {
- font-family:Roboto;
-}
-
-/*
- * Main Seciton / Layout
- */
-
-.flex {
- display:flex;
- flex:1 1 auto;
- margin-top:0px;
-}
-main article {
- margin:0px auto;
- max-width:900px;
- padding:30px 40px;
-}
-.flex article {
- padding-bottom:0px;
-}
-.flex article pre {
- min-height: calc(100vh - 120px);
- margin-bottom:20px;
-}
-main aside {
- min-width:450px;
- width:450px;
- box-sizing: border-box;
- padding:40px 50px;
-}
-main aside > div {
- position: sticky;
- top:0px;
-}
-
-
-
-/*
- * Build Console
- */
-
-.console {
- margin:0px;
- flex: 1 1 auto;
- /*margin-top: -1px;*/
- max-width:auto;
- padding:30px 40px 20px 0px;
-}
-
-.console pre {
- color:#eff1f5;
- border-radius:2px;
- background:#2b303b;
- white-space: pre-wrap;
- word-wrap: break-word;
- box-sizing: border-box;
- padding:35px 40px;
- line-height:18px;
- font-family: "Roboto Mono";
- font-size:12px;
- font-weight:300;
-}
-
-@media (-webkit-max-device-pixel-ratio: 1) {
- .console pre {
- font-weight:400;
- line-height:20px;
- font-size:13px;
- }
-}
-
-/*
- * Repo List
- */
-
-
- /*
- * Build List
- */
-
- .repo-list { }
- .repo-list li {
- display:flex;
- padding:30px 0px;
- border-top:1px solid #f0f4f7;
- position:relative;
-}
-.repo-list img {
- width:32px;
- height:32px;
- border-radius:50%;
- margin-left:5px;
-}
-.repo-list li:first-child {
- border-top:none;
-}
-.repo-list li > div:first-child {
- width:60px;
- min-width:60px;
-}
-.repo-list li > div:nth-child(2) {
- flex:1 1 auto;
-}
-.repo-list h2 {
- line-height:32px;
- font-size:18px;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- margin-bottom:1px;
-}
-.repo-list p {
- color:#a7adba;
- margin-top:3px;
- font-size:14px;
- line-height:20px;
- display:none;
-}
-
-
-/*
- * Build List
- */
-
-.build-list { }
-.build-list li {
- display:flex;
- /*padding:30px 0px 30px 35px;*/
- padding:30px 0px;
- border-top:1px solid #f0f4f7;
- position:relative;
-}
-/*.build-list li:nth-child(even) {
- background:#FAFBFC;
-}*/
-.build-list li:first-child {
- border-top:none;
-}
-.build-list li > div:first-child {
- width:60px;
- min-width:60px;
-}
-.build-list li > div:nth-child(2) {
- flex:1 1 auto;
-}
-.build-list h2 {
- line-height:32px;
- font-size:18px;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- margin-bottom:1px;
-}
-.build-section p,
-.build-list p {
- color:#a7adba;
- margin-top:3px;
- font-size:14px;
- line-height:20px;
-}
-.build-section em,
-.build-list em {
- color:#65737e;
-}
-.build-list h2 small:before {
- content:"#";
- margin-right:3px;
-}
-.build-list h2 small:after {
- content:" ";
- margin-right:10px;
-}
-
-
-/*
- * Build Details
- */
-
-.build-section {
- margin-bottom:40px;
- display:flex;
-}
-.build-section > div:first-child {
- min-width:60px;
- width:60px;
- display:none;
-}
-.build-section > div:last-child {
- flex: 1 1 auto;
- padding-top:4px;
- font-size:17px;
- line-height:22px;
-}
-.build-detail {
- padding-left:50px;
- box-sizing: border-box;
-}
-.build-summary h2 {
- line-height:23px;
-}
-.build-summary h2 small {
- font-size: 11px;
- text-transform: uppercase;
- padding: 3px 10px;
- border-radius: 2px;
- margin-right: 5px;
- vertical-align: top;
- color:#FFF;
- width:auto;
- height:auto;
- display:inline;
-}
-.build-summary p {
- margin-top:10px;
-}
-
-/*
- * Job List
- */
-
-.job-list { }
-.job-list > a,
-.job-list > li {
- display:flex;
- padding:20px 0px;
- border-top:1px solid #f0f4f7;
-}
-
-.job-list > a > div:first-child,
-.job-list > li > div:first-child {
- width:50px;
- min-width:50px;
-}
-.job-list > a > div:nth-child(2),
-.job-list > li > div:nth-child(2) { /** TEMPORARILY HIDDEN. MAY DECIDE TO REMOVE */
- min-width:25px;
- font-size:13px;
- text-align:right;
- padding: 10px 20px 0px 10px;
- font-weight:bold;
- font-size:15px;
- display:none;
-}
-.job-list > a > div:nth-child(3),
-.job-list > li > div:nth-child(3) {
- flex:1 1 auto;
- font-size:13px;
-}
-.job-list > a div.param,
-.job-list > li div.param {
- margin-top:5px;
-}
-.job-list > a div.param:first-child,
-.job-list > li div.param:first-child {
- margin-top:9px;
-}
-.job-list > a div.meta,
-.job-list > li div.meta {
- margin-top: 5px;
- color: #a7adba;
-}
-.job-list > a div.meta-group {
- padding-top:10px;
- display:none;
-}
-.job-list > a.active div.meta-group {
- display:block;
-}
-.job-list:not(.matrix-list) > a div.meta:first-child {
- color: #4c555a;
- margin-top: -2px;
- padding-bottom: 5px;
- font-size: 14px;
-}
-
-li menu {
- position:absolute;
- top:15px;
- right:0px;
- display:none;
-}
-li:hover menu {
- display:inline-block;
-}
-li menu .button {
- border-radius:50%;
- width:36px;
- height:36px;
- line-height:36px;
- padding:0px;
-
- color:#dfe1e8;
- background: #fff;
- border:1px solid #FFF;
- outline:none;
- cursor:pointer;
-
-
- width: auto;
- text-transform: uppercase;
- padding: 0px 10px;
- border-radius: 2px;
- font-size: 11px;
- line-height: 30px;
- height: auto;
- margin-left: 10px;
-
-
-}
-li menu .button:hover {
- border:1px solid #a7adba;
- background:#FFF;
- color:#a7adba;
-}
-li menu .button i {
- font-size:22px;
-}
-
-li menu .button.success {
- color: #FFF;
- border:1px solid #a3be8c;
- background: #a3be8c;
-
- color: #a3be8c;
- background:#FFF;
-
-
-}
-li menu .button.danger {
- color: #FFF;
- background: #bf616a;
-
- color:#bf616a;
- background:#FFF;
- border:1px solid #bf616a;
-}
-
-
-
-/*
- * Tail button to follow a build
- */
-
-.button-tail {
- position: fixed;
- bottom: 50px;
- right: 80px;
- width: 38px;
- height: 38px;
- background: rgba(255,255,255,0.2);
- border-radius: 50%;
- box-shadow: 1px 2px 2px rgba(0,0,0,0.2);
- cursor: pointer;
-
- bottom: 15px;
- right: 60px;
- }
-.button-tail i {
- text-align:center;
- color:rgba(255,255,255,0.5);
- width:38px;
- line-height:38px;
- display:inline-block;
-}
-
-
-/*
- * Random buttons used throughtout
- */
-/*
-menu {
- display:block;
- text-align:right;
- margin-bottom:20px;
-}
-
-menu .button {
- margin-left:5px;
- border:1px solid #f0f0f0;
-}
-menu .button span {
- margin:0px 10px;
- text-transform: uppercase;
-}*/
-.button {
- border-radius:2px;
- line-height:32px;
- display:inline-block;
- vertical-align: middle;
- padding:4px 15px 4px 15px;
- text-decoration: none;
- font-size:13px;
- background:#eff1f5;
- color: rgba(0,0,0,0.5);
-}
-.button:hover {
- background:#dfe1e8;
-}
-/*
-.button-watch {
- background: #a7adba;
-}
-.button-settings {
- background:#d08770;
-}
-*/
-.button i {
- vertical-align: middle;
- /*margin-right:5px;*/
- line-height:17px;
- font-size:18px;
-}
-
-.button-restart {
- background: #FFF;
- border: 1px solid #8fa1b3;
- color: #8fa1b3;
- font-size: 13px;
- text-transform: uppercase;
- margin-bottom: 20px;
- margin-top:-20px;
- padding: 0px 10px;
- line-height: 25px;
- cursor:pointer;
-}
-.button-cancel {
- background: #FFF;
- border: 1px solid #d08770;
- color: #d08770;
- font-size: 13px;
- text-transform: uppercase;
- margin-bottom: 20px;
- margin-top:-20px;
- padding: 0px 10px;
- line-height: 25px;
- cursor:pointer;
-}
-.button-cancel:hover {
- background: #d08770;
- border: 1px solid #d08770;
- color: #fff;
-}
-.button-login {
- margin-top: 15px;
- font-size: 13px;
- text-transform: uppercase;
- background: #FFF;
- border: 1px solid #8fa1b3;
- color: #8fa1b3;
- line-height: 25px;
-}
-.button-login:hover {
- background: #8fa1b3;
- border: 1px solid #8fa1b3;
- color: #fff;
-}
-
-/*
- * Status Indicator
- */
-
-.status {
- width: 32px;
- height: 32px;
- border-radius: 50%;
- display: inline-block;
-}
-.status i {
- line-height: 32px;
- width: 32px;
- vertical-align: middle;
- text-align: center;
- font-size:24px;
- color:rgba(255,255,255,0.7);
-}
-.status-small {
- width: 28px;
- height: 28px;
-}
-.status-small i {
- line-height: 28px;
- width: 28px;
- height: 28px;
-}
-
-/* Search Form */
-.search {
- display:block;
- width:100%;
- margin:0px 0px 37px 0px;
-}
-input[type="search"] {
- background: #eff1f5;
- line-height: 50px;
- border:none;
- border-radius:3px;
- display:block;
- width:100%;
- font-size:14px;
- padding:0px 15px;
- font-family:"Roboto";
-
-}
-
-/* SETTINGS SECTION */
-
-
-section .row {
- display: flex;
- position: relative;
- text-decoration: none;
-}
-section .row a {
- text-decoration: none;
-}
-section .row > div:first-child {
- padding: 30px 0px;
- border-bottom: 1px solid #f0f4f7;
- width: 200px;
- min-width: 200px;
- font-size:15px;
- color: #343d46;
-}
-
-section .row > div:last-child {
- flex: 1 1 auto;
- padding: 30px;
- border-bottom: 1px solid #f0f4f7;
- overflow:hidden;
- color: #65737e;
-}
-
-section .row:last-child > div {
- border-bottom: none;
-}
-
-pre.snippet-padding {
- padding: 30px 0px;
-}
-pre.snippet {
- white-space: pre-wrap;
- word-wrap: break-word;
- font-size: 13px;
- line-height: 18px;
- font-family: "Roboto Mono";
-}
-.slider-label {
- display: inline-block;
- margin-left: 10px;
-}
-
-
-::-webkit-input-placeholder { /* WebKit browsers */
- color: #a7adba;
-}
-:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
- color: #a7adba;
- opacity: 1;
-}
-::-moz-placeholder { /* Mozilla Firefox 19+ */
- color: #a7adba;
- opacity: 1;
-}
-:-ms-input-placeholder { /* Internet Explorer 10+ */
- color: #a7adba;
-}
-
-
-
-/* ROUND INDICATORS */
-.status {
- border-radius:50%;
-}
-.status.error,
-.status.killed,
-.status.failure {
- background: #bf616a;
-}
-.status.success {
- background:#a3be8c;
-}
-.status.running,
-.status.pending {
- background:#ebcb8b;
-}
-
-.status.running i,
-.status.pending i {
- -webkit-animation-name: delayed-rotate;
- -webkit-animation-duration: 1s;
- -webkit-animation-iteration-count: infinite;
- -webkit-animation-timing-function: ease-in-out;
-
- -moz-animation-name: delayed-rotate;
- -moz-animation-duration: 1s;
- -moz-animation-iteration-count: infinite;
- -moz-animation-timing-function: ease-in-out;
-
- animation-name: delayed-rotate;
- animation-duration: 1s;
- animation-iteration-count: infinite;
- animation-timing-function: ease-in-out;
-}
-.build-list li > div:first-child,
-.job-list li > div:first-child {
- width: 55px;
- min-width: 55px;
-}
-
-
-
-/*
- * Search Menu
- */
-
-section.search {
- background: #eff1f5;
- margin: 0px 0px 37px 0px;
- border-radius: 3px;
- display:flex;
- flex-shrink: 0;
-}
-section.search input[type="search"] {
- line-height: 50px;
- border: none;
- border-radius: 3px;
- display: block;
- width: 100%;
- font-size: 16px;
- padding: 0px 15px;
- flex:1 1 auto;
- font-family:"Roboto";
-}
-section.search menu {
- display:flex;
- flex-shrink: 0;
-}
-section.search menu button,
-section.search menu a {
- line-height: 50px;
- vertical-align: middle;
- display: inline-block;
- padding: 0px 15px;
- color: rgba(0,0,0,0.3);
- background:transparent;
- border:none;
- border-left: 1px solid #FFF;
- cursor:pointer;
- outline:none;
-}
-section.search menu i {
- vertical-align: middle;
-}
-
-
-
-/*
- * Lists
- */
diff --git a/cmd/drone-server/static/styles/range.css b/cmd/drone-server/static/styles/range.css
deleted file mode 100644
index 91bcb79f8..000000000
--- a/cmd/drone-server/static/styles/range.css
+++ /dev/null
@@ -1,109 +0,0 @@
-input[type="range"]:focus ~ .slider-label {
- display: inline-block;
-}
-
-input[type=range] {
- -webkit-appearance: none;
- margin: 6px 0;
- width: 200px;
-}
-
-input[type=range]:focus {
- outline: none;
-}
-
-input[type=range]::-webkit-slider-runnable-track {
- width: 100%;
- height: 8px;
- cursor: pointer;
- animate: 0.2s;
- box-shadow: none;
- background: rgba(0, 150, 136, 0.5);
- background: rgba(102, 187, 106, 0.5);
- border-radius: 5px;
- border: none;
-}
-
-input[type=range]::-webkit-slider-thumb {
- box-shadow: none;
- border: none;
- height: 26px;
- width: 26px;
- border-radius: 50px;
- background: #009688;
- background: #66bb6a;
- cursor: pointer;
- -webkit-appearance: none;
- margin-top: -10px;
-}
-
-input[type=range]:focus::-webkit-slider-runnable-track {
- background: rgba(0, 150, 136, 0.5);
- background: rgba(102, 187, 106, 0.5);
-}
-
-input[type=range]::-moz-range-track {
- width: 100%;
- height: 8px;
- cursor: pointer;
- animate: 0.2s;
- box-shadow: none;
- background: rgba(0, 150, 136, 0.5);
- background: rgba(102, 187, 106, 0.5);
- border-radius: 5px;
- border: none;
-}
-
-input[type=range]::-moz-range-thumb {
- box-shadow: none;
- border: none;
- height: 26px;
- width: 26px;
- border-radius: 50px;
- background: #009688;
- background: #66bb6a;
- cursor: pointer;
-}
-
-input[type=range]::-ms-track {
- width: 100%;
- height: 8.4px;
- cursor: pointer;
- animate: 0.2s;
- background: transparent;
- border-color: transparent;
- border-width: 16px 0;
- color: transparent;
-}
-
-input[type=range]::-ms-fill-lower {
- background: #2a6495;
- border: 0.2px solid #010101;
- border-radius: 2.6px;
- box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
-}
-
-input[type=range]::-ms-fill-upper {
- background: #3071a9;
- border: 0.2px solid #010101;
- border-radius: 2.6px;
- box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
-}
-
-input[type=range]::-ms-thumb {
- box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
- border: 1px solid #000000;
- height: 36px;
- width: 16px;
- border-radius: 3px;
- background: #ffffff;
- cursor: pointer;
-}
-
-input[type=range]:focus::-ms-fill-lower {
- background: #3071a9;
-}
-
-input[type=range]:focus::-ms-fill-upper {
- background: #367ebd;
-}
diff --git a/cmd/drone-server/static/styles/reset.css b/cmd/drone-server/static/styles/reset.css
deleted file mode 100644
index e3c6b7c3a..000000000
--- a/cmd/drone-server/static/styles/reset.css
+++ /dev/null
@@ -1,47 +0,0 @@
-* {
- box-sizing: border-box;
-}
-html, body, div, span, applet, object, iframe,
-h1, h2, h3, h4, h5, h6, p, blockquote, pre,
-a, abbr, acronym, address, big, cite, code,
-del, dfn, em, img, ins, kbd, q, s, samp,
-small, strike, strong, sub, sup, tt, var,
-b, u, i, center,
-dl, dt, dd, ol, ul, li,
-fieldset, form, label, legend,
-table, caption, tbody, tfoot, thead, tr, th, td,
-article, aside, canvas, details, embed,
-figure, figcaption, footer, header, hgroup,
-menu, nav, output, ruby, section, summary,
-time, mark, audio, video {
- margin: 0;
- padding: 0;
- border: 0;
- font-size: 100%;
- font: inherit;
- vertical-align: baseline;
-}
-
-article, aside, details, figcaption, figure,
-footer, header, hgroup, menu, nav, section {
- display: block;
-}
-body {
- line-height: 1;
-}
-ol, ul {
- list-style: none;
-}
-blockquote, q {
- quotes: none;
-}
-blockquote:before, blockquote:after,
-q:before, q:after {
- content: '';
- content: none;
-}
-table {
- border-collapse: collapse;
- border-spacing: 0;
-}
-textarea, input { outline: none; }
diff --git a/cmd/drone-server/static/styles/switch.css b/cmd/drone-server/static/styles/switch.css
deleted file mode 100644
index 9ac08d662..000000000
--- a/cmd/drone-server/static/styles/switch.css
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-http://codepen.io/batazor/pen/KwKryj
-*/
-
-.switch {
- display: inline-block;
- position: relative;
- width: 40px;
- height: 8px;
- border-radius: 10.416666666666668px;
- background: #E0E0E0;
- -webkit-transition: background 0.28s cubic-bezier(0.4, 0, 0.2, 1);
- transition: background 0.28s cubic-bezier(0.4, 0, 0.2, 1);
- vertical-align: middle;
- cursor: pointer;
-}
-
-.switch::before {
- content: '';
- position: absolute;
- top: -8.604166666666667px;
- left: -2.604166666666667px;
- width: 26.04166666666667px;
- height: 26.04166666666667px;
- background: #bdbdbd;
- border-radius: 50%;
- -webkit-transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1), background 0.28s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1);
- transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1), background 0.28s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1);
-}
-
-.switch:active::before {
- box-shadow: 0 2px 10.416666666666668px rgba(0, 0, 0, 0.28), 0 0 0 25px rgba(0, 0, 0, 0.1);
-}
-
-.switch:active::before {
- box-shadow: 0 2px 10.416666666666668px rgba(0, 0, 0, 0.28), 0 0 0 25px rgba(0, 0, 0, 0.1);
-}
-
-input:checked + .switch {
- background: rgba(0, 150, 136, 0.5);
- background: rgba(102, 187, 106, 0.5);
-}
-
-input:checked + .switch::before {
- left: 20.562499999999996px;
- background: #009688;
- background: #66bb6a;
-}
-
-input:checked + .switch:active::before {
- box-shadow: 0 2px 10.416666666666668px rgba(0, 0, 0, 0.28), 0 0 0 25px rgba(0, 150, 136, 0.2);
-}
diff --git a/pkg/server/badge.go b/controller/badge.go
similarity index 100%
rename from pkg/server/badge.go
rename to controller/badge.go
diff --git a/pkg/server/badge_test.go b/controller/badge_test.go
similarity index 100%
rename from pkg/server/badge_test.go
rename to controller/badge_test.go
diff --git a/pkg/server/commits.go b/controller/commits.go
similarity index 100%
rename from pkg/server/commits.go
rename to controller/commits.go
diff --git a/pkg/server/gitlab.go b/controller/gitlab.go
similarity index 100%
rename from pkg/server/gitlab.go
rename to controller/gitlab.go
diff --git a/pkg/server/hooks.go b/controller/hooks.go
similarity index 100%
rename from pkg/server/hooks.go
rename to controller/hooks.go
diff --git a/pkg/server/login.go b/controller/login.go
similarity index 100%
rename from pkg/server/login.go
rename to controller/login.go
diff --git a/pkg/server/queue.go b/controller/queue.go
similarity index 100%
rename from pkg/server/queue.go
rename to controller/queue.go
diff --git a/pkg/server/recorder/recorder.go b/controller/recorder/recorder.go
similarity index 100%
rename from pkg/server/recorder/recorder.go
rename to controller/recorder/recorder.go
diff --git a/pkg/server/repos.go b/controller/repos.go
similarity index 100%
rename from pkg/server/repos.go
rename to controller/repos.go
diff --git a/pkg/server/server.go b/controller/server.go
similarity index 100%
rename from pkg/server/server.go
rename to controller/server.go
diff --git a/pkg/server/user.go b/controller/user.go
similarity index 100%
rename from pkg/server/user.go
rename to controller/user.go
diff --git a/pkg/server/user_test.go b/controller/user_test.go
similarity index 100%
rename from pkg/server/user_test.go
rename to controller/user_test.go
diff --git a/pkg/server/users.go b/controller/users.go
similarity index 100%
rename from pkg/server/users.go
rename to controller/users.go
diff --git a/pkg/server/ws.go b/controller/ws.go
similarity index 100%
rename from pkg/server/ws.go
rename to controller/ws.go
diff --git a/pkg/bus/builtin/bus.go b/engine/bus.go
similarity index 100%
rename from pkg/bus/builtin/bus.go
rename to engine/bus.go
diff --git a/pkg/bus/builtin/bus_test.go b/engine/bus_test.go
similarity index 100%
rename from pkg/bus/builtin/bus_test.go
rename to engine/bus_test.go
diff --git a/pkg/queue/builtin/queue.go b/engine/queue.go
similarity index 100%
rename from pkg/queue/builtin/queue.go
rename to engine/queue.go
diff --git a/pkg/queue/builtin/queue_test.go b/engine/queue_test.go
similarity index 100%
rename from pkg/queue/builtin/queue_test.go
rename to engine/queue_test.go
diff --git a/pkg/runner/builtin/runner.go b/engine/runner.go
similarity index 100%
rename from pkg/runner/builtin/runner.go
rename to engine/runner.go
diff --git a/pkg/runner/builtin/updater.go b/engine/updater.go
similarity index 100%
rename from pkg/runner/builtin/updater.go
rename to engine/updater.go
diff --git a/pkg/runner/builtin/worker.go b/engine/worker.go
similarity index 100%
rename from pkg/runner/builtin/worker.go
rename to engine/worker.go
diff --git a/pkg/types/build.go b/model/build.go
similarity index 100%
rename from pkg/types/build.go
rename to model/build.go
diff --git a/pkg/types/config.go b/model/config.go
similarity index 100%
rename from pkg/types/config.go
rename to model/config.go
diff --git a/pkg/types/hook.go b/model/hook.go
similarity index 100%
rename from pkg/types/hook.go
rename to model/hook.go
diff --git a/pkg/types/job.go b/model/job.go
similarity index 100%
rename from pkg/types/job.go
rename to model/job.go
diff --git a/pkg/types/repo.go b/model/repo.go
similarity index 100%
rename from pkg/types/repo.go
rename to model/repo.go
diff --git a/pkg/types/status.go b/model/status.go
similarity index 100%
rename from pkg/types/status.go
rename to model/status.go
diff --git a/pkg/types/system.go b/model/system.go
similarity index 100%
rename from pkg/types/system.go
rename to model/system.go
diff --git a/pkg/types/user.go b/model/user.go
similarity index 100%
rename from pkg/types/user.go
rename to model/user.go
diff --git a/pkg/types/util.go b/model/util.go
similarity index 100%
rename from pkg/types/util.go
rename to model/util.go
diff --git a/pkg/types/util_test.go b/model/util_test.go
similarity index 100%
rename from pkg/types/util_test.go
rename to model/util_test.go
diff --git a/pkg/bus/bus.go b/pkg/bus/bus.go
deleted file mode 100644
index bed61b6f1..000000000
--- a/pkg/bus/bus.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package bus
-
-const (
- EventRepo = "repo"
- EventUser = "user"
- EventAgent = "agent"
-)
-
-type Event struct {
- Kind string
- Name string
- Msg []byte
-}
-
-type Bus interface {
- Subscribe(chan *Event)
- Unsubscribe(chan *Event)
- Send(*Event)
-}
diff --git a/pkg/oauth2/oauth2.go b/pkg/oauth2/oauth2.go
deleted file mode 100644
index 97059c499..000000000
--- a/pkg/oauth2/oauth2.go
+++ /dev/null
@@ -1,471 +0,0 @@
-// Copyright 2011 The goauth2 Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package oauth supports making OAuth2-authenticated HTTP requests.
-//
-// Example usage:
-//
-// // Specify your configuration. (typically as a global variable)
-// var config = &oauth.Config{
-// ClientId: YOUR_CLIENT_ID,
-// ClientSecret: YOUR_CLIENT_SECRET,
-// Scope: "https://www.googleapis.com/auth/buzz",
-// AuthURL: "https://accounts.google.com/o/oauth2/auth",
-// TokenURL: "https://accounts.google.com/o/oauth2/token",
-// RedirectURL: "http://you.example.org/handler",
-// }
-//
-// // A landing page redirects to the OAuth provider to get the auth code.
-// func landing(w http.ResponseWriter, r *http.Request) {
-// http.Redirect(w, r, config.AuthCodeURL("foo"), http.StatusFound)
-// }
-//
-// // The user will be redirected back to this handler, that takes the
-// // "code" query parameter and Exchanges it for an access token.
-// func handler(w http.ResponseWriter, r *http.Request) {
-// t := &oauth.Transport{Config: config}
-// t.Exchange(r.FormValue("code"))
-// // The Transport now has a valid Token. Create an *http.Client
-// // with which we can make authenticated API requests.
-// c := t.Client()
-// c.Post(...)
-// // ...
-// // btw, r.FormValue("state") == "foo"
-// }
-//
-package oauth2
-
-import (
- "encoding/json"
- "errors"
- "fmt"
- "io"
- "io/ioutil"
- "mime"
- "net/http"
- "net/url"
- "os"
- "strconv"
- "strings"
- "sync"
- "time"
-)
-
-// OAuthError is the error type returned by many operations.
-//
-// In retrospect it should not exist. Don't depend on it.
-type OAuthError struct {
- prefix string
- msg string
-}
-
-func (oe OAuthError) Error() string {
- return "OAuthError: " + oe.prefix + ": " + oe.msg
-}
-
-// Cache specifies the methods that implement a Token cache.
-type Cache interface {
- Token() (*Token, error)
- PutToken(*Token) error
-}
-
-// CacheFile implements Cache. Its value is the name of the file in which
-// the Token is stored in JSON format.
-type CacheFile string
-
-func (f CacheFile) Token() (*Token, error) {
- file, err := os.Open(string(f))
- if err != nil {
- return nil, OAuthError{"CacheFile.Token", err.Error()}
- }
- defer file.Close()
- tok := &Token{}
- if err := json.NewDecoder(file).Decode(tok); err != nil {
- return nil, OAuthError{"CacheFile.Token", err.Error()}
- }
- return tok, nil
-}
-
-func (f CacheFile) PutToken(tok *Token) error {
- file, err := os.OpenFile(string(f), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
- if err != nil {
- return OAuthError{"CacheFile.PutToken", err.Error()}
- }
- if err := json.NewEncoder(file).Encode(tok); err != nil {
- file.Close()
- return OAuthError{"CacheFile.PutToken", err.Error()}
- }
- if err := file.Close(); err != nil {
- return OAuthError{"CacheFile.PutToken", err.Error()}
- }
- return nil
-}
-
-// Config is the configuration of an OAuth consumer.
-type Config struct {
- // ClientId is the OAuth client identifier used when communicating with
- // the configured OAuth provider.
- ClientId string
-
- // ClientSecret is the OAuth client secret used when communicating with
- // the configured OAuth provider.
- ClientSecret string
-
- // Scope identifies the level of access being requested. Multiple scope
- // values should be provided as a space-delimited string.
- Scope string
-
- // AuthURL is the URL the user will be directed to in order to grant
- // access.
- AuthURL string
-
- // TokenURL is the URL used to retrieve OAuth tokens.
- TokenURL string
-
- // RedirectURL is the URL to which the user will be returned after
- // granting (or denying) access.
- RedirectURL string
-
- // TokenCache allows tokens to be cached for subsequent requests.
- TokenCache Cache
-
- // AccessType is an OAuth extension that gets sent as the
- // "access_type" field in the URL from AuthCodeURL.
- // See https://developers.google.com/accounts/docs/OAuth2WebServer.
- // It may be "online" (the default) or "offline".
- // If your application needs to refresh access tokens when the
- // user is not present at the browser, then use offline. This
- // will result in your application obtaining a refresh token
- // the first time your application exchanges an authorization
- // code for a user.
- AccessType string
-
- // ApprovalPrompt indicates whether the user should be
- // re-prompted for consent. If set to "auto" (default) the
- // user will be prompted only if they haven't previously
- // granted consent and the code can only be exchanged for an
- // access token.
- // If set to "force" the user will always be prompted, and the
- // code can be exchanged for a refresh token.
- ApprovalPrompt string
-}
-
-// Token contains an end-user's tokens.
-// This is the data you must store to persist authentication.
-type Token struct {
- AccessToken string
- RefreshToken string
- Expiry time.Time // If zero the token has no (known) expiry time.
-
- // Extra optionally contains extra metadata from the server
- // when updating a token. The only current key that may be
- // populated is "id_token". It may be nil and will be
- // initialized as needed.
- Extra map[string]string
-}
-
-// Expired reports whether the token has expired or is invalid.
-func (t *Token) Expired() bool {
- if t.AccessToken == "" {
- return true
- }
- if t.Expiry.IsZero() {
- return false
- }
- return t.Expiry.Before(time.Now())
-}
-
-// Transport implements http.RoundTripper. When configured with a valid
-// Config and Token it can be used to make authenticated HTTP requests.
-//
-// t := &oauth.Transport{config}
-// t.Exchange(code)
-// // t now contains a valid Token
-// r, _, err := t.Client().Get("http://example.org/url/requiring/auth")
-//
-// It will automatically refresh the Token if it can,
-// updating the supplied Token in place.
-type Transport struct {
- *Config
- *Token
-
- // mu guards modifying the token.
- mu sync.Mutex
-
- // Transport is the HTTP transport to use when making requests.
- // It will default to http.DefaultTransport if nil.
- // (It should never be an oauth.Transport.)
- Transport http.RoundTripper
-}
-
-// Client returns an *http.Client that makes OAuth-authenticated requests.
-func (t *Transport) Client() *http.Client {
- return &http.Client{Transport: t}
-}
-
-func (t *Transport) transport() http.RoundTripper {
- if t.Transport != nil {
- return t.Transport
- }
- return http.DefaultTransport
-}
-
-// AuthCodeURL returns a URL that the end-user should be redirected to,
-// so that they may obtain an authorization code.
-func (c *Config) AuthCodeURL(state string) string {
- url_, err := url.Parse(c.AuthURL)
- if err != nil {
- panic("AuthURL malformed: " + err.Error())
- }
- q := url.Values{
- "response_type": {"code"},
- "client_id": {c.ClientId},
- "state": condVal(state),
- "scope": condVal(c.Scope),
- "redirect_uri": condVal(c.RedirectURL),
- "access_type": condVal(c.AccessType),
- "approval_prompt": condVal(c.ApprovalPrompt),
- }.Encode()
- if url_.RawQuery == "" {
- url_.RawQuery = q
- } else {
- url_.RawQuery += "&" + q
- }
- return url_.String()
-}
-
-func condVal(v string) []string {
- if v == "" {
- return nil
- }
- return []string{v}
-}
-
-// Exchange takes a code and gets access Token from the remote server.
-func (t *Transport) Exchange(code string) (*Token, error) {
- if t.Config == nil {
- return nil, OAuthError{"Exchange", "no Config supplied"}
- }
-
- // If the transport or the cache already has a token, it is
- // passed to `updateToken` to preserve existing refresh token.
- tok := t.Token
- if tok == nil && t.TokenCache != nil {
- tok, _ = t.TokenCache.Token()
- }
- if tok == nil {
- tok = new(Token)
- }
- err := t.updateToken(tok, url.Values{
- "grant_type": {"authorization_code"},
- "redirect_uri": {t.RedirectURL},
- "scope": {t.Scope},
- "code": {code},
- })
- if err != nil {
- return nil, err
- }
- t.Token = tok
- if t.TokenCache != nil {
- return tok, t.TokenCache.PutToken(tok)
- }
- return tok, nil
-}
-
-// RoundTrip executes a single HTTP transaction using the Transport's
-// Token as authorization headers.
-//
-// This method will attempt to renew the Token if it has expired and may return
-// an error related to that Token renewal before attempting the client request.
-// If the Token cannot be renewed a non-nil os.Error value will be returned.
-// If the Token is invalid callers should expect HTTP-level errors,
-// as indicated by the Response's StatusCode.
-func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
- accessToken, err := t.getAccessToken()
- if err != nil {
- return nil, err
- }
- // To set the Authorization header, we must make a copy of the Request
- // so that we don't modify the Request we were given.
- // This is required by the specification of http.RoundTripper.
- req = cloneRequest(req)
- req.Header.Set("Authorization", "Bearer "+accessToken)
-
- // Make the HTTP request.
- return t.transport().RoundTrip(req)
-}
-
-func (t *Transport) getAccessToken() (string, error) {
- t.mu.Lock()
- defer t.mu.Unlock()
-
- if t.Token == nil {
- if t.Config == nil {
- return "", OAuthError{"RoundTrip", "no Config supplied"}
- }
- if t.TokenCache == nil {
- return "", OAuthError{"RoundTrip", "no Token supplied"}
- }
- var err error
- t.Token, err = t.TokenCache.Token()
- if err != nil {
- return "", err
- }
- }
-
- // Refresh the Token if it has expired.
- if t.Expired() {
- if err := t.Refresh(); err != nil {
- return "", err
- }
- }
- if t.AccessToken == "" {
- return "", errors.New("no access token obtained from refresh")
- }
- return t.AccessToken, nil
-}
-
-// cloneRequest returns a clone of the provided *http.Request.
-// The clone is a shallow copy of the struct and its Header map.
-func cloneRequest(r *http.Request) *http.Request {
- // shallow copy of the struct
- r2 := new(http.Request)
- *r2 = *r
- // deep copy of the Header
- r2.Header = make(http.Header)
- for k, s := range r.Header {
- r2.Header[k] = s
- }
- return r2
-}
-
-// Refresh renews the Transport's AccessToken using its RefreshToken.
-func (t *Transport) Refresh() error {
- if t.Token == nil {
- return OAuthError{"Refresh", "no existing Token"}
- }
- if t.RefreshToken == "" {
- return OAuthError{"Refresh", "Token expired; no Refresh Token"}
- }
- if t.Config == nil {
- return OAuthError{"Refresh", "no Config supplied"}
- }
-
- err := t.updateToken(t.Token, url.Values{
- "grant_type": {"refresh_token"},
- "refresh_token": {t.RefreshToken},
- })
- if err != nil {
- return err
- }
- if t.TokenCache != nil {
- return t.TokenCache.PutToken(t.Token)
- }
- return nil
-}
-
-// AuthenticateClient gets an access Token using the client_credentials grant
-// type.
-func (t *Transport) AuthenticateClient() error {
- if t.Config == nil {
- return OAuthError{"Exchange", "no Config supplied"}
- }
- if t.Token == nil {
- t.Token = &Token{}
- }
- return t.updateToken(t.Token, url.Values{"grant_type": {"client_credentials"}})
-}
-
-// providerAuthHeaderWorks reports whether the OAuth2 server identified by the tokenURL
-// implements the OAuth2 spec correctly
-// See https://code.google.com/p/goauth2/issues/detail?id=31 for background.
-// In summary:
-// - Reddit only accepts client secret in the Authorization header
-// - Dropbox accepts either it in URL param or Auth header, but not both.
-// - Google only accepts URL param (not spec compliant?), not Auth header
-func providerAuthHeaderWorks(tokenURL string) bool {
- if strings.HasPrefix(tokenURL, "https://accounts.google.com/") ||
- strings.HasPrefix(tokenURL, "https://github.com/") ||
- strings.HasPrefix(tokenURL, "https://api.instagram.com/") ||
- strings.HasPrefix(tokenURL, "https://www.douban.com/") {
- // Some sites fail to implement the OAuth2 spec fully.
- return false
- }
-
- // Assume the provider implements the spec properly
- // otherwise. We can add more exceptions as they're
- // discovered. We will _not_ be adding configurable hooks
- // to this package to let users select server bugs.
- return true
-}
-
-// updateToken mutates both tok and v.
-func (t *Transport) updateToken(tok *Token, v url.Values) error {
- v.Set("client_id", t.ClientId)
- v.Set("client_secret", t.ClientSecret)
- client := &http.Client{Transport: t.transport()}
- req, err := http.NewRequest("POST", t.TokenURL, strings.NewReader(v.Encode()))
- if err != nil {
- return err
- }
- req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
- req.SetBasicAuth(t.ClientId, t.ClientSecret)
- r, err := client.Do(req)
- if err != nil {
- return err
- }
- defer r.Body.Close()
- if r.StatusCode != 200 {
- return OAuthError{"updateToken", "Unexpected HTTP status " + r.Status}
- }
- var b struct {
- Access string `json:"access_token"`
- Refresh string `json:"refresh_token"`
- ExpiresIn int64 `json:"expires_in"` // seconds
- Id string `json:"id_token"`
- }
-
- body, err := ioutil.ReadAll(io.LimitReader(r.Body, 1<<20))
- if err != nil {
- return err
- }
-
- content, _, _ := mime.ParseMediaType(r.Header.Get("Content-Type"))
- switch content {
- case "application/x-www-form-urlencoded", "text/plain":
- vals, err := url.ParseQuery(string(body))
- if err != nil {
- return err
- }
-
- b.Access = vals.Get("access_token")
- b.Refresh = vals.Get("refresh_token")
- b.ExpiresIn, _ = strconv.ParseInt(vals.Get("expires_in"), 10, 64)
- b.Id = vals.Get("id_token")
- default:
- if err = json.Unmarshal(body, &b); err != nil {
- return fmt.Errorf("got bad response from server: %q", body)
- }
- }
- if b.Access == "" {
- return errors.New("received empty access token from authorization server")
- }
- tok.AccessToken = b.Access
- // Don't overwrite `RefreshToken` with an empty value
- if b.Refresh != "" {
- tok.RefreshToken = b.Refresh
- }
- if b.ExpiresIn == 0 {
- tok.Expiry = time.Time{}
- } else {
- tok.Expiry = time.Now().Add(time.Duration(b.ExpiresIn) * time.Second)
- }
- if b.Id != "" {
- if tok.Extra == nil {
- tok.Extra = make(map[string]string)
- }
- tok.Extra["id_token"] = b.Id
- }
- return nil
-}
diff --git a/pkg/queue/plugin/client.go b/pkg/queue/plugin/client.go
deleted file mode 100644
index 57728029b..000000000
--- a/pkg/queue/plugin/client.go
+++ /dev/null
@@ -1,122 +0,0 @@
-package plugin
-
-import (
- "bytes"
- "encoding/json"
- "io"
- "net/http"
- "net/url"
-
- "github.com/drone/drone/pkg/queue"
-)
-
-type Client struct {
- url string
- token string
-}
-
-func New(url, token string) *Client {
- return &Client{url, token}
-}
-
-// Publish makes an http request to the remote queue
-// to insert work at the tail.
-func (c *Client) Publish(work *queue.Work) error {
- return c.send("POST", "/queue", work, nil)
-}
-
-// Remove makes an http request to the remote queue to
-// remove the specified work item.
-func (c *Client) Remove(work *queue.Work) error {
- return c.send("DELETE", "/queue", work, nil)
-}
-
-// Pull makes an http request to the remote queue to
-// retrieve work. This initiates a long poll and will
-// block until complete.
-func (c *Client) Pull() *queue.Work {
- out := &queue.Work{}
- err := c.send("POST", "/queue/pull", nil, out)
- if err != nil {
- // TODO handle error
- }
- return out
-}
-
-// Pull makes an http request to the remote queue to
-// retrieve work. This initiates a long poll and will
-// block until complete.
-func (c *Client) PullClose(cn queue.CloseNotifier) *queue.Work {
- out := &queue.Work{}
- err := c.send("POST", "/queue/pull", nil, out)
- if err != nil {
- // TODO handle error
- }
- return out
-}
-
-// Ack makes an http request to the remote queue
-// to acknowledge an item in the queue was processed.
-func (c *Client) Ack(work *queue.Work) error {
- return c.send("POST", "/queue/ack", nil, nil)
-}
-
-// Items makes an http request to the remote queue
-// to fetch a list of all work.
-func (c *Client) Items() []*queue.Work {
- out := []*queue.Work{}
- err := c.send("GET", "/queue/items", nil, &out)
- if err != nil {
- // TODO handle error
- }
- return out
-}
-
-// send is a helper function that makes an authenticated
-// request to the remote http plugin.
-func (c *Client) send(method, path string, in interface{}, out interface{}) error {
- url_, err := url.Parse(c.url + path)
- if err != nil {
- return err
- }
-
- var buf io.ReadWriter
- if in != nil {
- buf = new(bytes.Buffer)
- err := json.NewEncoder(buf).Encode(in)
- if err != nil {
- return err
- }
- }
-
- req, err := http.NewRequest(method, url_.String(), buf)
- if err != nil {
- return err
- }
- req.Header.Add("Authorization", "Bearer "+c.token)
- req.Header.Add("Content-Type", "application/json")
- resp, err := http.DefaultClient.Do(req)
- if err != nil {
- return err
- }
- defer resp.Body.Close()
- if out == nil {
- return nil
- }
- return json.NewDecoder(resp.Body).Decode(out)
-}
-
-// In order to implement PullClose() we'll need to use a custom transport:
-//
-// tr := &http.Transport{}
-// client := &http.Client{Transport: tr}
-// c := make(chan error, 1)
-// go func() { c <- f(client.Do(req)) }()
-// select {
-// case <-ctx.Done():
-// tr.CancelRequest(req)
-// <-c // Wait for f to return.
-// return ctx.Err()
-// case err := <-c:
-// return err
-// }
diff --git a/pkg/queue/plugin/server.go b/pkg/queue/plugin/server.go
deleted file mode 100644
index 8b3ae9d64..000000000
--- a/pkg/queue/plugin/server.go
+++ /dev/null
@@ -1,111 +0,0 @@
-package plugin
-
-import (
- "net/http"
-
- "github.com/drone/drone/Godeps/_workspace/src/github.com/gin-gonic/gin"
- "github.com/drone/drone/pkg/queue"
-)
-
-// Handle returns an http.Handler that enables a remote
-// client to interop with a Queue over http.
-func Handle(queue queue.Queue, token string) http.Handler {
- r := gin.New()
-
- // middleware to validate the authorization token
- // and to inject the queue into the http context.
- bearer := "Bearer " + token
- r.Use(func(c *gin.Context) {
- if c.Request.Header.Get("Authorization") != bearer {
- c.AbortWithStatus(403)
- return
- }
- c.Set("queue", queue)
- c.Next()
- })
-
- r.POST("/queue", publish)
- r.DELETE("/queue", remove)
- r.POST("/queue/pull", pull)
- r.POST("/queue/ack", ack)
- r.POST("/queue/items", items)
-
- return r
-}
-
-// publish handles an http request to the queue
-// to insert work at the tail.
-func publish(c *gin.Context) {
- q := fromContext(c)
- work := &queue.Work{}
- if !c.Bind(work) {
- c.AbortWithStatus(400)
- return
- }
- err := q.Publish(work)
- if err != nil {
- c.Fail(500, err)
- return
- }
- c.Writer.WriteHeader(200)
-}
-
-// remove handles an http request to the queue
-// to remove a work item.
-func remove(c *gin.Context) {
- q := fromContext(c)
- work := &queue.Work{}
- if !c.Bind(work) {
- c.AbortWithStatus(400)
- return
- }
- err := q.Remove(work)
- if err != nil {
- c.Fail(500, err)
- return
- }
- c.Writer.WriteHeader(200)
-}
-
-// pull handles an http request to the queue
-// to retrieve work.
-func pull(c *gin.Context) {
- q := fromContext(c)
- work := q.PullClose(c.Writer)
- if work == nil {
- c.AbortWithStatus(500)
- return
- }
- c.JSON(200, work)
-}
-
-// ack handles an http request to the queue
-// to confirm an item was successfully pulled.
-func ack(c *gin.Context) {
- q := fromContext(c)
- work := &queue.Work{}
- if !c.Bind(work) {
- c.AbortWithStatus(400)
- return
- }
- err := q.Ack(work)
- if err != nil {
- c.Fail(500, err)
- return
- }
- c.Writer.WriteHeader(200)
-}
-
-// items handles an http request to the queue to
-// return a list of all work items.
-func items(c *gin.Context) {
- q := fromContext(c)
- items := q.Items()
- c.JSON(200, items)
-}
-
-// helper function to retrieve the Queue from
-// the context and cast appropriately.
-func fromContext(c *gin.Context) queue.Queue {
- return c.MustGet("queue").(queue.Queue)
-}
diff --git a/pkg/queue/queue.go b/pkg/queue/queue.go
deleted file mode 100644
index 400f28e61..000000000
--- a/pkg/queue/queue.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package queue
-
-type Queue interface {
- // Publish inserts work at the tail of this queue, waiting for
- // space to become available if the queue is full.
- Publish(*Work) error
-
- // Remove removes the specified work item from this queue,
- // if it is present.
- Remove(*Work) error
-
- // Pull retrieves and removes the head of this queue, waiting
- // if necessary until work becomes available.
- Pull() *Work
-
- // PullClose retrieves and removes the head of this queue,
- // waiting if necessary until work becomes available. The
- // CloseNotifier should be provided to clone the channel
- // if the subscribing client terminates its connection.
- PullClose(CloseNotifier) *Work
-
- // Ack acknowledges an item in the queue was processed.
- Ack(*Work) error
-
- // Items returns a slice containing all of the work in this
- // queue, in proper sequence.
- Items() []*Work
-}
-
-type CloseNotifier interface {
- // CloseNotify returns a channel that receives a single value
- // when the client connection has gone away.
- CloseNotify() <-chan bool
-}
diff --git a/pkg/queue/worker.go b/pkg/queue/worker.go
deleted file mode 100644
index 8151b55a3..000000000
--- a/pkg/queue/worker.go
+++ /dev/null
@@ -1,76 +0,0 @@
-package queue
-
-import (
- "io"
-
- common "github.com/drone/drone/pkg/types"
-)
-
-// Work represents an item for work to be
-// processed by a worker.
-type Work struct {
- System *common.System `json:"system"`
- User *common.User `json:"user"`
- Repo *common.Repo `json:"repo"`
- Build *common.Build `json:"build"`
- BuildPrev *common.Build `json:"build_last"`
- Keys *common.Keypair `json:"keypair"`
- Netrc *common.Netrc `json:"netrc"`
- Config []byte `json:"config"`
- Secret []byte `json:"secret"`
-}
-
-// represents a worker that has connected
-// to the system in order to perform work
-type Worker struct {
- Name string
- Addr string
- IsHealthy bool
-}
-
-// Ping pings to worker to verify it is
-// available and in good health.
-func (w *Worker) Ping() (bool, error) {
- return false, nil
-}
-
-// Logs fetches the logs for a work item.
-func (w *Worker) Logs() (io.Reader, error) {
- return nil, nil
-}
-
-// Cancel cancels a work item.
-func (w *Worker) Cancel() error {
- return nil
-}
-
-// type Monitor struct {
-// manager *Manager
-// }
-
-// func NewMonitor(manager *Manager) *Monitor {
-// return &Monitor{manager}
-// }
-
-// // start is a helper function that is used to monitor
-// // all registered workers and ensure they are in a
-// // healthy state.
-// func (m *Monitor) Start() {
-// ticker := time.NewTicker(1 * time.Hour)
-// go func() {
-// for {
-// select {
-// case <-ticker.C:
-// workers := m.manager.Workers()
-// for _, worker := range workers {
-// // ping the worker to make sure it is
-// // available and still accepting builds.
-// if _, err := worker.Ping(); err != nil {
-// m.manager.SetHealth(worker, false)
-// } else {
-// m.manager.SetHealth(worker, true)
-// }
-// }
-// }
-// }
-// }
diff --git a/pkg/remote/client/client.go b/pkg/remote/client/client.go
deleted file mode 100644
index 6d3c18ab6..000000000
--- a/pkg/remote/client/client.go
+++ /dev/null
@@ -1,74 +0,0 @@
-package client
-
-// import (
-// "net"
-// "net/http"
-// "net/rpc"
-
-// common "github.com/drone/drone/pkg/types"
-// )
-
-// // Client communicates with a Remote plugin using the
-// // net/rpc protocol.
-// type Client struct {
-// *rpc.Client
-// }
-
-// // New returns a new, remote datastore backend that connects
-// // via tcp and exchanges data using Go's RPC mechanism.
-// func New(conf *config.Config) (*Client, error) {
-// // conn, err := net.Dial("tcp", conf.Server.Addr)
-// // if err != nil {
-// // return nil, err
-// // }
-// // client := &Client{
-// // rpc.NewClient(conn),
-// // }
-// // return client, nil
-// return nil, nil
-// }
-
-// func (c *Client) Login(token, secret string) (*common.User, error) {
-// return nil, nil
-// }
-
-// // Repo fetches the named repository from the remote system.
-// func (c *Client) Repo(u *common.User, owner, repo string) (*common.Repo, error) {
-// return nil, nil
-// }
-
-// func (c *Client) Perm(u *common.User, owner, repo string) (*common.Perm, error) {
-// return nil, nil
-// }
-
-// func (c *Client) Script(u *common.User, r *common.Repo, b *common.Build) ([]byte, error) {
-// return nil, nil
-// }
-
-// func (c *Client) Status(u *common.User, r *common.Repo, b *common.Build, link string) error {
-// return nil
-// }
-
-// func (c *Client) Activate(u *common.User, r *common.Repo, k *common.Keypair, link string) error {
-// return nil
-// }
-
-// func (c *Client) Deactivate(u *common.User, r *common.Repo, link string) error {
-// return nil
-// }
-
-// func (c *Client) Hook(r *http.Request) (*common.Hook, error) {
-// hook := new(common.Hook)
-// header := make(http.Header)
-// copyHeader(r.Header, header)
-
-// return hook, nil
-// }
-
-// func copyHeader(dst, src http.Header) {
-// for k, vv := range src {
-// for _, v := range vv {
-// dst.Add(k, v)
-// }
-// }
-// }
diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go
deleted file mode 100644
index 99683848c..000000000
--- a/pkg/runner/runner.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package runner
-
-import (
- "io"
-
- "github.com/drone/drone/pkg/queue"
- "github.com/drone/drone/pkg/types"
-)
-
-type Runner interface {
- Run(work *queue.Work) error
- Cancel(*types.Job) error
- Logs(*types.Job) (io.ReadCloser, error)
-}
-
-// Updater defines a set of functions that are required for
-// the runner to sent Drone updates during a build.
-type Updater interface {
- SetBuild(*types.User, *types.Repo, *types.Build) error
- SetJob(*types.Repo, *types.Build, *types.Job) error
- SetLogs(*types.Repo, *types.Build, *types.Job, io.ReadCloser) error
-}
diff --git a/pkg/store/builtin/agent.go b/pkg/store/builtin/agent.go
deleted file mode 100644
index 323e6d49e..000000000
--- a/pkg/store/builtin/agent.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package builtin
-
-import (
- "database/sql"
-
- "github.com/drone/drone/pkg/types"
-)
-
-type Agentstore struct {
- *sql.DB
-}
-
-func NewAgentstore(db *sql.DB) *Agentstore {
- return &Agentstore{db}
-}
-
-// Agent returns an agent by ID.
-func (db *Agentstore) Agent(build *types.Build) (string, error) {
- agent, err := getAgent(db, rebind(stmtAgentSelectAgentCommit), build.ID)
- if err != nil {
- return "", err
- }
- return agent.Addr, nil
-}
-
-// SetAgent updates an agent in the datastore.
-func (db *Agentstore) SetAgent(build *types.Build, addr string) error {
- agent := Agent{Addr: addr, BuildID: build.ID}
- return createAgent(db, rebind(stmtAgentInsert), &agent)
-}
-
-type Agent struct {
- ID int64
- Addr string
- BuildID int64 `sql:"unique:ux_agent_build"`
-}
diff --git a/pkg/store/builtin/agent_sql.go b/pkg/store/builtin/agent_sql.go
deleted file mode 100644
index 3280d0843..000000000
--- a/pkg/store/builtin/agent_sql.go
+++ /dev/null
@@ -1,184 +0,0 @@
-package builtin
-
-// DO NOT EDIT
-// code generated by go:generate
-
-import (
- "database/sql"
- "encoding/json"
-)
-
-var _ = json.Marshal
-
-// generic database interface, matching both *sql.Db and *sql.Tx
-type agentDB interface {
- Exec(query string, args ...interface{}) (sql.Result, error)
- Query(query string, args ...interface{}) (*sql.Rows, error)
- QueryRow(query string, args ...interface{}) *sql.Row
-}
-
-func getAgent(db agentDB, query string, args ...interface{}) (*Agent, error) {
- row := db.QueryRow(query, args...)
- return scanAgent(row)
-}
-
-func getAgents(db agentDB, query string, args ...interface{}) ([]*Agent, error) {
- rows, err := db.Query(query, args...)
- if err != nil {
- return nil, err
- }
- defer rows.Close()
- return scanAgents(rows)
-}
-
-func createAgent(db agentDB, query string, v *Agent) error {
- var v0 string
- var v1 int64
- v0 = v.Addr
- v1 = v.BuildID
-
- res, err := db.Exec(query,
- &v0,
- &v1,
- )
- if err != nil {
- return err
- }
-
- v.ID, err = res.LastInsertId()
- return err
-}
-
-func updateAgent(db agentDB, query string, v *Agent) error {
- var v0 int64
- var v1 string
- var v2 int64
- v0 = v.ID
- v1 = v.Addr
- v2 = v.BuildID
-
- _, err := db.Exec(query,
- &v1,
- &v2,
- &v0,
- )
- return err
-}
-
-func scanAgent(row *sql.Row) (*Agent, error) {
- var v0 int64
- var v1 string
- var v2 int64
-
- err := row.Scan(
- &v0,
- &v1,
- &v2,
- )
- if err != nil {
- return nil, err
- }
-
- v := &Agent{}
- v.ID = v0
- v.Addr = v1
- v.BuildID = v2
-
- return v, nil
-}
-
-func scanAgents(rows *sql.Rows) ([]*Agent, error) {
- var err error
- var vv []*Agent
- for rows.Next() {
- var v0 int64
- var v1 string
- var v2 int64
- err = rows.Scan(
- &v0,
- &v1,
- &v2,
- )
- if err != nil {
- return vv, err
- }
-
- v := &Agent{}
- v.ID = v0
- v.Addr = v1
- v.BuildID = v2
- vv = append(vv, v)
- }
- return vv, rows.Err()
-}
-
-const stmtAgentSelectList = `
-SELECT
- agent_id
-,agent_addr
-,agent_build_id
-FROM agents
-`
-
-const stmtAgentSelectRange = `
-SELECT
- agent_id
-,agent_addr
-,agent_commit_id
-FROM agents
-LIMIT ? OFFSET ?
-`
-
-const stmtAgentSelect = `
-SELECT
- agent_id
-,agent_addr
-,agent_commit_id
-FROM agents
-WHERE agent_id = ?
-`
-
-const stmtAgentSelectAgentCommit = `
-SELECT
- agent_id
-,agent_addr
-,agent_commit_id
-FROM agents
-WHERE agent_commit_id = ?
-`
-
-const stmtAgentSelectCount = `
-SELECT count(1)
-FROM agents
-`
-
-const stmtAgentInsert = `
-INSERT INTO agents (
- agent_addr
-,agent_commit_id
-) VALUES (?,?);
-`
-
-const stmtAgentUpdate = `
-UPDATE agents SET
- agent_addr = ?
-,agent_commit_id = ?
-WHERE agent_id = ?
-`
-
-const stmtAgentDelete = `
-DELETE FROM agents
-WHERE agent_id = ?
-`
-
-const stmtAgentTable = `
-CREATE TABLE IF NOT EXISTS agents (
- agent_id INTEGER PRIMARY KEY AUTOINCREMENT
-,agent_addr VARCHAR
-,agent_commit_idINTEGER
-);
-`
-
-const stmtAgentAgentCommitIndex = `
-CREATE UNIQUE INDEX IF NOT EXISTS ux_agent_commit ON agents (agent_commit_id);
-`
diff --git a/pkg/store/builtin/blob.go b/pkg/store/builtin/blob.go
deleted file mode 100644
index 102a267a0..000000000
--- a/pkg/store/builtin/blob.go
+++ /dev/null
@@ -1,85 +0,0 @@
-package builtin
-
-import (
- "bytes"
- "database/sql"
- "io"
- "io/ioutil"
-)
-
-type Blob struct {
- ID int64
- Path string `sql:"unique:ux_blob_path"`
- Data []byte
-}
-
-type Blobstore struct {
- *sql.DB
-}
-
-// Del removes an object from the blobstore.
-func (db *Blobstore) DelBlob(path string) error {
- blob, _ := getBlob(db, rebind(stmtBlobSelectBlobPath), path)
- if blob == nil {
- return nil
- }
- _, err := db.Exec(rebind(stmtBlobDelete), blob.ID)
- return err
-}
-
-// Get retrieves an object from the blobstore.
-func (db *Blobstore) GetBlob(path string) ([]byte, error) {
- blob, err := getBlob(db, rebind(stmtBlobSelectBlobPath), path)
- if err != nil {
- return nil, nil
- }
- return blob.Data, nil
-}
-
-// GetBlobReader retrieves an object from the blobstore.
-// It is the caller's responsibility to call Close on
-// the ReadCloser when finished reading.
-func (db *Blobstore) GetBlobReader(path string) (io.ReadCloser, error) {
- var blob, err = db.GetBlob(path)
- var buf = bytes.NewBuffer(blob)
- return ioutil.NopCloser(buf), err
-}
-
-// SetBlob inserts an object into the blobstore.
-func (db *Blobstore) SetBlob(path string, data []byte) error {
- blob, _ := getBlob(db, rebind(stmtBlobSelectBlobPath), path)
- if blob == nil {
- blob = &Blob{}
- }
- blob.Path = path
- blob.Data = data
- if blob.ID == 0 {
- return createBlob(db, rebind(stmtBlobInsert), blob)
- }
- return updateBlob(db, rebind(stmtBlobUpdate), blob)
-}
-
-// SetBlobReader inserts an object into the blobstore by
-// consuming data from r until EOF.
-func (db *Blobstore) SetBlobReader(path string, r io.Reader) error {
- var data, _ = ioutil.ReadAll(r)
- return db.SetBlob(path, data)
-}
-
-func NewBlobstore(db *sql.DB) *Blobstore {
- return &Blobstore{db}
-}
-
-// Blob table name in database.
-const blobTable = "blobs"
-
-const blobQuery = `
-SELECT *
-FROM blobs
-WHERE blob_path = ?;
-`
-
-const blobDeleteStmt = `
-DELETE FROM blobs
-WHERE blob_path = ?;
-`
diff --git a/pkg/store/builtin/blob_sql.go b/pkg/store/builtin/blob_sql.go
deleted file mode 100644
index 8de131f6f..000000000
--- a/pkg/store/builtin/blob_sql.go
+++ /dev/null
@@ -1,184 +0,0 @@
-package builtin
-
-// DO NOT EDIT
-// code generated by go:generate
-
-import (
- "database/sql"
- "encoding/json"
-)
-
-var _ = json.Marshal
-
-// generic database interface, matching both *sql.Db and *sql.Tx
-type blobDB interface {
- Exec(query string, args ...interface{}) (sql.Result, error)
- Query(query string, args ...interface{}) (*sql.Rows, error)
- QueryRow(query string, args ...interface{}) *sql.Row
-}
-
-func getBlob(db blobDB, query string, args ...interface{}) (*Blob, error) {
- row := db.QueryRow(query, args...)
- return scanBlob(row)
-}
-
-func getBlobs(db blobDB, query string, args ...interface{}) ([]*Blob, error) {
- rows, err := db.Query(query, args...)
- if err != nil {
- return nil, err
- }
- defer rows.Close()
- return scanBlobs(rows)
-}
-
-func createBlob(db blobDB, query string, v *Blob) error {
- var v0 string
- var v1 []byte
- v0 = v.Path
- v1 = v.Data
-
- res, err := db.Exec(query,
- &v0,
- &v1,
- )
- if err != nil {
- return err
- }
-
- v.ID, err = res.LastInsertId()
- return err
-}
-
-func updateBlob(db blobDB, query string, v *Blob) error {
- var v0 int64
- var v1 string
- var v2 []byte
- v0 = v.ID
- v1 = v.Path
- v2 = v.Data
-
- _, err := db.Exec(query,
- &v1,
- &v2,
- &v0,
- )
- return err
-}
-
-func scanBlob(row *sql.Row) (*Blob, error) {
- var v0 int64
- var v1 string
- var v2 []byte
-
- err := row.Scan(
- &v0,
- &v1,
- &v2,
- )
- if err != nil {
- return nil, err
- }
-
- v := &Blob{}
- v.ID = v0
- v.Path = v1
- v.Data = v2
-
- return v, nil
-}
-
-func scanBlobs(rows *sql.Rows) ([]*Blob, error) {
- var err error
- var vv []*Blob
- for rows.Next() {
- var v0 int64
- var v1 string
- var v2 []byte
- err = rows.Scan(
- &v0,
- &v1,
- &v2,
- )
- if err != nil {
- return vv, err
- }
-
- v := &Blob{}
- v.ID = v0
- v.Path = v1
- v.Data = v2
- vv = append(vv, v)
- }
- return vv, rows.Err()
-}
-
-const stmtBlobSelectList = `
-SELECT
- blob_id
-,blob_path
-,blob_data
-FROM blobs
-`
-
-const stmtBlobSelectRange = `
-SELECT
- blob_id
-,blob_path
-,blob_data
-FROM blobs
-LIMIT ? OFFSET ?
-`
-
-const stmtBlobSelect = `
-SELECT
- blob_id
-,blob_path
-,blob_data
-FROM blobs
-WHERE blob_id = ?
-`
-
-const stmtBlobSelectBlobPath = `
-SELECT
- blob_id
-,blob_path
-,blob_data
-FROM blobs
-WHERE blob_path = ?
-`
-
-const stmtBlobSelectCount = `
-SELECT count(1)
-FROM blobs
-`
-
-const stmtBlobInsert = `
-INSERT INTO blobs (
- blob_path
-,blob_data
-) VALUES (?,?);
-`
-
-const stmtBlobUpdate = `
-UPDATE blobs SET
- blob_path = ?
-,blob_data = ?
-WHERE blob_id = ?
-`
-
-const stmtBlobDelete = `
-DELETE FROM blobs
-WHERE blob_id = ?
-`
-
-const stmtBlobTable = `
-CREATE TABLE IF NOT EXISTS blobs (
- blob_id INTEGER PRIMARY KEY AUTOINCREMENT
-,blob_path VARCHAR
-,blob_data BLOB
-);
-`
-
-const stmtBlobBlobPathIndex = `
-CREATE UNIQUE INDEX IF NOT EXISTS ux_blob_path ON blobs (blob_path);
-`
diff --git a/pkg/store/builtin/blob_test.go b/pkg/store/builtin/blob_test.go
deleted file mode 100644
index f0a303f9e..000000000
--- a/pkg/store/builtin/blob_test.go
+++ /dev/null
@@ -1,66 +0,0 @@
-package builtin
-
-import (
- "bytes"
- "io/ioutil"
- "testing"
-
- "github.com/drone/drone/Godeps/_workspace/src/github.com/franela/goblin"
-)
-
-func TestBlobstore(t *testing.T) {
- db := mustConnectTest()
- bs := NewBlobstore(db)
- defer db.Close()
-
- g := goblin.Goblin(t)
- g.Describe("Blobstore", func() {
-
- // before each test be sure to purge the package
- // table data from the database.
- g.BeforeEach(func() {
- db.Exec("DELETE FROM blobs")
- })
-
- g.It("Should Set a Blob", func() {
- err := bs.SetBlob("foo", []byte("bar"))
- g.Assert(err == nil).IsTrue()
- })
-
- g.It("Should Set a Blob reader", func() {
- var buf bytes.Buffer
- buf.Write([]byte("bar"))
- err := bs.SetBlobReader("foo", &buf)
- g.Assert(err == nil).IsTrue()
- })
-
- g.It("Should Overwrite a Blob", func() {
- bs.SetBlob("foo", []byte("bar"))
- bs.SetBlob("foo", []byte("baz"))
- blob, err := bs.GetBlob("foo")
- g.Assert(err == nil).IsTrue()
- g.Assert(string(blob)).Equal("baz")
- })
-
- g.It("Should Get a Blob", func() {
- bs.SetBlob("foo", []byte("bar"))
- blob, err := bs.GetBlob("foo")
- g.Assert(err == nil).IsTrue()
- g.Assert(string(blob)).Equal("bar")
- })
-
- g.It("Should Get a Blob reader", func() {
- bs.SetBlob("foo", []byte("bar"))
- r, _ := bs.GetBlobReader("foo")
- blob, _ := ioutil.ReadAll(r)
- g.Assert(string(blob)).Equal("bar")
- })
-
- g.It("Should Del a Blob", func() {
- bs.SetBlob("foo", []byte("bar"))
- err := bs.DelBlob("foo")
- g.Assert(err == nil).IsTrue()
- })
-
- })
-}
diff --git a/pkg/store/builtin/build.go b/pkg/store/builtin/build.go
deleted file mode 100644
index 5e9ace3eb..000000000
--- a/pkg/store/builtin/build.go
+++ /dev/null
@@ -1,222 +0,0 @@
-package builtin
-
-import (
- "database/sql"
-
- "github.com/drone/drone/pkg/types"
-)
-
-type Buildstore struct {
- *sql.DB
-}
-
-func NewBuildstore(db *sql.DB) *Buildstore {
- return &Buildstore{db}
-}
-
-// Build gets a build by ID
-func (db *Buildstore) Build(id int64) (*types.Build, error) {
- return getBuild(db, rebind(stmtBuildSelect), id)
-}
-
-// BuildNumber gets the specified build number for the
-// named repository and build number
-func (db *Buildstore) BuildNumber(repo *types.Repo, seq int) (*types.Build, error) {
- return getBuild(db, rebind(stmtBuildSelectBuildNumber), repo.ID, seq)
-}
-
-// BuildPullRequest gets the specific build for the
-// named repository and pull request number
-func (db *Buildstore) BuildPullRequestNumber(repo *types.Repo, seq int) (*types.Build, error) {
- return getBuild(db, rebind(stmtBuildSelectPullRequestNumber), repo.ID, seq)
-}
-
-// BuildSha gets the specific build for the
-// named repository and sha
-func (db *Buildstore) BuildSha(repo *types.Repo, sha, branch string) (*types.Build, error) {
- return getBuild(db, rebind(stmtBuildSelectSha), repo.ID, sha, branch)
-}
-
-// BuildLast gets the last executed build for the
-// named repository.
-func (db *Buildstore) BuildLast(repo *types.Repo, branch string) (*types.Build, error) {
- return getBuild(db, rebind(buildLastQuery), repo.ID, branch)
-}
-
-// BuildList gets a list of recent builds for the
-// named repository.
-func (db *Buildstore) BuildList(repo *types.Repo, limit, offset int) ([]*types.Build, error) {
- return getBuilds(db, rebind(buildListQuery), repo.ID, limit, offset)
-}
-
-// AddBuild inserts a new build in the datastore.
-func (db *Buildstore) AddBuild(build *types.Build) error {
- tx, err := db.Begin()
- if err != nil {
- return err
- }
- defer tx.Rollback()
-
- // extract the next build number from the database
- row := tx.QueryRow(rebind(buildNumberLast), build.RepoID)
- if row != nil {
- row.Scan(&build.Number)
- }
-
- build.Number = build.Number + 1 // increment
- err = createBuild(tx, rebind(stmtBuildInsert), build)
- if err != nil {
- return err
- }
-
- for _, job := range build.Jobs {
- job.BuildID = build.ID
- err := createJob(tx, rebind(stmtJobInsert), job)
- if err != nil {
- return err
- }
- }
- return tx.Commit()
-}
-
-// SetBuild updates an existing build and build jobs.
-func (db *Buildstore) SetBuild(build *types.Build) error {
- tx, err := db.Begin()
- if err != nil {
- return err
- }
- defer tx.Rollback()
-
- err = updateBuild(tx, rebind(stmtBuildUpdate), build)
- if err != nil {
- return err
- }
-
- for _, job := range build.Jobs {
- err = updateJob(tx, rebind(stmtJobUpdate), job)
- if err != nil {
- return err
- }
- }
- return tx.Commit()
-}
-
-// KillBuilds updates all pending or started builds
-// in the datastore settings the status to killed.
-func (db *Buildstore) KillBuilds() error {
- var _, err1 = db.Exec(rebind(buildKillStmt))
- if err1 != nil {
- return err1
- }
- var _, err2 = db.Exec(rebind(jobKillStmt))
- return err2
-}
-
-const stmtBuildSelectPullRequestNumber = stmtBuildSelectList + `
-WHERE build_repo_id = ?
-AND build_pull_request_number = ?
-ORDER BY build_number DESC
-LIMIT 1
-`
-
-const stmtBuildSelectSha = stmtBuildSelectList + `
-WHERE build_repo_id = ?
-AND build_commit_sha = ?
-AND build_commit_branch = ?
-ORDER BY build_number DESC
-LIMIT 1
-`
-
-// SQL query to retrieve the latest builds across all branches.
-const buildListQuery = `
-SELECT
- build_id
-,build_repo_id
-,build_number
-,build_status
-,build_started
-,build_finished
-,build_commit_sha
-,build_commit_ref
-,build_commit_link
-,build_commit_branch
-,build_commit_message
-,build_commit_timestamp
-,build_commit_remote
-,build_commit_author_login
-,build_commit_author_email
-,build_pull_request_number
-,build_pull_request_title
-,build_pull_request_link
-,build_pull_request_base_sha
-,build_pull_request_base_ref
-,build_pull_request_base_link
-,build_pull_request_base_branch
-,build_pull_request_base_message
-,build_pull_request_base_timestamp
-,build_pull_request_base_remote
-,build_pull_request_base_author_login
-,build_pull_request_base_author_email
-FROM builds
-WHERE build_repo_id = ?
-ORDER BY build_number DESC
-LIMIT ? OFFSET ?
-`
-
-// SQL query to retrieve the most recent build.
-// TODO exclude pull requests
-const buildLastQuery = `
-SELECT
- build_id
-,build_repo_id
-,build_number
-,build_status
-,build_started
-,build_finished
-,build_commit_sha
-,build_commit_ref
-,build_commit_link
-,build_commit_branch
-,build_commit_message
-,build_commit_timestamp
-,build_commit_remote
-,build_commit_author_login
-,build_commit_author_email
-,build_pull_request_number
-,build_pull_request_title
-,build_pull_request_link
-,build_pull_request_base_sha
-,build_pull_request_base_ref
-,build_pull_request_base_link
-,build_pull_request_base_branch
-,build_pull_request_base_message
-,build_pull_request_base_timestamp
-,build_pull_request_base_remote
-,build_pull_request_base_author_login
-,build_pull_request_base_author_email
-FROM builds
-WHERE build_repo_id = ?
- AND build_commit_branch = ?
-ORDER BY build_number DESC
-LIMIT 1
-`
-
-// SQL statement to cancel all running builds.
-const buildKillStmt = `
-UPDATE builds SET build_status = 'killed'
-WHERE build_status IN ('pending', 'running');
-`
-
-// SQL statement to cancel all running build jobs.
-const jobKillStmt = `
-UPDATE jobs SET job_status = 'killed'
-WHERE job_status IN ('pending', 'running');
-`
-
-// SQL statement to retrieve the latest sequential
-// build number for a build
-const buildNumberLast = `
-SELECT MAX(build_number)
-FROM builds
-WHERE build_repo_id = ?
-`
diff --git a/pkg/store/builtin/build_sql.go b/pkg/store/builtin/build_sql.go
deleted file mode 100644
index eabc37285..000000000
--- a/pkg/store/builtin/build_sql.go
+++ /dev/null
@@ -1,747 +0,0 @@
-package builtin
-
-// DO NOT EDIT
-// code generated by go:generate
-
-import (
- "database/sql"
- "encoding/json"
-
- . "github.com/drone/drone/pkg/types"
-)
-
-var _ = json.Marshal
-
-// generic database interface, matching both *sql.Db and *sql.Tx
-type buildDB interface {
- Exec(query string, args ...interface{}) (sql.Result, error)
- Query(query string, args ...interface{}) (*sql.Rows, error)
- QueryRow(query string, args ...interface{}) *sql.Row
-}
-
-func getBuild(db buildDB, query string, args ...interface{}) (*Build, error) {
- row := db.QueryRow(query, args...)
- return scanBuild(row)
-}
-
-func getBuilds(db buildDB, query string, args ...interface{}) ([]*Build, error) {
- rows, err := db.Query(query, args...)
- if err != nil {
- return nil, err
- }
- defer rows.Close()
- return scanBuilds(rows)
-}
-
-func createBuild(db buildDB, query string, v *Build) error {
- var v0 int64
- var v1 int
- var v2 string
- var v3 int64
- var v4 int64
- var v5 string
- var v6 string
- var v7 string
- var v8 string
- var v9 string
- var v10 string
- var v11 string
- var v12 string
- var v13 string
- var v14 int
- var v15 string
- var v16 string
- var v17 string
- var v18 string
- var v19 string
- var v20 string
- var v21 string
- var v22 string
- var v23 string
- var v24 string
- var v25 string
- v0 = v.RepoID
- v1 = v.Number
- v2 = v.Status
- v3 = v.Started
- v4 = v.Finished
- if v.Commit != nil {
- v5 = v.Commit.Sha
- v6 = v.Commit.Ref
- v7 = v.Commit.Link
- v8 = v.Commit.Branch
- v9 = v.Commit.Message
- v10 = v.Commit.Timestamp
- v11 = v.Commit.Remote
- if v.Commit.Author != nil {
- v12 = v.Commit.Author.Login
- v13 = v.Commit.Author.Email
- }
- }
- if v.PullRequest != nil {
- v14 = v.PullRequest.Number
- v15 = v.PullRequest.Title
- v16 = v.PullRequest.Link
- if v.PullRequest.Base != nil {
- v17 = v.PullRequest.Base.Sha
- v18 = v.PullRequest.Base.Ref
- v19 = v.PullRequest.Base.Link
- v20 = v.PullRequest.Base.Branch
- v21 = v.PullRequest.Base.Message
- v22 = v.PullRequest.Base.Timestamp
- v23 = v.PullRequest.Base.Remote
- if v.PullRequest.Base.Author != nil {
- v24 = v.PullRequest.Base.Author.Login
- v25 = v.PullRequest.Base.Author.Email
- }
- }
- }
- res, err := db.Exec(query,
- &v0,
- &v1,
- &v2,
- &v3,
- &v4,
- &v5,
- &v6,
- &v7,
- &v8,
- &v9,
- &v10,
- &v11,
- &v12,
- &v13,
- &v14,
- &v15,
- &v16,
- &v17,
- &v18,
- &v19,
- &v20,
- &v21,
- &v22,
- &v23,
- &v24,
- &v25,
- )
- if err != nil {
- return err
- }
-
- v.ID, err = res.LastInsertId()
- return err
-}
-
-func updateBuild(db buildDB, query string, v *Build) error {
- var v0 int64
- var v1 int64
- var v2 int
- var v3 string
- var v4 int64
- var v5 int64
- var v6 string
- var v7 string
- var v8 string
- var v9 string
- var v10 string
- var v11 string
- var v12 string
- var v13 string
- var v14 string
- var v15 int
- var v16 string
- var v17 string
- var v18 string
- var v19 string
- var v20 string
- var v21 string
- var v22 string
- var v23 string
- var v24 string
- var v25 string
- var v26 string
- v0 = v.ID
- v1 = v.RepoID
- v2 = v.Number
- v3 = v.Status
- v4 = v.Started
- v5 = v.Finished
- if v.Commit != nil {
- v6 = v.Commit.Sha
- v7 = v.Commit.Ref
- v8 = v.Commit.Link
- v9 = v.Commit.Branch
- v10 = v.Commit.Message
- v11 = v.Commit.Timestamp
- v12 = v.Commit.Remote
- if v.Commit.Author != nil {
- v13 = v.Commit.Author.Login
- v14 = v.Commit.Author.Email
- }
- }
- if v.PullRequest != nil {
- v15 = v.PullRequest.Number
- v16 = v.PullRequest.Title
- v17 = v.PullRequest.Link
- if v.PullRequest.Base != nil {
- v18 = v.PullRequest.Base.Sha
- v19 = v.PullRequest.Base.Ref
- v20 = v.PullRequest.Base.Link
- v21 = v.PullRequest.Base.Branch
- v22 = v.PullRequest.Base.Message
- v23 = v.PullRequest.Base.Timestamp
- v24 = v.PullRequest.Base.Remote
- if v.PullRequest.Base.Author != nil {
- v25 = v.PullRequest.Base.Author.Login
- v26 = v.PullRequest.Base.Author.Email
- }
- }
- }
-
- _, err := db.Exec(query,
- &v1,
- &v2,
- &v3,
- &v4,
- &v5,
- &v6,
- &v7,
- &v8,
- &v9,
- &v10,
- &v11,
- &v12,
- &v13,
- &v14,
- &v15,
- &v16,
- &v17,
- &v18,
- &v19,
- &v20,
- &v21,
- &v22,
- &v23,
- &v24,
- &v25,
- &v26,
- &v0,
- )
- return err
-}
-
-func scanBuild(row *sql.Row) (*Build, error) {
- var v0 int64
- var v1 int64
- var v2 int
- var v3 string
- var v4 int64
- var v5 int64
- var v6 string
- var v7 string
- var v8 string
- var v9 string
- var v10 string
- var v11 string
- var v12 string
- var v13 string
- var v14 string
- var v15 int
- var v16 string
- var v17 string
- var v18 string
- var v19 string
- var v20 string
- var v21 string
- var v22 string
- var v23 string
- var v24 string
- var v25 string
- var v26 string
-
- err := row.Scan(
- &v0,
- &v1,
- &v2,
- &v3,
- &v4,
- &v5,
- &v6,
- &v7,
- &v8,
- &v9,
- &v10,
- &v11,
- &v12,
- &v13,
- &v14,
- &v15,
- &v16,
- &v17,
- &v18,
- &v19,
- &v20,
- &v21,
- &v22,
- &v23,
- &v24,
- &v25,
- &v26,
- )
- if err != nil {
- return nil, err
- }
-
- v := &Build{}
- v.ID = v0
- v.RepoID = v1
- v.Number = v2
- v.Status = v3
- v.Started = v4
- v.Finished = v5
- v.Commit = &Commit{}
- v.Commit.Sha = v6
- v.Commit.Ref = v7
- v.Commit.Link = v8
- v.Commit.Branch = v9
- v.Commit.Message = v10
- v.Commit.Timestamp = v11
- v.Commit.Remote = v12
- v.Commit.Author = &Author{}
- v.Commit.Author.Login = v13
- v.Commit.Author.Email = v14
- v.PullRequest = &PullRequest{}
- v.PullRequest.Number = v15
- v.PullRequest.Title = v16
- v.PullRequest.Link = v17
- v.PullRequest.Base = &Commit{}
- v.PullRequest.Base.Sha = v18
- v.PullRequest.Base.Ref = v19
- v.PullRequest.Base.Link = v20
- v.PullRequest.Base.Branch = v21
- v.PullRequest.Base.Message = v22
- v.PullRequest.Base.Timestamp = v23
- v.PullRequest.Base.Remote = v24
- v.PullRequest.Base.Author = &Author{}
- v.PullRequest.Base.Author.Login = v25
- v.PullRequest.Base.Author.Email = v26
-
- return v, nil
-}
-
-func scanBuilds(rows *sql.Rows) ([]*Build, error) {
- var err error
- var vv []*Build
- for rows.Next() {
- var v0 int64
- var v1 int64
- var v2 int
- var v3 string
- var v4 int64
- var v5 int64
- var v6 string
- var v7 string
- var v8 string
- var v9 string
- var v10 string
- var v11 string
- var v12 string
- var v13 string
- var v14 string
- var v15 int
- var v16 string
- var v17 string
- var v18 string
- var v19 string
- var v20 string
- var v21 string
- var v22 string
- var v23 string
- var v24 string
- var v25 string
- var v26 string
- err = rows.Scan(
- &v0,
- &v1,
- &v2,
- &v3,
- &v4,
- &v5,
- &v6,
- &v7,
- &v8,
- &v9,
- &v10,
- &v11,
- &v12,
- &v13,
- &v14,
- &v15,
- &v16,
- &v17,
- &v18,
- &v19,
- &v20,
- &v21,
- &v22,
- &v23,
- &v24,
- &v25,
- &v26,
- )
- if err != nil {
- return vv, err
- }
-
- v := &Build{}
- v.ID = v0
- v.RepoID = v1
- v.Number = v2
- v.Status = v3
- v.Started = v4
- v.Finished = v5
- v.Commit = &Commit{}
- v.Commit.Sha = v6
- v.Commit.Ref = v7
- v.Commit.Link = v8
- v.Commit.Branch = v9
- v.Commit.Message = v10
- v.Commit.Timestamp = v11
- v.Commit.Remote = v12
- v.Commit.Author = &Author{}
- v.Commit.Author.Login = v13
- v.Commit.Author.Email = v14
- v.PullRequest = &PullRequest{}
- v.PullRequest.Number = v15
- v.PullRequest.Title = v16
- v.PullRequest.Link = v17
- v.PullRequest.Base = &Commit{}
- v.PullRequest.Base.Sha = v18
- v.PullRequest.Base.Ref = v19
- v.PullRequest.Base.Link = v20
- v.PullRequest.Base.Branch = v21
- v.PullRequest.Base.Message = v22
- v.PullRequest.Base.Timestamp = v23
- v.PullRequest.Base.Remote = v24
- v.PullRequest.Base.Author = &Author{}
- v.PullRequest.Base.Author.Login = v25
- v.PullRequest.Base.Author.Email = v26
- vv = append(vv, v)
- }
- return vv, rows.Err()
-}
-
-const stmtBuildSelectList = `
-SELECT
- build_id
-,build_repo_id
-,build_number
-,build_status
-,build_started
-,build_finished
-,build_commit_sha
-,build_commit_ref
-,build_commit_link
-,build_commit_branch
-,build_commit_message
-,build_commit_timestamp
-,build_commit_remote
-,build_commit_author_login
-,build_commit_author_email
-,build_pull_request_number
-,build_pull_request_title
-,build_pull_request_link
-,build_pull_request_base_sha
-,build_pull_request_base_ref
-,build_pull_request_base_link
-,build_pull_request_base_branch
-,build_pull_request_base_message
-,build_pull_request_base_timestamp
-,build_pull_request_base_remote
-,build_pull_request_base_author_login
-,build_pull_request_base_author_email
-FROM builds
-`
-
-const stmtBuildSelectRange = `
-SELECT
- build_id
-,build_repo_id
-,build_number
-,build_status
-,build_started
-,build_finished
-,build_commit_sha
-,build_commit_ref
-,build_commit_link
-,build_commit_branch
-,build_commit_message
-,build_commit_timestamp
-,build_commit_remote
-,build_commit_author_login
-,build_commit_author_email
-,build_pull_request_number
-,build_pull_request_title
-,build_pull_request_link
-,build_pull_request_base_sha
-,build_pull_request_base_ref
-,build_pull_request_base_link
-,build_pull_request_base_branch
-,build_pull_request_base_message
-,build_pull_request_base_timestamp
-,build_pull_request_base_remote
-,build_pull_request_base_author_login
-,build_pull_request_base_author_email
-FROM builds
-LIMIT ? OFFSET ?
-`
-
-const stmtBuildSelect = `
-SELECT
- build_id
-,build_repo_id
-,build_number
-,build_status
-,build_started
-,build_finished
-,build_commit_sha
-,build_commit_ref
-,build_commit_link
-,build_commit_branch
-,build_commit_message
-,build_commit_timestamp
-,build_commit_remote
-,build_commit_author_login
-,build_commit_author_email
-,build_pull_request_number
-,build_pull_request_title
-,build_pull_request_link
-,build_pull_request_base_sha
-,build_pull_request_base_ref
-,build_pull_request_base_link
-,build_pull_request_base_branch
-,build_pull_request_base_message
-,build_pull_request_base_timestamp
-,build_pull_request_base_remote
-,build_pull_request_base_author_login
-,build_pull_request_base_author_email
-FROM builds
-WHERE build_id = ?
-`
-
-const stmtBuildSelectBuildRepoId = `
-SELECT
- build_id
-,build_repo_id
-,build_number
-,build_status
-,build_started
-,build_finished
-,build_commit_sha
-,build_commit_ref
-,build_commit_link
-,build_commit_branch
-,build_commit_message
-,build_commit_timestamp
-,build_commit_remote
-,build_commit_author_login
-,build_commit_author_email
-,build_pull_request_number
-,build_pull_request_title
-,build_pull_request_link
-,build_pull_request_base_sha
-,build_pull_request_base_ref
-,build_pull_request_base_link
-,build_pull_request_base_branch
-,build_pull_request_base_message
-,build_pull_request_base_timestamp
-,build_pull_request_base_remote
-,build_pull_request_base_author_login
-,build_pull_request_base_author_email
-FROM builds
-WHERE build_repo_id = ?
-`
-
-const stmtBuildSelectBuildNumber = `
-SELECT
- build_id
-,build_repo_id
-,build_number
-,build_status
-,build_started
-,build_finished
-,build_commit_sha
-,build_commit_ref
-,build_commit_link
-,build_commit_branch
-,build_commit_message
-,build_commit_timestamp
-,build_commit_remote
-,build_commit_author_login
-,build_commit_author_email
-,build_pull_request_number
-,build_pull_request_title
-,build_pull_request_link
-,build_pull_request_base_sha
-,build_pull_request_base_ref
-,build_pull_request_base_link
-,build_pull_request_base_branch
-,build_pull_request_base_message
-,build_pull_request_base_timestamp
-,build_pull_request_base_remote
-,build_pull_request_base_author_login
-,build_pull_request_base_author_email
-FROM builds
-WHERE build_repo_id = ?
-AND build_number = ?
-`
-
-const stmtBuildSelectCommitBranch = `
-SELECT
- build_id
-,build_repo_id
-,build_number
-,build_status
-,build_started
-,build_finished
-,build_commit_sha
-,build_commit_ref
-,build_commit_link
-,build_commit_branch
-,build_commit_message
-,build_commit_timestamp
-,build_commit_remote
-,build_commit_author_login
-,build_commit_author_email
-,build_pull_request_number
-,build_pull_request_title
-,build_pull_request_link
-,build_pull_request_base_sha
-,build_pull_request_base_ref
-,build_pull_request_base_link
-,build_pull_request_base_branch
-,build_pull_request_base_message
-,build_pull_request_base_timestamp
-,build_pull_request_base_remote
-,build_pull_request_base_author_login
-,build_pull_request_base_author_email
-FROM builds
-WHERE build_branch = ?
-AND build_branch = ?
-`
-
-const stmtBuildSelectCount = `
-SELECT count(1)
-FROM builds
-`
-
-const stmtBuildInsert = `
-INSERT INTO builds (
- build_repo_id
-,build_number
-,build_status
-,build_started
-,build_finished
-,build_commit_sha
-,build_commit_ref
-,build_commit_link
-,build_commit_branch
-,build_commit_message
-,build_commit_timestamp
-,build_commit_remote
-,build_commit_author_login
-,build_commit_author_email
-,build_pull_request_number
-,build_pull_request_title
-,build_pull_request_link
-,build_pull_request_base_sha
-,build_pull_request_base_ref
-,build_pull_request_base_link
-,build_pull_request_base_branch
-,build_pull_request_base_message
-,build_pull_request_base_timestamp
-,build_pull_request_base_remote
-,build_pull_request_base_author_login
-,build_pull_request_base_author_email
-) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);
-`
-
-const stmtBuildUpdate = `
-UPDATE builds SET
- build_repo_id = ?
-,build_number = ?
-,build_status = ?
-,build_started = ?
-,build_finished = ?
-,build_commit_sha = ?
-,build_commit_ref = ?
-,build_commit_link = ?
-,build_commit_branch = ?
-,build_commit_message = ?
-,build_commit_timestamp = ?
-,build_commit_remote = ?
-,build_commit_author_login = ?
-,build_commit_author_email = ?
-,build_pull_request_number = ?
-,build_pull_request_title = ?
-,build_pull_request_link = ?
-,build_pull_request_base_sha = ?
-,build_pull_request_base_ref = ?
-,build_pull_request_base_link = ?
-,build_pull_request_base_branch = ?
-,build_pull_request_base_message = ?
-,build_pull_request_base_timestamp = ?
-,build_pull_request_base_remote = ?
-,build_pull_request_base_author_login = ?
-,build_pull_request_base_author_email = ?
-WHERE build_id = ?
-`
-
-const stmtBuildDelete = `
-DELETE FROM builds
-WHERE build_id = ?
-`
-
-const stmtBuildTable = `
-CREATE TABLE IF NOT EXISTS builds (
- build_id INTEGER PRIMARY KEY AUTOINCREMENT
-,build_repo_id INTEGER
-,build_number INTEGER
-,build_status VARCHAR
-,build_started INTEGER
-,build_finished INTEGER
-,build_commit_sha VARCHAR
-,build_commit_ref VARCHAR
-,build_commit_link VARCHAR
-,build_commit_branch VARCHAR
-,build_commit_message VARCHAR
-,build_commit_timestamp VARCHAR
-,build_commit_remote VARCHAR
-,build_commit_author_login VARCHAR
-,build_commit_author_email VARCHAR
-,build_pull_request_number INTEGER
-,build_pull_request_title VARCHAR
-,build_pull_request_link VARCHAR
-,build_pull_request_base_sha VARCHAR
-,build_pull_request_base_ref VARCHAR
-,build_pull_request_base_link VARCHAR
-,build_pull_request_base_branch VARCHAR
-,build_pull_request_base_message VARCHAR
-,build_pull_request_base_timestamp VARCHAR
-,build_pull_request_base_remote VARCHAR
-,build_pull_request_base_author_login VARCHAR
-,build_pull_request_base_author_email VARCHAR
-);
-`
-
-const stmtBuildBuildRepoIdIndex = `
-CREATE INDEX IF NOT EXISTS ix_build_repo_id ON builds (build_repo_id);
-`
-
-const stmtBuildBuildNumberIndex = `
-CREATE UNIQUE INDEX IF NOT EXISTS ux_build_number ON builds (build_repo_id,build_number);
-`
-
-const stmtBuildCommitBranchIndex = `
-CREATE INDEX IF NOT EXISTS ix_commit_branch ON builds (build_branch,build_branch);
-`
diff --git a/pkg/store/builtin/build_test.go b/pkg/store/builtin/build_test.go
deleted file mode 100644
index 80aa02f0c..000000000
--- a/pkg/store/builtin/build_test.go
+++ /dev/null
@@ -1,172 +0,0 @@
-package builtin
-
-import (
- "testing"
-
- "github.com/drone/drone/Godeps/_workspace/src/github.com/franela/goblin"
- "github.com/drone/drone/pkg/types"
-)
-
-func TestCommitstore(t *testing.T) {
- db := mustConnectTest()
- bs := NewBuildstore(db)
- defer db.Close()
-
- g := goblin.Goblin(t)
- g.Describe("Buildstore", func() {
-
- // before each test be sure to purge the package
- // table data from the database.
- g.BeforeEach(func() {
- db.Exec("DELETE FROM builds")
- db.Exec("DELETE FROM jobs")
- })
-
- g.It("Should Post a Build", func() {
- build := types.Build{
- RepoID: 1,
- Status: types.StateSuccess,
- Commit: &types.Commit{
- Ref: "refs/heads/master",
- Sha: "85f8c029b902ed9400bc600bac301a0aadb144ac",
- },
- }
- err := bs.AddBuild(&build)
- g.Assert(err == nil).IsTrue()
- g.Assert(build.ID != 0).IsTrue()
- g.Assert(build.Number).Equal(1)
- g.Assert(build.Commit.Ref).Equal("refs/heads/master")
- g.Assert(build.Commit.Sha).Equal("85f8c029b902ed9400bc600bac301a0aadb144ac")
- })
-
- g.It("Should Put a Build", func() {
- build := types.Build{
- RepoID: 1,
- Number: 5,
- Status: types.StatePending,
- Commit: &types.Commit{
- Ref: "refs/heads/master",
- Sha: "85f8c029b902ed9400bc600bac301a0aadb144ac",
- },
- }
- bs.AddBuild(&build)
- build.Status = types.StateRunning
- err1 := bs.SetBuild(&build)
- getbuild, err2 := bs.Build(build.ID)
- g.Assert(err1 == nil).IsTrue()
- g.Assert(err2 == nil).IsTrue()
- g.Assert(build.ID).Equal(getbuild.ID)
- g.Assert(build.RepoID).Equal(getbuild.RepoID)
- g.Assert(build.Status).Equal(getbuild.Status)
- g.Assert(build.Number).Equal(getbuild.Number)
- })
-
- g.It("Should Get a Build", func() {
- build := types.Build{
- RepoID: 1,
- Status: types.StateSuccess,
- }
- bs.AddBuild(&build)
- getbuild, err := bs.Build(build.ID)
- g.Assert(err == nil).IsTrue()
- g.Assert(build.ID).Equal(getbuild.ID)
- g.Assert(build.RepoID).Equal(getbuild.RepoID)
- g.Assert(build.Status).Equal(getbuild.Status)
- })
-
- g.It("Should Get a Build by Number", func() {
- build1 := &types.Build{
- RepoID: 1,
- Status: types.StatePending,
- }
- build2 := &types.Build{
- RepoID: 1,
- Status: types.StatePending,
- }
- err1 := bs.AddBuild(build1)
- err2 := bs.AddBuild(build2)
- getbuild, err3 := bs.BuildNumber(&types.Repo{ID: 1}, build2.Number)
- g.Assert(err1 == nil).IsTrue()
- g.Assert(err2 == nil).IsTrue()
- g.Assert(err3 == nil).IsTrue()
- g.Assert(build2.ID).Equal(getbuild.ID)
- g.Assert(build2.RepoID).Equal(getbuild.RepoID)
- g.Assert(build2.Number).Equal(getbuild.Number)
- })
-
- g.It("Should Kill Pending or Started Builds", func() {
- build1 := &types.Build{
- RepoID: 1,
- Status: types.StateRunning,
- }
- build2 := &types.Build{
- RepoID: 1,
- Status: types.StatePending,
- }
- bs.AddBuild(build1)
- bs.AddBuild(build2)
- err1 := bs.KillBuilds()
- getbuild1, err2 := bs.Build(build1.ID)
- getbuild2, err3 := bs.Build(build2.ID)
- g.Assert(err1 == nil).IsTrue()
- g.Assert(err2 == nil).IsTrue()
- g.Assert(err3 == nil).IsTrue()
- g.Assert(getbuild1.Status).Equal(types.StateKilled)
- g.Assert(getbuild2.Status).Equal(types.StateKilled)
- })
-
- g.It("Should get recent Builds", func() {
- build1 := &types.Build{
- RepoID: 1,
- Status: types.StateFailure,
- }
- build2 := &types.Build{
- RepoID: 1,
- Status: types.StateSuccess,
- }
- bs.AddBuild(build1)
- bs.AddBuild(build2)
- builds, err := bs.BuildList(&types.Repo{ID: 1}, 20, 0)
- g.Assert(err == nil).IsTrue()
- g.Assert(len(builds)).Equal(2)
- g.Assert(builds[0].ID).Equal(build2.ID)
- g.Assert(builds[0].RepoID).Equal(build2.RepoID)
- g.Assert(builds[0].Status).Equal(build2.Status)
- })
- //
- // g.It("Should get the last Commit", func() {
- // commit1 := &types.Commit{
- // RepoID: 1,
- // State: types.StateFailure,
- // Branch: "master",
- // Ref: "refs/heads/master",
- // Sha: "85f8c029b902ed9400bc600bac301a0aadb144ac",
- // }
- // commit2 := &types.Commit{
- // RepoID: 1,
- // State: types.StateFailure,
- // Branch: "master",
- // Ref: "refs/heads/master",
- // Sha: "8d6a233744a5dcacbf2605d4592a4bfe8b37320d",
- // }
- // commit3 := &types.Commit{
- // RepoID: 1,
- // State: types.StateSuccess,
- // Branch: "dev",
- // Ref: "refs/heads/dev",
- // Sha: "85f8c029b902ed9400bc600bac301a0aadb144ac",
- // }
- // err1 := bs.AddCommit(commit1)
- // err2 := bs.AddCommit(commit2)
- // err3 := bs.AddCommit(commit3)
- // last, err4 := bs.CommitLast(&types.Repo{ID: 1}, "master")
- // g.Assert(err1 == nil).IsTrue()
- // g.Assert(err2 == nil).IsTrue()
- // g.Assert(err3 == nil).IsTrue()
- // g.Assert(err4 == nil).IsTrue()
- // g.Assert(last.ID).Equal(commit2.ID)
- // g.Assert(last.RepoID).Equal(commit2.RepoID)
- // g.Assert(last.Sequence).Equal(commit2.Sequence)
- // })
- })
-}
diff --git a/pkg/store/builtin/job.go b/pkg/store/builtin/job.go
deleted file mode 100644
index 1db0655c4..000000000
--- a/pkg/store/builtin/job.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package builtin
-
-import (
- "database/sql"
-
- "github.com/drone/drone/pkg/types"
-)
-
-type Jobstore struct {
- *sql.DB
-}
-
-func NewJobstore(db *sql.DB) *Jobstore {
- return &Jobstore{db}
-}
-
-// Job returns a Job by ID.
-func (db *Jobstore) Job(id int64) (*types.Job, error) {
- return getJob(db, rebind(stmtJobSelect), id)
-}
-
-// JobNumber returns a job by sequence number.
-func (db *Jobstore) JobNumber(build *types.Build, seq int) (*types.Job, error) {
- return getJob(db, rebind(stmtJobSelectBuildNumber), build.ID, seq)
-}
-
-// JobList returns a list of all build jobs
-func (db *Jobstore) JobList(build *types.Build) ([]*types.Job, error) {
- return getJobs(db, rebind(stmtJobSelectJobBuildId), build.ID)
-}
-
-// SetJob updates an existing build job.
-func (db *Jobstore) SetJob(job *types.Job) error {
- return updateJob(db, rebind(stmtJobUpdate), job)
-}
-
-// AddJob inserts a build job.
-func (db *Jobstore) AddJob(job *types.Job) error {
- return createJob(db, rebind(stmtJobInsert), job)
-}
diff --git a/pkg/store/builtin/job_sql.go b/pkg/store/builtin/job_sql.go
deleted file mode 100644
index 1fb8e6e28..000000000
--- a/pkg/store/builtin/job_sql.go
+++ /dev/null
@@ -1,300 +0,0 @@
-package builtin
-
-// DO NOT EDIT
-// code generated by go:generate
-
-import (
- "database/sql"
- "encoding/json"
-
- . "github.com/drone/drone/pkg/types"
-)
-
-var _ = json.Marshal
-
-// generic database interface, matching both *sql.Db and *sql.Tx
-type jobDB interface {
- Exec(query string, args ...interface{}) (sql.Result, error)
- Query(query string, args ...interface{}) (*sql.Rows, error)
- QueryRow(query string, args ...interface{}) *sql.Row
-}
-
-func getJob(db jobDB, query string, args ...interface{}) (*Job, error) {
- row := db.QueryRow(query, args...)
- return scanJob(row)
-}
-
-func getJobs(db jobDB, query string, args ...interface{}) ([]*Job, error) {
- rows, err := db.Query(query, args...)
- if err != nil {
- return nil, err
- }
- defer rows.Close()
- return scanJobs(rows)
-}
-
-func createJob(db jobDB, query string, v *Job) error {
- var v0 int64
- var v1 int
- var v2 string
- var v3 int
- var v4 int64
- var v5 int64
- var v6 []byte
- v0 = v.BuildID
- v1 = v.Number
- v2 = v.Status
- v3 = v.ExitCode
- v4 = v.Started
- v5 = v.Finished
- v6, _ = json.Marshal(v.Environment)
-
- res, err := db.Exec(query,
- &v0,
- &v1,
- &v2,
- &v3,
- &v4,
- &v5,
- &v6,
- )
- if err != nil {
- return err
- }
-
- v.ID, err = res.LastInsertId()
- return err
-}
-
-func updateJob(db jobDB, query string, v *Job) error {
- var v0 int64
- var v1 int64
- var v2 int
- var v3 string
- var v4 int
- var v5 int64
- var v6 int64
- var v7 []byte
- v0 = v.ID
- v1 = v.BuildID
- v2 = v.Number
- v3 = v.Status
- v4 = v.ExitCode
- v5 = v.Started
- v6 = v.Finished
- v7, _ = json.Marshal(v.Environment)
-
- _, err := db.Exec(query,
- &v1,
- &v2,
- &v3,
- &v4,
- &v5,
- &v6,
- &v7,
- &v0,
- )
- return err
-}
-
-func scanJob(row *sql.Row) (*Job, error) {
- var v0 int64
- var v1 int64
- var v2 int
- var v3 string
- var v4 int
- var v5 int64
- var v6 int64
- var v7 []byte
-
- err := row.Scan(
- &v0,
- &v1,
- &v2,
- &v3,
- &v4,
- &v5,
- &v6,
- &v7,
- )
- if err != nil {
- return nil, err
- }
-
- v := &Job{}
- v.ID = v0
- v.BuildID = v1
- v.Number = v2
- v.Status = v3
- v.ExitCode = v4
- v.Started = v5
- v.Finished = v6
- json.Unmarshal(v7, &v.Environment)
-
- return v, nil
-}
-
-func scanJobs(rows *sql.Rows) ([]*Job, error) {
- var err error
- var vv []*Job
- for rows.Next() {
- var v0 int64
- var v1 int64
- var v2 int
- var v3 string
- var v4 int
- var v5 int64
- var v6 int64
- var v7 []byte
- err = rows.Scan(
- &v0,
- &v1,
- &v2,
- &v3,
- &v4,
- &v5,
- &v6,
- &v7,
- )
- if err != nil {
- return vv, err
- }
-
- v := &Job{}
- v.ID = v0
- v.BuildID = v1
- v.Number = v2
- v.Status = v3
- v.ExitCode = v4
- v.Started = v5
- v.Finished = v6
- json.Unmarshal(v7, &v.Environment)
- vv = append(vv, v)
- }
- return vv, rows.Err()
-}
-
-const stmtJobSelectList = `
-SELECT
- job_id
-,job_build_id
-,job_number
-,job_status
-,job_exit_code
-,job_started
-,job_finished
-,job_environment
-FROM jobs
-`
-
-const stmtJobSelectRange = `
-SELECT
- job_id
-,job_build_id
-,job_number
-,job_status
-,job_exit_code
-,job_started
-,job_finished
-,job_environment
-FROM jobs
-LIMIT ? OFFSET ?
-`
-
-const stmtJobSelect = `
-SELECT
- job_id
-,job_build_id
-,job_number
-,job_status
-,job_exit_code
-,job_started
-,job_finished
-,job_environment
-FROM jobs
-WHERE job_id = ?
-`
-
-const stmtJobSelectJobBuildId = `
-SELECT
- job_id
-,job_build_id
-,job_number
-,job_status
-,job_exit_code
-,job_started
-,job_finished
-,job_environment
-FROM jobs
-WHERE job_build_id = ?
-`
-
-const stmtJobSelectBuildNumber = `
-SELECT
- job_id
-,job_build_id
-,job_number
-,job_status
-,job_exit_code
-,job_started
-,job_finished
-,job_environment
-FROM jobs
-WHERE job_build_id = ?
-AND job_number = ?
-`
-
-const stmtJobSelectCount = `
-SELECT count(1)
-FROM jobs
-`
-
-const stmtJobInsert = `
-INSERT INTO jobs (
- job_build_id
-,job_number
-,job_status
-,job_exit_code
-,job_started
-,job_finished
-,job_environment
-) VALUES (?,?,?,?,?,?,?);
-`
-
-const stmtJobUpdate = `
-UPDATE jobs SET
- job_build_id = ?
-,job_number = ?
-,job_status = ?
-,job_exit_code = ?
-,job_started = ?
-,job_finished = ?
-,job_environment = ?
-WHERE job_id = ?
-`
-
-const stmtJobDelete = `
-DELETE FROM jobs
-WHERE job_id = ?
-`
-
-const stmtJobTable = `
-CREATE TABLE IF NOT EXISTS jobs (
- job_id INTEGER PRIMARY KEY AUTOINCREMENT
-,job_build_id INTEGER
-,job_number INTEGER
-,job_status VARCHAR(512)
-,job_exit_code INTEGER
-,job_started INTEGER
-,job_finished INTEGER
-,job_environmentVARCHAR(2048)
-);
-`
-
-const stmtJobJobBuildIdIndex = `
-CREATE INDEX IF NOT EXISTS ix_job_build_id ON jobs (job_build_id);
-`
-
-const stmtJobBuildNumberIndex = `
-CREATE UNIQUE INDEX IF NOT EXISTS ux_build_number ON jobs (job_build_id,job_number);
-`
diff --git a/pkg/store/builtin/job_test.go b/pkg/store/builtin/job_test.go
deleted file mode 100644
index 6d06fb8db..000000000
--- a/pkg/store/builtin/job_test.go
+++ /dev/null
@@ -1,119 +0,0 @@
-package builtin
-
-import (
- "testing"
-
- "github.com/drone/drone/Godeps/_workspace/src/github.com/franela/goblin"
- "github.com/drone/drone/pkg/types"
-)
-
-func TestBuildstore(t *testing.T) {
- db := mustConnectTest()
- bs := NewJobstore(db)
- cs := NewBuildstore(db)
- defer db.Close()
-
- g := goblin.Goblin(t)
- g.Describe("Jobstore", func() {
-
- // before each test we purge the package table data from the database.
- g.BeforeEach(func() {
- db.Exec("DELETE FROM jobs")
- db.Exec("DELETE FROM builds")
- })
-
- g.It("Should Set a job", func() {
- job := &types.Job{
- BuildID: 1,
- Status: "pending",
- ExitCode: 0,
- Number: 1,
- }
- err1 := bs.AddJob(job)
- g.Assert(err1 == nil).IsTrue()
- g.Assert(job.ID != 0).IsTrue()
-
- job.Status = "started"
- err2 := bs.SetJob(job)
- g.Assert(err2 == nil).IsTrue()
-
- getjob, err3 := bs.Job(job.ID)
- g.Assert(err3 == nil).IsTrue()
- g.Assert(getjob.Status).Equal(job.Status)
- })
-
- g.It("Should Get a Job by ID", func() {
- job := &types.Job{
- BuildID: 1,
- Status: "pending",
- ExitCode: 1,
- Number: 1,
- Environment: map[string]string{"foo": "bar"},
- }
- err1 := bs.AddJob(job)
- g.Assert(err1 == nil).IsTrue()
- g.Assert(job.ID != 0).IsTrue()
-
- getjob, err2 := bs.Job(job.ID)
- g.Assert(err2 == nil).IsTrue()
- g.Assert(getjob.ID).Equal(job.ID)
- g.Assert(getjob.Status).Equal(job.Status)
- g.Assert(getjob.ExitCode).Equal(job.ExitCode)
- g.Assert(getjob.Environment).Equal(job.Environment)
- g.Assert(getjob.Environment["foo"]).Equal("bar")
- })
-
- g.It("Should Get a Job by Number", func() {
- job := &types.Job{
- BuildID: 1,
- Status: "pending",
- ExitCode: 1,
- Number: 1,
- }
- err1 := bs.AddJob(job)
- g.Assert(err1 == nil).IsTrue()
- g.Assert(job.ID != 0).IsTrue()
-
- getjob, err2 := bs.JobNumber(&types.Build{ID: 1}, 1)
- g.Assert(err2 == nil).IsTrue()
- g.Assert(getjob.ID).Equal(job.ID)
- g.Assert(getjob.Status).Equal(job.Status)
- })
-
- g.It("Should Get a List of Jobs by Commit", func() {
-
- build := types.Build{
- RepoID: 1,
- Status: types.StateSuccess,
- Jobs: []*types.Job{
- &types.Job{
- BuildID: 1,
- Status: "success",
- ExitCode: 0,
- Number: 1,
- },
- &types.Job{
- BuildID: 3,
- Status: "error",
- ExitCode: 1,
- Number: 2,
- },
- &types.Job{
- BuildID: 5,
- Status: "pending",
- ExitCode: 0,
- Number: 3,
- },
- },
- }
- //
- err1 := cs.AddBuild(&build)
- g.Assert(err1 == nil).IsTrue()
- getjobs, err2 := bs.JobList(&build)
- g.Assert(err2 == nil).IsTrue()
- g.Assert(len(getjobs)).Equal(3)
- g.Assert(getjobs[0].Number).Equal(1)
- g.Assert(getjobs[0].Status).Equal(types.StateSuccess)
- })
- })
-}
diff --git a/pkg/store/builtin/migrate/helper.go b/pkg/store/builtin/migrate/helper.go
deleted file mode 100644
index c09be4a39..000000000
--- a/pkg/store/builtin/migrate/helper.go
+++ /dev/null
@@ -1,47 +0,0 @@
-package migrate
-
-import (
- "strconv"
- "strings"
-
- "github.com/drone/drone/Godeps/_workspace/src/github.com/russross/meddler"
-)
-
-// transform is a helper function that transforms sql
-// statements to work with multiple database types.
-func transform(stmt string) string {
- switch meddler.Default {
- case meddler.MySQL:
- stmt = strings.Replace(stmt, "AUTOINCREMENT", "AUTO_INCREMENT", -1)
- stmt = strings.Replace(stmt, "BLOB", "MEDIUMBLOB", -1)
- case meddler.PostgreSQL:
- stmt = strings.Replace(stmt, "INTEGER PRIMARY KEY AUTOINCREMENT", "SERIAL PRIMARY KEY", -1)
- stmt = strings.Replace(stmt, "BLOB", "BYTEA", -1)
- }
- return stmt
-}
-
-// rebind is a helper function that changes the sql
-// bind type from ? to $ for postgres queries.
-func rebind(query string) string {
- if meddler.Default != meddler.PostgreSQL {
- return query
- }
-
- qb := []byte(query)
- // Add space enough for 10 params before we have to allocate
- rqb := make([]byte, 0, len(qb)+10)
- j := 1
- for _, b := range qb {
- if b == '?' {
- rqb = append(rqb, '$')
- for _, b := range strconv.Itoa(j) {
- rqb = append(rqb, byte(b))
- }
- j++
- } else {
- rqb = append(rqb, b)
- }
- }
- return string(rqb)
-}
diff --git a/pkg/store/builtin/migrate/migrate.go b/pkg/store/builtin/migrate/migrate.go
deleted file mode 100644
index 2936149e8..000000000
--- a/pkg/store/builtin/migrate/migrate.go
+++ /dev/null
@@ -1,199 +0,0 @@
-package migrate
-
-import (
- "github.com/drone/drone/Godeps/_workspace/src/github.com/BurntSushi/migration"
-)
-
-// Setup is the database migration function that
-// will setup the initial SQL database structure.
-func Setup(tx migration.LimitedTx) error {
- var stmts = []string{
- userTable,
- starTable,
- repoTable,
- repoUserIndex,
- buildTable,
- buildRepoIndex,
- buildBranchIndex,
- tokenTable,
- jobTable,
- jobBuildIndex,
- statusTable,
- statusCommitIndex,
- blobTable,
- agentTable,
- }
- for _, stmt := range stmts {
- _, err := tx.Exec(transform(stmt))
- if err != nil {
- return err
- }
- }
- return nil
-}
-
-var userTable = `
-CREATE TABLE IF NOT EXISTS users (
- user_id INTEGER PRIMARY KEY AUTOINCREMENT
- ,user_login VARCHAR(255)
- ,user_token VARCHAR(255)
- ,user_secret VARCHAR(255)
- ,user_email VARCHAR(255)
- ,user_avatar VARCHAR(255)
- ,user_admin BOOLEAN
- ,user_active BOOLEAN
- ,user_hash VARCHAR(255)
- ,UNIQUE(user_login)
-);
-`
-
-var repoTable = `
-CREATE TABLE IF NOT EXISTS repos (
- repo_id INTEGER PRIMARY KEY AUTOINCREMENT
- ,repo_user_id INTEGER
- ,repo_owner VARCHAR(255)
- ,repo_name VARCHAR(255)
- ,repo_avatar VARCHAR(1024)
- ,repo_full_name VARCHAR(512)
- ,repo_self VARCHAR(1024)
- ,repo_link VARCHAR(1024)
- ,repo_clone VARCHAR(1024)
- ,repo_branch VARCHAR(255)
- ,repo_private BOOLEAN
- ,repo_trusted BOOLEAN
- ,repo_timeout INTEGER
- ,repo_keys_public BLOB
- ,repo_keys_private BLOB
- ,repo_hooks_pull_request BOOLEAN
- ,repo_hooks_push BOOLEAN
- ,repo_hooks_tags BOOLEAN
- ,repo_params BLOB
- ,repo_hash VARCHAR(255)
-
- ,UNIQUE(repo_owner, repo_name)
- ,UNIQUE(repo_full_name)
-);
-`
-
-var repoUserIndex = `
-CREATE INDEX repos_user_idx ON repos (repo_user_id);
-`
-
-var starTable = `
-CREATE TABLE IF NOT EXISTS stars (
- star_id INTEGER PRIMARY KEY AUTOINCREMENT
- ,star_user_id INTEGER
- ,star_repo_id INTEGER
- ,UNIQUE (star_repo_id, star_user_id)
-);
-`
-
-var buildTable = `
-CREATE TABLE IF NOT EXISTS builds (
- build_id INTEGER PRIMARY KEY AUTOINCREMENT
- ,build_repo_id INTEGER
- ,build_number INTEGER
- ,build_status VARCHAR(512)
- ,build_started INTEGER
- ,build_finished INTEGER
- ,build_commit_sha VARCHAR(512)
- ,build_commit_ref VARCHAR(512)
- ,build_commit_link VARCHAR(2048)
- ,build_commit_branch VARCHAR(512)
- ,build_commit_message VARCHAR(2048)
- ,build_commit_timestamp VARCHAR(512)
- ,build_commit_remote VARCHAR(512)
- ,build_commit_author_login VARCHAR(512)
- ,build_commit_author_email VARCHAR(512)
- ,build_pull_request_number INTEGER
- ,build_pull_request_title VARCHAR(512)
- ,build_pull_request_link VARCHAR(2048)
- ,build_pull_request_base_sha VARCHAR(512)
- ,build_pull_request_base_ref VARCHAR(512)
- ,build_pull_request_base_link VARCHAR(2048)
- ,build_pull_request_base_branch VARCHAR(512)
- ,build_pull_request_base_message VARCHAR(2048)
- ,build_pull_request_base_timestamp VARCHAR(512)
- ,build_pull_request_base_remote VARCHAR(512)
- ,build_pull_request_base_author_login VARCHAR(512)
- ,build_pull_request_base_author_email VARCHAR(512)
- ,UNIQUE(build_repo_id, build_number)
-);
-`
-
-var buildRepoIndex = `
-CREATE INDEX build_repo_idx ON builds (build_repo_id);
-`
-
-var buildBranchIndex = `
-CREATE INDEX build_branch_idx ON builds (build_commit_branch);
-`
-
-var tokenTable = `
-CREATE TABLE IF NOT EXISTS tokens (
- token_id INTEGER PRIMARY KEY AUTOINCREMENT
- ,token_user_id INTEGER
- ,token_kind VARCHAR(255)
- ,token_label VARCHAR(255)
- ,token_expiry INTEGER
- ,token_issued INTEGER
- ,UNIQUE(token_user_id, token_label)
-);
-`
-
-var tokenUserIndex = `
-CREATE INDEX tokens_user_idx ON tokens (token_user_id);
-`
-
-var jobTable = `
-CREATE TABLE IF NOT EXISTS jobs (
- job_id INTEGER PRIMARY KEY AUTOINCREMENT
- ,job_build_id INTEGER
- ,job_number INTEGER
- ,job_status VARCHAR(255)
- ,job_exit_code INTEGER
- ,job_started INTEGER
- ,job_finished INTEGER
- ,job_environment VARCHAR(2000)
- ,UNIQUE(job_build_id, job_number)
-);
-`
-
-var jobBuildIndex = `
-CREATE INDEX ix_job_build_id ON jobs (job_build_id);
-`
-
-var statusTable = `
-CREATE TABLE IF NOT EXISTS status (
- status_id INTEGER PRIMARY KEY AUTOINCREMENT
- ,commit_id INTEGER
- ,status_state VARCHAR(255)
- ,status_desc VARCHAR(2000)
- ,status_link VARCHAR(2000)
- ,status_context INTEGER
- ,status_attachment BOOL
- ,UNIQUE(commit_id, status_context)
-);
-`
-
-var statusCommitIndex = `
-CREATE INDEX status_commit_idx ON status (commit_id);
-`
-
-var blobTable = `
-CREATE TABLE IF NOT EXISTS blobs (
- blob_id INTEGER PRIMARY KEY AUTOINCREMENT
- ,blob_path VARCHAR(255)
- ,blob_data BLOB
- ,UNIQUE(blob_path)
-);
-`
-
-var agentTable = `
-CREATE TABLE IF NOT EXISTS agents (
- agent_id INTEGER PRIMARY KEY AUTOINCREMENT
- ,agent_build_id INTEGER
- ,agent_addr VARCHAR(2000)
- ,UNIQUE(agent_build_id)
-);
-`
diff --git a/pkg/store/builtin/migrate/version.go b/pkg/store/builtin/migrate/version.go
deleted file mode 100644
index a4494d0d8..000000000
--- a/pkg/store/builtin/migrate/version.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package migrate
-
-import (
- "github.com/drone/drone/Godeps/_workspace/src/github.com/BurntSushi/migration"
-)
-
-// GetVersion gets the migration version from the database,
-// creating the migration table if it does not already exist.
-func GetVersion(tx migration.LimitedTx) (int, error) {
- v, err := getVersion(tx)
- if err != nil {
- if err := createVersionTable(tx); err != nil {
- return 0, err
- }
- return getVersion(tx)
- }
- return v, nil
-}
-
-// SetVersion sets the migration version in the database,
-// creating the migration table if it does not already exist.
-func SetVersion(tx migration.LimitedTx, version int) error {
- if err := setVersion(tx, version); err != nil {
- if err := createVersionTable(tx); err != nil {
- return err
- }
- return setVersion(tx, version)
- }
- return nil
-}
-
-// setVersion updates the migration version in the database.
-func setVersion(tx migration.LimitedTx, version int) error {
- _, err := tx.Exec(rebind("UPDATE migration_version SET version = ?"), version)
- return err
-}
-
-// getVersion gets the migration version in the database.
-func getVersion(tx migration.LimitedTx) (int, error) {
- var version int
- row := tx.QueryRow("SELECT version FROM migration_version")
- if err := row.Scan(&version); err != nil {
- return 0, err
- }
- return version, nil
-}
-
-// createVersionTable creates the version table and inserts the
-// initial value (0) into the database.
-func createVersionTable(tx migration.LimitedTx) error {
- _, err := tx.Exec("CREATE TABLE migration_version ( version INTEGER )")
- if err != nil {
- return err
- }
- _, err = tx.Exec("INSERT INTO migration_version (version) VALUES (0)")
- return err
-}
diff --git a/pkg/store/builtin/repo.go b/pkg/store/builtin/repo.go
deleted file mode 100644
index 19f264e21..000000000
--- a/pkg/store/builtin/repo.go
+++ /dev/null
@@ -1,80 +0,0 @@
-package builtin
-
-import (
- "database/sql"
-
- "github.com/drone/drone/pkg/types"
-)
-
-type Repostore struct {
- *sql.DB
-}
-
-func NewRepostore(db *sql.DB) *Repostore {
- return &Repostore{db}
-}
-
-// Repo retrieves a specific repo from the
-// datastore for the given ID.
-func (db *Repostore) Repo(id int64) (*types.Repo, error) {
- return getRepo(db, rebind(stmtRepoSelect), id)
-}
-
-// RepoName retrieves a repo from the datastore
-// for the specified name.
-func (db *Repostore) RepoName(owner, name string) (*types.Repo, error) {
- return getRepo(db, rebind(stmtRepoSelectRepoOwnerName), owner, name)
-}
-
-// RepoList retrieves a list of all repos from
-// the datastore accessible by the given user ID.
-func (db *Repostore) RepoList(user *types.User) ([]*types.Repo, error) {
- return getRepos(db, rebind(repoListQuery), user.ID)
-}
-
-// AddRepo inserts a repo in the datastore.
-func (db *Repostore) AddRepo(repo *types.Repo) error {
- return createRepo(db, rebind(stmtRepoInsert), repo)
-}
-
-// SetRepo updates a repo in the datastore.
-func (db *Repostore) SetRepo(repo *types.Repo) error {
- return updateRepo(db, rebind(stmtRepoUpdate), repo)
-}
-
-// DelRepo removes the repo from the datastore.
-func (db *Repostore) DelRepo(repo *types.Repo) error {
- var _, err = db.Exec(rebind(stmtRepoDelete), repo.ID)
- return err
-}
-
-// SQL statement to retrieve a list of Repos
-// with permissions for the given User ID.
-const repoListQuery = `
-SELECT
- repo_id
-,repo_user_id
-,repo_owner
-,repo_name
-,repo_full_name
-,repo_avatar
-,repo_self
-,repo_link
-,repo_clone
-,repo_branch
-,repo_private
-,repo_trusted
-,repo_timeout
-,repo_keys_public
-,repo_keys_private
-,repo_hooks_pull_request
-,repo_hooks_push
-,repo_hooks_tags
-,repo_params
-,repo_hash
-FROM
- repos r
-,stars s
-WHERE r.repo_id = s.star_repo_id
- AND s.star_user_id = ?
-`
diff --git a/pkg/store/builtin/repo_sql.go b/pkg/store/builtin/repo_sql.go
deleted file mode 100644
index 3f83a2758..000000000
--- a/pkg/store/builtin/repo_sql.go
+++ /dev/null
@@ -1,582 +0,0 @@
-package builtin
-
-// DO NOT EDIT
-// code generated by go:generate
-
-import (
- "database/sql"
- "encoding/json"
-
- . "github.com/drone/drone/pkg/types"
-)
-
-var _ = json.Marshal
-
-// generic database interface, matching both *sql.Db and *sql.Tx
-type repoDB interface {
- Exec(query string, args ...interface{}) (sql.Result, error)
- Query(query string, args ...interface{}) (*sql.Rows, error)
- QueryRow(query string, args ...interface{}) *sql.Row
-}
-
-func getRepo(db repoDB, query string, args ...interface{}) (*Repo, error) {
- row := db.QueryRow(query, args...)
- return scanRepo(row)
-}
-
-func getRepos(db repoDB, query string, args ...interface{}) ([]*Repo, error) {
- rows, err := db.Query(query, args...)
- if err != nil {
- return nil, err
- }
- defer rows.Close()
- return scanRepos(rows)
-}
-
-func createRepo(db repoDB, query string, v *Repo) error {
- var v0 int64
- var v1 string
- var v2 string
- var v3 string
- var v4 string
- var v5 string
- var v6 string
- var v7 string
- var v8 string
- var v9 bool
- var v10 bool
- var v11 int64
- var v12 string
- var v13 string
- var v14 bool
- var v15 bool
- var v16 bool
- var v17 []byte
- var v18 string
- v0 = v.UserID
- v1 = v.Owner
- v2 = v.Name
- v3 = v.FullName
- v4 = v.Avatar
- v5 = v.Self
- v6 = v.Link
- v7 = v.Clone
- v8 = v.Branch
- v9 = v.Private
- v10 = v.Trusted
- v11 = v.Timeout
- if v.Keys != nil {
- v12 = v.Keys.Public
- v13 = v.Keys.Private
- }
- if v.Hooks != nil {
- v14 = v.Hooks.PullRequest
- v15 = v.Hooks.Push
- v16 = v.Hooks.Tags
- }
- v17, _ = json.Marshal(v.Params)
- v18 = v.Hash
-
- res, err := db.Exec(query,
- &v0,
- &v1,
- &v2,
- &v3,
- &v4,
- &v5,
- &v6,
- &v7,
- &v8,
- &v9,
- &v10,
- &v11,
- &v12,
- &v13,
- &v14,
- &v15,
- &v16,
- &v17,
- &v18,
- )
- if err != nil {
- return err
- }
-
- v.ID, err = res.LastInsertId()
- return err
-}
-
-func updateRepo(db repoDB, query string, v *Repo) error {
- var v0 int64
- var v1 int64
- var v2 string
- var v3 string
- var v4 string
- var v5 string
- var v6 string
- var v7 string
- var v8 string
- var v9 string
- var v10 bool
- var v11 bool
- var v12 int64
- var v13 string
- var v14 string
- var v15 bool
- var v16 bool
- var v17 bool
- var v18 []byte
- var v19 string
- v0 = v.ID
- v1 = v.UserID
- v2 = v.Owner
- v3 = v.Name
- v4 = v.FullName
- v5 = v.Avatar
- v6 = v.Self
- v7 = v.Link
- v8 = v.Clone
- v9 = v.Branch
- v10 = v.Private
- v11 = v.Trusted
- v12 = v.Timeout
- if v.Keys != nil {
- v13 = v.Keys.Public
- v14 = v.Keys.Private
- }
- if v.Hooks != nil {
- v15 = v.Hooks.PullRequest
- v16 = v.Hooks.Push
- v17 = v.Hooks.Tags
- }
- v18, _ = json.Marshal(v.Params)
- v19 = v.Hash
-
- _, err := db.Exec(query,
- &v1,
- &v2,
- &v3,
- &v4,
- &v5,
- &v6,
- &v7,
- &v8,
- &v9,
- &v10,
- &v11,
- &v12,
- &v13,
- &v14,
- &v15,
- &v16,
- &v17,
- &v18,
- &v19,
- &v0,
- )
- return err
-}
-
-func scanRepo(row *sql.Row) (*Repo, error) {
- var v0 int64
- var v1 int64
- var v2 string
- var v3 string
- var v4 string
- var v5 string
- var v6 string
- var v7 string
- var v8 string
- var v9 string
- var v10 bool
- var v11 bool
- var v12 int64
- var v13 string
- var v14 string
- var v15 bool
- var v16 bool
- var v17 bool
- var v18 []byte
- var v19 string
-
- err := row.Scan(
- &v0,
- &v1,
- &v2,
- &v3,
- &v4,
- &v5,
- &v6,
- &v7,
- &v8,
- &v9,
- &v10,
- &v11,
- &v12,
- &v13,
- &v14,
- &v15,
- &v16,
- &v17,
- &v18,
- &v19,
- )
- if err != nil {
- return nil, err
- }
-
- v := &Repo{}
- v.ID = v0
- v.UserID = v1
- v.Owner = v2
- v.Name = v3
- v.FullName = v4
- v.Avatar = v5
- v.Self = v6
- v.Link = v7
- v.Clone = v8
- v.Branch = v9
- v.Private = v10
- v.Trusted = v11
- v.Timeout = v12
- v.Keys = &Keypair{}
- v.Keys.Public = v13
- v.Keys.Private = v14
- v.Hooks = &Hooks{}
- v.Hooks.PullRequest = v15
- v.Hooks.Push = v16
- v.Hooks.Tags = v17
- json.Unmarshal(v18, &v.Params)
- v.Hash = v19
-
- return v, nil
-}
-
-func scanRepos(rows *sql.Rows) ([]*Repo, error) {
- var err error
- var vv []*Repo
- for rows.Next() {
- var v0 int64
- var v1 int64
- var v2 string
- var v3 string
- var v4 string
- var v5 string
- var v6 string
- var v7 string
- var v8 string
- var v9 string
- var v10 bool
- var v11 bool
- var v12 int64
- var v13 string
- var v14 string
- var v15 bool
- var v16 bool
- var v17 bool
- var v18 []byte
- var v19 string
- err = rows.Scan(
- &v0,
- &v1,
- &v2,
- &v3,
- &v4,
- &v5,
- &v6,
- &v7,
- &v8,
- &v9,
- &v10,
- &v11,
- &v12,
- &v13,
- &v14,
- &v15,
- &v16,
- &v17,
- &v18,
- &v19,
- )
- if err != nil {
- return vv, err
- }
-
- v := &Repo{}
- v.ID = v0
- v.UserID = v1
- v.Owner = v2
- v.Name = v3
- v.FullName = v4
- v.Avatar = v5
- v.Self = v6
- v.Link = v7
- v.Clone = v8
- v.Branch = v9
- v.Private = v10
- v.Trusted = v11
- v.Timeout = v12
- v.Keys = &Keypair{}
- v.Keys.Public = v13
- v.Keys.Private = v14
- v.Hooks = &Hooks{}
- v.Hooks.PullRequest = v15
- v.Hooks.Push = v16
- v.Hooks.Tags = v17
- json.Unmarshal(v18, &v.Params)
- v.Hash = v19
- vv = append(vv, v)
- }
- return vv, rows.Err()
-}
-
-const stmtRepoSelectList = `
-SELECT
- repo_id
-,repo_user_id
-,repo_owner
-,repo_name
-,repo_full_name
-,repo_avatar
-,repo_self
-,repo_link
-,repo_clone
-,repo_branch
-,repo_private
-,repo_trusted
-,repo_timeout
-,repo_keys_public
-,repo_keys_private
-,repo_hooks_pull_request
-,repo_hooks_push
-,repo_hooks_tags
-,repo_params
-,repo_hash
-FROM repos
-`
-
-const stmtRepoSelectRange = `
-SELECT
- repo_id
-,repo_user_id
-,repo_owner
-,repo_name
-,repo_full_name
-,repo_avatar
-,repo_self
-,repo_link
-,repo_clone
-,repo_branch
-,repo_private
-,repo_trusted
-,repo_timeout
-,repo_keys_public
-,repo_keys_private
-,repo_hooks_pull_request
-,repo_hooks_push
-,repo_hooks_tags
-,repo_params
-,repo_hash
-FROM repos
-LIMIT ? OFFSET ?
-`
-
-const stmtRepoSelect = `
-SELECT
- repo_id
-,repo_user_id
-,repo_owner
-,repo_name
-,repo_full_name
-,repo_avatar
-,repo_self
-,repo_link
-,repo_clone
-,repo_branch
-,repo_private
-,repo_trusted
-,repo_timeout
-,repo_keys_public
-,repo_keys_private
-,repo_hooks_pull_request
-,repo_hooks_push
-,repo_hooks_tags
-,repo_params
-,repo_hash
-FROM repos
-WHERE repo_id = ?
-`
-
-const stmtRepoSelectRepoFullName = `
-SELECT
- repo_id
-,repo_user_id
-,repo_owner
-,repo_name
-,repo_full_name
-,repo_avatar
-,repo_self
-,repo_link
-,repo_clone
-,repo_branch
-,repo_private
-,repo_trusted
-,repo_timeout
-,repo_keys_public
-,repo_keys_private
-,repo_hooks_pull_request
-,repo_hooks_push
-,repo_hooks_tags
-,repo_params
-,repo_hash
-FROM repos
-WHERE repo_full_name = ?
-`
-
-const stmtRepoSelectRepoUserId = `
-SELECT
- repo_id
-,repo_user_id
-,repo_owner
-,repo_name
-,repo_full_name
-,repo_avatar
-,repo_self
-,repo_link
-,repo_clone
-,repo_branch
-,repo_private
-,repo_trusted
-,repo_timeout
-,repo_keys_public
-,repo_keys_private
-,repo_hooks_pull_request
-,repo_hooks_push
-,repo_hooks_tags
-,repo_params
-,repo_hash
-FROM repos
-WHERE repo_user_id = ?
-`
-
-const stmtRepoSelectRepoOwnerName = `
-SELECT
- repo_id
-,repo_user_id
-,repo_owner
-,repo_name
-,repo_full_name
-,repo_avatar
-,repo_self
-,repo_link
-,repo_clone
-,repo_branch
-,repo_private
-,repo_trusted
-,repo_timeout
-,repo_keys_public
-,repo_keys_private
-,repo_hooks_pull_request
-,repo_hooks_push
-,repo_hooks_tags
-,repo_params
-,repo_hash
-FROM repos
-WHERE repo_owner = ?
-AND repo_name = ?
-`
-
-const stmtRepoSelectCount = `
-SELECT count(1)
-FROM repos
-`
-
-const stmtRepoInsert = `
-INSERT INTO repos (
- repo_user_id
-,repo_owner
-,repo_name
-,repo_full_name
-,repo_avatar
-,repo_self
-,repo_link
-,repo_clone
-,repo_branch
-,repo_private
-,repo_trusted
-,repo_timeout
-,repo_keys_public
-,repo_keys_private
-,repo_hooks_pull_request
-,repo_hooks_push
-,repo_hooks_tags
-,repo_params
-,repo_hash
-) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);
-`
-
-const stmtRepoUpdate = `
-UPDATE repos SET
- repo_user_id = ?
-,repo_owner = ?
-,repo_name = ?
-,repo_full_name = ?
-,repo_avatar = ?
-,repo_self = ?
-,repo_link = ?
-,repo_clone = ?
-,repo_branch = ?
-,repo_private = ?
-,repo_trusted = ?
-,repo_timeout = ?
-,repo_keys_public = ?
-,repo_keys_private = ?
-,repo_hooks_pull_request = ?
-,repo_hooks_push = ?
-,repo_hooks_tags = ?
-,repo_params = ?
-,repo_hash = ?
-WHERE repo_id = ?
-`
-
-const stmtRepoDelete = `
-DELETE FROM repos
-WHERE repo_id = ?
-`
-
-const stmtRepoTable = `
-CREATE TABLE IF NOT EXISTS repos (
- repo_id INTEGER PRIMARY KEY AUTOINCREMENT
-,repo_user_id INTEGER
-,repo_owner VARCHAR
-,repo_name VARCHAR
-,repo_full_name VARCHAR
-,repo_avatar VARCHAR
-,repo_self VARCHAR
-,repo_link VARCHAR
-,repo_clone VARCHAR
-,repo_branch VARCHAR
-,repo_private BOOLEAN
-,repo_trusted BOOLEAN
-,repo_timeout INTEGER
-,repo_keys_public VARCHAR
-,repo_keys_private VARCHAR
-,repo_hooks_pull_request BOOLEAN
-,repo_hooks_push BOOLEAN
-,repo_hooks_tags BOOLEAN
-,repo_params BLOB
-,repo_hash VARCHAR
-);
-`
-
-const stmtRepoRepoFullNameIndex = `
-CREATE UNIQUE INDEX IF NOT EXISTS ux_repo_full_name ON repos (repo_full_name);
-`
-
-const stmtRepoRepoUserIdIndex = `
-CREATE INDEX IF NOT EXISTS ix_repo_user_id ON repos (repo_user_id);
-`
-
-const stmtRepoRepoOwnerNameIndex = `
-CREATE UNIQUE INDEX IF NOT EXISTS ux_repo_owner_name ON repos (repo_owner,repo_name);
-`
diff --git a/pkg/store/builtin/repo_test.go b/pkg/store/builtin/repo_test.go
deleted file mode 100644
index 7c9210c1b..000000000
--- a/pkg/store/builtin/repo_test.go
+++ /dev/null
@@ -1,137 +0,0 @@
-package builtin
-
-import (
- "testing"
-
- "github.com/drone/drone/Godeps/_workspace/src/github.com/franela/goblin"
- "github.com/drone/drone/pkg/types"
-)
-
-func TestRepostore(t *testing.T) {
- db := mustConnectTest()
- rs := NewRepostore(db)
- ss := NewStarstore(db)
- defer db.Close()
-
- g := goblin.Goblin(t)
- g.Describe("Repostore", func() {
-
- // before each test be sure to purge the package
- // table data from the database.
- g.BeforeEach(func() {
- db.Exec("DELETE FROM stars")
- db.Exec("DELETE FROM repos")
- db.Exec("DELETE FROM users")
- })
-
- g.It("Should Set a Repo", func() {
- repo := types.Repo{
- UserID: 1,
- Owner: "bradrydzewski",
- Name: "drone",
- }
- err1 := rs.AddRepo(&repo)
- err2 := rs.SetRepo(&repo)
- getrepo, err3 := rs.Repo(repo.ID)
- g.Assert(err1 == nil).IsTrue()
- g.Assert(err2 == nil).IsTrue()
- g.Assert(err3 == nil).IsTrue()
- g.Assert(repo.ID).Equal(getrepo.ID)
- })
-
- g.It("Should Add a Repo", func() {
- repo := types.Repo{
- UserID: 1,
- Owner: "bradrydzewski",
- Name: "drone",
- }
- err := rs.AddRepo(&repo)
- g.Assert(err == nil).IsTrue()
- g.Assert(repo.ID != 0).IsTrue()
- })
-
- g.It("Should Get a Repo by ID", func() {
- repo := types.Repo{
- UserID: 1,
- Owner: "bradrydzewski",
- Name: "drone",
- }
- rs.AddRepo(&repo)
- getrepo, err := rs.Repo(repo.ID)
- g.Assert(err == nil).IsTrue()
- g.Assert(repo.ID).Equal(getrepo.ID)
- g.Assert(repo.UserID).Equal(getrepo.UserID)
- g.Assert(repo.Owner).Equal(getrepo.Owner)
- g.Assert(repo.Name).Equal(getrepo.Name)
- })
-
- g.It("Should Get a Repo by Name", func() {
- repo := types.Repo{
- UserID: 1,
- Owner: "bradrydzewski",
- Name: "drone",
- }
- rs.AddRepo(&repo)
- getrepo, err := rs.RepoName(repo.Owner, repo.Name)
- g.Assert(err == nil).IsTrue()
- g.Assert(repo.ID).Equal(getrepo.ID)
- g.Assert(repo.UserID).Equal(getrepo.UserID)
- g.Assert(repo.Owner).Equal(getrepo.Owner)
- g.Assert(repo.Name).Equal(getrepo.Name)
- })
-
- g.It("Should Get a Repo List by User", func() {
- repo1 := types.Repo{
- UserID: 1,
- Owner: "bradrydzewski",
- Name: "drone",
- }
- repo2 := types.Repo{
- UserID: 1,
- Owner: "bradrydzewski",
- Name: "drone-dart",
- }
- rs.AddRepo(&repo1)
- rs.AddRepo(&repo2)
- ss.AddStar(&types.User{ID: 1}, &repo1)
- repos, err := rs.RepoList(&types.User{ID: 1})
- g.Assert(err == nil).IsTrue()
- g.Assert(len(repos)).Equal(1)
- g.Assert(repos[0].UserID).Equal(repo1.UserID)
- g.Assert(repos[0].Owner).Equal(repo1.Owner)
- g.Assert(repos[0].Name).Equal(repo1.Name)
- })
-
- g.It("Should Delete a Repo", func() {
- repo := types.Repo{
- UserID: 1,
- Owner: "bradrydzewski",
- Name: "drone",
- }
- rs.AddRepo(&repo)
- _, err1 := rs.Repo(repo.ID)
- err2 := rs.DelRepo(&repo)
- _, err3 := rs.Repo(repo.ID)
- g.Assert(err1 == nil).IsTrue()
- g.Assert(err2 == nil).IsTrue()
- g.Assert(err3 == nil).IsFalse()
- })
-
- g.It("Should Enforce Unique Repo Name", func() {
- repo1 := types.Repo{
- UserID: 1,
- Owner: "bradrydzewski",
- Name: "drone",
- }
- repo2 := types.Repo{
- UserID: 2,
- Owner: "bradrydzewski",
- Name: "drone",
- }
- err1 := rs.AddRepo(&repo1)
- err2 := rs.AddRepo(&repo2)
- g.Assert(err1 == nil).IsTrue()
- g.Assert(err2 == nil).IsFalse()
- })
- })
-}
diff --git a/pkg/store/builtin/star.go b/pkg/store/builtin/star.go
deleted file mode 100644
index f01afab95..000000000
--- a/pkg/store/builtin/star.go
+++ /dev/null
@@ -1,47 +0,0 @@
-package builtin
-
-import (
- "database/sql"
-
- "github.com/drone/drone/pkg/types"
-)
-
-type Starstore struct {
- *sql.DB
-}
-
-func NewStarstore(db *sql.DB) *Starstore {
- return &Starstore{db}
-}
-
-// Starred returns true if the user starred
-// the given repository.
-func (db *Starstore) Starred(user *types.User, repo *types.Repo) (bool, error) {
- _, err := getStar(db, rebind(stmtStarSelectStarUserRepo), user.ID, repo.ID)
- return (err == nil), err
-}
-
-// AddStar inserts a starred repo / user in the datastore.
-func (db *Starstore) AddStar(user *types.User, repo *types.Repo) error {
- var star = &Star{UserID: user.ID, RepoID: repo.ID}
- return createStar(db, rebind(stmtStarInsert), star)
-}
-
-// DelStar removes starred repo / user from the datastore.
-func (db *Starstore) DelStar(user *types.User, repo *types.Repo) error {
- var _, err = db.Exec(rebind(stmtStartDeleteUserRepo), user.ID, repo.ID)
- return err
-}
-
-type Star struct {
- ID int64
- UserID int64 `sql:"unique:ux_star_user_repo"`
- RepoID int64 `sql:"unique:ux_star_user_repo"`
-}
-
-// SQL statement to delete a star by ID.
-const stmtStartDeleteUserRepo = `
-DELETE FROM stars
-WHERE star_user_id=?
- AND star_repo_id=?
-`
diff --git a/pkg/store/builtin/star_sql.go b/pkg/store/builtin/star_sql.go
deleted file mode 100644
index 979bb20bc..000000000
--- a/pkg/store/builtin/star_sql.go
+++ /dev/null
@@ -1,185 +0,0 @@
-package builtin
-
-// DO NOT EDIT
-// code generated by go:generate
-
-import (
- "database/sql"
- "encoding/json"
-)
-
-var _ = json.Marshal
-
-// generic database interface, matching both *sql.Db and *sql.Tx
-type starDB interface {
- Exec(query string, args ...interface{}) (sql.Result, error)
- Query(query string, args ...interface{}) (*sql.Rows, error)
- QueryRow(query string, args ...interface{}) *sql.Row
-}
-
-func getStar(db starDB, query string, args ...interface{}) (*Star, error) {
- row := db.QueryRow(query, args...)
- return scanStar(row)
-}
-
-func getStars(db starDB, query string, args ...interface{}) ([]*Star, error) {
- rows, err := db.Query(query, args...)
- if err != nil {
- return nil, err
- }
- defer rows.Close()
- return scanStars(rows)
-}
-
-func createStar(db starDB, query string, v *Star) error {
- var v0 int64
- var v1 int64
- v0 = v.UserID
- v1 = v.RepoID
-
- res, err := db.Exec(query,
- &v0,
- &v1,
- )
- if err != nil {
- return err
- }
-
- v.ID, err = res.LastInsertId()
- return err
-}
-
-func updateStar(db starDB, query string, v *Star) error {
- var v0 int64
- var v1 int64
- var v2 int64
- v0 = v.ID
- v1 = v.UserID
- v2 = v.RepoID
-
- _, err := db.Exec(query,
- &v1,
- &v2,
- &v0,
- )
- return err
-}
-
-func scanStar(row *sql.Row) (*Star, error) {
- var v0 int64
- var v1 int64
- var v2 int64
-
- err := row.Scan(
- &v0,
- &v1,
- &v2,
- )
- if err != nil {
- return nil, err
- }
-
- v := &Star{}
- v.ID = v0
- v.UserID = v1
- v.RepoID = v2
-
- return v, nil
-}
-
-func scanStars(rows *sql.Rows) ([]*Star, error) {
- var err error
- var vv []*Star
- for rows.Next() {
- var v0 int64
- var v1 int64
- var v2 int64
- err = rows.Scan(
- &v0,
- &v1,
- &v2,
- )
- if err != nil {
- return vv, err
- }
-
- v := &Star{}
- v.ID = v0
- v.UserID = v1
- v.RepoID = v2
- vv = append(vv, v)
- }
- return vv, rows.Err()
-}
-
-const stmtStarSelectList = `
-SELECT
- star_id
-,star_user_id
-,star_repo_id
-FROM stars
-`
-
-const stmtStarSelectRange = `
-SELECT
- star_id
-,star_user_id
-,star_repo_id
-FROM stars
-LIMIT ? OFFSET ?
-`
-
-const stmtStarSelect = `
-SELECT
- star_id
-,star_user_id
-,star_repo_id
-FROM stars
-WHERE star_id = ?
-`
-
-const stmtStarSelectStarUserRepo = `
-SELECT
- star_id
-,star_user_id
-,star_repo_id
-FROM stars
-WHERE star_user_id = ?
-AND star_repo_id = ?
-`
-
-const stmtStarSelectCount = `
-SELECT count(1)
-FROM stars
-`
-
-const stmtStarInsert = `
-INSERT INTO stars (
- star_user_id
-,star_repo_id
-) VALUES (?,?);
-`
-
-const stmtStarUpdate = `
-UPDATE stars SET
- star_user_id = ?
-,star_repo_id = ?
-WHERE star_id = ?
-`
-
-const stmtStarDelete = `
-DELETE FROM stars
-WHERE star_id = ?
-`
-
-const stmtStarTable = `
-CREATE TABLE IF NOT EXISTS stars (
- star_id INTEGER PRIMARY KEY AUTOINCREMENT
-,star_user_id INTEGER
-,star_repo_id INTEGER
-);
-`
-
-const stmtStarStarUserRepoIndex = `
-CREATE UNIQUE INDEX IF NOT EXISTS ux_star_user_repo ON stars (star_user_id,star_repo_id);
-`
diff --git a/pkg/store/builtin/star_test.go b/pkg/store/builtin/star_test.go
deleted file mode 100644
index 9cbc17988..000000000
--- a/pkg/store/builtin/star_test.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package builtin
-
-import (
- "testing"
-
- "github.com/drone/drone/Godeps/_workspace/src/github.com/franela/goblin"
- "github.com/drone/drone/pkg/types"
-)
-
-func TestStarstore(t *testing.T) {
- db := mustConnectTest()
- ss := NewStarstore(db)
- defer db.Close()
-
- g := goblin.Goblin(t)
- g.Describe("Starstore", func() {
-
- // before each test be sure to purge the package
- // table data from the database.
- g.BeforeEach(func() {
- db.Exec("DELETE FROM stars")
- })
-
- g.It("Should Add a Star", func() {
- user := types.User{ID: 1}
- repo := types.Repo{ID: 2}
- err := ss.AddStar(&user, &repo)
- g.Assert(err == nil).IsTrue()
- })
-
- g.It("Should Get Starred", func() {
- user := types.User{ID: 1}
- repo := types.Repo{ID: 2}
- ss.AddStar(&user, &repo)
- ok, err := ss.Starred(&user, &repo)
- g.Assert(err == nil).IsTrue()
- g.Assert(ok).IsTrue()
- })
-
- g.It("Should Not Get Starred", func() {
- user := types.User{ID: 1}
- repo := types.Repo{ID: 2}
- ok, err := ss.Starred(&user, &repo)
- g.Assert(err != nil).IsTrue()
- g.Assert(ok).IsFalse()
- })
-
- g.It("Should Del a Star", func() {
- user := types.User{ID: 1}
- repo := types.Repo{ID: 2}
- ss.AddStar(&user, &repo)
- _, err1 := ss.Starred(&user, &repo)
- err2 := ss.DelStar(&user, &repo)
- _, err3 := ss.Starred(&user, &repo)
- g.Assert(err1 == nil).IsTrue()
- g.Assert(err2 == nil).IsTrue()
- g.Assert(err3 == nil).IsFalse()
- })
- })
-}
diff --git a/pkg/store/builtin/store.go b/pkg/store/builtin/store.go
deleted file mode 100644
index 4e6b43f89..000000000
--- a/pkg/store/builtin/store.go
+++ /dev/null
@@ -1,107 +0,0 @@
-package builtin
-
-import (
- "database/sql"
- "os"
-
- "github.com/drone/drone/pkg/store"
- "github.com/drone/drone/pkg/store/builtin/migrate"
-
- "github.com/drone/drone/Godeps/_workspace/src/github.com/BurntSushi/migration"
- _ "github.com/drone/drone/Godeps/_workspace/src/github.com/go-sql-driver/mysql"
- _ "github.com/drone/drone/Godeps/_workspace/src/github.com/lib/pq"
- _ "github.com/drone/drone/Godeps/_workspace/src/github.com/mattn/go-sqlite3"
- "github.com/drone/drone/Godeps/_workspace/src/github.com/russross/meddler"
-)
-
-const (
- driverPostgres = "postgres"
- driverSqlite = "sqlite3"
- driverMysql = "mysql"
-)
-
-func init() {
- store.Register("sqlite3", NewDriver)
- store.Register("postgres", NewDriver)
- store.Register("mysql", NewDriver)
-}
-
-func NewDriver(driver, datasource string) (store.Store, error) {
- conn, err := Connect(driver, datasource)
- if err != nil {
- return nil, err
- }
- return New(conn), nil
-}
-
-// Connect is a helper function that establishes a new
-// database connection and auto-generates the database
-// schema. If the database already exists, it will perform
-// and update as needed.
-func Connect(driver, datasource string) (*sql.DB, error) {
- switch driver {
- case driverPostgres:
- meddler.Default = meddler.PostgreSQL
- case driverSqlite:
- meddler.Default = meddler.SQLite
- }
-
- migration.DefaultGetVersion = migrate.GetVersion
- migration.DefaultSetVersion = migrate.SetVersion
- var migrations = []migration.Migrator{
- migrate.Setup,
- }
- return migration.Open(driver, datasource, migrations)
-}
-
-// MustConnect is a helper function that creates a
-// new database connection and auto-generates the
-// database schema. An error causes a panic.
-func MustConnect(driver, datasource string) *sql.DB {
- db, err := Connect(driver, datasource)
- if err != nil {
- panic(err)
- }
- return db
-}
-
-// mustConnectTest is a helper function that creates a
-// new database connection using environment variables.
-// If not environment varaibles are found, the default
-// in-memory SQLite database is used.
-func mustConnectTest() *sql.DB {
- var (
- driver = os.Getenv("TEST_DRIVER")
- datasource = os.Getenv("TEST_DATASOURCE")
- )
- if len(driver) == 0 {
- driver = driverSqlite
- datasource = ":memory:"
- }
- db, err := Connect(driver, datasource)
- if err != nil {
- panic(err)
- }
- return db
-}
-
-// New returns a new Datastore
-func New(db *sql.DB) store.Store {
- return struct {
- *Userstore
- *Repostore
- *Buildstore
- *Jobstore
- *Blobstore
- *Starstore
- *Agentstore
- }{
- NewUserstore(db),
- NewRepostore(db),
- NewBuildstore(db),
- NewJobstore(db),
- NewBlobstore(db),
- NewStarstore(db),
- NewAgentstore(db),
- }
-}
diff --git a/pkg/store/builtin/user.go b/pkg/store/builtin/user.go
deleted file mode 100644
index 261477ce1..000000000
--- a/pkg/store/builtin/user.go
+++ /dev/null
@@ -1,111 +0,0 @@
-package builtin
-
-import (
- "database/sql"
-
- "github.com/drone/drone/pkg/types"
-)
-
-type Userstore struct {
- *sql.DB
-}
-
-func NewUserstore(db *sql.DB) *Userstore {
- return &Userstore{db}
-}
-
-// User returns a user by user ID.
-func (db *Userstore) User(id int64) (*types.User, error) {
- return getUser(db, rebind(stmtUserSelect), id)
-}
-
-// UserLogin returns a user by user login.
-func (db *Userstore) UserLogin(login string) (*types.User, error) {
- return getUser(db, rebind(stmtUserSelectUserLogin), login)
-}
-
-// UserList returns a list of all registered users.
-func (db *Userstore) UserList() ([]*types.User, error) {
- return getUsers(db, rebind(stmtUserSelectList))
-}
-
-// UserFeed retrieves a digest of recent builds
-// from the datastore accessible to the specified user.
-func (db *Userstore) UserFeed(user *types.User, limit, offset int) ([]*types.RepoCommit, error) {
- rows, err := db.Query(rebind(userFeedQuery), user.ID, limit, offset)
- if err != nil {
- return nil, err
- }
- defer rows.Close()
- return scanRepoCommits(rows)
-}
-
-// UserCount returns a count of all registered users.
-func (db *Userstore) UserCount() (int, error) {
- var count int
- err := db.QueryRow(stmtUserSelectCount).Scan(&count)
- return count, err
-}
-
-// AddUser inserts a new user into the datastore.
-// If the user login already exists an error is returned.
-func (db *Userstore) AddUser(user *types.User) error {
- return createUser(db, rebind(stmtUserInsert), user)
-}
-
-// SetUser updates an existing user.
-func (db *Userstore) SetUser(user *types.User) error {
- return updateUser(db, rebind(stmtUserUpdate), user)
-}
-
-// DelUser removes the user from the datastore.
-func (db *Userstore) DelUser(user *types.User) error {
- var _, err = db.Exec(rebind(stmtUserDelete), user.ID)
- return err
-}
-
-// SQL query to retrieve a build feed for the given
-// user account.
-const userFeedQuery = `
-SELECT
- r.repo_id
-,r.repo_owner
-,r.repo_name
-,r.repo_full_name
-,b.build_number
-,b.build_status
-,b.build_started
-,b.build_finished
-FROM
- builds b
-,repos r
-,stars s
-WHERE b.build_repo_id = r.repo_id
- AND r.repo_id = s.star_repo_id
- AND s.star_user_id = ?
-ORDER BY b.build_number DESC
-LIMIT ? OFFSET ?
-`
-
-func scanRepoCommits(rows *sql.Rows) ([]*types.RepoCommit, error) {
- var err error
- var vv []*types.RepoCommit
- for rows.Next() {
- v := &types.RepoCommit{}
- err = rows.Scan(
- &v.ID,
- &v.Owner,
- &v.Name,
- &v.FullName,
- &v.Number,
- &v.Status,
- &v.Started,
- &v.Finished,
- )
- if err != nil {
- return vv, err
- }
- vv = append(vv, v)
- }
- return vv, rows.Err()
-}
diff --git a/pkg/store/builtin/user_sql.go b/pkg/store/builtin/user_sql.go
deleted file mode 100644
index 2f0bbf594..000000000
--- a/pkg/store/builtin/user_sql.go
+++ /dev/null
@@ -1,300 +0,0 @@
-package builtin
-
-// DO NOT EDIT
-// code generated by go:generate
-
-import (
- "database/sql"
- "encoding/json"
-
- . "github.com/drone/drone/pkg/types"
-)
-
-var _ = json.Marshal
-
-// generic database interface, matching both *sql.Db and *sql.Tx
-type userDB interface {
- Exec(query string, args ...interface{}) (sql.Result, error)
- Query(query string, args ...interface{}) (*sql.Rows, error)
- QueryRow(query string, args ...interface{}) *sql.Row
-}
-
-func getUser(db userDB, query string, args ...interface{}) (*User, error) {
- row := db.QueryRow(query, args...)
- return scanUser(row)
-}
-
-func getUsers(db userDB, query string, args ...interface{}) ([]*User, error) {
- rows, err := db.Query(query, args...)
- if err != nil {
- return nil, err
- }
- defer rows.Close()
- return scanUsers(rows)
-}
-
-func createUser(db userDB, query string, v *User) error {
- var v0 string
- var v1 string
- var v2 string
- var v3 string
- var v4 string
- var v5 bool
- var v6 bool
- var v7 string
- v0 = v.Login
- v1 = v.Token
- v2 = v.Secret
- v3 = v.Email
- v4 = v.Avatar
- v5 = v.Active
- v6 = v.Admin
- v7 = v.Hash
-
- res, err := db.Exec(query,
- &v0,
- &v1,
- &v2,
- &v3,
- &v4,
- &v5,
- &v6,
- &v7,
- )
- if err != nil {
- return err
- }
-
- v.ID, err = res.LastInsertId()
- return err
-}
-
-func updateUser(db userDB, query string, v *User) error {
- var v0 int64
- var v1 string
- var v2 string
- var v3 string
- var v4 string
- var v5 string
- var v6 bool
- var v7 bool
- var v8 string
- v0 = v.ID
- v1 = v.Login
- v2 = v.Token
- v3 = v.Secret
- v4 = v.Email
- v5 = v.Avatar
- v6 = v.Active
- v7 = v.Admin
- v8 = v.Hash
-
- _, err := db.Exec(query,
- &v1,
- &v2,
- &v3,
- &v4,
- &v5,
- &v6,
- &v7,
- &v8,
- &v0,
- )
- return err
-}
-
-func scanUser(row *sql.Row) (*User, error) {
- var v0 int64
- var v1 string
- var v2 string
- var v3 string
- var v4 string
- var v5 string
- var v6 bool
- var v7 bool
- var v8 string
-
- err := row.Scan(
- &v0,
- &v1,
- &v2,
- &v3,
- &v4,
- &v5,
- &v6,
- &v7,
- &v8,
- )
- if err != nil {
- return nil, err
- }
-
- v := &User{}
- v.ID = v0
- v.Login = v1
- v.Token = v2
- v.Secret = v3
- v.Email = v4
- v.Avatar = v5
- v.Active = v6
- v.Admin = v7
- v.Hash = v8
-
- return v, nil
-}
-
-func scanUsers(rows *sql.Rows) ([]*User, error) {
- var err error
- var vv []*User
- for rows.Next() {
- var v0 int64
- var v1 string
- var v2 string
- var v3 string
- var v4 string
- var v5 string
- var v6 bool
- var v7 bool
- var v8 string
- err = rows.Scan(
- &v0,
- &v1,
- &v2,
- &v3,
- &v4,
- &v5,
- &v6,
- &v7,
- &v8,
- )
- if err != nil {
- return vv, err
- }
-
- v := &User{}
- v.ID = v0
- v.Login = v1
- v.Token = v2
- v.Secret = v3
- v.Email = v4
- v.Avatar = v5
- v.Active = v6
- v.Admin = v7
- v.Hash = v8
- vv = append(vv, v)
- }
- return vv, rows.Err()
-}
-
-const stmtUserSelectList = `
-SELECT
- user_id
-,user_login
-,user_token
-,user_secret
-,user_email
-,user_avatar
-,user_active
-,user_admin
-,user_hash
-FROM users
-`
-
-const stmtUserSelectRange = `
-SELECT
- user_id
-,user_login
-,user_token
-,user_secret
-,user_email
-,user_avatar
-,user_active
-,user_admin
-,user_hash
-FROM users
-LIMIT ? OFFSET ?
-`
-
-const stmtUserSelect = `
-SELECT
- user_id
-,user_login
-,user_token
-,user_secret
-,user_email
-,user_avatar
-,user_active
-,user_admin
-,user_hash
-FROM users
-WHERE user_id = ?
-`
-
-const stmtUserSelectUserLogin = `
-SELECT
- user_id
-,user_login
-,user_token
-,user_secret
-,user_email
-,user_avatar
-,user_active
-,user_admin
-,user_hash
-FROM users
-WHERE user_login = ?
-`
-
-const stmtUserSelectCount = `
-SELECT count(1)
-FROM users
-`
-
-const stmtUserInsert = `
-INSERT INTO users (
- user_login
-,user_token
-,user_secret
-,user_email
-,user_avatar
-,user_active
-,user_admin
-,user_hash
-) VALUES (?,?,?,?,?,?,?,?);
-`
-
-const stmtUserUpdate = `
-UPDATE users SET
- user_login = ?
-,user_token = ?
-,user_secret = ?
-,user_email = ?
-,user_avatar = ?
-,user_active = ?
-,user_admin = ?
-,user_hash = ?
-WHERE user_id = ?
-`
-
-const stmtUserDelete = `
-DELETE FROM users
-WHERE user_id = ?
-`
-
-const stmtUserTable = `
-CREATE TABLE IF NOT EXISTS users (
- user_id INTEGER PRIMARY KEY AUTOINCREMENT
-,user_login VARCHAR
-,user_token VARCHAR
-,user_secret VARCHAR
-,user_email VARCHAR
-,user_avatar VARCHAR
-,user_active BOOLEAN
-,user_admin BOOLEAN
-,user_hash VARCHAR
-);
-`
-
-const stmtUserUserLoginIndex = `
-CREATE UNIQUE INDEX IF NOT EXISTS ux_user_login ON users (user_login);
-`
diff --git a/pkg/store/builtin/users_test.go b/pkg/store/builtin/users_test.go
deleted file mode 100644
index f5a90eeed..000000000
--- a/pkg/store/builtin/users_test.go
+++ /dev/null
@@ -1,211 +0,0 @@
-package builtin
-
-import (
- "testing"
-
- "github.com/drone/drone/Godeps/_workspace/src/github.com/franela/goblin"
- "github.com/drone/drone/pkg/types"
-)
-
-func TestUserstore(t *testing.T) {
- db := mustConnectTest()
- us := NewUserstore(db)
- cs := NewBuildstore(db)
- rs := NewRepostore(db)
- ss := NewStarstore(db)
- defer db.Close()
-
- g := goblin.Goblin(t)
- g.Describe("Userstore", func() {
-
- // before each test be sure to purge the package
- // table data from the database.
- g.BeforeEach(func() {
- db.Exec("DELETE FROM users")
- db.Exec("DELETE FROM stars")
- db.Exec("DELETE FROM repos")
- db.Exec("DELETE FROM builds")
- db.Exec("DELETE FROM jobs")
- })
-
- g.It("Should Update a User", func() {
- user := types.User{
- Login: "joe",
- Email: "foo@bar.com",
- Token: "e42080dddf012c718e476da161d21ad5",
- }
- err1 := us.AddUser(&user)
- err2 := us.SetUser(&user)
- getuser, err3 := us.User(user.ID)
- g.Assert(err1 == nil).IsTrue()
- g.Assert(err2 == nil).IsTrue()
- g.Assert(err3 == nil).IsTrue()
- g.Assert(user.ID).Equal(getuser.ID)
- })
-
- g.It("Should Add a new User", func() {
- user := types.User{
- Login: "joe",
- Email: "foo@bar.com",
- Token: "e42080dddf012c718e476da161d21ad5",
- }
- err := us.AddUser(&user)
- g.Assert(err == nil).IsTrue()
- g.Assert(user.ID != 0).IsTrue()
- })
-
- g.It("Should Get a User", func() {
- user := types.User{
- Login: "joe",
- Token: "f0b461ca586c27872b43a0685cbc2847",
- Secret: "976f22a5eef7caacb7e678d6c52f49b1",
- Email: "foo@bar.com",
- Avatar: "b9015b0857e16ac4d94a0ffd9a0b79c8",
- Active: true,
- Admin: true,
- }
- us.AddUser(&user)
- getuser, err := us.User(user.ID)
- g.Assert(err == nil).IsTrue()
- g.Assert(user.ID).Equal(getuser.ID)
- g.Assert(user.Login).Equal(getuser.Login)
- g.Assert(user.Token).Equal(getuser.Token)
- g.Assert(user.Secret).Equal(getuser.Secret)
- g.Assert(user.Email).Equal(getuser.Email)
- g.Assert(user.Avatar).Equal(getuser.Avatar)
- g.Assert(user.Active).Equal(getuser.Active)
- g.Assert(user.Admin).Equal(getuser.Admin)
- })
-
- g.It("Should Get a User By Login", func() {
- user := types.User{
- Login: "joe",
- Email: "foo@bar.com",
- Token: "e42080dddf012c718e476da161d21ad5",
- }
- us.AddUser(&user)
- getuser, err := us.UserLogin(user.Login)
- g.Assert(err == nil).IsTrue()
- g.Assert(user.ID).Equal(getuser.ID)
- g.Assert(user.Login).Equal(getuser.Login)
- })
-
- g.It("Should Enforce Unique User Login", func() {
- user1 := types.User{
- Login: "joe",
- Email: "foo@bar.com",
- Token: "e42080dddf012c718e476da161d21ad5",
- }
- user2 := types.User{
- Login: "joe",
- Email: "foo@bar.com",
- Token: "ab20g0ddaf012c744e136da16aa21ad9",
- }
- err1 := us.AddUser(&user1)
- err2 := us.AddUser(&user2)
- g.Assert(err1 == nil).IsTrue()
- g.Assert(err2 == nil).IsFalse()
- })
-
- g.It("Should Get a User List", func() {
- user1 := types.User{
- Login: "jane",
- Email: "foo@bar.com",
- Token: "ab20g0ddaf012c744e136da16aa21ad9",
- }
- user2 := types.User{
- Login: "joe",
- Email: "foo@bar.com",
- Token: "e42080dddf012c718e476da161d21ad5",
- }
- us.AddUser(&user1)
- us.AddUser(&user2)
- users, err := us.UserList()
- g.Assert(err == nil).IsTrue()
- g.Assert(len(users)).Equal(2)
- g.Assert(users[0].Login).Equal(user1.Login)
- g.Assert(users[0].Email).Equal(user1.Email)
- g.Assert(users[0].Token).Equal(user1.Token)
- })
-
- g.It("Should Get a User Count", func() {
- user1 := types.User{
- Login: "jane",
- Email: "foo@bar.com",
- Token: "ab20g0ddaf012c744e136da16aa21ad9",
- }
- user2 := types.User{
- Login: "joe",
- Email: "foo@bar.com",
- Token: "e42080dddf012c718e476da161d21ad5",
- }
- us.AddUser(&user1)
- us.AddUser(&user2)
- count, err := us.UserCount()
- g.Assert(err == nil).IsTrue()
- g.Assert(count).Equal(2)
- })
-
- g.It("Should Get a User Count Zero", func() {
- count, err := us.UserCount()
- g.Assert(err == nil).IsTrue()
- g.Assert(count).Equal(0)
- })
-
- g.It("Should Del a User", func() {
- user := types.User{
- Login: "joe",
- Email: "foo@bar.com",
- Token: "e42080dddf012c718e476da161d21ad5",
- }
- us.AddUser(&user)
- _, err1 := us.User(user.ID)
- err2 := us.DelUser(&user)
- _, err3 := us.User(user.ID)
- g.Assert(err1 == nil).IsTrue()
- g.Assert(err2 == nil).IsTrue()
- g.Assert(err3 == nil).IsFalse()
- })
-
- g.It("Should get the Build feed for a User", func() {
- repo1 := &types.Repo{
- UserID: 1,
- Owner: "bradrydzewski",
- Name: "drone",
- FullName: "bradrydzewski/drone",
- }
- repo2 := &types.Repo{
- UserID: 2,
- Owner: "drone",
- Name: "drone",
- FullName: "drone/drone",
- }
- rs.AddRepo(repo1)
- rs.AddRepo(repo2)
- ss.AddStar(&types.User{ID: 1}, repo1)
-
- build1 := &types.Build{
- RepoID: repo1.ID,
- Status: types.StateFailure,
- }
- build2 := &types.Build{
- RepoID: repo1.ID,
- Status: types.StateSuccess,
- }
- build3 := &types.Build{
- RepoID: repo2.ID,
- Status: types.StateSuccess,
- }
- cs.AddBuild(build1)
- cs.AddBuild(build2)
- cs.AddBuild(build3)
-
- builds, err := us.UserFeed(&types.User{ID: 1}, 20, 0)
- g.Assert(err == nil).IsTrue()
- g.Assert(len(builds)).Equal(2)
- //g.Assert(builds[0].Status).Equal(commit2.Status)
- g.Assert(builds[0].Owner).Equal("bradrydzewski")
- g.Assert(builds[0].Name).Equal("drone")
- })
- })
-}
diff --git a/pkg/store/builtin/util.go b/pkg/store/builtin/util.go
deleted file mode 100644
index 3d475cf9a..000000000
--- a/pkg/store/builtin/util.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package builtin
-
-import (
- "strconv"
-
- "github.com/drone/drone/Godeps/_workspace/src/github.com/russross/meddler"
-)
-
-// rebind is a helper function that changes the sql
-// bind type from ? to $ for postgres queries.
-func rebind(query string) string {
- if meddler.Default != meddler.PostgreSQL {
- return query
- }
-
- qb := []byte(query)
- // Add space enough for 5 params before we have to allocate
- rqb := make([]byte, 0, len(qb)+5)
- j := 1
- for _, b := range qb {
- if b == '?' {
- rqb = append(rqb, '$')
- for _, b := range strconv.Itoa(j) {
- rqb = append(rqb, byte(b))
- }
- j++
- } else {
- rqb = append(rqb, b)
- }
- }
- return string(rqb)
-}
diff --git a/pkg/store/mock/mock.go b/pkg/store/mock/mock.go
deleted file mode 100644
index b2952dcf3..000000000
--- a/pkg/store/mock/mock.go
+++ /dev/null
@@ -1,344 +0,0 @@
-package mocks
-
-import (
- "io"
-
- "github.com/drone/drone/Godeps/_workspace/src/github.com/stretchr/testify/mock"
- "github.com/drone/drone/pkg/types"
-)
-
-type Store struct {
- mock.Mock
-}
-
-func (m *Store) User(id int64) (*types.User, error) {
- ret := m.Called(id)
-
- var r0 *types.User
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*types.User)
- }
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) UserLogin(_a0 string) (*types.User, error) {
- ret := m.Called(_a0)
-
- var r0 *types.User
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*types.User)
- }
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) UserList() ([]*types.User, error) {
- ret := m.Called()
-
- var r0 []*types.User
- if ret.Get(0) != nil {
- r0 = ret.Get(0).([]*types.User)
- }
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) UserFeed(_a0 *types.User, _a1 int, _a2 int) ([]*types.RepoCommit, error) {
- ret := m.Called(_a0, _a1, _a2)
-
- var r0 []*types.RepoCommit
- if ret.Get(0) != nil {
- r0 = ret.Get(0).([]*types.RepoCommit)
- }
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) UserCount() (int, error) {
- ret := m.Called()
-
- r0 := ret.Get(0).(int)
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) AddUser(_a0 *types.User) error {
- ret := m.Called(_a0)
-
- r0 := ret.Error(0)
-
- return r0
-}
-func (m *Store) SetUser(_a0 *types.User) error {
- ret := m.Called(_a0)
-
- r0 := ret.Error(0)
-
- return r0
-}
-func (m *Store) DelUser(_a0 *types.User) error {
- ret := m.Called(_a0)
-
- r0 := ret.Error(0)
-
- return r0
-}
-func (m *Store) Starred(_a0 *types.User, _a1 *types.Repo) (bool, error) {
- ret := m.Called(_a0, _a1)
-
- r0 := ret.Get(0).(bool)
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) AddStar(_a0 *types.User, _a1 *types.Repo) error {
- ret := m.Called(_a0, _a1)
-
- r0 := ret.Error(0)
-
- return r0
-}
-func (m *Store) DelStar(_a0 *types.User, _a1 *types.Repo) error {
- ret := m.Called(_a0, _a1)
-
- r0 := ret.Error(0)
-
- return r0
-}
-func (m *Store) Repo(id int64) (*types.Repo, error) {
- ret := m.Called(id)
-
- var r0 *types.Repo
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*types.Repo)
- }
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) RepoName(owner string, name string) (*types.Repo, error) {
- ret := m.Called(owner, name)
-
- var r0 *types.Repo
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*types.Repo)
- }
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) RepoList(_a0 *types.User) ([]*types.Repo, error) {
- ret := m.Called(_a0)
-
- var r0 []*types.Repo
- if ret.Get(0) != nil {
- r0 = ret.Get(0).([]*types.Repo)
- }
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) AddRepo(_a0 *types.Repo) error {
- ret := m.Called(_a0)
-
- r0 := ret.Error(0)
-
- return r0
-}
-func (m *Store) SetRepo(_a0 *types.Repo) error {
- ret := m.Called(_a0)
-
- r0 := ret.Error(0)
-
- return r0
-}
-func (m *Store) DelRepo(_a0 *types.Repo) error {
- ret := m.Called(_a0)
-
- r0 := ret.Error(0)
-
- return r0
-}
-func (m *Store) Build(_a0 int64) (*types.Build, error) {
- ret := m.Called(_a0)
-
- var r0 *types.Build
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*types.Build)
- }
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) BuildNumber(_a0 *types.Repo, _a1 int) (*types.Build, error) {
- ret := m.Called(_a0, _a1)
-
- var r0 *types.Build
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*types.Build)
- }
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) BuildPullRequestNumber(_a0 *types.Repo, _a1 int) (*types.Build, error) {
- ret := m.Called(_a0, _a1)
-
- var r0 *types.Build
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*types.Build)
- }
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) BuildSha(_a0 *types.Repo, _a1, _a2 string) (*types.Build, error) {
- ret := m.Called(_a0, _a1, _a2)
-
- var r0 *types.Build
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*types.Build)
- }
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) BuildLast(_a0 *types.Repo, _a1 string) (*types.Build, error) {
- ret := m.Called(_a0, _a1)
-
- var r0 *types.Build
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*types.Build)
- }
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) BuildList(_a0 *types.Repo, _a1 int, _a2 int) ([]*types.Build, error) {
- ret := m.Called(_a0, _a1, _a2)
-
- var r0 []*types.Build
- if ret.Get(0) != nil {
- r0 = ret.Get(0).([]*types.Build)
- }
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) AddBuild(_a0 *types.Build) error {
- ret := m.Called(_a0)
-
- r0 := ret.Error(0)
-
- return r0
-}
-func (m *Store) SetBuild(_a0 *types.Build) error {
- ret := m.Called(_a0)
-
- r0 := ret.Error(0)
-
- return r0
-}
-func (m *Store) KillBuilds() error {
- ret := m.Called()
-
- r0 := ret.Error(0)
-
- return r0
-}
-func (m *Store) Job(_a0 int64) (*types.Job, error) {
- ret := m.Called(_a0)
-
- var r0 *types.Job
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*types.Job)
- }
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) JobNumber(_a0 *types.Build, _a1 int) (*types.Job, error) {
- ret := m.Called(_a0, _a1)
-
- var r0 *types.Job
- if ret.Get(0) != nil {
- r0 = ret.Get(0).(*types.Job)
- }
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) JobList(_a0 *types.Build) ([]*types.Job, error) {
- ret := m.Called(_a0)
-
- var r0 []*types.Job
- if ret.Get(0) != nil {
- r0 = ret.Get(0).([]*types.Job)
- }
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) SetJob(_a0 *types.Job) error {
- ret := m.Called(_a0)
-
- r0 := ret.Error(0)
-
- return r0
-}
-func (m *Store) GetBlob(path string) ([]byte, error) {
- ret := m.Called(path)
-
- var r0 []byte
- if ret.Get(0) != nil {
- r0 = ret.Get(0).([]byte)
- }
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) GetBlobReader(path string) (io.ReadCloser, error) {
- ret := m.Called(path)
-
- r0 := ret.Get(0).(io.ReadCloser)
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) SetBlob(path string, data []byte) error {
- ret := m.Called(path, data)
-
- r0 := ret.Error(0)
-
- return r0
-}
-func (m *Store) SetBlobReader(path string, r io.Reader) error {
- ret := m.Called(path, r)
-
- r0 := ret.Error(0)
-
- return r0
-}
-func (m *Store) DelBlob(path string) error {
- ret := m.Called(path)
-
- r0 := ret.Error(0)
-
- return r0
-}
-func (m *Store) Agent(_a0 *types.Build) (string, error) {
- ret := m.Called(_a0)
-
- r0 := ret.Get(0).(string)
- r1 := ret.Error(1)
-
- return r0, r1
-}
-func (m *Store) SetAgent(_a0 *types.Build, _a1 string) error {
- ret := m.Called(_a0, _a1)
-
- r0 := ret.Error(0)
-
- return r0
-}
diff --git a/pkg/store/store.go b/pkg/store/store.go
deleted file mode 100644
index 1b3c545e0..000000000
--- a/pkg/store/store.go
+++ /dev/null
@@ -1,182 +0,0 @@
-package store
-
-import (
- "io"
-
- "github.com/drone/drone/pkg/types"
-
- log "github.com/drone/drone/Godeps/_workspace/src/github.com/Sirupsen/logrus"
-)
-
-var drivers = make(map[string]DriverFunc)
-
-// Register makes a datastore driver available by the provided name.
-// If Register is called twice with the same name or if driver is nil,
-// it panics.
-func Register(name string, driver DriverFunc) {
- if driver == nil {
- panic("datastore: Register driver is nil")
- }
- if _, dup := drivers[name]; dup {
- panic("datastore: Register called twice for driver " + name)
- }
- drivers[name] = driver
-}
-
-// DriverFunc returns a new connection to the datastore.
-// The name is a string in a driver-specific format.
-type DriverFunc func(driver, datasource string) (Store, error)
-
-// New creates a new database connection specified by its database driver
-// name and a driver-specific data source name, usually consisting of at
-// least a database name and connection information.
-func New(driver, datasource string) (Store, error) {
- fn, ok := drivers[driver]
- if !ok {
- log.Fatalf("datastore: unknown driver %q", driver)
- }
- log.Infof("datastore: loading driver %s", driver)
- log.Infof("datastore: loading config %s", datasource)
- return fn(driver, datasource)
-}
-
-type Store interface {
-
- // User returns a user by user ID.
- User(id int64) (*types.User, error)
-
- // UserLogin returns a user by user login.
- UserLogin(string) (*types.User, error)
-
- // UserList returns a list of all registered users.
- UserList() ([]*types.User, error)
-
- // UserFeed retrieves a digest of recent builds
- // from the datastore accessible to the specified user.
- UserFeed(*types.User, int, int) ([]*types.RepoCommit, error)
-
- // UserCount returns a count of all registered users.
- UserCount() (int, error)
-
- // AddUser inserts a new user into the datastore.
- // If the user login already exists an error is returned.
- AddUser(*types.User) error
-
- // SetUser updates an existing user.
- SetUser(*types.User) error
-
- // DelUser removes the user from the datastore.
- DelUser(*types.User) error
-
- //
-
- // Starred returns true if the user starred
- // the given repository.
- Starred(*types.User, *types.Repo) (bool, error)
-
- // AddStar stars a repository.
- AddStar(*types.User, *types.Repo) error
-
- // DelStar unstars a repository.
- DelStar(*types.User, *types.Repo) error
-
- //
-
- // Repo retrieves a specific repo from the
- // datastore for the given ID.
- Repo(id int64) (*types.Repo, error)
-
- // RepoName retrieves a repo from the datastore
- // for the specified name.
- RepoName(owner, name string) (*types.Repo, error)
-
- // RepoList retrieves a list of all repos from
- // the datastore accessible by the given user ID.
- RepoList(*types.User) ([]*types.Repo, error)
-
- // AddRepo inserts a repo in the datastore.
- AddRepo(*types.Repo) error
-
- // SetRepo updates a repo in the datastore.
- SetRepo(*types.Repo) error
-
- // DelRepo removes the repo from the datastore.
- DelRepo(*types.Repo) error
-
- //
-
- // Build gets a build by ID
- Build(int64) (*types.Build, error)
-
- // BuildNumber gets the specified build number for the
- // named repository and build number
- BuildNumber(*types.Repo, int) (*types.Build, error)
-
- // BuildPullRequestNumber gets the specified build number for the
- // named repository and build number
- BuildPullRequestNumber(*types.Repo, int) (*types.Build, error)
-
- // BuildSha gets the specified build number for the
- // named repository and sha
- BuildSha(*types.Repo, string, string) (*types.Build, error)
-
- // BuildLast gets the last executed build for the
- // named repository and branch
- BuildLast(*types.Repo, string) (*types.Build, error)
-
- // BuildList gets a list of recent builds for the
- // named repository.
- BuildList(*types.Repo, int, int) ([]*types.Build, error)
-
- // AddBuild inserts a new build in the datastore.
- AddBuild(*types.Build) error
-
- // SetBuild updates an existing build and build jobs.
- SetBuild(*types.Build) error
-
- // KillBuilds updates all pending or started builds
- // in the datastore settings the status to killed.
- KillBuilds() error
-
- //
-
- // Build returns a build by ID.
- Job(int64) (*types.Job, error)
-
- // JobNumber returns a jobs by sequence number.
- JobNumber(*types.Build, int) (*types.Job, error)
-
- // JobList returns a list of all build jobs
- JobList(*types.Build) ([]*types.Job, error)
-
- // SetJob updates an existing job.
- SetJob(*types.Job) error
-
- //
-
- // Get retrieves an object from the blobstore.
- GetBlob(path string) ([]byte, error)
-
- // GetBlobReader retrieves an object from the blobstore.
- // It is the caller's responsibility to call Close on
- // the ReadCloser when finished reading.
- GetBlobReader(path string) (io.ReadCloser, error)
-
- // Set inserts an object into the blobstore.
- SetBlob(path string, data []byte) error
-
- // SetBlobReader inserts an object into the blobstore by
- // consuming data from r until EOF.
- SetBlobReader(path string, r io.Reader) error
-
- // Del removes an object from the blobstore.
- DelBlob(path string) error
-
- //
-
- // Agent returns an agent by ID.
- Agent(*types.Build) (string, error)
-
- // SetAgent updates an agent in the datastore.
- SetAgent(*types.Build, string) error
-}
diff --git a/pkg/remote/builtin/github/github.go b/remote/github/github/github.go
similarity index 100%
rename from pkg/remote/builtin/github/github.go
rename to remote/github/github/github.go
diff --git a/pkg/remote/builtin/github/helper.go b/remote/github/github/helper.go
similarity index 100%
rename from pkg/remote/builtin/github/helper.go
rename to remote/github/github/helper.go
diff --git a/pkg/remote/builtin/gitlab/gitlab.go b/remote/gitlab/gitlab/gitlab.go
similarity index 100%
rename from pkg/remote/builtin/gitlab/gitlab.go
rename to remote/gitlab/gitlab/gitlab.go
diff --git a/pkg/remote/builtin/gitlab/gitlab_test.go b/remote/gitlab/gitlab/gitlab_test.go
similarity index 100%
rename from pkg/remote/builtin/gitlab/gitlab_test.go
rename to remote/gitlab/gitlab/gitlab_test.go
diff --git a/pkg/remote/builtin/gitlab/helper.go b/remote/gitlab/gitlab/helper.go
similarity index 100%
rename from pkg/remote/builtin/gitlab/helper.go
rename to remote/gitlab/gitlab/helper.go
diff --git a/pkg/remote/builtin/gitlab/testdata/hooks.go b/remote/gitlab/gitlab/testdata/hooks.go
similarity index 100%
rename from pkg/remote/builtin/gitlab/testdata/hooks.go
rename to remote/gitlab/gitlab/testdata/hooks.go
diff --git a/pkg/remote/builtin/gitlab/testdata/oauth.go b/remote/gitlab/gitlab/testdata/oauth.go
similarity index 100%
rename from pkg/remote/builtin/gitlab/testdata/oauth.go
rename to remote/gitlab/gitlab/testdata/oauth.go
diff --git a/pkg/remote/builtin/gitlab/testdata/projects.go b/remote/gitlab/gitlab/testdata/projects.go
similarity index 100%
rename from pkg/remote/builtin/gitlab/testdata/projects.go
rename to remote/gitlab/gitlab/testdata/projects.go
diff --git a/pkg/remote/builtin/gitlab/testdata/testdata.go b/remote/gitlab/gitlab/testdata/testdata.go
similarity index 100%
rename from pkg/remote/builtin/gitlab/testdata/testdata.go
rename to remote/gitlab/gitlab/testdata/testdata.go
diff --git a/pkg/remote/builtin/gitlab/testdata/users.go b/remote/gitlab/gitlab/testdata/users.go
similarity index 100%
rename from pkg/remote/builtin/gitlab/testdata/users.go
rename to remote/gitlab/gitlab/testdata/users.go
diff --git a/pkg/remote/remote.go b/remote/remote.go
similarity index 100%
rename from pkg/remote/remote.go
rename to remote/remote.go
diff --git a/pkg/ccmenu/ccmenu.go b/shared/ccmenu/ccmenu.go
similarity index 100%
rename from pkg/ccmenu/ccmenu.go
rename to shared/ccmenu/ccmenu.go
diff --git a/pkg/utils/sshutil/sshutil.go b/shared/crypto/sshutil/sshutil.go
similarity index 100%
rename from pkg/utils/sshutil/sshutil.go
rename to shared/crypto/sshutil/sshutil.go
diff --git a/pkg/utils/sshutil/sshutil_test.go b/shared/crypto/sshutil/sshutil_test.go
similarity index 100%
rename from pkg/utils/sshutil/sshutil_test.go
rename to shared/crypto/sshutil/sshutil_test.go
diff --git a/pkg/docker/copy.go b/shared/docker/copy.go
similarity index 100%
rename from pkg/docker/copy.go
rename to shared/docker/copy.go
diff --git a/pkg/utils/httputil/httputil.go b/shared/httputil/httputil.go
similarity index 100%
rename from pkg/utils/httputil/httputil.go
rename to shared/httputil/httputil.go
diff --git a/pkg/token/token.go b/shared/token/token.go
similarity index 100%
rename from pkg/token/token.go
rename to shared/token/token.go
diff --git a/pkg/token/token_test.go b/shared/token/token_test.go
similarity index 100%
rename from pkg/token/token_test.go
rename to shared/token/token_test.go
diff --git a/pkg/yaml/matrix/matrix.go b/yaml/matrix/matrix.go
similarity index 100%
rename from pkg/yaml/matrix/matrix.go
rename to yaml/matrix/matrix.go
diff --git a/pkg/yaml/matrix/matrix_test.go b/yaml/matrix/matrix_test.go
similarity index 100%
rename from pkg/yaml/matrix/matrix_test.go
rename to yaml/matrix/matrix_test.go
diff --git a/pkg/yaml/parse.go b/yaml/parse.go
similarity index 100%
rename from pkg/yaml/parse.go
rename to yaml/parse.go
diff --git a/pkg/yaml/secure/secure.go b/yaml/secure/secure.go
similarity index 100%
rename from pkg/yaml/secure/secure.go
rename to yaml/secure/secure.go
diff --git a/pkg/yaml/secure/secure_test.go b/yaml/secure/secure_test.go
similarity index 100%
rename from pkg/yaml/secure/secure_test.go
rename to yaml/secure/secure_test.go