{"action":"opened","number":29047,"pull_request":{"url":"https://api.github.com/repos/saltstack/salt/pulls/29047","id":51242998,"html_url":"https://github.com/saltstack/salt/pull/29047","diff_url":"https://github.com/saltstack/salt/pull/29047.diff","patch_url":"https://github.com/saltstack/salt/pull/29047.patch","issue_url":"https://api.github.com/repos/saltstack/salt/issues/29047","number":29047,"state":"open","locked":false,"title":"Fix salt.modules.gpg.import_key exception: 'GPG_1_3_1 referenced before assignment'","user":{"login":"schwing","id":1611712,"avatar_url":"https://avatars.githubusercontent.com/u/1611712?v=3","gravatar_id":"","url":"https://api.github.com/users/schwing","html_url":"https://github.com/schwing","followers_url":"https://api.github.com/users/schwing/followers","following_url":"https://api.github.com/users/schwing/following{/other_user}","gists_url":"https://api.github.com/users/schwing/gists{/gist_id}","starred_url":"https://api.github.com/users/schwing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schwing/subscriptions","organizations_url":"https://api.github.com/users/schwing/orgs","repos_url":"https://api.github.com/users/schwing/repos","events_url":"https://api.github.com/users/schwing/events{/privacy}","received_events_url":"https://api.github.com/users/schwing/received_events","type":"User","site_admin":false},"body":"###### Changes:\r\n- Fix gpg.import_key() exception: local variable 'GPG_1_3_1' referenced before assignment\r\n- Update the unit tests to test both the gpg.GPG_1_3_1=True and\r\ngpg.GPG_1_3_1=False cases.\r\n\r\n###### Purpose:\r\nCurrently, assigning a value to the GPG_1_3_1 global within gpg.import_key() uses local variable scope. When the the python-gnupg version is < 1.3.1, this exception results:\r\n```yaml\r\n----------\r\n          ID: import-gpg-key\r\n    Function: module.run\r\n        Name: gpg.import_key\r\n      Result: False\r\n     Comment: Module function gpg.import_key threw an exception. Exception: local variable 'GPG_1_3_1' referenced before assignment\r\n     Started: 04:35:16.756421\r\n    Duration: 12.642 ms\r\n     Changes:\r\n```\r\n\r\n###### Reproduction steps:\r\n1. Create a state file containing:\r\n  ```yaml\r\n  {% set public_key = salt['cp.get_file_str']('https://repo.saltstack.com/apt/debian/latest/SALTSTACK-GPG-KEY.pub') %}\r\n\r\n  import-gpg-key:\r\n    module.run:\r\n      - name: gpg.import_key\r\n      - user: salt\r\n      - text: {{ public_key | yaml_encode }}\r\n  ```\r\n2. Run the state:\r\n`salt-call --local --file-root=$(pwd) state.sls gpgbug -l debug`\r\n\r\n###### Debug log: [debug.txt](https://github.com/saltstack/salt/files/39144/debug.txt)","created_at":"2015-11-19T16:11:27Z","updated_at":"2015-11-19T16:11:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/saltstack/salt/pulls/29047/commits","review_comments_url":"https://api.github.com/repos/saltstack/salt/pulls/29047/comments","review_comment_url":"https://api.github.com/repos/saltstack/salt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/29047/comments","statuses_url":"https://api.github.com/repos/saltstack/salt/statuses/813f6e68081427e94f5c32fc927ee2d7d9a94a3a","head":{"label":"schwing:fix-gpg-exception","ref":"fix-gpg-exception","sha":"813f6e68081427e94f5c32fc927ee2d7d9a94a3a","user":{"login":"schwing","id":1611712,"avatar_url":"https://avatars.githubusercontent.com/u/1611712?v=3","gravatar_id":"","url":"https://api.github.com/users/schwing","html_url":"https://github.com/schwing","followers_url":"https://api.github.com/users/schwing/followers","following_url":"https://api.github.com/users/schwing/following{/other_user}","gists_url":"https://api.github.com/users/schwing/gists{/gist_id}","starred_url":"https://api.github.com/users/schwing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schwing/subscriptions","organizations_url":"https://api.github.com/users/schwing/orgs","repos_url":"https://api.github.com/users/schwing/repos","events_url":"https://api.github.com/users/schwing/events{/privacy}","received_events_url":"https://api.github.com/users/schwing/received_events","type":"User","site_admin":false},"repo":{"id":46467893,"name":"salt","full_name":"schwing/salt","owner":{"login":"schwing","id":1611712,"avatar_url":"https://avatars.githubusercontent.com/u/1611712?v=3","gravatar_id":"","url":"https://api.github.com/users/schwing","html_url":"https://github.com/schwing","followers_url":"https://api.github.com/users/schwing/followers","following_url":"https://api.github.com/users/schwing/following{/other_user}","gists_url":"https://api.github.com/users/schwing/gists{/gist_id}","starred_url":"https://api.github.com/users/schwing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schwing/subscriptions","organizations_url":"https://api.github.com/users/schwing/orgs","repos_url":"https://api.github.com/users/schwing/repos","events_url":"https://api.github.com/users/schwing/events{/privacy}","received_events_url":"https://api.github.com/users/schwing/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/schwing/salt","description":"Infrastructure automation and management system","fork":true,"url":"https://api.github.com/repos/schwing/salt","forks_url":"https://api.github.com/repos/schwing/salt/forks","keys_url":"https://api.github.com/repos/schwing/salt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/schwing/salt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/schwing/salt/teams","hooks_url":"https://api.github.com/repos/schwing/salt/hooks","issue_events_url":"https://api.github.com/repos/schwing/salt/issues/events{/number}","events_url":"https://api.github.com/repos/schwing/salt/events","assignees_url":"https://api.github.com/repos/schwing/salt/assignees{/user}","branches_url":"https://api.github.com/repos/schwing/salt/branches{/branch}","tags_url":"https://api.github.com/repos/schwing/salt/tags","blobs_url":"https://api.github.com/repos/schwing/salt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/schwing/salt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/schwing/salt/git/refs{/sha}","trees_url":"https://api.github.com/repos/schwing/salt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/schwing/salt/statuses/{sha}","languages_url":"https://api.github.com/repos/schwing/salt/languages","stargazers_url":"https://api.github.com/repos/schwing/salt/stargazers","contributors_url":"https://api.github.com/repos/schwing/salt/contributors","subscribers_url":"https://api.github.com/repos/schwing/salt/subscribers","subscription_url":"https://api.github.com/repos/schwing/salt/subscription","commits_url":"https://api.github.com/repos/schwing/salt/commits{/sha}","git_commits_url":"https://api.github.com/repos/schwing/salt/git/commits{/sha}","comments_url":"https://api.github.com/repos/schwing/salt/comments{/number}","issue_comment_url":"https://api.github.com/repos/schwing/salt/issues/comments{/number}","contents_url":"https://api.github.com/repos/schwing/salt/contents/{+path}","compare_url":"https://api.github.com/repos/schwing/salt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/schwing/salt/merges","archive_url":"https://api.github.com/repos/schwing/salt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/schwing/salt/downloads","issues_url":"https://api.github.com/repos/schwing/salt/issues{/number}","pulls_url":"https://api.github.com/repos/schwing/salt/pulls{/number}","milestones_url":"https://api.github.com/repos/schwing/salt/milestones{/number}","notifications_url":"https://api.github.com/repos/schwing/salt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/schwing/salt/labels{/name}","releases_url":"https://api.github.com/repos/schwing/salt/releases{/id}","created_at":"2015-11-19T04:38:02Z","updated_at":"2015-11-19T04:38:25Z","pushed_at":"2015-11-19T15:34:39Z","git_url":"git://github.com/schwing/salt.git","ssh_url":"git@github.com:schwing/salt.git","clone_url":"https://github.com/schwing/salt.git","svn_url":"https://github.com/schwing/salt","homepage":"saltstack.com","size":128139,"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:2015.8","ref":"2015.8","sha":"14b5d0ed0fbcc61e586e57180f236e0d167ffb20","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-11-19T15:41:01Z","pushed_at":"2015-11-19T15:42:08Z","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":141945,"stargazers_count":5899,"watchers_count":5899,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2543,"mirror_url":null,"open_issues_count":3161,"forks":2543,"open_issues":3161,"watchers":5899,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/saltstack/salt/pulls/29047"},"html":{"href":"https://github.com/saltstack/salt/pull/29047"},"issue":{"href":"https://api.github.com/repos/saltstack/salt/issues/29047"},"comments":{"href":"https://api.github.com/repos/saltstack/salt/issues/29047/comments"},"review_comments":{"href":"https://api.github.com/repos/saltstack/salt/pulls/29047/comments"},"review_comment":{"href":"https://api.github.com/repos/saltstack/salt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/saltstack/salt/pulls/29047/commits"},"statuses":{"href":"https://api.github.com/repos/saltstack/salt/statuses/813f6e68081427e94f5c32fc927ee2d7d9a94a3a"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":4,"deletions":5,"changed_files":2}}