Skip to content

Commit 950b79e

Browse files
docs: add Git repository initialization guide for v2
Add comprehensive documentation for initializing Git repositories with existing features files in Flipt v2. This addresses the common workflow where users have existing feature.yaml/yml files but no Git repository initialized. Key features documented: - Support for both features.yaml and features.yml - Git repository detection and initialization - Working directory synchronization - Docker usage patterns - Configuration examples and troubleshooting Closes #361 (documents .yml file support) Related to flipt-io/flipt#4674 and flipt-io/flipt#4623 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Mark Phelps <[email protected]>
1 parent 1f6af7a commit 950b79e

File tree

2 files changed

+249
-26
lines changed

2 files changed

+249
-26
lines changed

docs.json

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@
2929
"groups": [
3030
{
3131
"group": "Overview",
32-
"pages": [
33-
"introduction",
34-
"concepts"
35-
]
32+
"pages": ["introduction", "concepts"]
3633
},
3734
{
3835
"group": "Use Cases",
@@ -177,9 +174,7 @@
177174
},
178175
{
179176
"group": "Authorization",
180-
"pages": [
181-
"authorization/overview"
182-
]
177+
"pages": ["authorization/overview"]
183178
},
184179
{
185180
"group": "Operations",
@@ -206,9 +201,7 @@
206201
"groups": [
207202
{
208203
"group": "Overview",
209-
"pages": [
210-
"reference/overview"
211-
]
204+
"pages": ["reference/overview"]
212205
},
213206
{
214207
"group": "Authentication",
@@ -319,9 +312,7 @@
319312
{
320313
"anchor": "Changelog",
321314
"icon": "clock",
322-
"pages": [
323-
"changelog/overview"
324-
]
315+
"pages": ["changelog/overview"]
325316
},
326317
{
327318
"anchor": "AI Context",
@@ -370,10 +361,7 @@
370361
"group": "Pro Features",
371362
"tag": "NEW",
372363
"icon": "crown",
373-
"pages": [
374-
"/v2/pro",
375-
"/v2/licensing"
376-
]
364+
"pages": ["/v2/pro", "/v2/licensing"]
377365
},
378366
{
379367
"group": "Configuration",
@@ -399,9 +387,7 @@
399387
"v2/integration/overview",
400388
{
401389
"group": "Server-Side SDKs",
402-
"pages": [
403-
"v2/integration/server/rest"
404-
]
390+
"pages": ["v2/integration/server/rest"]
405391
},
406392
"v2/integration/client",
407393
"v2/integration/openfeature"
@@ -466,6 +452,7 @@
466452
{
467453
"group": "Environments",
468454
"pages": [
455+
"v2/guides/operations/environments/git-repository-initialization",
469456
"v2/guides/operations/environments/git-sync",
470457
"v2/guides/operations/environments/git-scm",
471458
"v2/guides/operations/environments/commit-signing-setup"
@@ -475,19 +462,15 @@
475462
},
476463
{
477464
"group": "Migration Guides",
478-
"pages": [
479-
"v2/guides/migration/cloud/flipt-cloud-to-v2"
480-
]
465+
"pages": ["v2/guides/migration/cloud/flipt-cloud-to-v2"]
481466
}
482467
]
483468
},
484469
{
485470
"group": "Tooling",
486471
"icon": "hammer",
487472
"tag": "NEW",
488-
"pages": [
489-
"v2/tooling/github-actions"
490-
]
473+
"pages": ["v2/tooling/github-actions"]
491474
}
492475
]
493476
},
Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
---
2+
title: Git Repository Initialization
3+
description: Learn how to initialize Git repositories for existing feature flag configurations in Flipt v2.
4+
---
5+
6+
This guide explains how to set up Git repository initialization for existing feature flag configurations in Flipt v2. This is particularly useful when you already have `features.yaml` or `features.yml` files but need to initialize version control for them.
7+
8+
## Overview
9+
10+
Flipt v2 supports automatic Git repository detection and initialization for existing feature files when using the local storage backend. This addresses the common workflow where you have existing feature flag configurations but no Git repository initialized yet.
11+
12+
Previously, when users had existing feature files but no Git repository, Flipt would fail with errors like:
13+
14+
- `"repository does not exist"`
15+
- `"reference not found"`
16+
17+
With the enhancements introduced in Flipt v2, you can now follow an intuitive workflow to initialize Git repositories for your existing feature configurations.
18+
19+
## Supported File Formats
20+
21+
Flipt v2 supports both YAML file extensions for feature configurations:
22+
23+
- `features.yaml` (recommended)
24+
- `features.yml`
25+
26+
Both formats work identically and you can use whichever extension you prefer.
27+
28+
## Basic Setup Workflow
29+
30+
The typical workflow for initializing a Git repository with existing feature files is:
31+
32+
### 1. Organize Your Feature Files
33+
34+
Create a directory structure with your existing features:
35+
36+
```bash
37+
mkdir -p my-project/flags/production
38+
cp existing-features.yaml my-project/flags/production/features.yaml
39+
```
40+
41+
### 2. Initialize Git Repository
42+
43+
Navigate to your flags directory and initialize Git:
44+
45+
```bash
46+
cd my-project/flags
47+
git init
48+
git add .
49+
git commit -m "Initial features"
50+
```
51+
52+
### 3. Configure Flipt
53+
54+
Create a Flipt configuration that points to your flags directory:
55+
56+
```yaml
57+
storage:
58+
local:
59+
name: "local"
60+
backend:
61+
type: local
62+
path: "flags" # Path to your flags directory
63+
branch: "main"
64+
65+
environments:
66+
default:
67+
name: "Default"
68+
storage: "local"
69+
default: true
70+
```
71+
72+
### 4. Start Flipt Server
73+
74+
Run Flipt pointing to your configuration:
75+
76+
```bash
77+
cd .. # Back to my-project directory
78+
flipt server --config config.yml
79+
```
80+
81+
## Repository Detection
82+
83+
Flipt v2 includes enhanced repository detection logic that can handle:
84+
85+
1. **Normal Git Repositories**: Standard repositories created with `git init` (with `.git` subdirectory)
86+
2. **Bare Repositories**: Repositories managed internally by Flipt (Git files in root directory)
87+
3. **Automatic Fallback**: Graceful handling when repository types are ambiguous
88+
89+
The system automatically:
90+
91+
- Detects the repository type
92+
- Creates necessary remote tracking references (`refs/remotes/origin/main`)
93+
- Sets up proper branch management for Flipt's operations
94+
95+
## Working Directory Synchronization
96+
97+
When you make changes through the Flipt UI, the system automatically:
98+
99+
- Updates the actual `.yaml` files on disk for normal repositories
100+
- Maintains backward compatibility with existing bare repository workflows
101+
- Synchronizes changes back to the filesystem
102+
103+
This means changes made in the Flipt web interface will be reflected in your actual feature files, allowing you to see modifications through standard Git tools.
104+
105+
## Configuration Examples
106+
107+
### Basic Local Storage
108+
109+
```yaml
110+
storage:
111+
backend:
112+
type: local
113+
path: "." # Current directory
114+
```
115+
116+
### Multiple Environments
117+
118+
```yaml
119+
storage:
120+
staging:
121+
name: "Staging"
122+
backend:
123+
type: local
124+
path: "flags/staging"
125+
branch: "staging"
126+
production:
127+
name: "Production"
128+
backend:
129+
type: local
130+
path: "flags/production"
131+
branch: "main"
132+
133+
environments:
134+
staging:
135+
name: "Staging"
136+
storage: "staging"
137+
production:
138+
name: "Production"
139+
storage: "production"
140+
default: true
141+
```
142+
143+
### With Remote Git Repository
144+
145+
You can also combine local storage with remote Git synchronization:
146+
147+
```yaml
148+
storage:
149+
local:
150+
name: "Local with Remote"
151+
remote: "https://github.com/your-org/feature-flags.git"
152+
branch: "main"
153+
poll_interval: "30s"
154+
credentials: "github"
155+
backend:
156+
type: local
157+
path: "flags"
158+
159+
environments:
160+
default:
161+
name: "Default"
162+
storage: "local"
163+
default: true
164+
165+
credentials:
166+
github:
167+
type: access_token
168+
access_token: "your-github-token"
169+
```
170+
171+
## Docker Usage
172+
173+
When using Docker, you can initialize the repository in your container build process:
174+
175+
```dockerfile
176+
FROM docker-registry.example.com/base:latest as builder
177+
178+
COPY main/features /tmp/data
179+
RUN cd /tmp/data && \
180+
git config --global init.defaultBranch main && \
181+
git init && \
182+
git config user.name "Flipt Container" && \
183+
git config user.email "[email protected]" && \
184+
git add . && \
185+
git commit -m "Initial commit with feature flags"
186+
187+
FROM docker.flipt.io/flipt/flipt:v2
188+
189+
COPY --from=builder --chown=flipt:flipt /tmp/data /data
190+
COPY --chown=flipt:flipt main/config.yml /config.yml
191+
192+
USER flipt
193+
EXPOSE 8080 9000
194+
195+
CMD ["/flipt", "server", "--config", "/config.yml"]
196+
```
197+
198+
## Troubleshooting
199+
200+
### Repository Does Not Exist Error
201+
202+
If you see this error, ensure that:
203+
204+
1. Your `path` configuration points to a valid directory
205+
2. The directory contains your feature files
206+
3. Git is properly initialized in the directory
207+
208+
### Features Not Loading
209+
210+
Check that:
211+
212+
1. Your feature files use the correct naming: `features.yaml` or `features.yml`
213+
2. The files are in the correct directory structure
214+
3. The YAML syntax is valid
215+
216+
### Changes Not Persisting
217+
218+
For normal Git repositories:
219+
220+
- Changes made in the UI should automatically sync to your files
221+
- Check that Flipt has write permissions to the directory
222+
- Verify that the Git repository is properly initialized
223+
224+
## Best Practices
225+
226+
1. **Use Descriptive Commit Messages**: When initializing your repository, use clear commit messages that describe your feature set
227+
2. **Organize by Environment**: Structure your directories to separate different environments (staging, production, etc.)
228+
3. **Regular Commits**: Consider setting up automated commits for changes made through the UI
229+
4. **Backup Strategy**: Implement a backup strategy for your feature flag configurations
230+
5. **File Naming**: Stick to either `.yaml` or `.yml` consistently across your project
231+
232+
## Backward Compatibility
233+
234+
This enhancement is fully backward compatible:
235+
236+
- Existing bare repository workflows continue to work unchanged
237+
- All existing functionality is preserved
238+
- Safe fallbacks handle edge cases gracefully
239+
240+
You can migrate existing setups without any breaking changes.

0 commit comments

Comments
 (0)