Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Config.php « Aws « TestRunner « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: aec6aa621a3665f10240fdae63c21c79bb8caeb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/**
 * Piwik - free/libre analytics platform
 *
 * @link https://matomo.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 */

namespace Piwik\Plugins\TestRunner\Aws;

use \Piwik\Config as PiwikConfig;

class Config
{
    public function getRegion()
    {
        return trim($this->getConfigValue('aws_region'));
    }

    public function getAmi()
    {
        return trim($this->getConfigValue('aws_ami'));
    }

    public function getInstanceType()
    {
        return trim($this->getConfigValue('aws_instance_type'));
    }

    public function getKeyName()
    {
        return $this->getConfigValue('aws_keyname');
    }

    public function getPemFile()
    {
        return trim($this->getConfigValue('aws_pem_file'));
    }

    public function getAccessKey()
    {
        return trim($this->getConfigValue('aws_accesskey'));
    }

    public function getSecretKey()
    {
        return trim($this->getConfigValue('aws_secret'));
    }

    public function getSecurityGroups()
    {
        $groups = $this->getConfigValue('aws_securitygroups');

        if (empty($groups)) {
            $groups = array();
        }

        return (array) $groups;
    }

    public function validate()
    {
        $configKeysToValidate = array(
            'aws_accesskey',
            'aws_secret',
            'aws_region',
            'aws_ami',
            'aws_instance_type',
            'aws_pem_file',
            'aws_keyname',
            'aws_securitygroups',
        );

        foreach ($configKeysToValidate as $key) {
            if (!$this->getConfigValue($key)) {
                throw new \RuntimeException("[tests]$key is not configured in config/config.ini.php");
            }
        }

        $pemFile = $this->getPemFile();

        if (!file_exists($pemFile)) {
            throw new \RuntimeException('[tests]aws_pem_file the file does not exist or is not readable');
        }
    }

    private function getConfig()
    {
        return PiwikConfig::getInstance()->tests;
    }

    private function getConfigValue($key)
    {
        $config = $this->getConfig();

        return $config[$key];
    }
}