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(cfnspec): support us-west-2 only services #23928

Merged
merged 2 commits into from
Jan 31, 2023
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
9 changes: 9 additions & 0 deletions packages/@aws-cdk/cfnspec/build-tools/spec-diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ async function main() {
const newSpec = await fs.readJSON(newSpecFile);
const oldSpec = await fs.readJSON(oldSpecFile);

// Diff operates on PropertyTypes & ResourceTypes
// Ensure they always exist in the old spec
if (!oldSpec.PropertyTypes) {
oldSpec.PropertyTypes = {};
}
if (!oldSpec.ResourceTypes) {
oldSpec.ResourceTypes = {};
}

const out = jsonDiff(oldSpec, newSpec);

// Here's the magic output format of this thing
Expand Down
19 changes: 15 additions & 4 deletions packages/@aws-cdk/cfnspec/build-tools/split-spec-by-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ import { writeSorted } from './patch-set';
import { CfnSpec, CfnSpecValidator, formatErrorInContext } from './validate-cfn';

async function main(args: string[]) {
if (args.length < 2) {
throw new Error('Usage: split-spec-by-service <SPECFILE> <DIRECTORY>');
if (args.length < 3) {
throw new Error('Usage: split-spec-by-service <SPECFILE> <DIRECTORY> [<SERVICES>]');
}

const [specFile, outDir] = args;
const [specFile, outDir, services] = args;
const allowedServices = services.trim().split(' ').filter(Boolean);

log(`Loading specification: ${specFile}`);
const spec: CfnSpec = await fs.readJson(specFile);

Expand All @@ -39,8 +41,17 @@ async function main(args: string[]) {
}

// Write out
log('Writing');
if (allowedServices.length > 0) {
log(`Writing: ${allowedServices.join(' ')}`);
} else {
log('Writing all services');
}
for (const [svcName, svcSpec] of Object.entries(byService)) {
// Skip services that are not explicitly allowed
if (allowedServices.length > 0 && !allowedServices.includes(svcName)) {
continue;
}

const successTarget = path.join(outDir, `000_${svcName}.json`);
const rejectedTarget = path.join(outDir, `.000_${svcName}.rejected.json`);

Expand Down
11 changes: 10 additions & 1 deletion packages/@aws-cdk/cfnspec/build-tools/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function update-spec() {
local targetdir=$3
local gunzip=$4
local split=$5
local services=${@:6}

local tmpdir="$(mktemp -d)"
local newspec="${tmpdir}/new_proposed.json"
Expand All @@ -42,10 +43,11 @@ function update-spec() {

# Calculate the old and new combined specs, so we can do a diff on the changes
echo >&2 "Updating source spec..."
mkdir -p ${targetdir}

node build-tools/patch-set.js --quiet "${targetdir}" "${oldcombined}"
if ${split}; then
node build-tools/split-spec-by-service.js "${newspec}" "${targetdir}"
node build-tools/split-spec-by-service.js "${newspec}" "${targetdir}" "${services}"
else
cp "${newspec}" "${targetdir}/spec.json"
sort-json "${targetdir}/spec.json"
Expand All @@ -66,6 +68,12 @@ update-spec \
spec-source/specification/000_cfn/000_official \
true true

update-spec \
"CloudFormation Resource Specification (us-west-2)" \
"${2:-https://d201a2mn26r7lk.cloudfront.net/latest/gzip/CloudFormationResourceSpecification.json}" \
spec-source/specification/001_cfn_us-west-2/000_official \
true true AWS_DeviceFarm

old_version=$(cat cfn.version)
new_version=$(node -p "require('${scriptdir}/../spec-source/specification/000_cfn/000_official/001_Version.json').ResourceSpecificationVersion")
echo >&2 "Recording new version..."
Expand All @@ -76,6 +84,7 @@ echo "$new_version" > cfn.version
if [[ "$new_version" != "$old_version" ]]; then
echo >&2 "Reporting outdated specs..."
node build-tools/report-issues spec-source/specification/000_cfn/000_official/ outdated >> CHANGELOG.md.new
node build-tools/report-issues spec-source/specification/001_cfn_us-west-2/000_official/ outdated >> CHANGELOG.md.new
fi

update-spec \
Expand Down