【问题标题】:Helm SDK download chart from extenanl repository来自 extenanl 存储库的 Helm SDK 下载图表
【发布时间】:2021-08-16 02:33:36
【问题描述】:

我需要下载位于外部 OCI 存储库的图表,当我使用单击图表和版本的链接下载它并提供用户和密码时,它可以工作但不能使用以下代码,这是我尝试并得到的一个错误

无法下载版本“1.0.0”的“https://fdr.cdn.repositories.amp/artifactory/control-1.0.0.tgz”(提示:运行helm repo update 可能会有所帮助) ,如果我点击上面的链接,它会询问用户并传递(在浏览器中),当我提供它时(在代码中相同),图表已下载,知道为什么代码不起作用?

这是我尝试过的

    package main

import (
    "fmt"
    "os"

    "helm.sh/helm/v3/pkg/action"
    "helm.sh/helm/v3/pkg/cli"
    "helm.sh/helm/v3/pkg/repo"
)

var config *cli.EnvSettings

func main() {
    config = cli.New()
    re := repo.Entry{
        Name:     "control",
        URL:      "https://fdr.cdn.repositories.amp/artifactory/control",
        Username:              "myuser",
        Password:              "mypass",
    }
    file, err := repo.LoadFile(config.RepositoryConfig)
    if err != nil {
        fmt.Println(err.Error())
    }
    file.Update(&re)
    file.WriteFile(config.RepositoryConfig, os.ModeAppend)

    co := action.ChartPathOptions{
        InsecureSkipTLSverify: false,
        RepoURL:               "https://fdr.cdn.repositories.amp/artifactory/control",
        Username:              "myuser",
        Password:              "mypass",
        Version:               "1.0.0",
    }

    fp, err := co.LocateChart("control", config)
    if err != nil {
        fmt.Println(err.Error())
    }
    fmt.Println(fp)
}

同时调试我发现的代码错误来自哪里https://github.com/helm/helm/blob/release-3.6/pkg/downloader/chart_downloader.go#L352 它试图找到一些在我的笔记本电脑中不存在的缓存,我该如何禁用它或其他一些解决方案使其工作?

【问题讨论】:

    标签: go kubernetes kubernetes-helm


    【解决方案1】:

    我认为您需要在找到图表之前更新您的存储库。

    This 是 CLI 用于更新存储库的代码。

    this 是对存储库执行更新的函数。

    【讨论】:

    • 感谢您提供了相同的功能 :)
    猜你喜欢
    • 2021-08-03
    • 2021-04-29
    • 1970-01-01
    • 1970-01-01
    • 2019-04-09
    • 2021-05-12
    • 1970-01-01
    • 2020-11-05
    • 2017-11-15
    相关资源
    最近更新 更多