remove the graph-explorer servier from ocis (#4733)

This commit is contained in:
David Christofas
2022-10-04 15:55:30 +02:00
committed by GitHub
parent 3e43f414b6
commit 3babaf1a4d
58 changed files with 6 additions and 1350 deletions

View File

@@ -66,7 +66,6 @@ config = {
"services/auth-machine",
"services/frontend",
"services/gateway",
"services/graph-explorer",
"services/graph",
"services/groups",
"services/idm",
@@ -1944,7 +1943,7 @@ def ocisServer(storage, accounts_hash_difficulty = 4, volumes = [], depends_on =
"SHARING_USER_OWNCLOUDSQL_DB_NAME": "owncloud",
# General oCIS config
# OCIS_RUN_SERVICES specifies to start all fullstack services except idm and idp. These are replaced by external services
"OCIS_RUN_SERVICES": "app-registry,app-provider,auth-basic,auth-machine,frontend,gateway,graph,graph-explorer,groups,nats,notifications,ocdav,ocs,proxy,search,settings,sharing,storage-system,storage-publiclink,storage-shares,storage-users,store,thumbnails,users,web,webdav",
"OCIS_RUN_SERVICES": "app-registry,app-provider,auth-basic,auth-machine,frontend,gateway,graph,groups,nats,notifications,ocdav,ocs,proxy,search,settings,sharing,storage-system,storage-publiclink,storage-shares,storage-users,store,thumbnails,users,web,webdav",
"OCIS_LOG_LEVEL": "info",
"OCIS_URL": OCIS_URL,
"OCIS_BASE_DATA_PATH": "/mnt/data/ocis",

2
.vscode/launch.json vendored
View File

@@ -27,7 +27,7 @@
// demo users
"IDM_CREATE_DEMO_USERS": "true",
// OCIS_RUN_SERVICES allows to start a subset of services even in the supervised mode
//"OCIS_RUN_SERVICES": "settings,storage-system,graph,graph-explorer,idp,idm,ocs,store,thumbnails,web,webdav,frontend,gateway,users,groups,auth-basic,storage-authmachine,storage-users,storage-shares,storage-publiclink,storage-system,app-provider,sharing,proxy,ocdav",
//"OCIS_RUN_SERVICES": "settings,storage-system,graph,idp,idm,ocs,store,thumbnails,web,webdav,frontend,gateway,users,groups,auth-basic,storage-authmachine,storage-users,storage-shares,storage-publiclink,storage-system,app-provider,sharing,proxy,ocdav",
/*
* Keep secrets and passwords in one block to allow easy uncommenting

View File

@@ -25,7 +25,6 @@ OCIS_MODULES = \
services/frontend \
services/gateway \
services/graph \
services/graph-explorer \
services/groups \
services/idm \
services/idp \

View File

@@ -51,8 +51,6 @@ policies:
backend: http://localhost:9140
- endpoint: /graph/
backend: http://localhost:9120
- endpoint: /graph-explorer
backend: http://localhost:9135
- endpoint: /api/v0/settings
backend: http://localhost:9190
- endpoint: /settings.js

View File

@@ -111,7 +111,7 @@ services:
OCIS_STORAGE_READ_ONLY: "false" # TODO: conflict with OWNCLOUDSQL -> https://github.com/owncloud/ocis/issues/2303
# General oCIS config
# OCIS_RUN_SERVICES specifies to start all fullstack services except idm and idp. These are replaced by external services
OCIS_RUN_SERVICES: app-registry,app-provider,auth-basic,auth-machine,frontend,gateway,graph,graph-explorer,groups,nats,notifications,ocdav,ocs,proxy,search,settings,sharing,storage-system,storage-publiclink,storage-shares,storage-users,store,thumbnails,users,web,webdav
OCIS_RUN_SERVICES: app-registry,app-provider,auth-basic,auth-machine,frontend,gateway,graph,groups,nats,notifications,ocdav,ocs,proxy,search,settings,sharing,storage-system,storage-publiclink,storage-shares,storage-users,store,thumbnails,users,web,webdav
OCIS_LOG_LEVEL: ${OCIS_LOG_LEVEL:-error} # make oCIS less verbose
OCIS_LOG_COLOR: "${OCIS_LOG_COLOR:-false}"
OCIS_URL: https://${CLOUD_DOMAIN:-cloud.owncloud.test}

View File

@@ -51,8 +51,6 @@ policies:
backend: http://localhost:9140
- endpoint: /graph/
backend: http://localhost:9120
- endpoint: /graph-explorer
backend: http://localhost:9135
- endpoint: /api/v0/settings
backend: http://localhost:9190
- endpoint: /settings.js

View File

@@ -47,8 +47,6 @@ policies:
backend: http://frontend:9140
- endpoint: /graph/
backend: http://graph:9120
- endpoint: /graph-explorer
backend: http://graph-explorer:9135
- endpoint: /api/v0/settings
backend: http://settings:9190
- endpoint: /settings.js

View File

@@ -185,28 +185,6 @@ services:
driver: "local"
restart: always
graph-explorer:
image: owncloud/ocis:${OCIS_DOCKER_TAG:-latest}
deploy:
replicas: ${OCIS_SCALE:-1}
networks:
ocis-net:
entrypoint:
- ocis
- graph-explorer
- server
environment:
GRAPH_EXPLOER_LOG_LEVEL: "${OCIS_LOG_LEVEL:-error}"
GRAPH_EXPLOER_LOG_COLOR: "${OCIS_LOG_COLOR:-false}"
GRAPH_EXPLOER_LOG_PRETTY: "${OCIS_LOG_PRETTY:-false}"
GRAPH_EXPLORER_HTTP_ADDR: 0.0.0.0:9135
GRAPH_EXPLORER_ISSUER: https://${OCIS_DOMAIN}
GRAPH_EXPLORER_GRAPH_URL_BASE: https://${OCIS_DOMAIN}
logging:
driver: "local"
restart: always
audit:
image: owncloud/ocis:${OCIS_DOCKER_TAG:-latest}
deploy:

View File

@@ -83,14 +83,6 @@ services:
OCIS_TRACING_ENDPOINT: jaeger-agent:6831
# metrics
GRAPH_DEBUG_ADDR: 0.0.0.0:9124
#graph-explorer:
# environment:
# # tracing
# OCIS_TRACING_ENABLED: "true"
# OCIS_TRACING_TYPE: jaeger
# OCIS_TRACING_ENDPOINT: jaeger-agent:6831
# # metrics
# GRAPH_EXPLORER_DEBUG_ADDR: 0.0.0.0:9136
storage-system:
environment:
# tracing

View File

@@ -74,7 +74,7 @@ services:
IDP_LDAP_UUID_ATTRIBUTE_TYPE: binary
GRAPH_LDAP_SERVER_WRITE_ENABLED: "false" # assuming the external ldap is readonly
# OCIS_RUN_SERVICES specifies to start all services except glauth, idm and accounts. These are replaced by external services
OCIS_RUN_SERVICES: app-registry,app-provider,audit,auth-basic,auth-machine,frontend,gateway,graph,graph-explorer,groups,idp,nats,notifications,ocdav,ocs,proxy,search,settings,sharing,storage-system,storage-publiclink,storage-shares,storage-users,store,thumbnails,users,web,webdav
OCIS_RUN_SERVICES: app-registry,app-provider,audit,auth-basic,auth-machine,frontend,gateway,graph,groups,idp,nats,notifications,ocdav,ocs,proxy,search,settings,sharing,storage-system,storage-publiclink,storage-shares,storage-users,store,thumbnails,users,web,webdav
# General oCIS config
OCIS_URL: https://${OCIS_DOMAIN:-ocis.owncloud.test}
OCIS_LOG_LEVEL: ${OCIS_LOG_LEVEL:-error} # make oCIS less verbose

View File

@@ -28,7 +28,6 @@ Run the debug binary with `OCIS_LOG_LEVEL=debug bin/ocis-debug server` and then
12837 pts/1 Sl+ 0:00 bin/ocis-debug server
12845 pts/1 Sl 0:00 bin/ocis-debug graph
12847 pts/1 Sl 0:00 bin/ocis-debug reva-auth-bearer
12848 pts/1 Sl 0:00 bin/ocis-debug graph-explorer
12849 pts/1 Sl 0:00 bin/ocis-debug ocs
12850 pts/1 Sl 0:00 bin/ocis-debug reva-storage-oc-data
12863 pts/1 Sl 0:00 bin/ocis-debug webdav
@@ -78,7 +77,6 @@ LOG_LEVEL="debug"
bin/ocis --log-level=$LOG_LEVEL micro &
bin/ocis --log-level=$LOG_LEVEL glauth &
bin/ocis --log-level=$LOG_LEVEL graph-explorer &
bin/ocis --log-level=$LOG_LEVEL graph &
#bin/ocis --log-level=$LOG_LEVEL hello &
bin/ocis --log-level=$LOG_LEVEL idp &
@@ -107,7 +105,6 @@ bin/ocis --log-level=$LOG_LEVEL proxy &
12837 pts/1 Sl+ 0:00 bin/ocis-debug server
12845 pts/1 Sl 0:00 bin/ocis-debug graph
12847 pts/1 Sl 0:00 bin/ocis-debug reva-auth-bearer
12848 pts/1 Sl 0:00 bin/ocis-debug graph-explorer
12849 pts/1 Sl 0:00 bin/ocis-debug ocs
12850 pts/1 Sl 0:00 bin/ocis-debug reva-storage-oc-data
12863 pts/1 Sl 0:00 bin/ocis-debug webdav

View File

@@ -1,18 +0,0 @@
---
title: "Graph-Explorer"
date: 2018-05-02T00:00:00+00:00
weight: 20
geekdocRepo: https://github.com/owncloud/ocis
geekdocEditPath: edit/master/docs/services/graph-explorer
geekdocFilePath: _index.md
geekdocCollapseSection: true
---
## Abstract
This service embeds [Graph-Explorer](https://github.com/owncloud/ocis/tree/master/graph-explorer) to provide a UI for ownCloud Infinite Scale.
## Table of Contents
{{< toc-tree >}}

View File

@@ -1,15 +0,0 @@
---
title: Service Configuration
date: 2018-05-02T00:00:00+00:00
weight: 20
geekdocRepo: https://github.com/owncloud/ocis
geekdocEditPath: edit/master/docs/services/graph-explorer
geekdocFilePath: configuration.md
geekdocCollapseSection: true
---
## Example YAML Config
{{< include file="services/_includes/graph-explorer-config-example.yaml" language="yaml" >}}
{{< include file="services/_includes/graph-explorer_configvars.md" >}}

View File

@@ -31,7 +31,7 @@ We also suggest to use the last port in your extensions' range as a debug/metric
| 9120-9124 | [graph]({{< ref "./graph/_index.md" >}}) |
| 9125-9129 | FREE (formerly used by glauth) |
| 9130-9134 | [idp]({{< ref "./idp/_index.md" >}}) |
| 9135-9139 | [graph-explorer]({{< ref "./graph-explorer/_index.md" >}}) |
| 9135-9139 | FREE (formerly used by graph-explorer) |
| 9140-9141 | [frontend]({{< ref "./frontend/_index.md" >}}) |
| 9142-9143 | [gateway]({{< ref "./gateway/_index.md" >}}) |
| 9144-9145 | [users]({{< ref "./users/_index.md" >}}) |

View File

@@ -11,7 +11,6 @@ import (
authmachine "github.com/owncloud/ocis/v2/services/auth-machine/pkg/config"
frontend "github.com/owncloud/ocis/v2/services/frontend/pkg/config"
gateway "github.com/owncloud/ocis/v2/services/gateway/pkg/config"
graphExplorer "github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config"
graph "github.com/owncloud/ocis/v2/services/graph/pkg/config"
groups "github.com/owncloud/ocis/v2/services/groups/pkg/config"
idm "github.com/owncloud/ocis/v2/services/idm/pkg/config"
@@ -83,7 +82,6 @@ type Config struct {
Frontend *frontend.Config `yaml:"frontend"`
Gateway *gateway.Config `yaml:"gateway"`
Graph *graph.Config `yaml:"graph"`
GraphExplorer *graphExplorer.Config `yaml:"graph_explorer"`
Groups *groups.Config `yaml:"groups"`
IDM *idm.Config `yaml:"idm"`
IDP *idp.Config `yaml:"idp"`

View File

@@ -9,7 +9,6 @@ import (
authmachine "github.com/owncloud/ocis/v2/services/auth-machine/pkg/config/defaults"
frontend "github.com/owncloud/ocis/v2/services/frontend/pkg/config/defaults"
gateway "github.com/owncloud/ocis/v2/services/gateway/pkg/config/defaults"
graphExplorer "github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config/defaults"
graph "github.com/owncloud/ocis/v2/services/graph/pkg/config/defaults"
groups "github.com/owncloud/ocis/v2/services/groups/pkg/config/defaults"
idm "github.com/owncloud/ocis/v2/services/idm/pkg/config/defaults"
@@ -50,7 +49,6 @@ func DefaultConfig() *Config {
Frontend: frontend.DefaultConfig(),
Gateway: gateway.DefaultConfig(),
Graph: graph.DefaultConfig(),
GraphExplorer: graphExplorer.DefaultConfig(),
Groups: groups.DefaultConfig(),
IDM: idm.DefaultConfig(),
IDP: idp.DefaultConfig(),

View File

@@ -1,30 +0,0 @@
package command
import (
"github.com/owncloud/ocis/v2/ocis-pkg/config"
"github.com/owncloud/ocis/v2/ocis-pkg/config/configlog"
"github.com/owncloud/ocis/v2/ocis-pkg/config/parser"
"github.com/owncloud/ocis/v2/ocis/pkg/command/helper"
"github.com/owncloud/ocis/v2/ocis/pkg/register"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/command"
"github.com/urfave/cli/v2"
)
// GraphExplorerCommand is the entrypoint for the graph-explorer command.
func GraphExplorerCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: cfg.GraphExplorer.Service.Name,
Usage: helper.SubcommandDescription(cfg.GraphExplorer.Service.Name),
Category: "services",
Before: func(c *cli.Context) error {
configlog.Error(parser.ParseConfig(cfg, true))
cfg.GraphExplorer.Commons = cfg.Commons
return nil
},
Subcommands: command.GetCommands(cfg.GraphExplorer),
}
}
func init() {
register.AddCommand(GraphExplorerCommand)
}

View File

@@ -26,7 +26,6 @@ import (
authmachine "github.com/owncloud/ocis/v2/services/auth-machine/pkg/command"
frontend "github.com/owncloud/ocis/v2/services/frontend/pkg/command"
gateway "github.com/owncloud/ocis/v2/services/gateway/pkg/command"
graphExplorer "github.com/owncloud/ocis/v2/services/graph-explorer/pkg/command"
graph "github.com/owncloud/ocis/v2/services/graph/pkg/command"
groups "github.com/owncloud/ocis/v2/services/groups/pkg/command"
idm "github.com/owncloud/ocis/v2/services/idm/pkg/command"
@@ -106,7 +105,6 @@ func NewService(options ...Option) (*Service, error) {
s.ServicesRegistry[opts.Config.Nats.Service.Name] = nats.NewSutureService
s.ServicesRegistry[opts.Config.StorageSystem.Service.Name] = storageSystem.NewSutureService
s.ServicesRegistry[opts.Config.Graph.Service.Name] = graph.NewSutureService
s.ServicesRegistry[opts.Config.GraphExplorer.Service.Name] = graphExplorer.NewSutureService
s.ServicesRegistry[opts.Config.IDM.Service.Name] = idm.NewSutureService
s.ServicesRegistry[opts.Config.OCS.Service.Name] = ocs.NewSutureService
s.ServicesRegistry[opts.Config.Store.Service.Name] = store.NewSutureService

View File

@@ -1,2 +0,0 @@
*
!bin/

View File

@@ -1,44 +0,0 @@
SHELL := bash
NAME := graph-explorer
include ../../.make/recursion.mk
############ tooling ############
ifneq (, $(shell command -v go 2> /dev/null)) # suppress `command not found warnings` for non go targets in CI
include ../../.bingo/Variables.mk
endif
############ go tooling ############
include ../../.make/go.mk
############ release ############
include ../../.make/release.mk
############ docs generate ############
include ../../.make/docs.mk
.PHONY: docs-generate
docs-generate: config-docs-generate
############ generate ############
include ../../.make/generate.mk
.PHONY: ci-go-generate
ci-go-generate: # CI runs ci-node-generate automatically before this target
.PHONY: ci-node-generate
ci-node-generate: pull-assets
.PHONY: pull-assets
pull-assets:
git clean -xfd assets
curl --fail -slL -o- https://github.com/owncloud/graph-explorer/releases/download/v1.7.10.3/release.tar.gz | tar xvzf - -C assets/
############ licenses ############
.PHONY: ci-node-check-licenses
ci-node-check-licenses:
#TODO: check this fork!
.PHONY: ci-node-save-licenses
ci-node-save-licenses:
#TODO: check this fork! But it doesn't even build

View File

@@ -1,14 +0,0 @@
package main
import (
"os"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/command"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config/defaults"
)
func main() {
if err := command.Execute(defaults.DefaultConfig()); err != nil {
os.Exit(1)
}
}

View File

@@ -1,19 +0,0 @@
FROM amd64/alpine:latest
RUN apk update && \
apk upgrade && \
apk add ca-certificates mailcap && \
rm -rf /var/cache/apk/* && \
echo 'hosts: files dns' >| /etc/nsswitch.conf
LABEL maintainer="ownCloud GmbH <devops@owncloud.com>" \
org.label-schema.name="oCIS Graph-Explorer" \
org.label-schema.vendor="ownCloud GmbH" \
org.label-schema.schema-version="1.0"
EXPOSE 9100 9104
ENTRYPOINT ["/usr/bin/ocis-graph-explorer"]
CMD ["server"]
COPY bin/ocis-graph-explorer /usr/bin/ocis-graph-explorer

View File

@@ -1,19 +0,0 @@
FROM arm32v6/alpine:latest
RUN apk update && \
apk upgrade && \
apk add ca-certificates mailcap && \
rm -rf /var/cache/apk/* && \
echo 'hosts: files dns' >| /etc/nsswitch.conf
LABEL maintainer="ownCloud GmbH <devops@owncloud.com>" \
org.label-schema.name="oCIS Graph-Explorer" \
org.label-schema.vendor="ownCloud GmbH" \
org.label-schema.schema-version="1.0"
EXPOSE 9100 9104
ENTRYPOINT ["/usr/bin/ocis-graph-explorer"]
CMD ["server"]
COPY bin/ocis-graph-explorer /usr/bin/ocis-graph-explorer

View File

@@ -1,19 +0,0 @@
FROM arm64v8/alpine:latest
RUN apk update && \
apk upgrade && \
apk add ca-certificates mailcap && \
rm -rf /var/cache/apk/* && \
echo 'hosts: files dns' >| /etc/nsswitch.conf
LABEL maintainer="ownCloud GmbH <devops@owncloud.com>" \
org.label-schema.name="oCIS Graph-Explorer" \
org.label-schema.vendor="ownCloud GmbH" \
org.label-schema.schema-version="1.0"
EXPOSE 9100 9104
ENTRYPOINT ["/usr/bin/ocis-graph-explorer"]
CMD ["server"]
COPY bin/ocis-graph-explorer /usr/bin/ocis-graph-explorer

View File

@@ -1,22 +0,0 @@
image: owncloud/ocis-graph-explorer:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
- image: owncloud/ocis-graph-explorer:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
platform:
architecture: amd64
os: linux
- image: owncloud/ocis-graph-explorer:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
platform:
architecture: arm64
variant: v8
os: linux
- image: owncloud/ocis-graph-explorer:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
architecture: arm
variant: v6
os: linux

View File

@@ -1,9 +0,0 @@
package graphexplorer
import (
"embed"
)
//go:generate make generate
//go:embed assets/*
var Assets embed.FS

View File

@@ -1,50 +0,0 @@
package assets
import (
"net/http"
"github.com/owncloud/ocis/v2/ocis-pkg/assetsfs"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
graphexplorer "github.com/owncloud/ocis/v2/services/graph-explorer"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config"
)
// New returns a new http filesystem to serve assets.
func New(opts ...Option) http.FileSystem {
options := newOptions(opts...)
return assetsfs.New(graphexplorer.Assets, "", options.Logger)
}
// Option defines a single option function.
type Option func(o *Options)
// Options defines the available options for this package.
type Options struct {
Logger log.Logger
Config *config.Config
}
// newOptions initializes the available default options.
func newOptions(opts ...Option) Options {
opt := Options{}
for _, o := range opts {
o(&opt)
}
return opt
}
// Logger provides a function to set the logger option.
func Logger(val log.Logger) Option {
return func(o *Options) {
o.Logger = val
}
}
// Config provides a function to set the config option.
func Config(val *config.Config) Option {
return func(o *Options) {
o.Config = val
}
}

View File

@@ -1,54 +0,0 @@
package command
import (
"fmt"
"net/http"
"github.com/owncloud/ocis/v2/ocis-pkg/config/configlog"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config/parser"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/logging"
"github.com/urfave/cli/v2"
)
// Health is the entrypoint for the health command.
func Health(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "health",
Usage: "check health status",
Category: "info",
Before: func(c *cli.Context) error {
return configlog.ReturnError(parser.ParseConfig(cfg))
},
Action: func(c *cli.Context) error {
logger := logging.Configure(cfg.Service.Name, cfg.Log)
resp, err := http.Get(
fmt.Sprintf(
"http://%s/healthz",
cfg.Debug.Addr,
),
)
if err != nil {
logger.Fatal().
Err(err).
Msg("Failed to request health check")
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
logger.Fatal().
Int("code", resp.StatusCode).
Msg("Health seems to be in bad state")
}
logger.Debug().
Int("code", resp.StatusCode).
Msg("Health got a good state")
return nil
},
}
}

View File

@@ -1,59 +0,0 @@
package command
import (
"context"
"os"
"github.com/owncloud/ocis/v2/ocis-pkg/clihelper"
ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config"
"github.com/thejerf/suture/v4"
"github.com/urfave/cli/v2"
)
// GetCommands provides all commands for this service
func GetCommands(cfg *config.Config) cli.Commands {
return []*cli.Command{
// start this service
Server(cfg),
// interaction with this service
// infos about this service
Health(cfg),
Version(cfg),
}
}
// Execute is the entry point for the graph-explorer command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultApp(&cli.App{
Name: "graph-explorer",
Usage: "Serve Graph-Explorer for oCIS",
Commands: GetCommands(cfg),
})
return app.Run(os.Args)
}
// SutureService allows for the graph-explorer command to be embedded and supervised by a suture supervisor tree.
type SutureService struct {
cfg *config.Config
}
// NewSutureService creates a new graph-explorer.SutureService
func NewSutureService(cfg *ociscfg.Config) suture.Service {
cfg.GraphExplorer.Commons = cfg.Commons
return SutureService{
cfg: cfg.GraphExplorer,
}
}
func (s SutureService) Serve(ctx context.Context) error {
s.cfg.Context = ctx
if err := Execute(s.cfg); err != nil {
return err
}
return nil
}

View File

@@ -1,104 +0,0 @@
package command
import (
"context"
"fmt"
"github.com/oklog/run"
"github.com/owncloud/ocis/v2/ocis-pkg/config/configlog"
"github.com/owncloud/ocis/v2/ocis-pkg/version"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config/parser"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/logging"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/metrics"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/server/debug"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/server/http"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/tracing"
"github.com/urfave/cli/v2"
)
// Server is the entrypoint for the server command.
func Server(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "server",
Usage: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name),
Category: "server",
Before: func(ctx *cli.Context) error {
return configlog.ReturnFatal(parser.ParseConfig(cfg))
},
Action: func(c *cli.Context) error {
logger := logging.Configure(cfg.Service.Name, cfg.Log)
err := tracing.Configure(cfg)
if err != nil {
return err
}
var (
gr = run.Group{}
ctx, cancel = func() (context.Context, context.CancelFunc) {
if cfg.Context == nil {
return context.WithCancel(context.Background())
}
return context.WithCancel(cfg.Context)
}()
mtrcs = metrics.New()
)
defer cancel()
mtrcs.BuildInfo.WithLabelValues(version.GetString()).Set(1)
{
server, err := http.Server(
http.Logger(logger),
http.Context(ctx),
http.Namespace(cfg.HTTP.Namespace),
http.Config(cfg),
http.Metrics(mtrcs),
)
if err != nil {
logger.Info().Err(err).Str("transport", "http").Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
err := server.Run()
if err != nil {
logger.Error().
Err(err).
Str("transport", "http").
Msg("Failed to start server")
}
return err
}, func(err error) {
logger.Error().
Str("transport", "http").
Err(err).
Msg("Shutting down server")
cancel()
})
}
{
server, err := debug.Server(
debug.Logger(logger),
debug.Context(ctx),
debug.Config(cfg),
)
if err != nil {
logger.Info().Err(err).Str("transport", "debug").Msg("Failed to initialize server")
return err
}
gr.Add(server.ListenAndServe, func(_ error) {
_ = server.Shutdown(ctx)
cancel()
})
}
return gr.Run()
},
}
}

View File

@@ -1,50 +0,0 @@
package command
import (
"fmt"
"os"
"github.com/owncloud/ocis/v2/ocis-pkg/registry"
"github.com/owncloud/ocis/v2/ocis-pkg/version"
tw "github.com/olekukonko/tablewriter"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config"
"github.com/urfave/cli/v2"
)
// Version prints the service versions of all running instances.
func Version(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "version",
Usage: "print the version of this binary and the running service instances",
Category: "info",
Action: func(c *cli.Context) error {
fmt.Println("Version: " + version.GetString())
fmt.Printf("Compiled: %s\n", version.Compiled())
fmt.Println("")
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get %s services from the registry: %v", cfg.Service.Name, err))
return err
}
if len(services) == 0 {
fmt.Println("No running " + cfg.Service.Name + " service found.")
return nil
}
table := tw.NewWriter(os.Stdout)
table.SetHeader([]string{"Version", "Address", "Id"})
table.SetAutoFormatHeaders(false)
for _, s := range services {
for _, n := range s.Nodes {
table.Append([]string{s.Version, n.Address, n.Id})
}
}
table.Render()
return nil
},
}
}

View File

@@ -1,32 +0,0 @@
package config
import (
"context"
"github.com/owncloud/ocis/v2/ocis-pkg/shared"
)
// Config combines all available configuration parts.
type Config struct {
Commons *shared.Commons `yaml:"-"` // don't use this directly as configuration for a service
Service Service `yaml:"-"`
Tracing *Tracing `yaml:"tracing"`
Log *Log `yaml:"log"`
Debug Debug `yaml:"debug"`
HTTP HTTP `yaml:"http"`
GraphExplorer GraphExplorer `yaml:"graph_explorer"`
Context context.Context `yaml:"-"`
}
// GraphExplorer defines the available graph-explorer configuration.
type GraphExplorer struct {
ClientID string `yaml:"client_id" env:"GRAPH_EXPLORER_CLIENT_ID" desc:"OIDC client ID the graph explorer uses. This client needs to be set up in your IDP."`
Issuer string `yaml:"issuer" env:"OCIS_URL;OCIS_OIDC_ISSUER;GRAPH_EXPLORER_ISSUER" desc:"URL of the OIDC issuer. It defaults to URL of the builtin IDP."`
GraphURLBase string `yaml:"graph_url_base" env:"OCIS_URL;GRAPH_EXPLORER_GRAPH_URL_BASE" desc:"Base URL where the graph explorer is reachable for users."`
GraphURLPath string `yaml:"graph_url_path" env:"GRAPH_EXPLORER_GRAPH_URL_PATH" desc:"URL path where the graph explorer is reachable for users."`
}

View File

@@ -1,9 +0,0 @@
package config
// Debug defines the available debug configuration.
type Debug struct {
Addr string `yaml:"addr" env:"GRAPH_EXPLORER_DEBUG_ADDR" desc:"Bind address of the debug server, where metrics, health, config and debug endpoints will be exposed."`
Token string `yaml:"token" env:"GRAPH_EXPLORER_DEBUG_TOKEN" desc:"Token to secure the metrics endpoint."`
Pprof bool `yaml:"pprof" env:"GRAPH_EXPLORER_DEBUG_PPROF" desc:"Enables pprof, which can be used for profiling."`
Zpages bool `yaml:"zpages" env:"GRAPH_EXPLORER_DEBUG_ZPAGES" desc:"Enables zpages, which can be used for collecting and viewing in-memory traces."`
}

View File

@@ -1,71 +0,0 @@
package defaults
import (
"strings"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config"
)
func FullDefaultConfig() *config.Config {
cfg := DefaultConfig()
EnsureDefaults(cfg)
Sanitize(cfg)
return cfg
}
func DefaultConfig() *config.Config {
return &config.Config{
Debug: config.Debug{
Addr: "127.0.0.1:9136",
Token: "",
Pprof: false,
Zpages: false,
},
HTTP: config.HTTP{
Addr: "127.0.0.1:9135",
Root: "/graph-explorer",
Namespace: "com.owncloud.web",
},
Service: config.Service{
Name: "graph-explorer",
},
GraphExplorer: config.GraphExplorer{
ClientID: "ocis-explorer.js",
Issuer: "https://localhost:9200",
GraphURLBase: "https://localhost:9200",
GraphURLPath: "/graph",
},
}
}
func EnsureDefaults(cfg *config.Config) {
// provide with defaults for shared logging, since we need a valid destination address for "envdecode".
if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil {
cfg.Log = &config.Log{
Level: cfg.Commons.Log.Level,
Pretty: cfg.Commons.Log.Pretty,
Color: cfg.Commons.Log.Color,
File: cfg.Commons.Log.File,
}
} else if cfg.Log == nil {
cfg.Log = &config.Log{}
}
// provide with defaults for shared tracing, since we need a valid destination address for "envdecode".
if cfg.Tracing == nil && cfg.Commons != nil && cfg.Commons.Tracing != nil {
cfg.Tracing = &config.Tracing{
Enabled: cfg.Commons.Tracing.Enabled,
Type: cfg.Commons.Tracing.Type,
Endpoint: cfg.Commons.Tracing.Endpoint,
Collector: cfg.Commons.Tracing.Collector,
}
} else if cfg.Tracing == nil {
cfg.Tracing = &config.Tracing{}
}
}
func Sanitize(cfg *config.Config) {
// sanitize config
if cfg.HTTP.Root == "/" {
cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/graph-explorer")
}
}

View File

@@ -1,16 +0,0 @@
package config
// HTTP defines the available http configuration.
type HTTP struct {
Addr string `yaml:"addr" env:"GRAPH_EXPLORER_HTTP_ADDR" desc:"The bind address of the HTTP service."`
Root string `yaml:"root" env:"GRAPH_EXPLORER_HTTP_ROOT" desc:"Subdirectory that serves as the root for this HTTP service."`
Namespace string `yaml:"-"`
}
// CORS defines the available cors configuration.
type CORS struct {
AllowedOrigins []string `yaml:"allowed_origins"`
AllowedMethods []string `yaml:"allowed_methods"`
AllowedHeaders []string `yaml:"allowed_headers"`
AllowCredentials bool `yaml:"allowed_credentials"`
}

View File

@@ -1,9 +0,0 @@
package config
// Log defines the available log configuration.
type Log struct {
Level string `mapstructure:"level" env:"OCIS_LOG_LEVEL;GRAPH_EXPLORER_LOG_LEVEL" desc:"The log level. Valid values are: \"panic\", \"fatal\", \"error\", \"warn\", \"info\", \"debug\", \"trace\"."`
Pretty bool `mapstructure:"pretty" env:"OCIS_LOG_PRETTY;GRAPH_EXPLORER_LOG_PRETTY" desc:"Activates pretty log output."`
Color bool `mapstructure:"color" env:"OCIS_LOG_COLOR;GRAPH_EXPLORER_LOG_COLOR" desc:"Activates colorized log output."`
File string `mapstructure:"file" env:"OCIS_LOG_FILE;GRAPH_EXPLORER_LOG_FILE" desc:"The path to the log file. Activates logging to this file if set."`
}

View File

@@ -1,38 +0,0 @@
package parser
import (
"errors"
ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config/defaults"
"github.com/owncloud/ocis/v2/ocis-pkg/config/envdecode"
)
// ParseConfig loads configuration from known paths.
func ParseConfig(cfg *config.Config) error {
_, err := ociscfg.BindSourcesToStructs(cfg.Service.Name, cfg)
if err != nil {
return err
}
defaults.EnsureDefaults(cfg)
// load all env variables relevant to the config in the current context.
if err := envdecode.Decode(cfg); err != nil {
// no environment variable set for this config is an expected "error"
if !errors.Is(err, envdecode.ErrNoTargetFieldsAreSet) {
return err
}
}
// sanitize config
defaults.Sanitize(cfg)
return Validate(cfg)
}
func Validate(cfg *config.Config) error {
return nil
}

View File

@@ -1,6 +0,0 @@
package config
// Service defines the available service configuration.
type Service struct {
Name string `yaml:"-"`
}

View File

@@ -1,9 +0,0 @@
package config
// Tracing defines the available tracing configuration.
type Tracing struct {
Enabled bool `yaml:"enabled" env:"OCIS_TRACING_ENABLED;GRAPH_EXPLORER_TRACING_ENABLED" desc:"Activates tracing."`
Type string `yaml:"type" env:"OCIS_TRACING_TYPE;GRAPH_EXPLORER_TRACING_TYPE" desc:"The type of tracing. Defaults to \"\", which is the same as \"jaeger\". Allowed tracing types are \"jaeger\" and \"\" as of now."`
Endpoint string `yaml:"endpoint" env:"OCIS_TRACING_ENDPOINT;GRAPH_EXPLORER_TRACING_ENDPOINT" desc:"The endpoint of the tracing agent."`
Collector string `yaml:"collector" env:"OCIS_TRACING_COLLECTOR;GRAPH_EXPLORER_TRACING_COLLECTOR" desc:"The HTTP endpoint for sending spans directly to a collector, i.e. http://jaeger-collector:14268/api/traces. Only used if the tracing endpoint is unset."`
}

View File

@@ -1,17 +0,0 @@
package logging
import (
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config"
)
// LoggerFromConfig initializes a service-specific logger instance.
func Configure(name string, cfg *config.Log) log.Logger {
return log.NewLogger(
log.Name(name),
log.Level(cfg.Level),
log.Pretty(cfg.Pretty),
log.Color(cfg.Color),
log.File(cfg.File),
)
}

View File

@@ -1,33 +0,0 @@
package metrics
import "github.com/prometheus/client_golang/prometheus"
var (
// Namespace defines the namespace for the defines metrics.
Namespace = "ocis"
// Subsystem defines the subsystem for the defines metrics.
Subsystem = "graph-explorer"
)
// Metrics defines the available metrics of this service.
type Metrics struct {
// Counter *prometheus.CounterVec
BuildInfo *prometheus.GaugeVec
}
// New initializes the available metrics.
func New() *Metrics {
m := &Metrics{
BuildInfo: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: Subsystem,
Name: "build_info",
Help: "Build information",
}, []string{"version"}),
}
_ = prometheus.Register(m.BuildInfo)
// TODO: implement metrics
return m
}

View File

@@ -1,50 +0,0 @@
package debug
import (
"context"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config"
)
// Option defines a single option function.
type Option func(o *Options)
// Options defines the available options for this package.
type Options struct {
Logger log.Logger
Context context.Context
Config *config.Config
}
// newOptions initializes the available default options.
func newOptions(opts ...Option) Options {
opt := Options{}
for _, o := range opts {
o(&opt)
}
return opt
}
// Logger provides a function to set the logger option.
func Logger(val log.Logger) Option {
return func(o *Options) {
o.Logger = val
}
}
// Context provides a function to set the context option.
func Context(val context.Context) Option {
return func(o *Options) {
o.Context = val
}
}
// Config provides a function to set the config option.
func Config(val *config.Config) Option {
return func(o *Options) {
o.Config = val
}
}

View File

@@ -1,59 +0,0 @@
package debug
import (
"io"
"net/http"
"github.com/owncloud/ocis/v2/ocis-pkg/service/debug"
"github.com/owncloud/ocis/v2/ocis-pkg/version"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config"
)
// Server initializes the debug service and server.
func Server(opts ...Option) (*http.Server, error) {
options := newOptions(opts...)
return debug.NewService(
debug.Logger(options.Logger),
debug.Name(options.Config.Service.Name),
debug.Version(version.GetString()),
debug.Address(options.Config.Debug.Addr),
debug.Token(options.Config.Debug.Token),
debug.Pprof(options.Config.Debug.Pprof),
debug.Zpages(options.Config.Debug.Zpages),
debug.Health(health(options.Config)),
debug.Ready(ready(options.Config)),
), nil
}
// health implements the health check.
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK)
// TODO: check if services are up and running
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
// io.WriteString should not fail but if it does we want to know.
if err != nil {
panic(err)
}
}
}
// ready implements the ready check.
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK)
// TODO: check if services are up and running
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
// io.WriteString should not fail but if it does we want to know.
if err != nil {
panic(err)
}
}
}

View File

@@ -1,76 +0,0 @@
package http
import (
"context"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/metrics"
"github.com/urfave/cli/v2"
)
// Option defines a single option function.
type Option func(o *Options)
// Options defines the available options for this package.
type Options struct {
Logger log.Logger
Context context.Context
Config *config.Config
Metrics *metrics.Metrics
Flags []cli.Flag
Namespace string
}
// newOptions initializes the available default options.
func newOptions(opts ...Option) Options {
opt := Options{}
for _, o := range opts {
o(&opt)
}
return opt
}
// Logger provides a function to set the logger option.
func Logger(val log.Logger) Option {
return func(o *Options) {
o.Logger = val
}
}
// Context provides a function to set the context option.
func Context(val context.Context) Option {
return func(o *Options) {
o.Context = val
}
}
// Config provides a function to set the config option.
func Config(val *config.Config) Option {
return func(o *Options) {
o.Config = val
}
}
// Metrics provides a function to set the metrics option.
func Metrics(val *metrics.Metrics) Option {
return func(o *Options) {
o.Metrics = val
}
}
// Flags provides a function to set the flags option.
func Flags(val []cli.Flag) Option {
return func(o *Options) {
o.Flags = append(o.Flags, val...)
}
}
// Namespace provides a function to set the Namespace option.
func Namespace(val string) Option {
return func(o *Options) {
o.Namespace = val
}
}

View File

@@ -1,55 +0,0 @@
package http
import (
chimiddleware "github.com/go-chi/chi/v5/middleware"
"github.com/owncloud/ocis/v2/ocis-pkg/middleware"
"github.com/owncloud/ocis/v2/ocis-pkg/service/http"
"github.com/owncloud/ocis/v2/ocis-pkg/version"
svc "github.com/owncloud/ocis/v2/services/graph-explorer/pkg/service/v0"
"go-micro.dev/v4"
)
// Server initializes the http service and server.
func Server(opts ...Option) (http.Service, error) {
options := newOptions(opts...)
service := http.NewService(
http.Logger(options.Logger),
http.Namespace(options.Namespace),
http.Name("graph-explorer"),
http.Version(version.GetString()),
http.Address(options.Config.HTTP.Addr),
http.Context(options.Context),
http.Flags(options.Flags...),
)
handle := svc.NewService(
svc.Logger(options.Logger),
svc.Config(options.Config),
svc.Middleware(
chimiddleware.RealIP,
chimiddleware.RequestID,
middleware.NoCache,
middleware.Secure,
middleware.Version(
"graph-explorer",
version.GetString(),
),
middleware.Logger(
options.Logger,
),
),
)
{
handle = svc.NewInstrument(handle, options.Metrics)
handle = svc.NewLogging(handle, options.Logger)
handle = svc.NewTracing(handle)
}
if err := micro.RegisterHandler(service.Server(), handle); err != nil {
return http.Service{}, err
}
return service, nil
}

View File

@@ -1,30 +0,0 @@
package svc
import (
"net/http"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/metrics"
)
// NewInstrument returns a service that instruments metrics.
func NewInstrument(next Service, metrics *metrics.Metrics) Service {
return instrument{
next: next,
metrics: metrics,
}
}
type instrument struct {
next Service
metrics *metrics.Metrics
}
// ServeHTTP implements the Service interface.
func (i instrument) ServeHTTP(w http.ResponseWriter, r *http.Request) {
i.next.ServeHTTP(w, r)
}
// ConfigJs implements the Service interface.
func (i instrument) ConfigJs(w http.ResponseWriter, r *http.Request) {
i.next.ConfigJs(w, r)
}

View File

@@ -1,30 +0,0 @@
package svc
import (
"net/http"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
)
// NewLogging returns a service that logs messages.
func NewLogging(next Service, logger log.Logger) Service {
return logging{
next: next,
logger: logger,
}
}
type logging struct {
next Service
logger log.Logger
}
// ServeHTTP implements the Service interface.
func (l logging) ServeHTTP(w http.ResponseWriter, r *http.Request) {
l.next.ServeHTTP(w, r)
}
// ConfigJs implements the Service interface.
func (l logging) ConfigJs(w http.ResponseWriter, r *http.Request) {
l.next.ConfigJs(w, r)
}

View File

@@ -1,50 +0,0 @@
package svc
import (
"net/http"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config"
)
// Option defines a single option function.
type Option func(o *Options)
// Options defines the available options for this package.
type Options struct {
Logger log.Logger
Config *config.Config
Middleware []func(http.Handler) http.Handler
}
// newOptions initializes the available default options.
func newOptions(opts ...Option) Options {
opt := Options{}
for _, o := range opts {
o(&opt)
}
return opt
}
// Logger provides a function to set the logger option.
func Logger(val log.Logger) Option {
return func(o *Options) {
o.Logger = val
}
}
// Config provides a function to set the config option.
func Config(val *config.Config) Option {
return func(o *Options) {
o.Config = val
}
}
// Middleware provides a function to set the middleware option.
func Middleware(val ...func(http.Handler) http.Handler) Option {
return func(o *Options) {
o.Middleware = val
}
}

View File

@@ -1,110 +0,0 @@
package svc
import (
"fmt"
"io"
"net/http"
"strings"
"github.com/go-chi/chi/v5"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/assets"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config"
)
// Service defines the service handlers.
type Service interface {
ServeHTTP(http.ResponseWriter, *http.Request)
ConfigJs(http.ResponseWriter, *http.Request)
}
// NewService returns a service implementation for Service.
func NewService(opts ...Option) Service {
options := newOptions(opts...)
m := chi.NewMux()
m.Use(options.Middleware...)
svc := GraphExplorer{
logger: options.Logger,
config: options.Config,
mux: m,
}
m.Route(options.Config.HTTP.Root, func(r chi.Router) {
r.Get("/config.js", svc.ConfigJs)
r.Mount("/", svc.Static())
})
return svc
}
// GraphExplorer defines implements the business logic for Service.
type GraphExplorer struct {
logger log.Logger
config *config.Config
mux *chi.Mux
}
// ServeHTTP implements the Service interface.
func (p GraphExplorer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
p.mux.ServeHTTP(w, r)
}
// ConfigJs implements the Service interface.
func (p GraphExplorer) ConfigJs(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/javascript")
w.WriteHeader(http.StatusOK)
if _, err := io.WriteString(w, fmt.Sprintf("window.ClientId = \"%v\";", p.config.GraphExplorer.ClientID)); err != nil {
p.logger.Error().Err(err).Msg("Could not write to response writer")
}
if _, err := io.WriteString(w, fmt.Sprintf("window.Iss = \"%v\";", p.config.GraphExplorer.Issuer)); err != nil {
p.logger.Error().Err(err).Msg("Could not write to response writer")
}
if _, err := io.WriteString(w, fmt.Sprintf("window.GraphUrl = \"%v\";", p.config.GraphExplorer.GraphURLBase+p.config.GraphExplorer.GraphURLPath)); err != nil {
p.logger.Error().Err(err).Msg("Could not write to response writer")
}
}
// Static simply serves all static files.
func (p GraphExplorer) Static() http.HandlerFunc {
rootWithSlash := p.config.HTTP.Root
if !strings.HasSuffix(rootWithSlash, "/") {
rootWithSlash = rootWithSlash + "/"
}
static := http.StripPrefix(
rootWithSlash,
http.FileServer(
assets.New(
assets.Logger(p.logger),
assets.Config(p.config),
),
),
)
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if rootWithSlash != "/" && r.URL.Path == p.config.HTTP.Root {
http.Redirect(
w,
r,
rootWithSlash,
http.StatusMovedPermanently,
)
return
}
if r.URL.Path != rootWithSlash && strings.HasSuffix(r.URL.Path, "/") {
http.NotFound(
w,
r,
)
return
}
static.ServeHTTP(w, r)
})
}

View File

@@ -1,26 +0,0 @@
package svc
import (
"net/http"
)
// NewTracing returns a service that instruments traces.
func NewTracing(next Service) Service {
return tracing{
next: next,
}
}
type tracing struct {
next Service
}
// ServeHTTP implements the Service interface.
func (t tracing) ServeHTTP(w http.ResponseWriter, r *http.Request) {
t.next.ServeHTTP(w, r)
}
// ConfigJs implements the Service interface.
func (t tracing) ConfigJs(w http.ResponseWriter, r *http.Request) {
t.next.ConfigJs(w, r)
}

View File

@@ -1,23 +0,0 @@
package tracing
import (
pkgtrace "github.com/owncloud/ocis/v2/ocis-pkg/tracing"
"github.com/owncloud/ocis/v2/services/graph-explorer/pkg/config"
"go.opentelemetry.io/otel/trace"
)
var (
// TraceProvider is the global trace provider for the proxy service.
TraceProvider = trace.NewNoopTracerProvider()
)
func Configure(cfg *config.Config) error {
var err error
if cfg.Tracing.Enabled {
if TraceProvider, err = pkgtrace.GetTraceProvider(cfg.Tracing.Endpoint, cfg.Tracing.Collector, cfg.Service.Name, cfg.Tracing.Type); err != nil {
return err
}
}
return nil
}

View File

@@ -1,2 +0,0 @@
# backend
-r '^(cmd|pkg)/.*\.go$' -R '^node_modules/' -s -- sh -c 'make bin/ocis-graph-explorer-debug && bin/ocis-graph-explorer-debug --log-level debug server --debug-pprof --debug-zpages --asset-path assets/'

View File

@@ -81,17 +81,6 @@ func DefaultConfig() *config.Config {
"{{OCIS_URL}}",
},
},
{
ID: "ocis-explorer.js",
Name: "oCIS Graph Explorer",
Trusted: true,
RedirectURIs: []string{
"{{OCIS_URL}}/graph-explorer/",
},
Origins: []string{
"{{OCIS_URL}}",
},
},
{
ID: "xdXOt13JKxym1B1QcEncf2XDkLAexMBFwiT9j6EfhhHFJhs2KM9jbjTmf8JBXE69",
Secret: "UBntmLjC2yYCeHwsyj73Uwo9TAaecAetRwMw0xYcvNL9yRdLSUi0hUAHfvCHFeFh",

View File

@@ -190,11 +190,6 @@ func DefaultPolicies() []config.Policy {
Endpoint: "/graph/",
Backend: "http://localhost:9120",
},
{
Endpoint: "/graph-explorer",
Backend: "http://localhost:9135",
Unprotected: true,
},
{
Endpoint: "/api/v0/settings",
Backend: "http://localhost:9190",

View File

@@ -33,7 +33,7 @@ sonar.go.coverage.reportPaths=cache/coverage/*
# golangci-lint does not support wildcard
# https://github.com/SonarSource/slang/blob/85b05160bc1b31c6072a35f8818da4376b107afa/sonar-go-plugin/src/main/java/org/sonar/go/externalreport/GolangCILintReportSensor.java#L37
# https://github.com/SonarSource/slang/blob/85b05160bc1b31c6072a35f8818da4376b107afa/sonar-go-plugin/src/main/java/org/sonar/go/externalreport/AbstractReportSensor.java#L76-L90
sonar.go.golangci-lint.reportPaths=cache/checkstyle/app-provider_checkstyle.xml,cache/checkstyle/app-registry_checkstyle.xml,cache/checkstyle/audit_checkstyle.xml,cache/checkstyle/auth-basic_checkstyle.xml,cache/checkstyle/auth-bearer_checkstyle.xml,cache/checkstyle/auth-machine_checkstyle.xml,cache/checkstyle/frontend_checkstyle.xml,cache/checkstyle/gateway_checkstyle.xml,cache/checkstyle/graph_checkstyle.xml,cache/checkstyle/graph-explorer_checkstyle.xml,cache/checkstyle/groups_checkstyle.xml,cache/checkstyle/idm_checkstyle.xml,cache/checkstyle/idp_checkstyle.xml,cache/checkstyle/nats_checkstyle.xml,cache/checkstyle/notifications_checkstyle.xml,cache/checkstyle/ocdav_checkstyle.xml,cache/checkstyle/ocs_checkstyle.xml,cache/checkstyle/proxy_checkstyle.xml,cache/checkstyle/search_checkstyle.xml,cache/checkstyle/settings_checkstyle.xml,cache/checkstyle/sharing_checkstyle.xml,cache/checkstyle/storage-publiclink_checkstyle.xml,cache/checkstyle/storage-shares_checkstyle.xml,cache/checkstyle/storage-system_checkstyle.xml,cache/checkstyle/storage-users_checkstyle.xml,cache/checkstyle/store_checkstyle.xml,cache/checkstyle/thumbnails_checkstyle.xml,cache/checkstyle/users_checkstyle.xml,cache/checkstyle/web_checkstyle.xml,cache/checkstyle/webdav_checkstyle.xml
sonar.go.golangci-lint.reportPaths=cache/checkstyle/app-provider_checkstyle.xml,cache/checkstyle/app-registry_checkstyle.xml,cache/checkstyle/audit_checkstyle.xml,cache/checkstyle/auth-basic_checkstyle.xml,cache/checkstyle/auth-bearer_checkstyle.xml,cache/checkstyle/auth-machine_checkstyle.xml,cache/checkstyle/frontend_checkstyle.xml,cache/checkstyle/gateway_checkstyle.xml,cache/checkstyle/graph_checkstyle.xml,cache/checkstyle/groups_checkstyle.xml,cache/checkstyle/idm_checkstyle.xml,cache/checkstyle/idp_checkstyle.xml,cache/checkstyle/nats_checkstyle.xml,cache/checkstyle/notifications_checkstyle.xml,cache/checkstyle/ocdav_checkstyle.xml,cache/checkstyle/ocs_checkstyle.xml,cache/checkstyle/proxy_checkstyle.xml,cache/checkstyle/search_checkstyle.xml,cache/checkstyle/settings_checkstyle.xml,cache/checkstyle/sharing_checkstyle.xml,cache/checkstyle/storage-publiclink_checkstyle.xml,cache/checkstyle/storage-shares_checkstyle.xml,cache/checkstyle/storage-system_checkstyle.xml,cache/checkstyle/storage-users_checkstyle.xml,cache/checkstyle/store_checkstyle.xml,cache/checkstyle/thumbnails_checkstyle.xml,cache/checkstyle/users_checkstyle.xml,cache/checkstyle/web_checkstyle.xml,cache/checkstyle/webdav_checkstyle.xml
# Exclude files
sonar.exclusions=**/third_party,docs/**,changelog/**,*/pkg/assets/embed.go,idp/assets/identifier/**,**/package.json,**/rollup.config.js,CHANGELOG.md,**/pkg/proto/**/*.pb.*,deployments/**,tests/**,vendor-bin/**,README.md,**/mocks/

View File

@@ -51,8 +51,6 @@ policies:
backend: http://localhost:9140
- endpoint: /graph/
backend: http://localhost:9120
- endpoint: /graph-explorer
backend: http://localhost:9135
- endpoint: /api/v0/settings
backend: http://localhost:9190
- endpoint: /settings.js