Skip to content

Commit

Permalink
Add support for go repos (#298)
Browse files Browse the repository at this point in the history
Co-authored-by: Olivier Clavel <[email protected]>
  • Loading branch information
enicholson125 and zeitounator authored Oct 28, 2020
1 parent 4b05796 commit 3c9ef78
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ All three repository types are combined with the following default values :
negative_cache_ttl: 1440 # Nexus gui default. For proxies only
```

Maven, Pypi, Docker, Raw, Rubygems, Bower, NPM, Git-LFS, yum, apt, helm, r, p2 and conda repository types:
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 All @@ -658,6 +658,7 @@ maven is configured by default
nexus_config_r: false
nexus_config_p2: false
nexus_config_conda: false
nexus_config_go: false
```

These are all false unless you override them from playbook / group_var / cli, these all utilize the same mechanism as maven.
Expand Down
16 changes: 16 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ nexus_config_helm: false
nexus_config_r: false
nexus_config_p2: false
nexus_config_conda: false
nexus_config_go: false

nexus_content_selectors: []
# example selector item :
Expand Down Expand Up @@ -262,6 +263,9 @@ nexus_blob_names: # Splited blob name list @ blob_vars.yml
blob: 'default'
conda:
blob: 'default'
go:
blob: 'default'


nexus_blobstores: []
# example blobstore item :
Expand Down Expand Up @@ -744,3 +748,15 @@ _nexus_repos_conda_defaults:
nexus_repos_conda_proxy: []
# - name: conda-proxy
# remote_url: 'https://repo.continuum.io/pkgs/'

_nexus_repos_go_defaults:
blob_store: "{{ nexus_blob_names.go.blob }}"
strict_content_validation: true
write_policy: allow_once # one of "allow", "allow_once" or "deny"
maximum_component_age: 1440 # Nexus gui default. For proxies only
maximum_metadata_age: 1440 # Nexus gui default. For proxies only
negative_cache_enabled: true # Nexus gui default. For proxies only
negative_cache_ttl: 1440 # Nexus gui default. For proxies only

nexus_repos_go_group: []
nexus_repos_go_proxy: []
5 changes: 5 additions & 0 deletions molecule/nexus_common_test_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ nexus_config_apt: true
nexus_config_helm: true
nexus_config_r: true
nexus_config_conda: true
nexus_config_go: true

nexus_anonymous_access: true

Expand Down Expand Up @@ -226,6 +227,10 @@ nexus_repos_conda_proxy:
- name: conda-proxy
remote_url: 'https://repo.continuum.io/pkgs/'

nexus_repos_go_proxy:
- name: go-proxy
remote_url: 'https://golang.org/pkg/'

nexus_content_selectors:
# Docker by namespace. For mode details see:
# https://help.sonatype.com/repomanager3/formats/docker-registry/content-selectors-and-docker
Expand Down
33 changes: 33 additions & 0 deletions tasks/process_repos_list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -578,3 +578,36 @@
+
(nexus_repos_r_proxy | map('combine', {"format": "conda", "type": "proxy"}) | list)
}}
- name: Process definitions for go repositories
when: nexus_config_go | bool
block:

- name: apply defaults to go proxy repos
set_fact:
nexus_repos_go_proxy: >-
{%- set result=[] -%}
{%- for repo in nexus_repos_go_proxy -%}
{{ result.append(_nexus_repos_go_defaults | combine(repo)) }}
{%- endfor -%}
{{ result | to_json | from_json }}
- name: apply defaults to go group repos
set_fact:
nexus_repos_go_group: >-
{%- set result=[] -%}
{%- for repo in nexus_repos_go_group -%}
{{ result.append(_nexus_repos_go_defaults | combine(repo)) }}
{%- endfor -%}
{{ result | to_json | from_json }}
- name: Add go repositories to global repos list
set_fact:
_nexus_repos_global_list: >-
{{
_nexus_repos_global_list | default([])
+
(nexus_repos_go_proxy | map('combine', {"format": "go", "type": "proxy"}) | list)
+
(nexus_repos_go_group | map('combine', {"format": "go", "type": "group"}) | list)
}}
5 changes: 5 additions & 0 deletions vars/blob_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ nexus_blob_names:
blob: '{{ nexus_blob_prefix }}p2'
conda:
blob: '{{ nexus_blob_prefix }}conda'
go:
blob: '{{ nexus_blob_prefix }}go'


nexus_blobstores:
- name: '{{ nexus_blob_prefix }}raw'
Expand Down Expand Up @@ -63,3 +66,5 @@ nexus_blobstores:
path: "{{ nexus_data_dir }}/blobs/{{ nexus_blob_names.p2.blob }}"
- name: '{{ nexus_blob_prefix }}conda'
path: "{{ nexus_data_dir }}/blobs/{{ nexus_blob_names.conda.blob }}"
- name: '{{ nexus_blob_prefix }}go'
path: "{{ nexus_data_dir }}/blobs/{{ nexus_blob_names.go.blob }}"

0 comments on commit 3c9ef78

Please sign in to comment.