Skip to content

Commit

Permalink
Update bosh to work with BOSH cli v6.4.4
Browse files Browse the repository at this point in the history
As of BOSH cli 6.4.4, BOSH_* variables set to "" cause errors, so now
they are simply unset.
  • Loading branch information
dennisjbell committed Aug 3, 2021
1 parent 5932464 commit 22da67c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
7 changes: 3 additions & 4 deletions lib/Genesis/BOSH.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ sub _bosh {
$opts->{env}{HTTPS_PROXY} = ''; # bosh dislikes this env var
$opts->{env}{https_proxy} = ''; # bosh dislikes this env var

$opts->{env}{BOSH_ENVIRONMENT} ||= ''; # ensure using ~/.bosh/config via alias
$opts->{env}{BOSH_CA_CERT} ||= '';
$opts->{env}{BOSH_CLIENT} ||= '';
$opts->{env}{BOSH_CLIENT_SECRET} ||= '';
for (qw/BOSH_ENVIRONMENT BOSH_CA_CERT BOSH_CLIENT BOSH_CLIENT_SECRET/) {
$opts->{env}{$_} = undef unless defined($opts->{env}{$_}); # ensure using ~/.bosh/config via alias
}
}

if ($args[0] =~ m/^bosh(\s|$)/) {
Expand Down
40 changes: 29 additions & 11 deletions t/05-bosh.t
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ subtest 'environment variable management' => sub {
local %ENV;

fake_bosh(<<'EOF');
echo HTTPS_PROXY=$HTTPS_PROXY...
echo https_proxy=$https_proxy...
echo BOSH_ENVIRONMENT=$BOSH_ENVIRONMENT...
echo BOSH_CA_CERT=$BOSH_CA_CERT...
echo BOSH_CLIENT=$BOSH_CLIENT...
echo BOSH_CLIENT_SECRET=$BOSH_CLIENT_SECRET...
echo HTTPS_PROXY=${HTTPS_PROXY-"<unset>"}...
echo https_proxy=${https_proxy-"<unset>"}...
echo BOSH_ENVIRONMENT=${BOSH_ENVIRONMENT-"<unset>"}...
echo BOSH_CA_CERT=${BOSH_CA_CERT-"<unset>"}...
echo BOSH_CLIENT=${BOSH_CLIENT-"<unset>"}...
echo BOSH_CLIENT_SECRET=${BOSH_CLIENT_SECRET-"<unset>"}...
EOF

$ENV{$_} = "a {$_} got missed" for (qw(
Expand All @@ -149,10 +149,10 @@ EOF
stdout_is(sub { Genesis::BOSH::_bosh({ interactive => 1 }, 'bosh', 'foo'); }, <<EOF,
HTTPS_PROXY=...
https_proxy=...
BOSH_ENVIRONMENT=...
BOSH_CA_CERT=...
BOSH_CLIENT=...
BOSH_CLIENT_SECRET=...
BOSH_ENVIRONMENT=<unset>...
BOSH_CA_CERT=<unset>...
BOSH_CLIENT=<unset>...
BOSH_CLIENT_SECRET=<unset>...
EOF
"bosh() helper should clear out the environment implicitly");

Expand All @@ -166,12 +166,30 @@ EOF
}, 'bosh foo'); }, <<EOF,
HTTPS_PROXY=...
https_proxy=...
BOSH_ENVIRONMENT=...
BOSH_ENVIRONMENT=<unset>...
BOSH_CA_CERT=save my ca cert...
BOSH_CLIENT=save my client id...
BOSH_CLIENT_SECRET=save my client secret...
EOF
"bosh() helper should clear out the environment implicitly");

$ENV{GENESIS_HONOR_ENV}=1;
stdout_is(sub { Genesis::BOSH::_bosh({
interactive => 1,
env => {
BOSH_CA_CERT => 'save my ca cert',
BOSH_CLIENT => 'save my client id',
BOSH_CLIENT_SECRET => 'save my client secret',
},
}, 'bosh foo'); }, <<EOF,
HTTPS_PROXY=a {HTTPS_PROXY} got missed...
https_proxy=a {https_proxy} got missed...
BOSH_ENVIRONMENT=a {BOSH_ENVIRONMENT} got missed...
BOSH_CA_CERT=save my ca cert...
BOSH_CLIENT=save my client id...
BOSH_CLIENT_SECRET=save my client secret...
EOF
"bosh() helper should not clear out the environment if told to honour env");
};


Expand Down

0 comments on commit 22da67c

Please sign in to comment.