Skip to content

Commit bc217dc

Browse files
committed
Remove deprecated proxy fields from Provider API
The spec.proxy field and 'proxy' key in secrets are no longer supported. These fields were deprecated in v2.7 with the introduction of spec.proxySecretRef as the recommended approach. Signed-off-by: cappyzawa <[email protected]>
1 parent ce1662c commit bc217dc

File tree

6 files changed

+5
-113
lines changed

6 files changed

+5
-113
lines changed

api/v1beta3/provider_types.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,6 @@ type ProviderSpec struct {
9898
// +optional
9999
Timeout *metav1.Duration `json:"timeout,omitempty"`
100100

101-
// Proxy the HTTP/S address of the proxy server.
102-
// Deprecated: Use ProxySecretRef instead. Will be removed in v1.
103-
// +kubebuilder:validation:Pattern="^(http|https)://.*$"
104-
// +kubebuilder:validation:MaxLength:=2048
105-
// +kubebuilder:validation:Optional
106-
// +optional
107-
Proxy string `json:"proxy,omitempty"`
108-
109101
// ProxySecretRef specifies the Secret containing the proxy configuration
110102
// for this Provider. The Secret should contain an 'address' key with the
111103
// HTTP/S address of the proxy server. Optional 'username' and 'password'

config/crd/bases/notification.toolkit.fluxcd.io_providers.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,6 @@ spec:
297297
Deprecated and not used in v1beta3.
298298
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$
299299
type: string
300-
proxy:
301-
description: |-
302-
Proxy the HTTP/S address of the proxy server.
303-
Deprecated: Use ProxySecretRef instead. Will be removed in v1.
304-
maxLength: 2048
305-
pattern: ^(http|https)://.*$
306-
type: string
307300
proxySecretRef:
308301
description: |-
309302
ProxySecretRef specifies the Secret containing the proxy configuration

docs/api/v1beta3/notification.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -323,19 +323,6 @@ Kubernetes meta/v1.Duration
323323
</tr>
324324
<tr>
325325
<td>
326-
<code>proxy</code><br>
327-
<em>
328-
string
329-
</em>
330-
</td>
331-
<td>
332-
<em>(Optional)</em>
333-
<p>Proxy the HTTP/S address of the proxy server.
334-
Deprecated: Use ProxySecretRef instead. Will be removed in v1.</p>
335-
</td>
336-
</tr>
337-
<tr>
338-
<td>
339326
<code>proxySecretRef</code><br>
340327
<em>
341328
<a href="https://pkg.go.dev/github.com/fluxcd/pkg/apis/meta#LocalObjectReference">
@@ -671,19 +658,6 @@ Kubernetes meta/v1.Duration
671658
</tr>
672659
<tr>
673660
<td>
674-
<code>proxy</code><br>
675-
<em>
676-
string
677-
</em>
678-
</td>
679-
<td>
680-
<em>(Optional)</em>
681-
<p>Proxy the HTTP/S address of the proxy server.
682-
Deprecated: Use ProxySecretRef instead. Will be removed in v1.</p>
683-
</td>
684-
</tr>
685-
<tr>
686-
<td>
687661
<code>proxySecretRef</code><br>
688662
<em>
689663
<a href="https://pkg.go.dev/github.com/fluxcd/pkg/apis/meta#LocalObjectReference">

docs/spec/v1beta3/providers.md

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,6 @@ credentials for the provider API.
12531253
The Kubernetes secret can have any of the following keys:
12541254

12551255
- `address` - overrides `.spec.address`
1256-
- `proxy` - overrides `.spec.proxy` (deprecated, use `.spec.proxySecretRef` instead. **Support for this key will be removed in v1**)
12571256
- `token` - used for authentication
12581257
- `username` - overrides `.spec.username`
12591258
- `password` - used for authentication, often in combination with `username` (or `.spec.username`)
@@ -1312,7 +1311,7 @@ stringData:
13121311
#### Proxy auth example
13131312

13141313
Some networks need to use an authenticated proxy to access external services.
1315-
The recommended approach is to use `.spec.proxySecretRef` with a dedicated Secret:
1314+
Use `.spec.proxySecretRef` with a dedicated Secret:
13161315

13171316
```yaml
13181317
---
@@ -1327,20 +1326,6 @@ stringData:
13271326
password: "proxy_password"
13281327
```
13291328

1330-
**Legacy approach (deprecated):**
1331-
The proxy address can also be stored in the main secret to hide parameters like the username and password:
1332-
1333-
```yaml
1334-
---
1335-
apiVersion: v1
1336-
kind: Secret
1337-
metadata:
1338-
name: my-provider-proxy-legacy
1339-
namespace: default
1340-
stringData:
1341-
proxy: "http://username:password@proxy_url:proxy_port"
1342-
```
1343-
13441329
### Certificate secret reference
13451330

13461331
`.spec.certSecretRef` is an optional field to specify a name reference to a
@@ -1466,19 +1451,11 @@ the controller will log a deprecation warning.
14661451

14671452
### HTTP/S proxy
14681453

1469-
`.spec.proxy` is an optional field to specify an HTTP/S proxy address.
1470-
**Warning:** This field is deprecated, use `.spec.proxySecretRef` instead. **Support for this field will be removed in v1.**
1471-
14721454
`.spec.proxySecretRef` is an optional field to specify a name reference to a
14731455
Secret in the same namespace as the Provider, containing the proxy configuration.
14741456
The Secret should contain an `address` key with the HTTP/S address of the proxy server.
14751457
Optional `username` and `password` keys can be provided for proxy authentication.
14761458

1477-
If the proxy address contains sensitive information such as basic auth credentials, it is
1478-
recommended to use `.spec.proxySecretRef` instead of `.spec.proxy`.
1479-
When `.spec.proxySecretRef` is specified, both `.spec.proxy` and the `proxy` key from
1480-
`.spec.secretRef` are ignored.
1481-
14821459
### Timeout
14831460

14841461
`.spec.timeout` is an optional field to specify the timeout for the

internal/server/event_handlers.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"errors"
2323
"fmt"
2424
"net/http"
25-
"net/url"
2625
"regexp"
2726
"slices"
2827
"strings"
@@ -317,13 +316,10 @@ func extractAuthFromSecret(ctx context.Context, secret *corev1.Secret) ([]notifi
317316
}
318317
}
319318

320-
if val, ok := secret.Data["proxy"]; ok {
321-
deprecatedProxy := strings.TrimSpace(string(val))
322-
if _, err := url.Parse(deprecatedProxy); err != nil {
323-
return nil, nil, fmt.Errorf("invalid 'proxy' in secret '%s/%s'", secret.Namespace, secret.Name)
324-
}
325-
log.FromContext(ctx).Error(nil, "warning: specifying proxy with 'proxy' key in the referenced secret is deprecated, use spec.proxySecretRef with 'address' key instead. Support for the 'proxy' key will be removed in v1.")
326-
options = append(options, notifier.WithProxyURL(deprecatedProxy))
319+
if _, ok := secret.Data["proxy"]; ok {
320+
err := errors.New("specifying proxy with 'proxy' key in the referenced secret is deprecated, use spec.proxySecretRef with 'address' key instead. Support for the 'proxy' key is removed in v1")
321+
log.FromContext(ctx).Error(err, "no longer supported.")
322+
return nil, nil, err
327323
}
328324

329325
if h, ok := secret.Data["headers"]; ok {
@@ -380,12 +376,6 @@ func createNotifier(ctx context.Context, kubeClient client.Client, provider *api
380376
options = append(options, notifier.WithTokenCache(tokenCache))
381377
}
382378

383-
// TODO: Remove deprecated proxy handling when Provider v1 is released.
384-
if provider.Spec.Proxy != "" {
385-
log.FromContext(ctx).Error(nil, "warning: spec.proxy is deprecated, please use spec.proxySecretRef instead. Support for this field will be removed in v1.")
386-
options = append(options, notifier.WithProxyURL(provider.Spec.Proxy))
387-
}
388-
389379
webhook := provider.Spec.Address
390380
var token string
391381
var secretData map[string][]byte

internal/server/event_handlers_test.go

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@ func TestCreateNotifier(t *testing.T) {
600600
},
601601
wantErr: true,
602602
},
603-
// TODO: Remove deprecated secret proxy key tests when Provider v1 is released.
604603
{
605604
name: "reference to secret with valid address, proxy, headers",
606605
providerSpec: &apiv1beta3.ProviderSpec{
@@ -612,17 +611,6 @@ func TestCreateNotifier(t *testing.T) {
612611
"proxy": []byte("https://exampleproxy.com"),
613612
"headers": []byte(`foo: bar`),
614613
},
615-
},
616-
{
617-
name: "reference to secret with invalid proxy",
618-
providerSpec: &apiv1beta3.ProviderSpec{
619-
Type: "slack",
620-
SecretRef: &meta.LocalObjectReference{Name: secretName},
621-
},
622-
secretData: map[string][]byte{
623-
"address": []byte("https://example.com"),
624-
"proxy": []byte("https://exampleproxy.com|"),
625-
},
626614
wantErr: true,
627615
},
628616
{
@@ -648,19 +636,6 @@ func TestCreateNotifier(t *testing.T) {
648636
"address": []byte("https://example.com"),
649637
},
650638
},
651-
// TODO: Remove deprecated spec.proxy field tests when Provider v1 is released.
652-
{
653-
name: "invalid spec proxy overridden by valid secret ref proxy",
654-
providerSpec: &apiv1beta3.ProviderSpec{
655-
Type: "slack",
656-
SecretRef: &meta.LocalObjectReference{Name: secretName},
657-
Proxy: "https://example.com|",
658-
},
659-
secretData: map[string][]byte{
660-
"address": []byte("https://example.com"),
661-
"proxy": []byte("https://example.com"),
662-
},
663-
},
664639
{
665640
name: "reference to unsupported cert secret type",
666641
providerSpec: &apiv1beta3.ProviderSpec{
@@ -870,15 +845,6 @@ Wf86aX6PepsntZv2GYlA5UpabfT2EZICICpJ5h/iI+i341gBmLiAFQOyTDT+/wQc
870845
},
871846
wantErr: true,
872847
},
873-
// TODO: Remove deprecated spec.proxy field tests when Provider v1 is released.
874-
{
875-
name: "deprecated spec.proxy field",
876-
providerSpec: &apiv1beta3.ProviderSpec{
877-
Type: "generic",
878-
Address: "https://example.com",
879-
Proxy: "http://proxy.example.com:8080",
880-
},
881-
},
882848
{
883849
name: "provider type that does not require address field",
884850
providerSpec: &apiv1beta3.ProviderSpec{

0 commit comments

Comments
 (0)