lib/WWW/Hetzner/CLI/Cmd/Server/Cmd/Rebuild.pm

filter: Statementstmt 100% 30 / 30 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 90.9% 40 / 44 CC 5 SCAR 11.8
CC
5
Cov
92%
execute
5.1
BEGIN
1.0
BEGIN
1.0
CRAP 3.3
« lib/WWW/Hetzner/CLI/Cmd/Record/Cmd/Create.pm ↑ Summary lib/WWW/Hetzner/Cloud/Certificate.pm »
1 package WWW::Hetzner::CLI::Cmd::Server::Cmd::Rebuild;
2 # ABSTRACT: Rebuild a server with a new image
3  
4 1 our $VERSION = '0.102';
5  
6 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use MooX::Cmd;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use MooX::Options protect_argv => 0, usage_string => 'USAGE: hcloud.pl server rebuild <id> --image <image>';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use JSON::MaybeXS qw(encode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 with 'WWW::Hetzner::CLI::Role::WaitsForAction';
11  
12 1 option image => (
13 is => 'ro',
14 format => 's',
15 required => 1,
16 doc => 'Image to rebuild with (e.g., debian-12, ubuntu-24.04)',
17 );
18  
19 2 ▶sub execute {
Subroutine execute: called CC=5 SCAR=16.2
Pod undocumented
20 2 my ($self, $args, $chain) = @_;
21 2 ▶ my $id = $args->[0] or die "Usage: hcloud.pl server rebuild <id> --image <image>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud.pl server rebuild <id> --image <image>\n" 2 0 2
22  
23 2 my $main = $chain->[0];
24 2 my $cloud = $main->cloud;
25  
26 2 print "Rebuilding server $id with image ", $self->image, "...\n";
27 2 my $action = $cloud->servers->rebuild($id, $self->image);
28 2 $self->handle_action($action);
29  
30 2 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq 'json') { } 1 1 2
31 1 print encode_json({ %{ $action->data }, %{ $action->result } }), "\n";
32 } else {
33 1 ▶ print $self->no_wait
Branch: 1 branch
BranchTrueFalseTotal
$self->no_wait ? : 1 0 1
34 ? "Server rebuild requested. Data on the server will be lost.\n"
35 : "Server rebuilt. Data on the server has been lost.\n";
36 1 ▶ if (defined $action->root_password) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $action->root_password) 1 0 1
37 1 print "Root password: ", $action->root_password, "\n";
38 }
39 }
40 }
41  
42 1 1;
43  
44 __END__
« lib/WWW/Hetzner/CLI/Cmd/Record/Cmd/Create.pm ↑ Summary lib/WWW/Hetzner/Cloud/Certificate.pm »