mirror of https://github.com/helm/helm
commit
b143f2b89e
@ -1,12 +1,15 @@
|
||||
To add your organization to this list, simply add your organization's name,
|
||||
optionally with a link. The list is in alphabetical order.
|
||||
To add your organization to this list, open a pull request that adds your
|
||||
organization's name, optionally with a link. The list is in alphabetical order.
|
||||
|
||||
(Remember to use `git commit --signoff` to comply with the DCO)
|
||||
|
||||
# Organizations Using Helm
|
||||
|
||||
- [Blood Orange](https://bloodorange.io)
|
||||
- [Microsoft](https://microsoft.com)
|
||||
- [IBM](https://www.ibm.com)
|
||||
- [Microsoft](https://microsoft.com)
|
||||
- [Qovery](https://www.qovery.com/)
|
||||
- [Samsung SDS](https://www.samsungsds.com/)
|
||||
[Ville de Montreal](https://montreal.ca)
|
||||
- [Ville de Montreal](https://montreal.ca)
|
||||
|
||||
_This file is part of the CNCF official documentation for projects._
|
||||
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
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 main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"helm.sh/helm/v3/pkg/repo/repotest"
|
||||
)
|
||||
|
||||
func TestShowPreReleaseChart(t *testing.T) {
|
||||
srv, err := repotest.NewTempServer("testdata/testcharts/*.tgz*")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer srv.Stop()
|
||||
|
||||
if err := srv.LinkIndices(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
args string
|
||||
flags string
|
||||
fail bool
|
||||
expectedErr string
|
||||
}{
|
||||
{
|
||||
name: "show pre-release chart",
|
||||
args: "test/pre-release-chart",
|
||||
fail: true,
|
||||
expectedErr: "failed to download \"test/pre-release-chart\"",
|
||||
},
|
||||
{
|
||||
name: "show pre-release chart with 'devel' flag",
|
||||
args: "test/pre-release-chart",
|
||||
flags: "--devel",
|
||||
fail: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
outdir := srv.Root()
|
||||
cmd := fmt.Sprintf("show all '%s' %s --repository-config %s --repository-cache %s",
|
||||
tt.args,
|
||||
tt.flags,
|
||||
filepath.Join(outdir, "repositories.yaml"),
|
||||
outdir,
|
||||
)
|
||||
//_, out, err := executeActionCommand(cmd)
|
||||
_, _, err := executeActionCommand(cmd)
|
||||
if err != nil {
|
||||
if tt.fail {
|
||||
if !strings.Contains(err.Error(), tt.expectedErr) {
|
||||
t.Errorf("%q expected error: %s, got: %s", tt.name, tt.expectedErr, err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
t.Errorf("%q reported error: %s", tt.name, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
echo "plugin.complete was called"
|
||||
echo "Namespace: ${HELM_NAMESPACE:-NO_NS}"
|
||||
echo "Num args received: ${#}"
|
||||
echo "Args received: ${@}"
|
||||
|
||||
# Final printout is the optional completion directive of the form :<directive>
|
||||
if [ "$HELM_NAMESPACE" = "default" ]; then
|
||||
echo ":4"
|
||||
else
|
||||
echo ":2"
|
||||
fi
|
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
echo "echo plugin.complete was called"
|
||||
echo "Namespace: ${HELM_NAMESPACE:-NO_NS}"
|
||||
echo "Num args received: ${#}"
|
||||
echo "Args received: ${@}"
|
||||
|
||||
# Final printout is the optional completion directive of the form :<directive>
|
||||
if [ "$HELM_NAMESPACE" = "default" ]; then
|
||||
# Output an invalid directive, which should be ignored
|
||||
echo ":2222"
|
||||
# else
|
||||
# Don't include the directive, to test it is really optional
|
||||
fi
|
@ -0,0 +1,13 @@
|
||||
name: env
|
||||
commands:
|
||||
- name: list
|
||||
flags:
|
||||
- a
|
||||
- all
|
||||
- log
|
||||
- name: remove
|
||||
validArgs:
|
||||
- all
|
||||
- one
|
||||
flags:
|
||||
- global
|
@ -0,0 +1,5 @@
|
||||
commands:
|
||||
- name: code
|
||||
flags:
|
||||
- a
|
||||
- b
|
@ -0,0 +1,19 @@
|
||||
name: wrongname
|
||||
commands:
|
||||
- name: empty
|
||||
- name: full
|
||||
commands:
|
||||
- name: more
|
||||
validArgs:
|
||||
- one
|
||||
- two
|
||||
flags:
|
||||
- b
|
||||
- ball
|
||||
- name: less
|
||||
flags:
|
||||
- a
|
||||
- all
|
||||
flags:
|
||||
- z
|
||||
- q
|
@ -0,0 +1,5 @@
|
||||
plugin.complete was called
|
||||
Namespace: default
|
||||
Num args received: 1
|
||||
Args received:
|
||||
:4
|
@ -0,0 +1,5 @@
|
||||
plugin.complete was called
|
||||
Namespace: default
|
||||
Num args received: 2
|
||||
Args received: --myflag
|
||||
:4
|
@ -0,0 +1,5 @@
|
||||
plugin.complete was called
|
||||
Namespace: mynamespace
|
||||
Num args received: 2
|
||||
Args received: --myflag start
|
||||
:2
|
@ -0,0 +1,5 @@
|
||||
plugin.complete was called
|
||||
Namespace: mynamespace
|
||||
Num args received: 1
|
||||
Args received:
|
||||
:2
|
@ -0,0 +1,5 @@
|
||||
echo plugin.complete was called
|
||||
Namespace: default
|
||||
Num args received: 1
|
||||
Args received:
|
||||
:0
|
@ -0,0 +1,5 @@
|
||||
echo plugin.complete was called
|
||||
Namespace: mynamespace
|
||||
Num args received: 1
|
||||
Args received:
|
||||
:0
|
@ -0,0 +1,13 @@
|
||||
---
|
||||
# Source: chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: "RELEASE-NAME-my-alpine"
|
||||
spec:
|
||||
containers:
|
||||
- name: waiter
|
||||
image: "alpine:3.9"
|
||||
command: ["/bin/sleep","9000"]
|
||||
invalid
|
||||
Error: YAML parse error on chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml: error converting YAML to JSON: yaml: line 11: could not find expected ':'
|
@ -0,0 +1,3 @@
|
||||
Error: YAML parse error on chart-with-template-with-invalid-yaml/templates/alpine-pod.yaml: error converting YAML to JSON: yaml: line 11: could not find expected ':'
|
||||
|
||||
Use --debug flag to render out invalid YAML
|
@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
description: Deploy a basic Alpine Linux pod
|
||||
home: https://helm.sh/helm
|
||||
name: chart-with-template-with-invalid-yaml
|
||||
sources:
|
||||
- https://github.com/helm/helm
|
||||
version: 0.1.0
|
||||
type: application
|
@ -0,0 +1,13 @@
|
||||
#Alpine: A simple Helm chart
|
||||
|
||||
Run a single pod of Alpine Linux.
|
||||
|
||||
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.yaml` file contains the default values for the
|
||||
`alpine-pod.yaml` template.
|
||||
|
||||
You can install this example using `helm install ./alpine`.
|
@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: "{{.Release.Name}}-{{.Values.Name}}"
|
||||
spec:
|
||||
containers:
|
||||
- name: waiter
|
||||
image: "alpine:3.9"
|
||||
command: ["/bin/sleep","9000"]
|
||||
invalid
|
@ -0,0 +1 @@
|
||||
Name: my-alpine
|
@ -0,0 +1,123 @@
|
||||
/*
|
||||
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"
|
||||
|
||||
"helm.sh/helm/v3/pkg/kube"
|
||||
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/cli-runtime/pkg/resource"
|
||||
)
|
||||
|
||||
func newDeploymentResource(name, namespace string) *resource.Info {
|
||||
return &resource.Info{
|
||||
Name: name,
|
||||
Mapping: &meta.RESTMapping{
|
||||
Resource: schema.GroupVersionResource{Group: "apps", Version: "v1", Resource: "deployment"},
|
||||
GroupVersionKind: schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "Deployment"},
|
||||
},
|
||||
Object: &appsv1.Deployment{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckOwnership(t *testing.T) {
|
||||
deployFoo := newDeploymentResource("foo", "ns-a")
|
||||
|
||||
// Verify that a resource that lacks labels/annotations is not owned
|
||||
err := checkOwnership(deployFoo.Object, "rel-a", "ns-a")
|
||||
assert.EqualError(t, err, `invalid ownership metadata; label validation error: missing key "app.kubernetes.io/managed-by": must be set to "Helm"; annotation validation error: missing key "meta.helm.sh/release-name": must be set to "rel-a"; annotation validation error: missing key "meta.helm.sh/release-namespace": must be set to "ns-a"`)
|
||||
|
||||
// Set managed by label and verify annotation error message
|
||||
_ = accessor.SetLabels(deployFoo.Object, map[string]string{
|
||||
appManagedByLabel: appManagedByHelm,
|
||||
})
|
||||
err = checkOwnership(deployFoo.Object, "rel-a", "ns-a")
|
||||
assert.EqualError(t, err, `invalid ownership metadata; annotation validation error: missing key "meta.helm.sh/release-name": must be set to "rel-a"; annotation validation error: missing key "meta.helm.sh/release-namespace": must be set to "ns-a"`)
|
||||
|
||||
// Set only the release name annotation and verify missing release namespace error message
|
||||
_ = accessor.SetAnnotations(deployFoo.Object, map[string]string{
|
||||
helmReleaseNameAnnotation: "rel-a",
|
||||
})
|
||||
err = checkOwnership(deployFoo.Object, "rel-a", "ns-a")
|
||||
assert.EqualError(t, err, `invalid ownership metadata; annotation validation error: missing key "meta.helm.sh/release-namespace": must be set to "ns-a"`)
|
||||
|
||||
// Set both release name and namespace annotations and verify no ownership errors
|
||||
_ = accessor.SetAnnotations(deployFoo.Object, map[string]string{
|
||||
helmReleaseNameAnnotation: "rel-a",
|
||||
helmReleaseNamespaceAnnotation: "ns-a",
|
||||
})
|
||||
err = checkOwnership(deployFoo.Object, "rel-a", "ns-a")
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Verify ownership error for wrong release name
|
||||
err = checkOwnership(deployFoo.Object, "rel-b", "ns-a")
|
||||
assert.EqualError(t, err, `invalid ownership metadata; annotation validation error: key "meta.helm.sh/release-name" must equal "rel-b": current value is "rel-a"`)
|
||||
|
||||
// Verify ownership error for wrong release namespace
|
||||
err = checkOwnership(deployFoo.Object, "rel-a", "ns-b")
|
||||
assert.EqualError(t, err, `invalid ownership metadata; annotation validation error: key "meta.helm.sh/release-namespace" must equal "ns-b": current value is "ns-a"`)
|
||||
|
||||
// Verify ownership error for wrong manager label
|
||||
_ = accessor.SetLabels(deployFoo.Object, map[string]string{
|
||||
appManagedByLabel: "helm",
|
||||
})
|
||||
err = checkOwnership(deployFoo.Object, "rel-a", "ns-a")
|
||||
assert.EqualError(t, err, `invalid ownership metadata; label validation error: key "app.kubernetes.io/managed-by" must equal "Helm": current value is "helm"`)
|
||||
}
|
||||
|
||||
func TestSetMetadataVisitor(t *testing.T) {
|
||||
var (
|
||||
err error
|
||||
deployFoo = newDeploymentResource("foo", "ns-a")
|
||||
deployBar = newDeploymentResource("bar", "ns-a-system")
|
||||
resources = kube.ResourceList{deployFoo, deployBar}
|
||||
)
|
||||
|
||||
// Set release tracking metadata and verify no error
|
||||
err = resources.Visit(setMetadataVisitor("rel-a", "ns-a", true))
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Verify that release "b" cannot take ownership of "a"
|
||||
err = resources.Visit(setMetadataVisitor("rel-b", "ns-a", false))
|
||||
assert.Error(t, err)
|
||||
|
||||
// Force release "b" to take ownership
|
||||
err = resources.Visit(setMetadataVisitor("rel-b", "ns-a", true))
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Check that there is now no ownership error when setting metadata without force
|
||||
err = resources.Visit(setMetadataVisitor("rel-b", "ns-a", false))
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Add a new resource that is missing ownership metadata and verify error
|
||||
resources.Append(newDeploymentResource("baz", "default"))
|
||||
err = resources.Visit(setMetadataVisitor("rel-b", "ns-a", false))
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), `Deployment "baz" in namespace "" cannot be owned`)
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
dependencies:
|
||||
- name: dev
|
||||
repository: file://envs/dev
|
||||
version: v0.1.0
|
||||
- name: prod
|
||||
repository: file://envs/prod
|
||||
version: v0.1.0
|
||||
digest: sha256:9403fc24f6cf9d6055820126cf7633b4bd1fed3c77e4880c674059f536346182
|
||||
generated: "2020-02-03T10:38:51.180474+01:00"
|
@ -0,0 +1,22 @@
|
||||
apiVersion: v2
|
||||
name: parent-chart
|
||||
version: v0.1.0
|
||||
appVersion: v0.1.0
|
||||
dependencies:
|
||||
- name: dev
|
||||
repository: "file://envs/dev"
|
||||
version: ">= 0.0.1"
|
||||
condition: dev.enabled,global.dev.enabled
|
||||
tags:
|
||||
- dev
|
||||
import-values:
|
||||
- data
|
||||
|
||||
- name: prod
|
||||
repository: "file://envs/prod"
|
||||
version: ">= 0.0.1"
|
||||
condition: prod.enabled,global.prod.enabled
|
||||
tags:
|
||||
- prod
|
||||
import-values:
|
||||
- data
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,4 @@
|
||||
apiVersion: v2
|
||||
name: dev
|
||||
version: v0.1.0
|
||||
appVersion: v0.1.0
|
@ -0,0 +1,9 @@
|
||||
# Dev values parent-chart
|
||||
nameOverride: parent-chart-dev
|
||||
exports:
|
||||
data:
|
||||
resources:
|
||||
autoscaler:
|
||||
minReplicas: 1
|
||||
maxReplicas: 3
|
||||
targetCPUUtilizationPercentage: 80
|
@ -0,0 +1,4 @@
|
||||
apiVersion: v2
|
||||
name: prod
|
||||
version: v0.1.0
|
||||
appVersion: v0.1.0
|
@ -0,0 +1,9 @@
|
||||
# Prod values parent-chart
|
||||
nameOverride: parent-chart-prod
|
||||
exports:
|
||||
data:
|
||||
resources:
|
||||
autoscaler:
|
||||
minReplicas: 2
|
||||
maxReplicas: 5
|
||||
targetCPUUtilizationPercentage: 90
|
@ -0,0 +1,16 @@
|
||||
###################################################################################################
|
||||
# parent-chart horizontal pod autoscaler
|
||||
###################################################################################################
|
||||
apiVersion: autoscaling/v1
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-autoscaler
|
||||
namespace: {{ .Release.Namespace }}
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1beta1
|
||||
kind: Deployment
|
||||
name: {{ .Release.Name }}
|
||||
minReplicas: {{ required "A valid .Values.resources.autoscaler.minReplicas entry required!" .Values.resources.autoscaler.minReplicas }}
|
||||
maxReplicas: {{ required "A valid .Values.resources.autoscaler.maxReplicas entry required!" .Values.resources.autoscaler.maxReplicas }}
|
||||
targetCPUUtilizationPercentage: {{ required "A valid .Values.resources.autoscaler.targetCPUUtilizationPercentage!" .Values.resources.autoscaler.targetCPUUtilizationPercentage }}
|
@ -0,0 +1,10 @@
|
||||
# Default values for parent-chart.
|
||||
nameOverride: parent-chart
|
||||
tags:
|
||||
dev: false
|
||||
prod: true
|
||||
resources:
|
||||
autoscaler:
|
||||
minReplicas: 0
|
||||
maxReplicas: 0
|
||||
targetCPUUtilizationPercentage: 99
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
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 kube // import "helm.sh/helm/v3/pkg/kube"
|
||||
|
||||
// ResourcePolicyAnno is the annotation name for a resource policy
|
||||
const ResourcePolicyAnno = "helm.sh/resource-policy"
|
||||
|
||||
// KeepPolicy is the resource policy type for keep
|
||||
//
|
||||
// This resource policy type allows resources to skip being deleted
|
||||
// during an uninstallRelease action.
|
||||
const KeepPolicy = "keep"
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
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 rules
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var (
|
||||
nonExistingValuesFilePath = filepath.Join("/fake/dir", "values.yaml")
|
||||
)
|
||||
|
||||
func TestValidateValuesYamlNotDirectory(t *testing.T) {
|
||||
_ = os.Mkdir(nonExistingValuesFilePath, os.ModePerm)
|
||||
defer os.Remove(nonExistingValuesFilePath)
|
||||
|
||||
err := validateValuesFileExistence(nonExistingValuesFilePath)
|
||||
if err == nil {
|
||||
t.Errorf("validateValuesFileExistence to return a linter error, got no error")
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue