       cloneData.config           ?= {}
       cloneData.config.clonedFrom = @getId()
 
-      # TODO make sure to clone custom credentials as well ~ GG
-
-      JStackTemplate.create client, cloneData, (err, cloneStackTemplate) ->
-        if err then callback new KodingError 'Clone failed', err
-        else callback null, cloneStackTemplate
+      { custom } = cloneData.credentials or {}
+      custom    ?= []
+
+      if custom.length > 0
+        cloneCustomCredentials client, custom, (err, creds) ->
+          return callback new KodingError 'Failed to clone credentials'  if err
+          cloneData.credentials.custom = creds
+          JStackTemplate.create client, cloneData, callback
+      else
+        JStackTemplate.create client, cloneData, callback
 
 
 # Base StackTemplate example for koding group

}

###



      @update { $set: data }, (err) => callback err, this


  cloneCustomCredentials = (client, credentials, callback) ->

    JCredential = require './credential'
    clonedCreds = []
    queue       = []

    credentials.forEach (identifier) -> queue.push ->
      JCredential.fetchByIdentifier client, identifier, (err, credential) ->
        if not err and credential
          credential.clone client, (err, cloneCredential) ->
            if err
              console.warn "Clone failed:", err
            else
              clonedCreds.push cloneCredential.identifier
            queue.next()
        else
          queue.next()

    queue.push ->
      callback null, clonedCreds

    daisy queue


  clone: permit

    advanced: [
