Skip to content

Commit

Permalink
clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
yishi-ttd committed Oct 27, 2023
1 parent 520f12b commit f3e87ab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
14 changes: 0 additions & 14 deletions scripts/gcp-oidc/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,6 @@ if [ -z "${API_TOKEN_SECRET_NAME}" ]; then
exit 1
fi

GCP_TOKEN=$(wget "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token" -q --header "Metadata-Flavor: Google" -O - | jq -e -r ".access_token")
if [ $? -ne 0 -o -z "${GCP_TOKEN}" ]; then
echo "Failed to get GCP token"
exit 1
fi

API_TOKEN=$(wget "https://secretmanager.googleapis.com/v1/${API_TOKEN_SECRET_NAME}:access" -q --header "authorization: Bearer ${GCP_TOKEN}" --header "content-type: application/json" -O - | jq -e -r ".payload.data" | base64 -d)
if [ $? -ne 0 -o -z "${API_TOKEN}" ]; then
echo "Failed to get API token"
exit 1
fi

export core_api_token="${API_TOKEN}"
export optout_api_token="${API_TOKEN}"
export gcp_secret_version_name="${API_TOKEN_SECRET_NAME}"

# -- locate config file
Expand Down
12 changes: 2 additions & 10 deletions src/main/java/com/uid2/operator/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -500,16 +500,8 @@ private IOperatorKeyRetriever createOperatorKeyRetriever() throws Exception {
return OperatorKeyRetrieverFactory.getAzureOperatorKeyRetriever(vaultName, secretName);
}
case "gcp-oidc": {
try{
LOGGER.info("load secret version name.");
var secretVersionName = this.config.getString(Const.Config.GcpSecretVersionNameProp);
return new GcpOperatorKeyRetriever(secretVersionName);
// sut.retrieve();
// return () -> this.config.getString(Const.Config.CoreApiTokenProp);
}
catch (Exception e){
LOGGER.info("Fail to load secret version." + e);
}
var secretVersionName = this.config.getString(Const.Config.GcpSecretVersionNameProp);
return new GcpOperatorKeyRetriever(secretVersionName);
}
default: {
// default to load from config
Expand Down

0 comments on commit f3e87ab

Please sign in to comment.