{"action":"created","comment":{"url":"https://api.github.com/repos/saltstack/salt/pulls/comments/35023618","id":35023618,"diff_hunk":"@@ -0,0 +1,162 @@\n+# -*- coding: utf-8 -*-\n+\n+'''\n+Manage Chocolatey package installs\n+'''\n+\n+\n+def __virtual__():\n+    '''\n+    Load only if chocolatey is loaded\n+    '''\n+    return 'chocolatey' if 'chocolatey.install' in __salt__ else False\n+\n+\n+def install(name, version=None, source=None, force=False, install_args=None,\n+            override_args=False, force_x86=False):\n+\n+    '''\n+    Installs a package if not already installed\n+\n+    name\n+      The name of the package to be installed.\n+\n+    version\n+      Install a specific version of the package. Defaults to latest version.\n+\n+    source\n+      Chocolatey repository (directory, share or remote URL, feed). Defaults to\n+      the official Chocolatey feed.\n+\n+    force\n+      Reinstall the current version of an existing package. Default is false.\n+\n+    install_args\n+      A list of install arguments you want to pass to the installation\n+      process i.e product key or feature list\n+\n+    override_args\n+      Set to true if you want to override the original install arguments (\n+      for the native installer)in the package and use your own.\n+      When this is set to False install_args will be appended to the end of\n+      the default arguments\n+\n+    force_x86\n+      Force x86 (32bit) installation on 64 bit systems. Defaults to false.\n+\n+\n+    .. code-block:: yaml\n+\n+        Installsomepackage:\n+          chocolatey.install:\n+            - name: packagename\n+            - version: '12.04'\n+            - source: 'mychocolatey/source'\n+            - force: True\n+\n+\n+\n+    '''\n+\n+    ret = {'name': name,\n+           'result': True,\n+           'changes': {},\n+           'comment': ''}\n+\n+    # Determine if the package is installed\n+    if name not in __salt__['cmd.run']('choco list --local-only'):\n+        ret['changes'] = {'name': '{0} will be installed'.format(name)}\n+    elif force:\n+        ret['changes'] = {'name': '{0} is already installed but will reinstall'\n+            .format(name)}\n+    else:\n+        ret['comment'] = 'The Package {0} is already installed'.format(name)\n+        return ret\n+\n+    if __opts__['test']:\n+        ret['result'] = None\n+        return ret\n+\n+    # Install the package\n+    ret['changes'] = {name: __salt__['chocolatey.install'](name, version,\n+                                                             source,\n+                                                             force,\n+                                                             install_args,\n+                                                             override_args,\n+                                                             force_x86)}\n+\n+    if 'Running chocolatey failed' not in ret['changes']:\n+        ret['result'] = True\n+    else:\n+        ret['result'] = False\n+\n+    if not ret['result']:\n+        ret['comment'] = 'Failed to install the package {0}'.format(name)\n+\n+    return ret\n+\n+\n+def uninstall(name, version=None, uninstall_args=None, override_args=False):\n+    '''\n+    Uninstalls a package\n+\n+    name\n+      The name of the package to be uninstalled\n+\n+    version\n+      Uninstalls a specific version of the package. Defaults to latest\n+      version installed.\n+\n+    uninstall_args\n+      A list of uninstall arguments you want to pass to the uninstallation\n+      process i.e product key or feature list\n+\n+    override_args\n+      Set to true if you want to override the original uninstall arguments (\n+      for the native uninstaller)in the package and use your own.\n+      When this is set to False uninstall_args will be appended to the end of\n+      the default arguments\n+\n+\n+\n+\n+    .. code-block: yaml\n+\n+      Removemypackage:\n+        chocolatey.uninstall:\n+          - name: mypackage\n+          - version: '21.5'\n+\n+    '''\n+\n+    ret = {'name': name,\n+           'result': True,\n+           'changes': {},\n+           'comment': ''}\n+\n+    # Determine if package is installed\n+    if name in __salt__['cmd.run']('choco list --local-only'):\n+        ret['changes'] = {'name': '{0} will be removed'.format(name)}\n+    else:\n+        ret['comment'] = 'The package {0} is not installed'.format(name)\n+        return ret\n+\n+    if __opts__['test']:\n+        ret['result'] = None","path":"salt/states/chocolatey.py","position":145,"original_position":145,"commit_id":"0db68dc8a9752111b781fd3f5012baee8d0f868b","original_commit_id":"0db68dc8a9752111b781fd3f5012baee8d0f868b","user":{"login":"cachedout","id":111616,"avatar_url":"https://avatars.githubusercontent.com/u/111616?v=3","gravatar_id":"","url":"https://api.github.com/users/cachedout","html_url":"https://github.com/cachedout","followers_url":"https://api.github.com/users/cachedout/followers","following_url":"https://api.github.com/users/cachedout/following{/other_user}","gists_url":"https://api.github.com/users/cachedout/gists{/gist_id}","starred_url":"https://api.github.com/users/cachedout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cachedout/subscriptions","organizations_url":"https://api.github.com/users/cachedout/orgs","repos_url":"https://api.github.com/users/cachedout/repos","events_url":"https://api.github.com/users/cachedout/events{/privacy}","received_events_url":"https://api.github.com/users/cachedout/received_events","type":"User","site_admin":false},"body":"Same thing here. We need to inform the user what *would* have happened instead of just doing a no-op.","created_at":"2015-07-20T17:58:21Z","updated_at":"2015-07-20T17:58:21Z","html_url":"https://github.com/saltstack/salt/pull/25522#discussion_r35023618","pull_request_url":"https://api.github.com/repos/saltstack/salt/pulls/25522","_links":{"self":{"href":"https://api.github.com/repos/saltstack/salt/pulls/comments/35023618"},"html":{"href":"https://github.com/saltstack/salt/pull/25522#discussion_r35023618"},"pull_request":{"href":"https://api.github.com/repos/saltstack/salt/pulls/25522"}}},"pull_request":{"url":"https://api.github.com/repos/saltstack/salt/pulls/25522","id":40263669,"html_url":"https://github.com/saltstack/salt/pull/25522","diff_url":"https://github.com/saltstack/salt/pull/25522.diff","patch_url":"https://github.com/saltstack/salt/pull/25522.patch","issue_url":"https://api.github.com/repos/saltstack/salt/issues/25522","number":25522,"state":"open","locked":false,"title":"Adding Chocolatey state module","user":{"login":"rdutch","id":10076820,"avatar_url":"https://avatars.githubusercontent.com/u/10076820?v=3","gravatar_id":"","url":"https://api.github.com/users/rdutch","html_url":"https://github.com/rdutch","followers_url":"https://api.github.com/users/rdutch/followers","following_url":"https://api.github.com/users/rdutch/following{/other_user}","gists_url":"https://api.github.com/users/rdutch/gists{/gist_id}","starred_url":"https://api.github.com/users/rdutch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rdutch/subscriptions","organizations_url":"https://api.github.com/users/rdutch/orgs","repos_url":"https://api.github.com/users/rdutch/repos","events_url":"https://api.github.com/users/rdutch/events{/privacy}","received_events_url":"https://api.github.com/users/rdutch/received_events","type":"User","site_admin":false},"body":"Chocolatey state module for installing and uninstalling chocolatey Windows packages.\r\nThe state will check if a package is already installed and if not install or visa versa for uninstalling.\r\n","created_at":"2015-07-17T19:28:41Z","updated_at":"2015-07-20T17:58:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"01934c3a31770110c35993424aa98ac6b7568c04","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/saltstack/salt/pulls/25522/commits","review_comments_url":"https://api.github.com/repos/saltstack/salt/pulls/25522/comments","review_comment_url":"https://api.github.com/repos/saltstack/salt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/25522/comments","statuses_url":"https://api.github.com/repos/saltstack/salt/statuses/0db68dc8a9752111b781fd3f5012baee8d0f868b","head":{"label":"rdutch:chocolatey_state","ref":"chocolatey_state","sha":"0db68dc8a9752111b781fd3f5012baee8d0f868b","user":{"login":"rdutch","id":10076820,"avatar_url":"https://avatars.githubusercontent.com/u/10076820?v=3","gravatar_id":"","url":"https://api.github.com/users/rdutch","html_url":"https://github.com/rdutch","followers_url":"https://api.github.com/users/rdutch/followers","following_url":"https://api.github.com/users/rdutch/following{/other_user}","gists_url":"https://api.github.com/users/rdutch/gists{/gist_id}","starred_url":"https://api.github.com/users/rdutch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rdutch/subscriptions","organizations_url":"https://api.github.com/users/rdutch/orgs","repos_url":"https://api.github.com/users/rdutch/repos","events_url":"https://api.github.com/users/rdutch/events{/privacy}","received_events_url":"https://api.github.com/users/rdutch/received_events","type":"User","site_admin":false},"repo":{"id":27553173,"name":"salt","full_name":"rdutch/salt","owner":{"login":"rdutch","id":10076820,"avatar_url":"https://avatars.githubusercontent.com/u/10076820?v=3","gravatar_id":"","url":"https://api.github.com/users/rdutch","html_url":"https://github.com/rdutch","followers_url":"https://api.github.com/users/rdutch/followers","following_url":"https://api.github.com/users/rdutch/following{/other_user}","gists_url":"https://api.github.com/users/rdutch/gists{/gist_id}","starred_url":"https://api.github.com/users/rdutch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rdutch/subscriptions","organizations_url":"https://api.github.com/users/rdutch/orgs","repos_url":"https://api.github.com/users/rdutch/repos","events_url":"https://api.github.com/users/rdutch/events{/privacy}","received_events_url":"https://api.github.com/users/rdutch/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rdutch/salt","description":"Infrastructure automation and management system","fork":true,"url":"https://api.github.com/repos/rdutch/salt","forks_url":"https://api.github.com/repos/rdutch/salt/forks","keys_url":"https://api.github.com/repos/rdutch/salt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rdutch/salt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rdutch/salt/teams","hooks_url":"https://api.github.com/repos/rdutch/salt/hooks","issue_events_url":"https://api.github.com/repos/rdutch/salt/issues/events{/number}","events_url":"https://api.github.com/repos/rdutch/salt/events","assignees_url":"https://api.github.com/repos/rdutch/salt/assignees{/user}","branches_url":"https://api.github.com/repos/rdutch/salt/branches{/branch}","tags_url":"https://api.github.com/repos/rdutch/salt/tags","blobs_url":"https://api.github.com/repos/rdutch/salt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rdutch/salt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rdutch/salt/git/refs{/sha}","trees_url":"https://api.github.com/repos/rdutch/salt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rdutch/salt/statuses/{sha}","languages_url":"https://api.github.com/repos/rdutch/salt/languages","stargazers_url":"https://api.github.com/repos/rdutch/salt/stargazers","contributors_url":"https://api.github.com/repos/rdutch/salt/contributors","subscribers_url":"https://api.github.com/repos/rdutch/salt/subscribers","subscription_url":"https://api.github.com/repos/rdutch/salt/subscription","commits_url":"https://api.github.com/repos/rdutch/salt/commits{/sha}","git_commits_url":"https://api.github.com/repos/rdutch/salt/git/commits{/sha}","comments_url":"https://api.github.com/repos/rdutch/salt/comments{/number}","issue_comment_url":"https://api.github.com/repos/rdutch/salt/issues/comments{/number}","contents_url":"https://api.github.com/repos/rdutch/salt/contents/{+path}","compare_url":"https://api.github.com/repos/rdutch/salt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rdutch/salt/merges","archive_url":"https://api.github.com/repos/rdutch/salt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rdutch/salt/downloads","issues_url":"https://api.github.com/repos/rdutch/salt/issues{/number}","pulls_url":"https://api.github.com/repos/rdutch/salt/pulls{/number}","milestones_url":"https://api.github.com/repos/rdutch/salt/milestones{/number}","notifications_url":"https://api.github.com/repos/rdutch/salt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rdutch/salt/labels{/name}","releases_url":"https://api.github.com/repos/rdutch/salt/releases{/id}","created_at":"2014-12-04T18:08:46Z","updated_at":"2014-12-04T18:08:54Z","pushed_at":"2015-07-20T13:48:17Z","git_url":"git://github.com/rdutch/salt.git","ssh_url":"git@github.com:rdutch/salt.git","clone_url":"https://github.com/rdutch/salt.git","svn_url":"https://github.com/rdutch/salt","homepage":"saltstack.com","size":113874,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"develop"}},"base":{"label":"saltstack:develop","ref":"develop","sha":"8e1fa5f032304569615de9f684068927598bc1f6","user":{"login":"saltstack","id":1147473,"avatar_url":"https://avatars.githubusercontent.com/u/1147473?v=3","gravatar_id":"","url":"https://api.github.com/users/saltstack","html_url":"https://github.com/saltstack","followers_url":"https://api.github.com/users/saltstack/followers","following_url":"https://api.github.com/users/saltstack/following{/other_user}","gists_url":"https://api.github.com/users/saltstack/gists{/gist_id}","starred_url":"https://api.github.com/users/saltstack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saltstack/subscriptions","organizations_url":"https://api.github.com/users/saltstack/orgs","repos_url":"https://api.github.com/users/saltstack/repos","events_url":"https://api.github.com/users/saltstack/events{/privacy}","received_events_url":"https://api.github.com/users/saltstack/received_events","type":"Organization","site_admin":false},"repo":{"id":1390248,"name":"salt","full_name":"saltstack/salt","owner":{"login":"saltstack","id":1147473,"avatar_url":"https://avatars.githubusercontent.com/u/1147473?v=3","gravatar_id":"","url":"https://api.github.com/users/saltstack","html_url":"https://github.com/saltstack","followers_url":"https://api.github.com/users/saltstack/followers","following_url":"https://api.github.com/users/saltstack/following{/other_user}","gists_url":"https://api.github.com/users/saltstack/gists{/gist_id}","starred_url":"https://api.github.com/users/saltstack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saltstack/subscriptions","organizations_url":"https://api.github.com/users/saltstack/orgs","repos_url":"https://api.github.com/users/saltstack/repos","events_url":"https://api.github.com/users/saltstack/events{/privacy}","received_events_url":"https://api.github.com/users/saltstack/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/saltstack/salt","description":"Infrastructure automation and management system","fork":false,"url":"https://api.github.com/repos/saltstack/salt","forks_url":"https://api.github.com/repos/saltstack/salt/forks","keys_url":"https://api.github.com/repos/saltstack/salt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/saltstack/salt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/saltstack/salt/teams","hooks_url":"https://api.github.com/repos/saltstack/salt/hooks","issue_events_url":"https://api.github.com/repos/saltstack/salt/issues/events{/number}","events_url":"https://api.github.com/repos/saltstack/salt/events","assignees_url":"https://api.github.com/repos/saltstack/salt/assignees{/user}","branches_url":"https://api.github.com/repos/saltstack/salt/branches{/branch}","tags_url":"https://api.github.com/repos/saltstack/salt/tags","blobs_url":"https://api.github.com/repos/saltstack/salt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/saltstack/salt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/saltstack/salt/git/refs{/sha}","trees_url":"https://api.github.com/repos/saltstack/salt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/saltstack/salt/statuses/{sha}","languages_url":"https://api.github.com/repos/saltstack/salt/languages","stargazers_url":"https://api.github.com/repos/saltstack/salt/stargazers","contributors_url":"https://api.github.com/repos/saltstack/salt/contributors","subscribers_url":"https://api.github.com/repos/saltstack/salt/subscribers","subscription_url":"https://api.github.com/repos/saltstack/salt/subscription","commits_url":"https://api.github.com/repos/saltstack/salt/commits{/sha}","git_commits_url":"https://api.github.com/repos/saltstack/salt/git/commits{/sha}","comments_url":"https://api.github.com/repos/saltstack/salt/comments{/number}","issue_comment_url":"https://api.github.com/repos/saltstack/salt/issues/comments{/number}","contents_url":"https://api.github.com/repos/saltstack/salt/contents/{+path}","compare_url":"https://api.github.com/repos/saltstack/salt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/saltstack/salt/merges","archive_url":"https://api.github.com/repos/saltstack/salt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/saltstack/salt/downloads","issues_url":"https://api.github.com/repos/saltstack/salt/issues{/number}","pulls_url":"https://api.github.com/repos/saltstack/salt/pulls{/number}","milestones_url":"https://api.github.com/repos/saltstack/salt/milestones{/number}","notifications_url":"https://api.github.com/repos/saltstack/salt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/saltstack/salt/labels{/name}","releases_url":"https://api.github.com/repos/saltstack/salt/releases{/id}","created_at":"2011-02-20T20:16:56Z","updated_at":"2015-07-20T06:34:56Z","pushed_at":"2015-07-20T17:51:36Z","git_url":"git://github.com/saltstack/salt.git","ssh_url":"git@github.com:saltstack/salt.git","clone_url":"https://github.com/saltstack/salt.git","svn_url":"https://github.com/saltstack/salt","homepage":"saltstack.com","size":233510,"stargazers_count":5427,"watchers_count":5427,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2309,"mirror_url":null,"open_issues_count":2771,"forks":2309,"open_issues":2771,"watchers":5427,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/saltstack/salt/pulls/25522"},"html":{"href":"https://github.com/saltstack/salt/pull/25522"},"issue":{"href":"https://api.github.com/repos/saltstack/salt/issues/25522"},"comments":{"href":"https://api.github.com/repos/saltstack/salt/issues/25522/comments"},"review_comments":{"href":"https://api.github.com/repos/saltstack/salt/pulls/25522/comments"},"review_comment":{"href":"https://api.github.com/repos/saltstack/salt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/saltstack/salt/pulls/25522/commits"},"statuses":{"href":"https://api.github.com/repos/saltstack/salt/statuses/0db68dc8a9752111b781fd3f5012baee8d0f868b"}}}}