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"`
|
||||||
|
|
||||||
|
// todo re-factor these
|
||||||
|
Clone *common.Clone `json:"clone"`
|
||||||
Keys *common.Keypair `json:"keys"`
|
Keys *common.Keypair `json:"keys"`
|
||||||
Netrc *common.Netrc `json:"netrc"`
|
Netrc *common.Netrc `json:"netrc"`
|
||||||
Yaml []byte `json:"yaml"`
|
|
||||||
Env []string `json:"environment"`
|
|
||||||
Plugins []string `json:"plugins"`
|
|
||||||
|
|
||||||
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',
|
controller: 'RepoEditCtrl',
|
||||||
resolve: resolveUser
|
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', {
|
.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;
|
||||||
|
@ -15,3 +16,4 @@ margin-right: 10px;">Delete</button>
|
||||||
</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 {
|
||||||
|
System *common.System `json:"system"`
|
||||||
User *common.User `json:"user"`
|
User *common.User `json:"user"`
|
||||||
Repo *common.Repo `json:"repo"`
|
Repo *common.Repo `json:"repo"`
|
||||||
Build *common.Build `json:"build"`
|
Build *common.Build `json:"build"`
|
||||||
Keys *common.Keypair `json:"keypair"`
|
Keys *common.Keypair `json:"keypair"`
|
||||||
Netrc *common.Netrc `json:"netrc"`
|
Netrc *common.Netrc `json:"netrc"`
|
||||||
Yaml []byte `json:"yaml"`
|
Yaml []byte `json:"yaml"`
|
||||||
Env []string `json:"environment"`
|
|
||||||
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{
|
||||||
|
System: w.System,
|
||||||
|
Workspace: &types.Workspace{Netrc: w.Netrc, Keys: w.Keys},
|
||||||
Repo: w.Repo,
|
Repo: w.Repo,
|
||||||
Build: w.Build,
|
Build: w.Build,
|
||||||
Keys: w.Keys,
|
|
||||||
Netrc: w.Netrc,
|
|
||||||
Yaml: w.Yaml,
|
|
||||||
Job: job,
|
Job: job,
|
||||||
Env: w.Env,
|
Yaml: w.Yaml,
|
||||||
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{
|
||||||
|
System: w.System,
|
||||||
|
Workspace: &types.Workspace{Netrc: w.Netrc, Keys: w.Keys},
|
||||||
Repo: w.Repo,
|
Repo: w.Repo,
|
||||||
Build: w.Build,
|
Build: w.Build,
|
||||||
Keys: w.Keys,
|
|
||||||
Netrc: w.Netrc,
|
|
||||||
Yaml: w.Yaml,
|
|
||||||
Job: job,
|
Job: job,
|
||||||
Env: w.Env,
|
Yaml: w.Yaml,
|
||||||
Plugins: w.Plugins,
|
|
||||||
}
|
}
|
||||||
in, err := json.Marshal(work)
|
in, err := json.Marshal(work)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -29,16 +29,16 @@ 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"}
|
||||||
|
@ -48,11 +48,14 @@ 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"
|
||||||
|
@ -197,8 +198,11 @@ func RunBuild(c *gin.Context) {
|
||||||
Keys: repo.Keys,
|
Keys: repo.Keys,
|
||||||
Netrc: netrc,
|
Netrc: netrc,
|
||||||
Yaml: raw,
|
Yaml: raw,
|
||||||
|
System: &common.System{
|
||||||
|
Link: httputil.GetURL(c.Request),
|
||||||
Plugins: conf.Plugins,
|
Plugins: conf.Plugins,
|
||||||
Env: conf.Environment,
|
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"
|
||||||
|
@ -164,7 +165,10 @@ func PostHook(c *gin.Context) {
|
||||||
Keys: repo.Keys,
|
Keys: repo.Keys,
|
||||||
Netrc: netrc,
|
Netrc: netrc,
|
||||||
Yaml: raw,
|
Yaml: raw,
|
||||||
|
System: &common.System{
|
||||||
|
Link: httputil.GetURL(c.Request),
|
||||||
Plugins: conf.Plugins,
|
Plugins: conf.Plugins,
|
||||||
Env: conf.Environment,
|
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
|
||||||
|
@ -65,6 +66,9 @@ type Step struct {
|
||||||
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