-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Merge pull request #19 from abolfazl8131/develop
update helm prompt
- Loading branch information
Showing
9 changed files
with
140 additions
and
43 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,86 @@ | ||
import os | ||
import yaml | ||
|
||
# Project structure | ||
project_name = "MyHelm" | ||
base_dir = "app/media" | ||
project_path = os.path.join(base_dir, project_name) | ||
|
||
# Define directories and files | ||
dirs = [ | ||
os.path.join(project_path, "charts"), | ||
os.path.join(project_path, "crds"), | ||
os.path.join(project_path, "templates", "web"), | ||
] | ||
|
||
files = { | ||
"Chart.yaml": """apiVersion: v1 | ||
name: MyHelm | ||
description: A Helm chart for Kubernetes | ||
version: 0.1.0 | ||
""", | ||
"values.yaml": """image: | ||
repository: rembg | ||
tag: latest | ||
pullPolicy: IfNotPresent | ||
""", | ||
project_dir = os.path.join(base_dir, project_name) | ||
|
||
# Directories to create | ||
dirs = ["charts", "crds", "templates/web"] | ||
|
||
# Creating the directory structure | ||
for dir in dirs: | ||
os.makedirs(os.path.join(project_dir, dir), exist_ok=True) | ||
|
||
# Chart.yaml content | ||
chart_yaml = { | ||
"apiVersion": "v1", | ||
"name": project_name, | ||
"version": "0.1.0", | ||
"description": "A Helm chart for MyHelm", | ||
"maintainers": [{"name": "Your Name", "email": "youremail@example.com"}], | ||
"keywords": ["helm", "chart"], | ||
"home": "https://example.com", | ||
"sources": ["https://github.com/example/MyHelm"] | ||
} | ||
|
||
# Create project structure | ||
os.makedirs(project_path, exist_ok=True) | ||
for d in dirs: | ||
os.makedirs(d, exist_ok=True) | ||
# Writing Chart.yaml | ||
with open(os.path.join(project_dir, "Chart.yaml"), 'w') as chart_file: | ||
yaml.dump(chart_yaml, chart_file) | ||
|
||
# values.yaml content based on provided information | ||
values_yaml = { | ||
"web": { | ||
"image": "nginx", | ||
"service": { | ||
"enabled": True, | ||
"port": 80 | ||
} | ||
} | ||
} | ||
|
||
# Writing values.yaml | ||
with open(os.path.join(project_dir, "values.yaml"), 'w') as values_file: | ||
yaml.dump(values_yaml, values_file) | ||
|
||
# Template files content | ||
deployment_yaml = """apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: web | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: web | ||
template: | ||
metadata: | ||
labels: | ||
app: web | ||
spec: | ||
containers: | ||
- name: web | ||
image: {{ .Values.web.image }} | ||
ports: | ||
- containerPort: {{ .Values.web.service.port }} | ||
""" | ||
|
||
service_yaml = """apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: web | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- port: {{ .Values.web.service.port }} | ||
selector: | ||
app: web | ||
""" | ||
|
||
# Creating deployment.yaml and service.yaml in templates/web | ||
with open(os.path.join(project_dir, "templates/web/deployment.yaml"), 'w') as dep_file: | ||
dep_file.write(deployment_yaml) | ||
|
||
# Create files with default content | ||
for file_name, content in files.items(): | ||
with open(os.path.join(project_path, file_name), 'w') as f: | ||
f.write(content) | ||
with open(os.path.join(project_dir, "templates/web/service.yaml"), 'w') as svc_file: | ||
svc_file.write(service_yaml) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
apiVersion: v1 | ||
description: A Helm chart for MyHelm | ||
home: https://example.com | ||
keywords: | ||
- helm | ||
- chart | ||
maintainers: | ||
- email: youremail@example.com | ||
name: Your Name | ||
name: MyHelm | ||
description: A Helm chart for Kubernetes | ||
sources: | ||
- https://github.com/example/MyHelm | ||
version: 0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: web | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: web | ||
template: | ||
metadata: | ||
labels: | ||
app: web | ||
spec: | ||
containers: | ||
- name: web | ||
image: {{ .Values.web.image }} | ||
ports: | ||
- containerPort: {{ .Values.web.service.port }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: web | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- port: {{ .Values.web.service.port }} | ||
selector: | ||
app: web |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
image: | ||
repository: rembg | ||
tag: latest | ||
pullPolicy: IfNotPresent | ||
web: | ||
image: nginx | ||
service: | ||
enabled: true | ||
port: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters