-
Notifications
You must be signed in to change notification settings - Fork 682
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update configure command to support configuring feature flags (#96)
* Update configure command to support configuring feature flags This uses the changes from github/valet#5879 to fetch available flags via the list-features --json flag. It parses out the possible env vars and walks the customer through setting any feature flags they desire. If there are any issues getting the available feature flags JSON, we don't ask the customer to configure feature flags, as it won't cause any breaking issues and we don't want to break the configure command. * Move feature configuration to its own flag * Add unit tests * Undo changes to ConfigurationServiceTests * Code review fixes
- Loading branch information
Showing
12 changed files
with
253 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System.Text.Json; | ||
using ActionsImporter.Models; | ||
using NUnit.Framework; | ||
|
||
namespace ActionsImporter.UnitTests.Models; | ||
|
||
[TestFixture] | ||
public class FeatureTests | ||
{ | ||
private readonly string featureResult = @" | ||
{ | ||
""name"": ""actions/cache"", | ||
""description"": ""Control usage of actions/cache inside of workflows. Outputs a comment if not enabled."", | ||
""enabled"": false, | ||
""ghes_version"": ""ghes-3.5"", | ||
""customer_facing"": true, | ||
""env_name"": ""FEATURE_ACTIONS_CACHE"" | ||
} | ||
"; | ||
|
||
[Test] | ||
public void Initialize() | ||
{ | ||
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true, }; | ||
var feature = JsonSerializer.Deserialize<Feature>(featureResult, options); | ||
|
||
Assert.AreEqual("actions/cache", feature?.Name); | ||
Assert.AreEqual("Control usage of actions/cache inside of workflows. Outputs a comment if not enabled.", feature?.Description); | ||
Assert.AreEqual("FEATURE_ACTIONS_CACHE", feature?.EnvName); | ||
Assert.IsFalse(feature?.Enabled); | ||
} | ||
|
||
[Test] | ||
public void EnabledMessage() | ||
{ | ||
var enabledFeature = new Feature | ||
{ | ||
Enabled = true, | ||
}; | ||
Assert.AreEqual("enabled", enabledFeature.EnabledMessage()); | ||
} | ||
|
||
[Test] | ||
public void DisabledMessage() | ||
{ | ||
var disabledFeature = new Feature | ||
{ | ||
Enabled = false, | ||
}; | ||
Assert.AreEqual("disabled", disabledFeature.EnabledMessage()); | ||
|
||
} | ||
} |
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,13 @@ | ||
namespace ActionsImporter.Handlers; | ||
|
||
public class ConfigureHandler | ||
{ | ||
private readonly App _app; | ||
|
||
public ConfigureHandler(App app) | ||
{ | ||
_app = app; | ||
} | ||
|
||
public Func<Task<int>> Run(string[] args) => () => _app.ConfigureAsync(args); | ||
} |
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,17 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace ActionsImporter.Models; | ||
|
||
public class Feature | ||
{ | ||
public string Name { get; set; } = string.Empty; | ||
|
||
public string Description { get; set; } = string.Empty; | ||
|
||
[JsonPropertyName("env_name")] | ||
public string EnvName { get; set; } = string.Empty; | ||
|
||
public bool Enabled { get; set; } | ||
|
||
public string EnabledMessage() => Enabled ? "enabled" : "disabled"; | ||
} |
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