{"action":"created","comment":{"url":"https://api.github.com/repos/chef/mixlib-install/pulls/comments/47812527","id":47812527,"diff_hunk":"@@ -19,72 +19,114 @@\n require \"net/http\"\n require \"json\"\n require \"mixlib/install/artifact_info\"\n+require \"mixlib/versioning\"\n require \"artifactory\"\n \n module Mixlib\n   class Install\n     class Backend\n       class Artifactory\n-        ARTIFACTORY_ENDPOINT = \"http://artifactory.chef.co\".freeze\n-\n-        ARTIFACTORY_REPOSITORY = \"omnibus-unstable-local\".freeze\n-\n-        attr_reader :options\n-        attr_reader :client\n+        attr_accessor :options\n \n         def initialize(options)\n           @options = options\n-          @client = ::Artifactory::Client.new(endpoint: ARTIFACTORY_ENDPOINT)\n         end\n \n+        # Create filtered list of artifacts\n+        #\n+        # @return [Array<ArtifactInfo>] list of artifacts for the configured\n+        # channel, product name, and product version.\n+        # @return [ArtifactInfo] arifact info for the configured\n+        # channel, product name, product version and platform info\n+        #\n         def info\n-          begin\n-            results = client.get(\"/api/search/prop\", params, headers)[\"results\"]\n-          rescue Errno::ETIMEDOUT => e\n-            raise e, \"unstable channel uses endpoint #{ARTIFACTORY_ENDPOINT} \\\n-which is currently only accessible through Chef's internal network.\"\n-          end\n+          artifacts = artifactory_info.collect { |a| create_artifact(a) }\n+          artifacts_for_version = artifacts.find_all { |a| a.version == resolve_version(artifacts) }\n \n           if options.platform\n-            artifact(results.first)\n-          else\n-            results.collect do |result|\n-              artifact(result)\n+            artifacts_for_version.find do |a|\n+              a.platform == options.platform &&\n+                a.platform_version == options.platform_version &&\n+                a.architecture == options.architecture\n             end\n+          else\n+            artifacts_for_version\n           end\n         end\n \n-        private\n+        # Fetches all artifacts from the configured Artifactory repository using\n+        # channel and product name as search criteria\n+        #\n+        # @return [Array<Hash>] list of artifactory hash data\n+        #\n+        # Hash data:\n+        #   download_uri: The full url download path\n+        #   <property_name>: The names of the properties associcated to the artifact\n+        #\n+        def artifactory_info\n+          query = <<-QUERY\n+items.find(\n+  {\"repo\": \"omnibus-#{options.channel}-local\"},\n+  {\"@omnibus.project\": \"#{options.product_name}\"}\n+).include(\"name\", \"path\", \"repo\", \"property\")\n+          QUERY\n \n-        def artifact(result)\n-          ArtifactInfo.new(\n-            md5:              result[\"properties\"][\"omnibus.md5\"].first,\n-            sha256:           result[\"properties\"][\"omnibus.sha256\"].first,\n-            version:          result[\"properties\"][\"omnibus.version\"].first,\n-            platform:         result[\"properties\"][\"omnibus.platform\"].first,\n-            platform_version: result[\"properties\"][\"omnibus.platform_version\"].first,\n-            architecture:     result[\"properties\"][\"omnibus.architecture\"].first,\n-            url:              result[\"downloadUri\"]\n+          # Creates a client based on ENVs:\n+          #   ARTIFACTORY_ENDPOINT\n+          #   ARTIFACTORY_USERNAME\n+          #   ARTIFACTORY_PASSWORD\n+          client = ::Artifactory::Client.new(\n+            endpoint: ENV[\"ARTIFACTORY_ENDPOINT\"] || \"http://artifactory.chef.co\"\n           )\n-        end\n \n-        def params\n-          params = {\n-            \"repos\" => ARTIFACTORY_REPOSITORY,\n-            \"omnibus.version\" => options.product_version\n-          }\n+          results = client.post(\"#{::Artifactory.endpoint}/api/search/aql\",\n+                                query, \"Content-Type\" => \"text/plain\")\n \n-          if options.platform\n-            params[\"omnibus.platform\"] = options.platform\n-            params[\"omnibus.platform_version\"] = options.platform_version\n-            params[\"omnibus.architecture\"] = options.architecture\n+          results[\"results\"].collect do |result|","path":"lib/mixlib/install/backend/artifactory.rb","position":104,"original_position":104,"commit_id":"1c49233df2768102d683f4aef0e1a738a5151893","original_commit_id":"d234afe65ef421702b932b618b182714bce3c165","user":{"login":"patrick-wright","id":6841563,"avatar_url":"https://avatars.githubusercontent.com/u/6841563?v=3","gravatar_id":"","url":"https://api.github.com/users/patrick-wright","html_url":"https://github.com/patrick-wright","followers_url":"https://api.github.com/users/patrick-wright/followers","following_url":"https://api.github.com/users/patrick-wright/following{/other_user}","gists_url":"https://api.github.com/users/patrick-wright/gists{/gist_id}","starred_url":"https://api.github.com/users/patrick-wright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patrick-wright/subscriptions","organizations_url":"https://api.github.com/users/patrick-wright/orgs","repos_url":"https://api.github.com/users/patrick-wright/repos","events_url":"https://api.github.com/users/patrick-wright/events{/privacy}","received_events_url":"https://api.github.com/users/patrick-wright/received_events","type":"User","site_admin":false},"body":"Will do.  I'l going to spend a little time today to see if I can have AQL return the full downloadUri in the results.","created_at":"2015-12-16T18:18:16Z","updated_at":"2015-12-16T18:18:16Z","html_url":"https://github.com/chef/mixlib-install/pull/35#discussion_r47812527","pull_request_url":"https://api.github.com/repos/chef/mixlib-install/pulls/35","_links":{"self":{"href":"https://api.github.com/repos/chef/mixlib-install/pulls/comments/47812527"},"html":{"href":"https://github.com/chef/mixlib-install/pull/35#discussion_r47812527"},"pull_request":{"href":"https://api.github.com/repos/chef/mixlib-install/pulls/35"}}},"pull_request":{"url":"https://api.github.com/repos/chef/mixlib-install/pulls/35","id":53626353,"html_url":"https://github.com/chef/mixlib-install/pull/35","diff_url":"https://github.com/chef/mixlib-install/pull/35.diff","patch_url":"https://github.com/chef/mixlib-install/pull/35.patch","issue_url":"https://api.github.com/repos/chef/mixlib-install/issues/35","number":35,"state":"open","locked":false,"title":"support latest version keyword for unstable channel","user":{"login":"patrick-wright","id":6841563,"avatar_url":"https://avatars.githubusercontent.com/u/6841563?v=3","gravatar_id":"","url":"https://api.github.com/users/patrick-wright","html_url":"https://github.com/patrick-wright","followers_url":"https://api.github.com/users/patrick-wright/followers","following_url":"https://api.github.com/users/patrick-wright/following{/other_user}","gists_url":"https://api.github.com/users/patrick-wright/gists{/gist_id}","starred_url":"https://api.github.com/users/patrick-wright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patrick-wright/subscriptions","organizations_url":"https://api.github.com/users/patrick-wright/orgs","repos_url":"https://api.github.com/users/patrick-wright/repos","events_url":"https://api.github.com/users/patrick-wright/events{/privacy}","received_events_url":"https://api.github.com/users/patrick-wright/received_events","type":"User","site_admin":false},"body":"Adds support for using `:latest` (code), or `'latest'` (kitchen.yml) when using the unstable channel against artifactory.\r\n\r\n@jtimberman @sersut @schisamo ","created_at":"2015-12-14T21:43:57Z","updated_at":"2015-12-16T18:18:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"57f597c838fae108567caba119abdf74d27a3540","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/chef/mixlib-install/pulls/35/commits","review_comments_url":"https://api.github.com/repos/chef/mixlib-install/pulls/35/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/35/comments","statuses_url":"https://api.github.com/repos/chef/mixlib-install/statuses/1c49233df2768102d683f4aef0e1a738a5151893","head":{"label":"chef:pw/unstable_latest","ref":"pw/unstable_latest","sha":"1c49233df2768102d683f4aef0e1a738a5151893","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-16T18:14:31Z","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":146,"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":"bfc3fbbcb29ee64cbf83f1e961479b597a265acf","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-16T18:14:31Z","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":146,"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/35"},"html":{"href":"https://github.com/chef/mixlib-install/pull/35"},"issue":{"href":"https://api.github.com/repos/chef/mixlib-install/issues/35"},"comments":{"href":"https://api.github.com/repos/chef/mixlib-install/issues/35/comments"},"review_comments":{"href":"https://api.github.com/repos/chef/mixlib-install/pulls/35/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/35/commits"},"statuses":{"href":"https://api.github.com/repos/chef/mixlib-install/statuses/1c49233df2768102d683f4aef0e1a738a5151893"}}}}