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

added 'mode' argument #80

Closed
wants to merge 1 commit into from
Closed

added 'mode' argument #80

wants to merge 1 commit into from

Conversation

ricardbejarano
Copy link

Proposed solution for #17.

Adds the mode argument to the archive_file data source:

data "archive_file" "test" {
  source_dir  = "src"
  output_path = "src.zip"
  type        = "zip"
  mode        = 755  // or 0755 (zero-trailed), doesn't matter
}

Works exclusively with source_dir or source_file.
It performs the equivalent of a chmod -R ${mode} ${source_dir|source_file} before deflating.


Tested with Terraform v0.13.5:

$ mkdir -p src/code
$ echo "is Hashicorp hiring SREs?" > src/code/test-one.txt
$ echo "if so, let me know ;P" > src/code/test-two.txt
$ chmod -R 700 src 
$ \ls -l src/code 
total 16
-rwx------  1 caretaker  staff  26 Jan 23 20:57 test-one.txt
-rwx------  1 caretaker  staff  22 Jan 23 20:58 test-two.txt


$ terraform apply
data.archive_file.test: Refreshing state... [id=4bab5837844bf9b668fc2e80172e86622db79742]

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.


$ rm -rf src
$ unzip src.zip 
Archive:  src.zip
  inflating: code/test-one.txt       
  inflating: code/test-two.txt       
$ \ls -l code 
total 16
-rwxr-xr-x  1 caretaker  staff  26 Jan  1  2049 test-one.txt
-rwxr-xr-x  1 caretaker  staff  22 Jan  1  2049 test-two.txt
$

Works as well with source_file.

@hashicorp-cla
Copy link

hashicorp-cla commented Jan 23, 2021

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes


Ricard Bejarano seems not to be a GitHub user.
You need a GitHub account to be able to sign the CLA.
If you have already a GitHub account, please add the email address used for this commit to your account.

Have you signed the CLA already but the status is still pending? Recheck it.

@ricardbejarano
Copy link
Author

Logs on failed runs in Travis show as null to me, but the PR'd changes should work just fine.

Base automatically changed from master to main February 1, 2021 17:31
@ricardbejarano
Copy link
Author

ricardbejarano commented Mar 10, 2021

CI shows as failed not because any jobs failed. but because they didn't run, they show as "cancelled".

Can a maintainer please retrigger them and then review/merge?
Can we get some activity?

Thanks!

@virgofx
Copy link
Contributor

virgofx commented May 5, 2021

The workaround in #90 has been released in terraform-provider-archive v2.2.0 which adds output_file_mode and supercedes this PR. I think this can be closed now.

@ricardbejarano
Copy link
Author

I'm afraid these are separate issues.

I haven't checked but output_file_mode sounds like the mode the outputted .zip file gets, while this PR is to change the permissions of the contents once inflated.

These are separate issues I'm afraid.

@virgofx
Copy link
Contributor

virgofx commented May 5, 2021

@ricardbejarano output_file_mode is for the files contained within the zip. Not the outer file which is what I think you're thinking it does? Since that's not the case, wouldn't that fix your issue?

We probably could have thought longer about the parameter name, if that's causing confusing; however, it's documented fairly thoroughly with an example. I think it should suffice.

Thus, I would recommend that we close this PR.

Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants