File tree Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change 88
99# OS generated files
1010.DS_Store
11+
12+ # Go workspace file
13+ go.work
14+ go.work.sum
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Add replace directives to local files to go.work
3+ set -eo pipefail
4+
5+ while getopts " s:" option; do
6+ case " ${option} " in
7+ s)
8+ SDK_DIR=${OPTARG}
9+ ;;
10+
11+ * )
12+ echo " call: $0 [-s sdk-dir] <apis*>"
13+ exit 0
14+ ;;
15+ esac
16+ done
17+ shift $(( OPTIND- 1 ))
18+
19+ if [ -z " $SDK_DIR " ]; then
20+ SDK_DIR=../stackit-sdk-generator/sdk-repo-updated
21+ echo " No SDK_DIR set, using $SDK_DIR "
22+ fi
23+
24+
25+ if [ ! -f go.work ]; then
26+ go work init
27+ go work use .
28+ else
29+ echo " go.work already exists"
30+ fi
31+
32+ if [ $# -gt 0 ]; then
33+ # modules passed via commandline
34+ for service in $* ; do
35+ if [ ! -d $SDK_DIR /services/$service ]; then
36+ echo " service directory $SDK_DIR /services/$service does not exist"
37+ exit 1
38+ fi
39+ echo " replacing selected service $service "
40+ if [ " $service " = " core" ]; then
41+ go work edit -replace github.com/stackitcloud/stackit-sdk-go/core=$SDK_DIR /core
42+ else
43+ go work edit -replace github.com/stackitcloud/stackit-sdk-go/services/$service =$SDK_DIR /services/$service
44+ fi
45+ done
46+ else
47+ # replace all modules
48+ echo " replacing all services"
49+ go work edit -replace github.com/stackitcloud/stackit-sdk-go/core=$SDK_DIR /core
50+ for n in $( find ${SDK_DIR} /services -name go.mod) ; do
51+ service=$( dirname $n )
52+ service=${service# ${SDK_DIR} / services/ }
53+ go work edit -replace github.com/stackitcloud/stackit-sdk-go/services/$service =$( dirname $n )
54+ done
55+ fi
56+ go work edit -fmt
57+ go work sync
You can’t perform that action at this time.
0 commit comments