Skip to content

Commit c14960a

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

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/commands/config_verify.go

+5
Original file line numberDiff line numberDiff line change
@@ -3,13 +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"
15+
"github.com/santhosh-tekuri/jsonschema/v5/httploader"
1316
_ "github.com/santhosh-tekuri/jsonschema/v5/httploader"
1417
"github.com/spf13/cobra"
1518
"github.com/spf13/pflag"
@@ -100,6 +103,8 @@ func createSchemaURL(flags *pflag.FlagSet, buildInfo BuildInfo) (string, error)
100103
func validateConfiguration(schemaPath, targetFile string) error {
101104
compiler := jsonschema.NewCompiler()
102105
compiler.Draft = jsonschema.Draft7
106+
const loadSchemaTimeout = 2 * time.Second
107+
httploader.Client = &http.Client{Timeout: loadSchemaTimeout}
103108

104109
schema, err := compiler.Compile(schemaPath)
105110
if err != nil {

0 commit comments

Comments
 (0)