"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HelmChart=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},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},literal_string_1=()=>{var tmp=require("../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp};class HelmChart extends constructs_1().Construct{static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_eks_v2.HelmChart",version:"2.256.1"};static RESOURCE_TYPE="Custom::AWSCDK-EKS-HelmChart";chart;repository;version;chartAsset;atomic;constructor(scope,id,props){super(scope,id);try{jsiiDeprecationWarnings().aws_cdk_lib_aws_eks_v2_HelmChartProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,HelmChart),error}this.chart=props.chart,this.repository=props.repository,this.version=props.version,this.chartAsset=props.chartAsset;const stack=core_1().Stack.of(this),provider=kubectl_provider_1().KubectlProvider.getKubectlProvider(this,props.cluster);if(!provider)throw new(core_1()).ValidationError((0,literal_string_1().lit)`KubectlProviderDefinedClusterDefine`,"Kubectl Provider is not defined in this cluster. Define it when creating the cluster",this);const timeout=props.timeout?.toSeconds();if(timeout&&timeout>900)throw new(core_1()).ValidationError((0,literal_string_1().lit)`HelmChartTimeoutCannotHigher`,"Helm chart timeout cannot be higher than 15 minutes.",this);if(!this.chart&&!this.chartAsset)throw new(core_1()).ValidationError((0,literal_string_1().lit)`MustBeEitherChartChartasset`,"Either 'chart' or 'chartAsset' must be specified to install a helm chart",this);if(this.chartAsset&&(this.repository||this.version))throw new(core_1()).ValidationError((0,literal_string_1().lit)`ChartAssetRepositoryVersionConflict`,"Neither 'repository' nor 'version' can be used when configuring 'chartAsset'",this);const wait=props.wait??!1,createNamespace=props.createNamespace??!0,skipCrds=props.skipCrds??!1,atomic=props.atomic??!1,grant=this.chartAsset?.bucket.grantRead(provider.role),customResource=new(core_1()).CustomResource(this,"Resource",{serviceToken:provider.serviceToken,resourceType:HelmChart.RESOURCE_TYPE,removalPolicy:props.removalPolicy,properties:{ClusterName:props.cluster.clusterName,Release:props.release??core_1().Names.uniqueId(this).slice(-53).toLowerCase(),Chart:this.chart,ChartAssetURL:this.chartAsset?.s3ObjectUrl,Version:this.version,Wait:wait||void 0,Timeout:timeout?`${timeout.toString()}s`:void 0,Values:props.values?stack.toJsonString(props.values):void 0,Namespace:props.namespace??"default",Repository:this.repository,CreateNamespace:createNamespace||void 0,SkipCrds:skipCrds||void 0,Atomic:atomic||void 0}});grant?.applyBefore(customResource)}}exports.HelmChart=HelmChart;
