add: read config from subscription link for run command
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -49,8 +50,16 @@ func readConfigAt(path string) (*OptionsEntry, error) {
|
|||||||
configContent []byte
|
configContent []byte
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
subscriptionLink := os.Getenv("SING_SUBSCRIPTION_LINK")
|
||||||
if path == "stdin" {
|
if path == "stdin" {
|
||||||
configContent, err = io.ReadAll(os.Stdin)
|
configContent, err = io.ReadAll(os.Stdin)
|
||||||
|
} else if path == "env" && subscriptionLink != "" {
|
||||||
|
configContentResponse, err := http.Get(subscriptionLink)
|
||||||
|
if err != nil {
|
||||||
|
return nil, E.Cause(err, "failed to GET subscription link")
|
||||||
|
}
|
||||||
|
defer configContentResponse.Body.Close()
|
||||||
|
configContent, err = io.ReadAll(configContentResponse.Body)
|
||||||
} else {
|
} else {
|
||||||
configContent, err = os.ReadFile(path)
|
configContent, err = os.ReadFile(path)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user