Commit Graph

48 Commits

Author SHA1 Message Date
Miloslav Trmač 51c3d1d4b4 Don't try to parse imageName as transport:image in pullImage
Both callers now consistently pass the transport in the "transport"
parameter, so parsing imageName could only be incorrect.

This could possibly fix cases like pulling docker://dir:localpath,
and the debug log will no longer say
"error parsing image name %q, trying with transport %q: %v" on every pull attempt.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #1361
Approved by: rhatdan
2019-02-27 14:07:22 +00:00
Miloslav Trmač 3f84d99643 Use reference.WithTag instead of manual string manipulation in Pull
Should not change behavior, except possibly failing early if the server
returns an invalid tag name.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #1361
Approved by: rhatdan
2019-02-27 14:07:22 +00:00
Miloslav Trmač fa2a247388 Don't pass image = transport:repo:tag, transport=transport to pullImage
pullImage has a dedicated transport: parameter, don't pass the transport
in the image name as well. The semantics of the imageName parameter to
pullImage is now unambiguous.

Should not change behavior, pullImage was trying
alltransports.ParseImageName(imageName) first.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #1361
Approved by: rhatdan
2019-02-27 14:07:22 +00:00
Miloslav Trmač 949709cd18 Fix confusing variable naming in Pull
The result of ParseImageName("docker://"...) is not a storageRef.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #1361
Approved by: rhatdan
2019-02-27 14:07:22 +00:00
Miloslav Trmač c8727b4033 Fix a few issues found by tests/validate/gometalinter.sh
For some reason, the CI does not report any of these; on macOS
I see many more reports (including complaints about the standard
library), this only cleans up the trivial cases.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #1365
Approved by: rhatdan
2019-02-25 10:27:46 +00:00
Daniel J Walsh 3531a2dfb5 Remove quiet option from pull options
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1319
Approved by: rhatdan
2019-02-20 19:31:09 +00:00
Daniel J Walsh fa71977101 Support oci layout format
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1319
Approved by: rhatdan
2019-02-20 19:31:09 +00:00
Daniel J Walsh f9e645a461 Fix pulling of images within buildah
Change references to Transfer to transfer to make it internal only.
It should be determined from the image specification and only determined
in one place.

Make buildah.Pull use registries.conf

Currently buildah pull does not resolve images based on registries.conf
This does not match the behaviour of buildah from or buildah bud

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1319
Approved by: rhatdan
2019-02-20 19:31:09 +00:00
TomSweeneyRedHat f1cec509e0 Add Quiet to PullOptions and PushOptions
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Add Quiet to the PullOptions and PushOptions structures.
If set to true output will be in 'quiet' mode.  This
will primarily be used by callers such as OpenShift.

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #1302
Approved by: rhatdan
2019-01-23 20:40:14 +00:00
Zhou Hao 9a6a441f77 pull: add all-tags option
Add all-tags option to download all tagged images in the repository

After change:
```
➜  buildah git:(add-pull-all) ✗ ./buildah pull --all-tags busybox
Pulling docker://busybox:1-glibc
Getting image source signatures
Skipping fetch of repeat blob sha256:68d65759a692b254073928cce9b3da459b59ee063f4aeb217cd6bcdfac5f838b
Copying config sha256:755a2703667876f4259f24a3225ef503483953ef553fba8758406beefc2ce3f9
 1.46 KiB / 1.46 KiB [======================================================] 0s
Writing manifest to image destination
Storing signatures
755a2703667876f4259f24a3225ef503483953ef553fba8758406beefc2ce3f9
Pulling docker://busybox:1-musl
Getting image source signatures
Skipping fetch of repeat blob sha256:d900fc804a8829d0ea4db613927f60a28a1ef933aa1dbafdaab43630579646c2
Copying config sha256:3cc47384c4cb779466fe40182420bd90ba761a5f26f8564580a114bcd0dfa911
 1.46 KiB / 1.46 KiB [======================================================] 0s
Writing manifest to image destination
Storing signatures
3cc47384c4cb779466fe40182420bd90ba761a5f26f8564580a114bcd0dfa911
Pulling docker://busybox:1-ubuntu
```

Signed-off-by: Zhou Hao <zhouhao@cn.fujitsu.com>

Closes: #1263
Approved by: rhatdan
2019-01-09 20:05:43 +00:00
Nalin Dahyabhai 65707368d8 Use a blob cache when we're asked to use one
Add API hooks for designating locations to be used as blob caches when
pulling and pushing images.  When we commit read-only copies of
container layers for use in images, if we're using blob caching, store a
copy of the layer in the blob cache directory so that it can be found.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1149
Approved by: rhatdan
2018-12-04 18:53:15 +00:00
Daniel J Walsh 4a6f4aeb6b
Resolve image names with default transport in from command
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-10-21 06:33:35 -04:00
Nalin Dahyabhai 189ebeccd7 Update for changes in the containers/image API
Copying an image now returns the manifest of the written image.  Return
the digest of that manifest, and a canonical reference, from our Commit
and Push APIs.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1097
Approved by: rhatdan
2018-10-15 21:27:07 +00:00
Miloslav Trmač 6e0074eeed Move the "short name but no search registries" error handling to resolveImage
Use the value now returned by util.ResolveImage instead of trying to
recompute it.

Then drop the no longer used getRegistries.  (It might be reasonable
to split that part of util.ResolveImage to make it shorter; but it should
not ideally have any independent second-guessing callers.  So, just
keep the inlined one instead; that way we certainly don't break it.)

Also drop the no longer used hasRegistry.

CHANGES BEHAVIOR:
- Most notably, the "short name but no search registries" code
  has been broken for some time; pullImage was called with
  localhost/$shortname, which was a qualified name, so the
  specialized error handling was never attempted.
- Temporarily, the error handling in the "short name but no
  search registries" code trigers even if there were actually
  valid values to try (in practice there is always localhost/$shortname,
  and possibly also options.Registry/$shortname).  The next commit
  will improve it again.
- We now have more legitimate access to the original short name,
  so include it in the error message (it was technically available
  before, but using it was awkward).

NOTE: registriesConfPath is computed using the sysregistries
package, but actual access happens using the sysregistriesv2 package.
That should be cleaned up eventually.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #909
Approved by: rhatdan
2018-10-13 11:56:07 +00:00
Ben Parees add81c3de4 fix missing format param
Signed-off-by: Ben Parees <bparees@redhat.com>

Closes: #1083
Approved by: rhatdan
2018-10-12 19:22:46 +00:00
Nalin Dahyabhai bc2ea08003 Make sure we log or return every error
Make sure that when attempting to diagnose an error, if we encounter an
error during the diagnostic attempt, we return the original error rather
than the error encountered in trying to diagnose it.  Log that one.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1072
Approved by: rhatdan
2018-10-07 12:07:09 +00:00
Nalin Dahyabhai 464a3e587f pullImage(): when completing an image name, try docker://
If we're handed a name for a source image, and
alltransports.ParseImageName() doesn't like it as-is, we normally try
prefixing the Transport option and parsing it again.  If that option
isn't set, though, we return an error, when we should be trying the
default ("docker"), which is how NewBuilder() does things.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1072
Approved by: rhatdan
2018-10-07 12:07:09 +00:00
Nalin Dahyabhai 318fc8940f Enforce "blocked" for registries for the "docker" transport
Check if reading and writing from the registry named by an image is
allowed when the transport is "docker".

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1056
Approved by: rhatdan
2018-10-05 15:30:11 +00:00
Nalin Dahyabhai 62c01da3e4 Correctly set DockerInsecureSkipTLSVerify when pulling images
The image library's copy routine doesn't itself consult the registries
configuration in order to decide whether or not to disable TLS
verification when communicating with a registry, so it's on us to use
the name of a source or destination image to decide whether to set the
flag for that behavior.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1056
Approved by: rhatdan
2018-10-05 15:30:11 +00:00
Daniel J Walsh ba012ddec6
Move buildah from projecatatomic/buildah to containers/buildah
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-09-18 08:06:11 -04:00
W. Trevor King 0d39b40e02 pull: Return image-pulling errors from pullImage
Instead of throwing out the upstream error message, save it and return
it if we can't come up with a more-specific suggestion.  This softens
the approach from 043fd2e3 (Add registry errors for pull,
2018-06-01, #747), because that could make debugging harder [1].

[1]: https://github.com/projectatomic/buildah/issues/849

Signed-off-by: W. Trevor King <wking@tremily.us>

Closes: #1014
Approved by: rhatdan
2018-09-14 18:41:39 +00:00
Miloslav Trmač 344fbdc882 Remove an unused srcRef.NewImageSource in pullImage
- The result is not used anywhere
- In the common case of pulling from docker:// this does not do
  anything notable (only sets up configuration, no network checks)
- ... but it can be pretty expensive for compressed archives,
  creating an uncompressed on-disk copy.
- copy.Image soon after the removed code calls srcRef.NewImageSource
  internally anyway.

This should not change behavior on success; it may change which error is
reported if there is more than one reason for the pull to fail.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #922
Approved by: TomSweeneyRedHat
2018-08-10 20:31:27 +00:00
Nalin Dahyabhai 618bf54c74 Export a Pull() function
Provide a Pull() function that can be called directly, to go with the
Push() function.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #918
Approved by: rhatdan
2018-08-09 18:18:11 +00:00
TomSweeneyRedHat 338b23ea3e Revert pull error handling from 881
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #910
Approved by: rhatdan
2018-08-04 07:58:21 +00:00
TomSweeneyRedHat ba976ed310 Return policy error on pull
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #881
Approved by: rhatdan
2018-08-03 17:29:14 +00:00
Nalin Dahyabhai 8be2b62372 Fix handling of --registries-conf
Instead of ignoring the global --registries-conf option and using only
$REGISTRIES_CONFIG_PATH, use it for the option default.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #854
Approved by: rhatdan
2018-07-07 10:48:44 +00:00
TomSweeneyRedHat 043fd2e300 Add registry errors for pull
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2018-06-06 13:05:56 -04:00
umohnani8 2749191a5f buildah push/from can push and pull images with no reference
pushing with format <transport>:<path> is valid now.
Add support to pull images from oci-archive that have no image ref name.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #697
Approved by: rhatdan
2018-05-16 18:49:37 +00:00
Daniel J Walsh 37ecc5d42a Simple changes to allow buildah to pass make validate
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #606
Approved by: rhatdan
2018-04-20 09:57:35 +00:00
umohnani8 9ffd47edca Vendor in latest containers/image and containers/storage
Changes to paramters in functions.
Change to the error returned by the oci and oci-archive transport.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #578
Approved by: rhatdan
2018-04-13 16:56:21 +00:00
umohnani8 1ca41dcbcb Add various transport support to buildah from
buildah from now supports pulling images using the following transports:
docker-archive, oci-archive, and dir.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #524
Approved by: TomSweeneyRedHat
2018-03-22 17:22:47 +00:00
Nalin Dahyabhai 47ac96155f Use configured registries to resolve image names
When locating an image for pulling, inspection, or pushing, if we're
given an image name that doesn't include a domain/registry, try building
a set of candidate names using the configured registries as domains, and
then pull/inspect/push using the first of those names that works.

If a name that we're given corresponds to a prefix of the ID of a local
image, skip completion and use the ID directly instead.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #360
Approved by: rhatdan
2017-12-14 22:21:16 +00:00
Urvashi Mohnani 4419612150 Add manifest type conversion to buildah push
buildah push supports manifest type conversion when pushing using the 'dir' transport
Manifest types include oci, v2s1, and v2s2
e.g buildah push --format v2s2 alpine dir:my-directory

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>

Closes: #321
Approved by: rhatdan
2017-11-15 13:38:28 +00:00
Daniel J Walsh 8ecefa978c Vendor in changes to support sirupsen/logrus
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-10-10 17:30:11 +00:00
TomSweeneyRedHat 498f0ae9d7 Add credentials to buildah from
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Add credentials to buildah from

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #204
Approved by: nalind
2017-08-22 18:55:38 +00:00
Nalin Dahyabhai 265d2da6cf Always free signature.PolicyContexts
Whenever we create a containers/image/signature.PolicyContext, make sure
we don't forget to destroy it.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #231
Approved by: rhatdan
2017-08-14 12:02:07 +00:00
Nalin Dahyabhai 94f2bf025a Replace --registry with --transport
Replace --registry command line flags with --transport.  For backward
compatibility, add Transport as an addtional setting that we prepend to
the still-optional Registry setting if the Transport and image name
alone don't provide a parseable image reference.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #235
Approved by: rhatdan
2017-08-03 15:55:13 +00:00
Nalin Dahyabhai 262b43a866 Improve "from" behavior with unnamed references
Fix our instantiation behavior when the source image reference is not a
named reference.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #235
Approved by: rhatdan
2017-08-03 15:55:13 +00:00
Dan Walsh 33c2a8a418 gccgo is giving errors about using copy
golang-bin-1.8.1-1.fc26.x86_64
gcc-go-7.1.1-1.fc26.x86_64

Signed-off-by: Dan Walsh <dwalsh@redhat.com>

Closes: #135
Approved by: nalind
2017-06-06 19:40:56 +00:00
Dan Walsh 8ced1276e5 Change functions that use a fmt.Errorf to wrap an err to error.Wrapf
Impove error reporting by wrapping all returned err functions with
error.Wrapf

Signed-off-by: Dan Walsh <dwalsh@redhat.com>

Closes: #124
Approved by: nalind

Signed-off-by: Dan Walsh <dwalsh@redhat.com>

Closes: #125
Approved by: nalind
2017-06-02 14:17:04 +00:00
Dan Walsh 95c2a2d99c Vendor in containers/storage and containers/image
Signed-off-by: Dan Walsh <dwalsh@redhat.com>

Closes: #103
Approved by: nalind
2017-05-17 21:19:24 +00:00
Nalin Dahyabhai 12e582ee1a Report pull/commit progress by default
Have 'from', 'commit', and 'build-using-dockerfile' report progress via
stderr (so that capturing output from 'from' and 'commit' still works as
expected) unless --quiet is used to suppress the reporting.

Closes #94.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #98
Approved by: rhatdan
2017-05-10 12:53:25 +00:00
Nalin Dahyabhai 6d03588e83 Don't bother setting redundant image names
When we pull down an image to use as a starting point, we no longer need
to attach any additional names to it, as the image library can now find
it correctly without requiring us to do so.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #99
Approved by: rhatdan
2017-05-09 20:13:04 +00:00
Nalin Dahyabhai b7a598ca21 Fixup metalinter errors
Fix a number of issues flagged by gometalinter.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #62
Approved by: rhatdan
2017-04-12 21:25:35 +00:00
Nalin Dahyabhai 943191c7c2 Correctly set tags on the names of pulled images
Correctly set the tag portion of the name that we assign to images that
we've pulled.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #42
Approved by: nalind
2017-03-24 22:47:33 +00:00
Nalin Dahyabhai f0b508598a Update implementation to match dependencies
types.ImageSource.Close() can return an error now, and ParseImageName()
moved to containers/image/transports/alltransports.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-03-22 16:33:24 -04:00
Nalin Dahyabhai 22422cc399 Update to match API changes in dependencies
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-02-13 17:21:45 -05:00
Nalin Dahyabhai 0ab0890e4e Massive refactoring
Pull most of the core logic from the CLI into a package that should be
easier to consume as a library.  Add a "config" command that updates the
builder object's configuration.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-02-10 11:48:15 -05:00