From 24a60f5e6f8f3a383dfce554d644bfd974c4b5fd Mon Sep 17 00:00:00 2001 From: odubajDT <93584209+odubajDT@users.noreply.github.com> Date: Wed, 17 May 2023 15:49:32 +0200 Subject: [PATCH 1/2] fix(metrics-operator): introduce IsStatusSet method to KeptnMetric (#1427) Signed-off-by: odubajDT --- .../api/v1alpha3/keptnmetric_types.go | 4 ++ .../api/v1alpha3/keptnmetric_types_test.go | 53 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 metrics-operator/api/v1alpha3/keptnmetric_types_test.go diff --git a/metrics-operator/api/v1alpha3/keptnmetric_types.go b/metrics-operator/api/v1alpha3/keptnmetric_types.go index d4781566ec0..5b4e5076097 100644 --- a/metrics-operator/api/v1alpha3/keptnmetric_types.go +++ b/metrics-operator/api/v1alpha3/keptnmetric_types.go @@ -79,3 +79,7 @@ type KeptnMetricList struct { func init() { SchemeBuilder.Register(&KeptnMetric{}, &KeptnMetricList{}) } + +func (s *KeptnMetric) IsStatusSet() bool { + return s.Status.Value != "" +} diff --git a/metrics-operator/api/v1alpha3/keptnmetric_types_test.go b/metrics-operator/api/v1alpha3/keptnmetric_types_test.go new file mode 100644 index 00000000000..a7700f4017c --- /dev/null +++ b/metrics-operator/api/v1alpha3/keptnmetric_types_test.go @@ -0,0 +1,53 @@ +package v1alpha3 + +import ( + "testing" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func TestKeptnMetric_IsStatusSet(t *testing.T) { + type fields struct { + TypeMeta v1.TypeMeta + ObjectMeta v1.ObjectMeta + Spec KeptnMetricSpec + Status KeptnMetricStatus + } + tests := []struct { + name string + fields fields + want bool + }{ + { + name: "No value set", + fields: fields{ + Status: KeptnMetricStatus{ + Value: "", + }, + }, + want: false, + }, + { + name: "we have a value", + fields: fields{ + Status: KeptnMetricStatus{ + Value: "1.0", + }, + }, + want: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + s := &KeptnMetric{ + TypeMeta: tt.fields.TypeMeta, + ObjectMeta: tt.fields.ObjectMeta, + Spec: tt.fields.Spec, + Status: tt.fields.Status, + } + if got := s.IsStatusSet(); got != tt.want { + t.Errorf("IsStatusSet() = %v, want %v", got, tt.want) + } + }) + } +} From f0f7edf7041d438b8d8804ad9341ef878ed625de Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 17 May 2023 16:10:59 +0200 Subject: [PATCH 2/2] deps: update github.com/keptn/lifecycle-toolkit/metrics-operator digest to e381f7f (#1268) Signed-off-by: Renovate Bot Signed-off-by: odubajDT Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: odubajDT --- operator/controllers/common/fake/fakeclient.go | 2 +- .../common/providers/keptnmetric/keptnmetric.go | 2 +- .../common/providers/keptnmetric/keptnmetric_test.go | 2 +- .../lifecycle/keptnevaluation/controller_test.go | 2 +- operator/go.mod | 4 ++-- operator/go.sum | 8 ++++---- operator/main.go | 2 +- operator/test/component/common/common.go | 2 +- operator/test/component/evaluation/evaluation_test.go | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/operator/controllers/common/fake/fakeclient.go b/operator/controllers/common/fake/fakeclient.go index c627e2ced30..dd4dc356a1f 100644 --- a/operator/controllers/common/fake/fakeclient.go +++ b/operator/controllers/common/fake/fakeclient.go @@ -1,7 +1,7 @@ package fake import ( - metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha2" + metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha3" lfcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" optionsv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/apis/options/v1alpha1" corev1 "k8s.io/api/core/v1" diff --git a/operator/controllers/common/providers/keptnmetric/keptnmetric.go b/operator/controllers/common/providers/keptnmetric/keptnmetric.go index fd08879a7b1..7cc6ba799d3 100644 --- a/operator/controllers/common/providers/keptnmetric/keptnmetric.go +++ b/operator/controllers/common/providers/keptnmetric/keptnmetric.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/go-logr/logr" - metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha2" + metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha3" klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" "github.com/keptn/lifecycle-toolkit/operator/controllers/common" "k8s.io/apimachinery/pkg/types" diff --git a/operator/controllers/common/providers/keptnmetric/keptnmetric_test.go b/operator/controllers/common/providers/keptnmetric/keptnmetric_test.go index e05cb5919ac..beed84da0ef 100644 --- a/operator/controllers/common/providers/keptnmetric/keptnmetric_test.go +++ b/operator/controllers/common/providers/keptnmetric/keptnmetric_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha2" + metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha3" klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" "github.com/keptn/lifecycle-toolkit/operator/controllers/common" "github.com/stretchr/testify/require" diff --git a/operator/controllers/lifecycle/keptnevaluation/controller_test.go b/operator/controllers/lifecycle/keptnevaluation/controller_test.go index 06288380956..f63900019f4 100644 --- a/operator/controllers/lifecycle/keptnevaluation/controller_test.go +++ b/operator/controllers/lifecycle/keptnevaluation/controller_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/go-logr/logr" - metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha2" + metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha3" klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3/common" controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common" diff --git a/operator/go.mod b/operator/go.mod index a34af9878ef..6f3f8fc81c5 100644 --- a/operator/go.mod +++ b/operator/go.mod @@ -9,7 +9,7 @@ require ( github.com/imdario/mergo v0.3.15 github.com/kelseyhightower/envconfig v1.4.0 github.com/keptn/lifecycle-toolkit/klt-cert-manager v0.0.0-20230517124521-e381f7fc6d79 - github.com/keptn/lifecycle-toolkit/metrics-operator v0.0.0-20230413082525-dd15d4a0e0e4 + github.com/keptn/lifecycle-toolkit/metrics-operator v0.0.0-20230517134932-24a60f5e6f8f github.com/magiconair/properties v1.8.7 github.com/onsi/ginkgo/v2 v2.9.4 github.com/onsi/gomega v1.27.6 @@ -95,7 +95,7 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect k8s.io/component-base v0.26.4 // indirect - k8s.io/klog/v2 v2.90.1 // indirect + k8s.io/klog/v2 v2.100.1 // indirect k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect diff --git a/operator/go.sum b/operator/go.sum index 8272d267caf..ae45c3cd865 100644 --- a/operator/go.sum +++ b/operator/go.sum @@ -208,8 +208,8 @@ github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dv github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= github.com/keptn/lifecycle-toolkit/klt-cert-manager v0.0.0-20230517124521-e381f7fc6d79 h1:V44aeshIPrEu2L4ElKJ9Y0VPDp5j9BhT8eMzhjICyGU= github.com/keptn/lifecycle-toolkit/klt-cert-manager v0.0.0-20230517124521-e381f7fc6d79/go.mod h1:sEy6RzY7TzpDQGfbmyteR7K+NrmZ2g5wPz0FzhUNE+U= -github.com/keptn/lifecycle-toolkit/metrics-operator v0.0.0-20230413082525-dd15d4a0e0e4 h1:LI+iOb7v1zIAtHQum79CbV+4HB1PCAim+TuCCRRsW7o= -github.com/keptn/lifecycle-toolkit/metrics-operator v0.0.0-20230413082525-dd15d4a0e0e4/go.mod h1:8rQ1flqblBWy43k4xJnoaMUA7e50zP95QIab3z6NCw4= +github.com/keptn/lifecycle-toolkit/metrics-operator v0.0.0-20230517134932-24a60f5e6f8f h1:FDUUg4O36+nQFpr6L4M4Xz6ZcxG/YUr1/crE90DfjaE= +github.com/keptn/lifecycle-toolkit/metrics-operator v0.0.0-20230517134932-24a60f5e6f8f/go.mod h1:aWxBCTaDbsZWnA3gzV4X4e3CgX4lps5fmIyi5pwPKxc= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= @@ -648,8 +648,8 @@ k8s.io/client-go v0.26.4 h1:/7P/IbGBuT73A+G97trf44NTPSNqvuBREpOfdLbHvD4= k8s.io/client-go v0.26.4/go.mod h1:6qOItWm3EwxJdl/8p5t7FWtWUOwyMdA8N9ekbW4idpI= k8s.io/component-base v0.26.4 h1:Bg2xzyXNKL3eAuiTEu3XE198d6z22ENgFgGQv2GGOUk= k8s.io/component-base v0.26.4/go.mod h1:lTuWL1Xz/a4e80gmIC3YZG2JCO4xNwtKWHJWeJmsq20= -k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= -k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= +k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= +k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 h1:+70TFaan3hfJzs+7VK2o+OGxg8HsuBr/5f6tVAjDu6E= k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4= k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk= diff --git a/operator/main.go b/operator/main.go index d7b70e9b87b..3c1b5f23789 100644 --- a/operator/main.go +++ b/operator/main.go @@ -28,7 +28,7 @@ import ( "github.com/keptn/lifecycle-toolkit/klt-cert-manager/pkg/certificates" certCommon "github.com/keptn/lifecycle-toolkit/klt-cert-manager/pkg/common" "github.com/keptn/lifecycle-toolkit/klt-cert-manager/pkg/webhook" - metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha2" + metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha3" lifecyclev1alpha1 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha1" lifecyclev1alpha2 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha2" lifecyclev1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" diff --git a/operator/test/component/common/common.go b/operator/test/component/common/common.go index 6b010ad1f40..3f78d1408a0 100644 --- a/operator/test/component/common/common.go +++ b/operator/test/component/common/common.go @@ -8,7 +8,7 @@ import ( "strings" "time" - metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha2" + metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha3" klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" apicommon "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3/common" controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common" diff --git a/operator/test/component/evaluation/evaluation_test.go b/operator/test/component/evaluation/evaluation_test.go index ba8e41e4f87..9cef2968749 100644 --- a/operator/test/component/evaluation/evaluation_test.go +++ b/operator/test/component/evaluation/evaluation_test.go @@ -5,7 +5,7 @@ import ( "fmt" "time" - metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha2" + metricsapi "github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha3" klcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" apicommon "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3/common" controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common"