prepare for refactor

This commit is contained in:
d34dscene
2025-06-16 16:26:55 +02:00
parent 65bb32e28c
commit 20d31f3bb3
73 changed files with 1591 additions and 467 deletions

View File

@@ -1,12 +1,9 @@
when:
- branch: [main, nightly]
- branch: [main]
event: [push, tag, deployment, manual]
path:
include:
- 'web/**'
- 'agent/**'
- 'internal/**'
- 'pkg/**'
- '*.go'
- 'go.mod'
- 'go.sum'

View File

@@ -1,28 +0,0 @@
FROM --platform=$BUILDPLATFORM alpine
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG VERSION
ARG COMMIT
ARG DATE
# Metadata labels
LABEL org.opencontainers.image.vendor="Mizuchi Labs"
LABEL org.opencontainers.image.source="https://github.com/MizuchiLabs/mantrae"
LABEL org.opencontainers.image.title="Mantrae"
LABEL org.opencontainers.image.version=$VERSION
LABEL org.opencontainers.image.revision=$COMMIT
LABEL org.opencontainers.image.created=$DATE
LABEL org.opencontainers.image.licenses="MIT"
WORKDIR /app
COPY mantrae-${TARGETOS}-${TARGETARCH} /usr/local/bin/mantrae
EXPOSE 3000
EXPOSE 8090
ENTRYPOINT ["/usr/local/bin/mantrae"]

View File

@@ -1,23 +0,0 @@
FROM alpine
ARG TARGETOS
ARG TARGETARCH
ARG VERSION
ARG COMMIT
ARG DATE
# Metadata labels
LABEL org.opencontainers.image.vendor="Mizuchi Labs"
LABEL org.opencontainers.image.source="https://github.com/MizuchiLabs/mantrae"
LABEL org.opencontainers.image.title="Mantrae Agent"
LABEL org.opencontainers.image.version=$VERSION
LABEL org.opencontainers.image.revision=$COMMIT
LABEL org.opencontainers.image.created=$DATE
LABEL org.opencontainers.image.licenses="MIT"
WORKDIR /app
COPY mae-${TARGETOS}-${TARGETARCH} /usr/local/bin/mae
ENTRYPOINT ["/usr/local/bin/mae"]

View File

@@ -10,9 +10,9 @@ import (
"sync"
"connectrpc.com/connect"
agentv1 "github.com/MizuchiLabs/mantrae/agent/proto/gen/agent/v1"
"github.com/MizuchiLabs/mantrae/agent/proto/gen/agent/v1/agentv1connect"
"github.com/MizuchiLabs/mantrae/pkg/meta"
"github.com/mizuchilabs/mantrae/pkg/meta"
agentv1 "github.com/mizuchilabs/mantrae/proto/gen/agent/v1"
"github.com/mizuchilabs/mantrae/proto/gen/agent/v1/agentv1connect"
)
const tokenFile = "data/.mantrae-token"
@@ -48,7 +48,7 @@ func (ts *TokenSource) SetToken(ctx context.Context) error {
}
if ts.token == "" {
ts.mu.Unlock()
return errors.New("No token found in environment or file")
return errors.New("no token found in environment or file")
}
// Write it back

View File

@@ -10,8 +10,8 @@ import (
"time"
"connectrpc.com/connect"
agentv1 "github.com/MizuchiLabs/mantrae/agent/proto/gen/agent/v1"
"github.com/MizuchiLabs/mantrae/agent/proto/gen/agent/v1/agentv1connect"
agentv1 "github.com/mizuchilabs/mantrae/proto/gen/agent/v1"
"github.com/mizuchilabs/mantrae/proto/gen/agent/v1/agentv1connect"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
"google.golang.org/protobuf/types/known/timestamppb"

View File

@@ -8,9 +8,9 @@ import (
"os/signal"
"syscall"
"github.com/MizuchiLabs/mantrae/agent/client"
"github.com/MizuchiLabs/mantrae/pkg/build"
"github.com/MizuchiLabs/mantrae/pkg/logger"
"github.com/mizuchilabs/mantrae/agent/client"
"github.com/mizuchilabs/mantrae/pkg/build"
"github.com/mizuchilabs/mantrae/pkg/logger"
)
func main() {

View File

@@ -1,13 +1,16 @@
version: v2
clean: true
managed:
enabled: true
override:
- file_option: go_package_prefix
value: github.com/MizuchiLabs/mantrae/agent/proto/gen
value: github.com/mizuchilabs/mantrae/proto/gen
plugins:
- local: protoc-gen-go
out: gen
out: proto/gen
opt: paths=source_relative
- local: protoc-gen-connect-go
out: gen
out: proto/gen
opt: paths=source_relative
inputs:
- directory: proto

View File

@@ -1,8 +1,11 @@
# For details on buf.yaml configuration, visit https://buf.build/docs/configuration/v2/buf-yaml
version: v2
modules:
- path: proto
lint:
use:
- STANDARD
breaking:
use:
- FILE

32
go.mod
View File

@@ -1,4 +1,4 @@
module github.com/MizuchiLabs/mantrae
module github.com/mizuchilabs/mantrae
go 1.24.0
@@ -6,10 +6,10 @@ require (
connectrpc.com/connect v1.18.1
connectrpc.com/grpchealth v1.4.0
connectrpc.com/grpcreflect v1.3.0
github.com/aws/aws-sdk-go-v2 v1.36.3
github.com/aws/aws-sdk-go-v2/config v1.29.15
github.com/aws/aws-sdk-go-v2/credentials v1.17.68
github.com/aws/aws-sdk-go-v2/service/s3 v1.80.1
github.com/aws/aws-sdk-go-v2 v1.36.4
github.com/aws/aws-sdk-go-v2/config v1.29.16
github.com/aws/aws-sdk-go-v2/credentials v1.17.69
github.com/aws/aws-sdk-go-v2/service/s3 v1.80.2
github.com/caarlos0/env/v11 v11.3.1
github.com/cloudflare/cloudflare-go v0.115.0
github.com/coreos/go-oidc/v3 v3.14.1
@@ -26,25 +26,25 @@ require (
golang.org/x/net v0.41.0
golang.org/x/oauth2 v0.30.0
google.golang.org/protobuf v1.36.6
modernc.org/sqlite v1.37.1
modernc.org/sqlite v1.38.0
sigs.k8s.io/yaml v1.4.0
)
require (
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.31 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.35 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.35 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.34 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.35 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.2 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.15 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.25.3 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.33.20 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.16 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.16 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.25.4 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.2 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.33.21 // indirect
github.com/aws/smithy-go v1.22.3 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.2 // indirect

60
go.sum
View File

@@ -10,40 +10,40 @@ github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/aws/aws-sdk-go-v2 v1.36.3 h1:mJoei2CxPutQVxaATCzDUjcZEjVRdpsiiXi2o38yqWM=
github.com/aws/aws-sdk-go-v2 v1.36.3/go.mod h1:LLXuLpgzEbD766Z5ECcRmi8AzSwfZItDtmABVkRLGzg=
github.com/aws/aws-sdk-go-v2 v1.36.4 h1:GySzjhVvx0ERP6eyfAbAuAXLtAda5TEy19E5q5W8I9E=
github.com/aws/aws-sdk-go-v2 v1.36.4/go.mod h1:LLXuLpgzEbD766Z5ECcRmi8AzSwfZItDtmABVkRLGzg=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10 h1:zAybnyUQXIZ5mok5Jqwlf58/TFE7uvd3IAsa1aF9cXs=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10/go.mod h1:qqvMj6gHLR/EXWZw4ZbqlPbQUyenf4h82UQUlKc+l14=
github.com/aws/aws-sdk-go-v2/config v1.29.15 h1:I5XjesVMpDZXZEZonVfjI12VNMrYa38LtLnw4NtY5Ss=
github.com/aws/aws-sdk-go-v2/config v1.29.15/go.mod h1:tNIp4JIPonlsgaO5hxO372a6gjhN63aSWl2GVl5QoBQ=
github.com/aws/aws-sdk-go-v2/credentials v1.17.68 h1:cFb9yjI02/sWHBSYXAtkamjzCuRymvmeFmt0TC0MbYY=
github.com/aws/aws-sdk-go-v2/credentials v1.17.68/go.mod h1:H6E+jBzyqUu8u0vGaU6POkK3P0NylYEeRZ6ynBpMqIk=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 h1:x793wxmUWVDhshP8WW2mlnXuFrO4cOd3HLBroh1paFw=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30/go.mod h1:Jpne2tDnYiFascUEs2AWHJL9Yp7A5ZVy3TNyxaAjD6M=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 h1:ZK5jHhnrioRkUNOc+hOgQKlUL5JeC3S6JgLxtQ+Rm0Q=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34/go.mod h1:p4VfIceZokChbA9FzMbRGz5OV+lekcVtHlPKEO0gSZY=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34 h1:SZwFm17ZUNNg5Np0ioo/gq8Mn6u9w19Mri8DnJ15Jf0=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34/go.mod h1:dFZsC0BLo346mvKQLWmoJxT+Sjp+qcVR1tRVHQGOH9Q=
github.com/aws/aws-sdk-go-v2/config v1.29.16 h1:XkruGnXX1nEZ+Nyo9v84TzsX+nj86icbFAeust6uo8A=
github.com/aws/aws-sdk-go-v2/config v1.29.16/go.mod h1:uCW7PNjGwZ5cOGZ5jr8vCWrYkGIhPoTNV23Q/tpHKzg=
github.com/aws/aws-sdk-go-v2/credentials v1.17.69 h1:8B8ZQboRc3uaIKjshve/XlvJ570R7BKNy3gftSbS178=
github.com/aws/aws-sdk-go-v2/credentials v1.17.69/go.mod h1:gPME6I8grR1jCqBFEGthULiolzf/Sexq/Wy42ibKK9c=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.31 h1:oQWSGexYasNpYp4epLGZxxjsDo8BMBh6iNWkTXQvkwk=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.31/go.mod h1:nc332eGUU+djP3vrMI6blS0woaCfHTe3KiSQUVTMRq0=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.35 h1:o1v1VFfPcDVlK3ll1L5xHsaQAFdNtZ5GXnNR7SwueC4=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.35/go.mod h1:rZUQNYMNG+8uZxz9FOerQJ+FceCiodXvixpeRtdESrU=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.35 h1:R5b82ubO2NntENm3SAm0ADME+H630HomNJdgv+yZ3xw=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.35/go.mod h1:FuA+nmgMRfkzVKYDNEqQadvEMxtxl9+RLT9ribCwEMs=
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 h1:bIqFDwgGXXN1Kpp99pDOdKMTTb5d2KyU5X/BZxjOkRo=
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3/go.mod h1:H5O/EsxDWyU+LP/V8i5sm8cxoZgc2fdNR9bxlOFrQTo=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.34 h1:ZNTqv4nIdE/DiBfUUfXcLZ/Spcuz+RjeziUtNJackkM=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.34/go.mod h1:zf7Vcd1ViW7cPqYWEHLHJkS50X0JS2IKz9Cgaj6ugrs=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.35 h1:th/m+Q18CkajTw1iqx2cKkLCij/uz8NMwJFPK91p2ug=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.35/go.mod h1:dkJuf0a1Bc8HAA0Zm2MoTGm/WDC18Td9vSbrQ1+VqE8=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 h1:eAh2A4b5IzM/lum78bZ590jy36+d/aFLgKF/4Vd1xPE=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3/go.mod h1:0yKJC/kb8sAnmlYa6Zs3QVYqaC8ug2AbnNChv5Ox3uA=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.2 h1:BCG7DCXEXpNCcpwCxg1oi9pkJWH2+eZzTn9MY56MbVw=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.2/go.mod h1:iu6FSzgt+M2/x3Dk8zhycdIcHjEFb36IS8HVUVFoMg0=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 h1:dM9/92u2F1JbDaGooxTq18wmmFzbJRfXfVfy96/1CXM=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15/go.mod h1:SwFBy2vjtA0vZbjjaFtfN045boopadnoVPhu4Fv66vY=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.15 h1:moLQUoVq91LiqT1nbvzDukyqAlCv89ZmwaHw/ZFlFZg=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.15/go.mod h1:ZH34PJUc8ApjBIfgQCFvkWcUDBtl/WTD+uiYHjd8igA=
github.com/aws/aws-sdk-go-v2/service/s3 v1.80.1 h1:xYEAf/6QHiTZDccKnPMbsMwlau13GsDsTgdue3wmHGw=
github.com/aws/aws-sdk-go-v2/service/s3 v1.80.1/go.mod h1:qbn305Je/IofWBJ4bJz/Q7pDEtnnoInw/dGt71v6rHE=
github.com/aws/aws-sdk-go-v2/service/sso v1.25.3 h1:1Gw+9ajCV1jogloEv1RRnvfRFia2cL6c9cuKV2Ps+G8=
github.com/aws/aws-sdk-go-v2/service/sso v1.25.3/go.mod h1:qs4a9T5EMLl/Cajiw2TcbNt2UNo/Hqlyp+GiuG4CFDI=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1 h1:hXmVKytPfTy5axZ+fYbR5d0cFmC3JvwLm5kM83luako=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1/go.mod h1:MlYRNmYu/fGPoxBQVvBYr9nyr948aY/WLUvwBMBJubs=
github.com/aws/aws-sdk-go-v2/service/sts v1.33.20 h1:oIaQ1e17CSKaWmUTu62MtraRWVIosn/iONMuZt0gbqc=
github.com/aws/aws-sdk-go-v2/service/sts v1.33.20/go.mod h1:cQnB8CUnxbMU82JvlqjKR2HBOm3fe9pWorWBza6MBJ4=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.3 h1:VHPZakq2L7w+RLzV54LmQavbvheFaR2u1NomJRSEfcU=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.3/go.mod h1:DX1e/lkbsAt0MkY3NgLYuH4jQvRfw8MYxTe9feR7aXM=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.16 h1:/ldKrPPXTC421bTNWrUIpq3CxwHwRI/kpc+jPUTJocM=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.16/go.mod h1:5vkf/Ws0/wgIMJDQbjI4p2op86hNW6Hie5QtebrDgT8=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.16 h1:2HuI7vWKhFWsBhIr2Zq8KfFZT6xqaId2XXnXZjkbEuc=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.16/go.mod h1:BrwWnsfbFtFeRjdx0iM1ymvlqDX1Oz68JsQaibX/wG8=
github.com/aws/aws-sdk-go-v2/service/s3 v1.80.2 h1:T6Wu+8E2LeTUqzqQ/Bh1EoFNj1u4jUyveMgmTlu9fDU=
github.com/aws/aws-sdk-go-v2/service/s3 v1.80.2/go.mod h1:chSY8zfqmS0OnhZoO/hpPx/BHfAIL80m77HwhRLYScY=
github.com/aws/aws-sdk-go-v2/service/sso v1.25.4 h1:EU58LP8ozQDVroOEyAfcq0cGc5R/FTZjVoYJ6tvby3w=
github.com/aws/aws-sdk-go-v2/service/sso v1.25.4/go.mod h1:CrtOgCcysxMvrCoHnvNAD7PHWclmoFG78Q2xLK0KKcs=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.2 h1:XB4z0hbQtpmBnb1FQYvKaCM7UsS6Y/u8jVBwIUGeCTk=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.2/go.mod h1:hwRpqkRxnQ58J9blRDrB4IanlXCpcKmsC83EhG77upg=
github.com/aws/aws-sdk-go-v2/service/sts v1.33.21 h1:nyLjs8sYJShFYj6aiyjCBI3EcLn1udWrQTjEF+SOXB0=
github.com/aws/aws-sdk-go-v2/service/sts v1.33.21/go.mod h1:EhdxtZ+g84MSGrSrHzZiUm9PYiZkrADNja15wtRJSJo=
github.com/aws/smithy-go v1.22.3 h1:Z//5NuZCSW6R4PhQ93hShNbyBbn8BWCmCVCt+Q8Io5k=
github.com/aws/smithy-go v1.22.3/go.mod h1:t1ufH5HMublsJYulve2RKmHDC15xu1f26kHCp/HgceI=
github.com/caarlos0/env/v11 v11.3.1 h1:cArPWC15hWmEt+gWk7YBi7lEXTXCvpaSdCiZE2X5mCA=
@@ -312,8 +312,8 @@ modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
modernc.org/sqlite v1.37.1 h1:EgHJK/FPoqC+q2YBXg7fUmES37pCHFc97sI7zSayBEs=
modernc.org/sqlite v1.37.1/go.mod h1:XwdRtsE1MpiBcL54+MbKcaDvcuej+IYSMfLN6gSKV8g=
modernc.org/sqlite v1.38.0 h1:+4OrfPQ8pxHKuWG4md1JpR/EYAh3Md7TdejuuzE7EUI=
modernc.org/sqlite v1.38.0/go.mod h1:1Bj+yES4SVvBZ4cBOpVZ6QgesMCKpJZDq0nxYzOpmNE=
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=

View File

@@ -1,56 +0,0 @@
package agent
import (
"errors"
"time"
"github.com/golang-jwt/jwt/v5"
)
type AgentClaims struct {
AgentID string `json:"agentId,omitempty"`
ProfileID int64 `json:"profileId,omitempty"`
ServerURL string `json:"serverUrl,omitempty"`
jwt.RegisteredClaims
}
// EncodeJWT generates a JWT for agents
func (a *AgentClaims) EncodeJWT(secret string, expirationTime time.Duration) (string, error) {
if a.ServerURL == "" || a.ProfileID == 0 {
return "", errors.New("serverUrl and profileID cannot be empty")
}
if expirationTime == 0 {
expirationTime = time.Hour * 24
}
claims := &AgentClaims{
AgentID: a.AgentID,
ProfileID: a.ProfileID,
ServerURL: a.ServerURL,
RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(time.Now().Add(expirationTime)),
IssuedAt: jwt.NewNumericDate(time.Now()),
},
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
return token.SignedString([]byte(secret))
}
// DecodeJWT decodes the agent token and returns claims if valid
func DecodeJWT(tokenString, secret string) (*AgentClaims, error) {
claims := &AgentClaims{}
token, err := jwt.ParseWithClaims(
tokenString,
claims,
func(token *jwt.Token) (any, error) {
return []byte(secret), nil
},
)
if err != nil || !token.Valid {
return nil, err
}
return claims, nil
}

View File

@@ -6,12 +6,12 @@ import (
"strconv"
"time"
"github.com/MizuchiLabs/mantrae/internal/api/agent"
"github.com/MizuchiLabs/mantrae/internal/config"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/settings"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/google/uuid"
"github.com/mizuchilabs/mantrae/internal/api/service"
"github.com/mizuchilabs/mantrae/internal/config"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/settings"
"github.com/mizuchilabs/mantrae/internal/util"
)
func ListAgents(a *config.App) http.HandlerFunc {
@@ -82,7 +82,7 @@ func CreateAgent(a *config.App) http.HandlerFunc {
return
}
claims := &agent.AgentClaims{
claims := &service.AgentClaims{
AgentID: uuid.New().String(),
ProfileID: profileID,
ServerURL: serverUrl.String("http://127.0.0.1:3000"),
@@ -181,7 +181,7 @@ func RotateAgentToken(a *config.App) http.HandlerFunc {
return
}
claims := &agent.AgentClaims{
claims := &service.AgentClaims{
AgentID: dbAgent.ID,
ProfileID: dbAgent.ProfileID,
ServerURL: serverUrl.String("http://127.0.0.1:3000"),

View File

@@ -6,12 +6,12 @@ import (
"net/http"
"time"
"github.com/MizuchiLabs/mantrae/internal/api/middlewares"
"github.com/MizuchiLabs/mantrae/internal/config"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/mail"
"github.com/MizuchiLabs/mantrae/internal/settings"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/internal/api/middlewares"
"github.com/mizuchilabs/mantrae/internal/config"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/mail"
"github.com/mizuchilabs/mantrae/internal/settings"
"github.com/mizuchilabs/mantrae/internal/util"
"golang.org/x/crypto/bcrypt"
)

View File

@@ -9,10 +9,10 @@ import (
"strconv"
"time"
"github.com/MizuchiLabs/mantrae/internal/backup"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/source"
"github.com/MizuchiLabs/mantrae/internal/traefik"
"github.com/mizuchilabs/mantrae/internal/backup"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/source"
"github.com/mizuchilabs/mantrae/internal/traefik"
)
func CreateBackup(bm *backup.BackupManager) http.HandlerFunc {

View File

@@ -6,10 +6,10 @@ import (
"net/http"
"strconv"
"github.com/MizuchiLabs/mantrae/internal/config"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/dns"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/internal/config"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/dns"
"github.com/mizuchilabs/mantrae/internal/util"
)
func ListDNSProviders(a *config.App) http.HandlerFunc {

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"strconv"
"github.com/MizuchiLabs/mantrae/internal/config"
"github.com/mizuchilabs/mantrae/internal/config"
)
func ListErrors(a *config.App) http.HandlerFunc {

View File

@@ -3,7 +3,7 @@ package handler
import (
"net/http"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/internal/util"
)
// GetEvents streams server-sent events (SSE) for real-time updates.

View File

@@ -7,10 +7,10 @@ import (
"strconv"
"strings"
"github.com/MizuchiLabs/mantrae/internal/config"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/source"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/internal/config"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/source"
"github.com/mizuchilabs/mantrae/internal/util"
"github.com/traefik/traefik/v3/pkg/config/runtime"
)

View File

@@ -12,10 +12,10 @@ import (
"strings"
"time"
"github.com/MizuchiLabs/mantrae/internal/config"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/settings"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/internal/config"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/settings"
"github.com/mizuchilabs/mantrae/internal/util"
"github.com/coreos/go-oidc/v3/oidc"
"golang.org/x/oauth2"
)

View File

@@ -6,11 +6,11 @@ import (
"net/http"
"strconv"
"github.com/MizuchiLabs/mantrae/internal/config"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/source"
"github.com/MizuchiLabs/mantrae/internal/traefik"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/internal/config"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/source"
"github.com/mizuchilabs/mantrae/internal/traefik"
"github.com/mizuchilabs/mantrae/internal/util"
)
func ListProfiles(a *config.App) http.HandlerFunc {

View File

@@ -9,10 +9,10 @@ import (
"strconv"
"strings"
"github.com/MizuchiLabs/mantrae/internal/config"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/source"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/internal/config"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/source"
"github.com/mizuchilabs/mantrae/internal/util"
"github.com/traefik/traefik/v3/pkg/config/runtime"
)

View File

@@ -4,9 +4,9 @@ import (
"encoding/json"
"net/http"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/settings"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/settings"
"github.com/mizuchilabs/mantrae/internal/util"
)
func ListSettings(sm *settings.SettingsManager) http.HandlerFunc {

View File

@@ -5,10 +5,10 @@ import (
"net/http"
"strconv"
"github.com/MizuchiLabs/mantrae/internal/config"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/source"
"github.com/MizuchiLabs/mantrae/internal/traefik"
"github.com/mizuchilabs/mantrae/internal/config"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/source"
"github.com/mizuchilabs/mantrae/internal/traefik"
"github.com/traefik/traefik/v3/pkg/config/runtime"
)

View File

@@ -5,9 +5,9 @@ import (
"net/http"
"strconv"
"github.com/MizuchiLabs/mantrae/internal/config"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/internal/config"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/util"
)
func ListUsers(a *config.App) http.HandlerFunc {

View File

@@ -4,8 +4,8 @@ import (
"encoding/json"
"net/http"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/MizuchiLabs/mantrae/pkg/build"
"github.com/mizuchilabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/pkg/build"
)
// GetVersion returns the current version of Mantrae as a plain text response

View File

@@ -7,10 +7,10 @@ import (
"strings"
"connectrpc.com/connect"
"github.com/MizuchiLabs/mantrae/internal/config"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/MizuchiLabs/mantrae/pkg/meta"
"github.com/mizuchilabs/mantrae/internal/config"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/pkg/meta"
"golang.org/x/crypto/bcrypt"
)

View File

@@ -3,7 +3,7 @@ package middlewares
import (
"net/http"
"github.com/MizuchiLabs/mantrae/internal/config"
"github.com/mizuchilabs/mantrae/internal/config"
)
type Middleware func(http.Handler) http.Handler

View File

@@ -3,8 +3,8 @@ package server
import (
"net/http"
"github.com/MizuchiLabs/mantrae/internal/api/handler"
"github.com/MizuchiLabs/mantrae/internal/api/middlewares"
"github.com/mizuchilabs/mantrae/internal/api/handler"
"github.com/mizuchilabs/mantrae/internal/api/middlewares"
)
func (s *Server) routes() {

View File

@@ -14,12 +14,12 @@ import (
"connectrpc.com/connect"
"connectrpc.com/grpchealth"
"connectrpc.com/grpcreflect"
"github.com/MizuchiLabs/mantrae/agent/proto/gen/agent/v1/agentv1connect"
"github.com/MizuchiLabs/mantrae/internal/api/agent"
"github.com/MizuchiLabs/mantrae/internal/api/middlewares"
"github.com/MizuchiLabs/mantrae/internal/config"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/MizuchiLabs/mantrae/web"
"github.com/mizuchilabs/mantrae/internal/api/middlewares"
"github.com/mizuchilabs/mantrae/internal/api/service"
"github.com/mizuchilabs/mantrae/internal/config"
"github.com/mizuchilabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/proto/gen/agent/v1/agentv1connect"
"github.com/mizuchilabs/mantrae/web"
)
type Server struct {
@@ -140,8 +140,8 @@ func (s *Server) registerServices() {
serviceNames := []string{agentv1connect.AgentServiceName}
reflector := grpcreflect.NewStaticReflector(serviceNames...)
checker := grpchealth.NewStaticChecker(serviceNames...)
reflector := grpcreflect.NewStaticReflector(serviceNames...)
s.mux.Handle(grpchealth.NewHandler(checker))
s.mux.Handle(grpcreflect.NewHandlerV1(reflector))
@@ -149,5 +149,7 @@ func (s *Server) registerServices() {
// Service implementations
agentOpts := append(opts, connect.WithInterceptors(middlewares.AgentAuth(s.app)))
s.mux.Handle(agentv1connect.NewAgentServiceHandler(agent.NewAgentServer(s.app), agentOpts...))
s.mux.Handle(
agentv1connect.NewAgentServiceHandler(service.NewAgentService(s.app), agentOpts...),
)
}

View File

@@ -1,4 +1,4 @@
package agent
package service
import (
"context"
@@ -8,25 +8,26 @@ import (
"connectrpc.com/connect"
agentv1 "github.com/MizuchiLabs/mantrae/agent/proto/gen/agent/v1"
"github.com/MizuchiLabs/mantrae/internal/api/middlewares"
"github.com/MizuchiLabs/mantrae/internal/config"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/settings"
"github.com/MizuchiLabs/mantrae/internal/traefik"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/MizuchiLabs/mantrae/pkg/meta"
"github.com/golang-jwt/jwt/v5"
"github.com/mizuchilabs/mantrae/internal/api/middlewares"
"github.com/mizuchilabs/mantrae/internal/config"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/settings"
"github.com/mizuchilabs/mantrae/internal/traefik"
"github.com/mizuchilabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/pkg/meta"
agentv1 "github.com/mizuchilabs/mantrae/proto/gen/agent/v1"
)
type AgentServer struct {
type AgentService struct {
app *config.App
}
func NewAgentServer(app *config.App) *AgentServer {
return &AgentServer{app: app}
func NewAgentService(app *config.App) *AgentService {
return &AgentService{app: app}
}
func (s *AgentServer) HealthCheck(
func (s *AgentService) HealthCheck(
ctx context.Context,
req *connect.Request[agentv1.HealthCheckRequest],
) (*connect.Response[agentv1.HealthCheckResponse], error) {
@@ -42,7 +43,7 @@ func (s *AgentServer) HealthCheck(
return connect.NewResponse(&agentv1.HealthCheckResponse{Ok: true, Token: *token}), nil
}
func (s *AgentServer) GetContainer(
func (s *AgentService) GetContainer(
ctx context.Context,
req *connect.Request[agentv1.GetContainerRequest],
) (*connect.Response[agentv1.GetContainerResponse], error) {
@@ -100,7 +101,7 @@ func (s *AgentServer) GetContainer(
return connect.NewResponse(&agentv1.GetContainerResponse{}), nil
}
func (s *AgentServer) updateToken(ctx context.Context, id string) (*string, error) {
func (s *AgentService) updateToken(ctx context.Context, id string) (*string, error) {
q := s.app.Conn.GetQuery()
agent, err := q.GetAgent(ctx, id)
if err != nil {
@@ -113,8 +114,8 @@ func (s *AgentServer) updateToken(ctx context.Context, id string) (*string, erro
}
// Only update the token if it's close to expiring (less than 25%)
lifetime := claims.ExpiresAt.Time.Sub(claims.IssuedAt.Time)
remaining := claims.ExpiresAt.Time.Sub(time.Now())
lifetime := claims.ExpiresAt.Sub(claims.IssuedAt.Time)
remaining := time.Until(claims.ExpiresAt.Time)
if remaining > lifetime/4 {
return &agent.Token, nil // Still valid
}
@@ -137,3 +138,52 @@ func (s *AgentServer) updateToken(ctx context.Context, id string) (*string, erro
return &token, nil
}
// Helpers --------------------------------------------------------------------
type AgentClaims struct {
AgentID string `json:"agentId,omitempty"`
ProfileID int64 `json:"profileId,omitempty"`
ServerURL string `json:"serverUrl,omitempty"`
jwt.RegisteredClaims
}
// EncodeJWT generates a JWT for agents
func (a *AgentClaims) EncodeJWT(secret string, expirationTime time.Duration) (string, error) {
if a.ServerURL == "" || a.ProfileID == 0 {
return "", errors.New("serverUrl and profileID cannot be empty")
}
if expirationTime == 0 {
expirationTime = time.Hour * 24
}
claims := &AgentClaims{
AgentID: a.AgentID,
ProfileID: a.ProfileID,
ServerURL: a.ServerURL,
RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(time.Now().Add(expirationTime)),
IssuedAt: jwt.NewNumericDate(time.Now()),
},
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
return token.SignedString([]byte(secret))
}
// DecodeJWT decodes the agent token and returns claims if valid
func DecodeJWT(tokenString, secret string) (*AgentClaims, error) {
claims := &AgentClaims{}
token, err := jwt.ParseWithClaims(
tokenString,
claims,
func(token *jwt.Token) (any, error) {
return []byte(secret), nil
},
)
if err != nil || !token.Valid {
return nil, err
}
return claims, nil
}

View File

@@ -0,0 +1,50 @@
package service
import (
"time"
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/wrapperspb"
)
func SafeString(s *string) string {
if s == nil {
return ""
}
return *s
}
func SafeInt32(i *int32) int32 {
if i == nil {
return 0
}
return *i
}
func SafeInt64(i *int64) int64 {
if i == nil {
return 0
}
return *i
}
func SafeFloat(f *float64) float64 {
if f == nil {
return 0.0
}
return *f
}
func SafeBool(b *bool) *wrapperspb.BoolValue {
if b == nil {
return wrapperspb.Bool(false)
}
return wrapperspb.Bool(*b)
}
func SafeTimestamp(t *time.Time) *timestamppb.Timestamp {
if t == nil {
return nil
}
return timestamppb.New(*t)
}

View File

@@ -0,0 +1,150 @@
package service
import (
"context"
"connectrpc.com/connect"
"github.com/google/uuid"
"github.com/mizuchilabs/mantrae/internal/config"
"github.com/mizuchilabs/mantrae/internal/db"
profilev1 "github.com/mizuchilabs/mantrae/proto/gen/server/v1"
)
type ProfileService struct {
app *config.App
}
func NewProfileService(app *config.App) *ProfileService {
return &ProfileService{app: app}
}
func (s *ProfileService) GetProfile(
ctx context.Context,
req *connect.Request[profilev1.GetProfileRequest],
) (*connect.Response[profilev1.GetProfileResponse], error) {
profile, err := s.app.Conn.GetQuery().GetProfile(ctx, req.Msg.Id)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, err)
}
return connect.NewResponse(&profilev1.GetProfileResponse{
Profile: &profilev1.Profile{
Id: profile.ID,
Name: profile.Name,
Description: SafeString(profile.Description),
CreatedAt: SafeTimestamp(profile.CreatedAt),
UpdatedAt: SafeTimestamp(profile.UpdatedAt),
},
}), nil
}
func (s *ProfileService) CreateProfile(
ctx context.Context,
req *connect.Request[profilev1.CreateProfileRequest],
) (*connect.Response[profilev1.CreateProfileResponse], error) {
id, err := uuid.NewV7()
if err != nil {
return nil, connect.NewError(connect.CodeInternal, err)
}
params := db.CreateProfileParams{
ID: id.String(),
Name: req.Msg.Name,
}
if req.Msg.Description != nil {
params.Description = req.Msg.Description
}
profile, err := s.app.Conn.GetQuery().CreateProfile(ctx, params)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, err)
}
return connect.NewResponse(&profilev1.CreateProfileResponse{
Profile: &profilev1.Profile{
Id: profile.ID,
Name: profile.Name,
Description: SafeString(profile.Description),
CreatedAt: SafeTimestamp(profile.CreatedAt),
UpdatedAt: SafeTimestamp(profile.UpdatedAt),
},
}), nil
}
func (s *ProfileService) UpdateProfile(
ctx context.Context,
req *connect.Request[profilev1.UpdateProfileRequest],
) (*connect.Response[profilev1.UpdateProfileResponse], error) {
params := db.UpdateProfileParams{
ID: req.Msg.Id,
Name: req.Msg.Name,
}
if req.Msg.Description != nil {
params.Description = req.Msg.Description
}
profile, err := s.app.Conn.GetQuery().UpdateProfile(ctx, params)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, err)
}
return connect.NewResponse(&profilev1.UpdateProfileResponse{
Profile: &profilev1.Profile{
Id: profile.ID,
Name: profile.Name,
Description: SafeString(profile.Description),
CreatedAt: SafeTimestamp(profile.CreatedAt),
UpdatedAt: SafeTimestamp(profile.UpdatedAt),
},
}), nil
}
func (s *ProfileService) DeleteProfile(
ctx context.Context,
req *connect.Request[profilev1.DeleteProfileRequest],
) (*connect.Response[profilev1.DeleteProfileResponse], error) {
err := s.app.Conn.GetQuery().DeleteProfile(ctx, req.Msg.Id)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, err)
}
return connect.NewResponse(&profilev1.DeleteProfileResponse{}), nil
}
func (s *ProfileService) ListProfiles(
ctx context.Context,
req *connect.Request[profilev1.ListProfilesRequest],
) (*connect.Response[profilev1.ListProfilesResponse], error) {
var params db.ListProfilesParams
if req.Msg.Limit == nil {
params.Limit = 100
} else {
params.Limit = *req.Msg.Limit
}
if req.Msg.Offset == nil {
params.Offset = 0
} else {
params.Offset = *req.Msg.Offset
}
dbProfiles, err := s.app.Conn.GetQuery().ListProfiles(ctx, params)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, err)
}
totalCount, err := s.app.Conn.GetQuery().CountProfiles(ctx)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, err)
}
var profiles []*profilev1.Profile
for _, profile := range dbProfiles {
profiles = append(profiles, &profilev1.Profile{
Id: profile.ID,
Name: profile.Name,
Description: SafeString(profile.Description),
CreatedAt: SafeTimestamp(profile.CreatedAt),
UpdatedAt: SafeTimestamp(profile.UpdatedAt),
})
}
return connect.NewResponse(&profilev1.ListProfilesResponse{
Profiles: profiles,
TotalCount: totalCount,
}), nil
}

View File

@@ -11,10 +11,10 @@ import (
"sync"
"time"
"github.com/MizuchiLabs/mantrae/internal/app"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/settings"
"github.com/MizuchiLabs/mantrae/internal/storage"
"github.com/mizuchilabs/mantrae/internal/app"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/settings"
"github.com/mizuchilabs/mantrae/internal/storage"
)
type BackupManager struct {

View File

@@ -7,8 +7,8 @@ import (
"fmt"
"os"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/pkg/build"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/pkg/build"
)
type Flags struct {

View File

@@ -7,13 +7,13 @@ import (
"os"
"strings"
"github.com/MizuchiLabs/mantrae/internal/app"
"github.com/MizuchiLabs/mantrae/internal/backup"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/settings"
"github.com/MizuchiLabs/mantrae/internal/source"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/MizuchiLabs/mantrae/pkg/logger"
"github.com/mizuchilabs/mantrae/internal/app"
"github.com/mizuchilabs/mantrae/internal/backup"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/settings"
"github.com/mizuchilabs/mantrae/internal/source"
"github.com/mizuchilabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/pkg/logger"
"golang.org/x/crypto/bcrypt"
)

View File

@@ -5,10 +5,10 @@ import (
"log/slog"
"time"
"github.com/MizuchiLabs/mantrae/internal/dns"
"github.com/MizuchiLabs/mantrae/internal/settings"
"github.com/MizuchiLabs/mantrae/internal/traefik"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/internal/dns"
"github.com/mizuchilabs/mantrae/internal/settings"
"github.com/mizuchilabs/mantrae/internal/traefik"
"github.com/mizuchilabs/mantrae/internal/util"
)
// setupBackgroundJobs initiates essential background operations for the application.

View File

@@ -1,11 +1,8 @@
-- +goose Up
CREATE TABLE "profiles" (
id INTEGER PRIMARY KEY AUTOINCREMENT,
id TEXT PRIMARY KEY,
name VARCHAR(255) NOT NULL UNIQUE,
url TEXT NOT NULL,
username VARCHAR(255),
password TEXT,
tls BOOLEAN NOT NULL DEFAULT FALSE,
description TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
@@ -107,8 +104,8 @@ WHERE
is_active = 1;
END;
-- +goose StatementEnd
-- +goose StatementEnd
-- +goose StatementBegin
CREATE TRIGGER ensure_single_active_update BEFORE
UPDATE ON dns_providers FOR EACH ROW WHEN NEW.is_active = 1 BEGIN
@@ -119,16 +116,23 @@ WHERE
is_active = 1;
END;
-- +goose StatementEnd
-- +goose StatementEnd
CREATE UNIQUE INDEX unique_dns_error ON errors (profile_id, category, details);
-- +goose Down
DROP TABLE IF EXISTS profiles;
DROP TABLE IF EXISTS dns_providers;
DROP TABLE IF EXISTS traefik;
DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS settings;
DROP TABLE IF EXISTS agents;
DROP TABLE IF EXISTS router_dns_provider;
DROP TABLE IF EXISTS errors;

View File

@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// sqlc v1.29.0
// source: agents.sql
package db

View File

@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// sqlc v1.29.0
package db
@@ -27,6 +27,9 @@ func Prepare(ctx context.Context, db DBTX) (*Queries, error) {
if q.addRouterDNSProviderStmt, err = db.PrepareContext(ctx, addRouterDNSProvider); err != nil {
return nil, fmt.Errorf("error preparing query AddRouterDNSProvider: %w", err)
}
if q.countProfilesStmt, err = db.PrepareContext(ctx, countProfiles); err != nil {
return nil, fmt.Errorf("error preparing query CountProfiles: %w", err)
}
if q.createAgentStmt, err = db.PrepareContext(ctx, createAgent); err != nil {
return nil, fmt.Errorf("error preparing query CreateAgent: %w", err)
}
@@ -202,6 +205,11 @@ func (q *Queries) Close() error {
err = fmt.Errorf("error closing addRouterDNSProviderStmt: %w", cerr)
}
}
if q.countProfilesStmt != nil {
if cerr := q.countProfilesStmt.Close(); cerr != nil {
err = fmt.Errorf("error closing countProfilesStmt: %w", cerr)
}
}
if q.createAgentStmt != nil {
if cerr := q.createAgentStmt.Close(); cerr != nil {
err = fmt.Errorf("error closing createAgentStmt: %w", cerr)
@@ -517,6 +525,7 @@ type Queries struct {
db DBTX
tx *sql.Tx
addRouterDNSProviderStmt *sql.Stmt
countProfilesStmt *sql.Stmt
createAgentStmt *sql.Stmt
createDNSProviderStmt *sql.Stmt
createProfileStmt *sql.Stmt
@@ -579,6 +588,7 @@ func (q *Queries) WithTx(tx *sql.Tx) *Queries {
db: tx,
tx: tx,
addRouterDNSProviderStmt: q.addRouterDNSProviderStmt,
countProfilesStmt: q.countProfilesStmt,
createAgentStmt: q.createAgentStmt,
createDNSProviderStmt: q.createDNSProviderStmt,
createProfileStmt: q.createProfileStmt,

View File

@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// sqlc v1.29.0
// source: dns_providers.sql
package db

View File

@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// sqlc v1.29.0
// source: errors.sql
package db

View File

@@ -6,8 +6,8 @@ import (
"embed"
"fmt"
"github.com/MizuchiLabs/mantrae/internal/app"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/internal/app"
"github.com/mizuchilabs/mantrae/internal/util"
"github.com/pressly/goose/v3"
"modernc.org/sqlite"
)

View File

@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// sqlc v1.29.0
package db
@@ -43,14 +43,11 @@ type Error struct {
}
type Profile struct {
ID int64 `json:"id"`
Name string `json:"name"`
Url string `json:"url"`
Username *string `json:"username"`
Password *string `json:"password"`
Tls bool `json:"tls"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
ID string `json:"id"`
Name string `json:"name"`
Description *string `json:"description"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
}
type RouterDnsProvider struct {

View File

@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// sqlc v1.29.0
// source: profiles.sql
package db
@@ -9,32 +9,44 @@ import (
"context"
)
const countProfiles = `-- name: CountProfiles :one
SELECT
COUNT(*)
FROM
profiles
`
func (q *Queries) CountProfiles(ctx context.Context) (int64, error) {
row := q.queryRow(ctx, q.countProfilesStmt, countProfiles)
var count int64
err := row.Scan(&count)
return count, err
}
const createProfile = `-- name: CreateProfile :one
INSERT INTO
profiles (name, url, username, password, tls)
profiles (id, name, description, created_at, updated_at)
VALUES
(?, ?, ?, ?, ?) RETURNING id
(?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) RETURNING id, name, description, created_at, updated_at
`
type CreateProfileParams struct {
Name string `json:"name"`
Url string `json:"url"`
Username *string `json:"username"`
Password *string `json:"password"`
Tls bool `json:"tls"`
ID string `json:"id"`
Name string `json:"name"`
Description *string `json:"description"`
}
func (q *Queries) CreateProfile(ctx context.Context, arg CreateProfileParams) (int64, error) {
row := q.queryRow(ctx, q.createProfileStmt, createProfile,
arg.Name,
arg.Url,
arg.Username,
arg.Password,
arg.Tls,
func (q *Queries) CreateProfile(ctx context.Context, arg CreateProfileParams) (Profile, error) {
row := q.queryRow(ctx, q.createProfileStmt, createProfile, arg.ID, arg.Name, arg.Description)
var i Profile
err := row.Scan(
&i.ID,
&i.Name,
&i.Description,
&i.CreatedAt,
&i.UpdatedAt,
)
var id int64
err := row.Scan(&id)
return id, err
return i, err
}
const deleteProfile = `-- name: DeleteProfile :exec
@@ -43,30 +55,27 @@ WHERE
id = ?
`
func (q *Queries) DeleteProfile(ctx context.Context, id int64) error {
func (q *Queries) DeleteProfile(ctx context.Context, id string) error {
_, err := q.exec(ctx, q.deleteProfileStmt, deleteProfile, id)
return err
}
const getProfile = `-- name: GetProfile :one
SELECT
id, name, url, username, password, tls, created_at, updated_at
id, name, description, created_at, updated_at
FROM
profiles
WHERE
id = ?
`
func (q *Queries) GetProfile(ctx context.Context, id int64) (Profile, error) {
func (q *Queries) GetProfile(ctx context.Context, id string) (Profile, error) {
row := q.queryRow(ctx, q.getProfileStmt, getProfile, id)
var i Profile
err := row.Scan(
&i.ID,
&i.Name,
&i.Url,
&i.Username,
&i.Password,
&i.Tls,
&i.Description,
&i.CreatedAt,
&i.UpdatedAt,
)
@@ -75,7 +84,7 @@ func (q *Queries) GetProfile(ctx context.Context, id int64) (Profile, error) {
const getProfileByName = `-- name: GetProfileByName :one
SELECT
id, name, url, username, password, tls, created_at, updated_at
id, name, description, created_at, updated_at
FROM
profiles
WHERE
@@ -88,10 +97,7 @@ func (q *Queries) GetProfileByName(ctx context.Context, name string) (Profile, e
err := row.Scan(
&i.ID,
&i.Name,
&i.Url,
&i.Username,
&i.Password,
&i.Tls,
&i.Description,
&i.CreatedAt,
&i.UpdatedAt,
)
@@ -100,15 +106,24 @@ func (q *Queries) GetProfileByName(ctx context.Context, name string) (Profile, e
const listProfiles = `-- name: ListProfiles :many
SELECT
id, name, url, username, password, tls, created_at, updated_at
id, name, description, created_at, updated_at
FROM
profiles
ORDER BY
name
LIMIT
?
OFFSET
?
`
func (q *Queries) ListProfiles(ctx context.Context) ([]Profile, error) {
rows, err := q.query(ctx, q.listProfilesStmt, listProfiles)
type ListProfilesParams struct {
Limit int64 `json:"limit"`
Offset int64 `json:"offset"`
}
func (q *Queries) ListProfiles(ctx context.Context, arg ListProfilesParams) ([]Profile, error) {
rows, err := q.query(ctx, q.listProfilesStmt, listProfiles, arg.Limit, arg.Offset)
if err != nil {
return nil, err
}
@@ -119,10 +134,7 @@ func (q *Queries) ListProfiles(ctx context.Context) ([]Profile, error) {
if err := rows.Scan(
&i.ID,
&i.Name,
&i.Url,
&i.Username,
&i.Password,
&i.Tls,
&i.Description,
&i.CreatedAt,
&i.UpdatedAt,
); err != nil {
@@ -139,36 +151,31 @@ func (q *Queries) ListProfiles(ctx context.Context) ([]Profile, error) {
return items, nil
}
const updateProfile = `-- name: UpdateProfile :exec
const updateProfile = `-- name: UpdateProfile :one
UPDATE profiles
SET
name = ?,
url = ?,
username = ?,
password = ?,
tls = ?,
description = ?,
updated_at = CURRENT_TIMESTAMP
WHERE
id = ?
id = ? RETURNING id, name, description, created_at, updated_at
`
type UpdateProfileParams struct {
Name string `json:"name"`
Url string `json:"url"`
Username *string `json:"username"`
Password *string `json:"password"`
Tls bool `json:"tls"`
ID int64 `json:"id"`
Name string `json:"name"`
Description *string `json:"description"`
ID string `json:"id"`
}
func (q *Queries) UpdateProfile(ctx context.Context, arg UpdateProfileParams) error {
_, err := q.exec(ctx, q.updateProfileStmt, updateProfile,
arg.Name,
arg.Url,
arg.Username,
arg.Password,
arg.Tls,
arg.ID,
func (q *Queries) UpdateProfile(ctx context.Context, arg UpdateProfileParams) (Profile, error) {
row := q.queryRow(ctx, q.updateProfileStmt, updateProfile, arg.Name, arg.Description, arg.ID)
var i Profile
err := row.Scan(
&i.ID,
&i.Name,
&i.Description,
&i.CreatedAt,
&i.UpdatedAt,
)
return err
return i, err
}

View File

@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// sqlc v1.29.0
package db
@@ -10,16 +10,17 @@ import (
type Querier interface {
AddRouterDNSProvider(ctx context.Context, arg AddRouterDNSProviderParams) error
CountProfiles(ctx context.Context) (int64, error)
CreateAgent(ctx context.Context, arg CreateAgentParams) error
CreateDNSProvider(ctx context.Context, arg CreateDNSProviderParams) error
CreateProfile(ctx context.Context, arg CreateProfileParams) (int64, error)
CreateProfile(ctx context.Context, arg CreateProfileParams) (Profile, error)
CreateUser(ctx context.Context, arg CreateUserParams) (int64, error)
DeleteAgent(ctx context.Context, id string) error
DeleteDNSProvider(ctx context.Context, id int64) error
DeleteErrorById(ctx context.Context, id int64) error
DeleteErrorsByProfile(ctx context.Context, profileID int64) error
DeleteErrorsByProfileCategory(ctx context.Context, arg DeleteErrorsByProfileCategoryParams) error
DeleteProfile(ctx context.Context, id int64) error
DeleteProfile(ctx context.Context, id string) error
DeleteRouterDNSProvider(ctx context.Context, arg DeleteRouterDNSProviderParams) error
DeleteSetting(ctx context.Context, key string) error
DeleteTraefikConfig(ctx context.Context, id int64) error
@@ -32,7 +33,7 @@ type Querier interface {
GetDNSProvider(ctx context.Context, id int64) (DnsProvider, error)
GetErrorsByProfile(ctx context.Context, profileID int64) ([]Error, error)
GetLocalTraefikConfig(ctx context.Context, profileID int64) (Traefik, error)
GetProfile(ctx context.Context, id int64) (Profile, error)
GetProfile(ctx context.Context, id string) (Profile, error)
GetProfileByName(ctx context.Context, name string) (Profile, error)
GetRouterDNSProviderByID(ctx context.Context, arg GetRouterDNSProviderByIDParams) (GetRouterDNSProviderByIDRow, error)
GetRouterDNSProviders(ctx context.Context, arg GetRouterDNSProvidersParams) ([]GetRouterDNSProvidersRow, error)
@@ -47,7 +48,7 @@ type Querier interface {
ListAgentsByProfile(ctx context.Context, profileID int64) ([]Agent, error)
ListDNSProviders(ctx context.Context) ([]DnsProvider, error)
ListErrors(ctx context.Context) ([]Error, error)
ListProfiles(ctx context.Context) ([]Profile, error)
ListProfiles(ctx context.Context, arg ListProfilesParams) ([]Profile, error)
ListRouterDNSProvidersByTraefikID(ctx context.Context, traefikID int64) ([]ListRouterDNSProvidersByTraefikIDRow, error)
ListSettings(ctx context.Context) ([]Setting, error)
ListTraefikIDs(ctx context.Context) ([]int64, error)
@@ -57,7 +58,7 @@ type Querier interface {
UpdateAgentIP(ctx context.Context, arg UpdateAgentIPParams) error
UpdateAgentToken(ctx context.Context, arg UpdateAgentTokenParams) error
UpdateDNSProvider(ctx context.Context, arg UpdateDNSProviderParams) error
UpdateProfile(ctx context.Context, arg UpdateProfileParams) error
UpdateProfile(ctx context.Context, arg UpdateProfileParams) (Profile, error)
UpdateUser(ctx context.Context, arg UpdateUserParams) error
UpdateUserLastLogin(ctx context.Context, id int64) error
UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) error

View File

@@ -1,8 +1,8 @@
-- name: CreateProfile :one
INSERT INTO
profiles (name, url, username, password, tls)
profiles (id, name, description, created_at, updated_at)
VALUES
(?, ?, ?, ?, ?) RETURNING id;
(?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) RETURNING *;
-- name: GetProfile :one
SELECT
@@ -26,19 +26,26 @@ SELECT
FROM
profiles
ORDER BY
name;
name
LIMIT
?
OFFSET
?;
-- name: UpdateProfile :exec
-- name: CountProfiles :one
SELECT
COUNT(*)
FROM
profiles;
-- name: UpdateProfile :one
UPDATE profiles
SET
name = ?,
url = ?,
username = ?,
password = ?,
tls = ?,
description = ?,
updated_at = CURRENT_TIMESTAMP
WHERE
id = ?;
id = ? RETURNING *;
-- name: DeleteProfile :exec
DELETE FROM profiles

View File

@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// sqlc v1.29.0
// source: router_dns_provider.sql
package db

View File

@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// sqlc v1.29.0
// source: settings.sql
package db

View File

@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// sqlc v1.29.0
// source: traefik.sql
package db

View File

@@ -1,6 +1,6 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// sqlc v1.29.0
// source: users.sql
package db

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"strings"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/internal/util"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
)

View File

@@ -6,8 +6,8 @@ import (
"fmt"
"log/slog"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/util"
)
type DNSProvider interface {

View File

@@ -5,8 +5,8 @@ import (
"fmt"
"log/slog"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/util"
"github.com/cloudflare/cloudflare-go"
)

View File

@@ -5,8 +5,8 @@ import (
"fmt"
"log/slog"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/util"
"github.com/joeig/go-powerdns/v3"
)

View File

@@ -11,8 +11,8 @@ import (
"net/url"
"slices"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/util"
)
type TechnitiumProvider struct {

View File

@@ -5,7 +5,7 @@ import (
"html/template"
"net/smtp"
"github.com/MizuchiLabs/mantrae/internal/mail/templates"
"github.com/mizuchilabs/mantrae/internal/mail/templates"
"github.com/domodwyer/mailyak/v3"
)

View File

@@ -8,7 +8,7 @@ import (
"strconv"
"time"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/db"
)
type SettingWithDescription struct {

View File

@@ -6,7 +6,7 @@ import (
"strconv"
"strings"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/db"
)
func (sm *SettingsManager) validateSetting(

View File

@@ -8,7 +8,7 @@ import (
"path/filepath"
"sort"
"github.com/MizuchiLabs/mantrae/internal/app"
"github.com/mizuchilabs/mantrae/internal/app"
)
// LocalStorage implements StorageBackend for local filesystem

View File

@@ -8,7 +8,7 @@ import (
"sort"
"time"
"github.com/MizuchiLabs/mantrae/internal/settings"
"github.com/mizuchilabs/mantrae/internal/settings"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials"

View File

@@ -5,7 +5,7 @@ import (
"database/sql"
"fmt"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/traefik/paerser/parser"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/config/runtime"

View File

@@ -11,9 +11,9 @@ import (
"net/http"
"time"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/MizuchiLabs/mantrae/internal/source"
"github.com/MizuchiLabs/mantrae/internal/util"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/source"
"github.com/mizuchilabs/mantrae/internal/util"
)
const (

View File

@@ -6,7 +6,7 @@ import (
"io"
"mime/multipart"
"github.com/MizuchiLabs/mantrae/internal/db"
"github.com/mizuchilabs/mantrae/internal/db"
"github.com/traefik/traefik/v3/pkg/config/dynamic"
"github.com/traefik/traefik/v3/pkg/config/runtime"
"golang.org/x/exp/maps"

View File

@@ -7,8 +7,8 @@ import (
"os/signal"
"syscall"
"github.com/MizuchiLabs/mantrae/internal/api/server"
"github.com/MizuchiLabs/mantrae/internal/config"
"github.com/mizuchilabs/mantrae/internal/api/server"
"github.com/mizuchilabs/mantrae/internal/config"
)
func main() {

View File

@@ -16,7 +16,7 @@ import (
)
const (
RepoURL = "https://api.github.com/repos/MizuchiLabs/mantrae"
RepoURL = "https://api.github.com/repos/mizuchilabs/mantrae"
)
type releaseAsset struct {

View File

@@ -4,7 +4,7 @@ import (
"log/slog"
"strings"
"github.com/MizuchiLabs/mantrae/pkg/util"
"github.com/mizuchilabs/mantrae/pkg/util"
)
func Setup() {

View File

@@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.5
// protoc-gen-go v1.36.6
// protoc (unknown)
// source: agent/v1/agent.proto
@@ -316,78 +316,42 @@ func (x *HealthCheckResponse) GetToken() string {
var File_agent_v1_agent_proto protoreflect.FileDescriptor
var file_agent_v1_agent_proto_rawDesc = string([]byte{
0x0a, 0x14, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x67, 0x65, 0x6e, 0x74,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x76, 0x31,
0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x22, 0xff, 0x02, 0x0a, 0x09, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x12,
0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12,
0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e,
0x61, 0x6d, 0x65, 0x12, 0x37, 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x18, 0x03, 0x20,
0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x43,
0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45,
0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x12, 0x14, 0x0a, 0x05,
0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x6d, 0x61,
0x67, 0x65, 0x12, 0x3a, 0x0a, 0x07, 0x70, 0x6f, 0x72, 0x74, 0x6d, 0x61, 0x70, 0x18, 0x05, 0x20,
0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x43,
0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x6d, 0x61, 0x70,
0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x70, 0x6f, 0x72, 0x74, 0x6d, 0x61, 0x70, 0x12, 0x16,
0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x34, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65,
0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74,
0x61, 0x6d, 0x70, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x1a, 0x39, 0x0a, 0x0b,
0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b,
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61,
0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3a, 0x0a, 0x0c, 0x50, 0x6f, 0x72, 0x74, 0x6d,
0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01,
0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c,
0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a,
0x02, 0x38, 0x01, 0x22, 0xda, 0x01, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61,
0x69, 0x6e, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x68,
0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x68,
0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69,
0x63, 0x5f, 0x69, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c,
0x69, 0x63, 0x49, 0x70, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x5f,
0x69, 0x70, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x69, 0x76, 0x61,
0x74, 0x65, 0x49, 0x70, 0x73, 0x12, 0x33, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e,
0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x61, 0x67, 0x65, 0x6e,
0x74, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x0a,
0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x12, 0x34, 0x0a, 0x07, 0x75, 0x70,
0x64, 0x61, 0x74, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69,
0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x07, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64,
0x22, 0x16, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x0a, 0x12, 0x48, 0x65, 0x61, 0x6c,
0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x3b,
0x0a, 0x13, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28,
0x08, 0x52, 0x02, 0x6f, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x32, 0xa9, 0x01, 0x0a, 0x0c,
0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4d, 0x0a, 0x0c,
0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x12, 0x1d, 0x2e, 0x61,
0x67, 0x65, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61,
0x69, 0x6e, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x61, 0x67,
0x65, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69,
0x6e, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x0b, 0x48,
0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x1c, 0x2e, 0x61, 0x67, 0x65,
0x6e, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63,
0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x61, 0x67, 0x65, 0x6e, 0x74,
0x2e, 0x76, 0x31, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x9c, 0x01, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x2e,
0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x50,
0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x4d, 0x69, 0x7a, 0x75, 0x63, 0x68, 0x69, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x6d,
0x61, 0x6e, 0x74, 0x72, 0x61, 0x65, 0x2f, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x3b,
0x61, 0x67, 0x65, 0x6e, 0x74, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x41, 0x58, 0x58, 0xaa, 0x02, 0x08,
0x41, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x08, 0x41, 0x67, 0x65, 0x6e, 0x74,
0x5c, 0x56, 0x31, 0xe2, 0x02, 0x14, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x47,
0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x09, 0x41, 0x67, 0x65,
0x6e, 0x74, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
})
const file_agent_v1_agent_proto_rawDesc = "" +
"\n" +
"\x14agent/v1/agent.proto\x12\bagent.v1\x1a\x1fgoogle/protobuf/timestamp.proto\"\xff\x02\n" +
"\tContainer\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" +
"\x04name\x18\x02 \x01(\tR\x04name\x127\n" +
"\x06labels\x18\x03 \x03(\v2\x1f.agent.v1.Container.LabelsEntryR\x06labels\x12\x14\n" +
"\x05image\x18\x04 \x01(\tR\x05image\x12:\n" +
"\aportmap\x18\x05 \x03(\v2 .agent.v1.Container.PortmapEntryR\aportmap\x12\x16\n" +
"\x06status\x18\x06 \x01(\tR\x06status\x124\n" +
"\acreated\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\acreated\x1a9\n" +
"\vLabelsEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\x1a:\n" +
"\fPortmapEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\x05R\x03key\x12\x14\n" +
"\x05value\x18\x02 \x01(\x05R\x05value:\x028\x01\"\xda\x01\n" +
"\x13GetContainerRequest\x12\x1a\n" +
"\bhostname\x18\x01 \x01(\tR\bhostname\x12\x1b\n" +
"\tpublic_ip\x18\x02 \x01(\tR\bpublicIp\x12\x1f\n" +
"\vprivate_ips\x18\x03 \x03(\tR\n" +
"privateIps\x123\n" +
"\n" +
"containers\x18\x04 \x03(\v2\x13.agent.v1.ContainerR\n" +
"containers\x124\n" +
"\aupdated\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\aupdated\"\x16\n" +
"\x14GetContainerResponse\"\x14\n" +
"\x12HealthCheckRequest\";\n" +
"\x13HealthCheckResponse\x12\x0e\n" +
"\x02ok\x18\x01 \x01(\bR\x02ok\x12\x14\n" +
"\x05token\x18\x02 \x01(\tR\x05token2\xa9\x01\n" +
"\fAgentService\x12M\n" +
"\fGetContainer\x12\x1d.agent.v1.GetContainerRequest\x1a\x1e.agent.v1.GetContainerResponse\x12J\n" +
"\vHealthCheck\x12\x1c.agent.v1.HealthCheckRequest\x1a\x1d.agent.v1.HealthCheckResponseB\x96\x01\n" +
"\fcom.agent.v1B\n" +
"AgentProtoP\x01Z9github.com/mizuchilabs/mantrae/proto/gen/agent/v1;agentv1\xa2\x02\x03AXX\xaa\x02\bAgent.V1\xca\x02\bAgent\\V1\xe2\x02\x14Agent\\V1\\GPBMetadata\xea\x02\tAgent::V1b\x06proto3"
var (
file_agent_v1_agent_proto_rawDescOnce sync.Once

View File

@@ -8,7 +8,7 @@ import (
connect "connectrpc.com/connect"
context "context"
errors "errors"
v1 "github.com/MizuchiLabs/mantrae/agent/proto/gen/agent/v1"
v1 "github.com/mizuchilabs/mantrae/proto/gen/agent/v1"
http "net/http"
strings "strings"
)

View File

@@ -0,0 +1,701 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.6
// protoc (unknown)
// source: server/v1/profile.proto
package serverv1
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type Profile struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
CreatedAt *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Profile) Reset() {
*x = Profile{}
mi := &file_server_v1_profile_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Profile) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Profile) ProtoMessage() {}
func (x *Profile) ProtoReflect() protoreflect.Message {
mi := &file_server_v1_profile_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Profile.ProtoReflect.Descriptor instead.
func (*Profile) Descriptor() ([]byte, []int) {
return file_server_v1_profile_proto_rawDescGZIP(), []int{0}
}
func (x *Profile) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *Profile) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Profile) GetDescription() string {
if x != nil {
return x.Description
}
return ""
}
func (x *Profile) GetCreatedAt() *timestamppb.Timestamp {
if x != nil {
return x.CreatedAt
}
return nil
}
func (x *Profile) GetUpdatedAt() *timestamppb.Timestamp {
if x != nil {
return x.UpdatedAt
}
return nil
}
type GetProfileRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetProfileRequest) Reset() {
*x = GetProfileRequest{}
mi := &file_server_v1_profile_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetProfileRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetProfileRequest) ProtoMessage() {}
func (x *GetProfileRequest) ProtoReflect() protoreflect.Message {
mi := &file_server_v1_profile_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetProfileRequest.ProtoReflect.Descriptor instead.
func (*GetProfileRequest) Descriptor() ([]byte, []int) {
return file_server_v1_profile_proto_rawDescGZIP(), []int{1}
}
func (x *GetProfileRequest) GetId() string {
if x != nil {
return x.Id
}
return ""
}
type GetProfileResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Profile *Profile `protobuf:"bytes,1,opt,name=profile,proto3" json:"profile,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetProfileResponse) Reset() {
*x = GetProfileResponse{}
mi := &file_server_v1_profile_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetProfileResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetProfileResponse) ProtoMessage() {}
func (x *GetProfileResponse) ProtoReflect() protoreflect.Message {
mi := &file_server_v1_profile_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetProfileResponse.ProtoReflect.Descriptor instead.
func (*GetProfileResponse) Descriptor() ([]byte, []int) {
return file_server_v1_profile_proto_rawDescGZIP(), []int{2}
}
func (x *GetProfileResponse) GetProfile() *Profile {
if x != nil {
return x.Profile
}
return nil
}
type CreateProfileRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Description *string `protobuf:"bytes,2,opt,name=description,proto3,oneof" json:"description,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CreateProfileRequest) Reset() {
*x = CreateProfileRequest{}
mi := &file_server_v1_profile_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CreateProfileRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateProfileRequest) ProtoMessage() {}
func (x *CreateProfileRequest) ProtoReflect() protoreflect.Message {
mi := &file_server_v1_profile_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CreateProfileRequest.ProtoReflect.Descriptor instead.
func (*CreateProfileRequest) Descriptor() ([]byte, []int) {
return file_server_v1_profile_proto_rawDescGZIP(), []int{3}
}
func (x *CreateProfileRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *CreateProfileRequest) GetDescription() string {
if x != nil && x.Description != nil {
return *x.Description
}
return ""
}
type CreateProfileResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Profile *Profile `protobuf:"bytes,1,opt,name=profile,proto3" json:"profile,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CreateProfileResponse) Reset() {
*x = CreateProfileResponse{}
mi := &file_server_v1_profile_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CreateProfileResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateProfileResponse) ProtoMessage() {}
func (x *CreateProfileResponse) ProtoReflect() protoreflect.Message {
mi := &file_server_v1_profile_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CreateProfileResponse.ProtoReflect.Descriptor instead.
func (*CreateProfileResponse) Descriptor() ([]byte, []int) {
return file_server_v1_profile_proto_rawDescGZIP(), []int{4}
}
func (x *CreateProfileResponse) GetProfile() *Profile {
if x != nil {
return x.Profile
}
return nil
}
type UpdateProfileRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Description *string `protobuf:"bytes,3,opt,name=description,proto3,oneof" json:"description,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *UpdateProfileRequest) Reset() {
*x = UpdateProfileRequest{}
mi := &file_server_v1_profile_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *UpdateProfileRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateProfileRequest) ProtoMessage() {}
func (x *UpdateProfileRequest) ProtoReflect() protoreflect.Message {
mi := &file_server_v1_profile_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UpdateProfileRequest.ProtoReflect.Descriptor instead.
func (*UpdateProfileRequest) Descriptor() ([]byte, []int) {
return file_server_v1_profile_proto_rawDescGZIP(), []int{5}
}
func (x *UpdateProfileRequest) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *UpdateProfileRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *UpdateProfileRequest) GetDescription() string {
if x != nil && x.Description != nil {
return *x.Description
}
return ""
}
type UpdateProfileResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Profile *Profile `protobuf:"bytes,1,opt,name=profile,proto3" json:"profile,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *UpdateProfileResponse) Reset() {
*x = UpdateProfileResponse{}
mi := &file_server_v1_profile_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *UpdateProfileResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateProfileResponse) ProtoMessage() {}
func (x *UpdateProfileResponse) ProtoReflect() protoreflect.Message {
mi := &file_server_v1_profile_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UpdateProfileResponse.ProtoReflect.Descriptor instead.
func (*UpdateProfileResponse) Descriptor() ([]byte, []int) {
return file_server_v1_profile_proto_rawDescGZIP(), []int{6}
}
func (x *UpdateProfileResponse) GetProfile() *Profile {
if x != nil {
return x.Profile
}
return nil
}
type DeleteProfileRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *DeleteProfileRequest) Reset() {
*x = DeleteProfileRequest{}
mi := &file_server_v1_profile_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *DeleteProfileRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeleteProfileRequest) ProtoMessage() {}
func (x *DeleteProfileRequest) ProtoReflect() protoreflect.Message {
mi := &file_server_v1_profile_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DeleteProfileRequest.ProtoReflect.Descriptor instead.
func (*DeleteProfileRequest) Descriptor() ([]byte, []int) {
return file_server_v1_profile_proto_rawDescGZIP(), []int{7}
}
func (x *DeleteProfileRequest) GetId() string {
if x != nil {
return x.Id
}
return ""
}
type DeleteProfileResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *DeleteProfileResponse) Reset() {
*x = DeleteProfileResponse{}
mi := &file_server_v1_profile_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *DeleteProfileResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeleteProfileResponse) ProtoMessage() {}
func (x *DeleteProfileResponse) ProtoReflect() protoreflect.Message {
mi := &file_server_v1_profile_proto_msgTypes[8]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DeleteProfileResponse.ProtoReflect.Descriptor instead.
func (*DeleteProfileResponse) Descriptor() ([]byte, []int) {
return file_server_v1_profile_proto_rawDescGZIP(), []int{8}
}
type ListProfilesRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Limit *int64 `protobuf:"varint,1,opt,name=limit,proto3,oneof" json:"limit,omitempty"`
Offset *int64 `protobuf:"varint,2,opt,name=offset,proto3,oneof" json:"offset,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ListProfilesRequest) Reset() {
*x = ListProfilesRequest{}
mi := &file_server_v1_profile_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListProfilesRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListProfilesRequest) ProtoMessage() {}
func (x *ListProfilesRequest) ProtoReflect() protoreflect.Message {
mi := &file_server_v1_profile_proto_msgTypes[9]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListProfilesRequest.ProtoReflect.Descriptor instead.
func (*ListProfilesRequest) Descriptor() ([]byte, []int) {
return file_server_v1_profile_proto_rawDescGZIP(), []int{9}
}
func (x *ListProfilesRequest) GetLimit() int64 {
if x != nil && x.Limit != nil {
return *x.Limit
}
return 0
}
func (x *ListProfilesRequest) GetOffset() int64 {
if x != nil && x.Offset != nil {
return *x.Offset
}
return 0
}
type ListProfilesResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Profiles []*Profile `protobuf:"bytes,1,rep,name=profiles,proto3" json:"profiles,omitempty"`
TotalCount int64 `protobuf:"varint,2,opt,name=total_count,json=totalCount,proto3" json:"total_count,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ListProfilesResponse) Reset() {
*x = ListProfilesResponse{}
mi := &file_server_v1_profile_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListProfilesResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListProfilesResponse) ProtoMessage() {}
func (x *ListProfilesResponse) ProtoReflect() protoreflect.Message {
mi := &file_server_v1_profile_proto_msgTypes[10]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListProfilesResponse.ProtoReflect.Descriptor instead.
func (*ListProfilesResponse) Descriptor() ([]byte, []int) {
return file_server_v1_profile_proto_rawDescGZIP(), []int{10}
}
func (x *ListProfilesResponse) GetProfiles() []*Profile {
if x != nil {
return x.Profiles
}
return nil
}
func (x *ListProfilesResponse) GetTotalCount() int64 {
if x != nil {
return x.TotalCount
}
return 0
}
var File_server_v1_profile_proto protoreflect.FileDescriptor
const file_server_v1_profile_proto_rawDesc = "" +
"\n" +
"\x17server/v1/profile.proto\x12\tserver.v1\x1a\x1fgoogle/protobuf/timestamp.proto\"\xc5\x01\n" +
"\aProfile\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" +
"\x04name\x18\x02 \x01(\tR\x04name\x12 \n" +
"\vdescription\x18\x03 \x01(\tR\vdescription\x129\n" +
"\n" +
"created_at\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x129\n" +
"\n" +
"updated_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\tupdatedAt\"#\n" +
"\x11GetProfileRequest\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\"B\n" +
"\x12GetProfileResponse\x12,\n" +
"\aprofile\x18\x01 \x01(\v2\x12.server.v1.ProfileR\aprofile\"a\n" +
"\x14CreateProfileRequest\x12\x12\n" +
"\x04name\x18\x01 \x01(\tR\x04name\x12%\n" +
"\vdescription\x18\x02 \x01(\tH\x00R\vdescription\x88\x01\x01B\x0e\n" +
"\f_description\"E\n" +
"\x15CreateProfileResponse\x12,\n" +
"\aprofile\x18\x01 \x01(\v2\x12.server.v1.ProfileR\aprofile\"q\n" +
"\x14UpdateProfileRequest\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" +
"\x04name\x18\x02 \x01(\tR\x04name\x12%\n" +
"\vdescription\x18\x03 \x01(\tH\x00R\vdescription\x88\x01\x01B\x0e\n" +
"\f_description\"E\n" +
"\x15UpdateProfileResponse\x12,\n" +
"\aprofile\x18\x01 \x01(\v2\x12.server.v1.ProfileR\aprofile\"&\n" +
"\x14DeleteProfileRequest\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\"\x17\n" +
"\x15DeleteProfileResponse\"b\n" +
"\x13ListProfilesRequest\x12\x19\n" +
"\x05limit\x18\x01 \x01(\x03H\x00R\x05limit\x88\x01\x01\x12\x1b\n" +
"\x06offset\x18\x02 \x01(\x03H\x01R\x06offset\x88\x01\x01B\b\n" +
"\x06_limitB\t\n" +
"\a_offset\"g\n" +
"\x14ListProfilesResponse\x12.\n" +
"\bprofiles\x18\x01 \x03(\v2\x12.server.v1.ProfileR\bprofiles\x12\x1f\n" +
"\vtotal_count\x18\x02 \x01(\x03R\n" +
"totalCount2\xa8\x03\n" +
"\x0eProfileService\x12I\n" +
"\n" +
"GetProfile\x12\x1c.server.v1.GetProfileRequest\x1a\x1d.server.v1.GetProfileResponse\x12R\n" +
"\rCreateProfile\x12\x1f.server.v1.CreateProfileRequest\x1a .server.v1.CreateProfileResponse\x12R\n" +
"\rUpdateProfile\x12\x1f.server.v1.UpdateProfileRequest\x1a .server.v1.UpdateProfileResponse\x12R\n" +
"\rDeleteProfile\x12\x1f.server.v1.DeleteProfileRequest\x1a .server.v1.DeleteProfileResponse\x12O\n" +
"\fListProfiles\x12\x1e.server.v1.ListProfilesRequest\x1a\x1f.server.v1.ListProfilesResponseB\x9f\x01\n" +
"\rcom.server.v1B\fProfileProtoP\x01Z;github.com/mizuchilabs/mantrae/proto/gen/server/v1;serverv1\xa2\x02\x03SXX\xaa\x02\tServer.V1\xca\x02\tServer\\V1\xe2\x02\x15Server\\V1\\GPBMetadata\xea\x02\n" +
"Server::V1b\x06proto3"
var (
file_server_v1_profile_proto_rawDescOnce sync.Once
file_server_v1_profile_proto_rawDescData []byte
)
func file_server_v1_profile_proto_rawDescGZIP() []byte {
file_server_v1_profile_proto_rawDescOnce.Do(func() {
file_server_v1_profile_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_server_v1_profile_proto_rawDesc), len(file_server_v1_profile_proto_rawDesc)))
})
return file_server_v1_profile_proto_rawDescData
}
var file_server_v1_profile_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_server_v1_profile_proto_goTypes = []any{
(*Profile)(nil), // 0: server.v1.Profile
(*GetProfileRequest)(nil), // 1: server.v1.GetProfileRequest
(*GetProfileResponse)(nil), // 2: server.v1.GetProfileResponse
(*CreateProfileRequest)(nil), // 3: server.v1.CreateProfileRequest
(*CreateProfileResponse)(nil), // 4: server.v1.CreateProfileResponse
(*UpdateProfileRequest)(nil), // 5: server.v1.UpdateProfileRequest
(*UpdateProfileResponse)(nil), // 6: server.v1.UpdateProfileResponse
(*DeleteProfileRequest)(nil), // 7: server.v1.DeleteProfileRequest
(*DeleteProfileResponse)(nil), // 8: server.v1.DeleteProfileResponse
(*ListProfilesRequest)(nil), // 9: server.v1.ListProfilesRequest
(*ListProfilesResponse)(nil), // 10: server.v1.ListProfilesResponse
(*timestamppb.Timestamp)(nil), // 11: google.protobuf.Timestamp
}
var file_server_v1_profile_proto_depIdxs = []int32{
11, // 0: server.v1.Profile.created_at:type_name -> google.protobuf.Timestamp
11, // 1: server.v1.Profile.updated_at:type_name -> google.protobuf.Timestamp
0, // 2: server.v1.GetProfileResponse.profile:type_name -> server.v1.Profile
0, // 3: server.v1.CreateProfileResponse.profile:type_name -> server.v1.Profile
0, // 4: server.v1.UpdateProfileResponse.profile:type_name -> server.v1.Profile
0, // 5: server.v1.ListProfilesResponse.profiles:type_name -> server.v1.Profile
1, // 6: server.v1.ProfileService.GetProfile:input_type -> server.v1.GetProfileRequest
3, // 7: server.v1.ProfileService.CreateProfile:input_type -> server.v1.CreateProfileRequest
5, // 8: server.v1.ProfileService.UpdateProfile:input_type -> server.v1.UpdateProfileRequest
7, // 9: server.v1.ProfileService.DeleteProfile:input_type -> server.v1.DeleteProfileRequest
9, // 10: server.v1.ProfileService.ListProfiles:input_type -> server.v1.ListProfilesRequest
2, // 11: server.v1.ProfileService.GetProfile:output_type -> server.v1.GetProfileResponse
4, // 12: server.v1.ProfileService.CreateProfile:output_type -> server.v1.CreateProfileResponse
6, // 13: server.v1.ProfileService.UpdateProfile:output_type -> server.v1.UpdateProfileResponse
8, // 14: server.v1.ProfileService.DeleteProfile:output_type -> server.v1.DeleteProfileResponse
10, // 15: server.v1.ProfileService.ListProfiles:output_type -> server.v1.ListProfilesResponse
11, // [11:16] is the sub-list for method output_type
6, // [6:11] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
}
func init() { file_server_v1_profile_proto_init() }
func file_server_v1_profile_proto_init() {
if File_server_v1_profile_proto != nil {
return
}
file_server_v1_profile_proto_msgTypes[3].OneofWrappers = []any{}
file_server_v1_profile_proto_msgTypes[5].OneofWrappers = []any{}
file_server_v1_profile_proto_msgTypes[9].OneofWrappers = []any{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_server_v1_profile_proto_rawDesc), len(file_server_v1_profile_proto_rawDesc)),
NumEnums: 0,
NumMessages: 11,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_server_v1_profile_proto_goTypes,
DependencyIndexes: file_server_v1_profile_proto_depIdxs,
MessageInfos: file_server_v1_profile_proto_msgTypes,
}.Build()
File_server_v1_profile_proto = out.File
file_server_v1_profile_proto_goTypes = nil
file_server_v1_profile_proto_depIdxs = nil
}

View File

@@ -0,0 +1,225 @@
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: server/v1/profile.proto
package serverv1connect
import (
connect "connectrpc.com/connect"
context "context"
errors "errors"
v1 "github.com/mizuchilabs/mantrae/proto/gen/server/v1"
http "net/http"
strings "strings"
)
// This is a compile-time assertion to ensure that this generated file and the connect package are
// compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of connect newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of connect or updating the connect
// version compiled into your binary.
const _ = connect.IsAtLeastVersion1_13_0
const (
// ProfileServiceName is the fully-qualified name of the ProfileService service.
ProfileServiceName = "server.v1.ProfileService"
)
// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
// ProfileServiceGetProfileProcedure is the fully-qualified name of the ProfileService's GetProfile
// RPC.
ProfileServiceGetProfileProcedure = "/server.v1.ProfileService/GetProfile"
// ProfileServiceCreateProfileProcedure is the fully-qualified name of the ProfileService's
// CreateProfile RPC.
ProfileServiceCreateProfileProcedure = "/server.v1.ProfileService/CreateProfile"
// ProfileServiceUpdateProfileProcedure is the fully-qualified name of the ProfileService's
// UpdateProfile RPC.
ProfileServiceUpdateProfileProcedure = "/server.v1.ProfileService/UpdateProfile"
// ProfileServiceDeleteProfileProcedure is the fully-qualified name of the ProfileService's
// DeleteProfile RPC.
ProfileServiceDeleteProfileProcedure = "/server.v1.ProfileService/DeleteProfile"
// ProfileServiceListProfilesProcedure is the fully-qualified name of the ProfileService's
// ListProfiles RPC.
ProfileServiceListProfilesProcedure = "/server.v1.ProfileService/ListProfiles"
)
// ProfileServiceClient is a client for the server.v1.ProfileService service.
type ProfileServiceClient interface {
GetProfile(context.Context, *connect.Request[v1.GetProfileRequest]) (*connect.Response[v1.GetProfileResponse], error)
CreateProfile(context.Context, *connect.Request[v1.CreateProfileRequest]) (*connect.Response[v1.CreateProfileResponse], error)
UpdateProfile(context.Context, *connect.Request[v1.UpdateProfileRequest]) (*connect.Response[v1.UpdateProfileResponse], error)
DeleteProfile(context.Context, *connect.Request[v1.DeleteProfileRequest]) (*connect.Response[v1.DeleteProfileResponse], error)
ListProfiles(context.Context, *connect.Request[v1.ListProfilesRequest]) (*connect.Response[v1.ListProfilesResponse], error)
}
// NewProfileServiceClient constructs a client for the server.v1.ProfileService service. By default,
// it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and
// sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC()
// or connect.WithGRPCWeb() options.
//
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc).
func NewProfileServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) ProfileServiceClient {
baseURL = strings.TrimRight(baseURL, "/")
profileServiceMethods := v1.File_server_v1_profile_proto.Services().ByName("ProfileService").Methods()
return &profileServiceClient{
getProfile: connect.NewClient[v1.GetProfileRequest, v1.GetProfileResponse](
httpClient,
baseURL+ProfileServiceGetProfileProcedure,
connect.WithSchema(profileServiceMethods.ByName("GetProfile")),
connect.WithClientOptions(opts...),
),
createProfile: connect.NewClient[v1.CreateProfileRequest, v1.CreateProfileResponse](
httpClient,
baseURL+ProfileServiceCreateProfileProcedure,
connect.WithSchema(profileServiceMethods.ByName("CreateProfile")),
connect.WithClientOptions(opts...),
),
updateProfile: connect.NewClient[v1.UpdateProfileRequest, v1.UpdateProfileResponse](
httpClient,
baseURL+ProfileServiceUpdateProfileProcedure,
connect.WithSchema(profileServiceMethods.ByName("UpdateProfile")),
connect.WithClientOptions(opts...),
),
deleteProfile: connect.NewClient[v1.DeleteProfileRequest, v1.DeleteProfileResponse](
httpClient,
baseURL+ProfileServiceDeleteProfileProcedure,
connect.WithSchema(profileServiceMethods.ByName("DeleteProfile")),
connect.WithClientOptions(opts...),
),
listProfiles: connect.NewClient[v1.ListProfilesRequest, v1.ListProfilesResponse](
httpClient,
baseURL+ProfileServiceListProfilesProcedure,
connect.WithSchema(profileServiceMethods.ByName("ListProfiles")),
connect.WithClientOptions(opts...),
),
}
}
// profileServiceClient implements ProfileServiceClient.
type profileServiceClient struct {
getProfile *connect.Client[v1.GetProfileRequest, v1.GetProfileResponse]
createProfile *connect.Client[v1.CreateProfileRequest, v1.CreateProfileResponse]
updateProfile *connect.Client[v1.UpdateProfileRequest, v1.UpdateProfileResponse]
deleteProfile *connect.Client[v1.DeleteProfileRequest, v1.DeleteProfileResponse]
listProfiles *connect.Client[v1.ListProfilesRequest, v1.ListProfilesResponse]
}
// GetProfile calls server.v1.ProfileService.GetProfile.
func (c *profileServiceClient) GetProfile(ctx context.Context, req *connect.Request[v1.GetProfileRequest]) (*connect.Response[v1.GetProfileResponse], error) {
return c.getProfile.CallUnary(ctx, req)
}
// CreateProfile calls server.v1.ProfileService.CreateProfile.
func (c *profileServiceClient) CreateProfile(ctx context.Context, req *connect.Request[v1.CreateProfileRequest]) (*connect.Response[v1.CreateProfileResponse], error) {
return c.createProfile.CallUnary(ctx, req)
}
// UpdateProfile calls server.v1.ProfileService.UpdateProfile.
func (c *profileServiceClient) UpdateProfile(ctx context.Context, req *connect.Request[v1.UpdateProfileRequest]) (*connect.Response[v1.UpdateProfileResponse], error) {
return c.updateProfile.CallUnary(ctx, req)
}
// DeleteProfile calls server.v1.ProfileService.DeleteProfile.
func (c *profileServiceClient) DeleteProfile(ctx context.Context, req *connect.Request[v1.DeleteProfileRequest]) (*connect.Response[v1.DeleteProfileResponse], error) {
return c.deleteProfile.CallUnary(ctx, req)
}
// ListProfiles calls server.v1.ProfileService.ListProfiles.
func (c *profileServiceClient) ListProfiles(ctx context.Context, req *connect.Request[v1.ListProfilesRequest]) (*connect.Response[v1.ListProfilesResponse], error) {
return c.listProfiles.CallUnary(ctx, req)
}
// ProfileServiceHandler is an implementation of the server.v1.ProfileService service.
type ProfileServiceHandler interface {
GetProfile(context.Context, *connect.Request[v1.GetProfileRequest]) (*connect.Response[v1.GetProfileResponse], error)
CreateProfile(context.Context, *connect.Request[v1.CreateProfileRequest]) (*connect.Response[v1.CreateProfileResponse], error)
UpdateProfile(context.Context, *connect.Request[v1.UpdateProfileRequest]) (*connect.Response[v1.UpdateProfileResponse], error)
DeleteProfile(context.Context, *connect.Request[v1.DeleteProfileRequest]) (*connect.Response[v1.DeleteProfileResponse], error)
ListProfiles(context.Context, *connect.Request[v1.ListProfilesRequest]) (*connect.Response[v1.ListProfilesResponse], error)
}
// NewProfileServiceHandler builds an HTTP handler from the service implementation. It returns the
// path on which to mount the handler and the handler itself.
//
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression.
func NewProfileServiceHandler(svc ProfileServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
profileServiceMethods := v1.File_server_v1_profile_proto.Services().ByName("ProfileService").Methods()
profileServiceGetProfileHandler := connect.NewUnaryHandler(
ProfileServiceGetProfileProcedure,
svc.GetProfile,
connect.WithSchema(profileServiceMethods.ByName("GetProfile")),
connect.WithHandlerOptions(opts...),
)
profileServiceCreateProfileHandler := connect.NewUnaryHandler(
ProfileServiceCreateProfileProcedure,
svc.CreateProfile,
connect.WithSchema(profileServiceMethods.ByName("CreateProfile")),
connect.WithHandlerOptions(opts...),
)
profileServiceUpdateProfileHandler := connect.NewUnaryHandler(
ProfileServiceUpdateProfileProcedure,
svc.UpdateProfile,
connect.WithSchema(profileServiceMethods.ByName("UpdateProfile")),
connect.WithHandlerOptions(opts...),
)
profileServiceDeleteProfileHandler := connect.NewUnaryHandler(
ProfileServiceDeleteProfileProcedure,
svc.DeleteProfile,
connect.WithSchema(profileServiceMethods.ByName("DeleteProfile")),
connect.WithHandlerOptions(opts...),
)
profileServiceListProfilesHandler := connect.NewUnaryHandler(
ProfileServiceListProfilesProcedure,
svc.ListProfiles,
connect.WithSchema(profileServiceMethods.ByName("ListProfiles")),
connect.WithHandlerOptions(opts...),
)
return "/server.v1.ProfileService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case ProfileServiceGetProfileProcedure:
profileServiceGetProfileHandler.ServeHTTP(w, r)
case ProfileServiceCreateProfileProcedure:
profileServiceCreateProfileHandler.ServeHTTP(w, r)
case ProfileServiceUpdateProfileProcedure:
profileServiceUpdateProfileHandler.ServeHTTP(w, r)
case ProfileServiceDeleteProfileProcedure:
profileServiceDeleteProfileHandler.ServeHTTP(w, r)
case ProfileServiceListProfilesProcedure:
profileServiceListProfilesHandler.ServeHTTP(w, r)
default:
http.NotFound(w, r)
}
})
}
// UnimplementedProfileServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedProfileServiceHandler struct{}
func (UnimplementedProfileServiceHandler) GetProfile(context.Context, *connect.Request[v1.GetProfileRequest]) (*connect.Response[v1.GetProfileResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("server.v1.ProfileService.GetProfile is not implemented"))
}
func (UnimplementedProfileServiceHandler) CreateProfile(context.Context, *connect.Request[v1.CreateProfileRequest]) (*connect.Response[v1.CreateProfileResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("server.v1.ProfileService.CreateProfile is not implemented"))
}
func (UnimplementedProfileServiceHandler) UpdateProfile(context.Context, *connect.Request[v1.UpdateProfileRequest]) (*connect.Response[v1.UpdateProfileResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("server.v1.ProfileService.UpdateProfile is not implemented"))
}
func (UnimplementedProfileServiceHandler) DeleteProfile(context.Context, *connect.Request[v1.DeleteProfileRequest]) (*connect.Response[v1.DeleteProfileResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("server.v1.ProfileService.DeleteProfile is not implemented"))
}
func (UnimplementedProfileServiceHandler) ListProfiles(context.Context, *connect.Request[v1.ListProfilesRequest]) (*connect.Response[v1.ListProfilesResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("server.v1.ProfileService.ListProfiles is not implemented"))
}

View File

@@ -0,0 +1,59 @@
syntax = "proto3";
package server.v1;
import "google/protobuf/timestamp.proto";
service ProfileService {
rpc GetProfile(GetProfileRequest) returns (GetProfileResponse);
rpc CreateProfile(CreateProfileRequest) returns (CreateProfileResponse);
rpc UpdateProfile(UpdateProfileRequest) returns (UpdateProfileResponse);
rpc DeleteProfile(DeleteProfileRequest) returns (DeleteProfileResponse);
rpc ListProfiles(ListProfilesRequest) returns (ListProfilesResponse);
}
message Profile {
string id = 1;
string name = 2;
string description = 3;
google.protobuf.Timestamp created_at = 4;
google.protobuf.Timestamp updated_at = 5;
}
message GetProfileRequest {
string id = 1;
}
message GetProfileResponse {
Profile profile = 1;
}
message CreateProfileRequest {
string name = 1;
optional string description = 2;
}
message CreateProfileResponse {
Profile profile = 1;
}
message UpdateProfileRequest {
string id = 1;
string name = 2;
optional string description = 3;
}
message UpdateProfileResponse {
Profile profile = 1;
}
message DeleteProfileRequest {
string id = 1;
}
message DeleteProfileResponse {}
message ListProfilesRequest {
optional int64 limit = 1;
optional int64 offset = 2;
}
message ListProfilesResponse {
repeated Profile profiles = 1;
int64 total_count = 2;
}

View File

@@ -1,7 +1,8 @@
version: "2"
sql:
- engine: "sqlite"
schema: "internal/db/migrations"
# schema: "internal/db/migrations"
schema: "internal/db/00000_base.sql"
queries: "internal/db/queries"
gen:
go: