@@ -5,6 +5,7 @@ use std::{collections::HashMap, fmt, fs::remove_dir_all, path::PathBuf};
55use clap:: Parser ;
66use colored:: * ;
77use exitcode:: ExitCode ;
8+ use vector_vrl_metrics:: MetricsStorage ;
89
910use crate :: {
1011 config:: { self , Config , ConfigDiff , TransformContext , loading:: ConfigBuilderLoader } ,
@@ -119,7 +120,7 @@ pub async fn validate(opts: &Opts, color: bool) -> ExitCode {
119120 } ;
120121
121122 if opts. no_environment {
122- validated &= validate_transforms_no_environment ( opts , & config, & mut fmt) . await ;
123+ validated &= validate_transforms_no_environment ( & config, & mut fmt) . await ;
123124 } else if let Some ( tmp_directory) = create_tmp_directory ( & mut config, & mut fmt) {
124125 validated &= validate_environment ( opts, & config, & mut fmt) . await ;
125126 remove_tmp_directory ( tmp_directory) ;
@@ -181,43 +182,60 @@ pub fn validate_config(opts: &Opts, fmt: &mut Formatter) -> Option<Config> {
181182 Some ( config)
182183}
183184
184- async fn validate_transforms_no_environment (
185- opts : & Opts ,
186- config : & Config ,
187- fmt : & mut Formatter ,
188- ) -> bool {
185+ async fn validate_transforms_no_environment ( config : & Config , fmt : & mut Formatter ) -> bool {
186+ let enrichment_tables = vector_lib:: enrichment:: TableRegistry :: default ( ) ;
187+ enrichment_tables. load_compile_time_table_ids (
188+ config
189+ . enrichment_tables ( )
190+ . map ( |( key, _table) | key. to_string ( ) ) ,
191+ ) ;
192+
193+ let metrics_storage = MetricsStorage :: default ( ) ;
189194 let mut definition_cache = HashMap :: new ( ) ;
190- let mut warnings = Vec :: new ( ) ;
191195 let mut errors = Vec :: new ( ) ;
192196
193197 for ( key, transform) in config. transforms ( ) {
194- if transform. inner . build_requires_environment ( ) {
195- warnings. push ( format ! (
196- "Transform \" {key}\" skipped build validation because it requires environment-dependent setup."
197- ) ) ;
198- continue ;
199- }
200-
201- let merged_schema_definition = topology:: schema:: input_definitions (
198+ let input_definitions = topology:: schema:: input_definitions (
202199 & transform. inputs ,
203200 config,
204- Default :: default ( ) ,
201+ enrichment_tables . clone ( ) ,
205202 & mut definition_cache,
206203 )
207- . map ( |input_definitions| {
208- input_definitions
209- . into_iter ( )
210- . map ( |( _, definition) | definition)
211- . reduce ( Definition :: merge)
212- . unwrap_or_else ( Definition :: any)
213- } )
214- . unwrap_or_else ( |_| Definition :: any ( ) ) ;
204+ . unwrap_or_default ( ) ;
205+
206+ let merged_schema_definition = input_definitions
207+ . iter ( )
208+ . map ( |( _, definition) | definition. clone ( ) )
209+ . reduce ( Definition :: merge)
210+ . unwrap_or_else ( Definition :: any) ;
211+
212+ let schema_definitions = transform
213+ . inner
214+ . outputs (
215+ & TransformContext {
216+ enrichment_tables : enrichment_tables. clone ( ) ,
217+ metrics_storage : metrics_storage. clone ( ) ,
218+ schema : config. schema ,
219+ ..Default :: default ( )
220+ } ,
221+ & input_definitions,
222+ )
223+ . into_iter ( )
224+ . map ( |output| {
225+ let definitions = output. schema_definitions ( config. schema . enabled ) ;
226+ ( output. port , definitions)
227+ } )
228+ . collect ( ) ;
215229
216230 let context = TransformContext {
217231 key : Some ( key. clone ( ) ) ,
218232 globals : config. global . clone ( ) ,
233+ enrichment_tables : enrichment_tables. clone ( ) ,
234+ metrics_storage : metrics_storage. clone ( ) ,
235+ schema_definitions,
219236 merged_schema_definition,
220237 schema : config. schema ,
238+ skip_environment_checks : true ,
221239 ..Default :: default ( )
222240 } ;
223241
@@ -226,16 +244,9 @@ async fn validate_transforms_no_environment(
226244 }
227245 }
228246
229- if !warnings. is_empty ( ) {
230- fmt. title ( "Transform warnings" ) ;
231- fmt. sub_warning ( & warnings) ;
232- }
233-
234- if errors. is_empty ( ) && warnings. is_empty ( ) {
247+ if errors. is_empty ( ) {
235248 fmt. success ( "Transform configuration" ) ;
236249 true
237- } else if errors. is_empty ( ) {
238- !opts. deny_warnings
239250 } else {
240251 fmt. title ( "Transform errors" ) ;
241252 fmt. sub_error ( errors) ;
0 commit comments