summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames E. Blair <jeblair@redhat.com>2019-03-01 12:34:42 -0800
committerJames E. Blair <jeblair@redhat.com>2019-03-01 12:43:13 -0800
commitf5121119c861901da32b19da868bd0eb5dde16e1 (patch)
tree35504f77754e431dbdbde5054ad897b3c81c432e
parentf6c78a3605c040bbbdddb0b463d7ce3f17c3aca4 (diff)
Use artifact name rather than log_url
So that we can return the preview URL as the success url, use the artifact name to look up the forward URL. Change-Id: I8d67e1527d8f911579779a9a036a3c7f5c79a27f
Notes
Notes (review): Code-Review+2: Clark Boylan <cboylan@sapwetik.org> Code-Review+2: James E. Blair <corvus@inaugust.com> Workflow+1: James E. Blair <corvus@inaugust.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Sat, 02 Mar 2019 03:43:49 +0000 Reviewed-on: https://review.openstack.org/640509 Project: openstack-infra/zuul-preview Branch: refs/heads/master
-rw-r--r--zuul-preview/main.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/zuul-preview/main.cc b/zuul-preview/main.cc
index 8493be1..f15df88 100644
--- a/zuul-preview/main.cc
+++ b/zuul-preview/main.cc
@@ -122,7 +122,7 @@ int main(int, char**)
122 // (protected by an internal mutex) and expect exactly one line of 122 // (protected by an internal mutex) and expect exactly one line of
123 // output for each. 123 // output for each.
124 // Expected input: 124 // Expected input:
125 // https://zuul.opendev.org site.926bb0aaddad4bc3853269451e115dcb.openstack.preview.opendev.org 125 // https://zuul.opendev.org site.167715b656ee4504baa940c5bd9f3821.openstack.preview.opendev.org
126 while (getline(cin, input)) { 126 while (getline(cin, input)) {
127 127
128 // Split the input into api_url, hostname 128 // Split the input into api_url, hostname
@@ -163,12 +163,18 @@ int main(int, char**)
163 web::http::methods::GET, uri.to_string()).get(); 163 web::http::methods::GET, uri.to_string()).get();
164 // body is a web::json::value 164 // body is a web::json::value
165 auto body = response.extract_json().get(); 165 auto body = response.extract_json().get();
166 auto artifacts = body["artifacts"].as_array();
166 167
167 // TODO: use artifact instead of log_url 168 string artifact_url = "Artifact_not_found";
168 // body["log_url"].as_string() returns a const std::string& 169 for (uint i = 0; i < artifacts.size(); i++) {
169 cout << body["log_url"].as_string() << endl; 170 if (artifacts[i]["name"].as_string() == artifact) {
171 artifact_url = artifacts[i]["url"].as_string();
172 }
173 }
170 174
171 cache.put(hostname, body["log_url"].as_string()); 175 cout << artifact_url << endl;
176
177 cache.put(hostname, artifact_url);
172 } catch (...) { 178 } catch (...) {
173 // If anything goes wrong, we still need to return only a single 179 // If anything goes wrong, we still need to return only a single
174 // string to apache, and recover for the next request, so we 180 // string to apache, and recover for the next request, so we