Skip to content

Commit

Permalink
chore(metrics-operator): cleanup APIs (#3270)
Browse files Browse the repository at this point in the history
Signed-off-by: odubajDT <[email protected]>
  • Loading branch information
odubajDT authored Mar 21, 2024
1 parent c3ef392 commit a683c9a
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 440 deletions.
44 changes: 0 additions & 44 deletions metrics-operator/api/v1beta1/analysis_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package v1beta1

import (
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -119,45 +117,3 @@ type AnalysisList struct {
func init() {
SchemeBuilder.Register(&Analysis{}, &AnalysisList{})
}

// GetFrom returns the 'from' timestamp from the status of the Analysis.
// This function has been added to provide a clear way of retrieving the correct timestamp
// to use, which is the one from the Status.
func (a *Analysis) GetFrom() time.Time {
return a.Status.Timeframe.GetFrom()
}

// GetTo returns the 'from' timestamp from the status of the Analysis.
// This function has been added to provide a clear way of retrieving the correct timestamp
// to use, which is the one from the Status.
func (a *Analysis) GetTo() time.Time {
return a.Status.Timeframe.GetTo()
}

func (a *Analysis) EnsureTimeframeIsSet() {
// make sure the correct time frame is set in the status - once an Analysis with a duration string specifying the
// time frame is triggered, the time frame derived from that duration should stay the same and not shift over the course
// of multiple reconciliation loops
if a.Status.Timeframe.From.IsZero() || a.Status.Timeframe.To.IsZero() {
a.Status.Timeframe.From = metav1.Time{
Time: a.Spec.GetFrom(),
}
a.Status.Timeframe.To = metav1.Time{
Time: a.Spec.GetTo(),
}
}
}

func (t *Timeframe) GetFrom() time.Time {
if t.Recent.Duration > 0 {
return time.Now().UTC().Add(-t.Recent.Duration)
}
return t.From.Time
}

func (t *Timeframe) GetTo() time.Time {
if t.Recent.Duration > 0 {
return time.Now().UTC()
}
return t.To.Time
}
80 changes: 0 additions & 80 deletions metrics-operator/api/v1beta1/analysis_types_test.go

This file was deleted.

4 changes: 0 additions & 4 deletions metrics-operator/api/v1beta1/analysisdefinition_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,3 @@ type AnalysisDefinitionList struct {
func init() {
SchemeBuilder.Register(&AnalysisDefinition{}, &AnalysisDefinitionList{})
}

func (o *OperatorValue) GetFloatValue() float64 {
return o.FixedValue.AsApproximateFloat64()
}
16 changes: 0 additions & 16 deletions metrics-operator/api/v1beta1/analysisdefinition_types_test.go

This file was deleted.

20 changes: 0 additions & 20 deletions metrics-operator/api/v1beta1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ type ObjectReference struct {
Namespace string `json:"namespace,omitempty"`
}

func (o *ObjectReference) IsNamespaceSet() bool {
return o.Namespace != ""
}

func (o *ObjectReference) GetNamespace(defaultNamespace string) string {
if o.IsNamespaceSet() {
return o.Namespace
}

return defaultNamespace
}

// AnalysisState represents the state of the analysis
type AnalysisState string

Expand All @@ -28,11 +16,3 @@ const (
StateProgressing AnalysisState = "Progressing"
StateCompleted AnalysisState = "Completed"
)

func (s AnalysisState) IsPending() bool {
return s == StatePending || s == ""
}

func (s AnalysisState) IsCompleted() bool {
return s == StateCompleted
}
46 changes: 0 additions & 46 deletions metrics-operator/api/v1beta1/common_test.go

This file was deleted.

4 changes: 0 additions & 4 deletions metrics-operator/api/v1beta1/keptnmetric_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,3 @@ type KeptnMetricList struct {
func init() {
SchemeBuilder.Register(&KeptnMetric{}, &KeptnMetricList{})
}

func (s *KeptnMetric) IsStatusSet() bool {
return s.Status.Value != ""
}
53 changes: 0 additions & 53 deletions metrics-operator/api/v1beta1/keptnmetric_types_test.go

This file was deleted.

31 changes: 0 additions & 31 deletions metrics-operator/api/v1beta1/keptnmetricsprovider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package v1beta1

import (
"strings"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -67,32 +65,3 @@ type KeptnMetricsProviderList struct {
func init() {
SchemeBuilder.Register(&KeptnMetricsProvider{}, &KeptnMetricsProviderList{})
}

func (p *KeptnMetricsProvider) HasSecretDefined() bool {
if p.Spec.SecretKeyRef == (corev1.SecretKeySelector{}) {
return false
}
//if the secret name exists the secret is defined
if strings.TrimSpace(p.Spec.SecretKeyRef.Name) == "" {
return false
}
return true
}

func (p *KeptnMetricsProvider) HasSecretKeyDefined() bool {
if p.Spec.SecretKeyRef == (corev1.SecretKeySelector{}) {
return false
}
//if the secret name exists the secret is defined
if strings.TrimSpace(p.Spec.SecretKeyRef.Key) == "" {
return false
}
return true
}

func (p *KeptnMetricsProvider) GetType() string {
if p.Spec.Type != "" {
return p.Spec.Type
}
return p.Name
}
Loading

0 comments on commit a683c9a

Please sign in to comment.