Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,24 +321,25 @@ That is, if you pass a param via CLI, for example, it will overwrite the corresp

###### Registry

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

###### Jenkins

Expand Down
4 changes: 4 additions & 0 deletions docs/configuration.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,10 @@
"type" : [ "string", "null" ],
"description" : "Use with registry-proxy-url, added to Jenkins as credentials and created as pull secrets, when create-image-pull-secrets is set."
},
"proxyPath" : {
"type" : [ "string", "null" ],
"description" : "Optional when registry-proxy-url is set and the registry is running on a non root web path."
},
"proxyUrl" : {
"type" : [ "string", "null" ],
"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."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ String getDockerRegistryCredentials() { 'registry-user' }

<#if config.registry.twoRegistries>
String getDockerRegistryProxyBaseUrl() { env.${config.application.namePrefixForEnvVars}REGISTRY_PROXY_URL }
String getDockerRegistryProxyPath() { env.${config.application.namePrefixForEnvVars}REGISTRY_PROXY_PATH }
String getDockerRegistryProxyCredentials() { 'registry-proxy-user' }
</#if>

Expand Down Expand Up @@ -82,7 +83,8 @@ node {
</#noparse>
<#if config.registry.twoRegistries>
<#noparse>
docker.withRegistry("https://${dockerRegistryProxyBaseUrl}", dockerRegistryProxyCredentials) {
String proxyPathPrefix = !dockerRegistryProxyPath?.trim() ? "" : "${dockerRegistryProxyPath.trim()}/"
docker.withRegistry("https://${dockerRegistryProxyBaseUrl}/${proxyPathPrefix}", dockerRegistryProxyCredentials) {
image = docker.build(imageName, '.')
}
</#noparse>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ String getDockerRegistryCredentials() { 'registry-user' }

<#if config.registry.twoRegistries>
String getDockerRegistryProxyBaseUrl() { env.${config.application.namePrefixForEnvVars}REGISTRY_PROXY_URL }
String getDockerRegistryProxyPath() { env.${config.application.namePrefixForEnvVars}REGISTRY_PROXY_PATH }
String getDockerRegistryProxyCredentials() { 'registry-proxy-user' }
</#if>
<#noparse>
Expand Down
2 changes: 1 addition & 1 deletion docs/developers.md
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ EOF
* Deploy playground:

```bash
# Create a docker container or use an available immage from a registry
# Create a docker container or use an available image from a registry
# docker build -t gop:dev .
GOP_IMAGE=gop:ingress
PATH_TWO_REGISTRIES=scripts/local/two-registries.yaml #Adjust to path above
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ String getDockerRegistryCredentials() { 'registry-user' }

<#if config.registry.twoRegistries>
String getDockerRegistryProxyBaseUrl() { env.${config.application.namePrefixForEnvVars}REGISTRY_PROXY_URL }
String getDockerRegistryProxyPath() { env.${config.application.namePrefixForEnvVars}REGISTRY_PROXY_PATH }
String getDockerRegistryProxyCredentials() { 'registry-proxy-user' }
</#if>

Expand Down Expand Up @@ -83,7 +84,8 @@ node {
</#noparse>
<#if config.registry.twoRegistries>
<#noparse>
docker.withRegistry("https://${dockerRegistryProxyBaseUrl}", dockerRegistryProxyCredentials) {
String proxyPathPrefix = !dockerRegistryProxyPath?.trim() ? "" : "${dockerRegistryProxyPath}/"
docker.withRegistry("https://${dockerRegistryProxyBaseUrl}/${proxyPathPrefix}", dockerRegistryProxyCredentials) {
image = docker.build(imageName, '.')
}
</#noparse>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ String getDockerRegistryCredentials() { 'registry-user' }

<#if config.registry.twoRegistries>
String getDockerRegistryProxyBaseUrl() { env.${config.application.namePrefixForEnvVars}REGISTRY_PROXY_URL }
String getDockerRegistryProxyPath() { env.${config.application.namePrefixForEnvVars}REGISTRY_PROXY_PATH }
String getDockerRegistryProxyCredentials() { 'registry-proxy-user' }
</#if>

Expand Down Expand Up @@ -76,7 +77,8 @@ node {
</#noparse>
<#if config.registry.twoRegistries>
<#noparse>
docker.withRegistry("https://${dockerRegistryProxyBaseUrl}", dockerRegistryProxyCredentials) {
String proxyPathPrefix = !dockerRegistryProxyPath?.trim() ? "" : "${dockerRegistryProxyPath}/"
docker.withRegistry("https://${dockerRegistryProxyBaseUrl}/${proxyPathPrefix}", dockerRegistryProxyCredentials) {
image = docker.build(imageName, '.')
}
</#noparse>
Expand Down
4 changes: 4 additions & 0 deletions src/main/groovy/com/cloudogu/gitops/config/Config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ class Config {
@JsonPropertyDescription(REGISTRY_PROXY_URL_DESCRIPTION)
String proxyUrl = ''

@Option(names = ['--registry-proxy-path'], description = REGISTRY_PROXY_PATH_DESCRIPTION)
@JsonPropertyDescription(REGISTRY_PROXY_PATH_DESCRIPTION)
String proxyPath = ''

@Option(names = ['--registry-proxy-username'], description = REGISTRY_PROXY_PASSWORD_DESCRIPTION)
@JsonPropertyDescription(REGISTRY_PROXY_USERNAME_DESCRIPTION)
String proxyUsername = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface ConfigConstants {
String REGISTRY_PASSWORD_DESCRIPTION = 'Optional when registry-url is set'

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.'
String REGISTRY_PROXY_PATH_DESCRIPTION = 'Optional when registry-proxy-url is set and the registry is running on a non root web path.'
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.'
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.'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class JenkinsDestructionHandler implements DestructionHandler {
globalPropertyManager.deleteGlobalProperty("${configuration.application.namePrefixForEnvVars}REGISTRY_URL")
globalPropertyManager.deleteGlobalProperty("${configuration.application.namePrefixForEnvVars}REGISTRY_PATH")
globalPropertyManager.deleteGlobalProperty("${configuration.application.namePrefixForEnvVars}REGISTRY_PROXY_URL")
globalPropertyManager.deleteGlobalProperty("${configuration.application.namePrefixForEnvVars}REGISTRY_PROXY_PATH")

globalPropertyManager.deleteGlobalProperty("${configuration.application.namePrefixForEnvVars}K8S_VERSION")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class Jenkins extends Feature {

if (config.registry.twoRegistries) {
globalPropertyManager.setGlobalProperty("${config.application.namePrefixForEnvVars}REGISTRY_PROXY_URL", config.registry.proxyUrl)
globalPropertyManager.setGlobalProperty("${config.application.namePrefixForEnvVars}REGISTRY_PROXY_PATH", config.registry.proxyPath)
}

if (config.jenkins.mavenCentralMirror) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ me:x:1000:''')
config.registry.username = 'reg-usr'
config.registry.password = 'reg-pw'
config.registry.proxyUrl = 'reg-proxy-url'
config.registry.proxyPath = 'reg-proxy-path'
config.registry.proxyUsername = 'reg-proxy-usr'
config.registry.proxyPassword = 'reg-proxy-pw'
config.jenkins.internal = false
Expand Down Expand Up @@ -224,6 +225,7 @@ me:x:1000:''')
verify(globalPropertyManager).setGlobalProperty('MY_PREFIX_REGISTRY_URL', 'reg-url')
verify(globalPropertyManager).setGlobalProperty('MY_PREFIX_REGISTRY_PATH', 'reg-path')
verify(globalPropertyManager, never()).setGlobalProperty(eq('MY_PREFIX_REGISTRY_PROXY_URL'), anyString())
verify(globalPropertyManager, never()).setGlobalProperty(eq('MY_PREFIX_REGISTRY_PROXY_PATH'), anyString())
verify(globalPropertyManager, never()).setGlobalProperty(eq('MAVEN_CENTRAL_MIRROR'), anyString())

verify(userManager).createUser('metrics-usr', 'metrics-pw')
Expand Down Expand Up @@ -293,12 +295,14 @@ me:x:1000:''')
config.registry.username = 'reg-usr'
config.registry.password = 'reg-pw'
config.registry.proxyUrl = 'reg-proxy-url'
config.registry.proxyPath = 'reg-proxy-path'
config.registry.proxyUsername = 'reg-proxy-usr'
config.registry.proxyPassword = 'reg-proxy-pw'

createJenkins().install()

verify(globalPropertyManager).setGlobalProperty('MY_PREFIX_REGISTRY_PROXY_URL', 'reg-proxy-url')
verify(globalPropertyManager).setGlobalProperty('MY_PREFIX_REGISTRY_PROXY_PATH', 'reg-proxy-path')

verify(globalPropertyManager).setGlobalProperty(eq('MY_PREFIX_REGISTRY_URL'), anyString())
verify(globalPropertyManager).setGlobalProperty(eq('MY_PREFIX_REGISTRY_PATH'), anyString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,9 @@ class ArgoCDTest {
'imageName = "${dockerRegistryBaseUrl}/${pathPrefix}${application}:${imageTag}"'
]
List twoRegistriesExpectedLines = [
'docker.withRegistry("https://${dockerRegistryProxyBaseUrl}", dockerRegistryProxyCredentials) {']
'String proxyPathPrefix = !dockerRegistryProxyPath?.trim() ? "" : "${dockerRegistryProxyPath}/"',
'docker.withRegistry("https://${dockerRegistryProxyBaseUrl}/${proxyPathPrefix}", dockerRegistryProxyCredentials) {',
]

for (def petclinicRepo : petClinicRepos) {
String jenkinsfile = new File(petclinicRepo.absoluteLocalRepoTmpDir, 'Jenkinsfile').text
Expand Down