summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKartik Null Cating-Subramanian <ksubramanian@chef.io>2015-05-06 14:19:37 -0400
committerKartik Null Cating-Subramanian <ksubramanian@chef.io>2015-06-09 14:20:32 -0400
commit15ffd19b7f17815cb7e18410f319e35ad6a984da (patch)
tree3f38cb81bbdef373a048e92349facba1bf1d613f
parentdbd585a41bd359cd13f901abf194bc8c93537a29 (diff)
downloadchef-15ffd19b7f17815cb7e18410f319e35ad6a984da.tar.gz
Refactor the argument quoting logic and export one function for each binary.
-rw-r--r--distro/powershell/chef.psm161
1 files changed, 37 insertions, 24 deletions
diff --git a/distro/powershell/chef.psm1 b/distro/powershell/chef.psm1
index cdcaed55bb..670667b7a2 100644
--- a/distro/powershell/chef.psm1
+++ b/distro/powershell/chef.psm1
@@ -1,24 +1,4 @@
-function chef-client {
- <#
- .SYNOPSIS
- A chef-client is an agent that runs locally on every node that is under management by Chef.
- .DESCRIPTION
- When a chef-client is run, it will perform all of the steps that are required to bring the node into the expected state, including:
-
- Registering and authenticating the node with the Chef server
- Building the node object
- Synchronizing cookbooks
- Compiling the resource collection by loading each of the required cookbooks, including recipes, attributes, and all other dependencies
- Taking the appropriate and required actions to configure the node
- Looking for exceptions and notifications, handling each as required
- .EXAMPLE
- chef-client --help
- #>
- [CmdletBinding()]
- param (
- [parameter(ValueFromRemainingArguments=$true)] $All
- )
-
+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 ".
@@ -29,6 +9,39 @@
# 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 = $All | foreach { '"' + ( $_ -replace "([\\'""])",'\$1' ) + '"' }
- & "ruby.exe" "chef-client" $Transformed
-} \ No newline at end of file
+ $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