Merge pull request #1265 from DiniFarb/fix_configfile

fix: config file CLI argument for relative paths -> v0.23.1
This commit is contained in:
Ben Reedy 2023-08-01 20:56:52 +10:00 committed by GitHub
commit b0a1a38829
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,8 +18,8 @@ import (
"fmt"
"io"
"net/http"
"net/url"
"os"
"strings"
"github.com/alecthomas/kingpin/v2"
"github.com/go-kit/log"
@ -40,11 +40,8 @@ type Resolver struct {
func NewResolver(file string, logger log.Logger, insecure_skip_verify bool) (*Resolver, error) {
flags := map[string]string{}
var fileBytes []byte
url, err := url.ParseRequestURI(file)
if err != nil {
return nil, err
}
if url.Scheme == "http" || url.Scheme == "https" {
var err error
if strings.HasPrefix(file, "http://") || strings.HasPrefix(file, "https://") {
_ = level.Info(logger).Log("msg", fmt.Sprintf("Loading configuration file from URL: %v", file))
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: insecure_skip_verify},