given/when constructs are deprecated in newer versions of perl.
@@ -144,8 +144,7 @@ $session_id_file = "$cloudconfig_dir/$tenant/deploy-session-id";
my $command = shift;
-given($command) {
- when ("upload") {
+if ($command eq "upload") {
my $application_package = shift;
if (!$opt_F) {
if (!$application_package) {
@@ -161,8 +160,7 @@ given($command) {
}
do_http_request("upload", $application_package);
- }
- when ("prepare") {
+} elsif ($command eq "prepare") {
my $arg = shift;
if ($arg && looks_like_number($arg) && !(-d $arg)) {
do_http_request("prepare", "", $arg);
@@ -173,24 +171,21 @@ given($command) {
} else {
do_http_request("prepare");
}
- }
- when ("activate") {
+} elsif ($command eq "activate") {
my $session_id = shift;
do_http_request("activate", "", $session_id);
- }
- when ("fetch") {
+} elsif ($command eq "fetch") {
my $arg = shift;
if ($arg) {
fetch_active_application($arg);
} else {
usage("fetch", $arg);
}
- }
- when ("help") {
+} elsif ($command eq "help") {
my $arg = shift;
usage($command, $arg);
- }
- default { usage($command); }
+} else {
+ usage($command);
}
@@ -214,19 +209,21 @@ sub usage {
$command = $arg;
}
- given($command) {
- when ("upload") { usage_upload(); }
- when ("prepare") { usage_prepare(); }
- when ("activate") { usage_activate(); }
- when ("fetch") { usage_fetch(); }
- default {
+ if ($command eq "upload") {
+ usage_upload();
+ } elsif ($command eq "prepare") {
+ usage_prepare();
+ } elsif ($command eq "activate") {
+ usage_activate();
+ } elsif ($command eq "fetch") {
+ usage_fetch();
+ } else {
print "Usage: vespa-deploy [-h] [-v] [-f] [-t] [-p] [<command>] [args]\n";
print "Supported commands: 'upload', 'prepare', 'activate', 'fetch' and 'help'\n";
print "Supported options: '-h' (help), '-v' (verbose), '-f' (force/ignore validation errors), '-t' (timeout in seconds), '-p' (config server http port)\n";
print "Try 'vespa-deploy help <command>' to get more help\n";
}
}
-}
sub usage_upload {
print "Usage: vespa-deploy upload <application package>\n";
@@ -340,19 +337,15 @@ sub do_http_request {
my $output;
my $exitcode = 1;
- given($command) {
- when ("upload") {
+ if ($command eq "upload") {
($exitcode, $output) = http_upload(\@configsources, $configsource_url, $application_package);
- }
- when ("prepare") {
+ } elsif ($command eq "prepare") {
$output = http_prepare($configsource_url, $supplied_session_id);
$exitcode = $? >> 8;
- }
- when ("activate") {
+ } elsif ($command eq "activate") {
$output = http_activate($configsource_url, $supplied_session_id);
$exitcode = $? >> 8;
}
- }
my $response;
if ($exitcode != 0) {
