diff options
| author | Matt Robinson <matt@puppetlabs.com> | 2011-05-19 21:18:55 -0700 |
|---|---|---|
| committer | Matt Robinson <matt@puppetlabs.com> | 2011-05-19 21:18:55 -0700 |
| commit | eeeab02fd97a625ec0e21ecd5d0ed7f0067027ef (patch) | |
| tree | 704477b4d8c2b255707e65135b3bb0d10253e06c /ext | |
| parent | be2f20899d76621db4cf574d074f0ae89777272e (diff) | |
| parent | 99bf07e76bab47760b9eb3dc42f08582c568388f (diff) | |
| download | puppet-eeeab02fd97a625ec0e21ecd5d0ed7f0067027ef.tar.gz puppet-eeeab02fd97a625ec0e21ecd5d0ed7f0067027ef.tar.xz puppet-eeeab02fd97a625ec0e21ecd5d0ed7f0067027ef.zip | |
Merge branch '2.7.next' into 2.7.x
* 2.7.next: (42 commits)
(#6395) Add extpuppet help, eval, and interfaces
Adding a sleep state post starting master
maint: fix spec_helper inclusions again.
(#7523) Refactor the grammar to reduce duplication
(#7114) Fix specs for ssh authorized key parsed provider
(#7114) Target returns correct value
(#7114) Add integration tests for authorized_key
(#7114) Improve unit tests for ssh_authorized_key
(#7114) Improve value validation for authorized_key
(#7300) Fix instances method of mount provider
(#7259) Remove ActiveRecord requirement from indirector face spec
(#7259) Do not try to load all Terminus classes when configuring the Indirector
(#3836) External nodes should only capture stdout
Revert "(#7220) Add the ability to "inherit" options."
maint: sync 'authconfig' to 'rest_authconfig' setting
adding test for ticket 7139
(#7139) Accept '/' as a valid path in filesets
(#7300) Add specs for the mount provider
case seems needless here as there is only two opts, also the rest of the file seems to use if so this should make things more consistant
(#6845) Mount writes incorrect vfstab entries
...
Diffstat (limited to 'ext')
| -rwxr-xr-x | ext/envpuppet | 59 | ||||
| -rw-r--r-- | ext/vim/README | 3 | ||||
| -rw-r--r-- | ext/vim/ftplugin/puppet.vim | 94 | ||||
| -rw-r--r-- | ext/vim/indent/puppet.vim | 76 |
4 files changed, 228 insertions, 4 deletions
diff --git a/ext/envpuppet b/ext/envpuppet index d921a19b8..c794e6764 100755 --- a/ext/envpuppet +++ b/ext/envpuppet @@ -34,6 +34,38 @@ set -e set -u +if [[ "${1:-}" == "--help" ]]; then + cat <<EO_HELP +This command reconfigures the environment once for development. +It is designed to wrap around any other command, specifically puppet + +Jeff McCune <jeff@puppetlabs.com> +2011-02-09 + +Puppet should not be installed in site_ruby because all of \$LOAD_PATH +is searched by puppet when loading libraries and the installed version +will taint the development version + +The following enviornment variables configure the behavior of envpuppet + + ENVPUPPET_BASEDIR=${HOME}/src + the base directory where puppet, facter, etc... live. + + ENVPUPPET_BLEEDING=true Enables bleeding edge prototypes like + puppet-interfaces + +The PATH and RUBYLIB are the primary environment variables modified by +the envpuppet script. + +If no arguments are given, the environment variables are printed to STDOUT +allowing the output to be sourced. For example: + + eval \$(envpuppet) + +EO_HELP + exit 0 +fi + if test -d puppet -o -d facter; then echo " WARNING!" echo " Strange things happen if puppet or facter are in the" @@ -50,15 +82,23 @@ fi # Set this to where you check out puppet and facter : ${ENVPUPPET_BASEDIR:="${HOME}/src"} +# Are we bleeding edge? +: ${ENVPUPPET_BLEEDING:='false'} -# git://github.com/reductivelabs/puppet.git +# git://github.com/puppetlabs/puppet.git mypath="${ENVPUPPET_BASEDIR}/puppet/sbin:${ENVPUPPET_BASEDIR}/puppet/bin" myrubylib="${ENVPUPPET_BASEDIR}/puppet/lib" -# git://github.com/reductivelabs/facter.git +# git://github.com/puppetlabs/facter.git mypath="${mypath}:${ENVPUPPET_BASEDIR}/facter/bin" myrubylib="${myrubylib}:${ENVPUPPET_BASEDIR}/facter/lib" +if [[ "${ENVPUPPET_BLEEDING:-}" == "true" ]]; then + # git://github.com/puppetlabs/facter.git + mypath="${mypath}:${ENVPUPPET_BASEDIR}/puppet-interfaces/bin" + myrubylib="${myrubylib}:${ENVPUPPET_BASEDIR}/puppet-interfaces/lib" +fi + # http://github.com/jamtur01/puppet-scaffold.git mypath="${mypath}:${ENVPUPPET_BASEDIR}/puppet-scaffold/bin" myrubylib="${myrubylib}:${ENVPUPPET_BASEDIR}/puppet-scaffold/lib" @@ -73,8 +113,21 @@ myrubylib="${myrubylib}:${ENVPUPPET_BASEDIR}/puppet-module-tool/lib" mypath="${mypath}:${PATH:-}" myrubylib="${myrubylib}:${RUBYLIB:-}" +export ENVPUPPET_OLD_PATH="${PATH:-}" +export ENVPUPPET_OLD_RUBYLIB="${RUBYLIB:-}" + # Trim any trailing colons from the path list. export PATH="${mypath%%:}" export RUBYLIB="${myrubylib%%:}" -exec "$@" +if [[ $# -eq 0 ]]; then + echo "export ENVPUPPET_OLD_PATH='${ENVPUPPET_OLD_PATH}'" + echo "export ENVPUPPET_OLD_RUBYLIB='${ENVPUPPET_OLD_RUBYLIB}'" + echo "export ENVPUPPET_BASEDIR='${ENVPUPPET_BASEDIR}'" + echo "export ENVPUPPET_BLEEDING='${ENVPUPPET_BLEEDING}'" + echo "export PATH='${PATH}'" + echo "export RUBYLIB='${RUBYLIB}'" +else + exec "$@" +fi + diff --git a/ext/vim/README b/ext/vim/README index 776bb1eb2..7fd2934fb 100644 --- a/ext/vim/README +++ b/ext/vim/README @@ -1,2 +1,3 @@ To install these files, copy them into ~/.vim, or the relevant -system-wide location. +system-wide location. To use the ftplugin and indenting, you may need +to enable them with "filetype plugin indent on" in your vimrc. diff --git a/ext/vim/ftplugin/puppet.vim b/ext/vim/ftplugin/puppet.vim new file mode 100644 index 000000000..b6491554b --- /dev/null +++ b/ext/vim/ftplugin/puppet.vim @@ -0,0 +1,94 @@ +" Vim filetype plugin +" Language: Puppet +" Maintainer: Todd Zullinger <tmz@pobox.com> +" Last Change: 2009 Aug 19 +" vim: set sw=4 sts=4: + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +if !exists("no_plugin_maps") && !exists("no_puppet_maps") + if !hasmapto("<Plug>AlignRange") + map <buffer> <LocalLeader>= <Plug>AlignRange + endif +endif + +noremap <buffer> <unique> <script> <Plug>AlignArrows :call <SID>AlignArrows()<CR> +noremap <buffer> <unique> <script> <Plug>AlignRange :call <SID>AlignRange()<CR> + +iabbrev => =><C-R>=<SID>AlignArrows('=>')<CR> +iabbrev +> +><C-R>=<SID>AlignArrows('+>')<CR> + +if exists('*s:AlignArrows') + finish +endif + +let s:arrow_re = '[=+]>' +let s:selector_re = '[=+]>\s*\$.*\s*?\s*{\s*$' + +function! s:AlignArrows(op) + let cursor_pos = getpos('.') + let lnum = line('.') + let line = getline(lnum) + if line !~ s:arrow_re + return + endif + let pos = stridx(line, a:op) + let start = lnum + let end = lnum + let pnum = lnum - 1 + while 1 + let pline = getline(pnum) + if pline !~ s:arrow_re || pline =~ s:selector_re + break + endif + let start = pnum + let pnum -= 1 + endwhile + let cnum = end + while 1 + let cline = getline(cnum) + if cline !~ s:arrow_re || + \ (indent(cnum) != indent(cnum+1) && getline(cnum+1) !~ '\s*}') + break + endif + let end = cnum + let cnum += 1 + endwhile + call s:AlignSection(start, end) + let cursor_pos[2] = stridx(getline('.'), a:op) + strlen(a:op) + 1 + call setpos('.', cursor_pos) + return '' +endfunction + +function! s:AlignRange() range + call s:AlignSection(a:firstline, a:lastline) +endfunction + +" AlignSection and AlignLine are from the vim wiki: +" http://vim.wikia.com/wiki/Regex-based_text_alignment +function! s:AlignSection(start, end) + let extra = 1 + let sep = s:arrow_re + let maxpos = 0 + let section = getline(a:start, a:end) + for line in section + let pos = match(line, ' *'.sep) + if maxpos < pos + let maxpos = pos + endif + endfor + call map(section, 's:AlignLine(v:val, sep, maxpos, extra)') + call setline(a:start, section) +endfunction + +function! s:AlignLine(line, sep, maxpos, extra) + let m = matchlist(a:line, '\(.\{-}\) \{-}\('.a:sep.'.*\)') + if empty(m) + return a:line + endif + let spaces = repeat(' ', a:maxpos - strlen(m[1]) + a:extra) + return m[1] . spaces . m[2] +endfunction diff --git a/ext/vim/indent/puppet.vim b/ext/vim/indent/puppet.vim new file mode 100644 index 000000000..689e06879 --- /dev/null +++ b/ext/vim/indent/puppet.vim @@ -0,0 +1,76 @@ +" Vim indent file +" Language: Puppet +" Maintainer: Todd Zullinger <tmz@pobox.com> +" Last Change: 2009 Aug 19 +" vim: set sw=4 sts=4: + +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal autoindent smartindent +setlocal indentexpr=GetPuppetIndent() +setlocal indentkeys+=0],0) + +if exists("*GetPuppetIndent") + finish +endif + +" Check if a line is part of an include 'block', e.g.: +" include foo, +" bar, +" baz +function! s:PartOfInclude(lnum) + let lnum = a:lnum + while lnum + let lnum = lnum - 1 + let line = getline(lnum) + if line !~ ',$' + break + endif + if line =~ '^\s*include\s\+[^,]\+,$' + return 1 + endif + endwhile + return 0 +endfunction + +function! s:OpenBrace(lnum) + call cursor(a:lnum, 1) + return searchpair('{\|\[\|(', '', '}\|\]\|)', 'nbW') +endfunction + +function! GetPuppetIndent() + let pnum = prevnonblank(v:lnum - 1) + if pnum == 0 + return 0 + endif + + let line = getline(v:lnum) + let pline = getline(pnum) + let ind = indent(pnum) + + if pline =~ '^\s*#' + return ind + endif + + if pline =~ '\({\|\[\|(\|:\)$' + let ind += &sw + elseif pline =~ ';$' && pline !~ '[^:]\+:.*[=+]>.*' + let ind -= &sw + elseif pline =~ '^\s*include\s\+.*,$' + let ind += &sw + endif + + if pline !~ ',$' && s:PartOfInclude(pnum) + let ind -= &sw + endif + + " Match } }, }; ] ]: ) + if line =~ '^\s*\(}\(,\|;\)\?$\|]:\?$\|)\)' + let ind = indent(s:OpenBrace(v:lnum)) + endif + + return ind +endfunction |
