Skip to content

Commit 1e7b964

Browse files
committed
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 9ae35e9 commit 1e7b964

File tree

6 files changed

+47
-9
lines changed

6 files changed

+47
-9
lines changed

api/v1beta2/helmrepository_types.go

+5
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

@@ -91,6 +92,10 @@ type HelmRepositorySpec struct {
9192
// +required
9293
Interval metav1.Duration `json:"interval"`
9394

95+
// Insecure allows connecting to a non-TLS HTTP container registry.
96+
// +optional
97+
Insecure bool `json:"insecure,omitempty"`
98+
9499
// Timeout is used for the index fetch operation for an HTTPS helm repository,
95100
// and for remote OCI Repository operations like pulling for an OCI helm repository.
96101
// Its default value is 60s.

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

+4
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ spec:
313313
required:
314314
- name
315315
type: object
316+
insecure:
317+
description: Insecure allows connecting to a non-TLS HTTP container
318+
registry.
319+
type: boolean
316320
interval:
317321
description: Interval at which the HelmRepository URL is checked for
318322
updates. This interval is approximate and may be subject to jitter

docs/api/v1beta2/source.md

+24
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,18 @@ efficient use of resources.</p>
873873
</tr>
874874
<tr>
875875
<td>
876+
<code>insecure</code><br>
877+
<em>
878+
bool
879+
</em>
880+
</td>
881+
<td>
882+
<em>(Optional)</em>
883+
<p>Insecure allows connecting to a non-TLS HTTP container registry.</p>
884+
</td>
885+
</tr>
886+
<tr>
887+
<td>
876888
<code>timeout</code><br>
877889
<em>
878890
<a href="https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#Duration">
@@ -2590,6 +2602,18 @@ efficient use of resources.</p>
25902602
</tr>
25912603
<tr>
25922604
<td>
2605+
<code>insecure</code><br>
2606+
<em>
2607+
bool
2608+
</em>
2609+
</td>
2610+
<td>
2611+
<em>(Optional)</em>
2612+
<p>Insecure allows connecting to a non-TLS HTTP container registry.</p>
2613+
</td>
2614+
</tr>
2615+
<tr>
2616+
<td>
25932617
<code>timeout</code><br>
25942618
<em>
25952619
<a href="https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#Duration">

docs/spec/v1beta2/helmrepositories.md

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

161-
162161
### Type
163162

164163
`.spec.type` is an optional field that specifies the Helm repository type.
165164

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

168-
169167
### Provider
170168

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

359+
### Insecure
360+
361+
`.spec.insecure` is an optional field to allow connecting to an insecure (HTTP)
362+
container registry server, if set to `true`. The default value is `false`,
363+
denying insecure non-TLS connections when fetching Helm chart OCI artifacts.
364+
361365
### Interval
362366

363367
`.spec.interval` is a required field that specifies the interval which the
@@ -426,8 +430,8 @@ metadata:
426430
name: example-user
427431
namespace: default
428432
stringData:
429-
username: example
430-
password: 123456
433+
username: "user-123456"
434+
password: "pass-123456"
431435
```
432436

433437
OCI Helm repository example:
@@ -452,8 +456,8 @@ metadata:
452456
name: oci-creds
453457
namespace: default
454458
stringData:
455-
username: example
456-
password: 123456
459+
username: "user-123456"
460+
password: "pass-123456"
457461
```
458462

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

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

475479
### 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.Spec.Timeout.Duration),
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)