Example #1
0
 def test_get_from_config_map(self):
     env_var = get_from_config_map(key_name="foo",
                                   config_map_key_name="cm_key",
                                   config_map_ref_name="cm_ref")
     assert env_var.name == "foo"
     assert isinstance(env_var.value_from, k8s_schemas.V1EnvVarSource)
     assert env_var.value_from.config_map_key_ref.name == "cm_ref"
     assert env_var.value_from.config_map_key_ref.key == "cm_key"
Example #2
0
 def get_items_from_config_map(self):
     # None
     assert get_items_from_secret(None) == []
     # Secret without items
     secret = V1K8sResourceType(name="test",
                                schema=V1K8sResourceSchema(name="test"),
                                is_requested=True)
     assert get_items_from_secret(secret) == []
     secret = V1K8sResourceType(
         name="test",
         schema=V1K8sResourceSchema(name="test", items=[]),
         is_requested=True,
     )
     assert get_items_from_secret(secret) == []
     # Secret with items
     secret = V1K8sResourceType(
         name="test",
         schema=V1K8sResourceSchema(name="test", items=["item1", "item2"]),
         is_requested=True,
     )
     assert get_items_from_secret(secret) == [
         get_from_config_map("item1", "item1", secret.schema.name),
         get_from_config_map("item2", "item2", secret.schema.name),
     ]