Skip to content

Commit ed0088a

Browse files
committed
dev: set timeout for loading JSON schema
1 parent c00c1a5 commit ed0088a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/commands/config_verify.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ package commands
33
import (
44
"errors"
55
"fmt"
6+
"net/http"
67
"os"
78
"path/filepath"
89
"strings"
10+
"time"
911

1012
hcversion "github.com/hashicorp/go-version"
1113
"github.com/pelletier/go-toml/v2"
1214
"github.com/santhosh-tekuri/jsonschema/v5"
13-
_ "github.com/santhosh-tekuri/jsonschema/v5/httploader"
15+
"github.com/santhosh-tekuri/jsonschema/v5/httploader"
1416
"github.com/spf13/cobra"
1517
"github.com/spf13/pflag"
1618
"gopkg.in/yaml.v3"
@@ -100,6 +102,8 @@ func createSchemaURL(flags *pflag.FlagSet, buildInfo BuildInfo) (string, error)
100102
func validateConfiguration(schemaPath, targetFile string) error {
101103
compiler := jsonschema.NewCompiler()
102104
compiler.Draft = jsonschema.Draft7
105+
const loadSchemaTimeout = 2 * time.Second
106+
httploader.Client = &http.Client{Timeout: loadSchemaTimeout}
103107

104108
schema, err := compiler.Compile(schemaPath)
105109
if err != nil {

0 commit comments

Comments
 (0)