@@ -45,6 +45,11 @@ func Validate(config *latest.Config) error {
4545 return err
4646 }
4747
48+ err = validatePipelines (config )
49+ if err != nil {
50+ return err
51+ }
52+
4853 err = validateImages (config )
4954 if err != nil {
5055 return err
@@ -85,11 +90,8 @@ func Validate(config *latest.Config) error {
8590
8691func validateVars (vars map [string ]* latest.Variable ) error {
8792 for i , v := range vars {
88- if i == "" {
89- return fmt .Errorf ("vars[*].name has to be specified" )
90- }
9193 if encoding .IsUnsafeUpperName (v .Name ) {
92- return fmt .Errorf ("vars[%s].name %s has to match the following regex: %v" , i , v . Name , encoding .UnsafeUpperNameRegEx .String ())
94+ return fmt .Errorf ("vars. %s has to match the following regex: %v" , i , encoding .UnsafeUpperNameRegEx .String ())
9395 }
9496 }
9597
@@ -118,16 +120,26 @@ func validateRequire(config *latest.Config) error {
118120 return nil
119121}
120122
123+ func validatePipelines (config * latest.Config ) error {
124+ for name := range config .Pipelines {
125+ if encoding .IsUnsafeName (name ) {
126+ return fmt .Errorf ("pipelines.%s has to match the following regex: %v" , name , encoding .UnsafeNameRegEx .String ())
127+ }
128+ }
129+
130+ return nil
131+ }
132+
121133func validateDependencies (config * latest.Config ) error {
122134 for name , dep := range config .Dependencies {
123135 if encoding .IsUnsafeName (name ) {
124- return fmt .Errorf ("dependencies[%s] has to match the following regex: %v" , name , encoding .UnsafeNameRegEx .String ())
136+ return fmt .Errorf ("dependencies.%s has to match the following regex: %v" , name , encoding .UnsafeNameRegEx .String ())
125137 }
126138 if dep .Source == nil {
127- return errors .Errorf ("dependencies[%s] .source is required" , name )
139+ return errors .Errorf ("dependencies.%s .source is required" , name )
128140 }
129141 if dep .Source .Git == "" && dep .Source .Path == "" {
130- return errors .Errorf ("dependencies[%s] .git or dependencies[%s].path is required" , name , name )
142+ return errors .Errorf ("dependencies.%s .git or dependencies[%s].path is required" , name , name )
131143 }
132144 }
133145
@@ -136,14 +148,11 @@ func validateDependencies(config *latest.Config) error {
136148
137149func validateCommands (config * latest.Config ) error {
138150 for key , command := range config .Commands {
139- if command .Name == "" {
140- return errors .Errorf ("commands[%s].name is required" , key )
141- }
142- if encoding .IsUnsafeUpperName (command .Name ) {
143- return fmt .Errorf ("commands[%s] has to match the following regex: %v" , command .Name , encoding .UnsafeUpperNameRegEx .String ())
151+ if encoding .IsUnsafeName (command .Name ) {
152+ return fmt .Errorf ("commands.%s has to match the following regex: %v" , command .Name , encoding .UnsafeNameRegEx .String ())
144153 }
145154 if command .Command == "" {
146- return errors .Errorf ("commands[%s] .command is required" , key )
155+ return errors .Errorf ("commands.%s .command is required" , key )
147156 }
148157 }
149158
@@ -207,18 +216,18 @@ func validateHooks(config *latest.Config) error {
207216
208217func validateDeployments (config * latest.Config ) error {
209218 for index , deployConfig := range config .Deployments {
210- if deployConfig .Name == "" {
211- return errors .Errorf ("deployments[%s].name is required" , index )
212- }
213219 if encoding .IsUnsafeName (deployConfig .Name ) {
214- return fmt .Errorf ("deployments[%s].name %s has to match the following regex: %v" , index , deployConfig . Name , encoding .UnsafeNameRegEx .String ())
220+ return fmt .Errorf ("deployments. %s has to match the following regex: %v" , index , encoding .UnsafeNameRegEx .String ())
215221 }
216222 if deployConfig .Helm == nil && deployConfig .Kubectl == nil {
217223 return errors .Errorf ("Please specify either helm or kubectl as deployment type in deployment %s" , deployConfig .Name )
218224 }
219225 if deployConfig .Kubectl != nil && deployConfig .Kubectl .Manifests == nil {
220226 return errors .Errorf ("deployments[%s].kubectl.manifests is required" , index )
221227 }
228+ if deployConfig .Kubectl != nil && deployConfig .Helm != nil {
229+ return errors .Errorf ("deployments[%s].kubectl and deployments[%s].helm cannot be used together" , index , index )
230+ }
222231 }
223232
224233 return nil
@@ -243,11 +252,11 @@ func ValidateComponentConfig(deployConfig *latest.DeploymentConfig, overwriteVal
243252
244253func validatePullSecrets (config * latest.Config ) error {
245254 for _ , ps := range config .PullSecrets {
246- if ps .Name == "" {
247- return errors .Errorf ("pull secret keys cannot be an empty string" )
248- }
249255 if encoding .IsUnsafeName (ps .Name ) {
250- return fmt .Errorf ("pullSecrets[%s] has to match the following regex: %v" , ps .Name , encoding .UnsafeNameRegEx .String ())
256+ return fmt .Errorf ("pullSecrets.%s has to match the following regex: %v" , ps .Name , encoding .UnsafeNameRegEx .String ())
257+ }
258+ if ps .Registry == "" {
259+ return fmt .Errorf ("pullSecrets.%s.registry is required" , ps .Name )
251260 }
252261 }
253262
@@ -258,11 +267,8 @@ func validateImages(config *latest.Config) error {
258267 // images lists all the image names in order to check for duplicates
259268 images := map [string ]bool {}
260269 for imageConfigName , imageConf := range config .Images {
261- if imageConfigName == "" {
262- return errors .Errorf ("images keys cannot be an empty string" )
263- }
264270 if encoding .IsUnsafeName (imageConfigName ) {
265- return fmt .Errorf ("images[%s] has to match the following regex: %v" , imageConfigName , encoding .UnsafeNameRegEx .String ())
271+ return fmt .Errorf ("images.%s has to match the following regex: %v" , imageConfigName , encoding .UnsafeNameRegEx .String ())
266272 }
267273 if imageConf == nil {
268274 return errors .Errorf ("images.%s is empty and should at least contain an image name" , imageConfigName )
@@ -304,14 +310,11 @@ func validateImages(config *latest.Config) error {
304310func validateDev (config * latest.Config ) error {
305311 for devPodName , devPod := range config .Dev {
306312 devPodName = strings .TrimSpace (devPodName )
307- if devPodName == "" {
308- return errors .Errorf ("dev[%s] is required" , devPodName )
309- }
310313 if encoding .IsUnsafeName (devPodName ) {
311- return fmt .Errorf ("dev[%s] has to match the following regex: %v" , devPodName , encoding .UnsafeNameRegEx .String ())
314+ return fmt .Errorf ("dev.%s has to match the following regex: %v" , devPodName , encoding .UnsafeNameRegEx .String ())
312315 }
313316 if len (devPod .LabelSelector ) == 0 && devPod .ImageSelector == "" {
314- return errors .Errorf ("dev[%s] : image selector and label selector are nil" , devPodName )
317+ return errors .Errorf ("dev.%s : image selector and label selector are nil" , devPodName )
315318 }
316319
317320 definedSelectors := 0
@@ -322,16 +325,16 @@ func validateDev(config *latest.Config) error {
322325 definedSelectors ++
323326 }
324327 if definedSelectors > 1 {
325- return errors .Errorf ("dev[%s] : image selector and label selector cannot all be defined " , devPodName )
328+ return errors .Errorf ("dev.%s : image selector and label selector cannot be used together " , devPodName )
326329 }
327330
328- err := validateDevContainer (fmt .Sprintf ("dev[%s] " , devPodName ), & devPod .DevContainer , false )
331+ err := validateDevContainer (fmt .Sprintf ("dev.%s " , devPodName ), & devPod .DevContainer , false )
329332 if err != nil {
330333 return err
331334 }
332335 if len (devPod .Containers ) > 0 {
333336 for i , c := range devPod .Containers {
334- err := validateDevContainer (fmt .Sprintf ("dev[%s] .containers[%s]" , devPodName , i ), c , true )
337+ err := validateDevContainer (fmt .Sprintf ("dev.%s .containers[%s]" , devPodName , i ), c , true )
335338 if err != nil {
336339 return err
337340 }
0 commit comments