| 111 | } |
| 112 | |
| 113 | func 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 |