-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: add new interfaces for Assets #12700
Changes from 3 commits
8b4c9b6
eaf0f9f
d4710fc
11b7c13
35fef7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,16 @@ import * as fs from 'fs'; | |
import * as path from 'path'; | ||
import * as assets from '@aws-cdk/assets'; | ||
import * as ecr from '@aws-cdk/aws-ecr'; | ||
import { Annotations, Construct as CoreConstruct, FeatureFlags, IgnoreMode, Stack, Token } from '@aws-cdk/core'; | ||
import { | ||
Annotations, AssetStaging, Construct as CoreConstruct, FeatureFlags, FileFingerprintOptions, IgnoreMode, Stack, SymlinkFollowMode, Token, | ||
} from '@aws-cdk/core'; | ||
import * as cxapi from '@aws-cdk/cx-api'; | ||
import { Construct } from 'constructs'; | ||
|
||
/** | ||
* Options for DockerImageAsset | ||
*/ | ||
export interface DockerImageAssetOptions extends assets.FingerprintOptions { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume changes to this file are not related to your PR description, yes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what you're asking, sorry. They are very much related (in fact, the description explicitly calls out |
||
export interface DockerImageAssetOptions extends assets.FingerprintOptions, FileFingerprintOptions { | ||
/** | ||
* ECR repository name | ||
* | ||
|
@@ -137,8 +139,9 @@ export class DockerImageAsset extends CoreConstruct implements assets.IAsset { | |
// deletion of the ECR repository the app used). | ||
extraHash.version = '1.21.0'; | ||
|
||
const staging = new assets.Staging(this, 'Staging', { | ||
const staging = new AssetStaging(this, 'Staging', { | ||
...props, | ||
follow: props.followSymlinks ?? toSymlinkFollow(props.follow), | ||
exclude, | ||
ignoreMode, | ||
sourcePath: dir, | ||
|
@@ -181,3 +184,13 @@ function validateBuildArgs(buildArgs?: { [key: string]: string }) { | |
} | ||
} | ||
} | ||
|
||
function toSymlinkFollow(follow?: assets.FollowMode): SymlinkFollowMode | undefined { | ||
switch (follow) { | ||
case undefined: return undefined; | ||
case assets.FollowMode.NEVER: return SymlinkFollowMode.NEVER; | ||
case assets.FollowMode.ALWAYS: return SymlinkFollowMode.ALWAYS; | ||
case assets.FollowMode.BLOCK_EXTERNAL: return SymlinkFollowMode.BLOCK_EXTERNAL; | ||
case assets.FollowMode.EXTERNAL: return SymlinkFollowMode.EXTERNAL; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,19 +56,9 @@ export enum IgnoreMode { | |
* context flag is set. | ||
*/ | ||
DOCKER = 'docker' | ||
}; | ||
|
||
/** | ||
* Obtains applied when copying directories into the staging location. | ||
*/ | ||
export interface CopyOptions { | ||
/** | ||
* A strategy for how to handle symlinks. | ||
* | ||
* @default SymlinkFollowMode.NEVER | ||
*/ | ||
readonly follow?: SymlinkFollowMode; | ||
} | ||
|
||
interface FileOptions { | ||
/** | ||
* Glob patterns to exclude from the copy. | ||
* | ||
|
@@ -85,9 +75,30 @@ export interface CopyOptions { | |
} | ||
|
||
/** | ||
* Options related to calculating source hash. | ||
* Obtains applied when copying directories into the staging location. | ||
skinny85 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
export interface CopyOptions extends FileOptions { | ||
/** | ||
* A strategy for how to handle symlinks. | ||
* | ||
* @default SymlinkFollowMode.NEVER | ||
*/ | ||
readonly follow?: SymlinkFollowMode; | ||
} | ||
|
||
/** | ||
* Options applied when copying directories into the staging location. | ||
*/ | ||
export interface FingerprintOptions extends CopyOptions { | ||
export interface FileCopyOptions extends FileOptions { | ||
Comment on lines
+80
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need both of these or can we deprecate the former? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, sorry, I don't understand what you're asking here (deprecate which interface?). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't have to be sorry. It's ok. I was asking about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, we can deprecate Let me know if you want to make this part of this PR, or tackle it separately after this is merged. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you get @eladb's eyes on this? He owns and has built this area and it'd best for him to take a look at this PR and assess this change. I'll defer to him on what the right thing here is. |
||
/** | ||
* A strategy for how to handle symlinks. | ||
* | ||
* @default SymlinkFollowMode.NEVER | ||
*/ | ||
readonly followSymlinks?: SymlinkFollowMode; | ||
} | ||
|
||
interface ExtraHashOptions { | ||
/** | ||
* Extra information to encode into the fingerprint (e.g. build instructions | ||
* and other inputs) | ||
|
@@ -96,3 +107,15 @@ export interface FingerprintOptions extends CopyOptions { | |
*/ | ||
readonly extraHash?: string; | ||
} | ||
|
||
/** | ||
* Options related to calculating source hash. | ||
*/ | ||
export interface FingerprintOptions extends CopyOptions, ExtraHashOptions { | ||
} | ||
|
||
/** | ||
* Options related to calculating source hash. | ||
*/ | ||
export interface FileFingerprintOptions extends FileCopyOptions, ExtraHashOptions { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is
followSymlinks
defined?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's defined in
FileCopyOptions
in@aws-cdk/core
.