Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/controllers/chart/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,10 @@ func job(chart *v1.HelmChart, apiServerPort string) (*batch.Job, *corev1.Secret,
Name: "klipper-config",
MountPath: "/home/klipper-helm/.config",
},
{
Name: "tmp",
MountPath: "/tmp",
},
},
},
},
Expand Down Expand Up @@ -506,6 +510,14 @@ func job(chart *v1.HelmChart, apiServerPort string) (*batch.Job, *corev1.Secret,
},
},
},
{
Name: "tmp",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{
Medium: "Memory",
},
},
},
},
},
},
Expand Down
25 changes: 25 additions & 0 deletions test/framework/framework.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package framework

import (
"bytes"
"context"
"encoding/base64"
"fmt"
"io"
"net/http"
"os"
"time"

Expand Down Expand Up @@ -211,3 +214,25 @@ func (f *Framework) GetJob(chart *v1.HelmChart) (*batchv1.Job, error) {
}
return f.ClientSet.BatchV1().Jobs(chart.Namespace).Get(context.TODO(), chart.Status.JobName, metav1.GetOptions{})
}

// GetChartContent returns the base64-encoded chart tarball,
// downloaded from the specified URL.
func (f *Framework) GetChartContent(url string) (string, error) {
resp, err := http.Get(url)
if err != nil {
return "", err
}
if resp.StatusCode != 200 {
return "", fmt.Errorf("unexpected HTTP response: %s", resp.Status)
}

b := &bytes.Buffer{}
w := base64.NewEncoder(base64.StdEncoding, b)
if _, err := io.Copy(w, resp.Body); err != nil {
return "", err
}
if err := w.Close(); err != nil {
return "", err
}
return string(b.Bytes()), nil
}
46 changes: 46 additions & 0 deletions test/suite/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,52 @@ var _ = Describe("Helm Tests", Ordered, func() {

})

Context("When a helm V3 chart specifies ChartContent", func() {
var (
err error
chart *v1.HelmChart
pods []corev1.Pod
)
BeforeEach(func() {
chart = framework.NewHelmChart("traefik-example-chartcontent",
"",
"1.86.1",
"v3",
"metrics:\n prometheus:\n enabled: true\nkubernetes:\n ingressEndpoint:\n useDefaultPublishedService: true\nimage: docker.io/rancher/library-traefik\n",
map[string]intstr.IntOrString{
"rbac.enabled": {
Type: intstr.String,
StrVal: "true",
},
"ssl.enabled": {
Type: intstr.String,
StrVal: "true",
},
})
chart.Spec.ChartContent, err = framework.GetChartContent("https://charts.helm.sh/stable/packages/traefik-1.86.1.tgz")
Expect(err).ToNot(HaveOccurred())

chart, err = framework.CreateHelmChart(chart, framework.Namespace)
Expect(err).ToNot(HaveOccurred())

pods, err = framework.WaitForChartApp(chart, "traefik", 120*time.Second, 1)
Expect(err).ToNot(HaveOccurred())
})
It("Should install the release successfully", func() {
Expect(len(pods)).To(BeEquivalentTo(1))
})
AfterEach(func() {
err = framework.DeleteHelmChart(chart.Name, framework.Namespace)
Expect(err).ToNot(HaveOccurred())

Eventually(func() bool {
_, err := framework.GetHelmChart(chart.Name, framework.Namespace)
return err != nil && apierrors.IsNotFound(err)
}, 120*time.Second, 5*time.Second).Should(BeTrue())
})

})

Context("When a helm V3 chart creates a namespace", func() {
var (
err error
Expand Down