{"action":"created","comment":{"url":"https://api.github.com/repos/puppetlabs/puppet/pulls/comments/140106148","pull_request_review_id":64131794,"id":140106148,"diff_hunk":"@@ -0,0 +1,50 @@\n+# Uploads the given file or directory to the given set of nodes and returns the result from each upload.\n+#\n+# * This function does nothing if the list of nodes is empty.\n+# * It is possible to run on the node 'localhost'\n+# * A node is a String with a node's hostname or a URI that also describes how to connect and run the task on that node\n+#   including \"user\" and \"password\" parts of a URI.\n+# * The returned value contains information about the result per node. TODO: needs mapping to a runtime Pcore Object to be useful\n+#\n+#\n+# Since > 5.4.0 TODO: Update when version is known\n+#\n+Puppet::Functions.create_function(:file_upload, Puppet::Functions::InternalFunction) do\n+  local_types do\n+    type 'NodeOrNodes = Variant[String[1], Array[NodeOrNodes]]'\n+  end\n+\n+  dispatch :file_upload do\n+    scope_param\n+    param 'String[1]', :source\n+    param 'String[1]', :destination\n+    repeated_param 'NodeOrNodes', :nodes\n+  end\n+\n+  def file_upload(scope, source, destination, *nodes)\n+    unless Puppet[:tasks]\n+      raise Puppet::ParseErrorWithIssue.from_issue_and_stack(\n+        Puppet::Pops::Issues::TASK_OPERATION_NOT_SUPPORTED_WHEN_COMPILING,\n+        {:operation => 'file_upload'})\n+    end\n+\n+    unless Puppet.features.bolt?\n+      raise Puppet::ParseErrorWithIssue.from_issue_and_stack(Puppet::Pops::Issues::TASK_MISSING_BOLT, :action => _('do file uploads'))\n+    end\n+\n+    found = Puppet::Parser::Files.find_file(source, scope.compiler.environment)\n+    unless found && Puppet::FileSystem.exist?(found)\n+      raise Puppet::ParseErrorWithIssue.from_issue_and_stack(Puppet::Pops::Issues::NO_SUCH_FILE_OR_DIRECTORY, {:file => source})\n+    end\n+\n+    hosts = nodes.flatten\n+    if hosts.empty?\n+      call_function('debug', \"Simulating file upload of '#{found}' - no hosts given - no action taken\")\n+      []\n+    else\n+      Bolt::Executor.from_uris(hosts).file_upload(found, destination).map do |_, result|\n+        result.success? ? result.output_string : result.exit_code","path":"lib/puppet/functions/file_upload.rb","position":46,"original_position":46,"commit_id":"a5e393231c5235444c0cdd993ff0f2ff2feb2970","original_commit_id":"a5e393231c5235444c0cdd993ff0f2ff2feb2970","user":{"login":"pcarlisle","id":1234752,"avatar_url":"https://avatars0.githubusercontent.com/u/1234752?v=4","gravatar_id":"","url":"https://api.github.com/users/pcarlisle","html_url":"https://github.com/pcarlisle","followers_url":"https://api.github.com/users/pcarlisle/followers","following_url":"https://api.github.com/users/pcarlisle/following{/other_user}","gists_url":"https://api.github.com/users/pcarlisle/gists{/gist_id}","starred_url":"https://api.github.com/users/pcarlisle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pcarlisle/subscriptions","organizations_url":"https://api.github.com/users/pcarlisle/orgs","repos_url":"https://api.github.com/users/pcarlisle/repos","events_url":"https://api.github.com/users/pcarlisle/events{/privacy}","received_events_url":"https://api.github.com/users/pcarlisle/received_events","type":"User","site_admin":false},"body":"Oh I'm slightly wrong, if there's no command line output output_string is still valid and just prints the same thing as value, so that's fine. In fact outupt_string will also print the exception on an exceptionfailure.","created_at":"2017-09-20T22:09:59Z","updated_at":"2017-09-20T22:09:59Z","html_url":"https://github.com/puppetlabs/puppet/pull/6222#discussion_r140106148","pull_request_url":"https://api.github.com/repos/puppetlabs/puppet/pulls/6222","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/puppet/pulls/comments/140106148"},"html":{"href":"https://github.com/puppetlabs/puppet/pull/6222#discussion_r140106148"},"pull_request":{"href":"https://api.github.com/repos/puppetlabs/puppet/pulls/6222"}},"in_reply_to_id":140105880},"pull_request":{"url":"https://api.github.com/repos/puppetlabs/puppet/pulls/6222","id":142073494,"html_url":"https://github.com/puppetlabs/puppet/pull/6222","diff_url":"https://github.com/puppetlabs/puppet/pull/6222.diff","patch_url":"https://github.com/puppetlabs/puppet/pull/6222.patch","issue_url":"https://api.github.com/repos/puppetlabs/puppet/issues/6222","number":6222,"state":"open","locked":false,"title":"(PUP-7967) Add file_upload function","user":{"login":"thallgren","id":209495,"avatar_url":"https://avatars2.githubusercontent.com/u/209495?v=4","gravatar_id":"","url":"https://api.github.com/users/thallgren","html_url":"https://github.com/thallgren","followers_url":"https://api.github.com/users/thallgren/followers","following_url":"https://api.github.com/users/thallgren/following{/other_user}","gists_url":"https://api.github.com/users/thallgren/gists{/gist_id}","starred_url":"https://api.github.com/users/thallgren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thallgren/subscriptions","organizations_url":"https://api.github.com/users/thallgren/orgs","repos_url":"https://api.github.com/users/thallgren/repos","events_url":"https://api.github.com/users/thallgren/events{/privacy}","received_events_url":"https://api.github.com/users/thallgren/received_events","type":"User","site_admin":false},"body":"Adds a `file_upload` function that can upload a file or directory\r\nto a set of nodes by calling the `Bolt::Executor#file_upload`. The\r\nfunction requires that --tasks is enabled and that the `bolt` feature\r\nis present.","created_at":"2017-09-20T11:20:57Z","updated_at":"2017-09-20T22:09:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6df7a32e3d3ae76369d6326976cc4176fa572f47","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/puppetlabs/puppet/pulls/6222/commits","review_comments_url":"https://api.github.com/repos/puppetlabs/puppet/pulls/6222/comments","review_comment_url":"https://api.github.com/repos/puppetlabs/puppet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/puppetlabs/puppet/issues/6222/comments","statuses_url":"https://api.github.com/repos/puppetlabs/puppet/statuses/a5e393231c5235444c0cdd993ff0f2ff2feb2970","head":{"label":"thallgren:issue/pup-7967/file_upload","ref":"issue/pup-7967/file_upload","sha":"a5e393231c5235444c0cdd993ff0f2ff2feb2970","user":{"login":"thallgren","id":209495,"avatar_url":"https://avatars2.githubusercontent.com/u/209495?v=4","gravatar_id":"","url":"https://api.github.com/users/thallgren","html_url":"https://github.com/thallgren","followers_url":"https://api.github.com/users/thallgren/followers","following_url":"https://api.github.com/users/thallgren/following{/other_user}","gists_url":"https://api.github.com/users/thallgren/gists{/gist_id}","starred_url":"https://api.github.com/users/thallgren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thallgren/subscriptions","organizations_url":"https://api.github.com/users/thallgren/orgs","repos_url":"https://api.github.com/users/thallgren/repos","events_url":"https://api.github.com/users/thallgren/events{/privacy}","received_events_url":"https://api.github.com/users/thallgren/received_events","type":"User","site_admin":false},"repo":{"id":15137589,"name":"puppet","full_name":"thallgren/puppet","owner":{"login":"thallgren","id":209495,"avatar_url":"https://avatars2.githubusercontent.com/u/209495?v=4","gravatar_id":"","url":"https://api.github.com/users/thallgren","html_url":"https://github.com/thallgren","followers_url":"https://api.github.com/users/thallgren/followers","following_url":"https://api.github.com/users/thallgren/following{/other_user}","gists_url":"https://api.github.com/users/thallgren/gists{/gist_id}","starred_url":"https://api.github.com/users/thallgren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thallgren/subscriptions","organizations_url":"https://api.github.com/users/thallgren/orgs","repos_url":"https://api.github.com/users/thallgren/repos","events_url":"https://api.github.com/users/thallgren/events{/privacy}","received_events_url":"https://api.github.com/users/thallgren/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/thallgren/puppet","description":"Server automation framework and application","fork":true,"url":"https://api.github.com/repos/thallgren/puppet","forks_url":"https://api.github.com/repos/thallgren/puppet/forks","keys_url":"https://api.github.com/repos/thallgren/puppet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thallgren/puppet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thallgren/puppet/teams","hooks_url":"https://api.github.com/repos/thallgren/puppet/hooks","issue_events_url":"https://api.github.com/repos/thallgren/puppet/issues/events{/number}","events_url":"https://api.github.com/repos/thallgren/puppet/events","assignees_url":"https://api.github.com/repos/thallgren/puppet/assignees{/user}","branches_url":"https://api.github.com/repos/thallgren/puppet/branches{/branch}","tags_url":"https://api.github.com/repos/thallgren/puppet/tags","blobs_url":"https://api.github.com/repos/thallgren/puppet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thallgren/puppet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thallgren/puppet/git/refs{/sha}","trees_url":"https://api.github.com/repos/thallgren/puppet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thallgren/puppet/statuses/{sha}","languages_url":"https://api.github.com/repos/thallgren/puppet/languages","stargazers_url":"https://api.github.com/repos/thallgren/puppet/stargazers","contributors_url":"https://api.github.com/repos/thallgren/puppet/contributors","subscribers_url":"https://api.github.com/repos/thallgren/puppet/subscribers","subscription_url":"https://api.github.com/repos/thallgren/puppet/subscription","commits_url":"https://api.github.com/repos/thallgren/puppet/commits{/sha}","git_commits_url":"https://api.github.com/repos/thallgren/puppet/git/commits{/sha}","comments_url":"https://api.github.com/repos/thallgren/puppet/comments{/number}","issue_comment_url":"https://api.github.com/repos/thallgren/puppet/issues/comments{/number}","contents_url":"https://api.github.com/repos/thallgren/puppet/contents/{+path}","compare_url":"https://api.github.com/repos/thallgren/puppet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thallgren/puppet/merges","archive_url":"https://api.github.com/repos/thallgren/puppet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thallgren/puppet/downloads","issues_url":"https://api.github.com/repos/thallgren/puppet/issues{/number}","pulls_url":"https://api.github.com/repos/thallgren/puppet/pulls{/number}","milestones_url":"https://api.github.com/repos/thallgren/puppet/milestones{/number}","notifications_url":"https://api.github.com/repos/thallgren/puppet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thallgren/puppet/labels{/name}","releases_url":"https://api.github.com/repos/thallgren/puppet/releases{/id}","deployments_url":"https://api.github.com/repos/thallgren/puppet/deployments","created_at":"2013-12-12T14:09:32Z","updated_at":"2015-01-21T18:51:48Z","pushed_at":"2017-09-20T11:17:08Z","git_url":"git://github.com/thallgren/puppet.git","ssh_url":"git@github.com:thallgren/puppet.git","clone_url":"https://github.com/thallgren/puppet.git","svn_url":"https://github.com/thallgren/puppet","homepage":"http://www.puppetlabs.com/puppet/introduction/","size":59643,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"puppetlabs:feature_puppet-tasks","ref":"feature_puppet-tasks","sha":"44cc16d7adb69bdc11d5baefe7116a513c54fde3","user":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars0.githubusercontent.com/u/234268?v=4","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":910744,"name":"puppet","full_name":"puppetlabs/puppet","owner":{"login":"puppetlabs","id":234268,"avatar_url":"https://avatars0.githubusercontent.com/u/234268?v=4","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/puppetlabs/puppet","description":"Server automation framework and application","fork":false,"url":"https://api.github.com/repos/puppetlabs/puppet","forks_url":"https://api.github.com/repos/puppetlabs/puppet/forks","keys_url":"https://api.github.com/repos/puppetlabs/puppet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/puppetlabs/puppet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/puppetlabs/puppet/teams","hooks_url":"https://api.github.com/repos/puppetlabs/puppet/hooks","issue_events_url":"https://api.github.com/repos/puppetlabs/puppet/issues/events{/number}","events_url":"https://api.github.com/repos/puppetlabs/puppet/events","assignees_url":"https://api.github.com/repos/puppetlabs/puppet/assignees{/user}","branches_url":"https://api.github.com/repos/puppetlabs/puppet/branches{/branch}","tags_url":"https://api.github.com/repos/puppetlabs/puppet/tags","blobs_url":"https://api.github.com/repos/puppetlabs/puppet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/puppetlabs/puppet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/puppetlabs/puppet/git/refs{/sha}","trees_url":"https://api.github.com/repos/puppetlabs/puppet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/puppetlabs/puppet/statuses/{sha}","languages_url":"https://api.github.com/repos/puppetlabs/puppet/languages","stargazers_url":"https://api.github.com/repos/puppetlabs/puppet/stargazers","contributors_url":"https://api.github.com/repos/puppetlabs/puppet/contributors","subscribers_url":"https://api.github.com/repos/puppetlabs/puppet/subscribers","subscription_url":"https://api.github.com/repos/puppetlabs/puppet/subscription","commits_url":"https://api.github.com/repos/puppetlabs/puppet/commits{/sha}","git_commits_url":"https://api.github.com/repos/puppetlabs/puppet/git/commits{/sha}","comments_url":"https://api.github.com/repos/puppetlabs/puppet/comments{/number}","issue_comment_url":"https://api.github.com/repos/puppetlabs/puppet/issues/comments{/number}","contents_url":"https://api.github.com/repos/puppetlabs/puppet/contents/{+path}","compare_url":"https://api.github.com/repos/puppetlabs/puppet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/puppetlabs/puppet/merges","archive_url":"https://api.github.com/repos/puppetlabs/puppet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/puppetlabs/puppet/downloads","issues_url":"https://api.github.com/repos/puppetlabs/puppet/issues{/number}","pulls_url":"https://api.github.com/repos/puppetlabs/puppet/pulls{/number}","milestones_url":"https://api.github.com/repos/puppetlabs/puppet/milestones{/number}","notifications_url":"https://api.github.com/repos/puppetlabs/puppet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/puppetlabs/puppet/labels{/name}","releases_url":"https://api.github.com/repos/puppetlabs/puppet/releases{/id}","deployments_url":"https://api.github.com/repos/puppetlabs/puppet/deployments","created_at":"2010-09-14T19:26:44Z","updated_at":"2017-09-19T09:28:34Z","pushed_at":"2017-09-20T21:45:34Z","git_url":"git://github.com/puppetlabs/puppet.git","ssh_url":"git@github.com:puppetlabs/puppet.git","clone_url":"https://github.com/puppetlabs/puppet.git","svn_url":"https://github.com/puppetlabs/puppet","homepage":"https://puppet.com/puppet/what-is-puppet","size":59403,"stargazers_count":4639,"watchers_count":4639,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1907,"mirror_url":null,"open_issues_count":67,"forks":1907,"open_issues":67,"watchers":4639,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/puppet/pulls/6222"},"html":{"href":"https://github.com/puppetlabs/puppet/pull/6222"},"issue":{"href":"https://api.github.com/repos/puppetlabs/puppet/issues/6222"},"comments":{"href":"https://api.github.com/repos/puppetlabs/puppet/issues/6222/comments"},"review_comments":{"href":"https://api.github.com/repos/puppetlabs/puppet/pulls/6222/comments"},"review_comment":{"href":"https://api.github.com/repos/puppetlabs/puppet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/puppetlabs/puppet/pulls/6222/commits"},"statuses":{"href":"https://api.github.com/repos/puppetlabs/puppet/statuses/a5e393231c5235444c0cdd993ff0f2ff2feb2970"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"pcarlisle"}}