Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit b148d0a

Browse files
authored
fix: use resolved object when constructing cloud configuration (#974)
1 parent ff72982 commit b148d0a

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

cmd/config/validate.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,19 @@ func Validate(
129129
return nil, fmt.Errorf("failed to create schema: %w", err)
130130
}
131131

132-
cfg, err = appconfig.SecretsResolver[model.ConfigConfig](cfg, secrets, schema.Fill)
132+
cfg, err = appconfig.SecretsResolver(cfg, secrets, schema.Fill)
133133
if err != nil {
134134
return nil, fmt.Errorf("failed to validate config: %w", err)
135135
}
136136

137137
return cfg, nil
138138
}
139139

140+
// ValidateRemote validates the configuration of a remote project by fetching
141+
// the secrets and applying them to the configuration. It also applies any
142+
// JSON patches from the overlay directory if it exists.
143+
// It returns the original configuration with the applied patches (without being filled
144+
// and without secrets resolved) and another configuration filled and with secrets resolved.
140145
func ValidateRemote(
141146
ctx context.Context,
142147
ce *clienv.CliEnv,
@@ -148,6 +153,14 @@ func ValidateRemote(
148153
return nil, nil, fmt.Errorf("failed to parse config: %w", err)
149154
}
150155

156+
if clienv.PathExists(ce.Path.Overlay(subdomain)) {
157+
var err error
158+
cfg, err = ApplyJSONPatches(*cfg, ce.Path.Overlay(subdomain))
159+
if err != nil {
160+
return nil, nil, fmt.Errorf("failed to apply json patches: %w", err)
161+
}
162+
}
163+
151164
schema, err := schema.New()
152165
if err != nil {
153166
return nil, nil, fmt.Errorf("failed to create schema: %w", err)
@@ -166,16 +179,9 @@ func ValidateRemote(
166179
return nil, nil, fmt.Errorf("failed to get secrets: %w", err)
167180
}
168181

169-
if clienv.PathExists(ce.Path.Overlay(subdomain)) {
170-
var err error
171-
cfg, err = ApplyJSONPatches(*cfg, ce.Path.Overlay(subdomain))
172-
if err != nil {
173-
return nil, nil, fmt.Errorf("failed to apply json patches: %w", err)
174-
}
175-
}
176-
177182
secrets := respToSecrets(secretsResp.GetAppSecrets(), false)
178-
cfgSecrets, err := appconfig.SecretsResolver[model.ConfigConfig](cfg, secrets, schema.Fill)
183+
184+
cfgSecrets, err := appconfig.SecretsResolver(cfg, secrets, schema.Fill)
179185
if err != nil {
180186
return nil, nil, fmt.Errorf("failed to validate config: %w", err)
181187
}

cmd/dev/cloud.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ func cloud( //nolint:funlen
176176
ctxWithTimeout, cancel := context.WithTimeout(ctx, 5*time.Second) //nolint:mnd
177177
defer cancel()
178178
ce.Infoln("Checking versions...")
179-
if err := software.CheckVersions(ctxWithTimeout, ce, cfg, appVersion); err != nil {
179+
if err := software.CheckVersions(ctxWithTimeout, ce, cfgSecrets, appVersion); err != nil {
180180
ce.Warnln("Problem verifying recommended versions: %s", err.Error())
181181
}
182182

183183
ce.Infoln("Setting up Nhost development environment...")
184184
composeFile, err := dockercompose.CloudComposeFileFromConfig(
185-
cfg,
185+
cfgSecrets,
186186
ce.LocalSubdomain(),
187187
proj.GetSubdomain(),
188188
proj.GetRegion().GetName(),
@@ -231,7 +231,7 @@ func cloud( //nolint:funlen
231231
ctx,
232232
ce.LocalSubdomain(),
233233
ce.Path.NhostFolder(),
234-
*cfg.Hasura.Version,
234+
*cfgSecrets.Hasura.Version,
235235
"metadata", "export",
236236
"--skip-update-check",
237237
"--log-level", "ERROR",

0 commit comments

Comments
 (0)