Skip to content

Commit

Permalink
fix: check to see if we already have a SA for the project
Browse files Browse the repository at this point in the history
  • Loading branch information
aearly committed Aug 2, 2019
1 parent 854e23d commit 4fc360a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/reconcile.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ module.exports = function (clusterInfo, uuid = require('uuid')) {

const { common, cluster, tokens } = inputSettings

if (!cluster.credentials) {
try {
// see if we already have a SA for this project
const email = `${common.projectId}-k8s-sa@${common.projectId}.iam.gserviceaccount.com`
const creds = await clusterInfo.getServiceAccount(email)
if (creds) cluster.credentials = creds
log.info('reusing existing service account for the project')
} catch (e) {
log.error(e.stack)
}
}

if (typeof common.credentials === 'string') {
common.credentials = JSON.parse(common.credentials)
}
Expand Down Expand Up @@ -197,6 +209,8 @@ module.exports = function (clusterInfo, uuid = require('uuid')) {

const { environment = 'production' } = cluster

delete cluster.operation

const commonKeys = Object.keys(cluster).filter(key => {
return (cluster[key] === tokens[key] || fastDeepEqual(cluster[key], tokens[key]))
})
Expand Down

0 comments on commit 4fc360a

Please sign in to comment.