diff --git a/src/networkpolicy/helperFunctions.go b/src/networkpolicy/helperFunctions.go index 54aaee4a..75d04956 100644 --- a/src/networkpolicy/helperFunctions.go +++ b/src/networkpolicy/helperFunctions.go @@ -779,7 +779,7 @@ func GetNetPolicy(cluster, namespace, policyType string) *wpb.WorkerResponse { var response wpb.WorkerResponse - if strings.Contains(policyType, "cilium") { + if strings.Contains(policyType, "CiliumNetworkPolicy") { latestPolicies := libs.GetNetworkPolicies(CfgDB, cluster, namespace, "latest", "", "") log.Info().Msgf("No. of latestPolicies - %d", len(latestPolicies)) ciliumPolicies := plugin.ConvertKnoxPoliciesToCiliumPolicies(latestPolicies) @@ -797,7 +797,7 @@ func GetNetPolicy(cluster, namespace, policyType string) *wpb.WorkerResponse { response.Ciliumpolicy = append(response.Ciliumpolicy, &ciliumpolicy) } response.K8SNetworkpolicy = nil - } else if strings.Contains(policyType, "generic") { + } else if strings.Contains(policyType, "NetworkPolicy") { knoxNetPolicies := libs.GetNetworkPolicies(config.CurrentCfg.ConfigDB, cluster, namespace, "latest", "", "") policies := plugin.ConvertKnoxNetPolicyToK8sNetworkPolicy(cluster, namespace, knoxNetPolicies) diff --git a/src/plugin/k8sNetwork.go b/src/plugin/k8sNetwork.go index c7cd00d7..49e0df8c 100644 --- a/src/plugin/k8sNetwork.go +++ b/src/plugin/k8sNetwork.go @@ -27,7 +27,6 @@ func ConvertKnoxNetPolicyToK8sNetworkPolicy(clustername, namespace string, knoxN k8NetPol.Kind = types.K8sNwPolicyKind k8NetPol.Name = knp.Metadata["name"] k8NetPol.Namespace = knp.Metadata["namespace"] - k8NetPol.ClusterName = knp.Metadata["cluster_name"] k8NetPol.Labels = knp.Spec.Selector.MatchLabels if len(knp.Spec.Egress) > 0 { diff --git a/src/server/grpcServer.go b/src/server/grpcServer.go index fa9f143e..30076955 100644 --- a/src/server/grpcServer.go +++ b/src/server/grpcServer.go @@ -107,18 +107,18 @@ func (s *workerServer) GetWorkerStatus(ctx context.Context, in *wpb.WorkerReques func (s *workerServer) Convert(ctx context.Context, in *wpb.WorkerRequest) (*wpb.WorkerResponse, error) { - if strings.Contains(in.GetPolicytype(), "network") { + if strings.Contains(in.GetPolicytype(), "CiliumNetworkPolicy") || strings.Contains(in.GetPolicytype(), "NetworkPolicy") { log.Info().Msg("Convert network policy called") network.InitNetPolicyDiscoveryConfiguration() network.WriteNetworkPoliciesToFile(in.GetClustername(), in.GetNamespace()) return network.GetNetPolicy(in.Clustername, in.Namespace, in.GetPolicytype()), nil - } else if in.GetPolicytype() == "system" { + } else if in.GetPolicytype() == "KubearmorSecurityPolicy" { log.Info().Msg("Convert system policy called") system.InitSysPolicyDiscoveryConfiguration() system.WriteSystemPoliciesToFile(in.GetNamespace(), in.GetClustername(), in.GetLabels(), in.GetFromsource(), in.GetIncludenetwork()) return system.GetSysPolicy(in.Namespace, in.Clustername, in.Labels, in.Fromsource, in.Includenetwork), nil } else { - log.Info().Msg("Convert policy called, but no policy type") + log.Error().Msgf("unsupported policy type - %s", in.GetPolicytype()) } return &wpb.WorkerResponse{Res: "ok"}, nil