Skip to content

Commit

Permalink
Add Collection Node Copy
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Jun 4, 2024
1 parent 7470e8d commit 7a98692
Show file tree
Hide file tree
Showing 119 changed files with 471 additions and 364 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ dotnet_diagnostic.IDE0083.severity = warning # Use pattern matching
dotnet_diagnostic.IDE0084.severity = warning # Use IsNot
dotnet_diagnostic.IDE0090.severity = warning # Use new(...)
dotnet_diagnostic.IDE1006.severity = warning # Naming styles Task Open() Task OpenAsync()
dotnet_diagnostic.IDE1006WithoutSuggestion.severity = suggestion
# dotnet_diagnostic.IDE1006WithoutSuggestion.severity = suggestion


# Microsoft.VisualStudio.Threading.Analyzers
Expand Down
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,34 @@
// },
"enableStepFiltering": false
},
{
"name": "Copy User Product Collection",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/Stars.Console/bin/Debug/net6.0/Stars.dll",
"args": [
"copy",
"-v",
"-r",
"4",
"--output",
"/tmp/stars",
"s3://dc-acceptance-catalog/users/evopm1/products/evopm1-product-test_upload-product1/evopm1-product-test_upload-product1.json"
],
"cwd": "${workspaceFolder}/src",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false,
"logging": {
"moduleLoad": false
},
"justMyCode": false,
"requireExactSource": false,
"enableStepFiltering": false
},

{
"name": ".NET Core Attach",
"type": "coreclr",
Expand Down
2 changes: 1 addition & 1 deletion src/Stars.Console.Tests/Utilities/XunitTextWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Stars.Console.Tests
public class XunitTextWriter : TextWriter
{
private readonly ITestOutputHelper _output;
private readonly StringBuilder _sb = new StringBuilder();
private readonly StringBuilder _sb = new();

public XunitTextWriter(ITestOutputHelper output)
{
Expand Down
32 changes: 16 additions & 16 deletions src/Stars.Console/ConsoleCredentialsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ namespace Terradue.Stars.Console.Operations
{
internal class ConsoleCredentialsManager : ConfigurationCredentialsManager
{
private readonly IConsole console;
private readonly ConsoleUserSettings consoleUserSettings;
private readonly IConsole _console;
private readonly ConsoleUserSettings _consoleUserSettings;

public ConsoleCredentialsManager(IOptions<CredentialsOptions> options, IConsole console, ConsoleUserSettings consoleUserSettings, ILogger<ConsoleCredentialsManager> logger) : base(options, logger)
{
this.console = console;
this.consoleUserSettings = consoleUserSettings;
_console = console;
_consoleUserSettings = consoleUserSettings;
}

public override NetworkCredential GetCredential(Uri uri, string authType)
Expand All @@ -39,14 +39,14 @@ public override NetworkCredential GetCredential(Uri uri, string authType)
catch { }
if (cred == null && authority.Length > 2 && uri.UserInfo != "preauth")
{
if (!console.IsInputRedirected)
if (!_console.IsInputRedirected)
{
console.WriteLine("No credentials found for {0}. Please provide one.", uriCut);
_console.WriteLine("No credentials found for {0}. Please provide one.", uriCut);
cred = PromptCredentials(uriCut, authType);
}
if (cred != null)
{
base.CacheCredential(uriCut, authType, cred);
CacheCredential(uriCut, authType, cred);
PromptSaveCredentials(cred, uriCut, authType);
}
}
Expand All @@ -59,8 +59,8 @@ private void PromptSaveCredentials(ICredentials cred, Uri uri, string authType)
int i = 3;
while ((string.IsNullOrEmpty(answer) || !"yn".Contains(answer[0])) && i > 0)
{
console.Write("Save credentials in user settings? [y/N]:");
answer = console.In.ReadLine().ToLower();
_console.Write("Save credentials in user settings? [y/N]:");
answer = _console.In.ReadLine().ToLower();
i--;
}
if (answer == "y")
Expand All @@ -70,12 +70,12 @@ private void PromptSaveCredentials(ICredentials cred, Uri uri, string authType)
private void SaveCredentials(ICredentials cred, Uri uri, string authType)
{
CredentialsConfigurationSection credConfigSection = cred.ToCredentialsConfigurationSection(uri, authType);
consoleUserSettings.AddOrUpdateSetting("Credentials:" + Guid.NewGuid().ToString(), credConfigSection);
_consoleUserSettings.AddOrUpdateSetting("Credentials:" + Guid.NewGuid().ToString(), credConfigSection);
}

private NetworkCredential PromptCredentials(Uri uri, string authType)
{
if (console.IsInputRedirected) return null;
if (_console.IsInputRedirected) return null;

string usernameLabel = "username";
string passwordLabel = "password";
Expand All @@ -90,16 +90,16 @@ private NetworkCredential PromptCredentials(Uri uri, string authType)
int rtry = 3;
while (string.IsNullOrEmpty(username) && rtry > 0)
{
console.Write(usernameLabel + ": ");
username = console.In.ReadLine();
_console.Write(usernameLabel + ": ");
username = _console.In.ReadLine();
rtry--;
}
if (string.IsNullOrEmpty(username))
{
console.WriteLine("No input. Skipping");
_console.WriteLine("No input. Skipping");
return null;
}
console.Write(passwordLabel + ": ");
_console.Write(passwordLabel + ": ");
var pass = string.Empty;
ConsoleKey key;
do
Expand All @@ -118,7 +118,7 @@ private NetworkCredential PromptCredentials(Uri uri, string authType)
pass += keyInfo.KeyChar;
}
} while (key != ConsoleKey.Enter);
console.WriteLine();
_console.WriteLine();

return new NetworkCredential(username, pass);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Stars.Console/ConsoleUserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Terradue.Stars.Console
{
internal class ConsoleUserSettings
{
private readonly string userSettingsFilePath = Path.Join(System.Environment.GetEnvironmentVariable("HOME"), ".config", "Stars", "usersettings.json");
private readonly string userSettingsFilePath = Path.Join(Environment.GetEnvironmentVariable("HOME"), ".config", "Stars", "usersettings.json");
private readonly ILogger logger;
private readonly IConfigurationRoot configuration;

Expand Down
2 changes: 1 addition & 1 deletion src/Stars.Console/Operations/BaseOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private ServiceCollection RegisterServices()
foreach (var yamlFilename in Directory.EnumerateFiles("/etc/Stars/conf.d", "*.json", SearchOption.TopDirectoryOnly))
builder.AddNewtonsoftJsonFile(yamlFilename);
}
builder.AddNewtonsoftJsonFile(Path.Join(System.Environment.GetEnvironmentVariable("HOME"), ".config", "Stars", "usersettings.json"), optional: true)
builder.AddNewtonsoftJsonFile(Path.Join(Environment.GetEnvironmentVariable("HOME"), ".config", "Stars", "usersettings.json"), optional: true)
.AddNewtonsoftJsonFile("appsettings.json", optional: true);

//only add secrets in development
Expand Down
Loading

0 comments on commit 7a98692

Please sign in to comment.