Skip to content

Commit a2fd076

Browse files
authored
Merge branch 'main' into peterwoodworth/ssltest
2 parents 7d365a3 + 1a8c9f9 commit a2fd076

6 files changed

Lines changed: 70 additions & 5 deletions

File tree

.github/workflows/close-stale-prs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ on:
22
schedule:
33
# Cron format: min hr day month dow
44
- cron: "0 0 * * *"
5+
workflow_dispatch:
56
jobs:
67
close-stale-prs:
78
permissions:
@@ -11,7 +12,10 @@ jobs:
1112
- uses: rix0rrr/close-stale-prs@main
1213
with:
1314
# Required
14-
github-token: ${{ secrets.GITHUB_TOKEN }}
15+
# Must be PROJEN_GITHUB_TOKEN because the default GHA GitHub token will not have permissions to
16+
# know whether a user is a MEMBER of the organization or not, so we would not be able to filter PR reviews
17+
# appropriately.
18+
github-token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
1519
stale-days: 21
1620
response-days: 7
1721

packages/@aws-cdk/aws-ecr/lib/repository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ export class Repository extends RepositoryBase {
561561
this.policyDocument = new iam.PolicyDocument();
562562
}
563563
this.policyDocument.addStatements(statement);
564-
return { statementAdded: false, policyDependable: this.policyDocument };
564+
return { statementAdded: true, policyDependable: this.policyDocument };
565565
}
566566

567567
/**

packages/@aws-cdk/aws-ecr/test/repository.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,5 +701,43 @@ describe('repository', () => {
701701
repositoryName: 'a//a-a',
702702
})).toThrow(/must follow the specified pattern/);
703703
});
704+
705+
test('return value addToResourcePolicy', () => {
706+
// GIVEN
707+
const stack = new cdk.Stack();
708+
const policyStmt1 = new iam.PolicyStatement({
709+
actions: ['*'],
710+
principals: [new iam.AnyPrincipal()],
711+
});
712+
const policyStmt2 = new iam.PolicyStatement({
713+
effect: iam.Effect.DENY,
714+
actions: ['ecr:BatchGetImage', 'ecr:GetDownloadUrlForLayer'],
715+
principals: [new iam.AnyPrincipal()],
716+
});
717+
const policyText1 = '{"Statement": [{"Action": "*", "Effect": "Allow", "Principal": {"AWS": "*"}}], "Version": "2012-10-17"}';
718+
const policyText2 = `{"Statement": [
719+
{"Action": "*", "Effect": "Allow", "Principal": {"AWS": "*"}},
720+
{"Action": ["ecr:BatchGetImage", "ecr:GetDownloadUrlForLayer"], "Effect": "Deny", "Principal": {"AWS": "*"}}
721+
], "Version": "2012-10-17"}`;
722+
723+
// WHEN
724+
const artifact1 = new ecr.Repository(stack, 'Repo1').addToResourcePolicy(policyStmt1);
725+
const repo = new ecr.Repository(stack, 'Repo2');
726+
repo.addToResourcePolicy(policyStmt1);
727+
const artifact2 =repo.addToResourcePolicy(policyStmt2);
728+
729+
// THEN
730+
expect(stack.resolve(artifact1.statementAdded)).toEqual(true);
731+
expect(stack.resolve(artifact1.policyDependable)).toEqual(JSON.parse(policyText1));
732+
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {
733+
RepositoryPolicyText: JSON.parse(policyText1),
734+
});
735+
736+
expect(stack.resolve(artifact2.statementAdded)).toEqual(true);
737+
expect(stack.resolve(artifact2.policyDependable)).toEqual(JSON.parse(policyText2));
738+
Template.fromStack(stack).hasResourceProperties('AWS::ECR::Repository', {
739+
RepositoryPolicyText: JSON.parse(policyText2),
740+
});
741+
});
704742
});
705743
});

tools/@aws-cdk/cdk-build-tools/lib/lint.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as path from 'path';
22
import * as process from 'process';
33
import * as fs from 'fs-extra';
4-
import { shell } from './os';
4+
import { shell, escape } from './os';
55
import { CDKBuildOptions, CompilerOverrides } from './package-info';
66

77
export async function lintCurrentPackage(options: CDKBuildOptions, compilers: CompilerOverrides & { fix?: boolean } = {}): Promise<void> {
@@ -27,7 +27,7 @@ export async function lintCurrentPackage(options: CDKBuildOptions, compilers: Co
2727

2828
if (await fs.pathExists('README.md')) {
2929
await shell([
30-
process.execPath,
30+
escape(process.execPath),
3131
...process.execArgv,
3232
'--',
3333
require.resolve('markdownlint-cli'),

tools/@aws-cdk/cdk-build-tools/lib/os.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ export async function shell(command: string[], options: ShellOptions = {}): Prom
5656
});
5757
}
5858

59+
/**
60+
* Escape a shell argument for the current shell
61+
*/
62+
export function escape(x: string) {
63+
if (process.platform === 'win32') {
64+
return windowsEscape(x);
65+
}
66+
return posixEscape(x);
67+
}
68+
5969
/**
6070
* Render the given command line as a string
6171
*

tools/@aws-cdk/pkglint/test/libary-creation.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,21 @@ describe('createModuleDefinitionFromCfnNamespace', () => {
5959
});
6060

6161
describe('createLibraryReadme', () => {
62+
let tempDir: string | undefined;
63+
64+
beforeEach(() => {
65+
tempDir = undefined;
66+
});
67+
68+
afterEach(async () => {
69+
if (tempDir) {
70+
await fs.emptyDir(tempDir);
71+
await fs.rmdir(tempDir);
72+
}
73+
});
74+
6275
test('library name is valid', async () => {
63-
const tempDir = fs.mkdtempSync(path.join(__dirname, 'temp'));
76+
tempDir = fs.mkdtempSync(path.join(__dirname, 'temp'));
6477
const readmePath = path.join(tempDir, 'README.md');
6578
await createLibraryReadme('Alexa::ASK', readmePath);
6679

0 commit comments

Comments
 (0)