Fix golang lint errors (#2068)
* Fix golang lint errors Signed-off-by: Harsh Thakur <harshthakur9030@gmail.com> * Typo for fields Signed-off-by: Harsh Thakur <harshthakur9030@gmail.com> * Multi error fix Signed-off-by: Harsh Thakur <harshthakur9030@gmail.com> * Multi error fix Signed-off-by: Harsh Thakur <harshthakur9030@gmail.com> * Add nolint to logtostderr errcheck Signed-off-by: Harsh Thakur <harshthakur9030@gmail.com>
This commit is contained in:
@@ -296,14 +296,6 @@ func checkAndUpdateTriggerFields(mqt, newMqt *fv1.MessageQueueTrigger) bool {
|
||||
return updated
|
||||
}
|
||||
|
||||
func getResourceVersion(scaledObjectName string, kedaClient dynamic.ResourceInterface) (version string, err error) {
|
||||
scaledObject, err := kedaClient.Get(context.TODO(), scaledObjectName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return scaledObject.GetResourceVersion(), nil
|
||||
}
|
||||
|
||||
func getAuthTriggerSpec(mqt *fv1.MessageQueueTrigger, authenticationRef string, kubeClient kubernetes.Interface) (*unstructured.Unstructured, error) {
|
||||
secret, err := kubeClient.CoreV1().Secrets(apiv1.NamespaceDefault).Get(context.TODO(), mqt.Spec.Secret, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
|
||||
@@ -369,59 +369,6 @@ func Test_checkAndUpdateTriggerFields(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func newUnstructured(apiVersion, kind, namespace, name, resourceVersion string) *unstructured.Unstructured {
|
||||
return &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
"apiVersion": apiVersion,
|
||||
"kind": kind,
|
||||
"metadata": map[string]interface{}{
|
||||
"namespace": namespace,
|
||||
"name": name,
|
||||
"resourceVersion": resourceVersion,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// commented because this fails with k8s.io/client-go v0.17.2
|
||||
// func Test_getResourceVersion(t *testing.T) {
|
||||
// scheme := runtime.NewScheme()
|
||||
// fakeDynamicClient := &dynfake.FakeDynamicClient
|
||||
// client := dynfake.NewSimpleDynamicClient(scheme, newUnstructured(apiVersion, "ScaledObject", "default", "test-1", "12345"))
|
||||
// dynamicResourceClient := client.Resource(schema.GroupVersionResource{
|
||||
// Group: Group,
|
||||
// Version: Version,
|
||||
// Resource: "scaledobjects",
|
||||
// })
|
||||
// fmt.Println(dynamicResourceClient.List(metav1.ListOptions{}))
|
||||
// fmt.Println(dynamicResourceClient.Get("test-1", metav1.GetOptions{}))
|
||||
// type args struct {
|
||||
// scaledObjectName string
|
||||
// kedaClient dynamic.ResourceInterface
|
||||
// }
|
||||
// tests := []struct {
|
||||
// name string
|
||||
// args args
|
||||
// wantVersion string
|
||||
// wantErr bool
|
||||
// }{
|
||||
// {"Valid Resource", args{"test-1", dynamicResourceClient}, "12345", false},
|
||||
// {"Invalid Resource", args{"test-2", dynamicResourceClient}, "", true},
|
||||
// }
|
||||
// for _, tt := range tests {
|
||||
// t.Run(tt.name, func(t *testing.T) {
|
||||
// gotVersion, err := getResourceVersion(tt.args.scaledObjectName, tt.args.kedaClient)
|
||||
// if (err != nil) != tt.wantErr {
|
||||
// t.Errorf("getResourceVersion() error = %v, wantErr %v", err, tt.wantErr)
|
||||
// return
|
||||
// }
|
||||
// if gotVersion != tt.wantVersion {
|
||||
// t.Errorf("getResourceVersion() = %v, want %v", gotVersion, tt.wantVersion)
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
|
||||
func Test_getAuthTriggerSpec(t *testing.T) {
|
||||
|
||||
// Valid - with Secret
|
||||
|
||||
Reference in New Issue
Block a user