Skip to content

How to sync subtrees in 0.25.0? #1807

@michaelfig

Description

@michaelfig

Expected behavior

I want to sync subtrees like:

src/foo/bar/baz.js -> /usr/src/app/src/foo/bar/baz.js
src/foo2/bot.js -> /usr/src/app/src/foo2/bot.js
src/other.js -> /usr/src/app/src/other.js
something.txt -> usr/src/app/something.txt

In 0.23.0, I could accomplish this simply with:

    sync:
      '**': /usr/src/app/

Actual behavior

0.25.0 (and 0.24.0) strips all path information from the destination files, so they all get collapsed and synced directly to /usr/src/app/ (and not subdirectories of it). This is due to PR #1709.

I would argue that PR #1709 broke working use-cases, because now the only way I know how to achieve this simple subtree mapping is to add explicit sync rules for every subdirectory in my project (!). The use-case that #1709 was trying to fix (collapsing certain subdirectories into a root) can be achieved by adding explicit rules for specific directories.

Docker does not support any kind of ** glob match, so I would argue that skaffold's behaviour here should be more predictable (substituting the glob's match into the resulting destination path), rather than trying to follow some notion of how Docker's COPY command works.

Sync rules are not COPYs, they are tarball generators. I think recursive tar is the model that should be used for syncing, with its defaults of preserving paths unless explicitly pruned by a mapping.

Information

  • Skaffold version: 0.25.0
  • Operating system: darwin-amd64
  • Contents of skaffold.yaml:
apiVersion: skaffold/v1beta4
kind: Config
build:
  artifacts:
  - image: michaelfig/something
    sync:
      '**': /usr/src/app/
deploy:
  kubectl:
    manifests:
    - 'k8s-*.yaml'

Steps to reproduce the behavior

  1. Run skaffold dev
  2. Create/modify a file somewhere deep in the tree.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions