Skip to content

Commit

Permalink
Changed variable names to be more unique.
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrasch committed Jul 27, 2017
1 parent 2dc6c6b commit d3995c8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions step-templates/determine-rolling-deploy-window-size.json
Expand Up @@ -9,15 +9,15 @@
"Octopus.Action.Script.Syntax": "PowerShell",
"Octopus.Action.Script.ScriptSource": "Inline",
"Octopus.Action.RunOnServer": "false",
"Octopus.Action.Script.ScriptBody": "#region Verify variables\r\n\r\n#No need to verify PerformRollingDeploy as this is a checkbox and will always have a boolean value. Report value back for logging.\r\nTry\r\n{\r\n $performRollingDeploy = [System.Convert]::ToBoolean($OctopusParameters['PerformRollingDeploy'])\r\n Write-Host ('Perform Rolling Deploy: ' + $performRollingDeploy)\r\n}\r\nCatch\r\n{\r\n Throw \"Cannot convert Perform Rolling Deploy: '\" + $OctopusParameters['PerformRollingDeploy'] + \"' to boolean value. Try having the expression or variable evaluate to 'True' or 'False'.\"\r\n}\r\n\r\n#Verify ServerPercentageToDeploy can be converted to integer.\r\nIf ([string]::IsNullOrEmpty($OctopusParameters['ServerPercentageToDeploy']))\r\n{\r\n Throw 'Server percentage to deploy cannot be null.'\r\n}\r\n\r\n[int]$serverPercentageToDeploy = 0\r\n[bool]$result = [int]::TryParse($OctopusParameters['ServerPercentageToDeploy'], [ref]$serverPercentageToDeploy)\r\n\r\nIf ($result)\r\n{\r\n Write-Host ('Server percentage to deploy: ' + $serverPercentageToDeploy + '%')\r\n $serverPercentToDisconnect = $serverPercentageToDeploy / 100\r\n $serverPercentToRoundUp = $serverPercentToDisconnect + 0.01\r\n}\r\nElse\r\n{\r\n Throw \"Cannot convert Server percentage to deploy: '\" + $OctopusParameters['ServerPercentageToDeploy'] + \"' to integer.\"\r\n}\r\n\r\n#Verify ServerRole is not null.\r\nIf ([string]::IsNullOrEmpty($OctopusParameters['ServerRole']))\r\n{\r\n Throw 'Server Role for Rolling Deploy cannot be null.'\r\n}\r\n$role = $OctopusParameters['ServerRole']\r\nWrite-Host ('Server Role for Rolling Deploy: ' + $role)\r\n\r\n#endregion\r\n\r\n\r\n#region Process\r\n\r\n$serverCountToDeployTo = 9999\r\n\r\nIf ($performRollingDeploy)\r\n{\r\n $servers = $OctopusParameters['Octopus.Environment.MachinesInRole[' + $role + ']']\r\n $totalMachines = ($servers.Split(',')).Count\r\n $serverCountToDeployTo = [math]::Round(($totalMachines * $serverPercentToDisconnect) + $serverPercentToRoundUp)\r\n\r\n Write-Host ('Total machines: ' + $totalMachines)\r\n\r\n If ($serverCountToDeployTo -eq 0)\r\n {\r\n $serverCountToDeployTo++\r\n }\r\n}\r\n\r\nWrite-Host ('Window Size: ' + $serverCountToDeployTo)\r\n\r\n#To use this value, set Window size value to: #{Octopus.Action[Determine Rolling Deploy Window Size].Output.WindowSize}\r\nSet-OctopusVariable -name \"WindowSize\" -value $serverCountToDeployTo\r\n\r\n#endregion\r\n",
"Octopus.Action.Script.ScriptBody": "#region Verify variables\r\n\r\n#No need to verify PerformRollingDeploy as this is a checkbox and will always have a boolean value. Report value back for logging.\r\nTry\r\n{\r\n $performRollingDeploy = [System.Convert]::ToBoolean($OctopusParameters['DRDWSPerformRollingDeploy'])\r\n Write-Host ('Perform Rolling Deploy: ' + $performRollingDeploy)\r\n}\r\nCatch\r\n{\r\n Throw \"Cannot convert Perform Rolling Deploy: '\" + $OctopusParameters['DRDWSPerformRollingDeploy'] + \"' to boolean value. Try having the expression or variable evaluate to 'True' or 'False'.\"\r\n}\r\n\r\n#Verify ServerPercentageToDeploy can be converted to integer.\r\nIf ([string]::IsNullOrEmpty($OctopusParameters['DRDWSServerPercentageToDeploy']))\r\n{\r\n Throw 'Server percentage to deploy cannot be null.'\r\n}\r\n\r\n[int]$serverPercentageToDeploy = 0\r\n[bool]$result = [int]::TryParse($OctopusParameters['DRDWSServerPercentageToDeploy'], [ref]$serverPercentageToDeploy)\r\n\r\nIf ($result)\r\n{\r\n Write-Host ('Server percentage to deploy: ' + $serverPercentageToDeploy + '%')\r\n $serverPercentToDisconnect = $serverPercentageToDeploy / 100\r\n $serverPercentToRoundUp = $serverPercentToDisconnect + 0.01\r\n}\r\nElse\r\n{\r\n Throw \"Cannot convert Server percentage to deploy: '\" + $OctopusParameters['DRDWSServerPercentageToDeploy'] + \"' to integer.\"\r\n}\r\n\r\n#Verify ServerRole is not null.\r\nIf ([string]::IsNullOrEmpty($OctopusParameters['DRDWSServerRole']))\r\n{\r\n Throw 'Server Role for Rolling Deploy cannot be null.'\r\n}\r\n$role = $OctopusParameters['DRDWSServerRole']\r\nWrite-Host ('Server Role for Rolling Deploy: ' + $role)\r\n\r\n#endregion\r\n\r\n\r\n#region Process\r\n\r\n$serverCountToDeployTo = 9999\r\n\r\nIf ($performRollingDeploy)\r\n{\r\n $servers = $OctopusParameters['Octopus.Environment.MachinesInRole[' + $role + ']']\r\n $totalMachines = ($servers.Split(',')).Count\r\n $serverCountToDeployTo = [math]::Round(($totalMachines * $serverPercentToDisconnect) + $serverPercentToRoundUp)\r\n\r\n Write-Host ('Total machines: ' + $totalMachines)\r\n\r\n If ($serverCountToDeployTo -eq 0)\r\n {\r\n $serverCountToDeployTo++\r\n }\r\n}\r\n\r\nWrite-Host ('Window Size: ' + $serverCountToDeployTo)\r\n\r\n#To use this value, set Window size value to: #{Octopus.Action[Determine Rolling Deploy Window Size].Output.WindowSize}\r\nSet-OctopusVariable -name \"WindowSize\" -value $serverCountToDeployTo\r\n\r\n#endregion\r\n",
"Octopus.Action.Script.ScriptFileName": null,
"Octopus.Action.Package.FeedId": null,
"Octopus.Action.Package.PackageId": null
},
"Parameters": [
{
"Id": "561333cc-14ea-44be-aca2-ccb06e0c582f",
"Name": "PerformRollingDeploy",
"Name": "DRDWSPerformRollingDeploy",
"Label": "Perform Rolling Deploy?",
"HelpText": "If checkbox is unchecked, all servers will be deployed to. \nNOTE: This can be set to use a variable or expression.",
"DefaultValue": "True",
Expand All @@ -28,7 +28,7 @@
},
{
"Id": "ecf32591-130c-41cb-b8f5-405e3b1c5d28",
"Name": "ServerPercentageToDeploy",
"Name": "DRDWSServerPercentageToDeploy",
"Label": "Server percentage to deploy",
"HelpText": "Percentage of servers to perform rolling deploy on at a time. Enter as whole number. \nExample for 25%: 25",
"DefaultValue": "",
Expand All @@ -39,7 +39,7 @@
},
{
"Id": "bed9618f-6ede-4c6b-a4b1-a6f0d0a685d4",
"Name": "ServerRole",
"Name": "DRDWSServerRole",
"Label": "Server Role for Rolling Deploy",
"HelpText": null,
"DefaultValue": "",
Expand All @@ -49,9 +49,9 @@
"Links": {}
}
],
"LastModifiedBy": "tbrasch",
"LastModifiedBy": "tbrasch",
"$Meta": {
"ExportedAt": "2017-07-27T16:35:08.300Z",
"ExportedAt": "2017-07-27T17:01:46.652Z",
"OctopusVersion": "3.15.7",
"Type": "ActionTemplate"
},
Expand Down

0 comments on commit d3995c8

Please sign in to comment.