mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-20 15:44:25 +01:00
Mnovich/fix cli permisisons (#3074)
This commit is contained in:
5
.github/workflows/build-cli.yml
vendored
5
.github/workflows/build-cli.yml
vendored
@@ -288,8 +288,7 @@ jobs:
|
|||||||
|
|
||||||
# Move the built binary to the expected location
|
# Move the built binary to the expected location
|
||||||
mkdir -p target/x86_64-pc-windows-gnu/release
|
mkdir -p target/x86_64-pc-windows-gnu/release
|
||||||
chmod -R ug+rwX target/x86_64-pc-windows-gnu/release
|
mv temporal-service/temporal-service.exe target/x86_64-pc-windows-gnu/release/temporal-service.exe
|
||||||
cp -f temporal-service/temporal-service.exe target/x86_64-pc-windows-gnu/release/temporal-service.exe
|
|
||||||
echo "temporal-service.exe built successfully for Windows"
|
echo "temporal-service.exe built successfully for Windows"
|
||||||
|
|
||||||
- name: Download temporal CLI (Linux/macOS)
|
- name: Download temporal CLI (Linux/macOS)
|
||||||
@@ -401,4 +400,4 @@ jobs:
|
|||||||
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # pin@v4
|
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # pin@v4
|
||||||
with:
|
with:
|
||||||
name: goose-${{ matrix.architecture }}-${{ matrix.target-suffix }}
|
name: goose-${{ matrix.architecture }}-${{ matrix.target-suffix }}
|
||||||
path: ${{ env.ARTIFACT }}
|
path: ${{ env.ARTIFACT }}
|
||||||
@@ -13,7 +13,6 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -177,79 +176,45 @@ func findTemporalCLI() (string, error) {
|
|||||||
|
|
||||||
// If not found in PATH, try different possible locations for the temporal CLI
|
// If not found in PATH, try different possible locations for the temporal CLI
|
||||||
log.Println("Checking bundled/local locations for temporal CLI...")
|
log.Println("Checking bundled/local locations for temporal CLI...")
|
||||||
currentPaths := []string{
|
possiblePaths := []string{
|
||||||
"./temporal",
|
"./temporal", // Current directory
|
||||||
"./temporal.exe",
|
|
||||||
}
|
|
||||||
if path, err := getExistingTemporalCLIFrom(currentPaths); err == nil {
|
|
||||||
return path, nil
|
|
||||||
} else {
|
|
||||||
log.Printf("Attempt to find in local directory failed: %s.", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also try relative to the current executable (most important for bundled apps)
|
// Also try relative to the current executable (most important for bundled apps)
|
||||||
exePath, err := os.Executable()
|
if exePath, err := os.Executable(); err == nil {
|
||||||
if err != nil {
|
exeDir := filepath.Dir(exePath)
|
||||||
|
log.Printf("Executable directory: %s", exeDir)
|
||||||
|
additionalPaths := []string{
|
||||||
|
filepath.Join(exeDir, "temporal"),
|
||||||
|
filepath.Join(exeDir, "temporal.exe"), // Windows
|
||||||
|
// Also try one level up (for development)
|
||||||
|
filepath.Join(exeDir, "..", "temporal"),
|
||||||
|
filepath.Join(exeDir, "..", "temporal.exe"),
|
||||||
|
}
|
||||||
|
possiblePaths = append(possiblePaths, additionalPaths...)
|
||||||
|
log.Printf("Will check these additional paths: %v", additionalPaths)
|
||||||
|
} else {
|
||||||
log.Printf("Failed to get executable path: %v", err)
|
log.Printf("Failed to get executable path: %v", err)
|
||||||
}
|
}
|
||||||
exeDir := filepath.Dir(exePath)
|
|
||||||
log.Printf("Executable directory: %s", exeDir)
|
|
||||||
additionalPaths := []string{
|
|
||||||
filepath.Join(exeDir, "temporal"),
|
|
||||||
filepath.Join(exeDir, "temporal.exe"), // Windows
|
|
||||||
// Also try one level up (for development)
|
|
||||||
filepath.Join(exeDir, "..", "temporal"),
|
|
||||||
filepath.Join(exeDir, "..", "temporal.exe"),
|
|
||||||
}
|
|
||||||
log.Printf("Will check these additional paths: %v", additionalPaths)
|
|
||||||
return getExistingTemporalCLIFrom(additionalPaths)
|
|
||||||
}
|
|
||||||
|
|
||||||
// getExistingTemporalCLIFrom gets a list of paths and returns one of those that is an existing and working Temporal CLI binary
|
|
||||||
func getExistingTemporalCLIFrom(possiblePaths []string) (string, error) {
|
|
||||||
log.Printf("Checking %d possible paths for temporal CLI", len(possiblePaths))
|
log.Printf("Checking %d possible paths for temporal CLI", len(possiblePaths))
|
||||||
|
|
||||||
// Check all possible paths in parallel, pick the first one that works.
|
// Test each possible path
|
||||||
pathFound := make(chan string)
|
|
||||||
var wg sync.WaitGroup
|
|
||||||
// This allows us to cancel whatever remaining work is done when we find a valid path.
|
|
||||||
psCtx, psCancel := context.WithCancel(context.Background())
|
|
||||||
for i, path := range possiblePaths {
|
for i, path := range possiblePaths {
|
||||||
wg.Add(1)
|
log.Printf("Checking path %d/%d: %s", i+1, len(possiblePaths), path)
|
||||||
go func() {
|
if _, err := os.Stat(path); err == nil {
|
||||||
defer wg.Done()
|
|
||||||
log.Printf("Checking path %d/%d: %s", i+1, len(possiblePaths), path)
|
|
||||||
if _, err := os.Stat(path); err != nil {
|
|
||||||
log.Printf("File does not exist at %s: %v", path, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.Printf("File exists at: %s", path)
|
log.Printf("File exists at: %s", path)
|
||||||
// File exists, test if it's executable and the right binary
|
// File exists, test if it's executable and the right binary
|
||||||
cmd := exec.CommandContext(psCtx, path, "--version")
|
cmd := exec.Command(path, "--version")
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err == nil {
|
||||||
log.Printf("Failed to verify temporal CLI at %s: %v", path, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
select {
|
|
||||||
case pathFound <- path:
|
|
||||||
log.Printf("Successfully verified temporal CLI at: %s", path)
|
log.Printf("Successfully verified temporal CLI at: %s", path)
|
||||||
case <-psCtx.Done():
|
return path, nil
|
||||||
// No need to report the path not chosen.
|
} else {
|
||||||
|
log.Printf("Failed to verify temporal CLI at %s: %v", path, err)
|
||||||
}
|
}
|
||||||
}()
|
} else {
|
||||||
}
|
log.Printf("File does not exist at %s: %v", path, err)
|
||||||
// We transform the workgroup wait into a channel so we can wait for either this or pathFound
|
}
|
||||||
pathNotFound := make(chan bool)
|
|
||||||
go func() {
|
|
||||||
wg.Wait()
|
|
||||||
pathNotFound <- true
|
|
||||||
}()
|
|
||||||
select {
|
|
||||||
case path := <-pathFound:
|
|
||||||
psCancel() // Cancel the remaining search functions otherwise they'll just exist eternally.
|
|
||||||
return path, nil
|
|
||||||
case <-pathNotFound:
|
|
||||||
// No need to do anything, this just says that none of the functions were able to do it and there's nothing left to cleanup
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", fmt.Errorf("temporal CLI not found in PATH or any of the expected locations: %v", possiblePaths)
|
return "", fmt.Errorf("temporal CLI not found in PATH or any of the expected locations: %v", possiblePaths)
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user