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!
Procházet zdrojové kódy

Added ability to tag builds

tags/0.92
Stanislaw Adaszewski před 4 roky
rodič
revize
ee2e02ba26
3 změnil soubory, kde provedl 26 přidání a 4 odebrání
  1. +1
    -0
      focker.py
  2. +7
    -3
      image.py
  3. +18
    -1
      zfs.py

+ 1
- 0
focker.py Zobrazit soubor

@@ -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 Zobrazit soubor

@@ -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 Zobrazit soubor

@@ -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:


Načítá se…
Zrušit
Uložit