Skip to content

Commit 18e7802

Browse files
committed
Added create pipeline implementation. Still working on ui.
1 parent c5f6ac0 commit 18e7802

File tree

3 files changed

+99
-69
lines changed

3 files changed

+99
-69
lines changed

frontend/client/App.vue

+10
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,14 @@ html {
166166
color: whitesmoke;
167167
}
168168
169+
.select select {
170+
background-color: #19191b;
171+
color: white;
172+
border-color: #2a2735;
173+
}
174+
175+
.is-blue {
176+
color: #4da2fc !important;
177+
}
178+
169179
</style>

frontend/client/views/pipelines/create.vue

+83-65
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,70 @@
11
<template>
22
<div class="tile is-ancestor">
3-
<div class="tile is-vertical is-5">
4-
<div class="tile">
5-
<div class="tile is-parent is-vertical">
6-
<article class="tile is-child notification content-article">
7-
<div class="content">
8-
<label class="label">Copy the link of your <strong>git repo</strong> here.</label>
9-
<p class="control has-icons-left">
10-
<input class="input is-medium input-bar" v-focus v-model.lazy="gitURL" type="text" placeholder="Link to git repo ...">
11-
<span class="icon is-small is-left">
12-
<i class="fa fa-git"></i>
13-
</span>
14-
<span style="color: red;" v-if="gitNeedAuth">You are not authorized. Invalid username and/or password!</span>
15-
<span style="color: red;" v-if="gitInvalidURL">Invalid link to git repo provided!</span>
16-
<div v-if="gitBranches.length > 0">
17-
<span>Branch:</span>
18-
<div class="select is-fullwidth">
19-
<select v-model="gitBranchSelected">
20-
<option v-for="branch in gitBranches" :key="branch" :value="branch">{{ branch }}</option>
21-
</select>
22-
</div>
23-
</div>
24-
</p>
25-
<p class="control">
26-
<a class="button is-primary" v-on:click="showCredentialsModal">
27-
<span class="icon">
28-
<i class="fa fa-certificate"></i>
29-
</span>
30-
<span>Add credentials</span>
31-
</a>
32-
</p>
33-
<hr class="dotted-line">
34-
<label class="label">Type the name of your pipeline. You can put your pipelines into folders by defining a path. For example <strong>MyFolder/MyAwesomePipeline</strong>.</label>
35-
<p class="control has-icons-left">
36-
<input class="input is-medium input-bar" v-model="pipelineName" type="text" placeholder="Pipeline name ...">
37-
<span class="icon is-small is-left">
38-
<i class="fa fa-book"></i>
39-
</span>
40-
</p>
41-
<hr class="dotted-line">
42-
<a class="button is-primary" v-on:click="createPipeline">
43-
<span class="icon">
44-
<i class="fa fa-plus"></i>
45-
</span>
46-
<span>Create Pipeline</span>
47-
</a>
3+
<div class="tile is-vertical is-parent is-5">
4+
<article class="tile is-child notification content-article">
5+
<div class="content">
6+
<label class="label">Copy the link of your <strong>git repo</strong> here.</label>
7+
<p class="control has-icons-left" v-bind:class="{ 'has-icons-right': gitSuccess }">
8+
<input class="input is-medium input-bar" v-focus v-model.lazy="gitURL" type="text" placeholder="Link to git repo ...">
9+
<span class="icon is-small is-left">
10+
<i class="fa fa-git"></i>
11+
</span>
12+
<span v-if="gitSuccess" class="icon is-small is-right is-blue">
13+
<i class="fa fa-check"></i>
14+
</span>
15+
</p>
16+
<span style="color: red" v-if="gitErrorMsg">Cannot access git repo: {{ gitErrorMsg }}</span>
17+
<div v-if="gitBranches.length > 0">
18+
<span>Branch:</span>
19+
<div class="select is-fullwidth">
20+
<select v-model="gitBranchSelected">
21+
<option v-for="branch in gitBranches" :key="branch" :value="branch">{{ branch }}</option>
22+
</select>
4823
</div>
49-
</article>
24+
</div>
25+
<p class="control" style="padding-top: 10px;">
26+
<a class="button is-primary" v-on:click="showCredentialsModal">
27+
<span class="icon">
28+
<i class="fa fa-certificate"></i>
29+
</span>
30+
<span>Add credentials</span>
31+
</a>
32+
</p>
33+
<hr class="dotted-line">
34+
<label class="label">Type the name of your pipeline. You can put your pipelines into folders by defining a path. For example <strong>MyFolder/MyAwesomePipeline</strong>.</label>
35+
<p class="control has-icons-left">
36+
<input class="input is-medium input-bar" v-model="pipelineName" type="text" placeholder="Pipeline name ...">
37+
<span class="icon is-small is-left">
38+
<i class="fa fa-book"></i>
39+
</span>
40+
</p>
41+
<hr class="dotted-line">
42+
<a class="button is-primary" v-on:click="createPipeline" v-bind:class="{ 'is-loading': createPipelineStatus }">
43+
<span class="icon">
44+
<i class="fa fa-plus"></i>
45+
</span>
46+
<span>Create Pipeline</span>
47+
</a>
5048
</div>
49+
</article>
50+
51+
<div class="tile is-child">
52+
<article class="tile is-child notification content-article">
53+
<div class="content">
54+
Current Status: Some-Status-Here
55+
<progress-bar :type="'info'" :size="'medium'" :value="45" :max="100" :show-label="true"></progress-bar>
56+
</div>
57+
</article>
58+
</div>
59+
</div>
60+
61+
<div class="tile is-vertical is-parent is-3">
62+
<div class="tile is-child">
63+
<article class="tile is-child notification content-article">
64+
<div class="content">
65+
Plugin Types here *TODO*
66+
</div>
67+
</article>
5168
</div>
5269
</div>
5370

@@ -112,14 +129,15 @@
112129
<script>
113130
import { Modal } from 'vue-bulma-modal'
114131
import { Collapse, Item as CollapseItem } from 'vue-bulma-collapse'
132+
import ProgressBar from 'vue-bulma-progress-bar'
115133
116134
export default {
117135
118136
data () {
119137
return {
120138
gitURL: '',
121-
gitNeedAuth: false,
122-
gitInvalidURL: false,
139+
gitErrorMsg: '',
140+
gitSuccess: false,
123141
gitCredentialsModal: false,
124142
gitUsername: '',
125143
gitPassword: '',
@@ -128,14 +146,16 @@ export default {
128146
keyPassword: '',
129147
gitBranches: [],
130148
gitBranchSelected: '',
131-
pipelineName: ''
149+
pipelineName: '',
150+
createPipelineStatus: '20'
132151
}
133152
},
134153
135154
components: {
136155
Modal,
137156
Collapse,
138-
CollapseItem
157+
CollapseItem,
158+
ProgressBar
139159
},
140160
141161
watch: {
@@ -150,6 +170,11 @@ export default {
150170
return
151171
}
152172
173+
// Reset last fetches
174+
this.gitBranches = []
175+
this.gitBranchSelected = ''
176+
this.gitSuccess = false
177+
153178
var gitrepo = {
154179
giturl: this.gitURL,
155180
gituser: this.gitUsername,
@@ -164,8 +189,8 @@ export default {
164189
this.$http.post('/api/v1/pipelines/gitlsremote', gitrepo)
165190
.then((response) => {
166191
// Reset error message before
167-
this.gitNeedAuth = false
168-
this.gitInvalidURL = false
192+
this.gitErrorMsg = ''
193+
this.gitSuccess = true
169194
170195
// Get branches and set to master if available
171196
this.gitBranches = response.data.gitbranches
@@ -179,19 +204,10 @@ export default {
179204
if (!this.gitBranchSelected && this.gitBranches.length > 0) {
180205
this.gitBranchSelected = this.gitBranches[0]
181206
}
182-
183-
console.log(response.data)
184207
})
185208
.catch((error) => {
186-
// Need authentication
187-
if (error.response && error.response.status === 403) {
188-
this.gitNeedAuth = true
189-
this.gitInvalidURL = false
190-
} else if (error.response && error.response.status === 400) {
191-
this.gitInvalidURL = true
192-
this.gitNeedAuth = false
193-
}
194-
console.log(error.response.data)
209+
// Add error message
210+
this.gitErrorMsg = error.response.data
195211
})
196212
},
197213
@@ -213,13 +229,15 @@ export default {
213229
gitrepo: gitrepo
214230
}
215231
232+
this.createPipelineStatus = '20'
216233
this.$http.post('/api/v1/pipelines/create', pipeline)
217234
.then((response) => {
218-
console.log("Pipeline successful created!")
235+
console.log('Pipeline successful created!')
219236
})
220237
.catch((error) => {
221-
console.log(error)
238+
console.log(error.response.data)
222239
})
240+
this.createPipelineStatus = '100'
223241
},
224242
225243
close () {

pipeline/git.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"os"
55
"strings"
66

7+
"gopkg.in/src-d/go-git.v4/plumbing"
8+
79
"github.com/gaia-pipeline/gaia"
810
"github.com/satori/go.uuid"
911
git "gopkg.in/src-d/go-git.v4"
@@ -29,12 +31,12 @@ func GitLSRemote(repo *gaia.GitRepo) error {
2931
}
3032

3133
// Attach credentials if provided
32-
var sshKey *ssh.PublicKeys
34+
var auth transport.AuthMethod
3335
if repo.Username != "" && repo.Password != "" {
3436
ep.User = repo.Username
3537
ep.Password = repo.Password
3638
} else if repo.PrivateKey.Key != "" {
37-
sshKey, err = ssh.NewPublicKeys(repo.PrivateKey.Username, []byte(repo.PrivateKey.Key), repo.PrivateKey.Password)
39+
auth, err = ssh.NewPublicKeys(repo.PrivateKey.Username, []byte(repo.PrivateKey.Key), repo.PrivateKey.Password)
3840
if err != nil {
3941
return err
4042
}
@@ -47,7 +49,7 @@ func GitLSRemote(repo *gaia.GitRepo) error {
4749
}
4850

4951
// Open new session
50-
s, err := cl.NewUploadPackSession(ep, sshKey)
52+
s, err := cl.NewUploadPackSession(ep, auth)
5153
if err != nil {
5254
return err
5355
}
@@ -112,7 +114,7 @@ func GitCloneRepo(repo *gaia.GitRepo) error {
112114
URL: repo.URL,
113115
RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
114116
SingleBranch: true,
115-
RemoteName: repo.SelectedBranch,
117+
ReferenceName: plumbing.ReferenceName(repo.SelectedBranch),
116118
})
117119
if err != nil {
118120
return err

0 commit comments

Comments
 (0)