Skip to content

Commit

Permalink
Atomic/util.py: Handle TOML
Browse files Browse the repository at this point in the history
Make sure that when TOML input for registries is used,
it is parsed correctly.  Also, remain able to parse
YAML if still being used.

Signed-off-by: baude <[email protected]>

Closes: projectatomic#1137
Approved by: rhatdan
  • Loading branch information
baude authored and rh-atomic-bot committed Nov 29, 2017
1 parent de599a7 commit e5124cc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Atomic/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,16 @@ def get_registries():
if registries_tool_path() is not None:
registries_json = load_registries_from_yaml()
# Eliminate any duplicates with set.
_registries = list(set(registries_json.get("registries", [])))
_insecure_registries = list(set(registries_json.get('insecure_registries', [])))
_blocked_registries = list(set(registries_json.get('block_registries', [])))
if "registries.search" in registries_json:
# We are dealing with toml
_registries = list(set(registries_json.get("registries.search", []).get("registries", [])))
_insecure_registries = list(set(registries_json.get("registries.insecure", []).get("registries", [])))
_blocked_registries= list(set(registries_json.get("registries.block", []).get("registries", [])))
else:
# We are dealing with yaml
_registries = list(set(registries_json.get("registries", [])))
_insecure_registries = list(set(registries_json.get('insecure_registries', [])))
_blocked_registries = list(set(registries_json.get('block_registries', [])))
duplicate_secure_insecure = list(set(_registries).intersection(_insecure_registries))
if len(duplicate_secure_insecure) > 0:
raise ValueError("There are duplicate values for registries and insecure registries. Please correct "
Expand Down

0 comments on commit e5124cc

Please sign in to comment.