import Artifact from 'pipeline-transfer/functions/transfer/transfer/artifact/artifact.js'
Artifact
This class handles retrieving CodePipeline artifact files as well as accessing file contents in addition to attributes defined inside JSON files residing within the artifact.
As the artifacts passed to the function may reside within remote buckets which this function does not have sufficient permissions to access, credentials are used from the initial CodePipeline event object.
Static Method Summary
Static Public Methods | ||
public static |
toArtifact(artifact: *, credentials: {}): Artifact Transform the properties received from CodePipeline into a new instance of this class. |
|
public static |
toArtifactMapEntry(artifact: *, credentials: *): Array[String, Artifact] Returns an array which can be used to constuct a Map of artifacts. |
Constructor Summary
Public Constructor | ||
public |
constructor(s3Location: Object) Constructs a new Artifact instance. |
Member Summary
Public Members | ||
public |
The AWS Access Key ID which will be used to retrieve the remote artifact. |
|
public |
The name of the S3 bucket which the remote artifact file resides in. |
|
public get |
client: S3 Returns a new S3 client with credentials pre-configured. |
|
public |
A fully resolved path to the directory storing the decompressed contents
of the remote artifact in the |
|
public |
A filename representing the name of the artifact once downloaded and stored locally. |
|
public |
A fully resolved Path to the local artifact when downloaded and written
to the |
|
public |
A local ID for this artifact. |
|
public |
Determines if this artifact has been retrieved, decompressed and written to local file storage. |
|
public |
The key for the remote artifact file. |
|
public |
The AWS Secret Access Key which will be used to retrieve the remote artifact. |
|
public |
The AWS Session Token which will be used to retrieve the remote artifact. |
Method Summary
Public Methods | ||
public |
attribute(filename: *, key: *): * Once Artifact#ready has resolved successfully, this function can be used to retrieve the value of a specific property key from within a JSON file residing inside the decompressed artifact. |
|
public |
get(filename: *): Buffer Once Artifact#ready has resolved successfully, this function can be used to retrieve a specific file's contents from within the decompressed artifact. |
|
public |
Returns an array of File instances which represent all matched files from inside the retrieved, decompressed artifact. |
|
public |
A utility function to ensure that this artifact has first retrived and decompressed the remote artifact file, before any attempts are made to retrieve artifact contents. |
Private Methods | ||
private |
async fetch(): Buffer |
|
private |
|
|
private |
|
Static Public Methods
public static toArtifact(artifact: *, credentials: {}): Artifact source
Transform the properties received from CodePipeline into a new instance of this class.
This function maps the required properties from the CodePipeline invocation event structure.
Params:
Name | Type | Attribute | Description |
artifact | * | ||
credentials | {} |
|
public static toArtifactMapEntry(artifact: *, credentials: *): Array[String, Artifact] source
Returns an array which can be used to constuct a Map of artifacts.
Params:
Name | Type | Attribute | Description |
artifact | * | ||
credentials | * |
Return:
Array[String, Artifact] |
Public Constructors
Public Members
public accessKeyId: String source
The AWS Access Key ID which will be used to retrieve the remote artifact.
public bucketName: String source
The name of the S3 bucket which the remote artifact file resides in.
public dir: String source
A fully resolved path to the directory storing the decompressed contents
of the remote artifact in the /tmp
directory.
public filename: String source
A filename representing the name of the artifact once downloaded and stored locally.
public filepath: String source
A fully resolved Path to the local artifact when downloaded and written
to the /tmp/
directory.
public isReady: Boolean source
Determines if this artifact has been retrieved, decompressed and written to local file storage.
Public Methods
public attribute(filename: *, key: *): * source
Once Artifact#ready has resolved successfully, this function can be used to retrieve the value of a specific property key from within a JSON file residing inside the decompressed artifact.
Params:
Name | Type | Attribute | Description |
filename | * | ||
key | * |
Return:
* | [String] the value of the key from within a JSON file. |
public get(filename: *): Buffer source
Once Artifact#ready has resolved successfully, this function can be used to retrieve a specific file's contents from within the decompressed artifact.
Params:
Name | Type | Attribute | Description |
filename | * |
Return:
Buffer | a utf-8 buffer of the file's contents. |
public async match(select: String, path: String): Array[File] source
Returns an array of File instances which represent all matched files from inside the retrieved, decompressed artifact.
public async ready(): Boolean source
A utility function to ensure that this artifact has first retrived and decompressed the remote artifact file, before any attempts are made to retrieve artifact contents.
Private Methods
private async fetch(): Buffer source
Return:
Buffer | the buffer contents of the remote artifacts retrieved from S3. |