Skip to content

Commit

Permalink
Update generate.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bossOfCode authored Aug 23, 2024
1 parent c7a54ad commit 941ac7b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
version = os.environ.get("INPUTS_UUID")
namespace = os.environ.get("INPUTS_NAMESPACE")
name = os.environ.get("INPUTS_NAME")
output = ""

versions = [1, 3, 4, 5]
namespaces = ["DNS", "URL", "OID", "X500"]
Expand All @@ -18,27 +17,26 @@ def print_in_os(argument):

if version in versions or namespace in namespaces:
if version == 1:
output = uuid.uuid1()
output = str(uuid.uuid1())
else:
if version == 3:
output = uuid.uuid3(str("NAMESPACES_" + namespace), name)
output = str(uuid.uuid3(str("NAMESPACES_" + namespace), name))
else:
if version == 4:
output = uuid.uuid4()
output = str(uuid.uuid4())
else:
if version == 5:
output = uuid.uuid5(str("NAMESPACES_" + namespace), name)
output = str(uuid.uuid5(str("NAMESPACES_" + namespace), name))
else:
if namespace in namespaces:
sys.exit(f"ERROR: namespace cannot be {namespace}; must be either DNS, URL, OID, or X500.")
else:
if version in versions:
sys.exit(f"ERROR: version {version} does not exist")

FINAL = str(output)
SAFE = uuid.SafeUUID

print_in_os(f"echo 'uuid={FINAL}' >> $GITHUB_OUTPUT")
print_in_os(f"echo 'uuid={output}' >> $GITHUB_OUTPUT")
print_in_os(f"echo 'safe={SAFE}' >> $GITHUB_OUTPUT")

if SAFE == "unsafe":
Expand Down

0 comments on commit 941ac7b

Please sign in to comment.