| 1 | package API::Docker::Role::Entity::Plugin; | ||||||||||
| 2 | # ABSTRACT: Plugin operations, on the generated plugin type | ||||||||||
| 3 | 52 | our $VERSION = '0.006'; | |||||||||
| 4 | 52 | ▶ | use Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 52 | with 'API::Docker::Role::Entity'; | |||||||||
| 6 | 52 | requires 'name'; | |||||||||
| 7 | 52 | ▶ | use API::Docker::Type::Plugin; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 52 | ▶ | use Carp qw( croak ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 52 | ▶ | use Package::Stash; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 52 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | sub inspect { | ||||||||
|
Subroutine
inspect: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 14 | 1 | my ($self) = @_; | |||||||||
| 15 | 1 | return $self->client->plugins->inspect($self->name); | |||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | |||||||||||
| 19 | 1 | ▶ | sub enable { | ||||||||
|
Subroutine
enable: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 20 | 1 | my ($self, %opts) = @_; | |||||||||
| 21 | 1 | return $self->client->plugins->enable($self->name, %opts); | |||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | 1 | ▶ | sub disable { | ||||||||
|
Subroutine
disable: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 26 | 1 | my ($self, %opts) = @_; | |||||||||
| 27 | 1 | return $self->client->plugins->disable($self->name, %opts); | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | |||||||||||
| 31 | 1 | ▶ | sub remove { | ||||||||
|
Subroutine
remove: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 32 | 1 | my ($self, %opts) = @_; | |||||||||
| 33 | 1 | return $self->client->plugins->remove($self->name, %opts); | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | |||||||||||
| 37 | 1 | ▶ | sub configure { | ||||||||
|
Subroutine
configure: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 38 | 1 | my ($self, @settings) = @_; | |||||||||
| 39 | 1 | return $self->client->plugins->configure($self->name, @settings); | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | |||||||||||
| 43 | 1 | ▶ | sub upgrade { | ||||||||
|
Subroutine
upgrade: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 44 | 1 | my ($self, %opts) = @_; | |||||||||
| 45 | 1 | return $self->client->plugins->upgrade($self->name, %opts); | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | |||||||||||
| 49 | 1 | ▶ | sub push { | ||||||||
|
Subroutine
push: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 50 | 1 | my ($self, %opts) = @_; | |||||||||
| 51 | 1 | return $self->client->plugins->push($self->name, %opts); | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | |||||||||||
| 55 | # --- composition ----------------------------------------------------------- | ||||||||||
| 56 | # | ||||||||||
| 57 | # Here rather than in API::Docker::API::Plugins, for the reason spelled out in | ||||||||||
| 58 | # API::Docker::Role::Entity::Container: loading this role is what puts the | ||||||||||
| 59 | # methods on the class. | ||||||||||
| 60 | # | ||||||||||
| 61 | # The clash check is not decoration. Moo composes a role into a class the | ||||||||||
| 62 | # class-wins way, so a generated accessor of the same name as a method here | ||||||||||
| 63 | # would silently keep its place and the method would be missing -- and the | ||||||||||
| 64 | # generated classes are written from a specification that grows fields | ||||||||||
| 65 | # without asking. This is the resource where the two vocabularies come | ||||||||||
| 66 | # closest: the class already declares `config`, `enabled` and `settings` | ||||||||||
| 67 | # beside this role's `configure` and `enable`. None of the seven names | ||||||||||
| 68 | # collides today; a future one says so on the first `use`. | ||||||||||
| 69 | { | ||||||||||
| 70 | 52 | my @provided = Package::Stash->new(__PACKAGE__)->list_all_symbols('CODE'); | |||||||||
| 71 | 52 | for my $class ('API::Docker::Type::Plugin') { | |||||||||
| 72 | 52 | my $fields = $class->docker_attributes; | |||||||||
| 73 | 52 | my @clash = sort grep { $fields->{$_} } @provided; | |||||||||
| 74 | 52 | ▶ | croak __PACKAGE__ . ': ' . $class . ' declares ' . join(', ', @clash) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | . ' as a daemon field; the generated accessor would win over the ' | ||||||||||
| 76 | . 'method of that name and it would be missing without a word' | ||||||||||
| 77 | if @clash; | ||||||||||
| 78 | 52 | Moo::Role->apply_roles_to_package($class, __PACKAGE__); | |||||||||
| 79 | } | ||||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | |||||||||||
| 83 | 52 | 1; | |||||||||
| 84 | |||||||||||
| 85 | __END__ | ||||||||||