Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create multiple namespaces using "file:///" source #669

Closed
cvolante54 opened this issue Jul 30, 2021 · 5 comments
Closed

Cannot create multiple namespaces using "file:///" source #669

cvolante54 opened this issue Jul 30, 2021 · 5 comments
Labels
stale Feedback from one or more authors is required to proceed.

Comments

@cvolante54
Copy link

cvolante54 commented Jul 30, 2021

Describe the bug

When using a file as the source to configure the namespaces, the interface is limited to only one file, and the file itself is limited to only allow for one namespace to be created (source code: https://github.com/ory/keto/blob/master/internal/driver/config/namespace_watcher.go#L152)

Reproducing the bug

Steps to reproduce the behavior:

  1. Run keto version v0.6
  2. Configure the namespaces parameter in the configuration file to be "namespaces: file:///etc/extra/config/keto_namespaces.json"
  3. Inside the keto_namespaces.json only one namespace definition is allowed (ex. { "id": 0, "name": "sample" })

Server logs
When an array of namespaces is passed into the file:

level=error msg=could not parse namespace file audience=application error=map[message:json: cannot unmarshal array into Go value of type namespace.Namespace] file_name=/etc/extra/config/keto_namespaces.json service_name=ORY Keto service_version=master

Server configuration
The only relevant section:

namespaces: file:///etc/extra/config/keto_namespaces.json

Expected behavior

I expect that multiple namespaces can be passed through a file namespaces source just like multiple namespaces can be defined in the configuration file itself.

Environment

  • Version: v0.6
  • Environment: Docker/Kubernetes
@zepatrik
Copy link
Member

To specify multiple files, use an array of paths:

namespaces:
  - file:///path1
  - file:///path2
  - file:///path3

or alternatively, point the path to the directory that contains all namespace files:

namespaces: file:///keto-namespaces

@zepatrik
Copy link
Member

The relevant code for that is here:

info, err := os.Stat(u.Path)
if err != nil {
return nil, errors.WithStack(err)
}
if info.IsDir() {
nw.w, err = watcherx.WatchDirectory(ctx, u.Path, nw.ec)
} else {
nw.w, err = watcherx.Watch(ctx, u, nw.ec)
}

@zepatrik
Copy link
Member

zepatrik commented Aug 3, 2021

@cvolante54 can you confirm this is working now?

@zepatrik zepatrik added the stale Feedback from one or more authors is required to proceed. label Aug 3, 2021
@cvolante54
Copy link
Author

@zepatrik Yes, using a directory path and multiple files worked!

@zepatrik
Copy link
Member

zepatrik commented Aug 3, 2021

Awesome 👍

@zepatrik zepatrik closed this as completed Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Feedback from one or more authors is required to proceed.
Projects
None yet
Development

No branches or pull requests

2 participants