mirror of https://github.com/helm/helm
commit
0a38457f89
@ -0,0 +1,12 @@
|
||||
<!-- Thanks for sending a pull request! Here are some tips for you:
|
||||
1. Make sure to read the Contributing Guide before submitting your PR: https://github.com/helm/helm/blob/master/CONTRIBUTING.md
|
||||
2. If this PR closes another issue, add 'closes #<issue number>' somewhere in the PR summary. GitHub will automatically close that issue when this PR gets merged. Alternatively, adding 'refs #<issue number>' will not close the issue, but help provide the reviewer more context.-->
|
||||
|
||||
**What this PR does / why we need it**:
|
||||
|
||||
**Special notes for your reviewer**:
|
||||
|
||||
**If applicable**:
|
||||
- [ ] this PR contains documentation
|
||||
- [ ] this PR contains unit tests
|
||||
- [ ] this PR has been tested for backwards compatibility
|
@ -1 +1 @@
|
||||
version.BuildInfo{Version:"v3.1", GitCommit:"", GitTreeState:"", GoVersion:""}
|
||||
version.BuildInfo{Version:"v3.2", GitCommit:"", GitTreeState:"", GoVersion:""}
|
||||
|
@ -1 +1 @@
|
||||
version.BuildInfo{Version:"v3.1", GitCommit:"", GitTreeState:"", GoVersion:""}
|
||||
version.BuildInfo{Version:"v3.2", GitCommit:"", GitTreeState:"", GoVersion:""}
|
||||
|
@ -1 +1 @@
|
||||
v3.1
|
||||
v3.2
|
||||
|
@ -1 +1 @@
|
||||
Version: v3.1
|
||||
Version: v3.2
|
@ -1 +1 @@
|
||||
version.BuildInfo{Version:"v3.1", GitCommit:"", GitTreeState:"", GoVersion:""}
|
||||
version.BuildInfo{Version:"v3.2", GitCommit:"", GitTreeState:"", GoVersion:""}
|
||||
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
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 fileutil
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"helm.sh/helm/v3/internal/third_party/dep/fs"
|
||||
)
|
||||
|
||||
// AtomicWriteFile atomically (as atomic as os.Rename allows) writes a file to a
|
||||
// disk.
|
||||
func AtomicWriteFile(filename string, reader io.Reader, mode os.FileMode) error {
|
||||
tempFile, err := ioutil.TempFile(filepath.Split(filename))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tempName := tempFile.Name()
|
||||
|
||||
if _, err := io.Copy(tempFile, reader); err != nil {
|
||||
tempFile.Close() // return value is ignored as we are already on error path
|
||||
return err
|
||||
}
|
||||
|
||||
if err := tempFile.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := os.Chmod(tempName, mode); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return fs.RenameWithFallback(tempName, filename)
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
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 fileutil
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAtomicWriteFile(t *testing.T) {
|
||||
dir, err := ioutil.TempDir("", "helm-tmp")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
testpath := filepath.Join(dir, "test")
|
||||
stringContent := "Test content"
|
||||
reader := bytes.NewReader([]byte(stringContent))
|
||||
mode := os.FileMode(0644)
|
||||
|
||||
err = AtomicWriteFile(testpath, reader, mode)
|
||||
if err != nil {
|
||||
t.Errorf("AtomicWriteFile error: %s", err)
|
||||
}
|
||||
|
||||
got, err := ioutil.ReadFile(testpath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if stringContent != string(got) {
|
||||
t.Fatalf("expected: %s, got: %s", stringContent, string(got))
|
||||
}
|
||||
|
||||
gotinfo, err := os.Stat(testpath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if mode != gotinfo.Mode() {
|
||||
t.Fatalf("expected %s: to be the same mode as %s",
|
||||
mode, gotinfo.Mode())
|
||||
}
|
||||
}
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
ignore/
|
@ -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,27 @@
|
||||
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
|
||||
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 @@
|
||||
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,5 @@
|
||||
apiVersion: v1
|
||||
name: alpine
|
||||
description: Deploy a basic Alpine Linux pod
|
||||
version: 0.1.0
|
||||
home: https://helm.sh/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 ./alpine`.
|
@ -0,0 +1,5 @@
|
||||
apiVersion: v1
|
||||
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:
|
||||
app.kubernetes.io/managed-by: {{.Release.Service}}
|
||||
app.kubernetes.io/name: {{.Chart.Name}}
|
||||
helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}"
|
||||
spec:
|
||||
restartPolicy: {{default "Never" .restart_policy}}
|
||||
containers:
|
||||
- name: waiter
|
||||
image: "alpine:3.9"
|
||||
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 @@
|
||||
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,64 @@
|
||||
/*
|
||||
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 "helm.sh/helm/v3/pkg/lint/rules"
|
||||
|
||||
import "fmt"
|
||||
|
||||
// deprecatedAPIs lists APIs that are deprecated (left) with suggested alternatives (right).
|
||||
//
|
||||
// An empty rvalue indicates that the API is completely deprecated.
|
||||
var deprecatedAPIs = map[string]string{
|
||||
"extensions/v1 Deployment": "apps/v1 Deployment",
|
||||
"extensions/v1 DaemonSet": "apps/v1 DaemonSet",
|
||||
"extensions/v1 ReplicaSet": "apps/v1 ReplicaSet",
|
||||
"extensions/v1beta1 PodSecurityPolicy": "policy/v1beta1 PodSecurityPolicy",
|
||||
"extensions/v1beta1 NetworkPolicy": "networking.k8s.io/v1beta1 NetworkPolicy",
|
||||
"extensions/v1beta1 Ingress": "networking.k8s.io/v1beta1 Ingress",
|
||||
"apps/v1beta1 Deployment": "apps/v1 Deployment",
|
||||
"apps/v1beta1 StatefulSet": "apps/v1 StatefulSet",
|
||||
"apps/v1beta1 DaemonSet": "apps/v1 DaemonSet",
|
||||
"apps/v1beta1 ReplicaSet": "apps/v1 ReplicaSet",
|
||||
"apps/v1beta2 Deployment": "apps/v1 Deployment",
|
||||
"apps/v1beta2 StatefulSet": "apps/v1 StatefulSet",
|
||||
"apps/v1beta2 DaemonSet": "apps/v1 DaemonSet",
|
||||
"apps/v1beta2 ReplicaSet": "apps/v1 ReplicaSet",
|
||||
}
|
||||
|
||||
// deprecatedAPIError indicates than an API is deprecated in Kubernetes
|
||||
type deprecatedAPIError struct {
|
||||
Deprecated string
|
||||
Alternative string
|
||||
}
|
||||
|
||||
func (e deprecatedAPIError) Error() string {
|
||||
msg := fmt.Sprintf("the kind %q is deprecated", e.Deprecated)
|
||||
if e.Alternative != "" {
|
||||
msg += fmt.Sprintf(" in favor of %q", e.Alternative)
|
||||
}
|
||||
return msg
|
||||
}
|
||||
|
||||
func validateNoDeprecations(resource *K8sYamlStruct) error {
|
||||
gvk := fmt.Sprintf("%s %s", resource.APIVersion, resource.Kind)
|
||||
if alt, ok := deprecatedAPIs[gvk]; ok {
|
||||
return deprecatedAPIError{
|
||||
Deprecated: gvk,
|
||||
Alternative: alt,
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
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 "helm.sh/helm/v3/pkg/lint/rules"
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestValidateNoDeprecations(t *testing.T) {
|
||||
deprecated := &K8sYamlStruct{
|
||||
APIVersion: "extensions/v1",
|
||||
Kind: "Deployment",
|
||||
}
|
||||
err := validateNoDeprecations(deprecated)
|
||||
if err == nil {
|
||||
t.Fatal("Expected deprecated extension to be flagged")
|
||||
}
|
||||
|
||||
depErr := err.(deprecatedAPIError)
|
||||
if depErr.Alternative != "apps/v1 Deployment" {
|
||||
t.Errorf("Expected %q to be replaced by %q", depErr.Deprecated, depErr.Alternative)
|
||||
}
|
||||
|
||||
if err := validateNoDeprecations(&K8sYamlStruct{
|
||||
APIVersion: "v1",
|
||||
Kind: "Pod",
|
||||
}); err != nil {
|
||||
t.Errorf("Expected a v1 Pod to not be deprecated")
|
||||
}
|
||||
}
|
@ -1,2 +1,2 @@
|
||||
metadata:
|
||||
name: {{.Values.name | default "foo" | title}}
|
||||
name: {{ .Values.name | default "foo" | lower }}
|
||||
|
@ -1 +1 @@
|
||||
name: "goodone here"
|
||||
name: "goodone-here"
|
||||
|
Loading…
Reference in new issue