Skip to content

Commit 0fc7ad0

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents da1c8f5 + 62ec585 commit 0fc7ad0

37 files changed

Lines changed: 3640 additions & 129 deletions

.github/labeler.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@ helm:
22
- changed-files:
33
- any-glob-to-any-file: helm/**
44

5+
web-ui:
6+
- changed-files:
7+
- any-glob-to-any-file: web/**
8+
59
doc:
610
- changed-files:
711
- any-glob-to-any-file: '**/*.md'
812

13+
unit-test:
14+
- changed-files:
15+
- any-glob-to-any-file: 'app/tests/*.py'
16+
917
docker-compose:
1018
- changed-files:
1119
- any-glob-to-any-file: '**/docker-compose.yml'
@@ -21,17 +29,24 @@ requirements:
2129

2230
gpt:
2331
- changed-files:
24-
- any-glob-to-any-file: '**/app/gpt_services.py'
32+
- any-glob-to-any-file: 'app/gpt_services.py'
2533

2634
services:
2735
- changed-files:
28-
- any-glob-to-any-file: '**/app/services.py'
36+
- any-glob-to-any-file: 'app/services.py'
2937

3038
fastapi:
3139
- changed-files:
32-
- any-glob-to-any-file: '**/app/main.py'
40+
- any-glob-to-any-file: 'app/main.py'
3341

3442
prompt:
3543
- changed-files:
36-
- any-glob-to-any-file: '**/app/prompt_generators.py'
44+
- any-glob-to-any-file: 'app/prompt_generators.py'
45+
46+
directory-generators:
47+
- changed-files:
48+
- any-glob-to-any-file: 'app/directory_generators/**'
3749

50+
pydantic-models:
51+
- changed-files:
52+
- any-glob-to-any-file: 'app/models/**'

.github/workflows/ci.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
name: Realse Version
2+
23
on:
3-
pull_request:
4-
types:
5-
- closed
4+
push:
65
branches:
76
- master
7+
paths:
8+
- 'app/**'
9+
- 'web/**'
810

911
jobs:
1012
releaseGithub:
11-
if: github.event.pull_request.merged == true
1213
runs-on: ubuntu-22.04
1314
permissions:
1415
contents: write
1516
pull-requests: write
1617
steps:
17-
- uses: actions/checkout@v4
18-
with:
19-
ref: ${{ github.event.pull_request.merge_commit_sha }}
20-
fetch-depth: '0'
21-
2218
- name: Bump version and push tag
2319
id: bump
2420
uses: mathieudutour/github-tag-action@v6.2

.github/workflows/docker.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
name: Docker Health Check
22

33
on:
4-
pull_request:
4+
pull_request_target:
55
branches:
66
- master
77

88
jobs:
99
docker_health_check:
1010
runs-on: ubuntu-latest
1111
steps:
12-
13-
- uses: actions/checkout@v4
12+
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
with:
16+
ref: ${{ github.event.pull_request.head.ref }}
17+
repository: ${{ github.event.pull_request.head.repo.full_name }}
18+
1419
- name: install requirements
1520
run: pip install -r requirements.txt
1621

137 Bytes
Binary file not shown.
Lines changed: 60 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,22 @@
11
import os
22

3-
# Define the project structure
4-
project_name = "MyHelm"
5-
base_path = f"app/media/{project_name}"
3+
def create_helm_project_structure(base_path):
4+
project_path = os.path.join(base_path, 'app/media/MyHelm')
5+
os.makedirs(os.path.join(project_path, 'charts'), exist_ok=True)
6+
os.makedirs(os.path.join(project_path, 'templates', 'web'), exist_ok=True)
67

7-
directories = [
8-
"charts/",
9-
"templates/web/"
10-
]
11-
12-
files = [
13-
"Chart.yaml",
14-
"values.yaml",
15-
"templates/web/service.yaml",
16-
"templates/web/deployment.yaml",
17-
"templates/web/secret.yaml" # Only if there are environment variables
18-
]
19-
20-
# Create the directories
21-
for directory in directories:
22-
os.makedirs(os.path.join(base_path, directory), exist_ok=True)
23-
24-
# Create the Chart.yaml file
25-
chart_yaml_content = """apiVersion: v2
26-
name: mychart
8+
chart_yaml_content = """apiVersion: v2
9+
name: MyHelm
2710
description: A Helm chart for Kubernetes
2811
version: 0.1.0
2912
"""
30-
with open(os.path.join(base_path, "Chart.yaml"), "w") as chart_file:
31-
chart_file.write(chart_yaml_content)
32-
33-
# Create the values.yaml file
34-
values_yaml_content = """web:
13+
14+
values_yaml_content = """web:
3515
image: nginx
3616
service:
3717
targetPort: 80
3818
replicas: 1
3919
persistence:
40-
enabled: true
4120
size: 1Gi
4221
accessModes:
4322
- ReadWriteOnce
@@ -48,71 +27,86 @@
4827
enabled: false
4928
host: www.example.com
5029
"""
51-
with open(os.path.join(base_path, "values.yaml"), "w") as values_file:
52-
values_file.write(values_yaml_content)
5330

54-
# Create service.yaml file
55-
service_yaml_content = """apiVersion: v1
31+
service_yaml_content = """apiVersion: v1
5632
kind: Service
5733
metadata:
58-
name: web
34+
name: {{ include "MyHelm.fullname" . }}-web
5935
spec:
6036
type: ClusterIP
6137
ports:
62-
- port: 80
63-
targetPort: {{ .Values.web.service.targetPort }}
38+
- port: {{ .Values.web.service.targetPort }}
6439
selector:
65-
app: {{ .Release.Name }}
40+
app: {{ include "MyHelm.name" . }}
6641
"""
6742

68-
with open(os.path.join(base_path, "templates/web/service.yaml"), "w") as service_file:
69-
service_file.write(service_yaml_content)
70-
71-
# Create deployment.yaml file
72-
deployment_yaml_content = """apiVersion: apps/v1
43+
deployment_yaml_content = """apiVersion: apps/v1
7344
kind: Deployment
7445
metadata:
75-
name: web
46+
name: {{ include "MyHelm.fullname" . }}-web
7647
spec:
7748
replicas: {{ .Values.web.replicas }}
78-
selector:
79-
matchLabels:
80-
app: {{ .Release.Name }}
8149
template:
8250
metadata:
8351
labels:
84-
app: {{ .Release.Name }}
52+
app: {{ include "MyHelm.name" . }}
8553
spec:
8654
containers:
8755
- name: web
8856
image: {{ .Values.web.image }}
8957
ports:
9058
- containerPort: {{ .Values.web.service.targetPort }}
9159
env:
92-
- name: ENV1
93-
value: {{ .Values.web.env[0].value }}
94-
volumeClaimTemplates:
95-
- metadata:
96-
name: web-pvc
97-
spec:
98-
accessModes: {{ .Values.web.persistence.accessModes | toYaml }}
99-
resources:
100-
requests:
101-
storage: {{ .Values.web.persistence.size }}
60+
{{- range .Values.web.env }}
61+
- name: {{ .name }}
62+
value: {{ .value }}
63+
{{- end }}
10264
"""
10365

104-
with open(os.path.join(base_path, "templates/web/deployment.yaml"), "w") as deployment_file:
105-
deployment_file.write(deployment_yaml_content)
106-
107-
# Create secret.yaml file
108-
secret_yaml_content = """apiVersion: v1
66+
secret_yaml_content = """apiVersion: v1
10967
kind: Secret
11068
metadata:
111-
name: web-secret
69+
name: {{ include "MyHelm.fullname" . }}-web-env
11270
type: Opaque
11371
data:
114-
ENV1: aGl
72+
ENV1: {{ .Values.web.env | toJson | b64enc | quote }}
73+
"""
74+
75+
helpers_tpl_content = """{{/*
76+
Expand the name of the chart.
77+
*/}}
78+
{{- define "MyHelm.name" -}}
79+
{{- .Chart.Name | replace "-" "_" | lower -}}
80+
{{- end -}}
81+
82+
{{/*
83+
Create a default fully qualified domain name
84+
*/}}
85+
{{- define "MyHelm.fullname" -}}
86+
{{- if .Chart.Name -}}
87+
{{- .Release.Name | lower | replace "-" "_" | trimSuffix "-" | append (include "MyHelm.name" . | lower) | toLower -}}
88+
{{- else -}}
89+
{{- .Release.Name | lower -}}
90+
{{- end -}}
91+
{{- end -}}
11592
"""
11693

117-
with open(os.path.join(base_path, "templates/web/secret.yaml"), "w") as secret_file:
118-
secret_file.write(secret_yaml_content)
94+
with open(os.path.join(project_path, 'Chart.yaml'), 'w') as file:
95+
file.write(chart_yaml_content)
96+
97+
with open(os.path.join(project_path, 'values.yaml'), 'w') as file:
98+
file.write(values_yaml_content)
99+
100+
with open(os.path.join(project_path, 'templates', 'web', 'service.yaml'), 'w') as file:
101+
file.write(service_yaml_content)
102+
103+
with open(os.path.join(project_path, 'templates', 'web', 'deployment.yaml'), 'w') as file:
104+
file.write(deployment_yaml_content)
105+
106+
with open(os.path.join(project_path, 'templates', 'web', 'secret.yaml'), 'w') as file:
107+
file.write(secret_yaml_content)
108+
109+
with open(os.path.join(project_path, 'templates', 'web', 'helpers.tpl'), 'w') as file:
110+
file.write(helpers_tpl_content)
111+
112+
create_helm_project_structure('.')

app/gpt_services.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ def gpt_service(prompt):
66

77
try:
88
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
9-
109
chat_completion = client.chat.completions.create(
1110
messages=[
1211
{

app/media/MyHelm/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
apiVersion: v2
2-
name: mychart
2+
name: MyHelm
33
description: A Helm chart for Kubernetes
44
version: 0.1.0
Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
11
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
4-
name: web
4+
name: {{ include "MyHelm.fullname" . }}-web
55
spec:
66
replicas: {{ .Values.web.replicas }}
7-
selector:
8-
matchLabels:
9-
app: {{ .Release.Name }}
107
template:
118
metadata:
129
labels:
13-
app: {{ .Release.Name }}
10+
app: {{ include "MyHelm.name" . }}
1411
spec:
1512
containers:
1613
- name: web
1714
image: {{ .Values.web.image }}
1815
ports:
1916
- containerPort: {{ .Values.web.service.targetPort }}
2017
env:
21-
- name: ENV1
22-
value: {{ .Values.web.env[0].value }}
23-
volumeClaimTemplates:
24-
- metadata:
25-
name: web-pvc
26-
spec:
27-
accessModes: {{ .Values.web.persistence.accessModes | toYaml }}
28-
resources:
29-
requests:
30-
storage: {{ .Values.web.persistence.size }}
18+
{{- range .Values.web.env }}
19+
- name: {{ .name }}
20+
value: {{ .value }}
21+
{{- end }}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "MyHelm.name" -}}
5+
{{- .Chart.Name | replace "-" "_" | lower -}}
6+
{{- end -}}
7+
8+
{{/*
9+
Create a default fully qualified domain name
10+
*/}}
11+
{{- define "MyHelm.fullname" -}}
12+
{{- if .Chart.Name -}}
13+
{{- .Release.Name | lower | replace "-" "_" | trimSuffix "-" | append (include "MyHelm.name" . | lower) | toLower -}}
14+
{{- else -}}
15+
{{- .Release.Name | lower -}}
16+
{{- end -}}
17+
{{- end -}}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
kind: Secret
33
metadata:
4-
name: web-secret
4+
name: {{ include "MyHelm.fullname" . }}-web-env
55
type: Opaque
66
data:
7-
ENV1: aGl
7+
ENV1: {{ .Values.web.env | toJson | b64enc | quote }}

0 commit comments

Comments
 (0)