示例#1
0
文件: install.go 项目: kgrvamsi/helm
// 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 following order:
//
//	- Namespaces
// 	- Secrets
// 	- Volumes
// 	- Services
// 	- Pods
// 	- ReplicationControllers
func Install(chart, home, namespace string, force bool) {
	if !chartInstalled(chart, home) {
		log.Info("No installed chart named %q. Installing now.", chart)
		fetch(chart, chart, home)
	}

	cd := filepath.Join(home, WorkspaceChartPath, chart)
	c, err := model.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, filepath.Join(home, WorkspaceChartPath))
	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.")
		}
	}

	if err := uploadManifests(c, namespace); err != nil {
		log.Die("Failed to upload manifests: %s", err)
	}
	PrintREADME(chart, home)
}
示例#2
0
// List lists all of the local charts.
func List(homedir string) {
	md := filepath.Join(homedir, WorkspaceChartPath, "*")
	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 := model.Load(filepath.Join(c, "Chart.yaml")); err == nil {
			log.Info("\t%s (%s %s) - %s", cname, ch.Name, ch.Version, ch.Description)
			continue
		}
		log.Info("\t%s (unknown)", cname)
	}
}
示例#3
0
文件: list.go 项目: BVrolyk/helm
func listNS(homedir, ns string) {
	md := filepath.Join(homedir, ManifestsPath, ns, "*")
	charts, err := filepath.Glob(md)
	if err != nil {
		Warn("Could not find any charts in %q: %s", md, err)
	}
	for _, c := range charts {
		cname := filepath.Base(c)
		if ch, err := model.Load(filepath.Join(c, "Chart.yaml")); err == nil {
			Info("\t%s (%s %s) - %s", cname, ch.Name, ch.Version, ch.Description)
			continue
		}
		Info("\t%s (unknown)", cname)
	}
}
示例#4
0
func Uninstall(chart, home, namespace string) {
	if !chartInstalled(chart, home) {
		log.Info("No installed chart named %q. Nothing to delete.", chart)
		return
	}

	cd := filepath.Join(home, WorkspaceChartPath, chart)
	c, err := model.Load(cd)
	if err != nil {
		log.Die("Failed to load chart: %s", err)
	}

	if err := deleteChart(c, namespace); err != nil {
		log.Die("Failed to completely delete chart: %s", err)
	}
}
示例#5
0
文件: install.go 项目: kgrvamsi/helm
func AltInstall(chart, cachedir, home, namespace string, force bool) {
	// Make sure there is a chart in the cachedir.
	if _, err := os.Stat(filepath.Join(cachedir, "Chart.yaml")); err != nil {
		log.Die("Expected a Chart.yaml in %s: %s", cachedir, err)
	}
	// Make sure there is a manifests dir.
	if fi, err := os.Stat(filepath.Join(cachedir, "manifests")); err != nil {
		log.Die("Expected 'manifests/' in %s: %s", cachedir, err)
	} else if !fi.IsDir() {
		log.Die("Expected 'manifests/' to be a directory in %s: %s", cachedir, err)
	}

	// Copy the source chart to the workspace. We ruthlessly overwrite in
	// this case.
	dest := filepath.Join(home, WorkspaceChartPath, chart)
	if err := copyDir(cachedir, dest); err != nil {
		log.Die("Failed to copy %s to %s: %s", cachedir, dest, err)
	}

	// Load the chart.
	c, err := model.Load(dest)
	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, filepath.Join(home, WorkspaceChartPath))
	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.")
		}
	}

	if err := uploadManifests(c, namespace); err != nil {
		log.Die("Failed to upload manifests: %s", err)
	}
}
示例#6
0
文件: search.go 项目: lanej/helm
// Search looks for packages with 'term' in their name.
func Search(term, homedir string) {
	term = sanitizeTerm(term)
	sp := filepath.Join(homedir, CacheChartPath, "*"+term+"*")
	dirs, err := filepath.Glob(sp)
	if err != nil {
		Die("No results found. %s", err)
	}

	Info("\n=================")
	Info("Available Charts")
	Info("=================\n")

	for _, d := range dirs {
		y, err := model.Load(filepath.Join(d, "Chart.yaml"))
		if err != nil {
			Info("\t%s - UNKNOWN", filepath.Base(d))
			continue
		}
		Info("\t%s (%s %s) - %s", filepath.Base(d), y.Name, y.Version, y.Description)
	}

	Info("")
}