Skip to content

Commit 37e75cb

Browse files
authored
Remove duplicate validation code (#195)
1 parent 92d2f6e commit 37e75cb

File tree

1 file changed

+4
-31
lines changed

1 file changed

+4
-31
lines changed

cmd/src/actions_exec.go

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,6 @@ Format of the action JSON files:
211211

212212
logger := newActionLogger(*verbose, *keepLogsFlag)
213213

214-
err = validateAction(ctx, action)
215-
if err != nil {
216-
return errors.Wrap(err, "Validation of action failed")
217-
}
218-
219214
// Build Docker images etc.
220215
err = prepareAction(ctx, action)
221216
if err != nil {
@@ -355,38 +350,16 @@ func validateActionDefinition(def []byte) error {
355350
return errs.ErrorOrNil()
356351
}
357352

358-
func validateAction(ctx context.Context, action Action) error {
359-
for _, step := range action.Steps {
360-
if step.Type == "docker" {
361-
if step.Image == "" {
362-
return fmt.Errorf("docker run step has to specify 'image'")
363-
}
364-
365-
if step.ImageContentDigest != "" {
366-
return errors.New("setting the ImageContentDigest field of a docker run step is not allowed")
367-
}
368-
}
369-
370-
if step.Type == "command" && len(step.Args) < 1 {
371-
return errors.New("command run step has to specify 'args'")
372-
}
373-
}
374-
375-
return nil
376-
}
377-
378353
func prepareAction(ctx context.Context, action Action) error {
379354
// Build any Docker images.
380355
for _, step := range action.Steps {
381356
if step.Type == "docker" {
382357
// Set digests for Docker images so we don't cache action runs in 2 different images with
383358
// the same tag.
384-
if step.Image != "" {
385-
var err error
386-
step.ImageContentDigest, err = getDockerImageContentDigest(ctx, step.Image)
387-
if err != nil {
388-
return errors.Wrap(err, "Failed to get Docker image content digest")
389-
}
359+
var err error
360+
step.ImageContentDigest, err = getDockerImageContentDigest(ctx, step.Image)
361+
if err != nil {
362+
return errors.Wrap(err, "Failed to get Docker image content digest")
390363
}
391364
}
392365
}

0 commit comments

Comments
 (0)