Skip to content

Commit

Permalink
fix: use rendered KOTS kinds to create version even when configuratio…
Browse files Browse the repository at this point in the history
…n is needed (#4332)
  • Loading branch information
sgalsaleh authored Jan 8, 2024
1 parent e71fea2 commit 93aa174
Show file tree
Hide file tree
Showing 26 changed files with 620 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ func Pull(upstreamURI string, pullOptions PullOptions) (string, error) {
}

if needsConfig {
if err := kotsutil.WriteKotsKinds(renderedKotsKindsMap, u.GetKotsKindsDir(writeUpstreamOptions)); err != nil {
return "", errors.Wrap(err, "failed to write the rendered kots kinds")
}
if processImageOptions.RewriteImages && processImageOptions.AirgapRoot != "" {
// if this is an airgap install, we still need to process the images
if _, err = midstream.ProcessAirgapImages(processImageOptions, renderedKotsKinds, fetchOptions.License, log); err != nil {
Expand Down
13 changes: 13 additions & 0 deletions pkg/tests/pull/cases/needsconfig/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Name: test pulling with unset required config items
PullOptions:
Namespace: app-namespace
ExcludeAdminConsole: true
IsAirgap: true
Silent: true
LocalPath: cases/needsconfig/upstream
RootDir: cases/needsconfig/results
SharedPassword: dummy-pass
RewriteImages: false
Downstreams:
- this-cluster
SkipHelmChartCheck: true
6 changes: 6 additions & 0 deletions pkg/tests/pull/cases/needsconfig/upstream/app/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: test-config
data:
key: value
8 changes: 8 additions & 0 deletions pkg/tests/pull/cases/needsconfig/upstream/kots-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kots.io/v1beta1
kind: Application
metadata:
name: my-app
annotations:
kots.io/exclude: "true"
spec:
title: My App
68 changes: 68 additions & 0 deletions pkg/tests/pull/cases/needsconfig/upstream/kots-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
apiVersion: kots.io/v1beta1
kind: Config
metadata:
name: my-app
spec:
groups:
- name: setup
title: Setup
items:
# ---- HelmChart v1beta2 ---- #
- name: helmchart_release_name
title: Release Name
type: text
default: "my-chart-release-name"
- name: helmchart_values
title: Values
type: textarea
default: |
foo: bar
bar: baz
- name: helmchart_exclude
title: Exclude
type: bool
default: "1"
- name: helmchart_namespace
title: Namespace
type: text
default: "my-namespace"
- name: helmchart_optional_values_1_when
title: Optional Values 1 When
type: bool
default: "1"
- name: helmchart_optional_values_1_recursive_merge
title: Optional Values 1 Recursive Merge
type: bool
default: "1"
- name: helmchart_optional_values_1_values
title: Optional Values 1 Values
type: textarea
default: |
foo: bar
bar: baz
- name: helmchart_builder
title: Builder
type: textarea
default: |
foo: bar
bar: baz
- name: helmchart_weight
title: Weight
type: text
default: "1"
- name: helmchart_helm_upgrade_flags_1
title: Helm Upgrade Flags 1
type: text
default: "--timeout 70s"

# ---- Preflight v1beta2 ---- #
- name: allow_privilege_escalation
title: Allow Privilege Escalation
type: bool
default: "1"

# ---- Other ---- #
- name: unset_required_config_item
title: Unset Required Config Item
type: text
required: true
12 changes: 12 additions & 0 deletions pkg/tests/pull/cases/needsconfig/upstream/kots-preflight.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: troubleshoot.sh/v1beta2
kind: Preflight
metadata:
name: my-app
spec:
collectors:
- runPod:
podSpec:
containers:
- image: myimage
securityContext:
allowPrivilegeEscalation: repl{{ ConfigOptionEquals "allow_privilege_escalation" "1" }}
Binary file not shown.
22 changes: 22 additions & 0 deletions pkg/tests/pull/cases/needsconfig/upstream/my-excluded-chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: kots.io/v1beta2
kind: HelmChart
metadata:
name: my-excluded-chart
annotations:
kots.io/exclude: "true"
spec:
chart:
name: my-chart
chartVersion: 0.1.0
releaseName: repl{{ ConfigOption "helmchart_release_name" }}
values: repl{{ ConfigOption "helmchart_values" | nindent 4 }}
exclude: repl{{ ConfigOptionEquals "helmchart_exclude" "1" }}
namespace: repl{{ ConfigOption "helmchart_namespace" }}
optionalValues:
- when: '{{repl ConfigOptionEquals "helmchart_optional_values_1_when" "1" }}'
recursiveMerge: repl{{ ConfigOptionEquals "helmchart_optional_values_1_recursive_merge" "1" }}
values: repl{{ ConfigOption "helmchart_optional_values_1_values" | nindent 8 }}
builder: repl{{ ConfigOption "helmchart_builder" | nindent 4 }}
weight: repl{{ ConfigOption "helmchart_weight" }}
helmUpgradeFlags:
- repl{{ ConfigOption "helmchart_helm_upgrade_flags_1" }}
49 changes: 49 additions & 0 deletions pkg/tests/pull/cases/needsconfig/upstream/userdata/license.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apiVersion: kots.io/v1beta1
kind: License
metadata:
creationTimestamp: null
name: testcustomer
spec:
appSlug: my-app
channelID: 1vusIYZLAVxMG6q760OJmRKj5i5
channelName: My Channel
customerName: Test Customer
endpoint: https://replicated.app
entitlements:
bool_field:
title: Bool Field
value: true
valueType: Boolean
expires_at:
description: License Expiration
title: Expiration
value: "2030-07-27T00:00:00Z"
valueType: String
hidden_field:
isHidden: true
title: Hidden Field
value: this is secret
valueType: String
int_field:
title: Int Field
value: 123
valueType: Integer
string_field:
title: StringField
value: single line text
valueType: String
text_field:
title: Text Field
value: |-
multi
line
text
valueType: Text
isAirgapSupported: true
isGitOpsSupported: true
isSnapshotSupported: true
licenseID: 1vusOokxAVp1tkRGuyxnF23PJcq
licenseSequence: 7
licenseType: prod
signature: eyJsaWNlbnNlRGF0YSI6ImV5SmhjR2xXWlhKemFXOXVJam9pYTI5MGN5NXBieTkyTVdKbGRHRXhJaXdpYTJsdVpDSTZJa3hwWTJWdWMyVWlMQ0p0WlhSaFpHRjBZU0k2ZXlKdVlXMWxJam9pZEdWemRHTjFjM1J2YldWeUluMHNJbk53WldNaU9uc2liR2xqWlc1elpVbEVJam9pTVhaMWMwOXZhM2hCVm5BeGRHdFNSM1Y1Z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xNSEJFVkROR2VGTnROVVJVVlRWVlltMDFiVnBGUm5sWldIQjZaRVJqTVZaSGFFeFBXRUpVVWtacmRrd3diek5aTUZaSlVteFdWRXd5T1VoV1JXeHNWa1ZPTUZSSE1WWlJNR04zVkd4R2JGa3pTblJUUm1zMFZVWk9hMVpWU2pCVU1WbDNZbXQwY0ZSclZuQmpia0poVFZjNWFtSldiSEZaYTNob1UyeHNWV0pGUmtWWGJVWnZWakZLVUZkcWJGSmhXRVp1V2xkb1EyRnVRak5TUjNNd1lWWkpOVTVXVmxkV1ZUVnlUMGhLYjFsVlRYbGhiVGcwVjBkYWVGbHFWbFppYlhoeFpFWkZkMDU1Y3pCaFZsSkpWRVpPTm1WRk1IcGxWWFJ2VFVaR1ZtRXdWVFJSVnpsSFVsaEtVRTFZUmxCU01WcFJVMVJDTmxsV2FIcFdWWEJ0WTBSU2JFMVVRazlPVjNSU1ZucFdUMU5XWTNaU1ZYUkZVMGhzYlU5VmJGaGtNMUl3WTFWc1lXTlhSakJTYTA1RVlVWmtjbUo2VmtSU00wSllUREkxUmsxWVl6SmxWM1JKVlZoQk1sVXhTbEppU0Zwd1VrVXdNRlpFVWt0VU1rWnNVVmQwYzFSV1VrMVVWV055V1RCYVRHSXpaRTlUVm05NVlraE9SR1JzVG5aUmFrWmFaVmRPVGxOVlNteGFiRXB1Wld0U2RVMHhSVGxRVTBselNXMWtjMkl5U21oaVJYUnNaVlZzYTBscWIybFpiVkpzV2xSVk1rNVVXWGRaTWxwcFRrUk9hazlYU1hsUFIwcHRUMVJvYkZsWFRtaGFiVVV5VGtSWmFXWlJQVDBpZlE9PSJ9
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kots.io/v1beta1
kind: Application
metadata:
name: my-app
annotations:
kots.io/exclude: "true"
spec:
title: My App
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
apiVersion: kots.io/v1beta1
kind: Config
metadata:
creationTimestamp: null
name: my-app
spec:
groups:
- items:
- default: my-chart-release-name
name: helmchart_release_name
title: Release Name
type: text
value: ""
- default: |
foo: bar
bar: baz
name: helmchart_values
title: Values
type: textarea
value: ""
- default: "1"
name: helmchart_exclude
title: Exclude
type: bool
value: ""
- default: my-namespace
name: helmchart_namespace
title: Namespace
type: text
value: ""
- default: "1"
name: helmchart_optional_values_1_when
title: Optional Values 1 When
type: bool
value: ""
- default: "1"
name: helmchart_optional_values_1_recursive_merge
title: Optional Values 1 Recursive Merge
type: bool
value: ""
- default: |
foo: bar
bar: baz
name: helmchart_optional_values_1_values
title: Optional Values 1 Values
type: textarea
value: ""
- default: |
foo: bar
bar: baz
name: helmchart_builder
title: Builder
type: textarea
value: ""
- default: "1"
name: helmchart_weight
title: Weight
type: text
value: ""
- default: --timeout 70s
name: helmchart_helm_upgrade_flags_1
title: Helm Upgrade Flags 1
type: text
value: ""
- default: "1"
name: allow_privilege_escalation
title: Allow Privilege Escalation
type: bool
value: ""
- default: ""
name: unset_required_config_item
required: true
title: Unset Required Config Item
type: text
value: ""
name: setup
title: Setup
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: troubleshoot.sh/v1beta2
kind: Preflight
metadata:
name: my-app
spec:
collectors:
- runPod:
podSpec:
containers:
- image: myimage
securityContext:
allowPrivilegeEscalation: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: kots.io/v1beta2
kind: HelmChart
metadata:
name: my-excluded-chart
annotations:
kots.io/exclude: "true"
spec:
chart:
name: my-chart
chartVersion: 0.1.0
releaseName: my-chart-release-name
values:
foo: bar
bar: baz

exclude: true
namespace: my-namespace
optionalValues:
- when: 'true'
recursiveMerge: true
values:
foo: bar
bar: baz

builder:
foo: bar
bar: baz

weight: 1
helmUpgradeFlags:
- --timeout 70s
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: kots.io/v1beta1
kind: ConfigValues
metadata:
creationTimestamp: null
name: my-app
spec:
values:
allow_privilege_escalation:
default: "1"
helmchart_builder:
default: |
foo: bar
bar: baz
helmchart_exclude:
default: "1"
helmchart_helm_upgrade_flags_1:
default: --timeout 70s
helmchart_namespace:
default: my-namespace
helmchart_optional_values_1_recursive_merge:
default: "1"
helmchart_optional_values_1_values:
default: |
foo: bar
bar: baz
helmchart_optional_values_1_when:
default: "1"
helmchart_release_name:
default: my-chart-release-name
helmchart_values:
default: |
foo: bar
bar: baz
helmchart_weight:
default: "1"
unset_required_config_item: {}
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kots.io/v1beta1
kind: Installation
metadata:
creationTimestamp: null
name: my-app
spec:
channelID: 1vusIYZLAVxMG6q760OJmRKj5i5
channelName: My Channel
status: {}
Loading

0 comments on commit 93aa174

Please sign in to comment.