Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added --role as data type for apply

  • Loading branch information...
commit 6b5dc84653f1d982551784482dc3ce1ae8e3e606 1 parent 5c97ce6
@dagolden authored
View
7 lib/Pantry/App/Command.pm
@@ -222,9 +222,10 @@ HERE
sub data_options {
return (
- [ 'recipe|r=s@' => "A recipe (without 'recipe[...]')" ],
- [ 'default|d=s@' => "Default attribute (as KEY or KEY=VALUE)" ],
- [ 'override=s@' => "Override attribute (as KEY or KEY=VALUE) (roles only)" ],
+ [ 'recipe|r=s@' => "A recipe (without 'recipe[...]')" ],
+ [ 'role|R=s@' => "A role (without 'role[...]')" ],
+ [ 'default|d=s@' => "Default attribute (as KEY or KEY=VALUE)" ],
+ [ 'override=s@' => "Override attribute (as KEY or KEY=VALUE) (roles only)" ],
);
}
View
7 lib/Pantry/App/Command/apply.pm
@@ -53,7 +53,7 @@ sub _apply_obj {
my $obj = $self->_check_name($type, $name);
- $self->_apply_recipe($obj, $opt);
+ $self->_apply_runlist($obj, $opt);
for my $k ( sort keys %{$setters{$type}} ) {
if ( my $method = $setters{$type}{$k} ) {
@@ -76,11 +76,14 @@ sub _check_name {
return $obj;
}
-sub _apply_recipe {
+sub _apply_runlist {
my ($self, $obj, $opt) = @_;
if ($opt->{recipe}) {
$obj->append_to_run_list(map { "recipe[$_]" } @{$opt->{recipe}});
}
+ if ($opt->{role}) {
+ $obj->append_to_run_list(map { "role[$_]" } @{$opt->{role}});
+ }
return;
}
View
12 t/app/apply.t
@@ -35,6 +35,12 @@ my @cases = (
},
},
{
+ argv => [ qw/-R web/ ],
+ expected => {
+ run_list => [ 'role[web]' ],
+ },
+ },
+ {
argv => [ qw/-d nginx.port=80/ ],
expected => {
run_list => [],
@@ -70,6 +76,12 @@ my @cases = (
},
},
{
+ argv => [ qw/-R web/ ],
+ expected => {
+ run_list => [ 'role[web]' ],
+ },
+ },
+ {
argv => [ qw/-d nginx.port=80/ ],
expected => {
default_attributes => {
Please sign in to comment.
Something went wrong with that request. Please try again.