编辑代码

product = 'gbw'
profile = 'test'


def acrAdress(product,profile){

 // aliyun acr address 
    registryEnv = [
                'intranet':'cngongbao-registry-vpc.cn-hangzhou.cr.aliyuncs.com',
                'extranet':'cngongbao-registry.cn-hangzhou.cr.aliyuncs.com'
            ]
    
    // 杭州生产集群部署包含的产品线
    hangzhouCluster = [
                'gbw',
                'gbd',
                'ly-xuancheng',
                'ly-yaan'
            ]
    
    // 成都生产集群部署包含的产品线
    chengduCluster = ['financial']
    
    // 标准化部署
    standardProduct = [
                'gbw',
                'gbd'
            ]
    
    // 非标准化部署
    nonstandardProduct = [
                'ly-xuancheng',
                'ly-yaan',
                'financial'
            ]
    
    // 部署ack到环境
    DPACK = [
                'prod',
                'gray',
                'release'
            ]
    
    
    // 非部署在ack 杭州集群内走公网
    if (!DPACK.contains(profile) || !hangzhouCluster.contains(product)){
        registry =  registryEnv.get('extranet')
        namespace = 'snapshot'
        println registry + '/' + namespace 
        return registry + '/' + namespace
    } 
    
    // 标准化部署
    // if (standardProduct.contains(product) && DPACK.contains(profile)){  
    if (standardProduct.contains(product)){
        registry =  registryEnv.get('intranet')
        namespace = 'release'
        println registry + '/' + namespace 
        return registry + '/' + namespace
    }
    
    // 非标准化部署
    if (nonstandardProduct.contains(product)){
        if (DPACK){
            registry =  registryEnv.get('intranet')
            namespace = 'snapshot'      
            println registry + '/' + namespace 
            return registry + '/' + namespace 
        } 
    }
}


def switchAck(product,profile){
    // 杭州生产集群部署包含的产品线
    hangzhouCluster = [
                'gbw',
                'gbd',
                'ly-xuancheng',
                'ly-yaan'
            ]
    
    // 成都生产集群部署包含的产品线
    chengduCluster = ['financial']

        // 部署ack到环境
    DPACK = [
                'prod',
                'gray',
                'release'
            ]
    
    if (hangzhouCluster.contains(product) && DPACKcontains(profile) ){
        ackRegion = 'hangzhou'
        println ackRegion
        return ackRegion
    }
    
    if (chengduCluster.contains(product) && DPACKcontains(profile) ){
        ackRegion = 'chengdu'
        println ackRegion
        return ackRegion
    }
}

acrAdress('financial','prod')