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

Create resource for tar archiving #677

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mattesko
Copy link
Contributor

This is a work-in-progress

Notes

  1. Create a tar resource so that files and directories can be archived
  2. Features a compression parameter to choose whether to compress the resulting archive with gzip
  3. Create an mcl example for the tar resource

file "/tmp/mgmt/file2.txt" {
content => "hello world",
state => $const.res.file.state.exists,
Before => Tar["${filepath}"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Implementing AutoEdges for the tar resource would make this not necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do.

@mattesko
Copy link
Contributor Author

mattesko commented Dec 12, 2021

I'm still implementing this. I'm trying to fix a bug where Watch keeps notifying mgmt about a state change, and CheckApply runs in an infinite loop:

...
13:54:45 engine: tar[/tmp/mytar.tar]: CheckApply(true): Return(true, <nil>)
13:54:45 engine: tar[/tmp/mytar.tar]: resource: Event(/tmp/mytar.tar): WRITE
13:54:45 engine: tar[/tmp/mytar.tar]: CheckApply(true)
13:54:45 engine: tar[/tmp/mytar.tar]: CheckApply(true): Return(true, <nil>)
13:54:45 engine: tar[/tmp/mytar.tar]: resource: Event(/tmp/mytar.tar): WRITE
13:54:45 engine: tar[/tmp/mytar.tar]: CheckApply(true)
13:54:45 engine: tar[/tmp/mytar.tar]: CheckApply(true): Return(true, <nil>)
13:54:45 engine: tar[/tmp/mytar.tar]: resource: Event(/tmp/mytar.tar): WRITE
13:54:45 engine: tar[/tmp/mytar.tar]: resource: Event(/tmp/mytar.tar): WRITE
13:54:45 engine: tar[/tmp/mytar.tar]: CheckApply(true)
13:54:45 engine: tar[/tmp/mytar.tar]: CheckApply(true): Return(true, <nil>)
13:54:45 engine: tar[/tmp/mytar.tar]: resource: Event(/tmp/mytar.tar): WRITE
13:54:45 engine: tar[/tmp/mytar.tar]: CheckApply(true)
...

I'm not sure if it's because CheckApply isn't implemented properly, and keeps writing to my resource, or if my Watch method isn't implemented properly. Can go over this on a call.
Fixed.

Features:
1. tar archive creation for a given list of input files
2. tar archive compression
@mattesko mattesko marked this pull request as ready for review January 5, 2022 00:42
Comment on lines +111 to +113
if obj.Compress && !strings.HasSuffix(strings.ToLower(obj.Name()), ".gz") {
return fmt.Errorf("expected a suffix of .gz, .Gz, or .gZ for compressed archive")
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could probably remove this. Ideally the user should name the tar file whatever they want.

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.

None yet

2 participants