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:
@@ -658,7 +658,7 @@ type (
|
||||
// +optional
|
||||
Prefix *string `json:"prefix,omitempty"`
|
||||
|
||||
// Deprecated: Use Methods instead of Method.
|
||||
// Use Methods instead of Method. This field is going to be deprecated in a future release
|
||||
// HTTP method to access a function.
|
||||
// +optional
|
||||
Method string `json:"method"`
|
||||
|
||||
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package v1
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"regexp"
|
||||
@@ -585,7 +586,7 @@ func (e *Environment) Validate() error {
|
||||
if e.Spec.Runtime.PodSpec != nil {
|
||||
for _, container := range e.Spec.Runtime.PodSpec.Containers {
|
||||
if container.Command == nil && container.Image == e.Spec.Runtime.Image && container.Name != e.ObjectMeta.Name {
|
||||
multierror.Append(result, fmt.Errorf("container with image same as runtime image in podspec, must have name same as environment name"))
|
||||
result = multierror.Append(result, errors.New("container with image same as runtime image in podspec, must have name same as environment name"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -42,10 +42,10 @@ func EnsureFissionCRDs(logger *zap.Logger, clientset *apiextensionsclient.Client
|
||||
for _, crdName := range crdsExpected {
|
||||
crd, err := clientset.ApiextensionsV1().CustomResourceDefinitions().Get(context.TODO(), crdName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
multierror.Append(errs, fmt.Errorf("CRD %s not found: %s", crdName, err))
|
||||
errs = multierror.Append(errs, fmt.Errorf("CRD %s not found: %s", crdName, err))
|
||||
}
|
||||
if crd == nil {
|
||||
multierror.Append(errs, fmt.Errorf("CRD %s not found", crdName))
|
||||
errs = multierror.Append(errs, fmt.Errorf("CRD %s not found", crdName))
|
||||
}
|
||||
}
|
||||
return errs.ErrorOrNil()
|
||||
|
||||
@@ -154,15 +154,15 @@ func MergePodSpec(srcPodSpec *apiv1.PodSpec, targetPodSpec *apiv1.PodSpec) (*api
|
||||
srcPodSpec.AutomountServiceAccountToken = targetPodSpec.AutomountServiceAccountToken
|
||||
}
|
||||
|
||||
if targetPodSpec.HostNetwork != false {
|
||||
if targetPodSpec.HostNetwork {
|
||||
srcPodSpec.HostNetwork = targetPodSpec.HostNetwork
|
||||
}
|
||||
|
||||
if targetPodSpec.HostPID != false {
|
||||
if targetPodSpec.HostPID {
|
||||
srcPodSpec.HostPID = targetPodSpec.HostPID
|
||||
}
|
||||
|
||||
if targetPodSpec.HostIPC != false {
|
||||
if targetPodSpec.HostIPC {
|
||||
srcPodSpec.HostIPC = targetPodSpec.HostIPC
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -39,7 +39,7 @@ func TestPoolCache(t *testing.T) {
|
||||
|
||||
checkErr(c.DeleteValue("func", "ip"))
|
||||
|
||||
_, active, err = c.GetValue("func", 5)
|
||||
_, _, err = c.GetValue("func", 5)
|
||||
if err == nil {
|
||||
log.Panicf("found deleted element")
|
||||
}
|
||||
|
||||
@@ -169,7 +169,10 @@ func (roundTripper *RetryingRoundTripper) RoundTrip(req *http.Request) (*http.Re
|
||||
// close req body
|
||||
defer func() {
|
||||
if req.Body != nil {
|
||||
req.Body.(*fakeCloseReadCloser).RealClose()
|
||||
err := req.Body.(*fakeCloseReadCloser).RealClose()
|
||||
if err != nil {
|
||||
roundTripper.logger.Error("Error closing body", zap.Error(err))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -670,10 +673,10 @@ func (fh functionHandler) getProxyErrorHandler(start time.Time, rrt *RetryingRou
|
||||
fh.logger.Debug(msg, zap.Any("function", fh.function), zap.Any("request_header", req.Header))
|
||||
case context.DeadlineExceeded:
|
||||
status = http.StatusGatewayTimeout
|
||||
msg = "function not responses before the timeout"
|
||||
msg := "function not responses before the timeout"
|
||||
fh.logger.Error(msg, zap.Any("function", fh.function), zap.Any("request_header", req.Header))
|
||||
default:
|
||||
code, msg := ferror.GetHTTPError(err)
|
||||
code, _ := ferror.GetHTTPError(err)
|
||||
status = code
|
||||
msg = "error sending request to function"
|
||||
fh.logger.Error(msg, zap.Error(err), zap.Any("function", fh.function), zap.Any("request_header", req.Header), zap.Any("code", code))
|
||||
|
||||
Reference in New Issue
Block a user