Skip to content

Commit

Permalink
bump sdk, add new global var
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Okhlopkov <[email protected]>
  • Loading branch information
Pavel Okhlopkov committed Nov 15, 2024
1 parent 92e19d2 commit 69f5544
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ require (
replace github.com/go-openapi/validate => github.com/flant/go-openapi-validate v0.19.12-flant.0

require (
github.com/deckhouse/module-sdk v0.0.0-20241114101830-23c1625a3180
github.com/deckhouse/module-sdk v0.0.0-20241115114054-a4c8097d415a
github.com/gojuno/minimock/v3 v3.4.1
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241106140903-258b93b3334e h1:QUQ
github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241106140903-258b93b3334e/go.mod h1:Mk5HRzkc5pIcDIZ2JJ6DPuuqnwhXVkb3you8M8Mg+4w=
github.com/deckhouse/module-sdk v0.0.0-20241114101830-23c1625a3180 h1:uZQFTYdEc/4ypHv+aO4ep5m41pVVUnWj+ZBknsmjR+M=
github.com/deckhouse/module-sdk v0.0.0-20241114101830-23c1625a3180/go.mod h1:q9jIxjVSVhPRJLWC001c7ujYZIzoPKjiF4LV0Zm+XCE=
github.com/deckhouse/module-sdk v0.0.0-20241115114054-a4c8097d415a h1:pEX95Y6y0zXcN5aHb+s+ToMgunsEf/Ky/4Xz1XPcBGY=
github.com/deckhouse/module-sdk v0.0.0-20241115114054-a4c8097d415a/go.mod h1:q9jIxjVSVhPRJLWC001c7ujYZIzoPKjiF4LV0Zm+XCE=
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=
Expand Down
13 changes: 10 additions & 3 deletions pkg/app/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ var DebugUnixSocket = "/var/run/shell-operator/debug.socket"

var DebugHttpServerAddr = ""

var DebugKeepTmpFiles = "no"
var (
DebugKeepTmpFilesVar = "no"
DebugKeepTmpFiles = false
)

var DebugKubernetesAPI = false

Expand All @@ -27,8 +30,12 @@ func DefineDebugFlags(kpApp *kingpin.Application, cmd *kingpin.CmdClause) {
cmd.Flag("debug-keep-tmp-files", "set to yes to disable cleanup of temporary files").
Envar("DEBUG_KEEP_TMP_FILES").
Hidden().
Default(DebugKeepTmpFiles).
StringVar(&DebugKeepTmpFiles)
Default(DebugKeepTmpFilesVar).Action(func(_ *kingpin.ParseContext) error {
DebugKeepTmpFiles = DebugKeepTmpFilesVar == "yes"

return nil
}).
StringVar(&DebugKeepTmpFilesVar)

cmd.Flag("debug-kubernetes-api", "enable client-go debug messages").
Envar("DEBUG_KUBERNETES_API").
Expand Down
2 changes: 1 addition & 1 deletion pkg/hook/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (h *Hook) Run(_ BindingType, context []BindingContext, logLabels map[string

// remove tmp file on hook exit
defer func() {
if app.DebugKeepTmpFiles != "yes" {
if app.DebugKeepTmpFiles {
_ = os.Remove(contextPath)
_ = os.Remove(metricsPath)
_ = os.Remove(conversionPath)
Expand Down
2 changes: 1 addition & 1 deletion pkg/shell-operator/kube_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/deckhouse/deckhouse/pkg/log"
metricstorage "github.com/deckhouse/module-sdk/pkg/metric-storage"

objectpatch "github.com/deckhouse/module-sdk/pkg/object-patch"

klient "github.com/flant/kube-client/client"
"github.com/flant/shell-operator/pkg/app"
utils "github.com/flant/shell-operator/pkg/utils/labels"
Expand Down
2 changes: 1 addition & 1 deletion pkg/shell-operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
kubeeventsmanager "github.com/deckhouse/module-sdk/pkg/kube-events-manager"
kemTypes "github.com/deckhouse/module-sdk/pkg/kube-events-manager/types"
metricstorage "github.com/deckhouse/module-sdk/pkg/metric-storage"
objectpatch "github.com/deckhouse/module-sdk/pkg/object-patch"
"github.com/deckhouse/module-sdk/pkg/webhook/admission"
"github.com/deckhouse/module-sdk/pkg/webhook/conversion"
"github.com/gofrs/uuid/v5"
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"

objectpatch "github.com/deckhouse/module-sdk/pkg/object-patch"
klient "github.com/flant/kube-client/client"
"github.com/flant/shell-operator/pkg/hook"
"github.com/flant/shell-operator/pkg/hook/controller"
Expand Down
3 changes: 2 additions & 1 deletion test/hook/context/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
kubeeventsmanager "github.com/deckhouse/module-sdk/pkg/kube-events-manager"

"github.com/flant/kube-client/fake"
"github.com/flant/shell-operator/pkg/app"
schedulemanager "github.com/flant/shell-operator/pkg/schedule_manager"
)

Expand Down Expand Up @@ -102,7 +103,7 @@ func (b *BindingContextController) Run(initialState string) (GeneratedBindingCon
}

if b.Hook == nil {
testHook := hook.NewHook("test", "test", b.logger.Named("hook"))
testHook := hook.NewHook("test", "test", app.DebugKeepTmpFiles, app.LogProxyHookJSON, app.ProxyJsonLogKey, b.logger.Named("hook"))
testHook, err = testHook.LoadConfig([]byte(b.HookConfig))
if err != nil {
return GeneratedBindingContexts{}, fmt.Errorf("couldn't load or validate hook configuration: %v", err)
Expand Down

0 comments on commit 69f5544

Please sign in to comment.