mirror of https://github.com/helm/helm
Merge 24f643364d
into 299a6463a0
commit
c6222b78ac
@ -0,0 +1 @@
|
|||||||
|
glob-external-1
|
@ -0,0 +1 @@
|
|||||||
|
glob-external-2
|
@ -0,0 +1 @@
|
|||||||
|
out-of-chart-dir
|
@ -0,0 +1,6 @@
|
|||||||
|
NAME: virgil
|
||||||
|
LAST DEPLOYED: Fri Sep 2 22:04:05 1977
|
||||||
|
NAMESPACE: default
|
||||||
|
STATUS: deployed
|
||||||
|
REVISION: 1
|
||||||
|
TEST SUITE: None
|
@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
# Source: configmap/templates/config-map.yaml
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: "release-name-"
|
||||||
|
labels:
|
||||||
|
# The "app.kubernetes.io/managed-by" 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.
|
||||||
|
app.kubernetes.io/managed-by: "Helm"
|
||||||
|
# The "app.kubernetes.io/instance" convention makes it easy to tie a release
|
||||||
|
# to all of the Kubernetes resources that were created as part of that
|
||||||
|
# release.
|
||||||
|
app.kubernetes.io/instance: "release-name"
|
||||||
|
app.kubernetes.io/version: 1.0
|
||||||
|
# This makes it easy to audit chart usage.
|
||||||
|
helm.sh/chart: "configmap-0.1.0"
|
||||||
|
data:
|
||||||
|
external.1.conf: |
|
||||||
|
glob-external-1
|
||||||
|
external.2.conf: |
|
||||||
|
glob-external-2
|
||||||
|
external.txt: |
|
||||||
|
out-of-chart-dir
|
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
# Source: configmap/templates/config-map.yaml
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: "release-name-"
|
||||||
|
labels:
|
||||||
|
# The "app.kubernetes.io/managed-by" 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.
|
||||||
|
app.kubernetes.io/managed-by: "Helm"
|
||||||
|
# The "app.kubernetes.io/instance" convention makes it easy to tie a release
|
||||||
|
# to all of the Kubernetes resources that were created as part of that
|
||||||
|
# release.
|
||||||
|
app.kubernetes.io/instance: "release-name"
|
||||||
|
app.kubernetes.io/version: 1.0
|
||||||
|
# This makes it easy to audit chart usage.
|
||||||
|
helm.sh/chart: "configmap-0.1.0"
|
||||||
|
data:
|
||||||
|
external.txt: |
|
||||||
|
out-of-chart-dir
|
@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
# Source: configmap/templates/config-map.yaml
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: "release-name-"
|
||||||
|
labels:
|
||||||
|
# The "app.kubernetes.io/managed-by" 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.
|
||||||
|
app.kubernetes.io/managed-by: "Helm"
|
||||||
|
# The "app.kubernetes.io/instance" convention makes it easy to tie a release
|
||||||
|
# to all of the Kubernetes resources that were created as part of that
|
||||||
|
# release.
|
||||||
|
app.kubernetes.io/instance: "release-name"
|
||||||
|
app.kubernetes.io/version: 1.0
|
||||||
|
# This makes it easy to audit chart usage.
|
||||||
|
helm.sh/chart: "configmap-0.1.0"
|
||||||
|
data:
|
||||||
|
external.1.conf: |
|
||||||
|
glob-external-1
|
||||||
|
external.2.conf: |
|
||||||
|
glob-external-2
|
@ -0,0 +1,8 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
appVersion: "1.0"
|
||||||
|
description: Deploy a basic Config Map from an external file
|
||||||
|
home: https://helm.sh/helm
|
||||||
|
name: configmap
|
||||||
|
sources:
|
||||||
|
- https://github.com/helm/helm
|
||||||
|
version: 0.1.0
|
@ -0,0 +1 @@
|
|||||||
|
in-chart
|
@ -0,0 +1,23 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: "{{.Release.Name}}-{{.Values.Name}}"
|
||||||
|
labels:
|
||||||
|
# The "app.kubernetes.io/managed-by" 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.
|
||||||
|
app.kubernetes.io/managed-by: {{.Release.Service | quote }}
|
||||||
|
# The "app.kubernetes.io/instance" convention makes it easy to tie a release
|
||||||
|
# to all of the Kubernetes resources that were created as part of that
|
||||||
|
# release.
|
||||||
|
app.kubernetes.io/instance: {{.Release.Name | quote }}
|
||||||
|
app.kubernetes.io/version: {{ .Chart.AppVersion }}
|
||||||
|
# This makes it easy to audit chart usage.
|
||||||
|
helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}"
|
||||||
|
data:
|
||||||
|
{{- if .Values.external }}
|
||||||
|
{{ (.Files.Glob .Values.external).AsConfig | indent 2 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.glob.enabled }}
|
||||||
|
{{ (.Files.Glob .Values.glob.path).AsConfig | indent 2 }}
|
||||||
|
{{- end }}
|
@ -0,0 +1,4 @@
|
|||||||
|
external: false
|
||||||
|
glob:
|
||||||
|
enabled: false
|
||||||
|
path: "testdata/files/*"
|
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
Copyright The Helm Authors.
|
||||||
|
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 action
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// expandFilePath expands a local file, dir or glob path to a list of files
|
||||||
|
func expandFilePath(path string) ([]string, error) {
|
||||||
|
if strings.Contains(path, "*") {
|
||||||
|
// if this is a glob, we expand it and return a list of files
|
||||||
|
return expandGlob(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
fileInfo, err := os.Stat(path)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if fileInfo.IsDir() {
|
||||||
|
// if this is a valid dir, we return all files within
|
||||||
|
return expandDir(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
// finally, this is a file, so we return it
|
||||||
|
return []string{path}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func expandGlob(path string) ([]string, error) {
|
||||||
|
paths, err := filepath.Glob(path)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(paths) == 0 {
|
||||||
|
return nil, errors.New("empty glob")
|
||||||
|
}
|
||||||
|
|
||||||
|
return paths, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func expandDir(path string) ([]string, error) {
|
||||||
|
f, err := os.Open(path)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
filesInfos, err := f.Readdir(-1)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var filesPaths []string
|
||||||
|
localDirName := strings.TrimRight(path, "/") + "/"
|
||||||
|
for _, file := range filesInfos {
|
||||||
|
filesPaths = append(filesPaths, localDirName+file.Name())
|
||||||
|
}
|
||||||
|
return filesPaths, nil
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
Copyright The Helm Authors.
|
||||||
|
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 action
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestExpandLocalPath(t *testing.T) {
|
||||||
|
req := require.New(t)
|
||||||
|
|
||||||
|
glob, err := expandFilePath("testdata/output/*.txt")
|
||||||
|
req.NoError(err)
|
||||||
|
req.Contains(glob, "testdata/output/list-compressed-deps.txt")
|
||||||
|
req.Contains(glob, "testdata/output/list-missing-deps.txt")
|
||||||
|
|
||||||
|
dir, err := expandFilePath("testdata/files/")
|
||||||
|
req.NoError(err)
|
||||||
|
req.Contains(dir, "testdata/files/external.txt")
|
||||||
|
|
||||||
|
_, err = expandFilePath("testdata/non_existing")
|
||||||
|
req.Error(err)
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
Copyright The Helm Authors.
|
||||||
|
|
||||||
|
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 action
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func rollbackAction(t *testing.T) *Rollback {
|
||||||
|
config := actionConfigFixture(t)
|
||||||
|
rollbackAction := NewRollback(config)
|
||||||
|
|
||||||
|
return rollbackAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRollbackToReleaseWithExternalFile(t *testing.T) {
|
||||||
|
is := assert.New(t)
|
||||||
|
vals := map[string]interface{}{}
|
||||||
|
|
||||||
|
chartVersion1 := buildChart(withExternalFileTemplate(ExternalFileRelPath))
|
||||||
|
chartVersion2 := buildChart()
|
||||||
|
|
||||||
|
instAction := installAction(t)
|
||||||
|
instAction.ExternalPaths = append(instAction.ExternalPaths, ExternalFileRelPath)
|
||||||
|
relVersion1, err := instAction.Run(chartVersion1, vals)
|
||||||
|
is.Contains(relVersion1.Manifest, "out-of-chart-dir")
|
||||||
|
is.NoError(err)
|
||||||
|
|
||||||
|
upAction := upgradeAction(t)
|
||||||
|
err = upAction.cfg.Releases.Create(relVersion1)
|
||||||
|
is.NoError(err)
|
||||||
|
relVersion2, err := upAction.Run(relVersion1.Name, chartVersion2, vals)
|
||||||
|
is.NotContains(relVersion2.Manifest, "out-out-chart-dir")
|
||||||
|
is.NoError(err)
|
||||||
|
|
||||||
|
rollAction := rollbackAction(t)
|
||||||
|
err = rollAction.cfg.Releases.Create(relVersion1)
|
||||||
|
is.NoError(err)
|
||||||
|
err = rollAction.cfg.Releases.Create(relVersion2)
|
||||||
|
is.NoError(err)
|
||||||
|
currentRelease, targetRelease, err := rollAction.prepareRollback(relVersion2.Name)
|
||||||
|
is.NoError(err)
|
||||||
|
relVersion3, err := rollAction.performRollback(currentRelease, targetRelease)
|
||||||
|
is.NoError(err)
|
||||||
|
|
||||||
|
is.Contains(relVersion3.Manifest, "out-of-chart-dir")
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
out-of-chart-dir
|
Loading…
Reference in new issue