IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Ver código fonte

Added ability to tag builds

tags/0.92
Stanislaw Adaszewski 4 anos atrás
pai
commit
ee2e02ba26
3 arquivos alterados com 26 adições e 4 exclusões
  1. +1
    -0
      focker.py
  2. +7
    -3
      image.py
  3. +18
    -1
      zfs.py

+ 1
- 0
focker.py Ver arquivo

@@ -15,6 +15,7 @@ def create_parser():
parser = subparsers.add_parser('build')
parser.set_defaults(func=command_image_build)
parser.add_argument('focker_dir', type=str)
parser.add_argument('--tag', '-t', type=str, nargs='+', default=[])
return parser_top


+ 7
- 3
image.py Ver arquivo

@@ -51,11 +51,13 @@ def build(spec):
feed = {
'focker:sha256': st_sha256
}
zfs_tag(name, feed)
# zfs_tag(snap_name, feed)
zfs_set_props(name, feed)
# zfs_set_props(snap_name, feed)
base = snap_name
base_sha256 = st_sha256
return (base, base_sha256)
def command_image_build(args):
fname = os.path.join(args.focker_dir, 'Fockerfile')
@@ -65,4 +67,6 @@ def command_image_build(args):
with open(fname, 'r') as f:
spec = yaml.safe_load(f)
print('spec:', spec)
build(spec)
image, image_sha256 = build(spec)
zfs_untag(args.tag)
zfs_tag(image.split('@')[0], args.tag)

+ 18
- 1
zfs.py Ver arquivo

@@ -44,7 +44,7 @@ def zfs_exists(name):
return True
def zfs_tag(name, props):
def zfs_set_props(name, props):
for (k, v) in props.items():
zfs_run(['zfs', 'set', k + '=' + v, name])
@@ -72,6 +72,23 @@ def zfs_snapshot_by_sha256(sha256):
return lst[0][1]
def zfs_tag(name, tags):
if len(tags) > 0:
zfs_run(['zfs', 'set', 'focker:tags=' + ' '.join(tags), name])
else:
zfs_run(['zfs', 'inherit', 'focker:tags', name])
def zfs_untag(tags):
lst = zfs_parse_output(['zfs', 'list', '-o', 'name,focker:tags', '-H'])
lst = filter(lambda a: any([b in a[1].split(' ') for b in tags]), lst)
for row in lst:
cur_tags = row[1].split(' ')
for t in tags:
cur_tags.remove(t)
zfs_tag(row[0], cur_tags)
def zfs_init():
poolname = zfs_parse_output(['zfs', 'list', '-H', '/'])
if len(poolname) == 0:


Carregando…
Cancelar
Salvar