aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
3 lines (2 loc) • 1.73 kB
JavaScript
var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Tags=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var match_1=()=>{var tmp=require("./match");return match_1=()=>tmp,tmp},matcher_1=()=>{var tmp=require("./matcher");return matcher_1=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},error_1=()=>{var tmp=require("./private/error");return error_1=()=>tmp,tmp};class Tags{static fromStack(stack){try{jsiiDeprecationWarnings().aws_cdk_lib_Stack(stack)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromStack),error}return new Tags(getManifestTags(stack))}constructor(tags){this._tags=tags}hasValues(tags){if(matcher_1().Matcher.isMatcher(tags)&&tags.name==="absent")throw new(error_1()).AssertionError('Match.absent() will never match Tags because "{}" is the default value. Use Tags.hasNone() instead.');const result=(matcher_1().Matcher.isMatcher(tags)?tags:match_1().Match.objectLike(tags)).test(this.all());if(result.hasFailed())throw new(error_1()).AssertionError(`Stack tags did not match as expected:
`+result.renderMismatch())}hasNone(){this.hasValues(match_1().Match.exact({}))}all(){return this._tags}}exports.Tags=Tags,_a=JSII_RTTI_SYMBOL_1,Tags[_a]={fqn:"aws-cdk-lib.assertions.Tags",version:"2.185.0"};function getManifestTags(stack){const root=stack.node.root;if(!core_1().Stage.isStage(root))throw new(error_1()).AssertionError("unexpected: all stacks must be part of a Stage or an App");return root.synth().getStackArtifact(stack.artifactId).tags}
;