Skip to content

Commit b2e2ea7

Browse files
committed
README: update on extends
1 parent 015c3bf commit b2e2ea7

File tree

1 file changed

+83
-15
lines changed

1 file changed

+83
-15
lines changed

README.md

Lines changed: 83 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ See [announcement blog post for motivation](XXX).
1616
- **Multiple Provider Backends**: [Keyring](https://docs.rs/keyring/latest/keyring/) (system credential store), [.env](https://www.dotenv.org/), and environment variable support
1717
- **Type-Safe Rust SDK**: Generate strongly-typed structs from your `secretspec.toml` for compile-time safety
1818
- **Profile Support**: Override secret requirements and defaults per profile (development, production, etc.)
19+
- **Configuration Inheritance**: Extend and override shared configurations using the `extends` feature
1920
- **Simple Migration**: `secretspec init` to migrate from existing `.env` files
2021

2122
## Quick Start
@@ -79,23 +80,21 @@ Each project has a `secretspec.toml` file that declares the required secrets:
7980
[project]
8081
name = "my-app" # Inferred from current directory name when using `secretspec init`
8182
revision = "1.0"
83+
# Optional: extend other configuration files
84+
extends = ["../shared/common", "../shared/auth"]
8285

83-
[secrets.DATABASE_URL]
84-
description = "PostgreSQL connection string"
85-
required = true
86+
[profiles.default]
87+
DATABASE_URL = { description = "PostgreSQL connection string", required = true }
88+
REDIS_URL = { description = "Redis connection string", required = false, default = "redis://localhost:6379" }
8689

87-
[secrets.REDIS_URL]
88-
description = "Redis connection string"
89-
required = false
90-
default = "redis://localhost:6379"
90+
# Profile-specific configurations
91+
[profiles.development]
92+
DATABASE_URL = { description = "PostgreSQL connection string", required = false, default = "sqlite://./dev.db" }
93+
REDIS_URL = { description = "Redis connection string", required = false, default = "redis://localhost:6379" }
9194

92-
# Profile-specific overrides
93-
[secrets.DATABASE_URL.development]
94-
default = "sqlite://./dev.db"
95-
required = false
96-
97-
[secrets.DATABASE_URL.production]
98-
required = true # no default - must be set
95+
[profiles.production]
96+
DATABASE_URL = { description = "PostgreSQL connection string", required = true }
97+
REDIS_URL = { description = "Redis connection string", required = true }
9998
```
10099

101100
### Provider Configuration
@@ -108,11 +107,13 @@ SecretSpec provider can be configured through three methods (in order of precede
108107

109108
## Provider Backends
110109

111-
SecretSpec includes three built-in provider backends:
110+
SecretSpec includes five built-in provider backends:
112111

113112
- **keyring** - Secure system credential store integration
114113
- **dotenv** - Local .env file storage
115114
- **env** - Read-only environment variable access
115+
- **lastpass** - LastPass password manager integration
116+
- **1password** - 1Password secrets management
116117

117118
*Additional provider backends are welcome!**
118119

@@ -156,6 +157,73 @@ your-connection-string
156157
$ secretspec check --provider env
157158
```
158159

160+
### LastPass Provider
161+
162+
Integrates with LastPass password manager for secure cloud-based secret storage.
163+
164+
```bash
165+
# Use LastPass for this command
166+
$ secretspec set DATABASE_URL --provider lastpass
167+
168+
# Check secrets from LastPass
169+
$ secretspec check --provider lastpass
170+
```
171+
172+
### 1Password Provider
173+
174+
Integrates with 1Password for team-based secret management.
175+
176+
```bash
177+
# Use 1Password for this command
178+
$ secretspec set DATABASE_URL --provider 1password
179+
180+
# Run with 1Password secrets
181+
$ secretspec run --provider 1password -- npm start
182+
```
183+
184+
185+
## Configuration Inheritance
186+
187+
SecretSpec supports configuration inheritance through the `extends` field in the `[project]` section. This allows you to:
188+
189+
- Share common secrets across multiple projects
190+
- Build layered configurations (base → shared → project-specific)
191+
- Maintain DRY principles in your secret management
192+
193+
### Example: Shared Configuration
194+
195+
**shared/common/secretspec.toml:**
196+
```toml
197+
[project]
198+
name = "common"
199+
revision = "1.0"
200+
201+
[profiles.default]
202+
DATABASE_URL = { description = "Main database", required = true }
203+
REDIS_URL = { description = "Cache server", required = false, default = "redis://localhost:6379" }
204+
```
205+
206+
**myapp/secretspec.toml:**
207+
```toml
208+
[project]
209+
name = "myapp"
210+
revision = "1.0"
211+
extends = ["../shared/common"]
212+
213+
[profiles.default]
214+
# Override DATABASE_URL description
215+
DATABASE_URL = { description = "MyApp database", required = true }
216+
# Add new app-specific secret
217+
API_KEY = { description = "External API key", required = true }
218+
```
219+
220+
### Inheritance Rules
221+
222+
- Multiple configs can be extended: `extends = ["../common", "../auth"]`
223+
- Paths are relative to the extending file's directory
224+
- The extending config takes precedence over extended configs
225+
- Secrets are merged at the profile level
226+
- Circular dependencies are detected and prevented
159227

160228
## Rust SDK
161229

0 commit comments

Comments
 (0)