Example #1
0
    def test_get_env_from_secrets(self):
        # None
        assert get_env_from_secrets(secrets=None) == []
        # Secret with items
        secret1 = V1K8sResourceType(
            name="test1",
            schema=V1K8sResourceSchema(name="test1", items=["item1", "item2"]),
            is_requested=True,
        )
        # Secret
        secret2 = V1K8sResourceType(
            name="test2",
            schema=V1K8sResourceSchema(name="test_ref"),
            is_requested=True)

        assert get_env_from_secrets(secrets=[secret1, secret2]) == [
            get_env_from_secret(secret2)
        ]
Example #2
0
 def test_get_env_from_k8s_resources(self):
     assert get_env_from_k8s_resources(secrets=[], config_maps=[]) == []
     res1 = V1K8sResourceType(name="test",
                              schema=V1K8sResourceSchema(name="test"),
                              is_requested=True)
     res2 = V1K8sResourceType(name="test2",
                              schema=V1K8sResourceSchema(name="test2"),
                              is_requested=True)
     expected = get_env_from_secrets(secrets=[res1, res2])
     assert (get_env_from_k8s_resources(secrets=[res1, res2],
                                        config_maps=[]) == expected)
     expected = get_env_from_secrets(
         secrets=[res1]) + get_env_from_config_maps(config_maps=[res2])
     assert (get_env_from_k8s_resources(secrets=[res1],
                                        config_maps=[res2]) == expected)
     expected = get_env_from_config_maps(config_maps=[res1, res2])
     assert (get_env_from_k8s_resources(secrets=[],
                                        config_maps=[res1,
                                                     res2]) == expected)