@@ -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.
140145func 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 }
0 commit comments