-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhance: credentials: add GPTSCRIPT_CREDENTIAL_EXPIRATION (#709)
Signed-off-by: Grant Linville <[email protected]>
- Loading branch information
1 parent
160a733
commit b77cd13
Showing
7 changed files
with
97 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
cred: credentialTool with 2 as hours | ||
cred: credentialTool with 1 as hours | ||
|
||
#!python3 | ||
|
||
import os | ||
|
||
print("Expires: " + os.getenv("GPTSCRIPT_CREDENTIAL_EXPIRATION", ""), end="") | ||
|
||
--- | ||
name: credentialTool | ||
args: hours: the number of hours from now to expire | ||
|
||
#!python3 | ||
|
||
import os | ||
import json | ||
from datetime import datetime, timedelta, timezone | ||
|
||
class Output: | ||
def __init__(self, env, expires_at): | ||
self.env = env | ||
self.expiresAt = expires_at | ||
|
||
def to_dict(self): | ||
return { | ||
"env": self.env, | ||
"expiresAt": self.expiresAt.isoformat() | ||
} | ||
|
||
hours_str = os.getenv("HOURS") | ||
if hours_str is None: | ||
print("HOURS environment variable is not set") | ||
os._exit(1) | ||
|
||
try: | ||
hours = int(hours_str) | ||
except ValueError: | ||
print("failed to parse HOURS") | ||
os._exit(1) | ||
|
||
expires_at = datetime.now(timezone.utc) + timedelta(hours=hours) | ||
out = Output(env={"yeet": "yote"}, expires_at=expires_at) | ||
out_json = json.dumps(out.to_dict()) | ||
|
||
print(out_json) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters