Skip to content

Commit 6a3101c

Browse files
committed
Added go workspace script
1 parent 62a30d2 commit 6a3101c

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

hack/go-mod.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo "Updating dependencies for Machine API Provider AWS workspace"
6+
7+
go work use -r .
8+
9+
# Discover all modules from the workspace
10+
echo "Discovering modules from workspace..."
11+
MODULES=$(go work edit -json | grep -o '"DiskPath": "[^"]*"' | cut -d'"' -f4 | sed 's|^\./||')
12+
echo "Found modules: $MODULES"
13+
14+
# Pass 1: tidy all modules
15+
echo "Running go mod tidy for all modules (pass 1)..."
16+
for module in $MODULES; do
17+
if [ -f "$module/go.mod" ]; then
18+
echo "Tidying $module"
19+
(cd "$module" && go mod tidy)
20+
fi
21+
done
22+
23+
# Sync: propagate highest require versions across all modules
24+
echo "Syncing Go workspace..."
25+
go work sync
26+
27+
# Pass 2: re-tidy after sync may have bumped versions
28+
echo "Running go mod tidy for all modules (pass 2)..."
29+
for module in $MODULES; do
30+
if [ -f "$module/go.mod" ]; then
31+
echo "Tidying $module"
32+
(cd "$module" && go mod tidy)
33+
fi
34+
done
35+
36+
# Verify all modules
37+
echo "Verifying all modules..."
38+
for module in $MODULES; do
39+
if [ -f "$module/go.mod" ]; then
40+
echo "Verifying $module"
41+
(cd "$module" && go mod verify)
42+
fi
43+
done
44+
45+
# Create unified vendor directory
46+
echo "Creating unified vendor directory..."
47+
go work vendor -v

0 commit comments

Comments
 (0)