Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 4 additions & 31 deletions cmd/src/actions_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
}
}
}
Expand Down