@@ -69,174 +69,6 @@ private async Task PullSecretsAsync()
6969 var solutionFullName = SolutionSecrets2019Package . _dte . Solution . FullName ;
7070
7171 await _pullCommand . Execute ( solutionFullName ) ;
72-
73- /*
74- SolutionFile solution = new SolutionFile(solutionFullName);
75-
76- ICollection<SecretFile> secretFiles = solution.GetProjectsSecretFiles();
77- if (secretFiles.Count == 0)
78- {
79- await UseStatusBarAsync("No secrets found.");
80- return;
81- }
82-
83- var synchronizationSettings = solution.CustomSynchronizationSettings;
84-
85- // Select the repository for the curront solution
86- IRepository repository = Context.Current.GetRepository(synchronizationSettings) ?? Context.Current.Repository;
87-
88- await UseStatusBarAsync($"Pulling secrets from {repository.RepositoryTypeFullName} for the solution: {solution.Name} ...");
89-
90- if (repository is AzureKeyVaultRepository azureKvRepository)
91- {
92- if (!await azureKvRepository.IsReady())
93- {
94- try
95- {
96- await azureKvRepository.AuthorizeAsync();
97- }
98- catch (AuthenticationFailedException)
99- {
100- System.Windows.MessageBox.Show($"Azure authentication failed. Check your credential in\nTools -> Options -> Azure Service Authentication.", Vsix.Name, MessageBoxButton.OK, MessageBoxImage.Exclamation);
101- await UseStatusBarAsync(String.Empty);
102- return;
103- }
104- catch (Exception)
105- {
106- await UseStatusBarAsync("Error pulling secrets for the solution.");
107- return;
108- }
109- }
110-
111- if (!await azureKvRepository.IsReady())
112- {
113- await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
114- System.Windows.MessageBox.Show($"Access denied to Azure Key Vault {azureKvRepository.RepositoryName}.", Vsix.Name, MessageBoxButton.OK, MessageBoxImage.Exclamation);
115- commandService.OpenOption<Options.AzureKeyVault.AzureKeyVaultOptionPage>();
116- await UseStatusBarAsync("Error pulling secrets for the solution.");
117- return;
118- }
119- }
120- else if (!await Context.Current.Cipher.IsReady() || !await repository.IsReady())
121- {
122- await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
123- System.Windows.MessageBox.Show("You need to configure the solution secrets synchronization before using the Push command.", Vsix.Name, MessageBoxButton.OK, MessageBoxImage.Exclamation);
124- commandService.OpenOption<Options.GitHubGists.GitHubGistsOptionPage>();
125- await UseStatusBarAsync("Error pulling secrets for the solution.");
126- return;
127- }
128-
129-
130- var repositoryFiles = await repository.PullFilesAsync(solution);
131- if (repositoryFiles.Count == 0)
132- {
133- await UseStatusBarAsync("Failed, secrets not found.");
134- return;
135- }
136-
137- // Validate header file
138- HeaderFile header = null;
139- foreach (var file in repositoryFiles)
140- {
141- if (file.name == "secrets" && file.content != null)
142- {
143- try
144- {
145- header = JsonConvert.DeserializeObject<HeaderFile>(file.content);
146- }
147- catch
148- { }
149- break;
150- }
151- }
152-
153- if (header == null)
154- {
155- await UseStatusBarAsync("Error pulling secrets for the solution.");
156- return;
157- }
158-
159- if (!header.IsVersionSupported())
160- {
161- await UseStatusBarAsync("Secrets format is not compatible.");
162- return;
163- }
164-
165- bool failed = false;
166- foreach (var repositoryFile in repositoryFiles)
167- {
168- if (repositoryFile.name != "secrets")
169- {
170- if (repositoryFile.content == null)
171- {
172- continue;
173- }
174-
175- Dictionary<string, string> remoteSecretFiles = null;
176-
177- try
178- {
179- remoteSecretFiles = JsonConvert.DeserializeObject<Dictionary<string, string>>(repositoryFile.content);
180- }
181- catch
182- {
183- await UseStatusBarAsync("Error pulling secrets for the solution.");
184- }
185-
186- if (remoteSecretFiles == null)
187- {
188- failed = true;
189- break;
190- }
191-
192- foreach (var remoteSecretFile in remoteSecretFiles)
193- {
194- string secretFileName = remoteSecretFile.Key;
195-
196- // This check is for compatibility with version 1.0.x
197- if (secretFileName == "content")
198- {
199- secretFileName = "secrets.json";
200- }
201-
202- foreach (var localSecretFile in secretFiles)
203- {
204- if (localSecretFile.ContainerName == repositoryFile.name
205- && localSecretFile.Name == secretFileName)
206- {
207- localSecretFile.Content = remoteSecretFile.Value;
208-
209- bool isFileOk = true;
210- if (repository.EncryptOnClient)
211- {
212- isFileOk = localSecretFile.Decrypt();
213- }
214-
215- if (isFileOk)
216- {
217- solution.SaveSecretSettingsFile(localSecretFile);
218- }
219- else
220- {
221- failed = true;
222- }
223- break;
224- }
225- }
226- }
227-
228- if (failed)
229- {
230- break;
231- }
232- }
233- }
234-
235- if (!failed)
236- await UseStatusBarAsync($"Secrets pulled successfully from {repository.RepositoryTypeFullName}.");
237- else
238- await UseStatusBarAsync("Secrets pull has failed!");
239- */
24072 }
24173
24274 }
0 commit comments