Helm SDK 从 extenanl 存储库下载图表
Helm SDK download chart from extenanl repository
我需要下载位于外部 OCI 存储库的图表,当我使用单击图表和版本的 link 下载它并提供用户名和密码时,它可以工作,但不能使用以下代码,这是我尝试过的错误
无法下载版本“1.0.0”的“https://fdr.cdn.repositories.amp/artifactory/control-1.0.0.tgz”(提示:运行 helm repo update
可能有帮助) ,如果我点击上面的 link 它会询问用户并通过(在浏览器中)以及当我提供它时(在代码中相同) 图表已 下载 ,知道为什么代码不起作用吗?
这是我试过的
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
它试图找到我的笔记本电脑中不存在的一些缓存,我该如何禁用它或使用其他解决方案使其正常工作?
我需要下载位于外部 OCI 存储库的图表,当我使用单击图表和版本的 link 下载它并提供用户名和密码时,它可以工作,但不能使用以下代码,这是我尝试过的错误
无法下载版本“1.0.0”的“https://fdr.cdn.repositories.amp/artifactory/control-1.0.0.tgz”(提示:运行 helm repo update
可能有帮助) ,如果我点击上面的 link 它会询问用户并通过(在浏览器中)以及当我提供它时(在代码中相同) 图表已 下载 ,知道为什么代码不起作用吗?
这是我试过的
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 它试图找到我的笔记本电脑中不存在的一些缓存,我该如何禁用它或使用其他解决方案使其正常工作?