Skip to content

Commit 089c9de

Browse files
authored
Update Argo CD instance check script to enhance API key validation and increment version (#1652)
1 parent 7246152 commit 089c9de

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

step-templates/octopus-check-for-argo-instance.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"Name": "Octopus - Check for Argo CD Instances",
44
"Description": "Checks to see if there are any Argo CD instances registered to the space.",
55
"ActionType": "Octopus.Script",
6-
"Version": 2,
6+
"Version": 3,
77
"CommunityActionTemplateId": null,
88
"Packages": [],
99
"GitDependencies": [],
1010
"Properties": {
1111
"Octopus.Action.Script.ScriptSource": "Inline",
1212
"Octopus.Action.Script.Syntax": "PowerShell",
13-
"Octopus.Action.Script.ScriptBody": "# Fix ANSI Color on PWSH Core issues when displaying objects\nif ($PSEdition -eq \"Core\") {\n $PSStyle.OutputRendering = \"PlainText\"\n}\n\n# Define variables\n$isArgoPresent = $false\n\n# Check to see if the Octopus.Web.ServerUri variable has a value\nif (![string]::IsNullOrWhitespace($OctopusParameters[\"Octopus.Web.ServerUri\"]))\n{\n $baseUrl = $OctopusParameters[\"Octopus.Web.ServerUri\"]\n}\nelse\n{\n $baseUrl = $OctopusParameters[\"Octopus.Web.BaseUrl\"]\n}\n\n# Validate parameters\nif ([string]::IsNullOrWhitespace($OctopusParameters[\"Template.Octopus.API.Key\"]) -or -not $OctopusParameters[\"Template.Octopus.API.Key\"].StartsWith(\"API-\"))\n{\n Write-Highlight \"An API Key was not provided, unable to check to see if there are any Argo CD instances registered in this space.\"\n}\nelse\n{\n $header = @{ \"X-Octopus-ApiKey\" = $OctopusParameters[\"Template.Octopus.API.Key\"] }\n\n # Get registered Argo CD instances\n $argoInstances = Invoke-RestMethod -Method Get -Uri \"$($baseUrl)/api/#{Octopus.Space.Id}/argocdinstances/summaries\" -Headers $header\n\n # Check the returned values\n if ($argoInstances.Resources.Count -gt 0)\n {\n Write-Highlight \"Found $($argoInstances.Resources.Count) Argo instance(s) registered!\"\n $isArgoPresent = $true\n }\n else\n {\n Write-Highlight \"No Argo CD instances registered to space $($OctopusParameters['Octopus.Space.Name']). Please [register an Argo CD instance](https://octopus.com/docs/argo-cd/instances) with this space.\"\n }\n}\n\n# Set output variable\nSet-OctopusVariable -Name ArgoPresent -Value $isArgoPresent"
13+
"Octopus.Action.Script.ScriptBody": "# Fix ANSI Color on PWSH Core issues when displaying objects\nif ($PSEdition -eq \"Core\") {\n $PSStyle.OutputRendering = \"PlainText\"\n}\n\n# Define variables\n$isArgoPresent = $false\n\n# Check to see if the Octopus.Web.ServerUri variable has a value\nif (![string]::IsNullOrWhitespace($OctopusParameters[\"Octopus.Web.ServerUri\"]))\n{\n $baseUrl = $OctopusParameters[\"Octopus.Web.ServerUri\"]\n}\nelse\n{\n $baseUrl = $OctopusParameters[\"Octopus.Web.BaseUrl\"]\n}\n\n# Validate parameters\nif ([string]::IsNullOrWhitespace($OctopusParameters[\"Template.Octopus.API.Key\"]) -or -not $OctopusParameters[\"Template.Octopus.API.Key\"].StartsWith(\"API-\"))\n{\n Write-Highlight \"An API Key was not provided, unable to check to see if there are any Argo CD instances registered in this space.\"\n Write-Highlight \"See the [Octopus documentation](https://octopus.com/docs/octopus-rest-api/how-to-create-an-api-key) for details on creating API keys.\"\n Write-Highlight \"Once you have an API key, add it to the $($OctopusParameters['Octopus.Step.Name']) step to enable the ability to check for Argo CD instances in this space.\"\n}\nelse\n{\n $header = @{ \"X-Octopus-ApiKey\" = $OctopusParameters[\"Template.Octopus.API.Key\"] }\n\n # Get registered Argo CD instances\n $argoInstances = Invoke-RestMethod -Method Get -Uri \"$($baseUrl)/api/#{Octopus.Space.Id}/argocdinstances/summaries\" -Headers $header\n\n # Check the returned values\n if ($argoInstances.Resources.Count -gt 0)\n {\n Write-Highlight \"Found $($argoInstances.Resources.Count) Argo instance(s) registered!\"\n $isArgoPresent = $true\n }\n else\n {\n Write-Highlight \"No Argo CD instances registered to space $($OctopusParameters['Octopus.Space.Name']). Please [register an Argo CD instance](https://octopus.com/docs/argo-cd/instances) with this space.\"\n }\n}\n\n# Set output variable\nSet-OctopusVariable -Name ArgoPresent -Value $isArgoPresent"
1414
},
1515
"Parameters": [
1616
{
@@ -30,6 +30,6 @@
3030
"OctopusVersion": "2025.4.6474",
3131
"Type": "ActionTemplate"
3232
},
33-
"LastModifiedBy": "twerthi",
33+
"LastModifiedBy": "mcasperson",
3434
"Category": "octopus"
3535
}

0 commit comments

Comments
 (0)