Skip to content
Draft
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
499 changes: 499 additions & 0 deletions protogen/gen/opencloud/services/web/v0/web.pb.go

Large diffs are not rendered by default.

122 changes: 122 additions & 0 deletions protogen/gen/opencloud/services/web/v0/web.pb.micro.go

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

80 changes: 80 additions & 0 deletions protogen/gen/opencloud/services/web/v0/web.swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"swagger": "2.0",
"info": {
"title": "OpenCloud web",
"version": "1.0.0",
"contact": {
"name": "OpenCloud GmbH",
"url": "https://github.com/opencloud-eu/opencloud",
"email": "support@opencloud.eu"
},
"license": {
"name": "Apache-2.0",
"url": "https://github.com/opencloud-eu/opencloud/blob/main/LICENSE"
}
},
"tags": [
{
"name": "WebService"
}
],
"schemes": [
"http",
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"definitions": {
"protobufAny": {
"type": "object",
"properties": {
"@type": {
"type": "string"
}
},
"additionalProperties": {}
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufAny"
}
}
}
},
"v0ThemeAddResponse": {
"type": "object"
},
"v0ThemeExistsResponse": {
"type": "object",
"properties": {
"exists": {
"type": "boolean",
"title": "Indicates if the theme exists"
}
}
},
"v0ThemeRemoveResponse": {
"type": "object"
}
},
"externalDocs": {
"description": "Developer Manual",
"url": "https://docs.opencloud.eu/services/web/"
}
}
1 change: 1 addition & 0 deletions protogen/proto/buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ plugins:
opencloud.services.eventhistory.v0;\
opencloud.messages.eventhistory.v0;\
opencloud.services.policies.v0;\
opencloud.services.web.v0;\
opencloud.messages.policies.v0"

- name: openapiv2
Expand Down
58 changes: 58 additions & 0 deletions protogen/proto/opencloud/services/web/v0/web.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
syntax = "proto3";

package opencloud.services.web.v0;

option go_package = "github.com/opencloud-eu/opencloud/protogen/gen/opencloud/services/web/v0";

import "protoc-gen-openapiv2/options/annotations.proto";

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
title: "OpenCloud web";
version: "1.0.0";
contact: {
name: "OpenCloud GmbH";
url: "https://github.com/opencloud-eu/opencloud";
email: "support@opencloud.eu";
};
license: {
name: "Apache-2.0";
url: "https://github.com/opencloud-eu/opencloud/blob/main/LICENSE";
};
};
schemes: HTTP;
schemes: HTTPS;
consumes: "application/json";
produces: "application/json";
external_docs: {
description: "Developer Manual";
url: "https://docs.opencloud.eu/services/web/";
};
};

service WebService {
rpc ThemeAdd(ThemeAddRequest) returns (ThemeAddResponse);
rpc ThemeExists(ThemeExistsRequest) returns (ThemeExistsResponse);
rpc ThemeRemove(ThemeRemoveRequest) returns (ThemeRemoveResponse);
}

message ThemeAddRequest {
string id = 1; // The ID of the theme to add
bytes data = 2; // The theme data in bytes
}

message ThemeAddResponse {}

message ThemeExistsRequest {
string id = 1; // The ID of the theme to check
}

message ThemeExistsResponse {
bool exists = 1; // Indicates if the theme exists
}

message ThemeRemoveRequest {
string id = 1; // The ID of the theme to remove
}

message ThemeRemoveResponse {}
7 changes: 7 additions & 0 deletions services/web/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ include ../../.make/default.mk
include ../../.make/go.mk
include ../../.make/release.mk
include ../../.make/docs.mk
include ../../.make/protobuf.mk

.PHONY: go-generate
go-generate: protobuf

.PHONY: protobuf
protobuf: buf-generate

.PHONY: node-generate-dev
node-generate-dev: pull-assets
Expand Down
23 changes: 23 additions & 0 deletions services/web/pkg/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@
"github.com/opencloud-eu/opencloud/pkg/config/configlog"
"github.com/opencloud-eu/opencloud/pkg/log"
"github.com/opencloud-eu/opencloud/pkg/runner"
ogrpc "github.com/opencloud-eu/opencloud/pkg/service/grpc"
"github.com/opencloud-eu/opencloud/pkg/tracing"
"github.com/opencloud-eu/opencloud/services/web/pkg/config"
"github.com/opencloud-eu/opencloud/services/web/pkg/config/parser"
"github.com/opencloud-eu/opencloud/services/web/pkg/metrics"
"github.com/opencloud-eu/opencloud/services/web/pkg/server/debug"
"github.com/opencloud-eu/opencloud/services/web/pkg/server/grpc"
"github.com/opencloud-eu/opencloud/services/web/pkg/server/http"

"github.com/spf13/cobra"
)

// Server is the entrypoint for the server command.
func Server(cfg *config.Config) *cobra.Command {

Check failure on line 26 in services/web/pkg/command/server.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 23 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=opencloud-eu_opencloud&issues=AZ21AEK99z6hsX0ARdPA&open=AZ21AEK99z6hsX0ARdPA&pullRequest=2651
return &cobra.Command{
Use: "server",
Short: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name),
Expand All @@ -48,6 +50,10 @@
}
}

cfg.GrpcClient, err = ogrpc.NewClient(
append(ogrpc.GetClientOptions(cfg.GRPCClientTLS), ogrpc.WithTraceProvider(traceProvider))...,
)

var cancel context.CancelFunc
if cfg.Context == nil {
cfg.Context, cancel = signal.NotifyContext(context.Background(), runner.StopSignals...)
Expand All @@ -71,7 +77,7 @@
logger.Info().
Err(err).
Str("transport", "http").
Msg("Failed to initialize server")

Check failure on line 80 in services/web/pkg/command/server.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "Failed to initialize server" 3 times.

See more on https://sonarcloud.io/project/issues?id=opencloud-eu_opencloud&issues=AZ21AEK99z6hsX0ARdO_&open=AZ21AEK99z6hsX0ARdO_&pullRequest=2651

return err
}
Expand All @@ -79,6 +85,23 @@
gr.Add(runner.NewGoMicroHttpServerRunner(cfg.Service.Name+".http", server))
}

{
grpcServer, err := grpc.Server(
grpc.Config(cfg),
grpc.Logger(logger),
grpc.Name(cfg.Service.Name),
grpc.Context(ctx),
grpc.JWTSecret(cfg.TokenManager.JWTSecret),
grpc.TraceProvider(traceProvider),
)
if err != nil {
logger.Info().Err(err).Str("transport", "grpc").Msg("Failed to initialize server")
return err
}

gr.Add(runner.NewGoMicroGrpcServerRunner(cfg.Service.Name+".grpc", grpcServer))
}

{
debugServer, err := debug.Server(
debug.Logger(logger),
Expand Down
22 changes: 20 additions & 2 deletions services/web/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package config
import (
"context"

"go-micro.dev/v4/client"

"github.com/opencloud-eu/opencloud/pkg/shared"
)

Expand All @@ -17,15 +19,31 @@ type Config struct {

HTTP HTTP `yaml:"http"`

GRPC GRPCConfig `yaml:"grpc"`
GrpcClient client.Client `yaml:"-"`

Asset Asset `yaml:"asset"`
File string `yaml:"file" env:"WEB_UI_CONFIG_FILE" desc:"Read the OpenCloud Web json based configuration from this path/file. The config file takes precedence over WEB_OPTION_xxx environment variables. See the text description for more details." introductionVersion:"1.0.0"`
Web Web `yaml:"web"`
Apps map[string]App

TokenManager *TokenManager `yaml:"token_manager"`

GatewayAddress string `yaml:"gateway_addr" env:"WEB_GATEWAY_GRPC_ADDR" desc:"The bind address of the GRPC service." introductionVersion:"1.0.0"`
Context context.Context `yaml:"-"`
GatewayAddress string `yaml:"gateway_addr" env:"WEB_GATEWAY_GRPC_ADDR" desc:"The bind address of the GRPC service." introductionVersion:"1.0.0"`
Context context.Context `yaml:"-"`
GRPCClientTLS *shared.GRPCClientTLS `yaml:"grpc_client_tls"`

Metadata Metadata `yaml:"metadata_config"`
}

// Metadata configures the metadata store to use
type Metadata struct {
GatewayAddress string `yaml:"gateway_addr" env:"WEB_STORAGE_GATEWAY_GRPC_ADDR;STORAGE_GATEWAY_GRPC_ADDR" desc:"GRPC address of the STORAGE-SYSTEM service." introductionVersion:"%%NEXT%%"`
StorageAddress string `yaml:"storage_addr" env:"WEB_STORAGE_GRPC_ADDR;STORAGE_GRPC_ADDR" desc:"GRPC address of the STORAGE-SYSTEM service." introductionVersion:"%%NEXT%%"`

SystemUserID string `yaml:"system_user_id" env:"OC_SYSTEM_USER_ID;WEB_SYSTEM_USER_ID" desc:"ID of the OpenCloud STORAGE-SYSTEM system user. Admins need to set the ID for the STORAGE-SYSTEM system user in this config option which is then used to reference the user. Any reasonable long string is possible, preferably this would be an UUIDv4 format." introductionVersion:"%%NEXT%%"`
SystemUserIDP string `yaml:"system_user_idp" env:"OC_SYSTEM_USER_IDP;WEB_SYSTEM_USER_IDP" desc:"IDP of the OpenCloud STORAGE-SYSTEM system user." introductionVersion:"%%NEXT%%"`
SystemUserAPIKey string `yaml:"system_user_api_key" env:"OC_SYSTEM_USER_API_KEY" desc:"API key for the STORAGE-SYSTEM system user." introductionVersion:"%%NEXT%%"`
}

// Asset defines the available asset configuration.
Expand Down
Loading