prepping for new drone-exec build agent
This commit is contained in:
parent
091b213300
commit
98a6c14331
14 changed files with 197 additions and 103 deletions
|
@ -10,16 +10,16 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Context struct {
|
type Context struct {
|
||||||
// Links *common.Link
|
System *common.System `json:"system"`
|
||||||
Clone *common.Clone `json:"clone"`
|
Repo *common.Repo `json:"repo"`
|
||||||
Repo *common.Repo `json:"repo"`
|
Build *common.Build `json:"build"`
|
||||||
Build *common.Build `json:"build"`
|
Job *common.Job `json:"job"`
|
||||||
Job *common.Job `json:"job"`
|
Yaml []byte `json:"yaml"`
|
||||||
Keys *common.Keypair `json:"keys"`
|
|
||||||
Netrc *common.Netrc `json:"netrc"`
|
// todo re-factor these
|
||||||
Yaml []byte `json:"yaml"`
|
Clone *common.Clone `json:"clone"`
|
||||||
Env []string `json:"environment"`
|
Keys *common.Keypair `json:"keys"`
|
||||||
Plugins []string `json:"plugins"`
|
Netrc *common.Netrc `json:"netrc"`
|
||||||
|
|
||||||
Conf *common.Config `json:"-"`
|
Conf *common.Config `json:"-"`
|
||||||
infos []*dockerclient.ContainerInfo
|
infos []*dockerclient.ContainerInfo
|
||||||
|
@ -33,7 +33,7 @@ func setup(c *Context) error {
|
||||||
Privileged: false,
|
Privileged: false,
|
||||||
Volumes: false,
|
Volumes: false,
|
||||||
Caching: false,
|
Caching: false,
|
||||||
Whitelist: c.Plugins,
|
Whitelist: c.System.Plugins,
|
||||||
}
|
}
|
||||||
|
|
||||||
// if repository is trusted the build may specify
|
// if repository is trusted the build may specify
|
||||||
|
@ -154,7 +154,7 @@ func runSteps(c *Context, steps map[string]*common.Step) (int, error) {
|
||||||
conf.Cmd = toCommand(c, step)
|
conf.Cmd = toCommand(c, step)
|
||||||
|
|
||||||
// append global environment variables
|
// append global environment variables
|
||||||
conf.Env = append(conf.Env, c.Env...)
|
conf.Env = append(conf.Env, c.System.Globals...)
|
||||||
|
|
||||||
info, err := run(c.client, conf, step.Pull)
|
info, err := run(c.client, conf, step.Pull)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -117,6 +117,16 @@
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
$scope.encrypt = function (plaintext) {
|
||||||
|
var data = {"DATA": plaintext};
|
||||||
|
repos.encrypt(fullName, data).then(function (payload) {
|
||||||
|
$scope.secure = payload.data["DATA"];
|
||||||
|
}).catch(function (err) {
|
||||||
|
$scope.error = err;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.deleteParam = function (key) {
|
$scope.deleteParam = function (key) {
|
||||||
delete $scope.repo.params[key];
|
delete $scope.repo.params[key];
|
||||||
|
|
||||||
|
@ -129,6 +139,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toSnakeCase(str) {
|
||||||
|
return str.replace(/ /g, '_').replace(/([a-z0-9])([A-Z0-9])/g, '$1_$2').toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
angular
|
angular
|
||||||
.module('drone')
|
.module('drone')
|
||||||
.controller('ReposCtrl', ReposCtrl)
|
.controller('ReposCtrl', ReposCtrl)
|
||||||
|
|
|
@ -144,23 +144,53 @@
|
||||||
},
|
},
|
||||||
title: 'Edit Repository'
|
title: 'Edit Repository'
|
||||||
})
|
})
|
||||||
.state('app.repo.env', {
|
.state('app.repo_del', {
|
||||||
url: '/:owner/:name/edit/env',
|
|
||||||
views: {
|
|
||||||
'toolbar': {templateUrl: '/static/scripts/views/repos/toolbar.html'},
|
|
||||||
'content': {templateUrl: '/static/scripts/views/repos/env.html'}
|
|
||||||
},
|
|
||||||
controller: 'RepoEditCtrl',
|
|
||||||
resolve: resolveUser
|
|
||||||
})
|
|
||||||
.state('app.repo.del', {
|
|
||||||
url: '/:owner/:name/delete',
|
url: '/:owner/:name/delete',
|
||||||
views: {
|
views: {
|
||||||
'toolbar': {templateUrl: '/static/scripts/views/repos/toolbar.html'},
|
'toolbar': {
|
||||||
'content': {templateUrl: '/static/scripts/views/repos/del.html'}
|
templateUrl: '/static/scripts/views/repos/toolbar.html',
|
||||||
|
controller: 'UserHeaderCtrl',
|
||||||
|
resolve: resolveUser
|
||||||
|
},
|
||||||
|
'content': {
|
||||||
|
templateUrl: '/static/scripts/views/repos/del.html',
|
||||||
|
controller: 'RepoEditCtrl',
|
||||||
|
resolve: resolveUser
|
||||||
|
}
|
||||||
},
|
},
|
||||||
controller: 'RepoEditCtrl',
|
title: 'Delete Repository'
|
||||||
resolve: resolveUser
|
})
|
||||||
|
.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', {
|
.state('app.build', {
|
||||||
url: '/:owner/:name/:number',
|
url: '/:owner/:name/:number',
|
||||||
|
|
|
@ -73,6 +73,15 @@
|
||||||
return $http.delete('/api/repos/' + repoName + '/unwatch');
|
return $http.delete('/api/repos/' + repoName + '/unwatch');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encrypt the set of parameters.
|
||||||
|
*
|
||||||
|
* @param {string} Name of the repository.
|
||||||
|
* @param {object} Key/Value map of parameters.
|
||||||
|
*/
|
||||||
|
this.encrypt = function (repoName, params) {
|
||||||
|
return $http.post('/api/repos/' + repoName + '/encrypt', params);
|
||||||
|
};
|
||||||
|
|
||||||
var callback,
|
var callback,
|
||||||
events,
|
events,
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
<main>
|
||||||
<article>
|
<article>
|
||||||
|
|
||||||
|
|
||||||
<section style="padding:30px; background-color:#EF5350;">
|
<section style="padding:30px; background-color:#bf616a;">
|
||||||
<button ng-click="delete(repo.full_name)" style="color:rgba(255,255,255,0.9);
|
<button ng-click="delete(repo.full_name)" style="color:rgba(255,255,255,0.9);
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
@ -14,4 +15,5 @@ margin-right: 10px;">Delete</button>
|
||||||
<span style="color:rgba(255,255,255,0.9);font-size:16px;">Warning: this action cannot be undone.</span>
|
<span style="color:rgba(255,255,255,0.9);font-size:16px;">Warning: this action cannot be undone.</span>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
</article>
|
</article>
|
||||||
|
</main>
|
28
cmd/drone-server/static/scripts/views/repos/secure.html
Normal file
28
cmd/drone-server/static/scripts/views/repos/secure.html
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<main>
|
||||||
|
<article>
|
||||||
|
|
||||||
|
<p style=" font-size: 16px;
|
||||||
|
margin-bottom: 10px;">Encrypt and store secret variables in your <code>.drone.yml</code> file<p>
|
||||||
|
<textarea spellcheck="false" placeholder="Enter a plaintext value here" ng-model="plaintext" style="
|
||||||
|
background-color: #eff1f5;
|
||||||
|
border-radius:3px;
|
||||||
|
border:none;
|
||||||
|
padding:10px;
|
||||||
|
min-height:100px;
|
||||||
|
max-width:100%;
|
||||||
|
display:block;
|
||||||
|
min-width:100%;
|
||||||
|
white-space: normal;
|
||||||
|
font-size: 14px;
|
||||||
|
word-wrap: normal;
|
||||||
|
word-break: break-all;"></textarea>
|
||||||
|
<button ng-click="encrypt(plaintext)">Encrypt</button>
|
||||||
|
|
||||||
|
|
||||||
|
<pre ng-if="secure" style=" white-space: normal;
|
||||||
|
font-size: 16px;
|
||||||
|
word-wrap: normal;
|
||||||
|
word-break: break-all;">{{secure}}</pre>
|
||||||
|
|
||||||
|
</article>
|
||||||
|
</main>
|
|
@ -9,14 +9,13 @@ import (
|
||||||
// Work represents an item for work to be
|
// Work represents an item for work to be
|
||||||
// processed by a worker.
|
// processed by a worker.
|
||||||
type Work struct {
|
type Work struct {
|
||||||
User *common.User `json:"user"`
|
System *common.System `json:"system"`
|
||||||
Repo *common.Repo `json:"repo"`
|
User *common.User `json:"user"`
|
||||||
Build *common.Build `json:"build"`
|
Repo *common.Repo `json:"repo"`
|
||||||
Keys *common.Keypair `json:"keypair"`
|
Build *common.Build `json:"build"`
|
||||||
Netrc *common.Netrc `json:"netrc"`
|
Keys *common.Keypair `json:"keypair"`
|
||||||
Yaml []byte `json:"yaml"`
|
Netrc *common.Netrc `json:"netrc"`
|
||||||
Env []string `json:"environment"`
|
Yaml []byte `json:"yaml"`
|
||||||
Plugins []string `json:"plugins"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// represents a worker that has connected
|
// represents a worker that has connected
|
||||||
|
|
|
@ -139,14 +139,12 @@ func (r *Runner) Run(w *queue.Work) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
work := &work{
|
work := &work{
|
||||||
Repo: w.Repo,
|
System: w.System,
|
||||||
Build: w.Build,
|
Workspace: &types.Workspace{Netrc: w.Netrc, Keys: w.Keys},
|
||||||
Keys: w.Keys,
|
Repo: w.Repo,
|
||||||
Netrc: w.Netrc,
|
Build: w.Build,
|
||||||
Yaml: w.Yaml,
|
Job: job,
|
||||||
Job: job,
|
Yaml: w.Yaml,
|
||||||
Env: w.Env,
|
|
||||||
Plugins: w.Plugins,
|
|
||||||
}
|
}
|
||||||
in, err := json.Marshal(work)
|
in, err := json.Marshal(work)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -221,14 +219,12 @@ func (r *Runner) Run(w *queue.Work) error {
|
||||||
// the destroy all containers afterward.
|
// the destroy all containers afterward.
|
||||||
for i, job := range w.Build.Jobs {
|
for i, job := range w.Build.Jobs {
|
||||||
work := &work{
|
work := &work{
|
||||||
Repo: w.Repo,
|
System: w.System,
|
||||||
Build: w.Build,
|
Workspace: &types.Workspace{Netrc: w.Netrc, Keys: w.Keys},
|
||||||
Keys: w.Keys,
|
Repo: w.Repo,
|
||||||
Netrc: w.Netrc,
|
Build: w.Build,
|
||||||
Yaml: w.Yaml,
|
Job: job,
|
||||||
Job: job,
|
Yaml: w.Yaml,
|
||||||
Env: w.Env,
|
|
||||||
Plugins: w.Plugins,
|
|
||||||
}
|
}
|
||||||
in, err := json.Marshal(work)
|
in, err := json.Marshal(work)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -29,30 +29,33 @@ var (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// name of the build agent container.
|
// name of the build agent container.
|
||||||
DefaultAgent = "drone/drone-build:latest"
|
DefaultAgent = "drone/drone-exec:latest"
|
||||||
|
|
||||||
// default name of the build agent executable
|
// default name of the build agent executable
|
||||||
DefaultEntrypoint = []string{"/bin/drone-build"}
|
DefaultEntrypoint = []string{"/bin/drone-build"}
|
||||||
|
|
||||||
// default argument to invoke build steps
|
// default argument to invoke build steps
|
||||||
DefaultBuildArgs = []string{"--build", "--clone", "--publish", "--deploy"}
|
DefaultBuildArgs = []string{"--cache", "--clone", "--build", "--deploy"}
|
||||||
|
|
||||||
// default argument to invoke build steps
|
// default argument to invoke build steps
|
||||||
DefaultPullRequestArgs = []string{"--build", "--clone"}
|
DefaultPullRequestArgs = []string{"--cache", "--clone", "--build"}
|
||||||
|
|
||||||
// default arguments to invoke notify steps
|
// default arguments to invoke notify steps
|
||||||
DefaultNotifyArgs = []string{"--notify"}
|
DefaultNotifyArgs = []string{"--notify"}
|
||||||
)
|
)
|
||||||
|
|
||||||
type work struct {
|
type work struct {
|
||||||
Repo *types.Repo `json:"repo"`
|
Repo *types.Repo `json:"repo"`
|
||||||
Build *types.Build `json:"build"`
|
Build *types.Build `json:"build"`
|
||||||
Job *types.Job `json:"job"`
|
Job *types.Job `json:"job"`
|
||||||
Keys *types.Keypair `json:"keys"`
|
System *types.System `json:"system"`
|
||||||
Netrc *types.Netrc `json:"netrc"`
|
Workspace *types.Workspace `json:"workspace"`
|
||||||
Yaml []byte `json:"yaml"`
|
Yaml []byte `json:"yaml"`
|
||||||
Env []string `json:"environment"`
|
|
||||||
Plugins []string `json:"plugins"`
|
// Keys *types.Keypair `json:"keys"` // remove
|
||||||
|
// Netrc *types.Netrc `json:"netrc"` // remove
|
||||||
|
// Env []string `json:"environment"` // remove
|
||||||
|
// Plugins []string `json:"plugins"` // remove
|
||||||
}
|
}
|
||||||
|
|
||||||
type worker struct {
|
type worker struct {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/drone/drone/Godeps/_workspace/src/github.com/gin-gonic/gin"
|
"github.com/drone/drone/Godeps/_workspace/src/github.com/gin-gonic/gin"
|
||||||
"github.com/drone/drone/pkg/queue"
|
"github.com/drone/drone/pkg/queue"
|
||||||
common "github.com/drone/drone/pkg/types"
|
common "github.com/drone/drone/pkg/types"
|
||||||
|
"github.com/drone/drone/pkg/utils/httputil"
|
||||||
"github.com/drone/drone/pkg/yaml/inject"
|
"github.com/drone/drone/pkg/yaml/inject"
|
||||||
"github.com/drone/drone/pkg/yaml/secure"
|
"github.com/drone/drone/pkg/yaml/secure"
|
||||||
// "github.com/gin-gonic/gin/binding"
|
// "github.com/gin-gonic/gin/binding"
|
||||||
|
@ -191,14 +192,17 @@ func RunBuild(c *gin.Context) {
|
||||||
c.JSON(202, build)
|
c.JSON(202, build)
|
||||||
|
|
||||||
queue_.Publish(&queue.Work{
|
queue_.Publish(&queue.Work{
|
||||||
User: user,
|
User: user,
|
||||||
Repo: repo,
|
Repo: repo,
|
||||||
Build: build,
|
Build: build,
|
||||||
Keys: repo.Keys,
|
Keys: repo.Keys,
|
||||||
Netrc: netrc,
|
Netrc: netrc,
|
||||||
Yaml: raw,
|
Yaml: raw,
|
||||||
Plugins: conf.Plugins,
|
System: &common.System{
|
||||||
Env: conf.Environment,
|
Link: httputil.GetURL(c.Request),
|
||||||
|
Plugins: conf.Plugins,
|
||||||
|
Globals: conf.Environment,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/drone/drone/Godeps/_workspace/src/github.com/gin-gonic/gin"
|
"github.com/drone/drone/Godeps/_workspace/src/github.com/gin-gonic/gin"
|
||||||
"github.com/drone/drone/pkg/queue"
|
"github.com/drone/drone/pkg/queue"
|
||||||
common "github.com/drone/drone/pkg/types"
|
common "github.com/drone/drone/pkg/types"
|
||||||
|
"github.com/drone/drone/pkg/utils/httputil"
|
||||||
"github.com/drone/drone/pkg/yaml"
|
"github.com/drone/drone/pkg/yaml"
|
||||||
"github.com/drone/drone/pkg/yaml/inject"
|
"github.com/drone/drone/pkg/yaml/inject"
|
||||||
"github.com/drone/drone/pkg/yaml/matrix"
|
"github.com/drone/drone/pkg/yaml/matrix"
|
||||||
|
@ -158,13 +159,16 @@ func PostHook(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
queue_.Publish(&queue.Work{
|
queue_.Publish(&queue.Work{
|
||||||
User: user,
|
User: user,
|
||||||
Repo: repo,
|
Repo: repo,
|
||||||
Build: build,
|
Build: build,
|
||||||
Keys: repo.Keys,
|
Keys: repo.Keys,
|
||||||
Netrc: netrc,
|
Netrc: netrc,
|
||||||
Yaml: raw,
|
Yaml: raw,
|
||||||
Plugins: conf.Plugins,
|
System: &common.System{
|
||||||
Env: conf.Environment,
|
Link: httputil.GetURL(c.Request),
|
||||||
|
Plugins: conf.Plugins,
|
||||||
|
Globals: conf.Environment,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
package types
|
|
||||||
|
|
||||||
type Clone struct {
|
|
||||||
Origin string `json:"origin"`
|
|
||||||
Remote string `json:"remote"`
|
|
||||||
Branch string `json:"branch"`
|
|
||||||
Sha string `json:"sha"`
|
|
||||||
Ref string `json:"ref"`
|
|
||||||
Dir string `json:"dir"`
|
|
||||||
Netrc *Netrc `json:"netrc"`
|
|
||||||
Keypair *Keypair `json:"keypair"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Netrc struct {
|
|
||||||
Machine string `json:"machine"`
|
|
||||||
Login string `json:"login"`
|
|
||||||
Password string `json:"user"`
|
|
||||||
}
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
// Config represents a repository build configuration.
|
// Config represents a repository build configuration.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
Cache *Step
|
||||||
Setup *Step
|
Setup *Step
|
||||||
Clone *Step
|
Clone *Step
|
||||||
Build *Step
|
Build *Step
|
||||||
|
@ -63,8 +64,11 @@ type Step struct {
|
||||||
// Condition represents a set of conditions that must
|
// Condition represents a set of conditions that must
|
||||||
// be met in order to proceed with a build or build step.
|
// be met in order to proceed with a build or build step.
|
||||||
type Condition struct {
|
type Condition struct {
|
||||||
Owner string // Indicates the step should run only for this repo (useful for forks)
|
Owner string // Indicates the step should run only for this repo (useful for forks)
|
||||||
Branch string // Indicates the step should run only for this branch
|
Branch string // Indicates the step should run only for this branch
|
||||||
|
Event string
|
||||||
|
Success string
|
||||||
|
Failure string
|
||||||
|
|
||||||
// Indicates the step should only run when the following
|
// Indicates the step should only run when the following
|
||||||
// matrix values are present for the sub-build.
|
// matrix values are present for the sub-build.
|
||||||
|
|
|
@ -1,8 +1,27 @@
|
||||||
package types
|
package types
|
||||||
|
|
||||||
|
// System provides important information about the Drone
|
||||||
|
// server to the plugin.
|
||||||
type System struct {
|
type System struct {
|
||||||
URL string // System URL
|
Version string `json:"version"`
|
||||||
Env map[string]string // Global environment variables
|
Link string `json:"link_url"`
|
||||||
Builder string // Name of build container (default drone/drone-build)
|
Plugins []string `json:"plugins"`
|
||||||
Plugins string // Name of approved plugin containers (default plugins/*)
|
Globals []string `json:"globals"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Workspace defines the build's workspace inside the
|
||||||
|
// container. This helps the plugin locate the source
|
||||||
|
// code directory.
|
||||||
|
type Workspace struct {
|
||||||
|
Root string `json:"root"`
|
||||||
|
Path string `json:"path"`
|
||||||
|
|
||||||
|
Netrc *Netrc `json:"netrc"`
|
||||||
|
Keys *Keypair `json:"keys"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Netrc struct {
|
||||||
|
Machine string `json:"machine"`
|
||||||
|
Login string `json:"login"`
|
||||||
|
Password string `json:"user"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue