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_secret_volumes(self): self.assert_secret(secret=self.non_mount_resource1, results=[]) self.assert_secret(secret=self.non_mount_resource2, results=[]) self.assert_secret( secret=self.mount_resource1, results=[get_volume_from_secret(secret=self.mount_resource1)], ) self.assert_secret( secret=self.mount_resource2, results=[get_volume_from_secret(secret=self.mount_resource2)], )
def test_single_connections(self): self.assert_single_artifacts_store(store=self.s3_store, results=[]) self.assert_single_artifacts_store(store=self.gcs_store, results=[]) self.assert_single_artifacts_store(store=self.az_store, results=[]) self.assert_single_artifacts_store( store=self.claim_store, results=[get_volume_from_connection(connection=self.claim_store)], ) self.assert_single_artifacts_store( store=self.host_path_store, results=[ get_volume_from_connection(connection=self.host_path_store) ], ) # Managed versions ctx_volume_name = constants.CONTEXT_VOLUME_ARTIFACTS self.assert_single_init_artifacts_store( store=self.s3_store, results=[ get_connections_context_volume(name=ctx_volume_name), get_volume_from_secret(secret=self.mount_resource1), ], ) self.assert_single_init_artifacts_store( store=self.gcs_store, results=[ get_connections_context_volume(name=ctx_volume_name), get_volume_from_secret(secret=self.mount_resource1), ], ) self.assert_single_init_artifacts_store( store=self.az_store, results=[ get_connections_context_volume(name=ctx_volume_name), get_volume_from_secret(secret=self.mount_resource1), ], ) self.assert_single_init_artifacts_store( store=self.claim_store, results=[ get_connections_context_volume(name=ctx_volume_name), get_volume_from_connection(connection=self.claim_store), ], ) self.assert_single_init_artifacts_store( store=self.host_path_store, results=[ get_connections_context_volume(name=ctx_volume_name), get_volume_from_connection(connection=self.host_path_store), ], )
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_secret_volumes(self): self.assert_secret( secret=self.non_mount_resource1, connection=False, results=[] ) self.assert_secret( secret=self.non_mount_resource2, connection=False, results=[] ) self.assert_secret(secret=self.mount_resource1, connection=False, results=[]) self.assert_secret(secret=self.mount_resource2, connection=False, results=[]) self.assert_secret( secret=self.mount_resource1, connection=True, results=[get_volume_from_secret(secret=self.mount_resource1)], ) self.assert_secret( secret=self.mount_resource2, connection=True, results=[get_volume_from_secret(secret=self.mount_resource2)], )
def test_get_volume_from_secret(self): # No store assert get_volume_from_secret(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_secret(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_secret(resource1) assert volume.name == resource1.name assert volume.secret.secret_name == resource1.name assert volume.secret.items == resource1.schema.items
def test_artifacts_store(self): self.assert_artifacts_store( store=self.s3_store, results=[ get_volume_from_secret(secret=self.mount_resource1), get_artifacts_context_volume(), ], ) self.assert_artifacts_store( store=self.gcs_store, results=[ get_volume_from_secret(secret=self.mount_resource1), get_artifacts_context_volume(), ], ) self.assert_artifacts_store( store=self.az_store, results=[ get_volume_from_secret(secret=self.mount_resource1), get_artifacts_context_volume(), ], ) self.assert_artifacts_store( store=self.claim_store, results=[ get_volume_from_connection(connection=self.claim_store), get_artifacts_context_volume(), ], ) self.assert_artifacts_store( store=self.host_path_store, results=[ get_volume_from_connection(connection=self.host_path_store), get_artifacts_context_volume(), ], )