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

chore: publishInParallel=false with tokens produces useless error m… #16196

Merged
merged 2 commits into from
Aug 24, 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
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,15 @@ export class CodeBuildFactory implements ICodePipelineActionFactory {
// Write to disk and replace with a reference
const relativeSpecFile = `buildspec-${Node.of(scope).addr}-${this.constructId}.yaml`;
const absSpecFile = path.join(cloudAssemblyBuildSpecDir(scope), relativeSpecFile);
fs.writeFileSync(absSpecFile, Stack.of(scope).resolve(actualBuildSpec.toBuildSpec()), { encoding: 'utf-8' });

// This should resolve to a pure JSON string. If it resolves to an object, it's a CFN
// expression, and we can't support that yet. Maybe someday if we think really hard about it.
const fileContents = Stack.of(scope).resolve(actualBuildSpec.toBuildSpec());

if (typeof fileContents !== 'string') {
throw new Error(`This BuildSpec contains CloudFormation references and is supported by publishInParallel=false: ${JSON.stringify(fileContents, undefined, 2)}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a typo here. It should say it's not supported, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

}
fs.writeFileSync(absSpecFile, fileContents, { encoding: 'utf-8' });
projectBuildSpec = codebuild.BuildSpec.fromSourceFilename(relativeSpecFile);
} else {
projectBuildSpec = actualBuildSpec;
Expand Down
24 changes: 22 additions & 2 deletions packages/@aws-cdk/pipelines/test/docker-credentials.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import * as iam from '@aws-cdk/aws-iam';
import * as secretsmanager from '@aws-cdk/aws-secretsmanager';
import * as cdk from '@aws-cdk/core';
import * as cdkp from '../lib';
import { ShellStep } from '../lib';
import { DockerAssetApp, TestApp } from './testhelpers';

let app: cdk.App;
let stack: cdk.Stack;

beforeEach(() => {
app = new cdk.App();
app = new TestApp();
stack = new cdk.Stack(app, 'Stack', {
env: { account: '0123456789012', region: 'eu-west-1' },
});
Expand Down Expand Up @@ -299,9 +301,27 @@ describe('EcrDockerCredential', () => {

expect(stack).not.toHaveResource('AWS::IAM::Policy');
});

});

// This test doesn't actually work yet. See https://github.com/aws/aws-cdk/issues/16164
// eslint-disable-next-line jest/no-disabled-tests
test.skip('with non-parallel publishing', () => {
const pipelines = new cdkp.CodePipeline(stack, 'Pipeline', {
synth: new ShellStep('Build', {
input: cdkp.CodePipelineSource.gitHub('test/test', 'test'),
commands: ['cdk synth'],
}),

publishAssetsInParallel: false,
dockerCredentials: [
cdkp.DockerCredential.ecr([repo]),
],
});
pipelines.addStage(new DockerAssetApp(stack, 'AssetApp'));

// Should not throw
app.synth();
});
});

describe('dockerCredentialsInstallCommands', () => {
Expand Down