From a67d21a6ea6dcd910afe98febbf186a6587e4feb Mon Sep 17 00:00:00 2001 From: chansuke Date: Sun, 24 Aug 2025 23:38:47 +0900 Subject: [PATCH] feat: add `insecure` and `caRef` to generator Gitlab Signed-off-by: chansuke --- argocd/schema_application_set.go | 29 +++++++++++++++++++++++++++++ argocd/structure_application_set.go | 13 +++++++++++++ argocd/structures.go | 16 ++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/argocd/schema_application_set.go b/argocd/schema_application_set.go index a52c7ca8..9224f565 100644 --- a/argocd/schema_application_set.go +++ b/argocd/schema_application_set.go @@ -994,6 +994,18 @@ func applicationSetPullRequestGeneratorSchemaV0() *schema.Schema { MaxItems: 1, Elem: secretRefResource(), }, + "insecure": { + Type: schema.TypeBool, + Description: "A flag for checking the validity of the SCM's certificates.", + Optional: true, + }, + "ca_ref": { + Type: schema.TypeList, + Description: "Reference to a ConfigMap key containing trusted CA certificates for verifying the SCM server's TLS certificate.", + Optional: true, + MaxItems: 1, + Elem: configMapRefResource(), + }, }, }, }, @@ -1078,3 +1090,20 @@ func secretRefResource() *schema.Resource { }, } } + +func configMapRefResource() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Description: "Key containing information in trusted CA certs.", + Required: true, + }, + "config_map_name": { + Type: schema.TypeString, + Description: "Name of the ConfigMap.", + Required: true, + }, + }, + } +} diff --git a/argocd/structure_application_set.go b/argocd/structure_application_set.go index c912c94f..b0e31a04 100644 --- a/argocd/structure_application_set.go +++ b/argocd/structure_application_set.go @@ -579,6 +579,14 @@ func expandApplicationSetPullRequestGeneratorGitlab(g map[string]interface{}) *a spgg.TokenRef = expandSecretRef(v[0].(map[string]interface{})) } + if v, ok := g["insecure"].(bool); ok { + spgg.Insecure = v + } + + if v, ok := g["ca_ref"].([]interface{}); ok && len(v) > 0 { + spgg.CARef = expandConfigMapKeyRef(v[0].(map[string]interface{})) + } + return spgg } @@ -1356,6 +1364,7 @@ func flattenApplicationSetPullRequestGeneratorGitlab(prgg *application.PullReque "api": prgg.API, "project": prgg.Project, "pull_request_state": prgg.PullRequestState, + "insecure": prgg.Insecure, } if len(prgg.Labels) > 0 { @@ -1366,6 +1375,10 @@ func flattenApplicationSetPullRequestGeneratorGitlab(prgg *application.PullReque g["token_ref"] = flattenSecretRef(*prgg.TokenRef) } + if prgg.CARef != nil { + g["ca_ref"] = flattenConfigMapKeyRef(*prgg.CARef) + } + return []map[string]interface{}{g} } diff --git a/argocd/structures.go b/argocd/structures.go index aa824050..8987c7fa 100644 --- a/argocd/structures.go +++ b/argocd/structures.go @@ -54,6 +54,13 @@ func expandSecretRef(sr map[string]interface{}) *application.SecretRef { } } +func expandConfigMapKeyRef(cmr map[string]interface{}) *application.ConfigMapKeyRef { + return &application.ConfigMapKeyRef{ + Key: cmr["key"].(string), + ConfigMapName: cmr["config_map_name"].(string), + } +} + func flattenIntOrString(ios *intstr.IntOrString) string { if ios == nil { return "" @@ -87,6 +94,15 @@ func flattenSecretRef(sr application.SecretRef) []map[string]interface{} { } } +func flattenConfigMapKeyRef(cmr application.ConfigMapKeyRef) []map[string]interface{} { + return []map[string]interface{}{ + { + "key": cmr.Key, + "config_map_name": cmr.ConfigMapName, + }, + } +} + func flattenSyncWindows(sws application.SyncWindows) (result []map[string]interface{}) { for _, sw := range sws { result = append(result, map[string]interface{}{