Always create a secret during release
* Always create a secret during release
Change the flow to always create a secret until we figure out project permissions
* Add limit 1
@@ -28,14 +28,7 @@ while getopts "p:" opt; do
esac
done
-VALID_KEYS=$(gcloud iam service-accounts keys list --iam-account=metrics-writer@${PROJECT_ID}.iam.gserviceaccount.com --project=${PROJECT_ID} --managed-by=user --filter="validBeforeTime.date('%Y-%m-%d', Z)>`date +%F`" --format="value(name)")
-retVal=$?
-if [ $retVal -ne 0 ]; then
- echo "No permissions to list keys."
- exit 1
-fi
-if [ -z "$VALID_KEYS" ]; then
# create a new valid key
gcloud iam service-accounts keys create ${KEY_FILE} --iam-account=metrics-writer@${PROJECT_ID}.iam.gserviceaccount.com --project=${PROJECT_ID}
retVal=$?
@@ -43,10 +36,6 @@ if [ -z "$VALID_KEYS" ]; then
echo "No key created."
exit 1
fi
- KEY_ID=$(gcloud iam service-accounts keys list --iam-account=metrics-writer@${PROJECT_ID}.iam.gserviceaccount.com --project=${PROJECT_ID} --managed-by=user --filter="validBeforeTime.date('%Y-%m-%d', Z)>`date +%F`" --format="value(name)")
+KEY_ID=$(gcloud iam service-accounts keys list --iam-account=metrics-writer@k8s-skaffold.iam.gserviceaccount.com --project=k8s-skaffold --managed-by=user --filter="validAfterTime.date('%Y-%m-%d', Z) = `date +%F`" --format="value(name)" --limit=1)
gsutil cp ${KEY_FILE} gs://${BUCKET_ID}/${KEY_ID}.json
gsutil cp ${KEY_FILE} gs://${BUCKET_ID}/${LATEST_GCS_PATH}
-else
- # download the valid key from gcs
- gsutil cp gs://${BUCKET_ID}/${LATEST_GCS_PATH} ${KEY_FILE}
-fi
\ No newline at end of file
