Exemple #1
0
        public static string Get(ExternalVariable property)
        {
            var attr         = EnvironmentVariableAttribute.Get(property);
            var valueFromEnv = Environment.GetEnvironmentVariable(attr.Name);

            if (valueFromEnv == null)
            {
                throw new Exception($"Environment Variable `{attr.Name}` could not be found. The value can be found in the password store under `{attr.LastPassName}`");
            }

            return(valueFromEnv);
        }
Exemple #2
0
        public static void LogMissingVariables()
        {
            var missingVariables = Enum.GetValues(typeof(ExternalVariable)).Cast <ExternalVariable>()
                                   .Select(prop => EnvironmentVariableAttribute.Get(prop))
                                   .Where(attr => Environment.GetEnvironmentVariable(attr.Name) == null)
                                   .ToList();

            if (!missingVariables.Any())
            {
                return;
            }

            Log.Warn($"The following environment variables could not be found: " +
                     $"\n{string.Join("\n", missingVariables.Select(var => $" - {var.Name}\t\tSource: {var.LastPassName}"))}" +
                     $"\n\nTests that rely on these variables are likely to fail.");
        }