Skip to content
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

revert: revert "chore: add new interfaces for Assets (#12700)" #12832

Merged
merged 2 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/@aws-cdk/assets/lib/fs/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export interface CopyOptions {
* A strategy for how to handle symlinks.
*
* @default Never
* @deprecated use `followSymlinks` instead
*/
readonly follow?: FollowMode;

Expand Down
19 changes: 3 additions & 16 deletions packages/@aws-cdk/aws-ecr-assets/lib/image-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ 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, AssetStaging, Construct as CoreConstruct, FeatureFlags, FileFingerprintOptions, IgnoreMode, Stack, SymlinkFollowMode, Token,
} from '@aws-cdk/core';
import { Annotations, Construct as CoreConstruct, FeatureFlags, IgnoreMode, Stack, 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, FileFingerprintOptions {
export interface DockerImageAssetOptions extends assets.FingerprintOptions {
/**
* ECR repository name
*
Expand Down Expand Up @@ -139,9 +137,8 @@ export class DockerImageAsset extends CoreConstruct implements assets.IAsset {
// deletion of the ECR repository the app used).
extraHash.version = '1.21.0';

const staging = new AssetStaging(this, 'Staging', {
const staging = new assets.Staging(this, 'Staging', {
...props,
follow: props.followSymlinks ?? toSymlinkFollow(props.follow),
exclude,
ignoreMode,
sourcePath: dir,
Expand Down Expand Up @@ -184,13 +181,3 @@ 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;
}
}
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-s3-assets/lib/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Construct as CoreConstruct } from '@aws-cdk/core';

const ARCHIVE_EXTENSIONS = ['.zip', '.jar'];

export interface AssetOptions extends assets.CopyOptions, cdk.FileCopyOptions, cdk.AssetOptions {
export interface AssetOptions extends assets.CopyOptions, cdk.AssetOptions {
/**
* A list of principals that should be able to read this asset from S3.
* You can use `asset.grantRead(principal)` to grant read permissions later.
Expand Down Expand Up @@ -128,7 +128,7 @@ export class Asset extends CoreConstruct implements cdk.IAsset {
const staging = new cdk.AssetStaging(this, 'Stage', {
...props,
sourcePath: path.resolve(props.path),
follow: props.followSymlinks ?? toSymlinkFollow(props.follow),
follow: toSymlinkFollow(props.follow),
assetHash: props.assetHash ?? props.sourceHash,
});

Expand Down
51 changes: 14 additions & 37 deletions packages/@aws-cdk/core/lib/fs/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,19 @@ 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.
*
Expand All @@ -75,30 +85,9 @@ interface FileOptions {
}

/**
* Options applied when copying directories
*/
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.
* Options related to calculating source hash.
*/
export interface FileCopyOptions extends FileOptions {
/**
* A strategy for how to handle symlinks.
*
* @default SymlinkFollowMode.NEVER
*/
readonly followSymlinks?: SymlinkFollowMode;
}

interface ExtraHashOptions {
export interface FingerprintOptions extends CopyOptions {
/**
* Extra information to encode into the fingerprint (e.g. build instructions
* and other inputs)
Expand All @@ -107,15 +96,3 @@ interface ExtraHashOptions {
*/
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 {
}