ngen-gitops 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ngen_gitops-0.1.1/MANIFEST.in +2 -0
- ngen_gitops-0.1.1/PKG-INFO +603 -0
- ngen_gitops-0.1.1/README.md +577 -0
- ngen_gitops-0.1.1/ngen_gitops/__init__.py +5 -0
- ngen_gitops-0.1.1/ngen_gitops/bitbucket.py +602 -0
- ngen_gitops-0.1.1/ngen_gitops/cli.py +332 -0
- ngen_gitops-0.1.1/ngen_gitops/config.py +136 -0
- ngen_gitops-0.1.1/ngen_gitops/server.py +337 -0
- ngen_gitops-0.1.1/ngen_gitops.egg-info/PKG-INFO +603 -0
- ngen_gitops-0.1.1/ngen_gitops.egg-info/SOURCES.txt +15 -0
- ngen_gitops-0.1.1/ngen_gitops.egg-info/dependency_links.txt +1 -0
- ngen_gitops-0.1.1/ngen_gitops.egg-info/entry_points.txt +2 -0
- ngen_gitops-0.1.1/ngen_gitops.egg-info/requires.txt +5 -0
- ngen_gitops-0.1.1/ngen_gitops.egg-info/top_level.txt +1 -0
- ngen_gitops-0.1.1/pyproject.toml +51 -0
- ngen_gitops-0.1.1/setup.cfg +4 -0
- ngen_gitops-0.1.1/setup.py +14 -0
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ngen-gitops
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: GitOps CLI and web server for Bitbucket operations
|
|
5
|
+
Author: ngen-gitops contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/mamatnurahmat/ngen-gitops
|
|
8
|
+
Project-URL: Repository, https://github.com/mamatnurahmat/ngen-gitops
|
|
9
|
+
Project-URL: Issues, https://github.com/mamatnurahmat/ngen-gitops/issues
|
|
10
|
+
Keywords: cli,gitops,bitbucket,devops,api,ci-cd
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Requires-Python: >=3.7
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
Requires-Dist: requests>=2.25.0
|
|
22
|
+
Requires-Dist: fastapi>=0.68.0
|
|
23
|
+
Requires-Dist: uvicorn>=0.15.0
|
|
24
|
+
Requires-Dist: pyyaml>=5.4.0
|
|
25
|
+
Requires-Dist: python-dotenv>=0.19.0
|
|
26
|
+
|
|
27
|
+
# ngen-gitops
|
|
28
|
+
|
|
29
|
+
GitOps CLI and web server for Bitbucket operations. Automate branch creation, YAML image updates, pull request creation, and merging via command-line interface or REST API.
|
|
30
|
+
|
|
31
|
+
[](https://badge.fury.io/py/ngen-gitops)
|
|
32
|
+
[](https://pypi.org/project/ngen-gitops/)
|
|
33
|
+
[](https://opensource.org/licenses/MIT)
|
|
34
|
+
|
|
35
|
+
## Features
|
|
36
|
+
|
|
37
|
+
- 🌿 **Branch Management**: Create branches from source branches
|
|
38
|
+
- 🖼️ **Image Updates**: Update container images in Kubernetes YAML files
|
|
39
|
+
- 🔄 **Pull Requests**: Create and merge pull requests automatically
|
|
40
|
+
- 🌐 **Web API**: REST API server with FastAPI for integration
|
|
41
|
+
- 🔐 **Secure**: Uses Bitbucket app passwords for authentication
|
|
42
|
+
- 📦 **Easy Configuration**: Simple JSON config file
|
|
43
|
+
- 🚀 **PyPI Package**: Install with pip
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install ngen-gitops
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Quick Start
|
|
52
|
+
|
|
53
|
+
### 1. Configuration
|
|
54
|
+
|
|
55
|
+
On first run, ngen-gitops creates a config file at `~/.ngen-gitops/config.json`:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"bitbucket": {
|
|
60
|
+
"username": "",
|
|
61
|
+
"app_password": "",
|
|
62
|
+
"organization": "loyaltoid"
|
|
63
|
+
},
|
|
64
|
+
"server": {
|
|
65
|
+
"host": "0.0.0.0",
|
|
66
|
+
"port": 8080
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Update the config with your credentials:**
|
|
72
|
+
|
|
73
|
+
1. Go to Bitbucket Settings → App passwords
|
|
74
|
+
2. Create a new app password with repository read/write permissions
|
|
75
|
+
3. Update `~/.ngen-gitops/config.json` with your username and app password
|
|
76
|
+
|
|
77
|
+
**Or use environment variables:**
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
export BITBUCKET_USER="your-username"
|
|
81
|
+
export BITBUCKET_APP_PASSWORD="your-app-password"
|
|
82
|
+
export BITBUCKET_ORG="your-organization"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 2. Verify Configuration
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
ngen-gitops config
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Usage
|
|
92
|
+
|
|
93
|
+
### CLI Commands
|
|
94
|
+
|
|
95
|
+
#### Create Branch
|
|
96
|
+
|
|
97
|
+
Create a new branch from a source branch:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
ngen-gitops create-branch <repo> <src_branch> <dest_branch>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Example:**
|
|
104
|
+
```bash
|
|
105
|
+
ngen-gitops create-branch my-app main feature/new-feature
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Output:**
|
|
109
|
+
```
|
|
110
|
+
🔍 Creating branch 'feature/new-feature' from 'main' in repository 'my-app'...
|
|
111
|
+
✅ Source branch 'main' validated (commit: abc1234)
|
|
112
|
+
✅ Branch 'feature/new-feature' created successfully from 'main'
|
|
113
|
+
|
|
114
|
+
✅ Branch 'feature/new-feature' created successfully
|
|
115
|
+
Branch URL: https://bitbucket.org/org/my-app/branch/feature/new-feature
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
#### Update Image in YAML
|
|
119
|
+
|
|
120
|
+
Update container image in Kubernetes YAML file:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
ngen-gitops set-image-yaml <repo> <branch> <yaml_path> <image> [--dry-run]
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Example:**
|
|
127
|
+
```bash
|
|
128
|
+
ngen-gitops set-image-yaml my-app develop k8s/deployment.yaml myregistry/myapp:v1.2.3
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Output:**
|
|
132
|
+
```
|
|
133
|
+
🔍 Cloning repository my-app (branch: develop)...
|
|
134
|
+
✅ Repository cloned
|
|
135
|
+
Current image(s): myregistry/myapp:v1.2.0
|
|
136
|
+
New image: myregistry/myapp:v1.2.3
|
|
137
|
+
✅ Updated image in YAML file
|
|
138
|
+
✅ Changes committed
|
|
139
|
+
✅ Changes pushed to develop
|
|
140
|
+
|
|
141
|
+
✅ Image updated to myregistry/myapp:v1.2.3 and pushed to develop
|
|
142
|
+
[develop abc1234] chore: update image to myregistry/myapp:v1.2.3
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Dry-run mode** (don't push changes):
|
|
146
|
+
```bash
|
|
147
|
+
ngen-gitops set-image-yaml my-app develop k8s/deployment.yaml myapp:v1.0.0 --dry-run
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
#### Create Pull Request
|
|
151
|
+
|
|
152
|
+
Create a pull request from source to destination branch:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
ngen-gitops pull-request <repo> <src_branch> <dest_branch> [--delete-after-merge]
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**Example:**
|
|
159
|
+
```bash
|
|
160
|
+
ngen-gitops pull-request my-app feature/new-feature develop --delete-after-merge
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**Output:**
|
|
164
|
+
```
|
|
165
|
+
🔍 Creating pull request from 'feature/new-feature' to 'develop' in repository 'my-app'...
|
|
166
|
+
⚠️ Source branch 'feature/new-feature' will be deleted after merge
|
|
167
|
+
✅ Source branch 'feature/new-feature' validated
|
|
168
|
+
✅ Destination branch 'develop' validated
|
|
169
|
+
✅ Pull request created successfully
|
|
170
|
+
PR #42
|
|
171
|
+
URL: https://bitbucket.org/org/my-app/pull-requests/42
|
|
172
|
+
|
|
173
|
+
✅ Pull request #42 created successfully
|
|
174
|
+
Pull Request URL: https://bitbucket.org/org/my-app/pull-requests/42
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### Merge Pull Request
|
|
178
|
+
|
|
179
|
+
Merge an existing pull request:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
ngen-gitops merge <pr_url> [--delete-after-merge]
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Example:**
|
|
186
|
+
```bash
|
|
187
|
+
ngen-gitops merge https://bitbucket.org/org/my-app/pull-requests/42
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**Output:**
|
|
191
|
+
```
|
|
192
|
+
🔍 Merging pull request #42 in repository 'my-app'...
|
|
193
|
+
✅ Pull request validated
|
|
194
|
+
Source branch: feature/new-feature
|
|
195
|
+
Destination branch: develop
|
|
196
|
+
State: OPEN
|
|
197
|
+
✅ Pull request #42 merged successfully
|
|
198
|
+
Merge commit: abc1234
|
|
199
|
+
|
|
200
|
+
✅ Pull request #42 merged successfully
|
|
201
|
+
Merge commit: abc1234
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
#### Start Web Server
|
|
205
|
+
|
|
206
|
+
Start the REST API server:
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
ngen-gitops server [--host HOST] [--port PORT]
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**Example:**
|
|
213
|
+
```bash
|
|
214
|
+
ngen-gitops server --port 8080
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Output:**
|
|
218
|
+
```
|
|
219
|
+
🚀 Starting ngen-gitops server...
|
|
220
|
+
Host: 0.0.0.0
|
|
221
|
+
Port: 8080
|
|
222
|
+
Endpoints:
|
|
223
|
+
- POST /v1/gitops/create-branch
|
|
224
|
+
- POST /v1/gitops/set-image-yaml
|
|
225
|
+
- POST /v1/gitops/pull-request
|
|
226
|
+
- POST /v1/gitops/merge
|
|
227
|
+
|
|
228
|
+
INFO: Started server process [12345]
|
|
229
|
+
INFO: Waiting for application startup.
|
|
230
|
+
INFO: Application startup complete.
|
|
231
|
+
INFO: Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### JSON Output
|
|
235
|
+
|
|
236
|
+
All commands support `--json` flag for machine-readable output:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
ngen-gitops create-branch my-app main develop --json
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
**Output:**
|
|
243
|
+
```json
|
|
244
|
+
{
|
|
245
|
+
"success": true,
|
|
246
|
+
"repository": "my-app",
|
|
247
|
+
"source_branch": "main",
|
|
248
|
+
"destination_branch": "develop",
|
|
249
|
+
"message": "Branch 'develop' created successfully",
|
|
250
|
+
"branch_url": "https://bitbucket.org/org/my-app/branch/develop"
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## REST API
|
|
255
|
+
|
|
256
|
+
### Starting the Server
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
ngen-gitops server --port 8080
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### API Endpoints
|
|
263
|
+
|
|
264
|
+
#### 1. Create Branch
|
|
265
|
+
|
|
266
|
+
**Endpoint:** `POST /v1/gitops/create-branch`
|
|
267
|
+
|
|
268
|
+
**Request:**
|
|
269
|
+
```json
|
|
270
|
+
{
|
|
271
|
+
"repo": "my-app",
|
|
272
|
+
"src_branch": "main",
|
|
273
|
+
"dest_branch": "feature/new-feature"
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**Response:**
|
|
278
|
+
```json
|
|
279
|
+
{
|
|
280
|
+
"success": true,
|
|
281
|
+
"repository": "my-app",
|
|
282
|
+
"source_branch": "main",
|
|
283
|
+
"destination_branch": "feature/new-feature",
|
|
284
|
+
"message": "Branch 'feature/new-feature' created successfully",
|
|
285
|
+
"branch_url": "https://bitbucket.org/org/my-app/branch/feature/new-feature"
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
**cURL Example:**
|
|
290
|
+
```bash
|
|
291
|
+
curl -X POST http://localhost:8080/v1/gitops/create-branch \
|
|
292
|
+
-H "Content-Type: application/json" \
|
|
293
|
+
-d '{
|
|
294
|
+
"repo": "my-app",
|
|
295
|
+
"src_branch": "main",
|
|
296
|
+
"dest_branch": "feature/new-feature"
|
|
297
|
+
}'
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
#### 2. Update Image in YAML
|
|
301
|
+
|
|
302
|
+
**Endpoint:** `POST /v1/gitops/set-image-yaml`
|
|
303
|
+
|
|
304
|
+
**Request:**
|
|
305
|
+
```json
|
|
306
|
+
{
|
|
307
|
+
"repo": "my-app",
|
|
308
|
+
"refs": "develop",
|
|
309
|
+
"yaml_path": "k8s/deployment.yaml",
|
|
310
|
+
"image": "myregistry/myapp:v1.2.3",
|
|
311
|
+
"dry_run": false
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
**Response:**
|
|
316
|
+
```json
|
|
317
|
+
{
|
|
318
|
+
"success": true,
|
|
319
|
+
"repository": "my-app",
|
|
320
|
+
"branch": "develop",
|
|
321
|
+
"yaml_path": "k8s/deployment.yaml",
|
|
322
|
+
"image": "myregistry/myapp:v1.2.3",
|
|
323
|
+
"message": "Image updated to myregistry/myapp:v1.2.3 and pushed to develop",
|
|
324
|
+
"commit": "[develop abc1234] chore: update image to myregistry/myapp:v1.2.3"
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
**cURL Example:**
|
|
329
|
+
```bash
|
|
330
|
+
curl -X POST http://localhost:8080/v1/gitops/set-image-yaml \
|
|
331
|
+
-H "Content-Type: application/json" \
|
|
332
|
+
-d '{
|
|
333
|
+
"repo": "my-app",
|
|
334
|
+
"refs": "develop",
|
|
335
|
+
"yaml_path": "k8s/deployment.yaml",
|
|
336
|
+
"image": "myregistry/myapp:v1.2.3",
|
|
337
|
+
"dry_run": false
|
|
338
|
+
}'
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
#### 3. Create Pull Request
|
|
342
|
+
|
|
343
|
+
**Endpoint:** `POST /v1/gitops/pull-request`
|
|
344
|
+
|
|
345
|
+
**Request:**
|
|
346
|
+
```json
|
|
347
|
+
{
|
|
348
|
+
"repo": "my-app",
|
|
349
|
+
"src_branch": "feature/new-feature",
|
|
350
|
+
"dest_branch": "develop",
|
|
351
|
+
"delete_after_merge": false
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
**Response:**
|
|
356
|
+
```json
|
|
357
|
+
{
|
|
358
|
+
"success": true,
|
|
359
|
+
"repository": "my-app",
|
|
360
|
+
"source": "feature/new-feature",
|
|
361
|
+
"destination": "develop",
|
|
362
|
+
"delete_after_merge": false,
|
|
363
|
+
"pr_id": 42,
|
|
364
|
+
"pr_url": "https://bitbucket.org/org/my-app/pull-requests/42",
|
|
365
|
+
"message": "Pull request #42 created successfully"
|
|
366
|
+
}
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
**cURL Example:**
|
|
370
|
+
```bash
|
|
371
|
+
curl -X POST http://localhost:8080/v1/gitops/pull-request \
|
|
372
|
+
-H "Content-Type: application/json" \
|
|
373
|
+
-d '{
|
|
374
|
+
"repo": "my-app",
|
|
375
|
+
"src_branch": "feature/new-feature",
|
|
376
|
+
"dest_branch": "develop",
|
|
377
|
+
"delete_after_merge": false
|
|
378
|
+
}'
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
#### 4. Merge Pull Request
|
|
382
|
+
|
|
383
|
+
**Endpoint:** `POST /v1/gitops/merge`
|
|
384
|
+
|
|
385
|
+
**Request:**
|
|
386
|
+
```json
|
|
387
|
+
{
|
|
388
|
+
"pr_url": "https://bitbucket.org/org/my-app/pull-requests/42",
|
|
389
|
+
"delete_after_merge": false
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
**Response:**
|
|
394
|
+
```json
|
|
395
|
+
{
|
|
396
|
+
"success": true,
|
|
397
|
+
"pr_url": "https://bitbucket.org/org/my-app/pull-requests/42",
|
|
398
|
+
"repository": "my-app",
|
|
399
|
+
"pr_id": "42",
|
|
400
|
+
"source": "feature/new-feature",
|
|
401
|
+
"destination": "develop",
|
|
402
|
+
"message": "Pull request #42 merged successfully",
|
|
403
|
+
"merge_commit": "abc1234",
|
|
404
|
+
"delete_after_merge": false
|
|
405
|
+
}
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
**cURL Example:**
|
|
409
|
+
```bash
|
|
410
|
+
curl -X POST http://localhost:8080/v1/gitops/merge \
|
|
411
|
+
-H "Content-Type: application/json" \
|
|
412
|
+
-d '{
|
|
413
|
+
"pr_url": "https://bitbucket.org/org/my-app/pull-requests/42",
|
|
414
|
+
"delete_after_merge": false
|
|
415
|
+
}'
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### API Documentation
|
|
419
|
+
|
|
420
|
+
When the server is running, visit:
|
|
421
|
+
|
|
422
|
+
- **Swagger UI**: `http://localhost:8080/docs`
|
|
423
|
+
- **ReDoc**: `http://localhost:8080/redoc`
|
|
424
|
+
|
|
425
|
+
## Use Cases
|
|
426
|
+
|
|
427
|
+
### CI/CD Integration
|
|
428
|
+
|
|
429
|
+
**Update image after Docker build:**
|
|
430
|
+
|
|
431
|
+
```bash
|
|
432
|
+
# Build Docker image
|
|
433
|
+
docker build -t myregistry/myapp:${VERSION} .
|
|
434
|
+
docker push myregistry/myapp:${VERSION}
|
|
435
|
+
|
|
436
|
+
# Update Kubernetes deployment
|
|
437
|
+
ngen-gitops set-image-yaml my-app develop k8s/deployment.yaml myregistry/myapp:${VERSION}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
**Automated PR workflow:**
|
|
441
|
+
|
|
442
|
+
```bash
|
|
443
|
+
# Create feature branch
|
|
444
|
+
ngen-gitops create-branch my-app develop feature/auto-update-${VERSION}
|
|
445
|
+
|
|
446
|
+
# Update image in feature branch
|
|
447
|
+
ngen-gitops set-image-yaml my-app feature/auto-update-${VERSION} k8s/deployment.yaml myregistry/myapp:${VERSION}
|
|
448
|
+
|
|
449
|
+
# Create pull request
|
|
450
|
+
PR_URL=$(ngen-gitops pull-request my-app feature/auto-update-${VERSION} develop --delete-after-merge --json | jq -r '.pr_url')
|
|
451
|
+
|
|
452
|
+
# Auto-merge (optional)
|
|
453
|
+
ngen-gitops merge $PR_URL
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
### REST API Integration
|
|
457
|
+
|
|
458
|
+
**Python example:**
|
|
459
|
+
|
|
460
|
+
```python
|
|
461
|
+
import requests
|
|
462
|
+
|
|
463
|
+
# Create branch
|
|
464
|
+
response = requests.post('http://localhost:8080/v1/gitops/create-branch', json={
|
|
465
|
+
'repo': 'my-app',
|
|
466
|
+
'src_branch': 'main',
|
|
467
|
+
'dest_branch': 'feature/new-feature'
|
|
468
|
+
})
|
|
469
|
+
print(response.json())
|
|
470
|
+
|
|
471
|
+
# Update image
|
|
472
|
+
response = requests.post('http://localhost:8080/v1/gitops/set-image-yaml', json={
|
|
473
|
+
'repo': 'my-app',
|
|
474
|
+
'refs': 'develop',
|
|
475
|
+
'yaml_path': 'k8s/deployment.yaml',
|
|
476
|
+
'image': 'myapp:v1.0.0',
|
|
477
|
+
'dry_run': False
|
|
478
|
+
})
|
|
479
|
+
print(response.json())
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
## Configuration
|
|
483
|
+
|
|
484
|
+
### Config File Location
|
|
485
|
+
|
|
486
|
+
`~/.ngen-gitops/config.json`
|
|
487
|
+
|
|
488
|
+
### Config Structure
|
|
489
|
+
|
|
490
|
+
```json
|
|
491
|
+
{
|
|
492
|
+
"bitbucket": {
|
|
493
|
+
"username": "your-bitbucket-username",
|
|
494
|
+
"app_password": "your-app-password",
|
|
495
|
+
"organization": "your-org-name"
|
|
496
|
+
},
|
|
497
|
+
"server": {
|
|
498
|
+
"host": "0.0.0.0",
|
|
499
|
+
"port": 8080
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
### Environment Variables
|
|
505
|
+
|
|
506
|
+
Override config with environment variables:
|
|
507
|
+
|
|
508
|
+
- `BITBUCKET_USER`: Bitbucket username
|
|
509
|
+
- `BITBUCKET_APP_PASSWORD`: Bitbucket app password
|
|
510
|
+
- `BITBUCKET_ORG`: Bitbucket organization
|
|
511
|
+
|
|
512
|
+
## Development
|
|
513
|
+
|
|
514
|
+
### Build from Source
|
|
515
|
+
|
|
516
|
+
```bash
|
|
517
|
+
# Clone repository
|
|
518
|
+
git clone https://github.com/mamatnurahmat/ngen-gitops.git
|
|
519
|
+
cd ngen-gitops
|
|
520
|
+
|
|
521
|
+
# Install in development mode
|
|
522
|
+
pip install -e .
|
|
523
|
+
|
|
524
|
+
# Run commands
|
|
525
|
+
ngen-gitops --help
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
### Build Package
|
|
529
|
+
|
|
530
|
+
```bash
|
|
531
|
+
# Install build tools
|
|
532
|
+
pip install build twine
|
|
533
|
+
|
|
534
|
+
# Build package
|
|
535
|
+
python -m build
|
|
536
|
+
|
|
537
|
+
# Check distribution
|
|
538
|
+
twine check dist/*
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
### Publish to PyPI
|
|
542
|
+
|
|
543
|
+
```bash
|
|
544
|
+
# Publish to TestPyPI first
|
|
545
|
+
twine upload --repository testpypi dist/*
|
|
546
|
+
|
|
547
|
+
# Test installation
|
|
548
|
+
pip install --index-url https://test.pypi.org/simple/ ngen-gitops
|
|
549
|
+
|
|
550
|
+
# Publish to PyPI
|
|
551
|
+
twine upload dist/*
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
## Troubleshooting
|
|
555
|
+
|
|
556
|
+
### Authentication Errors
|
|
557
|
+
|
|
558
|
+
**Problem:** `Bitbucket credentials not configured`
|
|
559
|
+
|
|
560
|
+
**Solution:**
|
|
561
|
+
1. Check config file exists: `~/.ngen-gitops/config.json`
|
|
562
|
+
2. Verify credentials are set correctly
|
|
563
|
+
3. Or set environment variables: `BITBUCKET_USER` and `BITBUCKET_APP_PASSWORD`
|
|
564
|
+
|
|
565
|
+
### Branch Not Found
|
|
566
|
+
|
|
567
|
+
**Problem:** `Source branch 'xyz' not found`
|
|
568
|
+
|
|
569
|
+
**Solution:**
|
|
570
|
+
1. Verify branch name is correct (case-sensitive)
|
|
571
|
+
2. Check branch exists in Bitbucket repository
|
|
572
|
+
3. Use `git branch -a` to list all branches
|
|
573
|
+
|
|
574
|
+
### Image Update Fails
|
|
575
|
+
|
|
576
|
+
**Problem:** `File 'k8s/deployment.yaml' not found`
|
|
577
|
+
|
|
578
|
+
**Solution:**
|
|
579
|
+
1. Verify YAML path is correct relative to repository root
|
|
580
|
+
2. Check file exists in the specified branch
|
|
581
|
+
3. Ensure YAML file contains `image:` field
|
|
582
|
+
|
|
583
|
+
## License
|
|
584
|
+
|
|
585
|
+
MIT License - see LICENSE file for details
|
|
586
|
+
|
|
587
|
+
## Contributing
|
|
588
|
+
|
|
589
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
590
|
+
|
|
591
|
+
## Author
|
|
592
|
+
|
|
593
|
+
ngen-gitops contributors
|
|
594
|
+
|
|
595
|
+
## Related Projects
|
|
596
|
+
|
|
597
|
+
- [ngen-j](https://github.com/mamatnurahmat/ngen-j) - Jenkins API management CLI
|
|
598
|
+
|
|
599
|
+
## Links
|
|
600
|
+
|
|
601
|
+
- **GitHub**: https://github.com/mamatnurahmat/ngen-gitops
|
|
602
|
+
- **PyPI**: https://pypi.org/project/ngen-gitops/
|
|
603
|
+
- **Issues**: https://github.com/mamatnurahmat/ngen-gitops/issues
|