refactor: Revise Dockerfile - Remove entrypoint.sh (#598)
* chore: Formatting * chore: Formatting (fix indent) * refactor: Remove entrypoint * chore: Remove `entrypoint.sh` from `.goreleaser.yaml` * tests: Replace `entrypoint.sh` script usage in `e2eentry.sh` * Set default plugin argument from environment variable in main function and update Dockerfile to remove CMD instruction * Add user and group setup for testing in Dockerfile and update e2e entry script * Update cmd/sshpiperd/main.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update cmd/sshpiperd/main.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove test user and group creation from Dockerfile and move it to e2e entry script; update plugin argument handling in main function * Update Dockerfile Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Skip empty plugin directory entries in main function --------- Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
2edfa6b4c3
commit
ca311e15cd
6 changed files with 51 additions and 27 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime/debug"
|
||||
"slices"
|
||||
"time"
|
||||
|
|
@ -264,6 +265,46 @@ func main() {
|
|||
var plugins []*plugin.GrpcPlugin
|
||||
|
||||
args := ctx.Args().Slice()
|
||||
|
||||
// If no command-line arguments are provided, fall back to the PLUGIN environment variable.
|
||||
if len(args) == 0 {
|
||||
pluginEnv := os.Getenv("PLUGIN")
|
||||
if pluginEnv != "" {
|
||||
|
||||
exePath, err := os.Executable()
|
||||
exeDir := ""
|
||||
if err == nil {
|
||||
exeDir = fmt.Sprintf("%s/", filepath.Dir(exePath))
|
||||
}
|
||||
|
||||
pluginDirs := []string{
|
||||
filepath.Join(exeDir, "plugins"),
|
||||
os.Getenv("SSHPIPERD_PLUGIN_PATH"),
|
||||
}
|
||||
|
||||
found := false
|
||||
|
||||
for _, dir := range pluginDirs {
|
||||
if dir == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
pluginexe := filepath.Join(dir, pluginEnv)
|
||||
if _, err := os.Stat(pluginexe); err == nil {
|
||||
args = append(args, pluginexe)
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
if path, err := exec.LookPath(pluginEnv); err == nil {
|
||||
args = append(args, path)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
remain := args
|
||||
|
||||
for len(remain) > 0 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue