-
Notifications
You must be signed in to change notification settings - Fork 506
Expand file tree
/
Copy pathoctopus-check-for-argo-instance.json
More file actions
35 lines (35 loc) · 3 KB
/
octopus-check-for-argo-instance.json
File metadata and controls
35 lines (35 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{
"Id": "7da3a76e-57ca-4542-846a-73c00252206c",
"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": 3,
"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\"]) -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"
},
"Parameters": [
{
"Id": "dfeca839-7c5d-4d5f-a941-27522f918a67",
"Name": "Template.Octopus.API.Key",
"Label": "Octopus Deploy API Key",
"HelpText": "The Octopus Deploy API Key to use when making calls to the Octopus API.",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "Sensitive"
}
}
],
"StepPackageId": "Octopus.Script",
"$Meta": {
"ExportedAt": "2025-11-05T23:41:23.320Z",
"OctopusVersion": "2025.4.6474",
"Type": "ActionTemplate"
},
"LastModifiedBy": "mcasperson",
"Category": "octopus"
}