Skip to content

Commit 76a072a

Browse files
committed
WIP create pipeline...still
1 parent d915bf2 commit 76a072a

File tree

9 files changed

+82
-88
lines changed

9 files changed

+82
-88
lines changed

frontend/build/webpack.dev.conf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = merge(baseWebpackConfig, {
3232
}),
3333
// https://github.com/ampedandwired/html-webpack-plugin
3434
new HtmlWebpackPlugin({
35-
title: 'Gaia - Build powerful pipelines with pure Go',
35+
title: 'Gaia - Build powerful automation pipelines with any language you prefer.',
3636
filename: 'index.html',
3737
template: 'index.html',
3838
inject: true,

frontend/build/webpack.prod.conf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const webpackConfig = merge(baseWebpackConfig, {
5151
// you can customize output by editing /index.html
5252
// see https://github.com/ampedandwired/html-webpack-plugin
5353
new HtmlWebpackPlugin({
54-
title: 'Gaia - Build powerful pipelines with pure Go',
54+
title: 'Gaia - Build powerful automation pipelines with any language you prefer.',
5555
filename: process.env.NODE_ENV === 'testing'
5656
? 'index.html'
5757
: config.build.index,

frontend/client/views/pipelines/create.vue

+33-27
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
</p>
4848
<span style="color: red" v-if="pipelineErrorMsg">Pipeline Name incorrect: {{ pipelineErrorMsg }}</span>
4949
<hr class="dotted-line">
50-
<a class="button is-primary" v-on:click="createPipeline" v-bind:class="{ 'is-loading': createPipelineStatus, 'is-disabled': !gitSuccess || !pipelineNameSuccess }">
50+
<a class="button is-primary" v-on:click="createPipeline" v-bind:class="{ 'is-disabled': !gitSuccess || !pipelineNameSuccess }">
5151
<span class="icon">
5252
<i class="fa fa-plus"></i>
5353
</span>
@@ -85,7 +85,7 @@
8585

8686
<div class="tile is-parent is-8">
8787
<article class="tile is-child notification content-article box">
88-
<p class="subtitle">Created pipelines</p>
88+
<p class="subtitle">Pipelines history</p>
8989
<div class="content">
9090
<div class="table-responsive">
9191
<table class="table">
@@ -97,27 +97,24 @@
9797
<th class="th">Creation date</th>
9898
</tr>
9999
</thead>
100-
<tfoot>
101-
<tr>
102-
<th class="th">Name</th>
103-
<th class="th">Status</th>
104-
<th class="th">Type</th>
105-
<th class="th">Creation date</th>
106-
</tr>
107-
</tfoot>
108100
<tbody>
109-
<tr class="blink">
101+
<tr class="blink" v-for="pipeline in createdPipelines" :key="pipeline">
110102
<td>
111-
Pipeline Name
103+
{{ pipeline.pipelinename }}
112104
</td>
113105
<td class="th">
114-
<progress-bar :type="'info'" :size="'small'" :value="80" :max="100" :show-label="false"></progress-bar>
106+
<div v-if="pipeline.status < 100">
107+
<progress-bar :type="'info'" :size="'small'" :value="pipeline.status" :max="100" :show-label="false"></progress-bar>
108+
</div>
109+
<div v-if="pipeline.status === 100">
110+
<span style="color: green;">Completed</span>
111+
</div>
115112
</td>
116113
<td>
117-
Pipeline Type
114+
{{ pipeline.pipelinetype }}
118115
</td>
119116
<td>
120-
Pipeline Date
117+
{{ pipeline.creationdate }}
121118
</td>
122119
</tr>
123120
</tbody>
@@ -201,11 +198,11 @@ export default {
201198
gitSuccess: false,
202199
gitCredentialsModal: false,
203200
gitBranches: [],
204-
createPipelineStatus: 0,
205201
giturl: '',
206202
pipelinename: '',
207203
pipelineNameSuccess: false,
208204
pipelineErrorMsg: '',
205+
createdPipelines: [],
209206
pipeline: {
210207
pipelinename: '',
211208
pipelinetype: 'golang',
@@ -240,6 +237,9 @@ export default {
240237
duration: 500,
241238
arrow: true
242239
})
240+
241+
// created pipelines history
242+
this.fetchData()
243243
},
244244
245245
watch: {
@@ -248,10 +248,22 @@ export default {
248248
},
249249
pipelinename: function () {
250250
this.checkPipelineNameAvailable()
251-
}
251+
},
252+
'$route': 'fetchData'
252253
},
253254
254255
methods: {
256+
fetchData () {
257+
this.$http
258+
.get('/api/v1/pipelines/created')
259+
.then(response => {
260+
this.createdPipelines = response.data
261+
})
262+
.catch(error => {
263+
console.log(error.response.data)
264+
})
265+
},
266+
255267
checkGitRepo () {
256268
if (this.giturl === '') {
257269
return
@@ -300,7 +312,7 @@ export default {
300312
301313
// Request for availability
302314
this.$http
303-
.post('/api/v1/pipelines/nameavailable', this.pipeline)
315+
.post('/api/v1/pipelines/name', this.pipeline)
304316
.then(response => {
305317
// pipeline name valid and available
306318
this.pipelineErrorMsg = ''
@@ -313,26 +325,20 @@ export default {
313325
},
314326
315327
createPipeline () {
316-
// let's start with 10% for the progress bar
317-
this.createPipelineStatus = 10
318-
319328
// copy giturl into our struct and pipeline name
320329
this.pipeline.gitrepo.giturl = this.giturl
321330
this.pipeline.pipelinename = this.pipelinename
322331
323-
// Checkout git repo
332+
// Start the create pipeline process in the backend
324333
this.$http
325334
.post('/api/v1/pipelines/create', this.pipeline)
326335
.then(response => {
327-
console.log('Pipeline successful created!')
328-
this.createPipelineStatus = 30
336+
// Run fetchData to see the pipeline in our history table
337+
this.fetchData()
329338
})
330339
.catch(error => {
331340
console.log(error.response.data)
332341
})
333-
334-
// finish
335-
this.createPipelineStatus = 100
336342
},
337343
338344
close () {

frontend/package-lock.json

-47
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "gaia",
33
"version": "0.1.1",
4-
"description": "Build powerful automation pipelines in a language you may think is the best.",
4+
"description": "Build powerful automation pipelines with any language you prefer.",
55
"repository": "gaia-pipeline/gaia",
66
"homepage": "https://github.com/gaia-pipeline/gaia",
77
"license": "Apache-2.0",
@@ -15,7 +15,11 @@
1515
"pipeline",
1616
"golang",
1717
"build",
18-
"deployment"
18+
"deployment",
19+
"java",
20+
"nodejs",
21+
"cplusplus",
22+
"python"
1923
],
2024
"engines": {
2125
"node": ">=4",
@@ -41,12 +45,10 @@
4145
"plotly.js": "^1.33.1",
4246
"tippy.js": "^2.0.9",
4347
"vue": "^2.5.13",
44-
"vue-bulma-brace": "^0.1.0",
4548
"vue-bulma-breadcrumb": "^1.0.1",
4649
"vue-bulma-card": "^1.0.2",
4750
"vue-bulma-collapse": "1.0.3",
4851
"vue-bulma-datepicker": "^1.3.0",
49-
"vue-bulma-emoji": "^0.0.2",
5052
"vue-bulma-expanding": "^0.0.1",
5153
"vue-bulma-jump": "^0.0.2",
5254
"vue-bulma-message": "^1.1.1",
@@ -56,7 +58,6 @@
5658
"vue-bulma-slider": "^1.0.2",
5759
"vue-bulma-switch": "^1.0.4",
5860
"vue-cleave": "1.1.1",
59-
"vue-lory": "0.0.4",
6061
"vue-nprogress": "0.1.5",
6162
"vue-peity": "0.5.0",
6263
"vue-router": "^3.0.1",

gaia.go

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ type Pipeline struct {
2929
Name string `json:"pipelinename"`
3030
Repo GitRepo `json:"gitrepo"`
3131
Type PluginType `json:"pipelinetype"`
32+
Status int `json:"status"`
33+
ErrMsg string `json:"errmsg"`
3234
CreationDate time.Time `json:"creationdate"`
3335
}
3436

handlers/handler.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ func InitHandlers(c *gaia.Config, i *iris.Application, s *store.Store) error {
4444
i.Post(p+"users/login", UserLogin)
4545
i.Post(p+"pipelines/gitlsremote", PipelineGitLSRemote)
4646
i.Post(p+"pipelines/create", PipelineBuildFromSource)
47-
i.Post(p+"pipelines/nameavailable", PipelineNameAvailable)
48-
i.Get(p+"pipelines/creategetall", CreatePipelineGetAll)
47+
i.Post(p+"pipelines/name", PipelineNameAvailable)
48+
i.Get(p+"pipelines/created", CreatePipelineGetAll)
4949

5050
return nil
5151
}

handlers/pipeline.go

+36-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ var (
1515
)
1616

1717
const (
18+
// Split char to separate path from pipeline and name
1819
pipelinePathSplitChar = "/"
20+
21+
// Percent of pipeline creation progress after git clone
22+
pipelineCloneStatus = 25
23+
24+
// Completed percent progress
25+
pipelineCompleteStatus = 100
1926
)
2027

2128
// PipelineGitLSRemote checks for available git remote branches.
@@ -41,7 +48,7 @@ func PipelineGitLSRemote(ctx iris.Context) {
4148
}
4249

4350
// PipelineBuildFromSource clones a given git repo and
44-
// compiles the included source file to a plugin.
51+
// compiles the included source file to a pipeline.
4552
func PipelineBuildFromSource(ctx iris.Context) {
4653
p := &gaia.Pipeline{}
4754
if err := ctx.ReadJSON(p); err != nil {
@@ -62,22 +69,47 @@ func PipelineBuildFromSource(ctx iris.Context) {
6269
return
6370
}
6471

72+
// Cloning the repo and compiling the pipeline will be done async
73+
go createPipelineExecute(p)
74+
}
75+
76+
// createPipelineExecute clones the given git repo and compiles
77+
// the pipeline. After every step, the status will be store.
78+
// This method is designed to be called async.
79+
func createPipelineExecute(p *gaia.Pipeline) {
6580
// Clone git repo
66-
err = pipeline.GitCloneRepo(&p.Repo)
81+
err := pipeline.GitCloneRepo(&p.Repo)
6782
if err != nil {
68-
ctx.StatusCode(iris.StatusInternalServerError)
69-
ctx.WriteString(err.Error())
83+
// Add error message and store
84+
p.ErrMsg = err.Error()
85+
storeService.CreatePipelinePut(p)
7086
cfg.Logger.Debug("cannot clone repo", "error", err.Error())
7187
return
7288
}
7389

90+
// Update status of our pipeline build
91+
p.Status = pipelineCloneStatus
92+
err = storeService.CreatePipelinePut(p)
93+
if err != nil {
94+
cfg.Logger.Error("cannot put create pipeline into store", "error", err.Error())
95+
return
96+
}
97+
7498
// Start compiling process for given plugin type
7599
switch p.Type {
76100
case gaia.GOLANG:
77101
// Start compile process for golang TODO
78102
}
79103

80104
// copy compiled binary to plugins folder
105+
106+
// Set create pipeline status to complete
107+
p.Status = pipelineCompleteStatus
108+
err = storeService.CreatePipelinePut(p)
109+
if err != nil {
110+
cfg.Logger.Error("cannot put create pipeline into store", "error", err.Error())
111+
return
112+
}
81113
}
82114

83115
// CreatePipelineGetAll returns a json array of

0 commit comments

Comments
 (0)