Skip to content

Commit

Permalink
exporter: Add --token-cmd argument
Browse files Browse the repository at this point in the history
  • Loading branch information
holesch committed Aug 11, 2024
1 parent 6abb093 commit 6671aa3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions not_my_board/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def add_cacert_arg(subparser):
)
subparser.set_defaults(verbose=True)
add_cacert_arg(subparser)
subparser.add_argument("--token-cmd", help="generate ID tokens with shell command")
subparser.add_argument("hub_url", help="http(s) URL of the hub")
subparser.add_argument(
"export_description", type=pathlib.Path, help="path to a export description"
Expand Down Expand Up @@ -161,7 +162,8 @@ def _hub_command(_):

async def _export_command(args):
http_client = http.Client(args.cacert)
token_src = auth.IdTokenFromFile(args.hub_url, http_client, TOKEN_STORE_PATH)
token_src = _token_src(args, http_client)

async with export.Exporter(
args.hub_url, args.export_description, http_client, token_src
) as exporter:
Expand All @@ -172,16 +174,18 @@ async def _export_command(args):
async def _agent_command(args):
http_client = http.Client(args.cacert)
io = agent.AgentIO(args.hub_url, http_client)

if args.token_cmd:
token_src = auth.IdTokenFromCmd(args.hub_url, http_client, args.token_cmd)
else:
token_src = auth.IdTokenFromFile(args.hub_url, http_client, TOKEN_STORE_PATH)
token_src = _token_src(args, http_client)

async with agent.Agent(args.hub_url, io, token_src) as agent_:
await agent_.serve_forever()


def _token_src(args, http_client):
if args.token_cmd:
return auth.IdTokenFromCmd(args.hub_url, http_client, args.token_cmd)
return auth.IdTokenFromFile(args.hub_url, http_client, TOKEN_STORE_PATH)


async def _reserve_command(args):
await client.reserve(args.import_description, args.with_name)

Expand Down

0 comments on commit 6671aa3

Please sign in to comment.