public void CanResolveUnixPath() { HomePath path = new HomePath("~/src"); path.Resolve().StartsWith("~").IsFalse(); path.Path.StartsWith("~/").IsTrue(); path.Resolve().StartsWith(BamHome.UserHome); Message.PrintLine("Unix path: {0}", ConsoleColor.Cyan, path.Resolve()); }
private static OktaClientConfiguration GetConfigurationOrDefault(OktaClientConfiguration apiClientConfiguration = null) { string configurationFileRoot = Directory.GetCurrentDirectory(); var homeOktaYamlLocation = HomePath.Resolve("~", ".okta", "okta.yaml"); var applicationAppSettingsLocation = Path.Combine(configurationFileRoot ?? string.Empty, "appsettings.json"); var applicationOktaYamlLocation = Path.Combine(configurationFileRoot ?? string.Empty, "okta.yaml"); var configBuilder = new ConfigurationBuilder() .AddYamlFile(homeOktaYamlLocation, optional: true) .AddJsonFile(applicationAppSettingsLocation, optional: true) .AddYamlFile(applicationOktaYamlLocation, optional: true) .AddEnvironmentVariables("okta", "_", root: "okta") .AddEnvironmentVariables("okta_testing", "_", root: "okta") .AddObject(apiClientConfiguration, root: "okta:client") .AddObject(apiClientConfiguration, root: "okta:testing") .AddObject(apiClientConfiguration); var compiledConfig = new OktaClientConfiguration(); configBuilder.Build().GetSection("okta").GetSection("client").Bind(compiledConfig); configBuilder.Build().GetSection("okta").GetSection("testing").Bind(compiledConfig); configBuilder.Build().Bind(compiledConfig); return(compiledConfig); }
private static FlexibleConfiguration.Abstractions.IConfigurationRoot CompileFromConfigurationSources(OktaClientConfiguration apiClientConfiguration = null) { string configurationFileRoot = Directory.GetCurrentDirectory(); var homeOktaYamlLocation = HomePath.Resolve("~", ".okta", "okta.yaml"); var applicationAppSettingsLocation = Path.Combine(configurationFileRoot ?? string.Empty, "appsettings.json"); var applicationOktaYamlLocation = Path.Combine(configurationFileRoot ?? string.Empty, "okta.yaml"); var configBuilder = new ConfigurationBuilder() .AddYamlFile(homeOktaYamlLocation, optional: true) .AddJsonFile(applicationAppSettingsLocation, optional: true) .AddYamlFile(applicationOktaYamlLocation, optional: true) .AddEnvironmentVariables("okta", "_", root: "okta") .AddObject(apiClientConfiguration, root: "okta:client"); return(configBuilder.Build()); }