summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2019-02-11 15:18:29 +0000
committerMonty Taylor <mordred@inaugust.com>2019-02-11 15:18:29 +0000
commitf463a6c794b73a6f5958780e47de6e461ae1b4c5 (patch)
tree64f7504ee74d27204d5850a0e72481cf5270fd08
parent49b41704e01e2fa62d38541f7de2eba1f12e9ab9 (diff)
Revert "Use uniform initializer syntax everywhere"
-rw-r--r--zuul-preview/main.cc34
1 files changed, 17 insertions, 17 deletions
diff --git a/zuul-preview/main.cc b/zuul-preview/main.cc
index 9159802..79e655d 100644
--- a/zuul-preview/main.cc
+++ b/zuul-preview/main.cc
@@ -26,9 +26,9 @@ using namespace std;
26 26
27vector<string> split(const string &in) 27vector<string> split(const string &in)
28{ 28{
29 istringstream stream{in}; 29 istringstream stream(in);
30 vector<string> parts{}; 30 vector<string> parts;
31 string part{}; 31 string part;
32 while (getline(stream, part, '.')) { 32 while (getline(stream, part, '.')) {
33 parts.push_back(part); 33 parts.push_back(part);
34 } 34 }
@@ -56,11 +56,11 @@ public:
56 // If the entry is present, it is moved to the head of the queue. 56 // If the entry is present, it is moved to the head of the queue.
57 optional<const string> get(const string &key) 57 optional<const string> get(const string &key)
58 { 58 {
59 auto location{map.find(key)}; 59 auto location = map.find(key);
60 if (location == map.end()) 60 if (location == map.end())
61 return {}; 61 return {};
62 62
63 auto val{*(location->second)}; 63 auto val = *(location->second);
64 queue.erase(location->second); 64 queue.erase(location->second);
65 queue.push_front(val); 65 queue.push_front(val);
66 //cout << "get push " << val.second << endl; 66 //cout << "get push " << val.second << endl;
@@ -71,12 +71,12 @@ public:
71 // recently used entry. 71 // recently used entry.
72 void put(const string &key, const string &value) 72 void put(const string &key, const string &value)
73 { 73 {
74 auto location{map.find(key)}; 74 auto location = map.find(key);
75 if (location != map.end()) 75 if (location != map.end())
76 return; 76 return;
77 77
78 if (queue.size() == size) { 78 if (queue.size() == size) {
79 auto last{queue.back()}; 79 auto last = queue.back();
80 //cout << "put pop " << last.second << endl; 80 //cout << "put pop " << last.second << endl;
81 queue.pop_back(); 81 queue.pop_back();
82 map.erase(last.first); 82 map.erase(last.first);
@@ -91,7 +91,7 @@ public:
91 91
92int main(int, char**) 92int main(int, char**)
93{ 93{
94 web::http::client::http_client client{"https://zuul.opendev.org"}; 94 web::http::client::http_client client("https://zuul.opendev.org");
95 95
96 string hostname; 96 string hostname;
97 Cache cache{2}; 97 Cache cache{2};
@@ -104,20 +104,20 @@ int main(int, char**)
104 // site.688b70499b9a41a08f498ed6e932960c.openstack 104 // site.688b70499b9a41a08f498ed6e932960c.openstack
105 // site.dbefc23dcc594577a8bfa4db4f9b0a8f.openstack 105 // site.dbefc23dcc594577a8bfa4db4f9b0a8f.openstack
106 106
107 auto val{cache.get(hostname)}; 107 auto val = cache.get(hostname);
108 if (val.has_value()) { 108 if (val.has_value()) {
109 cout << val.value() << endl; 109 cout << val.value() << endl;
110 continue; 110 continue;
111 } 111 }
112 112
113 auto parts{split(hostname)}; 113 auto parts = split(hostname);
114 if (parts.size() < 3) { 114 if (parts.size() < 3) {
115 cout << "not enough args" << endl; 115 cout << "not enough args" << endl;
116 continue; 116 continue;
117 } 117 }
118 auto artifact{parts[0]}; 118 auto artifact = parts[0];
119 auto buildid{parts[1]}; 119 auto buildid = parts[1];
120 auto tenant{parts[2]}; 120 auto tenant = parts[2];
121 /* 121 /*
122 cout << artifact << endl 122 cout << artifact << endl
123 << buildid << endl 123 << buildid << endl
@@ -126,13 +126,13 @@ int main(int, char**)
126 126
127 // 75031cad206c4014ad7a3387091d15ab 127 // 75031cad206c4014ad7a3387091d15ab
128 try { 128 try {
129 web::uri_builder uri{"/api/tenant/" + tenant + "/build"}; 129 auto uri = web::uri_builder("/api/tenant/" + tenant + "/build");
130 uri.append_path(buildid); 130 uri.append_path(buildid);
131 auto response{client.request( 131 auto response = client.request(
132 web::http::methods::GET, uri.to_string()).get()}; 132 web::http::methods::GET, uri.to_string()).get();
133 // body is a web::json::value 133 // body is a web::json::value
134 // cout << response.status_code() << endl; 134 // cout << response.status_code() << endl;
135 auto body{response.extract_json().get()}; 135 auto body = response.extract_json().get();
136 //cout << body.serialize() << endl; 136 //cout << body.serialize() << endl;
137 137
138 // TODO: use artifact 138 // TODO: use artifact