vendir icon indicating copy to clipboard operation
vendir copied to clipboard

How to effectively sync multiple directories ?

Open gaurav-nelson opened this issue 4 years ago • 6 comments

I am trying to sync content from multiple directories from the same repository, however, when I use the following yml configuration, it fetches the repository all over again. Is there a better way to handle this?

# PS: https://carvel.dev/vendir/docs/latest/vendir-spec/

apiVersion: vendir.k14s.io/v1alpha1
kind: Config
directories:
- path: docs/modules
  contents:
  - path: ROOT/partials
    git:
      url: https://github.com/openshift/openshift-docs
      ref: rhacs-docs
    includePaths:
    - modules/*
    newRootPath: modules/
  - path: ROOT/images
    git:
      url: https://github.com/openshift/openshift-docs
      ref: rhacs-docs
    includePaths:
    - images/*
    newRootPath: images/
  - path: ROOT/pages
    git:
      url: https://github.com/openshift/openshift-docs
      ref: rhacs-docs
    includePaths:
    - welcome/*
    newRootPath: welcome/
  - path: _files
    git:
      url: https://github.com/openshift/openshift-docs
      ref: rhacs-docs
    includePaths:
    - files/*
    newRootPath: files/
  - path: architecture/pages
    git:
      url: https://github.com/openshift/openshift-docs
      ref: rhacs-docs
    includePaths:
    - architecture/*
    newRootPath: architecture/
  - path: backup_and_restore/pages
    git:
      url: https://github.com/openshift/openshift-docs
      ref: rhacs-docs
    includePaths:
    - backup_and_restore/*
    newRootPath: backup_and_restore/
  - path: cli/pages
    git:
      url: https://github.com/openshift/openshift-docs
      ref: rhacs-docs
    includePaths:
    - cli/*
    newRootPath: cli/
  - path: configuration/pages
    git:
      url: https://github.com/openshift/openshift-docs
      ref: rhacs-docs
    includePaths:
    - configuration/*
    newRootPath: configuration/
  - path: installing/pages
    git:
      url: https://github.com/openshift/openshift-docs
      ref: rhacs-docs
    includePaths:
    - installing/*
    newRootPath: installing/
  - path: integration/pages
    git:
      url: https://github.com/openshift/openshift-docs
      ref: rhacs-docs
    includePaths:
    - integration/*
    newRootPath: integration/
  - path: operating/pages
    git:
      url: https://github.com/openshift/openshift-docs
      ref: rhacs-docs
    includePaths:
    - operating/*
    newRootPath: operating/
  - path: release_notes/pages
    git:
      url: https://github.com/openshift/openshift-docs
      ref: rhacs-docs
    includePaths:
    - release_notes/*
    newRootPath: release_notes/
  - path: support/pages
    git:
      url: https://github.com/openshift/openshift-docs
      ref: rhacs-docs
    includePaths:
    - support/*
    newRootPath: support/
  - path: upgrading/pages
    git:
      url: https://github.com/openshift/openshift-docs
      ref: rhacs-docs
    includePaths:
    - upgrading/*
    newRootPath: upgrading/

The source repository is at https://github.com/gaurav-nelson/rhacs-docs

gaurav-nelson avatar Aug 31 '21 01:08 gaurav-nelson

@gaurav-nelson we currently did not include any optimization for fetching same repo multiple times. would be ideal but probably requires a bit of writing down how to best achieve it. do we just see that config is the same across multiple directories or do we introduce top level key called source that could be referenced by each directory?

cppforlife avatar Sep 07 '21 15:09 cppforlife

Surely there are multiple ways to handle this, I like the idea of having top level source. So something like:

apiVersion: vendir.k14s.io/v1alpha1
kind: Config
sources:
- name: source1
  type: git
  url: https://<repository-address>
  ref: <branch-name>
- name: source2
  type: git
  url: https://<repository-address>
  ref: <branch-name>
directories:
- path: docs/modules
  contents:
  - path: ROOT/partials
    source: source1
    includePaths:
    - modules/*
    newRootPath: modules/
  - path: ROOT/images
    source: source1
    includePaths:
    - images/*
    newRootPath: images/
  - path: ROOT/partials
    source: source2
    includePaths:
    - modules/*
    newRootPath: modules/
  - path: ROOT/images
    source: source2
    includePaths:
    - images/*
    newRootPath: images/

  • Define a top level sources key which users can use to declare all supported sources git, image, http, hg etc.
  • define a source key that can be used to link items to the declared sources.

OR

Have a top level source item and process all the directories for that item, then proceed with the next source and so on.

apiVersion: vendir.k14s.io/v1alpha1
kind: Config
source:
  name: source1
  type: git
  url: https://<repository-address>
  ref: <branch-name>
directories:
- path: docs/modules
  contents:
  - path: ROOT/partials
    includePaths:
    - modules/*
    newRootPath: modules/
  - path: ROOT/images
    includePaths:
    - images/*
    newRootPath: images/
source:
  name: source2
  type: git
  url: https://<repository-address>
  ref: <branch-name>
directories:
- path: docs/modules
  contents:
  - path: ROOT/partials
    includePaths:
    - modules/*
    newRootPath: modules/
  - path: ROOT/images
    includePaths:
    - images/*
    newRootPath: images/

gaurav-nelson avatar Sep 08 '21 01:09 gaurav-nelson

This issue is being marked as stale due to a long period of inactivity and will be closed in 5 days if there is no response.

github-actions[bot] avatar Oct 19 '21 00:10 github-actions[bot]

sources with a top level key seems like a right idea imho, though with slight modifications:

apiVersion: vendir.k14s.io/v1alpha1
kind: Config

sources:
- name: source1
  git:
    url: https://<repository-address>
    ref: <branch-name>

directories:
- path: docs/modules
  contents:
  - path: ROOT/partials
    source: source1
    includePaths:
    - modules/*
    newRootPath: modules/

cppforlife avatar Oct 20 '21 14:10 cppforlife

This would be a good addition

psjamesh avatar Jan 25 '23 11:01 psjamesh