-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proper management of environment (#316)
* #315: Better environment management grid-bot.nomad: ~ Rename meta variable to ENVIRONMENT so it gets resolved to NOMAD_META_ENVIRONMENT ~ Remove need to specify the environment variable. EnvironmentProvider.cs: ~ Basic class that reads either the ENVIRONMENT environment variable or the NOMAD_META_ENVIRONMENT environment variable, or defaults to development. SettingsProviderDefaults.cs: ~ Use EnvironmentProvider. src/Program.cs: ~ Fix an issue with the Redis resolver where it was resolving the wrong environment (for staging builds that were using development builds it was using "development" as the environment instead of the configured environment) * Better versioning ~ Embed build information. ~ Print build metadata ~ Prevent the source revision in the informational version. * Allow configuring of the nomad log level. * Bump Networking to 1.0.5 Fixes one of the issues noted in #316
- Loading branch information
Showing
12 changed files
with
103 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace Grid.Bot; | ||
|
||
using System; | ||
|
||
/// <summary> | ||
/// Provides the environment name for the settings provider. | ||
/// </summary> | ||
public static class EnvironmentProvider | ||
{ | ||
private const string _providerEnvironmentNameEnvVar = "ENVIRONMENT"; | ||
private const string _nomadEnvironmentMetadataEnvVar = $"NOMAD_META_{_providerEnvironmentNameEnvVar}"; | ||
|
||
private const string _defaultEnvironmentName = "development"; | ||
private static readonly string _providerEnvironmentName = | ||
Environment.GetEnvironmentVariable(_providerEnvironmentNameEnvVar) | ||
?? Environment.GetEnvironmentVariable(_nomadEnvironmentMetadataEnvVar) | ||
?? _defaultEnvironmentName; | ||
|
||
/// <summary> | ||
/// Gets the environment name for the settings provider. | ||
/// </summary> | ||
public static string EnvironmentName => _providerEnvironmentName; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<Project> | ||
<Target Name="AddGitMetadaAssemblyAttributes" | ||
BeforeTargets="GetAssemblyAttributes"> | ||
|
||
<!--Executes the Git Commands to get the Hash and Branch--> | ||
<Exec Command="git rev-parse HEAD" ConsoleToMSBuild="true" | ||
StandardOutputImportance="low" IgnoreExitCode="true" Condition=" '$(CommitHash)' == '' " | ||
WorkingDirectory="$(RootDirectory)"> | ||
<Output TaskParameter="ConsoleOutput" PropertyName="CommitHash" /> | ||
</Exec> | ||
<Exec Command="git rev-parse --short HEAD" ConsoleToMSBuild="true" | ||
StandardOutputImportance="low" IgnoreExitCode="true" | ||
Condition=" '$(CommitShortHash)' == '' " WorkingDirectory="$(RootDirectory)"> | ||
<Output TaskParameter="ConsoleOutput" PropertyName="CommitShortHash" /> | ||
</Exec> | ||
<Exec Command="git rev-parse --abbrev-ref HEAD" ConsoleToMSBuild="true" | ||
StandardOutputImportance="low" IgnoreExitCode="true" | ||
Condition=" '$(CommitBranch)' == '' " WorkingDirectory="$(RootDirectory)"> | ||
<Output TaskParameter="ConsoleOutput" PropertyName="CommitBranch" /> | ||
</Exec> | ||
|
||
<ItemGroup> | ||
<AssemblyMetadata Include="BuildTimestamp" | ||
Value="$([System.DateTime]::UtcNow.ToString(yyyy-MM-ddTHH:mm:ssK))" /> | ||
<AssemblyMetadata Condition=" $(CommitHash) != '' " Include="GitHash" | ||
Value="$(CommitHash)" /> | ||
<AssemblyMetadata Condition=" $(CommitBranch) != '' " Include="GitBranch" | ||
Value="$(CommitBranch)" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
</Project> |