Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow TLS to pull chart from OCI repository #804

Merged
merged 4 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 0 additions & 1 deletion cmd/mindthegap/create/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ func pullCharts(
repoConfig.RepoURL,
chartName,
chartVersion,
[]helm.ConfigOpt{helm.RegistryClientConfigOpt()},
opts...,
)
if err != nil {
Expand Down
26 changes: 3 additions & 23 deletions helm/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,38 +99,18 @@ func CAFileOpt(caFile string) action.PullOpt {
}
}

type ConfigOpt func(*action.Configuration) error

func RegistryClientConfigOpt(opts ...registry.ClientOption) ConfigOpt {
return func(cfg *action.Configuration) error {
cl, err := registry.NewClient(opts...)
if err != nil {
return fmt.Errorf("failed to create registry client: %w", err)
}

cfg.RegistryClient = cl

return nil
func CertFileOpt(certFile string) action.PullOpt {
jimmidyson marked this conversation as resolved.
Show resolved Hide resolved
return func(p *action.Pull) {
p.CertFile = certFile
}
}

func (c *Client) GetChartFromRepo(
outputDir, repoURL, chartName, chartVersion string,
configOpts []ConfigOpt,
extraPullOpts ...action.PullOpt,
) (string, error) {
cfg := &action.Configuration{Log: c.out.V(4).Infof}

if registry.IsOCI(chartName) {
configOpts = append([]ConfigOpt{RegistryClientConfigOpt()}, configOpts...)
}

for _, f := range configOpts {
if err := f(cfg); err != nil {
return "", fmt.Errorf("failed to configure helm client: %w", err)
}
}

pull := action.NewPullWithOpts(
append(
extraPullOpts,
Expand Down
1 change: 0 additions & 1 deletion test/e2e/helmbundle/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ func ValidateChartIsAvailable(
"",
fmt.Sprintf("%s://%s:%d/charts/%s", helm.OCIScheme, addr, port, chartName),
chartVersion,
[]helm.ConfigOpt{helm.RegistryClientConfigOpt()},
pullOpts...,
)
gomega.ExpectWithOffset(1, err).NotTo(gomega.HaveOccurred())
Expand Down
9 changes: 5 additions & 4 deletions test/e2e/helmbundle/serve_bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/mesosphere/mindthegap/test/e2e/helmbundle/helpers"
)

var _ = Describe("Serve Bundle", func() {
var _ = Describe("Serve Helm Bundle", func() {
var (
bundleFile string
cmd *cobra.Command
Expand Down Expand Up @@ -93,7 +93,7 @@ var _ = Describe("Serve Bundle", func() {
ipAddr := helpers.GetFirstNonLoopbackIP(GinkgoT())

tempCertDir := GinkgoT().TempDir()
_, _, certFile, keyFile := helpers.GenerateCertificateAndKeyWithIPSAN(
caCertFile, _, certFile, keyFile := helpers.GenerateCertificateAndKeyWithIPSAN(
GinkgoT(),
tempCertDir,
ipAddr,
Expand Down Expand Up @@ -126,8 +126,9 @@ var _ = Describe("Serve Bundle", func() {

helpers.WaitForTCPPort(GinkgoT(), ipAddr.String(), port)

// TODO Reenable once Helm supports custom CA certs and self-signed certs.
// helpers.ValidateChartIsAvailable(GinkgoT(), "127.0.0.1", port, "podinfo", "6.2.0", helm.CAFileOpt(caCertFile))
helpers.ValidateChartIsAvailable(GinkgoT(), ipAddr.String(), port, "podinfo", "6.2.0", helm.CAFileOpt(caCertFile), helm.CertFileOpt(certFile))

helpers.ValidateChartIsAvailable(GinkgoT(), ipAddr.String(), port, "node-feature-discovery", "0.15.2", helm.CAFileOpt(caCertFile), helm.CertFileOpt(certFile))
jimmidyson marked this conversation as resolved.
Show resolved Hide resolved

close(stopCh)

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/imagebundle/serve_bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/mesosphere/mindthegap/test/e2e/imagebundle/helpers"
)

var _ = Describe("Serve Bundle", func() {
var _ = Describe("Serve Image Bundle", func() {
var (
bundleFile string
cmd *cobra.Command
Expand Down
Loading