Skip to content

Commit da7aa07

Browse files
committed
Merge branch 'master' into jcasc
2 parents 64aaf8c + cf85d40 commit da7aa07

17 files changed

Lines changed: 394 additions & 230 deletions

File tree

app/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from app.routes.utils import *
22
from app.routes.terraform import *
33
from app.routes.helm import *
4-
from app.routes.ansible import *
4+
from app.routes.ansible import *
5+
from app.routes.jcasc import *
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{{/*
2+
Common template helpers
3+
*/}}
4+
{{- define "my-helm.fullname" -}}
5+
{{- printf "%s-%s" .Release.Name .Chart.Name | trunc 63 | trimSuffix "-" -}}
6+
{{- end -}}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: web-ingress
6+
spec:
7+
rules:
8+
- host: 123.com
9+
http:
10+
paths:
11+
- path: /
12+
pathType: Prefix
13+
backend:
14+
service:
15+
name: web
16+
port:
17+
number: 80
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
resource "argocd_repository" "repository" {
2+
count = var.repository_create ? 1 : 0
3+
repo = var.argocd_repository_info["repo"]
4+
username = var.argocd_repository_info["username"]
5+
password = var.argocd_repository_info["password"]
6+
}
7+
8+
resource "argocd_application" "application" {
9+
count = var.application_create ? 1 : 0
10+
11+
depends_on = []
12+
13+
metadata {
14+
name = var.argocd_application["name"]
15+
namespace = "argocd"
16+
labels = {
17+
using_sync_policy_options = "true"
18+
}
19+
}
20+
21+
spec {
22+
destination {
23+
server = var.argocd_application["destination_server"]
24+
namespace = var.argocd_application["destination_namespace"]
25+
}
26+
27+
source {
28+
repo_url = var.argocd_application["source_repo_url"]
29+
path = var.argocd_application["source_path"]
30+
target_revision = var.argocd_application["source_target_revision"]
31+
}
32+
33+
sync_policy {
34+
automated {
35+
prune = false
36+
self_heal = true
37+
}
38+
sync_options = var.argocd_sync_options
39+
}
40+
}
41+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
repository_create = false
2+
argocd_repository_info = {
3+
repo = "https://YOUR_REPO.git"
4+
username = "USERNAME"
5+
password = "CHANGE_ME_WITH_TOKEN"
6+
}
7+
8+
application_create = true
9+
argocd_application = {
10+
name = "APPLICATION_NAME"
11+
destination_server = "https://kubernetes.default.svc"
12+
destination_namespace = "DESTINATION_NAMESPACE"
13+
source_repo_url = "https://YOUR_REPO.git"
14+
source_path = "SOURCE_PATH"
15+
source_target_revision = "SOURCE_TARGET_REVISION"
16+
}
17+
18+
argocd_sync_options = ["CreateNamespace=true", "ApplyOutOfSyncOnly=true", "FailOnSharedResource=true"]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
variable "repository_create" {
2+
type = bool
3+
}
4+
5+
variable "argocd_repository_info" {
6+
type = map(string)
7+
}
8+
9+
variable "application_create" {
10+
type = bool
11+
}
12+
13+
variable "argocd_application" {
14+
type = map(string)
15+
}
16+
17+
variable "argocd_sync_options" {
18+
type = list(string)
19+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.0"
3+
4+
required_providers {
5+
argocd = {
6+
source = "oboukili/argocd"
7+
version = ">= 6.0.2"
8+
}
9+
}
10+
}

app/models/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .helm_models import *
22
from .terraform_models import *
33
from .utils import *
4-
from .ansible_models import *
4+
from .ansible_models import *
5+
from .jcasc import *

app/models/jcasc.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from pydantic import BaseModel
2+
from typing import List, Optional
3+
4+
5+
class Jcasc(BaseModel):
6+
allowsSignup:bool = True
7+
allowAnonymousRead:bool = True
8+
cache_size:int = 1
9+
executators:int = 1
10+
required_plugins:List[str]
11+

app/routes/jcasc.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from app.app_instance import app
2+
from app.gpt_services import gpt_service
3+
from app.services import (write_installation,edit_directory_generator,execute_pythonfile)
4+
from app.models import (Jcasc,Output)
5+
from app.template_generators.jenkins.jcasc import jcasc_template_generator
6+
import os
7+
8+
@app.post("/jcasc-template/")
9+
async def jcasc_template_generation(request:Jcasc) -> Output:
10+
if os.environ.get("TEST"):
11+
return Output(output='output')
12+
generated_prompt = jcasc_template_generator(request)
13+
output = gpt_service(generated_prompt)
14+
edit_directory_generator("jcasc_generator",output)
15+
execute_pythonfile("MyJcasc","jcasc_generator")
16+
return Output(output='output')

0 commit comments

Comments
 (0)