Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(argocd): fix argocd pattern #159

Merged
merged 2 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 30 additions & 14 deletions app/media/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
iam_create_user = true
iam_users = [
{
name = "devopshobbies"
path = "/"
}
]

iam_create_group = true
iam_groups = [
{
name = "developers"
path = "/"
}
argocd_instance_info = {
server_addr = "http://argocd.local"
username = "username"
password = "password"
insecure = true
}

]

repository_create = true
argocd_repository_info = {
repo = "https://your_repo.git"
username = "username"
password = "token"
}


application_create = false
argocd_application = {
name = "myapp"
destination_server = "https://kubernetes.default.svc"
destination_namespace = "default"
source_repo_url = "https://your_repo.git"
source_path = "myapp/manifests"
source_target_revision = "master"
}


argocd_sync_options = ["CreateNamespace=true", "ApplyOutOfSyncOnly=true", "FailOnSharedResource=true"]

auto_prune = false
self_heal = false
2 changes: 1 addition & 1 deletion app/models/terraform_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class ArgoApplication(BaseModel):
class IaCTemplateGenerationArgoCD(BaseModel):
argocd_application:ArgoApplication | None = None
argocd_repository:bool = True
application_depends_repository:bool = True



class IaCTemplateGenerationELB(BaseModel):
Expand Down
59 changes: 33 additions & 26 deletions app/template_generators/terraform/argocd.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,44 @@ def IaC_template_generator_argocd(input) -> str:
argocd_application_selfheal = 'true' if input.argocd_application.sync_policy.self_heal else 'false'
else:
argocd_create_application = 'false'
argocd_application_auto_prune = ""
argocd_application_selfheal = ""
argocd_application_auto_prune = "false"
argocd_application_selfheal = "false"

depends_on = 'depends_on = []'
if input.application_depends_repository == True:
depends_on = 'depends_on = [argocd_repository.repository]'

tfvars_file = """
argocd_instance_info = {
server_addr = "ARGOCD_DOMAIN"
username = "admin"
password = "ARGOCD_ADMIN_PASS"

argocd_instance_info = """{
server_addr = "http://argocd.local"
username = "username"
password = "password"
insecure = true
}

repository_create = true
argocd_repository_info = {
repo = "https://YOUR_REPO.git"
username = "USERNAME"
password = "CHANGE_ME_WITH_TOKEN"
"""
argocd_repository_info = """{
repo = "https://your_repo.git"
username = "username"
password = "token"
}

application_create = true
argocd_application = {
name = "APPLICATION_NAME"
"""
argocd_application = """{
name = "myapp"
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"
destination_namespace = "default"
source_repo_url = "https://your_repo.git"
source_path = "myapp/manifests"
source_target_revision = "master"
}
"""

tfvars_file = f"""
argocd_instance_info = {argocd_instance_info}

repository_create = {argocd_create_repository}
argocd_repository_info = {argocd_repository_info}

application_create = {argocd_create_application}
argocd_application = {argocd_application}

argocd_sync_options = ["CreateNamespace=true", "ApplyOutOfSyncOnly=true", "FailOnSharedResource=true"]

argocd_sync_options = ["CreateNamespace=true", "ApplyOutOfSyncOnly=true", "FailOnSharedResource=true"]"""
auto_prune = {argocd_application_auto_prune}
self_heal = {argocd_application_selfheal} """
return tfvars_file
Loading