Skip to content

Commit 6f31e40

Browse files
authored
Merge pull request #159 from devopshobbies/terrform/argocd
fix(argocd): fix argocd pattern
2 parents c9cbcff + 442ed14 commit 6f31e40

File tree

3 files changed

+64
-41
lines changed

3 files changed

+64
-41
lines changed

app/media/terraform.tfvars

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
1-
iam_create_user = true
2-
iam_users = [
3-
{
4-
name = "devopshobbies"
5-
path = "/"
6-
}
7-
]
81

9-
iam_create_group = true
10-
iam_groups = [
11-
{
12-
name = "developers"
13-
path = "/"
14-
}
2+
argocd_instance_info = {
3+
server_addr = "http://argocd.local"
4+
username = "username"
5+
password = "password"
6+
insecure = true
7+
}
158

16-
]
9+
10+
repository_create = true
11+
argocd_repository_info = {
12+
repo = "https://your_repo.git"
13+
username = "username"
14+
password = "token"
15+
}
16+
17+
18+
application_create = false
19+
argocd_application = {
20+
name = "myapp"
21+
destination_server = "https://kubernetes.default.svc"
22+
destination_namespace = "default"
23+
source_repo_url = "https://your_repo.git"
24+
source_path = "myapp/manifests"
25+
source_target_revision = "master"
26+
}
27+
28+
29+
argocd_sync_options = ["CreateNamespace=true", "ApplyOutOfSyncOnly=true", "FailOnSharedResource=true"]
30+
31+
auto_prune = false
32+
self_heal = false

app/models/terraform_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class ArgoApplication(BaseModel):
9393
class IaCTemplateGenerationArgoCD(BaseModel):
9494
argocd_application:ArgoApplication | None = None
9595
argocd_repository:bool = True
96-
application_depends_repository:bool = True
96+
9797

9898

9999
class IaCTemplateGenerationELB(BaseModel):

app/template_generators/terraform/argocd.py

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,44 @@ def IaC_template_generator_argocd(input) -> str:
99
argocd_application_selfheal = 'true' if input.argocd_application.sync_policy.self_heal else 'false'
1010
else:
1111
argocd_create_application = 'false'
12-
argocd_application_auto_prune = ""
13-
argocd_application_selfheal = ""
12+
argocd_application_auto_prune = "false"
13+
argocd_application_selfheal = "false"
1414

15-
depends_on = 'depends_on = []'
16-
if input.application_depends_repository == True:
17-
depends_on = 'depends_on = [argocd_repository.repository]'
18-
19-
tfvars_file = """
20-
argocd_instance_info = {
21-
server_addr = "ARGOCD_DOMAIN"
22-
username = "admin"
23-
password = "ARGOCD_ADMIN_PASS"
15+
16+
argocd_instance_info = """{
17+
server_addr = "http://argocd.local"
18+
username = "username"
19+
password = "password"
2420
insecure = true
2521
}
26-
27-
repository_create = true
28-
argocd_repository_info = {
29-
repo = "https://YOUR_REPO.git"
30-
username = "USERNAME"
31-
password = "CHANGE_ME_WITH_TOKEN"
22+
"""
23+
argocd_repository_info = """{
24+
repo = "https://your_repo.git"
25+
username = "username"
26+
password = "token"
3227
}
33-
34-
application_create = true
35-
argocd_application = {
36-
name = "APPLICATION_NAME"
28+
"""
29+
argocd_application = """{
30+
name = "myapp"
3731
destination_server = "https://kubernetes.default.svc"
38-
destination_namespace = "DESTINATION_NAMESPACE"
39-
source_repo_url = "https://YOUR_REPO.git"
40-
source_path = "SOURCE_PATH"
41-
source_target_revision = "SOURCE_TARGET_REVISION"
32+
destination_namespace = "default"
33+
source_repo_url = "https://your_repo.git"
34+
source_path = "myapp/manifests"
35+
source_target_revision = "master"
4236
}
37+
"""
38+
39+
tfvars_file = f"""
40+
argocd_instance_info = {argocd_instance_info}
41+
42+
repository_create = {argocd_create_repository}
43+
argocd_repository_info = {argocd_repository_info}
44+
45+
application_create = {argocd_create_application}
46+
argocd_application = {argocd_application}
47+
48+
argocd_sync_options = ["CreateNamespace=true", "ApplyOutOfSyncOnly=true", "FailOnSharedResource=true"]
4349
44-
argocd_sync_options = ["CreateNamespace=true", "ApplyOutOfSyncOnly=true", "FailOnSharedResource=true"]"""
50+
auto_prune = {argocd_application_auto_prune}
51+
self_heal = {argocd_application_selfheal} """
4552
return tfvars_file

0 commit comments

Comments
 (0)