Skip to content

Commit

Permalink
Complete implementation of service account credentials for policy API
Browse files Browse the repository at this point in the history
  • Loading branch information
rlxdev committed Nov 19, 2024
1 parent bb6b92d commit 5e30c1c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 28 deletions.
44 changes: 22 additions & 22 deletions scubagoggles/docs/upgrading/Upgrading.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Upgrading and Maintenance

## Upgrading ScubaGoggles
Assuming you installed ScubaGoggles as described in [Download and Install](/docs/installation/DownloadAndInstall.md), upgrading to the lastest version of ScubaGoggles should be as simple as:
- Repeating the steps described in [Download and Install](/docs/installation/DownloadAndInstall.md) with the new release.
- Making the OPA executable available, by either:
- downloading the executable again as described in [Download the OPA executable](/docs/installation/OPA.md),
- copying the executable from the old release folder to the new release folder, or
- using the `--opapath` parameter to tell ScubaGoggles where to look for the executable.
- Making your credentials available, by either:
- copying your `credentials.json` file to the new release folder or
- using the `--credentials` parameter to tell ScubaGoggles where to look for your credentials.

If instead you cloned the ScubaGoggles repo and wish to run ScubaGoggles on the latest code from main (only recommended for development purposes), be sure to run `python -m pip install .` inside the ScubaGoggles directory after pulling the latest code.

## Upgrading OPA
While new versions of OPA are periodically released, it is only necessary to upgrade OPA if the version you have locally is unsupported. Running `python download_opa.py --help` lists the supported OPA versions.

Upgrading OPA is as simple as downloading the desired executable, which can be done by running the `download_opa.py` script again. See [Download the OPA executable](/docs/installation/OPA.md) for detailed instructions.

## Navigation
- Return to [Documentation Home](/README.md)
# Upgrading and Maintenance

## Upgrading ScubaGoggles
Assuming you installed ScubaGoggles as described in [Download and Install](/docs/installation/DownloadAndInstall.md), upgrading to the lastest version of ScubaGoggles should be as simple as:
- Repeating the steps described in [Download and Install](/docs/installation/DownloadAndInstall.md) with the new release.
- Making the OPA executable available, by either:
- downloading the executable again as described in [Download the OPA executable](/docs/installation/OPA.md),
- copying the executable from the old release folder to the new release folder, or
- using the `--opapath` parameter to tell ScubaGoggles where to look for the executable.
- Making your credentials available, by either:
- copying your `credentials.json` file to the new release folder or
- using the `--credentials` parameter to tell ScubaGoggles where to look for your credentials.

If instead you cloned the ScubaGoggles repo and wish to run ScubaGoggles on the latest code from main (only recommended for development purposes), be sure to run `python -m pip install .` inside the ScubaGoggles directory after pulling the latest code.

## Upgrading OPA
While new versions of OPA are periodically released, it is only necessary to upgrade OPA if the version you have locally is unsupported. Running `python download_opa.py --help` lists the supported OPA versions.

Upgrading OPA is as simple as downloading the desired executable, which can be done by running the `download_opa.py` script again. See [Download the OPA executable](/docs/installation/OPA.md) for detailed instructions.

## Navigation
- Return to [Documentation Home](/README.md)
4 changes: 3 additions & 1 deletion scubagoggles/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def _run_gws_providers(self):
args = self._args
products = args.baselines

with Provider(args.customerid, args.credentials) as provider:
with Provider(args.customerid,
args.credentials,
args.subjectemail) as provider:
provider_dict = provider.call_gws_providers(products, args.quiet)
provider_dict['baseline_suffix'] = Version.suffix
provider_dict['successful_calls'] = list(provider.successful_calls)
Expand Down
15 changes: 10 additions & 5 deletions scubagoggles/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,21 @@ class Provider:
Class for making the GWS api calls and tracking the results.
"""

def __init__(self, customer_id: str, credentials_file: Path):
"""
Initialize the Provider.
def __init__(self,
customer_id: str,
credentials_file: Path,
svc_account_email: str = None):

"""Initialize the Provider.
:param customer_id: the ID of the customer to run against.
:param credentials_file: file specification of Google JSON-format
credentials
credentials.
:param svc_account_email: (optional) email address for the service
account.
"""

self._gws_auth = GwsAuth(credentials_file)
self._gws_auth = GwsAuth(credentials_file, svc_account_email)
self._credentials = self._gws_auth.credentials
self._services = {}
self._customer_id = customer_id
Expand Down

0 comments on commit 5e30c1c

Please sign in to comment.