• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang util.WorkspaceChartDirectory函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/helm/helm/util.WorkspaceChartDirectory函数的典型用法代码示例。如果您正苦于以下问题:Golang WorkspaceChartDirectory函数的具体用法?Golang WorkspaceChartDirectory怎么用?Golang WorkspaceChartDirectory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了WorkspaceChartDirectory函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestLintEmptyChartYaml

func TestLintEmptyChartYaml(t *testing.T) {
	tmpHome := test.CreateTmpHome()
	test.FakeUpdate(tmpHome)

	chartName := "badChart"

	Create(chartName, tmpHome)

	badChartYaml, _ := yaml.Marshal(make(map[string]string))

	chartYaml := util.WorkspaceChartDirectory(tmpHome, chartName, Chartfile)

	os.Remove(chartYaml)
	ioutil.WriteFile(chartYaml, badChartYaml, 0644)

	output := test.CaptureOutput(func() {
		Lint(util.WorkspaceChartDirectory(tmpHome, chartName))
	})

	test.ExpectContains(t, output, "Chart.yaml has a name field : false")
	test.ExpectContains(t, output, "Chart.yaml has a version field : false")
	test.ExpectContains(t, output, "Chart.yaml has a description field : false")
	test.ExpectContains(t, output, "Chart.yaml has a maintainers field : false")
	test.ExpectContains(t, output, fmt.Sprintf("Chart [%s] has failed some necessary checks", chartName))
}
开发者ID:michelleN,项目名称:helm,代码行数:25,代码来源:lint_test.go


示例2: Fetch

// Fetch gets a chart from the source repo and copies to the workdir.
//
// - chartName is the source
// - lname is the local name for that chart (chart-name); if blank, it is set to the chart.
// - homedir is the home directory for the user
func Fetch(chartName, lname, homedir string) {

	r := mustConfig(homedir).Repos
	repository, chartName := r.RepoChart(chartName)

	if lname == "" {
		lname = chartName
	}

	fetch(chartName, lname, homedir, repository)

	chartFilePath := helm.WorkspaceChartDirectory(homedir, lname, Chartfile)
	cfile, err := chart.LoadChartfile(chartFilePath)
	if err != nil {
		log.Die("Source is not a valid chart. Missing Chart.yaml: %s", err)
	}

	deps, err := dependency.Resolve(cfile, helm.WorkspaceChartDirectory(homedir))
	if err != nil {
		log.Warn("Could not check dependencies: %s", err)
		return
	}

	if len(deps) > 0 {
		log.Warn("Unsatisfied dependencies:")
		for _, d := range deps {
			log.Msg("\t%s %s", d.Name, d.Version)
		}
	}

	log.Info("Fetched chart into workspace %s", helm.WorkspaceChartDirectory(homedir, lname))
	log.Info("Done")
}
开发者ID:michelleN,项目名称:helm,代码行数:38,代码来源:fetch.go


示例3: Install

// Install loads a chart into Kubernetes.
//
// If the chart is not found in the workspace, it is fetched and then installed.
//
// During install, manifests are sent to Kubernetes in the ordered specified by InstallOrder.
func Install(chartName, home, namespace string, force bool, generate bool, exclude []string, client kubectl.Runner) {
	ochart := chartName
	r := mustConfig(home).Repos
	table, chartName := r.RepoChart(chartName)

	if !chartFetched(chartName, home) {
		log.Info("No chart named %q in your workspace. Fetching now.", ochart)
		fetch(chartName, chartName, home, table)
	}

	cd := helm.WorkspaceChartDirectory(home, chartName)
	c, err := chart.Load(cd)
	if err != nil {
		log.Die("Failed to load chart: %s", err)
	}

	// Give user the option to bale if dependencies are not satisfied.
	nope, err := dependency.Resolve(c.Chartfile, helm.WorkspaceChartDirectory(home))

	if err != nil {
		log.Warn("Failed to check dependencies: %s", err)
		if !force {
			log.Die("Re-run with --force to install anyway.")
		}
	} else if len(nope) > 0 {
		log.Warn("Unsatisfied dependencies:")
		for _, d := range nope {
			log.Msg("\t%s %s", d.Name, d.Version)
		}
		if !force {
			log.Die("Stopping install. Re-run with --force to install anyway.")
		}
	}

	// Run the generator if -g is set.
	if generate {
		Generate(chartName, home, exclude)
	}

	CheckKubePrereqs()

	log.Info("Running `kubectl create -f` ...")
	if err := uploadManifests(c, namespace, client); err != nil {
		log.Die("Failed to upload manifests: %s", err)
	}
	log.Info("Done")

	PrintREADME(chartName, home)
}
开发者ID:colonelmo,项目名称:helm,代码行数:54,代码来源:install.go


示例4: createWithChart

func createWithChart(chart *chart.Chartfile, chartName, homeDir string) {
	chartDir := helm.WorkspaceChartDirectory(homeDir, chartName)

	// create directories
	if err := os.MkdirAll(filepath.Join(chartDir, "manifests"), 0755); err != nil {
		log.Die("Could not create %q: %s", chartDir, err)
	}

	// create Chartfile.yaml
	if err := chart.Save(filepath.Join(chartDir, Chartfile)); err != nil {
		log.Die("Could not create Chart.yaml: err", err)
	}

	// create README.md
	if err := createReadme(chartDir, chart); err != nil {
		log.Die("Could not create README.md: err", err)
	}

	// create example-pod
	if err := createExampleManifest(chartDir); err != nil {
		log.Die("Could not create example manifest: err", err)
	}

	log.Info("Created chart in %s", chartDir)
}
开发者ID:michelleN,项目名称:helm,代码行数:25,代码来源:create.go


示例5: Publish

// Publish a chart from the workspace to the cache directory
//
// - chartName being published
// - homeDir is the helm home directory for the user
// - force publishing even if the chart directory already exists
func Publish(chartName, homeDir, repo string, force bool) {
	if repo == "" {
		repo = "charts"
	}

	if !mustConfig(homeDir).Repos.Exists(repo) {
		log.Err("Repo %s does not exist", repo)
		log.Info("Available repositories")
		ListRepos(homeDir)
		return
	}

	src := helm.WorkspaceChartDirectory(homeDir, chartName)
	dst := helm.CacheDirectory(homeDir, repo, chartName)

	if _, err := os.Stat(dst); err == nil {
		if force != true {
			log.Info("chart already exists, use -f to force")
			return
		}
	}

	if err := helm.CopyDir(src, dst); err != nil {
		log.Die("failed to publish directory: %v", err)
	}
}
开发者ID:michelleN,项目名称:helm,代码行数:31,代码来源:publish.go


示例6: TestLintMissingReadme

func TestLintMissingReadme(t *testing.T) {
	tmpHome := test.CreateTmpHome()
	test.FakeUpdate(tmpHome)

	chartName := "badChart"

	Create(chartName, tmpHome)

	os.Remove(filepath.Join(util.WorkspaceChartDirectory(tmpHome, chartName), "README.md"))

	output := test.CaptureOutput(func() {
		Lint(util.WorkspaceChartDirectory(tmpHome, chartName))
	})

	test.ExpectContains(t, output, "README.md is present and not empty : false")
}
开发者ID:michelleN,项目名称:helm,代码行数:16,代码来源:lint_test.go


示例7: fetch

func fetch(chartName, lname, homedir, chartpath string) {
	src := helm.CacheDirectory(homedir, chartpath, chartName)
	dest := helm.WorkspaceChartDirectory(homedir, lname)

	fi, err := os.Stat(src)
	if err != nil {
		log.Warn("Oops. Looks like there was an issue finding the chart, %s, n %s. Running `helm update` to ensure you have the latest version of all Charts from Github...", lname, src)
		Update(homedir)
		fi, err = os.Stat(src)
		if err != nil {
			log.Die("Chart %s not found in %s", lname, src)
		}
		log.Info("Good news! Looks like that did the trick. Onwards and upwards!")
	}

	if !fi.IsDir() {
		log.Die("Malformed chart %s: Chart must be in a directory.", chartName)
	}

	if err := os.MkdirAll(dest, 0755); err != nil {
		log.Die("Could not create %q: %s", dest, err)
	}

	log.Debug("Fetching %s to %s", src, dest)
	if err := helm.CopyDir(src, dest); err != nil {
		log.Die("Failed copying %s to %s", src, dest)
	}

	if err := updateChartfile(src, dest, lname); err != nil {
		log.Die("Failed to update Chart.yaml: %s", err)
	}
}
开发者ID:2opremio,项目名称:helm,代码行数:32,代码来源:fetch.go


示例8: Uninstall

// Uninstall removes a chart from Kubernetes.
//
// Manifests are removed from Kubernetes in the order specified by
// chart.UninstallOrder. Any unknown types are removed before that sequence
// is run.
func Uninstall(chartName, home, namespace string, force bool, client kubectl.Runner) {
	// This is a stop-gap until kubectl respects namespaces in manifests.
	if namespace == "" {
		log.Die("This command requires a namespace. Did you mean '-n default'?")
	}
	if !chartFetched(chartName, home) {
		log.Info("No chart named %q in your workspace. Nothing to delete.", chartName)
		return
	}

	cd := helm.WorkspaceChartDirectory(home, chartName)
	c, err := chart.Load(cd)
	if err != nil {
		log.Die("Failed to load chart: %s", err)
	}
	if err := deleteChart(c, namespace, true, client); err != nil {
		log.Die("Failed to list charts: %s", err)
	}
	if !force && !promptConfirm("Uninstall the listed objects?") {
		log.Info("Aborted uninstall")
		return
	}

	CheckKubePrereqs()

	log.Info("Running `kubectl delete` ...")
	if err := deleteChart(c, namespace, false, client); err != nil {
		log.Die("Failed to completely delete chart: %s", err)
	}
	log.Info("Done")
}
开发者ID:colonelmo,项目名称:helm,代码行数:36,代码来源:uninstall.go


示例9: lint

func lint(c *cli.Context) {
	home := home(c)

	all := c.Bool("all")

	if all {
		action.LintAll(home)
		return
	}

	minArgs(c, 1, "lint")

	a := c.Args()
	chartNameOrPath := a[0]

	fromHome := util.WorkspaceChartDirectory(home, chartNameOrPath)
	fromAbs := filepath.Clean(chartNameOrPath)

	_, err := os.Stat(fromAbs)

	if err == nil {
		action.Lint(fromAbs)
	} else {
		action.Lint(fromHome)
	}
}
开发者ID:michelleN,项目名称:helm,代码行数:26,代码来源:lint.go


示例10: TestLintMissingChartYaml

func TestLintMissingChartYaml(t *testing.T) {
	tmpHome := test.CreateTmpHome()
	test.FakeUpdate(tmpHome)

	chartName := "badChart"

	Create(chartName, tmpHome)

	os.Remove(filepath.Join(util.WorkspaceChartDirectory(tmpHome, chartName), Chartfile))

	output := test.CaptureOutput(func() {
		Lint(util.WorkspaceChartDirectory(tmpHome, chartName))
	})

	test.ExpectContains(t, output, "Chart.yaml is present : false")
	test.ExpectContains(t, output, "Chart [badChart] has failed some necessary checks.")
}
开发者ID:michelleN,项目名称:helm,代码行数:17,代码来源:lint_test.go


示例11: TestLintMissingManifestDirectory

func TestLintMissingManifestDirectory(t *testing.T) {
	tmpHome := test.CreateTmpHome()
	test.FakeUpdate(tmpHome)

	chartName := "brokeChart"

	Create(chartName, tmpHome)

	os.RemoveAll(filepath.Join(util.WorkspaceChartDirectory(tmpHome, chartName), "manifests"))

	output := test.CaptureOutput(func() {
		Lint(util.WorkspaceChartDirectory(tmpHome, chartName))
	})

	test.ExpectMatches(t, output, "Manifests directory is present : false")
	test.ExpectContains(t, output, "Chart ["+chartName+"] has failed some necessary checks")
}
开发者ID:michelleN,项目名称:helm,代码行数:17,代码来源:lint_test.go


示例12: chartFetched

// Check by chart directory name whether a chart is fetched into the workspace.
//
// This does NOT check the Chart.yaml file.
func chartFetched(chartName, home string) bool {
	p := helm.WorkspaceChartDirectory(home, chartName, Chartfile)
	log.Debug("Looking for %q", p)
	if fi, err := os.Stat(p); err != nil || fi.IsDir() {
		log.Debug("No chart: %s", err)
		return false
	}
	return true
}
开发者ID:colonelmo,项目名称:helm,代码行数:12,代码来源:install.go


示例13: Edit

// Edit charts using the shell-defined $EDITOR
//
// - chartName being edited
// - homeDir is the helm home directory for the user
func Edit(chartName, homeDir string) {

	chartDir := util.WorkspaceChartDirectory(homeDir, chartName)

	if _, err := os.Stat(chartDir); os.IsNotExist(err) {
		log.Die("Could not find chart: %s", chartName)
	}

	openEditor(chartDir)
}
开发者ID:michelleN,项目名称:helm,代码行数:14,代码来源:edit.go


示例14: TestLintBadPath

func TestLintBadPath(t *testing.T) {
	tmpHome := test.CreateTmpHome()
	chartName := "badChart"

	output := test.CaptureOutput(func() {
		Lint(util.WorkspaceChartDirectory(tmpHome, chartName))
	})

	msg := "Chart found at " + tmpHome + "/workspace/charts/" + chartName + " : false"
	test.ExpectContains(t, output, msg)
}
开发者ID:michelleN,项目名称:helm,代码行数:11,代码来源:lint_test.go


示例15: TestFetch

func TestFetch(t *testing.T) {
	tmpHome := test.CreateTmpHome()
	test.FakeUpdate(tmpHome)
	chartName := "kitchensink"

	actual := test.CaptureOutput(func() {
		Fetch(chartName, "", tmpHome)
	})

	workspacePath := util.WorkspaceChartDirectory(tmpHome, chartName)
	test.ExpectContains(t, actual, "Fetched chart into workspace "+workspacePath)
}
开发者ID:2opremio,项目名称:helm,代码行数:12,代码来源:fetch_test.go


示例16: TestLintMismatchedChartNameAndDir

func TestLintMismatchedChartNameAndDir(t *testing.T) {
	tmpHome := test.CreateTmpHome()
	chartName := "chart-0"
	chartDir := "chart-1"
	chart := newSkelChartfile(chartName)
	createWithChart(chart, chartDir, tmpHome)

	output := test.CaptureOutput(func() {
		Lint(util.WorkspaceChartDirectory(tmpHome, chartDir))
	})

	test.ExpectContains(t, output, "Name declared in Chart.yaml is the same as directory name. : false")
}
开发者ID:michelleN,项目名称:helm,代码行数:13,代码来源:lint_test.go


示例17: TestLintChartByPath

func TestLintChartByPath(t *testing.T) {
	home1 := test.CreateTmpHome()
	home2 := test.CreateTmpHome()

	chartName := "goodChart"
	action.Create(chartName, home1)

	output := test.CaptureOutput(func() {
		Cli().Run([]string{"helm", "--home", home2, "lint", util.WorkspaceChartDirectory(home1, chartName)})
	})

	test.ExpectContains(t, output, fmt.Sprintf("Chart [%s] has passed all necessary checks", chartName))
}
开发者ID:michelleN,项目名称:helm,代码行数:13,代码来源:lint_test.go


示例18: List

// List lists all of the local charts.
func List(homedir string) {
	md := helm.WorkspaceChartDirectory(homedir, "*")
	charts, err := filepath.Glob(md)
	if err != nil {
		log.Warn("Could not find any charts in %q: %s", md, err)
	}
	for _, c := range charts {
		cname := filepath.Base(c)
		if ch, err := chart.LoadChartfile(filepath.Join(c, Chartfile)); err == nil {
			log.Info("\t%s (%s %s) - %s", cname, ch.Name, ch.Version, ch.Description)
			continue
		}
		log.Info("\t%s (unknown)", cname)
	}
}
开发者ID:michelleN,项目名称:helm,代码行数:16,代码来源:list.go


示例19: Generate

// Generate runs generators on the entire chart.
//
// By design, this only operates on workspaces, as it should never be run
// on the cache.
func Generate(chart, homedir string, exclude []string) {
	if abs, err := filepath.Abs(homedir); err == nil {
		homedir = abs
	}
	chartPath := util.WorkspaceChartDirectory(homedir, chart)

	os.Setenv("HELM_HOME", homedir)
	os.Setenv("HELM_DEFAULT_REPO", mustConfig(homedir).Repos.Default)

	count, err := generator.Walk(chartPath, exclude)
	if err != nil {
		log.Die("Failed to complete generation: %s", err)
	}
	log.Info("Ran %d generators.", count)
}
开发者ID:michelleN,项目名称:helm,代码行数:19,代码来源:generate.go


示例20: LintAll

// LintAll vlaidates all charts are well-formed
//
// - homedir is the home directory for the user
func LintAll(homedir string) {
	md := util.WorkspaceChartDirectory(homedir, "*")
	chartPaths, err := filepath.Glob(md)
	if err != nil {
		log.Warn("Could not find any charts in %q: %s", md, err)
	}

	if len(chartPaths) == 0 {
		log.Warn("Could not find any charts in %q", md)
	} else {
		for _, chartPath := range chartPaths {
			Lint(chartPath)
		}
	}
}
开发者ID:colonelmo,项目名称:helm,代码行数:18,代码来源:lint.go



注:本文中的github.com/helm/helm/util.WorkspaceChartDirectory函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang bson.DecodeString函数代码示例发布时间:2022-05-28
下一篇:
Golang test.CreateTmpHome函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap