Skip to content

Commit 11a4cda

Browse files
authored
fix: argocd_cluster exec_provider_block should not produce a diff (#780)
Signed-off-by: Nathanael Liechti <[email protected]>
1 parent 662dbd6 commit 11a4cda

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

argocd/structure_cluster.go

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func flattenClusterInfo(info application.ClusterInfo) []map[string]interface{} {
177177
func flattenClusterConfig(config application.ClusterConfig, d *schema.ResourceData) []map[string]interface{} {
178178
r := map[string]interface{}{
179179
"username": config.Username,
180-
"exec_provider_config": flattenClusterConfigExecProviderConfig(config.ExecProviderConfig, d),
180+
"exec_provider_config": flattenClusterConfigExecProviderConfig(d),
181181
"tls_client_config": flattenClusterConfigTLSClientConfig(config.TLSClientConfig, d),
182182
}
183183

@@ -235,29 +235,31 @@ func flattenClusterConfigTLSClientConfig(tcc application.TLSClientConfig, d *sch
235235
return []map[string]interface{}{c}
236236
}
237237

238-
func flattenClusterConfigExecProviderConfig(epc *application.ExecProviderConfig, d *schema.ResourceData) []map[string]interface{} {
239-
if epc == nil {
240-
return nil
241-
}
242-
243-
c := map[string]interface{}{
244-
"api_version": epc.APIVersion,
245-
"command": epc.Command,
246-
"install_hint": epc.InstallHint,
247-
}
248-
249-
// ArgoCD API does not return these fields as they may contain
250-
// sensitive data. Thus, we can't track the state of these
251-
// attributes and load them from state instead.
252-
// See https://github.com/argoproj/argo-cd/blob/8840929187f4dd7b9d9fd908ea5085a006895507/server/cluster/cluster.go#L454-L461
238+
func flattenClusterConfigExecProviderConfig(d *schema.ResourceData) []map[string]interface{} {
239+
// ArgoCD API does not return the execProvider block as it may contain
240+
// sensitive data. Thus, we can't track the state of it
241+
// and load it from state instead.
242+
// See https://github.com/argoproj/argo-cd/commit/60c62a944b155702e6d89cbef4c04ff0f525692f#diff-47255bee56d3ad7830d9721f65c73fac53009229cb98c63c67745527d598835bL473-L486
243+
c := map[string]interface{}{}
253244
if args, ok := d.GetOk("config.0.exec_provider_config.0.args"); ok {
254245
c["args"] = args
255246
}
256-
257247
if env, ok := d.GetOk("config.0.exec_provider_config.0.env"); ok {
258248
c["env"] = env
259249
}
250+
if command, ok := d.GetOk("config.0.exec_provider_config.0.command"); ok {
251+
c["command"] = command
252+
}
253+
if apiVersion, ok := d.GetOk("config.0.exec_provider_config.0.api_version"); ok {
254+
c["api_version"] = apiVersion
255+
}
256+
if installHint, ok := d.GetOk("config.0.exec_provider_config.0.install_hint"); ok {
257+
c["install_hint"] = installHint
258+
}
260259

260+
if len(c) == 0 {
261+
return nil
262+
}
261263
return []map[string]interface{}{c}
262264
}
263265

0 commit comments

Comments
 (0)