Skip to content

Commit c899937

Browse files
Add --registry-proxy-path cli param (#367)
* add parameter --registry-proxy-path * fix typo * set REGISTRY_PROXY_PATH only if twoRegistries is enabled * add RegistryProxyPath to jenkinsfile Templates * temporarily change which branch to pull during integration tests * Jenkinsfile.ftl aktualisieren Co-authored-by: Thomas <thomas@thomasmichael.de> * Apply suggestion from @ThomasMichael1811 --------- Co-authored-by: Thomas <thomas@thomasmichael.de>
1 parent 0487ef4 commit c899937

13 files changed

Lines changed: 49 additions & 23 deletions

File tree

README.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -320,24 +320,25 @@ That is, if you pass a param via CLI, for example, it will overwrite the corresp
320320

321321
###### Registry
322322

323-
| CLI | Config | Default | Type | Description |
324-
|-----|--------|---------|------|-------------|
325-
| `--registry` | `registry.active` | `false` | Boolean | Installs a simple cluster-local registry for demonstration purposes. Warning: Registry does not provide authentication! |
326-
| `--internal-registry-port` | `registry.internalPort` | `30000` | Integer | Port of registry registry. Ignored when a registry*url params are set |
327-
| `--registry-url` | `registry.url` | `''` | String | The url of your external registry, used for pushing images |
328-
| `--registry-path` | `registry.path` | `''` | String | Optional when registry-url is set |
329-
| `--registry-username` | `registry.username` | `''` | String | Optional when registry-url is set |
330-
| `--registry-password` | `registry.password` | `''` | String | Optional when registry-url is set |
331-
| `--registry-proxy-url` | `registry.proxyUrl` | `''` | String | The url of your proxy-registry. Used in pipelines to authorize pull base images |
332-
| `--registry-proxy-username` | `registry.proxyUsername` | `''` | String | Use with registry-proxy-url, added to Jenkins as credentials and created as pull secrets |
333-
| `--registry-proxy-password` | `registry.proxyPassword` | `''` | String | Use with registry-proxy-url, added to Jenkins as credentials and created as pull secrets |
334-
| `--registry-username-read-only` | `registry.readOnlyUsername` | `''` | String | Optional alternative username for registry-url with read-only permissions |
335-
| `--registry-password-read-only` | `registry.readOnlyPassword` | `''` | String | Optional alternative password for registry-url with read-only permissions |
336-
| `--create-image-pull-secrets` | `registry.createImagePullSecrets` | `false` | Boolean | Create image pull secrets for registry and proxy-registry for all GOP namespaces |
337-
| - | `registry.helm.chart` | `'docker-registry'` | String | Name of the Helm chart |
338-
| - | `registry.helm.repoURL` | `'https://helm.twun.io'` | String | Repository url from which the Helm chart should be obtained |
339-
| - | `registry.helm.version` | `'2.2.3'` | String | The version of the Helm chart to be installed |
340-
| - | `registry.helm.values` | `[:]` | Map | Helm values of the chart |
323+
| CLI | Config | Default | Type | Description |
324+
|---------------------------------|-----------------------------------|---------|------|-------------|
325+
| `--registry` | `registry.active` | `false` | Boolean | Installs a simple cluster-local registry for demonstration purposes. Warning: Registry does not provide authentication! |
326+
| `--internal-registry-port` | `registry.internalPort` | `30000` | Integer | Port of registry registry. Ignored when a registry*url params are set |
327+
| `--registry-url` | `registry.url` | `''` | String | The url of your external registry, used for pushing images |
328+
| `--registry-path` | `registry.path` | `''` | String | Optional when registry-url is set |
329+
| `--registry-username` | `registry.username` | `''` | String | Optional when registry-url is set |
330+
| `--registry-password` | `registry.password` | `''` | String | Optional when registry-url is set |
331+
| `--registry-proxy-url` | `registry.proxyUrl` | `''` | String | The url of your proxy-registry. Used in pipelines to authorize pull base images |
332+
| `--registry-proxy-path` | `registry.proxyPath` | `''` | String | Optional when registry-proxy-url is set and the registry is running on a non root web path. |
333+
| `--registry-proxy-username` | `registry.proxyUsername` | `''` | String | Use with registry-proxy-url, added to Jenkins as credentials and created as pull secrets |
334+
| `--registry-proxy-password` | `registry.proxyPassword` | `''` | String | Use with registry-proxy-url, added to Jenkins as credentials and created as pull secrets |
335+
| `--registry-username-read-only` | `registry.readOnlyUsername` | `''` | String | Optional alternative username for registry-url with read-only permissions |
336+
| `--registry-password-read-only` | `registry.readOnlyPassword` | `''` | String | Optional alternative password for registry-url with read-only permissions |
337+
| `--create-image-pull-secrets` | `registry.createImagePullSecrets` | `false` | Boolean | Create image pull secrets for registry and proxy-registry for all GOP namespaces |
338+
| - | `registry.helm.chart` | `'docker-registry'` | String | Name of the Helm chart |
339+
| - | `registry.helm.repoURL` | `'https://helm.twun.io'` | String | Repository url from which the Helm chart should be obtained |
340+
| - | `registry.helm.version` | `'2.2.3'` | String | The version of the Helm chart to be installed |
341+
| - | `registry.helm.values` | `[:]` | Map | Helm values of the chart |
341342

342343
###### Jenkins
343344

docs/configuration.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,10 @@
772772
"type" : [ "string", "null" ],
773773
"description" : "Use with registry-proxy-url, added to Jenkins as credentials and created as pull secrets, when create-image-pull-secrets is set."
774774
},
775+
"proxyPath" : {
776+
"type" : [ "string", "null" ],
777+
"description" : "Optional when registry-proxy-url is set and the registry is running on a non root web path."
778+
},
775779
"proxyUrl" : {
776780
"type" : [ "string", "null" ],
777781
"description" : "The url of your proxy-registry. Used in pipelines to authorize pull base images. Use in conjunction with petclinic base image. Used in helm charts when create-image-pull-secrets is set. Use in conjunction with helm.*image fields."

docs/content-loader/example-tenant/petclinic-helm/Jenkinsfile.ftl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ String getDockerRegistryCredentials() { 'registry-user' }
1111

1212
<#if config.registry.twoRegistries>
1313
String getDockerRegistryProxyBaseUrl() { env.${config.application.namePrefixForEnvVars}REGISTRY_PROXY_URL }
14+
String getDockerRegistryProxyPath() { env.${config.application.namePrefixForEnvVars}REGISTRY_PROXY_PATH }
1415
String getDockerRegistryProxyCredentials() { 'registry-proxy-user' }
1516
</#if>
1617

@@ -82,7 +83,8 @@ node {
8283
</#noparse>
8384
<#if config.registry.twoRegistries>
8485
<#noparse>
85-
docker.withRegistry("https://${dockerRegistryProxyBaseUrl}", dockerRegistryProxyCredentials) {
86+
String proxyPathPrefix = !dockerRegistryProxyPath?.trim() ? "" : "${dockerRegistryProxyPath.trim()}/"
87+
docker.withRegistry("https://${dockerRegistryProxyBaseUrl}/${proxyPathPrefix}", dockerRegistryProxyCredentials) {
8688
image = docker.build(imageName, '.')
8789
}
8890
</#noparse>

docs/content-loader/example-tenant/petclinic-plain/Jenkinsfile.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ String getDockerRegistryCredentials() { 'registry-user' }
1111

1212
<#if config.registry.twoRegistries>
1313
String getDockerRegistryProxyBaseUrl() { env.${config.application.namePrefixForEnvVars}REGISTRY_PROXY_URL }
14+
String getDockerRegistryProxyPath() { env.${config.application.namePrefixForEnvVars}REGISTRY_PROXY_PATH }
1415
String getDockerRegistryProxyCredentials() { 'registry-proxy-user' }
1516
</#if>
1617
<#noparse>

docs/developers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ EOF
536536
* Deploy playground:
537537
538538
```bash
539-
# Create a docker container or use an available immage from a registry
539+
# Create a docker container or use an available image from a registry
540540
# docker build -t gop:dev .
541541
GOP_IMAGE=gop:ingress
542542
PATH_TWO_REGISTRIES=scripts/local/two-registries.yaml #Adjust to path above

examples/example-apps-via-content-loader/argocd/petclinic-helm/Jenkinsfile.ftl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ String getDockerRegistryCredentials() { 'registry-user' }
1212

1313
<#if config.registry.twoRegistries>
1414
String getDockerRegistryProxyBaseUrl() { env.${config.application.namePrefixForEnvVars}REGISTRY_PROXY_URL }
15+
String getDockerRegistryProxyPath() { env.${config.application.namePrefixForEnvVars}REGISTRY_PROXY_PATH }
1516
String getDockerRegistryProxyCredentials() { 'registry-proxy-user' }
1617
</#if>
1718

@@ -83,7 +84,8 @@ node {
8384
</#noparse>
8485
<#if config.registry.twoRegistries>
8586
<#noparse>
86-
docker.withRegistry("https://${dockerRegistryProxyBaseUrl}", dockerRegistryProxyCredentials) {
87+
String proxyPathPrefix = !dockerRegistryProxyPath?.trim() ? "" : "${dockerRegistryProxyPath}/"
88+
docker.withRegistry("https://${dockerRegistryProxyBaseUrl}/${proxyPathPrefix}", dockerRegistryProxyCredentials) {
8789
image = docker.build(imageName, '.')
8890
}
8991
</#noparse>

examples/example-apps-via-content-loader/argocd/petclinic-plain/Jenkinsfile.ftl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ String getDockerRegistryCredentials() { 'registry-user' }
1212

1313
<#if config.registry.twoRegistries>
1414
String getDockerRegistryProxyBaseUrl() { env.${config.application.namePrefixForEnvVars}REGISTRY_PROXY_URL }
15+
String getDockerRegistryProxyPath() { env.${config.application.namePrefixForEnvVars}REGISTRY_PROXY_PATH }
1516
String getDockerRegistryProxyCredentials() { 'registry-proxy-user' }
1617
</#if>
1718

@@ -76,7 +77,8 @@ node {
7677
</#noparse>
7778
<#if config.registry.twoRegistries>
7879
<#noparse>
79-
docker.withRegistry("https://${dockerRegistryProxyBaseUrl}", dockerRegistryProxyCredentials) {
80+
String proxyPathPrefix = !dockerRegistryProxyPath?.trim() ? "" : "${dockerRegistryProxyPath}/"
81+
docker.withRegistry("https://${dockerRegistryProxyBaseUrl}/${proxyPathPrefix}", dockerRegistryProxyCredentials) {
8082
image = docker.build(imageName, '.')
8183
}
8284
</#noparse>

src/main/groovy/com/cloudogu/gitops/config/Config.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ class Config {
208208
@JsonPropertyDescription(REGISTRY_PROXY_URL_DESCRIPTION)
209209
String proxyUrl = ''
210210

211+
@Option(names = ['--registry-proxy-path'], description = REGISTRY_PROXY_PATH_DESCRIPTION)
212+
@JsonPropertyDescription(REGISTRY_PROXY_PATH_DESCRIPTION)
213+
String proxyPath = ''
214+
211215
@Option(names = ['--registry-proxy-username'], description = REGISTRY_PROXY_PASSWORD_DESCRIPTION)
212216
@JsonPropertyDescription(REGISTRY_PROXY_USERNAME_DESCRIPTION)
213217
String proxyUsername = ''

src/main/groovy/com/cloudogu/gitops/config/ConfigConstants.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface ConfigConstants {
1616
String REGISTRY_PASSWORD_DESCRIPTION = 'Optional when registry-url is set'
1717

1818
String REGISTRY_PROXY_URL_DESCRIPTION = 'The url of your proxy-registry. Used in pipelines to authorize pull base images. Use in conjunction with petclinic base image. Used in helm charts when create-image-pull-secrets is set. Use in conjunction with helm.*image fields.'
19+
String REGISTRY_PROXY_PATH_DESCRIPTION = 'Optional when registry-proxy-url is set and the registry is running on a non root web path.'
1920
String REGISTRY_PROXY_USERNAME_DESCRIPTION = 'Use with registry-proxy-url, added to Jenkins as credentials and created as pull secrets, when create-image-pull-secrets is set.'
2021
String REGISTRY_PROXY_PASSWORD_DESCRIPTION = 'Use with registry-proxy-url, added to Jenkins as credentials and created as pull secrets, when create-image-pull-secrets is set.'
2122

src/main/groovy/com/cloudogu/gitops/destroy/JenkinsDestructionHandler.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class JenkinsDestructionHandler implements DestructionHandler {
2626
globalPropertyManager.deleteGlobalProperty("${configuration.application.namePrefixForEnvVars}REGISTRY_URL")
2727
globalPropertyManager.deleteGlobalProperty("${configuration.application.namePrefixForEnvVars}REGISTRY_PATH")
2828
globalPropertyManager.deleteGlobalProperty("${configuration.application.namePrefixForEnvVars}REGISTRY_PROXY_URL")
29+
globalPropertyManager.deleteGlobalProperty("${configuration.application.namePrefixForEnvVars}REGISTRY_PROXY_PATH")
30+
2931
globalPropertyManager.deleteGlobalProperty("${configuration.application.namePrefixForEnvVars}K8S_VERSION")
3032
}
3133
}

0 commit comments

Comments
 (0)