From f452d6986d1c915309f2e37c7ebf307ac8f676be Mon Sep 17 00:00:00 2001 From: Matthew Casperson Date: Mon, 24 Nov 2025 07:18:41 +1000 Subject: [PATCH] Update Argo CD instance check script to validate API key format and increment version --- step-templates/octopus-check-for-argo-instance.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/step-templates/octopus-check-for-argo-instance.json b/step-templates/octopus-check-for-argo-instance.json index a035fb74..1264f9d7 100644 --- a/step-templates/octopus-check-for-argo-instance.json +++ b/step-templates/octopus-check-for-argo-instance.json @@ -3,14 +3,14 @@ "Name": "Octopus - Check for Argo CD Instances", "Description": "Checks to see if there are any Argo CD instances registered to the space.", "ActionType": "Octopus.Script", - "Version": 1, + "Version": 2, "CommunityActionTemplateId": null, "Packages": [], "GitDependencies": [], "Properties": { "Octopus.Action.Script.ScriptSource": "Inline", "Octopus.Action.Script.Syntax": "PowerShell", - "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\"]))\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" + "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" }, "Parameters": [ {