Fix capabilities changes leaking into other tests

Signed-off-by: Thomas Dy <thatsmydoing@gmail.com>
pull/9040/head
Thomas Dy 4 years ago
parent 538670fda6
commit 0156ca61ca

@ -10,7 +10,6 @@ metadata:
kube-version/major: "1" kube-version/major: "1"
kube-version/minor: "20" kube-version/minor: "20"
kube-version/version: "v1.20.0" kube-version/version: "v1.20.0"
kube-api-version/test: v1
spec: spec:
type: ClusterIP type: ClusterIP
ports: ports:

@ -10,7 +10,6 @@ metadata:
kube-version/major: "1" kube-version/major: "1"
kube-version/minor: "20" kube-version/minor: "20"
kube-version/version: "v1.20.0" kube-version/version: "v1.20.0"
kube-api-version/test: v1
spec: spec:
type: ClusterIP type: ClusterIP
ports: ports:

@ -74,7 +74,6 @@ metadata:
kube-version/major: "1" kube-version/major: "1"
kube-version/minor: "20" kube-version/minor: "20"
kube-version/version: "v1.20.0" kube-version/version: "v1.20.0"
kube-api-version/test: v1
spec: spec:
type: ClusterIP type: ClusterIP
ports: ports:

@ -91,7 +91,6 @@ metadata:
kube-version/major: "1" kube-version/major: "1"
kube-version/minor: "20" kube-version/minor: "20"
kube-version/version: "v1.20.0" kube-version/version: "v1.20.0"
kube-api-version/test: v1
spec: spec:
type: ClusterIP type: ClusterIP
ports: ports:

@ -11,7 +11,8 @@ kind: Role
metadata: metadata:
name: subchart-role name: subchart-role
rules: rules:
- resources: ["*"] - apiGroups: [""]
resources: ["pods"]
verbs: ["get","list","watch"] verbs: ["get","list","watch"]
--- ---
# Source: subchart/templates/subdir/rolebinding.yaml # Source: subchart/templates/subdir/rolebinding.yaml
@ -82,3 +83,32 @@ spec:
name: nginx name: nginx
selector: selector:
app.kubernetes.io/name: subchart app.kubernetes.io/name: subchart
---
# Source: subchart/templates/tests/test-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: "RELEASE-NAME-testconfig"
annotations:
"helm.sh/hook": test
data:
message: Hello World
---
# Source: subchart/templates/tests/test-nothing.yaml
apiVersion: v1
kind: Pod
metadata:
name: "RELEASE-NAME-test"
annotations:
"helm.sh/hook": test
spec:
containers:
- name: test
image: "alpine:latest"
envFrom:
- configMapRef:
name: "RELEASE-NAME-testconfig"
command:
- echo
- "$message"
restartPolicy: Never

@ -198,7 +198,7 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release.
if i.ClientOnly { if i.ClientOnly {
// Add mock objects in here so it doesn't use Kube API server // Add mock objects in here so it doesn't use Kube API server
// NOTE(bacongobbler): used for `helm template` // NOTE(bacongobbler): used for `helm template`
i.cfg.Capabilities = chartutil.DefaultCapabilities i.cfg.Capabilities = chartutil.DefaultCapabilities.Copy()
if i.KubeVersion != nil { if i.KubeVersion != nil {
i.cfg.Capabilities.KubeVersion = *i.KubeVersion i.cfg.Capabilities.KubeVersion = *i.KubeVersion
} }

@ -59,6 +59,14 @@ type Capabilities struct {
HelmVersion helmversion.BuildInfo HelmVersion helmversion.BuildInfo
} }
func (capabilities *Capabilities) Copy() *Capabilities {
return &Capabilities{
KubeVersion: capabilities.KubeVersion,
APIVersions: capabilities.APIVersions,
HelmVersion: capabilities.HelmVersion,
}
}
// KubeVersion is the Kubernetes version. // KubeVersion is the Kubernetes version.
type KubeVersion struct { type KubeVersion struct {
Version string // Kubernetes version Version string // Kubernetes version

Loading…
Cancel
Save