Implement monorepo layout
Implemented the nexantic monorepo.
Smalltown code was moved to `core`. From now on all code will live in top level directories named after the projects with the exception for general purpose libraries which should go to `<lang>libs`.
General build and utility folders are underscore prefixed.
The repo name will from now on be rNXT (nexantic). I think this change makes sense since components in this repo will not all be part of Smalltown, the Smalltown brand has been claimed by Signon GmbH so we need to change it anyway and the longer we wait the harder it will be to change/move it.
Test Plan: Launched Smalltown using `./scripts/bin/bazel run //core/scripts:launch`
X-Origin-Diff: phab/D210
GitOrigin-RevId: fa5a7f08143d2ead2cb7206b4c63ab641794162c
diff --git a/core/api/api/BUILD.bazel b/core/api/api/BUILD.bazel
new file mode 100644
index 0000000..d28e60c
--- /dev/null
+++ b/core/api/api/BUILD.bazel
@@ -0,0 +1,25 @@
+load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
+
+proto_library(
+ name = "api_proto",
+ srcs = ["schema.proto"],
+ visibility = ["//visibility:public"],
+ deps = ["//core/api/common:common_proto"],
+)
+
+go_proto_library(
+ name = "api_go_proto",
+ compilers = ["@io_bazel_rules_go//proto:go_grpc"],
+ importpath = "git.monogon.dev/source/nexantic.git/core/generated/api",
+ proto = ":api_proto",
+ visibility = ["//visibility:public"],
+ deps = ["//core/api/common:go_default_library"],
+)
+
+go_library(
+ name = "go_default_library",
+ embed = [":api_go_proto"],
+ importpath = "git.monogon.dev/source/nexantic.git/core/generated/api",
+ visibility = ["//visibility:public"],
+)
diff --git a/core/api/api/schema.proto b/core/api/api/schema.proto
new file mode 100644
index 0000000..d6721a0
--- /dev/null
+++ b/core/api/api/schema.proto
@@ -0,0 +1,158 @@
+// Copyright 2020 The Monogon Project Authors.
+//
+// SPDX-License-Identifier: Apache-2.0
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+package api;
+
+import "core/api/common/main.proto";
+
+option go_package = "git.monogon.dev/source/nexantic.git/core/generated/api";
+
+service ClusterManagement {
+ // Add a node to the Smalltown cluster
+ rpc AddNode (AddNodeRequest) returns (AddNodeResponse) {
+
+ }
+
+ // Remove a node from the Smalltown cluster
+ rpc RemoveNode (RemoveNodeRequest) returns (RemoveNodeRequest) {
+
+ }
+
+ // Get all cluster nodes
+ rpc GetNodes (GetNodesRequest) returns (GetNodesResponse) {
+
+ }
+}
+
+service SetupService {
+ // SetupNewCluster configures this node to either start a new Smalltown cluster or join an existing one
+ rpc Setup (SetupRequest) returns (SetupResponse) {
+
+ }
+
+ // JoinCluster can be called by another Smalltown node when the node has been put in to JOIN_CLUSTER mode using Setup.
+ // This request sets up all necessary config variables, joins the consensus and puts the node in production state.
+ rpc ProvisionCluster (ProvisionClusterRequest) returns (ProvisionClusterResponse) {
+
+ }
+
+ rpc Attest (AttestRequest) returns (AttestResponse) {
+
+ }
+}
+
+message SetupRequest {
+ oneof request {
+ NewClusterRequest newCluster = 1;
+ JoinClusterRequest joinCluster = 2;
+ }
+
+}
+
+message NewClusterRequest {
+ string nodeName = 1;
+ string externalHost = 2;
+ smalltown.common.TrustBackend trustBackend = 3;
+}
+
+message JoinClusterRequest {
+}
+
+message SetupResponse {
+ oneof response {
+ NewClusterResponse newCluster = 1;
+ JoinClusterResponse joinCluster = 2;
+ }
+}
+
+message NewClusterResponse {
+}
+
+message JoinClusterResponse {
+ string provisioningToken = 1;
+}
+
+message ProvisionClusterRequest {
+ string provisioningToken = 1;
+
+ string initialCluster = 2;
+ string nodeName = 3;
+ string externalHost = 4;
+ smalltown.common.TrustBackend trustBackend = 5;
+ bytes storeKey = 6;
+}
+
+message ProvisionClusterResponse {
+
+}
+
+message AttestRequest {
+ string challenge = 1;
+}
+
+message AttestResponse {
+ string response = 1;
+}
+
+message Key {
+ string label = 1;
+ string type = 2;
+}
+
+message CreateKeyRequest {
+ Key key = 1;
+}
+
+message CreateKeyResponse {
+
+}
+
+message AddNodeRequest {
+ string host = 1;
+ uint32 apiPort = 2;
+ uint32 consensusPort = 3;
+ string token = 4;
+ string name = 5;
+ smalltown.common.TrustBackend trustBackend = 6;
+}
+
+message AddNodeResponse {
+
+}
+
+message RemoveNodeRequest {
+
+}
+
+message RemoveNodeResponse {
+
+}
+
+message GetNodesRequest {
+
+}
+
+message GetNodesResponse {
+ repeated Node nodes = 1;
+}
+
+message Node {
+ uint64 id = 1;
+ string name = 2;
+ string address = 3;
+ bool synced = 4;
+}
diff --git a/core/api/common/BUILD.bazel b/core/api/common/BUILD.bazel
new file mode 100644
index 0000000..30b3a27
--- /dev/null
+++ b/core/api/common/BUILD.bazel
@@ -0,0 +1,22 @@
+load("@io_bazel_rules_go//go:def.bzl", "go_library")
+load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
+
+proto_library(
+ name = "common_proto",
+ srcs = ["main.proto"],
+ visibility = ["//visibility:public"],
+)
+
+go_proto_library(
+ name = "common_go_proto",
+ importpath = "git.monogon.dev/source/nexantic.git/core/generated/common",
+ proto = ":common_proto",
+ visibility = ["//visibility:public"],
+)
+
+go_library(
+ name = "go_default_library",
+ embed = [":common_go_proto"],
+ importpath = "git.monogon.dev/source/nexantic.git/core/generated/common",
+ visibility = ["//visibility:public"],
+)
diff --git a/core/api/common/main.proto b/core/api/common/main.proto
new file mode 100644
index 0000000..8ce8f99
--- /dev/null
+++ b/core/api/common/main.proto
@@ -0,0 +1,30 @@
+// Copyright 2020 The Monogon Project Authors.
+//
+// SPDX-License-Identifier: Apache-2.0
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+syntax = "proto3";
+
+option go_package = "git.monogon.dev/source/nexantic.git/core/generated/common";
+package smalltown.common;
+
+message KV {
+ string key = 1;
+ bytes value = 2;
+}
+
+enum TrustBackend {
+ DUMMY = 0;
+ TPM = 1;
+}