Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd3610e6

Browse files
committed
More progress
1 parentb291b48 commitd3610e6

File tree

8 files changed

+108
-18
lines changed

8 files changed

+108
-18
lines changed

‎frontend/client/views/login.vue‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<template>
2+
<divclass="content has-text-centered">
3+
<p>
4+
<imgwidth="200"src="~assets/logo.png":alt="description">
5+
</p>
6+
7+
<h1class="is-title is-bold">Login</h1>
8+
</div>
9+
</template>
10+
11+
<script>
12+
exportdefault {
13+
}
14+
</script>
15+
16+
<style lang="scss" scoped>
17+
.is-title {
18+
text-transform:capitalize;
19+
}
20+
</style>

‎frontend/client/views/pipelines/create.vue‎

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
</span>
4040
</p>
4141
<hrclass="dotted-line">
42-
<aclass="button is-primary">
42+
<aclass="button is-primary"v-on:click="createPipeline">
4343
<spanclass="icon">
4444
<iclass="fa fa-plus"></i>
4545
</span>
@@ -176,7 +176,7 @@ export default {
176176
}
177177
178178
// if we cannot find master
179-
if (!this.gitBranchSelected) {
179+
if (!this.gitBranchSelected&&this.gitBranches.length>0) {
180180
this.gitBranchSelected=this.gitBranches[0]
181181
}
182182
@@ -195,6 +195,33 @@ export default {
195195
})
196196
},
197197
198+
createPipeline () {
199+
var gitrepo= {
200+
giturl:this.gitURL,
201+
gituser:this.gitUsername,
202+
gitpassword:this.gitPassword,
203+
selectedbranch:this.gitBranchSelected,
204+
privatekey: {
205+
key:this.privateKey,
206+
username:this.keyUsername,
207+
password:this.keyPassword
208+
}
209+
}
210+
211+
var pipeline= {
212+
pipelinename:this.pipelineName,
213+
gitrepo: gitrepo
214+
}
215+
216+
this.$http.post('/api/v1/pipelines/create', pipeline)
217+
.then((response)=> {
218+
console.log("Pipeline successful created!")
219+
})
220+
.catch((error)=> {
221+
console.log(error)
222+
})
223+
},
224+
198225
close () {
199226
this.checkGitRepo()
200227
this.gitCredentialsModal=false

‎frontend/package.json‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name":"gaia",
33
"version":"0.1.1",
4-
"description":"Build powerful pipelineswith any language",
5-
"repository":"michelvocks/gaia",
6-
"homepage":"https://github.com/michelvocks/gaia",
4+
"description":"Build powerfulautomationpipelinesin the langauge you think is the best.",
5+
"repository":"gaia-pipeline/gaia",
6+
"homepage":"https://github.com/gaia-pipeline/gaia",
77
"license":"Apache-2.0",
88
"author": {
99
"name":"Michel Vocks",
@@ -15,8 +15,7 @@
1515
"pipeline",
1616
"golang",
1717
"build",
18-
"deployment",
19-
"kubernetes"
18+
"deployment"
2019
],
2120
"engines": {
2221
"node":">=4",

‎gaia.go‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ type Pipeline struct {
3232

3333
// GitRepo represents a single git repository
3434
typeGitRepostruct {
35-
URLstring`json:"giturl"`
36-
Usernamestring`json:"gituser"`
37-
Passwordstring`json:"gitpassword"`
38-
PrivateKeyPrivateKey`json:"privatekey"`
39-
Branches []string`json:"gitbranches"`
40-
LocalDeststring
35+
URLstring`json:"giturl"`
36+
Usernamestring`json:"gituser"`
37+
Passwordstring`json:"gitpassword"`
38+
PrivateKeyPrivateKey`json:"privatekey"`
39+
SelectedBranchstring`json:"selectedbranch"`
40+
Branches []string`json:"gitbranches"`
41+
LocalDeststring
4142
}
4243

4344
// PrivateKey represents a pem encoded private key

‎handlers/handler.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ func InitHandlers(c *gaia.Config, i *iris.Application, s *store.Store) error {
4141
// Define prefix
4242
p:="/api/"+apiVersion+"/"
4343

44+
// Register handlers at iris instance
4445
i.Post(p+"users/login",UserLogin)
4546
i.Post(p+"pipelines/gitlsremote",PipelineGitLSRemote)
47+
i.Post(p+"pipelines/create",PipelineBuildFromSource)
4648

4749
returnnil
4850
}

‎handlers/pipeline.go‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,18 @@ func PipelineBuildFromSource(ctx iris.Context) {
3939
}
4040

4141
// Clone git repo
42+
err:=pipeline.GitCloneRepo(&p.Repo)
43+
iferr!=nil {
44+
ctx.StatusCode(iris.StatusInternalServerError)
45+
ctx.WriteString(err.Error())
46+
return
47+
}
48+
49+
// Start compiling process for given plugin type
50+
switchp.Type {
51+
casegaia.GOLANG:
52+
// Start compile process for golang TODO
53+
}
4254

43-
// set go compiler variables
44-
// compile
4555
// copy compiled binary to plugins folder
4656
}

‎pipeline/git.go‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ import (
55
"strings"
66

77
"github.com/michelvocks/gaia"
8+
"github.com/satori/go.uuid"
89
git"gopkg.in/src-d/go-git.v4"
910
"gopkg.in/src-d/go-git.v4/plumbing/transport"
1011
"gopkg.in/src-d/go-git.v4/plumbing/transport/client"
12+
"gopkg.in/src-d/go-git.v4/plumbing/transport/http"
1113
"gopkg.in/src-d/go-git.v4/plumbing/transport/ssh"
1214
)
1315

1416
const (
15-
refHead="refs/heads"
17+
refHead="refs/heads"
18+
tmpFolder="tmp"
1619
)
1720

1821
// GitLSRemote get remote branches from a git repo
@@ -78,17 +81,38 @@ func GitLSRemote(repo *gaia.GitRepo) error {
7881
// GitCloneRepo clones the given repo to a local folder.
7982
// The destination will be attached to the given repo obj.
8083
funcGitCloneRepo(repo*gaia.GitRepo)error {
81-
// Create local temp folder for checkout
82-
folder:="temp/notyetdefined"
84+
// create uuid for clone folder
85+
uuid:=uuid.Must(uuid.NewV4())
86+
87+
// Create local temp folder for clone
88+
folder:=tmpFolder+string(os.PathSeparator)+uuid.String()
8389
err:=os.MkdirAll(folder,0700)
8490
iferr!=nil {
8591
returnerr
8692
}
8793

94+
// Check if credentials were provided
95+
varauth transport.AuthMethod
96+
ifrepo.Username!=""&&repo.Password!="" {
97+
// Basic auth provided
98+
auth=&http.BasicAuth{
99+
Username:repo.Username,
100+
Password:repo.Password,
101+
}
102+
}elseifrepo.PrivateKey.Key!="" {
103+
auth,err=ssh.NewPublicKeys(repo.PrivateKey.Username, []byte(repo.PrivateKey.Key),repo.PrivateKey.Password)
104+
iferr!=nil {
105+
returnerr
106+
}
107+
}
108+
88109
// Clone repo
89110
_,err=git.PlainClone(folder,false,&git.CloneOptions{
111+
Auth:auth,
90112
URL:repo.URL,
91113
RecurseSubmodules:git.DefaultSubmoduleRecursionDepth,
114+
SingleBranch:true,
115+
RemoteName:repo.SelectedBranch,
92116
})
93117
iferr!=nil {
94118
returnerr

‎pipeline/git_test.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package pipeline
22

33
import (
4+
"os"
45
"testing"
56

67
"github.com/michelvocks/gaia"
@@ -14,4 +15,10 @@ func TestGitCloneRepo(t *testing.T) {
1415
iferr!=nil {
1516
t.Fatal(err)
1617
}
18+
19+
// clean up
20+
err=os.RemoveAll("tmp")
21+
iferr!=nil {
22+
t.Fatal(err)
23+
}
1724
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp