From 6c8d565470322c372856756176efc99b64311634 Mon Sep 17 00:00:00 2001 From: yossigilad-aquasec Date: Sun, 22 May 2022 10:48:30 +0300 Subject: [PATCH] Fixing kube-enforcer group creation issue: Error: {"message":"Currently container runtime is not supported, supported container runtime is only docker for kube enforcer","code":400} --- GNUmakefile | 2 +- aquasec/resource_enforcer_group.go | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index d2f926b..8967e56 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -6,7 +6,7 @@ HOSTNAME := github.com NAMESPACE := aquasec NAME := aquasec BINARY := terraform-provider-${NAME} -VERSION := 0.8.10 +VERSION := 0.8.11 OS_ARCH := $(shell go env GOOS)_$(shell go env GOARCH) default: build diff --git a/aquasec/resource_enforcer_group.go b/aquasec/resource_enforcer_group.go index cfff691..c1e3bfb 100644 --- a/aquasec/resource_enforcer_group.go +++ b/aquasec/resource_enforcer_group.go @@ -500,6 +500,16 @@ func expandEnforcerGroup(d *schema.ResourceData) client.EnforcerGroup { enforcerType, ok := d.GetOk("type") if ok { enforcerGroup.Type = enforcerType.(string) + if enforcerType != "agent" { + enforcerGroup.RuntimeType = "docker" + } else { + runtimeType, ok := d.GetOk("runtime_type") + if ok { + enforcerGroup.RuntimeType = runtimeType.(string) + } else { + enforcerGroup.RuntimeType = "docker" + } + } } admissionControl, ok := d.GetOk("admission_control") @@ -677,11 +687,6 @@ func expandEnforcerGroup(d *schema.ResourceData) client.EnforcerGroup { enforcerGroup.RiskExplorerAutoDiscovery = riskExplorerAutoDiscovery.(bool) } - runtimeType, ok := d.GetOk("runtime_type") - if ok { - enforcerGroup.RuntimeType = runtimeType.(string) - } - syncHostImages, ok := d.GetOk("sync_host_images") if ok { enforcerGroup.SyncHostImages = syncHostImages.(bool)