Skip to content

Commit

Permalink
Adding sep config back
Browse files Browse the repository at this point in the history
  • Loading branch information
abuabraham-ttd committed Jan 19, 2025
1 parent aa91898 commit 35d0a2f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion scripts/confidential_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def validate_operator_key():
expected_env = "I" if debug_mode or env == "integ" else "P"
if operator_key.split("-")[2] != expected_env:
raise InvalidOperatorKey(self.__class__.__name__)
print("Validated operator key matches environment ",operator_key)
print("Validated operator key matches environment")
else:
print("Skipping operator key validation")

Expand Down
14 changes: 14 additions & 0 deletions scripts/gcp-oidc/conf/integ-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"sites_metadata_path": "https://core.uidapi.com/sites/refresh",
"clients_metadata_path": "https://core.uidapi.com/clients/refresh",
"keysets_metadata_path": "https://core.uidapi.com/key/keyset/refresh",
"keyset_keys_metadata_path": "https://core.uidapi.com/key/keyset-keys/refresh",
"client_side_keypairs_metadata_path": "https://core.uidapi.com/client_side_keypairs/refresh",
"salts_metadata_path": "https://core.uidapi.com/salt/refresh",
"services_metadata_path": "https://core.uidapi.com/services/refresh",
"service_links_metadata_path": "https://core.uidapi.com/service_links/refresh",
"optout_metadata_path": "https://optout.uidapi.com/optout/refresh",
"core_attest_url": "https://core.uidapi.com/attest",
"optout_api_uri": "https://optout.uidapi.com/optout/replicate",
"optout_s3_folder": "uid-optout-integ/"
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"optout_metadata_path": "https://optout.uidapi.com/optout/refresh",
"core_attest_url": "https://core.uidapi.com/attest",
"optout_api_uri": "https://optout.uidapi.com/optout/replicate",
"optout_s3_folder": "uid-optout-integ/",
"optout_s3_folder": "optout-v2/",
"identity_token_expires_after_seconds": 259200
}
7 changes: 3 additions & 4 deletions scripts/gcp-oidc/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,18 @@ def _get_secret(self, secret_identifier=None) -> ConfidentialComputeConfig:
raise MissingConfig(self.__class__.__name__, ["API_TOKEN_SECRET_NAME"])
try:
client = secretmanager.SecretManagerServiceClient()
secret_version_name = f"projects/{default()[1]}/secrets/ian-secret-operator-key/versions/latest"
secret_version_name = f"projects/{default()[1]}/secrets/{os.getenv("API_TOKEN_SECRET_NAME")}/versions/latest"
response = client.access_secret_version(name=secret_version_name)
secret_value = response.payload.data.decode("UTF-8")
except PermissionDenied or DefaultCredentialsError :
raise MissingInstanceProfile(self.__class__.__name__)
except NotFound:
raise ConfigNotFound(self.__class__.__name__, f"Secret Manager {os.getenv("API_TOKEN_SECRET_NAME")}")
config["api_token"] = secret_value
os.environ["gcp_secret_version_name"] = os.getenv("API_TOKEN_SECRET_NAME") # ideally add to config?
return config

def __populate_operator_config(self, destination):
#Add gcp_secret_version_name here?
target_config = f"/app/conf/uid2-config.json"
target_config = f"/app/conf/{self.configs["environment"].lower()}-config.json"
shutil.copy(target_config, destination)
with open(destination, 'r') as file:
config = file.read()
Expand All @@ -71,6 +69,7 @@ def run_compute(self) -> None:
self.validate_configuration()
config_locaton = "/tmp/final-config.json"
self.__populate_operator_config(config_locaton)
os.environ["gcp_secret_version_name"] = os.getenv("API_TOKEN_SECRET_NAME")
java_command = [
"java",
"-XX:MaxRAMPercentage=95",
Expand Down

0 comments on commit 35d0a2f

Please sign in to comment.