MCPcopy Create free account
hub / github.com/nhost/nhost / Validate

Function Validate

cli/cmd/config/validate.go:113–143  ·  view source on GitHub ↗
(
	ce *clienv.CliEnv,
	subdomain string,
	secrets model.Secrets,
)

Source from the content-addressed store, hash-verified

111}
112
113func Validate(
114 ce *clienv.CliEnv,
115 subdomain string,
116 secrets model.Secrets,
117) (*model.ConfigConfig, error) {
118 cfg := &model.ConfigConfig{} //nolint:exhaustruct
119 if err := clienv.UnmarshalFile(ce.Path.NhostToml(), cfg, toml.Unmarshal); err != nil {
120 return nil, fmt.Errorf("failed to parse config: %w", err)
121 }
122
123 if clienv.PathExists(ce.Path.Overlay(subdomain)) {
124 var err error
125
126 cfg, err = ApplyJSONPatches(*cfg, ce.Path.Overlay(subdomain))
127 if err != nil {
128 return nil, fmt.Errorf("failed to apply json patches: %w", err)
129 }
130 }
131
132 schema, err := schema.New()
133 if err != nil {
134 return nil, fmt.Errorf("failed to create schema: %w", err)
135 }
136
137 cfg, err = appconfig.SecretsResolver(cfg, secrets, schema.Fill)
138 if err != nil {
139 return nil, fmt.Errorf("failed to validate config: %w", err)
140 }
141
142 return cfg, nil
143}
144
145// ValidateRemote validates the configuration of a remote project by fetching
146// the secrets and applying them to the configuration. It also applies any

Callers 5

upFunction · 0.92
commandVersionFunction · 0.92
TestValidateFunction · 0.92
commandValidateFunction · 0.70
commandShowFunction · 0.70

Calls 6

UnmarshalFileFunction · 0.92
PathExistsFunction · 0.92
ApplyJSONPatchesFunction · 0.85
NhostTomlMethod · 0.80
ErrorfMethod · 0.80
OverlayMethod · 0.80

Tested by 1

TestValidateFunction · 0.74