Skip to content

Commit 6e78779

Browse files
stefanprodanaryan9600
authored andcommitted
Add .spec.insecure to HelmRepository
Allow connecting to Helm OCI repositories over plain HTTP (non-TLS endpoint). Signed-off-by: Stefan Prodan <[email protected]>
1 parent 936cfd6 commit 6e78779

File tree

6 files changed

+54
-9
lines changed

6 files changed

+54
-9
lines changed

api/v1beta2/helmrepository_types.go

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"github.com/fluxcd/pkg/apis/acl"
2525
"github.com/fluxcd/pkg/apis/meta"
26+
2627
apiv1 "github.com/fluxcd/source-controller/api/v1"
2728
)
2829

@@ -92,6 +93,11 @@ type HelmRepositorySpec struct {
9293
// +optional
9394
Interval metav1.Duration `json:"interval,omitempty"`
9495

96+
// Insecure allows connecting to a non-TLS HTTP container registry.
97+
// This field is only taken into account if the .spec.type field is set to 'oci'.
98+
// +optional
99+
Insecure bool `json:"insecure,omitempty"`
100+
95101
// Timeout is used for the index fetch operation for an HTTPS helm repository,
96102
// and for remote OCI Repository operations like pulling for an OCI helm
97103
// chart by the associated HelmChart.

config/crd/bases/source.toolkit.fluxcd.io_helmrepositories.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,11 @@ spec:
313313
required:
314314
- name
315315
type: object
316+
insecure:
317+
description: Insecure allows connecting to a non-TLS HTTP container
318+
registry. This field is only taken into account if the .spec.type
319+
field is set to 'oci'.
320+
type: boolean
316321
interval:
317322
description: Interval at which the HelmRepository URL is checked for
318323
updates. This interval is approximate and may be subject to jitter

docs/api/v1beta2/source.md

+26
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,19 @@ efficient use of resources.</p>
874874
</tr>
875875
<tr>
876876
<td>
877+
<code>insecure</code><br>
878+
<em>
879+
bool
880+
</em>
881+
</td>
882+
<td>
883+
<em>(Optional)</em>
884+
<p>Insecure allows connecting to a non-TLS HTTP container registry.
885+
This field is only taken into account if the .spec.type field is set to &lsquo;oci&rsquo;.</p>
886+
</td>
887+
</tr>
888+
<tr>
889+
<td>
877890
<code>timeout</code><br>
878891
<em>
879892
<a href="https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#Duration">
@@ -2593,6 +2606,19 @@ efficient use of resources.</p>
25932606
</tr>
25942607
<tr>
25952608
<td>
2609+
<code>insecure</code><br>
2610+
<em>
2611+
bool
2612+
</em>
2613+
</td>
2614+
<td>
2615+
<em>(Optional)</em>
2616+
<p>Insecure allows connecting to a non-TLS HTTP container registry.
2617+
This field is only taken into account if the .spec.type field is set to &lsquo;oci&rsquo;.</p>
2618+
</td>
2619+
</tr>
2620+
<tr>
2621+
<td>
25962622
<code>timeout</code><br>
25972623
<em>
25982624
<a href="https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#Duration">

docs/spec/v1beta2/helmrepositories.md

+14-7
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,12 @@ valid [DNS subdomain name](https://kubernetes.io/docs/concepts/overview/working-
147147
A HelmRepository also needs a
148148
[`.spec` section](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status).
149149

150-
151150
### Type
152151

153152
`.spec.type` is an optional field that specifies the Helm repository type.
154153

155154
Possible values are `default` for a Helm HTTP/S repository, or `oci` for an OCI Helm repository.
156155

157-
158156
### Provider
159157

160158
`.spec.provider` is an optional field that allows specifying an OIDC provider used
@@ -347,6 +345,15 @@ the needed permission is instead `storage.objects.list` which can be bound as pa
347345
of the Container Registry Service Agent role. Take a look at [this guide](https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity)
348346
for more information about setting up GKE Workload Identity.
349347

348+
### Insecure
349+
350+
`.spec.insecure` is an optional field to allow connecting to an insecure (HTTP)
351+
container registry server, if set to `true`. The default value is `false`,
352+
denying insecure non-TLS connections when fetching Helm chart OCI artifacts.
353+
354+
**Note**: The insecure field is supported only for Helm OCI repositories.
355+
The `spec.type` field must be set to `oci`.
356+
350357
### Interval
351358

352359
**Note:** This field is ineffectual for [OCI Helm
@@ -422,8 +429,8 @@ metadata:
422429
name: example-user
423430
namespace: default
424431
stringData:
425-
username: example
426-
password: 123456
432+
username: "user-123456"
433+
password: "pass-123456"
427434
```
428435

429436
OCI Helm repository example:
@@ -448,8 +455,8 @@ metadata:
448455
name: oci-creds
449456
namespace: default
450457
stringData:
451-
username: example
452-
password: 123456
458+
username: "user-123456"
459+
password: "pass-123456"
453460
```
454461

455462
For OCI Helm repositories, Kubernetes secrets of type [kubernetes.io/dockerconfigjson](https://kubernetes.io/docs/concepts/configuration/secret/#secret-types) are also supported.
@@ -465,7 +472,7 @@ flux create secret oci ghcr-auth \
465472

466473
**Warning:** Support for specifying TLS authentication data using this API has been
467474
deprecated. Please use [`.spec.certSecretRef`](#cert-secret-reference) instead.
468-
If the controller uses the secret specfied by this field to configure TLS, then
475+
If the controller uses the secret specified by this field to configure TLS, then
469476
a deprecation warning will be logged.
470477

471478
### Cert secret reference

internal/helm/getter/client_opts.go

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func GetClientOpts(ctx context.Context, c client.Client, obj *helmv1.HelmReposit
7474
helmgetter.WithURL(url),
7575
helmgetter.WithTimeout(obj.GetTimeout()),
7676
helmgetter.WithPassCredentialsAll(obj.Spec.PassCredentials),
77+
helmgetter.WithPlainHTTP(obj.Spec.Insecure),
7778
},
7879
}
7980
ociRepo := obj.Spec.Type == helmv1.HelmRepositoryTypeOCI

internal/helm/getter/client_opts_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestGetClientOpts(t *testing.T) {
6868
},
6969
afterFunc: func(t *WithT, hcOpts *ClientOpts) {
7070
t.Expect(hcOpts.TlsConfig).ToNot(BeNil())
71-
t.Expect(len(hcOpts.GetterOpts)).To(Equal(4))
71+
t.Expect(len(hcOpts.GetterOpts)).To(Equal(5))
7272
},
7373
},
7474
{
@@ -85,7 +85,7 @@ func TestGetClientOpts(t *testing.T) {
8585
},
8686
afterFunc: func(t *WithT, hcOpts *ClientOpts) {
8787
t.Expect(hcOpts.TlsConfig).ToNot(BeNil())
88-
t.Expect(len(hcOpts.GetterOpts)).To(Equal(4))
88+
t.Expect(len(hcOpts.GetterOpts)).To(Equal(5))
8989
},
9090
err: ErrDeprecatedTLSConfig,
9191
},

0 commit comments

Comments
 (0)