-
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.
feature: Merge pull request #15 from abolfazl8131/feature/heml_prompt
add a prompt to generate a helm project
- Loading branch information
Showing
22 changed files
with
302 additions
and
153 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
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,82 @@ | ||
import os | ||
|
||
# Define the project structure | ||
project_name = "app/media/MyHelm" | ||
directories = ["charts", "crds", "templates"] | ||
files = ["Chart.yaml", "values.yaml"] | ||
|
||
# Define default content for Chart.yaml and values.yaml | ||
chart_yaml_content = """apiVersion: v2 | ||
name: myhelm | ||
description: A Helm chart for Kubernetes | ||
version: 0.1.0 | ||
""" | ||
values_yaml_content = """# Default values for myhelm. | ||
# This is a YAML-formatted file. | ||
# Declare variables to be passed into your templates. | ||
replicaCount: 1 | ||
image: | ||
repository: myimage | ||
pullPolicy: IfNotPresent | ||
tag: "" | ||
service: | ||
name: myservice | ||
type: ClusterIP | ||
port: 80 | ||
""" | ||
|
||
# Create the project structure | ||
os.makedirs(project_name, exist_ok=True) | ||
|
||
for directory in directories: | ||
os.makedirs(os.path.join(project_name, directory), exist_ok=True) | ||
|
||
for file in files: | ||
file_path = os.path.join(project_name, file) | ||
with open(file_path, 'w') as f: | ||
if file == "Chart.yaml": | ||
f.write(chart_yaml_content) | ||
elif file == "values.yaml": | ||
f.write(values_yaml_content) | ||
|
||
# Create a basic GitHub Actions workflow file | ||
github_actions_dir = os.path.join(project_name, ".github/workflows") | ||
os.makedirs(github_actions_dir, exist_ok=True) | ||
with open(os.path.join(github_actions_dir, "ci.yml"), 'w') as f: | ||
f.write("""name: CI | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: true | ||
tags: myimage:latest | ||
""") |
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,88 @@ | ||
import os | ||
|
||
project_name = "app/media/MyTerraform" | ||
base_directory = project_name.replace("/", os.sep) | ||
modules_directory = os.path.join(base_directory, "modules") | ||
ci_directory = os.path.join(base_directory, ".github", "workflows") | ||
|
||
os.makedirs(modules_directory, exist_ok=True) | ||
os.makedirs(ci_directory, exist_ok=True) | ||
|
||
terraform_main = f"""provider "aws" {{ | ||
region = "us-east-1" | ||
}} | ||
resource "aws_instance" "web" {{ | ||
ami = "ami-0c55b159cbfafe1f0" | ||
instance_type = "t2.micro" | ||
tags = {{ | ||
Name = "MyEC2Instance" | ||
}} | ||
}} | ||
""" | ||
|
||
terraform_variables = """variable "region" {{ | ||
description = "AWS region" | ||
type = string | ||
default = "us-east-1" | ||
}} | ||
variable "instance_type" {{ | ||
description = "EC2 Instance type" | ||
type = string | ||
default = "t2.micro" | ||
}} | ||
variable "ami" {{ | ||
description = "AMI ID" | ||
type = string | ||
default = "ami-0c55b159cbfafe1f0" | ||
}} | ||
""" | ||
|
||
github_actions = """name: Terraform CI | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
terraform: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Set up Terraform | ||
uses: hashicorp/setup-terraform@v1 | ||
with: | ||
terraform_version: 1.0.0 | ||
- name: Terraform Init | ||
run: terraform init | ||
- name: Terraform Plan | ||
run: terraform plan | ||
- name: Terraform Apply | ||
run: terraform apply -auto-approve | ||
env: | ||
TF_VAR_region: ${{ secrets.AWS_REGION }} | ||
TF_VAR_instance_type: ${{ secrets.AWS_INSTANCE_TYPE }} | ||
TF_VAR_ami: ${{ secrets.AWS_AMI }} | ||
""" | ||
|
||
with open(os.path.join(base_directory, "main.tf"), "w") as f: | ||
f.write(terraform_main) | ||
|
||
with open(os.path.join(base_directory, "variables.tf"), "w") as f: | ||
f.write(terraform_variables) | ||
|
||
with open(os.path.join(ci_directory, "terraform-ci.yml"), "w") as f: | ||
f.write(github_actions) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: true | ||
tags: myimage:latest |
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,4 @@ | ||
apiVersion: v2 | ||
name: myhelm | ||
description: A Helm chart for Kubernetes | ||
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,12 @@ | ||
# Default values for myhelm. | ||
# This is a YAML-formatted file. | ||
# Declare variables to be passed into your templates. | ||
replicaCount: 1 | ||
image: | ||
repository: myimage | ||
pullPolicy: IfNotPresent | ||
tag: "" | ||
service: | ||
name: myservice | ||
type: ClusterIP | ||
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
Oops, something went wrong.