🌳
pt0/deployF/harvF/get1WcCertNameF.mts
3import * as _ from 'lodash-es'
5const hasWcDomain = (domains: string | string[]) => {
6 const domainA = _.isArray(domains) ? domains : [domains]
7 return domainA.some(d => d.includes('*'))
8}
10export const get1WcCertName = () => {
11 const ctx = getKlusterCtx()
12 const {wcCertName, klustCertsH} = ctx
13 if (wcCertName) return wcCertName
14 if (klustCertsH) {
15 const certNames = Object.keys(klustCertsH)
16 if (certNames.length === 1) return certNames[0]
17 const wcCertNames = certNames.filter(n => hasWcDomain(klustCertsH[n]))
18 if (wcCertNames.length === 1) return wcCertNames[0]
19 throPtErr('multiple certs in klustCertsH, specify wcCertName', {certNames, wcCertNames})
20 }
21 throPtErr('!wcCertName and !klustCertsH')