From b886f62e74685af71f30ffd1c63e540d721182d5 Mon Sep 17 00:00:00 2001 From: Erik Seliger Date: Tue, 5 May 2020 18:27:49 +0200 Subject: [PATCH] Remove duplicate validation code All the cases covered by this function are caught by the JSON schema. --- cmd/src/actions_exec.go | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/cmd/src/actions_exec.go b/cmd/src/actions_exec.go index b0c01cbff9..38f79052fa 100644 --- a/cmd/src/actions_exec.go +++ b/cmd/src/actions_exec.go @@ -211,11 +211,6 @@ Format of the action JSON files: logger := newActionLogger(*verbose, *keepLogsFlag) - err = validateAction(ctx, action) - if err != nil { - return errors.Wrap(err, "Validation of action failed") - } - // Build Docker images etc. err = prepareAction(ctx, action) if err != nil { @@ -355,38 +350,16 @@ func validateActionDefinition(def []byte) error { return errs.ErrorOrNil() } -func validateAction(ctx context.Context, action Action) error { - for _, step := range action.Steps { - if step.Type == "docker" { - if step.Image == "" { - return fmt.Errorf("docker run step has to specify 'image'") - } - - if step.ImageContentDigest != "" { - return errors.New("setting the ImageContentDigest field of a docker run step is not allowed") - } - } - - if step.Type == "command" && len(step.Args) < 1 { - return errors.New("command run step has to specify 'args'") - } - } - - return nil -} - func prepareAction(ctx context.Context, action Action) error { // Build any Docker images. for _, step := range action.Steps { if step.Type == "docker" { // Set digests for Docker images so we don't cache action runs in 2 different images with // the same tag. - if step.Image != "" { - var err error - step.ImageContentDigest, err = getDockerImageContentDigest(ctx, step.Image) - if err != nil { - return errors.Wrap(err, "Failed to get Docker image content digest") - } + var err error + step.ImageContentDigest, err = getDockerImageContentDigest(ctx, step.Image) + if err != nil { + return errors.Wrap(err, "Failed to get Docker image content digest") } } }