Release key only on Live and Competition

This commit is contained in:
Matias committed 2019-02-16 21:22:40 -03:00
1 parent df6f199f3b
commit b7cfc5028c
1 file changed
+5 -2
@@ -7,6 +7,7 @@ import teamQuery from '../../graphQLCalls/teamQuery'
import { isDefined } from '../../config/utils'
import cloneDetails from '../cloneDetails'
import authorizeClone from '../../graphQLCalls/authorizeClone'
import { LIVE, COMPETITION } from '../../enums/CloneMode'
const args = {
id: { type: new GraphQLNonNull(GraphQLID) }
@@ -32,8 +33,10 @@ const resolve = async (parent, { id }, context) => {
let team = await teamQuery(context.authorization, clone.teamId)
clone = await cloneDetails(context.userId, team.data.data.teams_TeamById, clone)
logger.debug('removeClone -> Release the clone key.')
await authorizeClone(context.authorization, clone.keyId, clone.id, true)
if ( (clone.mode === LIVE || clone.mode === COMPETITION) && !isDefined(clone.keyId)) {
logger.debug('removeClone -> Release the clone key.')
await authorizeClone(context.authorization, clone.keyId, clone.id, true)
}
logger.debug('removeClone -> Removing Clone from Kubernates.')
await removeKuberneteClone(clone)