From d045a0b37fcbebda3fbdf568b2e1c664a4d9d887 Mon Sep 17 00:00:00 2001 From: Yevhen Tienkaiev Date: Sun, 31 Mar 2024 04:54:30 +0300 Subject: [PATCH] Add full support for Argo CD external urls --- internal/notification/healthdeployment.go | 11 ++++++++++- internal/notification/phasedeployment.go | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/internal/notification/healthdeployment.go b/internal/notification/healthdeployment.go index 2400fc19..74ad7b97 100644 --- a/internal/notification/healthdeployment.go +++ b/internal/notification/healthdeployment.go @@ -42,7 +42,16 @@ func generateDeploymentStatusOnHealthChanged(app argocdv1alpha1.Application, arg }, } if len(app.Status.Summary.ExternalURLs) > 0 { - ds.GitHubDeploymentStatus.EnvironmentURL = app.Status.Summary.ExternalURLs[0] + // Split the first element of ExternalURLs by `|` + parts := strings.SplitN(app.Status.Summary.ExternalURLs[0], "|", 2) + if len(parts) == 2 { + // Assign the second part to EnvironmentURL as url + // https://argo-cd.readthedocs.io/en/stable/user-guide/external-url/ + // this is hidden supported functionality https://github.com/argoproj/argo-cd/blob/f0b03071fc00fd81433d2c16861c193992d5a093/common/common.go#L186 + ds.GitHubDeploymentStatus.EnvironmentURL = parts[1] + } else { + ds.GitHubDeploymentStatus.EnvironmentURL = app.Status.Summary.ExternalURLs[0] + } } switch app.Status.Health.Status { case health.HealthStatusHealthy: diff --git a/internal/notification/phasedeployment.go b/internal/notification/phasedeployment.go index 026ddf99..dfde40c5 100644 --- a/internal/notification/phasedeployment.go +++ b/internal/notification/phasedeployment.go @@ -49,7 +49,16 @@ func generateDeploymentStatusOnPhaseChanged(app argocdv1alpha1.Application, argo }, } if len(app.Status.Summary.ExternalURLs) > 0 { - ds.GitHubDeploymentStatus.EnvironmentURL = app.Status.Summary.ExternalURLs[0] + // Split the first element of ExternalURLs by `|` + parts := strings.SplitN(app.Status.Summary.ExternalURLs[0], "|", 2) + if len(parts) == 2 { + // Assign the second part to EnvironmentURL as url + // https://argo-cd.readthedocs.io/en/stable/user-guide/external-url/ + // this is hidden supported functionality https://github.com/argoproj/argo-cd/blob/f0b03071fc00fd81433d2c16861c193992d5a093/common/common.go#L186 + ds.GitHubDeploymentStatus.EnvironmentURL = parts[1] + } else { + ds.GitHubDeploymentStatus.EnvironmentURL = app.Status.Summary.ExternalURLs[0] + } } switch phase { case synccommon.OperationRunning: