Skip to content

Commit

Permalink
chore: lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
moshloop committed Aug 14, 2024
1 parent 5129df7 commit 3e4b71d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 50 deletions.
18 changes: 0 additions & 18 deletions context/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,21 +228,3 @@ func UpdateProperties(ctx Context, props map[string]string) error {
defer ctx.ClearCache()
return ctx.DB().Exec(query, args...).Error
}

func getLogLevel(level string) int {
if i, err := strconv.Atoi(level); err == nil {
return i
}
switch level {
case "debug":
return 1
case "trace":
return 2
case "warn":
return -1
case "error":
return -2
default:
return 0
}
}
21 changes: 0 additions & 21 deletions gorm/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ type Config struct {
type SqlLogger struct {
Config
commons.Logger
skipLevel int
}

func (l *SqlLogger) WithLogLevel(level any) *SqlLogger {
Expand Down Expand Up @@ -162,23 +161,3 @@ func (l *SqlLogger) ParamsFilter(ctx context.Context, sql string, params ...inte
}
return sql, nil
}

type traceRecorder struct {
Logger
BeginAt time.Time
SQL string
RowsAffected int64
Err error
}

// New trace recorder
func (l *traceRecorder) New() *traceRecorder {
return &traceRecorder{Logger: l.Logger, BeginAt: time.Now()}
}

// Trace implement logger interface
func (l *traceRecorder) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error) {
l.BeginAt = begin
l.SQL, l.RowsAffected = fc()
l.Err = err
}
6 changes: 5 additions & 1 deletion hack/migrate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ package main
import (
"github.com/flanksource/commons/logger"
"github.com/flanksource/duty"
"github.com/flanksource/duty/api"

"github.com/spf13/cobra"
)

var migrate = &cobra.Command{
Use: "migrate",
Run: func(cmd *cobra.Command, args []string) {
if err := duty.Migrate(connection, nil); err != nil {
if err := duty.Migrate(api.Config{
ConnectionString: connection,
}); err != nil {
logger.Fatalf(err.Error())
}
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/kube/labels/selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// nolint
package labels

import (
Expand Down
9 changes: 5 additions & 4 deletions pkg/kube/labels/selector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
Copyright 2014 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance wginkgo.Ith the License.
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in wrginkgo.Iting, software
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Wginkgo.ItHOUT WARRANTIES OR CONDginkgo.ItIONS OF ANY KIND, eginkgo.Ither express or implied.
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limginkgo.Itations under the License.
limitations under the License.
*/

// nolint
package labels

import (
Expand Down
6 changes: 3 additions & 3 deletions telemetry/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ func InitTracer(serviceName, collectorURL string, insecure bool, resourceAttrs .
otel.SetTextMapPropagator(propagation.TraceContext{})

return func(ctx context.Context) error {
logger.Infof("Shutting down exporter")
exporter.Shutdown(ctx)
logger.Infof("Shutdown exporter")
logger.Debugf("Shutting down otel exporter")
_ = exporter.Shutdown(ctx)
logger.Debugf("Shutdown complete")
return nil
}
}
3 changes: 1 addition & 2 deletions tests/matcher/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func MatchMap(a map[string]string, jq ...string) gcustom.CustomGomegaMatcher {
}

for _, _jq := range jq {

expectedJSONb, err = ParseJQ([]byte(expectedJSON), _jq)
if err != nil {
return false, err
Expand All @@ -50,7 +49,7 @@ func MatchMap(a map[string]string, jq ...string) gcustom.CustomGomegaMatcher {
}
}

diff, err := generateDiff(string(expectedJSON), string(actualJSON))
diff, err := generateDiff(string(actualJSONb), string(expectedJSONb))
if err != nil {
return false, err
}
Expand Down

0 comments on commit 3e4b71d

Please sign in to comment.