Initialize and manage data with a file
This guide explains how to load data into Casdoor from a JSON or YAML file, how to let Casdoor keep its objects in sync with that file, and how to export the data of a running instance.
Learning outcomes
- Load organizations, applications, users, and other objects when Casdoor starts.
- Keep Casdoor objects in a file in Git and apply changes without a restart.
- Export the data of an instance and load it into another instance.
What you need
- A Casdoor instance and access to its
conf/app.confor its environment variables - For the Kubernetes sections:
kubectlaccess to the cluster, or the Helm chart
About the init data file
When you ship Casdoor as part of a larger product, you can preload organizations, applications, users, and other objects, so that the product works without manual setup. Casdoor reads these objects from one file, the init data file.
The file serves two purposes:
- Initialization: Casdoor loads the file once, when it starts.
- Configuration as code: Casdoor watches the file and applies every change while it runs. See Manage configuration as code.
A template is available at init_data.json.template. A file that ends in .yaml or .yml is read as YAML with the same structure.