Skip to content

Add INI store docs #41

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 142 additions & 0 deletions content/Stores/ini-file.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
---
id: ini-file
slug: ini-file
title: INI File
---

Integrates the Configu Orchestrator with your INI files.

## Limitations

<Admonition type="info">
- Configs belonging to the root set will always appear above all other section due to how INI files work.

</Admonition>

## SDK Usage

<CodeTabs labels={["Node SDK", "Python SDK"]}>

```js
import path from 'path';
import {
IniFileConfigStore,
ConfigSet,
ConfigSchema,
UpsertCommand,
EvalCommand,
ExportCommand,
TestCommand,
DeleteCommand,
} from '@configu/node';

(async () => {
try {
const store = new IniFileConfigStore({ path: 'store.ini' });
const set = new ConfigSet('test');
const schema = new ConfigSchema(path.join(__dirname, 'get-started.cfgu.json'));

await new TestCommand({ store, clean: true }).run();

await new UpsertCommand({
store,
set,
schema,
configs: {
GREETING: 'hey',
SUBJECT: 'configu node.js sdk',
},
}).run();

const data = await new EvalCommand({
store,
set,
schema,
}).run();

const configurationData = await new ExportCommand({
data,
}).run();

console.log(configurationData);

await new DeleteCommand({ store, set, schema }).run();
} catch (error) {
console.error(error);
}
})();
```

```python
coming soon
```

</CodeTabs>

## CLI Usage

Configu's CLI needs to be directed to your desired file by providing a file path via the [.configu file](../cli-config).

example .configu file:

```json
{
"stores": {
"ini-file-store": {
"type": "ini-file",
"configuration": {
"path": "path/to/file.ini"
}
}
}
}
```

### Test command

```bash
configu test --store "ini-file-store" --clean
```

### Upsert command

```bash
configu upsert --store "ini-file-store" --set "test" --schema "./get-started.cfgu.json" \
-c "GREETING=hey" \
-c "SUBJECT=configu node.js sdk"
```

### Eval and export commands

```bash
configu eval --store "ini-file-store" --set "test" --schema "./get-started.cfgu.json" \
| configu export
```

Export result:

```json
{
"GREETING": "hey",
"SUBJECT": "configu node.js sdk",
"MESSAGE": "hey, configu node.js sdk!"
}
```

### Delete command

Clean up the previous upsert by using:

```bash
configu delete --store "ini-file-store" --set "test" --schema "./get-started.cfgu.json"
```

## Examples

INI file store after upsert:

```ini
[test]
GREETING=hey
SUBJECT=configu node.js sdk
```
10 changes: 10 additions & 0 deletions content/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@
}
]
},
{
"title": "Stores",
"isOpenByDefault": false,
"items": [
{
"title": "INI file",
"slug": "ini-file"
}
]
},
{
"title": "IDE Plugins",
"isOpenByDefault": false,
Expand Down