Skip to content

Commit 3ca810b

Browse files
authored
Merge pull request #5 from cloudogu/feature/helm-repo-type
new gitopsBuildLib version
2 parents 39df905 + 02fba41 commit 3ca810b

File tree

3 files changed

+42
-42
lines changed

3 files changed

+42
-42
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ gitOpsBuildLib = library(identifier: "gitops-build-lib@<gitOpsBuildLibVersion>",
124124

125125
If you can access the internet or just dont want to mirror the repo you can just import it directly from github using the [pipeline-github-lib plugin](https://plugins.jenkins.io/pipeline-github-lib/) plugin.
126126
```groovy
127-
@Library('github.com/cloudogu/[email protected].7')
127+
@Library('github.com/cloudogu/[email protected].8')
128128
import com.cloudogu.gitops.gitopsbuildlib.*
129129
```
130130

test/com/cloudogu/gitopsbuildlib/deployment/DeploymentTest.groovy

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ class DeploymentTest {
1313

1414
Deployment deploymentUnderTest = new DeploymentUnderTest(scriptMock.mock, [
1515
application: 'app',
16+
stages: [
17+
staging: [
18+
namespace: 'fluxv1-staging'
19+
]
20+
],
1621
deployments: [
1722
sourcePath: 'k8s'
1823
],
@@ -38,8 +43,15 @@ class DeploymentTest {
3843
image: 'img'
3944
]
4045
]
46+
],
47+
fileConfigmaps: [
48+
[
49+
name : "index",
50+
sourceFilePath : "../index.html",
51+
stage: ["staging"]
52+
]
4153
]
42-
])
54+
] as Map)
4355

4456
@Test
4557
void 'creating folders for plain deployment'() {
@@ -59,6 +71,34 @@ class DeploymentTest {
5971
assertThat(scriptMock.actualEchoArgs[2]).isEqualTo('Executing validator helmKubeval')
6072
}
6173

74+
@Test
75+
void 'create configmaps from files'() {
76+
77+
deploymentUnderTest.createFileConfigmaps('staging')
78+
79+
assertThat(scriptMock.actualShArgs[0]).isEqualTo('[returnStdout:true, script:KUBECONFIG=pwd/.kube/config kubectl create configmap index --from-file=index.html=workspace/k8s/../index.html --dry-run=client -o yaml -n fluxv1-staging]')
80+
81+
assertThat(scriptMock.actualWriteFileArgs[0]).isEqualTo('[file:pwd/.kube/config, text:apiVersion: v1\n' +
82+
'clusters:\n' +
83+
'- cluster:\n' +
84+
' certificate-authority-data: DATA+OMITTED\n' +
85+
' server: https://localhost\n' +
86+
' name: self-hosted-cluster\n' +
87+
'contexts:\n' +
88+
'- context:\n' +
89+
' cluster: self-hosted-cluster\n' +
90+
' user: svcs-acct-dply\n' +
91+
' name: svcs-acct-context\n' +
92+
'current-context: svcs-acct-context\n' +
93+
'kind: Config\n' +
94+
'preferences: {}\n' +
95+
'users:\n' +
96+
'- name: svcs-acct-dply\n' +
97+
' user:\n' +
98+
' token: DATA+OMITTED]')
99+
assertThat(scriptMock.actualWriteFileArgs[1]).contains('[file:staging/app/generatedResources/index.yaml')
100+
}
101+
62102
class DeploymentUnderTest extends Deployment {
63103

64104
DeploymentUnderTest(Object script, Object gitopsConfig) {

test/com/cloudogu/gitopsbuildlib/deployment/HelmTest.groovy

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ class HelmTest {
7070
assertThat(scriptMock.actualShArgs[1]).isEqualTo('[returnStdout:true, script:helm values workspace/chart/chartPath -f workspace/k8s/values-staging.yaml -f workspace/k8s/values-shared.yaml ]')
7171
assertThat(scriptMock.actualShArgs[2]).isEqualTo('rm -rf workspace/chart || true')
7272
assertThat(scriptMock.actualShArgs[3]).isEqualTo('rm staging/testapp/mergedValues.yaml')
73-
assertThat(scriptMock.actualShArgs[4]).isEqualTo('[returnStdout:true, script:KUBECONFIG=pwd/.kube/config kubectl create configmap index --from-file=index.html=workspace/k8s/../index.html --dry-run=client -o yaml -n fluxv1-staging]')
7473
assertThat(scriptMock.actualWriteFileArgs[0]).isEqualTo('[file:staging/testapp/mergedValues.yaml, ' +
7574
'text:[git clone repoUrl workspace/chart || true, ' +
7675
'[returnStdout:true, ' +
@@ -102,25 +101,6 @@ class HelmTest {
102101
' be:\n' +
103102
' changed: \'oldValue\'\n' +
104103
']')
105-
assertThat(scriptMock.actualWriteFileArgs[2]).isEqualTo('[file:pwd/.kube/config, text:apiVersion: v1\n' +
106-
'clusters:\n' +
107-
'- cluster:\n' +
108-
' certificate-authority-data: DATA+OMITTED\n' +
109-
' server: https://localhost\n' +
110-
' name: self-hosted-cluster\n' +
111-
'contexts:\n' +
112-
'- context:\n' +
113-
' cluster: self-hosted-cluster\n' +
114-
' user: svcs-acct-dply\n' +
115-
' name: svcs-acct-context\n' +
116-
'current-context: svcs-acct-context\n' +
117-
'kind: Config\n' +
118-
'preferences: {}\n' +
119-
'users:\n' +
120-
'- name: svcs-acct-dply\n' +
121-
' user:\n' +
122-
' token: DATA+OMITTED]')
123-
assertThat(scriptMock.actualWriteFileArgs[3]).contains('[file:staging/testapp/generatedResources/index.yaml')
124104
}
125105

126106
@Test
@@ -134,7 +114,6 @@ class HelmTest {
134114
assertThat(scriptMock.actualShArgs[3]).isEqualTo('[returnStdout:true, script:helm values workspace/chart/chartName -f workspace/k8s/values-staging.yaml -f workspace/k8s/values-shared.yaml ]')
135115
assertThat(scriptMock.actualShArgs[4]).isEqualTo('rm -rf workspace/chart || true')
136116
assertThat(scriptMock.actualShArgs[5]).isEqualTo('rm staging/testapp/mergedValues.yaml')
137-
assertThat(scriptMock.actualShArgs[6]).isEqualTo('[returnStdout:true, script:KUBECONFIG=pwd/.kube/config kubectl create configmap index --from-file=index.html=workspace/k8s/../index.html --dry-run=client -o yaml -n fluxv1-staging]')
138117
assertThat(scriptMock.actualWriteFileArgs[0]).isEqualTo('[file:staging/testapp/mergedValues.yaml, ' +
139118
'text:[helm repo add chartRepo repoUrl, helm repo update, ' +
140119
'helm pull chartRepo/chartName --version=1.0 --untar --untardir=workspace/chart, ' +
@@ -166,24 +145,5 @@ class HelmTest {
166145
' be:\n' +
167146
' changed: \'oldValue\'\n' +
168147
']')
169-
assertThat(scriptMock.actualWriteFileArgs[2]).isEqualTo('[file:pwd/.kube/config, text:apiVersion: v1\n' +
170-
'clusters:\n' +
171-
'- cluster:\n' +
172-
' certificate-authority-data: DATA+OMITTED\n' +
173-
' server: https://localhost\n' +
174-
' name: self-hosted-cluster\n' +
175-
'contexts:\n' +
176-
'- context:\n' +
177-
' cluster: self-hosted-cluster\n' +
178-
' user: svcs-acct-dply\n' +
179-
' name: svcs-acct-context\n' +
180-
'current-context: svcs-acct-context\n' +
181-
'kind: Config\n' +
182-
'preferences: {}\n' +
183-
'users:\n' +
184-
'- name: svcs-acct-dply\n' +
185-
' user:\n' +
186-
' token: DATA+OMITTED]')
187-
assertThat(scriptMock.actualWriteFileArgs[3]).contains('[file:staging/testapp/generatedResources/index.yaml')
188148
}
189149
}

0 commit comments

Comments
 (0)