Skip to content

Commit a67d21a

Browse files
committed
feat: add insecure and caRef to generator Gitlab
Signed-off-by: chansuke <moonset20@gmail.com>
1 parent 5bd3123 commit a67d21a

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

argocd/schema_application_set.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,18 @@ func applicationSetPullRequestGeneratorSchemaV0() *schema.Schema {
994994
MaxItems: 1,
995995
Elem: secretRefResource(),
996996
},
997+
"insecure": {
998+
Type: schema.TypeBool,
999+
Description: "A flag for checking the validity of the SCM's certificates.",
1000+
Optional: true,
1001+
},
1002+
"ca_ref": {
1003+
Type: schema.TypeList,
1004+
Description: "Reference to a ConfigMap key containing trusted CA certificates for verifying the SCM server's TLS certificate.",
1005+
Optional: true,
1006+
MaxItems: 1,
1007+
Elem: configMapRefResource(),
1008+
},
9971009
},
9981010
},
9991011
},
@@ -1078,3 +1090,20 @@ func secretRefResource() *schema.Resource {
10781090
},
10791091
}
10801092
}
1093+
1094+
func configMapRefResource() *schema.Resource {
1095+
return &schema.Resource{
1096+
Schema: map[string]*schema.Schema{
1097+
"key": {
1098+
Type: schema.TypeString,
1099+
Description: "Key containing information in trusted CA certs.",
1100+
Required: true,
1101+
},
1102+
"config_map_name": {
1103+
Type: schema.TypeString,
1104+
Description: "Name of the ConfigMap.",
1105+
Required: true,
1106+
},
1107+
},
1108+
}
1109+
}

argocd/structure_application_set.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,14 @@ func expandApplicationSetPullRequestGeneratorGitlab(g map[string]interface{}) *a
579579
spgg.TokenRef = expandSecretRef(v[0].(map[string]interface{}))
580580
}
581581

582+
if v, ok := g["insecure"].(bool); ok {
583+
spgg.Insecure = v
584+
}
585+
586+
if v, ok := g["ca_ref"].([]interface{}); ok && len(v) > 0 {
587+
spgg.CARef = expandConfigMapKeyRef(v[0].(map[string]interface{}))
588+
}
589+
582590
return spgg
583591
}
584592

@@ -1356,6 +1364,7 @@ func flattenApplicationSetPullRequestGeneratorGitlab(prgg *application.PullReque
13561364
"api": prgg.API,
13571365
"project": prgg.Project,
13581366
"pull_request_state": prgg.PullRequestState,
1367+
"insecure": prgg.Insecure,
13591368
}
13601369

13611370
if len(prgg.Labels) > 0 {
@@ -1366,6 +1375,10 @@ func flattenApplicationSetPullRequestGeneratorGitlab(prgg *application.PullReque
13661375
g["token_ref"] = flattenSecretRef(*prgg.TokenRef)
13671376
}
13681377

1378+
if prgg.CARef != nil {
1379+
g["ca_ref"] = flattenConfigMapKeyRef(*prgg.CARef)
1380+
}
1381+
13691382
return []map[string]interface{}{g}
13701383
}
13711384

argocd/structures.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ func expandSecretRef(sr map[string]interface{}) *application.SecretRef {
5454
}
5555
}
5656

57+
func expandConfigMapKeyRef(cmr map[string]interface{}) *application.ConfigMapKeyRef {
58+
return &application.ConfigMapKeyRef{
59+
Key: cmr["key"].(string),
60+
ConfigMapName: cmr["config_map_name"].(string),
61+
}
62+
}
63+
5764
func flattenIntOrString(ios *intstr.IntOrString) string {
5865
if ios == nil {
5966
return ""
@@ -87,6 +94,15 @@ func flattenSecretRef(sr application.SecretRef) []map[string]interface{} {
8794
}
8895
}
8996

97+
func flattenConfigMapKeyRef(cmr application.ConfigMapKeyRef) []map[string]interface{} {
98+
return []map[string]interface{}{
99+
{
100+
"key": cmr.Key,
101+
"config_map_name": cmr.ConfigMapName,
102+
},
103+
}
104+
}
105+
90106
func flattenSyncWindows(sws application.SyncWindows) (result []map[string]interface{}) {
91107
for _, sw := range sws {
92108
result = append(result, map[string]interface{}{

0 commit comments

Comments
 (0)