Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image import #315

Merged
merged 13 commits into from
Apr 1, 2020
Merged

Image import #315

merged 13 commits into from
Apr 1, 2020

Commits on Mar 31, 2020

  1. Configuration menu
    Copy the full SHA
    4c81091 View commit details
    Browse the repository at this point in the history
  2. Construct a filesystem from an expanded image

    This implements one half of an image cache -- creating a filesystem
    from the cache, given an image name. (The other half is to download
    and put the files into the cache in the first place.)
    
    In the process, I moved the overlay filesystem to its own package.
    squaremo committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    a2078ad View commit details
    Browse the repository at this point in the history
  3. Sketch code for downloading images to cache

    Rough-and-ready code for downloading images into the cache. Manifests
    referred to by digest get written out; otherwise, they get tagged.
    squaremo committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    5ac1ecd View commit details
    Browse the repository at this point in the history
  4. Tidy image cache download

     - factor out the symlink of tag manifests
     - factor out writing a layer
     - write each layer to a tmp dir, then move it, so failures don't
       leave partial layers
     - test that the cached image can be accessed using its digest,
       without using the image registry
    squaremo committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    66bd2b6 View commit details
    Browse the repository at this point in the history
  5. Add --lib flag for specifying an image as library

    This gives the vm (and therefore any command that runs the VM) a flag
    `--lib`, which will cache and use the mentioned image in the module
    search path.
    
    At present the module search path only uses a FileResolver; that is,
    it expects modules in a flat structure.
    
    Ths involves a bit of extra test scaffolding, so that invocations of
    `jk` when testing can use `--lib` (and `--cache` to set the cache to a
    fresh, temporary directory). In particular, an image registry is
    started, and images from tarballs uploaded to it. This is described in
    `tests/testfiles/README-images.md`.
    squaremo committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    a149fd2 View commit details
    Browse the repository at this point in the history
  6. Account for whiteout files

    In the OCI image format, the layer filesystems can contain "whiteout"
    files (think liquid paper or tipp-ex). This suppress any like-named
    file in the layers below.
    
        https://github.com/opencontainers/image-spec/blob/master/layer.md#whiteouts
    
    This commit accounts for whiteouts in the overlay VFS when opening a
    file or enumerating files in a directory.
    
    It's a fairly naive implementation, which checks each possible
    whiteout file, when traversing layers (since whiteouts hide things in
    the _next_ layer).
    squaremo committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    06c2b13 View commit details
    Browse the repository at this point in the history
  7. Ensure that symlinks are preserved in cache

    This is important because images may contain symlinks to save
    repeating files. A notable example is alpine, in which everything in
    /bin/ is a symlink to the busybox binary.
    squaremo committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    743aef8 View commit details
    Browse the repository at this point in the history
  8. Test imports from images with whiteouts

    This adds tests for present and missing files in a library image that
    contains whiteout files.
    
    The test surfaced a mistake: the opaque whiteout file name is
    `.wh..wh..opq`, not `.wh..wh.opq`. Owps.
    squaremo committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    be33227 View commit details
    Browse the repository at this point in the history
  9. Chroot filesystem in images

    Instead of expecting modules to be dumped in the root directory, it's
    friendlier to give jk a "namespace" by putting things in a
    subdirectory. For modules, I have chosen `/jk/modules`.
    
    But to make sure we look for files in the right location (and not
    outside it!), we have to do the same thing as we do for modules in the
    "real" filesystem, and treat the chosen directory as the root of the
    image filesystem. This requires an extra layer, to "chroot" in the
    image filesystem.
    squaremo committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    f5a5e63 View commit details
    Browse the repository at this point in the history
  10. Report qualified path for import candidates

    It's much easier to debug if you get the full path (including the
    image name) for an import candidate, when an import fails.
    squaremo committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    4e7b087 View commit details
    Browse the repository at this point in the history
  11. Provide src and build for test image tarball

    Starting with foolib, which is the easy one.
    squaremo committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    dc65e38 View commit details
    Browse the repository at this point in the history
  12. Build for barlib test image

    Phew! This took some figuring out. Details in README-images.md.
    squaremo committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    fe3bbde View commit details
    Browse the repository at this point in the history
  13. Validate --lib values as image refs

    This needs a "plugin" to pflag, which I've put in `pkg/cli`.
    squaremo committed Mar 31, 2020
    Configuration menu
    Copy the full SHA
    70a1d91 View commit details
    Browse the repository at this point in the history