add: read config from subscription link for run command
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
@@ -49,8 +50,16 @@ func readConfigAt(path string) (*OptionsEntry, error) {
|
||||
configContent []byte
|
||||
err error
|
||||
)
|
||||
subscriptionLink := os.Getenv("SING_SUBSCRIPTION_LINK")
|
||||
if path == "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 {
|
||||
configContent, err = os.ReadFile(path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user