-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShouldConfigure.php
More file actions
50 lines (39 loc) · 1.48 KB
/
ShouldConfigure.php
File metadata and controls
50 lines (39 loc) · 1.48 KB
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
<?php
namespace Webteractive\Devstack;
trait ShouldConfigure
{
use WithStorage;
protected $repository;
protected $branch;
protected $token;
protected $config;
protected $runtimes = [];
public function ensureConfigurationIsSet($runtime = null)
{
if ($this->devstackStorage()->doesntExists('config.json')) {
if ($runtime) {
$this->info("\nBefore we can start installing the <comment>{$runtime}</comment> runtime, we have
to configure the credentials needed to download
it. Please follow the next screens.
");
}
$this->storeConfiguration();
}
$this->config = json_decode($this->devstackStorage()->get('config.json'), true);
return $this;
}
public function storeConfiguration()
{
$this->repository = $this->ask('Please supply the devstack runtimes repository:', null);
$this->branch = $this->ask('Please supply the devstack runtimes repository branch:', 'main');
$this->token = $this->ask('Please supply the personal access token of the devstack runtime repository:', null);
$this->devstackStorage()->put('config.json', json_encode([
'repository' => $this->repository,
'branch' => $this->branch,
'token' => $this->token,
], JSON_PRETTY_PRINT));
$this->line()
->info("Configuration are set!")
->line($this->devstackStorage()->get('config.json'));
}
}