@@ -561,7 +561,7 @@ func (st *Step) ValidAndNormalize(name string, baseConfigs map[string]json.RawMe
561561 }
562562 preHook , err := st .GetPreHook ()
563563 if err != nil {
564- return errors .NewNotValid (err , "Invalid prehook action" )
564+ return errors .NewNotValid (err , "Invalid prehook action" )
565565 }
566566 if preHook != nil {
567567 ph , err := validExecutor (baseConfigs , * preHook , nil )
@@ -573,52 +573,6 @@ func (st *Step) ValidAndNormalize(name string, baseConfigs map[string]json.RawMe
573573 }
574574 }
575575
576- // check that we don't set restricted field from the template
577- if st .State != "" {
578- return errors .NewNotValid (nil , "step state must not be set" )
579- }
580-
581- if st .ChildrenSteps != nil {
582- return errors .NewNotValid (nil , "step children_steps must not be set" )
583- }
584-
585- if st .ChildrenStepMap != nil {
586- return errors .NewNotValid (nil , "step children_steps_map must not be set" )
587- }
588-
589- if st .Output != nil {
590- return errors .NewNotValid (nil , "step output must not be set" )
591- }
592-
593- if st .Metadata != nil {
594- return errors .NewNotValid (nil , "step metadatas must not be set" )
595- }
596-
597- if st .Tags != nil {
598- return errors .NewNotValid (nil , "step tags must not be set" )
599- }
600-
601- if st .Children != nil {
602- return errors .NewNotValid (nil , "step children must not be set" )
603- }
604-
605- if st .Error != "" {
606- return errors .NewNotValid (nil , "step error must not be set" )
607- }
608-
609- if st .TryCount != 0 {
610- return errors .NewNotValid (nil , "step try_count must not be set" )
611- }
612-
613- t := time.Time {}
614- if st .LastRun != t {
615- return errors .NewNotValid (nil , "step last_time must not be set" )
616- }
617-
618- if st .Item != nil {
619- return errors .NewNotValid (nil , "step item must not be set" )
620- }
621-
622576 if st .ForEachStrategy != "" && st .ForEach == "" {
623577 return errors .NewNotValid (nil , "step foreach_strategy can't be set without foreach" )
624578 }
@@ -711,6 +665,58 @@ func (st *Step) ValidAndNormalize(name string, baseConfigs map[string]json.RawMe
711665 return nil
712666}
713667
668+ // ValidAndNormalizeNewStep will validate that a given step doesn't have extragenous fields defined
669+ // when coming from a task_template.
670+ func (st * Step ) ValidAndNormalizeNewStep () error {
671+ // check that we don't set restricted field from the template
672+ if st .State != "" {
673+ return errors .NewNotValid (nil , "step state must not be set" )
674+ }
675+
676+ if st .ChildrenSteps != nil {
677+ return errors .NewNotValid (nil , "step children_steps must not be set" )
678+ }
679+
680+ if st .ChildrenStepMap != nil {
681+ return errors .NewNotValid (nil , "step children_steps_map must not be set" )
682+ }
683+
684+ if st .Output != nil {
685+ return errors .NewNotValid (nil , "step output must not be set" )
686+ }
687+
688+ if st .Metadata != nil {
689+ return errors .NewNotValid (nil , "step metadatas must not be set" )
690+ }
691+
692+ if st .Tags != nil {
693+ return errors .NewNotValid (nil , "step tags must not be set" )
694+ }
695+
696+ if st .Children != nil {
697+ return errors .NewNotValid (nil , "step children must not be set" )
698+ }
699+
700+ if st .Error != "" {
701+ return errors .NewNotValid (nil , "step error must not be set" )
702+ }
703+
704+ if st .TryCount != 0 {
705+ return errors .NewNotValid (nil , "step try_count must not be set" )
706+ }
707+
708+ t := time.Time {}
709+ if st .LastRun != t {
710+ return errors .NewNotValid (nil , "step last_time must not be set" )
711+ }
712+
713+ if st .Item != nil {
714+ return errors .NewNotValid (nil , "step item must not be set" )
715+ }
716+
717+ return nil
718+ }
719+
714720// IsRunnable asserts that Step is in a runnable state
715721func (st * Step ) IsRunnable () bool {
716722 return utils .ListContainsString (runnableStates , st .State )
0 commit comments