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

file.managed: Allow local file sources to use source_hash #29289

Merged
merged 1 commit into from Dec 1, 2015

Conversation

terminalmage
Copy link
Contributor

Fixes #26526.

@terminalmage
Copy link
Contributor Author

While the diff may not be 100% clear on this, all this PR does is move the check if the file is a local file below where source_hash is evaluated, so that using a sha256 hash is done as a fallback if source_hash is not provided.

source_sum = {'hsum': file_sum, 'hash_type': 'sha256'}
elif source.startswith('/'):
file_sum = get_hash(source, form='sha256')
source_sum = {'hsum': file_sum, 'hash_type': 'sha256'}
elif source_hash:
protos = ('salt', 'http', 'https', 'ftp', 'swift', 's3')
Copy link
Contributor

Choose a reason for hiding this comment

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

@terminalmage, can we add 'file' to this list of accepted source_hash protos? Will that allow us to specify a hash in the form: source_hash: file:///path/to/hashfile.hash?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that would work. If you want to submit the PR, go ahead, otherwise I can do it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright, I'm on it.

@cachedout
Copy link
Contributor

Makes sense. Cool.

cachedout pushed a commit that referenced this pull request Dec 1, 2015
file.managed: Allow local file sources to use source_hash
@cachedout cachedout merged commit 0fd3e8b into saltstack:2015.8 Dec 1, 2015
@lorengordon
Copy link
Contributor

Maybe a slight tangent, but I think this mesage is not quite right when the source_hash scheme matches the protos list. The message seems to be saying the syntax is something like source_hash: md5=salt://path/to/hashfile.md5. But the code passes source_hash without modification directly to _urlparse(), so I think the message is wrong. The syntax would just be source_hash: <proto>://path/to/hashfile. Perhaps the message is intending to explain how extract_hash() reads the file, but I don't think that is coming across. I think that is covered in the file state docs. Also, it would maybe be nice if the message referenced the allowed protos.

@lorengordon
Copy link
Contributor

Oops, already merged. Shucks.

@cachedout
Copy link
Contributor

@lorengordon Can you send over a PR with those changes? I'd love to include them.

@lorengordon
Copy link
Contributor

@cachedout, yep, see #29305.

@cachedout
Copy link
Contributor

@lorengordon Thank you very much.

@terminalmage
Copy link
Contributor Author

@lorengordon Thanks!

@terminalmage terminalmage deleted the issue26526 branch January 12, 2016 17:56
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

3 participants