@@ -29,7 +29,6 @@ import (
29
29
"github.com/tektoncd/pipeline/pkg/apis/config"
30
30
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
31
31
"github.com/tektoncd/pipeline/pkg/internal/resultref"
32
- "k8s.io/apimachinery/pkg/util/sets"
33
32
"k8s.io/apimachinery/pkg/util/validation"
34
33
"knative.dev/pkg/apis"
35
34
)
@@ -104,7 +103,8 @@ func RefNameLikeUrl(name string) error {
104
103
return nil
105
104
}
106
105
107
- func validateStep (ctx context.Context , s Step , names sets.String ) (errs * apis.FieldError ) {
106
+ // Validate implements apis.Validatable
107
+ func (s * Step ) Validate (ctx context.Context ) (errs * apis.FieldError ) {
108
108
if err := validateArtifactsReferencesInStep (ctx , s ); err != nil {
109
109
return err
110
110
}
@@ -181,17 +181,13 @@ func validateStep(ctx context.Context, s Step, names sets.String) (errs *apis.Fi
181
181
}
182
182
183
183
if s .Name != "" {
184
- if names .Has (s .Name ) {
185
- errs = errs .Also (apis .ErrMultipleOneOf ("name" ))
186
- }
187
184
if e := validation .IsDNS1123Label (s .Name ); len (e ) > 0 {
188
185
errs = errs .Also (& apis.FieldError {
189
186
Message : fmt .Sprintf ("invalid value %q" , s .Name ),
190
187
Paths : []string {"name" },
191
188
Details : "Task step name must be a valid DNS Label, For more info refer to https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names" ,
192
189
})
193
190
}
194
- names .Insert (s .Name )
195
191
}
196
192
197
193
if s .Timeout != nil {
@@ -254,7 +250,7 @@ func isParamRefs(s string) bool {
254
250
return strings .HasPrefix (s , "$(" + ParamsPrefix )
255
251
}
256
252
257
- func validateArtifactsReferencesInStep (ctx context.Context , s Step ) * apis.FieldError {
253
+ func validateArtifactsReferencesInStep (ctx context.Context , s * Step ) * apis.FieldError {
258
254
cfg := config .FromContextOrDefaults (ctx )
259
255
if cfg == nil || cfg .FeatureFlags == nil {
260
256
cfg = & config.Config {
@@ -295,11 +291,11 @@ func taskArtifactReferenceExists(src string) bool {
295
291
return len (artifactref .TaskArtifactRegex .FindAllStringSubmatch (src , - 1 )) > 0 || strings .Contains (src , "$(" + artifactref .TaskArtifactPathPattern + ")" )
296
292
}
297
293
298
- func validateStepResultReference (s Step ) (errs * apis.FieldError ) {
294
+ func validateStepResultReference (s * Step ) (errs * apis.FieldError ) {
299
295
errs = errs .Also (errorIfStepResultReferencedInField (s .Name , "name" ))
300
296
errs = errs .Also (errorIfStepResultReferencedInField (s .Image , "image" ))
301
297
errs = errs .Also (errorIfStepResultReferencedInField (s .Script , "script" ))
302
- errs = errs .Also (errorIfStepResultReferencedInField (string (s .ImagePullPolicy ), "imagePullPoliicy " ))
298
+ errs = errs .Also (errorIfStepResultReferencedInField (string (s .ImagePullPolicy ), "imagePullPolicy " ))
303
299
errs = errs .Also (errorIfStepResultReferencedInField (s .WorkingDir , "workingDir" ))
304
300
for _ , e := range s .EnvFrom {
305
301
errs = errs .Also (errorIfStepResultReferencedInField (e .Prefix , "envFrom.prefix" ))
@@ -333,7 +329,7 @@ func errorIfStepResultReferencedInField(value, fieldName string) (errs *apis.Fie
333
329
return errs
334
330
}
335
331
336
- func validateStepArtifactsReference (s Step ) (errs * apis.FieldError ) {
332
+ func validateStepArtifactsReference (s * Step ) (errs * apis.FieldError ) {
337
333
errs = errs .Also (errorIfStepArtifactReferencedInField (s .Name , "name" ))
338
334
errs = errs .Also (errorIfStepArtifactReferencedInField (s .Image , "image" ))
339
335
errs = errs .Also (errorIfStepArtifactReferencedInField (string (s .ImagePullPolicy ), "imagePullPolicy" ))
0 commit comments