A few more test files.
This commit is contained in:
parent
33f1ea6cd1
commit
478827da20
@ -19,6 +19,12 @@
|
||||
DEF_MERGE_TYPE = 'replace'
|
||||
MERGE_TYPES = ('append', 'prepend', DEF_MERGE_TYPE,)
|
||||
|
||||
def _has_any(what, *keys):
|
||||
for k in keys:
|
||||
if k in what:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class Merger(object):
|
||||
def __init__(self, merger, opts):
|
||||
@ -30,9 +36,9 @@ class Merger(object):
|
||||
self._method = m
|
||||
break
|
||||
# Affect how recursive merging is done on other primitives
|
||||
self._recurse_str = 'recurse_str' in opts
|
||||
self._recurse_dict = 'recurse_dict' in opts
|
||||
self._recurse_array = 'recurse_array' in opts
|
||||
self._recurse_str = _has_any(opts, 'recurse_str')
|
||||
self._recurse_dict = _has_any(opts, 'recurse_dict')
|
||||
self._recurse_array = _has_any(opts, 'recurse_array', 'recurse_list')
|
||||
|
||||
def __str__(self):
|
||||
return ('ListMerger: (method=%s,recurse_str=%s,'
|
||||
|
9
tests/data/merge_sources/expected6.yaml
Normal file
9
tests/data/merge_sources/expected6.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
#cloud-config
|
||||
|
||||
run_cmds:
|
||||
- bash
|
||||
- top
|
||||
- ps
|
||||
- vi
|
||||
- emacs
|
||||
|
38
tests/data/merge_sources/expected7.yaml
Normal file
38
tests/data/merge_sources/expected7.yaml
Normal file
@ -0,0 +1,38 @@
|
||||
#cloud-config
|
||||
|
||||
users:
|
||||
- default
|
||||
- name: foobar
|
||||
gecos: Foo B. Bar
|
||||
primary-group: foobar
|
||||
groups: users
|
||||
selinux-user: staff_u
|
||||
expiredate: 2012-09-01
|
||||
ssh-import-id: foobar
|
||||
lock-passwd: false
|
||||
passwd: $6$j212wezy$7H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/
|
||||
- name: barfoo
|
||||
gecos: Bar B. Foo
|
||||
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||
groups: users, admin
|
||||
ssh-import-id: None
|
||||
lock-passwd: true
|
||||
ssh-authorized-keys:
|
||||
- <ssh pub key 1>
|
||||
- <ssh pub key 2>
|
||||
- name: cloudy
|
||||
gecos: Magic Cloud App Daemon User
|
||||
inactive: true
|
||||
system: true
|
||||
- bob
|
||||
- joe
|
||||
- sue
|
||||
- name: foobar_jr
|
||||
gecos: Foo B. Bar Jr
|
||||
primary-group: foobar
|
||||
groups: users
|
||||
selinux-user: staff_u
|
||||
expiredate: 2012-09-01
|
||||
ssh-import-id: foobar
|
||||
lock-passwd: false
|
||||
passwd: $6$j212wezy$7H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/
|
7
tests/data/merge_sources/expected8.yaml
Normal file
7
tests/data/merge_sources/expected8.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
#cloud-config
|
||||
|
||||
mounts:
|
||||
- [ ephemeral22, /mnt, auto, "defaults,noexec" ]
|
||||
- [ sdc, /opt/data ]
|
||||
- [ xvdh, /opt/data, "auto", "defaults,nobootwait", "0", "0" ]
|
||||
- [ dd, /dev/zero ]
|
5
tests/data/merge_sources/expected9.yaml
Normal file
5
tests/data/merge_sources/expected9.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
#cloud-config
|
||||
|
||||
phone_home:
|
||||
url: http://my.example.com/$INSTANCE_ID/$BLAH_BLAH
|
||||
post: [ pub_key_dsa, pub_key_rsa, pub_key_ecdsa, instance_id ]
|
5
tests/data/merge_sources/source6-1.yaml
Normal file
5
tests/data/merge_sources/source6-1.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
#cloud-config
|
||||
|
||||
run_cmds:
|
||||
- bash
|
||||
- top
|
8
tests/data/merge_sources/source6-2.yaml
Normal file
8
tests/data/merge_sources/source6-2.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
#cloud-config
|
||||
|
||||
run_cmds:
|
||||
- ps
|
||||
- vi
|
||||
- emacs
|
||||
|
||||
merge_type: 'list(append)+dict(recurse_array)+str()'
|
27
tests/data/merge_sources/source7-1.yaml
Normal file
27
tests/data/merge_sources/source7-1.yaml
Normal file
@ -0,0 +1,27 @@
|
||||
#cloud-config
|
||||
|
||||
users:
|
||||
- default
|
||||
- name: foobar
|
||||
gecos: Foo B. Bar
|
||||
primary-group: foobar
|
||||
groups: users
|
||||
selinux-user: staff_u
|
||||
expiredate: 2012-09-01
|
||||
ssh-import-id: foobar
|
||||
lock-passwd: false
|
||||
passwd: $6$j212wezy$7H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/
|
||||
- name: barfoo
|
||||
gecos: Bar B. Foo
|
||||
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||
groups: users, admin
|
||||
ssh-import-id: None
|
||||
lock-passwd: true
|
||||
ssh-authorized-keys:
|
||||
- <ssh pub key 1>
|
||||
- <ssh pub key 2>
|
||||
- name: cloudy
|
||||
gecos: Magic Cloud App Daemon User
|
||||
inactive: true
|
||||
system: true
|
||||
|
17
tests/data/merge_sources/source7-2.yaml
Normal file
17
tests/data/merge_sources/source7-2.yaml
Normal file
@ -0,0 +1,17 @@
|
||||
#cloud-config
|
||||
|
||||
users:
|
||||
- bob
|
||||
- joe
|
||||
- sue
|
||||
- name: foobar_jr
|
||||
gecos: Foo B. Bar Jr
|
||||
primary-group: foobar
|
||||
groups: users
|
||||
selinux-user: staff_u
|
||||
expiredate: 2012-09-01
|
||||
ssh-import-id: foobar
|
||||
lock-passwd: false
|
||||
passwd: $6$j212wezy$7H/1LT4f9/N3wpgNunhsIqtMj62OKiS3nyNwuizouQc3u7MbYCarYeAHWYPYb2FT.lbioDm2RrkJPb9BZMN1O/
|
||||
|
||||
merge_how: "dict(recurse_array)+list(append)"
|
7
tests/data/merge_sources/source8-1.yaml
Normal file
7
tests/data/merge_sources/source8-1.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
#cloud-config
|
||||
|
||||
mounts:
|
||||
- [ ephemeral0, /mnt, auto, "defaults,noexec" ]
|
||||
- [ sdc, /opt/data ]
|
||||
- [ xvdh, /opt/data, "auto", "defaults,nobootwait", "0", "0" ]
|
||||
- [ dd, /dev/zero ]
|
6
tests/data/merge_sources/source8-2.yaml
Normal file
6
tests/data/merge_sources/source8-2.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
#cloud-config
|
||||
|
||||
mounts:
|
||||
- [ ephemeral22, /mnt, auto, "defaults,noexec" ]
|
||||
|
||||
merge_how: 'dict(recurse_array)+list(recurse_list,recurse_str)+str()'
|
5
tests/data/merge_sources/source9-1.yaml
Normal file
5
tests/data/merge_sources/source9-1.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
#cloud-config
|
||||
|
||||
phone_home:
|
||||
url: http://my.example.com/$INSTANCE_ID/
|
||||
post: [ pub_key_dsa, pub_key_rsa, pub_key_ecdsa, instance_id ]
|
6
tests/data/merge_sources/source9-2.yaml
Normal file
6
tests/data/merge_sources/source9-2.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
#cloud-config
|
||||
|
||||
phone_home:
|
||||
url: $BLAH_BLAH
|
||||
|
||||
merge_how: 'dict(recurse_str)+str(append)'
|
Loading…
x
Reference in New Issue
Block a user