From e716cf63fc9e340fdb92b296da0bfc4048116f01 Mon Sep 17 00:00:00 2001 From: Gervasio Marchand Date: Sun, 4 Dec 2022 23:02:45 -0300 Subject: [PATCH] Rename things once again --- README.md | 22 +++++++++---------- ...ddHostCommand.cs => AddInstanceCommand.cs} | 4 ++-- ...ostCommand.cs => DeleteInstanceCommand.cs} | 4 ++-- src/FakeRelay.Cli/Commands/ListCommand.cs | 2 +- ...ostCommand.cs => UpdateInstanceCommand.cs} | 4 ++-- src/FakeRelay.Cli/Program.cs | 14 ++++++------ .../{HostSettings.cs => InstanceSettings.cs} | 2 +- 7 files changed, 26 insertions(+), 26 deletions(-) rename src/FakeRelay.Cli/Commands/{AddHostCommand.cs => AddInstanceCommand.cs} (79%) rename src/FakeRelay.Cli/Commands/{DeleteHostCommand.cs => DeleteInstanceCommand.cs} (76%) rename src/FakeRelay.Cli/Commands/{UpdateHostCommand.cs => UpdateInstanceCommand.cs} (79%) rename src/FakeRelay.Cli/Settings/{HostSettings.cs => InstanceSettings.cs} (82%) diff --git a/README.md b/README.md index ac8f44b..e6bbbd8 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ version: '2' services: fakerelay: image: 'ghcr.io/g3rv4/fakerelay:latest' - command: 'web' + command: web hostname: fakerelay environment: - ASPNETCORE_ENVIRONMENT=Production @@ -92,42 +92,42 @@ If you want requests to the homepage to redirect visitors somewhere, you can add } ``` -### List authorized hosts +### List authorized instances ``` g3rv4@s1:~/docker/FakeRelay$ docker-compose run --rm cli list-instances ┌─────────────────┬──────────────────────────────────────────────────────────────────────────────────────────┐ -│ Host │ Key │ +│ Instance │ Key │ ├─────────────────┼──────────────────────────────────────────────────────────────────────────────────────────┤ │ m2.g3rv4.com │ KlYKnm9GJcM0B1p8K98vw8FSpWzWOimZ7/3C9kTdWGUmK3xmFEJJwTZ1wqERVTugLH/9alYILFehqu9Ns2MEAw== │ │ mastodon.social │ 1TxL6m1Esx6tnv4EPxscvAmdQN7qSn0nKeyoM7LD8b9mz+GNfrKaHiWgiT3QcNMUA+dWLyWD8qyl1MuKJ+4uHA== │ └─────────────────┴──────────────────────────────────────────────────────────────────────────────────────────┘ ``` -### Add authorized hosts +### Add authorized instance -You can add hosts, and that will generate their tokens using the `add-host` command. That will output the key: +When you add an instance, the system will generate a token to index stuff on it and return that: ``` -g3rv4@s1:~/docker/FakeRelay$ docker-compose run --rm cli host add mastodon.social +g3rv4@s1:~/docker/FakeRelay$ docker-compose run --rm cli instance add mastodon.social Key generated for mastodon.social vti7J0MDDw1O5EPRwfuUafJJjpErhXTwECGEvuw/G4UVWgLXtnrnmPIRRsOcvMD0juwSlvUnchIzgla030AIRw== ``` ### Rotate a key -You can use `update-host` to rotate a hosts' key: +You can use `instance update` to rotate a instance's key: ``` -g3rv4@s1:~/docker/FakeRelay$ docker-compose run --rm cli host update mastodon.social +g3rv4@s1:~/docker/FakeRelay$ docker-compose run --rm cli instance update mastodon.social Key generated for mastodon.social wpSX9xpPgX0gjgAxO0Jc+GLSOXubVgv73FOvAihR2EmgK/AfDHz21sF72uqrLnVGzcq2BDXosMeKdFR76q6fpg== ``` -### Remove a host +### Remove an instance -If you want to revoke a host's key, you can use `delete-host`: +If you want to revoke a instance's key, you can use `instance delete`: ``` -g3rv4@s1:~/docker/FakeRelay$ docker-compose run --rm cli host delete mastodon.social +g3rv4@s1:~/docker/FakeRelay$ docker-compose run --rm cli instance delete mastodon.social Key deleted for mastodon.social ``` \ No newline at end of file diff --git a/src/FakeRelay.Cli/Commands/AddHostCommand.cs b/src/FakeRelay.Cli/Commands/AddInstanceCommand.cs similarity index 79% rename from src/FakeRelay.Cli/Commands/AddHostCommand.cs rename to src/FakeRelay.Cli/Commands/AddInstanceCommand.cs index 41255b4..27c7522 100644 --- a/src/FakeRelay.Cli/Commands/AddHostCommand.cs +++ b/src/FakeRelay.Cli/Commands/AddInstanceCommand.cs @@ -5,9 +5,9 @@ using Spectre.Console.Cli; namespace FakeRelay.Cli.Commands; -public class AddHostCommand : ConfigEnabledAsyncCommand +public class AddInstanceCommand : ConfigEnabledAsyncCommand { - public override async Task ExecuteAsync(CommandContext context, HostSettings settings) + public override async Task ExecuteAsync(CommandContext context, InstanceSettings settings) { var token = await ApiKeysHelper.AddTokenForHostAsync(settings.Host); AnsiConsole.Markup($"[green]Key generated for {settings.Host}[/]\n"); diff --git a/src/FakeRelay.Cli/Commands/DeleteHostCommand.cs b/src/FakeRelay.Cli/Commands/DeleteInstanceCommand.cs similarity index 76% rename from src/FakeRelay.Cli/Commands/DeleteHostCommand.cs rename to src/FakeRelay.Cli/Commands/DeleteInstanceCommand.cs index d774549..aa54fcb 100644 --- a/src/FakeRelay.Cli/Commands/DeleteHostCommand.cs +++ b/src/FakeRelay.Cli/Commands/DeleteInstanceCommand.cs @@ -5,9 +5,9 @@ using Spectre.Console.Cli; namespace FakeRelay.Cli.Commands; -public class DeleteHostCommand : ConfigEnabledAsyncCommand +public class DeleteInstanceCommand : ConfigEnabledAsyncCommand { - public override async Task ExecuteAsync(CommandContext context, HostSettings settings) + public override async Task ExecuteAsync(CommandContext context, InstanceSettings settings) { await ApiKeysHelper.DeleteTokenForHostAsync(settings.Host); AnsiConsole.Markup($"[green]Key deleted for {settings.Host}[/]\n"); diff --git a/src/FakeRelay.Cli/Commands/ListCommand.cs b/src/FakeRelay.Cli/Commands/ListCommand.cs index 150316c..08b1289 100644 --- a/src/FakeRelay.Cli/Commands/ListCommand.cs +++ b/src/FakeRelay.Cli/Commands/ListCommand.cs @@ -14,7 +14,7 @@ public class ListInstancesCommand : ConfigEnabledAsyncCommand +public class UpdateInstanceCommand : ConfigEnabledAsyncCommand { - public override async Task ExecuteAsync(CommandContext context, HostSettings settings) + public override async Task ExecuteAsync(CommandContext context, InstanceSettings settings) { var token = await ApiKeysHelper.UpdateTokenForHostAsync(settings.Host); AnsiConsole.Markup($"[green]Key generated for {settings.Host}[/]\n"); diff --git a/src/FakeRelay.Cli/Program.cs b/src/FakeRelay.Cli/Program.cs index 9b3ed55..fc3f128 100644 --- a/src/FakeRelay.Cli/Program.cs +++ b/src/FakeRelay.Cli/Program.cs @@ -5,14 +5,14 @@ using Spectre.Console.Cli; var app = new CommandApp(); app.Configure(config => { - config.AddBranch("host", host => + config.AddBranch("instance", instance => { - host.AddCommand("add") - .WithDescription("Adds a host to the relay and generates a key."); - host.AddCommand("update") - .WithDescription("Generates a new key for the host. The old one can't be used anymore."); - host.AddCommand("delete") - .WithDescription("Deletes the existing keys for the host. They can't use FakeRelay anymore."); + instance.AddCommand("add") + .WithDescription("Adds an instance to the relay and generates a key."); + instance.AddCommand("update") + .WithDescription("Generates a new key for the instance. The old one can't be used anymore."); + instance.AddCommand("delete") + .WithDescription("Deletes the existing keys for the instance. They can't use FakeRelay anymore."); }); config.AddCommand("list-instances") diff --git a/src/FakeRelay.Cli/Settings/HostSettings.cs b/src/FakeRelay.Cli/Settings/InstanceSettings.cs similarity index 82% rename from src/FakeRelay.Cli/Settings/HostSettings.cs rename to src/FakeRelay.Cli/Settings/InstanceSettings.cs index 65c33b1..b36839f 100644 --- a/src/FakeRelay.Cli/Settings/HostSettings.cs +++ b/src/FakeRelay.Cli/Settings/InstanceSettings.cs @@ -3,7 +3,7 @@ using Spectre.Console.Cli; namespace FakeRelay.Cli.Settings; -public class HostSettings : EmptyBaseSettings +public class InstanceSettings : EmptyBaseSettings { [Description("The instance that connects to this FakeRelay.")] [CommandArgument(0, "")]