def _render_and_write_kubernetes_config(
        self,
        kubernetes_config_path: str,
        application_name: str,
        secrets: List[Secret],
        custom_values: Dict[str, str],
    ) -> str:
        """
        Render the jinja-templated kubernetes configuration adn write it out to a temporary file.
        Args:
            kubernetes_config_path: The raw, jinja-templated kubernetes configuration path.
            application_name: Current application name

        Returns:
            The path to the temporary file where the rendered kubernetes configuration is stored.
        """
        vault_values = {_.jinja_safe_key: ensure_base64(_.val) for _ in secrets}

        context_values = {
            **{
                _.jinja_safe_key: ensure_base64(_.val)
                for _ in Context().get_or_else(ContextKey.EVENTHUB_PRODUCER_POLICY_SECRETS, {})
            },
            **{
                _.jinja_safe_key: ensure_base64(_.val)
                for _ in Context().get_or_else(ContextKey.EVENTHUB_CONSUMER_GROUP_SECRETS, {})
            },
        }

        kubernetes_config = self._render_kubernetes_config(
            kubernetes_config_path, application_name, {**vault_values, **context_values}, custom_values
        )
        return self._write_kubernetes_config(kubernetes_config)
Exemple #2
0
def test_ensure_base64_encoded():
    result = victim.ensure_base64("c29tZXRoaW5n")
    assert result == "c29tZXRoaW5n"
Exemple #3
0
def test_ensure_base64_non_encoded():
    result = victim.ensure_base64("something")
    assert result == "c29tZXRoaW5n"