1 | <?php |
||
19 | class LeankoalaReporter implements Reporter |
||
20 | { |
||
21 | /** |
||
22 | * @var Result[] |
||
23 | */ |
||
24 | private $results = []; |
||
25 | |||
26 | /** |
||
27 | * @var Configuration |
||
28 | */ |
||
29 | private $config; |
||
30 | private $system; |
||
31 | private $collect; |
||
32 | private $identifier; |
||
33 | private $systemUseRetriever; |
||
34 | private $tool = 'smoke'; |
||
35 | private $groupBy; |
||
36 | private $server; |
||
37 | private $addComingFrom; |
||
38 | |||
39 | /** |
||
40 | * @var KoalaReporter |
||
41 | */ |
||
42 | private $reporter; |
||
43 | |||
44 | /** |
||
45 | * @var Retriever |
||
46 | */ |
||
47 | private $retriever; |
||
48 | |||
49 | private $output; |
||
50 | |||
51 | /** |
||
52 | * @var LeankoalaExtension |
||
53 | */ |
||
54 | private $leankoalaExtension; |
||
55 | |||
56 | const STATUS_SUCCESS = 'success'; |
||
57 | const STATUS_FAILURE = 'failure'; |
||
58 | |||
59 | public function init($apiKey, Configuration $_configuration, OutputInterface $_output, $server = 'https://webhook.koalamon.com', $system = '', $identifier = '', $tool = '', $collect = true, $systemUseRetriever = false, $groupBy = false, $addComingFrom = true) |
||
60 | { |
||
61 | $httpClient = new \GuzzleHttp\Client(); |
||
62 | |||
63 | $this->reporter = new KoalaReporter('', $apiKey, $httpClient, $server); |
||
64 | |||
65 | $this->reporter->setEventProcessor(MongoDBProcessor::createByEnvironmentVars('leankoala')); |
||
66 | |||
67 | $this->config = $_configuration; |
||
68 | $this->systemUseRetriever = $systemUseRetriever; |
||
69 | |||
70 | $this->system = $system; |
||
71 | $this->collect = $collect; |
||
72 | $this->identifier = $identifier; |
||
73 | $this->groupBy = $groupBy; |
||
74 | |||
75 | $this->addComingFrom = $addComingFrom; |
||
76 | |||
77 | if ($tool) { |
||
78 | $this->tool = $tool; |
||
79 | } |
||
80 | |||
81 | $this->leankoalaExtension = $_configuration->getExtension('Leankoala'); |
||
82 | |||
83 | $this->server = $server; |
||
84 | $this->output = $_output; |
||
85 | } |
||
86 | |||
87 | public function setResponseRetriever(Retriever $retriever) |
||
91 | |||
92 | public function processResults($results) |
||
96 | |||
97 | public function finish() |
||
105 | |||
106 | private function getComponent($ruleName) |
||
113 | |||
114 | private function sendCollectedResults() |
||
164 | |||
165 | private function sendSingleResults() |
||
189 | |||
190 | private function getIdentifier(CheckResult $result) |
||
194 | |||
195 | private function getPrefix($string) |
||
199 | |||
200 | /** |
||
201 | * @param $identifier |
||
202 | * @param $system |
||
203 | * @param $message |
||
204 | * @param $status |
||
205 | * @param $value |
||
206 | * @param $tool |
||
207 | * @param $component |
||
208 | * @param Attribute[] $attributes |
||
209 | */ |
||
210 | private function send($identifier, $system, $message, $status, $value, $tool, $component, $attributes = []) |
||
221 | } |
||
222 |