From d756de7fa98f09c02be65aeac4bc15619dc3d8a3 Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Wed, 20 Nov 2024 15:06:49 +0100 Subject: [PATCH] fix: revert removal of the `proxyURL` field Closes #7114 Signed-off-by: Simon Pasquier --- CHANGELOG.md | 4 + Documentation/api.md | 26 +++ bundle.yaml | 72 +++++++ ...toring.coreos.com_alertmanagerconfigs.yaml | 144 +++++++++++++ ...toring.coreos.com_alertmanagerconfigs.yaml | 72 +++++++ .../alertmanagerconfigs-crd.json | 48 +++++ .../alertmanagerconfigs-v1beta1-crd.libsonnet | 48 +++++ pkg/alertmanager/amcfg.go | 10 + pkg/alertmanager/amcfg_test.go | 192 +++++++++++++----- pkg/apis/monitoring/v1/alertmanager_types.go | 3 +- .../v1alpha1/alertmanager_config_types.go | 11 +- .../v1alpha1/zz_generated.deepcopy.go | 5 + .../v1beta1/alertmanager_config_types.go | 11 +- .../monitoring/v1beta1/conversion_from.go | 1 + pkg/apis/monitoring/v1beta1/conversion_to.go | 1 + .../v1beta1/zz_generated.deepcopy.go | 5 + .../monitoring/v1alpha1/httpconfig.go | 9 + .../monitoring/v1beta1/httpconfig.go | 9 + 18 files changed, 616 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e12eea0bd4..7bf2cba6481 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## Unreleased + +* [BUGFIX] Revert the removal of the `proxyURL` field in `AlertmanagerConfig` CRD. The field takes precedence over `proxyUrl`. #7114 + ## 0.78.1 / 2024-10-30 * [BUGFIX] Fix container images for architectures other than `amd64`. #7065 #7066 #7067 diff --git a/Documentation/api.md b/Documentation/api.md index 0e7fd951c38..e86e4460e6d 100644 --- a/Documentation/api.md +++ b/Documentation/api.md @@ -22263,6 +22263,19 @@ SafeTLSConfig +proxyURL
+ +string + + + +(Optional) +

Optional proxy URL.

+

If defined, this field takes precedence over proxyUrl.

+ + + + proxyUrl
string @@ -30915,6 +30928,19 @@ SafeTLSConfig +proxyURL
+ +string + + + +(Optional) +

Optional proxy URL.

+

If defined, this field takes precedence over proxyUrl.

+ + + + proxyUrl
string diff --git a/bundle.yaml b/bundle.yaml index 3f494dfd99f..0d2379f8373 100644 --- a/bundle.yaml +++ b/bundle.yaml @@ -775,6 +775,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -1766,6 +1772,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -2570,6 +2582,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -3356,6 +3374,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -4176,6 +4200,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -5090,6 +5120,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -5829,6 +5865,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -6671,6 +6713,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -7436,6 +7484,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -8162,6 +8216,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -8875,6 +8935,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -9653,6 +9719,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' diff --git a/example/prometheus-operator-crd-full/monitoring.coreos.com_alertmanagerconfigs.yaml b/example/prometheus-operator-crd-full/monitoring.coreos.com_alertmanagerconfigs.yaml index 010f7140eb4..aada216f6cf 100644 --- a/example/prometheus-operator-crd-full/monitoring.coreos.com_alertmanagerconfigs.yaml +++ b/example/prometheus-operator-crd-full/monitoring.coreos.com_alertmanagerconfigs.yaml @@ -774,6 +774,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -1765,6 +1771,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -2569,6 +2581,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -3355,6 +3373,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -4175,6 +4199,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -5089,6 +5119,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -5828,6 +5864,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -6670,6 +6712,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -7435,6 +7483,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -8161,6 +8215,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -8874,6 +8934,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -9652,6 +9718,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -10614,6 +10686,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -11584,6 +11662,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -12374,6 +12458,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -13154,6 +13244,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -13953,6 +14049,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -14839,6 +14941,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -15571,6 +15679,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -16399,6 +16513,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -17150,6 +17270,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -17867,6 +17993,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -18573,6 +18705,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -19330,6 +19468,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' diff --git a/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagerconfigs.yaml b/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagerconfigs.yaml index bb2b64b664b..c1aaee40570 100644 --- a/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagerconfigs.yaml +++ b/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagerconfigs.yaml @@ -775,6 +775,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -1766,6 +1772,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -2570,6 +2582,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -3356,6 +3374,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -4176,6 +4200,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -5090,6 +5120,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -5829,6 +5865,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -6671,6 +6713,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -7436,6 +7484,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -8162,6 +8216,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -8875,6 +8935,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' @@ -9653,6 +9719,12 @@ spec: It requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0. type: boolean + proxyURL: + description: |- + Optional proxy URL. + + If defined, this field takes precedence over `proxyUrl`. + type: string proxyUrl: description: '`proxyURL` defines the HTTP proxy server to use.' diff --git a/jsonnet/prometheus-operator/alertmanagerconfigs-crd.json b/jsonnet/prometheus-operator/alertmanagerconfigs-crd.json index 013aea0a2e1..bc8db01bfa3 100644 --- a/jsonnet/prometheus-operator/alertmanagerconfigs-crd.json +++ b/jsonnet/prometheus-operator/alertmanagerconfigs-crd.json @@ -726,6 +726,10 @@ "description": "Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.", "type": "boolean" }, + "proxyURL": { + "description": "Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.", + "type": "string" + }, "proxyUrl": { "description": "`proxyURL` defines the HTTP proxy server to use.", "pattern": "^http(s)?://.+$", @@ -1664,6 +1668,10 @@ "description": "Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.", "type": "boolean" }, + "proxyURL": { + "description": "Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.", + "type": "string" + }, "proxyUrl": { "description": "`proxyURL` defines the HTTP proxy server to use.", "pattern": "^http(s)?://.+$", @@ -2416,6 +2424,10 @@ "description": "Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.", "type": "boolean" }, + "proxyURL": { + "description": "Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.", + "type": "string" + }, "proxyUrl": { "description": "`proxyURL` defines the HTTP proxy server to use.", "pattern": "^http(s)?://.+$", @@ -3164,6 +3176,10 @@ "description": "Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.", "type": "boolean" }, + "proxyURL": { + "description": "Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.", + "type": "string" + }, "proxyUrl": { "description": "`proxyURL` defines the HTTP proxy server to use.", "pattern": "^http(s)?://.+$", @@ -3922,6 +3938,10 @@ "description": "Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.", "type": "boolean" }, + "proxyURL": { + "description": "Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.", + "type": "string" + }, "proxyUrl": { "description": "`proxyURL` defines the HTTP proxy server to use.", "pattern": "^http(s)?://.+$", @@ -4777,6 +4797,10 @@ "description": "Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.", "type": "boolean" }, + "proxyURL": { + "description": "Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.", + "type": "string" + }, "proxyUrl": { "description": "`proxyURL` defines the HTTP proxy server to use.", "pattern": "^http(s)?://.+$", @@ -5474,6 +5498,10 @@ "description": "Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.", "type": "boolean" }, + "proxyURL": { + "description": "Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.", + "type": "string" + }, "proxyUrl": { "description": "`proxyURL` defines the HTTP proxy server to use.", "pattern": "^http(s)?://.+$", @@ -6245,6 +6273,10 @@ "description": "Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.", "type": "boolean" }, + "proxyURL": { + "description": "Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.", + "type": "string" + }, "proxyUrl": { "description": "`proxyURL` defines the HTTP proxy server to use.", "pattern": "^http(s)?://.+$", @@ -6962,6 +6994,10 @@ "description": "Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.", "type": "boolean" }, + "proxyURL": { + "description": "Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.", + "type": "string" + }, "proxyUrl": { "description": "`proxyURL` defines the HTTP proxy server to use.", "pattern": "^http(s)?://.+$", @@ -7630,6 +7666,10 @@ "description": "Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.", "type": "boolean" }, + "proxyURL": { + "description": "Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.", + "type": "string" + }, "proxyUrl": { "description": "`proxyURL` defines the HTTP proxy server to use.", "pattern": "^http(s)?://.+$", @@ -8289,6 +8329,10 @@ "description": "Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.", "type": "boolean" }, + "proxyURL": { + "description": "Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.", + "type": "string" + }, "proxyUrl": { "description": "`proxyURL` defines the HTTP proxy server to use.", "pattern": "^http(s)?://.+$", @@ -9003,6 +9047,10 @@ "description": "Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.", "type": "boolean" }, + "proxyURL": { + "description": "Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.", + "type": "string" + }, "proxyUrl": { "description": "`proxyURL` defines the HTTP proxy server to use.", "pattern": "^http(s)?://.+$", diff --git a/jsonnet/prometheus-operator/alertmanagerconfigs-v1beta1-crd.libsonnet b/jsonnet/prometheus-operator/alertmanagerconfigs-v1beta1-crd.libsonnet index f381c1b497a..b1cd3c96e0b 100644 --- a/jsonnet/prometheus-operator/alertmanagerconfigs-v1beta1-crd.libsonnet +++ b/jsonnet/prometheus-operator/alertmanagerconfigs-v1beta1-crd.libsonnet @@ -595,6 +595,10 @@ description: 'Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.', type: 'boolean', }, + proxyURL: { + description: 'Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.', + type: 'string', + }, proxyUrl: { description: '`proxyURL` defines the HTTP proxy server to use.', pattern: '^http(s)?://.+$', @@ -1524,6 +1528,10 @@ description: 'Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.', type: 'boolean', }, + proxyURL: { + description: 'Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.', + type: 'string', + }, proxyUrl: { description: '`proxyURL` defines the HTTP proxy server to use.', pattern: '^http(s)?://.+$', @@ -2270,6 +2278,10 @@ description: 'Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.', type: 'boolean', }, + proxyURL: { + description: 'Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.', + type: 'string', + }, proxyUrl: { description: '`proxyURL` defines the HTTP proxy server to use.', pattern: '^http(s)?://.+$', @@ -3018,6 +3030,10 @@ description: 'Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.', type: 'boolean', }, + proxyURL: { + description: 'Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.', + type: 'string', + }, proxyUrl: { description: '`proxyURL` defines the HTTP proxy server to use.', pattern: '^http(s)?://.+$', @@ -3767,6 +3783,10 @@ description: 'Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.', type: 'boolean', }, + proxyURL: { + description: 'Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.', + type: 'string', + }, proxyUrl: { description: '`proxyURL` defines the HTTP proxy server to use.', pattern: '^http(s)?://.+$', @@ -4610,6 +4630,10 @@ description: 'Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.', type: 'boolean', }, + proxyURL: { + description: 'Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.', + type: 'string', + }, proxyUrl: { description: '`proxyURL` defines the HTTP proxy server to use.', pattern: '^http(s)?://.+$', @@ -5304,6 +5328,10 @@ description: 'Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.', type: 'boolean', }, + proxyURL: { + description: 'Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.', + type: 'string', + }, proxyUrl: { description: '`proxyURL` defines the HTTP proxy server to use.', pattern: '^http(s)?://.+$', @@ -6069,6 +6097,10 @@ description: 'Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.', type: 'boolean', }, + proxyURL: { + description: 'Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.', + type: 'string', + }, proxyUrl: { description: '`proxyURL` defines the HTTP proxy server to use.', pattern: '^http(s)?://.+$', @@ -6780,6 +6812,10 @@ description: 'Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.', type: 'boolean', }, + proxyURL: { + description: 'Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.', + type: 'string', + }, proxyUrl: { description: '`proxyURL` defines the HTTP proxy server to use.', pattern: '^http(s)?://.+$', @@ -7445,6 +7481,10 @@ description: 'Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.', type: 'boolean', }, + proxyURL: { + description: 'Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.', + type: 'string', + }, proxyUrl: { description: '`proxyURL` defines the HTTP proxy server to use.', pattern: '^http(s)?://.+$', @@ -8101,6 +8141,10 @@ description: 'Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.', type: 'boolean', }, + proxyURL: { + description: 'Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.', + type: 'string', + }, proxyUrl: { description: '`proxyURL` defines the HTTP proxy server to use.', pattern: '^http(s)?://.+$', @@ -8806,6 +8850,10 @@ description: 'Whether to use the proxy configuration defined by environment variables (HTTP_PROXY, HTTPS_PROXY, and NO_PROXY).\n\nIt requires Prometheus >= v2.43.0 or Alertmanager >= 0.25.0.', type: 'boolean', }, + proxyURL: { + description: 'Optional proxy URL.\n\nIf defined, this field takes precedence over `proxyUrl`.', + type: 'string', + }, proxyUrl: { description: '`proxyURL` defines the HTTP proxy server to use.', pattern: '^http(s)?://.+$', diff --git a/pkg/alertmanager/amcfg.go b/pkg/alertmanager/amcfg.go index 9f059e6b7f6..655656961c0 100644 --- a/pkg/alertmanager/amcfg.go +++ b/pkg/alertmanager/amcfg.go @@ -33,6 +33,7 @@ import ( "gopkg.in/yaml.v2" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" "github.com/prometheus-operator/prometheus-operator/internal/util" "github.com/prometheus-operator/prometheus-operator/pkg/alertmanager/validation" @@ -1501,6 +1502,15 @@ func (cb *configBuilder) convertHTTPConfig(ctx context.Context, in *monitoringv1 return nil, err } + // in.ProxyURL comes from the common v1.ProxyConfig struct and is + // serialized as `proxyUrl` while in.ProxyURLOriginal is serialized as + // `proxyURL`. ProxyURLOriginal existed first in the CRD spec hence it + // can't be removed till the next API bump and should take precedence over + // in.ProxyURL. + if ptr.Deref(in.ProxyURLOriginal, "") != "" { + proxyConfig.ProxyURL = *in.ProxyURLOriginal + } + out := &httpClientConfig{ proxyConfig: proxyConfig, FollowRedirects: in.FollowRedirects, diff --git a/pkg/alertmanager/amcfg_test.go b/pkg/alertmanager/amcfg_test.go index a83f7a0ae26..75152a1aa6a 100644 --- a/pkg/alertmanager/amcfg_test.go +++ b/pkg/alertmanager/amcfg_test.go @@ -35,13 +35,15 @@ import ( apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/fake" "k8s.io/utils/ptr" - monitoringingv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" + monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" monitoringv1alpha1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1alpha1" "github.com/prometheus-operator/prometheus-operator/pkg/assets" + "github.com/prometheus-operator/prometheus-operator/pkg/operator" ) func mustMarshalRoute(r monitoringv1alpha1.Route) []byte { @@ -77,18 +79,18 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { tests := []struct { name string amVersion *semver.Version - globalConfig *monitoringingv1.AlertmanagerGlobalConfig - matcherStrategy monitoringingv1.AlertmanagerConfigMatcherStrategy + globalConfig *monitoringv1.AlertmanagerGlobalConfig + matcherStrategy monitoringv1.AlertmanagerConfigMatcherStrategy amConfig *monitoringv1alpha1.AlertmanagerConfig want *alertmanagerConfig wantErr bool }{ { name: "valid global config", - globalConfig: &monitoringingv1.AlertmanagerGlobalConfig{ - SMTPConfig: &monitoringingv1.GlobalSMTPConfig{ + globalConfig: &monitoringv1.AlertmanagerGlobalConfig{ + SMTPConfig: &monitoringv1.GlobalSMTPConfig{ From: ptr.To("from"), - SmartHost: &monitoringingv1.HostPort{ + SmartHost: &monitoringv1.HostPort{ Host: "smtp.example.org", Port: "587", }, @@ -110,9 +112,9 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { RequireTLS: ptr.To(true), }, ResolveTimeout: "30s", - HTTPConfig: &monitoringingv1.HTTPConfig{ - OAuth2: &monitoringingv1.OAuth2{ - ClientID: monitoringingv1.SecretOrConfigMap{ + HTTPConfig: &monitoringv1.HTTPConfig{ + OAuth2: &monitoringv1.OAuth2{ + ClientID: monitoringv1.SecretOrConfigMap{ ConfigMap: &corev1.ConfigMapKeySelector{ LocalObjectReference: corev1.LocalObjectReference{ Name: "webhook-client-id", @@ -159,7 +161,7 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, }, }, - matcherStrategy: monitoringingv1.AlertmanagerConfigMatcherStrategy{ + matcherStrategy: monitoringv1.AlertmanagerConfigMatcherStrategy{ Type: "OnNamespace", }, want: &alertmanagerConfig{ @@ -213,7 +215,7 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, { name: "valid global config with Slack API URL", - globalConfig: &monitoringingv1.AlertmanagerGlobalConfig{ + globalConfig: &monitoringv1.AlertmanagerGlobalConfig{ SlackAPIURL: &corev1.SecretKeySelector{ Key: "url", LocalObjectReference: corev1.LocalObjectReference{ @@ -245,7 +247,7 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, }, }, - matcherStrategy: monitoringingv1.AlertmanagerConfigMatcherStrategy{ + matcherStrategy: monitoringv1.AlertmanagerConfigMatcherStrategy{ Type: "OnNamespace", }, want: &alertmanagerConfig{ @@ -276,7 +278,7 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, { name: "global config with invalid Slack API URL", - globalConfig: &monitoringingv1.AlertmanagerGlobalConfig{ + globalConfig: &monitoringv1.AlertmanagerGlobalConfig{ SlackAPIURL: &corev1.SecretKeySelector{ Key: "invalid_url", LocalObjectReference: corev1.LocalObjectReference{ @@ -305,14 +307,14 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, }, }, - matcherStrategy: monitoringingv1.AlertmanagerConfigMatcherStrategy{ + matcherStrategy: monitoringv1.AlertmanagerConfigMatcherStrategy{ Type: "OnNamespace", }, wantErr: true, }, { name: "global config with missing Slack API URL", - globalConfig: &monitoringingv1.AlertmanagerGlobalConfig{ + globalConfig: &monitoringv1.AlertmanagerGlobalConfig{ SlackAPIURL: &corev1.SecretKeySelector{ Key: "url", LocalObjectReference: corev1.LocalObjectReference{ @@ -341,14 +343,14 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, }, }, - matcherStrategy: monitoringingv1.AlertmanagerConfigMatcherStrategy{ + matcherStrategy: monitoringv1.AlertmanagerConfigMatcherStrategy{ Type: "OnNamespace", }, wantErr: true, }, { name: "valid global config with OpsGenie API URL", - globalConfig: &monitoringingv1.AlertmanagerGlobalConfig{ + globalConfig: &monitoringv1.AlertmanagerGlobalConfig{ OpsGenieAPIURL: &corev1.SecretKeySelector{ Key: "url", LocalObjectReference: corev1.LocalObjectReference{ @@ -380,7 +382,7 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, }, }, - matcherStrategy: monitoringingv1.AlertmanagerConfigMatcherStrategy{ + matcherStrategy: monitoringv1.AlertmanagerConfigMatcherStrategy{ Type: "OnNamespace", }, want: &alertmanagerConfig{ @@ -411,7 +413,7 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, { name: "global config with invalid OpsGenie API URL", - globalConfig: &monitoringingv1.AlertmanagerGlobalConfig{ + globalConfig: &monitoringv1.AlertmanagerGlobalConfig{ OpsGenieAPIURL: &corev1.SecretKeySelector{ Key: "invalid_url", LocalObjectReference: corev1.LocalObjectReference{ @@ -440,14 +442,14 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, }, }, - matcherStrategy: monitoringingv1.AlertmanagerConfigMatcherStrategy{ + matcherStrategy: monitoringv1.AlertmanagerConfigMatcherStrategy{ Type: "OnNamespace", }, wantErr: true, }, { name: "global config with missing OpsGenie API URL", - globalConfig: &monitoringingv1.AlertmanagerGlobalConfig{ + globalConfig: &monitoringv1.AlertmanagerGlobalConfig{ OpsGenieAPIURL: &corev1.SecretKeySelector{ Key: "url", LocalObjectReference: corev1.LocalObjectReference{ @@ -476,14 +478,14 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, }, }, - matcherStrategy: monitoringingv1.AlertmanagerConfigMatcherStrategy{ + matcherStrategy: monitoringv1.AlertmanagerConfigMatcherStrategy{ Type: "OnNamespace", }, wantErr: true, }, { name: "valid global config with OpsGenie API KEY", - globalConfig: &monitoringingv1.AlertmanagerGlobalConfig{ + globalConfig: &monitoringv1.AlertmanagerGlobalConfig{ OpsGenieAPIKey: &corev1.SecretKeySelector{ Key: "api_key", LocalObjectReference: corev1.LocalObjectReference{ @@ -515,7 +517,7 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, }, }, - matcherStrategy: monitoringingv1.AlertmanagerConfigMatcherStrategy{ + matcherStrategy: monitoringv1.AlertmanagerConfigMatcherStrategy{ Type: "OnNamespace", }, want: &alertmanagerConfig{ @@ -546,7 +548,7 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, { name: "global config with missing OpsGenie API KEY", - globalConfig: &monitoringingv1.AlertmanagerGlobalConfig{ + globalConfig: &monitoringv1.AlertmanagerGlobalConfig{ OpsGenieAPIKey: &corev1.SecretKeySelector{ Key: "api_key", LocalObjectReference: corev1.LocalObjectReference{ @@ -575,14 +577,14 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, }, }, - matcherStrategy: monitoringingv1.AlertmanagerConfigMatcherStrategy{ + matcherStrategy: monitoringv1.AlertmanagerConfigMatcherStrategy{ Type: "OnNamespace", }, wantErr: true, }, { name: "valid global config with Pagerduty URL", - globalConfig: &monitoringingv1.AlertmanagerGlobalConfig{ + globalConfig: &monitoringv1.AlertmanagerGlobalConfig{ PagerdutyURL: &pagerdutyURL, }, amConfig: &monitoringv1alpha1.AlertmanagerConfig{ @@ -609,7 +611,7 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, }, }, - matcherStrategy: monitoringingv1.AlertmanagerConfigMatcherStrategy{ + matcherStrategy: monitoringv1.AlertmanagerConfigMatcherStrategy{ Type: "OnNamespace", }, want: &alertmanagerConfig{ @@ -640,7 +642,7 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, { name: "global config with invalid Pagerduty URL", - globalConfig: &monitoringingv1.AlertmanagerGlobalConfig{ + globalConfig: &monitoringv1.AlertmanagerGlobalConfig{ PagerdutyURL: &invalidPagerdutyURL, }, amConfig: &monitoringv1alpha1.AlertmanagerConfig{ @@ -664,7 +666,7 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, }, }, - matcherStrategy: monitoringingv1.AlertmanagerConfigMatcherStrategy{ + matcherStrategy: monitoringv1.AlertmanagerConfigMatcherStrategy{ Type: "OnNamespace", }, wantErr: true, @@ -681,8 +683,8 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, { name: "globalConfig has null resolve timeout", - globalConfig: &monitoringingv1.AlertmanagerGlobalConfig{ - HTTPConfig: &monitoringingv1.HTTPConfig{ + globalConfig: &monitoringv1.AlertmanagerGlobalConfig{ + HTTPConfig: &monitoringv1.HTTPConfig{ FollowRedirects: ptr.To(true), }, }, @@ -702,7 +704,7 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, }, }, - matcherStrategy: monitoringingv1.AlertmanagerConfigMatcherStrategy{ + matcherStrategy: monitoringv1.AlertmanagerConfigMatcherStrategy{ Type: "OnNamespace", }, want: &alertmanagerConfig{ @@ -724,9 +726,9 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, { name: "globalConfig httpconfig/proxyconfig has null secretKey for proxyConnectHeader", - globalConfig: &monitoringingv1.AlertmanagerGlobalConfig{ - HTTPConfig: &monitoringingv1.HTTPConfig{ - ProxyConfig: monitoringingv1.ProxyConfig{ + globalConfig: &monitoringv1.AlertmanagerGlobalConfig{ + HTTPConfig: &monitoringv1.HTTPConfig{ + ProxyConfig: monitoringv1.ProxyConfig{ ProxyURL: ptr.To("http://example.com"), NoProxy: ptr.To("svc.cluster.local"), ProxyConnectHeader: map[string][]corev1.SecretKeySelector{ @@ -759,7 +761,7 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, }, }, - matcherStrategy: monitoringingv1.AlertmanagerConfigMatcherStrategy{ + matcherStrategy: monitoringv1.AlertmanagerConfigMatcherStrategy{ Type: "OnNamespace", }, wantErr: true, @@ -767,9 +769,9 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { { name: "valid globalConfig httpconfig/proxyconfig/proxyConnectHeader with amVersion24", amVersion: &version24, - globalConfig: &monitoringingv1.AlertmanagerGlobalConfig{ - HTTPConfig: &monitoringingv1.HTTPConfig{ - ProxyConfig: monitoringingv1.ProxyConfig{ + globalConfig: &monitoringv1.AlertmanagerGlobalConfig{ + HTTPConfig: &monitoringv1.HTTPConfig{ + ProxyConfig: monitoringv1.ProxyConfig{ ProxyURL: ptr.To("http://example.com"), NoProxy: ptr.To("svc.cluster.local"), ProxyConnectHeader: map[string][]corev1.SecretKeySelector{ @@ -802,7 +804,7 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, }, }, - matcherStrategy: monitoringingv1.AlertmanagerConfigMatcherStrategy{ + matcherStrategy: monitoringv1.AlertmanagerConfigMatcherStrategy{ Type: "OnNamespace", }, want: &alertmanagerConfig{ @@ -831,9 +833,9 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { { name: "valid globalConfig httpconfig/proxyconfig/proxyConnectHeader with amVersion26", amVersion: &version26, - globalConfig: &monitoringingv1.AlertmanagerGlobalConfig{ - HTTPConfig: &monitoringingv1.HTTPConfig{ - ProxyConfig: monitoringingv1.ProxyConfig{ + globalConfig: &monitoringv1.AlertmanagerGlobalConfig{ + HTTPConfig: &monitoringv1.HTTPConfig{ + ProxyConfig: monitoringv1.ProxyConfig{ ProxyURL: ptr.To("http://example.com"), NoProxy: ptr.To("svc.cluster.local"), ProxyConnectHeader: map[string][]corev1.SecretKeySelector{ @@ -866,7 +868,7 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, }, }, - matcherStrategy: monitoringingv1.AlertmanagerConfigMatcherStrategy{ + matcherStrategy: monitoringv1.AlertmanagerConfigMatcherStrategy{ Type: "OnNamespace", }, want: &alertmanagerConfig{ @@ -917,7 +919,7 @@ func TestInitializeFromAlertmanagerConfig(t *testing.T) { }, }, }, - matcherStrategy: monitoringingv1.AlertmanagerConfigMatcherStrategy{ + matcherStrategy: monitoringv1.AlertmanagerConfigMatcherStrategy{ Type: "OnNamespace", }, wantErr: true, @@ -1014,7 +1016,7 @@ func TestGenerateConfig(t *testing.T) { kclient kubernetes.Interface baseConfig alertmanagerConfig amVersion *semver.Version - matcherStrategy monitoringingv1.AlertmanagerConfigMatcherStrategy + matcherStrategy monitoringv1.AlertmanagerConfigMatcherStrategy amConfigs map[string]*monitoringv1alpha1.AlertmanagerConfig golden string } @@ -1359,7 +1361,7 @@ func TestGenerateConfig(t *testing.T) { Route: &route{Receiver: "null"}, Receivers: []*receiver{{Name: "null"}}, }, - matcherStrategy: monitoringingv1.AlertmanagerConfigMatcherStrategy{ + matcherStrategy: monitoringv1.AlertmanagerConfigMatcherStrategy{ Type: "None", }, amConfigs: map[string]*monitoringv1alpha1.AlertmanagerConfig{ @@ -1621,8 +1623,8 @@ func TestGenerateConfig(t *testing.T) { WebhookConfigs: []monitoringv1alpha1.WebhookConfig{{ URL: ptr.To("http://test.url"), HTTPConfig: &monitoringv1alpha1.HTTPConfig{ - OAuth2: &monitoringingv1.OAuth2{ - ClientID: monitoringingv1.SecretOrConfigMap{ + OAuth2: &monitoringv1.OAuth2{ + ClientID: monitoringv1.SecretOrConfigMap{ ConfigMap: &corev1.ConfigMapKeySelector{ LocalObjectReference: corev1.LocalObjectReference{ Name: "webhook-client-id", @@ -1973,7 +1975,7 @@ func TestGenerateConfig(t *testing.T) { SNSConfigs: []monitoringv1alpha1.SNSConfig{ { ApiURL: "https://sns.us-east-2.amazonaws.com", - Sigv4: &monitoringingv1.Sigv4{ + Sigv4: &monitoringv1.Sigv4{ Region: "us-east-2", AccessKey: &corev1.SecretKeySelector{ LocalObjectReference: corev1.LocalObjectReference{ @@ -2032,7 +2034,7 @@ func TestGenerateConfig(t *testing.T) { SNSConfigs: []monitoringv1alpha1.SNSConfig{ { ApiURL: "https://sns.us-east-2.amazonaws.com", - Sigv4: &monitoringingv1.Sigv4{ + Sigv4: &monitoringv1.Sigv4{ Region: "us-east-2", RoleArn: "test-roleARN", }, @@ -4555,6 +4557,92 @@ func TestLoadConfig(t *testing.T) { } } +func TestConvertHTTPConfig(t *testing.T) { + for _, tc := range []struct { + name string + cfg monitoringv1alpha1.HTTPConfig + + exp *httpClientConfig + }{ + { + name: "no proxy", + cfg: monitoringv1alpha1.HTTPConfig{}, + exp: &httpClientConfig{}, + }, + { + name: "proxyURL only", + cfg: monitoringv1alpha1.HTTPConfig{ + ProxyURLOriginal: ptr.To("http://example.com"), + }, + exp: &httpClientConfig{ + proxyConfig: proxyConfig{ + ProxyURL: "http://example.com", + }, + }, + }, + { + name: "proxyUrl only", + cfg: monitoringv1alpha1.HTTPConfig{ + ProxyConfig: monitoringv1.ProxyConfig{ + ProxyURL: ptr.To("http://example.com"), + }, + }, + exp: &httpClientConfig{ + proxyConfig: proxyConfig{ + ProxyURL: "http://example.com", + }, + }, + }, + { + name: "proxyUrl and proxyURL", + cfg: monitoringv1alpha1.HTTPConfig{ + ProxyURLOriginal: ptr.To("http://example.com"), + ProxyConfig: monitoringv1.ProxyConfig{ + ProxyURL: ptr.To("http://bad.example.com"), + }, + }, + exp: &httpClientConfig{ + proxyConfig: proxyConfig{ + ProxyURL: "http://example.com", + }, + }, + }, + { + name: "proxyUrl and empty proxyURL", + cfg: monitoringv1alpha1.HTTPConfig{ + ProxyURLOriginal: ptr.To(""), + ProxyConfig: monitoringv1.ProxyConfig{ + ProxyURL: ptr.To("http://example.com"), + }, + }, + exp: &httpClientConfig{ + proxyConfig: proxyConfig{ + ProxyURL: "http://example.com", + }, + }, + }, + } { + t.Run(tc.name, func(t *testing.T) { + v, err := semver.ParseTolerant(operator.DefaultAlertmanagerVersion) + require.NoError(t, err) + + cb := newConfigBuilder( + newNopLogger(t), + v, + nil, + monitoringv1.AlertmanagerConfigMatcherStrategy{ + Type: monitoringv1.OnNamespaceConfigMatcherStrategyType, + }, + ) + + cfg, err := cb.convertHTTPConfig(context.Background(), &tc.cfg, types.NamespacedName{}) + require.NoError(t, err) + + require.Equal(t, tc.exp, cfg) + }) + } +} + func parseURL(t *testing.T, u string) *config.URL { t.Helper() url, err := url.Parse(u) diff --git a/pkg/apis/monitoring/v1/alertmanager_types.go b/pkg/apis/monitoring/v1/alertmanager_types.go index ebd369d33ea..a3e99d5851f 100644 --- a/pkg/apis/monitoring/v1/alertmanager_types.go +++ b/pkg/apis/monitoring/v1/alertmanager_types.go @@ -473,8 +473,9 @@ type HTTPConfig struct { // TLS configuration for the client. // +optional TLSConfig *SafeTLSConfig `json:"tlsConfig,omitempty"` - // +optional + ProxyConfig `json:",inline"` + // FollowRedirects specifies whether the client should follow HTTP 3xx redirects. // +optional FollowRedirects *bool `json:"followRedirects,omitempty"` diff --git a/pkg/apis/monitoring/v1alpha1/alertmanager_config_types.go b/pkg/apis/monitoring/v1alpha1/alertmanager_config_types.go index f5cfb00d357..68291372cf9 100644 --- a/pkg/apis/monitoring/v1alpha1/alertmanager_config_types.go +++ b/pkg/apis/monitoring/v1alpha1/alertmanager_config_types.go @@ -621,8 +621,17 @@ type HTTPConfig struct { BearerTokenSecret *v1.SecretKeySelector `json:"bearerTokenSecret,omitempty"` // TLS configuration for the client. // +optional - TLSConfig *monitoringv1.SafeTLSConfig `json:"tlsConfig,omitempty"` + TLSConfig *monitoringv1.SafeTLSConfig `json:"tlsConfig,omitempty"` + + // Optional proxy URL. + // + // If defined, this field takes precedence over `proxyUrl`. + // + // +optional + ProxyURLOriginal *string `json:"proxyURL,omitempty"` + monitoringv1.ProxyConfig `json:",inline"` + // FollowRedirects specifies whether the client should follow HTTP 3xx redirects. // +optional FollowRedirects *bool `json:"followRedirects,omitempty"` diff --git a/pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go index 06fef77d731..c5ac6c1c571 100644 --- a/pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go @@ -865,6 +865,11 @@ func (in *HTTPConfig) DeepCopyInto(out *HTTPConfig) { *out = new(monitoringv1.SafeTLSConfig) (*in).DeepCopyInto(*out) } + if in.ProxyURLOriginal != nil { + in, out := &in.ProxyURLOriginal, &out.ProxyURLOriginal + *out = new(string) + **out = **in + } in.ProxyConfig.DeepCopyInto(&out.ProxyConfig) if in.FollowRedirects != nil { in, out := &in.FollowRedirects, &out.FollowRedirects diff --git a/pkg/apis/monitoring/v1beta1/alertmanager_config_types.go b/pkg/apis/monitoring/v1beta1/alertmanager_config_types.go index 9077645686f..201b99c76e7 100644 --- a/pkg/apis/monitoring/v1beta1/alertmanager_config_types.go +++ b/pkg/apis/monitoring/v1beta1/alertmanager_config_types.go @@ -614,8 +614,17 @@ type HTTPConfig struct { BearerTokenSecret *SecretKeySelector `json:"bearerTokenSecret,omitempty"` // TLS configuration for the client. // +optional - TLSConfig *monitoringv1.SafeTLSConfig `json:"tlsConfig,omitempty"` + TLSConfig *monitoringv1.SafeTLSConfig `json:"tlsConfig,omitempty"` + + // Optional proxy URL. + // + // If defined, this field takes precedence over `proxyUrl`. + // + // +optional + ProxyURLOriginal *string `json:"proxyURL,omitempty"` + monitoringv1.ProxyConfig `json:",inline"` + // FollowRedirects specifies whether the client should follow HTTP 3xx redirects. // +optional FollowRedirects *bool `json:"followRedirects,omitempty"` diff --git a/pkg/apis/monitoring/v1beta1/conversion_from.go b/pkg/apis/monitoring/v1beta1/conversion_from.go index 677586d9d0a..6dfb984a07e 100644 --- a/pkg/apis/monitoring/v1beta1/conversion_from.go +++ b/pkg/apis/monitoring/v1beta1/conversion_from.go @@ -148,6 +148,7 @@ func convertHTTPConfigFrom(in *v1alpha1.HTTPConfig) *HTTPConfig { OAuth2: in.OAuth2, BearerTokenSecret: convertSecretKeySelectorFrom(in.BearerTokenSecret), TLSConfig: in.TLSConfig, + ProxyURLOriginal: in.ProxyURLOriginal, ProxyConfig: in.ProxyConfig, FollowRedirects: in.FollowRedirects, } diff --git a/pkg/apis/monitoring/v1beta1/conversion_to.go b/pkg/apis/monitoring/v1beta1/conversion_to.go index 264644ce888..de8c8251246 100644 --- a/pkg/apis/monitoring/v1beta1/conversion_to.go +++ b/pkg/apis/monitoring/v1beta1/conversion_to.go @@ -141,6 +141,7 @@ func convertHTTPConfigTo(in *HTTPConfig) *v1alpha1.HTTPConfig { OAuth2: in.OAuth2, BearerTokenSecret: convertSecretKeySelectorTo(in.BearerTokenSecret), TLSConfig: in.TLSConfig, + ProxyURLOriginal: in.ProxyURLOriginal, ProxyConfig: in.ProxyConfig, FollowRedirects: in.FollowRedirects, } diff --git a/pkg/apis/monitoring/v1beta1/zz_generated.deepcopy.go b/pkg/apis/monitoring/v1beta1/zz_generated.deepcopy.go index 9ce58cc73db..d88bde07e67 100644 --- a/pkg/apis/monitoring/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/monitoring/v1beta1/zz_generated.deepcopy.go @@ -244,6 +244,11 @@ func (in *HTTPConfig) DeepCopyInto(out *HTTPConfig) { *out = new(monitoringv1.SafeTLSConfig) (*in).DeepCopyInto(*out) } + if in.ProxyURLOriginal != nil { + in, out := &in.ProxyURLOriginal, &out.ProxyURLOriginal + *out = new(string) + **out = **in + } in.ProxyConfig.DeepCopyInto(&out.ProxyConfig) if in.FollowRedirects != nil { in, out := &in.FollowRedirects, &out.FollowRedirects diff --git a/pkg/client/applyconfiguration/monitoring/v1alpha1/httpconfig.go b/pkg/client/applyconfiguration/monitoring/v1alpha1/httpconfig.go index fe7d265b6bc..01a019ca991 100644 --- a/pkg/client/applyconfiguration/monitoring/v1alpha1/httpconfig.go +++ b/pkg/client/applyconfiguration/monitoring/v1alpha1/httpconfig.go @@ -29,6 +29,7 @@ type HTTPConfigApplyConfiguration struct { OAuth2 *v1.OAuth2ApplyConfiguration `json:"oauth2,omitempty"` BearerTokenSecret *corev1.SecretKeySelector `json:"bearerTokenSecret,omitempty"` TLSConfig *v1.SafeTLSConfigApplyConfiguration `json:"tlsConfig,omitempty"` + ProxyURLOriginal *string `json:"proxyURL,omitempty"` v1.ProxyConfigApplyConfiguration `json:",inline"` FollowRedirects *bool `json:"followRedirects,omitempty"` } @@ -79,6 +80,14 @@ func (b *HTTPConfigApplyConfiguration) WithTLSConfig(value *v1.SafeTLSConfigAppl return b } +// WithProxyURLOriginal sets the ProxyURLOriginal field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ProxyURLOriginal field is set to the value of the last call. +func (b *HTTPConfigApplyConfiguration) WithProxyURLOriginal(value string) *HTTPConfigApplyConfiguration { + b.ProxyURLOriginal = &value + return b +} + // WithProxyURL sets the ProxyURL field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the ProxyURL field is set to the value of the last call. diff --git a/pkg/client/applyconfiguration/monitoring/v1beta1/httpconfig.go b/pkg/client/applyconfiguration/monitoring/v1beta1/httpconfig.go index c3ac2cd2dfb..8a70cd3a4dd 100644 --- a/pkg/client/applyconfiguration/monitoring/v1beta1/httpconfig.go +++ b/pkg/client/applyconfiguration/monitoring/v1beta1/httpconfig.go @@ -29,6 +29,7 @@ type HTTPConfigApplyConfiguration struct { OAuth2 *v1.OAuth2ApplyConfiguration `json:"oauth2,omitempty"` BearerTokenSecret *SecretKeySelectorApplyConfiguration `json:"bearerTokenSecret,omitempty"` TLSConfig *v1.SafeTLSConfigApplyConfiguration `json:"tlsConfig,omitempty"` + ProxyURLOriginal *string `json:"proxyURL,omitempty"` v1.ProxyConfigApplyConfiguration `json:",inline"` FollowRedirects *bool `json:"followRedirects,omitempty"` } @@ -79,6 +80,14 @@ func (b *HTTPConfigApplyConfiguration) WithTLSConfig(value *v1.SafeTLSConfigAppl return b } +// WithProxyURLOriginal sets the ProxyURLOriginal field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ProxyURLOriginal field is set to the value of the last call. +func (b *HTTPConfigApplyConfiguration) WithProxyURLOriginal(value string) *HTTPConfigApplyConfiguration { + b.ProxyURLOriginal = &value + return b +} + // WithProxyURL sets the ProxyURL field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the ProxyURL field is set to the value of the last call.