Git File Generator Globbing¶
The original and default implementation of the Git file generator does very greedy globbing. This can trigger errors or catch users off-guard. For example, consider the following repository layout:
└── cluster-charts/ ├── cluster1 │ ├── mychart/ │ │ ├── charts/ │ │ │ └── mysubchart/ │ │ │ ├── values.yaml │ │ │ └── etc… │ │ ├── values.yaml │ │ └── etc… │ └── myotherchart/ │ ├── values.yaml │ └── etc… └── cluster2 └── etc…
cluster1 we have two charts, one of them with a subchart.
Assuming we need the ApplicationSet to template values in the
values.yaml, then we need to use a Git file generator instead of a directory generator. The value of the
path key of the Git file generator should be set to:
However, the default implementation will interpret the above pattern as:
cluster1, that it will pick up both the chart's
values.yaml but also the one from its subchart. This will most likely fail, and even if it didn't it would be wrong.
There are multiple other ways this undesirable globbing can fail. For example:
This will return all YAML files in any directory at any level under
some-path, instead of only those directly under it.
Enabling the New Globbing¶
Since some users may rely on the old behavior it was decided to make the fix optional and not enabled by default.
It can be enabled in any of these ways:
--enable-new-git-file-globbingto the ApplicationSet controller args.
ARGOCD_APPLICATIONSET_CONTROLLER_ENABLE_NEW_GIT_FILE_GLOBBING=truein the ApplicationSet controller environment variables.
applicationsetcontroller.enable.new.git.file.globbing: truein the Argo CD ConfigMap.
Note that the default may change in the future.
The new Git file generator globbing uses the
doublestar package. You can find it here.
Below is a short excerpt from its documentation.
doublestar patterns match files and directories recursively. For example, if you had the following directory structure:
grandparent `-- parent |-- child1 `-- child2
You could find the children with patterns such as:
**/parent/*, or even just
** by itself (which will
return all files and directories recursively).
Bash's globstar is doublestar's inspiration and, as such, works similarly.
Note that the doublestar must appear as a path component by itself. A pattern
/path** is invalid and will be treated the same as
/path*/** should achieve the desired result. Additionally,
match all directories and files under the path directory, but
only match directories.