Footprintless

 view release on metacpan or  search on metacpan

lib/Footprintless/Factory.pm  view on Meta::CPAN


sub deployment {
    my ( $self, $coordinate, %options ) = @_;

    require Footprintless::Deployment;
    return Footprintless::Deployment->new( $self, $coordinate, %options );
}

sub DESTROY { }

sub entities {
    return $_[0]->{entities};
}

sub _init {
    my ( $self, $entities, %options ) = @_;

    $self->{entities}                = $entities;
    $self->{agent}                   = $options{agent};
    $self->{command_options_factory} = $options{command_options_factory};
    $self->{command_runner}          = $options{command_runner};
    $self->{localhost}               = $options{localhost};
    $self->{resource_manager}        = $options{resource_manager};

    $self->{plugins} = [];
    if ( $self->{entities}{'footprintless'} ) {
        my $plugin_modules = $self->{entities}{'footprintless'}{plugins};
        if ($plugin_modules) {
            foreach my $plugin_module (@$plugin_modules) {
                $logger->debugf( 'registering plugin %s', $plugin_module );
                $self->register_plugin(
                    Footprintless::Util::dynamic_module_new(
                        $plugin_module, $self->{entities}{'footprintless'}{$plugin_module}
                    )
                );
            }
        }
    }

    return $self;
}

sub localhost {
    my ($self) = @_;

    unless ( $self->{localhost} ) {
        require Footprintless::Localhost;
        $self->{localhost} = Footprintless::Localhost->new()->load_all();
    }

    return $self->{localhost};
}

sub log {
    my ( $self, $coordinate, %options ) = @_;

    require Footprintless::Log;
    return Footprintless::Log->new( $self, $coordinate, %options );
}

sub overlay {
    my ( $self, $coordinate, %options ) = @_;

    require Footprintless::Overlay;
    return Footprintless::Overlay->new( $self, $coordinate, %options );
}

sub plugins {
    return @{ $_[0]->{plugins} };
}

sub register_plugin {
    my ( $self, $plugin ) = @_;

    push( @{ $self->{plugins} }, $plugin );
}

sub resource_manager {
    my ( $self, $coordinate, %options ) = @_;

    unless ( $self->{resource_manager} ) {
        $self->{resource_manager} =
            Footprintless::Util::dynamic_module_new( 'Footprintless::ResourceManager',
            $self, $coordinate );
    }

    return $self->{resource_manager};
}

sub service {
    my ( $self, $coordinate, %options ) = @_;

    require Footprintless::Service;
    return Footprintless::Service->new( $self, $coordinate, %options );
}

sub tunnel {
    my ( $self, $coordinate, %options ) = @_;

    require Footprintless::Tunnel;
    return Footprintless::Tunnel->new( $self, $coordinate, %options );
}

1;

__END__

=pod

=head1 NAME

Footprintless::Factory - The default factory for footprintless modules

=head1 VERSION

version 1.29

=head1 DESCRIPTION

The default factory for footprintless modules.

lib/Footprintless/Factory.pm  view on Meta::CPAN

operate on the deployment at C<$coordinate>.  Supported options are

=over 4

=item command_options_factory

A C<command_options_factory> to use instead of that which is supplied by
this footprintless instance.

=item command_runner

A C<command_runner> to use instead of that which is supplied by
this footprintless instance.

=item localhost

A C<localhost> to use instead of that which is supplied by
this footprintless instance.

=item resource_manager

A C<resource_manager> to use instead of that which is supplied by
this footprintless instance.

=back

=head2 entities()

Returns the L<Config::Entities> that were resolved by this footprintless
instance.

=head2 localhost()

Returns the L<localhost|Footprintless::Localhost> resolver used by 
this instance.

=head2 log($coordinate, %options)

Returns a new instance of L<Footprintless::Log> preconfigured to
operate on the log at C<$coordinate>.  Supported options are

=over 4

=item command_options_factory

A C<command_options_factory> to use instead of that which is supplied by
this footprintless instance.

=item command_runner

A C<command_runner> to use instead of that which is supplied by
this footprintless instance.

=item localhost

A C<localhost> to use instead of that which is supplied by
this footprintless instance.

=back

=head2 overlay($coordinate, %options)

Returns a new instance of L<Footprintless::Overlay> preconfigured to
operate on the overlay at C<$coordinate>.  Supported options are

=over 4

=item command_options_factory

A C<command_options_factory> to use instead of that which is supplied by
this footprintless instance.

=item command_runner

A C<command_runner> to use instead of that which is supplied by
this footprintless instance.

=item localhost

A C<localhost> to use instead of that which is supplied by
this footprintless instance.

=item resource_manager

A C<resource_manager> to use instead of that which is supplied by
this footprintless instance.

=back

=head2 plugins()

Returns the registered plugins for this instance.

=head2 register_plugin($plugin)

Registers C<$plugin> with this instance.  C<$plugin> must be an instance
of L<Footprintless::Plugin> or a subclass.

=head2 resource_manager()

Returns the L<resource_manager|Footprintless::ResourcManager> used by 
this instance.

=head2 service($coordinate, %options)

Returns a new instance of L<Footprintless::Service> preconfigured to
operate on the service at C<$coordinate>.  Supported options are

=over 4

=item command_options_factory

A C<command_options_factory> to use instead of that which is supplied by
this footprintless instance.

=item command_runner

A C<command_runner> to use instead of that which is supplied by
this footprintless instance.

=item localhost

A C<localhost> to use instead of that which is supplied by
this footprintless instance.



( run in 0.792 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )