Migrating to keda2.0 (#1868)
Co-authored-by: Rahul Bhati <rjbhati009@gmail.com> Co-authored-by: Vishal <vishal-biyani@users.noreply.github.com>
This commit is contained in:
co-authored by
Rahul Bhati
Vishal
parent
045a365a1b
commit
e4a0aa3480
@@ -45,7 +45,6 @@ require (
|
|||||||
github.com/opencontainers/image-spec v1.0.1 // indirect
|
github.com/opencontainers/image-spec v1.0.1 // indirect
|
||||||
github.com/opencontainers/runc v0.1.1 // indirect
|
github.com/opencontainers/runc v0.1.1 // indirect
|
||||||
github.com/ory/dockertest v3.3.5+incompatible
|
github.com/ory/dockertest v3.3.5+incompatible
|
||||||
github.com/pierrec/lz4 v2.0.5+incompatible // indirect
|
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/prometheus/client_golang v1.0.0
|
github.com/prometheus/client_golang v1.0.0
|
||||||
github.com/prometheus/common v0.4.1
|
github.com/prometheus/common v0.4.1
|
||||||
|
|||||||
@@ -27,14 +27,21 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// Group refers to the group name in KEDA CRD
|
||||||
|
Group = "keda.sh"
|
||||||
|
// Version refers to the version name in KEDA CRD
|
||||||
|
Version = "v1alpha1"
|
||||||
|
|
||||||
|
// apiVersion refers to the api version name in KEDA CRD
|
||||||
|
apiVersion = Group + "/" + Version
|
||||||
scaledObjectGVR = schema.GroupVersionResource{
|
scaledObjectGVR = schema.GroupVersionResource{
|
||||||
Group: "keda.k8s.io",
|
Group: Group,
|
||||||
Version: "v1alpha1",
|
Version: Version,
|
||||||
Resource: "scaledobjects",
|
Resource: "scaledobjects",
|
||||||
}
|
}
|
||||||
authTriggerGVR = schema.GroupVersionResource{
|
authTriggerGVR = schema.GroupVersionResource{
|
||||||
Group: "keda.k8s.io",
|
Group: Group,
|
||||||
Version: "v1alpha1",
|
Version: Version,
|
||||||
Resource: "triggerauthentications",
|
Resource: "triggerauthentications",
|
||||||
}
|
}
|
||||||
matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)")
|
matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)")
|
||||||
@@ -306,7 +313,7 @@ func getAuthTriggerSpec(mqt *fv1.MessageQueueTrigger, authenticationRef string,
|
|||||||
authTriggerObj := &unstructured.Unstructured{
|
authTriggerObj := &unstructured.Unstructured{
|
||||||
Object: map[string]interface{}{
|
Object: map[string]interface{}{
|
||||||
"kind": "TriggerAuthentication",
|
"kind": "TriggerAuthentication",
|
||||||
"apiVersion": "keda.k8s.io/v1alpha1",
|
"apiVersion": apiVersion,
|
||||||
"metadata": map[string]interface{}{
|
"metadata": map[string]interface{}{
|
||||||
"name": authenticationRef,
|
"name": authenticationRef,
|
||||||
"namespace": mqt.ObjectMeta.Namespace,
|
"namespace": mqt.ObjectMeta.Namespace,
|
||||||
@@ -469,7 +476,7 @@ func getScaledObject(mqt *fv1.MessageQueueTrigger, authenticationRef string) *un
|
|||||||
return &unstructured.Unstructured{
|
return &unstructured.Unstructured{
|
||||||
Object: map[string]interface{}{
|
Object: map[string]interface{}{
|
||||||
"kind": "ScaledObject",
|
"kind": "ScaledObject",
|
||||||
"apiVersion": "keda.k8s.io/v1alpha1",
|
"apiVersion": apiVersion,
|
||||||
"metadata": map[string]interface{}{
|
"metadata": map[string]interface{}{
|
||||||
"name": mqt.ObjectMeta.Name,
|
"name": mqt.ObjectMeta.Name,
|
||||||
"namespace": mqt.ObjectMeta.Namespace,
|
"namespace": mqt.ObjectMeta.Namespace,
|
||||||
@@ -489,7 +496,7 @@ func getScaledObject(mqt *fv1.MessageQueueTrigger, authenticationRef string) *un
|
|||||||
"minReplicaCount": &mqt.Spec.MinReplicaCount,
|
"minReplicaCount": &mqt.Spec.MinReplicaCount,
|
||||||
"pollingInterval": &mqt.Spec.PollingInterval,
|
"pollingInterval": &mqt.Spec.PollingInterval,
|
||||||
"scaleTargetRef": map[string]interface{}{
|
"scaleTargetRef": map[string]interface{}{
|
||||||
"deploymentName": mqt.ObjectMeta.Name,
|
"name": mqt.ObjectMeta.Name,
|
||||||
},
|
},
|
||||||
"triggers": []interface{}{
|
"triggers": []interface{}{
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
|||||||
@@ -388,10 +388,10 @@ func newUnstructured(apiVersion, kind, namespace, name, resourceVersion string)
|
|||||||
|
|
||||||
func Test_getResourceVersion(t *testing.T) {
|
func Test_getResourceVersion(t *testing.T) {
|
||||||
scheme := runtime.NewScheme()
|
scheme := runtime.NewScheme()
|
||||||
client := dynfake.NewSimpleDynamicClient(scheme, newUnstructured("keda.k8s.io/v1alpha1", "ScaledObject", "default", "test-1", "12345"))
|
client := dynfake.NewSimpleDynamicClient(scheme, newUnstructured(apiVersion, "ScaledObject", "default", "test-1", "12345"))
|
||||||
dynamicResourceClient := client.Resource(schema.GroupVersionResource{
|
dynamicResourceClient := client.Resource(schema.GroupVersionResource{
|
||||||
Group: "keda.k8s.io",
|
Group: Group,
|
||||||
Version: "v1alpha1",
|
Version: Version,
|
||||||
Resource: "scaledobjects",
|
Resource: "scaledobjects",
|
||||||
})
|
})
|
||||||
type args struct {
|
type args struct {
|
||||||
@@ -489,7 +489,7 @@ func Test_getAuthTriggerSpec(t *testing.T) {
|
|||||||
expectedAuthTriggerObj := &unstructured.Unstructured{
|
expectedAuthTriggerObj := &unstructured.Unstructured{
|
||||||
Object: map[string]interface{}{
|
Object: map[string]interface{}{
|
||||||
"kind": "TriggerAuthentication",
|
"kind": "TriggerAuthentication",
|
||||||
"apiVersion": "keda.k8s.io/v1alpha1",
|
"apiVersion": apiVersion,
|
||||||
"metadata": map[string]interface{}{
|
"metadata": map[string]interface{}{
|
||||||
"name": authenticationRef,
|
"name": authenticationRef,
|
||||||
"namespace": mqt1.ObjectMeta.Namespace,
|
"namespace": mqt1.ObjectMeta.Namespace,
|
||||||
|
|||||||
Reference in New Issue
Block a user