1
0
Fork 0

Configuration of GitLab driver

pull/4670/head
Michal Gebauer 2015-12-03 14:30:07 +01:00
parent 611f9dcfe2
commit ce74477899
3 changed files with 29 additions and 4 deletions

View File

@ -136,6 +136,11 @@
"description": "A hash of domain name => github API oauth tokens, typically {\"github.com\":\"<token>\"}.", "description": "A hash of domain name => github API oauth tokens, typically {\"github.com\":\"<token>\"}.",
"additionalProperties": true "additionalProperties": true
}, },
"gitlab-oauth": {
"type": "object",
"description": "A hash of domain name => gitlab API oauth tokens, typically {\"gitlab.com\":\"<token>\"}.",
"additionalProperties": true
},
"http-basic": { "http-basic": {
"type": "object", "type": "object",
"description": "A hash of domain name => {\"username\": \"...\", \"password\": \"...\"}.", "description": "A hash of domain name => {\"username\": \"...\", \"password\": \"...\"}.",
@ -221,6 +226,13 @@
"type": "boolean", "type": "boolean",
"description": "Defaults to true. If set to false, the OAuth tokens created to access the github API will have a date instead of the machine hostname." "description": "Defaults to true. If set to false, the OAuth tokens created to access the github API will have a date instead of the machine hostname."
}, },
"gitlab-domains": {
"type": "array",
"description": "A list of domains to use in gitlab mode. This is used for custom GitLab setups, defaults to [\"gitlab.com\"].",
"items": {
"type": "string"
}
},
"archive-format": { "archive-format": {
"type": "string", "type": "string",
"description": "The default archiving format when not provided on cli, defaults to \"tar\"." "description": "The default archiving format when not provided on cli, defaults to \"tar\"."

View File

@ -164,7 +164,7 @@ EOT
} }
if ($input->getOption('global') && !$this->authConfigFile->exists()) { if ($input->getOption('global') && !$this->authConfigFile->exists()) {
touch($this->authConfigFile->getPath()); touch($this->authConfigFile->getPath());
$this->authConfigFile->write(array('http-basic' => new \ArrayObject, 'github-oauth' => new \ArrayObject)); $this->authConfigFile->write(array('http-basic' => new \ArrayObject, 'github-oauth' => new \ArrayObject, 'gitlab-oauth' => new \ArrayObject));
@chmod($this->authConfigFile->getPath(), 0600); @chmod($this->authConfigFile->getPath(), 0600);
} }
@ -358,6 +358,18 @@ EOT
return $vals; return $vals;
}, },
), ),
'gitlab-domains' => array(
function ($vals) {
if (!is_array($vals)) {
return 'array expected';
}
return true;
},
function ($vals) {
return $vals;
},
),
); );
foreach ($uniqueConfigValues as $name => $callbacks) { foreach ($uniqueConfigValues as $name => $callbacks) {
@ -433,7 +445,7 @@ EOT
} }
// handle github-oauth // handle github-oauth
if (preg_match('/^(github-oauth|http-basic)\.(.+)/', $settingKey, $matches)) { if (preg_match('/^(github-oauth|gitlab-oauth|http-basic)\.(.+)/', $settingKey, $matches)) {
if ($input->getOption('unset')) { if ($input->getOption('unset')) {
$this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]); $this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]);
$this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]); $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
@ -441,7 +453,7 @@ EOT
return; return;
} }
if ($matches[1] === 'github-oauth') { if ($matches[1] === 'github-oauth' || $matches[1] === 'gitlab-oauth') {
if (1 !== count($values)) { if (1 !== count($values)) {
throw new \RuntimeException('Too many arguments, expected only one token'); throw new \RuntimeException('Too many arguments, expected only one token');
} }

View File

@ -51,6 +51,7 @@ class Config
'archive-dir' => '.', 'archive-dir' => '.',
// valid keys without defaults (auth config stuff): // valid keys without defaults (auth config stuff):
// github-oauth // github-oauth
// gitlab-oauth
// http-basic // http-basic
); );
@ -111,7 +112,7 @@ class Config
// override defaults with given config // override defaults with given config
if (!empty($config['config']) && is_array($config['config'])) { if (!empty($config['config']) && is_array($config['config'])) {
foreach ($config['config'] as $key => $val) { foreach ($config['config'] as $key => $val) {
if (in_array($key, array('github-oauth', 'http-basic')) && isset($this->config[$key])) { if (in_array($key, array('github-oauth', 'gitlab-oauth', 'http-basic')) && isset($this->config[$key])) {
$this->config[$key] = array_merge($this->config[$key], $val); $this->config[$key] = array_merge($this->config[$key], $val);
} else { } else {
$this->config[$key] = $val; $this->config[$key] = $val;