Skip to content

Commit

Permalink
Clean up the code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
jaffinito committed Aug 1, 2023
1 parent 63b3c3c commit 9a82eae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build/S3Validator/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace S3Validator
{
public class Options
{
[Option('v', "version", Required = true, HelpText = "Version to validate")]
[Option('v', "version", Required = true, HelpText = "Version to validate.")]
public required string Version { get; set; }

[Option('c', "config", Default = "config.yml", Required = false, HelpText = "Path to the configuration file.")]
Expand Down
8 changes: 3 additions & 5 deletions build/S3Validator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ static void Main(string[] args)
.WithNotParsed(HandleParseError);

var version = result.Value.Version;

var configuration = LoadConfiguration(result.Value.ConfigurationPath);

var isValid = Validate(version, configuration);

if (!isValid)
{
ExitWithError(ExitCode.Error, "Validation failed for an unknown reason.");
Expand Down Expand Up @@ -73,7 +70,7 @@ private static bool Validate(string version, Configuration configuration)
status = "FileSize";
}

results.Add($"{status.PadRight(12)}{task.Result.RequestMessage?.RequestUri}");
results.Add($"{status,-12}{task.Result.RequestMessage?.RequestUri}");
}

if (!isValid)
Expand All @@ -84,7 +81,6 @@ private static bool Validate(string version, Configuration configuration)
return isValid;
}


private static void ValidateOptions(Options opts)
{
if (string.IsNullOrWhiteSpace(opts.Version)
Expand Down Expand Up @@ -125,6 +121,8 @@ public static void ExitWithError(ExitCode exitCode, string message)

public static class Helpers
{

// Simplfy the TryGetValue into something more usable.
public static T? GetValue<T>(this HttpRequestOptions options, string key)
{
options.TryGetValue(new HttpRequestOptionsKey<T>(key), out var value);
Expand Down
6 changes: 5 additions & 1 deletion build/S3Validator/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2020 New Relic, Inc. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

# BaseUrl
# Should include the full path the to root of the agent folder - no trailing slash. Example: https://download.newrelic.com/dot_net_agent
base-url: https://download.newrelic.com/dot_net_agent
Expand All @@ -11,7 +14,8 @@ directory-list:
- previous_releases/{version}

# FileList
# Use the relative path to each file and a minimum acceptable size. Do not use the exact size - this file should not need to be update just to change sizes under normal circumstances.
# Use the relative path, starting at each directory in DirectoryList, to each file and a minimum acceptable size.
# Do not use the exact size - this file should not need to be update just to change sizes under normal circumstances.
# Use '{version}' in places where the version would be found. This will be replaced with the version supplied to the tool on execution.
# Example: 'NewRelicDotNetAgent_10.13.0_x64.msi' becomes 'NewRelicDotNetAgent_{version}_x64.msi'
file-list:
Expand Down

0 comments on commit 9a82eae

Please sign in to comment.