Skip to content

Commit

Permalink
Merge branch 'master' into nija-at/apigwv2-authorizer-rejig
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Nov 30, 2021
2 parents 016b37c + 1799f7e commit 238be51
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 5 deletions.
30 changes: 30 additions & 0 deletions packages/@aws-cdk/aws-ec2/lib/instance-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,16 @@ export enum InstanceClass {
*/
G5 = 'g5',

/**
* Graphics-optimized instances powered by AWS Graviton2 Processors and NVIDIA T4G Tensor Core GPUs, 5th generation
*/
GRAPHICS5_GRAVITON2 = 'g5g',

/**
* Graphics-optimized instances powered by AWS Graviton2 Processors and NVIDIA T4G Tensor Core GPUs, 5th generation
*/
G5G = 'g5g',

/**
* Parallel-processing optimized instances, 2nd generation
*/
Expand Down Expand Up @@ -546,6 +556,16 @@ export enum InstanceClass {
*/
M6I = 'm6i',

/**
* Standard instances based on 3rd Gen AMD EPYC processors, 6th generation.
*/
STANDARD6_AMD = 'm6a',

/**
* Standard instances based on 3rd Gen AMD EPYC processors, 6th generation.
*/
M6A = 'm6a',

/**
* Standard instances, 6th generation with Graviton2 processors and local NVME drive
*/
Expand Down Expand Up @@ -585,6 +605,16 @@ export enum InstanceClass {
* Macintosh instances built on Apple Mac mini computers, 1st generation with Intel procesors
*/
MAC1 = 'mac1',

/**
* Multi-stream video transcoding instances for resolutions up to 4K UHD, 1st generation
*/
VIDEO_TRANSCODING1 = 'vt1',

/**
* Multi-stream video transcoding instances for resolutions up to 4K UHD, 1st generation
*/
VT1 = 'vt1',
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ec2/test/instance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('instance', () => {
test('instance architecture is correctly discerned for arm instances', () => {
// GIVEN
const sampleInstanceClasses = [
'a1', 't4g', 'c6g', 'c6gd', 'c6gn', 'm6g', 'm6gd', 'r6g', 'r6gd', // current Graviton-based instance classes
'a1', 't4g', 'c6g', 'c6gd', 'c6gn', 'm6g', 'm6gd', 'r6g', 'r6gd', 'g5g', // current Graviton-based instance classes
'a13', 't11g', 'y10ng', 'z11ngd', // theoretical future Graviton-based instance classes
];

Expand Down
24 changes: 23 additions & 1 deletion tools/@aws-cdk/generate-examples/lib/assemblies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as path from 'path';
import * as spec from '@jsii/spec';
import * as fs from 'fs-extra';
import { TypeScriptSnippet } from 'jsii-rosetta';
import { FIXTURE_NAME } from './generate-missing-examples';

/**
* Replaces the file where the original assembly file *should* be found with a new assembly file.
Expand All @@ -15,6 +16,18 @@ export async function replaceAssembly(assembly: spec.Assembly, directory: string
});
}

export function addFixtureToRosetta(directory: string, fileName: string, fixture: string) {
const rosettaPath = path.join(directory, 'rosetta');
if (!fs.existsSync(rosettaPath)) {
fs.mkdirSync(rosettaPath);
}
const filePath = path.join(rosettaPath, fileName);
if (fs.existsSync(filePath)) {
return;
}
fs.writeFileSync(filePath, fixture);
}

/**
* Replaces the old fingerprint with '***********'.
*
Expand All @@ -35,6 +48,15 @@ export function insertExample(example: TypeScriptSnippet, type: spec.Type): void
if (type.docs) {
type.docs.example = example.visibleSource;
} else {
type.docs = { example: example.visibleSource };
type.docs = {
example: example.visibleSource,
};
}
if (type.docs.custom) {
type.docs.custom.exampleMetadata = `fixture=${FIXTURE_NAME}`;
} else {
type.docs.custom = {
exampleMetadata: `fixture=${FIXTURE_NAME}`,
};
}
}
28 changes: 25 additions & 3 deletions tools/@aws-cdk/generate-examples/lib/generate-missing-examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import { Assembly, ClassType, InterfaceType, TypeSystem } from 'jsii-reflect';

// This import should come from @jsii/spec. Replace when that is possible.
import { LanguageTablet, RosettaTranslator, SnippetLocation, SnippetParameters, TypeScriptSnippet, typeScriptSnippetFromCompleteSource } from 'jsii-rosetta';
import { insertExample, replaceAssembly } from './assemblies';
import { insertExample, replaceAssembly, addFixtureToRosetta } from './assemblies';
import { generateAssignmentStatement } from './generate';

const COMMENT_WARNING = [
'// The code below shows an example of how to instantiate this type.',
'// The values are placeholders you should change.',
];

export const FIXTURE_NAME = '_generated';

export interface GenerateExamplesOptions {
readonly cacheFromTablet?: string;
readonly appendToTablet?: string;
Expand All @@ -31,14 +33,22 @@ export async function generateMissingExamples(assemblyLocations: string[], optio
return { assemblyLocation, assembly: await typesystem.load(assemblyLocation, { validate: false }) };
}));

const snippets = loadedAssemblies.flatMap(({ assembly }) => {
const snippets = loadedAssemblies.flatMap(({ assembly, assemblyLocation }) => {
// Classes and structs
const documentableTypes: Array<ClassType | InterfaceType> = [];
for (const m of [assembly, ...assembly.allSubmodules]) {
documentableTypes.push(...m.classes.filter(c => !c.docs.example));
documentableTypes.push(...m.interfaces.filter(c => !c.docs.example && c.datatype));
}

// add fixture to assembly's rosetta folder if it doesn't exist yet
const fixture = generateFixture(assembly);
addFixtureToRosetta(
assemblyLocation,
`${FIXTURE_NAME}.ts-fixture`,
fixture,
);

console.log(`${assembly.name}: ${documentableTypes.length} classes to document`);
if (documentableTypes.length === 0) { return []; }

Expand Down Expand Up @@ -73,6 +83,7 @@ export async function generateMissingExamples(assemblyLocations: string[], optio
true,
{
[SnippetParameters.$COMPILATION_DIRECTORY]: options.directory ?? process.cwd(),
[SnippetParameters.$PROJECT_DIRECTORY]: assemblyLocation,
});

insertExample(tsSnippet, classType.spec);
Expand Down Expand Up @@ -153,4 +164,15 @@ function correctConstructImport(assembly: Assembly) {
}

return 'import { Construct } from "constructs";';
}
}

function generateFixture(assembly: Assembly): string {
return [
correctConstructImport(assembly),
'class MyConstruct extends Construct {',
'constructor(scope: Construct, id: string) {',
'super(scope, id);',
'/// here',
'} }',
].join('\n').trimLeft();
}

0 comments on commit 238be51

Please sign in to comment.