@@ -13,33 +13,43 @@ public static class Config
1313 {
1414 private const string VariableGroupName = "variable" ;
1515 private const string VariablePattern = $ "\\ $\\ ((?<{ VariableGroupName } >[\\ w:\\ -.|]+)\\ )";
16- private static Lazy < JObject > ManifestVersions { get ; } = new Lazy < JObject > ( ( ) => LoadManifest ( "manifest.versions.json" ) ) ;
16+ private static Lazy < JObject > ManifestVersions { get ; } =
17+ new Lazy < JObject > ( ( ) => LoadManifest ( "manifest.versions.json" ) ) ;
1718
1819 public static Lazy < JObject > Manifest { get ; } = new Lazy < JObject > ( ( ) => LoadManifest ( "manifest.json" ) ) ;
19- public static string SourceRepoRoot { get ; } = Environment . GetEnvironmentVariable ( "SOURCE_REPO_ROOT" ) ?? string . Empty ;
20+ public static string SourceRepoRoot { get ; } =
21+ GetEnvironmentVariableOrDefault ( "SOURCE_REPO_ROOT" , string . Empty ) ;
2022 public static bool IsHttpVerificationDisabled { get ; } =
2123 Environment . GetEnvironmentVariable ( "DISABLE_HTTP_VERIFICATION" ) != null ;
22- public static bool PullImages { get ; } = Environment . GetEnvironmentVariable ( "PULL_IMAGES" ) != null ;
24+ public static bool PullImages { get ; } =
25+ ! string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "PULL_IMAGES" ) ) ;
2326 public static bool IsNightlyRepo { get ; } = GetIsNightlyRepo ( ) ;
2427 public static bool IsRunningInContainer { get ; } =
25- Environment . GetEnvironmentVariable ( "RUNNING_TESTS_IN_CONTAINER" ) != null ;
26- public static string RepoPrefix { get ; } = Environment . GetEnvironmentVariable ( "REPO_PREFIX" ) ?? string . Empty ;
28+ ! string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "RUNNING_TESTS_IN_CONTAINER" ) ) ;
29+ public static string RepoPrefix { get ; } = GetEnvironmentVariableOrDefault ( "REPO_PREFIX" , string . Empty ) ;
2730 public static string Registry { get ; } =
28- Environment . GetEnvironmentVariable ( "REGISTRY" ) ?? ( string ) Manifest . Value [ "registry" ] ;
31+ GetEnvironmentVariableOrDefault ( "REGISTRY" , ( string ) Manifest . Value [ "registry" ] ) ;
2932 public static string CacheRegistry { get ; } =
30- Environment . GetEnvironmentVariable ( "CACHE_REGISTRY" ) ?? string . Empty ;
33+ GetEnvironmentVariableOrDefault ( "CACHE_REGISTRY" , string . Empty ) ;
3134 public static string [ ] OsNames { get ; } =
32- ( Environment . GetEnvironmentVariable ( "IMAGE_OS_NAMES" ) ?? string . Empty ) . Split ( "," , StringSplitOptions . RemoveEmptyEntries ) ;
35+ GetEnvironmentVariableOrDefault ( "IMAGE_OS_NAMES" , string . Empty )
36+ . Split ( "," , StringSplitOptions . RemoveEmptyEntries ) ;
3337 public static string SourceBranch { get ; } =
34- Environment . GetEnvironmentVariable ( "SOURCE_BRANCH" ) ?? string . Empty ;
38+ GetEnvironmentVariableOrDefault ( "SOURCE_BRANCH" , string . Empty ) ;
3539 public static string InternalAccessToken { get ; } =
36- Environment . GetEnvironmentVariable ( "INTERNAL_ACCESS_TOKEN" ) ?? string . Empty ;
40+ GetEnvironmentVariableOrDefault ( "INTERNAL_ACCESS_TOKEN" , string . Empty ) ;
3741 public static string [ ] Paths { get ; } =
3842 Environment . GetEnvironmentVariable ( "DOCKERFILE_PATHS" ) ?
39- . Split ( ',' , StringSplitOptions . RemoveEmptyEntries ) ?? Array . Empty < string > ( ) ;
43+ . Split ( ',' , StringSplitOptions . RemoveEmptyEntries ) ?? [ ] ;
4044
4145 public static bool IsInternal { get ; } =
42- Environment . GetEnvironmentVariable ( "INTERNAL_TESTING" ) != null ;
46+ ! string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "INTERNAL_TESTING" ) ) ;
47+
48+ private static string GetEnvironmentVariableOrDefault ( string variableName , string defaultValue )
49+ {
50+ string value = Environment . GetEnvironmentVariable ( variableName ) ;
51+ return ! string . IsNullOrEmpty ( value ) ? value : defaultValue ;
52+ }
4353
4454 private static bool GetIsNightlyRepo ( )
4555 {
0 commit comments