Skip to content

Commit 4c8ec5d

Browse files
authored
feature: Merge pull request #17 from abolfazl8131/develop
update helmchart generator
2 parents e007015 + 3d4d12d commit 4c8ec5d

10 files changed

Lines changed: 42 additions & 125 deletions

File tree

-212 Bytes
Binary file not shown.
164 Bytes
Binary file not shown.
329 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Lines changed: 30 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,35 @@
11
import os
22

3-
# Define the project structure
4-
project_name = "app/media/MyHelm"
5-
directories = ["charts", "crds", "templates"]
6-
files = ["Chart.yaml", "values.yaml"]
7-
8-
# Define default content for Chart.yaml and values.yaml
9-
chart_yaml_content = """apiVersion: v2
10-
name: myhelm
3+
project_name = "MyHelm"
4+
base_dir = "app/media"
5+
project_path = os.path.join(base_dir, project_name)
6+
7+
# Define directories and files
8+
dirs = [
9+
os.path.join(project_path, "charts"),
10+
os.path.join(project_path, "crds"),
11+
os.path.join(project_path, "templates", "web"),
12+
]
13+
14+
files = {
15+
"Chart.yaml": """apiVersion: v1
16+
name: MyHelm
1117
description: A Helm chart for Kubernetes
1218
version: 0.1.0
13-
"""
14-
values_yaml_content = """# Default values for myhelm.
15-
# This is a YAML-formatted file.
16-
# Declare variables to be passed into your templates.
17-
replicaCount: 1
18-
image:
19-
repository: myimage
19+
""",
20+
"values.yaml": """image:
21+
repository: rembg
22+
tag: latest
2023
pullPolicy: IfNotPresent
21-
tag: ""
22-
service:
23-
name: myservice
24-
type: ClusterIP
25-
port: 80
26-
"""
27-
28-
# Create the project structure
29-
os.makedirs(project_name, exist_ok=True)
30-
31-
for directory in directories:
32-
os.makedirs(os.path.join(project_name, directory), exist_ok=True)
33-
34-
for file in files:
35-
file_path = os.path.join(project_name, file)
36-
with open(file_path, 'w') as f:
37-
if file == "Chart.yaml":
38-
f.write(chart_yaml_content)
39-
elif file == "values.yaml":
40-
f.write(values_yaml_content)
41-
42-
# Create a basic GitHub Actions workflow file
43-
github_actions_dir = os.path.join(project_name, ".github/workflows")
44-
os.makedirs(github_actions_dir, exist_ok=True)
45-
with open(os.path.join(github_actions_dir, "ci.yml"), 'w') as f:
46-
f.write("""name: CI
47-
48-
on:
49-
push:
50-
branches:
51-
- main
52-
pull_request:
53-
branches:
54-
- main
55-
56-
jobs:
57-
build:
58-
runs-on: ubuntu-latest
59-
60-
steps:
61-
- name: Checkout code
62-
uses: actions/checkout@v2
63-
64-
- name: Set up Docker Buildx
65-
uses: docker/setup-buildx-action@v1
66-
67-
- name: Cache Docker layers
68-
uses: actions/cache@v2
69-
with:
70-
path: /tmp/.buildx-cache
71-
key: ${{ runner.os }}-buildx-${{ github.sha }}
72-
restore-keys: |
73-
${{ runner.os }}-buildx-
74-
75-
- name: Build and push Docker image
76-
uses: docker/build-push-action@v2
77-
with:
78-
context: .
79-
file: Dockerfile
80-
push: true
81-
tags: myimage:latest
82-
""")
24+
""",
25+
}
26+
27+
# Create project structure
28+
os.makedirs(project_path, exist_ok=True)
29+
for d in dirs:
30+
os.makedirs(d, exist_ok=True)
31+
32+
# Create files with default content
33+
for file_name, content in files.items():
34+
with open(os.path.join(project_path, file_name), 'w') as f:
35+
f.write(content)

app/media/MyHelm/.github/workflows/ci.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

app/media/MyHelm/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: v2
2-
name: myhelm
1+
apiVersion: v1
2+
name: MyHelm
33
description: A Helm chart for Kubernetes
44
version: 0.1.0

app/media/MyHelm/values.yaml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
# Default values for myhelm.
2-
# This is a YAML-formatted file.
3-
# Declare variables to be passed into your templates.
4-
replicaCount: 1
51
image:
6-
repository: myimage
2+
repository: rembg
3+
tag: latest
74
pullPolicy: IfNotPresent
8-
tag: ""
9-
service:
10-
name: myservice
11-
type: ClusterIP
12-
port: 80

app/models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class IaCTemplateGeneration(BaseModel):
2828

2929
class HelmTemplateGeneration(BaseModel):
3030
CI_integration:bool = True
31+
api_version:int = 1
32+
templates:list[str]
33+
images:list[str]
34+
35+
3136

3237

3338

app/prompt_generators.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ def helm_template_generator(input : HelmTemplateGeneration) -> str:
6666
CI integrated (using github actions) = {input.CI_integration}.
6767
consider these directories : [charts/, crds/, templates/]
6868
consider these files : Chart.yaml & values.yaml
69+
in the templates/ directory create these directories: {input.templates}.
70+
set the api_version in the Chart.yaml : v{input.api_version}.
71+
initialize values.yaml based on these docker images : {input.images}
6972
7073
please set a something default in chart.yaml and values.yaml
7174

0 commit comments

Comments
 (0)