Skip to content

Commit 4bf6b5c

Browse files
author
Tarun Belani
committed
Remove common class for document data for dockerfile and component data
1 parent 09c3d98 commit 4bf6b5c

File tree

3 files changed

+36
-52
lines changed

3 files changed

+36
-52
lines changed

packages/@aws-cdk/aws-imagebuilder-alpha/lib/component.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as s3 from 'aws-cdk-lib/aws-s3';
66
import * as s3assets from 'aws-cdk-lib/aws-s3-assets';
77
import { propertyInjectable } from 'aws-cdk-lib/core/lib/prop-injectable';
88
import { Construct } from 'constructs';
9-
import { ImageBuilderData } from './imagebuilder-data';
9+
import * as yaml from 'yaml';
1010
import { OSVersion, Platform } from './os-version';
1111

1212
const COMPONENT_SYMBOL = Symbol.for('@aws-cdk/aws-imagebuilder-alpha.Component');
@@ -640,7 +640,7 @@ export enum ComponentSchemaVersion {
640640
/**
641641
* Helper class for referencing and uploading component data
642642
*/
643-
export abstract class ComponentData extends ImageBuilderData {
643+
export abstract class ComponentData {
644644
/**
645645
* Uploads component data from a local file to S3 to use as the component data
646646
*
@@ -655,7 +655,7 @@ export abstract class ComponentData extends ImageBuilderData {
655655
path: string,
656656
options: s3assets.AssetOptions = {},
657657
): S3ComponentData {
658-
const asset = this.createAsset(scope, id, path, options);
658+
const asset = new s3assets.Asset(scope, id, { ...options, path });
659659
return new S3ComponentDataFromAsset(asset);
660660
}
661661

@@ -675,7 +675,7 @@ export abstract class ComponentData extends ImageBuilderData {
675675
* @param data An inline JSON object representing the component data
676676
*/
677677
public static fromJsonObject(data: { [key: string]: any }): ComponentData {
678-
const inlineData = this.createInlineYaml(data);
678+
const inlineData = yaml.stringify(data, { indent: 2 });
679679
return new InlineComponentData(inlineData);
680680
}
681681

@@ -721,6 +721,20 @@ export abstract class ComponentData extends ImageBuilderData {
721721
public static fromInline(data: string): ComponentData {
722722
return new InlineComponentData(data);
723723
}
724+
725+
/**
726+
* Indicates that the provided component data is an S3 reference
727+
*/
728+
abstract readonly isS3Reference: boolean;
729+
730+
/**
731+
* The resulting inline string or S3 URL which references the component data
732+
*/
733+
public readonly value: string;
734+
735+
protected constructor(value: string) {
736+
this.value = value;
737+
}
724738
}
725739

726740
/**
@@ -742,7 +756,7 @@ export abstract class S3ComponentData extends ComponentData {
742756
/**
743757
* Grant put permissions to the given grantee for the component data in S3
744758
*
745-
* @param grantee - The principal
759+
* @param grantee The principal
746760
*/
747761
public grantPut(grantee: iam.IGrantable): iam.Grant {
748762
return this.bucket.grantPut(grantee, this.key);
@@ -751,7 +765,7 @@ export abstract class S3ComponentData extends ComponentData {
751765
/**
752766
* Grant read permissions to the given grantee for the component data in S3
753767
*
754-
* @param grantee - The principal
768+
* @param grantee The principal
755769
*/
756770
public grantRead(grantee: iam.IGrantable): iam.Grant {
757771
return this.bucket.grantRead(grantee, this.key);

packages/@aws-cdk/aws-imagebuilder-alpha/lib/container-recipe.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import * as s3assets from 'aws-cdk-lib/aws-s3-assets';
99
import { propertyInjectable } from 'aws-cdk-lib/core/lib/prop-injectable';
1010
import { Construct } from 'constructs';
1111
import { BaseContainerImage, ContainerInstanceImage } from './base-image';
12-
import { ImageBuilderData } from './imagebuilder-data';
1312
import { OSVersion } from './os-version';
1413
import { ComponentConfiguration, IRecipeBase } from './recipe-base';
1514

@@ -180,7 +179,7 @@ export abstract class Repository {
180179
/**
181180
* Helper class for referencing and uploading dockerfile data for the container recipe
182181
*/
183-
export abstract class DockerfileData extends ImageBuilderData {
182+
export abstract class DockerfileData {
184183
/**
185184
* Uploads dockerfile data from a local file to S3 to use as the dockerfile data
186185
*
@@ -195,7 +194,7 @@ export abstract class DockerfileData extends ImageBuilderData {
195194
path: string,
196195
options: s3assets.AssetOptions = {},
197196
): S3DockerfileData {
198-
const asset = this.createAsset(scope, id, path, options);
197+
const asset = new s3assets.Asset(scope, id, { ...options, path });
199198
return new S3DockerfileDataFromAsset(asset);
200199
}
201200

@@ -217,6 +216,20 @@ export abstract class DockerfileData extends ImageBuilderData {
217216
public static fromInline(data: string): DockerfileData {
218217
return new InlineDockerfileData(data);
219218
}
219+
220+
/**
221+
* Indicates that the provided component data is an S3 reference
222+
*/
223+
abstract readonly isS3Reference: boolean;
224+
225+
/**
226+
* The resulting inline string or S3 URL which references the component data
227+
*/
228+
public readonly value: string;
229+
230+
protected constructor(value: string) {
231+
this.value = value;
232+
}
220233
}
221234

222235
/**

packages/@aws-cdk/aws-imagebuilder-alpha/lib/imagebuilder-data.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)