def test_multiple_resources(self): assert get_pod_volumes( contexts=None, artifacts_store=None, init_connections=[], connection_by_names={}, secrets=[ self.non_mount_resource1, self.non_mount_resource1, self.mount_resource1, self.mount_resource2, ], config_maps=[ self.non_mount_resource1, self.non_mount_resource1, self.mount_resource1, self.mount_resource2, ], volumes=[], ) == [ get_volume_from_secret(secret=self.mount_resource1), get_volume_from_secret(secret=self.mount_resource2), get_volume_from_config_map(config_map=self.mount_resource1), get_volume_from_config_map(config_map=self.mount_resource2), ]
def test_config_map_volumes(self): self.assert_config_map(config_map=self.non_mount_resource1, connection=False, results=[]) self.assert_config_map(config_map=self.non_mount_resource2, connection=False, results=[]) self.assert_config_map(config_map=self.mount_resource1, connection=False, results=[]) self.assert_config_map(config_map=self.mount_resource2, connection=False, results=[]) self.assert_config_map( config_map=self.mount_resource1, connection=True, results=[ get_volume_from_config_map(config_map=self.mount_resource1) ], ) self.assert_config_map( config_map=self.mount_resource2, connection=True, results=[ get_volume_from_config_map(config_map=self.mount_resource2) ], )
def add_volume_from_resource(resource: V1K8sResourceType, is_secret: bool): if is_secret: volume = get_volume_from_secret(secret=resource) else: volume = get_volume_from_config_map(config_map=resource) if volume: volumes.append(volume)
def test_get_volume_from_config_map(self): # No store assert get_volume_from_config_map(None) is None # Store with mount path resource1 = V1K8sResourceType( name="test1", schema=V1K8sResourceSchema(name="ref", items=["item1", "item2"]), is_requested=False, ) assert get_volume_from_config_map(resource1) is None # Claim store resource1 = V1K8sResourceType( name="test1", schema=V1K8sResourceSchema( name="ref", items=["item1", "item2"], mount_path="/tmp" ), is_requested=False, ) volume = get_volume_from_config_map(resource1) assert volume.name == resource1.name assert volume.config_map.name == resource1.name assert volume.config_map.items == resource1.schema.items