From efa1b59ff480d0ea0038f4c647f18d87106f3ace Mon Sep 17 00:00:00 2001 From: Ignas Mikalajunas Date: Sat, 23 Dec 2023 23:20:44 +0200 Subject: [PATCH] Update documentation to invoke commands correctly, and use nukagit-cli --- README.md | 29 ++++++++++++------- .../main/java/lt/pow/nukagit/cli/AddUser.java | 2 +- .../lt/pow/nukagit/cli/CreateRepository.java | 22 ++++++++++++++ .../main/java/lt/pow/nukagit/cli/Main.java | 3 +- 4 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 cli/src/main/java/lt/pow/nukagit/cli/CreateRepository.java diff --git a/README.md b/README.md index 325759d..13b4e28 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,51 @@ # Nukagit - making git distributed ## What is this? + Nukagit is my attempt at making a JGIT DFS based git server backed by a combination of minio and mysql. It is a work in progress and is not ready for production use. The idea is to run a cross-regional minio cluster and a group replicated instance of mysql. This should result in very high availability and durability. And should also -provide good read performance in remote regions (group replication means latest data is +provide good read performance in remote regions (group replication means latest data is always available for reading). The write overhead of having to write to multiple remote regions is not such a huge problem, as most people can survive an extra second of latency when pushing to a remote git repository. ## Building + ```shell ./gradlew build ``` ## Running + ```shell docker-compose up -# you will have to run it a couple times because mysql fails to chown -# it's directory on a Mac +# you might have to run it a couple times because mysql fails to chown +# it's directory on a Mac with colima -./gradlew run --args="migrate" -./gradlew serve --args="serve" +./gradlew :run --args="migrate" +./gradlew :serve --args="serve" ``` ## Testing There are two kinds of repositories supported at the moment: + - In-memory ones that are created on clone - Minio/Mysql backed ones that you have top use grpc to create before cloning -There is no authorization yet, so we accept any username/ssh key -whatsoever, but it might be that at least some ssh public key has to be -present in the keychain. +First you will have to make a user: + +```shell +./gradlew :cli:run --args="add_user username -F ../src/test/resources/fixtures/id_ecdsa.pub" +``` + +Feel free to use your own public key instead of the one in the fixtures directory. To test an in-memory repository: + ```shell git clone "ssh://git@localhost:2222/memory/test-repository" # Repository will be created automatically @@ -44,9 +53,9 @@ git clone "ssh://git@localhost:2222/memory/test-repository" # a new ssh host key will be generated in keys/ssh_host_key.pem ``` -For a minio one run the request in `test-requests.http` to get the repository -created and then run: +For a minio one create the repository using the cli and then clone it: ```shell +./gradlew :cli:run --args="create_repository testing" git clone "ssh://git@localhost:2222/testing" ``` \ No newline at end of file diff --git a/cli/src/main/java/lt/pow/nukagit/cli/AddUser.java b/cli/src/main/java/lt/pow/nukagit/cli/AddUser.java index a904d38..872ca25 100644 --- a/cli/src/main/java/lt/pow/nukagit/cli/AddUser.java +++ b/cli/src/main/java/lt/pow/nukagit/cli/AddUser.java @@ -46,7 +46,7 @@ public void run() { keyString = new String(keyBytes, StandardCharsets.UTF_8); } - System.out.println("Adding User " + username + " with key " + keyString); + System.out.println("Adding User " + username); parent.usersGrpcClient().createUser(Users.CreateUserRequest.newBuilder() .setUsername(username) .setPublicKey(keyString) diff --git a/cli/src/main/java/lt/pow/nukagit/cli/CreateRepository.java b/cli/src/main/java/lt/pow/nukagit/cli/CreateRepository.java new file mode 100644 index 0000000..e775f9c --- /dev/null +++ b/cli/src/main/java/lt/pow/nukagit/cli/CreateRepository.java @@ -0,0 +1,22 @@ +package lt.pow.nukagit.cli; + +import lt.pow.nukagit.proto.Repositories; +import picocli.CommandLine; + +@CommandLine.Command(name = "create_repository", description = "Create repository") +public class CreateRepository implements Runnable { + @CommandLine.ParentCommand + private Main parent; + + @CommandLine.Parameters(index = "0", description = "Repository name.") + private String repositoryName; + + @Override + public void run() { + System.out.println("Creating repository " + repositoryName); + parent.repositoriesGrpcClient().createRepository(Repositories.CreateRepositoryRequest.newBuilder() + .setRepositoryName(repositoryName) + .build()); + System.out.println("Repository created"); + } +} diff --git a/cli/src/main/java/lt/pow/nukagit/cli/Main.java b/cli/src/main/java/lt/pow/nukagit/cli/Main.java index f4c5678..47cf443 100644 --- a/cli/src/main/java/lt/pow/nukagit/cli/Main.java +++ b/cli/src/main/java/lt/pow/nukagit/cli/Main.java @@ -8,7 +8,8 @@ @CommandLine.Command(name = "nuka_cli", description = "NukaGit CLI client", subcommands = { - AddUser.class + AddUser.class, + CreateRepository.class, }) public class Main implements Runnable { @CommandLine.Option(names = {"-h", "--help"}, usageHelp = true, description = "Display this help message")