Skip to content

Commit

Permalink
Merge branch 'devopshobbies:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
abolfazl8131 authored Nov 27, 2024
2 parents 6c4a7e1 + 6b07ce3 commit 51e8723
Show file tree
Hide file tree
Showing 18 changed files with 315 additions and 43 deletions.
3 changes: 2 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from app.routes.utils import *
from app.routes.terraform import *
from app.routes.helm import *
from app.routes.ansible import *
from app.routes.ansible import *
from app.routes.jcasc import *
6 changes: 6 additions & 0 deletions app/media/MyHelm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{/*
Common template helpers
*/}}
{{- define "my-helm.fullname" -}}
{{- printf "%s-%s" .Release.Name .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
17 changes: 17 additions & 0 deletions app/media/MyHelm/templates/web/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: web-ingress
spec:
rules:
- host: 123.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web
port:
number: 80
41 changes: 41 additions & 0 deletions app/media/MyTerraform/modules/argocd/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
resource "argocd_repository" "repository" {
count = var.repository_create ? 1 : 0
repo = var.argocd_repository_info["repo"]
username = var.argocd_repository_info["username"]
password = var.argocd_repository_info["password"]
}

resource "argocd_application" "application" {
count = var.application_create ? 1 : 0

depends_on = []

metadata {
name = var.argocd_application["name"]
namespace = "argocd"
labels = {
using_sync_policy_options = "true"
}
}

spec {
destination {
server = var.argocd_application["destination_server"]
namespace = var.argocd_application["destination_namespace"]
}

source {
repo_url = var.argocd_application["source_repo_url"]
path = var.argocd_application["source_path"]
target_revision = var.argocd_application["source_target_revision"]
}

sync_policy {
automated {
prune = false
self_heal = true
}
sync_options = var.argocd_sync_options
}
}
}
18 changes: 18 additions & 0 deletions app/media/MyTerraform/modules/argocd/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
repository_create = false
argocd_repository_info = {
repo = "https://YOUR_REPO.git"
username = "USERNAME"
password = "CHANGE_ME_WITH_TOKEN"
}

application_create = true
argocd_application = {
name = "APPLICATION_NAME"
destination_server = "https://kubernetes.default.svc"
destination_namespace = "DESTINATION_NAMESPACE"
source_repo_url = "https://YOUR_REPO.git"
source_path = "SOURCE_PATH"
source_target_revision = "SOURCE_TARGET_REVISION"
}

argocd_sync_options = ["CreateNamespace=true", "ApplyOutOfSyncOnly=true", "FailOnSharedResource=true"]
19 changes: 19 additions & 0 deletions app/media/MyTerraform/modules/argocd/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
variable "repository_create" {
type = bool
}

variable "argocd_repository_info" {
type = map(string)
}

variable "application_create" {
type = bool
}

variable "argocd_application" {
type = map(string)
}

variable "argocd_sync_options" {
type = list(string)
}
10 changes: 10 additions & 0 deletions app/media/MyTerraform/modules/argocd/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 1.0"

required_providers {
argocd = {
source = "oboukili/argocd"
version = ">= 6.0.2"
}
}
}
3 changes: 2 additions & 1 deletion app/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .helm_models import *
from .terraform_models import *
from .utils import *
from .ansible_models import *
from .ansible_models import *
from .jcasc import *
11 changes: 11 additions & 0 deletions app/models/jcasc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from pydantic import BaseModel
from typing import List, Optional


class Jcasc(BaseModel):
allowsSignup:bool = True
allowAnonymousRead:bool = True
cache_size:int = 1
executators:int = 1
required_plugins:List[str]

16 changes: 16 additions & 0 deletions app/routes/jcasc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from app.app_instance import app
from app.gpt_services import gpt_service
from app.services import (write_installation,edit_directory_generator,execute_pythonfile)
from app.models import (Jcasc,Output)
from app.template_generators.jenkins.jcasc import jcasc_template_generator
import os

@app.post("/jcasc-template/")
async def jcasc_template_generation(request:Jcasc) -> Output:
if os.environ.get("TEST"):
return Output(output='output')
generated_prompt = jcasc_template_generator(request)
output = gpt_service(generated_prompt)
edit_directory_generator("jcasc_generator",output)
execute_pythonfile("MyJcasc","jcasc_generator")
return Output(output='output')
4 changes: 4 additions & 0 deletions app/template_generators/jenkins/jcasc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

def jcasc_template_generator(input):
prompt = """M"""
return prompt
2 changes: 2 additions & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@emotion/react": "^11.13.3",
"@tanstack/react-query": "^5.59.19",
"axios": "^1.7.7",
"clsx": "^2.1.1",
"i": "^0.3.7",
"next-themes": "^0.4.3",
"npm": "^10.9.0",
Expand All @@ -22,6 +23,7 @@
"react-hook-form": "^7.53.2",
"react-icons": "^5.3.0",
"react-router-dom": "^6.27.0",
"tailwind-merge": "^2.5.5",
"uuid": "^11.0.3",
"zustand": "^5.0.1"
},
Expand Down
17 changes: 17 additions & 0 deletions web/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions web/src/components/internal-ui/PlatformBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface PlatformProps<FormData, RequestData> {
mapperFunction: (data: FormData) => RequestData;
}

const PlatformBox = <FormData extends {}, RequestData extends {}>({
const PlatformBox = <FormData extends object, RequestData extends object>({
serviceName,
defaultValues,
endpoint,
Expand All @@ -36,7 +36,7 @@ const PlatformBox = <FormData extends {}, RequestData extends {}>({
<div className="flex flex-col ">
<FormProvider {...formMethods}>
<form onSubmit={handleFormSubmit}>
<div className="flex flex-col justify-between w-full border items-center gap-y-5 border-orange-300 p-8">
<div className="flex flex-col items-center justify-between w-full p-8 border border-orange-300 gap-y-5">
<HStack lg={{ gap: 5 }} md={{ gap: 3 }}>
<p className="font-bold">{serviceName}: </p>
{fieldProperties.map((field) => (
Expand Down
5 changes: 1 addition & 4 deletions web/src/features/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,8 @@ export enum TerraformIAMFields {
export enum TerraformArgocdFields {
AUTO_PRUNE = "autoPrune",
SELF_HEAL = "selfHeal",
APPLY_OUT_OF_SYNC_ONLY = "applyOutOfSyncOnly",
CREATE_NAMESPACE = "createNamespace",
FAIL_OR_SHARE_RESOURCE = "failOrShareResource",
ARGOCD_REPOSITORY = "argocdRepository",
ARGOCD_CLUSTER = "argocdCluster",
APPLICATION_DEPENDS_REPOSITORY = "applicationDependsRepository",
}

export enum UserType {
Expand Down
Loading

0 comments on commit 51e8723

Please sign in to comment.