{"action":"created","comment":{"url":"https://api.github.com/repos/chef/mixlib-install/pulls/comments/46486541","id":46486541,"diff_hunk":"@@ -0,0 +1,264 @@\n+#\n+# Copyright:: Copyright (c) 2015 Chef, 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/versioning\"\n+\n+module Mixlib\n+  class Install\n+    class Product\n+      def initialize(&block)\n+        instance_eval(&block)\n+      end\n+\n+      DSL_PROPERTIES = [\n+        :config_file,\n+        :ctl_command,\n+        :package_name,\n+        :product_name\n+      ]\n+\n+      #\n+      # DSL methods can receive either a String or a Proc to calculate the\n+      # value of the property later on based on the version.\n+      # We error out if we get both the String and Proc, and we return the value\n+      # of the property if we do not receive anything.\n+      #\n+      # @param [String] prop_string\n+      #   value to be set in String form\n+      # @param [Proc] block\n+      #   value to be set in Proc form\n+      #\n+      # @return [String] value of the property\n+      #\n+      DSL_PROPERTIES.each do |prop|\n+        define_method prop do |prop_string = nil, &block|\n+          if block.nil?\n+            if prop_string.nil?\n+              value = instance_variable_get(\"@#{prop}\".to_sym)\n+              return nil if value.nil?\n+\n+              if value.is_a? String\n+                value\n+              else\n+                value.call(version_for(version))\n+              end\n+            else\n+              instance_variable_set(\"@#{prop}\".to_sym, prop_string)\n+            end\n+          else\n+            raise \"Not both at the same time.\" if !prop_string.nil?\n+            instance_variable_set(\"@#{prop}\".to_sym, block)\n+          end\n+        end\n+      end\n+\n+      #\n+      # Sets or retrieves the version for the product. This is used later\n+      # when we are reading the value of a property if a Proc is specified\n+      #\n+      def version(value = nil)\n+        if value.nil?\n+          @version\n+        else\n+          @version = value\n+        end\n+      end\n+\n+      #\n+      # Helper method to convert versions from String to Mixlib::Version\n+      #\n+      # @param [String] version_string\n+      #   value to be set in String form\n+      #\n+      # @return [Mixlib::Version]\n+      def version_for(version_string)\n+        Mixlib::Versioning.parse(version_string)\n+      end\n+    end\n+\n+    class ProductMatrix\n+      def initialize(&block)\n+        @product_map = {}\n+        instance_eval(&block)\n+      end\n+\n+      #\n+      # The only DSL method of this class. It creates a Product with given\n+      # `key` and stores it.\n+      #\n+      def product(key, &block)\n+        @product_map[key] = Product.new(&block)\n+      end\n+\n+      #\n+      # Fetches the keys of available products.\n+      #\n+      # @return Array[String] of keys\n+      def products\n+        @product_map.keys\n+      end\n+\n+      #\n+      # Looks up a product and sets version on it to be used later by the\n+      # Product.\n+      #\n+      # @param [String] key\n+      #   Lookup key of the product.\n+      # @param [String] version\n+      #   Version to be set for the product. By default version is set to :latest\n+      #\n+      # @return [Product]\n+      def lookup(key, version = :latest)\n+        product = @product_map[key]\n+        # We set the lookup version for the product to a very high number in\n+        # order to mimic :latest so that one does not need to handle this\n+        # symbol explicitly when constructing logic based on version numbers.\n+        version = \"1000.1000.1000\" if version.to_sym == :latest\n+        product.version(version)\n+        product\n+      end\n+    end\n+  end\n+end\n+\n+#\n+# If you are making a change to PRODUCT_MATRIX, please make sure\n+# you run `bundle exec rake matrix` at the home of this repository\n+# to update PRODUCT_MATRIX.md.\n+#\n+PRODUCT_MATRIX = Mixlib::Install::ProductMatrix.new do\n+  product \"chef\" do\n+    product_name \"Chef Client\"\n+    package_name \"chef\"\n+  end\n+\n+  product \"chefdk\" do\n+    product_name \"Chef Development Kit\"\n+    package_name \"chefdk\"\n+  end\n+\n+  product \"chef-server\" do\n+    product_name \"Chef Server\"\n+    package_name do |v|\n+      if (v < version_for(\"12.0.0\")) && (v > version_for(\"11.0.0\"))\n+        \"chef-server\"\n+      else\n+        \"chef-server-core\"\n+      end\n+    end\n+    ctl_command \"chef-server-ctl\"\n+    config_file \"/etc/opscode/chef-server.rb\"\n+  end\n+\n+  product \"manage\" do\n+    product_name \"Management Console\"\n+    package_name do |v|\n+      v < version_for(\"2.0.0\") ? \"opscode-manage\" : \"chef-manage\"\n+    end\n+    ctl_command do |v|\n+      v < version_for(\"2.0.0\") ? \"opscode-manage-ctl\" : \"chef-manage-ctl\"\n+    end\n+    config_file \"/etc/opscode-manage/manage.rb\"\n+  end\n+\n+  product \"chef-ha\" do\n+    product_name \"Chef Server High Availability addon\"\n+    package_name \"chef-ha\"\n+    config_file \"/etc/opscode/chef-server.rb\"\n+  end\n+\n+  product \"reporting\" do\n+    product_name \"Chef Server Reporting addon\"\n+    package_name \"opscode-reporting\"\n+    ctl_command \"opscode-reporting-ctl\"\n+    config_file \"/etc/opscode-reporting/opscode-reporting.rb\"\n+  end\n+\n+  product \"supermarket\" do\n+    product_name \"Chef Cloud Marketplace addon\"","path":"lib/mixlib/install/product.rb","position":192,"original_position":192,"commit_id":"45cafb6df54dc2c592498555067746731abd9324","original_commit_id":"45cafb6df54dc2c592498555067746731abd9324","user":{"login":"schisamo","id":6164,"avatar_url":"https://avatars.githubusercontent.com/u/6164?v=3","gravatar_id":"","url":"https://api.github.com/users/schisamo","html_url":"https://github.com/schisamo","followers_url":"https://api.github.com/users/schisamo/followers","following_url":"https://api.github.com/users/schisamo/following{/other_user}","gists_url":"https://api.github.com/users/schisamo/gists{/gist_id}","starred_url":"https://api.github.com/users/schisamo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schisamo/subscriptions","organizations_url":"https://api.github.com/users/schisamo/orgs","repos_url":"https://api.github.com/users/schisamo/repos","events_url":"https://api.github.com/users/schisamo/events{/privacy}","received_events_url":"https://api.github.com/users/schisamo/received_events","type":"User","site_admin":false},"body":"copy pasta error","created_at":"2015-12-02T22:34:36Z","updated_at":"2015-12-02T22:34:36Z","html_url":"https://github.com/chef/mixlib-install/pull/25#discussion_r46486541","pull_request_url":"https://api.github.com/repos/chef/mixlib-install/pulls/25","_links":{"self":{"href":"https://api.github.com/repos/chef/mixlib-install/pulls/comments/46486541"},"html":{"href":"https://github.com/chef/mixlib-install/pull/25#discussion_r46486541"},"pull_request":{"href":"https://api.github.com/repos/chef/mixlib-install/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/chef/mixlib-install/pulls/25","id":52445913,"html_url":"https://github.com/chef/mixlib-install/pull/25","diff_url":"https://github.com/chef/mixlib-install/pull/25.diff","patch_url":"https://github.com/chef/mixlib-install/pull/25.patch","issue_url":"https://api.github.com/repos/chef/mixlib-install/issues/25","number":25,"state":"open","locked":false,"title":"Move product matrix and its documentation from chef-ingredient.","user":{"login":"sersut","id":1695955,"avatar_url":"https://avatars.githubusercontent.com/u/1695955?v=3","gravatar_id":"","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},"body":"This PR moves [product matrix](https://github.com/chef-cookbooks/chef-ingredient/blob/master/PRODUCT_MATRIX.md) and its helper methods from chef-cookbooks/chef-ingredient to here. A few things to keep in mind while reviewing:\r\n\r\n1. I do not think the `package_name` column in the `PRODUCT_MATRIX.md` makes sense. I think we should add a description column for it to be more useful for the end user. But I did not do that and copied over only what we have. \r\n2. @jtimberman can you double check the version based logic in the matrix. I have double checked it but just in case :smile: \r\n\r\n/cc: @chef/engineering-services, @thommay ","created_at":"2015-12-02T19:58:09Z","updated_at":"2015-12-02T22:34:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"246e446be4453f32e91d0961369002a635032aab","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/chef/mixlib-install/pulls/25/commits","review_comments_url":"https://api.github.com/repos/chef/mixlib-install/pulls/25/comments","review_comment_url":"https://api.github.com/repos/chef/mixlib-install/pulls/comments{/number}","comments_url":"https://api.github.com/repos/chef/mixlib-install/issues/25/comments","statuses_url":"https://api.github.com/repos/chef/mixlib-install/statuses/45cafb6df54dc2c592498555067746731abd9324","head":{"label":"chef:sersut/product-matrix","ref":"sersut/product-matrix","sha":"45cafb6df54dc2c592498555067746731abd9324","user":{"login":"chef","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=3","gravatar_id":"","url":"https://api.github.com/users/chef","html_url":"https://github.com/chef","followers_url":"https://api.github.com/users/chef/followers","following_url":"https://api.github.com/users/chef/following{/other_user}","gists_url":"https://api.github.com/users/chef/gists{/gist_id}","starred_url":"https://api.github.com/users/chef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chef/subscriptions","organizations_url":"https://api.github.com/users/chef/orgs","repos_url":"https://api.github.com/users/chef/repos","events_url":"https://api.github.com/users/chef/events{/privacy}","received_events_url":"https://api.github.com/users/chef/received_events","type":"Organization","site_admin":false},"repo":{"id":39073784,"name":"mixlib-install","full_name":"chef/mixlib-install","owner":{"login":"chef","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=3","gravatar_id":"","url":"https://api.github.com/users/chef","html_url":"https://github.com/chef","followers_url":"https://api.github.com/users/chef/followers","following_url":"https://api.github.com/users/chef/following{/other_user}","gists_url":"https://api.github.com/users/chef/gists{/gist_id}","starred_url":"https://api.github.com/users/chef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chef/subscriptions","organizations_url":"https://api.github.com/users/chef/orgs","repos_url":"https://api.github.com/users/chef/repos","events_url":"https://api.github.com/users/chef/events{/privacy}","received_events_url":"https://api.github.com/users/chef/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chef/mixlib-install","description":"A mixin to help with omnitruck installs","fork":false,"url":"https://api.github.com/repos/chef/mixlib-install","forks_url":"https://api.github.com/repos/chef/mixlib-install/forks","keys_url":"https://api.github.com/repos/chef/mixlib-install/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chef/mixlib-install/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chef/mixlib-install/teams","hooks_url":"https://api.github.com/repos/chef/mixlib-install/hooks","issue_events_url":"https://api.github.com/repos/chef/mixlib-install/issues/events{/number}","events_url":"https://api.github.com/repos/chef/mixlib-install/events","assignees_url":"https://api.github.com/repos/chef/mixlib-install/assignees{/user}","branches_url":"https://api.github.com/repos/chef/mixlib-install/branches{/branch}","tags_url":"https://api.github.com/repos/chef/mixlib-install/tags","blobs_url":"https://api.github.com/repos/chef/mixlib-install/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chef/mixlib-install/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chef/mixlib-install/git/refs{/sha}","trees_url":"https://api.github.com/repos/chef/mixlib-install/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chef/mixlib-install/statuses/{sha}","languages_url":"https://api.github.com/repos/chef/mixlib-install/languages","stargazers_url":"https://api.github.com/repos/chef/mixlib-install/stargazers","contributors_url":"https://api.github.com/repos/chef/mixlib-install/contributors","subscribers_url":"https://api.github.com/repos/chef/mixlib-install/subscribers","subscription_url":"https://api.github.com/repos/chef/mixlib-install/subscription","commits_url":"https://api.github.com/repos/chef/mixlib-install/commits{/sha}","git_commits_url":"https://api.github.com/repos/chef/mixlib-install/git/commits{/sha}","comments_url":"https://api.github.com/repos/chef/mixlib-install/comments{/number}","issue_comment_url":"https://api.github.com/repos/chef/mixlib-install/issues/comments{/number}","contents_url":"https://api.github.com/repos/chef/mixlib-install/contents/{+path}","compare_url":"https://api.github.com/repos/chef/mixlib-install/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chef/mixlib-install/merges","archive_url":"https://api.github.com/repos/chef/mixlib-install/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chef/mixlib-install/downloads","issues_url":"https://api.github.com/repos/chef/mixlib-install/issues{/number}","pulls_url":"https://api.github.com/repos/chef/mixlib-install/pulls{/number}","milestones_url":"https://api.github.com/repos/chef/mixlib-install/milestones{/number}","notifications_url":"https://api.github.com/repos/chef/mixlib-install/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chef/mixlib-install/labels{/name}","releases_url":"https://api.github.com/repos/chef/mixlib-install/releases{/id}","created_at":"2015-07-14T12:34:25Z","updated_at":"2015-09-15T01:32:52Z","pushed_at":"2015-12-02T21:43:37Z","git_url":"git://github.com/chef/mixlib-install.git","ssh_url":"git@github.com:chef/mixlib-install.git","clone_url":"https://github.com/chef/mixlib-install.git","svn_url":"https://github.com/chef/mixlib-install","homepage":"","size":104,"stargazers_count":3,"watchers_count":3,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":12,"forks":6,"open_issues":12,"watchers":3,"default_branch":"master"}},"base":{"label":"chef:master","ref":"master","sha":"8a617d3c4df80f9bfc813382562fa84b12d0e9db","user":{"login":"chef","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=3","gravatar_id":"","url":"https://api.github.com/users/chef","html_url":"https://github.com/chef","followers_url":"https://api.github.com/users/chef/followers","following_url":"https://api.github.com/users/chef/following{/other_user}","gists_url":"https://api.github.com/users/chef/gists{/gist_id}","starred_url":"https://api.github.com/users/chef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chef/subscriptions","organizations_url":"https://api.github.com/users/chef/orgs","repos_url":"https://api.github.com/users/chef/repos","events_url":"https://api.github.com/users/chef/events{/privacy}","received_events_url":"https://api.github.com/users/chef/received_events","type":"Organization","site_admin":false},"repo":{"id":39073784,"name":"mixlib-install","full_name":"chef/mixlib-install","owner":{"login":"chef","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=3","gravatar_id":"","url":"https://api.github.com/users/chef","html_url":"https://github.com/chef","followers_url":"https://api.github.com/users/chef/followers","following_url":"https://api.github.com/users/chef/following{/other_user}","gists_url":"https://api.github.com/users/chef/gists{/gist_id}","starred_url":"https://api.github.com/users/chef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chef/subscriptions","organizations_url":"https://api.github.com/users/chef/orgs","repos_url":"https://api.github.com/users/chef/repos","events_url":"https://api.github.com/users/chef/events{/privacy}","received_events_url":"https://api.github.com/users/chef/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chef/mixlib-install","description":"A mixin to help with omnitruck installs","fork":false,"url":"https://api.github.com/repos/chef/mixlib-install","forks_url":"https://api.github.com/repos/chef/mixlib-install/forks","keys_url":"https://api.github.com/repos/chef/mixlib-install/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chef/mixlib-install/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chef/mixlib-install/teams","hooks_url":"https://api.github.com/repos/chef/mixlib-install/hooks","issue_events_url":"https://api.github.com/repos/chef/mixlib-install/issues/events{/number}","events_url":"https://api.github.com/repos/chef/mixlib-install/events","assignees_url":"https://api.github.com/repos/chef/mixlib-install/assignees{/user}","branches_url":"https://api.github.com/repos/chef/mixlib-install/branches{/branch}","tags_url":"https://api.github.com/repos/chef/mixlib-install/tags","blobs_url":"https://api.github.com/repos/chef/mixlib-install/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chef/mixlib-install/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chef/mixlib-install/git/refs{/sha}","trees_url":"https://api.github.com/repos/chef/mixlib-install/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chef/mixlib-install/statuses/{sha}","languages_url":"https://api.github.com/repos/chef/mixlib-install/languages","stargazers_url":"https://api.github.com/repos/chef/mixlib-install/stargazers","contributors_url":"https://api.github.com/repos/chef/mixlib-install/contributors","subscribers_url":"https://api.github.com/repos/chef/mixlib-install/subscribers","subscription_url":"https://api.github.com/repos/chef/mixlib-install/subscription","commits_url":"https://api.github.com/repos/chef/mixlib-install/commits{/sha}","git_commits_url":"https://api.github.com/repos/chef/mixlib-install/git/commits{/sha}","comments_url":"https://api.github.com/repos/chef/mixlib-install/comments{/number}","issue_comment_url":"https://api.github.com/repos/chef/mixlib-install/issues/comments{/number}","contents_url":"https://api.github.com/repos/chef/mixlib-install/contents/{+path}","compare_url":"https://api.github.com/repos/chef/mixlib-install/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chef/mixlib-install/merges","archive_url":"https://api.github.com/repos/chef/mixlib-install/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chef/mixlib-install/downloads","issues_url":"https://api.github.com/repos/chef/mixlib-install/issues{/number}","pulls_url":"https://api.github.com/repos/chef/mixlib-install/pulls{/number}","milestones_url":"https://api.github.com/repos/chef/mixlib-install/milestones{/number}","notifications_url":"https://api.github.com/repos/chef/mixlib-install/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chef/mixlib-install/labels{/name}","releases_url":"https://api.github.com/repos/chef/mixlib-install/releases{/id}","created_at":"2015-07-14T12:34:25Z","updated_at":"2015-09-15T01:32:52Z","pushed_at":"2015-12-02T21:43:37Z","git_url":"git://github.com/chef/mixlib-install.git","ssh_url":"git@github.com:chef/mixlib-install.git","clone_url":"https://github.com/chef/mixlib-install.git","svn_url":"https://github.com/chef/mixlib-install","homepage":"","size":104,"stargazers_count":3,"watchers_count":3,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":12,"forks":6,"open_issues":12,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chef/mixlib-install/pulls/25"},"html":{"href":"https://github.com/chef/mixlib-install/pull/25"},"issue":{"href":"https://api.github.com/repos/chef/mixlib-install/issues/25"},"comments":{"href":"https://api.github.com/repos/chef/mixlib-install/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/chef/mixlib-install/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/chef/mixlib-install/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/chef/mixlib-install/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/chef/mixlib-install/statuses/45cafb6df54dc2c592498555067746731abd9324"}}}}