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
18 changes: 18 additions & 0 deletions apps/infra/internal/app/grpc-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ type grpcServer struct {
logger *slog.Logger
}

// GetClusterGatewayResource implements infra.InfraServer.
func (g *grpcServer) GetClusterGatewayResource(ctx context.Context, in *infra.GetClusterGatewayResourceIn) (*infra.GetClusterGatewayResourceOut, error) {
l := grpc.NewRequestLogger(g.logger, "EnsureGlobalVPNConnection")
defer l.End()

gw, err := g.d.GetGatewayResource(ctx, in.AccountName, in.ClusterName)
if err != nil {
return nil, err
}

b, err := fn.K8sObjToYAML(gw)
if err != nil {
return nil, errors.NewE(err)
}

return &infra.GetClusterGatewayResourceOut{Gateway: b}, nil
}

// EnsureGlobalVPNConnection implements infra.InfraServer.
func (g *grpcServer) EnsureGlobalVPNConnection(ctx context.Context, in *infra.EnsureGlobalVPNConnectionIn) (*infra.EnsureGlobalVPNConnectionOut, error) {
l := grpc.NewRequestLogger(g.logger, "EnsureGlobalVPNConnection")
Expand Down
3 changes: 3 additions & 0 deletions apps/infra/internal/domain/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"time"

klNetworkingv1 "github.com/kloudlite/operator/apis/networking/v1"
networkingv1 "k8s.io/api/networking/v1"

"github.com/kloudlite/api/apps/infra/internal/entities"
Expand Down Expand Up @@ -61,6 +62,8 @@ type Domain interface {
ListGlobalVPN(ctx InfraContext, search map[string]repos.MatchFilter, pagination repos.CursorPagination) (*repos.PaginatedRecord[*entities.GlobalVPN], error)
GetGlobalVPN(ctx InfraContext, name string) (*entities.GlobalVPN, error)

GetGatewayResource(ctx context.Context, accountName string, clusterName string) (*klNetworkingv1.Gateway, error)

CreateGlobalVPNDevice(ctx InfraContext, device entities.GlobalVPNDevice) (*entities.GlobalVPNDevice, error)
UpdateGlobalVPNDevice(ctx InfraContext, device entities.GlobalVPNDevice) (*entities.GlobalVPNDevice, error)
DeleteGlobalVPNDevice(ctx InfraContext, gvpn string, device string) error
Expand Down
17 changes: 17 additions & 0 deletions apps/infra/internal/domain/global-vpn-cluster-connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,23 @@ func (d *domain) getGlobalVPNConnectionPeers(args getGlobalVPNConnectionPeersArg
return peers
}

// GetGatewayResource implements Domain.
func (d *domain) GetGatewayResource(ctx context.Context, accountName string, clusterName string) (*networkingv1.Gateway, error) {
gw, err := d.gvpnConnRepo.FindOne(ctx, repos.Filter{
fc.AccountName: accountName,
fc.ClusterName: clusterName,
})
if err != nil {
return nil, err
}

if gw == nil {
return nil, fmt.Errorf("failed to find gateway resource")
}

return &gw.Gateway, nil
}

func (d *domain) listGlobalVPNConnections(ctx InfraContext, vpnName string) ([]*entities.GlobalVPNConnection, error) {
return d.gvpnConnRepo.Find(ctx, repos.Query{
Filter: repos.Filter{
Expand Down
11 changes: 11 additions & 0 deletions apps/infra/protobufs/infra.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ service Infra {
rpc MarkClusterOnlineAt(MarkClusterOnlineAtIn) returns (MarkClusterOnlineAtOut);

rpc EnsureGlobalVPNConnection(EnsureGlobalVPNConnectionIn) returns (EnsureGlobalVPNConnectionOut);

rpc GetClusterGatewayResource(GetClusterGatewayResourceIn) returns (GetClusterGatewayResourceOut);
}

message GetClusterIn {
Expand Down Expand Up @@ -87,3 +89,12 @@ message EnsureGlobalVPNConnectionIn {
}

message EnsureGlobalVPNConnectionOut {}

message GetClusterGatewayResourceIn {
string accountName = 1;
string clusterName = 2;
}

message GetClusterGatewayResourceOut {
bytes gateway = 1;
}
229 changes: 187 additions & 42 deletions apps/infra/protobufs/infra/infra.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading