This repository has been archived by the owner on Sep 5, 2020. It is now read-only.
/
VcsDefinition.php
93 lines (84 loc) · 2.51 KB
/
VcsDefinition.php
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
<?php
/*
* This file is part of Rocketeer
*
* (c) Maxime Fabre <ehtnam6@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace Rocketeer\Services\Config\Definition;
use Symfony\Component\Config\Definition\TreeBuilder\NodeBuilder;
/**
* Configuration schema for the VCS node.
*/
class VcsDefinition extends AbstractDefinition
{
/**
* @var string
*/
protected $name = 'vcs';
/**
* @var string
*/
protected $description = 'The configuration of your repository';
/**
* @param NodeBuilder $node
*
* @return NodeBuilder
*/
protected function getChildren(NodeBuilder $node)
{
$node = $this->getCredentialsNodes($node);
$node = $this->getOptionsNodes($node);
return $node;
}
/**
* @param NodeBuilder $node
*
* @return NodeBuilder
*/
protected function getCredentialsNodes(NodeBuilder $node)
{
return $node
->enumNode('vcs')
->info('The VCS used')
->values(['git', 'svn', 'hg'])
->isRequired()
->defaultValue('git')
->end()
->scalarNode('repository')
->info('The SSH/HTTPS address to your repository')
->example('https://github.com/vendor/website.git')
->defaultValue($this->value('vcs.repository'))
->end()
->scalarNode('username')
->defaultValue($this->value('vcs.username'))
->end()
->scalarNode('password')
->defaultValue($this->value('vcs.password'))
->end();
}
/**
* @param NodeBuilder $node
*
* @return NodeBuilder
*/
protected function getOptionsNodes(NodeBuilder $node)
{
return $node
->scalarNode('branch')
->info('The branch to deploy')
->defaultValue('master')
->end()
->scalarNode('shallow')
->info("Whether your VCS should do a \"shallow\" clone of the repository or not - this means a clone with just the latest state of your application (no history).\nIf you're having problems cloning, try setting this to false")
->defaultTrue()
->end()
->scalarNode('submodules')
->info("Recursively pull in submodules.\nWorks only with Git")
->defaultTrue()
->end();
}
}