PromucFlow_constructor/deploy/docker/fs/opt/appsmith/generate-infra-details.sh
Trisha Anand 921807d80b
chore: Update incorrect docker tagging and add fargate tag in deployment telemetry (#33472)
## Description
> [!TIP]  
> _Add a TL;DR when the description is longer than 500 words or
extremely technical (helps the content, marketing, and DevRel team)._
>
> _Please also include relevant motivation and context. List any
dependencies that are required for this change. Add links to Notion,
Figma or any other documents that might be relevant to the PR._


Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/ok-to-test tags=""

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!CAUTION]  
> If you modify the content in this section, you are likely to disrupt
the CI result for your PR.

<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No

---------

Co-authored-by: Goutham Pratapa <goutham@appsmith.com>
2024-05-27 17:16:13 +05:30

79 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
infra_file="$TMP/infra.json"
mount_path="/appsmith-stacks"
## Get cloudProvider details
function get_cloud_provider() {
release_details=$(uname -r)
if [[ $release_details == *"amzn"* ]];then
# Example: 5.10.192-183.736.amzn2.x86_64
cloud_provider="amazon";
elif [[ $release_details == *"azure"* ]];then
# Example: 5.15.0-1059-azure
cloud_provider="azure";
elif [[ $release_details == *"cloud"* ]];then
# Example: 6.1.0-18-cloud-amd64
cloud_provider="gcp";
elif [[ $release_details == *"generic"* ]];then
# Example: 6.8.0-31-generic
cloud_provider="digitalocean"
elif [[ $release_details == *"ecs"* ]];then
cloud_provider="alibaba"
elif [[ -n "${DYNO}" ]];then
cloud_provider="heroku"
else
cloud_provider="others(including local)";
fi
}
## Get deployment tool details
function get_tool() {
if [[ -z "${KUBERNETES_SERVICE_HOST}" ]]; then
dep_tool="likely docker";
else
dep_tool="kubernetes";
fi
}
## Check if EFS is mounted
function check_for_efs() {
findmnt --mountpoint $mount_path | grep nfs && {
efs="present"
} || {
efs="absent"
}
}
## Check hostname
function get_hostname() {
hostname="$(cat /etc/hostname)"
}
## Get current Time
function get_current_time(){
currentTime="$(date -u -Iseconds)"
}
## Check if it's a ECS Fargate deployment
function check_for_fargate() {
if [[ $cloud_provider == "amazon" && $dep_tool == "likely docker" && $efs == "present" ]]; then
dep_tool="ecs-fargate"
fi
}
## Main Block
get_cloud_provider
get_tool
get_hostname
check_for_efs
check_for_fargate
get_current_time
infra_json='{"cloudProvider":"'"$cloud_provider"'","tool":"'"$dep_tool"'","efs":"'"$efs"'","hostname":"'"$hostname"'", "currentTime": "'"$currentTime"'"}'
echo "$infra_json"
echo $infra_json > $infra_file