-
Notifications
You must be signed in to change notification settings - Fork 436
/
Copy pathmessages.go
255 lines (241 loc) · 25.9 KB
/
messages.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
package sdk
import (
"fmt"
"github.com/pkg/errors"
"golang.org/x/text/language"
)
type (
lang language.Tag
trad map[lang]string
)
// Supported API language
var (
FR = lang(language.French)
EN = lang(language.AmericanEnglish)
)
// Message list
var (
MsgAppCreated = &Message{"MsgAppCreated", trad{FR: "L'application %s a été créée avec succès", EN: "Application %s successfully created"}, nil, RunInfoTypInfo}
MsgAppUpdated = &Message{"MsgAppUpdated", trad{FR: "L'application %s a été mise à jour avec succès", EN: "Application %s successfully updated"}, nil, RunInfoTypInfo}
MsgPipelineCreated = &Message{"MsgPipelineCreated", trad{FR: "Le pipeline %s a été créé avec succès", EN: "Pipeline %s successfully created"}, nil, RunInfoTypInfo}
MsgPipelineCreationAborted = &Message{"MsgPipelineCreationAborted", trad{FR: "La création du pipeline %s a été abandonnée", EN: "Pipeline %s creation aborted"}, nil, RunInfoTypeError}
MsgPipelineExists = &Message{"MsgPipelineExists", trad{FR: "Le pipeline %s existe déjà", EN: "Pipeline %s already exists"}, nil, RunInfoTypInfo}
MsgAppVariablesCreated = &Message{"MsgAppVariablesCreated", trad{FR: "Les variables ont été ajoutées avec succès sur l'application %s", EN: "Application variables for %s are successfully created"}, nil, RunInfoTypInfo}
MsgAppKeyCreated = &Message{"MsgAppKeyCreated", trad{FR: "La clé %s %s a été créée sur l'application %s", EN: "%s key %s created on application %s"}, nil, RunInfoTypInfo}
MsgEnvironmentExists = &Message{"MsgEnvironmentExists", trad{FR: "L'environnement %s existe déjà", EN: "Environment %s already exists"}, nil, RunInfoTypInfo}
MsgEnvironmentCreated = &Message{"MsgEnvironmentCreated", trad{FR: "L'environnement %s a été créé avec succès", EN: "Environment %s successfully created"}, nil, RunInfoTypInfo}
MsgEnvironmentVariableUpdated = &Message{"MsgEnvironmentVariableUpdated", trad{FR: "La variable %s de l'environnement %s a été mise à jour", EN: "Variable %s on environment %s has been updated"}, nil, RunInfoTypInfo}
MsgEnvironmentVariableCannotBeUpdated = &Message{"MsgEnvironmentVariableCannotBeUpdated", trad{FR: "La variable %s de l'environnement %s n'a pu être mise à jour : %s", EN: "Variable %s on environment %s cannot be updated: %s"}, nil, RunInfoTypeError}
MsgEnvironmentVariableCreated = &Message{"MsgEnvironmentVariableCreated", trad{FR: "La variable %s de l'environnement %s a été ajoutée", EN: "Variable %s on environment %s has been added"}, nil, RunInfoTypInfo}
MsgEnvironmentVariableCannotBeCreated = &Message{"MsgEnvironmentVariableCannotBeCreated", trad{FR: "La variable %s de l'environnement %s n'a pu être ajoutée : %s", EN: "Variable %s on environment %s cannot be added: %s"}, nil, RunInfoTypeError}
MsgEnvironmentGroupUpdated = &Message{"MsgEnvironmentGroupUpdated", trad{FR: "Le groupe %s de l'environnement %s a été mis à jour", EN: "Group %s on environment %s has been updated"}, nil, RunInfoTypInfo}
MsgEnvironmentGroupCannotBeUpdated = &Message{"MsgEnvironmentGroupCannotBeUpdated", trad{FR: "Le groupe %s de l'environnement %s n'a pu être mis à jour : %s", EN: "Group %s on environment %s cannot be updated: %s"}, nil, RunInfoTypeError}
MsgEnvironmentGroupCreated = &Message{"MsgEnvironmentGroupCreated", trad{FR: "Le groupe %s de l'environnement %s a été ajouté", EN: "Group %s on environment %s has been added"}, nil, RunInfoTypInfo}
MsgEnvironmentGroupCannotBeCreated = &Message{"MsgEnvironmentGroupCannotBeCreated", trad{FR: "Le groupe %s de l'environnement %s n'a pu être ajouté : %s", EN: "Group %s on environment %s cannot be added: %s"}, nil, RunInfoTypeError}
MsgEnvironmentGroupDeleted = &Message{"MsgEnvironmentGroupDeleted", trad{FR: "Le groupe %s de l'environnement %s a été supprimé", EN: "Group %s on environment %s has been deleted"}, nil, RunInfoTypInfo}
MsgEnvironmentGroupCannotBeDeleted = &Message{"MsgEnvironmentGMsgEnvironmentGroupCannotBeDeletedroupCannotBeCreated", trad{FR: "Le groupe %s de l'environnement %s n'a pu être supprimé : %s", EN: "Group %s on environment %s cannot be deleted: %s"}, nil, RunInfoTypeError}
MsgEnvironmentKeyCreated = &Message{"MsgEnvironmentKeyCreated", trad{FR: "La clé %s %s a été créée sur l'environnement %s", EN: "%s key %s created on environment %s"}, nil, RunInfoTypInfo}
MsgEnvironmentKeyCannotBeCreated = &Message{"MsgEnvironmentKeyCannotBeCreated", trad{FR: "La clé %s %s n'a pas été créée sur l'environnement %s", EN: "%s key %s cannot be created on environment %s: %v"}, nil, RunInfoTypeError}
MsgJobNotValidActionNotFound = &Message{"MsgJobNotValidActionNotFound", trad{FR: "Erreur de validation du Job %s : L'action %s à l'étape %d n'a pas été trouvée", EN: "Job %s validation Failure: Unknown action %s on step #%d"}, nil, RunInfoTypeError}
MsgJobNotValidInvalidActionParameter = &Message{"MsgJobNotValidInvalidActionParameter", trad{FR: "Erreur de validation du Job %s : Le paramètre %s de l'étape %d - %s est invalide", EN: "Job %s validation Failure: Invalid parameter %s on step #%d %s"}, nil, RunInfoTypeError}
MsgPipelineGroupUpdated = &Message{"MsgPipelineGroupUpdated", trad{FR: "Les permissions du groupe %s sur le pipeline %s on été mises à jour", EN: "Permission for group %s on pipeline %s has been updated"}, nil, RunInfoTypInfo}
MsgPipelineGroupAdded = &Message{"MsgPipelineGroupAdded", trad{FR: "Les permissions du groupe %s sur le pipeline %s on été ajoutées", EN: "Permission for group %s on pipeline %s has been added"}, nil, RunInfoTypInfo}
MsgPipelineGroupDeleted = &Message{"MsgPipelineGroupDeleted", trad{FR: "Les permissions du groupe %s sur le pipeline %s on été supprimées", EN: "Permission for group %s on pipeline %s has been deleted"}, nil, RunInfoTypInfo}
MsgPipelineStageUpdated = &Message{"MsgPipelineStageUpdated", trad{FR: "Le stage %s a été mis à jour", EN: "Stage %s updated"}, nil, RunInfoTypInfo}
MsgPipelineStageUpdating = &Message{"MsgPipelineStageUpdating", trad{FR: "Mise à jour du stage %s en cours...", EN: "Updating stage %s ..."}, nil, RunInfoTypInfo}
MsgPipelineStageDeletingOldJobs = &Message{"MsgPipelineStageDeletingOldJobs", trad{FR: "Suppression des anciens jobs du stage %s en cours...", EN: "Deleting old jobs in stage %s ..."}, nil, RunInfoTypInfo}
MsgPipelineStageInsertingNewJobs = &Message{"MsgPipelineStageInsertingNewJobs", trad{FR: "Insertion des nouveaux jobs dans le stage %s en cours...", EN: "Inserting new jobs in stage %s ..."}, nil, RunInfoTypInfo}
MsgPipelineStageAdded = &Message{"MsgPipelineStageAdded", trad{FR: "Le stage %s a été ajouté", EN: "Stage %s added"}, nil, RunInfoTypInfo}
MsgPipelineStageDeleted = &Message{"MsgPipelineStageDeleted", trad{FR: "Le stage %s a été supprimé", EN: "Stage %s deleted"}, nil, RunInfoTypInfo}
MsgPipelineJobUpdated = &Message{"MsgPipelineJobUpdated", trad{FR: "Le job %s du stage %s a été mis à jour", EN: "Job %s in stage %s updated"}, nil, RunInfoTypInfo}
MsgPipelineJobAdded = &Message{"MsgPipelineJobAdded", trad{FR: "Le job %s du stage %s a été ajouté", EN: "Job %s in stage %s added"}, nil, RunInfoTypInfo}
MsgPipelineJobDeleted = &Message{"MsgPipelineJobDeleted", trad{FR: "Le job %s du stage %s a été supprimé", EN: "Job %s in stage %s deleted"}, nil, RunInfoTypInfo}
MsgPipelineDetached = &Message{"MsgPipelineDetached", trad{FR: "Le pipeline %s est détaché du repository %s", EN: "The pipeline %s is detached from repository %s"}, nil, RunInfoTypInfo}
MsgApplicationDetached = &Message{"MsgApplicationDetached", trad{FR: "L'application %s est détachée du repository %s", EN: "The application %s is detached from repository %s"}, nil, RunInfoTypInfo}
MsgEnvironmentDetached = &Message{"MsgEnvironmentDetached", trad{FR: "L'environnement %s est détaché du repository %s", EN: "The environment %s is detached from repository %s"}, nil, RunInfoTypInfo}
MsgWorkflowDetached = &Message{"MsgWorkflowDetached", trad{FR: "Le workflow %s est détaché du repository %s", EN: "The workflow %s is detached from repository %s"}, nil, RunInfoTypInfo}
MsgSpawnInfoHatcheryStarts = &Message{"MsgSpawnInfoHatcheryStarts", trad{FR: "La Hatchery %s a démarré le lancement du worker %s avec le modèle %s", EN: "Hatchery %s starts spawn worker %s with model %s"}, nil, RunInfoTypInfo}
MsgSpawnInfoHatcheryErrorSpawn = &Message{"MsgSpawnInfoHatcheryErrorSpawn", trad{FR: "Une erreur est survenue lorsque la Hatchery %s a démarré un worker avec le modèle %s après %s, err: %s", EN: "Error while Hatchery %s spawns worker with model %s after %s, err: %s"}, nil, RunInfoTypeError}
MsgSpawnInfoHatcheryStartDockerPull = &Message{"MsgSpawnInfoHatcheryStartDockerPull", trad{FR: "La Hatchery %s a démarré le docker pull de l'image %s...", EN: "Hatchery %s starts docker pull %s..."}, nil, RunInfoTypInfo}
MsgSpawnInfoHatcheryEndDockerPull = &Message{"MsgSpawnInfoHatcheryEndDockerPull", trad{FR: "La Hatchery %s a terminé le docker pull de l'image %s", EN: "Hatchery %s docker pull %s done"}, nil, RunInfoTypInfo}
MsgSpawnInfoHatcheryEndDockerPullErr = &Message{"MsgSpawnInfoHatcheryEndDockerPullErr", trad{FR: "⚠ La Hatchery %s a terminé le docker pull de l'image %s en erreur: %s", EN: "⚠ Hatchery %s - docker pull %s done with error: %v"}, nil, RunInfoTypeError}
MsgSpawnInfoDeprecatedModel = &Message{"MsgSpawnInfoDeprecatedModel", trad{FR: "⚠ Attention vous utilisez un worker model (%s) déprécié", EN: "⚠ Pay attention you are using a deprecated worker model (%s)"}, nil, RunInfoTypeWarning}
MsgSpawnInfoWorkerEnd = &Message{"MsgSpawnInfoWorkerEnd", trad{FR: "✓ Le worker %s a terminé et a passé %s à travailler sur les étapes", EN: "✓ Worker %s finished working on this job"}, nil, RunInfoTypInfo}
MsgSpawnInfoJobDisabled = &Message{"MsgSpawnInfoJobDisabled", trad{FR: "✓ Le job a désactivé", EN: "✓ Job is disabled"}, nil, RunInfoTypInfo}
MsgSpawnInfoJobInQueue = &Message{"MsgSpawnInfoJobInQueue", trad{FR: "✓ Le job a été mis en file d'attente", EN: "✓ Job has been queued"}, nil, RunInfoTypInfo}
MsgSpawnInfoJobTaken = &Message{"MsgSpawnInfoJobTaken", trad{FR: "Le job %s a été pris par le worker %s", EN: "Job %s has been taken by worker %s"}, nil, RunInfoTypInfo}
MsgSpawnInfoJobTakenWorkerVersion = &Message{"MsgSpawnInfoJobTakenWorkerVersion", trad{FR: "Worker %s version:%s os:%s arch:%s", EN: "Worker %s version:%s os:%s arch:%s"}, nil, RunInfoTypInfo}
MsgSpawnInfoWorkerForJob = &Message{"MsgSpawnInfoWorkerForJob", trad{FR: "Ce worker %s a été créé pour lancer ce job", EN: "This worker %s was created to take this action"}, nil, RunInfoTypInfo}
MsgSpawnInfoWorkerForJobError = &Message{"MsgSpawnInfoWorkerForJobError", trad{FR: "⚠ Ce worker %s a été créé pour lancer ce job, mais ne possède pas tous les pré-requis. Vérifiez que les prérequis suivants: %s", EN: "⚠ This worker %s was created to take this action, but does not have all prerequisites. Please verify the following prerequisites: %s"}, nil, RunInfoTypeError}
MsgSpawnInfoJobError = &Message{"MsgSpawnInfoJobError", trad{FR: "⚠ Impossible de lancer ce job : %s", EN: "⚠ Unable to run this job: %s"}, nil, RunInfoTypInfo}
MsgWorkflowStarting = &Message{"MsgWorkflowStarting", trad{FR: "Le workflow %s#%s a été démarré", EN: "Workflow %s#%s has been started"}, nil, RunInfoTypInfo}
MsgWorkflowError = &Message{"MsgWorkflowError", trad{FR: "⚠ Une erreur est survenue: %v", EN: "⚠ An error has occurred: %v"}, nil, RunInfoTypeError}
MsgWorkflowConditionError = &Message{"MsgWorkflowConditionError", trad{FR: "Les conditions de lancement ne sont pas respectées.", EN: "Run conditions aren't ok."}, nil, RunInfoTypInfo}
MsgWorkflowNodeStop = &Message{"MsgWorkflowNodeStop", trad{FR: "Le pipeline a été arrété par %s", EN: "The pipeline has been stopped by %s"}, nil, RunInfoTypInfo}
MsgWorkflowNodeMutex = &Message{"MsgWorkflowNodeMutex", trad{FR: "Le pipeline %s est mis en attente tant qu'il est en cours sur un autre run", EN: "The pipeline %s is waiting while it's running on another run"}, nil, RunInfoTypInfo}
MsgWorkflowNodeMutexRelease = &Message{"MsgWorkflowNodeMutexRelease", trad{FR: "Lancement du pipeline %s", EN: "Triggering pipeline %s"}, nil, RunInfoTypInfo}
MsgWorkflowImportedUpdated = &Message{"MsgWorkflowImportedUpdated", trad{FR: "Le workflow %s a été mis à jour", EN: "Workflow %s has been updated"}, nil, RunInfoTypInfo}
MsgWorkflowImportedInserted = &Message{"MsgWorkflowImportedInserted", trad{FR: "Le workflow %s a été créé", EN: "Workflow %s has been created"}, nil, RunInfoTypInfo}
MsgSpawnInfoHatcheryCannotStartJob = &Message{"MsgSpawnInfoHatcheryCannotStart", trad{FR: "Aucune hatchery n'a pu démarrer de worker respectant vos pré-requis de job, merci de les vérifier.", EN: "No hatchery can spawn a worker corresponding your job's requirements. Please check your job's requirements."}, nil, RunInfoTypeWarning}
MsgWorkflowRunBranchDeleted = &Message{"MsgWorkflowRunBranchDeleted", trad{FR: "La branche %s a été supprimée", EN: "Branch %s has been deleted"}, nil, RunInfoTypInfo}
MsgWorkflowTemplateImportedInserted = &Message{"MsgWorkflowTemplateImportedInserted", trad{FR: "Le template de workflow %s/%s a été créé", EN: "Workflow template %s/%s has been created"}, nil, RunInfoTypInfo}
MsgWorkflowTemplateImportedUpdated = &Message{"MsgWorkflowTemplateImportedUpdated", trad{FR: "Le template de workflow %s/%s a été mis à jour", EN: "Workflow template %s/%s has been updated"}, nil, RunInfoTypInfo}
MsgWorkflowErrorBadPipelineName = &Message{"MsgWorkflowErrorBadPipelineName", trad{FR: "Le pipeline %s indiqué dans votre fichier yaml de workflow n'existe pas", EN: "The pipeline %s mentioned in your workflow's yaml file doesn't exist"}, nil, RunInfoTypeError}
MsgWorkflowErrorBadApplicationName = &Message{"MsgWorkflowErrorBadApplicationName", trad{FR: "L'application %s indiquée dans votre fichier yaml de workflow n'existe pas ou ne correspond pas aux normes ^[a-zA-Z0-9._-]{1,}$", EN: "The application %s mentioned in your workflow's yaml file doesn't exist or is incorrect with ^[a-zA-Z0-9._-]{1,}$"}, nil, RunInfoTypeError}
MsgWorkflowErrorBadEnvironmentName = &Message{"MsgWorkflowErrorBadEnvironmentName", trad{FR: "L'environnement %s indiqué dans votre fichier yaml de workflow n'existe pas", EN: "The environment %s mentioned in your workflow's yaml file doesn't exist"}, nil, RunInfoTypeError}
MsgWorkflowErrorBadIntegrationName = &Message{"MsgWorkflowErrorBadIntegrationName", trad{FR: "L'intégration %s indiquée dans votre fichier yaml n'existe pas", EN: "The integration %s mentioned in your yaml file doesn't exist"}, nil, RunInfoTypeError}
MsgWorkflowErrorBadCdsDir = &Message{"MsgWorkflowErrorBadCdsDir", trad{FR: "Un problème est survenu avec votre répertoire .cds", EN: "A problem occurred about your .cds directory"}, nil, RunInfoTypeError}
MsgWorkflowErrorUnknownKey = &Message{"MsgWorkflowErrorUnknownKey", trad{FR: "La clé '%s' est incorrecte ou n'existe pas", EN: "The key '%s' is incorrect or doesn't exist"}, nil, RunInfoTypeError}
MsgWorkflowErrorBadVCSStrategy = &Message{"MsgWorkflowErrorBadVCSStrategy", trad{FR: "Vos informations vcs_* sont incorrectes", EN: "Your vcs_* fields are incorrects"}, nil, RunInfoTypeError}
MsgWorkflowDeprecatedVersion = &Message{"MsgWorkflowDeprecatedVersion", trad{FR: "La configuration yaml de votre workflow est dans un format déprécié. Exportez le avec la CLI `cdsctl workflow export %s %s`", EN: "The yaml workflow configuration format is deprecated. Export your workflow with CLI `cdsctl workflow export %s %s`"}, nil, RunInfoTypeWarning}
MsgWorkflowGeneratedFromTemplateVersion = &Message{"MsgWorkflowGeneratedFromTemplateVersion", trad{FR: "Le workflow a été généré à partir du modèle de workflow: %s", EN: "The workflow was generated from the template: %s"}, nil, RunInfoTypInfo}
MsgTooMuchWorkflowRun = &Message{"MsgTooMuchWorkflowRun", trad{FR: "L'exécution de ce workflow est suspendu. Vous dépassez le nombre maximum d'éxécution autorisé (%.f). Merci de revoir la politique de retention de ce workflow", EN: "Workflow run is delayed. The maximum number of runs for this workflow has been reached ( %.f ). Please update your workflow retention policy"}, nil, RunInfoTypeWarning}
MsgSpawnErrorHatcheryRetryAttempt = &Message{"MsgSpawnErrorHatcheryRetryAttempt", trad{EN: "Job execution failed by hatchery %s. Reason: %s"}, nil, RunInfoTypeError}
MsgSpawnInfoDisableSecretInjection = &Message{"MsgSpawnInfoDisableSecretInjection", trad{EN: "⚠ Project's secrets were not automatically injected for this job because of a region prerequisite: %s"}, nil, RunInfoTypInfo}
MsgSpawnInfoManualSecretInjection = &Message{"MsgSpawnInfoManualSecretInjection", trad{EN: "Prerequisites of type secret matched %s secret(s)"}, nil, RunInfoTypInfo}
MsgSpawnInfoWorkerHookSetup = &Message{"MsgSpawnInfoWorkerHookSetup", trad{EN: "Setting up worker hook %q"}, nil, RunInfoTypInfo}
MsgSpawnInfoWorkerHookRun = &Message{"MsgSpawnInfoWorkerHookRun", trad{EN: "Running worker hook %q"}, nil, RunInfoTypInfo}
MsgSpawnInfoWorkerHookRunTeardown = &Message{"MsgSpawnInfoWorkerHookRunTeardown", trad{EN: "Running worker hook %q teardown"}, nil, RunInfoTypInfo}
MsgSpawnInfoWorkerDisabledByHatchery = &Message{"MsgSpawnInfoWorkerDisabledByHatchery", trad{EN: "The worker (not responding) %s was disabled by hatchery"}, nil, RunInfoTypeWarning}
MsgSpawnInfoWorkerDisabledByAdmin = &Message{"MsgSpawnInfoWorkerDisabledByAdmin", trad{EN: "The worker %s was disabled by an administrator"}, nil, RunInfoTypeWarning}
MsgSpawnInfoJobFailedCauseByWorkerLost = &Message{"MsgSpawnInfoJobFailedCauseByWorkerLost", trad{EN: "The job %s was set to failed due to lost connection with the worker"}, nil, RunInfoTypeWarning}
)
// Messages contains all sdk Messages
var Messages = map[string]*Message{
MsgAppCreated.ID: MsgAppCreated,
MsgAppUpdated.ID: MsgAppUpdated,
MsgPipelineCreated.ID: MsgPipelineCreated,
MsgPipelineCreationAborted.ID: MsgPipelineCreationAborted,
MsgPipelineExists.ID: MsgPipelineExists,
MsgAppVariablesCreated.ID: MsgAppVariablesCreated,
MsgAppKeyCreated.ID: MsgAppKeyCreated,
MsgEnvironmentExists.ID: MsgEnvironmentExists,
MsgEnvironmentCreated.ID: MsgEnvironmentCreated,
MsgEnvironmentVariableUpdated.ID: MsgEnvironmentVariableUpdated,
MsgEnvironmentVariableCannotBeUpdated.ID: MsgEnvironmentVariableCannotBeUpdated,
MsgEnvironmentVariableCreated.ID: MsgEnvironmentVariableCreated,
MsgEnvironmentVariableCannotBeCreated.ID: MsgEnvironmentVariableCannotBeCreated,
MsgEnvironmentGroupUpdated.ID: MsgEnvironmentGroupUpdated,
MsgEnvironmentGroupCannotBeUpdated.ID: MsgEnvironmentGroupCannotBeUpdated,
MsgEnvironmentGroupCreated.ID: MsgEnvironmentGroupCreated,
MsgEnvironmentGroupCannotBeCreated.ID: MsgEnvironmentGroupCannotBeCreated,
MsgEnvironmentGroupDeleted.ID: MsgEnvironmentGroupDeleted,
MsgEnvironmentGroupCannotBeDeleted.ID: MsgEnvironmentGroupCannotBeDeleted,
MsgEnvironmentKeyCreated.ID: MsgEnvironmentKeyCreated,
MsgEnvironmentKeyCannotBeCreated.ID: MsgEnvironmentKeyCannotBeCreated,
MsgJobNotValidActionNotFound.ID: MsgJobNotValidActionNotFound,
MsgJobNotValidInvalidActionParameter.ID: MsgJobNotValidInvalidActionParameter,
MsgPipelineGroupUpdated.ID: MsgPipelineGroupUpdated,
MsgPipelineGroupAdded.ID: MsgPipelineGroupAdded,
MsgPipelineGroupDeleted.ID: MsgPipelineGroupDeleted,
MsgPipelineStageUpdated.ID: MsgPipelineStageUpdated,
MsgPipelineStageUpdating.ID: MsgPipelineStageUpdating,
MsgPipelineStageDeletingOldJobs.ID: MsgPipelineStageDeletingOldJobs,
MsgPipelineStageInsertingNewJobs.ID: MsgPipelineStageInsertingNewJobs,
MsgPipelineStageAdded.ID: MsgPipelineStageAdded,
MsgPipelineStageDeleted.ID: MsgPipelineStageDeleted,
MsgPipelineJobUpdated.ID: MsgPipelineJobUpdated,
MsgPipelineJobAdded.ID: MsgPipelineJobAdded,
MsgPipelineJobDeleted.ID: MsgPipelineJobDeleted,
MsgPipelineDetached.ID: MsgPipelineDetached,
MsgApplicationDetached.ID: MsgApplicationDetached,
MsgEnvironmentDetached.ID: MsgEnvironmentDetached,
MsgWorkflowDetached.ID: MsgWorkflowDetached,
MsgSpawnInfoHatcheryStarts.ID: MsgSpawnInfoHatcheryStarts,
MsgSpawnInfoHatcheryErrorSpawn.ID: MsgSpawnInfoHatcheryErrorSpawn,
MsgSpawnInfoHatcheryStartDockerPull.ID: MsgSpawnInfoHatcheryStartDockerPull,
MsgSpawnInfoHatcheryEndDockerPull.ID: MsgSpawnInfoHatcheryEndDockerPull,
MsgSpawnInfoHatcheryEndDockerPullErr.ID: MsgSpawnInfoHatcheryEndDockerPullErr,
MsgSpawnInfoDeprecatedModel.ID: MsgSpawnInfoDeprecatedModel,
MsgSpawnInfoWorkerEnd.ID: MsgSpawnInfoWorkerEnd,
MsgSpawnInfoJobDisabled.ID: MsgSpawnInfoJobDisabled,
MsgSpawnInfoJobInQueue.ID: MsgSpawnInfoJobInQueue,
MsgSpawnInfoJobTaken.ID: MsgSpawnInfoJobTaken,
MsgSpawnInfoJobTakenWorkerVersion.ID: MsgSpawnInfoJobTakenWorkerVersion,
MsgSpawnInfoWorkerForJob.ID: MsgSpawnInfoWorkerForJob,
MsgSpawnInfoWorkerForJobError.ID: MsgSpawnInfoWorkerForJobError,
MsgSpawnInfoJobError.ID: MsgSpawnInfoJobError,
MsgWorkflowStarting.ID: MsgWorkflowStarting,
MsgWorkflowError.ID: MsgWorkflowError,
MsgWorkflowConditionError.ID: MsgWorkflowConditionError,
MsgWorkflowNodeStop.ID: MsgWorkflowNodeStop,
MsgWorkflowNodeMutex.ID: MsgWorkflowNodeMutex,
MsgWorkflowNodeMutexRelease.ID: MsgWorkflowNodeMutexRelease,
MsgWorkflowImportedUpdated.ID: MsgWorkflowImportedUpdated,
MsgWorkflowImportedInserted.ID: MsgWorkflowImportedInserted,
MsgSpawnInfoHatcheryCannotStartJob.ID: MsgSpawnInfoHatcheryCannotStartJob,
MsgWorkflowRunBranchDeleted.ID: MsgWorkflowRunBranchDeleted,
MsgWorkflowTemplateImportedInserted.ID: MsgWorkflowTemplateImportedInserted,
MsgWorkflowTemplateImportedUpdated.ID: MsgWorkflowTemplateImportedUpdated,
MsgWorkflowErrorBadPipelineName.ID: MsgWorkflowErrorBadPipelineName,
MsgWorkflowErrorBadApplicationName.ID: MsgWorkflowErrorBadApplicationName,
MsgWorkflowErrorBadEnvironmentName.ID: MsgWorkflowErrorBadEnvironmentName,
MsgWorkflowErrorBadIntegrationName.ID: MsgWorkflowErrorBadIntegrationName,
MsgWorkflowErrorBadCdsDir.ID: MsgWorkflowErrorBadCdsDir,
MsgWorkflowErrorUnknownKey.ID: MsgWorkflowErrorUnknownKey,
MsgWorkflowErrorBadVCSStrategy.ID: MsgWorkflowErrorBadVCSStrategy,
MsgWorkflowDeprecatedVersion.ID: MsgWorkflowDeprecatedVersion,
MsgWorkflowGeneratedFromTemplateVersion.ID: MsgWorkflowGeneratedFromTemplateVersion,
MsgTooMuchWorkflowRun.ID: MsgTooMuchWorkflowRun,
MsgSpawnErrorHatcheryRetryAttempt.ID: MsgSpawnErrorHatcheryRetryAttempt,
MsgSpawnInfoDisableSecretInjection.ID: MsgSpawnInfoDisableSecretInjection,
MsgSpawnInfoManualSecretInjection.ID: MsgSpawnInfoManualSecretInjection,
MsgSpawnInfoWorkerHookSetup.ID: MsgSpawnInfoWorkerHookSetup,
MsgSpawnInfoWorkerHookRun.ID: MsgSpawnInfoWorkerHookRun,
MsgSpawnInfoWorkerHookRunTeardown.ID: MsgSpawnInfoWorkerHookRunTeardown,
MsgSpawnInfoWorkerDisabledByHatchery.ID: MsgSpawnInfoWorkerDisabledByHatchery,
MsgSpawnInfoWorkerDisabledByAdmin.ID: MsgSpawnInfoWorkerDisabledByAdmin,
MsgSpawnInfoJobFailedCauseByWorkerLost.ID: MsgSpawnInfoJobFailedCauseByWorkerLost,
}
// Message represent a struc format translated messages
type Message struct {
ID string
Format trad
Args []interface{}
Type string
}
func (m Message) ToSpawnMsg() SpawnMsg {
return SpawnMsg{ID: m.ID, Args: m.Args, Type: m.Type}
}
// NewMessage instanciantes a new message
func NewMessage(m *Message, args ...interface{}) Message {
return Message{
Format: m.Format,
Args: args,
ID: m.ID,
Type: m.Type,
}
}
// SupportedLanguages on API errors
var (
SupportedLanguages = []language.Tag{
language.AmericanEnglish,
language.French,
}
)
// String returns formated string for the specified language
func (m *Message) String() string {
return fmt.Sprintf(m.Format[EN], m.Args...)
}
// MessagesToError returns a translated slices of messages as an error
func MessagesToError(messages []Message) error {
var s string
for i, err := range messages {
if i != 0 {
s += "; "
}
s += err.String()
}
return errors.New(s)
}
// ErrorToMessage returns message from an error if possible
func ErrorToMessage(err error) (Message, bool) {
cdsError := ExtractHTTPError(err)
switch cdsError.ID {
case ErrPipelineNotFound.ID:
return NewMessage(MsgWorkflowErrorBadPipelineName, cdsError.Data), true
case ErrEnvironmentNotFound.ID:
return NewMessage(MsgWorkflowErrorBadEnvironmentName, cdsError.Data), true
}
return Message{}, false
}