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:
Harsh Thakur
2021-02-05 10:28:54 +05:30
committed by GitHub
co-authored by Rahul Bhati Vishal
parent 045a365a1b
commit e4a0aa3480
3 changed files with 18 additions and 12 deletions
-1
View File
@@ -45,7 +45,6 @@ require (
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/opencontainers/runc v0.1.1 // indirect
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/prometheus/client_golang v1.0.0
github.com/prometheus/common v0.4.1
+14 -7
View File
@@ -27,14 +27,21 @@ import (
)
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{
Group: "keda.k8s.io",
Version: "v1alpha1",
Group: Group,
Version: Version,
Resource: "scaledobjects",
}
authTriggerGVR = schema.GroupVersionResource{
Group: "keda.k8s.io",
Version: "v1alpha1",
Group: Group,
Version: Version,
Resource: "triggerauthentications",
}
matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)")
@@ -306,7 +313,7 @@ func getAuthTriggerSpec(mqt *fv1.MessageQueueTrigger, authenticationRef string,
authTriggerObj := &unstructured.Unstructured{
Object: map[string]interface{}{
"kind": "TriggerAuthentication",
"apiVersion": "keda.k8s.io/v1alpha1",
"apiVersion": apiVersion,
"metadata": map[string]interface{}{
"name": authenticationRef,
"namespace": mqt.ObjectMeta.Namespace,
@@ -469,7 +476,7 @@ func getScaledObject(mqt *fv1.MessageQueueTrigger, authenticationRef string) *un
return &unstructured.Unstructured{
Object: map[string]interface{}{
"kind": "ScaledObject",
"apiVersion": "keda.k8s.io/v1alpha1",
"apiVersion": apiVersion,
"metadata": map[string]interface{}{
"name": mqt.ObjectMeta.Name,
"namespace": mqt.ObjectMeta.Namespace,
@@ -489,7 +496,7 @@ func getScaledObject(mqt *fv1.MessageQueueTrigger, authenticationRef string) *un
"minReplicaCount": &mqt.Spec.MinReplicaCount,
"pollingInterval": &mqt.Spec.PollingInterval,
"scaleTargetRef": map[string]interface{}{
"deploymentName": mqt.ObjectMeta.Name,
"name": mqt.ObjectMeta.Name,
},
"triggers": []interface{}{
map[string]interface{}{
+4 -4
View File
@@ -388,10 +388,10 @@ func newUnstructured(apiVersion, kind, namespace, name, resourceVersion string)
func Test_getResourceVersion(t *testing.T) {
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{
Group: "keda.k8s.io",
Version: "v1alpha1",
Group: Group,
Version: Version,
Resource: "scaledobjects",
})
type args struct {
@@ -489,7 +489,7 @@ func Test_getAuthTriggerSpec(t *testing.T) {
expectedAuthTriggerObj := &unstructured.Unstructured{
Object: map[string]interface{}{
"kind": "TriggerAuthentication",
"apiVersion": "keda.k8s.io/v1alpha1",
"apiVersion": apiVersion,
"metadata": map[string]interface{}{
"name": authenticationRef,
"namespace": mqt1.ObjectMeta.Namespace,