Skip to content

Commit

Permalink
Merge pull request #353 from nyrahul/main
Browse files Browse the repository at this point in the history
removed adm controller policy recommend
  • Loading branch information
nyrahul authored Aug 8, 2023
2 parents 4282ba6 + 0c5d6bc commit d0906eb
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions recommend/recommend.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

// DefaultPoliciesToBeRecommended are the default policies to be recommended
var DefaultPoliciesToBeRecommended = []string{KyvernoPolicy, KubeArmorPolicy}
var DefaultPoliciesToBeRecommended = []string{ /*KyvernoPolicy, */ KubeArmorPolicy}

// KyvernoPolicy is alias for kyverno policy. The actual kind of Kyverno policy is 'Policy' but we use 'KyvernoPolicy'
// to explicitly differentiate it from other policy types.
Expand Down Expand Up @@ -130,20 +130,26 @@ func Recommend(c *k8s.Client, o Options) error {
return err
}
for _, dp := range dps.Items {

if matchLabels(labelMap, dp.Spec.Template.Labels) {
images := []string{}
for _, container := range dp.Spec.Template.Spec.Containers {
images = append(images, container.Image)
}

deployments = append(deployments, Deployment{
Name: dp.Name,
Namespace: dp.Namespace,
Labels: dp.Spec.Template.Labels,
Images: images,
})
if !matchLabels(labelMap, dp.Spec.Template.Labels) {
continue
}
images := []string{}
for _, container := range dp.Spec.Template.Spec.Containers {
images = append(images, container.Image)
}

deployments = append(deployments, Deployment{
Name: dp.Name,
Namespace: dp.Namespace,
Labels: dp.Spec.Template.Labels,
Images: images,
})
}
if len(deployments) == 0 {
log.WithFields(log.Fields{
"namespace": o.Namespace,
}).Error("no k8s deployments found, hence nothing to recommend!")
return nil
}
} else {
deployments = append(deployments, Deployment{
Expand Down

0 comments on commit d0906eb

Please sign in to comment.