Example #1
0
    def _get_backend(self, type_name):
        "imports and registers backend according to type_name"
        try:
            return self.backends[type_name]
        except KeyError:
            ref_kwargs = {"embed_refs": self.embed_refs}
            if type_name == "plain":
                from kapitan.refs.base import PlainRefBackend

                # XXX embed_refs in plain backend does nothing
                self.register_backend(PlainRefBackend(self.path, **ref_kwargs))
            elif type_name == "base64":
                from kapitan.refs.base64 import Base64RefBackend

                self.register_backend(Base64RefBackend(self.path, **ref_kwargs))
            elif type_name == "gpg":
                from kapitan.refs.secrets.gpg import GPGBackend

                self.register_backend(GPGBackend(self.path, **ref_kwargs))
            elif type_name == "gkms":
                from kapitan.refs.secrets.gkms import GoogleKMSBackend

                self.register_backend(GoogleKMSBackend(self.path, **ref_kwargs))
            elif type_name == "awskms":
                from kapitan.refs.secrets.awskms import AWSKMSBackend

                self.register_backend(AWSKMSBackend(self.path, **ref_kwargs))
            elif type_name == "vaultkv":
                from kapitan.refs.secrets.vaultkv import VaultBackend

                self.register_backend(VaultBackend(self.path, **ref_kwargs))
            else:
                raise RefBackendError(f"no backend for ref type: {type_name}")
        return self.backends[type_name]
Example #2
0
 def _get_backend(self, type_name):
     "imports and registers backend according to type_name"
     try:
         return self.backends[type_name]
     except KeyError:
         if type_name == 'ref':
             from kapitan.refs.base import RefBackend
             self.register_backend(RefBackend(self.path))
         elif type_name == 'gpg':
             from kapitan.refs.secrets.gpg import GPGBackend
             self.register_backend(GPGBackend(self.path))
         elif type_name == 'gkms':
             from kapitan.refs.secrets.gkms import GoogleKMSBackend
             self.register_backend(GoogleKMSBackend(self.path))
         elif type_name == 'awskms':
             from kapitan.refs.secrets.awskms import AWSKMSBackend
             self.register_backend(AWSKMSBackend(self.path))
         else:
             raise RefBackendError('no backend for ref type: {}'.format(type_name))
     return self.backends[type_name]