File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Expand file tree Collapse file tree 2 files changed +52
-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+ if [ -d $1 ]; then
6+ SDK_DIR=$1
7+ shift
8+ fi
9+
10+ if [ -z " $SDK_DIR " ]; then
11+ SDK_DIR=../stackit-sdk-generator/sdk-repo-updated
12+ echo " No SDK_DIR set, using $SDK_DIR "
13+ fi
14+
15+
16+ if [ ! -f go.work ]; then
17+ go work init
18+ go work use .
19+ else
20+ echo " go.work already exists"
21+ fi
22+
23+ if [ $# -gt 0 ]; then
24+ # modules passed via commandline
25+ for service in $* ; do
26+ if [ ! -d $SDK_DIR /services/$service ]; then
27+ echo " service directory $SDK_DIR /services/$service does not exist"
28+ exit 1
29+ fi
30+ echo " replacing selected service $service "
31+ if [ " $service " = " core" ]; then
32+ go work edit -replace github.com/stackitcloud/stackit-sdk-go/core=$SDK_DIR /core
33+ else
34+ go work edit -replace github.com/stackitcloud/stackit-sdk-go/services/$service =$SDK_DIR /services/$service
35+ fi
36+ done
37+ else
38+ # replace all modules
39+ echo " replacing all services"
40+ go work edit -replace github.com/stackitcloud/stackit-sdk-go/core=$SDK_DIR /core
41+ for n in $( find ${SDK_DIR} /services -name go.mod) ; do
42+ service=$( dirname $n )
43+ service=${service# ${SDK_DIR} / services/ }
44+ go work edit -replace github.com/stackitcloud/stackit-sdk-go/services/$service =$( dirname $n )
45+ done
46+ fi
47+ go work edit -fmt
48+ go work sync
You can’t perform that action at this time.
0 commit comments