Example #1
0
 def test_get_base_container(self):
     store = V1ConnectionType(
         name="test_claim",
         kind=V1ConnectionKind.VOLUME_CLAIM,
         schema=V1ClaimConnection(mount_path="/tmp",
                                  volume_claim="test",
                                  read_only=True),
     )
     env = [get_env_var(name="key", value="value")]
     env_from = [k8s_schemas.V1EnvFromSource(secret_ref={"name": "ref"})]
     mounts = [k8s_schemas.V1VolumeMount(name="test", mount_path="/test")]
     container = get_base_store_container(
         container=k8s_schemas.V1Container(name="init"),
         container_name="init",
         polyaxon_init=V1PolyaxonInitContainer(
             image="foo/foo",
             image_tag="",
             image_pull_policy="IfNotPresent"),
         store=store,
         env=env,
         env_from=env_from,
         volume_mounts=mounts,
         args=["test"],
     )
     assert container.name == "init"
     assert container.image == "foo/foo"
     assert container.image_pull_policy == "IfNotPresent"
     assert container.command == ["/bin/sh", "-c"]
     assert container.args == ["test"]
     assert container.env == env
     assert container.env_from == env_from
     assert container.resources is not None
     assert container.volume_mounts == mounts + [
         get_mount_from_store(store=store)
     ]
Example #2
0
def get_env_from_config_map(
    config_map: V1K8sResourceType, ) -> Optional[k8s_schemas.V1EnvFromSource]:
    if not config_map or config_map.schema.items or config_map.schema.mount_path:
        return None

    return k8s_schemas.V1EnvFromSource(
        config_map_ref={"name": config_map.schema.name})
Example #3
0
def get_env_from_secret(
    secret: V1K8sResourceType,
) -> Optional[k8s_schemas.V1EnvFromSource]:
    if not secret or secret.schema.items or secret.schema.mount_path:
        return None

    return k8s_schemas.V1EnvFromSource(secret_ref={"name": secret.schema.name})