GitHub PullRequestReviewCommentEvent at 2014-09-17 17:54:19
Repository: chef
Actor: mcquin
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/opscode/chef/pulls/comments/17681332","id":17681332,"diff_hunk":"@@ -0,0 +1,134 @@\n+#\n+# Author:: Tyler Ball (<tball@opscode.com>)\n+# Copyright:: Copyright (c) 2014 Opscode, Inc.\n+# License:: Apache License, Version 2.0\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+#     http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+#\n+\n+require 'mixlib/cli'\n+require 'chef/config'\n+require 'chef/encrypted_data_bag_item/check_encrypted'\n+\n+class Chef\n+  class Knife\n+    module DataBagSecretOptions\n+      include Mixlib::CLI\n+      include Chef::EncryptedDataBagItem::CheckEncrypted\n+\n+      # The config object is populated by knife#merge_configs with knife.rb `knife[:*]` config values, but they do\n+      # not overwrite the command line properties.  It does mean, however, that `knife[:secret]` and `--secret-file`\n+      # passed at the same time populate both `config[:secret]` and `config[:secret_file]`.  We cannot differentiate\n+      # the valid case (`knife[:secret]` in config file and `--secret-file` on CL) and the invalid case (`--secret`\n+      # and `--secret-file` on the CL) - thats why I'm storing the CL options in a different config key if they\n+      # are provided.\n+\n+      def self.included(base)\n+        base.option :secret,\n+               :short => \"-s SECRET\",\n+               :long  => \"--secret \",\n+               :description => \"The secret key to use to encrypt data bag item values.  Can also be defaulted in your config with the key 'secret'\",\n+               # Need to store value from command line in separate variable - knife#merge_configs populates same keys\n+               # on config object from\n+               :proc => Proc.new { |s| set_cl_secret(s) }\n+\n+        base.option :secret_file,\n+               :long => \"--secret-file SECRET_FILE\",\n+               :description => \"A file containing the secret key to use to encrypt data bag item values.  Can also be defaulted in your config with the key 'secret_file'\",\n+               :proc => Proc.new { |sf| set_cl_secret_file(sf) }\n+\n+        base.option :encrypt,\n+               :long => \"--encrypt\",\n+               :description => \"If 'secret' or 'secret_file' is present in your config, then encrypt data bags using it\",\n+               :boolean => true,\n+               :default => false\n+      end\n+\n+      ##\n+      # Determine if the user has specified an appropriate secret for encrypting data bag items.\n+      # @returns boolean\n+      def encryption_secret_provided?(need_encrypt_flag = true)","path":"lib/chef/knife/data_bag_secret_options.rb","position":60,"original_position":60,"commit_id":"7fd89cc9b79d27c312440ce0b7fc3dd06e4d7043","original_commit_id":"7fd89cc9b79d27c312440ce0b7fc3dd06e4d7043","user":{"login":"mcquin","id":4721755,"avatar_url":"https://avatars.githubusercontent.com/u/4721755?v=2","gravatar_id":"b803bcb0516197b4a1567d1d2e1736de","url":"https://api.github.com/users/mcquin","html_url":"https://github.com/mcquin","followers_url":"https://api.github.com/users/mcquin/followers","following_url":"https://api.github.com/users/mcquin/following{/other_user}","gists_url":"https://api.github.com/users/mcquin/gists{/gist_id}","starred_url":"https://api.github.com/users/mcquin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcquin/subscriptions","organizations_url":"https://api.github.com/users/mcquin/orgs","repos_url":"https://api.github.com/users/mcquin/repos","events_url":"https://api.github.com/users/mcquin/events{/privacy}","received_events_url":"https://api.github.com/users/mcquin/received_events","type":"User","site_admin":false},"body":"So you could either write two methods: `encryption_secret_provided?` and `encryption_secret_provided_with_flag?`, or you could move the boolean parameter out of the `encryption_secret_provided?` function and use either a method like\r\n\r\n```ruby\r\ndef needs_encrypt_flag?\r\n  false\r\nend\r\n```\r\nin the data bag options module that can be overwritten in the knife data bag classes which require `--encrypt`, or include `attr_accesstor :needs_encrypt_flag` in the data bag options module, which can be set at the time the knife data bag classes call `encryption_secret_provided?`. These are relatively equivalent, though the latter is more flexible if the data bag class require `--encrypt` in only a few cases.","created_at":"2014-09-17T17:54:19Z","updated_at":"2014-09-17T17:54:19Z","html_url":"https://github.com/opscode/chef/pull/1902#discussion_r17681332","pull_request_url":"https://api.github.com/repos/opscode/chef/pulls/1902","_links":{"self":{"href":"https://api.github.com/repos/opscode/chef/pulls/comments/17681332"},"html":{"href":"https://github.com/opscode/chef/pull/1902#discussion_r17681332"},"pull_request":{"href":"https://api.github.com/repos/opscode/chef/pulls/1902"}}},"pull_request":{"url":"https://api.github.com/repos/opscode/chef/pulls/1902","id":20202529,"html_url":"https://github.com/opscode/chef/pull/1902","diff_url":"https://github.com/opscode/chef/pull/1902.diff","patch_url":"https://github.com/opscode/chef/pull/1902.patch","issue_url":"https://api.github.com/repos/opscode/chef/issues/1902","number":1902,"state":"open","locked":false,"title":"Justanshulsharma feature/encrypted data flag","user":{"login":"mcquin","id":4721755,"avatar_url":"https://avatars.githubusercontent.com/u/4721755?v=2","gravatar_id":"b803bcb0516197b4a1567d1d2e1736de","url":"https://api.github.com/users/mcquin","html_url":"https://github.com/mcquin","followers_url":"https://api.github.com/users/mcquin/followers","following_url":"https://api.github.com/users/mcquin/following{/other_user}","gists_url":"https://api.github.com/users/mcquin/gists{/gist_id}","starred_url":"https://api.github.com/users/mcquin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcquin/subscriptions","organizations_url":"https://api.github.com/users/mcquin/orgs","repos_url":"https://api.github.com/users/mcquin/repos","events_url":"https://api.github.com/users/mcquin/events{/privacy}","received_events_url":"https://api.github.com/users/mcquin/received_events","type":"User","site_admin":false},"body":"@justanshulsharma Thanks again for the work you did on adding this feature! After some discussion we decided to modify the behavior somewhat, so I've added work to your PR here.\r\n\r\n@serdar I don't have any more time to work on this before I leave. The code and unit tests for show and edit still need to be added. Also, I don't know if we have checks in place for what happens if knife.rb specifies `secret` and `secret_file` or if we need to add those to the code here.","created_at":"2014-08-22T23:24:48Z","updated_at":"2014-09-17T17:54:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1db44723236c563d6951c78dfbbc87c258890117","assignee":{"login":"tyler-ball","id":2481463,"avatar_url":"https://avatars.githubusercontent.com/u/2481463?v=2","gravatar_id":"282275b1172fdab2f64a2bbd88737a57","url":"https://api.github.com/users/tyler-ball","html_url":"https://github.com/tyler-ball","followers_url":"https://api.github.com/users/tyler-ball/followers","following_url":"https://api.github.com/users/tyler-ball/following{/other_user}","gists_url":"https://api.github.com/users/tyler-ball/gists{/gist_id}","starred_url":"https://api.github.com/users/tyler-ball/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tyler-ball/subscriptions","organizations_url":"https://api.github.com/users/tyler-ball/orgs","repos_url":"https://api.github.com/users/tyler-ball/repos","events_url":"https://api.github.com/users/tyler-ball/events{/privacy}","received_events_url":"https://api.github.com/users/tyler-ball/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/opscode/chef/milestones/2","labels_url":"https://api.github.com/repos/opscode/chef/milestones/2/labels","id":666211,"number":2,"title":"Chef 12","description":"","creator":{"login":"sersut","id":1695955,"avatar_url":"https://avatars.githubusercontent.com/u/1695955?v=2","gravatar_id":"96f67e1f6270e46bfc95c323d4e53fff","url":"https://api.github.com/users/sersut","html_url":"https://github.com/sersut","followers_url":"https://api.github.com/users/sersut/followers","following_url":"https://api.github.com/users/sersut/following{/other_user}","gists_url":"https://api.github.com/users/sersut/gists{/gist_id}","starred_url":"https://api.github.com/users/sersut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sersut/subscriptions","organizations_url":"https://api.github.com/users/sersut/orgs","repos_url":"https://api.github.com/users/sersut/repos","events_url":"https://api.github.com/users/sersut/events{/privacy}","received_events_url":"https://api.github.com/users/sersut/received_events","type":"User","site_admin":false},"open_issues":20,"closed_issues":31,"state":"open","created_at":"2014-05-21T20:48:49Z","updated_at":"2014-09-16T19:25:57Z","due_on":null},"commits_url":"https://api.github.com/repos/opscode/chef/pulls/1902/commits","review_comments_url":"https://api.github.com/repos/opscode/chef/pulls/1902/comments","review_comment_url":"https://api.github.com/repos/opscode/chef/pulls/comments/{number}","comments_url":"https://api.github.com/repos/opscode/chef/issues/1902/comments","statuses_url":"https://api.github.com/repos/opscode/chef/statuses/7fd89cc9b79d27c312440ce0b7fc3dd06e4d7043","head":{"label":"opscode:justanshulsharma-feature/encrypted_data_flag","ref":"justanshulsharma-feature/encrypted_data_flag","sha":"7fd89cc9b79d27c312440ce0b7fc3dd06e4d7043","user":{"login":"opscode","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=2","gravatar_id":"890bf76f4dc18c12a19c55e988a1bd5e","url":"https://api.github.com/users/opscode","html_url":"https://github.com/opscode","followers_url":"https://api.github.com/users/opscode/followers","following_url":"https://api.github.com/users/opscode/following{/other_user}","gists_url":"https://api.github.com/users/opscode/gists{/gist_id}","starred_url":"https://api.github.com/users/opscode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opscode/subscriptions","organizations_url":"https://api.github.com/users/opscode/orgs","repos_url":"https://api.github.com/users/opscode/repos","events_url":"https://api.github.com/users/opscode/events{/privacy}","received_events_url":"https://api.github.com/users/opscode/received_events","type":"Organization","site_admin":false},"repo":{"id":108278,"name":"chef","full_name":"opscode/chef","owner":{"login":"opscode","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=2","gravatar_id":"890bf76f4dc18c12a19c55e988a1bd5e","url":"https://api.github.com/users/opscode","html_url":"https://github.com/opscode","followers_url":"https://api.github.com/users/opscode/followers","following_url":"https://api.github.com/users/opscode/following{/other_user}","gists_url":"https://api.github.com/users/opscode/gists{/gist_id}","starred_url":"https://api.github.com/users/opscode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opscode/subscriptions","organizations_url":"https://api.github.com/users/opscode/orgs","repos_url":"https://api.github.com/users/opscode/repos","events_url":"https://api.github.com/users/opscode/events{/privacy}","received_events_url":"https://api.github.com/users/opscode/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opscode/chef","description":"A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure.","fork":false,"url":"https://api.github.com/repos/opscode/chef","forks_url":"https://api.github.com/repos/opscode/chef/forks","keys_url":"https://api.github.com/repos/opscode/chef/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opscode/chef/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opscode/chef/teams","hooks_url":"https://api.github.com/repos/opscode/chef/hooks","issue_events_url":"https://api.github.com/repos/opscode/chef/issues/events{/number}","events_url":"https://api.github.com/repos/opscode/chef/events","assignees_url":"https://api.github.com/repos/opscode/chef/assignees{/user}","branches_url":"https://api.github.com/repos/opscode/chef/branches{/branch}","tags_url":"https://api.github.com/repos/opscode/chef/tags","blobs_url":"https://api.github.com/repos/opscode/chef/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opscode/chef/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opscode/chef/git/refs{/sha}","trees_url":"https://api.github.com/repos/opscode/chef/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opscode/chef/statuses/{sha}","languages_url":"https://api.github.com/repos/opscode/chef/languages","stargazers_url":"https://api.github.com/repos/opscode/chef/stargazers","contributors_url":"https://api.github.com/repos/opscode/chef/contributors","subscribers_url":"https://api.github.com/repos/opscode/chef/subscribers","subscription_url":"https://api.github.com/repos/opscode/chef/subscription","commits_url":"https://api.github.com/repos/opscode/chef/commits{/sha}","git_commits_url":"https://api.github.com/repos/opscode/chef/git/commits{/sha}","comments_url":"https://api.github.com/repos/opscode/chef/comments{/number}","issue_comment_url":"https://api.github.com/repos/opscode/chef/issues/comments/{number}","contents_url":"https://api.github.com/repos/opscode/chef/contents/{+path}","compare_url":"https://api.github.com/repos/opscode/chef/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opscode/chef/merges","archive_url":"https://api.github.com/repos/opscode/chef/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opscode/chef/downloads","issues_url":"https://api.github.com/repos/opscode/chef/issues{/number}","pulls_url":"https://api.github.com/repos/opscode/chef/pulls{/number}","milestones_url":"https://api.github.com/repos/opscode/chef/milestones{/number}","notifications_url":"https://api.github.com/repos/opscode/chef/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opscode/chef/labels{/name}","releases_url":"https://api.github.com/repos/opscode/chef/releases{/id}","created_at":"2009-01-15T20:40:48Z","updated_at":"2014-09-17T16:03:06Z","pushed_at":"2014-09-17T17:49:11Z","git_url":"git://github.com/opscode/chef.git","ssh_url":"git@github.com:opscode/chef.git","clone_url":"https://github.com/opscode/chef.git","svn_url":"https://github.com/opscode/chef","homepage":"http://www.getchef.com/chef/","size":158501,"stargazers_count":3012,"watchers_count":3012,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1217,"mirror_url":null,"open_issues_count":236,"forks":1217,"open_issues":236,"watchers":3012,"default_branch":"master"}},"base":{"label":"opscode:master","ref":"master","sha":"1241ea6f9866d0e61d11129bb32e5fc96cd2bac0","user":{"login":"opscode","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=2","gravatar_id":"890bf76f4dc18c12a19c55e988a1bd5e","url":"https://api.github.com/users/opscode","html_url":"https://github.com/opscode","followers_url":"https://api.github.com/users/opscode/followers","following_url":"https://api.github.com/users/opscode/following{/other_user}","gists_url":"https://api.github.com/users/opscode/gists{/gist_id}","starred_url":"https://api.github.com/users/opscode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opscode/subscriptions","organizations_url":"https://api.github.com/users/opscode/orgs","repos_url":"https://api.github.com/users/opscode/repos","events_url":"https://api.github.com/users/opscode/events{/privacy}","received_events_url":"https://api.github.com/users/opscode/received_events","type":"Organization","site_admin":false},"repo":{"id":108278,"name":"chef","full_name":"opscode/chef","owner":{"login":"opscode","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=2","gravatar_id":"890bf76f4dc18c12a19c55e988a1bd5e","url":"https://api.github.com/users/opscode","html_url":"https://github.com/opscode","followers_url":"https://api.github.com/users/opscode/followers","following_url":"https://api.github.com/users/opscode/following{/other_user}","gists_url":"https://api.github.com/users/opscode/gists{/gist_id}","starred_url":"https://api.github.com/users/opscode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opscode/subscriptions","organizations_url":"https://api.github.com/users/opscode/orgs","repos_url":"https://api.github.com/users/opscode/repos","events_url":"https://api.github.com/users/opscode/events{/privacy}","received_events_url":"https://api.github.com/users/opscode/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opscode/chef","description":"A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure.","fork":false,"url":"https://api.github.com/repos/opscode/chef","forks_url":"https://api.github.com/repos/opscode/chef/forks","keys_url":"https://api.github.com/repos/opscode/chef/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opscode/chef/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opscode/chef/teams","hooks_url":"https://api.github.com/repos/opscode/chef/hooks","issue_events_url":"https://api.github.com/repos/opscode/chef/issues/events{/number}","events_url":"https://api.github.com/repos/opscode/chef/events","assignees_url":"https://api.github.com/repos/opscode/chef/assignees{/user}","branches_url":"https://api.github.com/repos/opscode/chef/branches{/branch}","tags_url":"https://api.github.com/repos/opscode/chef/tags","blobs_url":"https://api.github.com/repos/opscode/chef/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opscode/chef/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opscode/chef/git/refs{/sha}","trees_url":"https://api.github.com/repos/opscode/chef/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opscode/chef/statuses/{sha}","languages_url":"https://api.github.com/repos/opscode/chef/languages","stargazers_url":"https://api.github.com/repos/opscode/chef/stargazers","contributors_url":"https://api.github.com/repos/opscode/chef/contributors","subscribers_url":"https://api.github.com/repos/opscode/chef/subscribers","subscription_url":"https://api.github.com/repos/opscode/chef/subscription","commits_url":"https://api.github.com/repos/opscode/chef/commits{/sha}","git_commits_url":"https://api.github.com/repos/opscode/chef/git/commits{/sha}","comments_url":"https://api.github.com/repos/opscode/chef/comments{/number}","issue_comment_url":"https://api.github.com/repos/opscode/chef/issues/comments/{number}","contents_url":"https://api.github.com/repos/opscode/chef/contents/{+path}","compare_url":"https://api.github.com/repos/opscode/chef/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opscode/chef/merges","archive_url":"https://api.github.com/repos/opscode/chef/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opscode/chef/downloads","issues_url":"https://api.github.com/repos/opscode/chef/issues{/number}","pulls_url":"https://api.github.com/repos/opscode/chef/pulls{/number}","milestones_url":"https://api.github.com/repos/opscode/chef/milestones{/number}","notifications_url":"https://api.github.com/repos/opscode/chef/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opscode/chef/labels{/name}","releases_url":"https://api.github.com/repos/opscode/chef/releases{/id}","created_at":"2009-01-15T20:40:48Z","updated_at":"2014-09-17T16:03:06Z","pushed_at":"2014-09-17T17:49:11Z","git_url":"git://github.com/opscode/chef.git","ssh_url":"git@github.com:opscode/chef.git","clone_url":"https://github.com/opscode/chef.git","svn_url":"https://github.com/opscode/chef","homepage":"http://www.getchef.com/chef/","size":158501,"stargazers_count":3012,"watchers_count":3012,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1217,"mirror_url":null,"open_issues_count":236,"forks":1217,"open_issues":236,"watchers":3012,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/opscode/chef/pulls/1902"},"html":{"href":"https://github.com/opscode/chef/pull/1902"},"issue":{"href":"https://api.github.com/repos/opscode/chef/issues/1902"},"comments":{"href":"https://api.github.com/repos/opscode/chef/issues/1902/comments"},"review_comments":{"href":"https://api.github.com/repos/opscode/chef/pulls/1902/comments"},"review_comment":{"href":"https://api.github.com/repos/opscode/chef/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/opscode/chef/pulls/1902/commits"},"statuses":{"href":"https://api.github.com/repos/opscode/chef/statuses/7fd89cc9b79d27c312440ce0b7fc3dd06e4d7043"}}}}