78 instantiations of ConfigSource
aspire (6)
Configuration\ConfigSourceService.cs (6)
177var source = new ConfigSource 216return _creationSource = new ConfigSource { OptOut = true }; 330var source = new ConfigSource 417var binding = new ConfigSource 612var identity = new ConfigSource 720var identity = new ConfigSource
Aspire.Cli.Tests (72)
Backchannel\AppHostConnectionResolverTests.cs (1)
30await TestConfigSourceServices.SaveBindingAsync(new ConfigSource
Commands\AgentInitCommandTests.cs (1)
382new ConfigSource { Repository = "https://git.example/configuration", Path = "aspire.config.json", AppliedVersion = "version-1" },
Commands\ConfigSourceCommandTests.cs (16)
28private static readonly ConfigSource s_source = new() 43var source = new ConfigSource 100var source = new ConfigSource 361var source = new ConfigSource 491await TestConfigSourceServices.SaveBindingAsync(new() 678new ConfigSource { Repository = "https://parent.example/configuration", Path = "parent.json", AppliedVersion = "parent-version" }, 703await TestConfigSourceServices.SaveBindingAsync(new ConfigSource { OptOut = true }, workspace.WorkspaceRoot, CancellationToken.None); 829? new ConfigSource 835: new ConfigSource { OptOut = true }; 941var selectedSource = new ConfigSource { Repository = s_source.Repository, Path = "selected.json", AppliedVersion = s_source.AppliedVersion }; 1028var selectedSource = new ConfigSource { Repository = s_source.Repository, Path = "selected.json", AppliedVersion = s_source.AppliedVersion }; 1068var selectedSource = new ConfigSource 1200Assert.Equivalent(accepted ? s_source : new ConfigSource { OptOut = true }, AspireConfigFile.Load(output)?.ConfigSource, strict: true); 1221Assert.Equivalent(accepted ? s_source : new ConfigSource { OptOut = true }, AspireConfigFile.Load(workspace.Path)!.ConfigSource, strict: true); 1275await TestConfigSourceServices.SaveBindingAsync(new ConfigSource 1465? new ConfigSource
Commands\NewCommandLocalTemplateTests.InitConfig.cs (1)
143var listed = await store.ListAsync(new ConfigSource
Commands\NewCommandLocalTemplateTests.SourceListGit.cs (1)
315var source = new ConfigSource { Repository = repository.FullName, Path = "teams/platform.json", Ref = "config-preview" };
Configuration\ConfigSourceServiceGitTests.cs (17)
51var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 94var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 148var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 175await TestConfigSourceServices.SaveBindingAsync(new ConfigSource 389var source = new ConfigSource { Repository = workspace.Path, Path = path }; 413var source = new ConfigSource { Repository = repository.FullName, Path = path }; 441var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 475new() { Repository = workspace.Path, Path = AspireConfigFile.FileName }, 506new() { Repository = workspace.Path, Path = AspireConfigFile.FileName }, workspace.CreateDirectory("cache").FullName, TestContext.Current.CancellationToken)); 516new() { Repository = workspace.Path, Path = AspireConfigFile.FileName }, workspace.CreateDirectory("cache").FullName, TestContext.Current.CancellationToken)); 537new() { Repository = workspace.Path, Path = AspireConfigFile.FileName, Ref = reference }, 555new() { Repository = workspace.Path, Path = AspireConfigFile.FileName, Ref = expectedCommit }, 567var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 587var pinned = await client.CheckAsync(new() { Repository = source.Repository, Path = source.Path, Ref = original.Commit }, 613new() { Repository = workspace.Path, Path = AspireConfigFile.FileName, Ref = reference }, 636var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 667var source = new ConfigSource
Configuration\ConfigSourceServiceTests.cs (33)
162Assert.False(Directory.Exists(service.GetCacheDirectory(new ConfigSource 233await TestConfigSourceServices.SaveBindingAsync(new ConfigSource 299var globalSource = new ConfigSource 306var ignoredSource = new ConfigSource { Repository = s_appliedSource.Repository, Path = "ignored.json", AppliedVersion = "ignored-version" }; 393await TestConfigSourceServices.SaveBindingAsync(new ConfigSource 402await TestConfigSourceServices.SaveBindingAsync(new ConfigSource 475await TestConfigSourceServices.SaveBindingAsync(new ConfigSource 638private static readonly ConfigSource s_source = new() 643private static readonly ConfigSource s_appliedSource = new() 714var source = new ConfigSource 732new ConfigSource { Repository = repository, Path = s_source.Path }.Validate(); 741new ConfigSource { Repository = repository.FullName, Path = s_source.Path }.Validate(); 760Assert.Throws<ConfigSourceException>(() => new ConfigSource { Repository = repository, Path = s_source.Path }.Validate()); 769Assert.Throws<ConfigSourceException>(() => new ConfigSource { Repository = repository, Path = s_source.Path }.Validate()); 783Assert.Throws<ConfigSourceException>(() => new ConfigSource { Repository = s_source.Repository, Path = path }.Validate()); 795new ConfigSource { Repository = s_source.Repository, Path = s_source.Path, Ref = reference }.Validate(); 814Assert.Throws<ConfigSourceException>(() => new ConfigSource { Repository = s_source.Repository, Path = s_source.Path, Ref = reference }.Validate()).Message); 827var expected = new ConfigSource { Repository = s_source.Repository, Path = path ?? AspireConfigFile.FileName, Ref = "preview" }; 861Assert.Equivalent(detected ? new ConfigSource { Repository = ConfigSourceService.MicrosoftRepository, Path = AspireConfigFile.FileName } : null, 1095Assert.Equivalent(accepted ? new ConfigSource { Repository = ConfigSourceService.MicrosoftRepository, Path = AspireConfigFile.FileName } : new ConfigSource { OptOut = true }, 1143await service.MaterializeAsync(new ConfigSource { OptOut = true }, workspace.WorkspaceRoot, CancellationToken.None); 1166service.MaterializeAsync(optOut ? new ConfigSource { OptOut = true } : s_source, 1601await TestConfigSourceServices.SaveBindingAsync(new ConfigSource 1644new ConfigSource { Repository = s_source.Repository, Path = s_source.Path, AppliedVersion = "version-2" }, 1730var source = new ConfigSource { Repository = repository, Path = AspireConfigFile.FileName }; 1796await TestConfigSourceServices.SaveBindingAsync(new() 1910var changed = new ConfigSource 2054var invalid = new ConfigSource { Repository = repository, Path = s_source.Path, Ref = gitRef, AppliedVersion = "version-1" }; 2232service.GetCacheDirectory(new() { Repository = s_source.Repository, Path = "other.json" })); 2234service.GetCacheDirectory(new() { Repository = s_source.Repository, Path = s_source.Path, Ref = "preview" })); 2236service.GetCacheDirectory(new() { Repository = s_source.Repository, Path = s_source.Path, Ref = "preview" }), 2237service.GetCacheDirectory(new() { Repository = s_source.Repository, Path = s_source.Path, Ref = "main" }));
TestServices\TestConfigSourceServices.cs (2)
52await SaveBindingAsync(new ConfigSource 119var source = new ConfigSource
120 references to ConfigSource
aspire (50)
Commands\InitCommand.cs (1)
163var configSource = await ConfigSources.SelectForInitializationAsync(configurationDirectory, parseResult, cancellationToken);
Commands\NewCommand.cs (4)
590var configSource = await ConfigSources.ResolveAndAcquireConfigSourceAsync(parseResult, ConfigSourceStrings.NewUseSourcePrompt, cancellationToken); 731private async Task<CommandResult> CreateFromSourceAsync(TemplateSource source, ConfigSource? configSource, ParseResult parseResult, CancellationToken cancellationToken) 766ITemplate template, ConfigSource? configSource, ParseResult parseResult, CancellationToken cancellationToken) 793private async Task<CommandResult> CompleteTemplateAsync(TemplateResult templateResult, ConfigSource? configSource, ParseResult parseResult, CancellationToken cancellationToken)
Commands\TemplateManagementCommand.cs (1)
97var source = !json || parseResult.GetValue(ConfigSourceService.s_useSourceOption) is true
Configuration\AspireConfigFile.cs (2)
68[JsonPropertyName(ConfigSource.SectionName)] 71public ConfigSource? ConfigSource { get; set; }
Configuration\ConfigSource.cs (4)
43public static bool HasSameIdentity(ConfigSource first, ConfigSource second) 74internal sealed record ConfigSourceMetadata(ConfigSource Source, string Commit, string Version, DateTimeOffset FetchedAt); 77ConfigSource Source, string Commit, string Version, DateTimeOffset CheckedAt, string? ComparedAppliedVersion);
Configuration\ConfigSourceService.cs (36)
45private ConfigSource? _creationSource; 154public Task<ConfigSource?> ResolveAndAcquireConfigSourceAsync(ParseResult parseResult, string consentPrompt, CancellationToken cancellationToken) => 157internal async Task<ConfigSource?> ResolveAndAcquireConfigSourceAsync( 177var source = new ConfigSource 223private void DisplayConfigSourceDetails(ConfigSource source, string origin) 242private string? GetReadmeUrl(ConfigSource source) => 246public async Task<ConfigSource?> SelectForInitializationAsync( 252if (configuration is not null && configuration.ContainsKey(GetKey(configuration, ConfigSource.SectionName))) 261public async Task MaterializeAsync(ConfigSource source, DirectoryInfo projectDirectory, CancellationToken cancellationToken) 273if (configuration is not null && configuration.ContainsKey(GetKey(configuration, ConfigSource.SectionName))) 285var source = await ResolveAndAcquireConfigSourceAsync(parseResult, ConfigSourceStrings.UpdateUseSourcePrompt, cancellationToken); 292private async Task ApplySourceAsync(ConfigSource source, string path, CancellationToken cancellationToken) 304configuration[GetKey(configuration, ConfigSource.SectionName)] = new JsonObject { ["optOut"] = true }; 330var source = new ConfigSource 339internal async Task<JsonObject> GetTemplateSourcesAsync(ConfigSource source, CancellationToken cancellationToken) 376private async Task<bool> ApplySnapshotAsync(ConfigSource source, ConfigSourceSnapshot snapshot, string path, CancellationToken cancellationToken) 387if (ReadBinding(configuration) is { } current && !ConfigSource.HasSameIdentity(current, source)) 417var binding = new ConfigSource 424configuration[GetKey(configuration, ConfigSource.SectionName)] = JsonSerializer.SerializeToNode(binding, JsonSourceGenerationContext.Default.ConfigSource); 469var source = configPath is null ? null : await ReadBindingAsync(configPath, cancellationToken); 516internal async Task<ConfigSource?> ReadBindingAsync(string configPath, CancellationToken cancellationToken) 545private static ConfigSource? ReadBinding(JsonObject? config) 551var sourceProperty = config.FirstOrDefault(p => p.Key.Equals(ConfigSource.SectionName, StringComparison.OrdinalIgnoreCase)); 577internal string GetCacheDirectory(ConfigSource source) 583internal Task<ConfigSourceSnapshot> AcquireAsync(ConfigSource source, bool force, CancellationToken cancellationToken) => 587ConfigSource source, bool force, bool allowInteractiveInput, CancellationToken cancellationToken) 612var identity = new ConfigSource 682private async Task<ConfigSourceCheckMetadata> CheckVersionAsync(ConfigSource source, CancellationToken cancellationToken) 701if (previous is null || previous.Source is null || !ConfigSource.HasSameIdentity(previous.Source, source) 720var identity = new ConfigSource 739ConfigSource source, string directory, bool allowInteractiveInput, CancellationToken cancellationToken) 755if (configuration.Any(p => p.Key.Equals(ConfigSource.SectionName, StringComparison.OrdinalIgnoreCase) 756|| p.Key.StartsWith(ConfigSource.SectionName + ":", StringComparison.OrdinalIgnoreCase) 757|| p.Key.StartsWith(ConfigSource.SectionName + ".", StringComparison.OrdinalIgnoreCase))) 788private async Task<(string Commit, string Version)> CheckRepositoryAsync(ConfigSource source, string directory, CancellationToken cancellationToken) 814IGitClient client, ConfigSource source, string directory, bool allowInteractive, CancellationToken cancellationToken)
JsonSourceGenerationContext.cs (1)
40[JsonSerializable(typeof(ConfigSource))]
Templating\TemplateSourceStore.cs (1)
19public async Task<JsonObject> ListAsync(ConfigSource? configSource, CancellationToken cancellationToken)
Aspire.Cli.Tests (70)
Commands\ConfigSourceCommandTests.cs (15)
28private static readonly ConfigSource s_source = new() 43var source = new ConfigSource 100var source = new ConfigSource 361var source = new ConfigSource 828var expectedSource = accepted 941var selectedSource = new ConfigSource { Repository = s_source.Repository, Path = "selected.json", AppliedVersion = s_source.AppliedVersion }; 962Assert.True(ConfigSource.HasSameIdentity(selectedSource, source) || ConfigSource.HasSameIdentity(s_source, source)); 1028var selectedSource = new ConfigSource { Repository = s_source.Repository, Path = "selected.json", AppliedVersion = s_source.AppliedVersion }; 1036Assert.True(ConfigSource.HasSameIdentity(selectedSource, source)); 1068var selectedSource = new ConfigSource 1092Assert.True(ConfigSource.HasSameIdentity(selectedSource, source)); 1344ConfigSource? checkedSource = null; 1376Assert.True(ConfigSource.HasSameIdentity(s_source, checkedSource)); 1388Assert.True(ConfigSource.HasSameIdentity(s_source, source));
Commands\NewCommandLocalTemplateTests.SourceListGit.cs (3)
288TemporaryWorkspace workspace, TestInteractionService interaction, TestGitCommandRunner recording, ConfigSource source) 310private async Task<(ConfigSource Source, string Commit, string Version)> CreateTemplateSourceConfigurationRepositoryAsync( 315var source = new ConfigSource { Repository = repository.FullName, Path = "teams/platform.json", Ref = "config-preview" };
Configuration\ConfigSourceServiceGitTests.cs (10)
51var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 94var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 148var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 173TemporaryWorkspace workspace, IGitClient git, ConfigSource source, TimeProvider clock, CancellationToken token) 389var source = new ConfigSource { Repository = workspace.Path, Path = path }; 413var source = new ConfigSource { Repository = repository.FullName, Path = path }; 441var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 567var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 636var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 667var source = new ConfigSource
Configuration\ConfigSourceServiceTests.cs (30)
142var source = await service.ResolveAndAcquireConfigSourceAsync(ParseConsent(consent), ConfigSourceStrings.NewUseSourcePrompt, CancellationToken.None); 157Assert.True(Assert.IsType<ConfigSource>(source).OptOut); 299var globalSource = new ConfigSource 306var ignoredSource = new ConfigSource { Repository = s_appliedSource.Repository, Path = "ignored.json", AppliedVersion = "ignored-version" }; 328var operations = new ConcurrentQueue<ConfigSource>(); 345Assert.True(ConfigSource.HasSameIdentity(s_appliedSource, Assert.Single(operations))); 415void Record(ConfigSource source) 638private static readonly ConfigSource s_source = new() 643private static readonly ConfigSource s_appliedSource = new() 714var source = new ConfigSource 722Assert.Equal(equal, ConfigSource.HasSameIdentity(s_appliedSource, source)); 723Assert.Equal(equal, ConfigSource.HasSameIdentity(source, s_appliedSource)); 827var expected = new ConfigSource { Repository = s_source.Repository, Path = path ?? AspireConfigFile.FileName, Ref = "preview" }; 859var selected = await service.ResolveAndAcquireConfigSourceAsync(ParseConsent(detected ? true : null), ConfigSourceStrings.NewUseSourcePrompt, CancellationToken.None); 923var source = await service.ResolveAndAcquireConfigSourceAsync(ParseConsent(null), ConfigSourceStrings.NewUseSourcePrompt, CancellationToken.None); 926Assert.True(Assert.IsType<ConfigSource>(source).OptOut); 947var source = await service.ResolveAndAcquireConfigSourceAsync(ParseConsent(false), ConfigSourceStrings.NewUseSourcePrompt, CancellationToken.None); 949Assert.True(Assert.IsType<ConfigSource>(source).OptOut); 1039var source = await service.ResolveAndAcquireConfigSourceAsync(ParseConsent(consent), ConfigSourceStrings.NewUseSourcePrompt, CancellationToken.None); 1110var source = await service.ResolveAndAcquireConfigSourceAsync(ParseConsent(null), ConfigSourceStrings.NewUseSourcePrompt, CancellationToken.None); 1112Assert.False(Assert.IsType<ConfigSource>(source).OptOut); 1290var source = Assert.IsType<ConfigSource>( 1730var source = new ConfigSource { Repository = repository, Path = AspireConfigFile.FileName }; 1776var initialSource = hasAppliedVersion ? s_appliedSource : s_source; 1782Assert.True(ConfigSource.HasSameIdentity(s_appliedSource, second.Metadata.Source)); 1910var changed = new ConfigSource 2040var source = await service.SelectForInitializationAsync(project, ParseConsent(true), CancellationToken.None); 2043Assert.True(ConfigSource.HasSameIdentity(s_source, source)); 2054var invalid = new ConfigSource { Repository = repository, Path = s_source.Path, Ref = gitRef, AppliedVersion = "version-1" };
Interaction\ConsoleInteractionServiceTests.cs (6)
254var source = await service.ResolveAndAcquireConfigSourceAsync(command.Parse("--use-config-source false"), ConfigSourceStrings.NewUseSourcePrompt, CancellationToken.None); 256Assert.True(Assert.IsType<ConfigSource>(source).OptOut); 292var source = await service.ResolveAndAcquireConfigSourceAsync(command.Parse("--use-config-source"), ConfigSourceStrings.NewUseSourcePrompt, CancellationToken.None); 294Assert.False(Assert.IsType<ConfigSource>(source).OptOut); 329var source = await service.ResolveAndAcquireConfigSourceAsync(command.Parse("--use-config-source false"), ConfigSourceStrings.NewUseSourcePrompt, CancellationToken.None); 331Assert.True(Assert.IsType<ConfigSource>(source).OptOut);
TestServices\TestConfigSourceServices.cs (6)
20public static async Task SaveBindingAsync(ConfigSource source, DirectoryInfo projectDirectory, CancellationToken cancellationToken) 41this IGitClient git, ConfigSource source, string directory, CancellationToken cancellationToken, TimeProvider? clock = null) 49this IGitClient git, ConfigSource source, string directory, CancellationToken cancellationToken, TimeProvider? clock = null) 98public Func<ConfigSource, CancellationToken, Task<(string Version, JsonObject Configuration)>> ReadConfiguration { get; set; } 100public Func<ConfigSource, CancellationToken, Task<string>> InspectConfiguration { get; set; } 119var source = new ConfigSource