forked from DataDog/datadog-process-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-datadog-dependency.sh
executable file
·57 lines (47 loc) · 1.51 KB
/
update-datadog-dependency.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Okay, here it goes: The process agent depends on the datadog agent, which:
# - for some modules (EBPF) uses go:generate which needs to be run to even build the dependency.
# - for some other modules generate EBPF code, which we need but is not part of the regular go build
# This file makes sure those prebuild steps (go:generate and ebpf files) get built and installed.
set -e
DIR="${BASH_SOURCE%/*}"
if [ ! -d "$DIR" ]; then DIR="$PWD"; fi
if [ "$DIR" = "." ]; then DIR="$PWD"; fi
printUsage() {
cat << USAGE
Usage: ./update-datadog-dependency.sh --local <path>|--branch <branch>|--help
This script will update go.mod to point to a different remote
-l/--local -- Use a local directory as dependency
-b/--branch [branch] -- Use the given branch of github.com/StackVista/datadog-agent-upstream-for-process-agent as a dependency, defaults to stackstate-7.49.1
-h/--help -- Print this help page
USAGE
}
ACTION=""
BRANCH="stackstate-7.49.1"
while [ $# -gt 0 ]; do
case $1 in
-l|--local)
shift
go mod edit -replace "github.com/DataDog/datadog-agent=$1"
go mod tidy
exit 0
;;
-b|--branch)
shift
BRANCH="${1}"
echo "Using branch ${BRANCH}"
go mod edit -replace "github.com/DataDog/datadog-agent=github.com/StackVista/datadog-agent-upstream-for-process-agent@${BRANCH}"
go mod tidy
exit 0
;;
-h|--help)
printUsage
exit 0
;;
*)
echo "Unknown flag"
printUsage
exit 1
;;
esac
done