Skip to content

Commit 2b0b323

Browse files
authored
Merge pull request #4321 from sskaje/T7092
T7092: Add Container Registry Mirror
2 parents b70e368 + a8e0f01 commit 2b0b323

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

data/templates/container/registries.conf.j2

+10
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,14 @@
2828
{% set _ = registry_list.append(r) %}
2929
{% endfor %}
3030
unqualified-search-registries = {{ registry_list }}
31+
{% for r, r_options in registry.items() if r_options.disable is not vyos_defined %}
32+
[[registry]]
33+
{% if r_options.mirror is vyos_defined %}
34+
location = "{{ r_options.mirror.host_name if r_options.mirror.host_name is vyos_defined else r_options.mirror.address }}{{ ":" + r_options.mirror.port if r_options.mirror.port is vyos_defined }}{{ r_options.mirror.path if r_options.mirror.path is vyos_defined }}"
35+
{% else %}
36+
location = "{{ r }}"
37+
{% endif %}
38+
insecure = {{ 'true' if r_options.insecure is vyos_defined else 'false' }}
39+
prefix = "{{ r }}"
40+
{% endfor %}
3141
{% endif %}

interface-definitions/container.xml.in

+48
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,54 @@
571571
<children>
572572
#include <include/interface/authentication.xml.i>
573573
#include <include/generic-disable-node.xml.i>
574+
<leafNode name="insecure">
575+
<properties>
576+
<help>Allow registry access over unencrypted HTTP or TLS connections with untrusted certificates</help>
577+
<valueless/>
578+
</properties>
579+
</leafNode>
580+
<node name="mirror">
581+
<properties>
582+
<help>Registry mirror, use host-name|address[:port][/path]</help>
583+
</properties>
584+
<children>
585+
<leafNode name="address">
586+
<properties>
587+
<help>IP address of container registry mirror</help>
588+
<valueHelp>
589+
<format>ipv4</format>
590+
<description>IPv4 address of container registry mirror</description>
591+
</valueHelp>
592+
<valueHelp>
593+
<format>ipv6</format>
594+
<description>IPv6 address of container registry mirror</description>
595+
</valueHelp>
596+
<constraint>
597+
<validator name="ip-address"/>
598+
<validator name="ipv6-link-local"/>
599+
</constraint>
600+
</properties>
601+
</leafNode>
602+
<leafNode name="host-name">
603+
<properties>
604+
<help>Hostname of container registry mirror</help>
605+
<valueHelp>
606+
<format>hostname</format>
607+
<description>FQDN of container registry mirror</description>
608+
</valueHelp>
609+
<constraint>
610+
<validator name="fqdn"/>
611+
</constraint>
612+
</properties>
613+
</leafNode>
614+
#include <include/port-number.xml.i>
615+
<leafNode name="path">
616+
<properties>
617+
<help>Path of container registry mirror, optional, must be start with '/' if not empty</help>
618+
</properties>
619+
</leafNode>
620+
</children>
621+
</node>
574622
</children>
575623
</tagNode>
576624
</children>

src/conf_mode/container.py

+7
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,13 @@ def verify(container):
289289

290290
if 'registry' in container:
291291
for registry, registry_config in container['registry'].items():
292+
if 'mirror' in registry_config:
293+
if 'host_name' in registry_config['mirror'] and 'address' in registry_config['mirror']:
294+
raise ConfigError(f'Container registry mirror address/host-name are mutually exclusive!')
295+
296+
if 'path' in registry_config['mirror'] and not registry_config['mirror']['path'].startswith('/'):
297+
raise ConfigError('Container registry mirror path must start with "/"!')
298+
292299
if 'authentication' not in registry_config:
293300
continue
294301
if not {'username', 'password'} <= set(registry_config['authentication']):

0 commit comments

Comments
 (0)