summaryrefslogtreecommitdiff
path: root/distro/powershell/chef/chef.psm1
diff options
context:
space:
mode:
authorKartik Null Cating-Subramanian <ksubramanian@chef.io>2015-05-06 17:35:06 -0400
committerKartik Null Cating-Subramanian <ksubramanian@chef.io>2015-06-09 14:20:34 -0400
commit1b79704f4700e8ebbcbb04a9a6636b0b2e780920 (patch)
tree6a5770a41b1901c84c83d4a33ca4636500276748 /distro/powershell/chef/chef.psm1
parent15ffd19b7f17815cb7e18410f319e35ad6a984da (diff)
downloadchef-1b79704f4700e8ebbcbb04a9a6636b0b2e780920.tar.gz
Moved module file into its own directory. This helps module auto-detection.
Diffstat (limited to 'distro/powershell/chef/chef.psm1')
-rw-r--r--distro/powershell/chef/chef.psm147
1 files changed, 47 insertions, 0 deletions
diff --git a/distro/powershell/chef/chef.psm1 b/distro/powershell/chef/chef.psm1
new file mode 100644
index 0000000000..670667b7a2
--- /dev/null
+++ b/distro/powershell/chef/chef.psm1
@@ -0,0 +1,47 @@
+function Run-Command($command, $argList) {
+ # Take each input string, escape any \ ' or " character in it and then surround it with "s.
+ # This is to defeat the second-level parsing performed by the MSVCRT argument parser used
+ # by ruby which only understands \ ' and ".
+ #
+ # This is a fuster cluck. Don't touch this unless you are sure you understand regexes.
+ # The \\ is to request a literal \ match in a regex.
+ # The "" is to inject a literal " character in a PS string surrounded by "s.
+ # The replacement pattern must be '\$1' and not "\$1" because $1 is not a real variable
+ # that needs substituting - it's a capture group that's interpreted by the regex engine.
+ # \ in the replacement pattern does not need to be escaped - it is literally substituted.
+ $transformed = $argList | foreach { '"' + ( $_ -replace "([\\'""])",'\$1' ) + '"' }
+ #& "echoargs.exe" $transformed
+ & "ruby.exe" $command $transformed
+}
+
+
+function chef-apply {
+ Run-Command 'chef-apply' $args
+}
+
+function chef-client {
+ Run-Command 'chef-client' $args
+}
+
+function chef-service-manager {
+ Run-Command 'chef-service-manager' $args
+}
+
+function chef-shell {
+ Run-Command 'chef-shell' $args
+}
+
+function chef-solo {
+ Run-Command 'chef-solo' $args
+}
+
+function chef-windows-service {
+ Run-Command 'chef-windows-service' $args
+}
+
+function knife {
+ Run-Command 'knife' $args
+}
+
+Export-ModuleMember -function chef-*
+Export-ModuleMember -function knife \ No newline at end of file