Skip to content

Commit

Permalink
chore: synced file(s) with honestbank/.github
Browse files Browse the repository at this point in the history
  • Loading branch information
honestbank-bot committed Feb 6, 2024
1 parent 74b6707 commit ee67cc8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .golangci.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"issues": {
"exclude-rules": {
"path": "/",
"path": "_test.go",
"linters": ["errcheck"]
}
},
Expand Down
66 changes: 42 additions & 24 deletions catalog-info.generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ if [ ! -f $META_DATA_FILE ]; then
cat << EOF >> $META_DATA_FILE
{
"squad_name": "example-squad",
"dashboard": "https://example.com",
"design_document": "https://example.com",
"runbook": "https://example.com",
"manual_dependencies": [],
"type": "application",
"lifecycle": "production",
"manual_service_names": [],
"example-service-name": {
"tags" : [
"language:golang",
Expand All @@ -30,30 +32,45 @@ fi
OUTPUT_FILE="catalog-info.yaml"
: > $OUTPUT_FILE # Clear the output file before appending

typeset -A SQUAD_ALIAS
SQUAD_ALIAS[acquisition]=acquisition-squad
SQUAD_ALIAS[decisioning]=mlops-squad
SQUAD_ALIAS[mlops]=mlops-squad
SQUAD_ALIAS[self-service]=self-service-squad
SQUAD_ALIAS[spend]=spend-squad

typeset -A TEAM_MAP
TEAM_MAP[acquisition-squad]=backend-engineers
TEAM_MAP[acquisition]=backend-engineers
TEAM_MAP[data-engineering]=data-squad
TEAM_MAP[decisioning]=backend-engineers
TEAM_MAP[devops]=devops-engineers
TEAM_MAP[internal-infra]=devops-engineers
TEAM_MAP[mlops-squad]=backend-engineers
TEAM_MAP[self-service-squad]=backend-engineers
TEAM_MAP[self-service]=backend-engineers
TEAM_MAP[spend-squad]=backend-engineers
TEAM_MAP[spend]=backend-engineers

squad_exist_in_team() {
get_squad_name() {
local raw_squad_name=$1
squad_name=${SQUAD_ALIAS[$raw_squad_name]}
if [[ -z $squad_name ]]; then
echo $raw_squad_name
fi
echo $squad_name
}

get_gh_team() {
local pattern=$1
for key in "${(@k)TEAM_MAP}"; do
if [[ $key == $pattern ]]; then
return 0
fi
done
return 1
gh_team=${TEAM_MAP[$pattern]}
if [[ -z $gh_team ]]; then
echo null
fi
echo $gh_team
}

REPO_NAME=$(basename "$(pwd)")
SERVICE_NAMES=(${(s: :)$(yq e '.jobs.repository-release-prod.with.helm_release_names' "$RELEASE_WORKFLOW")})
if [[ ${#SERVICE_NAMES[@]} == 0 || "$SERVICE_NAMES" == "null" ]]; then
SERVICE_NAMES=(${(s: :)$(jq -r ".manual_service_names[]" $META_DATA_FILE)})
fi
if [[ ${#SERVICE_NAMES[@]} == 0 || "$SERVICE_NAMES" == "null" ]]; then
SERVICE_NAMES=($REPO_NAME)
fi
Expand All @@ -62,19 +79,18 @@ SQUAD_NAME=$(yq e '.jobs.repository-release-prod.with.argocd_state_repo' "$RELEA
SQUAD_NAME=$(echo "$SQUAD_NAME" | cut -c 14-50)
if [[ -z $SQUAD_NAME || "$SQUAD_NAME" == "null" ]]; then
SQUAD_NAME=$(jq -r '.squad_name' $META_DATA_FILE)
fi
GH_TEAM=""
if squad_exist_in_team "$SQUAD_NAME"; then
GH_TEAM=${TEAM_MAP[$SQUAD_NAME]}
else
GH_TEAM="devops-engineers"
SQUAD_NAME="$SQUAD_NAME-squad"
fi
SQUAD_NAME=$(get_squad_name $SQUAD_NAME)
GH_TEAM=$(get_gh_team $SQUAD_NAME)

if [[ "$GH_TEAM" == "null" ]]; then
if [[ "$GH_TEAM" == null ]]; then
echo "couldn't find service owner"
exit 1
fi

DASHBOARD=$(jq -r '.dashboard' $META_DATA_FILE)
DESIGN_DOCUMENT=$(jq -r '.design_document' $META_DATA_FILE)
RUNBOOK=$(jq -r '.runbook' $META_DATA_FILE)

Expand Down Expand Up @@ -136,19 +152,22 @@ $(for tag in "${TAGS[@]}"; do
echo " - $tag"
done)
links:
- url: $DESIGN_DOCUMENT
title: Design Document
- title: Dashboard
url: $DASHBOARD
icon: dashboard
- title: Design Document
url: $DESIGN_DOCUMENT
icon: menubook
- url: $RUNBOOK
title: Runbook
- title: Runbook
url: $RUNBOOK
icon: help
spec:
type: $TYPE
lifecycle: $LIFECYCLE
owner: group:$SQUAD_NAME-squad
owner: group:$SQUAD_NAME
$(
if (( ${#DEPENDENCIES[@]} > 0 )); then
echo "dependsOn:"
echo " dependsOn:"
fi
)
$(for resource in "${DEPENDENCIES[@]}"; do
Expand All @@ -163,4 +182,3 @@ fixed_content="${file_content%$'\n'}"
echo "$fixed_content" > "$OUTPUT_FILE"

echo "File generated: $OUTPUT_FILE"

0 comments on commit ee67cc8

Please sign in to comment.