Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .tools/nvim/__http__/infra/cmsvc.graphql.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
---

label: "list helm chart type Cluster msvc"
query: |+
query Infra_listHelmTypeClusterManagedServices {
infra_listHelmTypeClusterManagedServices {
totalCount
edges {
node {
kind
accountName
spec {
msvcSpec {
plugin {
kind
}
}
}
}
}
}
}
variables:
{}

---

label: "list Cluster msvc"
query: |+
query Infra_listClusterManagedServices {
infra_listClusterManagedServices {
totalCount
edges {
node {
accountName
kind
spec {
msvcSpec {
plugin {
kind
}
}
}
}
}
}
}


---
label: "Clone Cluster Managed Service"
query: |+
Expand All @@ -17,4 +66,34 @@ variables:
"destinationMsvcName": "msvc-one-clone2",
"displayName": "msvc one clone2"
}

---

label: "list Cluster msvc"
query: |+
query Infra_listClusterManagedServices {
infra_listClusterManagedServices {
totalCount
edges {
node {
accountName
kind
spec {
msvcSpec {
plugin {
kind
}
}
}
}
}
}
}
# variables:
# {
# "projectName": "sample-project",
# "deviceBlueprintName": "sample-device-blueprint",
# }


---
90 changes: 90 additions & 0 deletions .tools/nvim/__http__/workmachine/workmachine.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
label: "Create Workmachine"
query: |+
mutation Infra_createWorkMachine($clusterName: String!, $workmachine: WorkmachineIn!) {
infra_createWorkMachine(clusterName: $clusterName, workmachine: $workmachine) {
accountName
}
}
variables:
{
"clusterName": "ttt",
"workmachine": {
"displayName": "tt",
"metadata": {
"name": "tt"
}
}
}

---

label: "update Workmachine"
query: |+
mutation Infra_updateWorkMachine($clusterName: String!, $workmachine: WorkmachineIn!) {
infra_updateWorkMachine(clusterName: $clusterName, workmachine: $workmachine) {
accountName
}
}
variables:
{
"clusterName": "ttt",
"workmachine": {
"displayName": "mm",
"metadata": {
"name": "tt"
}
}
}

---

label: "update Workmachine Status"
query: |+
mutation Infra_updateWorkMachineStatus($clusterName: String!, $status: Boolean!, $name: String!) {
infra_updateWorkMachineStatus(clusterName: $clusterName, status: $status, name: $name)
}
variables:
{
"clusterName": "test-clus",
"status": true,
"name": "test-wm1"
}

---

label: "get workmachine"
query: |+
query Infra_getWorkmachine($clusterName: String!, $name: String!) {
infra_getWorkmachine(clusterName: $clusterName, name: $name) {
accountName
}
}
variables:
{
"clusterName": "test-clus",
"name": "test-wm1"
}

---

label: "list App"
query: |+
query Iot_listApps($projectName: String!, $deviceBlueprintName: String!) {
iot_listApps(projectName: $projectName, deviceBlueprintName: $deviceBlueprintName) {
totalCount
edges {
node {
displayName
id
}
}
}
}
variables:
{
"projectName": "sample-project",
"deviceBlueprintName": "sample-device-blueprint",
}

---
82 changes: 82 additions & 0 deletions .tools/nvim/__http__/workmachine/workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
label: "Create workspace"
query: |+
mutation Infra_createWorkspace($workspace: WorkspaceIn!, $clusterName: String!) {
infra_createWorkspace(workspace: $workspace, clusterName: $clusterName) {
accountName
}
}
variables:
{
"workspace": {
"metadata": {
"name": "test-ws1"
},
"displayName": "test ws1"
},
"clusterName": "test-clus"
}

---

label: "update workspace"
query: |+
mutation Infra_updateWorkspace($clusterName: String!, $workspace: WorkspaceIn!) {
infra_updateWorkspace(clusterName: $clusterName, workspace: $workspace) {
accountName
}
}
variables:
{
"workspace": {
"metadata": {
"name": "test-ws1"
},
"displayName": "test wss1"
},
"clusterName": "test-clus"
}

---

label: "delete Workspace"
query: |+
mutation Infra_deleteWorkspace($clusterName: String!, $name: String!) {
infra_deleteWorkspace(clusterName: $clusterName, name: $name)
}
variables:
{
"clusterName": "test-clus",
"name": "test-ws1"
}

---

label: "get workspace"
query: |+
query Infra_getWorkspace($clusterName: String!, $name: String!) {
infra_getWorkspace(clusterName: $clusterName, name: $name) {
accountName
}
}
variables:
{
"clusterName": "test-clus",
"name": "test-ws1"
}

---

label: "list workspace"
query: |+
query Infra_listWorkspaces($clusterName: String!) {
infra_listWorkspaces(clusterName: $clusterName) {
totalCount
}
}
variables:
{
"clusterName": "test-clus",
}

---
2 changes: 1 addition & 1 deletion .tools/taskfiles/docker.Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ tasks:
echo "image exists, but overridden"
fi

docker buildx build -t {{.image}} --output=type=image,compression=zstd,force-compression=true,compression-level=12,push={{.push_image}} {{.args}}
DOCKER_BUILDKIT=1 docker buildx build -t {{.image}} --output=type=image,compression=zstd,force-compression=true,compression-level=12,push={{.push_image}} {{.args}}
41 changes: 41 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Console",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/apps/console/main.go",
"args": [
"--dev"
],
"envFile": "${workspaceFolder}/apps/console/.secrets/env",
},
{
"name": "Infra",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/apps/infra/main.go",
"args": [
"--dev"
],
"envFile": "${workspaceFolder}/apps/infra/.secrets/env",
},
{
"name": "Auth",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/apps/auth/main.go",
"args": [
"--dev"
],
"envFile": "${workspaceFolder}/apps/auth/.secrets/env",
}
]
}
2 changes: 1 addition & 1 deletion apps/auth/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ tasks:

- task: docker:build-and-push
vars:
args: "--platform linux/amd64,linux/arm64 --build-arg BINARY={{.binary}} ."
args: "--platform linux/amd64 --build-arg BINARY={{.binary}} ."
image: "{{.image}}"

44 changes: 41 additions & 3 deletions apps/auth/internal/app/grpc-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package app

import (
"context"

"github.com/kloudlite/api/apps/auth/internal/entities"
"github.com/kloudlite/api/common"
"github.com/kloudlite/api/pkg/kv"
"github.com/kloudlite/api/pkg/repos"

"github.com/kloudlite/api/apps/auth/internal/domain"
Expand All @@ -12,7 +15,41 @@ import (

type authGrpcServer struct {
auth.UnimplementedAuthServer
d domain.Domain
d domain.Domain
sessionRepo kv.Repo[*common.AuthSession]
}

// GenerateMachineSession implements auth.AuthServer.
func (a *authGrpcServer) GenerateMachineSession(ctx context.Context, in *auth.GenerateMachineSessionIn) (*auth.GenerateMachineSessionOut, error) {
session, err := a.d.MachineLogin(ctx, in.UserId, in.MachineId, in.Cluster)
if err != nil {
return nil, errors.NewE(err)
}
err = a.sessionRepo.Set(ctx, string(session.Id), session)
if err != nil {
return nil, errors.NewE(err)
}
if session == nil {
return nil, errors.Newf("session is nil")
}
return &auth.GenerateMachineSessionOut{
SessionId: string(session.Id),
}, nil
}

// ClearMachineSessionByMachine implements auth.AuthServer.
func (a *authGrpcServer) ClearMachineSessionByMachine(context.Context, *auth.ClearMachineSessionByMachineIn) (*auth.ClearMachineSessionByMachineOut, error) {
panic("unimplemented")
}

// ClearMachineSessionByTeam implements auth.AuthServer.
func (a *authGrpcServer) ClearMachineSessionByTeam(context.Context, *auth.ClearMachineSessionByTeamIn) (*auth.ClearMachineSessionByTeamOut, error) {
panic("unimplemented")
}

// ClearMachineSessionByUser implements auth.AuthServer.
func (a *authGrpcServer) ClearMachineSessionByUser(context.Context, *auth.ClearMachineSessionByUserIn) (*auth.ClearMachineSessionByUserOut, error) {
panic("unimplemented")
}

func (a *authGrpcServer) GetUser(ctx context.Context, in *auth.GetUserIn) (*auth.GetUserOut, error) {
Expand Down Expand Up @@ -72,8 +109,9 @@ func (a *authGrpcServer) GetAccessToken(ctx context.Context, in *auth.GetAccessT
return a.FromAccToken(*token), nil
}

func fxRPCServer(d domain.Domain) auth.AuthServer {
func fxRPCServer(d domain.Domain, sessionRepo kv.Repo[*common.AuthSession]) auth.AuthServer {
return &authGrpcServer{
d: d,
d: d,
sessionRepo: sessionRepo,
}
}
1 change: 1 addition & 0 deletions apps/auth/internal/domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Domain interface {
CreateRemoteLogin(ctx context.Context, secret string) (repos.ID, error)

Login(ctx context.Context, email string, password string) (*common.AuthSession, error)
MachineLogin(ctx context.Context, userId string, machineId string, cluster string) (*common.AuthSession, error)
SignUp(ctx context.Context, name string, email string, password string, captchaToken string) (*common.AuthSession, error)
EnsureUserByEmail(ctx context.Context, email string) (*entities.User, error)
GetUserById(ctx context.Context, id repos.ID) (*entities.User, error)
Expand Down
Loading
Loading