Skip to content
This repository has been archived by the owner on Aug 1, 2020. It is now read-only.

Commit

Permalink
key to upper
Browse files Browse the repository at this point in the history
  • Loading branch information
SmetDenis committed Jul 9, 2018
1 parent 7316c7a commit db4e661
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@


```sh
teamcity-keykeeper key:save --name="some_key_name" --value="some_value";
teamcity-keykeeper key:restore --name="some_key_name";
teamcity-keykeeper key:save --name="some_env_var_name" --value="some_value";
teamcity-keykeeper key:restore --all;
```

Output
```sh
##teamcity[setParameter name='env.some_key_name' value='some_value']
##teamcity[setParameter name='env.SOME_ENV_VAR_NAME' value='some_value']
```


Expand Down
2 changes: 2 additions & 0 deletions src/KeyRestoreCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (!$input->getOption('all')) {
$name = trim($input->getOption('name'));
$value = $storage->get($name);
$name = strtoupper($name);
$output->writeln("##teamcity[setParameter name='env.{$name}' value='{$value}']");
} else {
foreach ($storage->getArrayCopy() as $name => $value) {
$name = strtoupper($name);
$output->writeln("##teamcity[setParameter name='env.{$name}' value='{$value}']");
}
}
Expand Down
10 changes: 6 additions & 4 deletions tests/KeyKeeperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function testSaveAndRestoreKey()
isContain("Key '{$name}' saved", $saveResult);

$restoreResult = trim(Cli::exec("php {$bin} key:restore --name='{$name}'"));
$name = strtoupper($name);
isSame("##teamcity[setParameter name='env.{$name}' value='{$value}']", $restoreResult);
}

Expand All @@ -54,6 +55,7 @@ public function testSpecialChars()
isContain("Key '{$name}' saved", $saveResult);

$restoreResult = trim(Cli::exec("php {$bin} key:restore --name='{$name}'"));
$name = strtoupper($name);
isSame("##teamcity[setParameter name='env.{$name}' value='{$value}']", $restoreResult);
}

Expand All @@ -65,8 +67,8 @@ public function testGetAllKeys()
Cli::exec("php {$bin} key:save --name='key2' --value='value2'");

$restoreResult = trim(Cli::exec("php {$bin} key:restore --all"));
isContain("##teamcity[setParameter name='env.key1' value='value1']", $restoreResult);
isContain("##teamcity[setParameter name='env.key2' value='value2']", $restoreResult);
isContain("##teamcity[setParameter name='env.KEY1' value='value1']", $restoreResult);
isContain("##teamcity[setParameter name='env.KEY2' value='value2']", $restoreResult);
}

public function testRemoveKeysWithOption()
Expand All @@ -77,7 +79,7 @@ public function testRemoveKeysWithOption()
Cli::exec("php {$bin} key:save --name='key' --value=''");

$restoreResult = trim(Cli::exec("php {$bin} key:restore --all"));
isContain("##teamcity[setParameter name='env.key' value='']", $restoreResult);
isContain("##teamcity[setParameter name='env.KEY' value='']", $restoreResult);
}

public function testRemoveKeysWithoutOption()
Expand All @@ -88,6 +90,6 @@ public function testRemoveKeysWithoutOption()
Cli::exec("php {$bin} key:save --name='key'");

$restoreResult = trim(Cli::exec("php {$bin} key:restore --all"));
isContain("##teamcity[setParameter name='env.key' value='']", $restoreResult);
isContain("##teamcity[setParameter name='env.KEY' value='']", $restoreResult);
}
}

0 comments on commit db4e661

Please sign in to comment.