"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.KubernetesManifest=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var constructs_1=()=>{var tmp=require("constructs");return constructs_1=()=>tmp,tmp},alb_controller_1=()=>{var tmp=require("./alb-controller");return alb_controller_1=()=>tmp,tmp},kubectl_provider_1=()=>{var tmp=require("./kubectl-provider");return kubectl_provider_1=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp};const PRUNE_LABEL_PREFIX="aws.cdk.eks/prune-";class KubernetesManifest extends constructs_1().Construct{constructor(scope,id,props){super(scope,id);try{jsiiDeprecationWarnings().aws_cdk_lib_aws_eks_KubernetesManifestProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,KubernetesManifest),error}const stack=core_1().Stack.of(this),provider=kubectl_provider_1().KubectlProvider.getOrCreate(this,props.cluster),pruneLabel=props.prune??props.cluster.prune?this.injectPruneLabel(props.manifest):void 0;(props.ingressAlb??!1)&&this.injectIngressAlbAnnotations(props.manifest,props.ingressAlbScheme??alb_controller_1().AlbScheme.INTERNAL);const customResource=new(core_1()).CustomResource(this,"Resource",{serviceToken:provider.serviceToken,resourceType:KubernetesManifest.RESOURCE_TYPE,properties:{Manifest:stack.toJsonString(props.manifest),ClusterName:props.cluster.clusterName,RoleArn:provider.roleArn,PruneLabel:pruneLabel,Overwrite:props.overwrite,SkipValidation:props.skipValidation}});this.node.defaultChild=customResource.node.defaultChild}injectPruneLabel(manifest){const pruneLabel=PRUNE_LABEL_PREFIX+constructs_1().Node.of(this).addr;for(const resource of manifest)typeof resource!="object"||!resource.kind||(resource.metadata||(resource.metadata={}),resource.metadata.labels||(resource.metadata.labels={}),resource.metadata.labels={[pruneLabel]:"",...resource.metadata.labels});return pruneLabel}injectIngressAlbAnnotations(manifest,scheme){for(const resource of manifest)typeof resource!="object"||!resource.kind||resource.kind==="Ingress"&&(resource.metadata.annotations={"kubernetes.io/ingress.class":"alb","alb.ingress.kubernetes.io/scheme":scheme,...resource.metadata.annotations})}}exports.KubernetesManifest=KubernetesManifest,_a=JSII_RTTI_SYMBOL_1,KubernetesManifest[_a]={fqn:"aws-cdk-lib.aws_eks.KubernetesManifest",version:"2.159.0"},KubernetesManifest.RESOURCE_TYPE="Custom::AWSCDK-EKS-KubernetesResource";
