Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions hack/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ run_dir="$(pwd)"
packages="$(go list ./... | grep -v /validation/)"
prefix="$(grep -oP 'module .*$' go.mod | sed 's|module ||')"

echo "Found packages: $packages in $run_dir with module $prefix"
echo "Found packages: ${packages[@]} in $run_dir with module $prefix"

for p in "$packages"; do
while IFS= read -r p; do
pkg_dir="${p#$prefix}"
if [ -z "$pkg_dir" ]; then
echo "Package $p cannot have dir after trim $prefix"
Expand All @@ -37,4 +37,4 @@ for p in "$packages"; do
echo "Run tests in $full_pkg_path"
cd "$full_pkg_path"
echo "test -v -p 1 $run_tests" | xargs go
done
done <<< "$packages"
59 changes: 59 additions & 0 deletions pkg/retry/globals.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2025 Flant JSC
//
// Licensed under the Apache License, Version 2.0 (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 writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// 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.

package retry

import (
"github.com/name212/govalue"

"github.com/deckhouse/lib-dhctl/pkg/log"
)

type GlobalInterruptChecker func() bool

func SetGlobalInterruptChecker(checker GlobalInterruptChecker) {
if govalue.IsNil(checker) {
return
}

globalInterruptChecker = checker
}

// SetGlobalDefaultLogger
// Deprecated:
// global logger used for backward compatibility in dhctl with
// deprecated functions NewLoop and NewSilentLoop
// Please use NewLoopWithParams and NewSilentLoopWithParams
func SetGlobalDefaultLogger(logger log.Logger) {
if govalue.IsNil(logger) {
return
}

defaultLogger = logger
}

var (
globalInterruptChecker GlobalInterruptChecker = func() bool { return false }
defaultLogger log.Logger = log.NewDummyLogger(false)
silentLogger = log.NewSilentLogger()
)

func getDefaultSilentLogger() *log.SilentLogger {
switch defaultLogger.(type) {
case *log.TeeLogger:
return defaultLogger.SilentLogger()
default:
return silentLogger
}
}
Loading