Skip to content

Commit

Permalink
Update documentation to invoke commands correctly, and use nukagit-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Ignas committed Dec 23, 2023
1 parent 5a879e0 commit efa1b59
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 12 deletions.
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,61 @@
# 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
# You will get a warning about connecting to a new ssh host, this is expected
# 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"
```
2 changes: 1 addition & 1 deletion cli/src/main/java/lt/pow/nukagit/cli/AddUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 22 additions & 0 deletions cli/src/main/java/lt/pow/nukagit/cli/CreateRepository.java
Original file line number Diff line number Diff line change
@@ -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");
}
}
3 changes: 2 additions & 1 deletion cli/src/main/java/lt/pow/nukagit/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit efa1b59

Please sign in to comment.