-
Notifications
You must be signed in to change notification settings - Fork 90
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
Implement upload/download for connections #664
Conversation
Signed-off-by: Thomas Heinen <[email protected]>
Hello tecracer-theinen! Thanks for the pull request! Here is what will happen next:
Thank you for contributing! |
Definitively need help with the |
lib/train/file.rb
Outdated
@@ -24,7 +24,7 @@ def sanitize_filename(_path) | |||
# interface methods: these fields should be implemented by every | |||
# backend File | |||
DATA_FIELDS = %w{ | |||
exist? mode owner group uid gid content mtime size selinux_label path | |||
exist? mode owner group uid gid content content= mtime size selinux_label path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that if you rename the method to be set_content
, you can avoid the name issue, but then you encounter arity issues in that all of the other data fields are expected to be called with no arguments. If the new method is omitted from the DATA_FIELDS list - it is not really a data field, it is a setter - and instead treated as an abstract method, the tests pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was an easy fix. Thank you!
Signed-off-by: Thomas Heinen <[email protected]>
Adds default
upload
/download
methods to transfer files. Also adds acontent=
method for remote file manipulation.Description
While the SSH and the WinRM transport plugin already implemented the
upload
/download
methods, those were not part of the general plugin API.Offering these two methods and general file manipulation capabilities greatly extends any tool built on Train (e.g. Chef Target Mode).
On
base_connection
, theupload
method iterates using the newcontent=
method which uses base64 en-/decoding on Unix/Windows platforms. Thelocal
transport got simple local file manipulations for this, thecisco_ios_connection
will throw an error. Can't test QNX/AIX, sorry.I actually prepared both a Test Kitchen "train" transport and a remote shell utility based on this and it's working fine with my Linux/Windows systems. So I suppose the same goes for any other transport (AWS Systems Manager, VMware GOM etc).
Related Issue
none
Types of changes
Checklist: