"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.KubernetesManifest=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),core_1=require("../../core"),constructs_1=require("constructs"),alb_controller_1=require("./alb-controller"),kubectl_provider_1=require("./kubectl-provider"),PRUNE_LABEL_PREFIX="aws.cdk.eks/prune-";class KubernetesManifest extends constructs_1.Construct{constructor(scope,id,props){var _b,_c,_d;super(scope,id);jsiiDeprecationWarnings.aws_cdk_lib_aws_eks_KubernetesManifestProps(props);const stack=core_1.Stack.of(this),provider=kubectl_provider_1.KubectlProvider.getOrCreate(this,props.cluster),pruneLabel=((_b=props.prune)!==null&&_b!==void 0?_b:props.cluster.prune)?this.injectPruneLabel(props.manifest):void 0;((_c=props.ingressAlb)!==null&&_c!==void 0?_c:!1)&&this.injectIngressAlbAnnotations(props.manifest,(_d=props.ingressAlbScheme)!==null&&_d!==void 0?_d: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.13.0"},KubernetesManifest.RESOURCE_TYPE="Custom::AWSCDK-EKS-KubernetesResource";
//# sourceMappingURL=k8s-manifest.js.map
