From f1780e98032b4304c25d1f74d13d99a18a736076 Mon Sep 17 00:00:00 2001 From: Olivier Michaelis <38879457+oliviermichaelis@users.noreply.github.com> Date: Tue, 4 Feb 2025 23:15:30 +0100 Subject: [PATCH] fix(pkg/chartutil): cleaning up to address review comments - shorten testdata chart name - remove unnecessary and distracting files, comments, and values Signed-off-by: Olivier Michaelis <38879457+oliviermichaelis@users.noreply.github.com> --- pkg/chartutil/dependencies_test.go | 4 +- .../.helmignore | 23 ------ .../charts/child/.helmignore | 23 ------ .../child/charts/grandchild/.helmignore | 23 ------ .../charts/child/charts/grandchild/Chart.yaml | 23 ------ .../charts/grandchild/templates/_helpers.tpl | 62 --------------- .../charts/grandchild/templates/service.yaml | 15 ---- .../child/charts/grandchild/values.yaml | 7 -- .../charts/child/values.yaml | 6 -- .../values.yaml | 79 ------------------- .../Chart.yaml | 4 +- .../charts/child/Chart.yaml | 3 - .../charts/child/charts/grandchild/Chart.yaml | 5 ++ .../charts/grandchild/templates/service.yaml | 11 +++ .../charts/child/values.yaml | 2 + 15 files changed, 21 insertions(+), 269 deletions(-) delete mode 100644 pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/.helmignore delete mode 100644 pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/.helmignore delete mode 100644 pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/.helmignore delete mode 100644 pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/Chart.yaml delete mode 100644 pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/templates/_helpers.tpl delete mode 100644 pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/templates/service.yaml delete mode 100644 pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/values.yaml delete mode 100644 pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/values.yaml delete mode 100644 pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/values.yaml rename pkg/chartutil/testdata/{chart-with-dependency-aliased-twice-with-condition => dependency-aliased-twice-with-condition}/Chart.yaml (76%) rename pkg/chartutil/testdata/{chart-with-dependency-aliased-twice-with-condition => dependency-aliased-twice-with-condition}/charts/child/Chart.yaml (67%) create mode 100644 pkg/chartutil/testdata/dependency-aliased-twice-with-condition/charts/child/charts/grandchild/Chart.yaml create mode 100644 pkg/chartutil/testdata/dependency-aliased-twice-with-condition/charts/child/charts/grandchild/templates/service.yaml create mode 100644 pkg/chartutil/testdata/dependency-aliased-twice-with-condition/charts/child/values.yaml diff --git a/pkg/chartutil/dependencies_test.go b/pkg/chartutil/dependencies_test.go index c717d2aa5..f2c2683f3 100644 --- a/pkg/chartutil/dependencies_test.go +++ b/pkg/chartutil/dependencies_test.go @@ -522,8 +522,8 @@ func TestDependentChartsWithSomeSubchartsSpecifiedInDependency(t *testing.T) { } } -func TestChartWithDependencyAliasedTwiceWithCondition(t *testing.T) { - c := loadChart(t, "testdata/chart-with-dependency-aliased-twice-with-condition") +func TestDependencyAliasedTwiceWithCondition(t *testing.T) { + c := loadChart(t, "testdata/dependency-aliased-twice-with-condition") if len(c.Dependencies()) != 1 { t.Fatalf("expected 1 dependencies for this chart, but got %d", len(c.Dependencies())) diff --git a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/.helmignore b/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/.helmignore deleted file mode 100644 index 0e8a0eb36..000000000 --- a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ diff --git a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/.helmignore b/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/.helmignore deleted file mode 100644 index 0e8a0eb36..000000000 --- a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ diff --git a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/.helmignore b/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/.helmignore deleted file mode 100644 index 0e8a0eb36..000000000 --- a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# 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/ diff --git a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/Chart.yaml b/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/Chart.yaml deleted file mode 100644 index b81606d7c..000000000 --- a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/Chart.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: v2 -name: grandchild -description: A Helm chart for Kubernetes - -# 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 diff --git a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/templates/_helpers.tpl b/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/templates/_helpers.tpl deleted file mode 100644 index 736d3f3f7..000000000 --- a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/templates/_helpers.tpl +++ /dev/null @@ -1,62 +0,0 @@ -{{/* -Expand the name of the chart. -*/}} -{{- define "grandchild.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "grandchild.fullname" -}} -{{- if .Values.fullnameOverride }} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} -{{- .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} -{{- end }} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "grandchild.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} -{{- end }} - -{{/* -Common labels -*/}} -{{- define "grandchild.labels" -}} -helm.sh/chart: {{ include "grandchild.chart" . }} -{{ include "grandchild.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end }} - -{{/* -Selector labels -*/}} -{{- define "grandchild.selectorLabels" -}} -app.kubernetes.io/name: {{ include "grandchild.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} - -{{/* -Create the name of the service account to use -*/}} -{{- define "grandchild.serviceAccountName" -}} -{{- if .Values.serviceAccount.create }} -{{- default (include "grandchild.fullname" .) .Values.serviceAccount.name }} -{{- else }} -{{- default "default" .Values.serviceAccount.name }} -{{- end }} -{{- end }} diff --git a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/templates/service.yaml b/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/templates/service.yaml deleted file mode 100644 index 06e7a9baf..000000000 --- a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/templates/service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "grandchild.fullname" . | lower }} - labels: - {{- include "grandchild.labels" . | nindent 4 }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - {{- include "grandchild.selectorLabels" . | nindent 4 }} diff --git a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/values.yaml b/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/values.yaml deleted file mode 100644 index 30b8225c8..000000000 --- a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/charts/grandchild/values.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# Default values for grandchild. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -service: - type: ClusterIP - port: 80 diff --git a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/values.yaml b/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/values.yaml deleted file mode 100644 index e0496dd24..000000000 --- a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/values.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# Default values for child. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -grandchildAlias: - enabled: false diff --git a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/values.yaml b/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/values.yaml deleted file mode 100644 index 16befb85b..000000000 --- a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/values.yaml +++ /dev/null @@ -1,79 +0,0 @@ -# Default values for chart-with-dependency-aliased-twice-with-condition. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -replicaCount: 1 - -image: - repository: nginx - pullPolicy: IfNotPresent - # Overrides the image tag whose default is the chart appVersion. - tag: "" - -imagePullSecrets: [] -nameOverride: "" -fullnameOverride: "" - -serviceAccount: - # Specifies whether a service account should be created - create: true - # Annotations to add to the service account - annotations: {} - # The name of the service account to use. - # If not set and create is true, a name is generated using the fullname template - name: "" - -podAnnotations: {} - -podSecurityContext: {} - # fsGroup: 2000 - -securityContext: {} - # capabilities: - # drop: - # - ALL - # readOnlyRootFilesystem: true - # runAsNonRoot: true - # runAsUser: 1000 - -service: - type: ClusterIP - port: 80 - -ingress: - enabled: false - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - hosts: - - host: chart-example.local - paths: [] - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - -resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi - -autoscaling: - enabled: false - minReplicas: 1 - maxReplicas: 100 - targetCPUUtilizationPercentage: 80 - # targetMemoryUtilizationPercentage: 80 - -nodeSelector: {} - -tolerations: [] - -affinity: {} diff --git a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/Chart.yaml b/pkg/chartutil/testdata/dependency-aliased-twice-with-condition/Chart.yaml similarity index 76% rename from pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/Chart.yaml rename to pkg/chartutil/testdata/dependency-aliased-twice-with-condition/Chart.yaml index c8fef83a4..84678fc41 100644 --- a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/Chart.yaml +++ b/pkg/chartutil/testdata/dependency-aliased-twice-with-condition/Chart.yaml @@ -1,9 +1,7 @@ apiVersion: v2 -name: chart-with-dependency-aliased-twice-with-condition +name: dependency-aliased-twice-with-condition description: A chart with a dependency that is referenced twice with different aliases. The aliased charts have a sub-dependency with a condition. -type: application version: 0.1.0 -appVersion: 1.16.0 dependencies: - name: child diff --git a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/Chart.yaml b/pkg/chartutil/testdata/dependency-aliased-twice-with-condition/charts/child/Chart.yaml similarity index 67% rename from pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/Chart.yaml rename to pkg/chartutil/testdata/dependency-aliased-twice-with-condition/charts/child/Chart.yaml index 890602456..22d8db8bb 100644 --- a/pkg/chartutil/testdata/chart-with-dependency-aliased-twice-with-condition/charts/child/Chart.yaml +++ b/pkg/chartutil/testdata/dependency-aliased-twice-with-condition/charts/child/Chart.yaml @@ -1,9 +1,6 @@ apiVersion: v2 name: child -description: A Helm chart for Kubernetes -type: application version: 0.1.0 -appVersion: 1.16.0 dependencies: - name: grandchild diff --git a/pkg/chartutil/testdata/dependency-aliased-twice-with-condition/charts/child/charts/grandchild/Chart.yaml b/pkg/chartutil/testdata/dependency-aliased-twice-with-condition/charts/child/charts/grandchild/Chart.yaml new file mode 100644 index 000000000..e59ddce9e --- /dev/null +++ b/pkg/chartutil/testdata/dependency-aliased-twice-with-condition/charts/child/charts/grandchild/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: grandchild +description: A Helm chart for Kubernetes +type: application +version: 0.1.0 diff --git a/pkg/chartutil/testdata/dependency-aliased-twice-with-condition/charts/child/charts/grandchild/templates/service.yaml b/pkg/chartutil/testdata/dependency-aliased-twice-with-condition/charts/child/charts/grandchild/templates/service.yaml new file mode 100644 index 000000000..df3649ced --- /dev/null +++ b/pkg/chartutil/testdata/dependency-aliased-twice-with-condition/charts/child/charts/grandchild/templates/service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name | lower }}-{{ .Chart.Name | lower }}-{{ randAlpha 4 | lower }} +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: http + protocol: TCP + name: http diff --git a/pkg/chartutil/testdata/dependency-aliased-twice-with-condition/charts/child/values.yaml b/pkg/chartutil/testdata/dependency-aliased-twice-with-condition/charts/child/values.yaml new file mode 100644 index 000000000..340caa160 --- /dev/null +++ b/pkg/chartutil/testdata/dependency-aliased-twice-with-condition/charts/child/values.yaml @@ -0,0 +1,2 @@ +grandchildAlias: + enabled: false