Skip to content

Commit 408f2d2

Browse files
committed
The Telepresence Helm chart could not be used as a chart dependency
The JSON schema validation implemented in Telepresence 2.22.0 had a defect: it rejected the `global` object. This object, a Helm-managed construct, facilitates the propagation of arbitrary configurations from a parent chart to its dependencies. Consequently, charts intended for dependency use must permit the presence of the `global` object. Closes #3833 Signed-off-by: Thomas Hallgren <[email protected]>
1 parent 77f7fe7 commit 408f2d2

File tree

5 files changed

+137
-0
lines changed

5 files changed

+137
-0
lines changed

CHANGELOG.yml

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ items:
2727
- version: 2.22.3
2828
date: (TBD)
2929
notes:
30+
- type: bugfix
31+
title: The Telepresence Helm chart could not be used as a dependency in another chart.
32+
body: >-
33+
The JSON schema validation implemented in Telepresence 2.22.0 had a defect: it rejected the `global` object.
34+
This object, a Helm-managed construct, facilitates the propagation of arbitrary configurations from a parent
35+
chart to its dependencies. Consequently, charts intended for dependency use must permit the presence of the
36+
`global` object.
37+
docs: https://github.com/telepresenceio/telepresence/issues/3833
3038
- type: bugfix
3139
title: Recreating namespaces was not possible when using a dynamically namespaced Traffic Manager
3240
body: >-

charts/telepresence-oss/values.schema.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ properties:
251251
items:
252252
$ref: "#/$defs/subject"
253253

254+
global:
255+
type: object
256+
additionalProperties: true
257+
254258
grpc:
255259
type: object
256260
additionalProperties: false

docs/release-notes.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
[comment]: # (Code generated by relnotesgen. DO NOT EDIT.)
33
# <img src="images/logo.png" height="64px"/> Telepresence Release Notes
44
## Version 2.22.3
5+
## <div style="display:flex;"><img src="images/bugfix.png" alt="bugfix" style="width:30px;height:fit-content;"/><div style="display:flex;margin-left:7px;">The Telepresence Helm chart could not be used as a dependency in another chart.</div></div>
6+
<div style="margin-left: 15px">
7+
8+
The JSON schema validation implemented in Telepresence 2.22.0 had a defect: it rejected the `global` object. This object, a Helm-managed construct, facilitates the propagation of arbitrary configurations from a parent chart to its dependencies. Consequently, charts intended for dependency use must permit the presence of the `global` object.
9+
</div>
10+
511
## <div style="display:flex;"><img src="images/bugfix.png" alt="bugfix" style="width:30px;height:fit-content;"/><div style="display:flex;margin-left:7px;">[Recreating namespaces was not possible when using a dynamically namespaced Traffic Manager](https://github.com/telepresenceio/telepresence/issues/3831)</div></div>
612
<div style="margin-left: 15px">
713

docs/release-notes.mdx

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ import { Note, Title, Body } from '@site/src/components/ReleaseNotes'
88

99
# Telepresence Release Notes
1010
## Version 2.22.3
11+
<Note>
12+
<Title type="bugfix">The Telepresence Helm chart could not be used as a dependency in another chart.</Title>
13+
<Body>
14+
The JSON schema validation implemented in Telepresence 2.22.0 had a defect: it rejected the `global` object. This object, a Helm-managed construct, facilitates the propagation of arbitrary configurations from a parent chart to its dependencies. Consequently, charts intended for dependency use must permit the presence of the `global` object.
15+
</Body>
16+
</Note>
1117
<Note>
1218
<Title type="bugfix" docs="https://github.com/telepresenceio/telepresence/issues/3831">Recreating namespaces was not possible when using a dynamically namespaced Traffic Manager</Title>
1319
<Body>

integration_test/install_test.go

+113
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package integration_test
22

33
import (
4+
"archive/tar"
5+
"compress/gzip"
46
"context"
57
"fmt"
8+
"io"
69
"os"
710
"path/filepath"
11+
"runtime"
812
"strings"
913
"time"
1014

@@ -330,3 +334,112 @@ func ensureTrafficManager(ctx context.Context, kc *k8s.Cluster) error {
330334
k8s.GetManagerNamespace(ctx),
331335
&helm.Request{Type: helm.Install})
332336
}
337+
338+
func unTgz(ctx context.Context, srcTgz, dstPath string) error {
339+
rd, err := os.Open(srcTgz)
340+
if err != nil {
341+
return err
342+
}
343+
defer rd.Close()
344+
345+
err = dos.MkdirAll(ctx, dstPath, 0o755)
346+
if err != nil {
347+
return err
348+
}
349+
350+
zrd, err := gzip.NewReader(rd)
351+
if err != nil {
352+
return err
353+
}
354+
src := tar.NewReader(zrd)
355+
for {
356+
header, err := src.Next()
357+
if err != nil {
358+
if err == io.EOF {
359+
break
360+
}
361+
return err
362+
}
363+
364+
dst := dstPath + "/" + header.Name
365+
mode := os.FileMode(header.Mode)
366+
switch header.Typeflag {
367+
case tar.TypeDir:
368+
err = dos.MkdirAll(ctx, dst, mode)
369+
if err != nil {
370+
return err
371+
}
372+
case tar.TypeReg:
373+
err = dos.MkdirAll(ctx, filepath.Dir(dst), 0o755)
374+
if err != nil {
375+
return err
376+
}
377+
w, err := dos.OpenFile(ctx, dst, os.O_CREATE|os.O_WRONLY, mode)
378+
if err != nil {
379+
return err
380+
}
381+
_, err = io.Copy(w, src)
382+
_ = w.Close()
383+
if err != nil {
384+
return err
385+
}
386+
default:
387+
return fmt.Errorf("unable to untar type : %c in file %s", header.Typeflag, header.Name)
388+
}
389+
}
390+
return nil
391+
}
392+
393+
func (is *installSuite) Test_HelmSubChart() {
394+
if runtime.GOOS == "windows" || !(is.ManagerVersion().EQ(version.Structured) && is.ClientVersion().EQ(version.Structured)) {
395+
is.T().Skip("Not part of compatibility tests. Need forward slashes in path, and PackageHelmChart assumes current version.")
396+
}
397+
ctx := is.Context()
398+
require := is.Require()
399+
400+
t := is.T()
401+
subChart, err := is.PackageHelmChart(ctx)
402+
require.NoError(err)
403+
404+
base := t.TempDir()
405+
require.NoError(unTgz(ctx, subChart, filepath.Join(base, "charts")))
406+
407+
chart := fmt.Sprintf(`apiVersion: v2
408+
dependencies:
409+
- name: telepresence-oss
410+
registry: ../charts/telepresence-oss
411+
version: %s
412+
condition: enabled
413+
description: Helm chart to deploy telepresence
414+
name: parent
415+
version: 1.0.0`, is.ClientVersion())
416+
417+
vals := is.GetSetArgsForHelm(ctx, map[string]any{
418+
"global": map[string]any{
419+
"some-string": "value",
420+
"some-obj": map[string]any{
421+
"foo": "bar",
422+
},
423+
"some-bool": true,
424+
},
425+
"telepresence-oss": map[string]any{
426+
"clientRbac": map[string]any{
427+
"create": true,
428+
"subjects": []rbac.Subject{
429+
{
430+
Kind: "ServiceAccount",
431+
Name: itest.TestUser,
432+
Namespace: is.ManagerNamespace(),
433+
},
434+
},
435+
},
436+
},
437+
}, false)
438+
require.NoError(dos.WriteFile(ctx, filepath.Join(base, "Chart.yaml"), []byte(chart), 0o644))
439+
440+
vals = append([]string{"template", "parent", base, "-n", is.ManagerNamespace()}, vals...)
441+
so, err := itest.Output(ctx, "helm", vals...)
442+
require.NoError(err)
443+
require.Contains(so, "# Source: parent/charts/telepresence-oss/templates/clientRbac/connect.yaml")
444+
require.Contains(so, "name: "+itest.TestUser)
445+
}

0 commit comments

Comments
 (0)