carvel-dev / carvel-dev/vendir

Feature Request: Support Flag to Disable Deletion

Open
#29 13 comments 1 reaction 0 assignees View on GitHub
carvel-accepted enhancement
Dominant language
Go
Stars
399
Forks
73
Avg merge
2h 53m
Merged PRs (30d)
2

Description

## use-case

We're using `vendir` in a number of different ways to vendor configuration files in from a centralized source.

1) One way is to "layer" configurations from a centralized source. That is, we import a base of configurations and then add a few minor customizations in new files.
2) The other way is we initialize configurations (then disable and diverge), while maintaining a record of when we divereged in the `vendir.yml`.

The problem is when we disable a configuration, then `vendir sync` wants to delete all the files. And if we add files into a vendir'd configuration, and then run `vendir sync`, it will delete those extraneous files. The current behavior makes sense, however, we're hoping we could introduce something that will address the use-cases above. We'll help implement it as well.

## Request A

Support an `enabled` setting. In the example below, `enabled` is set to `false`, so the configuration is skipped. Running `vendir sync` will not attempt to modify or delete the local copy (it's as though the stanza were deleted from the file). This is useful for when we deliberately want to diverge, but want to keep a record in `vendir.yml` the point at which we diverged.

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

directories:

# Terraform components
- path: components/terraform
contents:

- path: account-map
# Disable this from running
enabled: false
git:
url: https://github.com/cloudposse/terraform-aws-components
ref: 0.137.0
newRootPath: modules/account-map
includePaths:
- modules/account-map/**/*

- path: account-settings
git:
url: https://github.com/cloudposse/terraform-aws-components
ref: 0.137.0
newRootPath: modules/account-settings
includePaths:
- modules/account-settings/**/*

```

## Request B

Support an `ignorePaths` block which specifies paths that should not be deleted (or synchronized), even if they do not exist at the source. This is useful when we layer in configurations. For example, we add additional configuration files that do not exist at the source.

In the example below, the `ignorePaths` block says to ignore the fact that `backend.tf.json` does not exist at the source and also, ignore any files in the `catalog/*` folder.

```yaml

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

directories:

# Terraform components
- path: components/terraform
contents:

- path: account-map
# Ignore files which are generated locally and should not be overridden or deleted.
ignorePaths: &ignore
- backend.tf.json
- catalog/*
git:
url: https://github.com/cloudposse/terraform-aws-components
ref: 0.137.0
newRootPath: modules/account-map
includePaths:
- modules/account-map/**/*

- path: account-settings
# Use a YAML anchor to ignore common files
<<*ignore
git:
url: https://github.com/cloudposse/terraform-aws-components
ref: 0.137.0
newRootPath: modules/account-settings
includePaths:
- modules/account-settings/**/*
```

## Request C

Support a `--skip-delete` flag. on `vendir sync`. This is useful during development or as a precaution to avoid accidentally deleting any files.

Running `vendir sync --skip-delete` will run as usual, but not remove any files (but possibly overwrite).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.