Merge pull request #4 from butonic/separate-services

separate reva services
This commit is contained in:
Jörn Friedrich Dreyer
2020-01-17 10:11:14 +01:00
committed by GitHub
43 changed files with 5578 additions and 1306 deletions

View File

@@ -15,20 +15,57 @@ You can download prebuilt binaries from the GitHub releases or from our [downloa
## Development
Make sure you have a working Go environment, for further reference or a guide take a look at the [install instructions](http://golang.org/doc/install.html). This project requires Go >= v1.13. For the frontend it's also required to have [NodeJS](https://nodejs.org/en/download/package-manager/) and [Yarn](https://yarnpkg.com/lang/en/docs/install/) installed.
Make sure you have a working Go environment, for further reference or a guide take a look at the [install instructions](http://golang.org/doc/install.html).
```console
git clone https://github.com/owncloud/ocis-reva.git
cd ocis-reva
yarn install
yarn build
make generate build
./bin/ocis-reva -h
```
To run a demo installation you can use the preconfigured defaults and start all necessary services:
```
bin/ocis-reva frontend & \
bin/ocis-reva gateway & \
bin/ocis-reva users & \
bin/ocis-reva auth-basic & \
bin/ocis-reva auth-bearer & \
bin/ocis-reva sharing & \
bin/ocis-reva storage-root & \
bin/ocis-reva storage-home & \
bin/ocis-reva storage-home-data & \
bin/ocis-reva storage-oc & \
bin/ocis-reva storage-oc-data
```
The root storage serves the available namespaces from disk using the local storage driver. In order to be able to navigate into the `/home` and `/oc` storage providers you have to create these directories:
```
mkdir /var/tmp/reva/root/home
mkdir /var/tmp/reva/root/oc
```
Note: the owncloud storage driver currently requires a redis server running on the local machine.
You should now be able to get a file listing of a users home using
```
curl -X PROPFIND http://localhost:9140/remote.php/dav/files/ -v -u einstein:relativity
```
## Users
The default config uses the demo user backend, which contains three users:
```
einstein:relativity
marie:radioactivty
richard:superfluidity
```
For details on the `json` and `ldap` backends see the [documentation](https://owncloud.github.io/ocis-reva/#users)
## Security
If you find a security issue please contact security@owncloud.com first.

View File

@@ -0,0 +1,7 @@
Change: start multiple services with dedicated commands
The initial version would only allow us to use a set of reva configurations to start multiple services.
We use a more opinionated set of commands to start dedicated services that allows us to configure them individually.
It allowcs us to switch eg. the user backend to LDAP and fully it on the cli.
https://github.com/owncloud/ocis-reva/issues/6

View File

@@ -11,7 +11,7 @@ LABEL maintainer="ownCloud GmbH <devops@owncloud.com>" \
org.label-schema.vendor="ownCloud GmbH" \
org.label-schema.schema-version="1.0"
EXPOSE 9135 9136
EXPOSE 9140 9141 9142 9143
ENTRYPOINT ["/usr/bin/ocis-reva"]
CMD ["server"]

View File

@@ -11,7 +11,7 @@ LABEL maintainer="ownCloud GmbH <devops@owncloud.com>" \
org.label-schema.vendor="ownCloud GmbH" \
org.label-schema.schema-version="1.0"
EXPOSE 9135 9136
EXPOSE 9140 9141 9142 9143
ENTRYPOINT ["/usr/bin/ocis-reva"]
CMD ["server"]

View File

@@ -11,7 +11,7 @@ LABEL maintainer="ownCloud GmbH <devops@owncloud.com>" \
org.label-schema.vendor="ownCloud GmbH" \
org.label-schema.schema-version="1.0"
EXPOSE 9135 9136
EXPOSE 9140 9141 9142 9143
ENTRYPOINT ["/usr/bin/ocis-reva"]
CMD ["server"]

View File

@@ -5,4 +5,4 @@ anchor: "about"
weight: 10
---
This service provides a simple hello world example API to show the integration of custom plugins within [Phoenix](https://github.com/owncloud/phoenix).
This service provides an ocis extension that wraps [reva](https://github.com/cs3org/reva/) and adds an opinionated configuration to it.

View File

@@ -5,29 +5,20 @@ anchor: "building"
weight: 30
---
As this project is built with Go and NodeJS, so you need to install that first. The installation of Go and NodeJS is out of the scope of this document, please follow the official documentation for [Go](https://golang.org/doc/install), [NodeJS](https://nodejs.org/en/download/package-manager/) and [Yarn](https://yarnpkg.com/lang/en/docs/install/), to build this project you have to install Go >= v1.13. After the installation of the required tools you need to get the sources:
As this project is built with Go, so you need to install that first. The installation of Go is out of the scope of this document, please follow the official documentation for [Go](https://golang.org/doc/install).To build this project you have to install Go >= v1.13. After the installation of the required tools you need to get the sources:
{{< highlight txt >}}
git clone https://github.com/owncloud/ocis-reva.git
cd ocis-reva
{{< / highlight >}}
All required tool besides Go itself and make are bundled or getting automatically installed within the `GOPATH`. All commands to build this project are part of our `Makefile` and respectively our `package.json`.
All required tool besides Go itself and make are bundled or getting automatically installed within the `GOPATH`. All commands to build this project are part of our `Makefile`.
### Frontend
{{< highlight txt >}}
yarn install
yarn build
{{< / highlight >}}
The above commands will install the required build dependencies and build the whole frontend bundle. This bundle will we embeded into the binary later on.
### Backend
{{< highlight txt >}}
make generate
make build
{{< / highlight >}}
The above commands will embed the frontend bundle into the binary. Finally you should have the binary within the `bin/` folder now, give it a try with `./bin/ocis-reva -h` to see all available options.
The above command should produce the binary within the `bin/` folder now, give it a try with `./bin/ocis-reva -h` to see all available options.

View File

@@ -21,254 +21,5 @@ TBD
We provide overall three different variants of configuration. The variant based on environment variables and commandline flags are split up into global values and command-specific values.
#### Envrionment variables
The configuration tries to map different configuration options from reva into dedicated services. For now please run `bin/ocis-reva {command} -h` to see the list of available options or have a look at [the flagsets](https://github.com/owncloud/ocis-reva/tree/master/pkg/flagset) and the mapping to a reva config in the corresponding [commands](https://github.com/owncloud/ocis-reva/tree/master/pkg/command).
If you prefer to configure the service with environment variables you can see the available variables below.
##### Global
REVA_CONFIG_FILE
: Path to config file, empty default value
REVA_LOG_LEVEL
: Set logging level, defaults to `info`
REVA_LOG_COLOR
: Enable colored logging, defaults to `true`
REVA_LOG_PRETTY
: Enable pretty logging, defaults to `true`
##### Server
REVA_TRACING_ENABLED
: Enable sending traces, defaults to `false`
REVA_TRACING_TYPE
: Tracing backend type, defaults to `jaeger`
REVA_TRACING_ENDPOINT
: Endpoint for the agent, empty default value
REVA_TRACING_COLLECTOR
: Endpoint for the collector, empty default value
REVA_TRACING_SERVICE
: Service name for tracing, defaults to `reva`
REVA_DEBUG_ADDR
: Address to bind debug server, defaults to `0.0.0.0:9109`
REVA_DEBUG_TOKEN
: Token to grant metrics access, empty default value
REVA_DEBUG_PPROF
: Enable pprof debugging, defaults to `false`
REVA_DEBUG_ZPAGES
: Enable zpages debugging, defaults to `false`
REVA_HTTP_ADDR
: Address to bind http server, defaults to `0.0.0.0:9105`
REVA_HTTP_ROOT
: Root path of http server, defaults to `/`
REVA_GRPC_ADDR
: Address to bind grpc server, defaults to `0.0.0.0:9106`
REVA_ASSET_PATH
: Path to custom assets, empty default value
##### Health
REVA_DEBUG_ADDR
: Address to debug endpoint, defaults to `0.0.0.0:9109`
#### Commandline flags
If you prefer to configure the service with commandline flags you can see the available variables below.
##### Global
--config-file
: Path to config file, empty default value
--log-level
: Set logging level, defaults to `info`
--log-color
: Enable colored logging, defaults to `true`
--log-pretty
: Enable pretty logging, defaults to `true`
##### Server
--tracing-enabled
: Enable sending traces, defaults to `false`
--tracing-type
: Tracing backend type, defaults to `jaeger`
--tracing-endpoint
: Endpoint for the agent, empty default value
--tracing-collector
: Endpoint for the collector, empty default value
--tracing-service
: Service name for tracing, defaults to `reva`
--debug-addr
: Address to bind debug server, defaults to `0.0.0.0:9109`
--debug-token
: Token to grant metrics access, empty default value
--debug-pprof
: Enable pprof debugging, defaults to `false`
--debug-zpages
: Enable zpages debugging, defaults to `false`
--http-addr
: Address to bind http server, defaults to `0.0.0.0:9105`
--http-root
: Root path of http server, defaults to `/`
--grpc-addr
: Address to bind grpc server, defaults to `0.0.0.0:9106`
--asset-path
: Path to custom assets, empty default value
##### Health
--debug-addr
: Address to debug endpoint, defaults to `0.0.0.0:9109`
#### Configuration file
So far we support the file formats `JSON` and `YAML`, if you want to get a full example configuration just take a look at [our repository](https://github.com/owncloud/ocis-reva/tree/master/config), there you can always see the latest configuration format. These example configurations include all available options and the default values. The configuration file will be automatically loaded if it's placed at `/etc/ocis/reva.yml`, `${HOME}/.ocis/reva.yml` or `$(pwd)/config/reva.yml`.
### Usage
The program provides a few sub-commands on execution. The available configuration methods have already been mentioned above. Generally you can always see a formated help output if you execute the binary via `ocis-reva --help`.
#### Server
The server command is used to start the http and debug server on two addresses within a single process. The http server is serving the general webservice while the debug server is used for health check, readiness check and to server the metrics mentioned below. For further help please execute:
{{< highlight txt >}}
ocis-reva server --help
{{< / highlight >}}
#### Health
The health command is used to execute a health check, if the exit code equals zero the service should be up and running, if the exist code is greater than zero the service is not in a healthy state. Generally this command is used within our Docker containers, it could also be used within Kubernetes.
{{< highlight txt >}}
ocis-reva health --help
{{< / highlight >}}
### Metrics
This service provides some [Prometheus](https://prometheus.io/) metrics through the debug endpoint, you can optionally secure the metrics endpoint by some random token, which got to be configured through one of the flag `--debug-token` or the environment variable `REVA_DEBUG_TOKEN` mentioned above. By default the metrics endpoint is bound to `http://0.0.0.0:9109/metrics`.
go_gc_duration_seconds
: A summary of the GC invocation durations
go_gc_duration_seconds_sum
: A summary of the GC invocation durations
go_gc_duration_seconds_count
: A summary of the GC invocation durations
go_goroutines
: Number of goroutines that currently exist
go_info
: Information about the Go environment
go_memstats_alloc_bytes
: Number of bytes allocated and still in use
go_memstats_alloc_bytes_total
: Total number of bytes allocated, even if freed
go_memstats_buck_hash_sys_bytes
: Number of bytes used by the profiling bucket hash table
go_memstats_frees_total
: Total number of frees
go_memstats_gc_cpu_fraction
: The fraction of this program's available CPU time used by the GC since the program started
go_memstats_gc_sys_bytes
: Number of bytes used for garbage collection system metadata
go_memstats_heap_alloc_bytes
: Number of heap bytes allocated and still in use
go_memstats_heap_idle_bytes
: Number of heap bytes waiting to be used
go_memstats_heap_inuse_bytes
: Number of heap bytes that are in use
go_memstats_heap_objects
: Number of allocated objects
go_memstats_heap_released_bytes
: Number of heap bytes released to OS
go_memstats_heap_sys_bytes
: Number of heap bytes obtained from system
go_memstats_last_gc_time_seconds
: Number of seconds since 1970 of last garbage collection
go_memstats_lookups_total
: Total number of pointer lookups
go_memstats_mallocs_total
: Total number of mallocs
go_memstats_mcache_inuse_bytes
: Number of bytes in use by mcache structures
go_memstats_mcache_sys_bytes
: Number of bytes used for mcache structures obtained from system
go_memstats_mspan_inuse_bytes
: Number of bytes in use by mspan structures
go_memstats_mspan_sys_bytes
: Number of bytes used for mspan structures obtained from system
go_memstats_next_gc_bytes
: Number of heap bytes when next garbage collection will take place
go_memstats_other_sys_bytes
: Number of bytes used for other system allocations
go_memstats_stack_inuse_bytes
: Number of bytes in use by the stack allocator
go_memstats_stack_sys_bytes
: Number of bytes obtained from system for stack allocator
go_memstats_sys_bytes
: Number of bytes obtained from system
go_threads
: Number of OS threads created
promhttp_metric_handler_requests_in_flight
: Current number of scrapes being served
promhttp_metric_handler_requests_total
: Total number of scrapes by HTTP status code

49
docs/content/users.md Normal file
View File

@@ -0,0 +1,49 @@
---
title: "Users"
date: 2020-01-16T00:00:00+00:00
anchor: "users"
weight: 35
---
### Demo driver
This is the default user driver.It contains three users:
```
einstein:relativity
marie:radioactivty
richard:superfluidity
```
### JSON driver
In order to switch from the `demo` driver to JSON based users you need to export the relevant environment variables:
```
export REVA_USERS_DRIVER=json
export REVA_USERS_JSON=/path/to/users.json
```
For the format of the users.json have a look at the [reva examples](https://github.com/cs3org/reva/blob/master/examples/separate/users.demo.json)
### LDAP driver
In order to switch from the `demo` driver to LDAP you need to export the relevant environment variable:
```
export REVA_USERS_DRIVER=ldap
```
If the below defaults don't match your environment change them accordingly:
```
export REVA_LDAP_HOSTNAME=localhost
export REVA_LDAP_PORT=389
export REVA_LDAP_BASE_DN='dc=owncloud,dc=com'
export REVA_LDAP_USERFILTER='(objectclass=posixAccount)'
export REVA_LDAP_GROUPFILTER='(objectclass=posixGroup)'
export REVA_LDAP_BIND_DN='cn=admin,dc=owncloud,dc=com'
export REVA_LDAP_BIND_PASSWORD=admin
export REVA_LDAP_SCHEMA_UID=uid
export REVA_LDAP_SCHEMA_MAIL=mail
export REVA_LDAP_SCHEMA_DISPLAYNAME=displayName
export REVA_LDAP_SCHEMA_CN=cn
```
Then restart the `bin/ocis-reva users` and `bin/ocis-reva auth-basic` services for the changes to take effect.

4
go.mod
View File

@@ -5,14 +5,14 @@ go 1.13
require (
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cs3org/go-cs3apis v0.0.0-20191218073906-e3405ff6775e // indirect
github.com/cs3org/reva v0.0.2-0.20191217083445-dee8d1c71f95
github.com/cs3org/reva v0.0.2-0.20200115110931-4c7513415ec5
github.com/go-log/log v0.2.0 // indirect
github.com/gofrs/uuid v3.2.0+incompatible
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect
github.com/micro/cli v0.2.0
github.com/micro/go-micro v1.18.0 // indirect
github.com/oklog/run v1.0.0
github.com/owncloud/ocis-pkg v1.2.0
github.com/owncloud/ocis-pkg v1.2.1-0.20191217084055-eab942498596
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/prometheus/client_model v0.0.0-20191202183732-d1d2010b5bee // indirect
github.com/prometheus/procfs v0.0.8 // indirect

15
go.sum
View File

@@ -95,8 +95,8 @@ github.com/aws/aws-sdk-go v1.19.18/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpi
github.com/aws/aws-sdk-go v1.19.45/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.23.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.25.31/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.26.3 h1:szQdfJcUBAhQT0zZEx4sxoDuWb7iScoucxCiVxDmaBk=
github.com/aws/aws-sdk-go v1.26.3/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.28.2 h1:j5IXG9CdyLfcVfICqo1PXVv+rua+QQHbkXuvuU/JF+8=
github.com/aws/aws-sdk-go v1.28.2/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc=
github.com/beevik/ntp v0.2.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
@@ -165,8 +165,8 @@ github.com/cs3org/go-cs3apis v0.0.0-20191128165347-19746c015c83 h1:9bcp1jc6+36XU
github.com/cs3org/go-cs3apis v0.0.0-20191128165347-19746c015c83/go.mod h1:IsVGyZrOLUQD48JIhlM/xb3Vz6He5o2+W0ZTfUGY+IU=
github.com/cs3org/go-cs3apis v0.0.0-20191218073906-e3405ff6775e h1:cPcpOoPLdsIV2Bw1xMJCIw4ZAejtQqA6J0U56YHOJeQ=
github.com/cs3org/go-cs3apis v0.0.0-20191218073906-e3405ff6775e/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/cs3org/reva v0.0.2-0.20191217083445-dee8d1c71f95 h1:wrx5iQTS50W4gFDyYfR+kRuVlrSw4oXr22msH+uPjb0=
github.com/cs3org/reva v0.0.2-0.20191217083445-dee8d1c71f95/go.mod h1:lwilkLiV0vnGiyypVxDJZUbGjnAzVo0cgDCKxy/eLpw=
github.com/cs3org/reva v0.0.2-0.20200115110931-4c7513415ec5 h1:PkGon9KVtcApu462KRAmFV3iKHOk0S0CRoEzoar4eyE=
github.com/cs3org/reva v0.0.2-0.20200115110931-4c7513415ec5/go.mod h1:Hk3eCcdhtv4eIhKvRK736fQuOyS1HuHnUcz0Dq6NK1A=
github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -374,7 +374,6 @@ github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoI
github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M=
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/haya14busa/goverage v0.0.0-20180129164344-eec3514a20b5/go.mod h1:0YZ2wQSuwviXXXGUiK6zXzskyBLAbLXhamxzcFHSLoM=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbcucJdbSo=
@@ -558,8 +557,8 @@ github.com/oracle/oci-go-sdk v7.0.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukw
github.com/ory/fosite v0.30.2/go.mod h1:Lq9qQ9Sl6mcea2Tt8J7PU+wUeFYPZ+vg7N3zPVKGbN8=
github.com/ory/go-convenience v0.1.0/go.mod h1:uEY/a60PL5c12nYz4V5cHY03IBmwIAEm8TWB0yn9KNs=
github.com/ovh/go-ovh v0.0.0-20181109152953-ba5adb4cf014/go.mod h1:joRatxRJaZBsY3JAOEMcoOp05CnZzsx4scTxi95DHyQ=
github.com/owncloud/ocis-pkg v1.2.0 h1:eP0AOSEXAgiblL2yOpNOmriKhDXN+mai+4belBJRkWU=
github.com/owncloud/ocis-pkg v1.2.0/go.mod h1:EfbeXoe60Me2lB/AWjYl8UFNv4isqCPP6lokd5R7nyM=
github.com/owncloud/ocis-pkg v1.2.1-0.20191217084055-eab942498596 h1:3aMNmuDCIdKsaa4YdVTQEBJMjGz8KiuIB/+xlJUCT3k=
github.com/owncloud/ocis-pkg v1.2.1-0.20191217084055-eab942498596/go.mod h1:Wo0QfOmhadh2vNcUoQIsw2yaOT3zeftk+xaOOwP3y88=
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
github.com/parnurzeal/gorequest v0.2.15/go.mod h1:3Kh2QUMJoqw3icWAecsyzkpY7UzRfDhbRdTjtNwNiUE=
@@ -578,6 +577,8 @@ github.com/pierrec/lz4 v2.2.6+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/xattr v0.4.1/go.mod h1:W2cGD0TBEus7MkUgv0tNZ9JutLtVO3cXu+IBRuHqnFs=
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

187
pkg/command/authbasic.go Normal file
View File

@@ -0,0 +1,187 @@
package command
import (
"context"
"os"
"os/signal"
"path"
"time"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli"
"github.com/oklog/run"
"github.com/owncloud/ocis-reva/pkg/config"
"github.com/owncloud/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis-reva/pkg/server/debug"
)
// AuthBasic is the entrypoint for the auth-basic command.
func AuthBasic(cfg *config.Config) cli.Command {
return cli.Command{
Name: "auth-basic",
Usage: "Start reva authprovider for basic auth",
Flags: flagset.AuthBasicWithConfig(cfg),
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
if cfg.Tracing.Enabled {
switch t := cfg.Tracing.Type; t {
case "agent":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
case "jaeger":
logger.Info().
Str("type", t).
Msg("configuring reva to use the jaeger tracing backend")
case "zipkin":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
default:
logger.Warn().
Str("type", t).
Msg("Unknown tracing backend")
}
} else {
logger.Debug().
Msg("Tracing is not enabled")
}
var (
gr = run.Group{}
ctx, cancel = context.WithCancel(context.Background())
//metrics = metrics.New()
)
defer cancel()
{
uuid := uuid.Must(uuid.NewV4())
pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid")
rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.AuthBasic.MaxCPUs,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.AuthBasic.Network,
"address": cfg.Reva.AuthBasic.Addr,
// TODO extract interceptor config, which is the same for all grpc services
"interceptors": map[string]interface{}{
"auth": map[string]interface{}{
"token_manager": "jwt",
"token_managers": map[string]interface{}{
"jwt": map[string]interface{}{
"secret": cfg.Reva.JWTSecret,
},
},
},
},
// TODO build services dynamically
"services": map[string]interface{}{
"authprovider": map[string]interface{}{
"auth_manager": cfg.Reva.Users.Driver,
"auth_managers": map[string]interface{}{
"json": map[string]interface{}{
"users": cfg.Reva.Users.JSON,
},
"ldap": map[string]interface{}{
"hostname": cfg.Reva.LDAP.Hostname,
"port": cfg.Reva.LDAP.Port,
"base_dn": cfg.Reva.LDAP.BaseDN,
"userfilter": cfg.Reva.LDAP.UserFilter,
"groupfilter": cfg.Reva.LDAP.GroupFilter,
"bind_username": cfg.Reva.LDAP.BindDN,
"bind_password": cfg.Reva.LDAP.BindPassword,
"idp": cfg.Reva.LDAP.IDP,
"schema": map[string]interface{}{
"dn": "dn",
"uid": cfg.Reva.LDAP.Schema.UID,
"mail": cfg.Reva.LDAP.Schema.Mail,
"displayName": cfg.Reva.LDAP.Schema.DisplayName,
"cn": cfg.Reva.LDAP.Schema.CN,
},
},
},
},
},
},
}
gr.Add(func() error {
runtime.Run(rcfg, pidFile)
return nil
}, func(_ error) {
logger.Info().
Str("server", c.Command.Name).
Msg("Shutting down server")
cancel()
})
}
{
server, err := debug.Server(
debug.Name(c.Command.Name+"-debug"),
debug.Addr(cfg.Reva.AuthBasic.DebugAddr),
debug.Logger(logger),
debug.Context(ctx),
debug.Config(cfg),
)
if err != nil {
logger.Info().
Err(err).
Str("server", "debug").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.ListenAndServe()
}, func(_ error) {
ctx, timeout := context.WithTimeout(ctx, 5*time.Second)
defer timeout()
defer cancel()
if err := server.Shutdown(ctx); err != nil {
logger.Info().
Err(err).
Str("server", "debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("server", "debug").
Msg("Shutting down server")
}
})
}
{
stop := make(chan os.Signal, 1)
gr.Add(func() error {
signal.Notify(stop, os.Interrupt)
<-stop
return nil
}, func(err error) {
close(stop)
cancel()
})
}
return gr.Run()
},
}
}

View File

@@ -16,12 +16,12 @@ import (
"github.com/owncloud/ocis-reva/pkg/server/debug"
)
// AuthProvider is the entrypoint for the authprovider command.
func AuthProvider(cfg *config.Config) cli.Command {
// AuthBearer is the entrypoint for the auth-bearer command.
func AuthBearer(cfg *config.Config) cli.Command {
return cli.Command{
Name: "authprovider",
Usage: "Start authprovider server",
Flags: flagset.ServerWithConfig(cfg),
Name: "auth-bearer",
Usage: "Start reva authprovider for bearer auth",
Flags: flagset.AuthBearerWithConfig(cfg),
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
@@ -61,20 +61,19 @@ func AuthProvider(cfg *config.Config) cli.Command {
defer cancel()
// TODO Flags have to be injected all the way down to the go-micro service
{
uuid := uuid.Must(uuid.NewV4())
pidFile := path.Join(os.TempDir(), "revad-"+uuid.String()+".pid")
pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid")
rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.MaxCPUs,
"max_cpus": cfg.Reva.AuthBearer.MaxCPUs,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.GRPC.Network,
"address": cfg.Reva.GRPC.Addr,
"enabled_services": []string{"authprovider"},
"network": cfg.Reva.AuthBearer.Network,
"address": cfg.Reva.AuthBearer.Addr,
// TODO extract interceptor config, which is the same for all grpc services
"interceptors": map[string]interface{}{
"auth": map[string]interface{}{
"token_manager": "jwt",
@@ -83,34 +82,30 @@ func AuthProvider(cfg *config.Config) cli.Command {
"secret": cfg.Reva.JWTSecret,
},
},
"skip_methods": []string{
// we need to allow calls that happen during authentication
"/cs3.authproviderv0alpha.AuthProviderService/Authenticate",
"/cs3.userproviderv0alpha.UserProviderService/GetUser",
},
},
},
// TODO build services dynamically
"services": map[string]interface{}{
"authprovider": map[string]interface{}{
"auth_manager": "oidc",
"auth_managers": map[string]interface{}{
"oidc": map[string]interface{}{
"provider": cfg.AuthProvider.Provider,
"insecure": cfg.AuthProvider.Insecure,
"issuer": cfg.Reva.OIDC.Issuer,
"insecure": cfg.Reva.OIDC.Insecure,
"id_claim": cfg.Reva.OIDC.IDClaim,
},
},
},
},
},
}
// TODO merge configs for the same address
gr.Add(func() error {
runtime.Run(rcfg, pidFile)
return nil
}, func(_ error) {
logger.Info().
Str("server", "authprovider").
Str("server", c.Command.Name).
Msg("Shutting down server")
cancel()
@@ -119,6 +114,8 @@ func AuthProvider(cfg *config.Config) cli.Command {
{
server, err := debug.Server(
debug.Name(c.Command.Name+"-debug"),
debug.Addr(cfg.Reva.AuthBearer.DebugAddr),
debug.Logger(logger),
debug.Context(ctx),
debug.Config(cfg),

352
pkg/command/frontend.go Normal file
View File

@@ -0,0 +1,352 @@
package command
import (
"context"
"fmt"
"os"
"os/signal"
"path"
"time"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli"
"github.com/oklog/run"
"github.com/owncloud/ocis-reva/pkg/config"
"github.com/owncloud/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis-reva/pkg/server/debug"
)
// Frontend is the entrypoint for the frontend command.
func Frontend(cfg *config.Config) cli.Command {
return cli.Command{
Name: "frontend",
Usage: "Start reva frontend service",
Flags: flagset.FrontendWithConfig(cfg),
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
if cfg.Tracing.Enabled {
switch t := cfg.Tracing.Type; t {
case "agent":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
case "jaeger":
logger.Info().
Str("type", t).
Msg("configuring reva to use the jaeger tracing backend")
case "zipkin":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
default:
logger.Warn().
Str("type", t).
Msg("Unknown tracing backend")
}
} else {
logger.Debug().
Msg("Tracing is not enabled")
}
var (
gr = run.Group{}
ctx, cancel = context.WithCancel(context.Background())
//metrics = metrics.New()
)
defer cancel()
{
uuid := uuid.Must(uuid.NewV4())
pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid")
// pregenerate list of valid localhost ports for the desktop redirect_uri
// TODO use custom scheme like "owncloud://localhost/user/callback" tracked in
var desktopRedirectURIs [65535 - 1024]string
for port := 0; port < len(desktopRedirectURIs); port++ {
desktopRedirectURIs[port] = fmt.Sprintf("http://localhost:%d/callback", (port + 1024))
}
rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.Frontend.MaxCPUs,
},
"http": map[string]interface{}{
"network": cfg.Reva.Frontend.Network,
"address": cfg.Reva.Frontend.Addr,
"middlewares": map[string]interface{}{
"auth": map[string]interface{}{
"gateway": cfg.Reva.Gateway.URL,
"credential_chain": []string{"basic", "bearer"},
"token_strategy": "header",
"token_writer": "header",
"token_manager": "jwt",
"token_managers": map[string]interface{}{
"jwt": map[string]interface{}{
"secret": cfg.Reva.JWTSecret,
},
},
},
"cors": map[string]interface{}{
"allowed_origins": []string{"*"},
"allowed_methods": []string{
"OPTIONS",
"GET",
"PUT",
"POST",
"DELETE",
"MKCOL",
"PROPFIND",
"PROPPATCH",
"MOVE",
"COPY",
"REPORT",
"SEARCH",
},
"allowed_headers": []string{
"Origin",
"Accept",
"Depth",
"Content-Type",
"X-Requested-With",
"Authorization",
"Ocs-Apirequest",
"If-Match",
"If-None-Match",
"Destination",
"Overwrite",
},
"allow_credentials": true,
"options_passthrough": false,
},
},
// TODO build services dynamically
"services": map[string]interface{}{
"datagateway": map[string]interface{}{
"prefix": "data",
"gateway": "", // TODO not needed?
"transfer_shared_secret": cfg.Reva.TransferSecret,
},
"wellknown": map[string]interface{}{
"issuer": cfg.Reva.OIDC.Issuer,
"authorization_endpoint": cfg.Reva.OIDC.Issuer + "/oauth2/auth",
"token_endpoint": cfg.Reva.OIDC.Issuer + "/oauth2/token",
"revocation_endpoint": cfg.Reva.OIDC.Issuer + "/oauth2/auth",
"introspection_endpoint": cfg.Reva.OIDC.Issuer + "/oauth2/introspect",
"userinfo_endpoint": cfg.Reva.OIDC.Issuer + "/oauth2/userinfo",
},
"oidcprovider": map[string]interface{}{
"prefix": "oauth2",
"gateway": cfg.Reva.Gateway.URL,
"issuer": cfg.Reva.OIDC.Issuer,
"clients": map[string]interface{}{
// TODO make these configurable
// note: always use authorization code flow, see https://developer.okta.com/blog/2019/05/01/is-the-oauth-implicit-flow-dead for details
"phoenix": map[string]interface{}{
"id": "phoenix",
"redirect_uris": []string{"http://localhost:9100/oidc-callback.html", "http://localhost:9100/"},
"grant_types": []string{"implicit", "refresh_token", "authorization_code", "password", "client_credentials"},
"response_types": []string{"code"},
"scopes": []string{"openid", "profile", "email", "offline"},
"public": true, // force PKCS for public clients
},
"desktop": map[string]interface{}{
"id": "xdXOt13JKxym1B1QcEncf2XDkLAexMBFwiT9j6EfhhHFJhs2KM9jbjTmf8JBXE69",
"client_secret": "$2y$12$pKsCQPp8e/UOL1QDQhT3g.1J.KK8oMJACbEXIqRD0LiOxvgey.TtS",
// preregister localhost ports for the desktop
"redirect_uris": desktopRedirectURIs,
"grant_types": []string{"implicit", "refresh_token", "authorization_code", "password", "client_credentials"},
"response_types": []string{"code"},
"scopes": []string{"openid", "profile", "email", "offline", "offline_access"},
},
// TODO add cli command for token fetching
"cli": map[string]interface{}{
"id": "cli",
"client_secret": "$2a$10$IxMdI6d.LIRZPpSfEwNoeu4rY3FhDREsxFJXikcgdRRAStxUlsuEO", // = "foobar"
// use hardcoded port credentials for cli
"redirect_uris": []string{"http://localhost:18080/callback"},
"grant_types": []string{"implicit", "refresh_token", "authorization_code", "password", "client_credentials"},
"response_types": []string{"code"},
"scopes": []string{"openid", "profile", "email", "offline"},
},
},
},
"ocdav": map[string]interface{}{
"prefix": "",
"chunk_folder": "/var/tmp/revad/chunks",
"gateway": cfg.Reva.Gateway.URL,
"files_namespace": "/",
"webdav_namespace": "/",
},
"ocs": map[string]interface{}{
"gateway": cfg.Reva.Gateway.URL,
"config": map[string]interface{}{
"version": "1.8",
"website": "reva",
"host": "http://" + cfg.Reva.Frontend.URL, // TODO URLs should include the protocol
"contact": "admin@localhost",
"ssl": "false",
},
"capabilities": map[string]interface{}{
"capabilities": map[string]interface{}{
"core": map[string]interface{}{
"poll_interval": 60,
"webdav_root": "remote.php/webdav",
"status": map[string]interface{}{
"installed": true,
"maintenance": false,
"needsDbUpgrade": false,
"version": "10.0.11.5",
"versionstring": "10.0.11",
"edition": "community",
"productname": "reva",
"hostname": "",
},
},
"checksums": map[string]interface{}{
"supported_types": []string{"SHA256"},
"preferred_upload_type": "SHA256",
},
"files": map[string]interface{}{
"private_links": false,
"bigfilechunking": false,
"blacklisted_files": []string{},
"undelete": true,
"versioning": true,
},
"dav": map[string]interface{}{
"chunking": "1.0",
},
"files_sharing": map[string]interface{}{
"api_enabled": true,
"resharing": true,
"group_sharing": true,
"auto_accept_share": true,
"share_with_group_members_only": true,
"share_with_membership_groups_only": true,
"default_permissions": 22,
"search_min_length": 3,
"public": map[string]interface{}{
"enabled": true,
"send_mail": true,
"social_share": true,
"upload": true,
"multiple": true,
"supports_upload_only": true,
"password": map[string]interface{}{
"enforced": true,
"enforced_for": map[string]interface{}{
"read_only": true,
"read_write": true,
"upload_only": true,
},
},
"expire_date": map[string]interface{}{
"enabled": true,
},
},
"user": map[string]interface{}{
"send_mail": true,
},
"user_enumeration": map[string]interface{}{
"enabled": true,
"group_members_only": true,
},
"federation": map[string]interface{}{
"outgoing": true,
"incoming": true,
},
},
"notifications": map[string]interface{}{
"endpoints": []string{"list", "get", "delete"},
},
},
"version": map[string]interface{}{
"edition": "reva",
"major": 10,
"minor": 0,
"micro": 11,
"string": "10.0.11",
},
},
},
},
},
}
gr.Add(func() error {
runtime.Run(rcfg, pidFile)
return nil
}, func(_ error) {
logger.Info().
Str("server", c.Command.Name).
Msg("Shutting down server")
cancel()
})
}
{
server, err := debug.Server(
debug.Name(c.Command.Name+"-debug"),
debug.Addr(cfg.Reva.Frontend.DebugAddr),
debug.Logger(logger),
debug.Context(ctx),
debug.Config(cfg),
)
if err != nil {
logger.Info().
Err(err).
Str("server", "debug").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.ListenAndServe()
}, func(_ error) {
ctx, timeout := context.WithTimeout(ctx, 5*time.Second)
defer timeout()
defer cancel()
if err := server.Shutdown(ctx); err != nil {
logger.Info().
Err(err).
Str("server", "debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("server", "debug").
Msg("Shutting down server")
}
})
}
{
stop := make(chan os.Signal, 1)
gr.Add(func() error {
signal.Notify(stop, os.Interrupt)
<-stop
return nil
}, func(err error) {
close(stop)
cancel()
})
}
return gr.Run()
},
}
}

220
pkg/command/gateway.go Normal file
View File

@@ -0,0 +1,220 @@
package command
import (
"context"
"os"
"os/signal"
"path"
"time"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli"
"github.com/oklog/run"
"github.com/owncloud/ocis-reva/pkg/config"
"github.com/owncloud/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis-reva/pkg/server/debug"
)
// Gateway is the entrypoint for the gateway command.
func Gateway(cfg *config.Config) cli.Command {
return cli.Command{
Name: "gateway",
Usage: "Start reva gateway",
Flags: flagset.GatewayWithConfig(cfg),
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
if cfg.Tracing.Enabled {
switch t := cfg.Tracing.Type; t {
case "agent":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
case "jaeger":
logger.Info().
Str("type", t).
Msg("configuring reva to use the jaeger tracing backend")
case "zipkin":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
default:
logger.Warn().
Str("type", t).
Msg("Unknown tracing backend")
}
} else {
logger.Debug().
Msg("Tracing is not enabled")
}
var (
gr = run.Group{}
ctx, cancel = context.WithCancel(context.Background())
//metrics = metrics.New()
)
defer cancel()
{
uuid := uuid.Must(uuid.NewV4())
pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid")
rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.Gateway.MaxCPUs,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.Gateway.Network,
"address": cfg.Reva.Gateway.Addr,
// TODO extract interceptor config, which is the same for all grpc services
"interceptors": map[string]interface{}{
"auth": map[string]interface{}{
"token_manager": "jwt",
"token_managers": map[string]interface{}{
"jwt": map[string]interface{}{
"secret": cfg.Reva.JWTSecret,
},
},
},
},
// TODO build services dynamically
"services": map[string]interface{}{
"gateway": map[string]interface{}{
// registries is located on the gateway
"authregistrysvc": cfg.Reva.Gateway.URL,
"storageregistrysvc": cfg.Reva.Gateway.URL,
"appregistrysvc": cfg.Reva.Gateway.URL,
// user metadata is located on the users services
"preferencessvc": cfg.Reva.Users.URL,
"userprovidersvc": cfg.Reva.Users.URL,
// sharing is located on the sharing service
"usershareprovidersvc": cfg.Reva.Sharing.URL,
"publicshareprovidersvc": cfg.Reva.Sharing.URL,
"ocmshareprovidersvc": cfg.Reva.Sharing.URL,
"commit_share_to_storage_grant": cfg.Reva.Gateway.CommitShareToStorageGrant,
// other
"datagateway": cfg.Reva.Frontend.URL,
"transfer_shared_secret": cfg.Reva.TransferSecret,
"transfer_expires": cfg.Reva.TransferExpires,
"token_manager": "jwt",
"token_managers": map[string]interface{}{
"jwt": map[string]interface{}{
"secret": cfg.Reva.JWTSecret,
},
},
},
"authregistry": map[string]interface{}{
"driver": "static",
"drivers": map[string]interface{}{
"static": map[string]interface{}{
"rules": map[string]interface{}{
"basic": cfg.Reva.AuthBasic.URL,
"bearer": cfg.Reva.AuthBearer.URL,
},
},
},
},
"storageregistry": map[string]interface{}{
"driver": "static",
"drivers": map[string]interface{}{
"static": map[string]interface{}{
"rules": map[string]interface{}{
cfg.Reva.StorageRoot.MountPath: cfg.Reva.StorageRoot.URL,
cfg.Reva.StorageRoot.MountID: cfg.Reva.StorageRoot.URL,
cfg.Reva.StorageHome.MountPath: cfg.Reva.StorageHome.URL,
// home has no lookup by mount id because it resolves to another storage
cfg.Reva.StorageEOS.MountPath: cfg.Reva.StorageEOS.URL,
cfg.Reva.StorageEOS.MountID: cfg.Reva.StorageEOS.URL,
cfg.Reva.StorageOC.MountPath: cfg.Reva.StorageOC.URL,
cfg.Reva.StorageOC.MountID: cfg.Reva.StorageOC.URL,
cfg.Reva.StorageS3.MountPath: cfg.Reva.StorageS3.URL,
cfg.Reva.StorageS3.MountID: cfg.Reva.StorageS3.URL,
cfg.Reva.StorageWND.MountPath: cfg.Reva.StorageWND.URL,
cfg.Reva.StorageWND.MountID: cfg.Reva.StorageWND.URL,
cfg.Reva.StorageCustom.MountPath: cfg.Reva.StorageCustom.URL,
cfg.Reva.StorageCustom.MountID: cfg.Reva.StorageCustom.URL,
},
},
},
},
},
},
}
gr.Add(func() error {
runtime.Run(rcfg, pidFile)
return nil
}, func(_ error) {
logger.Info().
Str("server", c.Command.Name).
Msg("Shutting down server")
cancel()
})
}
{
server, err := debug.Server(
debug.Name(c.Command.Name+"-debug"),
debug.Addr(cfg.Reva.Gateway.DebugAddr),
debug.Logger(logger),
debug.Context(ctx),
debug.Config(cfg),
)
if err != nil {
logger.Info().
Err(err).
Str("server", "debug").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.ListenAndServe()
}, func(_ error) {
ctx, timeout := context.WithTimeout(ctx, 5*time.Second)
defer timeout()
defer cancel()
if err := server.Shutdown(ctx); err != nil {
logger.Info().
Err(err).
Str("server", "debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("server", "debug").
Msg("Shutting down server")
}
})
}
{
stop := make(chan os.Signal, 1)
gr.Add(func() error {
signal.Notify(stop, os.Interrupt)
<-stop
return nil
}, func(err error) {
close(stop)
cancel()
})
}
return gr.Run()
},
}
}

View File

@@ -1,453 +0,0 @@
package command
import (
"context"
"os"
"os/signal"
"path"
"time"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli"
"github.com/oklog/run"
"github.com/owncloud/ocis-reva/pkg/config"
"github.com/owncloud/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis-reva/pkg/server/debug"
)
// Legacy is the entrypoint for the legacy command.
func Legacy(cfg *config.Config) cli.Command {
return cli.Command{
Name: "legacy",
Usage: "Start legacy server mimicking oc10",
Flags: flagset.ServerWithConfig(cfg),
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
if cfg.Tracing.Enabled {
switch t := cfg.Tracing.Type; t {
case "agent":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
case "jaeger":
logger.Info().
Str("type", t).
Msg("configuring reva to use the jaeger tracing backend")
case "zipkin":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
default:
logger.Warn().
Str("type", t).
Msg("Unknown tracing backend")
}
} else {
logger.Debug().
Msg("Tracing is not enabled")
}
var (
gr = run.Group{}
ctx, cancel = context.WithCancel(context.Background())
)
defer cancel()
// Flags have to be injected all the way down to the go-micro service
{
uuid := uuid.Must(uuid.NewV4())
pidFile := path.Join(os.TempDir(), "revad-"+uuid.String()+".pid")
rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": cfg.Tracing.Service,
},
"log": map[string]interface{}{
"level": cfg.Reva.LogLevel,
//TODO mode": ""console" # "console" or "json"
//TODO output": ""./standalone.log"
},
"http": map[string]interface{}{
"network": cfg.Reva.HTTP.Network,
"address": cfg.Reva.HTTP.Addr,
"enabled_services": []string{
"dataprovider",
"ocdav",
"prometheus",
"wellknown",
"oidcprovider",
"ocs",
},
"enabled_middlewares": []string{
//"cors",
"auth",
},
"middlewares": map[string]interface{}{
"auth": map[string]interface{}{
"gateway": cfg.Reva.GRPC.Addr,
"auth_type": "oidc",
"credential_strategy": "oidc",
"token_strategy": "header",
"token_writer": "header",
"token_manager": "jwt",
"token_managers": map[string]interface{}{
"jwt": map[string]interface{}{
"secret": cfg.Reva.JWTSecret,
},
},
"skip_methods": []string{
"/favicon.ico",
"/status.php",
"/oauth2",
"/oauth2/auth",
"/oauth2/token",
// TODO protect the introspection endpoint from external requests.
// should only be reachable by internal services, which is why the
// oidc-provider.toml has clientid and secret that are used for a basic auth
//"/oauth2/introspect", // no longer used, oidc auth checks access token using the userinfo endpoint
"/oauth2/userinfo",
"/oauth2/sessions",
"/.well-known/openid-configuration",
"/metrics", // for prometheus metrics
},
},
},
"services": map[string]interface{}{
"oidcprovider": map[string]interface{}{
"prefix": "oauth2",
"gateway": cfg.Reva.GRPC.Addr,
"auth_type": "basic",
"issuer": cfg.Reva.HTTP.Addr,
"clients": map[string]interface{}{
"phoenix": map[string]interface{}{
"id": "phoenix",
// use ocis port range for phoenix
// TODO should use the micro / ocis http gateway, but then it would no longer be able to run standalone
// IMO the ports should be fetched from the ocis registry anyway
"redirect_uris": []string{"http://localhost:9100/oidc-callback.html", "http://localhost:9100/"},
"grant_types": []string{"implicit", "refresh_token", "authorization_code", "password", "client_credentials"},
"response_types": []string{"code"}, // use authorization code flow, see https://developer.okta.com/blog/2019/05/01/is-the-oauth-implicit-flow-dead for details
"scopes": []string{"openid", "profile", "email", "offline"},
"public": true, // force PKCS for public clients
},
"cli": map[string]interface{}{
"id": "cli",
"client_secret": "$2a$10$IxMdI6d.LIRZPpSfEwNoeu4rY3FhDREsxFJXikcgdRRAStxUlsuEO", // = "foobar"
// use hardcoded port credentials for cli
"redirect_uris": []string{"http://localhost:18080/callback"},
"grant_types": []string{"implicit", "refresh_token", "authorization_code", "password", "client_credentials"},
"response_types": []string{"code"}, // use authorization code flow, see https://developer.okta.com/blog/2019/05/01/is-the-oauth-implicit-flow-dead for details
"scopes": []string{"openid", "profile", "email", "offline"},
},
},
},
"dataprovider": map[string]interface{}{
"driver": "owncloud",
"prefix": "data",
"tmp_folder": "/var/tmp/",
"drivers": map[string]interface{}{
"owncloud": map[string]interface{}{
"datadirectory": "/var/tmp/reva/data",
},
},
},
"ocdav": map[string]interface{}{
"prefix": "",
"chunk_folder": "/var/tmp/revad/chunks",
"gateway": cfg.Reva.GRPC.Addr,
},
"ocs": map[string]interface{}{
"gateway": cfg.Reva.GRPC.Addr,
"config": map[string]interface{}{
"version": "1.8",
"website": "ocis",
"host": cfg.Reva.HTTP.Addr, // TODO should be read from registry
"contact": "admin@localhost",
"ssl": "false",
},
"capabilities": map[string]interface{}{
"capabilities": map[string]interface{}{
"core": map[string]interface{}{
"poll_interval": 60,
"webdav_root": "remote.php/webdav",
"status": map[string]interface{}{
"installed": true,
"maintenance": false,
"needsDbUpgrade": false,
"version": "10.0.11.5",
"versionstring": "10.0.11",
"edition": "community",
"productname": "reva",
"hostname": "",
},
},
"checksums": map[string]interface{}{
"supported_types": []string{"SHA256"},
"preferred_upload_type": "SHA256",
},
"files": map[string]interface{}{
"private_links": false,
"bigfilechunking": false,
"blacklisted_files": []string{},
"undelete": true,
"versioning": true,
},
"dav": map[string]interface{}{
"chunking": "1.0",
},
"files_sharing": map[string]interface{}{
"api_enabled": true,
"resharing": true,
"group_sharing": true,
"auto_accept_share": true,
"share_with_group_members_only": true,
"share_with_membership_groups_only": true,
"default_permissions": 22,
"search_min_length": 3,
"public": map[string]interface{}{
"enabled": true,
"send_mail": true,
"social_share": true,
"upload": true,
"multiple": true,
"supports_upload_only": true,
"password": map[string]interface{}{
"enforced": true,
"enforced_for": map[string]interface{}{
"read_only": true,
"read_write": true,
"upload_only": true,
},
},
"expire_date": map[string]interface{}{
"enabled": true,
},
},
"user": map[string]interface{}{
"send_mail": true,
},
"user_enumeration": map[string]interface{}{
"enabled": true,
"group_members_only": true,
},
"federation": map[string]interface{}{
"outgoing": true,
"incoming": true,
},
},
"notifications": map[string]interface{}{
"endpoints": []string{"list", "get", "delete"},
},
},
"version": map[string]interface{}{
"edition": "ocis",
"major": 11,
"minor": 0,
"micro": 0,
"string": "11.0.0",
},
},
},
},
},
"grpc": map[string]interface{}{
"network": cfg.Reva.GRPC.Network,
"address": cfg.Reva.GRPC.Addr,
"enabled_services": []string{
"authprovider", // provides basic auth
"storageprovider", // handles storage metadata
"usershareprovider", // provides user shares
"userprovider", // provides user matadata (used to look up email, displayname etc after a login)
"preferences", // provides user preferences
"gateway", // to lookup services and authenticate requests
"authregistry", // used by the gateway to look up auth providers
"storageregistry", // used by the gateway to look up storage providers
},
"interceptors": map[string]interface{}{
"auth": map[string]interface{}{
"token_manager": "jwt",
"token_managers": map[string]interface{}{
"jwt": map[string]interface{}{
"secret": cfg.Reva.JWTSecret,
},
},
"skip_methods": []string{
// we need to allow calls that happen during authentication
"/cs3.gatewayv0alpha.GatewayService/Authenticate",
"/cs3.gatewayv0alpha.GatewayService/WhoAmI",
"/cs3.gatewayv0alpha.GatewayService/GetUser",
"/cs3.gatewayv0alpha.GatewayService/ListAuthProviders",
"/cs3.authregistryv0alpha.AuthRegistryService/ListAuthProviders",
"/cs3.authregistryv0alpha.AuthRegistryService/GetAuthProvider",
"/cs3.authproviderv0alpha.AuthProviderService/Authenticate",
"/cs3.userproviderv0alpha.UserProviderService/GetUser",
},
},
},
"services": map[string]interface{}{
"gateway": map[string]interface{}{
"authregistrysvc": cfg.Reva.GRPC.Addr,
"storageregistrysvc": cfg.Reva.GRPC.Addr,
"appregistrysvc": cfg.Reva.GRPC.Addr,
"preferencessvc": cfg.Reva.GRPC.Addr,
"usershareprovidersvc": cfg.Reva.GRPC.Addr,
"publicshareprovidersvc": cfg.Reva.GRPC.Addr,
"ocmshareprovidersvc": cfg.Reva.GRPC.Addr,
"userprovidersvc": cfg.Reva.GRPC.Addr,
"commit_share_to_storage_grant": true,
"datagateway": "http://" + cfg.Reva.HTTP.Addr + "/data",
"transfer_shared_secret": "replace-me-with-a-transfer-secret",
"transfer_expires": 6, // give it a moment
"token_manager": "jwt",
"token_managers": map[string]interface{}{
"jwt": map[string]interface{}{
"secret": cfg.Reva.JWTSecret,
},
},
},
"authregistry": map[string]interface{}{
"driver": "static",
"drivers": map[string]interface{}{
"static": map[string]interface{}{
"rules": map[string]interface{}{
//"basic": "localhost:9999",
"oidc": cfg.Reva.GRPC.Addr,
},
},
},
},
"storageregistry": map[string]interface{}{
"driver": "static",
"drivers": map[string]interface{}{
"static": map[string]interface{}{
"rules": map[string]interface{}{
"/": cfg.Reva.GRPC.Addr,
"123e4567-e89b-12d3-a456-426655440000": cfg.Reva.GRPC.Addr,
},
},
},
},
"authprovider": map[string]interface{}{
"auth_manager": "oidc",
"auth_managers": map[string]interface{}{
"oidc": map[string]interface{}{
"provider": cfg.AuthProvider.Provider,
"insecure": cfg.AuthProvider.Insecure,
},
},
"userprovidersvc": cfg.Reva.GRPC.Addr,
},
"userprovider": map[string]interface{}{
"driver": "demo", // TODO use graph api
/*
"drivers": map[string]interface{}{
"graph": map[string]interface{}{
"provider": cfg.AuthProvider.Provider,
"insecure": cfg.AuthProvider.Insecure,
},
},
*/
},
"usershareprovider": map[string]interface{}{
"driver": "memory",
},
"storageprovider": map[string]interface{}{
"mount_path": "/",
"mount_id": "123e4567-e89b-12d3-a456-426655440000",
"data_server_url": "http://" + cfg.Reva.HTTP.Addr + "/data",
"expose_data_server": true,
"available_checksums": map[string]interface{}{
"md5": 100,
"unset": 1000,
},
"driver": "owncloud",
"drivers": map[string]interface{}{
"owncloud": map[string]interface{}{
"datadirectory": "/var/tmp/reva/data",
},
},
},
},
},
}
gr.Add(func() error {
// TODO micro knows nothing about reva
runtime.Run(rcfg, pidFile)
return nil
}, func(_ error) {
logger.Info().
Str("server", "reva").
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("server", "debug").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.ListenAndServe()
}, func(_ error) {
ctx, timeout := context.WithTimeout(ctx, 5*time.Second)
defer timeout()
defer cancel()
if err := server.Shutdown(ctx); err != nil {
logger.Info().
Err(err).
Str("server", "debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("server", "debug").
Msg("Shutting down server")
}
})
}
{
stop := make(chan os.Signal, 1)
gr.Add(func() error {
signal.Notify(stop, os.Interrupt)
<-stop
return nil
}, func(err error) {
close(stop)
cancel()
})
}
return gr.Run()
},
}
}

View File

@@ -74,9 +74,17 @@ func Execute() error {
},
Commands: []cli.Command{
Server(cfg),
Legacy(cfg),
AuthProvider(cfg),
Frontend(cfg),
Gateway(cfg),
Users(cfg),
AuthBasic(cfg),
AuthBearer(cfg),
Sharing(cfg),
StorageRoot(cfg),
StorageHome(cfg),
StorageHomeData(cfg),
StorageOC(cfg),
StorageOCData(cfg),
Health(cfg),
},
}

View File

@@ -1,328 +0,0 @@
package command
import (
"context"
"os"
"os/signal"
"path"
"sync"
"time"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli"
"github.com/oklog/run"
"github.com/owncloud/ocis-reva/pkg/config"
"github.com/owncloud/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis-reva/pkg/server/debug"
)
// Server is the entrypoint for the server command.
func Server(cfg *config.Config) cli.Command {
return cli.Command{
Name: "server",
Usage: "Start integrated server",
Flags: flagset.ServerWithConfig(cfg),
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
if cfg.Tracing.Enabled {
switch t := cfg.Tracing.Type; t {
case "agent":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
case "jaeger":
logger.Info().
Str("type", t).
Msg("configuring reva to use the jaeger tracing backend")
case "zipkin":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
default:
logger.Warn().
Str("type", t).
Msg("Unknown tracing backend")
}
} else {
logger.Debug().
Msg("Tracing is not enabled")
}
var (
gr = run.Group{}
ctx, cancel = context.WithCancel(context.Background())
)
defer cancel()
// Flags have to be injected all the way down to the go-micro service
{
if len(cfg.Reva.Configs) < 1 {
cfg.Reva.Configs = map[string]interface{}{
"default": map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.MaxCPUs,
"tracing_enabled": cfg.Tracing.Enabled,
"tracing_endpoint": cfg.Tracing.Endpoint,
"tracing_collector": cfg.Tracing.Collector,
"tracing_service_name": cfg.Tracing.Service,
},
"log": map[string]interface{}{
"level": cfg.Reva.LogLevel,
//TODO mode = "console" # "console" or "json"
//TODO output = "./standalone.log"
},
"http": map[string]interface{}{
"network": cfg.Reva.HTTP.Network,
"address": cfg.Reva.HTTP.Addr,
"enabled_services": []string{
"dataprovider",
"prometheus",
},
"enabled_middlewares": []string{
//"cors",
"auth",
},
"middlewares": map[string]interface{}{
"auth": map[string]interface{}{
"gateway": cfg.Reva.GRPC.Addr,
"auth_type": "oidc",
"credential_strategy": "oidc",
"token_strategy": "header",
"token_writer": "header",
"token_manager": "jwt",
"token_managers": map[string]interface{}{
"jwt": map[string]interface{}{
"secret": cfg.Reva.JWTSecret,
},
},
"skip_methods": []string{
"/metrics", // for prometheus metrics
},
},
},
"services": map[string]interface{}{
"dataprovider": map[string]interface{}{
"driver": "local",
"prefix": "data",
"tmp_folder": "/var/tmp/",
"drivers": map[string]interface{}{
"local": map[string]interface{}{
"root": "/var/tmp/reva/data",
},
},
},
},
},
"grpc": map[string]interface{}{
"network": cfg.Reva.GRPC.Network,
"address": cfg.Reva.GRPC.Addr,
"enabled_services": []string{
"authprovider", // provides basic auth
"storageprovider", // handles storage metadata
"usershareprovider", // provides user shares
"userprovider", // provides user matadata (used to look up email, displayname etc after a login)
"preferences", // provides user preferences
"gateway", // to lookup services and authenticate requests
"authregistry", // used by the gateway to look up auth providers
"storageregistry", // used by the gateway to look up storage providers
},
"interceptors": map[string]interface{}{
"auth": map[string]interface{}{
"token_manager": "jwt",
"token_managers": map[string]interface{}{
"jwt": map[string]interface{}{
"secret": cfg.Reva.JWTSecret,
},
},
"skip_methods": []string{
// we need to allow calls that happen during authentication
"/cs3.gatewayv0alpha.GatewayService/Authenticate",
"/cs3.gatewayv0alpha.GatewayService/WhoAmI",
"/cs3.gatewayv0alpha.GatewayService/GetUser",
"/cs3.gatewayv0alpha.GatewayService/ListAuthProviders",
"/cs3.authregistryv0alpha.AuthRegistryService/ListAuthProviders",
"/cs3.authregistryv0alpha.AuthRegistryService/GetAuthProvider",
"/cs3.authproviderv0alpha.AuthProviderService/Authenticate",
"/cs3.userproviderv0alpha.UserProviderService/GetUser",
},
},
},
"services": map[string]interface{}{
"gateway": map[string]interface{}{
"authregistrysvc": cfg.Reva.GRPC.Addr,
"storageregistrysvc": cfg.Reva.GRPC.Addr,
"appregistrysvc": cfg.Reva.GRPC.Addr,
"preferencessvc": cfg.Reva.GRPC.Addr,
"usershareprovidersvc": cfg.Reva.GRPC.Addr,
"publicshareprovidersvc": cfg.Reva.GRPC.Addr,
"ocmshareprovidersvc": cfg.Reva.GRPC.Addr,
"userprovidersvc": cfg.Reva.GRPC.Addr,
"commit_share_to_storage_grant": true,
"datagateway": "http://" + cfg.Reva.HTTP.Addr + "/data",
"transfer_shared_secret": "replace-me-with-a-transfer-secret",
"transfer_expires": 6, // give it a moment
"token_manager": "jwt",
"token_managers": map[string]interface{}{
"jwt": map[string]interface{}{
"secret": cfg.Reva.JWTSecret,
},
},
},
"authregistry": map[string]interface{}{
"driver": "static",
"drivers": map[string]interface{}{
"static": map[string]interface{}{
"rules": map[string]interface{}{
//"basic": "localhost:9999",
"oidc": cfg.Reva.GRPC.Addr,
},
},
},
},
"storageregistry": map[string]interface{}{
"driver": "static",
"drivers": map[string]interface{}{
"static": map[string]interface{}{
"rules": map[string]interface{}{
"/": cfg.Reva.GRPC.Addr,
"123e4567-e89b-12d3-a456-426655440000": cfg.Reva.GRPC.Addr,
},
},
},
},
"authprovider": map[string]interface{}{
"auth_manager": "oidc",
"auth_managers": map[string]interface{}{
"oidc": map[string]interface{}{
"provider": cfg.AuthProvider.Provider,
"insecure": cfg.AuthProvider.Insecure,
},
},
"userprovidersvc": cfg.Reva.GRPC.Addr,
},
"userprovider": map[string]interface{}{
"driver": "demo", // TODO use graph api
/*
"drivers": map[string]interface{}{
"graph": map[string]interface{}{
"provider": cfg.AuthProvider.Provider,
"insecure": cfg.AuthProvider.Insecure,
},
},
*/
},
"usershareprovider": map[string]interface{}{
"driver": "memory",
},
"storageprovider": map[string]interface{}{
"mount_path": "/",
"mount_id": "123e4567-e89b-12d3-a456-426655440000",
"data_server_url": "http://" + cfg.Reva.HTTP.Addr + "/data",
"expose_data_server": true,
"available_checksums": map[string]interface{}{
"md5": 100,
"unset": 1000,
},
"driver": "local",
"drivers": map[string]interface{}{
"local": map[string]interface{}{
"root": "/var/tmp/reva/data",
},
},
},
},
},
},
}
}
gr.Add(func() error {
var wg sync.WaitGroup
for k, conf := range cfg.Reva.Configs {
wg.Add(1)
go func(wg *sync.WaitGroup, config string, c map[string]interface{}) {
uuid := uuid.Must(uuid.NewV4())
pidFile := path.Join(os.TempDir(), "revad-"+uuid.String()+".pid")
logger.Info().
Str("config", config).
Str("server", "reva").
Msg("Starting server")
// TODO register reva as a service in micro
runtime.Run(c, pidFile)
wg.Done()
}(&wg, k, conf.(map[string]interface{}))
}
wg.Wait()
return nil
}, func(_ error) {
logger.Info().
Str("server", "reva").
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("server", "debug").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.ListenAndServe()
}, func(_ error) {
ctx, timeout := context.WithTimeout(ctx, 5*time.Second)
defer timeout()
defer cancel()
if err := server.Shutdown(ctx); err != nil {
logger.Info().
Err(err).
Str("server", "debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("server", "debug").
Msg("Shutting down server")
}
})
}
{
stop := make(chan os.Signal, 1)
gr.Add(func() error {
signal.Notify(stop, os.Interrupt)
<-stop
return nil
}, func(err error) {
close(stop)
cancel()
})
}
return gr.Run()
},
}
}

168
pkg/command/sharing.go Normal file
View File

@@ -0,0 +1,168 @@
package command
import (
"context"
"os"
"os/signal"
"path"
"time"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli"
"github.com/oklog/run"
"github.com/owncloud/ocis-reva/pkg/config"
"github.com/owncloud/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis-reva/pkg/server/debug"
)
// Sharing is the entrypoint for the sharing command.
func Sharing(cfg *config.Config) cli.Command {
return cli.Command{
Name: "sharing",
Usage: "Start reva sharing service",
Flags: flagset.SharingWithConfig(cfg),
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
if cfg.Tracing.Enabled {
switch t := cfg.Tracing.Type; t {
case "agent":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
case "jaeger":
logger.Info().
Str("type", t).
Msg("configuring reva to use the jaeger tracing backend")
case "zipkin":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
default:
logger.Warn().
Str("type", t).
Msg("Unknown tracing backend")
}
} else {
logger.Debug().
Msg("Tracing is not enabled")
}
var (
gr = run.Group{}
ctx, cancel = context.WithCancel(context.Background())
//metrics = metrics.New()
)
defer cancel()
{
uuid := uuid.Must(uuid.NewV4())
pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid")
rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.Sharing.MaxCPUs,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.Sharing.Network,
"address": cfg.Reva.Sharing.Addr,
// TODO extract interceptor config, which is the same for all grpc services
"interceptors": map[string]interface{}{
"auth": map[string]interface{}{
"token_manager": "jwt",
"token_managers": map[string]interface{}{
"jwt": map[string]interface{}{
"secret": cfg.Reva.JWTSecret,
},
},
},
},
// TODO build services dynamically
"services": map[string]interface{}{
"usershareprovider": map[string]interface{}{
"driver": "memory",
},
"publicshareprovider": map[string]interface{}{
"driver": "memory",
},
},
},
}
gr.Add(func() error {
runtime.Run(rcfg, pidFile)
return nil
}, func(_ error) {
logger.Info().
Str("server", c.Command.Name).
Msg("Shutting down server")
cancel()
})
}
{
server, err := debug.Server(
debug.Name(c.Command.Name+"-debug"),
debug.Addr(cfg.Reva.Sharing.DebugAddr),
debug.Logger(logger),
debug.Context(ctx),
debug.Config(cfg),
)
if err != nil {
logger.Info().
Err(err).
Str("server", c.Command.Name+"-debug").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.ListenAndServe()
}, func(_ error) {
ctx, timeout := context.WithTimeout(ctx, 5*time.Second)
defer timeout()
defer cancel()
if err := server.Shutdown(ctx); err != nil {
logger.Info().
Err(err).
Str("server", c.Command.Name+"-debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("server", c.Command.Name+"-debug").
Msg("Shutting down server")
}
})
}
{
stop := make(chan os.Signal, 1)
gr.Add(func() error {
signal.Notify(stop, os.Interrupt)
<-stop
return nil
}, func(err error) {
close(stop)
cancel()
})
}
return gr.Run()
},
}
}

210
pkg/command/storagehome.go Normal file
View File

@@ -0,0 +1,210 @@
package command
import (
"context"
"os"
"os/signal"
"path"
"time"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli"
"github.com/oklog/run"
"github.com/owncloud/ocis-reva/pkg/config"
"github.com/owncloud/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis-reva/pkg/server/debug"
)
// StorageHome is the entrypoint for the storage-home command.
func StorageHome(cfg *config.Config) cli.Command {
return cli.Command{
Name: "storage-home",
Usage: "Start reva storage-home service",
Flags: flagset.StorageHomeWithConfig(cfg),
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
if cfg.Tracing.Enabled {
switch t := cfg.Tracing.Type; t {
case "agent":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
case "jaeger":
logger.Info().
Str("type", t).
Msg("configuring reva to use the jaeger tracing backend")
case "zipkin":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
default:
logger.Warn().
Str("type", t).
Msg("Unknown tracing backend")
}
} else {
logger.Debug().
Msg("Tracing is not enabled")
}
var (
gr = run.Group{}
ctx, cancel = context.WithCancel(context.Background())
//metrics = metrics.New()
)
defer cancel()
{
uuid := uuid.Must(uuid.NewV4())
pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid")
rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.StorageHome.MaxCPUs,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.StorageHome.Network,
"address": cfg.Reva.StorageHome.Addr,
// TODO extract interceptor config, which is the same for all grpc services
"interceptors": map[string]interface{}{
"auth": map[string]interface{}{
"token_manager": "jwt",
"token_managers": map[string]interface{}{
"jwt": map[string]interface{}{
"secret": cfg.Reva.JWTSecret,
},
},
},
},
// TODO build services dynamically
"services": map[string]interface{}{
"storageprovider": map[string]interface{}{
"driver": cfg.Reva.StorageHome.Driver,
"drivers": map[string]interface{}{
"eos": map[string]interface{}{
"namespace": cfg.Reva.Storages.EOS.Namespace,
"eos_binary": cfg.Reva.Storages.EOS.EosBinary,
"xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary,
"master_url": cfg.Reva.Storages.EOS.MasterURL,
"slave_url": cfg.Reva.Storages.EOS.SlaveURL,
"cache_directory": cfg.Reva.Storages.EOS.CacheDirectory,
"enable_logging": cfg.Reva.Storages.EOS.EnableLogging,
"show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles,
"force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode,
"use_keytab": cfg.Reva.Storages.EOS.UseKeytab,
"sec_protocol": cfg.Reva.Storages.EOS.SecProtocol,
"keytab": cfg.Reva.Storages.EOS.Keytab,
"single_username": cfg.Reva.Storages.EOS.SingleUsername,
},
"local": map[string]interface{}{
"root": cfg.Reva.Storages.Local.Root,
},
"owncloud": map[string]interface{}{
"datadirectory": cfg.Reva.Storages.OwnCloud.Datadirectory,
},
"s3": map[string]interface{}{
"region": cfg.Reva.Storages.S3.Region,
"access_key": cfg.Reva.Storages.S3.AccessKey,
"secret_key": cfg.Reva.Storages.S3.SecretKey,
"endpoint": cfg.Reva.Storages.S3.Endpoint,
"bucket": cfg.Reva.Storages.S3.Bucket,
"prefix": cfg.Reva.Storages.S3.Prefix,
},
},
"path_wrapper": cfg.Reva.StorageHome.PathWrapper,
"path_wrappers": map[string]interface{}{
"context": map[string]interface{}{
"prefix": cfg.Reva.StorageHome.PathWrapperContext.Prefix,
},
},
"mount_path": cfg.Reva.StorageHome.MountPath,
"mount_id": cfg.Reva.StorageHome.MountID,
"expose_data_server": cfg.Reva.StorageHome.ExposeDataServer,
// TODO use cfg.Reva.StorageHomeData.URL, ?
"data_server_url": cfg.Reva.StorageHome.DataServerURL,
"available_checksums": map[string]interface{}{
"md5": 100,
"unset": 1000,
},
},
},
},
}
gr.Add(func() error {
runtime.Run(rcfg, pidFile)
return nil
}, func(_ error) {
logger.Info().
Str("server", c.Command.Name).
Msg("Shutting down server")
cancel()
})
}
{
server, err := debug.Server(
debug.Name(c.Command.Name+"-debug"),
debug.Addr(cfg.Reva.StorageHome.DebugAddr),
debug.Logger(logger),
debug.Context(ctx),
debug.Config(cfg),
)
if err != nil {
logger.Info().
Err(err).
Str("server", c.Command.Name+"-debug").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.ListenAndServe()
}, func(_ error) {
ctx, timeout := context.WithTimeout(ctx, 5*time.Second)
defer timeout()
defer cancel()
if err := server.Shutdown(ctx); err != nil {
logger.Info().
Err(err).
Str("server", c.Command.Name+"-debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("server", c.Command.Name+"-debug").
Msg("Shutting down server")
}
})
}
{
stop := make(chan os.Signal, 1)
gr.Add(func() error {
signal.Notify(stop, os.Interrupt)
<-stop
return nil
}, func(err error) {
close(stop)
cancel()
})
}
return gr.Run()
},
}
}

View File

@@ -0,0 +1,200 @@
package command
import (
"context"
"os"
"os/signal"
"path"
"time"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli"
"github.com/oklog/run"
"github.com/owncloud/ocis-reva/pkg/config"
"github.com/owncloud/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis-reva/pkg/server/debug"
)
// StorageHomeData is the entrypoint for the storage-home-data command.
func StorageHomeData(cfg *config.Config) cli.Command {
return cli.Command{
Name: "storage-home-data",
Usage: "Start reva storage-home-data service",
Flags: flagset.StorageHomeDataWithConfig(cfg),
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
if cfg.Tracing.Enabled {
switch t := cfg.Tracing.Type; t {
case "agent":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
case "jaeger":
logger.Info().
Str("type", t).
Msg("configuring reva to use the jaeger tracing backend")
case "zipkin":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
default:
logger.Warn().
Str("type", t).
Msg("Unknown tracing backend")
}
} else {
logger.Debug().
Msg("Tracing is not enabled")
}
var (
gr = run.Group{}
ctx, cancel = context.WithCancel(context.Background())
//metrics = metrics.New()
)
defer cancel()
{
uuid := uuid.Must(uuid.NewV4())
pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid")
rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.StorageHomeData.MaxCPUs,
},
"http": map[string]interface{}{
"network": cfg.Reva.StorageHomeData.Network,
"address": cfg.Reva.StorageHomeData.Addr,
"middlewares": map[string]interface{}{
"auth": map[string]interface{}{
"gateway": cfg.Reva.Gateway.URL,
"credential_chain": []string{"basic", "bearer"},
"token_strategy": "header",
"token_writer": "header",
"token_manager": "jwt",
"token_managers": map[string]interface{}{
"jwt": map[string]interface{}{
"secret": cfg.Reva.JWTSecret,
},
},
},
},
// TODO build services dynamically
"services": map[string]interface{}{
"dataprovider": map[string]interface{}{
"prefix": cfg.Reva.StorageHomeData.Prefix,
"driver": cfg.Reva.StorageHomeData.Driver,
"drivers": map[string]interface{}{
"eos": map[string]interface{}{
"namespace": cfg.Reva.Storages.EOS.Namespace,
"eos_binary": cfg.Reva.Storages.EOS.EosBinary,
"xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary,
"master_url": cfg.Reva.Storages.EOS.MasterURL,
"slave_url": cfg.Reva.Storages.EOS.SlaveURL,
"cache_directory": cfg.Reva.Storages.EOS.CacheDirectory,
"enable_logging": cfg.Reva.Storages.EOS.EnableLogging,
"show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles,
"force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode,
"use_keytab": cfg.Reva.Storages.EOS.UseKeytab,
"sec_protocol": cfg.Reva.Storages.EOS.SecProtocol,
"keytab": cfg.Reva.Storages.EOS.Keytab,
"single_username": cfg.Reva.Storages.EOS.SingleUsername,
},
"local": map[string]interface{}{
"root": cfg.Reva.Storages.Local.Root,
},
"owncloud": map[string]interface{}{
"datadirectory": cfg.Reva.Storages.OwnCloud.Datadirectory,
},
"s3": map[string]interface{}{
"region": cfg.Reva.Storages.S3.Region,
"access_key": cfg.Reva.Storages.S3.AccessKey,
"secret_key": cfg.Reva.Storages.S3.SecretKey,
"endpoint": cfg.Reva.Storages.S3.Endpoint,
"bucket": cfg.Reva.Storages.S3.Bucket,
"prefix": cfg.Reva.Storages.S3.Prefix,
},
},
"temp_folder": cfg.Reva.StorageHomeData.TempFolder,
},
},
},
}
gr.Add(func() error {
runtime.Run(rcfg, pidFile)
return nil
}, func(_ error) {
logger.Info().
Str("server", c.Command.Name).
Msg("Shutting down server")
cancel()
})
}
{
server, err := debug.Server(
debug.Name(c.Command.Name+"-debug"),
debug.Addr(cfg.Reva.StorageHomeData.DebugAddr),
debug.Logger(logger),
debug.Context(ctx),
debug.Config(cfg),
)
if err != nil {
logger.Info().
Err(err).
Str("server", c.Command.Name+"-debug").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.ListenAndServe()
}, func(_ error) {
ctx, timeout := context.WithTimeout(ctx, 5*time.Second)
defer timeout()
defer cancel()
if err := server.Shutdown(ctx); err != nil {
logger.Info().
Err(err).
Str("server", c.Command.Name+"-debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("server", c.Command.Name+"-debug").
Msg("Shutting down server")
}
})
}
{
stop := make(chan os.Signal, 1)
gr.Add(func() error {
signal.Notify(stop, os.Interrupt)
<-stop
return nil
}, func(err error) {
close(stop)
cancel()
})
}
return gr.Run()
},
}
}

210
pkg/command/storageoc.go Normal file
View File

@@ -0,0 +1,210 @@
package command
import (
"context"
"os"
"os/signal"
"path"
"time"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli"
"github.com/oklog/run"
"github.com/owncloud/ocis-reva/pkg/config"
"github.com/owncloud/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis-reva/pkg/server/debug"
)
// StorageOC is the entrypoint for the storage-oc command.
func StorageOC(cfg *config.Config) cli.Command {
return cli.Command{
Name: "storage-oc",
Usage: "Start reva storage-oc service",
Flags: flagset.StorageOCWithConfig(cfg),
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
if cfg.Tracing.Enabled {
switch t := cfg.Tracing.Type; t {
case "agent":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
case "jaeger":
logger.Info().
Str("type", t).
Msg("configuring reva to use the jaeger tracing backend")
case "zipkin":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
default:
logger.Warn().
Str("type", t).
Msg("Unknown tracing backend")
}
} else {
logger.Debug().
Msg("Tracing is not enabled")
}
var (
gr = run.Group{}
ctx, cancel = context.WithCancel(context.Background())
//metrics = metrics.New()
)
defer cancel()
{
uuid := uuid.Must(uuid.NewV4())
pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid")
rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.StorageOC.MaxCPUs,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.StorageOC.Network,
"address": cfg.Reva.StorageOC.Addr,
// TODO extract interceptor config, which is the same for all grpc services
"interceptors": map[string]interface{}{
"auth": map[string]interface{}{
"token_manager": "jwt",
"token_managers": map[string]interface{}{
"jwt": map[string]interface{}{
"secret": cfg.Reva.JWTSecret,
},
},
},
},
// TODO build services dynamically
"services": map[string]interface{}{
"storageprovider": map[string]interface{}{
"driver": cfg.Reva.StorageOC.Driver,
"drivers": map[string]interface{}{
"eos": map[string]interface{}{
"namespace": cfg.Reva.Storages.EOS.Namespace,
"eos_binary": cfg.Reva.Storages.EOS.EosBinary,
"xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary,
"master_url": cfg.Reva.Storages.EOS.MasterURL,
"slave_url": cfg.Reva.Storages.EOS.SlaveURL,
"cache_directory": cfg.Reva.Storages.EOS.CacheDirectory,
"enable_logging": cfg.Reva.Storages.EOS.EnableLogging,
"show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles,
"force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode,
"use_keytab": cfg.Reva.Storages.EOS.UseKeytab,
"sec_protocol": cfg.Reva.Storages.EOS.SecProtocol,
"keytab": cfg.Reva.Storages.EOS.Keytab,
"single_username": cfg.Reva.Storages.EOS.SingleUsername,
},
"local": map[string]interface{}{
"root": cfg.Reva.Storages.Local.Root,
},
"owncloud": map[string]interface{}{
"datadirectory": cfg.Reva.Storages.OwnCloud.Datadirectory,
},
"s3": map[string]interface{}{
"region": cfg.Reva.Storages.S3.Region,
"access_key": cfg.Reva.Storages.S3.AccessKey,
"secret_key": cfg.Reva.Storages.S3.SecretKey,
"endpoint": cfg.Reva.Storages.S3.Endpoint,
"bucket": cfg.Reva.Storages.S3.Bucket,
"prefix": cfg.Reva.Storages.S3.Prefix,
},
},
"path_wrapper": cfg.Reva.StorageOC.PathWrapper,
"path_wrappers": map[string]interface{}{
"context": map[string]interface{}{
"prefix": cfg.Reva.StorageOC.PathWrapperContext.Prefix,
},
},
"mount_path": cfg.Reva.StorageOC.MountPath,
"mount_id": cfg.Reva.StorageOC.MountID,
"expose_data_server": cfg.Reva.StorageOC.ExposeDataServer,
// TODO use cfg.Reva.SStorageOCData.URL, ?
"data_server_url": cfg.Reva.StorageOC.DataServerURL,
"available_checksums": map[string]interface{}{
"md5": 100,
"unset": 1000,
},
},
},
},
}
gr.Add(func() error {
runtime.Run(rcfg, pidFile)
return nil
}, func(_ error) {
logger.Info().
Str("server", c.Command.Name).
Msg("Shutting down server")
cancel()
})
}
{
server, err := debug.Server(
debug.Name(c.Command.Name+"-debug"),
debug.Addr(cfg.Reva.StorageOC.DebugAddr),
debug.Logger(logger),
debug.Context(ctx),
debug.Config(cfg),
)
if err != nil {
logger.Info().
Err(err).
Str("server", c.Command.Name+"-debug").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.ListenAndServe()
}, func(_ error) {
ctx, timeout := context.WithTimeout(ctx, 5*time.Second)
defer timeout()
defer cancel()
if err := server.Shutdown(ctx); err != nil {
logger.Info().
Err(err).
Str("server", c.Command.Name+"-debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("server", c.Command.Name+"-debug").
Msg("Shutting down server")
}
})
}
{
stop := make(chan os.Signal, 1)
gr.Add(func() error {
signal.Notify(stop, os.Interrupt)
<-stop
return nil
}, func(err error) {
close(stop)
cancel()
})
}
return gr.Run()
},
}
}

View File

@@ -0,0 +1,200 @@
package command
import (
"context"
"os"
"os/signal"
"path"
"time"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli"
"github.com/oklog/run"
"github.com/owncloud/ocis-reva/pkg/config"
"github.com/owncloud/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis-reva/pkg/server/debug"
)
// StorageOCData is the entrypoint for the storage-oc-data command.
func StorageOCData(cfg *config.Config) cli.Command {
return cli.Command{
Name: "storage-oc-data",
Usage: "Start reva storage-oc-data service",
Flags: flagset.StorageOCDataWithConfig(cfg),
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
if cfg.Tracing.Enabled {
switch t := cfg.Tracing.Type; t {
case "agent":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
case "jaeger":
logger.Info().
Str("type", t).
Msg("configuring reva to use the jaeger tracing backend")
case "zipkin":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
default:
logger.Warn().
Str("type", t).
Msg("Unknown tracing backend")
}
} else {
logger.Debug().
Msg("Tracing is not enabled")
}
var (
gr = run.Group{}
ctx, cancel = context.WithCancel(context.Background())
//metrics = metrics.New()
)
defer cancel()
{
uuid := uuid.Must(uuid.NewV4())
pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid")
rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.StorageOCData.MaxCPUs,
},
"http": map[string]interface{}{
"network": cfg.Reva.StorageOCData.Network,
"address": cfg.Reva.StorageOCData.Addr,
"middlewares": map[string]interface{}{
"auth": map[string]interface{}{
"gateway": cfg.Reva.Gateway.URL,
"credential_chain": []string{"basic", "bearer"},
"token_strategy": "header",
"token_writer": "header",
"token_manager": "jwt",
"token_managers": map[string]interface{}{
"jwt": map[string]interface{}{
"secret": cfg.Reva.JWTSecret,
},
},
},
},
// TODO build services dynamically
"services": map[string]interface{}{
"dataprovider": map[string]interface{}{
"prefix": cfg.Reva.StorageOCData.Prefix,
"driver": cfg.Reva.StorageOCData.Driver,
"drivers": map[string]interface{}{
"eos": map[string]interface{}{
"namespace": cfg.Reva.Storages.EOS.Namespace,
"eos_binary": cfg.Reva.Storages.EOS.EosBinary,
"xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary,
"master_url": cfg.Reva.Storages.EOS.MasterURL,
"slave_url": cfg.Reva.Storages.EOS.SlaveURL,
"cache_directory": cfg.Reva.Storages.EOS.CacheDirectory,
"enable_logging": cfg.Reva.Storages.EOS.EnableLogging,
"show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles,
"force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode,
"use_keytab": cfg.Reva.Storages.EOS.UseKeytab,
"sec_protocol": cfg.Reva.Storages.EOS.SecProtocol,
"keytab": cfg.Reva.Storages.EOS.Keytab,
"single_username": cfg.Reva.Storages.EOS.SingleUsername,
},
"local": map[string]interface{}{
"root": cfg.Reva.Storages.Local.Root,
},
"owncloud": map[string]interface{}{
"datadirectory": cfg.Reva.Storages.OwnCloud.Datadirectory,
},
"s3": map[string]interface{}{
"region": cfg.Reva.Storages.S3.Region,
"access_key": cfg.Reva.Storages.S3.AccessKey,
"secret_key": cfg.Reva.Storages.S3.SecretKey,
"endpoint": cfg.Reva.Storages.S3.Endpoint,
"bucket": cfg.Reva.Storages.S3.Bucket,
"prefix": cfg.Reva.Storages.S3.Prefix,
},
},
"temp_folder": cfg.Reva.StorageOCData.TempFolder,
},
},
},
}
gr.Add(func() error {
runtime.Run(rcfg, pidFile)
return nil
}, func(_ error) {
logger.Info().
Str("server", c.Command.Name).
Msg("Shutting down server")
cancel()
})
}
{
server, err := debug.Server(
debug.Name(c.Command.Name+"-debug"),
debug.Addr(cfg.Reva.StorageOCData.DebugAddr),
debug.Logger(logger),
debug.Context(ctx),
debug.Config(cfg),
)
if err != nil {
logger.Info().
Err(err).
Str("server", c.Command.Name+"-debug").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.ListenAndServe()
}, func(_ error) {
ctx, timeout := context.WithTimeout(ctx, 5*time.Second)
defer timeout()
defer cancel()
if err := server.Shutdown(ctx); err != nil {
logger.Info().
Err(err).
Str("server", c.Command.Name+"-debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("server", c.Command.Name+"-debug").
Msg("Shutting down server")
}
})
}
{
stop := make(chan os.Signal, 1)
gr.Add(func() error {
signal.Notify(stop, os.Interrupt)
<-stop
return nil
}, func(err error) {
close(stop)
cancel()
})
}
return gr.Run()
},
}
}

209
pkg/command/storageroot.go Normal file
View File

@@ -0,0 +1,209 @@
package command
import (
"context"
"os"
"os/signal"
"path"
"time"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli"
"github.com/oklog/run"
"github.com/owncloud/ocis-reva/pkg/config"
"github.com/owncloud/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis-reva/pkg/server/debug"
)
// StorageRoot is the entrypoint for the storage-root command.
func StorageRoot(cfg *config.Config) cli.Command {
return cli.Command{
Name: "storage-root",
Usage: "Start reva storage-root service",
Flags: flagset.StorageRootWithConfig(cfg),
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
if cfg.Tracing.Enabled {
switch t := cfg.Tracing.Type; t {
case "agent":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
case "jaeger":
logger.Info().
Str("type", t).
Msg("configuring reva to use the jaeger tracing backend")
case "zipkin":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
default:
logger.Warn().
Str("type", t).
Msg("Unknown tracing backend")
}
} else {
logger.Debug().
Msg("Tracing is not enabled")
}
var (
gr = run.Group{}
ctx, cancel = context.WithCancel(context.Background())
//metrics = metrics.New()
)
defer cancel()
{
uuid := uuid.Must(uuid.NewV4())
pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid")
rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.StorageRoot.MaxCPUs,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.StorageRoot.Network,
"address": cfg.Reva.StorageRoot.Addr,
// TODO extract interceptor config, which is the same for all grpc services
"interceptors": map[string]interface{}{
"auth": map[string]interface{}{
"token_manager": "jwt",
"token_managers": map[string]interface{}{
"jwt": map[string]interface{}{
"secret": cfg.Reva.JWTSecret,
},
},
},
},
// TODO build services dynamically
"services": map[string]interface{}{
"storageprovider": map[string]interface{}{
"driver": cfg.Reva.StorageRoot.Driver,
"drivers": map[string]interface{}{
"eos": map[string]interface{}{
"namespace": cfg.Reva.Storages.EOS.Namespace,
"eos_binary": cfg.Reva.Storages.EOS.EosBinary,
"xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary,
"master_url": cfg.Reva.Storages.EOS.MasterURL,
"slave_url": cfg.Reva.Storages.EOS.SlaveURL,
"cache_directory": cfg.Reva.Storages.EOS.CacheDirectory,
"enable_logging": cfg.Reva.Storages.EOS.EnableLogging,
"show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles,
"force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode,
"use_keytab": cfg.Reva.Storages.EOS.UseKeytab,
"sec_protocol": cfg.Reva.Storages.EOS.SecProtocol,
"keytab": cfg.Reva.Storages.EOS.Keytab,
"single_username": cfg.Reva.Storages.EOS.SingleUsername,
},
"local": map[string]interface{}{
"root": cfg.Reva.Storages.Local.Root,
},
"owncloud": map[string]interface{}{
"datadirectory": cfg.Reva.Storages.OwnCloud.Datadirectory,
},
"s3": map[string]interface{}{
"region": cfg.Reva.Storages.S3.Region,
"access_key": cfg.Reva.Storages.S3.AccessKey,
"secret_key": cfg.Reva.Storages.S3.SecretKey,
"endpoint": cfg.Reva.Storages.S3.Endpoint,
"bucket": cfg.Reva.Storages.S3.Bucket,
"prefix": cfg.Reva.Storages.S3.Prefix,
},
},
"path_wrapper": cfg.Reva.StorageRoot.PathWrapper,
"path_wrappers": map[string]interface{}{
"context": map[string]interface{}{
"prefix": cfg.Reva.StorageRoot.PathWrapperContext.Prefix,
},
},
"mount_path": cfg.Reva.StorageRoot.MountPath,
"mount_id": cfg.Reva.StorageRoot.MountID,
"expose_data_server": cfg.Reva.StorageRoot.ExposeDataServer,
"data_server_url": cfg.Reva.StorageRoot.DataServerURL,
"available_checksums": map[string]interface{}{
"md5": 100,
"unset": 1000,
},
},
},
},
}
gr.Add(func() error {
runtime.Run(rcfg, pidFile)
return nil
}, func(_ error) {
logger.Info().
Str("server", c.Command.Name).
Msg("Shutting down server")
cancel()
})
}
{
server, err := debug.Server(
debug.Name(c.Command.Name+"-debug"),
debug.Addr(cfg.Reva.StorageRoot.DebugAddr),
debug.Logger(logger),
debug.Context(ctx),
debug.Config(cfg),
)
if err != nil {
logger.Info().
Err(err).
Str("server", c.Command.Name+"-debug").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.ListenAndServe()
}, func(_ error) {
ctx, timeout := context.WithTimeout(ctx, 5*time.Second)
defer timeout()
defer cancel()
if err := server.Shutdown(ctx); err != nil {
logger.Info().
Err(err).
Str("server", c.Command.Name+"-debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("server", c.Command.Name+"-debug").
Msg("Shutting down server")
}
})
}
{
stop := make(chan os.Signal, 1)
gr.Add(func() error {
signal.Notify(stop, os.Interrupt)
<-stop
return nil
}, func(err error) {
close(stop)
cancel()
})
}
return gr.Run()
},
}
}

186
pkg/command/users.go Normal file
View File

@@ -0,0 +1,186 @@
package command
import (
"context"
"os"
"os/signal"
"path"
"time"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli"
"github.com/oklog/run"
"github.com/owncloud/ocis-reva/pkg/config"
"github.com/owncloud/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis-reva/pkg/server/debug"
)
// Users is the entrypoint for the sharing command.
func Users(cfg *config.Config) cli.Command {
return cli.Command{
Name: "users",
Usage: "Start reva users service",
Flags: flagset.UsersWithConfig(cfg),
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
if cfg.Tracing.Enabled {
switch t := cfg.Tracing.Type; t {
case "agent":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
case "jaeger":
logger.Info().
Str("type", t).
Msg("configuring reva to use the jaeger tracing backend")
case "zipkin":
logger.Error().
Str("type", t).
Msg("Reva only supports the jaeger tracing backend")
default:
logger.Warn().
Str("type", t).
Msg("Unknown tracing backend")
}
} else {
logger.Debug().
Msg("Tracing is not enabled")
}
var (
gr = run.Group{}
ctx, cancel = context.WithCancel(context.Background())
//metrics = metrics.New()
)
defer cancel()
{
uuid := uuid.Must(uuid.NewV4())
pidFile := path.Join(os.TempDir(), "revad-"+c.Command.Name+"-"+uuid.String()+".pid")
rcfg := map[string]interface{}{
"core": map[string]interface{}{
"max_cpus": cfg.Reva.Users.MaxCPUs,
},
"grpc": map[string]interface{}{
"network": cfg.Reva.Users.Network,
"address": cfg.Reva.Users.Addr,
// TODO extract interceptor config, which is the same for all grpc services
"interceptors": map[string]interface{}{
"auth": map[string]interface{}{
"token_manager": "jwt",
"token_managers": map[string]interface{}{
"jwt": map[string]interface{}{
"secret": cfg.Reva.JWTSecret,
},
},
},
},
// TODO build services dynamically
"services": map[string]interface{}{
"userprovider": map[string]interface{}{
"driver": cfg.Reva.Users.Driver,
"drivers": map[string]interface{}{
"json": map[string]interface{}{
"users": cfg.Reva.Users.JSON,
},
"ldap": map[string]interface{}{
"hostname": cfg.Reva.LDAP.Hostname,
"port": cfg.Reva.LDAP.Port,
"base_dn": cfg.Reva.LDAP.BaseDN,
"userfilter": cfg.Reva.LDAP.UserFilter,
"groupfilter": cfg.Reva.LDAP.GroupFilter,
"bind_username": cfg.Reva.LDAP.BindDN,
"bind_password": cfg.Reva.LDAP.BindPassword,
"idp": cfg.Reva.LDAP.IDP,
"schema": map[string]interface{}{
"dn": "dn",
"uid": cfg.Reva.LDAP.Schema.UID,
"mail": cfg.Reva.LDAP.Schema.Mail,
"displayName": cfg.Reva.LDAP.Schema.DisplayName,
"cn": cfg.Reva.LDAP.Schema.CN,
},
},
},
},
},
},
}
gr.Add(func() error {
runtime.Run(rcfg, pidFile)
return nil
}, func(_ error) {
logger.Info().
Str("server", c.Command.Name).
Msg("Shutting down server")
cancel()
})
}
{
server, err := debug.Server(
debug.Name(c.Command.Name+"-debug"),
debug.Addr(cfg.Reva.Users.DebugAddr),
debug.Logger(logger),
debug.Context(ctx),
debug.Config(cfg),
)
if err != nil {
logger.Info().
Err(err).
Str("server", c.Command.Name+"-debug").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.ListenAndServe()
}, func(_ error) {
ctx, timeout := context.WithTimeout(ctx, 5*time.Second)
defer timeout()
defer cancel()
if err := server.Shutdown(ctx); err != nil {
logger.Info().
Err(err).
Str("server", c.Command.Name+"-debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("server", c.Command.Name+"-debug").
Msg("Shutting down server")
}
})
}
{
stop := make(chan os.Signal, 1)
gr.Add(func() error {
signal.Notify(stop, os.Interrupt)
<-stop
return nil
}, func(err error) {
close(stop)
cancel()
})
}
return gr.Run()
},
}
}

View File

@@ -15,33 +15,179 @@ type Debug struct {
Zpages bool
}
type HTTP struct {
Network string
Addr string
Root string // TODO do we need the http root path
}
type GRPC struct {
Network string
Addr string
type Gateway struct {
Port
CommitShareToStorageGrant bool
}
// Reva defines the available reva configuration.
type Reva struct {
type Port struct {
// MaxCPUs can be a number or a percentage
MaxCPUs string
LogLevel string
// Network can be tcp, udp or unix
HTTP HTTP
GRPC GRPC
JWTSecret string
// Used to pass in configs from the ocis repo, multiple reva instances can be started with this
Configs map[string]interface{}
Network string
// Addr to listen on, hostname:port (0.0.0.0:9999 for all interfaces) or socket (/var/run/reva/sock)
Addr string
// Protocol can be grpc or http
Protocol string
// URL is used by the gateway and registries (eg http://localhost:9100 or https://cloud.example.com)
URL string
// DebugAddr for the debug endpoint to bind to
DebugAddr string
// Services can be used to give a list of services that should be started on this port
Services string
// used to store the parsed services
servicesList []string
// Config can be used to configure the reva instance.
// Services and Protocol will be ignored if this is used
Config map[string]interface{}
}
type Users struct {
Port
Driver string
JSON string
}
type PathWrapperContext struct {
Prefix string
}
type StoragePort struct {
Port
Driver string
PathWrapper string
PathWrapperContext PathWrapperContext
MountPath string
MountID string
ExposeDataServer bool
DataServerURL string
// TODO checksums ... figure out what that is supposed to do
// for HTTP ports with only one http service
Prefix string
TempFolder string
}
type StorageConfig struct {
EOS StorageEOS
Local StorageLocal
OwnCloud StorageOwnCloud
S3 StorageS3
// TODO checksums ... figure out what that is supposed to do
}
type StorageEOS struct {
// Namespace for metadata operations
Namespace string
// Location of the eos binary.
// Default is /usr/bin/eos.
EosBinary string
// Location of the xrdcopy binary.
// Default is /usr/bin/xrdcopy.
XrdcopyBinary string
// URL of the Master EOS MGM.
// Default is root://eos-example.org
MasterURL string
// URL of the Slave EOS MGM.
// Default is root://eos-example.org
SlaveURL string
// Location on the local fs where to store reads.
// Defaults to os.TempDir()
CacheDirectory string
// Enables logging of the commands executed
// Defaults to false
EnableLogging bool
// ShowHiddenSysFiles shows internal EOS files like
// .sys.v# and .sys.a# files.
ShowHiddenSysFiles bool
// ForceSingleUserMode will force connections to EOS to use SingleUsername
ForceSingleUserMode bool
// UseKeyTabAuth changes will authenticate requests by using an EOS keytab.
UseKeytab bool
// SecProtocol specifies the xrootd security protocol to use between the server and EOS.
SecProtocol string
// Keytab specifies the location of the keytab to use to authenticate to EOS.
Keytab string
// SingleUsername is the username to use when SingleUserMode is enabled
SingleUsername string
}
type StorageLocal struct {
Root string
}
type StorageOwnCloud struct {
Datadirectory string
}
type StorageS3 struct {
Region string
AccessKey string
SecretKey string
Endpoint string
Bucket string
Prefix string
}
type OIDC struct {
Issuer string
Insecure bool
IDClaim string
}
type LDAP struct {
Hostname string
Port int
BaseDN string
UserFilter string
GroupFilter string
BindDN string
BindPassword string
IDP string
Schema LDAPSchema
}
type LDAPSchema struct {
UID string
Mail string
DisplayName string
CN string
}
// AuthProvider defines the available authprovider configuration.
type AuthProvider struct {
Provider string
Insecure bool
// Reva defines the available reva configuration.
type Reva struct {
// JWTSecret used to sign jwt tokens between services
JWTSecret string
TransferSecret string
TransferExpires int
OIDC OIDC
LDAP LDAP
Storages StorageConfig
// Ports are used configure which services to start on which port
Frontend Port
Gateway Gateway
Users Users
AuthBasic Port
AuthBearer Port
Sharing Port
StorageRoot StoragePort
StorageHome StoragePort
StorageHomeData StoragePort
StorageEOS StoragePort
StorageEOSData StoragePort
StorageOC StoragePort
StorageOCData StoragePort
StorageS3 StoragePort
StorageS3Data StoragePort
StorageWND StoragePort
StorageWNDData StoragePort
StorageCustom StoragePort
StorageCustomData StoragePort
// Configs can be used to configure the reva instance.
// Services and Ports will be ignored if this is used
Configs map[string]interface{}
}
// Tracing defines the available tracing configuration.
@@ -60,13 +206,12 @@ type Asset struct {
// Config combines all available configuration parts.
type Config struct {
File string
Log Log
Debug Debug
Reva Reva
AuthProvider AuthProvider
Tracing Tracing
Asset Asset
File string
Log Log
Debug Debug
Reva Reva
Tracing Tracing
Asset Asset
}
// New initializes a new configuration with or without defaults.

223
pkg/flagset/authbasic.go Normal file
View File

@@ -0,0 +1,223 @@
package flagset
import (
"github.com/micro/cli"
"github.com/owncloud/ocis-reva/pkg/config"
)
// AuthBasicWithConfig applies cfg to the root flagset
func AuthBasicWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "tracing-enabled",
Usage: "Enable sending traces",
EnvVar: "REVA_TRACING_ENABLED",
Destination: &cfg.Tracing.Enabled,
},
&cli.StringFlag{
Name: "tracing-type",
Value: "jaeger",
Usage: "Tracing backend type",
EnvVar: "REVA_TRACING_TYPE",
Destination: &cfg.Tracing.Type,
},
&cli.StringFlag{
Name: "tracing-endpoint",
Value: "",
Usage: "Endpoint for the agent",
EnvVar: "REVA_TRACING_ENDPOINT",
Destination: &cfg.Tracing.Endpoint,
},
&cli.StringFlag{
Name: "tracing-collector",
Value: "",
Usage: "Endpoint for the collector",
EnvVar: "REVA_TRACING_COLLECTOR",
Destination: &cfg.Tracing.Collector,
},
&cli.StringFlag{
Name: "tracing-service",
Value: "reva",
Usage: "Service name for tracing",
EnvVar: "REVA_TRACING_SERVICE",
Destination: &cfg.Tracing.Service,
},
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9147",
Usage: "Address to bind debug server",
EnvVar: "REVA_AUTH_BASIC_DEBUG_ADDR",
Destination: &cfg.Reva.AuthBasic.DebugAddr,
},
&cli.StringFlag{
Name: "debug-token",
Value: "",
Usage: "Token to grant metrics access",
EnvVar: "REVA_DEBUG_TOKEN",
Destination: &cfg.Debug.Token,
},
&cli.BoolFlag{
Name: "debug-pprof",
Usage: "Enable pprof debugging",
EnvVar: "REVA_DEBUG_PPROF",
Destination: &cfg.Debug.Pprof,
},
&cli.BoolFlag{
Name: "debug-zpages",
Usage: "Enable zpages debugging",
EnvVar: "REVA_DEBUG_ZPAGES",
Destination: &cfg.Debug.Zpages,
},
// REVA
&cli.StringFlag{
Name: "jwt-secret",
Value: "Pive-Fumkiu4",
Usage: "Shared jwt secret for reva service communication",
EnvVar: "REVA_JWT_SECRET",
Destination: &cfg.Reva.JWTSecret,
},
// Users
&cli.StringFlag{
Name: "users-driver",
Value: "demo",
Usage: "user driver: 'demo', 'json' or 'ldap'",
EnvVar: "REVA_USERS_DRIVER",
Destination: &cfg.Reva.Users.Driver,
},
&cli.StringFlag{
Name: "users-json",
Value: "",
Usage: "Path to users.json file",
EnvVar: "REVA_USERS_JSON",
Destination: &cfg.Reva.Users.JSON,
},
// LDAP
&cli.StringFlag{
Name: "ldap-hostname",
Value: "localhost",
Usage: "LDAP hostname",
EnvVar: "REVA_LDAP_HOSTNAME",
Destination: &cfg.Reva.LDAP.Hostname,
},
&cli.IntFlag{
Name: "ldap-port",
Value: 389,
Usage: "LDAP port",
EnvVar: "REVA_LDAP_PORT",
Destination: &cfg.Reva.LDAP.Port,
},
&cli.StringFlag{
Name: "ldap-base-dn",
Value: "dc=owncloud,dc=com",
Usage: "LDAP basedn",
EnvVar: "REVA_LDAP_BASE_DN",
Destination: &cfg.Reva.LDAP.BaseDN,
},
&cli.StringFlag{
Name: "ldap-userfilter",
Value: "(objectclass=posixAccount)",
Usage: "LDAP userfilter",
EnvVar: "REVA_LDAP_USERFILTER",
Destination: &cfg.Reva.LDAP.UserFilter,
},
&cli.StringFlag{
Name: "ldap-groupfilter",
Value: "(objectclass=posixGroup)",
Usage: "LDAP groupfilter",
EnvVar: "REVA_LDAP_GROUPFILTER",
Destination: &cfg.Reva.LDAP.GroupFilter,
},
&cli.StringFlag{
Name: "ldap-bind-dn",
Value: "cn=admin,dc=owncloud,dc=com",
Usage: "LDAP bind dn",
EnvVar: "REVA_LDAP_BIND_DN",
Destination: &cfg.Reva.LDAP.BindDN,
},
&cli.StringFlag{
Name: "ldap-bind-password",
Value: "admin",
Usage: "LDAP bind password",
EnvVar: "REVA_LDAP_BIND_PASSWORD",
Destination: &cfg.Reva.LDAP.BindPassword,
},
// ldap dn is always the dn
&cli.StringFlag{
Name: "ldap-schema-uid",
Value: "uid",
Usage: "LDAP schema uid",
EnvVar: "REVA_LDAP_SCHEMA_UID",
Destination: &cfg.Reva.LDAP.Schema.UID,
},
&cli.StringFlag{
Name: "ldap-schema-mail",
Value: "mail",
Usage: "LDAP schema mail",
EnvVar: "REVA_LDAP_SCHEMA_Mail",
Destination: &cfg.Reva.LDAP.Schema.Mail,
},
&cli.StringFlag{
Name: "ldap-schema-displayName",
Value: "displayName",
Usage: "LDAP schema displayName",
EnvVar: "REVA_LDAP_SCHEMA_DISPLAYNAME",
Destination: &cfg.Reva.LDAP.Schema.DisplayName,
},
&cli.StringFlag{
Name: "ldap-schema-cn",
Value: "cn",
Usage: "LDAP schema cn",
EnvVar: "REVA_LDAP_SCHEMA_CN",
Destination: &cfg.Reva.LDAP.Schema.CN,
},
// Services
// AuthBasic
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva auth-basic service, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_AUTH_BASIC_NETWORK",
Destination: &cfg.Reva.AuthBasic.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "grpc",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVar: "REVA_AUTH_BASIC_PROTOCOL",
Destination: &cfg.Reva.AuthBasic.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9146",
Usage: "Address to bind reva service",
EnvVar: "REVA_AUTH_BASIC_ADDR",
Destination: &cfg.Reva.AuthBasic.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9146",
Usage: "URL to use for the reva service",
EnvVar: "REVA_AUTH_BASIC_URL",
Destination: &cfg.Reva.AuthBasic.URL,
},
&cli.StringFlag{
Name: "services",
Value: "authprovider",
Usage: "comma separated list of services to include",
EnvVar: "REVA_AUTH_BASIC_SERVICES",
Destination: &cfg.Reva.AuthBasic.Services,
},
}
}

148
pkg/flagset/authbearer.go Normal file
View File

@@ -0,0 +1,148 @@
package flagset
import (
"github.com/micro/cli"
"github.com/owncloud/ocis-reva/pkg/config"
)
// AuthBearerWithConfig applies cfg to the root flagset
func AuthBearerWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "tracing-enabled",
Usage: "Enable sending traces",
EnvVar: "REVA_TRACING_ENABLED",
Destination: &cfg.Tracing.Enabled,
},
&cli.StringFlag{
Name: "tracing-type",
Value: "jaeger",
Usage: "Tracing backend type",
EnvVar: "REVA_TRACING_TYPE",
Destination: &cfg.Tracing.Type,
},
&cli.StringFlag{
Name: "tracing-endpoint",
Value: "",
Usage: "Endpoint for the agent",
EnvVar: "REVA_TRACING_ENDPOINT",
Destination: &cfg.Tracing.Endpoint,
},
&cli.StringFlag{
Name: "tracing-collector",
Value: "",
Usage: "Endpoint for the collector",
EnvVar: "REVA_TRACING_COLLECTOR",
Destination: &cfg.Tracing.Collector,
},
&cli.StringFlag{
Name: "tracing-service",
Value: "reva",
Usage: "Service name for tracing",
EnvVar: "REVA_TRACING_SERVICE",
Destination: &cfg.Tracing.Service,
},
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9149",
Usage: "Address to bind debug server",
EnvVar: "REVA_AUTH_BEARER_DEBUG_ADDR",
Destination: &cfg.Reva.AuthBearer.DebugAddr,
},
&cli.StringFlag{
Name: "debug-token",
Value: "",
Usage: "Token to grant metrics access",
EnvVar: "REVA_DEBUG_TOKEN",
Destination: &cfg.Debug.Token,
},
&cli.BoolFlag{
Name: "debug-pprof",
Usage: "Enable pprof debugging",
EnvVar: "REVA_DEBUG_PPROF",
Destination: &cfg.Debug.Pprof,
},
&cli.BoolFlag{
Name: "debug-zpages",
Usage: "Enable zpages debugging",
EnvVar: "REVA_DEBUG_ZPAGES",
Destination: &cfg.Debug.Zpages,
},
// REVA
&cli.StringFlag{
Name: "jwt-secret",
Value: "Pive-Fumkiu4",
Usage: "Shared jwt secret for reva service communication",
EnvVar: "REVA_JWT_SECRET",
Destination: &cfg.Reva.JWTSecret,
},
// OIDC
&cli.StringFlag{
Name: "oidc-issuer",
Value: "http://localhost:9140",
Usage: "OIDC issuer",
EnvVar: "REVA_OIDC_ISSUER",
Destination: &cfg.Reva.OIDC.Issuer,
},
&cli.BoolFlag{
Name: "oidc-insecure",
Usage: "OIDC allow insecure communication",
EnvVar: "REVA_OIDC_INSECURE",
Destination: &cfg.Reva.OIDC.Insecure,
},
&cli.StringFlag{
Name: "oidc-id-claim",
Value: "sub", // sub is stable and defined as unique. the user manager needs to take care of the sub to user metadata lookup
Usage: "OIDC id claim",
EnvVar: "REVA_OIDC_ID_CLAIM",
Destination: &cfg.Reva.OIDC.IDClaim,
},
// Services
// AuthBearer
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_AUTH_BEARER_NETWORK",
Destination: &cfg.Reva.AuthBearer.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "grpc",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVar: "REVA_AUTH_BEARER_PROTOCOL",
Destination: &cfg.Reva.AuthBearer.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9148",
Usage: "Address to bind reva service",
EnvVar: "REVA_AUTH_BEARER_ADDR",
Destination: &cfg.Reva.AuthBearer.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9148",
Usage: "URL to use for the reva service",
EnvVar: "REVA_AUTH_BEARER_URL",
Destination: &cfg.Reva.AuthBearer.URL,
},
&cli.StringFlag{
Name: "services",
Value: "authprovider", // TODO preferences
Usage: "comma separated list of services to include",
EnvVar: "REVA_AUTH_BEARER_SERVICES",
Destination: &cfg.Reva.AuthBearer.Services,
},
}
}

View File

@@ -1,193 +0,0 @@
package flagset
import (
"github.com/micro/cli"
"github.com/owncloud/ocis-reva/pkg/config"
)
// RootWithConfig applies cfg to the root flagset
func RootWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "config-file",
Value: "",
Usage: "Path to config file",
EnvVar: "REVA_CONFIG_FILE",
Destination: &cfg.File,
},
&cli.StringFlag{
Name: "log-level",
Value: "info",
Usage: "Set logging level",
EnvVar: "REVA_LOG_LEVEL",
Destination: &cfg.Log.Level,
},
&cli.BoolTFlag{
Name: "log-pretty",
Usage: "Enable pretty logging",
EnvVar: "REVA_LOG_PRETTY",
Destination: &cfg.Log.Pretty,
},
&cli.BoolTFlag{
Name: "log-color",
Usage: "Enable colored logging",
EnvVar: "REVA_LOG_COLOR",
Destination: &cfg.Log.Color,
},
}
}
// HealthWithConfig applies cfg to the root flagset
func HealthWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9109",
Usage: "Address to debug endpoint",
EnvVar: "REVA_DEBUG_ADDR",
Destination: &cfg.Debug.Addr,
},
}
}
// ServerWithConfig applies cfg to the root flagset
func ServerWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "tracing-enabled",
Usage: "Enable sending traces",
EnvVar: "REVA_TRACING_ENABLED",
Destination: &cfg.Tracing.Enabled,
},
&cli.StringFlag{
Name: "tracing-type",
Value: "jaeger",
Usage: "Tracing backend type",
EnvVar: "REVA_TRACING_TYPE",
Destination: &cfg.Tracing.Type,
},
&cli.StringFlag{
Name: "tracing-endpoint",
Value: "",
Usage: "Endpoint for the agent",
EnvVar: "REVA_TRACING_ENDPOINT",
Destination: &cfg.Tracing.Endpoint,
},
&cli.StringFlag{
Name: "tracing-collector",
Value: "",
Usage: "Endpoint for the collector",
EnvVar: "REVA_TRACING_COLLECTOR",
Destination: &cfg.Tracing.Collector,
},
&cli.StringFlag{
Name: "tracing-service",
Value: "reva",
Usage: "Service name for tracing",
EnvVar: "REVA_TRACING_SERVICE",
Destination: &cfg.Tracing.Service,
},
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9139",
Usage: "Address to bind debug server",
EnvVar: "REVA_DEBUG_ADDR",
Destination: &cfg.Debug.Addr,
},
&cli.StringFlag{
Name: "debug-token",
Value: "",
Usage: "Token to grant metrics access",
EnvVar: "REVA_DEBUG_TOKEN",
Destination: &cfg.Debug.Token,
},
&cli.BoolFlag{
Name: "debug-pprof",
Usage: "Enable pprof debugging",
EnvVar: "REVA_DEBUG_PPROF",
Destination: &cfg.Debug.Pprof,
},
&cli.BoolFlag{
Name: "debug-zpages",
Usage: "Enable zpages debugging",
EnvVar: "REVA_DEBUG_ZPAGES",
Destination: &cfg.Debug.Zpages,
},
&cli.StringFlag{
Name: "reva-http-network",
Value: "tcp",
Usage: "Network to use for the reva http server, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_HTTP_NETWORK",
Destination: &cfg.Reva.HTTP.Network,
},
&cli.StringFlag{
Name: "reva-http-addr",
Value: "0.0.0.0:9135",
Usage: "Address to bind http port of reva server",
EnvVar: "REVA_HTTP_ADDR",
Destination: &cfg.Reva.HTTP.Addr,
},
&cli.StringFlag{
Name: "reva-http-root",
Value: "/",
Usage: "Root path of reva server",
EnvVar: "REVA__HTTP_ROOT",
Destination: &cfg.Reva.HTTP.Root,
},
&cli.StringFlag{
Name: "reva-grpc-network",
Value: "tcp",
Usage: "Network to use for the reva grpc server, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_GRPC_NETWORK",
Destination: &cfg.Reva.GRPC.Network,
},
&cli.StringFlag{
Name: "reva-grpc-addr",
Value: "0.0.0.0:9136",
Usage: "Address to bind grpc port of reva server",
EnvVar: "REVA_GRPC_ADDR",
Destination: &cfg.Reva.GRPC.Addr,
},
&cli.StringFlag{
Name: "reva-max-cpus",
Value: "2",
Usage: "Max number of cpus for reva server",
EnvVar: "REVA_MAX_CPUS",
Destination: &cfg.Reva.MaxCPUs,
},
&cli.StringFlag{
Name: "reva-log-level",
Value: "info",
Usage: "Log level for reva server",
EnvVar: "REVA_LOG_LEVEL",
Destination: &cfg.Reva.LogLevel,
},
&cli.StringFlag{
Name: "reva-jwt-secret",
Value: "Pive-Fumkiu4",
Usage: "Shared jwt secret for reva service communication",
EnvVar: "REVA_JWT_SECRET",
Destination: &cfg.Reva.JWTSecret,
},
&cli.StringFlag{
Name: "reva-authprovider-provider",
Value: "",
Usage: "URL of the OpenID Connect Provider",
EnvVar: "REVA_AUTHPROVIDER_PROVIDER",
Destination: &cfg.AuthProvider.Provider,
},
&cli.BoolFlag{
Name: "reva-authprovider-insecure",
Usage: "Allow insecure certificates",
EnvVar: "REVA_AUTHPROVIDER_INSECURE",
Destination: &cfg.AuthProvider.Insecure,
},
&cli.StringFlag{
Name: "asset-path",
Value: "",
Usage: "Path to custom assets",
EnvVar: "REVA_ASSET_PATH",
Destination: &cfg.Asset.Path,
},
}
}

167
pkg/flagset/frontend.go Normal file
View File

@@ -0,0 +1,167 @@
package flagset
import (
"github.com/micro/cli"
"github.com/owncloud/ocis-reva/pkg/config"
)
// FrontendWithConfig applies cfg to the root flagset
func FrontendWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "tracing-enabled",
Usage: "Enable sending traces",
EnvVar: "REVA_TRACING_ENABLED",
Destination: &cfg.Tracing.Enabled,
},
&cli.StringFlag{
Name: "tracing-type",
Value: "jaeger",
Usage: "Tracing backend type",
EnvVar: "REVA_TRACING_TYPE",
Destination: &cfg.Tracing.Type,
},
&cli.StringFlag{
Name: "tracing-endpoint",
Value: "",
Usage: "Endpoint for the agent",
EnvVar: "REVA_TRACING_ENDPOINT",
Destination: &cfg.Tracing.Endpoint,
},
&cli.StringFlag{
Name: "tracing-collector",
Value: "",
Usage: "Endpoint for the collector",
EnvVar: "REVA_TRACING_COLLECTOR",
Destination: &cfg.Tracing.Collector,
},
&cli.StringFlag{
Name: "tracing-service",
Value: "reva",
Usage: "Service name for tracing",
EnvVar: "REVA_TRACING_SERVICE",
Destination: &cfg.Tracing.Service,
},
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9141",
Usage: "Address to bind debug server",
EnvVar: "REVA_FRONTEND_DEBUG_ADDR",
Destination: &cfg.Reva.Frontend.DebugAddr,
},
&cli.StringFlag{
Name: "debug-token",
Value: "",
Usage: "Token to grant metrics access",
EnvVar: "REVA_DEBUG_TOKEN",
Destination: &cfg.Debug.Token,
},
&cli.BoolFlag{
Name: "debug-pprof",
Usage: "Enable pprof debugging",
EnvVar: "REVA_DEBUG_PPROF",
Destination: &cfg.Debug.Pprof,
},
&cli.BoolFlag{
Name: "debug-zpages",
Usage: "Enable zpages debugging",
EnvVar: "REVA_DEBUG_ZPAGES",
Destination: &cfg.Debug.Zpages,
},
// REVA
&cli.StringFlag{
Name: "jwt-secret",
Value: "Pive-Fumkiu4",
Usage: "Shared jwt secret for reva service communication",
EnvVar: "REVA_JWT_SECRET",
Destination: &cfg.Reva.JWTSecret,
},
&cli.StringFlag{
Name: "transfer-secret",
Value: "replace-me-with-a-transfer-secret",
Usage: "Transfer secret for datagateway",
EnvVar: "REVA_TRANSFER_SECRET",
Destination: &cfg.Reva.TransferSecret,
},
// OIDC
&cli.StringFlag{
Name: "oidc-issuer",
Value: "http://localhost:9140",
Usage: "OIDC issuer",
EnvVar: "REVA_OIDC_ISSUER",
Destination: &cfg.Reva.OIDC.Issuer,
},
&cli.BoolFlag{
Name: "oidc-insecure",
Usage: "OIDC allow insecure communication",
EnvVar: "REVA_OIDC_INSECURE",
Destination: &cfg.Reva.OIDC.Insecure,
},
&cli.StringFlag{
Name: "oidc-id-claim",
Value: "sub", // sub is stable and defined as unique. the user manager needs to take care of the sub to user metadata lookup
Usage: "OIDC id claim",
EnvVar: "REVA_OIDC_ID_CLAIM",
Destination: &cfg.Reva.OIDC.IDClaim,
},
// TODO allow configuring clients
// Services
// Frontend
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_FRONTEND_NETWORK",
Destination: &cfg.Reva.Frontend.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "http",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVar: "REVA_FRONTEND_PROTOCOL",
Destination: &cfg.Reva.Frontend.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9140",
Usage: "Address to bind reva service",
EnvVar: "REVA_FRONTEND_ADDR",
Destination: &cfg.Reva.Frontend.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9140",
Usage: "URL to use for the reva service",
EnvVar: "REVA_FRONTEND_URL",
Destination: &cfg.Reva.Frontend.URL,
},
&cli.StringFlag{
Name: "services",
Value: "datagateway,wellknown,oidcprovider,ocdav,ocs",
Usage: "comma separated list of services to include",
EnvVar: "REVA_FRONTEND_SERVICES",
Destination: &cfg.Reva.Frontend.Services,
},
// Gateway
&cli.StringFlag{
Name: "gateway-url",
Value: "localhost:9142",
Usage: "URL to use for the reva gateway service",
EnvVar: "REVA_GATEWAY_URL",
Destination: &cfg.Reva.Gateway.URL,
},
}
}

270
pkg/flagset/gateway.go Normal file
View File

@@ -0,0 +1,270 @@
package flagset
import (
"github.com/micro/cli"
"github.com/owncloud/ocis-reva/pkg/config"
)
// GatewayWithConfig applies cfg to the root flagset
func GatewayWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "tracing-enabled",
Usage: "Enable sending traces",
EnvVar: "REVA_TRACING_ENABLED",
Destination: &cfg.Tracing.Enabled,
},
&cli.StringFlag{
Name: "tracing-type",
Value: "jaeger",
Usage: "Tracing backend type",
EnvVar: "REVA_TRACING_TYPE",
Destination: &cfg.Tracing.Type,
},
&cli.StringFlag{
Name: "tracing-endpoint",
Value: "",
Usage: "Endpoint for the agent",
EnvVar: "REVA_TRACING_ENDPOINT",
Destination: &cfg.Tracing.Endpoint,
},
&cli.StringFlag{
Name: "tracing-collector",
Value: "",
Usage: "Endpoint for the collector",
EnvVar: "REVA_TRACING_COLLECTOR",
Destination: &cfg.Tracing.Collector,
},
&cli.StringFlag{
Name: "tracing-service",
Value: "reva",
Usage: "Service name for tracing",
EnvVar: "REVA_TRACING_SERVICE",
Destination: &cfg.Tracing.Service,
},
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9143",
Usage: "Address to bind debug server",
EnvVar: "REVA_GATEWAY_DEBUG_ADDR",
Destination: &cfg.Reva.Gateway.DebugAddr,
},
&cli.StringFlag{
Name: "debug-token",
Value: "",
Usage: "Token to grant metrics access",
EnvVar: "REVA_DEBUG_TOKEN",
Destination: &cfg.Debug.Token,
},
&cli.BoolFlag{
Name: "debug-pprof",
Usage: "Enable pprof debugging",
EnvVar: "REVA_DEBUG_PPROF",
Destination: &cfg.Debug.Pprof,
},
&cli.BoolFlag{
Name: "debug-zpages",
Usage: "Enable zpages debugging",
EnvVar: "REVA_DEBUG_ZPAGES",
Destination: &cfg.Debug.Zpages,
},
// REVA
&cli.StringFlag{
Name: "jwt-secret",
Value: "Pive-Fumkiu4",
Usage: "Shared jwt secret for reva service communication",
EnvVar: "REVA_JWT_SECRET",
Destination: &cfg.Reva.JWTSecret,
},
&cli.StringFlag{
Name: "transfer-secret",
Value: "replace-me-with-a-transfer-secret",
Usage: "Transfer secret for datagateway",
EnvVar: "REVA_TRANSFER_SECRET",
Destination: &cfg.Reva.TransferSecret,
},
&cli.IntFlag{
Name: "transfer-expires",
Value: 10,
Usage: "Transfer secret for datagateway",
EnvVar: "REVA_TRANSFER_EXPIRES",
Destination: &cfg.Reva.TransferExpires,
},
// TODO allow configuring clients
// Services
// Gateway
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_GATEWAY_NETWORK",
Destination: &cfg.Reva.Gateway.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "grpc",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVar: "REVA_GATEWAY_PROTOCOL",
Destination: &cfg.Reva.Gateway.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9142",
Usage: "Address to bind reva service",
EnvVar: "REVA_GATEWAY_ADDR",
Destination: &cfg.Reva.Gateway.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9142",
Usage: "URL to use for the reva service",
EnvVar: "REVA_GATEWAY_URL",
Destination: &cfg.Reva.Gateway.URL,
},
&cli.StringFlag{
Name: "services",
Value: "gateway,authregistry,storageregistry", // TODO appregistry
Usage: "comma separated list of services to include",
EnvVar: "REVA_GATEWAY_SERVICES",
Destination: &cfg.Reva.Gateway.Services,
},
// TODO should defaults to true. reverse logic to 'disable-share-commit'?
&cli.BoolFlag{
Name: "commit-share-to-storage-grant",
Usage: "Commit shares to the share manager as well as as a grant to the storage",
EnvVar: "REVA_GATEWAY_COMMIT_SHARE_TO_STRORAGE_GRANT",
Destination: &cfg.Reva.Gateway.CommitShareToStorageGrant,
},
// other services
// storage registry
&cli.StringFlag{
Name: "frontend-url",
Value: "localhost:9140",
Usage: "URL to use for the reva service",
EnvVar: "REVA_FRONTEND_URL",
Destination: &cfg.Reva.Frontend.URL,
},
&cli.StringFlag{
Name: "users-url",
Value: "localhost:9144",
Usage: "URL to use for the reva service",
EnvVar: "REVA_USERS_URL",
Destination: &cfg.Reva.Users.URL,
},
&cli.StringFlag{
Name: "auth-basic-url",
Value: "localhost:9146",
Usage: "URL to use for the reva service",
EnvVar: "REVA_AUTH_BASIC_URL",
Destination: &cfg.Reva.AuthBasic.URL,
},
&cli.StringFlag{
Name: "auth-bearer-url",
Value: "localhost:9148",
Usage: "URL to use for the reva service",
EnvVar: "REVA_AUTH_BEARER_URL",
Destination: &cfg.Reva.AuthBearer.URL,
},
&cli.StringFlag{
Name: "sharing-url",
Value: "localhost:9150",
Usage: "URL to use for the reva service",
EnvVar: "REVA_SHARING_URL",
Destination: &cfg.Reva.Sharing.URL,
},
&cli.StringFlag{
Name: "storage-root-url",
Value: "localhost:9152",
Usage: "URL to use for the reva service",
EnvVar: "REVA_STORAGE_ROOT_URL",
Destination: &cfg.Reva.StorageRoot.URL,
},
&cli.StringFlag{
Name: "storage-root-mount-path",
Value: "/",
Usage: "mount path",
EnvVar: "REVA_STORAGE_ROOT_MOUNT_PATH",
Destination: &cfg.Reva.StorageRoot.MountPath,
},
&cli.StringFlag{
Name: "storage-root-mount-id",
Value: "123e4567-e89b-12d3-a456-426655440001",
Usage: "mount id",
EnvVar: "REVA_STORAGE_ROOT_MOUNT_ID",
Destination: &cfg.Reva.StorageRoot.MountID,
},
&cli.StringFlag{
Name: "storage-home-url",
Value: "localhost:9154",
Usage: "URL to use for the reva service",
EnvVar: "REVA_STORAGE_HOME_URL",
Destination: &cfg.Reva.StorageHome.URL,
},
&cli.StringFlag{
Name: "storage-home-mount-path",
Value: "/home",
Usage: "mount path",
EnvVar: "REVA_STORAGE_HOME_MOUNT_PATH",
Destination: &cfg.Reva.StorageHome.MountPath,
},
&cli.StringFlag{
Name: "storage-home-mount-id",
Value: "123e4567-e89b-12d3-a456-426655440000",
Usage: "mount id",
EnvVar: "REVA_STORAGE_HOME_MOUNT_ID",
Destination: &cfg.Reva.StorageHome.MountID,
},
&cli.StringFlag{
Name: "storage-home-data-url",
Value: "localhost:9156",
Usage: "URL to use for the reva service",
EnvVar: "REVA_STORAGE_HOME_DATA_URL",
Destination: &cfg.Reva.StorageHomeData.URL,
},
&cli.StringFlag{
Name: "storage-oc-url",
Value: "localhost:9162",
Usage: "URL to use for the reva service",
EnvVar: "REVA_STORAGE_OC_URL",
Destination: &cfg.Reva.StorageOC.URL,
},
&cli.StringFlag{
Name: "storage-oc-mount-path",
Value: "/oc",
Usage: "mount path",
EnvVar: "REVA_STORAGE_OC_MOUNT_PATH",
Destination: &cfg.Reva.StorageOC.MountPath,
},
&cli.StringFlag{
Name: "storage-oc-mount-id",
Value: "123e4567-e89b-12d3-a456-426655440000",
Usage: "mount id",
EnvVar: "REVA_STORAGE_OC_MOUNT_ID",
Destination: &cfg.Reva.StorageOC.MountID,
},
&cli.StringFlag{
Name: "storage-oc-data-url",
Value: "localhost:9164",
Usage: "URL to use for the reva service",
EnvVar: "REVA_STORAGE_OC_DATA_URL",
Destination: &cfg.Reva.StorageOCData.URL,
},
}
}

19
pkg/flagset/health.go Normal file
View File

@@ -0,0 +1,19 @@
package flagset
import (
"github.com/micro/cli"
"github.com/owncloud/ocis-reva/pkg/config"
)
// HealthWithConfig applies cfg to the health flagset
func HealthWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9109",
Usage: "Address to debug endpoint",
EnvVar: "REVA_DEBUG_ADDR",
Destination: &cfg.Debug.Addr,
},
}
}

38
pkg/flagset/root.go Normal file
View File

@@ -0,0 +1,38 @@
package flagset
import (
"github.com/micro/cli"
"github.com/owncloud/ocis-reva/pkg/config"
)
// RootWithConfig applies cfg to the root flagset
func RootWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "config-file",
Value: "",
Usage: "Path to config file",
EnvVar: "REVA_CONFIG_FILE",
Destination: &cfg.File,
},
&cli.StringFlag{
Name: "log-level",
Value: "info",
Usage: "Set logging level",
EnvVar: "REVA_LOG_LEVEL",
Destination: &cfg.Log.Level,
},
&cli.BoolTFlag{
Name: "log-pretty",
Usage: "Enable pretty logging",
EnvVar: "REVA_LOG_PRETTY",
Destination: &cfg.Log.Pretty,
},
&cli.BoolTFlag{
Name: "log-color",
Usage: "Enable colored logging",
EnvVar: "REVA_LOG_COLOR",
Destination: &cfg.Log.Color,
},
}
}

507
pkg/flagset/server.go Normal file
View File

@@ -0,0 +1,507 @@
package flagset
/* TODO move this into dedicated flagsets, along with storage commands
import (
"github.com/micro/cli"
"github.com/owncloud/ocis-reva/pkg/config"
)
// ServerWithConfig applies cfg to the root flagset
func ServerWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
// debug ports are the odd ports
&cli.StringFlag{
Name: "storage-eos-debug-addr",
Value: "0.0.0.0:9159",
Usage: "Address to bind storage eos debug server",
EnvVar: "REVA_STORAGE_EOS_DEBUG_ADDR",
Destination: &cfg.Reva.StorageEOS.DebugAddr,
},
&cli.StringFlag{
Name: "storage-eos-data-debug-addr",
Value: "0.0.0.0:9161",
Usage: "Address to bind storage eos data debug server",
EnvVar: "REVA_STORAGE_HOME_DATA_DEBUG_ADDR",
Destination: &cfg.Reva.StorageEOSData.DebugAddr,
},
&cli.StringFlag{
Name: "storage-s3-debug-addr",
Value: "0.0.0.0:9167",
Usage: "Address to bind storage s3 debug server",
EnvVar: "REVA_STORAGE_S3_DEBUG_ADDR",
Destination: &cfg.Reva.StorageS3.DebugAddr,
},
&cli.StringFlag{
Name: "storage-s3-data-debug-addr",
Value: "0.0.0.0:9169",
Usage: "Address to bind storage s3 data debug server",
EnvVar: "REVA_STORAGE_S3_DATA_DEBUG_ADDR",
Destination: &cfg.Reva.StorageS3Data.DebugAddr,
},
&cli.StringFlag{
Name: "storage-custom-debug-addr",
Value: "0.0.0.0:9171",
Usage: "Address to bind storage custom debug server",
EnvVar: "REVA_STORAGE_CUSTOM_DEBUG_ADDR",
Destination: &cfg.Reva.StorageCustom.DebugAddr,
},
&cli.StringFlag{
Name: "storage-custom-data-debug-addr",
Value: "0.0.0.0:9173",
Usage: "Address to bind storage custom data debug server",
EnvVar: "REVA_STORAGE_CUSTOM_DATA_DEBUG_ADDR",
Destination: &cfg.Reva.StorageCustomData.DebugAddr,
},
// Services
// Storage eos
&cli.StringFlag{
Name: "storage-eos-network",
Value: "tcp",
Usage: "Network to use for the reva storage-eos service, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_STORAGE_EOS_NETWORK",
Destination: &cfg.Reva.StorageEOS.Network,
},
&cli.StringFlag{
Name: "storage-eos-protocol",
Value: "grpc",
Usage: "protocol for reva storage-eos service, can be 'http' or 'grpc'",
EnvVar: "REVA_STORAGE_EOS_PROTOCOL",
Destination: &cfg.Reva.StorageEOS.Protocol,
},
&cli.StringFlag{
Name: "storage-eos-addr",
Value: "0.0.0.0:9158",
Usage: "Address to bind reva storage-eos service",
EnvVar: "REVA_STORAGE_EOS_ADDR",
Destination: &cfg.Reva.StorageEOS.Addr,
},
&cli.StringFlag{
Name: "storage-eos-url",
Value: "localhost:9158",
Usage: "URL to use for the reva storage-eos service",
EnvVar: "REVA_STORAGE_EOS_URL",
Destination: &cfg.Reva.StorageEOS.URL,
},
&cli.StringFlag{
Name: "storage-eos-services",
Value: "storageprovider",
Usage: "comma separated list of services to include in the storage-eos service",
EnvVar: "REVA_STORAGE_EOS_SERVICES",
Destination: &cfg.Reva.StorageEOS.Services,
},
&cli.StringFlag{
Name: "storage-eos-driver",
Value: "local",
Usage: "eos storage driver",
EnvVar: "REVA_STORAGE_EOS_DRIVER",
Destination: &cfg.Reva.StorageEOS.Driver,
},
&cli.StringFlag{
Name: "storage-eos-path-wrapper",
Value: "",
Usage: "eos storage path wrapper",
EnvVar: "REVA_STORAGE_EOS_PATH_WRAPPER",
Destination: &cfg.Reva.StorageEOS.PathWrapper,
},
&cli.StringFlag{
Name: "storage-eos-path-wrapper-context-prefix",
Value: "",
Usage: "eos storage path wrapper context prefix",
EnvVar: "REVA_STORAGE_EOS_PATH_WRAPPER_CONTEXT_PREFIX",
Destination: &cfg.Reva.StorageEOS.PathWrapperContext.Prefix,
},
&cli.StringFlag{
Name: "storage-eos-mount-path",
Value: "/eos",
Usage: "eos storage mount path",
EnvVar: "REVA_STORAGE_EOS_MOUNT_PATH",
Destination: &cfg.Reva.StorageEOS.MountPath,
},
&cli.StringFlag{
Name: "storage-eos-mount-id",
Value: "",
Usage: "eos storage mount id",
EnvVar: "REVA_STORAGE_EOS_MOUNT_ID",
Destination: &cfg.Reva.StorageEOS.MountID,
},
&cli.BoolFlag{
Name: "storage-eos-expose-data-server",
Usage: "eos storage exposes a dedicated data server",
EnvVar: "REVA_STORAGE_EOS_EXPOSE_DATA_SERVER",
Destination: &cfg.Reva.StorageEOS.ExposeDataServer,
},
&cli.StringFlag{
Name: "storage-eos-data-server-url",
Value: "",
Usage: "eos storage data server url",
EnvVar: "REVA_STORAGE_EOS_DATA_SERVER_URL",
Destination: &cfg.Reva.StorageEOS.DataServerURL,
},
// Storage eos data
&cli.StringFlag{
Name: "storage-eos-data-network",
Value: "tcp",
Usage: "Network to use for the reva storage-eos data service, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_STORAGE_EOS_DATA_NETWORK",
Destination: &cfg.Reva.StorageEOSData.Network,
},
&cli.StringFlag{
Name: "storage-eos-data-protocol",
Value: "http",
Usage: "protocol for reva storage-eos data service, can be 'http' or 'grpc'",
EnvVar: "REVA_STORAGE_EOS_DATA_PROTOCOL",
Destination: &cfg.Reva.StorageEOSData.Protocol,
},
&cli.StringFlag{
Name: "storage-eos-data-addr",
Value: "0.0.0.0:9160",
Usage: "Address to bind reva storage-eos data service",
EnvVar: "REVA_STORAGE_EOS_DATA_ADDR",
Destination: &cfg.Reva.StorageEOSData.Addr,
},
&cli.StringFlag{
Name: "storage-eos-data-url",
Value: "localhost:9160",
Usage: "URL to use for the reva storage-eos data service",
EnvVar: "REVA_STORAGE_EOS_DATA_URL",
Destination: &cfg.Reva.StorageEOSData.URL,
},
&cli.StringFlag{
Name: "storage-eos-data-services",
Value: "dataprovider",
Usage: "comma separated list of services to include in the storage-eos data service",
EnvVar: "REVA_STORAGE_EOS_DATA_SERVICES",
Destination: &cfg.Reva.StorageEOSData.Services,
},
&cli.StringFlag{
Name: "storage-eos-data-driver",
Value: "eos",
Usage: "eos data storage driver",
EnvVar: "REVA_STORAGE_EOS_DATA_DRIVER",
Destination: &cfg.Reva.StorageEOSData.Driver,
},
&cli.StringFlag{
Name: "storage-eos-data-prefix",
Value: "data",
Usage: "prefix for the http endpoint, without leading slash",
EnvVar: "REVA_STORAGE_EOS_DATA_PREFIX",
Destination: &cfg.Reva.StorageEOSData.Prefix,
},
&cli.StringFlag{
Name: "storage-eos-data-temp-folder",
Value: "/var/tmp/",
Usage: "storage eos data temp folder",
EnvVar: "REVA_STORAGE_HOME_DATA_TEMP_FOLDER",
Destination: &cfg.Reva.StorageEOSData.TempFolder,
},
// Storage s3
&cli.StringFlag{
Name: "storage-s3-network",
Value: "tcp",
Usage: "Network to use for the reva storage-oc service, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_STORAGE_S3_NETWORK",
Destination: &cfg.Reva.StorageS3.Network,
},
&cli.StringFlag{
Name: "storage-s3-protocol",
Value: "grpc",
Usage: "protocol for reva storage-s3 service, can be 'http' or 'grpc'",
EnvVar: "REVA_STORAGE_S3_PROTOCOL",
Destination: &cfg.Reva.StorageS3.Protocol,
},
&cli.StringFlag{
Name: "storage-s3-addr",
Value: "0.0.0.0:9166",
Usage: "Address to bind reva storage-s3 service",
EnvVar: "REVA_STORAGE_S3_ADDR",
Destination: &cfg.Reva.StorageS3.Addr,
},
&cli.StringFlag{
Name: "storage-s3-url",
Value: "localhost:9166",
Usage: "URL to use for the reva storage-s3 service",
EnvVar: "REVA_STORAGE_S3_URL",
Destination: &cfg.Reva.StorageS3.URL,
},
&cli.StringFlag{
Name: "storage-s3-services",
Value: "storageprovider",
Usage: "comma separated list of services to include in the storage-s3 service",
EnvVar: "REVA_STORAGE_S3_SERVICES",
Destination: &cfg.Reva.StorageS3.Services,
},
&cli.StringFlag{
Name: "storage-s3-driver",
Value: "local",
Usage: "s3 storage driver",
EnvVar: "REVA_STORAGE_S3_DRIVER",
Destination: &cfg.Reva.StorageS3.Driver,
},
&cli.StringFlag{
Name: "storage-s3-path-wrapper",
Value: "",
Usage: "s3 storage path wrapper",
EnvVar: "REVA_STORAGE_S3_PATH_WRAPPER",
Destination: &cfg.Reva.StorageS3.PathWrapper,
},
&cli.StringFlag{
Name: "storage-s3-path-wrapper-context-prefix",
Value: "",
Usage: "s3 storage path wrapper context prefix",
EnvVar: "REVA_STORAGE_S3_PATH_WRAPPER_CONTEXT_PREFIX",
Destination: &cfg.Reva.StorageS3.PathWrapperContext.Prefix,
},
&cli.StringFlag{
Name: "storage-s3-mount-path",
Value: "",
Usage: "s3 storage mount path",
EnvVar: "REVA_STORAGE_S3_MOUNT_PATH",
Destination: &cfg.Reva.StorageS3.MountPath,
},
&cli.StringFlag{
Name: "storage-s3-mount-id",
Value: "",
Usage: "s3 storage mount id",
EnvVar: "REVA_STORAGE_S3_MOUNT_ID",
Destination: &cfg.Reva.StorageS3.MountID,
},
&cli.BoolFlag{
Name: "storage-s3-expose-data-server",
Usage: "s3 storage exposes a dedicated data server",
EnvVar: "REVA_STORAGE_S3_EXPOSE_DATA_SERVER",
Destination: &cfg.Reva.StorageS3.ExposeDataServer,
},
&cli.StringFlag{
Name: "storage-s3-data-server-url",
Value: "",
Usage: "s3 storage data server url",
EnvVar: "REVA_STORAGE_S3_DATA_SERVER_URL",
Destination: &cfg.Reva.StorageS3.DataServerURL,
},
// Storage s3 data
&cli.StringFlag{
Name: "storage-s3-data-network",
Value: "tcp",
Usage: "Network to use for the reva storage-s3 data service, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_STORAGE_S3_DATA_NETWORK",
Destination: &cfg.Reva.StorageS3Data.Network,
},
&cli.StringFlag{
Name: "storage-s3-data-protocol",
Value: "http",
Usage: "protocol for reva storage-s3 data service, can be 'http' or 'grpc'",
EnvVar: "REVA_STORAGE_S3_DATA_PROTOCOL",
Destination: &cfg.Reva.StorageS3Data.Protocol,
},
&cli.StringFlag{
Name: "storage-s3-data-addr",
Value: "0.0.0.0:9168",
Usage: "Address to bind reva storage-s3 data service",
EnvVar: "REVA_STORAGE_S3_DATA_ADDR",
Destination: &cfg.Reva.StorageS3Data.Addr,
},
&cli.StringFlag{
Name: "storage-s3-data-url",
Value: "localhost:9168",
Usage: "URL to use for the reva storage-s3 data service",
EnvVar: "REVA_STORAGE_S3_DATA_URL",
Destination: &cfg.Reva.StorageS3Data.URL,
},
&cli.StringFlag{
Name: "storage-s3-data-services",
Value: "dataprovider",
Usage: "comma separated list of services to include in the storage-s3 data service",
EnvVar: "REVA_STORAGE_S3_DATA_SERVICES",
Destination: &cfg.Reva.StorageS3Data.Services,
},
&cli.StringFlag{
Name: "storage-s3-data-driver",
Value: "s3",
Usage: "s3 data storage driver",
EnvVar: "REVA_STORAGE_S3_DATA_DRIVER",
Destination: &cfg.Reva.StorageS3Data.Driver,
},
&cli.StringFlag{
Name: "storage-s3-data-prefix",
Value: "data",
Usage: "prefix for the http endpoint, without leading slash",
EnvVar: "REVA_STORAGE_S3_DATA_PREFIX",
Destination: &cfg.Reva.StorageS3Data.Prefix,
},
&cli.StringFlag{
Name: "storage-s3-data-temp-folder",
Value: "/var/tmp/",
Usage: "storage s3 data temp folder",
EnvVar: "REVA_STORAGE_S3_DATA_TEMP_FOLDER",
Destination: &cfg.Reva.StorageS3Data.TempFolder,
},
// Storage custom
&cli.StringFlag{
Name: "storage-custom-network",
Value: "tcp",
Usage: "Network to use for the reva storage-custom service, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_STORAGE_CUSTOM_NETWORK",
Destination: &cfg.Reva.StorageCustom.Network,
},
&cli.StringFlag{
Name: "storage-custom-protocol",
Value: "grpc",
Usage: "protocol for reva storage-custom service, can be 'http' or 'grpc'",
EnvVar: "REVA_STORAGE_CUSTOM_PROTOCOL",
Destination: &cfg.Reva.StorageCustom.Protocol,
},
&cli.StringFlag{
Name: "storage-custom-addr",
Value: "0.0.0.0:9170",
Usage: "Address to bind reva storage-custom service",
EnvVar: "REVA_STORAGE_CUSTOM_ADDR",
Destination: &cfg.Reva.StorageCustom.Addr,
},
&cli.StringFlag{
Name: "storage-custom-url",
Value: "localhost:9170",
Usage: "URL to use for the reva storage-custom service",
EnvVar: "REVA_STORAGE_CUSTOM_URL",
Destination: &cfg.Reva.StorageCustom.URL,
},
&cli.StringFlag{
Name: "storage-custom-services",
Value: "storageprovider",
Usage: "comma separated list of services to include in the storage-custom service",
EnvVar: "REVA_STORAGE_CUSTOM_SERVICES",
Destination: &cfg.Reva.StorageCustom.Services,
},
&cli.StringFlag{
Name: "storage-custom-driver",
Value: "local",
Usage: "custom storage driver",
EnvVar: "REVA_STORAGE_CUSTOM_DRIVER",
Destination: &cfg.Reva.StorageCustom.Driver,
},
&cli.StringFlag{
Name: "storage-custom-path-wrapper",
Value: "",
Usage: "custom storage path wrapper",
EnvVar: "REVA_STORAGE_CUSTOM_PATH_WRAPPER",
Destination: &cfg.Reva.StorageCustom.PathWrapper,
},
&cli.StringFlag{
Name: "storage-custom-path-wrapper-context-prefix",
Value: "",
Usage: "custom storage path wrapper context prefix",
EnvVar: "REVA_STORAGE_CUSTOM_PATH_WRAPPER_CONTEXT_PREFIX",
Destination: &cfg.Reva.StorageCustom.PathWrapperContext.Prefix,
},
&cli.StringFlag{
Name: "storage-custom-mount-path",
Value: "",
Usage: "custom storage mount path",
EnvVar: "REVA_STORAGE_CUSTOM_MOUNT_PATH",
Destination: &cfg.Reva.StorageCustom.MountPath,
},
&cli.StringFlag{
Name: "storage-custom-mount-id",
Value: "",
Usage: "custom storage mount id",
EnvVar: "REVA_STORAGE_CUSTOM_MOUNT_ID",
Destination: &cfg.Reva.StorageCustom.MountID,
},
&cli.BoolFlag{
Name: "storage-custom-expose-data-server",
Usage: "custom storage exposes a dedicated data server",
EnvVar: "REVA_STORAGE_CUSTOM_EXPOSE_DATA_SERVER",
Destination: &cfg.Reva.StorageCustom.ExposeDataServer,
},
&cli.StringFlag{
Name: "storage-custom-data-server-url",
Value: "",
Usage: "custom storage data server url",
EnvVar: "REVA_STORAGE_CUSTOM_DATA_SERVER_URL",
Destination: &cfg.Reva.StorageCustom.DataServerURL,
},
// Storage custom data
&cli.StringFlag{
Name: "storage-custom-data-network",
Value: "tcp",
Usage: "Network to use for the reva storage-custom data service, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_STORAGE_CUSTOM_DATA_NETWORK",
Destination: &cfg.Reva.StorageCustomData.Network,
},
&cli.StringFlag{
Name: "storage-custom-data-protocol",
Value: "http",
Usage: "protocol for reva storage-custom data service, can be 'http' or 'grpc'",
EnvVar: "REVA_STORAGE_CUSTOM_DATA_PROTOCOL",
Destination: &cfg.Reva.StorageCustomData.Protocol,
},
&cli.StringFlag{
Name: "storage-custom-data-addr",
Value: "0.0.0.0:9172",
Usage: "Address to bind reva storage-custom data service",
EnvVar: "REVA_STORAGE_CUSTOM_DATA_ADDR",
Destination: &cfg.Reva.StorageCustomData.Addr,
},
&cli.StringFlag{
Name: "storage-custom-data-url",
Value: "localhost:9172",
Usage: "URL to use for the reva storage-custom data service",
EnvVar: "REVA_STORAGE_CUSTOM_DATA_URL",
Destination: &cfg.Reva.StorageCustomData.URL,
},
&cli.StringFlag{
Name: "storage-custom-data-services",
Value: "dataprovider",
Usage: "comma separated list of services to include in the storage-custom data service",
EnvVar: "REVA_STORAGE_CUSTOM_DATA_SERVICES",
Destination: &cfg.Reva.StorageCustomData.Services,
},
&cli.StringFlag{
Name: "storage-custom-data-driver",
Value: "",
Usage: "custom data storage driver",
EnvVar: "REVA_STORAGE_CUSTOM_DATA_DRIVER",
Destination: &cfg.Reva.StorageCustomData.Driver,
},
&cli.StringFlag{
Name: "storage-custom-data-prefix",
Value: "data",
Usage: "prefix for the http endpoint, without leading slash",
EnvVar: "REVA_STORAGE_S3_DATA_PREFIX",
Destination: &cfg.Reva.StorageCustomData.Prefix,
},
&cli.StringFlag{
Name: "storage-custom-data-temp-folder",
Value: "/var/tmp/",
Usage: "storage custom data temp folder",
EnvVar: "REVA_STORAGE_CUSTOM_DATA_TEMP_FOLDER",
Destination: &cfg.Reva.StorageCustomData.TempFolder,
},
&cli.StringFlag{
Name: "asset-path",
Value: "",
Usage: "Path to custom assets",
EnvVar: "REVA_ASSET_PATH",
Destination: &cfg.Asset.Path,
},
}
}
*/

125
pkg/flagset/sharing.go Normal file
View File

@@ -0,0 +1,125 @@
package flagset
import (
"github.com/micro/cli"
"github.com/owncloud/ocis-reva/pkg/config"
)
// SharingWithConfig applies cfg to the root flagset
func SharingWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "tracing-enabled",
Usage: "Enable sending traces",
EnvVar: "REVA_TRACING_ENABLED",
Destination: &cfg.Tracing.Enabled,
},
&cli.StringFlag{
Name: "tracing-type",
Value: "jaeger",
Usage: "Tracing backend type",
EnvVar: "REVA_TRACING_TYPE",
Destination: &cfg.Tracing.Type,
},
&cli.StringFlag{
Name: "tracing-endpoint",
Value: "",
Usage: "Endpoint for the agent",
EnvVar: "REVA_TRACING_ENDPOINT",
Destination: &cfg.Tracing.Endpoint,
},
&cli.StringFlag{
Name: "tracing-collector",
Value: "",
Usage: "Endpoint for the collector",
EnvVar: "REVA_TRACING_COLLECTOR",
Destination: &cfg.Tracing.Collector,
},
&cli.StringFlag{
Name: "tracing-service",
Value: "reva",
Usage: "Service name for tracing",
EnvVar: "REVA_TRACING_SERVICE",
Destination: &cfg.Tracing.Service,
},
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9151",
Usage: "Address to bind debug server",
EnvVar: "REVA_SHARING_DEBUG_ADDR",
Destination: &cfg.Reva.Sharing.DebugAddr,
},
&cli.StringFlag{
Name: "debug-token",
Value: "",
Usage: "Token to grant metrics access",
EnvVar: "REVA_DEBUG_TOKEN",
Destination: &cfg.Debug.Token,
},
&cli.BoolFlag{
Name: "debug-pprof",
Usage: "Enable pprof debugging",
EnvVar: "REVA_DEBUG_PPROF",
Destination: &cfg.Debug.Pprof,
},
&cli.BoolFlag{
Name: "debug-zpages",
Usage: "Enable zpages debugging",
EnvVar: "REVA_DEBUG_ZPAGES",
Destination: &cfg.Debug.Zpages,
},
// REVA
&cli.StringFlag{
Name: "jwt-secret",
Value: "Pive-Fumkiu4",
Usage: "Shared jwt secret for reva service communication",
EnvVar: "REVA_JWT_SECRET",
Destination: &cfg.Reva.JWTSecret,
},
// Services
// Sharing
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_SHARING_NETWORK",
Destination: &cfg.Reva.Sharing.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "grpc",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVar: "REVA_SHARING_PROTOCOL",
Destination: &cfg.Reva.Sharing.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9150",
Usage: "Address to bind reva service",
EnvVar: "REVA_SHARING_ADDR",
Destination: &cfg.Reva.Sharing.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9150",
Usage: "URL to use for the reva service",
EnvVar: "REVA_SHARING_URL",
Destination: &cfg.Reva.Sharing.URL,
},
&cli.StringFlag{
Name: "services",
Value: "usershareprovider,publicshareprovider", // TODO osmshareprovider
Usage: "comma separated list of services to include",
EnvVar: "REVA_SHARING_SERVICES",
Destination: &cfg.Reva.Sharing.Services,
},
}
}

288
pkg/flagset/storagehome.go Normal file
View File

@@ -0,0 +1,288 @@
package flagset
import (
"os"
"github.com/micro/cli"
"github.com/owncloud/ocis-reva/pkg/config"
)
// StorageHomeWithConfig applies cfg to the root flagset
func StorageHomeWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "tracing-enabled",
Usage: "Enable sending traces",
EnvVar: "REVA_TRACING_ENABLED",
Destination: &cfg.Tracing.Enabled,
},
&cli.StringFlag{
Name: "tracing-type",
Value: "jaeger",
Usage: "Tracing backend type",
EnvVar: "REVA_TRACING_TYPE",
Destination: &cfg.Tracing.Type,
},
&cli.StringFlag{
Name: "tracing-endpoint",
Value: "",
Usage: "Endpoint for the agent",
EnvVar: "REVA_TRACING_ENDPOINT",
Destination: &cfg.Tracing.Endpoint,
},
&cli.StringFlag{
Name: "tracing-collector",
Value: "",
Usage: "Endpoint for the collector",
EnvVar: "REVA_TRACING_COLLECTOR",
Destination: &cfg.Tracing.Collector,
},
&cli.StringFlag{
Name: "tracing-service",
Value: "reva",
Usage: "Service name for tracing",
EnvVar: "REVA_TRACING_SERVICE",
Destination: &cfg.Tracing.Service,
},
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9155",
Usage: "Address to bind debug server",
EnvVar: "REVA_STORAGE_HOME_DEBUG_ADDR",
Destination: &cfg.Reva.StorageHome.DebugAddr,
},
&cli.StringFlag{
Name: "debug-token",
Value: "",
Usage: "Token to grant metrics access",
EnvVar: "REVA_DEBUG_TOKEN",
Destination: &cfg.Debug.Token,
},
&cli.BoolFlag{
Name: "debug-pprof",
Usage: "Enable pprof debugging",
EnvVar: "REVA_DEBUG_PPROF",
Destination: &cfg.Debug.Pprof,
},
&cli.BoolFlag{
Name: "debug-zpages",
Usage: "Enable zpages debugging",
EnvVar: "REVA_DEBUG_ZPAGES",
Destination: &cfg.Debug.Zpages,
},
// REVA
&cli.StringFlag{
Name: "jwt-secret",
Value: "Pive-Fumkiu4",
Usage: "Shared jwt secret for reva service communication",
EnvVar: "REVA_JWT_SECRET",
Destination: &cfg.Reva.JWTSecret,
},
// Services
// Storage home
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_STORAGE_HOME_NETWORK",
Destination: &cfg.Reva.StorageHome.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "grpc",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVar: "REVA_STORAGE_HOME_PROTOCOL",
Destination: &cfg.Reva.StorageHome.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9154",
Usage: "Address to bind reva service",
EnvVar: "REVA_STORAGE_HOME_ADDR",
Destination: &cfg.Reva.StorageHome.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9154",
Usage: "URL to use for the reva service",
EnvVar: "REVA_STORAGE_HOME_URL",
Destination: &cfg.Reva.StorageHome.URL,
},
&cli.StringFlag{
Name: "services",
Value: "storageprovider",
Usage: "comma separated list of services to include",
EnvVar: "REVA_STORAGE_HOME_SERVICES",
Destination: &cfg.Reva.StorageHome.Services,
},
&cli.StringFlag{
Name: "driver",
Value: "owncloud",
Usage: "storage driver, eg. local, eos, owncloud or s3",
EnvVar: "REVA_STORAGE_HOME_DRIVER",
Destination: &cfg.Reva.StorageHome.Driver,
},
&cli.StringFlag{
Name: "path-wrapper",
Value: "context",
Usage: "path wrapper",
EnvVar: "REVA_STORAGE_HOME_PATH_WRAPPER",
Destination: &cfg.Reva.StorageHome.PathWrapper,
},
&cli.StringFlag{
Name: "path-wrapper-context-prefix",
Value: "",
Usage: "path wrapper context prefix",
EnvVar: "REVA_STORAGE_HOME_PATH_WRAPPER_CONTEXT_PREFIX",
Destination: &cfg.Reva.StorageHome.PathWrapperContext.Prefix,
},
&cli.StringFlag{
Name: "mount-path",
Value: "/home",
Usage: "mount path",
EnvVar: "REVA_STORAGE_HOME_MOUNT_PATH",
Destination: &cfg.Reva.StorageHome.MountPath,
},
&cli.StringFlag{
Name: "mount-id",
Value: "123e4567-e89b-12d3-a456-426655440000",
Usage: "mount id",
EnvVar: "REVA_STORAGE_HOME_MOUNT_ID",
Destination: &cfg.Reva.StorageHome.MountID,
},
&cli.BoolFlag{
Name: "expose-data-server",
Usage: "exposes a dedicated data server",
EnvVar: "REVA_STORAGE_HOME_EXPOSE_DATA_SERVER",
Destination: &cfg.Reva.StorageHome.ExposeDataServer,
},
&cli.StringFlag{
Name: "data-server-url",
Value: "http://localhost:9156/data",
Usage: "data server url",
EnvVar: "REVA_STORAGE_HOME_DATA_SERVER_URL",
Destination: &cfg.Reva.StorageHome.DataServerURL,
},
// Storage drivers
// Eos
&cli.StringFlag{
Name: "storage-eos-namespace",
Value: "",
Usage: "Namespace for metadata operations",
EnvVar: "REVA_STORAGE_EOS_NAMESPACE",
Destination: &cfg.Reva.Storages.EOS.Namespace,
},
&cli.StringFlag{
Name: "storage-eos-binary",
Value: "/usr/bin/eos",
Usage: "Location of the eos binary",
EnvVar: "REVA_STORAGE_EOS_BINARY",
Destination: &cfg.Reva.Storages.EOS.EosBinary,
},
&cli.StringFlag{
Name: "storage-eos-xrdcopy-binary",
Value: "/usr/bin/xrdcopy",
Usage: "Location of the xrdcopy binary",
EnvVar: "REVA_STORAGE_EOS_XRDCOPY_BINARY",
Destination: &cfg.Reva.Storages.EOS.XrdcopyBinary,
},
&cli.StringFlag{
Name: "storage-eos-master-url",
Value: "root://eos-example.org",
Usage: "URL of the Master EOS MGM",
EnvVar: "REVA_STORAGE_EOS_MASTER_URL",
Destination: &cfg.Reva.Storages.EOS.MasterURL,
},
&cli.StringFlag{
Name: "storage-eos-slave-url",
Value: "root://eos-example.org",
Usage: "URL of the Slave EOS MGM",
EnvVar: "REVA_STORAGE_EOS_SLAVE_URL",
Destination: &cfg.Reva.Storages.EOS.SlaveURL,
},
&cli.StringFlag{
Name: "storage-eos-cache-directory",
Value: os.TempDir(),
Usage: "Location on the local fs where to store reads",
EnvVar: "REVA_STORAGE_EOS_CACHE_DIRECTORY",
Destination: &cfg.Reva.Storages.EOS.CacheDirectory,
},
&cli.BoolFlag{
Name: "storage-eos-enable-logging",
Usage: "Enables logging of the commands executed",
EnvVar: "REVA_STORAGE_EOS_ENABLE_LOGGING",
Destination: &cfg.Reva.Storages.EOS.EnableLogging,
},
&cli.BoolFlag{
Name: "storage-eos-show-hidden-sysfiles",
Usage: "show internal EOS files like .sys.v# and .sys.a# files.",
EnvVar: "REVA_STORAGE_EOS_SHOW_HIDDEN_SYSFILES",
Destination: &cfg.Reva.Storages.EOS.ShowHiddenSysFiles,
},
&cli.BoolFlag{
Name: "storage-eos-force-singleuser-mode",
Usage: "force connections to EOS to use SingleUsername",
EnvVar: "REVA_STORAGE_EOS_FORCE_SINGLEUSER_MODE",
Destination: &cfg.Reva.Storages.EOS.ForceSingleUserMode,
},
&cli.BoolFlag{
Name: "storage-eos-use-keytab",
Usage: "authenticate requests by using an EOS keytab",
EnvVar: "REVA_STORAGE_EOS_USE_KEYTAB",
Destination: &cfg.Reva.Storages.EOS.UseKeytab,
},
&cli.StringFlag{
Name: "storage-eos-sec-protocol",
Value: "",
Usage: "the xrootd security protocol to use between the server and EOS",
EnvVar: "REVA_STORAGE_EOS_SEC_PROTOCOL",
Destination: &cfg.Reva.Storages.EOS.SecProtocol,
},
&cli.StringFlag{
Name: "storage-eos-keytab",
Value: "",
Usage: "the location of the keytab to use to authenticate to EOS",
EnvVar: "REVA_STORAGE_EOS_KEYTAB",
Destination: &cfg.Reva.Storages.EOS.Keytab,
},
&cli.StringFlag{
Name: "storage-eos-single-username",
Value: "",
Usage: "the username to use when SingleUserMode is enabled",
EnvVar: "REVA_STORAGE_EOS_SINGLE_USERNAME",
Destination: &cfg.Reva.Storages.EOS.SingleUsername,
},
// local
&cli.StringFlag{
Name: "storage-local-root",
Value: "/var/tmp/reva/root",
Usage: "the path to the local storage root",
EnvVar: "REVA_STORAGE_LOCAL_ROOT",
Destination: &cfg.Reva.Storages.Local.Root,
},
// owncloud
&cli.StringFlag{
Name: "storage-owncloud-datadir",
Value: "/var/tmp/reva/data",
Usage: "the path to the owncloud data directory",
EnvVar: "REVA_STORAGE_OWNCLOUD_DATADIR",
Destination: &cfg.Reva.Storages.OwnCloud.Datadirectory,
},
}
}

View File

@@ -0,0 +1,260 @@
package flagset
import (
"os"
"github.com/micro/cli"
"github.com/owncloud/ocis-reva/pkg/config"
)
// StorageHomeDataWithConfig applies cfg to the root flagset
func StorageHomeDataWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "tracing-enabled",
Usage: "Enable sending traces",
EnvVar: "REVA_TRACING_ENABLED",
Destination: &cfg.Tracing.Enabled,
},
&cli.StringFlag{
Name: "tracing-type",
Value: "jaeger",
Usage: "Tracing backend type",
EnvVar: "REVA_TRACING_TYPE",
Destination: &cfg.Tracing.Type,
},
&cli.StringFlag{
Name: "tracing-endpoint",
Value: "",
Usage: "Endpoint for the agent",
EnvVar: "REVA_TRACING_ENDPOINT",
Destination: &cfg.Tracing.Endpoint,
},
&cli.StringFlag{
Name: "tracing-collector",
Value: "",
Usage: "Endpoint for the collector",
EnvVar: "REVA_TRACING_COLLECTOR",
Destination: &cfg.Tracing.Collector,
},
&cli.StringFlag{
Name: "tracing-service",
Value: "reva",
Usage: "Service name for tracing",
EnvVar: "REVA_TRACING_SERVICE",
Destination: &cfg.Tracing.Service,
},
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9157",
Usage: "Address to bind debug server",
EnvVar: "REVA_STORAGE_HOME_DATA_DEBUG_ADDR",
Destination: &cfg.Reva.StorageHomeData.DebugAddr,
},
&cli.StringFlag{
Name: "debug-token",
Value: "",
Usage: "Token to grant metrics access",
EnvVar: "REVA_DEBUG_TOKEN",
Destination: &cfg.Debug.Token,
},
&cli.BoolFlag{
Name: "debug-pprof",
Usage: "Enable pprof debugging",
EnvVar: "REVA_DEBUG_PPROF",
Destination: &cfg.Debug.Pprof,
},
&cli.BoolFlag{
Name: "debug-zpages",
Usage: "Enable zpages debugging",
EnvVar: "REVA_DEBUG_ZPAGES",
Destination: &cfg.Debug.Zpages,
},
// REVA
&cli.StringFlag{
Name: "jwt-secret",
Value: "Pive-Fumkiu4",
Usage: "Shared jwt secret for reva service communication",
EnvVar: "REVA_JWT_SECRET",
Destination: &cfg.Reva.JWTSecret,
},
// Services
// Storage home data
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_STORAGE_HOME_DATA_NETWORK",
Destination: &cfg.Reva.StorageHomeData.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "http",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVar: "REVA_STORAGE_HOME_DATA_PROTOCOL",
Destination: &cfg.Reva.StorageHomeData.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9156",
Usage: "Address to bind reva service",
EnvVar: "REVA_STORAGE_HOME_DATA_ADDR",
Destination: &cfg.Reva.StorageHomeData.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9156",
Usage: "URL to use for the reva service",
EnvVar: "REVA_STORAGE_HOME_DATA_URL",
Destination: &cfg.Reva.StorageHomeData.URL,
},
&cli.StringFlag{
Name: "services",
Value: "dataprovider",
Usage: "comma separated list of services to include",
EnvVar: "REVA_STORAGE_HOME_DATA_SERVICES",
Destination: &cfg.Reva.StorageHomeData.Services,
},
&cli.StringFlag{
Name: "driver",
Value: "owncloud",
Usage: "storage driver, eg. local, eos, owncloud or s3",
EnvVar: "REVA_STORAGE_HOME_DATA_DRIVER",
Destination: &cfg.Reva.StorageHomeData.Driver,
},
&cli.StringFlag{
Name: "prefix",
Value: "data",
Usage: "prefix for the http endpoint, without leading slash",
EnvVar: "REVA_STORAGE_HOME_DATA_PREFIX",
Destination: &cfg.Reva.StorageHomeData.Prefix,
},
&cli.StringFlag{
Name: "temp-folder",
Value: "/var/tmp/",
Usage: "temp folder",
EnvVar: "REVA_STORAGE_HOME_DATA_TEMP_FOLDER",
Destination: &cfg.Reva.StorageHomeData.TempFolder,
},
// Storage drivers
// Eos
&cli.StringFlag{
Name: "storage-eos-namespace",
Value: "",
Usage: "Namespace for metadata operations",
EnvVar: "REVA_STORAGE_EOS_NAMESPACE",
Destination: &cfg.Reva.Storages.EOS.Namespace,
},
&cli.StringFlag{
Name: "storage-eos-binary",
Value: "/usr/bin/eos",
Usage: "Location of the eos binary",
EnvVar: "REVA_STORAGE_EOS_BINARY",
Destination: &cfg.Reva.Storages.EOS.EosBinary,
},
&cli.StringFlag{
Name: "storage-eos-xrdcopy-binary",
Value: "/usr/bin/xrdcopy",
Usage: "Location of the xrdcopy binary",
EnvVar: "REVA_STORAGE_EOS_XRDCOPY_BINARY",
Destination: &cfg.Reva.Storages.EOS.XrdcopyBinary,
},
&cli.StringFlag{
Name: "storage-eos-master-url",
Value: "root://eos-example.org",
Usage: "URL of the Master EOS MGM",
EnvVar: "REVA_STORAGE_EOS_MASTER_URL",
Destination: &cfg.Reva.Storages.EOS.MasterURL,
},
&cli.StringFlag{
Name: "storage-eos-slave-url",
Value: "root://eos-example.org",
Usage: "URL of the Slave EOS MGM",
EnvVar: "REVA_STORAGE_EOS_SLAVE_URL",
Destination: &cfg.Reva.Storages.EOS.SlaveURL,
},
&cli.StringFlag{
Name: "storage-eos-cache-directory",
Value: os.TempDir(),
Usage: "Location on the local fs where to store reads",
EnvVar: "REVA_STORAGE_EOS_CACHE_DIRECTORY",
Destination: &cfg.Reva.Storages.EOS.CacheDirectory,
},
&cli.BoolFlag{
Name: "storage-eos-enable-logging",
Usage: "Enables logging of the commands executed",
EnvVar: "REVA_STORAGE_EOS_ENABLE_LOGGING",
Destination: &cfg.Reva.Storages.EOS.EnableLogging,
},
&cli.BoolFlag{
Name: "storage-eos-show-hidden-sysfiles",
Usage: "show internal EOS files like .sys.v# and .sys.a# files.",
EnvVar: "REVA_STORAGE_EOS_SHOW_HIDDEN_SYSFILES",
Destination: &cfg.Reva.Storages.EOS.ShowHiddenSysFiles,
},
&cli.BoolFlag{
Name: "storage-eos-force-singleuser-mode",
Usage: "force connections to EOS to use SingleUsername",
EnvVar: "REVA_STORAGE_EOS_FORCE_SINGLEUSER_MODE",
Destination: &cfg.Reva.Storages.EOS.ForceSingleUserMode,
},
&cli.BoolFlag{
Name: "storage-eos-use-keytab",
Usage: "authenticate requests by using an EOS keytab",
EnvVar: "REVA_STORAGE_EOS_USE_KEYTAB",
Destination: &cfg.Reva.Storages.EOS.UseKeytab,
},
&cli.StringFlag{
Name: "storage-eos-sec-protocol",
Value: "",
Usage: "the xrootd security protocol to use between the server and EOS",
EnvVar: "REVA_STORAGE_EOS_SEC_PROTOCOL",
Destination: &cfg.Reva.Storages.EOS.SecProtocol,
},
&cli.StringFlag{
Name: "storage-eos-keytab",
Value: "",
Usage: "the location of the keytab to use to authenticate to EOS",
EnvVar: "REVA_STORAGE_EOS_KEYTAB",
Destination: &cfg.Reva.Storages.EOS.Keytab,
},
&cli.StringFlag{
Name: "storage-eos-single-username",
Value: "",
Usage: "the username to use when SingleUserMode is enabled",
EnvVar: "REVA_STORAGE_EOS_SINGLE_USERNAME",
Destination: &cfg.Reva.Storages.EOS.SingleUsername,
},
// local
&cli.StringFlag{
Name: "storage-local-root",
Value: "/var/tmp/reva/root",
Usage: "the path to the local storage root",
EnvVar: "REVA_STORAGE_LOCAL_ROOT",
Destination: &cfg.Reva.Storages.Local.Root,
},
// owncloud
&cli.StringFlag{
Name: "storage-owncloud-datadir",
Value: "/var/tmp/reva/data",
Usage: "the path to the owncloud data directory",
EnvVar: "REVA_STORAGE_OWNCLOUD_DATADIR",
Destination: &cfg.Reva.Storages.OwnCloud.Datadirectory,
},
}
}

288
pkg/flagset/storageoc.go Normal file
View File

@@ -0,0 +1,288 @@
package flagset
import (
"os"
"github.com/micro/cli"
"github.com/owncloud/ocis-reva/pkg/config"
)
// StorageOCWithConfig applies cfg to the root flagset
func StorageOCWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "tracing-enabled",
Usage: "Enable sending traces",
EnvVar: "REVA_TRACING_ENABLED",
Destination: &cfg.Tracing.Enabled,
},
&cli.StringFlag{
Name: "tracing-type",
Value: "jaeger",
Usage: "Tracing backend type",
EnvVar: "REVA_TRACING_TYPE",
Destination: &cfg.Tracing.Type,
},
&cli.StringFlag{
Name: "tracing-endpoint",
Value: "",
Usage: "Endpoint for the agent",
EnvVar: "REVA_TRACING_ENDPOINT",
Destination: &cfg.Tracing.Endpoint,
},
&cli.StringFlag{
Name: "tracing-collector",
Value: "",
Usage: "Endpoint for the collector",
EnvVar: "REVA_TRACING_COLLECTOR",
Destination: &cfg.Tracing.Collector,
},
&cli.StringFlag{
Name: "tracing-service",
Value: "reva",
Usage: "Service name for tracing",
EnvVar: "REVA_TRACING_SERVICE",
Destination: &cfg.Tracing.Service,
},
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9163",
Usage: "Address to bind debug server",
EnvVar: "REVA_STORAGE_OC_DEBUG_ADDR",
Destination: &cfg.Reva.StorageOC.DebugAddr,
},
&cli.StringFlag{
Name: "debug-token",
Value: "",
Usage: "Token to grant metrics access",
EnvVar: "REVA_DEBUG_TOKEN",
Destination: &cfg.Debug.Token,
},
&cli.BoolFlag{
Name: "debug-pprof",
Usage: "Enable pprof debugging",
EnvVar: "REVA_DEBUG_PPROF",
Destination: &cfg.Debug.Pprof,
},
&cli.BoolFlag{
Name: "debug-zpages",
Usage: "Enable zpages debugging",
EnvVar: "REVA_DEBUG_ZPAGES",
Destination: &cfg.Debug.Zpages,
},
// REVA
&cli.StringFlag{
Name: "jwt-secret",
Value: "Pive-Fumkiu4",
Usage: "Shared jwt secret for reva service communication",
EnvVar: "REVA_JWT_SECRET",
Destination: &cfg.Reva.JWTSecret,
},
// Services
// Storage oc
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_STORAGE_OC_NETWORK",
Destination: &cfg.Reva.StorageOC.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "grpc",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVar: "REVA_STORAGE_OC_PROTOCOL",
Destination: &cfg.Reva.StorageOC.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9162",
Usage: "Address to bind reva service",
EnvVar: "REVA_STORAGE_OC_ADDR",
Destination: &cfg.Reva.StorageOC.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9162",
Usage: "URL to use for the reva service",
EnvVar: "REVA_STORAGE_OC_URL",
Destination: &cfg.Reva.StorageOC.URL,
},
&cli.StringFlag{
Name: "services",
Value: "storageprovider",
Usage: "comma separated list of services to include",
EnvVar: "REVA_STORAGE_OC_SERVICES",
Destination: &cfg.Reva.StorageOC.Services,
},
&cli.StringFlag{
Name: "driver",
Value: "owncloud",
Usage: "storage driver, eg. local, eos, owncloud or s3",
EnvVar: "REVA_STORAGE_OC_DRIVER",
Destination: &cfg.Reva.StorageOC.Driver,
},
&cli.StringFlag{
Name: "path-wrapper",
Value: "",
Usage: "path wrapper",
EnvVar: "REVA_STORAGE_OC_PATH_WRAPPER",
Destination: &cfg.Reva.StorageOC.PathWrapper,
},
&cli.StringFlag{
Name: "path-wrapper-context-prefix",
Value: "",
Usage: "path wrapper context prefix",
EnvVar: "REVA_STORAGE_OC_PATH_WRAPPER_CONTEXT_PREFIX",
Destination: &cfg.Reva.StorageOC.PathWrapperContext.Prefix,
},
&cli.StringFlag{
Name: "mount-path",
Value: "/oc",
Usage: "mount path",
EnvVar: "REVA_STORAGE_OC_MOUNT_PATH",
Destination: &cfg.Reva.StorageOC.MountPath,
},
&cli.StringFlag{
Name: "mount-id",
Value: "123e4567-e89b-12d3-a456-426655440000",
Usage: "mount id",
EnvVar: "REVA_STORAGE_OC_MOUNT_ID",
Destination: &cfg.Reva.StorageOC.MountID,
},
&cli.BoolFlag{
Name: "expose-data-server",
Usage: "exposes a dedicated data server",
EnvVar: "REVA_STORAGE_OC_EXPOSE_DATA_SERVER",
Destination: &cfg.Reva.StorageOC.ExposeDataServer,
},
&cli.StringFlag{
Name: "data-server-url",
Value: "",
Usage: "data server url",
EnvVar: "REVA_STORAGE_OC_DATA_SERVER_URL",
Destination: &cfg.Reva.StorageOC.DataServerURL,
},
// Storage drivers
// Eos
&cli.StringFlag{
Name: "storage-eos-namespace",
Value: "",
Usage: "Namespace for metadata operations",
EnvVar: "REVA_STORAGE_EOS_NAMESPACE",
Destination: &cfg.Reva.Storages.EOS.Namespace,
},
&cli.StringFlag{
Name: "storage-eos-binary",
Value: "/usr/bin/eos",
Usage: "Location of the eos binary",
EnvVar: "REVA_STORAGE_EOS_BINARY",
Destination: &cfg.Reva.Storages.EOS.EosBinary,
},
&cli.StringFlag{
Name: "storage-eos-xrdcopy-binary",
Value: "/usr/bin/xrdcopy",
Usage: "Location of the xrdcopy binary",
EnvVar: "REVA_STORAGE_EOS_XRDCOPY_BINARY",
Destination: &cfg.Reva.Storages.EOS.XrdcopyBinary,
},
&cli.StringFlag{
Name: "storage-eos-master-url",
Value: "root://eos-example.org",
Usage: "URL of the Master EOS MGM",
EnvVar: "REVA_STORAGE_EOS_MASTER_URL",
Destination: &cfg.Reva.Storages.EOS.MasterURL,
},
&cli.StringFlag{
Name: "storage-eos-slave-url",
Value: "root://eos-example.org",
Usage: "URL of the Slave EOS MGM",
EnvVar: "REVA_STORAGE_EOS_SLAVE_URL",
Destination: &cfg.Reva.Storages.EOS.SlaveURL,
},
&cli.StringFlag{
Name: "storage-eos-cache-directory",
Value: os.TempDir(),
Usage: "Location on the local fs where to store reads",
EnvVar: "REVA_STORAGE_EOS_CACHE_DIRECTORY",
Destination: &cfg.Reva.Storages.EOS.CacheDirectory,
},
&cli.BoolFlag{
Name: "storage-eos-enable-logging",
Usage: "Enables logging of the commands executed",
EnvVar: "REVA_STORAGE_EOS_ENABLE_LOGGING",
Destination: &cfg.Reva.Storages.EOS.EnableLogging,
},
&cli.BoolFlag{
Name: "storage-eos-show-hidden-sysfiles",
Usage: "show internal EOS files like .sys.v# and .sys.a# files.",
EnvVar: "REVA_STORAGE_EOS_SHOW_HIDDEN_SYSFILES",
Destination: &cfg.Reva.Storages.EOS.ShowHiddenSysFiles,
},
&cli.BoolFlag{
Name: "storage-eos-force-singleuser-mode",
Usage: "force connections to EOS to use SingleUsername",
EnvVar: "REVA_STORAGE_EOS_FORCE_SINGLEUSER_MODE",
Destination: &cfg.Reva.Storages.EOS.ForceSingleUserMode,
},
&cli.BoolFlag{
Name: "storage-eos-use-keytab",
Usage: "authenticate requests by using an EOS keytab",
EnvVar: "REVA_STORAGE_EOS_USE_KEYTAB",
Destination: &cfg.Reva.Storages.EOS.UseKeytab,
},
&cli.StringFlag{
Name: "storage-eos-sec-protocol",
Value: "",
Usage: "the xrootd security protocol to use between the server and EOS",
EnvVar: "REVA_STORAGE_EOS_SEC_PROTOCOL",
Destination: &cfg.Reva.Storages.EOS.SecProtocol,
},
&cli.StringFlag{
Name: "storage-eos-keytab",
Value: "",
Usage: "the location of the keytab to use to authenticate to EOS",
EnvVar: "REVA_STORAGE_EOS_KEYTAB",
Destination: &cfg.Reva.Storages.EOS.Keytab,
},
&cli.StringFlag{
Name: "storage-eos-single-username",
Value: "",
Usage: "the username to use when SingleUserMode is enabled",
EnvVar: "REVA_STORAGE_EOS_SINGLE_USERNAME",
Destination: &cfg.Reva.Storages.EOS.SingleUsername,
},
// local
&cli.StringFlag{
Name: "storage-local-root",
Value: "/var/tmp/reva/root",
Usage: "the path to the local storage root",
EnvVar: "REVA_STORAGE_LOCAL_ROOT",
Destination: &cfg.Reva.Storages.Local.Root,
},
// owncloud
&cli.StringFlag{
Name: "storage-owncloud-datadir",
Value: "/var/tmp/reva/data",
Usage: "the path to the owncloud data directory",
EnvVar: "REVA_STORAGE_OWNCLOUD_DATADIR",
Destination: &cfg.Reva.Storages.OwnCloud.Datadirectory,
},
}
}

View File

@@ -0,0 +1,260 @@
package flagset
import (
"os"
"github.com/micro/cli"
"github.com/owncloud/ocis-reva/pkg/config"
)
// StorageOCDataWithConfig applies cfg to the root flagset
func StorageOCDataWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "tracing-enabled",
Usage: "Enable sending traces",
EnvVar: "REVA_TRACING_ENABLED",
Destination: &cfg.Tracing.Enabled,
},
&cli.StringFlag{
Name: "tracing-type",
Value: "jaeger",
Usage: "Tracing backend type",
EnvVar: "REVA_TRACING_TYPE",
Destination: &cfg.Tracing.Type,
},
&cli.StringFlag{
Name: "tracing-endpoint",
Value: "",
Usage: "Endpoint for the agent",
EnvVar: "REVA_TRACING_ENDPOINT",
Destination: &cfg.Tracing.Endpoint,
},
&cli.StringFlag{
Name: "tracing-collector",
Value: "",
Usage: "Endpoint for the collector",
EnvVar: "REVA_TRACING_COLLECTOR",
Destination: &cfg.Tracing.Collector,
},
&cli.StringFlag{
Name: "tracing-service",
Value: "reva",
Usage: "Service name for tracing",
EnvVar: "REVA_TRACING_SERVICE",
Destination: &cfg.Tracing.Service,
},
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9165",
Usage: "Address to bind debug server",
EnvVar: "REVA_STORAGE_OC_DATA_DEBUG_ADDR",
Destination: &cfg.Reva.StorageOCData.DebugAddr,
},
&cli.StringFlag{
Name: "debug-token",
Value: "",
Usage: "Token to grant metrics access",
EnvVar: "REVA_DEBUG_TOKEN",
Destination: &cfg.Debug.Token,
},
&cli.BoolFlag{
Name: "debug-pprof",
Usage: "Enable pprof debugging",
EnvVar: "REVA_DEBUG_PPROF",
Destination: &cfg.Debug.Pprof,
},
&cli.BoolFlag{
Name: "debug-zpages",
Usage: "Enable zpages debugging",
EnvVar: "REVA_DEBUG_ZPAGES",
Destination: &cfg.Debug.Zpages,
},
// REVA
&cli.StringFlag{
Name: "jwt-secret",
Value: "Pive-Fumkiu4",
Usage: "Shared jwt secret for reva service communication",
EnvVar: "REVA_JWT_SECRET",
Destination: &cfg.Reva.JWTSecret,
},
// Services
// Storage oc data
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_STORAGE_OC_DATA_NETWORK",
Destination: &cfg.Reva.StorageOCData.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "http",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVar: "REVA_STORAGE_OC_DATA_PROTOCOL",
Destination: &cfg.Reva.StorageOCData.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9164",
Usage: "Address to bind reva service",
EnvVar: "REVA_STORAGE_OC_DATA_ADDR",
Destination: &cfg.Reva.StorageOCData.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9164",
Usage: "URL to use for the reva service",
EnvVar: "REVA_STORAGE_OC_DATA_URL",
Destination: &cfg.Reva.StorageOCData.URL,
},
&cli.StringFlag{
Name: "services",
Value: "dataprovider",
Usage: "comma separated list of services to include in the storage-oc data service",
EnvVar: "REVA_STORAGE_OC_DATA_SERVICES",
Destination: &cfg.Reva.StorageOCData.Services,
},
&cli.StringFlag{
Name: "driver",
Value: "owncloud",
Usage: "storage driver, eg. local, eos, owncloud or s3",
EnvVar: "REVA_STORAGE_OC_DATA_DRIVER",
Destination: &cfg.Reva.StorageOCData.Driver,
},
&cli.StringFlag{
Name: "prefix",
Value: "data",
Usage: "prefix for the http endpoint, without leading slash",
EnvVar: "REVA_STORAGE_OC_DATA_PREFIX",
Destination: &cfg.Reva.StorageOCData.Prefix,
},
&cli.StringFlag{
Name: "temp-folder",
Value: "/var/tmp/",
Usage: "temp folder",
EnvVar: "REVA_STORAGE_OC_DATA_TEMP_FOLDER",
Destination: &cfg.Reva.StorageOCData.TempFolder,
},
// Storage drivers
// Eos
&cli.StringFlag{
Name: "storage-eos-namespace",
Value: "",
Usage: "Namespace for metadata operations",
EnvVar: "REVA_STORAGE_EOS_NAMESPACE",
Destination: &cfg.Reva.Storages.EOS.Namespace,
},
&cli.StringFlag{
Name: "storage-eos-binary",
Value: "/usr/bin/eos",
Usage: "Location of the eos binary",
EnvVar: "REVA_STORAGE_EOS_BINARY",
Destination: &cfg.Reva.Storages.EOS.EosBinary,
},
&cli.StringFlag{
Name: "storage-eos-xrdcopy-binary",
Value: "/usr/bin/xrdcopy",
Usage: "Location of the xrdcopy binary",
EnvVar: "REVA_STORAGE_EOS_XRDCOPY_BINARY",
Destination: &cfg.Reva.Storages.EOS.XrdcopyBinary,
},
&cli.StringFlag{
Name: "storage-eos-master-url",
Value: "root://eos-example.org",
Usage: "URL of the Master EOS MGM",
EnvVar: "REVA_STORAGE_EOS_MASTER_URL",
Destination: &cfg.Reva.Storages.EOS.MasterURL,
},
&cli.StringFlag{
Name: "storage-eos-slave-url",
Value: "root://eos-example.org",
Usage: "URL of the Slave EOS MGM",
EnvVar: "REVA_STORAGE_EOS_SLAVE_URL",
Destination: &cfg.Reva.Storages.EOS.SlaveURL,
},
&cli.StringFlag{
Name: "storage-eos-cache-directory",
Value: os.TempDir(),
Usage: "Location on the local fs where to store reads",
EnvVar: "REVA_STORAGE_EOS_CACHE_DIRECTORY",
Destination: &cfg.Reva.Storages.EOS.CacheDirectory,
},
&cli.BoolFlag{
Name: "storage-eos-enable-logging",
Usage: "Enables logging of the commands executed",
EnvVar: "REVA_STORAGE_EOS_ENABLE_LOGGING",
Destination: &cfg.Reva.Storages.EOS.EnableLogging,
},
&cli.BoolFlag{
Name: "storage-eos-show-hidden-sysfiles",
Usage: "show internal EOS files like .sys.v# and .sys.a# files.",
EnvVar: "REVA_STORAGE_EOS_SHOW_HIDDEN_SYSFILES",
Destination: &cfg.Reva.Storages.EOS.ShowHiddenSysFiles,
},
&cli.BoolFlag{
Name: "storage-eos-force-singleuser-mode",
Usage: "force connections to EOS to use SingleUsername",
EnvVar: "REVA_STORAGE_EOS_FORCE_SINGLEUSER_MODE",
Destination: &cfg.Reva.Storages.EOS.ForceSingleUserMode,
},
&cli.BoolFlag{
Name: "storage-eos-use-keytab",
Usage: "authenticate requests by using an EOS keytab",
EnvVar: "REVA_STORAGE_EOS_USE_KEYTAB",
Destination: &cfg.Reva.Storages.EOS.UseKeytab,
},
&cli.StringFlag{
Name: "storage-eos-sec-protocol",
Value: "",
Usage: "the xrootd security protocol to use between the server and EOS",
EnvVar: "REVA_STORAGE_EOS_SEC_PROTOCOL",
Destination: &cfg.Reva.Storages.EOS.SecProtocol,
},
&cli.StringFlag{
Name: "storage-eos-keytab",
Value: "",
Usage: "the location of the keytab to use to authenticate to EOS",
EnvVar: "REVA_STORAGE_EOS_KEYTAB",
Destination: &cfg.Reva.Storages.EOS.Keytab,
},
&cli.StringFlag{
Name: "storage-eos-single-username",
Value: "",
Usage: "the username to use when SingleUserMode is enabled",
EnvVar: "REVA_STORAGE_EOS_SINGLE_USERNAME",
Destination: &cfg.Reva.Storages.EOS.SingleUsername,
},
// local
&cli.StringFlag{
Name: "storage-local-root",
Value: "/var/tmp/reva/root",
Usage: "the path to the local storage root",
EnvVar: "REVA_STORAGE_LOCAL_ROOT",
Destination: &cfg.Reva.Storages.Local.Root,
},
// owncloud
&cli.StringFlag{
Name: "storage-owncloud-datadir",
Value: "/var/tmp/reva/data",
Usage: "the path to the owncloud data directory",
EnvVar: "REVA_STORAGE_OWNCLOUD_DATADIR",
Destination: &cfg.Reva.Storages.OwnCloud.Datadirectory,
},
}
}

288
pkg/flagset/storageroot.go Normal file
View File

@@ -0,0 +1,288 @@
package flagset
import (
"os"
"github.com/micro/cli"
"github.com/owncloud/ocis-reva/pkg/config"
)
// StorageRootWithConfig applies cfg to the root flagset
func StorageRootWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "tracing-enabled",
Usage: "Enable sending traces",
EnvVar: "REVA_TRACING_ENABLED",
Destination: &cfg.Tracing.Enabled,
},
&cli.StringFlag{
Name: "tracing-type",
Value: "jaeger",
Usage: "Tracing backend type",
EnvVar: "REVA_TRACING_TYPE",
Destination: &cfg.Tracing.Type,
},
&cli.StringFlag{
Name: "tracing-endpoint",
Value: "",
Usage: "Endpoint for the agent",
EnvVar: "REVA_TRACING_ENDPOINT",
Destination: &cfg.Tracing.Endpoint,
},
&cli.StringFlag{
Name: "tracing-collector",
Value: "",
Usage: "Endpoint for the collector",
EnvVar: "REVA_TRACING_COLLECTOR",
Destination: &cfg.Tracing.Collector,
},
&cli.StringFlag{
Name: "tracing-service",
Value: "reva",
Usage: "Service name for tracing",
EnvVar: "REVA_TRACING_SERVICE",
Destination: &cfg.Tracing.Service,
},
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9153",
Usage: "Address to bind debug server",
EnvVar: "REVA_STORAGE_ROOT_DEBUG_ADDR",
Destination: &cfg.Reva.StorageRoot.DebugAddr,
},
&cli.StringFlag{
Name: "debug-token",
Value: "",
Usage: "Token to grant metrics access",
EnvVar: "REVA_DEBUG_TOKEN",
Destination: &cfg.Debug.Token,
},
&cli.BoolFlag{
Name: "debug-pprof",
Usage: "Enable pprof debugging",
EnvVar: "REVA_DEBUG_PPROF",
Destination: &cfg.Debug.Pprof,
},
&cli.BoolFlag{
Name: "debug-zpages",
Usage: "Enable zpages debugging",
EnvVar: "REVA_DEBUG_ZPAGES",
Destination: &cfg.Debug.Zpages,
},
// REVA
&cli.StringFlag{
Name: "jwt-secret",
Value: "Pive-Fumkiu4",
Usage: "Shared jwt secret for reva service communication",
EnvVar: "REVA_JWT_SECRET",
Destination: &cfg.Reva.JWTSecret,
},
// Services
// Storage root
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_STORAGE_ROOT_NETWORK",
Destination: &cfg.Reva.StorageRoot.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "grpc",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVar: "REVA_STORAGE_ROOT_PROTOCOL",
Destination: &cfg.Reva.StorageRoot.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9152",
Usage: "Address to bind reva service",
EnvVar: "REVA_STORAGE_ROOT_ADDR",
Destination: &cfg.Reva.StorageRoot.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9152",
Usage: "URL to use for the reva service",
EnvVar: "REVA_STORAGE_ROOT_URL",
Destination: &cfg.Reva.StorageRoot.URL,
},
&cli.StringFlag{
Name: "services",
Value: "storageprovider",
Usage: "comma separated list of services to include in the storage-root service",
EnvVar: "REVA_STORAGE_ROOT_SERVICES",
Destination: &cfg.Reva.StorageRoot.Services,
},
&cli.StringFlag{
Name: "driver",
Value: "local",
Usage: "storage driver, eg. local, eos, owncloud or s3",
EnvVar: "REVA_STORAGE_ROOT_DRIVER",
Destination: &cfg.Reva.StorageRoot.Driver,
},
&cli.StringFlag{
Name: "path-wrapper",
Value: "",
Usage: "path wrapper",
EnvVar: "REVA_STORAGE_ROOT_PATH_WRAPPER",
Destination: &cfg.Reva.StorageRoot.PathWrapper,
},
&cli.StringFlag{
Name: "path-wrapper-context-prefix",
Value: "",
Usage: "path wrapper context prefix",
EnvVar: "REVA_STORAGE_ROOT_PATH_WRAPPER_CONTEXT_PREFIX",
Destination: &cfg.Reva.StorageRoot.PathWrapperContext.Prefix,
},
&cli.StringFlag{
Name: "mount-path",
Value: "/",
Usage: "mount path",
EnvVar: "REVA_STORAGE_ROOT_MOUNT_PATH",
Destination: &cfg.Reva.StorageRoot.MountPath,
},
&cli.StringFlag{
Name: "mount-id",
Value: "123e4567-e89b-12d3-a456-426655440001",
Usage: "mount id",
EnvVar: "REVA_STORAGE_ROOT_MOUNT_ID",
Destination: &cfg.Reva.StorageRoot.MountID,
},
&cli.BoolFlag{
Name: "expose-data-server",
Usage: "exposes a dedicated data server",
EnvVar: "REVA_STORAGE_ROOT_EXPOSE_DATA_SERVER",
Destination: &cfg.Reva.StorageRoot.ExposeDataServer,
},
&cli.StringFlag{
Name: "data-server-url",
Value: "",
Usage: "data server url",
EnvVar: "REVA_STORAGE_ROOT_DATA_SERVER_URL",
Destination: &cfg.Reva.StorageRoot.DataServerURL,
},
// Storage drivers
// Eos
&cli.StringFlag{
Name: "storage-eos-namespace",
Value: "",
Usage: "Namespace for metadata operations",
EnvVar: "REVA_STORAGE_EOS_NAMESPACE",
Destination: &cfg.Reva.Storages.EOS.Namespace,
},
&cli.StringFlag{
Name: "storage-eos-binary",
Value: "/usr/bin/eos",
Usage: "Location of the eos binary",
EnvVar: "REVA_STORAGE_EOS_BINARY",
Destination: &cfg.Reva.Storages.EOS.EosBinary,
},
&cli.StringFlag{
Name: "storage-eos-xrdcopy-binary",
Value: "/usr/bin/xrdcopy",
Usage: "Location of the xrdcopy binary",
EnvVar: "REVA_STORAGE_EOS_XRDCOPY_BINARY",
Destination: &cfg.Reva.Storages.EOS.XrdcopyBinary,
},
&cli.StringFlag{
Name: "storage-eos-master-url",
Value: "root://eos-example.org",
Usage: "URL of the Master EOS MGM",
EnvVar: "REVA_STORAGE_EOS_MASTER_URL",
Destination: &cfg.Reva.Storages.EOS.MasterURL,
},
&cli.StringFlag{
Name: "storage-eos-slave-url",
Value: "root://eos-example.org",
Usage: "URL of the Slave EOS MGM",
EnvVar: "REVA_STORAGE_EOS_SLAVE_URL",
Destination: &cfg.Reva.Storages.EOS.SlaveURL,
},
&cli.StringFlag{
Name: "storage-eos-cache-directory",
Value: os.TempDir(),
Usage: "Location on the local fs where to store reads",
EnvVar: "REVA_STORAGE_EOS_CACHE_DIRECTORY",
Destination: &cfg.Reva.Storages.EOS.CacheDirectory,
},
&cli.BoolFlag{
Name: "storage-eos-enable-logging",
Usage: "Enables logging of the commands executed",
EnvVar: "REVA_STORAGE_EOS_ENABLE_LOGGING",
Destination: &cfg.Reva.Storages.EOS.EnableLogging,
},
&cli.BoolFlag{
Name: "storage-eos-show-hidden-sysfiles",
Usage: "show internal EOS files like .sys.v# and .sys.a# files.",
EnvVar: "REVA_STORAGE_EOS_SHOW_HIDDEN_SYSFILES",
Destination: &cfg.Reva.Storages.EOS.ShowHiddenSysFiles,
},
&cli.BoolFlag{
Name: "storage-eos-force-singleuser-mode",
Usage: "force connections to EOS to use SingleUsername",
EnvVar: "REVA_STORAGE_EOS_FORCE_SINGLEUSER_MODE",
Destination: &cfg.Reva.Storages.EOS.ForceSingleUserMode,
},
&cli.BoolFlag{
Name: "storage-eos-use-keytab",
Usage: "authenticate requests by using an EOS keytab",
EnvVar: "REVA_STORAGE_EOS_USE_KEYTAB",
Destination: &cfg.Reva.Storages.EOS.UseKeytab,
},
&cli.StringFlag{
Name: "storage-eos-sec-protocol",
Value: "",
Usage: "the xrootd security protocol to use between the server and EOS",
EnvVar: "REVA_STORAGE_EOS_SEC_PROTOCOL",
Destination: &cfg.Reva.Storages.EOS.SecProtocol,
},
&cli.StringFlag{
Name: "storage-eos-keytab",
Value: "",
Usage: "the location of the keytab to use to authenticate to EOS",
EnvVar: "REVA_STORAGE_EOS_KEYTAB",
Destination: &cfg.Reva.Storages.EOS.Keytab,
},
&cli.StringFlag{
Name: "storage-eos-single-username",
Value: "",
Usage: "the username to use when SingleUserMode is enabled",
EnvVar: "REVA_STORAGE_EOS_SINGLE_USERNAME",
Destination: &cfg.Reva.Storages.EOS.SingleUsername,
},
// local
&cli.StringFlag{
Name: "storage-local-root",
Value: "/var/tmp/reva/root",
Usage: "the path to the local storage root",
EnvVar: "REVA_STORAGE_LOCAL_ROOT",
Destination: &cfg.Reva.Storages.Local.Root,
},
// owncloud
&cli.StringFlag{
Name: "storage-owncloud-datadir",
Value: "/var/tmp/reva/data",
Usage: "the path to the owncloud data directory",
EnvVar: "REVA_STORAGE_OWNCLOUD_DATADIR",
Destination: &cfg.Reva.Storages.OwnCloud.Datadirectory,
},
}
}

221
pkg/flagset/users.go Normal file
View File

@@ -0,0 +1,221 @@
package flagset
import (
"github.com/micro/cli"
"github.com/owncloud/ocis-reva/pkg/config"
)
// UsersWithConfig applies cfg to the root flagset
func UsersWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "tracing-enabled",
Usage: "Enable sending traces",
EnvVar: "REVA_TRACING_ENABLED",
Destination: &cfg.Tracing.Enabled,
},
&cli.StringFlag{
Name: "tracing-type",
Value: "jaeger",
Usage: "Tracing backend type",
EnvVar: "REVA_TRACING_TYPE",
Destination: &cfg.Tracing.Type,
},
&cli.StringFlag{
Name: "tracing-endpoint",
Value: "",
Usage: "Endpoint for the agent",
EnvVar: "REVA_TRACING_ENDPOINT",
Destination: &cfg.Tracing.Endpoint,
},
&cli.StringFlag{
Name: "tracing-collector",
Value: "",
Usage: "Endpoint for the collector",
EnvVar: "REVA_TRACING_COLLECTOR",
Destination: &cfg.Tracing.Collector,
},
&cli.StringFlag{
Name: "tracing-service",
Value: "reva",
Usage: "Service name for tracing",
EnvVar: "REVA_TRACING_SERVICE",
Destination: &cfg.Tracing.Service,
},
// debug ports are the odd ports
&cli.StringFlag{
Name: "debug-addr",
Value: "0.0.0.0:9145",
Usage: "Address to bind debug server",
EnvVar: "REVA_SHARING_DEBUG_ADDR",
Destination: &cfg.Reva.Users.DebugAddr,
},
&cli.StringFlag{
Name: "debug-token",
Value: "",
Usage: "Token to grant metrics access",
EnvVar: "REVA_DEBUG_TOKEN",
Destination: &cfg.Debug.Token,
},
&cli.BoolFlag{
Name: "debug-pprof",
Usage: "Enable pprof debugging",
EnvVar: "REVA_DEBUG_PPROF",
Destination: &cfg.Debug.Pprof,
},
&cli.BoolFlag{
Name: "debug-zpages",
Usage: "Enable zpages debugging",
EnvVar: "REVA_DEBUG_ZPAGES",
Destination: &cfg.Debug.Zpages,
},
// REVA
&cli.StringFlag{
Name: "jwt-secret",
Value: "Pive-Fumkiu4",
Usage: "Shared jwt secret for reva service communication",
EnvVar: "REVA_JWT_SECRET",
Destination: &cfg.Reva.JWTSecret,
},
// LDAP
&cli.StringFlag{
Name: "ldap-hostname",
Value: "localhost",
Usage: "LDAP hostname",
EnvVar: "REVA_LDAP_HOSTNAME",
Destination: &cfg.Reva.LDAP.Hostname,
},
&cli.IntFlag{
Name: "ldap-port",
Value: 389,
Usage: "LDAP port",
EnvVar: "REVA_LDAP_PORT",
Destination: &cfg.Reva.LDAP.Port,
},
&cli.StringFlag{
Name: "ldap-base-dn",
Value: "dc=owncloud,dc=com",
Usage: "LDAP basedn",
EnvVar: "REVA_LDAP_BASE_DN",
Destination: &cfg.Reva.LDAP.BaseDN,
},
&cli.StringFlag{
Name: "ldap-userfilter",
Value: "(objectclass=posixAccount)",
Usage: "LDAP userfilter",
EnvVar: "REVA_LDAP_USERFILTER",
Destination: &cfg.Reva.LDAP.UserFilter,
},
&cli.StringFlag{
Name: "ldap-groupfilter",
Value: "(objectclass=posixGroup)",
Usage: "LDAP groupfilter",
EnvVar: "REVA_LDAP_GROUPFILTER",
Destination: &cfg.Reva.LDAP.GroupFilter,
},
&cli.StringFlag{
Name: "ldap-bind-dn",
Value: "cn=admin,dc=owncloud,dc=com",
Usage: "LDAP bind dn",
EnvVar: "REVA_LDAP_BIND_DN",
Destination: &cfg.Reva.LDAP.BindDN,
},
&cli.StringFlag{
Name: "ldap-bind-password",
Value: "admin",
Usage: "LDAP bind password",
EnvVar: "REVA_LDAP_BIND_PASSWORD",
Destination: &cfg.Reva.LDAP.BindPassword,
},
// ldap dn is always the dn
&cli.StringFlag{
Name: "ldap-schema-uid",
Value: "uid",
Usage: "LDAP schema uid",
EnvVar: "REVA_LDAP_SCHEMA_UID",
Destination: &cfg.Reva.LDAP.Schema.UID,
},
&cli.StringFlag{
Name: "ldap-schema-mail",
Value: "mail",
Usage: "LDAP schema mail",
EnvVar: "REVA_LDAP_SCHEMA_MAIL",
Destination: &cfg.Reva.LDAP.Schema.Mail,
},
&cli.StringFlag{
Name: "ldap-schema-displayName",
Value: "displayName",
Usage: "LDAP schema displayName",
EnvVar: "REVA_LDAP_SCHEMA_DISPLAYNAME",
Destination: &cfg.Reva.LDAP.Schema.DisplayName,
},
&cli.StringFlag{
Name: "ldap-schema-cn",
Value: "cn",
Usage: "LDAP schema cn",
EnvVar: "REVA_LDAP_SCHEMA_CN",
Destination: &cfg.Reva.LDAP.Schema.CN,
},
// Services
// Users
&cli.StringFlag{
Name: "network",
Value: "tcp",
Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'",
EnvVar: "REVA_USERS_NETWORK",
Destination: &cfg.Reva.Users.Network,
},
&cli.StringFlag{
Name: "protocol",
Value: "grpc",
Usage: "protocol for reva service, can be 'http' or 'grpc'",
EnvVar: "REVA_USERS_PROTOCOL",
Destination: &cfg.Reva.Users.Protocol,
},
&cli.StringFlag{
Name: "addr",
Value: "0.0.0.0:9144",
Usage: "Address to bind reva service",
EnvVar: "REVA_USERS_ADDR",
Destination: &cfg.Reva.Users.Addr,
},
&cli.StringFlag{
Name: "url",
Value: "localhost:9144",
Usage: "URL to use for the reva service",
EnvVar: "REVA_USERS_URL",
Destination: &cfg.Reva.Users.URL,
},
&cli.StringFlag{
Name: "services",
Value: "userprovider", // TODO preferences
Usage: "comma separated list of services to include",
EnvVar: "REVA_USERS_SERVICES",
Destination: &cfg.Reva.Users.Services,
},
&cli.StringFlag{
Name: "driver",
Value: "demo",
Usage: "user driver: 'demo', 'json' or 'ldap'",
EnvVar: "REVA_USERS_DRIVER",
Destination: &cfg.Reva.Users.Driver,
},
&cli.StringFlag{
Name: "json-config",
Value: "",
Usage: "Path to users.json file",
EnvVar: "REVA_USERS_JSON",
Destination: &cfg.Reva.Users.JSON,
},
}
}

View File

@@ -3,8 +3,8 @@ package debug
import (
"context"
"github.com/owncloud/ocis-reva/pkg/config"
"github.com/owncloud/ocis-pkg/log"
"github.com/owncloud/ocis-reva/pkg/config"
)
// Option defines a single option function.
@@ -12,6 +12,8 @@ type Option func(o *Options)
// Options defines the available options for this package.
type Options struct {
Name string
Addr string
Logger log.Logger
Context context.Context
Config *config.Config
@@ -28,6 +30,20 @@ func newOptions(opts ...Option) Options {
return opt
}
// Name provides a function to set the name option.
func Name(val string) Option {
return func(o *Options) {
o.Name = val
}
}
// Addr provides a function to set the addr option.
func Addr(val string) Option {
return func(o *Options) {
o.Addr = val
}
}
// Logger provides a function to set the logger option.
func Logger(val log.Logger) Option {
return func(o *Options) {

View File

@@ -4,9 +4,9 @@ import (
"io"
"net/http"
"github.com/owncloud/ocis-pkg/service/debug"
"github.com/owncloud/ocis-reva/pkg/config"
"github.com/owncloud/ocis-reva/pkg/version"
"github.com/owncloud/ocis-pkg/service/debug"
)
// Server initializes the debug service and server.
@@ -15,9 +15,9 @@ func Server(opts ...Option) (*http.Server, error) {
return debug.NewService(
debug.Logger(options.Logger),
debug.Name("hello"),
debug.Name(options.Name),
debug.Version(version.String),
debug.Address(options.Config.Debug.Addr),
debug.Address(options.Addr),
debug.Token(options.Config.Debug.Token),
debug.Pprof(options.Config.Debug.Pprof),
debug.Zpages(options.Config.Debug.Zpages),