Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Fix empty value for env in helm values #790

Merged
merged 7 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion integration/init/factorio/expected/.ship/state.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"v1": {
"config": {},
"helmValues": "# Factorio image version\n# ref: https://quay.io/repository/games_on_k8s/factorio?tab=tags\nimage: quay.io/games_on_k8s/factorio\nimageTag: \"0.14.22\"\n\n# Configure resource requests and limits\n# ref: http://kubernetes.io/docs/user-guide/compute-resources/\nresources:\n requests:\n memory: 512Mi\n cpu: 500m\n\n# Most of these map to environment variables. See docker-factorio for details:\n# https://github.com/games-on-k8s/docker-factorio/blob/master/README.md#environment-variable-reference\nfactorioServer:\n name: Kubernetes Server\n description: Factorio running on Kubernetes\n port: 34197\n # Lock this server down with a password.\n # password: change.me\n maxPlayers: 255\n # Publishes this server in the server browser if true.\n # You'll want to set Factorio.User below if true, as it becomes required.\n isPublic: false\n verifyIdentity: false\n # Allows or disallows console commands. Must be one of: `true`, `false`, or `admins-only`.\n allowCommands: admins-only\n # Pause the server when nobody is connected?\n noAutoPause: \"false\"\n # You'll want to change this to NodePort if you are on AWS.\n serviceType: LoadBalancer\n\n autosave:\n # Auto-save interval in minutes.\n interval: 2\n slots: 3\n\n rcon:\n enabled: false\n port: 27015\n # Empty value here enables an auto-generated password.\n password: \"\"\n serviceType: LoadBalancer\n\nfactorio:\n # Your factorio.com User/pass is needed if factorioServer.IsPublic is true.\n user:\n username: your.username\n password: your.password\n\npersistence:\n ## factorio data Persistent Volume Storage Class\n ## If defined, storageClassName: \u003cstorageClass\u003e\n ## If set to \"-\", storageClassName: \"\", which disables dynamic provisioning\n ## If undefined (the default) or set to null, no storageClassName spec is\n ## set, choosing the default provisioner. (gp2 on AWS, standard on\n ## GKE, AWS \u0026 OpenStack)\n ##\n # storageClass: \"-\"\n savedGames:\n # Set this to false if you don't care to persist saved games between restarts.\n enabled: true\n size: 1Gi\n mods:\n enabled: false\n size: 128Mi\n",
"releaseName": "factorio",
"helmValuesDefaults": "# Factorio image version\n# ref: https://quay.io/repository/games_on_k8s/factorio?tab=tags\nimage: quay.io/games_on_k8s/factorio\nimageTag: \"0.14.22\"\n\n# Configure resource requests and limits\n# ref: http://kubernetes.io/docs/user-guide/compute-resources/\nresources:\n requests:\n memory: 512Mi\n cpu: 500m\n\n# Most of these map to environment variables. See docker-factorio for details:\n# https://github.com/games-on-k8s/docker-factorio/blob/master/README.md#environment-variable-reference\nfactorioServer:\n name: Kubernetes Server\n description: Factorio running on Kubernetes\n port: 34197\n # Lock this server down with a password.\n # password: change.me\n maxPlayers: 255\n # Publishes this server in the server browser if true.\n # You'll want to set Factorio.User below if true, as it becomes required.\n isPublic: false\n verifyIdentity: false\n # Allows or disallows console commands. Must be one of: `true`, `false`, or `admins-only`.\n allowCommands: admins-only\n # Pause the server when nobody is connected?\n noAutoPause: \"false\"\n # You'll want to change this to NodePort if you are on AWS.\n serviceType: LoadBalancer\n\n autosave:\n # Auto-save interval in minutes.\n interval: 2\n slots: 3\n\n rcon:\n enabled: false\n port: 27015\n # Empty value here enables an auto-generated password.\n password: \"\"\n serviceType: LoadBalancer\n\nfactorio:\n # Your factorio.com User/pass is needed if factorioServer.IsPublic is true.\n user:\n username: your.username\n password: your.password\n\npersistence:\n ## factorio data Persistent Volume Storage Class\n ## If defined, storageClassName: \u003cstorageClass\u003e\n ## If set to \"-\", storageClassName: \"\", which disables dynamic provisioning\n ## If undefined (the default) or set to null, no storageClassName spec is\n ## set, choosing the default provisioner. (gp2 on AWS, standard on\n ## GKE, AWS \u0026 OpenStack)\n ##\n # storageClass: \"-\"\n savedGames:\n # Set this to false if you don't care to persist saved games between restarts.\n enabled: true\n size: 1Gi\n mods:\n enabled: false\n size: 128Mi\n",
"upstream": "https://github.com/helm/charts/tree/ffb84f85a861e765caade879491a75a6dd3091a5/stable/factorio",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"v1": {
"config": {},
"helmValues": "replicaCount: 1\nimage:\n repository: nginx\n tag: stable\n\n",
"releaseName": "values-update",
"helmValuesDefaults": "replicaCount: 1\nimage:\n repository: nginx\n tag: stable\n\n",
"upstream": "https://github.com/replicatedhq/test-chart-root-dir/tree/507feecae588c958ebe82bcf701b8be63f34ac9b/",
Expand Down

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion integration/init/istio-1.0.3/expected/.ship/state.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion integration/init/istio-gogetter/expected/.ship/state.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion integration/init/istio/expected/.ship/state.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion integration/init/jaeger-helm/expected/.ship/state.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion integration/update/basic/expected/.ship/state.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"v1": {
"config": {},
"helmValues": "replicaCount: 5\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\nservice:\n type: ClusterIP\n port: 80\ningress:\n enabled: false\n annotations: {}\n path: /\n hosts:\n - chart-example.local\n tls: []\nresources: {}\nnodeSelector: {}\ntolerations: []\naffinity: {}\n",
"helmValues": "# Default values for basic.\n# This is a YAML-formatted file.\n# Declare variables to be passed into your templates.\n\nreplicaCount: 5\n\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\n\nservice:\n type: ClusterIP\n port: 80\n\ningress:\n enabled: false\n annotations: {}\n # kubernetes.io/ingress.class: nginx\n # kubernetes.io/tls-acme: \"true\"\n path: /\n hosts:\n - chart-example.local\n tls: []\n # - secretName: chart-example-tls\n # hosts:\n # - chart-example.local\n\nresources: {}\n # We usually recommend not to specify default resources and to leave this as a conscious\n # choice for the user. This also increases chances charts run on environments with little\n # resources, such as Minikube. If you do want to specify resources, uncomment the following\n # lines, adjust them as necessary, and remove the curly braces after 'resources:'.\n # limits:\n # cpu: 100m\n # memory: 128Mi\n # requests:\n # cpu: 100m\n # memory: 128Mi\n\nnodeSelector: {}\n\ntolerations: []\n\naffinity: {}\n",
"releaseName": "basic",
"helmValuesDefaults": "# Default values for basic.\n# This is a YAML-formatted file.\n# Declare variables to be passed into your templates.\n\nreplicaCount: 1\n\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\n\nservice:\n type: ClusterIP\n port: 80\n\ningress:\n enabled: false\n annotations: {}\n # kubernetes.io/ingress.class: nginx\n # kubernetes.io/tls-acme: \"true\"\n path: /\n hosts:\n - chart-example.local\n tls: []\n # - secretName: chart-example-tls\n # hosts:\n # - chart-example.local\n\nresources: {}\n # We usually recommend not to specify default resources and to leave this as a conscious\n # choice for the user. This also increases chances charts run on environments with little\n # resources, such as Minikube. If you do want to specify resources, uncomment the following\n # lines, adjust them as necessary, and remove the curly braces after 'resources:'.\n # limits:\n # cpu: 100m\n # memory: 128Mi\n # requests:\n # cpu: 100m\n # memory: 128Mi\n\nnodeSelector: {}\n\ntolerations: []\n\naffinity: {}\n",
"kustomize": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"v1": {
"config": {},
"helmValues": "replicaCount: 5\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\nservice:\n type: ClusterIP\n port: 80\ningress:\n enabled: false\n annotations: {}\n path: /\n hosts:\n - chart-example.local\n tls: []\nresources: {}\nnodeSelector: {}\ntolerations: []\naffinity: {}\n",
"helmValues": "# Default values for basic.\n# This is a YAML-formatted file.\n# Declare variables to be passed into your templates.\n\nreplicaCount: 5\n\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\n\nservice:\n type: ClusterIP\n port: 80\n\ningress:\n enabled: false\n annotations: {}\n # kubernetes.io/ingress.class: nginx\n # kubernetes.io/tls-acme: \"true\"\n path: /\n hosts:\n - chart-example.local\n tls: []\n # - secretName: chart-example-tls\n # hosts:\n # - chart-example.local\n\nresources: {}\n # We usually recommend not to specify default resources and to leave this as a conscious\n # choice for the user. This also increases chances charts run on environments with little\n # resources, such as Minikube. If you do want to specify resources, uncomment the following\n # lines, adjust them as necessary, and remove the curly braces after 'resources:'.\n # limits:\n # cpu: 100m\n # memory: 128Mi\n # requests:\n # cpu: 100m\n # memory: 128Mi\n\nnodeSelector: {}\n\ntolerations: []\n\naffinity: {}\n",
"releaseName": "basic",
"helmValuesDefaults": "# Default values for basic.\n# This is a YAML-formatted file.\n# Declare variables to be passed into your templates.\n\nreplicaCount: 1\n\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\n\nservice:\n type: ClusterIP\n port: 80\n\ningress:\n enabled: false\n annotations: {}\n # kubernetes.io/ingress.class: nginx\n # kubernetes.io/tls-acme: \"true\"\n path: /\n hosts:\n - chart-example.local\n tls: []\n # - secretName: chart-example-tls\n # hosts:\n # - chart-example.local\n\nresources: {}\n # We usually recommend not to specify default resources and to leave this as a conscious\n # choice for the user. This also increases chances charts run on environments with little\n # resources, such as Minikube. If you do want to specify resources, uncomment the following\n # lines, adjust them as necessary, and remove the curly braces after 'resources:'.\n # limits:\n # cpu: 100m\n # memory: 128Mi\n # requests:\n # cpu: 100m\n # memory: 128Mi\n\nnodeSelector: {}\n\ntolerations: []\n\naffinity: {}\n",
"kustomize": {
Expand Down
2 changes: 1 addition & 1 deletion integration/update/modify-chart/expected/.ship/state.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"v1": {
"config": {},
"helmValues": "replicaCount: 1\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\nservice:\n type: ClusterIP\n port: 80\ningress:\n enabled: false\n annotations: {}\n path: /\n hosts:\n - chart-example.local\n tls: []\nresources: {}\nnodeSelector: {}\ntolerations: []\naffinity: {}\n",
"helmValues": "# Default values for modify-chart.\n# This is a YAML-formatted file.\n# Declare variables to be passed into your templates.\n\nreplicaCount: 1\n\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\n\nservice:\n type: ClusterIP\n port: 80\n\ningress:\n enabled: false\n annotations: {}\n # kubernetes.io/ingress.class: nginx\n # kubernetes.io/tls-acme: \"true\"\n path: /\n hosts:\n - chart-example.local\n tls: []\n # - secretName: chart-example-tls\n # hosts:\n # - chart-example.local\n\nresources: {}\n # We usually recommend not to specify default resources and to leave this as a conscious\n # choice for the user. This also increases chances charts run on environments with little\n # resources, such as Minikube. If you do want to specify resources, uncomment the following\n # lines, adjust them as necessary, and remove the curly braces after 'resources:'.\n # limits:\n # cpu: 100m\n # memory: 128Mi\n # requests:\n # cpu: 100m\n # memory: 128Mi\n\nnodeSelector: {}\n\ntolerations: []\n\naffinity: {}\n",
"releaseName": "modify-chart",
"helmValuesDefaults": "# Default values for modify-chart.\n# This is a YAML-formatted file.\n# Declare variables to be passed into your templates.\n\nreplicaCount: 2\n\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\n\nservice:\n type: ClusterIP\n port: 80\n\ningress:\n enabled: false\n annotations: {}\n # kubernetes.io/ingress.class: nginx\n # kubernetes.io/tls-acme: \"true\"\n path: /\n hosts:\n - chart-example.local\n tls: []\n # - secretName: chart-example-tls\n # hosts:\n # - chart-example.local\n\nresources: {}\n # We usually recommend not to specify default resources and to leave this as a conscious\n # choice for the user. This also increases chances charts run on environments with little\n # resources, such as Minikube. If you do want to specify resources, uncomment the following\n # lines, adjust them as necessary, and remove the curly braces after 'resources:'.\n # limits:\n # cpu: 100m\n # memory: 128Mi\n # requests:\n # cpu: 100m\n # memory: 128Mi\n\nnodeSelector: {}\n\ntolerations: []\n\naffinity: {}\n",
"kustomize": {
Expand Down
2 changes: 1 addition & 1 deletion integration/update/values-static/expected/.ship/state.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"v1": {
"config": {},
"helmValues": "replicaCount: 2\nimage:\n repository: nginx\n tag: stable\n",
"helmValues": "replicaCount: 2\nimage:\n repository: nginx\n tag: stable\n\n",
"releaseName": "values-update",
"helmValuesDefaults": "replicaCount: 1\nimage:\n repository: nginx\n tag: stable\n\n",
"kustomize": {
Expand Down
4 changes: 2 additions & 2 deletions integration/update/version/expected/.ship/state.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"v1": {
"config": {},
"helmValues": "replicaCount: 1\nimage:\n repository: nginx\n tag: stable\n pullPolicy: Always\nservice:\n type: ClusterIP\n port: 82\ningress:\n enabled: false\n annotations: {}\n path: /\n hosts:\n - chart-example.local\n tls: []\nresources: {}\nnodeSelector: {}\ntolerations: []\naffinity: {}\n",
"helmValues": "replicaCount: 1\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\nservice:\n type: ClusterIP\n port: 80\ningress:\n enabled: false\n annotations: {}\n path: /\n hosts:\n - chart-example.local\n tls: []\nresources: {}\nnodeSelector: {}\ntolerations: []\naffinity: {}\n",
"releaseName": "version",
"helmValuesDefaults": "# Default values for basic.\n# This is a YAML-formatted file.\n# Declare variables to be passed into your templates.\n\nreplicaCount: 1\n\nimage:\n repository: nginx\n tag: stable\n pullPolicy: Always\n\nservice:\n type: ClusterIP\n port: 82\n\ningress:\n enabled: false\n annotations: {}\n # kubernetes.io/ingress.class: nginx\n # kubernetes.io/tls-acme: \"true\"\n path: /\n hosts:\n - chart-example.local\n tls: []\n # - secretName: chart-example-tls\n # hosts:\n # - chart-example.local\n\nresources: {}\n # We usually recommend not to specify default resources and to leave this as a conscious\n # choice for the user. This also increases chances charts run on environments with little\n # resources, such as Minikube. If you do want to specify resources, uncomment the following\n # lines, adjust them as necessary, and remove the curly braces after 'resources:'.\n # limits:\n # cpu: 100m\n # memory: 128Mi\n # requests:\n # cpu: 100m\n # memory: 128Mi\n\nnodeSelector: {}\n\ntolerations: []\n\naffinity: {}\n",
"helmValuesDefaults": "# Default values for basic.\n# This is a YAML-formatted file.\n# Declare variables to be passed into your templates.\n\nreplicaCount: 1\n\nimage:\n repository: nginx\n tag: stable\n pullPolicy: IfNotPresent\n\nservice:\n type: ClusterIP\n port: 80\n\ningress:\n enabled: false\n annotations: {}\n # kubernetes.io/ingress.class: nginx\n # kubernetes.io/tls-acme: \"true\"\n path: /\n hosts:\n - chart-example.local\n tls: []\n # - secretName: chart-example-tls\n # hosts:\n # - chart-example.local\n\nresources: {}\n # We usually recommend not to specify default resources and to leave this as a conscious\n # choice for the user. This also increases chances charts run on environments with little\n # resources, such as Minikube. If you do want to specify resources, uncomment the following\n # lines, adjust them as necessary, and remove the curly braces after 'resources:'.\n # limits:\n # cpu: 100m\n # memory: 128Mi\n # requests:\n # cpu: 100m\n # memory: 128Mi\n\nnodeSelector: {}\n\ntolerations: []\n\naffinity: {}\n",
"upstream": "https://github.com/replicatedhq/test-charts/tree/_latest_/version",
"metadata": {
"applicationType": "helm",
Expand Down
6 changes: 4 additions & 2 deletions pkg/api/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ type LocalAsset struct {
}

type ValuesFrom struct {
Path string `json:"path,omitempty" yaml:"path,omitempty" hcl:"path,omitempty"`
SaveToState bool `json:"save_to_state,omitempty" yaml:"save_to_state,omitempty" hcl:"save_to_state,omitempty"`
Path string `json:"path,omitempty" yaml:"path,omitempty" hcl:"path,omitempty"`
// SaveToState is used when a HelmValues step is not part of the lifecycle (e.g. Unfork) in order to save
// the merged helm values to state.
SaveToState bool `json:"save_to_state,omitempty" yaml:"save_to_state,omitempty" hcl:"save_to_state,omitempty"`
}

type ValuesFromLifecycle struct{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/lifecycle/render/helm/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ func fixLines(lines []string) []string {
// line has `env:` and nothing else but whitespace
if !checkIsChild(line, nextLine(idx, lines)) {
// next line is not a child, so env has no contents, add an empty object
lines[idx] = line + " {}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer for you to delete this block entirely and modify arrayLineRegex (line 63) to include env

lines[idx] = line + " []"
}
} else if valueLineRegex.MatchString(line) {
// line has `value:` and nothing else but whitespace
Expand Down
8 changes: 4 additions & 4 deletions pkg/lifecycle/render/helm/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ func Test_validateGeneratedFiles(t *testing.T) {
},
{
path: "test/missingEnv.yaml",
contents: ` env: {}`,
contents: ` env: []`,
},
{
path: "test/notMissingMultilineEnv.yaml",
Expand All @@ -547,7 +547,7 @@ func Test_validateGeneratedFiles(t *testing.T) {
{
path: "test/missingMultilineEnv.yaml",
contents: `
env: {}
env: []
something:`,
},
},
Expand Down Expand Up @@ -647,7 +647,7 @@ func Test_validateGeneratedFiles(t *testing.T) {
{
path: "test/comment_line_env.yaml",
contents: `
env: {}
env: []
#item

env:
Expand Down Expand Up @@ -722,7 +722,7 @@ func Test_validateGeneratedFiles(t *testing.T) {
path: "test/everything.yaml",
contents: `
args: []
env: {}
env: []
volumes: []
value: ""
value: ""
Expand Down
7 changes: 1 addition & 6 deletions pkg/specs/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ func (r *Resolver) DefaultHelmRelease(chartPath string, upstream string) api.Spe
ChartRoot: chartPath,
},
ValuesFrom: &api.ValuesFrom{
Path: constants.ShipPathInternalTmp,
SaveToState: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing this is as helm values are saved during the helm values step

Path: constants.ShipPathInternalTmp,
},
Upstream: upstream,
},
Expand Down Expand Up @@ -194,10 +193,6 @@ For continuous notification and preparation of application updates via email, we
return spec
}

func (r *Resolver) DefaultRawUnforkRelease(forkedPath string, upstreamPath string) api.Spec {
return api.Spec{}
}

func (r *Resolver) DefaultRawRelease(basePath string) api.Spec {
spec := api.Spec{
Assets: api.Assets{
Expand Down