diff options
author | Luca Bruno <lucabru@src.gnome.org> | 2015-11-19 13:11:17 +0100 |
---|---|---|
committer | Luca Bruno <lethalman88@gmail.com> | 2016-01-13 10:27:37 +0100 |
commit | 4a4561ce244c0cea1cb07fd02f176b11f094f570 (patch) | |
tree | 7c87251deac3f444ede07159f9446296fc4db0be /pkgs/build-support/docker/detjson.py | |
parent | a7468dd9514702e368c0b75e08dc552488feef06 (diff) |
dockerTools: nix functions for manipulating docker images
Diffstat (limited to 'pkgs/build-support/docker/detjson.py')
-rw-r--r-- | pkgs/build-support/docker/detjson.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/pkgs/build-support/docker/detjson.py b/pkgs/build-support/docker/detjson.py new file mode 100644 index 0000000000000..ba2c20a475a9f --- /dev/null +++ b/pkgs/build-support/docker/detjson.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Deterministic layer json: https://github.com/docker/hub-feedback/issues/488 + +import sys +reload(sys) +sys.setdefaultencoding('UTF8') +import json + +# If any of the keys below are equal to a certain value +# then we can delete it because it's the default value +SAFEDELS = { + "Size": 0, + "config": { + "ExposedPorts": None, + "MacAddress": "", + "NetworkDisabled": False, + "PortSpecs": None, + "VolumeDriver": "" + } +} +SAFEDELS["container_config"] = SAFEDELS["config"] + +def makedet(j, safedels): + for k,v in safedels.items(): + if type(v) == dict: + makedet(j[k], v) + elif k in j and j[k] == v: + del j[k] + +def main(): + j = json.load(sys.stdin) + makedet(j, SAFEDELS) + json.dump(j, sys.stdout, sort_keys=True) + +if __name__ == '__main__': + main() \ No newline at end of file |