poc: deploymeny example + driver tweaks
This commit is contained in:
6 files changed
+137
-25
No files matched your search
@@ -23,3 +23,45 @@ Keycloak can be optionally enabled by uncommenting the corresponding variables i
|
||||
- `KEYCLOAK=:keycloak.yml`
|
||||
|
||||
Note that Keycloak requires the default `ocis` Identity Provider to be disabled, which is automatically handled when the `keycloak.yml` configuration is used.
|
||||
|
||||
### Kiteworks Storage
|
||||
|
||||
Enables a read-only Kiteworks storage provider alongside the default oCIS storage.
|
||||
Kiteworks top-level folders appear as project spaces in the oCIS web UI.
|
||||
Creating new project spaces from the UI continues to use decomposedfs.
|
||||
|
||||
**Prerequisites:**
|
||||
|
||||
The Kiteworks storage driver is not part of an upstream oCIS release. Build the `owncloud/ocis:dev` image locally from this branch:
|
||||
```bash
|
||||
make -C ocis dev-docker
|
||||
```
|
||||
|
||||
**Required `.env` variables:**
|
||||
```env
|
||||
KITEWORKS_ENDPOINT=https://your-kiteworks-instance.example.com
|
||||
KITEWORKS_API_TOKEN=<your-api-token>
|
||||
```
|
||||
|
||||
**Optional `.env` variables:**
|
||||
```env
|
||||
KITEWORKS_MOUNT_ID=aa309def-b364-417b-8e41-85b8a9393c4b # stable UUID; change only to avoid collision with another deployment
|
||||
KITEWORKS_INSECURE=false # set true only if the Kiteworks TLS cert is self-signed
|
||||
```
|
||||
|
||||
**Start command:**
|
||||
```bash
|
||||
docker compose -f docker-compose.yml -f ocis.yml -f kiteworks-storage.yml up -d
|
||||
```
|
||||
|
||||
**Verify:**
|
||||
```bash
|
||||
# Kiteworks folders appear as project spaces alongside the personal decomposedfs space
|
||||
curl -su admin:admin "https://${OCIS_DOMAIN}/graph/v1.0/me/drives" \
|
||||
| jq '.value[] | {name, driveType}'
|
||||
|
||||
# Creating a new project space must succeed (HTTP 201) and land on decomposedfs
|
||||
curl -su admin:admin -X POST "https://${OCIS_DOMAIN}/graph/v1.0/drives" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"my space","driveType":"project"}' -w "\nHTTP %{http_code}\n"
|
||||
```
|
||||
@@ -0,0 +1,50 @@
|
||||
---
|
||||
services:
|
||||
ocis:
|
||||
environment:
|
||||
NATS_NATS_HOST: 0.0.0.0
|
||||
SETTINGS_GRPC_ADDR: ocis:9191
|
||||
# register the kiteworks storage-users sidecar in the gateway storage registry
|
||||
GATEWAY_STORAGE_KITEWORKS_ENDPOINT: storage-users-kiteworks:9460
|
||||
GATEWAY_STORAGE_KITEWORKS_MOUNT_ID: ${KITEWORKS_MOUNT_ID:-aa309def-b364-417b-8e41-85b8a9393c4b}
|
||||
|
||||
storage-users-kiteworks:
|
||||
image: ${OCIS_DOCKER_IMAGE:-owncloud/ocis}:${OCIS_DOCKER_TAG:-dev}
|
||||
networks:
|
||||
ocis-net:
|
||||
depends_on:
|
||||
ocis:
|
||||
condition: service_started
|
||||
command: ["storage-users", "server"]
|
||||
environment:
|
||||
OCIS_LOG_LEVEL: ${LOG_LEVEL:-info}
|
||||
OCIS_LOG_COLOR: "${LOG_PRETTY:-false}"
|
||||
OCIS_LOG_PRETTY: "${LOG_PRETTY:-false}"
|
||||
OCIS_INSECURE: "${INSECURE:-false}"
|
||||
# point all service-discovery and event endpoints at the main ocis container
|
||||
OCIS_GATEWAY_GRPC_ADDR: ocis:9142
|
||||
OCIS_EVENTS_ENDPOINT: ocis:9233
|
||||
OCIS_CACHE_STORE_NODES: ocis:9233
|
||||
MICRO_REGISTRY_ADDRESS: ocis:9233
|
||||
# required when INSECURE=true (ocis uses self-signed TLS on its NATS)
|
||||
STORAGE_USERS_EVENTS_TLS_INSECURE: "${INSECURE:-false}"
|
||||
STORAGE_USERS_EVENTS_CONSUMER_GROUP: kiteworks-dcfs
|
||||
# unique service identity so the registry treats this as a separate provider
|
||||
STORAGE_USERS_SERVICE_NAME: storage-users-kiteworks
|
||||
STORAGE_USERS_MOUNT_ID: ${KITEWORKS_MOUNT_ID:-aa309def-b364-417b-8e41-85b8a9393c4b}
|
||||
# use ports that don't conflict with the default storage-users (9160/9161/9159)
|
||||
STORAGE_USERS_GRPC_ADDR: storage-users-kiteworks:9460
|
||||
STORAGE_USERS_HTTP_ADDR: storage-users-kiteworks:9461
|
||||
STORAGE_USERS_DATA_SERVER_URL: http://storage-users-kiteworks:9461/data
|
||||
STORAGE_USERS_DEBUG_ADDR: storage-users-kiteworks:9459
|
||||
# kiteworks driver configuration
|
||||
STORAGE_USERS_DRIVER: kiteworks
|
||||
STORAGE_USERS_KITEWORKS_ENDPOINT: ${KITEWORKS_ENDPOINT}
|
||||
STORAGE_USERS_KITEWORKS_API_TOKEN: ${KITEWORKS_API_TOKEN}
|
||||
STORAGE_USERS_KITEWORKS_INSECURE: "${KITEWORKS_INSECURE:-false}"
|
||||
volumes:
|
||||
- ${OCIS_CONFIG_DIR:-ocis-config}:/etc/ocis
|
||||
- ${OCIS_DATA_DIR:-ocis-data}:/var/lib/ocis
|
||||
logging:
|
||||
driver: ${LOG_DRIVER:-local}
|
||||
restart: always
|
||||
@@ -219,6 +219,7 @@ func spacesProviders(cfg *config.Config, logger log.Logger) map[string]map[strin
|
||||
if cfg.StorageKiteworksEndpoint != "" {
|
||||
rules[cfg.StorageKiteworksEndpoint] = map[string]interface{}{
|
||||
"providerid": cfg.StorageKiteworksMountID,
|
||||
"readonly": true,
|
||||
"spaces": map[string]interface{}{
|
||||
"project": map[string]interface{}{
|
||||
"mount_point": "/kiteworks",
|
||||
|
||||
+3
-1
@@ -292,7 +292,9 @@ func (s *Server) Stop() error {
|
||||
|
||||
// GracefulStop gracefully stops the server.
|
||||
func (s *Server) GracefulStop() error {
|
||||
s.s.GracefulStop()
|
||||
if s.s != nil {
|
||||
s.s.GracefulStop()
|
||||
}
|
||||
s.cleanupServices()
|
||||
return nil
|
||||
}
|
||||
|
||||
+34
-24
@@ -143,26 +143,18 @@ func (d *Driver) ListStorageSpaces(ctx context.Context, _ []*provider.ListStorag
|
||||
return spaces, nil
|
||||
}
|
||||
|
||||
// resolveRef resolves a CS3 reference to a KW node ID, space ID, and the
|
||||
// absolute KW path of the space root. If ref.Path is set it walks the path
|
||||
// component-by-component through the KW folder tree.
|
||||
func (d *Driver) resolveRef(ctx context.Context, ref *provider.Reference) (nodeID, spaceID, spaceRootPath string, err error) {
|
||||
// resolveRef walks a CS3 reference to the target KW node ID and space ID.
|
||||
// If ref.Path is non-empty it resolves each component through ListFolderContents.
|
||||
func (d *Driver) resolveRef(ctx context.Context, ref *provider.Reference) (nodeID, spaceID string, err error) {
|
||||
spaceID = ref.GetResourceId().GetSpaceId()
|
||||
nodeID = ref.GetResourceId().GetOpaqueId()
|
||||
if nodeID == "" {
|
||||
nodeID = spaceID
|
||||
}
|
||||
|
||||
root, err := d.client(ctx).GetFolderByID(spaceID)
|
||||
if err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
spaceRootPath = root.Path
|
||||
|
||||
relPath := strings.TrimPrefix(strings.Trim(ref.GetPath(), "/"), ".")
|
||||
relPath = strings.Trim(relPath, "/")
|
||||
relPath := strings.Trim(strings.TrimPrefix(ref.GetPath(), "./"), "/.")
|
||||
if relPath == "" {
|
||||
return nodeID, spaceID, spaceRootPath, nil
|
||||
return nodeID, spaceID, nil
|
||||
}
|
||||
|
||||
c := d.client(ctx)
|
||||
@@ -172,7 +164,7 @@ func (d *Driver) resolveRef(ctx context.Context, ref *provider.Reference) (nodeI
|
||||
}
|
||||
children, err := c.ListFolderContents(nodeID)
|
||||
if err != nil {
|
||||
return "", "", "", err
|
||||
return "", "", err
|
||||
}
|
||||
var found bool
|
||||
for i := range children {
|
||||
@@ -183,18 +175,32 @@ func (d *Driver) resolveRef(ctx context.Context, ref *provider.Reference) (nodeI
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
return "", "", "", errtypes.NotFound(part)
|
||||
return "", "", errtypes.NotFound(part)
|
||||
}
|
||||
}
|
||||
return nodeID, spaceID, spaceRootPath, nil
|
||||
return nodeID, spaceID, nil
|
||||
}
|
||||
|
||||
// spaceRootPath fetches the absolute KW path of the space root folder.
|
||||
// Used by callers that need to convert absolute KW paths to space-relative paths.
|
||||
func (d *Driver) spaceRootPath(ctx context.Context, spaceID string) (string, error) {
|
||||
root, err := d.client(ctx).GetFolderByID(spaceID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return root.Path, nil
|
||||
}
|
||||
|
||||
func (d *Driver) GetMD(ctx context.Context, ref *provider.Reference, _, _ []string) (*provider.ResourceInfo, error) {
|
||||
nodeID, spaceID, spaceRootPath, err := d.resolveRef(ctx, ref)
|
||||
nodeID, spaceID, err := d.resolveRef(ctx, ref)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return d.nodeMD(ctx, nodeID, spaceID, spaceRootPath)
|
||||
rootPath, err := d.spaceRootPath(ctx, spaceID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return d.nodeMD(ctx, nodeID, spaceID, rootPath)
|
||||
}
|
||||
|
||||
// nodeMD fetches metadata for a node, trying folder first then file.
|
||||
@@ -220,7 +226,7 @@ func (d *Driver) nodeMD(ctx context.Context, nodeID, spaceID, spaceRootPath stri
|
||||
}
|
||||
|
||||
func (d *Driver) ListFolder(ctx context.Context, ref *provider.Reference, _, _ []string) ([]*provider.ResourceInfo, error) {
|
||||
nodeID, spaceID, spaceRootPath, err := d.resolveRef(ctx, ref)
|
||||
nodeID, spaceID, err := d.resolveRef(ctx, ref)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -232,7 +238,7 @@ func (d *Driver) ListFolder(ctx context.Context, ref *provider.Reference, _, _ [
|
||||
|
||||
infos := make([]*provider.ResourceInfo, 0, len(items))
|
||||
for i := range items {
|
||||
ri := d.toResourceInfo(&items[i], spaceID, spaceRootPath)
|
||||
ri := d.toResourceInfo(&items[i], spaceID, "")
|
||||
ri.Path = "/" + items[i].Name
|
||||
infos = append(infos, ri)
|
||||
}
|
||||
@@ -240,12 +246,16 @@ func (d *Driver) ListFolder(ctx context.Context, ref *provider.Reference, _, _ [
|
||||
}
|
||||
|
||||
func (d *Driver) Download(ctx context.Context, ref *provider.Reference, openReaderFunc func(*provider.ResourceInfo) bool) (*provider.ResourceInfo, io.ReadCloser, error) {
|
||||
nodeID, spaceID, spaceRootPath, err := d.resolveRef(ctx, ref)
|
||||
nodeID, spaceID, err := d.resolveRef(ctx, ref)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
rootPath, err := d.spaceRootPath(ctx, spaceID)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
ri, err := d.nodeMD(ctx, nodeID, spaceID, spaceRootPath)
|
||||
ri, err := d.nodeMD(ctx, nodeID, spaceID, rootPath)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -262,11 +272,11 @@ func (d *Driver) Download(ctx context.Context, ref *provider.Reference, openRead
|
||||
}
|
||||
|
||||
func (d *Driver) GetPathByID(ctx context.Context, id *provider.ResourceId) (string, error) {
|
||||
root, err := d.client(ctx).GetFolderByID(id.GetSpaceId())
|
||||
rootPath, err := d.spaceRootPath(ctx, id.GetSpaceId())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
ri, err := d.nodeMD(ctx, id.GetOpaqueId(), id.GetSpaceId(), root.Path)
|
||||
ri, err := d.nodeMD(ctx, id.GetOpaqueId(), id.GetSpaceId(), rootPath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
+7
@@ -79,6 +79,9 @@ type Provider struct {
|
||||
// Spaces is a map from space type to space config
|
||||
Spaces map[string]*spaceConfig `mapstructure:"spaces"`
|
||||
ProviderID string `mapstructure:"providerid"`
|
||||
// ReadOnly marks providers that serve existing spaces but cannot create new ones.
|
||||
// GetProvider skips them unless the request explicitly targets this provider via storage_id.
|
||||
ReadOnly bool `mapstructure:"readonly"`
|
||||
}
|
||||
|
||||
type templateData struct {
|
||||
@@ -205,6 +208,10 @@ func (r *registry) GetProvider(ctx context.Context, space *providerpb.StorageSpa
|
||||
if provider.ProviderID == utils.VaultStorageProviderID {
|
||||
continue
|
||||
}
|
||||
// Skip read-only providers (e.g. kiteworks) — they cannot create spaces
|
||||
if provider.ReadOnly {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if space.Owner != nil {
|
||||
|
||||
Reference in new issue
Block a user