本文整理匯總了Golang中github.com/helm/helm/log.Debug函數的典型用法代碼示例。如果您正苦於以下問題:Golang Debug函數的具體用法?Golang Debug怎麽用?Golang Debug使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Debug函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Resolve
// Resolve takes a chart and a location and checks whether the chart's dependencies are satisfied.
//
// The `installdir` is the location where installed charts are located. Typically
// this is in $HELM_HOME/workspace/charts.
//
// This returns a list of unsatisfied dependencies (NOT an error condition).
//
// It returns an error only if it cannot perform the task of resolving dependencies.
// Failed dependencies to not constitute an error.
func Resolve(cf *chart.Chartfile, installdir string) ([]*chart.Dependency, error) {
if len(cf.Dependencies) == 0 {
log.Debug("No dependencies to check. :achievement-unlocked:")
return []*chart.Dependency{}, nil
}
cache, err := dependencyCache(installdir)
if err != nil {
log.Debug("Failed to build dependency cache: %s", err)
return []*chart.Dependency{}, err
}
res := []*chart.Dependency{}
// TODO: This could be made more efficient.
for _, check := range cf.Dependencies {
resolved := false
for n, chart := range cache {
log.Debug("Checking if %s (%s) %s meets %s %s", chart.Name, n, chart.Version, check.Name, check.Version)
if chart.Name == check.Name && check.VersionOK(chart.Version) {
log.Debug("✔︎")
resolved = true
break
}
}
if !resolved {
log.Debug("No matches found for %s %s", check.Name, check.Version)
res = append(res, check)
}
}
return res, nil
}
示例2: 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
}
示例3: 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 := filepath.Join(home, WorkspaceChartPath, chartName, "Chart.yaml")
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
}
示例4: 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)
}
}
示例5: ensureHome
// ensureHome ensures that a HELM_HOME exists.
func ensureHome(home string) {
must := []string{home, filepath.Join(home, CachePath), filepath.Join(home, WorkspacePath), filepath.Join(home, CacheChartPath)}
for _, p := range must {
if fi, err := os.Stat(p); err != nil {
log.Debug("Creating %s", p)
if err := os.MkdirAll(p, 0755); err != nil {
log.Die("Could not create %q: %s", p, err)
}
} else if !fi.IsDir() {
log.Die("%s must be a directory.", home)
}
}
refi := filepath.Join(home, Configfile)
if _, err := os.Stat(refi); err != nil {
log.Info("Creating %s", refi)
// Attempt to create a Repos.yaml
if err := ioutil.WriteFile(refi, []byte(config.DefaultConfigfile), 0755); err != nil {
log.Die("Could not create %s: %s", refi, err)
}
}
if err := os.Chdir(home); err != nil {
log.Die("Could not change to directory %q: %s", home, err)
}
}
示例6: gitUpdate
// gitUpdate updates a Git repo.
func gitUpdate(git *vcs.GitRepo) error {
if err := git.Update(); err != nil {
return err
}
log.Debug("Updated %s from %s", git.LocalPath(), git.Remote())
return nil
}
示例7: marshalAndCreate
func marshalAndCreate(o interface{}, ns string, client kubectl.Runner) ([]byte, error) {
var b bytes.Buffer
if err := codec.JSON.Encode(&b).One(o); err != nil {
return nil, err
}
data := b.Bytes()
log.Debug("File: %s", string(data))
return client.Create(data, ns)
}
示例8: copyDir
// Copy a directory and its subdirectories.
func copyDir(src, dst string) error {
var failure error
walker := func(fname string, fi os.FileInfo, e error) error {
if e != nil {
log.Warn("Encounter error walking %q: %s", fname, e)
failure = e
return nil
}
log.Debug("Copying %s", fname)
rf, err := filepath.Rel(src, fname)
if err != nil {
log.Warn("Could not find relative path: %s", err)
return nil
}
df := filepath.Join(dst, rf)
// Handle directories by creating mirrors.
if fi.IsDir() {
if err := os.MkdirAll(df, fi.Mode()); err != nil {
log.Warn("Could not create %q: %s", df, err)
failure = err
}
return nil
}
// Otherwise, copy files.
in, err := os.Open(fname)
if err != nil {
log.Warn("Skipping file %s: %s", fname, err)
return nil
}
out, err := os.Create(df)
if err != nil {
in.Close()
log.Warn("Skipping file copy %s: %s", fname, err)
return nil
}
if _, err = io.Copy(out, in); err != nil {
log.Warn("Copy from %s to %s failed: %s", fname, df, err)
}
if err := out.Close(); err != nil {
log.Warn("Failed to close %q: %s", df, err)
}
if err := in.Close(); err != nil {
log.Warn("Failed to close reader %q: %s", fname, err)
}
return nil
}
filepath.Walk(src, walker)
return failure
}
示例9: deleteRepo
func (r *Repos) deleteRepo(name string) error {
rpath := filepath.Join(r.Dir, name)
if fi, err := os.Stat(rpath); err != nil || !fi.IsDir() {
log.Info("Deleted nothing. No repo named %s", name)
return nil
}
log.Debug("Deleting %s", rpath)
return os.RemoveAll(rpath)
}
示例10: renderTemplate
// renderTemplate renders a template and values into an output stream.
//
// tpl should be a string template.
func renderTemplate(out io.Writer, tpl string, vals interface{}) error {
t, err := template.New("helmTpl").Funcs(sprig.TxtFuncMap()).Parse(tpl)
if err != nil {
return err
}
log.Debug("Vals: %#v", vals)
if err := t.ExecuteTemplate(out, "helmTpl", vals); err != nil {
return err
}
return nil
}
示例11: kubectlDelete
func kubectlDelete(name, ktype, ns string) error {
log.Debug("Deleting %s (%s)", name, ktype)
a := []string{"delete", ktype, name}
if ns != "" {
a = append([]string{fmt.Sprintf("--namespace=%q", ns)}, a...)
}
cmd := exec.Command("kubectl", a...)
if d, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("%s: %s", string(d), err)
}
return nil
}
示例12: repoChartDiff
func repoChartDiff(rpath, initialVersion string) (string, error) {
// build git diff-tree command
cmd := exec.Command("git", "-C", rpath, "diff-tree", "--name-status", fmt.Sprintf("%s..HEAD", initialVersion))
log.Debug("git diff cmd: %s", cmd.Args)
out, err := cmd.CombinedOutput()
if err != nil {
return "", err
}
// cleanup any trailing whitespace
return strings.TrimSpace(string(out)), nil
}
示例13: ParseDir
// ParseDir parses all of the manifests inside of a chart directory.
//
// The directory should be the Chart directory (contains Chart.yaml and manifests/)
//
// This will return an error if the directory does not exist, or if there is an
// error parsing or decoding any yaml files.
func ParseDir(chartDir string) ([]*Manifest, error) {
dir := filepath.Join(chartDir, "manifests")
files := []*Manifest{}
if _, err := os.Stat(dir); err != nil {
return files, err
}
// add manifest files
walker := func(fname string, fi os.FileInfo, e error) error {
log.Debug("Parsing %s", fname)
// Chauncey was right.
if e != nil {
return e
}
if fi.IsDir() {
return nil
}
if filepath.Ext(fname) != ".yaml" {
log.Debug("Skipping %s. Not a YAML file.", fname)
return nil
}
m, err := Parse(fname)
if err != nil {
return err
}
files = append(files, m...)
return nil
}
return files, filepath.Walk(dir, walker)
}
示例14: fetch
func fetch(chartName, lname, homedir, chartpath string) {
src := filepath.Join(homedir, CachePath, chartpath, chartName)
dest := filepath.Join(homedir, WorkspaceChartPath, lname)
if fi, err := os.Stat(src); err != nil {
log.Die("Chart %s not found in %s", lname, src)
} else 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 := copyDir(src, dest); err != nil {
log.Die("Failed copying %s to %s", src, dest)
}
}
示例15: PrintREADME
// PrintREADME prints the README file (if it exists) to the console.
func PrintREADME(chart, home string) {
p := filepath.Join(home, WorkspaceChartPath, chart, "README.*")
files, err := filepath.Glob(p)
if err != nil || len(files) == 0 {
// No README. Skip.
log.Debug("No readme in %s", p)
return
}
f, err := os.Open(files[0])
if err != nil {
log.Warn("Could not read README: %s", err)
return
}
log.Msg(strings.Repeat("=", 40))
io.Copy(log.Stdout, f)
log.Msg(strings.Repeat("=", 40))
f.Close()
}