Skip to content

terraform_providers_lock produces error when terraform_validate is not called before #949

@jaygridley

Description

@jaygridley

With introduction of mode support to terraform_providers_lock hooks it should be possible to run the hook without terraform_validate when mode=only-check-is-current-lockfile-cross-platform, but it is not working as advertised.

It works as advertised only when lockfile_contains_all_needed_sha returns 0 = when the lock file is valid. If it NOT valid, for example it is missing hash for some platform, the condition

lockfile_contains_all_needed_sha "$platforms_count"; then
fails and code continues and runs terraform providers lock on line
"$tf_path" providers lock "${args[@]}"
.

IMHO the condition could be rewritten to:

if [ "$mode" == "only-check-is-current-lockfile-cross-platform" ] ; then
    lockfile_contains_all_needed_sha "$platforms_count"

    exit_code=$?
    return $exit_code
  fi

In this case it could be executed in mode=only-check-is-current-lockfile-cross-platform without running terraform_validate which runs terraform init under the hood.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions