Skip to content

Commit

Permalink
Add ability to allow redeployments for containers with latest tag (an…
Browse files Browse the repository at this point in the history
…sible-ThoTeam#395)

* Add ability to allow redeployments for containers with latest tag

---------

Co-authored-by: Olivier Clavel <[email protected]>
  • Loading branch information
brianveltman and zeitounator authored Dec 23, 2023
1 parent 6b9b039 commit 1d795a9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,16 @@ nexus_repos_docker_group:
- docker-hosted-repo
```

```yaml
nexus_repos_docker_hosted:
- name: some-docker-repo
blob_store: docker-blob
v1_enabled: false
write_policy: allow_once # Values: "allow", "allow_once" or "deny"
# When set, it will ignore the defined write_policy and allows to redeploy container images with the tag 'latest' only.
allow_redeploy_latest: true
```

Maven, Pypi, Docker, Raw, Rubygems, Bower, NPM, Git-LFS, yum, apt, helm, r, p2, conda and go repository types:
see `defaults/main.yml` for these options. For historical reasons and to keep backward compatibility,
maven is configured by default
Expand Down
9 changes: 9 additions & 0 deletions files/groovy/create_repos_from_list.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,15 @@ parsed_args.each { currentRepo ->
]
}

if (currentRepo.allow_redeploy_latest && currentRepo.type == 'hosted' && currentRepo.format == 'docker') {
configuration.attributes['storage'] = [
latestPolicy: currentRepo.allow_redeploy_latest ? currentRepo.allow_redeploy_latest : null,
// When setting the allow_redeploy_latest, the writePolicy must be set to ALLOW_ONCE and API expects blobStoreName param
writePolicy: currentRepo.allow_redeploy_latest ? "ALLOW_ONCE" : currentRepo.write_policy.toUpperCase(),
blobStoreName: currentRepo.blob_store
]
}

if (existingRepository == null) {
repositoryManager.create(configuration)
currentResult.put('status', 'created')
Expand Down
6 changes: 6 additions & 0 deletions molecule/nexus_common_test_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ nexus_repos_docker_hosted:
force_basic_auth: true
v1_enabled: true
write_policy: allow
- name: docker-private-redeploy
write_policy: deny # will be ignored when allow_redeploy_latest is true
allow_redeploy_latest: true
- name: docker-private-no-redeploy
write_policy: deny # will be effective when allow_redeploy_latest is false
allow_redeploy_latest: false

nexus_repos_docker_proxy: []
nexus_repos_apt_hosted:
Expand Down

0 comments on commit 1d795a9

Please sign in to comment.