11import 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
1117description: A Helm chart for Kubernetes
1218version: 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 )
0 commit comments