AssetStaging
Stages a file or directory from a location on the file system into a staging directory.
This is controlled by the context key 'aliyun:ros:disable-asset-staging' and enabled by the CLI by default in order to ensure that when the CDK app exists, all assets are available for deployment. Otherwise, if an app references assets in temporary locations, those will not be available when it exists.
The stagedPath
property is a stringified token that represents the location
of the file or directory after staging. It will be resolved only during the
"prepare" stage and may be either the original path or the staged path
depending on the context setting.
The file/directory are staged based on their content hash (fingerprint). This means that only if content was changed, copy will happen.
Initializers
using AlibabaCloud.SDK.ROS.CDK.Core;
new AssetStaging(Construct Scope, string Id, AssetStagingProps Props);
Name | Type | Description |
---|---|---|
Scope |
Construct |
No description. |
Id |
string |
No description. |
Props |
AssetStagingProps |
No description. |
Scope
Required
- Type: Construct
Id
Required
- Type: string
Props
Required
- Type: AssetStagingProps
Methods
Name | Description |
---|---|
ToString |
Returns a string representation of this construct. |
Synthesize |
Allows this construct to emit artifacts into the cloud assembly during synthesis. |
RelativeStagedPath |
Return the path to the staged asset, relative to the Cloud Assembly (manifest) directory of the given stack. |
ToString
private string ToString()
Returns a string representation of this construct.
Synthesize
private void Synthesize(ISynthesisSession Session)
Allows this construct to emit artifacts into the cloud assembly during synthesis.
This method is usually implemented by framework-level constructs such as Stack
and Asset
as they participate in synthesizing the cloud assembly.
- Type: ISynthesisSession
The synthesis session.
RelativeStagedPath
private string RelativeStagedPath(Stack Stack)
Return the path to the staged asset, relative to the Cloud Assembly (manifest) directory of the given stack.
Only returns a relative path if the asset was staged, returns an absolute path if it was not staged.
A bundled asset might end up in the outDir and still not count as "staged"; if asset staging is disabled we're technically expected to reference source directories, but we don't have a source directory for the bundled outputs (as the bundle output is written to a temporary directory). Nevertheless, we will still return an absolute path.
A non-obvious directory layout may look like this:
CLOUD ASSEMBLY ROOT
+-- asset.12345abcdef/
+-- assembly-Stage
+-- MyStack.template.json
+-- MyStack.assets.json <- will contain { "path": "../asset.12345abcdef" }
- Type: Stack
Static Functions
Name | Description |
---|---|
IsConstruct |
Return whether the given object is a Construct. |
ClearAssetHashCache |
Clears the asset hash cache. |
IsConstruct
using AlibabaCloud.SDK.ROS.CDK.Core;
AssetStaging.IsConstruct(object X);
Return whether the given object is a Construct.
- Type: object
ClearAssetHashCache
using AlibabaCloud.SDK.ROS.CDK.Core;
AssetStaging.ClearAssetHashCache();
Clears the asset hash cache.
Properties
Name | Type | Description |
---|---|---|
Node |
ConstructNode |
The construct tree node associated with this construct. |
AbsoluteStagedPath |
string |
Absolute path to the asset data. |
AssetHash |
string |
A cryptographic hash of the asset. |
IsArchive |
bool |
Whether this asset is an archive (zip or jar). |
Packaging |
FileAssetPackaging |
How this asset should be packaged. |
SourcePath |
string |
The absolute path of the asset as it was referenced by the user. |
Node
Required
public ConstructNode Node { get; }
- Type: ConstructNode
The construct tree node associated with this construct.
AbsoluteStagedPath
Required
public string AbsoluteStagedPath { get; }
- Type: string
Absolute path to the asset data.
If asset staging is disabled, this will just be the source path or a temporary directory used for bundling.
If asset staging is enabled it will be the staged path.
IMPORTANT: If you are going to call addFileAsset()
, use
relativeStagedPath()
instead.
AssetHash
Required
public string AssetHash { get; }
- Type: string
A cryptographic hash of the asset.
IsArchive
Required
public bool IsArchive { get; }
- Type: bool
Whether this asset is an archive (zip or jar).
Packaging
Required
public FileAssetPackaging Packaging { get; }
- Type: FileAssetPackaging
How this asset should be packaged.
SourcePath
Required
public string SourcePath { get; }
- Type: string
The absolute path of the asset as it was referenced by the user.
Constants
Name | Type | Description |
---|---|---|
BundlingInputDir |
string |
The directory inside the bundling container into which the asset sources will be mounted. |
BundlingOutputDir |
string |
The directory inside the bundling container into which the bundled output should be written. |
BundlingInputDir
Required
public string BundlingInputDir { get; }
- Type: string
The directory inside the bundling container into which the asset sources will be mounted.
BundlingOutputDir
Required
public string BundlingOutputDir { get; }
- Type: string
The directory inside the bundling container into which the bundled output should be written.