line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Sqitch::Command::deploy; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1882
|
use 5.010; |
|
2
|
|
|
|
|
10
|
|
4
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
83
|
|
5
|
2
|
|
|
2
|
|
15
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
51
|
|
6
|
2
|
|
|
2
|
|
9
|
use utf8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
7
|
2
|
|
|
2
|
|
55
|
use Moo; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
8
|
2
|
|
|
2
|
|
847
|
use App::Sqitch::Types qw(Int URI Str Bool HashRef); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
198
|
|
9
|
2
|
|
|
2
|
|
2532
|
use Locale::TextDomain qw(App-Sqitch); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
23
|
|
10
|
2
|
|
|
2
|
|
418
|
use Type::Utils qw(enum); |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
101
|
|
11
|
2
|
|
|
2
|
|
1239
|
use App::Sqitch::X qw(hurl); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
17
|
|
12
|
2
|
|
|
2
|
|
657
|
use List::Util qw(first); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
171
|
|
13
|
2
|
|
|
2
|
|
14
|
use namespace::autoclean; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
15
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
extends 'App::Sqitch::Command'; |
16
|
|
|
|
|
|
|
with 'App::Sqitch::Role::ContextCommand'; |
17
|
|
|
|
|
|
|
with 'App::Sqitch::Role::ConnectingCommand'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = 'v1.4.0'; # VERSION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has target => ( |
22
|
|
|
|
|
|
|
is => 'ro', |
23
|
|
|
|
|
|
|
isa => Str, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has to_change => ( |
27
|
|
|
|
|
|
|
is => 'ro', |
28
|
|
|
|
|
|
|
isa => Str, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has mode => ( |
32
|
|
|
|
|
|
|
is => 'ro', |
33
|
|
|
|
|
|
|
isa => enum([qw( |
34
|
|
|
|
|
|
|
change |
35
|
|
|
|
|
|
|
tag |
36
|
|
|
|
|
|
|
all |
37
|
|
|
|
|
|
|
)]), |
38
|
|
|
|
|
|
|
default => 'all', |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has log_only => ( |
42
|
|
|
|
|
|
|
is => 'ro', |
43
|
|
|
|
|
|
|
isa => Bool, |
44
|
|
|
|
|
|
|
default => 0, |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has lock_timeout => ( |
48
|
|
|
|
|
|
|
is => 'ro', |
49
|
|
|
|
|
|
|
isa => Int, |
50
|
|
|
|
|
|
|
lazy => 1, |
51
|
|
|
|
|
|
|
default => sub { App::Sqitch::Engine::default_lock_timeout() }, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has verify => ( |
55
|
|
|
|
|
|
|
is => 'ro', |
56
|
|
|
|
|
|
|
isa => Bool, |
57
|
|
|
|
|
|
|
default => 0, |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
has variables => ( |
61
|
|
|
|
|
|
|
is => 'ro', |
62
|
|
|
|
|
|
|
isa => HashRef, |
63
|
|
|
|
|
|
|
lazy => 1, |
64
|
|
|
|
|
|
|
default => sub { {} }, |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub options { |
68
|
|
|
|
|
|
|
return qw( |
69
|
|
|
|
|
|
|
target|t=s |
70
|
|
|
|
|
|
|
to-change|to|change=s |
71
|
|
|
|
|
|
|
mode=s |
72
|
|
|
|
|
|
|
set|s=s% |
73
|
|
|
|
|
|
|
log-only |
74
|
|
|
|
|
|
|
lock-timeout=i |
75
|
|
|
|
|
|
|
verify! |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub configure { |
80
|
|
|
|
|
|
|
my ( $class, $config, $opt ) = @_; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my %params = ( |
83
|
|
|
|
|
|
|
mode => $opt->{mode} || $config->get( key => 'deploy.mode' ) || 'all', |
84
|
|
|
|
|
|
|
verify => $opt->{verify} // $config->get( key => 'deploy.verify', as => 'boolean' ) // 0, |
85
|
|
|
|
|
|
|
log_only => $opt->{log_only} || 0, |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
for my $key (qw(to_change target lock_timeout)) { |
88
|
|
|
|
|
|
|
$params{$key} = $opt->{$key} if exists $opt->{$key}; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
if ( my $vars = $opt->{set} ) { |
91
|
|
|
|
|
|
|
$params{variables} = $vars; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
return \%params; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub _collect_vars { |
98
|
15
|
|
|
15
|
|
563
|
my ($self, $target) = @_; |
99
|
15
|
|
|
|
|
289
|
my $cfg = $self->sqitch->config; |
100
|
|
|
|
|
|
|
return ( |
101
|
15
|
|
|
|
|
68
|
%{ $cfg->get_section(section => 'core.variables') }, |
102
|
15
|
|
|
|
|
48
|
%{ $cfg->get_section(section => 'deploy.variables') }, |
103
|
15
|
|
|
|
|
308
|
%{ $target->variables }, # includes engine |
104
|
15
|
|
|
|
|
115
|
%{ $self->variables }, # --set |
|
15
|
|
|
|
|
680
|
|
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub execute { |
109
|
11
|
|
|
11
|
1
|
22545
|
my $self = shift; |
110
|
11
|
|
|
|
|
55
|
my ($targets, $changes) = $self->parse_args( |
111
|
|
|
|
|
|
|
target => $self->target, |
112
|
|
|
|
|
|
|
args => \@_, |
113
|
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# Warn on multiple targets. |
116
|
9
|
|
|
|
|
486
|
my $target = shift @{ $targets }; |
|
9
|
|
|
|
|
23
|
|
117
|
|
|
|
|
|
|
$self->warn(__x( |
118
|
|
|
|
|
|
|
'Too many targets specified; connecting to {target}', |
119
|
|
|
|
|
|
|
target => $target->name, |
120
|
9
|
100
|
|
|
|
16
|
)) if @{ $targets }; |
|
9
|
|
|
|
|
50
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# Warn on too many changes. |
123
|
9
|
|
100
|
|
|
164
|
my $change = $self->to_change // shift @{ $changes }; |
|
6
|
|
|
|
|
19
|
|
124
|
|
|
|
|
|
|
$self->warn(__x( |
125
|
|
|
|
|
|
|
'Too many changes specified; deploying to "{change}"', |
126
|
|
|
|
|
|
|
change => $change, |
127
|
9
|
100
|
|
|
|
12
|
)) if @{ $changes }; |
|
9
|
|
|
|
|
38
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# Now get to work. |
130
|
9
|
|
|
|
|
791
|
my $engine = $target->engine; |
131
|
9
|
|
|
|
|
1532
|
$engine->with_verify( $self->verify ); |
132
|
9
|
|
|
|
|
365
|
$engine->log_only( $self->log_only ); |
133
|
9
|
|
|
|
|
366
|
$engine->lock_timeout( $self->lock_timeout ); |
134
|
9
|
|
|
|
|
439
|
$engine->set_variables( $self->_collect_vars($target) ); |
135
|
9
|
|
|
|
|
217
|
$engine->deploy( $change, $self->mode ); |
136
|
9
|
|
|
|
|
145
|
return $self; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
__END__ |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 Name |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
App::Sqitch::Command::deploy - Deploy Sqitch changes to a database |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 Synopsis |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
my $cmd = App::Sqitch::Command::deploy->new(%params); |
150
|
|
|
|
|
|
|
$cmd->execute; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 Description |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
If you want to know how to use the C<deploy> command, you probably want to be |
155
|
|
|
|
|
|
|
reading C<sqitch-deploy>. But if you really want to know how the C<deploy> command |
156
|
|
|
|
|
|
|
works, read on. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 Interface |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head2 Class Methods |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head3 C<options> |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
my @opts = App::Sqitch::Command::deploy->options; |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Returns a list of L<Getopt::Long> option specifications for the command-line |
167
|
|
|
|
|
|
|
options for the C<deploy> command. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head2 Attributes |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head3 C<log_only> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Boolean indicating whether to log the deploy without running the scripts. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head3 C<lock_timeout> |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
The number of seconds to wait for an exclusive advisory lock on the target, |
178
|
|
|
|
|
|
|
for engines that support the feature. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head3 C<mode> |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Deploy mode, one of "change", "tag", or "all". |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head3 C<target> |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
The deployment target URI. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head3 C<to_change> |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Change up to which to deploy. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head3 C<verify> |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Boolean indicating whether or not to run verify scripts after each change. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head2 Instance Methods |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head3 C<execute> |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
$deploy->execute; |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Executes the deploy command. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head1 See Also |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=over |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=item L<sqitch-deploy> |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Documentation for the C<deploy> command to the Sqitch command-line client. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=item L<sqitch> |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
The Sqitch command-line client. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=back |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 Author |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
David E. Wheeler <david@justatheory.com> |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head1 License |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
Copyright (c) 2012-2023 iovation Inc., David E. Wheeler |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
227
|
|
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal |
228
|
|
|
|
|
|
|
in the Software without restriction, including without limitation the rights |
229
|
|
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
230
|
|
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is |
231
|
|
|
|
|
|
|
furnished to do so, subject to the following conditions: |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all |
234
|
|
|
|
|
|
|
copies or substantial portions of the Software. |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
237
|
|
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
238
|
|
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
239
|
|
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
240
|
|
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
241
|
|
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
242
|
|
|
|
|
|
|
SOFTWARE. |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=cut |