Skip to content

Commit 46f556b

Browse files
committed
feat(be): update demo project
1 parent 50d0684 commit 46f556b

File tree

2 files changed

+90
-7
lines changed

2 files changed

+90
-7
lines changed

api/projects/projects.go

Lines changed: 89 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,36 @@ func createDemoProject(projectID int, noneKeyID int, emptyEnvID int, store db.St
3838
var devInv db.Inventory
3939
var prodInv db.Inventory
4040

41+
var buildView db.View
42+
var deployView db.View
43+
var toolsView db.View
44+
45+
buildView, err = store.CreateView(db.View{
46+
ProjectID: projectID,
47+
Title: "Build",
48+
Position: 0,
49+
})
50+
51+
if err != nil {
52+
return
53+
}
54+
55+
deployView, err = store.CreateView(db.View{
56+
ProjectID: projectID,
57+
Title: "Deploy",
58+
Position: 1,
59+
})
60+
61+
if err != nil {
62+
return
63+
}
64+
65+
toolsView, err = store.CreateView(db.View{
66+
ProjectID: projectID,
67+
Title: "Tools",
68+
Position: 2,
69+
})
70+
4171
if err != nil {
4272
return
4373
}
@@ -105,27 +135,28 @@ func createDemoProject(projectID int, noneKeyID int, emptyEnvID int, store db.St
105135
return
106136
}
107137

108-
desc = "This task pings the website to provide real word example of using Semaphore."
138+
desc = "Pings the website to provide a real-world example of using Semaphore."
109139
_, err = store.CreateTemplate(db.Template{
110-
Name: "Ping Site",
140+
Name: "Ping google.com",
111141
Playbook: "ping.yml",
112142
Description: &desc,
113143
ProjectID: projectID,
114144
InventoryID: &prodInv.ID,
115145
EnvironmentID: &emptyEnvID,
116146
RepositoryID: demoRepo.ID,
117147
App: db.AppAnsible,
148+
ViewID: &toolsView.ID,
118149
})
119150

120151
if err != nil {
121152
return
122153
}
123154

124-
desc = "Creates artifact and store it in the cache."
155+
desc = "Creates a demo artifact and stores it in the cache."
125156

126157
var startVersion = "1.0.0"
127158
buildTpl, err := store.CreateTemplate(db.Template{
128-
Name: "Build",
159+
Name: "Build demo app",
129160
Playbook: "build.yml",
130161
Type: db.TemplateBuild,
131162
ProjectID: projectID,
@@ -134,6 +165,7 @@ func createDemoProject(projectID int, noneKeyID int, emptyEnvID int, store db.St
134165
RepositoryID: demoRepo.ID,
135166
StartVersion: &startVersion,
136167
App: db.AppAnsible,
168+
ViewID: &buildView.ID,
137169
})
138170

139171
if err != nil {
@@ -142,7 +174,7 @@ func createDemoProject(projectID int, noneKeyID int, emptyEnvID int, store db.St
142174

143175
var template db.Template
144176
template, err = store.CreateTemplate(db.Template{
145-
Name: "Deploy to Dev",
177+
Name: "Deploy demo app to Dev",
146178
Type: db.TemplateDeploy,
147179
Playbook: "deploy.yml",
148180
ProjectID: projectID,
@@ -152,6 +184,7 @@ func createDemoProject(projectID int, noneKeyID int, emptyEnvID int, store db.St
152184
BuildTemplateID: &buildTpl.ID,
153185
Autorun: true,
154186
App: db.AppAnsible,
187+
ViewID: &deployView.ID,
155188
})
156189

157190
if err != nil {
@@ -171,7 +204,7 @@ func createDemoProject(projectID int, noneKeyID int, emptyEnvID int, store db.St
171204
}
172205

173206
template, err = store.CreateTemplate(db.Template{
174-
Name: "Deploy to Production",
207+
Name: "Deploy demo app to Production",
175208
Type: db.TemplateDeploy,
176209
Playbook: "deploy.yml",
177210
ProjectID: projectID,
@@ -180,6 +213,7 @@ func createDemoProject(projectID int, noneKeyID int, emptyEnvID int, store db.St
180213
RepositoryID: demoRepo.ID,
181214
BuildTemplateID: &buildTpl.ID,
182215
App: db.AppAnsible,
216+
ViewID: &deployView.ID,
183217
})
184218

185219
if err != nil {
@@ -194,6 +228,55 @@ func createDemoProject(projectID int, noneKeyID int, emptyEnvID int, store db.St
194228
Type: "password",
195229
})
196230

231+
if err != nil {
232+
return
233+
}
234+
235+
template, err = store.CreateTemplate(db.Template{
236+
Name: "Apply infrastructure",
237+
Type: db.TemplateTask,
238+
Playbook: "",
239+
ProjectID: projectID,
240+
EnvironmentID: &emptyEnvID,
241+
RepositoryID: demoRepo.ID,
242+
BuildTemplateID: &buildTpl.ID,
243+
App: db.AppTofu,
244+
ViewID: &buildView.ID,
245+
})
246+
247+
if err != nil {
248+
return
249+
}
250+
251+
template, err = store.CreateTemplate(db.Template{
252+
Name: "Print system info (Bash)",
253+
Type: db.TemplateTask,
254+
Playbook: "print_system_info.sh",
255+
ProjectID: projectID,
256+
InventoryID: &prodInv.ID,
257+
EnvironmentID: &emptyEnvID,
258+
RepositoryID: demoRepo.ID,
259+
BuildTemplateID: &buildTpl.ID,
260+
App: db.AppBash,
261+
ViewID: &toolsView.ID,
262+
})
263+
264+
if err != nil {
265+
return
266+
}
267+
268+
template, err = store.CreateTemplate(db.Template{
269+
Name: "Print system info (PowerShell)",
270+
Type: db.TemplateTask,
271+
Playbook: "print_system_info.ps1",
272+
ProjectID: projectID,
273+
InventoryID: &prodInv.ID,
274+
EnvironmentID: &emptyEnvID,
275+
RepositoryID: demoRepo.ID,
276+
BuildTemplateID: &buildTpl.ID,
277+
App: db.AppPowerShell,
278+
ViewID: &toolsView.ID,
279+
})
197280
return
198281
}
199282

services/tasks/LocalJob.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ func (t *LocalJob) prepareRun(environmentVars []string, params interface{}) erro
588588
}
589589

590590
if err := t.App.InstallRequirements(environmentVars, params); err != nil {
591-
t.Log("Running galaxy failed: " + err.Error())
591+
t.Log("Failed to install requirements: " + err.Error())
592592
return err
593593
}
594594

0 commit comments

Comments
 (0)