Skip to content

Commit

Permalink
FWI-4945 - Migrate from go-funk library to lo in insights-plugins repo (
Browse files Browse the repository at this point in the history
#817)

* migrate admission plugin from go-funk to lo
* migrate opa plugin from go-funk to lo
* migrate right-sizer plugin from go-funk to lo
* migrate workloads plugin from go-funk to lo
  • Loading branch information
jslivka authored Sep 14, 2023
1 parent 545af00 commit 39660cc
Show file tree
Hide file tree
Showing 20 changed files with 54 additions and 34 deletions.
3 changes: 3 additions & 0 deletions plugins/admission/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.13.0
* Migrate from go-funk to lo

## 1.12.0
* Add 'Fairwinds Insights' indicator to Admission Controller response

Expand Down
2 changes: 1 addition & 1 deletion plugins/admission/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/samber/lo v1.38.1
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.4
github.com/thoas/go-funk v0.9.3
github.com/thoas/go-funk v0.9.3 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0
k8s.io/api v0.27.2
k8s.io/apimachinery v0.27.3
Expand Down
12 changes: 6 additions & 6 deletions plugins/admission/pkg/admission/admission.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"mime/multipart"
"net/http"

"github.com/samber/lo"
"github.com/sirupsen/logrus"
"github.com/thoas/go-funk"

admissionversion "github.com/fairwindsops/insights-plugins/plugins/admission"
"github.com/fairwindsops/insights-plugins/plugins/admission/pkg/models"
Expand Down Expand Up @@ -76,17 +76,17 @@ func sendResults(iConfig models.InsightsConfig, reports []models.ReportInfo) (pa
passed = resultMap["Success"].(bool)
actionItems := resultMap["ActionItems"]
if actionItems != nil {
actionItemToString := func(ai interface{}) string {
actionItemToString := func(ai interface{}, _ int) string {
aiMap := ai.(map[string]interface{})
return fmt.Sprintf("%s", aiMap["Title"].(string))
}
warnings = funk.Map(funk.Filter(actionItems.([]interface{}), func(ai interface{}) bool {
warnings = lo.Map(lo.Filter(actionItems.([]interface{}), func(ai interface{}, _ int) bool {
return !ai.(map[string]interface{})["Failure"].(bool)
}), actionItemToString).([]string)
}), actionItemToString)

errors = funk.Map(funk.Filter(actionItems.([]interface{}), func(ai interface{}) bool {
errors = lo.Map(lo.Filter(actionItems.([]interface{}), func(ai interface{}, _ int) bool {
return ai.(map[string]interface{})["Failure"].(bool)
}), actionItemToString).([]string)
}), actionItemToString)
}
if message, ok := resultMap["Message"]; ok {
if str, stringOK := message.(string); stringOK && len(message.(string)) > 0 {
Expand Down
6 changes: 3 additions & 3 deletions plugins/admission/pkg/opa/opa.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/fairwindsops/insights-plugins/plugins/opa/pkg/opa"
"github.com/fairwindsops/insights-plugins/plugins/opa/pkg/rego"
"github.com/hashicorp/go-multierror"
"github.com/samber/lo"
"github.com/sirupsen/logrus"
"github.com/thoas/go-funk"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"

Expand Down Expand Up @@ -76,13 +76,13 @@ func ProcessOPAV1(ctx context.Context, obj map[string]any, resourceName, apiGrou
CustomCheckName: instanceObject.CheckName,
Output: instanceObject.AdditionalData.Output,
Parameters: instanceObject.AdditionalData.Parameters,
Targets: funk.Map(instanceObject.Targets, func(s string) opa.KubeTarget {
Targets: lo.Map(instanceObject.Targets, func(s string, _ int) opa.KubeTarget {
splitValues := strings.Split(s, "/")
return opa.KubeTarget{
APIGroups: []string{splitValues[0]},
Kinds: []string{splitValues[1]},
}
}).([]opa.KubeTarget),
}),
},
}
foundTargetInInstance := false
Expand Down
2 changes: 1 addition & 1 deletion plugins/admission/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12.0
1.13.0
3 changes: 3 additions & 0 deletions plugins/opa/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 2.3.0
* migrate opa plugin from go-funk to lo

## 2.2.8
* update dependencies

Expand Down
3 changes: 2 additions & 1 deletion plugins/opa/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ replace github.com/fairwindsops/insights-plugins/plugins/opa => ./
require (
github.com/hashicorp/go-multierror v1.1.1
github.com/open-policy-agent/opa v0.49.0
github.com/samber/lo v1.38.1
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cobra v1.6.1
github.com/spf13/viper v1.15.0
github.com/stretchr/testify v1.8.1
github.com/thoas/go-funk v0.9.3
k8s.io/api v0.26.1
k8s.io/apimachinery v0.26.1
k8s.io/client-go v0.26.1
Expand Down Expand Up @@ -71,6 +71,7 @@ require (
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/yashtewari/glob-intersection v0.1.0 // indirect
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.5.0 // indirect
golang.org/x/sys v0.6.0 // indirect
Expand Down
6 changes: 4 additions & 2 deletions plugins/opa/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM=
github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
Expand Down Expand Up @@ -296,8 +298,6 @@ github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8
github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
github.com/tchap/go-patricia/v2 v2.3.1 h1:6rQp39lgIYZ+MHmdEq4xzuk1t7OdC35z/xm0BGhTkes=
github.com/tchap/go-patricia/v2 v2.3.1/go.mod h1:VZRHKAb53DLaG+nA9EaYYiaEx6YztwDlLElMsnSHD4k=
github.com/thoas/go-funk v0.9.3 h1:7+nAEx3kn5ZJcnDm2Bh23N2yOtweO14bi//dvRtgLpw=
github.com/thoas/go-funk v0.9.3/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
Expand Down Expand Up @@ -339,6 +339,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM=
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down
6 changes: 3 additions & 3 deletions plugins/opa/pkg/opa/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package opa
import (
"strings"

"github.com/thoas/go-funk"
"github.com/samber/lo"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -125,13 +125,13 @@ func (supposedInstance CheckSetting) GetCustomCheckInstance() CustomCheckInstanc
CustomCheckName: supposedInstance.CheckName,
Output: supposedInstance.AdditionalData.Output,
Parameters: supposedInstance.AdditionalData.Parameters,
Targets: funk.Map(supposedInstance.Targets, func(s string) KubeTarget {
Targets: lo.Map(supposedInstance.Targets, func(s string, _ int) KubeTarget {
splitValues := strings.Split(s, "/")
return KubeTarget{
APIGroups: []string{splitValues[0]},
Kinds: []string{splitValues[1]},
}
}).([]KubeTarget),
}),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/opa/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.8
2.3.0
3 changes: 3 additions & 0 deletions plugins/right-sizer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.5.0
* migrate right-sizer plugin from go-funk to lo

## 0.4.9
* Update image repo for noisy-neighbor, used by E2E test workload.

Expand Down
3 changes: 2 additions & 1 deletion plugins/right-sizer/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/google/go-cmp v0.5.9
github.com/jessevdk/go-flags v1.5.0
github.com/prometheus/client_golang v1.14.0
github.com/thoas/go-funk v0.9.3
github.com/samber/lo v1.38.1
gopkg.in/inf.v0 v0.9.1
k8s.io/api v0.26.1
k8s.io/apimachinery v0.26.1
Expand Down Expand Up @@ -42,6 +42,7 @@ require (
github.com/prometheus/common v0.39.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.5.0 // indirect
golang.org/x/sys v0.6.0 // indirect
Expand Down
7 changes: 4 additions & 3 deletions plugins/right-sizer/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NX
github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI=
github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM=
github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
Expand All @@ -134,14 +136,11 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/thoas/go-funk v0.9.3 h1:7+nAEx3kn5ZJcnDm2Bh23N2yOtweO14bi//dvRtgLpw=
github.com/thoas/go-funk v0.9.3/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
Expand All @@ -155,6 +154,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM=
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
Expand Down
8 changes: 4 additions & 4 deletions plugins/right-sizer/src/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
core "k8s.io/api/core/v1"

"github.com/google/go-cmp/cmp"
"github.com/thoas/go-funk"
"github.com/samber/lo"
kube_errors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes/scheme"
Expand Down Expand Up @@ -133,7 +133,7 @@ func NewController(stop chan struct{}, kubeClientResources util.KubeClientResour
o(cfg)
}

missingAllowedNamespaces := funk.RightJoinString(cfg.allowedNamespaces, cfg.allowedUpdateNamespaces)
_, missingAllowedNamespaces := lo.Difference(cfg.allowedNamespaces, cfg.allowedUpdateNamespaces)
if len(cfg.allowedNamespaces) > 0 && len(missingAllowedNamespaces) > 0 {
cfg.allowedNamespaces = append(cfg.allowedNamespaces, missingAllowedNamespaces...)
glog.Infof("NOTE: allowedNamespaces has been updated to include those only specified in allowedUpdateNamespaces, the new allowedNamespaces list is: %v", cfg.allowedNamespaces)
Expand Down Expand Up @@ -221,7 +221,7 @@ func isSameEventOccurrence(g *eventUpdateGroup) bool {
// pod, or an update related to an existing report item.
func (c *Controller) processEvent(event *core.Event) {
glog.V(4).Infof("got event %s/%s (count: %d), reason: %s, involved object: %s", event.ObjectMeta.Namespace, event.ObjectMeta.Name, event.Count, event.Reason, event.InvolvedObject.Kind)
if len(c.config.allowedNamespaces) > 0 && !funk.ContainsString(c.config.allowedNamespaces, event.ObjectMeta.Namespace) {
if len(c.config.allowedNamespaces) > 0 && !lo.Contains(c.config.allowedNamespaces, event.ObjectMeta.Namespace) {
glog.V(4).Infof("ignoring event %s/%s as its namespace is not allowed", event.ObjectMeta.Namespace, event.ObjectMeta.Name)
return
}
Expand Down Expand Up @@ -279,7 +279,7 @@ func (c *Controller) UpdateMemoryLimitsPrecheck(namespace string, OOMs int64) (b
if !c.config.updateMemoryLimits {
return false, "updating memory limits has not been enabled"
}
if len(c.config.allowedUpdateNamespaces) > 0 && !funk.ContainsString(c.config.allowedUpdateNamespaces, namespace) {
if len(c.config.allowedUpdateNamespaces) > 0 && !lo.Contains(c.config.allowedUpdateNamespaces, namespace) {
return false, fmt.Sprintf("namespace %s is not allowed by allowedUpdateNamespaces", namespace)
}
if c.config.updateMemoryLimitsMinimumOOMs > 0 && OOMs < c.config.updateMemoryLimitsMinimumOOMs {
Expand Down
2 changes: 1 addition & 1 deletion plugins/right-sizer/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.9
0.5.0
3 changes: 3 additions & 0 deletions plugins/workloads/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 2.6.0
* migrate from go-funk to lo

## 2.5.0
* add `PodLabels` and `PodAnnotations` to report output

Expand Down
3 changes: 2 additions & 1 deletion plugins/workloads/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.19

require (
github.com/fairwindsops/controller-utils v0.3.2
github.com/samber/lo v1.38.1
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.4
k8s.io/api v0.26.7
Expand All @@ -24,6 +25,7 @@ require (
github.com/mailru/easyjson v0.7.7 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
)

require (
Expand All @@ -49,7 +51,6 @@ require (
github.com/prometheus/common v0.39.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/thoas/go-funk v0.9.3
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.5.0 // indirect
golang.org/x/sys v0.6.0 // indirect
Expand Down
7 changes: 4 additions & 3 deletions plugins/workloads/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NX
github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI=
github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM=
github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
Expand All @@ -143,16 +145,13 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/thoas/go-funk v0.9.3 h1:7+nAEx3kn5ZJcnDm2Bh23N2yOtweO14bi//dvRtgLpw=
github.com/thoas/go-funk v0.9.3/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
Expand All @@ -167,6 +166,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM=
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
Expand Down
5 changes: 3 additions & 2 deletions plugins/workloads/pkg/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

"github.com/fairwindsops/controller-utils/pkg/controller"
"github.com/thoas/go-funk"
"github.com/samber/lo"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -249,5 +249,6 @@ func CreateResourceProviderFromAPI(ctx context.Context, dynamicClient dynamic.In
}

func checkIfNodeIsControlPlane(labels map[string]string) bool {
return funk.Contains(labels, "node-role.kubernetes.io/control-plane") || funk.Contains(labels, "node-role.kubernetes.io/master")
keys := lo.Keys[string, string](labels)
return lo.Contains(keys, "node-role.kubernetes.io/control-plane") || lo.Contains(keys, "node-role.kubernetes.io/master")
}
2 changes: 1 addition & 1 deletion plugins/workloads/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.0
2.6.0

0 comments on commit 39660cc

Please sign in to comment.