@@ -8,13 +8,12 @@ use jsonschema::{validator_for, Validator};
88use serde:: Deserialize ;
99use serde_json:: { json, Value } ;
1010
11- use crate :: services:: default_paths:: resolve_sce_default_locations;
11+ use crate :: services:: default_paths:: { resolve_sce_default_locations, schema , RepoPaths } ;
1212use crate :: services:: output_format:: OutputFormat ;
1313use crate :: services:: style:: { self } ;
1414
1515pub const NAME : & str = "config" ;
1616#[ cfg_attr( not( test) , allow( dead_code) ) ]
17- const GENERATED_CONFIG_SCHEMA_PATH : & str = "config/schema/sce-config.schema.json" ;
1817pub ( crate ) const SCE_CONFIG_SCHEMA_JSON : & str =
1918 include_str ! ( "../../assets/generated/config/schema/sce-config.schema.json" ) ;
2019
@@ -951,7 +950,7 @@ where
951950 } ) ;
952951 }
953952
954- let local_path = cwd . join ( ".sce" ) . join ( "config.json" ) ;
953+ let local_path = RepoPaths :: new ( cwd ) . sce_config_file ( ) ;
955954 if path_exists ( & local_path) {
956955 discovered_paths. push ( LoadedConfigPath {
957956 path : local_path,
@@ -981,6 +980,10 @@ fn config_schema_validator() -> &'static Validator {
981980 } )
982981}
983982
983+ fn generated_config_schema_path ( ) -> String {
984+ format ! ( "{}/{}" , schema:: SCHEMA_DIR , schema:: SCE_CONFIG_SCHEMA )
985+ }
986+
984987fn validate_config_value_against_schema ( value : & Value , path : & Path ) -> Result < ( ) > {
985988 let mut errors = config_schema_validator ( )
986989 . iter_errors ( value)
@@ -992,10 +995,11 @@ fn validate_config_value_against_schema(value: &Value, path: &Path) -> Result<()
992995 }
993996
994997 errors. sort ( ) ;
998+ let generated_schema_path = generated_config_schema_path ( ) ;
995999 bail ! (
9961000 "Config file '{}' failed schema validation against generated schema '{}': {}" ,
9971001 path. display( ) ,
998- GENERATED_CONFIG_SCHEMA_PATH ,
1002+ generated_schema_path ,
9991003 errors. join( " | " )
10001004 ) ;
10011005}
@@ -1960,13 +1964,13 @@ fn abbreviate_text_value(value: &str) -> String {
19601964#[ cfg( test) ]
19611965mod tests {
19621966 use super :: {
1963- format_show_output, format_validate_output, resolve_observability_runtime_config_with ,
1964- resolve_optional_auth_config_value , resolve_runtime_config_with , AuthConfigKeySpec ,
1965- BashPolicyConfig , ConfigPathSource , ConfigRequest , CustomBashPolicyEntry , FileConfigValue ,
1966- LoadedConfigPath , LogFileMode , LogFormat , LogLevel , OtlpProtocol , ReportFormat ,
1967- ResolvedObservabilityRuntimeConfig , ResolvedOptionalValue , ResolvedValue , RuntimeConfig ,
1968- ValueSource , DEFAULT_OTEL_ENDPOINT , GENERATED_CONFIG_SCHEMA_PATH , SCE_CONFIG_SCHEMA_JSON ,
1969- WORKOS_CLIENT_ID_BAKED_DEFAULT , WORKOS_CLIENT_ID_KEY ,
1967+ format_show_output, format_validate_output, generated_config_schema_path ,
1968+ resolve_observability_runtime_config_with , resolve_optional_auth_config_value ,
1969+ resolve_runtime_config_with , AuthConfigKeySpec , BashPolicyConfig , ConfigPathSource ,
1970+ ConfigRequest , CustomBashPolicyEntry , FileConfigValue , LoadedConfigPath , LogFileMode ,
1971+ LogFormat , LogLevel , OtlpProtocol , ReportFormat , ResolvedObservabilityRuntimeConfig ,
1972+ ResolvedOptionalValue , ResolvedValue , RuntimeConfig , ValueSource , DEFAULT_OTEL_ENDPOINT ,
1973+ SCE_CONFIG_SCHEMA_JSON , WORKOS_CLIENT_ID_BAKED_DEFAULT , WORKOS_CLIENT_ID_KEY ,
19701974 } ;
19711975 use anyhow:: Result ;
19721976 use serde_json:: { json, Value } ;
@@ -2334,7 +2338,7 @@ mod tests {
23342338 assert ! ( error
23352339 . to_string( )
23362340 . contains( "failed schema validation against generated schema" ) ) ;
2337- assert ! ( error. to_string( ) . contains( GENERATED_CONFIG_SCHEMA_PATH ) ) ;
2341+ assert ! ( error. to_string( ) . contains( & generated_config_schema_path ( ) ) ) ;
23382342 assert ! ( error. to_string( ) . contains( "unknown" ) ) ;
23392343 }
23402344
@@ -3066,7 +3070,7 @@ mod tests {
30663070 assert ! ( error
30673071 . to_string( )
30683072 . contains( "failed schema validation against generated schema" ) ) ;
3069- assert ! ( error. to_string( ) . contains( GENERATED_CONFIG_SCHEMA_PATH ) ) ;
3073+ assert ! ( error. to_string( ) . contains( & generated_config_schema_path ( ) ) ) ;
30703074
30713075 std:: fs:: remove_file ( & path) . ok ( ) ;
30723076 std:: fs:: remove_dir ( & temp_dir) . ok ( ) ;
0 commit comments