Skip to content

Commit

Permalink
fix: fixes broken comment parsing on values files with dos line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
norwoodj committed Jan 12, 2021
1 parent 2e20ce4 commit e65dfab
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 2 deletions.
23 changes: 23 additions & 0 deletions example-charts/dos-line-endings/.helmignore
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions example-charts/dos-line-endings/Chart.yaml
@@ -0,0 +1,24 @@
apiVersion: v2
name: dos-line-endings
description: A chart whose values file has dos line endings rather than unix ones


# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: 1.16.0
10 changes: 10 additions & 0 deletions example-charts/dos-line-endings/templates/tls.yaml
@@ -0,0 +1,10 @@
{{- if .Values.createTLS.enabled }}
apiVersion: v1
kind: Secret
type: kubernetes.io/tls
metadata:
name: {{ .Release.Name }}-tls
data:
tls.crt: {{ .Values.createTLS.tls.cert }}
tls.key: {{ .Values.createTLS.tls.key }}
{{- end }}
18 changes: 18 additions & 0 deletions example-charts/dos-line-endings/values.yaml
@@ -0,0 +1,18 @@
# Default values for helmdoc-test.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

livenessProbe:
httpGet:
# -- This is the liveness check endpoint
path: /healthz
port: http

controller:
publishService:
# -- Whether to expose the ingress controller to the public world sdf
enabled: false

# -- Number of nginx-ingress pods to load balance between sdf.
# Do not set this below 2.
replicas: 2
4 changes: 2 additions & 2 deletions pkg/helm/chart_info.go
Expand Up @@ -8,6 +8,7 @@ import (
"path"
"regexp"
"sort"
"strings"

log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"
Expand Down Expand Up @@ -69,12 +70,11 @@ func getYamlFileContents(filename string) ([]byte, error) {
}

yamlFileContents, err := ioutil.ReadFile(filename)

if err != nil {
panic(err)
}

return []byte(yamlFileContents), nil
return []byte(strings.Replace(string(yamlFileContents), "\r\n", "\n", -1)), nil
}

func isErrorInReadingNecessaryFile(filePath string, loadError error) bool {
Expand Down

0 comments on commit e65dfab

Please sign in to comment.