Skip to content

Commit d3a8f4f

Browse files
committed
refactor: move Ansible and OpenTofu packages to parent directory
- Move TorrustDeploy::Provision::Ansible to TorrustDeploy::Ansible - Move TorrustDeploy::Provision::OpenTofu to TorrustDeploy::OpenTofu - Remove empty TorrustDeploy::Provision directory - Update all imports and package declarations - Move corresponding test files from t/unit/provision/ to t/unit/ - Update all test references to use new package names - All tests and linting pass after refactor
1 parent d191999 commit d3a8f4f

File tree

6 files changed

+27
-27
lines changed

6 files changed

+27
-27
lines changed

lib/TorrustDeploy/Provision/Ansible.pm renamed to lib/TorrustDeploy/Ansible.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
package TorrustDeploy::Provision::Ansible;
1+
package TorrustDeploy::Ansible;
22

33
use v5.38;
44

55
use Path::Tiny qw(path);
66

77
=head1 NAME
88
9-
TorrustDeploy::Provision::Ansible - Ansible command wrapper for Torrust deployment
9+
TorrustDeploy::Ansible - Ansible command wrapper for Torrust deployment
1010
1111
=head1 DESCRIPTION
1212

lib/TorrustDeploy/App/Command/Provision.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package TorrustDeploy::App::Command::Provision;
33
use v5.38;
44

55
use TorrustDeploy::App -command;
6-
use TorrustDeploy::Provision::OpenTofu;
7-
use TorrustDeploy::Provision::Ansible;
6+
use TorrustDeploy::OpenTofu;
7+
use TorrustDeploy::Ansible;
88
use Path::Tiny qw(path);
99
use File::Spec;
1010
use Time::HiRes qw(sleep);
@@ -39,7 +39,7 @@ sub execute {
3939

4040
# Set up OpenTofu working directory and copy resolved templates
4141
my $tofu_dir = $work_dir->child('tofu');
42-
my $tofu = TorrustDeploy::Provision::OpenTofu->new();
42+
my $tofu = TorrustDeploy::OpenTofu->new();
4343
$tofu->copy_templates($tofu_dir);
4444

4545
# Initialize OpenTofu
@@ -54,7 +54,7 @@ sub execute {
5454

5555
# Set up Ansible working directory and copy resolved templates
5656
my $ansible_dir = $work_dir->child('ansible');
57-
my $ansible = TorrustDeploy::Provision::Ansible->new();
57+
my $ansible = TorrustDeploy::Ansible->new();
5858
$ansible->copy_templates_and_generate_inventory($vm_ip, $ansible_dir);
5959

6060
# Wait for cloud-init completion using Ansible

lib/TorrustDeploy/Provision/OpenTofu.pm renamed to lib/TorrustDeploy/OpenTofu.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package TorrustDeploy::Provision::OpenTofu;
1+
package TorrustDeploy::OpenTofu;
22

33
use v5.38;
44

@@ -7,7 +7,7 @@ use Path::Tiny qw(path);
77

88
=head1 NAME
99
10-
TorrustDeploy::Provision::OpenTofu - OpenTofu command wrapper for Torrust deployment
10+
TorrustDeploy::OpenTofu - OpenTofu command wrapper for Torrust deployment
1111
1212
=head1 DESCRIPTION
1313

t/unit/provision/ansible.t renamed to t/unit/ansible.t

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ use File::Temp qw(tempdir);
44
use Path::Tiny qw(path);
55

66
# Test the Ansible wrapper module
7-
use_ok('TorrustDeploy::Provision::Ansible');
7+
use_ok('TorrustDeploy::Ansible');
88

99
subtest 'constructor' => sub {
1010
plan tests => 2;
1111

12-
my $ansible = TorrustDeploy::Provision::Ansible->new();
12+
my $ansible = TorrustDeploy::Ansible->new();
1313
ok(defined $ansible, 'constructor returns defined object');
14-
isa_ok($ansible, 'TorrustDeploy::Provision::Ansible', 'object has correct class');
14+
isa_ok($ansible, 'TorrustDeploy::Ansible', 'object has correct class');
1515
};
1616

1717
subtest 'methods exist' => sub {
1818
plan tests => 2;
1919

20-
my $ansible = TorrustDeploy::Provision::Ansible->new();
20+
my $ansible = TorrustDeploy::Ansible->new();
2121
can_ok($ansible, 'copy_templates_and_generate_inventory');
2222
can_ok($ansible, 'run_verification');
2323
};
@@ -26,8 +26,8 @@ subtest 'basic functionality test' => sub {
2626
plan tests => 1;
2727

2828
# This is a simple smoke test - just verify the module loads and can be instantiated
29-
my $ansible = TorrustDeploy::Provision::Ansible->new();
30-
ok(ref($ansible) eq 'TorrustDeploy::Provision::Ansible', 'module works correctly');
29+
my $ansible = TorrustDeploy::Ansible->new();
30+
ok(ref($ansible) eq 'TorrustDeploy::Ansible', 'module works correctly');
3131
};
3232

3333
done_testing();

t/unit/command/provision.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ subtest 'Provision command template copying functionality' => sub {
8787
ok($test_tofu_dir->exists, 'Test tofu directory created');
8888

8989
# Test the OpenTofu copy_templates method since that's where it moved
90-
require TorrustDeploy::Provision::OpenTofu;
91-
my $tofu = TorrustDeploy::Provision::OpenTofu->new();
90+
require TorrustDeploy::OpenTofu;
91+
my $tofu = TorrustDeploy::OpenTofu->new();
9292

9393
eval {
9494
$tofu->copy_templates($test_tofu_dir);
@@ -117,8 +117,8 @@ subtest 'Provision command internal methods' => sub {
117117
});
118118

119119
# Test that OpenTofu functionality is available via the OpenTofu package
120-
require TorrustDeploy::Provision::OpenTofu;
121-
my $tofu = TorrustDeploy::Provision::OpenTofu->new();
120+
require TorrustDeploy::OpenTofu;
121+
my $tofu = TorrustDeploy::OpenTofu->new();
122122
ok($tofu->can('copy_templates'), 'OpenTofu package has copy_templates method');
123123
ok($tofu->can('init'), 'OpenTofu package has init method');
124124
ok($tofu->can('apply'), 'OpenTofu package has apply method');

t/unit/provision/opentofu.t renamed to t/unit/opentofu.t

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ use lib "$Bin/../../../lib";
44
use Path::Tiny qw(path);
55
use File::Temp qw(tempdir);
66

7-
use TorrustDeploy::Provision::OpenTofu;
7+
use TorrustDeploy::OpenTofu;
88

99
subtest 'OpenTofu module loads correctly' => sub {
10-
ok(TorrustDeploy::Provision::OpenTofu->can('new'), 'OpenTofu has new method');
11-
ok(TorrustDeploy::Provision::OpenTofu->can('copy_templates'), 'OpenTofu has copy_templates method');
12-
ok(TorrustDeploy::Provision::OpenTofu->can('init'), 'OpenTofu has init method');
13-
ok(TorrustDeploy::Provision::OpenTofu->can('apply'), 'OpenTofu has apply method');
14-
ok(TorrustDeploy::Provision::OpenTofu->can('get_vm_ip'), 'OpenTofu has get_vm_ip method');
10+
ok(TorrustDeploy::OpenTofu->can('new'), 'OpenTofu has new method');
11+
ok(TorrustDeploy::OpenTofu->can('copy_templates'), 'OpenTofu has copy_templates method');
12+
ok(TorrustDeploy::OpenTofu->can('init'), 'OpenTofu has init method');
13+
ok(TorrustDeploy::OpenTofu->can('apply'), 'OpenTofu has apply method');
14+
ok(TorrustDeploy::OpenTofu->can('get_vm_ip'), 'OpenTofu has get_vm_ip method');
1515
};
1616

1717
subtest 'OpenTofu instance creation' => sub {
18-
my $tofu = TorrustDeploy::Provision::OpenTofu->new();
18+
my $tofu = TorrustDeploy::OpenTofu->new();
1919
ok($tofu, 'OpenTofu instance created successfully');
20-
isa_ok($tofu, 'TorrustDeploy::Provision::OpenTofu');
20+
isa_ok($tofu, 'TorrustDeploy::OpenTofu');
2121
};
2222

2323
subtest 'OpenTofu template copying functionality' => sub {
24-
my $tofu = TorrustDeploy::Provision::OpenTofu->new();
24+
my $tofu = TorrustDeploy::OpenTofu->new();
2525

2626
# Create temporary directory for testing
2727
my $temp_dir = tempdir(CLEANUP => 1);

0 commit comments

Comments
 (0)