| |
@@ -1,6 +1,7 @@
|
| |
#!/usr/bin/env python
|
| |
from __future__ import print_function
|
| |
|
| |
+ import os
|
| |
import argparse
|
| |
import sys
|
| |
|
| |
@@ -61,6 +62,8 @@
|
| |
parser.add_argument(
|
| |
'--server', default=None, help="Use custom ODCS server.")
|
| |
parser.add_argument(
|
| |
+ '--token', default=None, help="OpenIDC token to use or path to token file")
|
| |
+ parser.add_argument(
|
| |
'--no-wait', action='store_true',
|
| |
help='When used, odcs client will not wait for the action to finish.')
|
| |
parser.add_argument(
|
| |
@@ -258,30 +261,37 @@
|
| |
odcs_url = args.server
|
| |
|
| |
if args.infra == 'fedora':
|
| |
- id_provider = id_provider_config[args.env]
|
| |
-
|
| |
- # Get the auth token using the OpenID client.
|
| |
- oidc = openidc_client.OpenIDCClient(
|
| |
- 'odcs',
|
| |
- id_provider,
|
| |
- {'Token': 'Token', 'Authorization': 'Authorization'},
|
| |
- 'odcs-authorizer',
|
| |
- 'notsecret',
|
| |
- )
|
| |
+ if args.token:
|
| |
+ if os.path.exists(args.token):
|
| |
+ with open(args.token, "r") as token_file:
|
| |
+ token = token_file.readline().strip()
|
| |
+ else:
|
| |
+ token = args.token
|
| |
+ else:
|
| |
+ id_provider = id_provider_config[args.env]
|
| |
+
|
| |
+ # Get the auth token using the OpenID client.
|
| |
+ oidc = openidc_client.OpenIDCClient(
|
| |
+ 'odcs',
|
| |
+ id_provider,
|
| |
+ {'Token': 'Token', 'Authorization': 'Authorization'},
|
| |
+ 'odcs-authorizer',
|
| |
+ 'notsecret',
|
| |
+ )
|
| |
|
| |
- scopes = [
|
| |
- 'openid',
|
| |
- 'https://id.fedoraproject.org/scope/groups',
|
| |
- 'https://pagure.io/odcs/new-compose',
|
| |
- 'https://pagure.io/odcs/renew-compose',
|
| |
- 'https://pagure.io/odcs/delete-compose',
|
| |
- ]
|
| |
- try:
|
| |
- token = oidc.get_token(scopes, new_token=True)
|
| |
- token = oidc.report_token_issue()
|
| |
- except requests.exceptions.HTTPError as e:
|
| |
- print(e.response.text)
|
| |
- raise
|
| |
+ scopes = [
|
| |
+ 'openid',
|
| |
+ 'https://id.fedoraproject.org/scope/groups',
|
| |
+ 'https://pagure.io/odcs/new-compose',
|
| |
+ 'https://pagure.io/odcs/renew-compose',
|
| |
+ 'https://pagure.io/odcs/delete-compose',
|
| |
+ ]
|
| |
+ try:
|
| |
+ token = oidc.get_token(scopes, new_token=True)
|
| |
+ token = oidc.report_token_issue()
|
| |
+ except requests.exceptions.HTTPError as e:
|
| |
+ print(e.response.text)
|
| |
+ raise
|
| |
|
| |
client = odcs.client.odcs.ODCS(
|
| |
odcs_url,
|
| |
This is needed in Fedora infrastructure to run nightly ODCS composes.