Dist-Zilla-Plugin-Docker-API

 view release on metacpan or  search on metacpan

.claude/agents/dzil-docker-worker.md  view on Meta::CPAN

---

You are the dzil-docker-worker for **Dist::Zilla::Plugin::Docker::API**.

Implement, refactor, debug and test this distribution. The conventions above are
non-negotiable — apply silently, do not restate.

**Where your lane ends.** You own the plugin: how phases hook into Dist::Zilla, how
dist.ini config becomes attributes, how tags are templated, and how `Client.pm` adapts
`API::Docker`. You do not own the Engine API. If the task turns on what the daemon
accepts or answers — an endpoint's parameters, an event stream's shape, registry auth,
version gating — that is `../p5-api-docker`'s, and the answer is a ticket on its board,
not a workaround here. Guessing at daemon behavior from this adapter is how a wrong
assumption gets cemented; `_split_image_ref` exists because exactly that went wrong once.

Work the karr card you were handed: note progress on it, block it with a reason when
stuck, hand it to `review` when done. Never `done`, never create cards — drift you
find goes as a note on your card, not into scope. Where this brief says to file or
record a ticket (here or on another repo's board), that means a note on your card
saying what and for which board; the dispatching agent files it.
Never `git commit`: leave the tree commit-ready and report what changed and why, plus a proposed commit subject and

.claude/skills/dzil-docker-core/SKILL.md  view on Meta::CPAN

## The client seam

`client_class` (default `…::API::Client`) is loaded with a runtime
`eval "require"` and constructed with two coderefs, `logger` and
`logger_fatal`, that funnel into the plugin's `log`/`log_fatal`. **This seam is
the entire test strategy** — everything below it is fake-able and nothing in
`API.pm` may reach `API::Docker` directly.

Inside `Client.pm`:

- **`_split_image_ref` exists because the engine's tag endpoint takes repo and
  tag separately** (`POST /images/{name}/tag?repo=&tag=`). Passing a full
  reference as `repo` leaves `tag` empty, the engine appends its own default,
  and podman rejects `example/app:1.0:latest` with a 500 — every version tag
  quietly lost. A colon before the last slash is a registry port, not a tag.
- **A failed build's output rides on the exception, not the event loop.**
  API::Docker croaks on the `errorDetail` event before the caller iterates, so
  the preceding stream is drained from `$err->events` — otherwise a failed
  build logs only its last line.
- **Concise mode is the default.** `_is_build_step_header` recognises the
  legacy builder (`Step N/M :`), Podman's classic builder (`STEP N/M:`) and
  BuildKit (`#N [N/M]`, `#N [name N/M]`). A fourth builder format needs a
  fourth pattern here, plus a case in `t/60-build-progress.t`.
- Registry auth is read from `~/.docker/config.json` (or `$DOCKER_CONFIG`),
  handling `identitytoken`, base64 `auth` and plain user/password, with the
  Docker Hub key aliases spelled out.

## Cross-repo: `../p5-api-docker` owns the wire

`API::Docker` is a Getty distribution in the same workspace and `cpanfile` pins
it (`0.003`). A question about what the daemon accepts or answers — endpoint
shape, event stream, auth header, version gating — is **that** repo's, and gets
a ticket on its board rather than a workaround here. `_split_image_ref` living
here rather than there is a deliberate choice: `API::Docker` mirrors the
endpoint and should keep doing so.

The consumer in the other direction is `@Author::GETTY::Docker` in
`../p5-dist-zilla-pluginbundle-author-getty`, which constructs this plugin
programmatically. Any attribute rename or `init_arg` change is a cross-repo
change — check that bundle still builds.

## Tests — the Recorder fake, never a daemon

`prove -lr t/` must pass on a machine with no engine at all, and does.

Changes  view on Meta::CPAN

    "COPY entrypoint.sh" plus ENTRYPOINT no longer needs a "RUN chmod
    +x"), symlinks as symlink entries (dangling ones no longer abort the
    build), and empty directories. Top-level dotfiles such as
    .dockerignore are no longer left out of the context.
  - build_load, release_load and the deprecated load are removed: nothing
    ever read them, as the image always lands in the engine's store when
    built through the API. Setting one in a dist.ini now warns that it is
    no longer supported and is discarded, like phase.
  - A second "platform" value is now a fatal error instead of being
    dropped silently, which built and pushed a single-platform image
    from a multi-platform config. The /build endpoint takes exactly one
    platform; multi-arch images are not what this plugin does.
  - Registry credentials are now resolved from an ordered list of auth
    files instead of only ~/.docker/config.json, so a plain "podman
    login" (or "docker login") is picked up automatically. The order,
    first file with a matching entry winning, is REGISTRY_AUTH_FILE,
    then $DOCKER_CONFIG/config.json, then Podman's
    $XDG_RUNTIME_DIR/containers/auth.json, then
    ~/.config/containers/auth.json, then ~/.docker/config.json. The
    per-registry entry selection is unchanged.

Changes  view on Meta::CPAN

    both checks.
  - A failed release push is fatal. API::Docker 0.004 croaks on a push
    failure rather than returning an errorDetail event, and the client
    catches it and surfaces it through the same log_fatal, carrying the
    engine's errorDetail message when the error is a stream error and
    the exception itself otherwise.
  - A failed build logs the complete build output, not just the failing
    step: the client drains the exception's event list through the same
    progress filter used for a live stream before re-raising.
  - Every tag after the first now applies. The image reference is split
    into repository and tag before reaching the engine's tag endpoint,
    so a registry host:port is no longer mistaken for the tag separator
    and %V/%v no longer vanish -- only "latest" survived the default tag
    list before. A tag the engine refuses is left out of the result
    instead of being reported as applied.
  - New DZIL_DOCKER_API_SKIP=1 skips the image build for one run -- no
    engine contact, no image -- for dzil build/install/test while the
    image cannot build yet. dzil release refuses to run with it set.
  - Document the container engine requirement in POD and README: any
    engine serving the Docker Engine HTTP API works, no docker binary
    needed, and target reaches it unchanged for multi-stage builds.

dist_zilla_docker_api_plugin_plan.md  view on Meta::CPAN

  auth      => $auth,
);

$client->inspect_image($image_ref);
$client->image_exists_locally($image_ref);
$client->remote_tag_exists($image_ref); # optional registry helper
```

### `...::Progress`

Docker build/push endpoints return streaming progress records. The plugin should parse these and forward:

```text
stream/status/progress -> log_debug or log
errorDetail/error      -> log_fatal
aux.ID                 -> captured image ID
```

Important: do not treat HTTP 200 alone as success. Docker build/push can return a successful HTTP response while the stream contains an error event. The adapter must parse the stream completely.

### `...::Registry`

lib/Dist/Zilla/Plugin/Docker/API.pm  view on Meta::CPAN

# then die on a socket that was never there.
sub before_build {
    my ($self) = @_;

    if ($ENV{DZIL_DOCKER_API_SKIP}) {
        $self->log('DZIL_DOCKER_API_SKIP is set: skipping the image build '
            .'for this run - no engine contact, no image');
        return;
    }

    # The classic /build endpoint takes exactly one platform; a second value
    # would otherwise be dropped without a word. This is configuration, not
    # engine contact, so DZIL_DOCKER_API_SKIP_PRECHECK does not skip it.
    my @platforms = @{ $self->platform };
    if (@platforms > 1) {
        $self->log_fatal('only one platform is supported, got '
            .scalar(@platforms).': '.join(', ', @platforms)
            .' - the /build endpoint takes exactly one platform, and this '
            .'plugin is not built for multi-arch images');
    }

    return if $ENV{DZIL_DOCKER_API_SKIP_PRECHECK};

    my $info = eval { $self->client->engine_info };
    my $error = $@;

    if ($error) {
        $error = $self->_flatten_error($error);

lib/Dist/Zilla/Plugin/Docker/API.pm  view on Meta::CPAN

without the check.

=item C<skip_latest_on_trial> - Skip C<latest> tag for trial releases

=item C<build_arg> - Build arguments (can be repeated, template-enabled)

=item C<label> - OCI labels (can be repeated, template-enabled)

=item C<platform> - Target platform, exactly one (e.g. C<linux/arm64>). The key
is repeatable only so that a second value is refused with a clear error: the
/build endpoint takes one platform, and this plugin is not built for multi-arch
images.

=back

=head1 DEPRECATED

The following names are still accepted but emit a warning and will be removed
in a future release. Each is funneled into its canonical attribute by
C<BUILDARGS>; where both spellings are given, the canonical one wins and the
collision is reported.

lib/Dist/Zilla/Plugin/Docker/API/Client.pm  view on Meta::CPAN

    my ($engine) = grep { ($_->{Name} // '') =~ /engine/i }
        @{ $version->{Components} // [] };

    return {
        version     => $version->{Version},
        api_version => $version->{ApiVersion},
        engine      => $engine ? $engine->{Name} : undef,
    };
}

# The engine's tag endpoint takes the repository and the tag as two separate
# parameters (POST /images/{name}/tag?repo=&tag=), so a full image reference
# has to be taken apart before it goes over the wire. Passing the whole thing
# as `repo` leaves `tag` empty and the engine fills in its own default:
# podman then rejects `example/app:1.0:latest` with a 500 and every version
# tag is quietly lost. Splitting happens here rather than in API::Docker,
# which mirrors the endpoint and should keep doing so.
sub _split_image_ref {
    my ( $self, $ref ) = @_;

    my $colon = rindex $ref, ':';
    return ( $ref, undef ) if $colon < 0;
    # A colon before the last slash belongs to a registry host:port, not to a
    # tag: registry.example.com:5000/team/app carries no tag at all.
    return ( $ref, undef ) if rindex($ref, '/') > $colon;

    return ( substr($ref, 0, $colon), substr($ref, $colon + 1) );

misc/agent-context/.claude/agents/dzil-docker-worker.md  view on Meta::CPAN

---

You are the dzil-docker-worker for **Dist::Zilla::Plugin::Docker::API**.

Implement, refactor, debug and test this distribution. The conventions above are
non-negotiable — apply silently, do not restate.

**Where your lane ends.** You own the plugin: how phases hook into Dist::Zilla, how
dist.ini config becomes attributes, how tags are templated, and how `Client.pm` adapts
`API::Docker`. You do not own the Engine API. If the task turns on what the daemon
accepts or answers — an endpoint's parameters, an event stream's shape, registry auth,
version gating — that is `../p5-api-docker`'s, and the answer is a ticket on its board,
not a workaround here. Guessing at daemon behavior from this adapter is how a wrong
assumption gets cemented; `_split_image_ref` exists because exactly that went wrong once.

Work the karr card you were handed: note progress on it, block it with a reason when
stuck, hand it to `review` when done. Never `done`, never create cards — drift you
find goes as a note on your card, not into scope. Where this brief says to file or
record a ticket (here or on another repo's board), that means a note on your card
saying what and for which board; the dispatching agent files it.
Never `git commit`: leave the tree commit-ready and report what changed and why, plus a proposed commit subject and

misc/agent-context/.claude/skills/dzil-docker-core/SKILL.md  view on Meta::CPAN

## The client seam

`client_class` (default `…::API::Client`) is loaded with a runtime
`eval "require"` and constructed with two coderefs, `logger` and
`logger_fatal`, that funnel into the plugin's `log`/`log_fatal`. **This seam is
the entire test strategy** — everything below it is fake-able and nothing in
`API.pm` may reach `API::Docker` directly.

Inside `Client.pm`:

- **`_split_image_ref` exists because the engine's tag endpoint takes repo and
  tag separately** (`POST /images/{name}/tag?repo=&tag=`). Passing a full
  reference as `repo` leaves `tag` empty, the engine appends its own default,
  and podman rejects `example/app:1.0:latest` with a 500 — every version tag
  quietly lost. A colon before the last slash is a registry port, not a tag.
- **A failed build's output rides on the exception, not the event loop.**
  API::Docker croaks on the `errorDetail` event before the caller iterates, so
  the preceding stream is drained from `$err->events` — otherwise a failed
  build logs only its last line.
- **Concise mode is the default.** `_is_build_step_header` recognises the
  legacy builder (`Step N/M :`), Podman's classic builder (`STEP N/M:`) and
  BuildKit (`#N [N/M]`, `#N [name N/M]`). A fourth builder format needs a
  fourth pattern here, plus a case in `t/60-build-progress.t`.
- Registry auth is read from `~/.docker/config.json` (or `$DOCKER_CONFIG`),
  handling `identitytoken`, base64 `auth` and plain user/password, with the
  Docker Hub key aliases spelled out.

## Cross-repo: `../p5-api-docker` owns the wire

`API::Docker` is a Getty distribution in the same workspace and `cpanfile` pins
it (`0.003`). A question about what the daemon accepts or answers — endpoint
shape, event stream, auth header, version gating — is **that** repo's, and gets
a ticket on its board rather than a workaround here. `_split_image_ref` living
here rather than there is a deliberate choice: `API::Docker` mirrors the
endpoint and should keep doing so.

The consumer in the other direction is `@Author::GETTY::Docker` in
`../p5-dist-zilla-pluginbundle-author-getty`, which constructs this plugin
programmatically. Any attribute rename or `init_arg` change is a cross-repo
change — check that bundle still builds.

## Tests — the Recorder fake, never a daemon

`prove -lr t/` must pass on a machine with no engine at all, and does.

misc/agent-context/.claude/skills/getty-perl-pod/SKILL.md  view on Meta::CPAN

transformer does not handle them — do not use them until it does.

```perl
has server => ( is => 'ro', required => 1, coerce => ... );

=attr server

Required. L<Kubernetes::REST::Server> instance or hashref with the connection
configuration.

    server => { endpoint => 'https://kubernetes.local:6443' }

=cut

sub list { ... }

=method list

    my $pods = $api->list('Pod', namespace => 'default');

Returns ...

t/45-image-ref-tagging.t  view on Meta::CPAN

#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;

use Dist::Zilla::Plugin::Docker::API::Client;

# The engine's tag endpoint takes the repository and the tag as two separate
# parameters (POST /images/{name}/tag?repo=&tag=). Handing it a full image
# reference as `repo` and no `tag` makes the engine append its own default:
# podman turns `example/app:1.0` into `example/app:1.0:latest` and answers 500.
# The result was that every version tag silently failed while the build log
# still claimed the image had been tagged.

{
    package FakeImages;
    sub new {
        my ($class, %arg) = @_;

t/85-platform.t  view on Meta::CPAN

BEGIN {
    plan skip_all => "Dist::Zilla::Tester not installed"
        unless eval { require Dist::Zilla::Tester; require Dist::Zilla::Chrome::Term; 1 };
}

use Dist::Zilla::Tester;
use Dist::Zilla::Chrome::Term;
use Path::Tiny;
use File::Temp qw(tempdir);

# The classic /build endpoint takes exactly one platform. 'platform' stays a
# repeatable key so the refusal comes from this plugin and not from
# Config::MVP, but a second value must not be silently dropped.

my $RECORDER = 'Dist::Zilla::Plugin::Docker::API::Client::Recorder';

sub build_dist {
    my ($plugin_config) = @_;
    my $tempdir  = tempdir(CLEANUP => 1);
    my $dist_dir = path($tempdir, 'dist');
    $dist_dir->mkpath;



( run in 1.473 second using v1.01-cache-2.11-cpan-eb134014566 )