mirror of https://github.com/helm/helm
Merge pull request #4518 from adamreese/dev-v3-ref-chart
ref(*): refactor chart/chartutilpull/4531/head
commit
35e931135c
@ -1 +1 @@
|
|||||||
Error: cannot load requirements: error converting YAML to JSON: yaml: line 2: did not find expected '-' indicator
|
Error: cannot load requirements.yaml: error converting YAML to JSON: yaml: line 2: did not find expected '-' indicator
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
name: alpine
|
||||||
|
description: Deploy a basic Alpine Linux pod
|
||||||
|
version: 0.1.0
|
||||||
|
home: https://github.com/kubernetes/helm
|
||||||
|
sources:
|
||||||
|
- https://github.com/kubernetes/helm
|
||||||
|
appVersion: 3.3
|
@ -0,0 +1,11 @@
|
|||||||
|
# Alpine: A simple Helm chart
|
||||||
|
|
||||||
|
Run a single pod of Alpine Linux.
|
||||||
|
|
||||||
|
The `templates/` directory contains a very simple pod resource with a
|
||||||
|
couple of parameters.
|
||||||
|
|
||||||
|
The `values.yaml` file contains the default values for the
|
||||||
|
`alpine-pod.yaml` template.
|
||||||
|
|
||||||
|
You can install this example using `helm install docs/examples/alpine`.
|
@ -0,0 +1,16 @@
|
|||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Expand the name of the chart.
|
||||||
|
*/}}
|
||||||
|
{{- define "alpine.name" -}}
|
||||||
|
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Create a default fully qualified app name.
|
||||||
|
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||||
|
*/}}
|
||||||
|
{{- define "alpine.fullname" -}}
|
||||||
|
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||||
|
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- end -}}
|
@ -0,0 +1,23 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: {{ template "alpine.fullname" . }}
|
||||||
|
labels:
|
||||||
|
# The "heritage" label is used to track which tool deployed a given chart.
|
||||||
|
# It is useful for admins who want to see what releases a particular tool
|
||||||
|
# is responsible for.
|
||||||
|
heritage: {{ .Release.Service }}
|
||||||
|
# The "release" convention makes it easy to tie a release to all of the
|
||||||
|
# Kubernetes resources that were created as part of that release.
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
# This makes it easy to audit chart usage.
|
||||||
|
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
|
||||||
|
app: {{ template "alpine.name" . }}
|
||||||
|
spec:
|
||||||
|
# This shows how to use a simple value. This will look for a passed-in value called restartPolicy.
|
||||||
|
restartPolicy: {{ .Values.restartPolicy }}
|
||||||
|
containers:
|
||||||
|
- name: waiter
|
||||||
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||||
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||||
|
command: ["/bin/sleep", "9000"]
|
@ -0,0 +1,6 @@
|
|||||||
|
image:
|
||||||
|
repository: alpine
|
||||||
|
tag: 3.3
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
|
restartPolicy: Never
|
@ -0,0 +1 @@
|
|||||||
|
Sample notes for {{ .Chart.Name }}
|
@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2018 The Kubernetes Authors All rights reserved.
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package chart
|
||||||
|
|
||||||
|
// Chart is a helm package that contains metadata, a default config, zero or more
|
||||||
|
// optionally parameterizable templates, and zero or more charts (dependencies).
|
||||||
|
type Chart struct {
|
||||||
|
// Metadata is the contents of the Chartfile.
|
||||||
|
Metadata *Metadata
|
||||||
|
// Requirements is the contents of requirements.yaml.
|
||||||
|
Requirements *Requirements
|
||||||
|
// RequirementsLock is the contents of requirements.lock.
|
||||||
|
RequirementsLock *RequirementsLock
|
||||||
|
// Templates for this chart.
|
||||||
|
Templates []*File
|
||||||
|
// Values are default config for this template.
|
||||||
|
Values []byte
|
||||||
|
// Files are miscellaneous files in a chart archive,
|
||||||
|
// e.g. README, LICENSE, etc.
|
||||||
|
Files []*File
|
||||||
|
|
||||||
|
parent *Chart
|
||||||
|
dependencies []*Chart
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetDependencies replaces the chart dependencies.
|
||||||
|
func (ch *Chart) SetDependencies(charts ...*Chart) {
|
||||||
|
ch.dependencies = nil
|
||||||
|
ch.AddDependency(charts...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name returns the name of the chart.
|
||||||
|
func (ch *Chart) Name() string {
|
||||||
|
if ch.Metadata == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return ch.Metadata.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddDependency determines if the chart is a subchart.
|
||||||
|
func (ch *Chart) AddDependency(charts ...*Chart) {
|
||||||
|
for i, x := range charts {
|
||||||
|
charts[i].parent = ch
|
||||||
|
ch.dependencies = append(ch.dependencies, x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Root finds the root chart.
|
||||||
|
func (ch *Chart) Root() *Chart {
|
||||||
|
if ch.IsRoot() {
|
||||||
|
return ch
|
||||||
|
}
|
||||||
|
return ch.Parent().Root()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dependencies are the charts that this chart depends on.
|
||||||
|
func (ch *Chart) Dependencies() []*Chart { return ch.dependencies }
|
||||||
|
|
||||||
|
// IsRoot determines if the chart is the root chart.
|
||||||
|
func (ch *Chart) IsRoot() bool { return ch.parent == nil }
|
||||||
|
|
||||||
|
// Parent returns a subchart's parent chart.
|
||||||
|
func (ch *Chart) Parent() *Chart { return ch.parent }
|
||||||
|
|
||||||
|
// Parent sets a subchart's parent chart.
|
||||||
|
func (ch *Chart) SetParent(chart *Chart) { ch.parent = chart }
|
||||||
|
|
||||||
|
// ChartPath returns the full path to this chart in dot notation.
|
||||||
|
func (ch *Chart) ChartPath() string {
|
||||||
|
if !ch.IsRoot() {
|
||||||
|
return ch.Parent().ChartPath() + "." + ch.Name()
|
||||||
|
}
|
||||||
|
return ch.Name()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChartFullPath returns the full path to this chart.
|
||||||
|
func (ch *Chart) ChartFullPath() string {
|
||||||
|
if !ch.IsRoot() {
|
||||||
|
return ch.Parent().ChartFullPath() + "/charts/" + ch.Name()
|
||||||
|
}
|
||||||
|
return ch.Name()
|
||||||
|
}
|
@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package loader
|
||||||
|
|
||||||
|
import (
|
||||||
|
"archive/tar"
|
||||||
|
"bytes"
|
||||||
|
"compress/gzip"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
"k8s.io/helm/pkg/chart"
|
||||||
|
)
|
||||||
|
|
||||||
|
type FileLoader string
|
||||||
|
|
||||||
|
func (l FileLoader) Load() (*chart.Chart, error) {
|
||||||
|
return LoadFile(string(l))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadFile loads from an archive file.
|
||||||
|
func LoadFile(name string) (*chart.Chart, error) {
|
||||||
|
if fi, err := os.Stat(name); err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if fi.IsDir() {
|
||||||
|
return nil, errors.New("cannot load a directory")
|
||||||
|
}
|
||||||
|
|
||||||
|
raw, err := os.Open(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer raw.Close()
|
||||||
|
|
||||||
|
return LoadArchive(raw)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadArchive loads from a reader containing a compressed tar archive.
|
||||||
|
func LoadArchive(in io.Reader) (*chart.Chart, error) {
|
||||||
|
unzipped, err := gzip.NewReader(in)
|
||||||
|
if err != nil {
|
||||||
|
return &chart.Chart{}, err
|
||||||
|
}
|
||||||
|
defer unzipped.Close()
|
||||||
|
|
||||||
|
files := []*BufferedFile{}
|
||||||
|
tr := tar.NewReader(unzipped)
|
||||||
|
for {
|
||||||
|
b := bytes.NewBuffer(nil)
|
||||||
|
hd, err := tr.Next()
|
||||||
|
if err == io.EOF {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return &chart.Chart{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if hd.FileInfo().IsDir() {
|
||||||
|
// Use this instead of hd.Typeflag because we don't have to do any
|
||||||
|
// inference chasing.
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Archive could contain \ if generated on Windows
|
||||||
|
delimiter := "/"
|
||||||
|
if strings.ContainsRune(hd.Name, '\\') {
|
||||||
|
delimiter = "\\"
|
||||||
|
}
|
||||||
|
|
||||||
|
parts := strings.Split(hd.Name, delimiter)
|
||||||
|
n := strings.Join(parts[1:], delimiter)
|
||||||
|
|
||||||
|
// Normalize the path to the / delimiter
|
||||||
|
n = strings.Replace(n, delimiter, "/", -1)
|
||||||
|
|
||||||
|
if parts[0] == "Chart.yaml" {
|
||||||
|
return nil, errors.New("chart yaml not in base directory")
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := io.Copy(b, tr); err != nil {
|
||||||
|
return &chart.Chart{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
files = append(files, &BufferedFile{Name: n, Data: b.Bytes()})
|
||||||
|
b.Reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(files) == 0 {
|
||||||
|
return nil, errors.New("no files in chart archive")
|
||||||
|
}
|
||||||
|
|
||||||
|
return LoadFiles(files)
|
||||||
|
}
|
@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package loader
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
"k8s.io/helm/pkg/chart"
|
||||||
|
"k8s.io/helm/pkg/ignore"
|
||||||
|
"k8s.io/helm/pkg/sympath"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DirLoader string
|
||||||
|
|
||||||
|
func (l DirLoader) Load() (*chart.Chart, error) {
|
||||||
|
return LoadDir(string(l))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadDir loads from a directory.
|
||||||
|
//
|
||||||
|
// This loads charts only from directories.
|
||||||
|
func LoadDir(dir string) (*chart.Chart, error) {
|
||||||
|
topdir, err := filepath.Abs(dir)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Just used for errors.
|
||||||
|
c := &chart.Chart{}
|
||||||
|
|
||||||
|
rules := ignore.Empty()
|
||||||
|
ifile := filepath.Join(topdir, ignore.HelmIgnore)
|
||||||
|
if _, err := os.Stat(ifile); err == nil {
|
||||||
|
r, err := ignore.ParseFile(ifile)
|
||||||
|
if err != nil {
|
||||||
|
return c, err
|
||||||
|
}
|
||||||
|
rules = r
|
||||||
|
}
|
||||||
|
rules.AddDefaults()
|
||||||
|
|
||||||
|
files := []*BufferedFile{}
|
||||||
|
topdir += string(filepath.Separator)
|
||||||
|
|
||||||
|
walk := func(name string, fi os.FileInfo, err error) error {
|
||||||
|
n := strings.TrimPrefix(name, topdir)
|
||||||
|
if n == "" {
|
||||||
|
// No need to process top level. Avoid bug with helmignore .* matching
|
||||||
|
// empty names. See issue 1779.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normalize to / since it will also work on Windows
|
||||||
|
n = filepath.ToSlash(n)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if fi.IsDir() {
|
||||||
|
// Directory-based ignore rules should involve skipping the entire
|
||||||
|
// contents of that directory.
|
||||||
|
if rules.Ignore(n, fi) {
|
||||||
|
return filepath.SkipDir
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// If a .helmignore file matches, skip this file.
|
||||||
|
if rules.Ignore(n, fi) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := ioutil.ReadFile(name)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrapf(err, "error reading %s", n)
|
||||||
|
}
|
||||||
|
|
||||||
|
files = append(files, &BufferedFile{Name: n, Data: data})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if err = sympath.Walk(topdir, walk); err != nil {
|
||||||
|
return c, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return LoadFiles(files)
|
||||||
|
}
|
@ -0,0 +1,151 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package loader
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/ghodss/yaml"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
"k8s.io/helm/pkg/chart"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ChartLoader interface {
|
||||||
|
Load() (*chart.Chart, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Loader(name string) (ChartLoader, error) {
|
||||||
|
fi, err := os.Stat(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if fi.IsDir() {
|
||||||
|
return DirLoader(name), nil
|
||||||
|
}
|
||||||
|
return FileLoader(name), nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load takes a string name, tries to resolve it to a file or directory, and then loads it.
|
||||||
|
//
|
||||||
|
// This is the preferred way to load a chart. It will discover the chart encoding
|
||||||
|
// and hand off to the appropriate chart reader.
|
||||||
|
//
|
||||||
|
// If a .helmignore file is present, the directory loader will skip loading any files
|
||||||
|
// matching it. But .helmignore is not evaluated when reading out of an archive.
|
||||||
|
func Load(name string) (*chart.Chart, error) {
|
||||||
|
l, err := Loader(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return l.Load()
|
||||||
|
}
|
||||||
|
|
||||||
|
// BufferedFile represents an archive file buffered for later processing.
|
||||||
|
type BufferedFile struct {
|
||||||
|
Name string
|
||||||
|
Data []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadFiles loads from in-memory files.
|
||||||
|
func LoadFiles(files []*BufferedFile) (*chart.Chart, error) {
|
||||||
|
c := new(chart.Chart)
|
||||||
|
subcharts := make(map[string][]*BufferedFile)
|
||||||
|
|
||||||
|
for _, f := range files {
|
||||||
|
switch {
|
||||||
|
case f.Name == "Chart.yaml":
|
||||||
|
c.Metadata = new(chart.Metadata)
|
||||||
|
if err := yaml.Unmarshal(f.Data, c.Metadata); err != nil {
|
||||||
|
return c, errors.Wrap(err, "cannot load Chart.yaml")
|
||||||
|
}
|
||||||
|
case f.Name == "requirements.yaml":
|
||||||
|
c.Requirements = new(chart.Requirements)
|
||||||
|
if err := yaml.Unmarshal(f.Data, c.Requirements); err != nil {
|
||||||
|
return c, errors.Wrap(err, "cannot load requirements.yaml")
|
||||||
|
}
|
||||||
|
case f.Name == "requirements.lock":
|
||||||
|
c.RequirementsLock = new(chart.RequirementsLock)
|
||||||
|
if err := yaml.Unmarshal(f.Data, &c.RequirementsLock); err != nil {
|
||||||
|
return c, errors.Wrap(err, "cannot load requirements.lock")
|
||||||
|
}
|
||||||
|
case f.Name == "values.yaml":
|
||||||
|
c.Values = f.Data
|
||||||
|
case strings.HasPrefix(f.Name, "templates/"):
|
||||||
|
c.Templates = append(c.Templates, &chart.File{Name: f.Name, Data: f.Data})
|
||||||
|
case strings.HasPrefix(f.Name, "charts/"):
|
||||||
|
if filepath.Ext(f.Name) == ".prov" {
|
||||||
|
c.Files = append(c.Files, &chart.File{Name: f.Name, Data: f.Data})
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
fname := strings.TrimPrefix(f.Name, "charts/")
|
||||||
|
cname := strings.SplitN(fname, "/", 2)[0]
|
||||||
|
subcharts[cname] = append(subcharts[cname], &BufferedFile{Name: fname, Data: f.Data})
|
||||||
|
default:
|
||||||
|
c.Files = append(c.Files, &chart.File{Name: f.Name, Data: f.Data})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure that we got a Chart.yaml file
|
||||||
|
if c.Metadata == nil {
|
||||||
|
return c, errors.New("chart metadata (Chart.yaml) missing")
|
||||||
|
}
|
||||||
|
if c.Name() == "" {
|
||||||
|
return c, errors.New("invalid chart (Chart.yaml): name must not be empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
for n, files := range subcharts {
|
||||||
|
var sc *chart.Chart
|
||||||
|
var err error
|
||||||
|
switch {
|
||||||
|
case strings.IndexAny(n, "_.") == 0:
|
||||||
|
continue
|
||||||
|
case filepath.Ext(n) == ".tgz":
|
||||||
|
file := files[0]
|
||||||
|
if file.Name != n {
|
||||||
|
return c, errors.Errorf("error unpacking tar in %s: expected %s, got %s", c.Name(), n, file.Name)
|
||||||
|
}
|
||||||
|
// Untar the chart and add to c.Dependencies
|
||||||
|
sc, err = LoadArchive(bytes.NewBuffer(file.Data))
|
||||||
|
default:
|
||||||
|
// We have to trim the prefix off of every file, and ignore any file
|
||||||
|
// that is in charts/, but isn't actually a chart.
|
||||||
|
buff := make([]*BufferedFile, 0, len(files))
|
||||||
|
for _, f := range files {
|
||||||
|
parts := strings.SplitN(f.Name, "/", 2)
|
||||||
|
if len(parts) < 2 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
f.Name = parts[1]
|
||||||
|
buff = append(buff, f)
|
||||||
|
}
|
||||||
|
sc, err = LoadFiles(buff)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return c, errors.Wrapf(err, "error unpacking %s in %s", n, c.Name())
|
||||||
|
}
|
||||||
|
c.AddDependency(sc)
|
||||||
|
}
|
||||||
|
|
||||||
|
return c, nil
|
||||||
|
}
|
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
ignore/
|
@ -0,0 +1,20 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
name: frobnitz
|
||||||
|
description: This is a frobnitz.
|
||||||
|
version: "1.2.3"
|
||||||
|
keywords:
|
||||||
|
- frobnitz
|
||||||
|
- sprocket
|
||||||
|
- dodad
|
||||||
|
maintainers:
|
||||||
|
- name: The Helm Team
|
||||||
|
email: helm@example.com
|
||||||
|
- name: Someone Else
|
||||||
|
email: nobody@example.com
|
||||||
|
sources:
|
||||||
|
- https://example.com/foo/bar
|
||||||
|
home: http://example.com
|
||||||
|
icon: https://example.com/64x64.png
|
||||||
|
annotations:
|
||||||
|
extrakey: extravalue
|
||||||
|
anotherkey: anothervalue
|
@ -0,0 +1 @@
|
|||||||
|
This is an install document. The client may display this.
|
@ -0,0 +1 @@
|
|||||||
|
LICENSE placeholder.
|
@ -0,0 +1,11 @@
|
|||||||
|
# Frobnitz
|
||||||
|
|
||||||
|
This is an example chart.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
This is an example. It has no usage.
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
For developer info, see the top-level repository.
|
@ -0,0 +1 @@
|
|||||||
|
This should be ignored by the loader, but may be included in a chart.
|
@ -0,0 +1,4 @@
|
|||||||
|
name: alpine
|
||||||
|
description: Deploy a basic Alpine Linux pod
|
||||||
|
version: 0.1.0
|
||||||
|
home: https://k8s.io/helm
|
@ -0,0 +1,9 @@
|
|||||||
|
This example was generated using the command `helm create alpine`.
|
||||||
|
|
||||||
|
The `templates/` directory contains a very simple pod resource with a
|
||||||
|
couple of parameters.
|
||||||
|
|
||||||
|
The `values.toml` file contains the default values for the
|
||||||
|
`alpine-pod.yaml` template.
|
||||||
|
|
||||||
|
You can install this example using `helm install docs/examples/alpine`.
|
@ -0,0 +1,4 @@
|
|||||||
|
name: mast1
|
||||||
|
description: A Helm chart for Kubernetes
|
||||||
|
version: 0.1.0
|
||||||
|
home: ""
|
@ -0,0 +1,4 @@
|
|||||||
|
# Default values for mast1.
|
||||||
|
# This is a YAML-formatted file.
|
||||||
|
# Declare name/value pairs to be passed into your templates.
|
||||||
|
# name = "value"
|
Binary file not shown.
@ -0,0 +1,14 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: {{.Release.Name}}-{{.Chart.Name}}
|
||||||
|
labels:
|
||||||
|
heritage: {{.Release.Service}}
|
||||||
|
chartName: {{.Chart.Name}}
|
||||||
|
chartVersion: {{.Chart.Version | quote}}
|
||||||
|
spec:
|
||||||
|
restartPolicy: {{default "Never" .restart_policy}}
|
||||||
|
containers:
|
||||||
|
- name: waiter
|
||||||
|
image: "alpine:3.3"
|
||||||
|
command: ["/bin/sleep","9000"]
|
@ -0,0 +1,2 @@
|
|||||||
|
# The pod name
|
||||||
|
name: "my-alpine"
|
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This is a placeholder for documentation.
|
After Width: | Height: | Size: 374 B |
@ -0,0 +1,8 @@
|
|||||||
|
dependencies:
|
||||||
|
- name: alpine
|
||||||
|
version: "0.1.0"
|
||||||
|
repository: https://example.com/charts
|
||||||
|
- name: mariner
|
||||||
|
version: "4.3.2"
|
||||||
|
repository: https://example.com/charts
|
||||||
|
digest: invalid
|
@ -0,0 +1,7 @@
|
|||||||
|
dependencies:
|
||||||
|
- name: alpine
|
||||||
|
version: "0.1.0"
|
||||||
|
repository: https://example.com/charts
|
||||||
|
- name: mariner
|
||||||
|
version: "4.3.2"
|
||||||
|
repository: https://example.com/charts
|
@ -0,0 +1 @@
|
|||||||
|
Hello {{.Name | default "world"}}
|
@ -0,0 +1,6 @@
|
|||||||
|
# A values file contains configuration.
|
||||||
|
|
||||||
|
name: "Some Name"
|
||||||
|
|
||||||
|
section:
|
||||||
|
name: "Name in a section"
|
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
ignore/
|
@ -0,0 +1,20 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
name: frobnitz_backslash
|
||||||
|
description: This is a frobnitz.
|
||||||
|
version: "1.2.3"
|
||||||
|
keywords:
|
||||||
|
- frobnitz
|
||||||
|
- sprocket
|
||||||
|
- dodad
|
||||||
|
maintainers:
|
||||||
|
- name: The Helm Team
|
||||||
|
email: helm@example.com
|
||||||
|
- name: Someone Else
|
||||||
|
email: nobody@example.com
|
||||||
|
sources:
|
||||||
|
- https://example.com/foo/bar
|
||||||
|
home: http://example.com
|
||||||
|
icon: https://example.com/64x64.png
|
||||||
|
annotations:
|
||||||
|
extrakey: extravalue
|
||||||
|
anotherkey: anothervalue
|
@ -0,0 +1 @@
|
|||||||
|
This is an install document. The client may display this.
|
@ -0,0 +1 @@
|
|||||||
|
LICENSE placeholder.
|
@ -0,0 +1,11 @@
|
|||||||
|
# Frobnitz
|
||||||
|
|
||||||
|
This is an example chart.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
This is an example. It has no usage.
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
For developer info, see the top-level repository.
|
@ -0,0 +1 @@
|
|||||||
|
This should be ignored by the loader, but may be included in a chart.
|
@ -0,0 +1,4 @@
|
|||||||
|
name: alpine
|
||||||
|
description: Deploy a basic Alpine Linux pod
|
||||||
|
version: 0.1.0
|
||||||
|
home: https://k8s.io/helm
|
@ -0,0 +1,9 @@
|
|||||||
|
This example was generated using the command `helm create alpine`.
|
||||||
|
|
||||||
|
The `templates/` directory contains a very simple pod resource with a
|
||||||
|
couple of parameters.
|
||||||
|
|
||||||
|
The `values.toml` file contains the default values for the
|
||||||
|
`alpine-pod.yaml` template.
|
||||||
|
|
||||||
|
You can install this example using `helm install docs/examples/alpine`.
|
@ -0,0 +1,4 @@
|
|||||||
|
name: mast1
|
||||||
|
description: A Helm chart for Kubernetes
|
||||||
|
version: 0.1.0
|
||||||
|
home: ""
|
@ -0,0 +1,4 @@
|
|||||||
|
# Default values for mast1.
|
||||||
|
# This is a YAML-formatted file.
|
||||||
|
# Declare name/value pairs to be passed into your templates.
|
||||||
|
# name = "value"
|
Binary file not shown.
@ -0,0 +1,14 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: {{.Release.Name}}-{{.Chart.Name}}
|
||||||
|
labels:
|
||||||
|
heritage: {{.Release.Service}}
|
||||||
|
chartName: {{.Chart.Name}}
|
||||||
|
chartVersion: {{.Chart.Version | quote}}
|
||||||
|
spec:
|
||||||
|
restartPolicy: {{default "Never" .restart_policy}}
|
||||||
|
containers:
|
||||||
|
- name: waiter
|
||||||
|
image: "alpine:3.3"
|
||||||
|
command: ["/bin/sleep","9000"]
|
@ -0,0 +1,2 @@
|
|||||||
|
# The pod name
|
||||||
|
name: "my-alpine"
|
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
This is a placeholder for documentation.
|
After Width: | Height: | Size: 374 B |
@ -0,0 +1,8 @@
|
|||||||
|
dependencies:
|
||||||
|
- name: alpine
|
||||||
|
version: "0.1.0"
|
||||||
|
repository: https://example.com/charts
|
||||||
|
- name: mariner
|
||||||
|
version: "4.3.2"
|
||||||
|
repository: https://example.com/charts
|
||||||
|
digest: invalid
|
@ -0,0 +1,7 @@
|
|||||||
|
dependencies:
|
||||||
|
- name: alpine
|
||||||
|
version: "0.1.0"
|
||||||
|
repository: https://example.com/charts
|
||||||
|
- name: mariner
|
||||||
|
version: "4.3.2"
|
||||||
|
repository: https://example.com/charts
|
@ -0,0 +1 @@
|
|||||||
|
Hello {{.Name | default "world"}}
|
@ -0,0 +1,6 @@
|
|||||||
|
# A values file contains configuration.
|
||||||
|
|
||||||
|
name: "Some Name"
|
||||||
|
|
||||||
|
section:
|
||||||
|
name: "Name in a section"
|
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2018 The Kubernetes Authors All rights reserved.
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package chart
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// Dependency describes a chart upon which another chart depends.
|
||||||
|
//
|
||||||
|
// Dependencies can be used to express developer intent, or to capture the state
|
||||||
|
// of a chart.
|
||||||
|
type Dependency struct {
|
||||||
|
// Name is the name of the dependency.
|
||||||
|
//
|
||||||
|
// This must mach the name in the dependency's Chart.yaml.
|
||||||
|
Name string `json:"name"`
|
||||||
|
// Version is the version (range) of this chart.
|
||||||
|
//
|
||||||
|
// A lock file will always produce a single version, while a dependency
|
||||||
|
// may contain a semantic version range.
|
||||||
|
Version string `json:"version,omitempty"`
|
||||||
|
// The URL to the repository.
|
||||||
|
//
|
||||||
|
// Appending `index.yaml` to this string should result in a URL that can be
|
||||||
|
// used to fetch the repository index.
|
||||||
|
Repository string `json:"repository"`
|
||||||
|
// A yaml path that resolves to a boolean, used for enabling/disabling charts (e.g. subchart1.enabled )
|
||||||
|
Condition string `json:"condition,omitempty"`
|
||||||
|
// Tags can be used to group charts for enabling/disabling together
|
||||||
|
Tags []string `json:"tags,omitempty"`
|
||||||
|
// Enabled bool determines if chart should be loaded
|
||||||
|
Enabled bool `json:"enabled,omitempty"`
|
||||||
|
// ImportValues holds the mapping of source values to parent key to be imported. Each item can be a
|
||||||
|
// string or pair of child/parent sublist items.
|
||||||
|
ImportValues []interface{} `json:"import-values,omitempty"`
|
||||||
|
// Alias usable alias to be used for the chart
|
||||||
|
Alias string `json:"alias,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Requirements is a list of requirements for a chart.
|
||||||
|
//
|
||||||
|
// Requirements are charts upon which this chart depends. This expresses
|
||||||
|
// developer intent.
|
||||||
|
type Requirements struct {
|
||||||
|
Dependencies []*Dependency `json:"dependencies"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RequirementsLock is a lock file for requirements.
|
||||||
|
//
|
||||||
|
// It represents the state that the dependencies should be in.
|
||||||
|
type RequirementsLock struct {
|
||||||
|
// Genderated is the date the lock file was last generated.
|
||||||
|
Generated time.Time `json:"generated"`
|
||||||
|
// Digest is a hash of the requirements file used to generate it.
|
||||||
|
Digest string `json:"digest"`
|
||||||
|
// Dependencies is the list of dependencies that this lock file has locked.
|
||||||
|
Dependencies []*Dependency `json:"dependencies"`
|
||||||
|
}
|
@ -1,286 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2016 The Kubernetes Authors All rights reserved.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package chartutil
|
|
||||||
|
|
||||||
import (
|
|
||||||
"archive/tar"
|
|
||||||
"bytes"
|
|
||||||
"compress/gzip"
|
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"k8s.io/helm/pkg/hapi/chart"
|
|
||||||
"k8s.io/helm/pkg/ignore"
|
|
||||||
"k8s.io/helm/pkg/sympath"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Load takes a string name, tries to resolve it to a file or directory, and then loads it.
|
|
||||||
//
|
|
||||||
// This is the preferred way to load a chart. It will discover the chart encoding
|
|
||||||
// and hand off to the appropriate chart reader.
|
|
||||||
//
|
|
||||||
// If a .helmignore file is present, the directory loader will skip loading any files
|
|
||||||
// matching it. But .helmignore is not evaluated when reading out of an archive.
|
|
||||||
func Load(name string) (*chart.Chart, error) {
|
|
||||||
fi, err := os.Stat(name)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if fi.IsDir() {
|
|
||||||
if validChart, err := IsChartDir(name); !validChart {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return LoadDir(name)
|
|
||||||
}
|
|
||||||
return LoadFile(name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// BufferedFile represents an archive file buffered for later processing.
|
|
||||||
type BufferedFile struct {
|
|
||||||
Name string
|
|
||||||
Data []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
// LoadArchive loads from a reader containing a compressed tar archive.
|
|
||||||
func LoadArchive(in io.Reader) (*chart.Chart, error) {
|
|
||||||
unzipped, err := gzip.NewReader(in)
|
|
||||||
if err != nil {
|
|
||||||
return &chart.Chart{}, err
|
|
||||||
}
|
|
||||||
defer unzipped.Close()
|
|
||||||
|
|
||||||
files := []*BufferedFile{}
|
|
||||||
tr := tar.NewReader(unzipped)
|
|
||||||
for {
|
|
||||||
b := bytes.NewBuffer(nil)
|
|
||||||
hd, err := tr.Next()
|
|
||||||
if err == io.EOF {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return &chart.Chart{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if hd.FileInfo().IsDir() {
|
|
||||||
// Use this instead of hd.Typeflag because we don't have to do any
|
|
||||||
// inference chasing.
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// Archive could contain \ if generated on Windows
|
|
||||||
delimiter := "/"
|
|
||||||
if strings.ContainsRune(hd.Name, '\\') {
|
|
||||||
delimiter = "\\"
|
|
||||||
}
|
|
||||||
|
|
||||||
parts := strings.Split(hd.Name, delimiter)
|
|
||||||
n := strings.Join(parts[1:], delimiter)
|
|
||||||
|
|
||||||
// Normalize the path to the / delimiter
|
|
||||||
n = strings.Replace(n, delimiter, "/", -1)
|
|
||||||
|
|
||||||
if parts[0] == "Chart.yaml" {
|
|
||||||
return nil, errors.New("chart yaml not in base directory")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := io.Copy(b, tr); err != nil {
|
|
||||||
return &chart.Chart{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
files = append(files, &BufferedFile{Name: n, Data: b.Bytes()})
|
|
||||||
b.Reset()
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(files) == 0 {
|
|
||||||
return nil, errors.New("no files in chart archive")
|
|
||||||
}
|
|
||||||
|
|
||||||
return LoadFiles(files)
|
|
||||||
}
|
|
||||||
|
|
||||||
// LoadFiles loads from in-memory files.
|
|
||||||
func LoadFiles(files []*BufferedFile) (*chart.Chart, error) {
|
|
||||||
c := &chart.Chart{}
|
|
||||||
subcharts := map[string][]*BufferedFile{}
|
|
||||||
|
|
||||||
for _, f := range files {
|
|
||||||
if f.Name == "Chart.yaml" {
|
|
||||||
m, err := UnmarshalChartfile(f.Data)
|
|
||||||
if err != nil {
|
|
||||||
return c, err
|
|
||||||
}
|
|
||||||
c.Metadata = m
|
|
||||||
} else if f.Name == "values.toml" {
|
|
||||||
return c, errors.New("values.toml is illegal as of 2.0.0-alpha.2")
|
|
||||||
} else if f.Name == "values.yaml" {
|
|
||||||
c.Values = f.Data
|
|
||||||
} else if strings.HasPrefix(f.Name, "templates/") {
|
|
||||||
c.Templates = append(c.Templates, &chart.File{Name: f.Name, Data: f.Data})
|
|
||||||
} else if strings.HasPrefix(f.Name, "charts/") {
|
|
||||||
if filepath.Ext(f.Name) == ".prov" {
|
|
||||||
c.Files = append(c.Files, &chart.File{Name: f.Name, Data: f.Data})
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
cname := strings.TrimPrefix(f.Name, "charts/")
|
|
||||||
if strings.IndexAny(cname, "._") == 0 {
|
|
||||||
// Ignore charts/ that start with . or _.
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
parts := strings.SplitN(cname, "/", 2)
|
|
||||||
scname := parts[0]
|
|
||||||
subcharts[scname] = append(subcharts[scname], &BufferedFile{Name: cname, Data: f.Data})
|
|
||||||
} else {
|
|
||||||
c.Files = append(c.Files, &chart.File{Name: f.Name, Data: f.Data})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure that we got a Chart.yaml file
|
|
||||||
if c.Metadata == nil {
|
|
||||||
return c, errors.New("chart metadata (Chart.yaml) missing")
|
|
||||||
}
|
|
||||||
if c.Metadata.Name == "" {
|
|
||||||
return c, errors.New("invalid chart (Chart.yaml): name must not be empty")
|
|
||||||
}
|
|
||||||
|
|
||||||
for n, files := range subcharts {
|
|
||||||
var sc *chart.Chart
|
|
||||||
var err error
|
|
||||||
if strings.IndexAny(n, "_.") == 0 {
|
|
||||||
continue
|
|
||||||
} else if filepath.Ext(n) == ".tgz" {
|
|
||||||
file := files[0]
|
|
||||||
if file.Name != n {
|
|
||||||
return c, errors.Errorf("error unpacking tar in %s: expected %s, got %s", c.Metadata.Name, n, file.Name)
|
|
||||||
}
|
|
||||||
// Untar the chart and add to c.Dependencies
|
|
||||||
b := bytes.NewBuffer(file.Data)
|
|
||||||
sc, err = LoadArchive(b)
|
|
||||||
} else {
|
|
||||||
// We have to trim the prefix off of every file, and ignore any file
|
|
||||||
// that is in charts/, but isn't actually a chart.
|
|
||||||
buff := make([]*BufferedFile, 0, len(files))
|
|
||||||
for _, f := range files {
|
|
||||||
parts := strings.SplitN(f.Name, "/", 2)
|
|
||||||
if len(parts) < 2 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
f.Name = parts[1]
|
|
||||||
buff = append(buff, f)
|
|
||||||
}
|
|
||||||
sc, err = LoadFiles(buff)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return c, errors.Wrapf(err, "error unpacking %s in %s", n, c.Metadata.Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
c.Dependencies = append(c.Dependencies, sc)
|
|
||||||
}
|
|
||||||
|
|
||||||
return c, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// LoadFile loads from an archive file.
|
|
||||||
func LoadFile(name string) (*chart.Chart, error) {
|
|
||||||
if fi, err := os.Stat(name); err != nil {
|
|
||||||
return nil, err
|
|
||||||
} else if fi.IsDir() {
|
|
||||||
return nil, errors.New("cannot load a directory")
|
|
||||||
}
|
|
||||||
|
|
||||||
raw, err := os.Open(name)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer raw.Close()
|
|
||||||
|
|
||||||
return LoadArchive(raw)
|
|
||||||
}
|
|
||||||
|
|
||||||
// LoadDir loads from a directory.
|
|
||||||
//
|
|
||||||
// This loads charts only from directories.
|
|
||||||
func LoadDir(dir string) (*chart.Chart, error) {
|
|
||||||
topdir, err := filepath.Abs(dir)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Just used for errors.
|
|
||||||
c := &chart.Chart{}
|
|
||||||
|
|
||||||
rules := ignore.Empty()
|
|
||||||
ifile := filepath.Join(topdir, ignore.HelmIgnore)
|
|
||||||
if _, err := os.Stat(ifile); err == nil {
|
|
||||||
r, err := ignore.ParseFile(ifile)
|
|
||||||
if err != nil {
|
|
||||||
return c, err
|
|
||||||
}
|
|
||||||
rules = r
|
|
||||||
}
|
|
||||||
rules.AddDefaults()
|
|
||||||
|
|
||||||
files := []*BufferedFile{}
|
|
||||||
topdir += string(filepath.Separator)
|
|
||||||
|
|
||||||
walk := func(name string, fi os.FileInfo, err error) error {
|
|
||||||
n := strings.TrimPrefix(name, topdir)
|
|
||||||
if n == "" {
|
|
||||||
// No need to process top level. Avoid bug with helmignore .* matching
|
|
||||||
// empty names. See issue 1779.
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Normalize to / since it will also work on Windows
|
|
||||||
n = filepath.ToSlash(n)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if fi.IsDir() {
|
|
||||||
// Directory-based ignore rules should involve skipping the entire
|
|
||||||
// contents of that directory.
|
|
||||||
if rules.Ignore(n, fi) {
|
|
||||||
return filepath.SkipDir
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// If a .helmignore file matches, skip this file.
|
|
||||||
if rules.Ignore(n, fi) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
data, err := ioutil.ReadFile(name)
|
|
||||||
if err != nil {
|
|
||||||
return errors.Wrapf(err, "error reading %s", n)
|
|
||||||
}
|
|
||||||
|
|
||||||
files = append(files, &BufferedFile{Name: n, Data: data})
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if err = sympath.Walk(topdir, walk); err != nil {
|
|
||||||
return c, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return LoadFiles(files)
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2018 The Kubernetes Authors All rights reserved.
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package chart
|
|
||||||
|
|
||||||
// Chart is a helm package that contains metadata, a default config, zero or more
|
|
||||||
// optionally parameterizable templates, and zero or more charts (dependencies).
|
|
||||||
type Chart struct {
|
|
||||||
// Metadata is the contents of the Chartfile.
|
|
||||||
Metadata *Metadata `json:"metadata,omitempty"`
|
|
||||||
// Templates for this chart.
|
|
||||||
Templates []*File `json:"templates,omitempty"`
|
|
||||||
// Dependencies are the charts that this chart depends on.
|
|
||||||
Dependencies []*Chart `json:"dependencies,omitempty"`
|
|
||||||
// Values are default config for this template.
|
|
||||||
Values []byte `json:"values,omitempty"`
|
|
||||||
// Files are miscellaneous files in a chart archive,
|
|
||||||
// e.g. README, LICENSE, etc.
|
|
||||||
Files []*File `json:"files,omitempty"`
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue