Commit Graph

208 Commits

Author SHA1 Message Date
Juan Bustamante 812530673f
chore: migrate from docker/docker to moby/moby client (#2512)
* chore: migrate from docker/docker to moby/moby client

Migrates all Docker client usage from github.com/docker/docker to
github.com/moby/moby/client following imgutil's PR #299 migration.

Key changes:
- Updated all DockerClient interfaces to use moby Result types
  (ImageHistoryResult, ContainerInspectResult, etc.)
- Migrated to Options pattern for API calls (ImagePullOptions,
  ContainerInspectOptions, etc.)
- Updated Result field access patterns (result.Items, result.Info, etc.)
- Fixed platform validation by passing dist.Target directly to
  ImagePull instead of string conversion
- Regenerated mocks for moby's APIClient interface
- Updated test assertions for moby's type system changes
- Fixed go.mod dependencies (moby packages now direct)

All tests passing (304 tests across pkg/client, pkg/image, internal/build).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>

* chore: migrate acceptance test manager to moby client

Updated acceptance/managers/image_manager.go to use the new moby client API.

Key changes:
- Updated imports from github.com/docker/docker to github.com/moby/moby
- Changed dockerCli type from client.APIClient to *client.Client
- Updated method signatures to use Options pattern:
  - Info() now requires client.InfoOptions{} and accesses .Info.OSType
  - ImageTag() uses client.ImageTagOptions with Source/Target fields
  - ImageInspect() returns Result type, access .InspectResponse field
  - ContainerCreate() uses client.ContainerCreateOptions struct
  - ContainerStart() uses client.ContainerStartOptions{}
  - ContainerKill() uses client.ContainerKillOptions{Signal: "SIGKILL"}
  - ContainerRemove() uses client.ContainerRemoveOptions{Force: true}
  - ContainerInspect() requires client.ContainerInspectOptions{} and returns Result
- Updated network port types:
  - Use network.MustParsePort() to create network.Port values
  - Changed from nat.PortSet/PortMap to network.PortSet/PortMap
  - Updated PortBinding from nat.PortBinding to network.PortBinding
- Fixed Result type accesses:
  - ContainerInspect: access result.Container instead of result directly
  - ImageInspect: access result.InspectResponse
  - Info: access result.Info.OSType

This completes the migration from docker/docker to moby/moby client across all test code.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>

* fix: use concrete Client type in acceptance tests

Changed all dockerCli parameter and variable types from client.APIClient
interface to *client.Client concrete type to match the updated helper
functions and managers that now require the concrete type.

Changes:
- Updated global dockerCli variable type
- Updated createStack() and createStackImage() parameter types
- Changed dockertypes.ImageBuildOptions to client.ImageBuildOptions
- Removed unused github.com/docker/docker/api/types import

This fixes compilation errors where the interface type couldn't be
used as the concrete type without type assertion.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>

* fixing format issues

Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>

* fix: migrate to client.New() and remove deprecated APIs

Updated all docker client initialization to use the new client.New()
function instead of the deprecated NewClientWithOpts(). The new API
enables API version negotiation by default, so WithAPIVersionNegotiation()
is no longer needed.

Changes:
- Replaced all NewClientWithOpts() calls with New()
- Removed WithAPIVersionNegotiation() option (now default behavior)
- Updated cmd/docker_init.go, pkg/client/client.go, and all test files
- Ran go mod tidy to clean up dependencies

Note: internal/build/testdata/fake-lifecycle/phase.go still uses the old
API since it references the legacy github.com/docker/docker/client package
and is built in a separate container context during tests.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>

* test: skip report tests for pack versions < v0.40.0

The report tests expect the fixture to show Platform API 0.14 and 0.15,
which are only supported in lifecycle 0.21.0+. Pack versions before
v0.40.0 use lifecycle 0.20.x which only supports Platform APIs up to 0.13.

Added PlatformAPI_0_14 feature flag that checks if pack >= v0.40.0.
The report tests now skip when testing with older pack versions that
don't support Platform APIs 0.14, 0.15.

This fixes the acceptance-combo (current, current, previous) test failure
where current pack (with lifecycle 0.21.0) outputs Platform APIs 0.3-0.15,
but the test was incorrectly expecting 0.3-0.13 due to the fixture override
file that was being picked up.

Removed the pack_previous_fixtures_overrides/report_output.txt file as
the override directory approach didn't work correctly for this test case.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>

* fix: add Platform API 0.14 and 0.15 support

When we updated to lifecycle 0.21.0, we updated the fixture file to
expect Platform APIs 0.14 and 0.15, but forgot to update the
SupportedPlatformAPIVersions in the code.

The pack report command reads from build.SupportedPlatformAPIVersions
to display which Platform APIs are supported, so this was causing a
mismatch between the fixture expectation and the actual output.

Changes:
- Added api.MustParse("0.14") and api.MustParse("0.15") to
  SupportedPlatformAPIVersions in internal/build/lifecycle_executor.go
- Removed the PlatformAPI_0_14 feature flag and skip logic from
  acceptance tests (no longer needed)

This fixes the acceptance test failures where the fixture expected
Platform APIs up to 0.15 but pack was only reporting up to 0.13.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>

---------

Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-20 07:20:36 -05:00
Juan Bustamante f5f0a62548
Use Docker API version negotiation instead of hardcoded version (#2474)
* Use Docker API version negotiation instead of hardcoded version

Fixes #2464

This change replaces all hardcoded Docker API version 1.38 references
with WithAPIVersionNegotiation(), allowing pack to automatically adapt
to the Docker daemon's supported API version.

Changes:
- Updated main client initialization to use API version negotiation
- Updated SSH Docker client to use API version negotiation
- Updated all test files to use API version negotiation
- Upgraded fake-lifecycle test dependencies from Docker client v1.4.2 (2019) to v28.5.1
- Fixed fake-lifecycle imports and API calls for compatibility with modern Docker client

Benefits:
- Works with modern Docker daemons requiring API 1.44+ (Docker 27+)
- Backward compatible with older Docker versions
- Future-proof - no need to update hardcoded versions
- Solves Windows runner issue without requiring Docker 27 upgrade

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>

* Update Example_build test to use newer builder with modern lifecycle

The cnbs/sample-builder:noble builder includes a recent lifecycle version
that supports Docker API 1.44+, fixing the test failure on systems with
modern Docker daemons (Docker 27+).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>

* Downgrade fake-lifecycle dependencies for Go 1.23 compatibility

Updated fake-lifecycle test module to support Go 1.23.4 (Windows runner):
- Downgraded lifecycle from v0.20.11 to v0.19.3
- Downgraded go-containerregistry from v0.20.6 to v0.19.2
- Set Go requirement to 1.23 (compatible with Go 1.23.4)
- Updated Dockerfile to use golang:1.23 base image

The older versions still support Docker API 1.44+ and work correctly
with modern Docker daemons requiring minimum API version 1.44.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>

---------

Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-11-22 15:28:14 -05:00
Jerico Pena 6ee43b1713
Bump imgutil to latest and docker from v27.5.1 to v28.3.0 (#2406)
* Bump imgutil to latest and docker from v27.5.1 to v28.3.0
* Remove deprecated DSA key form sshdialer

Signed-off-by: Jerico Pena <jericop@gmail.com>
2025-06-27 09:57:41 -05:00
Anatoli Babenia d5a88c789d
Make `go build` work without Makefile (#2390)
This merges `version.go` into `pkg/client/client.go`, which is the
only file that uses the it. Then it moves `cmd/pack/main.go` into
root. Now `go build` produces executable `pack` instead of bogus
`pack` with just `version.go`.

No need to specify `./cmd/pack` while compiling anymore.
The version is injected into client directly without extra files.

Signed-off-by: Anatoli Babenia <anatoli@rainforce.org>
Co-authored-by: Juan Bustamante <bustamantejj@gmail.com>
2025-06-03 07:47:11 -05:00
Natalie Arellano b59c10dd67 Fix lint
Signed-off-by: Natalie Arellano <narellano@vmware.com>
2024-10-28 14:50:17 -04:00
Husni Faiz 67feb16025
Add a new `manifest` command to support multi-architecture builds (#1705)
Implement Pack Manifest commands in support of https://github.com/buildpacks/rfcs/blob/main/text/0124-pack-manifest-list-commands.md

Signed-off-by: Husni Faiz <ahamedhusni73@gmail.com>
Signed-off-by: WYGIN <wygininc@gmail.com>
Signed-off-by: sai kiran <wyginc1@gmail.com>
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
Signed-off-by: Juan Bustamante <juan.bustamante@broadcom.com>
Signed-off-by: Sai Kiran Maggidi <107541780+WYGIN@users.noreply.github.com>
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>

Co-authored-by: Juan Bustamante <jbustamante@vmware.com>
Co-authored-by: WYGIN <wygininc@gmail.com>
Co-authored-by: sai kiran <wyginc1@gmail.com>
Co-authored-by: Juan Bustamante <juan.bustamante@broadcom.com>
Co-authored-by: Sai Kiran Maggidi <107541780+WYGIN@users.noreply.github.com>
Co-authored-by: Juan Bustamante <bustamantejj@gmail.com>
2024-05-08 12:56:14 -05:00
Juan Bustamante cafced7884
Exposing the logic for processing the Docker Context to be public
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
2024-04-04 09:06:09 -05:00
sarthaksarthak9 9a280cc932 Signed-off-by: sarthaksarthak9 <sarthaknegi908@gmail.com>
try to write logic if --force-color is not the expected behavior.
2023-11-19 15:33:56 +05:30
sarthaksarthak9 7c24b6ebdf Signed-off-by: sarthaksarthak9 <sarthaknegi908@gmail.com>
correct the logic errors
2023-11-11 09:49:44 +05:30
sarthaksarthak9 a1359c6db4 Signed-off-by: sarthaksarthak9 <sarthaknegi908@gmail.com>
"no longer need to define --force-color explicitly"
2023-11-10 22:59:40 +05:30
sarthaksarthak9 6167685fc7 Signed-off-by: sarthaksarthak9 <sarthaknegi908@gmail.com>
add -force-color
2023-11-08 08:33:46 +05:30
sarthaksarthak9 6f0a34ba07 Signed-off-by: sarthaksarthak9 <sarthaknegi908@gmail.com>
ran make verify
2023-11-08 08:12:17 +05:30
sarthaksarthak9 baeaeb68e0 Signed-off-by: sarthaksarthak9 <sarthaknegi908@gmail.com>
added force-color flag!!
2023-11-04 22:53:06 +05:30
sarthaksarthak9 5bb10e5d9a Signed-off-by: sarthaksarthak9 <sarthaknegi908@gmail.com>
Add --force-color flag to force color even when the output is not a TTY.
2023-10-26 22:36:51 +05:30
Juan Bustamante cb6d13b3ff
Adding support for reading docker context
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
2023-08-29 13:21:50 -05:00
Juan Bustamante cf7aa96d30
fixing error connecting to a remote daemon over ssh
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
2023-08-25 14:02:07 -05:00
Joe Kimmel 45dfc763f7 remove deprecated suggest-stacks command
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
2023-04-07 12:16:09 -07:00
Darshan Kumar ec1048e616 add pack extension --help
Signed-off-by: Darshan Kumar <itsdarshankumar@gmail.com>
2023-02-02 17:42:55 +05:30
Jason Schroeder f774522845
style: gofmt everything
`make format` to update styles.

Signed-off-by: Jason Schroeder <jschroeder@salesforce.com>
2023-01-11 09:29:38 -08:00
Anthony Emengo 7db1ac5f50 Address PR comments
- pack download-sbom -> pack sbom download ....
- Add warning message for pack inspect-image <> --bom
- Remove --local flag
- Add -o shorthand for --output-dir flag

Signed-off-by: Anthony Emengo <aemengo@vmware.com>
2022-02-02 10:29:56 -05:00
Anthony Emengo e638b02387 Add new command: pack download-sbom
Signed-off-by: Anthony Emengo <aemengo@vmware.com>
2022-02-02 10:17:56 -05:00
Javier Romero bec10bb11b Make BuildpackDownloader publically available
Before this change, the BuildpackDownloader leaked internal packages
making it unusable as a library.

The primary changes were to move dist and logging package to pkg.

Signed-off-by: Javier Romero <rjavier@vmware.com>
2021-11-01 14:01:10 -05:00
Javier Romero 70a502a14f WIP: Fix version setting
Signed-off-by: Javier Romero <rjavier@vmware.com>
2021-11-01 14:01:08 -05:00
Javier Romero 8d7dbb9167 wip: initial restructure
Signed-off-by: Javier Romero <rjavier@vmware.com>
2021-11-01 14:00:44 -05:00
Matej Vasek 224e0a47d2 Support for SSH connection
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-10-25 17:27:39 +02:00
Anthony Emengo 4d1ea11f68 Support registry mirror during build
Also adds a new config subcommand for registry-mirrors

Signed-off-by: Anthony Emengo <aemengo@vmware.com>
2021-07-06 13:38:28 -04:00
David Freilich 8bf0cd5abc Revert changes to commands
Signed-off-by: David Freilich <dfreilich@vmware.com>
2021-03-05 15:01:48 +02:00
David Freilich e313c9507d Add builder inspect and buildpack inspect command, and hide inspect-builder and inspect-buildpack commands
* Rename inspect-image to inspect, and add alias for inspect-image
* Change behavior for inspect-buildpack to look at default registry name in config, rather than deprecated default registry

Signed-off-by: David Freilich <dfreilich@vmware.com>
2021-03-05 14:15:04 +02:00
David Freilich e6afd257e1 Make logic clearer, by using if statement before disabling color
Signed-off-by: David Freilich <dfreilich@vmware.com>
2021-02-10 09:46:39 +02:00
David Freilich 82ade44b2b Disable color when not in terminal
* Move IsTerminal to internal logging package, to keep it general but not expose it as part of public API

Signed-off-by: David Freilich <dfreilich@vmware.com>
2021-02-10 09:43:56 +02:00
David Freilich e1b429bbfe Use dependency injection for config in commands
Signed-off-by: David Freilich <dfreilich@vmware.com>
2021-02-09 13:25:38 +02:00
David Freilich 269e83d162 Standardize command short descriptions
* Add long description for new config commands

Signed-off-by: David Freilich <dfreilich@vmware.com>
2021-01-08 14:38:27 +02:00
David Freilich 3472cb8dc0 Reorder commands, and hide deprecated commands"
Signed-off-by: David Freilich <dfreilich@vmware.com>
2021-01-06 13:32:44 +02:00
David Freilich b68365a82e Add default-builder command to config subcommand
* This command allows users to list, set, and unset a value for a default builder in the pack config.

Signed-off-by: David Freilich <dfreilich@vmware.com>
2021-01-04 18:31:52 +02:00
David Freilich 8d7e20ca47 Add config registries subcommand
* Deprecate add-registry, list_registries, remove_registry, and set_default_registry in favor of:
** pack config registries add
** pack config registries remove
** pack config registries list
** pack config registries deprecate [<registry>|--unset]

Signed-off-by: David Freilich <dfreilich@vmware.com>
2020-12-23 17:15:49 +02:00
Javier Romero 1e0f9c0f29
Merge branch 'main' into 922-config-run-image 2020-12-07 15:21:53 -06:00
David Freilich 16c9f64cae Add run-image-mirrors to config subcommand
Signed-off-by: David Freilich <dfreilich@vmware.com>
2020-12-07 12:32:28 +02:00
David Freilich d9bcaa0acf Rename pull-buildpack to buildpack pull
* Only show experimental buildpack commands if experimental set
* Use Supports instead of SupportsFeature

Signed-off-by: David Freilich <dfreilich@vmware.com>
2020-12-07 10:33:18 +02:00
David Freilich 27483dfcbf Add buildpack subcommand
Signed-off-by: David Freilich <dfreilich@vmware.com>
2020-12-07 10:33:18 +02:00
Javier Romero da7b3c61c8 Merge remote-tracking branch 'origin/main' into 490_inspect_image
Signed-off-by: Javier Romero <rjavier@vmware.com>
2020-12-04 14:29:02 -06:00
David Freilich 9caf489384 Merge main into branch
Signed-off-by: David Freilich <dfreilich@vmware.com>
2020-12-03 20:16:55 +02:00
David Freilich c67b0fb956 Move into commands package, and make functions private
Signed-off-by: David Freilich <dfreilich@vmware.com>
2020-12-03 14:35:56 +02:00
David Freilich d5b7bdc998 Fix imports
* Rename trusted-builder to trusted-builders, to follow RFC
* Change Config to NewConfigCommand

Signed-off-by: David Freilich <dfreilich@vmware.com>
2020-12-03 14:35:26 +02:00
David Freilich 05117d7dfc Add acceptance tests for config commands
* Add acceptance test for deprecation warning
* Fix linting errors
* Add command to rootCmd

Signed-off-by: David Freilich <dfreilich@vmware.com>
2020-12-03 14:35:26 +02:00
David Freilich f5ab4f5f09 Add config commands package
* Create config command generators, and replace list-trusted/trust/untrust builder funcs

Signed-off-by: David Freilich <dfreilich@vmware.com>
2020-12-03 14:35:26 +02:00
David Freilich 01bf73e7ae Make commands funcs public, to allow for easier usage when distributing to subcommands
Signed-off-by: David Freilich <dfreilich@vmware.com>
2020-12-03 14:35:24 +02:00
David Freilich 19b0d5227e Move into commands package, and make functions private
Signed-off-by: David Freilich <dfreilich@vmware.com>
2020-12-03 14:33:40 +02:00
David Freilich b6e99227ba Create builder subcommand
Signed-off-by: David Freilich <dfreilich@vmware.com>
2020-12-03 14:32:58 +02:00
David Freilich eeed910d8d Make commands funcs public, to allow for easier usage when distributing to subcommands
Signed-off-by: David Freilich <dfreilich@vmware.com>
2020-12-03 14:32:55 +02:00
David Freilich f03e481e8b
Merge branch 'main' into jkutner/pull-buildpack 2020-12-03 11:35:33 +02:00