Functions.core.sh 2.32 KB
Newer Older
据说甜蜜呢 committed
1 2 3 4 5 6 7 8 9 10 11
#!/bin/bash

set -e

function ToLower()
{
   declare input=$1
   declare output=($(echo "${input}" | tr 'A-Z' 'a-z'))
   eval $2=${output}
}

12 13 14 15
# function GetServices()
# {
#	
# }
据说甜蜜呢 committed
16 17 18 19 20 21 22 23 24

function GetServiceCsProjFile()
{
    declare prefix=${1}
	declare name=${2}
	declare csprojFile="./src/Services/${prefix}/${name}/${name}.csproj"
	eval $3="${csprojFile}"
}

据说甜蜜呢 committed
25 26 27 28 29 30 31 32
function GetServiceDir()
{
    declare prefix=${1}
	declare name=${2}
	declare dir="./src/Services/${prefix}/${name}"
	eval $3="${dir}"
}

据说甜蜜呢 committed
33 34 35 36 37 38 39 40 41 42 43 44 45
function GetServiceName()
{
    declare prefix=${1}
	declare name=($(ls ./src/Services/${prefix}|head -n 1|xargs -d '/' echo))
	eval $2="${name}"
}

function GetAppName()
{
    declare name=($(grep -oP '(?<=AppName>)[^<]+' "./devops/app.props"))
	eval $1="${name}"
}

据说甜蜜呢 committed
46 47 48
function GetNameSpace()
{
    GetMajor major
49 50 51
	declare ns=($(grep -oP '(?<=NameSpace>)[^<]+' "./devops/app.props"))
	declare nsOfK8s=$(echo "${ns}-v${major}" | tr 'A-Z' 'a-z')
	eval $1=${nsOfK8s}
据说甜蜜呢 committed
52 53
}

据说甜蜜呢 committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
function GetSolutionName()
{
    declare name=($(grep -oP '(?<=SolutionName>)[^<]+' "./devops/app.props"))
	eval $1="${name}"
}

function GetImageUserName()
{
    declare name=($(grep -oP '(?<=ImageUserName>)[^<]+' "devops/deploy.props"))
	eval $1="${name}"
}

function GetCiCdSettings()
{
    declare all=($(grep -oP '(?<=AllPublishable>)[^<]+' "/tmp/cicd.props"))
    declare no=($(grep -oP '(?<=NoPublishable>)[^<]+' "/tmp/cicd.props"))
	eval $1=${all}
	eval $2=${no}
}

function GetMajor()
{
    declare m=($(grep -oP '(?<=Major>)[^<]+' "./devops/version.props"))
	eval $1=${m}
}

function GetVersion()
{
    declare major=($(grep -oP '(?<=Major>)[^<]+' "./devops/version.props"))
	declare minor=($(grep -oP '(?<=Minor>)[^<]+' "./devops/version.props"))
	declare patch=($(grep -oP '(?<=Patch>)[^<]+' "./devops/version.props"))
	eval $1="${major}.${minor}.${patch}"
}

function GetImageRegistrySettings()
{
    declare host=($(grep -oP '(?<=ImageRegistryHost>)[^<]+' "devops/deploy.props"))
    declare username=($(grep -oP '(?<=ImageUserName>)[^<]+' "devops/deploy.props"))
	eval $1=${host}
	eval $2=${username}
}

function GetAccessTokenOf()
{
    declare token=($(grep -oP "(?<=${Environment}AccessToken>)[^<]+" "devops/deploy.props"))
	eval $1="${token}"
}

function IsPublishableOf()
{
    declare prefix=$0
    declare isP=($(grep -oP "(?<=${prefix}Publishable>)[^<]+" "/tmp/cicd.props"))
	eval $1=isP
}