forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy magician dependencies to the container image (GoogleCloudPlatfor…
…m#9299) Co-authored-by: Thomas Rodgers <[email protected]>
- Loading branch information
Showing
2 changed files
with
40 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
#!/bin/bash | ||
|
||
# Check if there's at least one argument | ||
if [ "$#" -eq 0 ]; then | ||
echo "No arguments provided" | ||
exit 1 | ||
fi | ||
|
||
# Get the directory of the current script | ||
DIR="$(dirname $(realpath $0))" | ||
|
||
# Construct the path to the Go program | ||
GO_PROGRAM="$DIR/../../../magician/" | ||
# Construct the path to the Go program directory and binary | ||
GO_PROGRAM_DIR="$DIR/../../../magician/" | ||
GO_BINARY="$GO_PROGRAM_DIR/magician_binary" | ||
|
||
pushd $GO_PROGRAM | ||
pushd $GO_PROGRAM_DIR | ||
|
||
set -x | ||
# Pass all arguments to the child command | ||
go run . "$@" | ||
# Check if the binary exists | ||
if [ ! -f "$GO_BINARY" ]; then | ||
# If it doesn't exist, compile the binary | ||
echo "Building the magician binary at $GO_BINARY" | ||
go build -o "$GO_BINARY" | ||
fi | ||
|
||
# If there are no arguments only compile the binary | ||
if [ "$#" -eq 0 ]; then | ||
echo "No arguments provided" | ||
exit 0 | ||
fi | ||
|
||
# Run the binary and pass all arguments | ||
$GO_BINARY "$@" | ||
set +x |