Skip to content

Commit

Permalink
Update composer.json & added exception to AnsiblePlaybook.php (#64)
Browse files Browse the repository at this point in the history
* Bump php versions & migrated phpunit xml

* Throw exception if passed $extraArgs is an object
  • Loading branch information
alxhlz authored Mar 2, 2021
1 parent 9bfea27 commit 4f2145c
Show file tree
Hide file tree
Showing 4 changed files with 2,380 additions and 33 deletions.
15 changes: 10 additions & 5 deletions Asm/Ansible/Command/AnsiblePlaybook.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,15 @@ public function extraVars($extraVars = ''): AnsiblePlaybookInterface
if (empty($extraVars))
return $this;

// Throw exception when $extraVars is an object
if (gettype($extraVars) === 'object') {
throw new InvalidArgumentException(sprintf('Expected string|array, got "%s"', gettype($extraVars)));
}

// Building the key=>value parameter
if (is_array($extraVars)){
if (is_array($extraVars)) {
$vars = [];
foreach ($extraVars as $key => $value){
foreach ($extraVars as $key => $value) {
$vars[] = sprintf('%s=%s', $key, $value);
}
$this->addOption('--extra-vars', implode(' ', $vars));
Expand Down Expand Up @@ -392,7 +397,7 @@ public function colors(bool $colors = true): AnsiblePlaybookInterface
*/
public function json(): AnsiblePlaybookInterface
{
$this->processBuilder->setEnv('ANSIBLE_STDOUT_CALLBACK','json');
$this->processBuilder->setEnv('ANSIBLE_STDOUT_CALLBACK', 'json');

return $this;
}
Expand Down Expand Up @@ -571,9 +576,9 @@ public function version(): AnsiblePlaybookInterface
*/
public function flushCache(): AnsiblePlaybookInterface
{
$this->addParameter('--flush-cache');
$this->addParameter('--flush-cache');

return $this;
return $this;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": "^7.1.0",
"php": "^7.1.0|>8.0.0",
"psr/log": "^1.1",
"symfony/process": "^4.0|^5.0"
},
Expand Down
Loading

0 comments on commit 4f2145c

Please sign in to comment.