Container-Buildah
view release on metacpan or search on metacpan
lib/Container/Buildah/Subcommand.pm view on Meta::CPAN
# Container::Buildah::Subcommand
# ABSTRACT: wrapper class for Container::Buildah to run subcommands of buildah
# by Ian Kluft
## no critic (Modules::RequireExplicitPackage)
# 'use strict' and 'use warnings' included here
use Modern::Perl qw(2015); # require 5.20.0
## use critic (Modules::RequireExplicitPackage)
package Container::Buildah::Subcommand;
$Container::Buildah::Subcommand::VERSION = '0.3.1';
use autodie;
use Carp qw(croak confess);
use POSIX qw(uname);
use IPC::Run;
use Data::Dumper;
use YAML::XS;
require Container::Buildah;
# exports
use Exporter qw(import);
our @EXPORT_OK = qw(process_params prog);
#
# parameter processing functions used by process_params()
#
# params_extract - set aside parameters which caller wants extracted for further processing that we can't generalize
# private class function
sub params_extract
{
my ($defs, $params, $extract_ref) = @_;
if (exists $defs->{extract}) {
if (ref $defs->{extract} ne "ARRAY") {
confess "process_params parameter 'extract' must be an array, got ".(ref $defs->{extract});
}
foreach my $argname (@{$defs->{extract}}) {
if (exists $params->{$argname}) {
$extract_ref->{$argname} = $params->{$argname};
delete $params->{$argname};
}
}
}
return;
}
# param_arg_init - initialize argument list
# private class function
sub param_arg_init
{
my ($defs, $arg_ref) = @_;
if (exists $defs->{arg_init}) {
if (not ref $defs->{arg_init}) {
push @$arg_ref, $defs->{arg_init};
} elsif (ref $defs->{arg_init} eq "ARRAY") {
push @$arg_ref, @{$defs->{arg_init}};
} else {
confess "process_params parameter 'arg_init' must be scalar or array, got ".(ref $defs->{arg_init});
}
}
return;
}
# param_exclusive - check for exclusive parameters - if any are present, it must be the only parameter
# private class function
( run in 0.415 second using v1.01-cache-2.11-cpan-39bf76dae61 )