From e0d10c611eac160d3e74b87b6dbb25d1106303b2 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Tue, 7 Apr 2020 08:33:34 -0700 Subject: [PATCH] Look up artifacts by metadata.type rather than name So that we can have nice looking names like "Preview Site", find the artifact by looking up the 'type' field in metadata. Change-Id: Ia01e95c77f068bd8ab3a515aa023c1f79332fc67 --- zuul-preview/main.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zuul-preview/main.cc b/zuul-preview/main.cc index 186b268..848fb55 100644 --- a/zuul-preview/main.cc +++ b/zuul-preview/main.cc @@ -122,6 +122,7 @@ int main(int, char**) // output for each. // Expected input: // https://zuul.opendev.org site.167715b656ee4504baa940c5bd9f3821.openstack.preview.opendev.org + // https://zuul.opendev.org javascript_content.7cf36db4b8574ef6a5ba1a64cb827741.zuul.preview.opendev.org while (getline(cin, input)) { // Split the input into api_url, hostname @@ -166,7 +167,9 @@ int main(int, char**) string artifact_url = "Artifact_not_found"; for (uint i = 0; i < artifacts.size(); i++) { - if (artifacts[i]["name"].as_string() == artifact) { + if (artifacts[i].has_field("metadata") && + artifacts[i]["metadata"].has_field("type") && + artifacts[i]["metadata"]["type"].as_string() == artifact) { artifact_url = artifacts[i]["url"].as_string(); } }