diff --git a/cmd/shell-operator/main.go b/cmd/shell-operator/main.go index 7f1a62e8..0da95723 100644 --- a/cmd/shell-operator/main.go +++ b/cmd/shell-operator/main.go @@ -8,8 +8,8 @@ import ( "gopkg.in/alecthomas/kingpin.v2" - "github.com/deckhouse/deckhouse/go_lib/log" - "github.com/flant/kube-client/klogtologrus" + "github.com/deckhouse/deckhouse/pkg/log" + "github.com/flant/kube-client/klogtolog" "github.com/flant/shell-operator/pkg/app" "github.com/flant/shell-operator/pkg/debug" "github.com/flant/shell-operator/pkg/jq" @@ -20,12 +20,15 @@ import ( func main() { kpApp := kingpin.New(app.AppName, fmt.Sprintf("%s %s: %s", app.AppName, app.Version, app.AppDescription)) + logger := log.NewLogger(log.Options{}) + log.SetDefault(logger) + // override usage template to reveal additional commands with information about start command kpApp.UsageTemplate(app.OperatorUsageTemplate(app.AppName)) // Initialize klog wrapper when all values are parsed kpApp.Action(func(c *kingpin.ParseContext) error { - klogtologrus.InitAdapter(app.DebugKubernetesAPI) + klogtolog.InitAdapter(app.DebugKubernetesAPI, logger.Named("klog")) return nil }) @@ -36,9 +39,6 @@ func main() { return nil }) - logger := log.NewLogger(log.Options{}) - log.SetDefault(logger) - // start main loop startCmd := kpApp.Command("start", "Start shell-operator."). Default(). diff --git a/go.mod b/go.mod index f190e02a..289ba7b7 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/flant/shell-operator go 1.22.8 require ( - github.com/deckhouse/deckhouse/go_lib/log v0.0.0-20241031173751-c2c6e864aa6b - github.com/flant/kube-client v1.2.0 + github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241102120041-7e44e3e22ab9 + github.com/flant/kube-client v0.0.0-20241102115103-02e0839b26f3 github.com/flant/libjq-go v1.6.3-0.20201126171326-c46a40ff22ee // branch: master github.com/go-chi/chi/v5 v5.1.0 github.com/go-openapi/spec v0.19.8 @@ -18,7 +18,6 @@ require ( github.com/onsi/gomega v1.34.2 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.20.5 - github.com/sirupsen/logrus v1.9.3 // indirect github.com/stretchr/testify v1.9.0 golang.org/x/time v0.7.0 gopkg.in/alecthomas/kingpin.v2 v2.2.6 diff --git a/go.sum b/go.sum index c46e5894..801334cb 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/deckhouse/deckhouse/go_lib/log v0.0.0-20241031173751-c2c6e864aa6b h1:x0T6FJSCibbVVj2N7ItjENm7h+ISiEZdypjFKVx9G88= -github.com/deckhouse/deckhouse/go_lib/log v0.0.0-20241031173751-c2c6e864aa6b/go.mod h1:h+LOQH/71Rhjj+ws0MjBHduAsgAkVJZsRuhQNjFPLa8= +github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241102120041-7e44e3e22ab9 h1:gCV1iKcaE69x3Knzj8isyVyEtRuG2YI4nmLIzBHBWeQ= +github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241102120041-7e44e3e22ab9/go.mod h1:Mk5HRzkc5pIcDIZ2JJ6DPuuqnwhXVkb3you8M8Mg+4w= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= @@ -33,8 +33,8 @@ github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCv github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/flant/go-openapi-validate v0.19.12-flant.0 h1:xk6kvc9fHKMgUdB6J7kbpbLR5vJOUzKAK8p3nrD7mDk= github.com/flant/go-openapi-validate v0.19.12-flant.0/go.mod h1:Rzou8hA/CBw8donlS6WNEUQupNvUZ0waH08tGe6kAQ4= -github.com/flant/kube-client v1.2.0 h1:cOjnZgwoJVm4scqsMGcgO6qctJ+Z6wRVTFqvyhoAOiQ= -github.com/flant/kube-client v1.2.0/go.mod h1:qjNvqCqnBqS+kc9Hj+wMBbkFzfdyGyiX4r4teE/0Pm8= +github.com/flant/kube-client v0.0.0-20241102115103-02e0839b26f3 h1:i2FCENEhO2PTuD1Y0RdNe9ZlBpR7J96LwtHai+EBPwk= +github.com/flant/kube-client v0.0.0-20241102115103-02e0839b26f3/go.mod h1:/Ufu7bBvrm1OsBgbzpSL+JXjIoORo+2BhZS+kLDKcMg= github.com/flant/libjq-go v1.6.3-0.20201126171326-c46a40ff22ee h1:evii83J+/6QGNvyf6tjQ/p27DPY9iftxIBb37ALJRTg= github.com/flant/libjq-go v1.6.3-0.20201126171326-c46a40ff22ee/go.mod h1:f+REaGl/+pZR97rbTcwHEka/MAipoQQ2Mc0iQUj4ak0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -259,8 +259,6 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= -github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -345,7 +343,6 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= diff --git a/pkg/app/log.go b/pkg/app/log.go index 4a7b60e2..40ef3572 100644 --- a/pkg/app/log.go +++ b/pkg/app/log.go @@ -7,7 +7,7 @@ import ( "gopkg.in/alecthomas/kingpin.v2" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/flant/shell-operator/pkg/config" ) diff --git a/pkg/config/config.go b/pkg/config/config.go index ec1d3c5b..bb5e493c 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -8,7 +8,7 @@ import ( "sync" "time" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" ) /** diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 5b81efab..2425a8bf 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/stretchr/testify/assert" ) diff --git a/pkg/debug/server.go b/pkg/debug/server.go index bea2ec02..39f2dd99 100644 --- a/pkg/debug/server.go +++ b/pkg/debug/server.go @@ -13,7 +13,7 @@ import ( "github.com/go-chi/chi/v5/middleware" "gopkg.in/yaml.v3" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" utils "github.com/flant/shell-operator/pkg/utils/file" structuredLogger "github.com/flant/shell-operator/pkg/utils/structured-logger" ) diff --git a/pkg/executor/executor.go b/pkg/executor/executor.go index 3da20fe5..9d1d4ee5 100644 --- a/pkg/executor/executor.go +++ b/pkg/executor/executor.go @@ -13,7 +13,7 @@ import ( "syscall" "time" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" utils "github.com/flant/shell-operator/pkg/utils/labels" "github.com/flant/shell-operator/pkg/app" diff --git a/pkg/executor/executor_test.go b/pkg/executor/executor_test.go index ae8bad09..6a008c3d 100644 --- a/pkg/executor/executor_test.go +++ b/pkg/executor/executor_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/pkg/hook/binding_context/binding_context.go b/pkg/hook/binding_context/binding_context.go index 5e6b0f36..502be2ce 100644 --- a/pkg/hook/binding_context/binding_context.go +++ b/pkg/hook/binding_context/binding_context.go @@ -3,7 +3,7 @@ package binding_context import ( "encoding/json" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" v1 "k8s.io/api/admission/v1" apixv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" diff --git a/pkg/hook/controller/admission_bindings_controller.go b/pkg/hook/controller/admission_bindings_controller.go index e491b350..b8adfd33 100644 --- a/pkg/hook/controller/admission_bindings_controller.go +++ b/pkg/hook/controller/admission_bindings_controller.go @@ -1,7 +1,7 @@ package controller import ( - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" v1 "k8s.io/api/admission/v1" . "github.com/flant/shell-operator/pkg/hook/binding_context" diff --git a/pkg/hook/controller/conversion_bindings_controller.go b/pkg/hook/controller/conversion_bindings_controller.go index 53044676..9f56e21e 100644 --- a/pkg/hook/controller/conversion_bindings_controller.go +++ b/pkg/hook/controller/conversion_bindings_controller.go @@ -1,7 +1,7 @@ package controller import ( - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" . "github.com/flant/shell-operator/pkg/hook/binding_context" diff --git a/pkg/hook/controller/hook_controller.go b/pkg/hook/controller/hook_controller.go index 2b25a1c6..0dc5bbbd 100644 --- a/pkg/hook/controller/hook_controller.go +++ b/pkg/hook/controller/hook_controller.go @@ -3,7 +3,7 @@ package controller import ( v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" . "github.com/flant/shell-operator/pkg/hook/binding_context" . "github.com/flant/shell-operator/pkg/hook/types" "github.com/flant/shell-operator/pkg/kube_events_manager" diff --git a/pkg/hook/controller/hook_controller_test.go b/pkg/hook/controller/hook_controller_test.go index 5a970d4b..92683f9f 100644 --- a/pkg/hook/controller/hook_controller_test.go +++ b/pkg/hook/controller/hook_controller_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" . "github.com/onsi/gomega" "github.com/flant/kube-client/fake" diff --git a/pkg/hook/controller/kubernetes_bindings_controller.go b/pkg/hook/controller/kubernetes_bindings_controller.go index ad7b1549..dd395d31 100644 --- a/pkg/hook/controller/kubernetes_bindings_controller.go +++ b/pkg/hook/controller/kubernetes_bindings_controller.go @@ -3,7 +3,7 @@ package controller import ( "fmt" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" . "github.com/flant/shell-operator/pkg/hook/binding_context" . "github.com/flant/shell-operator/pkg/hook/types" diff --git a/pkg/hook/hook.go b/pkg/hook/hook.go index 15fc3d45..8abe40e7 100644 --- a/pkg/hook/hook.go +++ b/pkg/hook/hook.go @@ -12,7 +12,7 @@ import ( "github.com/kennygrant/sanitize" "golang.org/x/time/rate" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/flant/shell-operator/pkg/app" "github.com/flant/shell-operator/pkg/executor" . "github.com/flant/shell-operator/pkg/hook/binding_context" diff --git a/pkg/hook/hook_manager.go b/pkg/hook/hook_manager.go index e6bbd76e..c278f9b2 100644 --- a/pkg/hook/hook_manager.go +++ b/pkg/hook/hook_manager.go @@ -10,7 +10,7 @@ import ( v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/flant/shell-operator/pkg/executor" "github.com/flant/shell-operator/pkg/hook/controller" . "github.com/flant/shell-operator/pkg/hook/types" diff --git a/pkg/hook/hook_manager_test.go b/pkg/hook/hook_manager_test.go index f1fa3ab6..f98d7a73 100644 --- a/pkg/hook/hook_manager_test.go +++ b/pkg/hook/hook_manager_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" . "github.com/onsi/gomega" "github.com/flant/shell-operator/pkg/app" diff --git a/pkg/hook/hook_test.go b/pkg/hook/hook_test.go index 87092ffc..25090a3d 100644 --- a/pkg/hook/hook_test.go +++ b/pkg/hook/hook_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" . "github.com/onsi/gomega" "golang.org/x/time/rate" diff --git a/pkg/hook/task_metadata/task_metadata.go b/pkg/hook/task_metadata/task_metadata.go index 4e75cb51..a1ba7b6d 100644 --- a/pkg/hook/task_metadata/task_metadata.go +++ b/pkg/hook/task_metadata/task_metadata.go @@ -3,7 +3,7 @@ package task_metadata import ( "fmt" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" "github.com/flant/shell-operator/pkg/hook/binding_context" "github.com/flant/shell-operator/pkg/hook/types" diff --git a/pkg/kube/object_patch/operation.go b/pkg/kube/object_patch/operation.go index bd92c974..291e799c 100644 --- a/pkg/kube/object_patch/operation.go +++ b/pkg/kube/object_patch/operation.go @@ -3,7 +3,7 @@ package object_patch import ( "fmt" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" "github.com/hashicorp/go-multierror" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" diff --git a/pkg/kube/object_patch/patch.go b/pkg/kube/object_patch/patch.go index ba9ba653..f46e22b7 100644 --- a/pkg/kube/object_patch/patch.go +++ b/pkg/kube/object_patch/patch.go @@ -6,7 +6,7 @@ import ( "fmt" "time" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/hashicorp/go-multierror" gerror "github.com/pkg/errors" "k8s.io/apimachinery/pkg/api/equality" diff --git a/pkg/kube/object_patch/patch_test.go b/pkg/kube/object_patch/patch_test.go index 3fe47e02..115654ad 100644 --- a/pkg/kube/object_patch/patch_test.go +++ b/pkg/kube/object_patch/patch_test.go @@ -6,7 +6,7 @@ import ( "os" "testing" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" "github.com/stretchr/testify/require" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/kube_events_manager/error_handler.go b/pkg/kube_events_manager/error_handler.go index f1d380b0..7562ff95 100644 --- a/pkg/kube_events_manager/error_handler.go +++ b/pkg/kube_events_manager/error_handler.go @@ -6,7 +6,7 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/client-go/tools/cache" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/flant/shell-operator/pkg/metric_storage" utils "github.com/flant/shell-operator/pkg/utils/labels" ) diff --git a/pkg/kube_events_manager/factory.go b/pkg/kube_events_manager/factory.go index 833be563..8e065c63 100644 --- a/pkg/kube_events_manager/factory.go +++ b/pkg/kube_events_manager/factory.go @@ -5,7 +5,7 @@ import ( "sync" "time" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/wait" diff --git a/pkg/kube_events_manager/kube_events_manager.go b/pkg/kube_events_manager/kube_events_manager.go index 1716448c..cc8b583c 100644 --- a/pkg/kube_events_manager/kube_events_manager.go +++ b/pkg/kube_events_manager/kube_events_manager.go @@ -5,7 +5,7 @@ import ( "runtime/trace" "sync" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" klient "github.com/flant/kube-client/client" . "github.com/flant/shell-operator/pkg/kube_events_manager/types" diff --git a/pkg/kube_events_manager/kube_events_manager_test.go b/pkg/kube_events_manager/kube_events_manager_test.go index eb73e5b6..04f69477 100644 --- a/pkg/kube_events_manager/kube_events_manager_test.go +++ b/pkg/kube_events_manager/kube_events_manager_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" "github.com/stretchr/testify/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" diff --git a/pkg/kube_events_manager/monitor.go b/pkg/kube_events_manager/monitor.go index 4bb0aed0..50e696d0 100644 --- a/pkg/kube_events_manager/monitor.go +++ b/pkg/kube_events_manager/monitor.go @@ -5,7 +5,7 @@ import ( "fmt" "sort" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" klient "github.com/flant/kube-client/client" . "github.com/flant/shell-operator/pkg/kube_events_manager/types" "github.com/flant/shell-operator/pkg/metric_storage" diff --git a/pkg/kube_events_manager/monitor_config.go b/pkg/kube_events_manager/monitor_config.go index 536bde49..2b515ac0 100644 --- a/pkg/kube_events_manager/monitor_config.go +++ b/pkg/kube_events_manager/monitor_config.go @@ -4,7 +4,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" . "github.com/flant/shell-operator/pkg/kube_events_manager/types" ) diff --git a/pkg/kube_events_manager/monitor_test.go b/pkg/kube_events_manager/monitor_test.go index c17816dc..b71d9a8b 100644 --- a/pkg/kube_events_manager/monitor_test.go +++ b/pkg/kube_events_manager/monitor_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/kube_events_manager/namespace_informer.go b/pkg/kube_events_manager/namespace_informer.go index 738f0285..34f3536b 100644 --- a/pkg/kube_events_manager/namespace_informer.go +++ b/pkg/kube_events_manager/namespace_informer.go @@ -6,7 +6,7 @@ import ( "context" "fmt" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" diff --git a/pkg/kube_events_manager/resource_informer.go b/pkg/kube_events_manager/resource_informer.go index ee189822..ee1020df 100644 --- a/pkg/kube_events_manager/resource_informer.go +++ b/pkg/kube_events_manager/resource_informer.go @@ -7,7 +7,7 @@ import ( "sync" "time" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/gofrs/uuid/v5" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" diff --git a/pkg/kube_events_manager/types/types.go b/pkg/kube_events_manager/types/types.go index 99db3dd9..0824b813 100644 --- a/pkg/kube_events_manager/types/types.go +++ b/pkg/kube_events_manager/types/types.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ) diff --git a/pkg/metric_storage/metric_storage.go b/pkg/metric_storage/metric_storage.go index 455d2a1b..a323eba4 100644 --- a/pkg/metric_storage/metric_storage.go +++ b/pkg/metric_storage/metric_storage.go @@ -12,7 +12,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/flant/shell-operator/pkg/metric_storage/operation" "github.com/flant/shell-operator/pkg/metric_storage/vault" . "github.com/flant/shell-operator/pkg/utils/labels" diff --git a/pkg/metric_storage/vault/vault.go b/pkg/metric_storage/vault/vault.go index f0b1aaee..058608dc 100644 --- a/pkg/metric_storage/vault/vault.go +++ b/pkg/metric_storage/vault/vault.go @@ -6,23 +6,23 @@ import ( "github.com/flant/shell-operator/pkg/metric" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" "github.com/prometheus/client_golang/prometheus" . "github.com/flant/shell-operator/pkg/utils/labels" ) type GroupedVault struct { - collectors map[string]metric.ConstCollector - mtx sync.Mutex - registerer prometheus.Registerer + collectors map[string]metric.ConstCollector + mtx sync.Mutex + registerer prometheus.Registerer resolveMetricNameFunc func(name string) string } func NewGroupedVault(resolveMetricNameFunc func(name string) string) *GroupedVault { return &GroupedVault{ - collectors: make(map[string]metric.ConstCollector), - resolveMetricNameFunc : resolveMetricNameFunc, + collectors: make(map[string]metric.ConstCollector), + resolveMetricNameFunc: resolveMetricNameFunc, } } diff --git a/pkg/metric_storage/vault/vault_test.go b/pkg/metric_storage/vault/vault_test.go index 885e993c..bc4fd2f1 100644 --- a/pkg/metric_storage/vault/vault_test.go +++ b/pkg/metric_storage/vault/vault_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" . "github.com/onsi/gomega" "github.com/prometheus/client_golang/prometheus" promtest "github.com/prometheus/client_golang/prometheus/testutil" @@ -20,7 +20,7 @@ func Test_CounterAdd(t *testing.T) { buf := &bytes.Buffer{} logger.SetOutput(buf) - v := NewGroupedVault(func (name string) string { return name }) + v := NewGroupedVault(func(name string) string { return name }) v.registerer = prometheus.DefaultRegisterer v.CounterAdd("group1", "metric_total", 1.0, map[string]string{"lbl": "val"}) diff --git a/pkg/schedule_manager/schedule_manager.go b/pkg/schedule_manager/schedule_manager.go index b67d24f4..59eeffc0 100644 --- a/pkg/schedule_manager/schedule_manager.go +++ b/pkg/schedule_manager/schedule_manager.go @@ -5,7 +5,7 @@ import ( "gopkg.in/robfig/cron.v2" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" . "github.com/flant/shell-operator/pkg/schedule_manager/types" ) diff --git a/pkg/schedule_manager/schedule_manager_test.go b/pkg/schedule_manager/schedule_manager_test.go index f15ce917..08112ce6 100644 --- a/pkg/schedule_manager/schedule_manager_test.go +++ b/pkg/schedule_manager/schedule_manager_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/flant/shell-operator/pkg/schedule_manager/types" ) diff --git a/pkg/shell-operator/bootstrap.go b/pkg/shell-operator/bootstrap.go index 78d1e5b3..260781b1 100644 --- a/pkg/shell-operator/bootstrap.go +++ b/pkg/shell-operator/bootstrap.go @@ -5,7 +5,7 @@ import ( "fmt" "log/slog" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/flant/shell-operator/pkg/app" "github.com/flant/shell-operator/pkg/config" "github.com/flant/shell-operator/pkg/debug" @@ -42,7 +42,7 @@ func Init(logger *log.Logger) (*ShellOperator, error) { return nil, err } - op := NewShellOperator(context.Background(), logger) + op := NewShellOperator(context.Background(), WithLogger(logger)) // Debug server. debugServer, err := RunDefaultDebugServer(app.DebugUnixSocket, app.DebugHttpServerAddr, op.logger.Named("debug-server")) diff --git a/pkg/shell-operator/combine_binding_context_test.go b/pkg/shell-operator/combine_binding_context_test.go index 3da53bfe..fa36a2bb 100644 --- a/pkg/shell-operator/combine_binding_context_test.go +++ b/pkg/shell-operator/combine_binding_context_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" . "github.com/onsi/gomega" "github.com/flant/shell-operator/pkg/hook/binding_context" diff --git a/pkg/shell-operator/debug_server.go b/pkg/shell-operator/debug_server.go index b75dbdf4..c8a34f53 100644 --- a/pkg/shell-operator/debug_server.go +++ b/pkg/shell-operator/debug_server.go @@ -8,7 +8,7 @@ import ( "github.com/go-chi/chi/v5" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/flant/shell-operator/pkg/config" "github.com/flant/shell-operator/pkg/debug" "github.com/flant/shell-operator/pkg/task/dump" diff --git a/pkg/shell-operator/http_server.go b/pkg/shell-operator/http_server.go index 3691264d..506e7e31 100644 --- a/pkg/shell-operator/http_server.go +++ b/pkg/shell-operator/http_server.go @@ -8,7 +8,7 @@ import ( "strings" "time" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" diff --git a/pkg/shell-operator/kube_client.go b/pkg/shell-operator/kube_client.go index 14571a11..bcd0dc07 100644 --- a/pkg/shell-operator/kube_client.go +++ b/pkg/shell-operator/kube_client.go @@ -3,7 +3,7 @@ package shell_operator import ( "fmt" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" klient "github.com/flant/kube-client/client" "github.com/flant/shell-operator/pkg/app" "github.com/flant/shell-operator/pkg/kube/object_patch" diff --git a/pkg/shell-operator/manager_events_handler.go b/pkg/shell-operator/manager_events_handler.go index 0eba72a5..643c8de0 100644 --- a/pkg/shell-operator/manager_events_handler.go +++ b/pkg/shell-operator/manager_events_handler.go @@ -3,7 +3,7 @@ package shell_operator import ( "context" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/flant/shell-operator/pkg/kube_events_manager" . "github.com/flant/shell-operator/pkg/kube_events_manager/types" diff --git a/pkg/shell-operator/operator.go b/pkg/shell-operator/operator.go index 6213cf10..099315fd 100644 --- a/pkg/shell-operator/operator.go +++ b/pkg/shell-operator/operator.go @@ -8,7 +8,7 @@ import ( "github.com/gofrs/uuid/v5" v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" klient "github.com/flant/kube-client/client" "github.com/flant/shell-operator/pkg/hook" "github.com/flant/shell-operator/pkg/hook/binding_context" @@ -59,16 +59,31 @@ type ShellOperator struct { ConversionWebhookManager *conversion.WebhookManager } -func NewShellOperator(ctx context.Context, logger *log.Logger) *ShellOperator { +type Option func(operator *ShellOperator) + +func WithLogger(logger *log.Logger) Option { + return func(operator *ShellOperator) { + operator.logger = logger + } +} + +func NewShellOperator(ctx context.Context, opts ...Option) *ShellOperator { if ctx == nil { ctx = context.Background() } + cctx, cancel := context.WithCancel(ctx) - return &ShellOperator{ + + so := &ShellOperator{ ctx: cctx, cancel: cancel, - logger: logger, } + + for _, opt := range opts { + opt(so) + } + + return so } // Start run the operator diff --git a/pkg/shell-operator/operator_test.go b/pkg/shell-operator/operator_test.go index f9e3127a..c6cd8d0f 100644 --- a/pkg/shell-operator/operator_test.go +++ b/pkg/shell-operator/operator_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" . "github.com/onsi/gomega" . "github.com/flant/shell-operator/pkg/hook/task_metadata" @@ -19,7 +19,7 @@ func Test_Operator_startup_tasks(t *testing.T) { hooksDir, err := utils.RequireExistingDirectory("testdata/startup_tasks/hooks") g.Expect(err).ShouldNot(HaveOccurred()) - op := NewShellOperator(context.Background(), log.NewNop()) + op := NewShellOperator(context.Background(), WithLogger(log.NewNop())) op.SetupEventManagers() op.setupHookManagers(hooksDir, "") diff --git a/pkg/task/queue/task_queue.go b/pkg/task/queue/task_queue.go index cc57dde7..f4c9fda1 100644 --- a/pkg/task/queue/task_queue.go +++ b/pkg/task/queue/task_queue.go @@ -8,7 +8,7 @@ import ( "sync" "time" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" "github.com/flant/shell-operator/pkg/metric_storage" "github.com/flant/shell-operator/pkg/task" diff --git a/pkg/utils/file/file.go b/pkg/utils/file/file.go index fcea31a6..c7359fd8 100644 --- a/pkg/utils/file/file.go +++ b/pkg/utils/file/file.go @@ -5,7 +5,7 @@ import ( "path/filepath" "strings" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" ) // FileExists returns true if path exists diff --git a/pkg/utils/file/file_test.go b/pkg/utils/file/file_test.go index e8754632..350b0fad 100644 --- a/pkg/utils/file/file_test.go +++ b/pkg/utils/file/file_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" "github.com/stretchr/testify/assert" ) diff --git a/pkg/utils/labels/labels.go b/pkg/utils/labels/labels.go index 4e84b048..3ca8ba1d 100644 --- a/pkg/utils/labels/labels.go +++ b/pkg/utils/labels/labels.go @@ -4,7 +4,7 @@ import ( "log/slog" "sort" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" ) // MergeLabels merges several maps into one. Last map keys overrides keys from first maps. diff --git a/pkg/utils/signal/signal.go b/pkg/utils/signal/signal.go index 2038465e..a3e7b8fc 100644 --- a/pkg/utils/signal/signal.go +++ b/pkg/utils/signal/signal.go @@ -5,7 +5,7 @@ import ( "os/signal" "syscall" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" ) // WaitForProcessInterruption wait for SIGINT or SIGTERM and run a callback function. diff --git a/pkg/utils/structured-logger/structured_logger.go b/pkg/utils/structured-logger/structured_logger.go index de440cae..7744ba8b 100644 --- a/pkg/utils/structured-logger/structured_logger.go +++ b/pkg/utils/structured-logger/structured_logger.go @@ -6,7 +6,7 @@ import ( "net/http" "time" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/go-chi/chi/v5/middleware" ) diff --git a/pkg/webhook/admission/handler.go b/pkg/webhook/admission/handler.go index 0e53513a..b29b7869 100644 --- a/pkg/webhook/admission/handler.go +++ b/pkg/webhook/admission/handler.go @@ -12,7 +12,7 @@ import ( v1 "k8s.io/api/admission/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" structuredLogger "github.com/flant/shell-operator/pkg/utils/structured-logger" ) diff --git a/pkg/webhook/admission/manager.go b/pkg/webhook/admission/manager.go index 263f21d9..5b20aa23 100644 --- a/pkg/webhook/admission/manager.go +++ b/pkg/webhook/admission/manager.go @@ -3,7 +3,7 @@ package admission import ( "os" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" klient "github.com/flant/kube-client/client" "github.com/flant/shell-operator/pkg/webhook/server" diff --git a/pkg/webhook/admission/resource.go b/pkg/webhook/admission/resource.go index 1c92f574..9999b11f 100644 --- a/pkg/webhook/admission/resource.go +++ b/pkg/webhook/admission/resource.go @@ -4,7 +4,7 @@ import ( "context" "strings" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" v1 "k8s.io/api/admissionregistration/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/webhook/conversion/handler.go b/pkg/webhook/conversion/handler.go index 62e446e9..8b4b17cb 100644 --- a/pkg/webhook/conversion/handler.go +++ b/pkg/webhook/conversion/handler.go @@ -13,7 +13,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" structuredLogger "github.com/flant/shell-operator/pkg/utils/structured-logger" ) diff --git a/pkg/webhook/conversion/manager.go b/pkg/webhook/conversion/manager.go index e786cd30..d4fbe7f2 100644 --- a/pkg/webhook/conversion/manager.go +++ b/pkg/webhook/conversion/manager.go @@ -4,7 +4,7 @@ import ( "context" "os" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" klient "github.com/flant/kube-client/client" diff --git a/pkg/webhook/server/server.go b/pkg/webhook/server/server.go index a91d9604..d43d2fb3 100644 --- a/pkg/webhook/server/server.go +++ b/pkg/webhook/server/server.go @@ -9,7 +9,7 @@ import ( "os" "time" - log "github.com/deckhouse/deckhouse/go_lib/log" + log "github.com/deckhouse/deckhouse/pkg/log" "github.com/go-chi/chi/v5" ) diff --git a/test/hook/context/generator.go b/test/hook/context/generator.go index 2bb6d6fe..cf7c104b 100644 --- a/test/hook/context/generator.go +++ b/test/hook/context/generator.go @@ -6,7 +6,7 @@ import ( "sync" "time" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" "github.com/flant/kube-client/fake" "github.com/flant/shell-operator/pkg/hook" . "github.com/flant/shell-operator/pkg/hook/binding_context" diff --git a/test/hook/context/generator_test.go b/test/hook/context/generator_test.go index 87e8c279..09028938 100644 --- a/test/hook/context/generator_test.go +++ b/test/hook/context/generator_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/deckhouse/deckhouse/go_lib/log" + "github.com/deckhouse/deckhouse/pkg/log" . "github.com/onsi/gomega" . "github.com/flant/shell-operator/pkg/hook/binding_context"