-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for multiple metrics providers (#1193)
Co-authored-by: odubajDT <93584209+odubajDT@users.noreply.github.com>
- Loading branch information
Showing
55 changed files
with
1,253 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha3" | ||
"sigs.k8s.io/controller-runtime/pkg/conversion" | ||
) | ||
|
||
// ConvertTo converts this KeptnMetric to the Hub version (v1alpha3) | ||
func (src *KeptnMetric) ConvertTo(dstRaw conversion.Hub) error { | ||
dst := dstRaw.(*v1alpha3.KeptnMetric) | ||
|
||
// Spec | ||
dst.Spec = v1alpha3.KeptnMetricSpec{ | ||
Provider: v1alpha3.ProviderRef{ | ||
Name: src.Spec.Provider.Name, | ||
}, | ||
Query: src.Spec.Query, | ||
FetchIntervalSeconds: src.Spec.FetchIntervalSeconds, | ||
} | ||
|
||
// ObjectMeta | ||
dst.ObjectMeta = src.ObjectMeta | ||
|
||
// Status | ||
dst.Status = v1alpha3.KeptnMetricStatus{ | ||
Value: src.Status.Value, | ||
RawValue: src.Status.RawValue, | ||
LastUpdated: src.Status.LastUpdated, | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// ConvertFrom converts from the Hub version (v1alpha3) to this version. | ||
func (dst *KeptnMetric) ConvertFrom(srcRaw conversion.Hub) error { | ||
src := srcRaw.(*v1alpha3.KeptnMetric) | ||
|
||
// Spec | ||
dst.Spec = KeptnMetricSpec{ | ||
Provider: ProviderRef{ | ||
Name: src.Spec.Provider.Name, | ||
}, | ||
Query: src.Spec.Query, | ||
FetchIntervalSeconds: src.Spec.FetchIntervalSeconds, | ||
} | ||
|
||
// ObjectMeta | ||
dst.ObjectMeta = src.ObjectMeta | ||
|
||
// Status | ||
dst.Status = KeptnMetricStatus{ | ||
Value: src.Status.Value, | ||
RawValue: src.Status.RawValue, | ||
LastUpdated: src.Status.LastUpdated, | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package v1alpha2 | ||
|
||
import ( | ||
"github.com/keptn/lifecycle-toolkit/metrics-operator/api/v1alpha3" | ||
"sigs.k8s.io/controller-runtime/pkg/conversion" | ||
) | ||
|
||
// ConvertTo converts this KeptnMetric to the Hub version (v1alpha3) | ||
func (src *KeptnMetric) ConvertTo(dstRaw conversion.Hub) error { | ||
dst := dstRaw.(*v1alpha3.KeptnMetric) | ||
|
||
// Spec | ||
dst.Spec = v1alpha3.KeptnMetricSpec{ | ||
Provider: v1alpha3.ProviderRef{ | ||
Name: src.Spec.Provider.Name, | ||
}, | ||
Query: src.Spec.Query, | ||
FetchIntervalSeconds: src.Spec.FetchIntervalSeconds, | ||
} | ||
|
||
// ObjectMeta | ||
dst.ObjectMeta = src.ObjectMeta | ||
|
||
// Status | ||
dst.Status = v1alpha3.KeptnMetricStatus{ | ||
Value: src.Status.Value, | ||
RawValue: src.Status.RawValue, | ||
LastUpdated: src.Status.LastUpdated, | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// ConvertFrom converts from the Hub version (v1alpha3) to this version. | ||
func (dst *KeptnMetric) ConvertFrom(srcRaw conversion.Hub) error { | ||
src := srcRaw.(*v1alpha3.KeptnMetric) | ||
|
||
// Spec | ||
dst.Spec = KeptnMetricSpec{ | ||
Provider: ProviderRef{ | ||
Name: src.Spec.Provider.Name, | ||
}, | ||
Query: src.Spec.Query, | ||
FetchIntervalSeconds: src.Spec.FetchIntervalSeconds, | ||
} | ||
|
||
// ObjectMeta | ||
dst.ObjectMeta = src.ObjectMeta | ||
|
||
// Status | ||
dst.Status = KeptnMetricStatus{ | ||
Value: src.Status.Value, | ||
RawValue: src.Status.RawValue, | ||
LastUpdated: src.Status.LastUpdated, | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.