Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore copy file on missing source #687

Merged
merged 5 commits into from
Jan 31, 2021
Merged

Ignore copy file on missing source #687

merged 5 commits into from
Jan 31, 2021

Conversation

ademariag
Copy link
Contributor

@ademariag ademariag commented Jan 29, 2021

Fixes issue #688

Proposed Changes

Allows the "copy" input type to continue even if the source path is missing.

The main motivation behins this change is to enable a workaround to handle terraform lock files which are now being produced when running terraform init, see hashicorp/terraform#27241

The solution would be to allow adding the following copy settings:

 kapitan:
    compile:
      - input_type: copy
        ignore_missing: true
        input_paths:
          - resources/state/${target_name}/.terraform.lock.hcl
        output_path: terraform/

Without this feature, the compile process would fail for all new environments where the state file has not already been placed in the state folder.

@ademariag ademariag requested review from ramaro and uberspot January 29, 2021 22:25
@ademariag ademariag marked this pull request as ready for review January 30, 2021 12:53
compile_path = os.path.abspath(compile_path) # Resolve relative paths
copy_tree(file_path, compile_path)
elif ignore_missing == False:
raise OSError(f"Path {file_path} does not exist and `ignore_missing` is {ignore_missing}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's better to raise CompileError to keep kapitan error handling/printing consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ramaro I used the same error that was already raised in line 39. Shall I also change that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants