{"action":"created","comment":{"url":"https://api.github.com/repos/mitchellh/packer/pulls/comments/93973261","pull_request_review_id":14504054,"id":93973261,"diff_hunk":"@@ -0,0 +1,262 @@\n+// This package implements a provisioner for Packer that executes\n+// Converge to provision a remote machine\n+\n+package converge\n+\n+import (\n+\t\"bytes\"\n+\t\"errors\"\n+\t\"fmt\"\n+\t\"log\"\n+\t\"net/http\"\n+\n+\t\"strings\"\n+\n+\t\"encoding/json\"\n+\n+\t\"regexp\"\n+\n+\t\"github.com/mitchellh/packer/common\"\n+\t\"github.com/mitchellh/packer/helper/config\"\n+\t\"github.com/mitchellh/packer/packer\"\n+\t\"github.com/mitchellh/packer/template/interpolate\"\n+)\n+\n+var versionRegex = regexp.MustCompile(`^[\\.\\-\\da-zA-Z]*$`)\n+\n+// Config for Converge provisioner\n+type Config struct {\n+\tcommon.PackerConfig `mapstructure:\",squash\"`\n+\n+\t// Bootstrapping\n+\tBootstrap bool   `mapstructure:\"bootstrap\"`\n+\tVersion   string `mapstructure:\"version\"`\n+\n+\t// Modules\n+\tModuleDirs []ModuleDir `mapstructure:\"module_dirs\"`\n+\tModules    []Module    `mapstructure:\"modules\"`\n+\n+\tctx interpolate.Context\n+}\n+\n+// ModuleDir is a directory to transfer to the remote system\n+type ModuleDir struct {\n+\tSource      string   `mapstructure:\"source\"`\n+\tDestination string   `mapstructure:\"destination\"`\n+\tExclude     []string `mapstructure:\"exclude\"`\n+}\n+\n+// Module contains information needed to run a module\n+type Module struct {\n+\tModule    string            `mapstructure:\"module\"`\n+\tDirectory string            `mapstructure:\"directory\"`\n+\tParams    map[string]string `mapstucture:\"params\"`\n+}\n+\n+// Provisioner for Converge\n+type Provisioner struct {\n+\tconfig Config\n+}\n+\n+// Prepare provisioner somehow. TODO: actual docs\n+func (p *Provisioner) Prepare(raws ...interface{}) error {\n+\terr := config.Decode(\n+\t\t&p.config,\n+\t\t&config.DecodeOpts{\n+\t\t\tInterpolate:        true,\n+\t\t\tInterpolateContext: &p.config.ctx,\n+\t\t},\n+\t\traws...,\n+\t)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\t// validate version\n+\tif !versionRegex.Match([]byte(p.config.Version)) {\n+\t\treturn fmt.Errorf(\"Invalid Converge version %q specified. Valid versions include only letters, numbers, dots, and dashes\", p.config.Version)\n+\t}\n+\n+\t// validate sources and destinations\n+\tfor i, dir := range p.config.ModuleDirs {\n+\t\tif dir.Source == \"\" {\n+\t\t\treturn fmt.Errorf(\"Source (\\\"source\\\" key) is required in Converge module dir #%d\", i)\n+\t\t}\n+\t\tif dir.Destination == \"\" {\n+\t\t\treturn fmt.Errorf(\"Destination (\\\"destination\\\" key) is required in Converge module dir #%d\", i)\n+\t\t}\n+\t}\n+\n+\t// validate modules\n+\tif len(p.config.Modules) == 0 {\n+\t\treturn errors.New(\"Converge requires at least one module (\\\"modules\\\" key) to provision the system\")\n+\t}\n+\tfor i, module := range p.config.Modules {\n+\t\tif module.Module == \"\" {\n+\t\t\treturn fmt.Errorf(\"Module (\\\"module\\\" key) is required in Converge module #%d\", i)\n+\t\t}\n+\t\tif module.Directory == \"\" {\n+\t\t\tp.config.Modules[i].Directory = \"/tmp\"\n+\t\t}\n+\t}\n+\n+\treturn err\n+}\n+\n+// Provision node somehow. TODO: actual docs\n+func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {\n+\tui.Say(\"Provisioning with Converge\")\n+\n+\t// bootstrapping\n+\tif err := p.maybeBootstrap(ui, comm); err != nil {\n+\t\treturn err // error messages are already user-friendly\n+\t}\n+\n+\t// check version (really, this make sure that Converge is installed before we try to run it)\n+\tif err := p.checkVersion(ui, comm); err != nil {\n+\t\treturn err // error messages are already user-friendly\n+\t}","path":"provisioner/converge/provisioner.go","position":118,"original_position":118,"commit_id":"549ff50a3c390a9f6bed050f00ae047f14bb3765","original_commit_id":"549ff50a3c390a9f6bed050f00ae047f14bb3765","user":{"login":"BrianHicks","id":355401,"avatar_url":"https://avatars.githubusercontent.com/u/355401?v=3","gravatar_id":"","url":"https://api.github.com/users/BrianHicks","html_url":"https://github.com/BrianHicks","followers_url":"https://api.github.com/users/BrianHicks/followers","following_url":"https://api.github.com/users/BrianHicks/following{/other_user}","gists_url":"https://api.github.com/users/BrianHicks/gists{/gist_id}","starred_url":"https://api.github.com/users/BrianHicks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrianHicks/subscriptions","organizations_url":"https://api.github.com/users/BrianHicks/orgs","repos_url":"https://api.github.com/users/BrianHicks/repos","events_url":"https://api.github.com/users/BrianHicks/events{/privacy}","received_events_url":"https://api.github.com/users/BrianHicks/received_events","type":"User","site_admin":false},"body":"It does fail if it's not on the path, do you mean not checking the version at all?","created_at":"2016-12-27T21:42:35Z","updated_at":"2016-12-27T21:42:35Z","html_url":"https://github.com/mitchellh/packer/pull/4326#discussion_r93973261","pull_request_url":"https://api.github.com/repos/mitchellh/packer/pulls/4326","_links":{"self":{"href":"https://api.github.com/repos/mitchellh/packer/pulls/comments/93973261"},"html":{"href":"https://github.com/mitchellh/packer/pull/4326#discussion_r93973261"},"pull_request":{"href":"https://api.github.com/repos/mitchellh/packer/pulls/4326"}}},"pull_request":{"url":"https://api.github.com/repos/mitchellh/packer/pulls/4326","id":99482686,"html_url":"https://github.com/mitchellh/packer/pull/4326","diff_url":"https://github.com/mitchellh/packer/pull/4326.diff","patch_url":"https://github.com/mitchellh/packer/pull/4326.patch","issue_url":"https://api.github.com/repos/mitchellh/packer/issues/4326","number":4326,"state":"open","locked":false,"title":"New Provisioner: Converge","user":{"login":"BrianHicks","id":355401,"avatar_url":"https://avatars.githubusercontent.com/u/355401?v=3","gravatar_id":"","url":"https://api.github.com/users/BrianHicks","html_url":"https://github.com/BrianHicks","followers_url":"https://api.github.com/users/BrianHicks/followers","following_url":"https://api.github.com/users/BrianHicks/following{/other_user}","gists_url":"https://api.github.com/users/BrianHicks/gists{/gist_id}","starred_url":"https://api.github.com/users/BrianHicks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrianHicks/subscriptions","organizations_url":"https://api.github.com/users/BrianHicks/orgs","repos_url":"https://api.github.com/users/BrianHicks/repos","events_url":"https://api.github.com/users/BrianHicks/events{/privacy}","received_events_url":"https://api.github.com/users/BrianHicks/received_events","type":"User","site_admin":false},"body":"This patch adds a [Converge](http://converge.aster.is) provisioner. I've tested it on DigitalOcean and didn't have any problems. It uses the regular Packer primitives for communication.\r\n\r\nI've included tests for the Prepare section of the provisioner. That looks like the extent of the tests that most provisioners include, unless I'm missing something?\r\n\r\nHappy to make any style changes necessary. This PR doesn't add any external dependencies, although I sure would like to use https://github.com/pkg/errors if it's allowed.\r\n\r\nTested with the following harness:\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n\t\"log\"\r\n\r\n\t\"github.com/asteris-llc/packer/packer/plugin\"\r\n\t\"github.com/asteris-llc/packer/provisioner/converge\"\r\n)\r\n\r\nfunc main() {\r\n\tserver, err := plugin.Server()\r\n\tif err != nil {\r\n\t\tlog.Fatalf(\"Error starting plugin server: %s\", err)\r\n\t}\r\n\r\n\tserver.RegisterProvisioner(new(converge.Provisioner))\r\n\r\n\tserver.Serve()\r\n}\r\n```\r\n\r\nThis code was written in my role as an Asteris employee. We're happy to release it under the MPL. Converge is Apache 2.0 licensed. As far as I can tell, there are no conflicts.","created_at":"2016-12-27T20:55:15Z","updated_at":"2016-12-27T21:42:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6d60bd610aa7ec7aab72d870eb73e7a4af37e4a2","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mitchellh/packer/pulls/4326/commits","review_comments_url":"https://api.github.com/repos/mitchellh/packer/pulls/4326/comments","review_comment_url":"https://api.github.com/repos/mitchellh/packer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mitchellh/packer/issues/4326/comments","statuses_url":"https://api.github.com/repos/mitchellh/packer/statuses/549ff50a3c390a9f6bed050f00ae047f14bb3765","head":{"label":"asteris-llc:feature/converge-provisioner","ref":"feature/converge-provisioner","sha":"549ff50a3c390a9f6bed050f00ae047f14bb3765","user":{"login":"asteris-llc","id":6193478,"avatar_url":"https://avatars.githubusercontent.com/u/6193478?v=3","gravatar_id":"","url":"https://api.github.com/users/asteris-llc","html_url":"https://github.com/asteris-llc","followers_url":"https://api.github.com/users/asteris-llc/followers","following_url":"https://api.github.com/users/asteris-llc/following{/other_user}","gists_url":"https://api.github.com/users/asteris-llc/gists{/gist_id}","starred_url":"https://api.github.com/users/asteris-llc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asteris-llc/subscriptions","organizations_url":"https://api.github.com/users/asteris-llc/orgs","repos_url":"https://api.github.com/users/asteris-llc/repos","events_url":"https://api.github.com/users/asteris-llc/events{/privacy}","received_events_url":"https://api.github.com/users/asteris-llc/received_events","type":"Organization","site_admin":false},"repo":{"id":76072237,"name":"packer","full_name":"asteris-llc/packer","owner":{"login":"asteris-llc","id":6193478,"avatar_url":"https://avatars.githubusercontent.com/u/6193478?v=3","gravatar_id":"","url":"https://api.github.com/users/asteris-llc","html_url":"https://github.com/asteris-llc","followers_url":"https://api.github.com/users/asteris-llc/followers","following_url":"https://api.github.com/users/asteris-llc/following{/other_user}","gists_url":"https://api.github.com/users/asteris-llc/gists{/gist_id}","starred_url":"https://api.github.com/users/asteris-llc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asteris-llc/subscriptions","organizations_url":"https://api.github.com/users/asteris-llc/orgs","repos_url":"https://api.github.com/users/asteris-llc/repos","events_url":"https://api.github.com/users/asteris-llc/events{/privacy}","received_events_url":"https://api.github.com/users/asteris-llc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/asteris-llc/packer","description":"Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.","fork":true,"url":"https://api.github.com/repos/asteris-llc/packer","forks_url":"https://api.github.com/repos/asteris-llc/packer/forks","keys_url":"https://api.github.com/repos/asteris-llc/packer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/asteris-llc/packer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/asteris-llc/packer/teams","hooks_url":"https://api.github.com/repos/asteris-llc/packer/hooks","issue_events_url":"https://api.github.com/repos/asteris-llc/packer/issues/events{/number}","events_url":"https://api.github.com/repos/asteris-llc/packer/events","assignees_url":"https://api.github.com/repos/asteris-llc/packer/assignees{/user}","branches_url":"https://api.github.com/repos/asteris-llc/packer/branches{/branch}","tags_url":"https://api.github.com/repos/asteris-llc/packer/tags","blobs_url":"https://api.github.com/repos/asteris-llc/packer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/asteris-llc/packer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/asteris-llc/packer/git/refs{/sha}","trees_url":"https://api.github.com/repos/asteris-llc/packer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/asteris-llc/packer/statuses/{sha}","languages_url":"https://api.github.com/repos/asteris-llc/packer/languages","stargazers_url":"https://api.github.com/repos/asteris-llc/packer/stargazers","contributors_url":"https://api.github.com/repos/asteris-llc/packer/contributors","subscribers_url":"https://api.github.com/repos/asteris-llc/packer/subscribers","subscription_url":"https://api.github.com/repos/asteris-llc/packer/subscription","commits_url":"https://api.github.com/repos/asteris-llc/packer/commits{/sha}","git_commits_url":"https://api.github.com/repos/asteris-llc/packer/git/commits{/sha}","comments_url":"https://api.github.com/repos/asteris-llc/packer/comments{/number}","issue_comment_url":"https://api.github.com/repos/asteris-llc/packer/issues/comments{/number}","contents_url":"https://api.github.com/repos/asteris-llc/packer/contents/{+path}","compare_url":"https://api.github.com/repos/asteris-llc/packer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/asteris-llc/packer/merges","archive_url":"https://api.github.com/repos/asteris-llc/packer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/asteris-llc/packer/downloads","issues_url":"https://api.github.com/repos/asteris-llc/packer/issues{/number}","pulls_url":"https://api.github.com/repos/asteris-llc/packer/pulls{/number}","milestones_url":"https://api.github.com/repos/asteris-llc/packer/milestones{/number}","notifications_url":"https://api.github.com/repos/asteris-llc/packer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/asteris-llc/packer/labels{/name}","releases_url":"https://api.github.com/repos/asteris-llc/packer/releases{/id}","deployments_url":"https://api.github.com/repos/asteris-llc/packer/deployments","created_at":"2016-12-09T21:40:28Z","updated_at":"2016-12-09T21:40:32Z","pushed_at":"2016-12-27T20:59:02Z","git_url":"git://github.com/asteris-llc/packer.git","ssh_url":"git@github.com:asteris-llc/packer.git","clone_url":"https://github.com/asteris-llc/packer.git","svn_url":"https://github.com/asteris-llc/packer","homepage":"http://www.packer.io","size":20780,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"mitchellh:master","ref":"master","sha":"77f878b89cbae1a82b4cd04180c3544ea9234af2","user":{"login":"mitchellh","id":1299,"avatar_url":"https://avatars.githubusercontent.com/u/1299?v=3","gravatar_id":"","url":"https://api.github.com/users/mitchellh","html_url":"https://github.com/mitchellh","followers_url":"https://api.github.com/users/mitchellh/followers","following_url":"https://api.github.com/users/mitchellh/following{/other_user}","gists_url":"https://api.github.com/users/mitchellh/gists{/gist_id}","starred_url":"https://api.github.com/users/mitchellh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitchellh/subscriptions","organizations_url":"https://api.github.com/users/mitchellh/orgs","repos_url":"https://api.github.com/users/mitchellh/repos","events_url":"https://api.github.com/users/mitchellh/events{/privacy}","received_events_url":"https://api.github.com/users/mitchellh/received_events","type":"User","site_admin":false},"repo":{"id":8966356,"name":"packer","full_name":"mitchellh/packer","owner":{"login":"mitchellh","id":1299,"avatar_url":"https://avatars.githubusercontent.com/u/1299?v=3","gravatar_id":"","url":"https://api.github.com/users/mitchellh","html_url":"https://github.com/mitchellh","followers_url":"https://api.github.com/users/mitchellh/followers","following_url":"https://api.github.com/users/mitchellh/following{/other_user}","gists_url":"https://api.github.com/users/mitchellh/gists{/gist_id}","starred_url":"https://api.github.com/users/mitchellh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitchellh/subscriptions","organizations_url":"https://api.github.com/users/mitchellh/orgs","repos_url":"https://api.github.com/users/mitchellh/repos","events_url":"https://api.github.com/users/mitchellh/events{/privacy}","received_events_url":"https://api.github.com/users/mitchellh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mitchellh/packer","description":"Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.","fork":false,"url":"https://api.github.com/repos/mitchellh/packer","forks_url":"https://api.github.com/repos/mitchellh/packer/forks","keys_url":"https://api.github.com/repos/mitchellh/packer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mitchellh/packer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mitchellh/packer/teams","hooks_url":"https://api.github.com/repos/mitchellh/packer/hooks","issue_events_url":"https://api.github.com/repos/mitchellh/packer/issues/events{/number}","events_url":"https://api.github.com/repos/mitchellh/packer/events","assignees_url":"https://api.github.com/repos/mitchellh/packer/assignees{/user}","branches_url":"https://api.github.com/repos/mitchellh/packer/branches{/branch}","tags_url":"https://api.github.com/repos/mitchellh/packer/tags","blobs_url":"https://api.github.com/repos/mitchellh/packer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mitchellh/packer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mitchellh/packer/git/refs{/sha}","trees_url":"https://api.github.com/repos/mitchellh/packer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mitchellh/packer/statuses/{sha}","languages_url":"https://api.github.com/repos/mitchellh/packer/languages","stargazers_url":"https://api.github.com/repos/mitchellh/packer/stargazers","contributors_url":"https://api.github.com/repos/mitchellh/packer/contributors","subscribers_url":"https://api.github.com/repos/mitchellh/packer/subscribers","subscription_url":"https://api.github.com/repos/mitchellh/packer/subscription","commits_url":"https://api.github.com/repos/mitchellh/packer/commits{/sha}","git_commits_url":"https://api.github.com/repos/mitchellh/packer/git/commits{/sha}","comments_url":"https://api.github.com/repos/mitchellh/packer/comments{/number}","issue_comment_url":"https://api.github.com/repos/mitchellh/packer/issues/comments{/number}","contents_url":"https://api.github.com/repos/mitchellh/packer/contents/{+path}","compare_url":"https://api.github.com/repos/mitchellh/packer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mitchellh/packer/merges","archive_url":"https://api.github.com/repos/mitchellh/packer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mitchellh/packer/downloads","issues_url":"https://api.github.com/repos/mitchellh/packer/issues{/number}","pulls_url":"https://api.github.com/repos/mitchellh/packer/pulls{/number}","milestones_url":"https://api.github.com/repos/mitchellh/packer/milestones{/number}","notifications_url":"https://api.github.com/repos/mitchellh/packer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mitchellh/packer/labels{/name}","releases_url":"https://api.github.com/repos/mitchellh/packer/releases{/id}","deployments_url":"https://api.github.com/repos/mitchellh/packer/deployments","created_at":"2013-03-23T05:43:03Z","updated_at":"2016-12-27T20:21:42Z","pushed_at":"2016-12-27T20:59:04Z","git_url":"git://github.com/mitchellh/packer.git","ssh_url":"git@github.com:mitchellh/packer.git","clone_url":"https://github.com/mitchellh/packer.git","svn_url":"https://github.com/mitchellh/packer","homepage":"http://www.packer.io","size":21187,"stargazers_count":6061,"watchers_count":6061,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1502,"mirror_url":null,"open_issues_count":499,"forks":1502,"open_issues":499,"watchers":6061,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mitchellh/packer/pulls/4326"},"html":{"href":"https://github.com/mitchellh/packer/pull/4326"},"issue":{"href":"https://api.github.com/repos/mitchellh/packer/issues/4326"},"comments":{"href":"https://api.github.com/repos/mitchellh/packer/issues/4326/comments"},"review_comments":{"href":"https://api.github.com/repos/mitchellh/packer/pulls/4326/comments"},"review_comment":{"href":"https://api.github.com/repos/mitchellh/packer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mitchellh/packer/pulls/4326/commits"},"statuses":{"href":"https://api.github.com/repos/mitchellh/packer/statuses/549ff50a3c390a9f6bed050f00ae047f14bb3765"}}}}
{"actor":{"display_login":"BrianHicks"}}