Skip to content

Commit

Permalink
added reflection and ability to specify strict ordering for add-ons, r…
Browse files Browse the repository at this point in the history
…esolves #560
  • Loading branch information
shapirov103 committed Jan 11, 2023
1 parent f81917b commit 77df253
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions examples/blueprint-construct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,14 @@ export default class BlueprintConstruct {
amiType: NodegroupAmiType.AL2_X86_64,
instanceTypes: [new ec2.InstanceType('m5.2xlarge')],
diskSize: 25,
desiredSize: 3,
nodeGroupSubnets: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS }
},
{
id: "mng2-customami",
instanceTypes: [new ec2.InstanceType('t3.large')],
nodeGroupCapacityType: CapacityType.SPOT,
desiredSize: 0,
customAmi: {
machineImage: ec2.MachineImage.genericLinux({
'us-east-1': 'ami-08e520f5673ee0894',
Expand Down
4 changes: 3 additions & 1 deletion lib/addons/ack/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// lib/certmanager_addon.ts
import { ManagedPolicy } from 'aws-cdk-lib/aws-iam';
import { Construct } from 'constructs';
import merge from "ts-deepmerge";
import { ClusterInfo, Values } from "../../spi";
import "reflect-metadata";
import { createNamespace, setPath } from "../../utils";
import { HelmAddOn, HelmAddOnProps, HelmAddOnUserProps } from "../helm-addon";
import { AckServiceName, serviceMappings } from './serviceMappings';

export * from "./serviceMappings";

/**
Expand Down Expand Up @@ -50,6 +51,7 @@ const defaultProps: AckAddOnProps = {
/**
* Main class to instantiate the Helm chart
*/
@Reflect.metadata("strictOrder", true)
export class AckAddOn extends HelmAddOn {

readonly options: AckAddOnProps;
Expand Down
6 changes: 5 additions & 1 deletion lib/utils/addon-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Construct } from "constructs";
import * as assert from "assert";
import { Construct } from "constructs";
import "reflect-metadata";
import { ClusterAddOn, ClusterInfo } from '../spi';

/**
Expand All @@ -11,6 +12,9 @@ export function getAddOnNameOrId(addOn: ClusterAddOn): string {
return addOn.id ?? addOn.constructor.name;
}

export function isStrictOrder(addOn: ClusterAddOn) : boolean {
return Reflect.getMetadata("strictOrder", addOn) ?? false;
}
/**
* Decorator function that accepts a list of AddOns and
* ensures addons are scheduled to be added as well as
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"js-yaml": "4.1.0",
"lint": "^1.1.2",
"lodash": "4.17.21",
"reflect-metadata": "^0.1.13",
"semver": "^7.3.8",
"simple-base": "^1.0.0",
"sync-request": "6.1.0",
Expand Down

0 comments on commit 77df253

Please sign in to comment.