8000 fix(api): Add check on import application as code #3711 (#3732) · ovh/cds@050268f · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 050268f

Browse files
bnjjjsguiheux
authored andcommitted
fix(api): Add check on import application as code #3711 (#3732)
1 parent bb1c29e commit 050268f

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

engine/api/application/application_parser.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ func ParseAndImport(db gorp.SqlExecutor, cache cache.Store, proj *sdk.Project, e
130130
if app.RepositoryStrategy.ConnectionType == "" {
131131
app.RepositoryStrategy.ConnectionType = "https"
132132
}
133+
if app.RepositoryStrategy.ConnectionType == "ssh" && app.RepositoryStrategy.SSHKey == "" {
134+
return app, nil, sdk.NewErrorFrom(sdk.ErrInvalidApplicationRepoStrategy, "Could not import application %s with a connection type ssh without ssh key", app.Name)
135+
}
133136
if eapp.VCSPassword != "" {
134137
clearPWD, err := decryptFunc(db, proj.ID, eapp.VCSPassword)
135138
if err != nil {

sdk/error.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ var (
169169
ErrWorkflowNotGenerated = Error{ID: 152, Status: http.StatusForbidden}
170170
ErrAlreadyLatestTemplate = Error{ID: 153, Status: http.StatusForbidden}
171171
ErrInvalidNodeDefaultPayload = Error{ID: 154, Status: http.StatusBadRequest}
172+
ErrInvalidApplicationRepoStrategy = Error{ID: 155, Status: http.StatusBadRequest}
172173
)
173174

174175
var errorsAmericanEnglish = map[int]string{
@@ -320,6 +321,7 @@ var errorsAmericanEnglish = map[int]string{
320321
ErrInvalidGroupMember.ID: "User is not a group's member",
321322
ErrWorkflowNotGenerated.ID: "Workflow was not generated by a template",
322323
ErrInvalidNodeDefaultPayload.ID: "Workflow node which isn't a root node cannot have a default payload",
324+
ErrInvalidApplicationRepoStrategy.ID: "The repository strategy for your application is not correct",
323325
}
324326

325327
var errorsFrench = map[int]string{
@@ -471,6 +473,7 @@ var errorsFrench = map[int]string{
471473
ErrInvalidGroupMember.ID: "L'utilisateur n'est pas membre du groupe",
472474
ErrWorkflowNotGenerated.ID: "Le workflow n'a pas été généré par un template",
473475
ErrInvalidNodeDefaultPayload.ID: "Le workflow est incorrect. Un payload par défaut ne peut pas être sur un pipeline autre que le premier du workflow",
476+
ErrInvalidApplicationRepoStrategy.ID: "La stratégie de dépôt (vcs) de l'application n'est pas correcte",
474477
}
475478

476479
var errorsLanguages = []map[int]string{

0 commit comments

Comments
 (0)
0