File: findfiles_up.cf

package info (click to toggle)
cfengine3 3.24.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,552 kB
  • sloc: ansic: 163,161; sh: 10,296; python: 2,950; makefile: 1,744; lex: 784; yacc: 633; perl: 211; pascal: 157; xml: 21; sed: 13
file content (34 lines) | stat: -rw-r--r-- 1,119 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#+begin_src prep
#@ ```
#@ mkdir -p /tmp/repo/.git/
#@ touch /tmp/repo/.git/config
#@ mkdir -p /tmp/repo/submodule/.git/
#@ touch /tmp/repo/submodule/.git/config
#@ mkdir -p /tmp/repo/submodule/some/place/deep/within/my/repo/
#@ ```
#+end_src
###############################################################################
#+begin_src cfengine3
bundle agent __main__
{
  vars:
      "path" # path to search up from
        string => "/tmp/repo/submodule/some/place/deep/within/my/repo/";
      "glob" # glob pattern matching filename
        string => ".git/config";
      "level" # how far to search
        int => "inf";
      "configs"
        data => findfiles_up("$(path)", "$(glob)", "$(level)");
  reports:
      "Submodules '$(glob)' is located in '$(configs[0])'";
      "Parents '$(glob)' is located in '$(configs[1])'";
}
#+end_src
###############################################################################
#+begin_src example_output
#@ ```
#@ R: Submodules '.git/config' is located in '/tmp/repo/submodule/.git/config'
#@ R: Parents '.git/config' is located in '/tmp/repo/.git/config'
#@ ```
#+end_src