Skip to content

Commit

Permalink
Add Dry Run option on publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxhy committed Mar 7, 2024
1 parent 21e5f29 commit de7e5ac
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
9 changes: 9 additions & 0 deletions KeyManager.Library.UI/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions KeyManager.Library.UI/Properties/Resources.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@
<data name="Drives" xml:space="preserve">
<value>Disques</value>
</data>
<data name="DryRun" xml:space="preserve">
<value>Essai (ne pas sauvegarder)</value>
</data>
<data name="EditDefaultKeyEntry" xml:space="preserve">
<value>Modifier la définition de l'enregistrement de clés par défaut</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions KeyManager.Library.UI/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@
<data name="Drives" xml:space="preserve">
<value>Drives</value>
</data>
<data name="DryRun" xml:space="preserve">
<value>Dry Run (don't store)</value>
</data>
<data name="EditDefaultKeyEntry" xml:space="preserve">
<value>Edit default key entry definition</value>
</data>
Expand Down
4 changes: 4 additions & 0 deletions KeyManager.Library.UI/PublishKeyStoreDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<ToggleButton IsChecked="{Binding Options.ResolveKeyLinks}" Style="{StaticResource MaterialDesignSwitchLightToggleButton}" />
<TextBlock Text="{x:Static properties:Resources.ResolveKeyLinks}" Padding="3" />
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="5">
<ToggleButton IsChecked="{Binding Options.DryRun}" Style="{StaticResource MaterialDesignSwitchLightToggleButton}" />
<TextBlock Text="{x:Static properties:Resources.DryRun}" Padding="3" />
</StackPanel>
<TextBox Text="{Binding Options.PublishVariable}" Margin="5,5,5,15"
materialDesign:HintAssist.HelperText="{x:Static properties:Resources.PublishVariableHelper}"
materialDesign:HintAssist.Hint="{x:Static properties:Resources.PublishVariable}"/>
Expand Down
9 changes: 8 additions & 1 deletion KeyManager.Library/KeyStore/KeyStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,14 @@ public virtual async Task Publish(KeyStore store, Func<string, KeyStore?> getFav
await store.Open();
try
{
await store.Store(changes);
if (!(Options?.DryRun).GetValueOrDefault(false))
{
await store.Store(changes);
}
else
{
log.Info("Dry Run, skipping key entries storing.");
}
}
finally
{
Expand Down
7 changes: 7 additions & 0 deletions KeyManager.Library/KeyStore/StoreOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ public bool ResolveKeyLinks
set => SetProperty(ref _resolveKeyLinks, value);
}

private bool _dryRun;
public bool DryRun
{
get => _dryRun;
set => SetProperty(ref _dryRun, value);
}

private string? _publishVariable;
public string? PublishVariable
{
Expand Down

0 comments on commit de7e5ac

Please sign in to comment.