Skip to content

Commit

Permalink
docs: improve the init data docs (#608)
Browse files Browse the repository at this point in the history
docs: add data initialization document
  • Loading branch information
xiao-kong-long authored Mar 5, 2024
1 parent 56b6959 commit 58a4d62
Showing 1 changed file with 35 additions and 10 deletions.
45 changes: 35 additions & 10 deletions docs/deployment/data-initialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ If you are deploying Casdoor with other services as a complete application, you

In such a situation, you can use data initialization to register your service in Casdoor through a configuration file. This file can be pre-defined or dynamically generated by your own service.

## How to use
Here we give a tutorial for importing or exporting config data.

## Import Config Data

If there is a configuration file named `init_data.json` at the root directory of Casdoor, it will be used to initialize data in Casdoor. All you have to do is place this file in the root directory where Casdoor will run.

Expand Down Expand Up @@ -58,19 +60,42 @@ spec:
name: casdoor-init-data-volume
```

## File details
## Export Config Data

Also, you can export configuration of your casdoor for transfering. It's easy! What should you do is run test case in `{root directory of casdoor}/object/init_data_dump_test.go`, a file named `init_data_dump.json` would genereated in same directory if testing successfully, this file contains your configuration information. If you want to transfer configuration of your casdoor project to another, just rename `init_data_dump.json` to `init_data.json` and move it to root directory of target casdoor project.

There is already a template named `init_data.json.template` in the root directory of Casdoor repository. You can refer to this file to customize your initialization.
## Reference

The following is the Go struct of each part and their documentation:
Here we list all configuration fields as follows:

| Object | Go Struct | Documentation |
|--------------------|-----------|--------------------------------------------------------|
| organizations | [struct](https://github.com/casdoor/casdoor/blob/2fec3f72ae9a38891a951e55e088b4967cdf4836/object/organization.go#L32) | [doc](https://casdoor.org/docs/organization/overview) |
| applications | [struct](https://github.com/casdoor/casdoor/blob/2fec3f72ae/object/application.go#L34) | [doc](https://casdoor.org/docs/application/overview) |
| users | [struct](https://github.com/casdoor/casdoor/blob/2fec3f72ae9a38891a951e55e088b4967cdf4836/object/user.go#L27) | [doc](https://casdoor.org/docs/user/overview) |
| providers | [struct](https://github.com/casdoor/casdoor/blob/2fec3f72ae9a38891a951e55e088b4967cdf4836/object/provider.go#L25) | [doc](https://casdoor.org/docs/provider/overview) |
| certs | [struct](https://github.com/casdoor/casdoor/blob/2fec3f72ae9a38891a951e55e088b4967cdf4836/object/cert.go#L24) |
| ldaps | [struct](https://github.com/casdoor/casdoor/blob/2fec3f72ae9a38891a951e55e088b4967cdf4836/object/ldap.go#L28) | [doc](https://casdoor.org/docs/ldap/overview) |
| organizations | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/organization.go#L50) | [doc](https://casdoor.org/docs/organization/overview) |
| applications | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/application.go#L59) | [doc](https://casdoor.org/docs/application/overview) |
| users | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/user.go#L49) | [doc](https://casdoor.org/docs/user/overview) |
| certs | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/cert.go#L24) | |
| providers | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/provider.go#L29) | [doc](https://casdoor.org/docs/provider/overview) |
| ldaps | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/ldap.go#L21) | [doc](https://casdoor.org/docs/ldap/overview) |
| models | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/model.go#L26) | |
| permissions | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/permission.go#L26) | [doc](https://casdoor.org/docs/permission/overview) |
| payments | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/payment.go#L26) | [doc](https://casdoor.org/zh/docs/products/payment) |
| products | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/product.go#L28) | [doc](https://casdoor.org/zh/docs/products/product) |
| resources | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/resource.go#L25) | [doc](https://casdoor.org/docs/resources/overview) |
| roles | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/role.go#L27) | [doc](https://casdoor.org/zh/docs/user/roles) |
| syncers | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/syncer.go#L33) | [doc](https://casdoor.org/docs/syncer/overview) |
| tokens | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/token.go#L46) | [doc](https://casdoor.org/docs/token/overview) |
| webhooks | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/webhook.go#L29) | [doc](https://casdoor.org/docs/webhooks/overview) |
| groups | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/group.go#L27) | [doc](https://casdoor.org/zh/docs/organization/organization-tree) |
| adapters | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/adapter.go#L28) | [doc](https://casdoor.org/zh/docs/permission/adapter) |
| enforcers | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/enforcer.go#L26) | |
| plans | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/plan.go#L25) | [doc](https://casdoor.org/zh/docs/pricing/plan) |
| pricings | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/pricing.go#L24) | [doc](https://casdoor.org/docs/pricing/overview) |
| invitations | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/invitation.go#L25) | [doc](https://casdoor.org/zh/docs/application/invitation-code) |
| records | [struct](https://github.com/casvisor/casvisor-go-sdk/blob/afd3c328ccf117cde693bf6f850d467933ceb1f7/casvisorsdk/record.go#L24) | |
| sessions | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/session.go#L30) | |
| subscriptions | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/subscription.go#L39) | [doc](https://casdoor.org/zh/docs/pricing/subscription) |
| transactions | [struct](https://github.com/casdoor/casdoor/blob/f9ee8a68cb36ef39a551ee49907c239b9d71840c/object/transaction.go#L24) | |

In addition, we provide a template named `init_data.json.template` in the root directory of Casdoor repository for your reference.

If you still feel confused about filling out this template, you can call the RESTful API or use the debug mode of your browser to see the response of `GetXXX` to these objects. The responses are in the same format as `init_data.json`.

0 comments on commit 58a4d62

Please sign in to comment.