mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-24 12:18:06 +08:00
vendor: update buildkit to v0.19.0-rc1
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
4
vendor/k8s.io/klog/v2/OWNERS
generated
vendored
4
vendor/k8s.io/klog/v2/OWNERS
generated
vendored
@@ -1,14 +1,16 @@
|
||||
# See the OWNERS docs at https://go.k8s.io/owners
|
||||
reviewers:
|
||||
- harshanarayana
|
||||
- mengjiao-liu
|
||||
- pohly
|
||||
approvers:
|
||||
- dims
|
||||
- pohly
|
||||
- thockin
|
||||
- serathius
|
||||
emeritus_approvers:
|
||||
- brancz
|
||||
- justinsb
|
||||
- lavalamp
|
||||
- piosz
|
||||
- serathius
|
||||
- tallclair
|
||||
|
31
vendor/k8s.io/klog/v2/contextual_slog.go
generated
vendored
Normal file
31
vendor/k8s.io/klog/v2/contextual_slog.go
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
//go:build go1.21
|
||||
// +build go1.21
|
||||
|
||||
/*
|
||||
Copyright 2021 The Kubernetes Authors.
|
||||
|
||||
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 klog
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
)
|
||||
|
||||
// SetSlogLogger reconfigures klog to log through the slog logger. The logger must not be nil.
|
||||
func SetSlogLogger(logger *slog.Logger) {
|
||||
SetLoggerWithOptions(logr.FromSlogHandler(logger.Handler()), ContextualLogger(true))
|
||||
}
|
99
vendor/k8s.io/klog/v2/klog.go
generated
vendored
99
vendor/k8s.io/klog/v2/klog.go
generated
vendored
@@ -14,9 +14,26 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package klog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.
|
||||
// It provides functions Info, Warning, Error, Fatal, plus formatting variants such as
|
||||
// Infof. It also provides V-style logging controlled by the -v and -vmodule=file=2 flags.
|
||||
// Package klog contains the following functionality:
|
||||
//
|
||||
// - output routing as defined via command line flags ([InitFlags])
|
||||
// - log formatting as text, either with a single, unstructured string ([Info], [Infof], etc.)
|
||||
// or as a structured log entry with message and key/value pairs ([InfoS], etc.)
|
||||
// - management of a go-logr [Logger] ([SetLogger], [Background], [TODO])
|
||||
// - helper functions for logging values ([Format]) and managing the state of klog ([CaptureState], [State.Restore])
|
||||
// - wrappers for [logr] APIs for contextual logging where the wrappers can
|
||||
// be turned into no-ops ([EnableContextualLogging], [NewContext], [FromContext],
|
||||
// [LoggerWithValues], [LoggerWithName]); if the ability to turn off
|
||||
// contextual logging is not needed, then go-logr can also be used directly
|
||||
// - type aliases for go-logr types to simplify imports in code which uses both (e.g. [Logger])
|
||||
// - [k8s.io/klog/v2/textlogger]: a logger which uses the same formatting as klog log with
|
||||
// simpler output routing; beware that it comes with its own command line flags
|
||||
// and does not use the ones from klog
|
||||
// - [k8s.io/klog/v2/ktesting]: per-test output in Go unit tests
|
||||
// - [k8s.io/klog/v2/klogr]: a deprecated, standalone [logr.Logger] on top of the main klog package;
|
||||
// use [Background] instead if klog output routing is needed, [k8s.io/klog/v2/textlogger] if not
|
||||
// - [k8s.io/klog/v2/examples]: demos of this functionality
|
||||
// - [k8s.io/klog/v2/test]: reusable tests for [logr.Logger] implementations
|
||||
//
|
||||
// Basic examples:
|
||||
//
|
||||
@@ -387,13 +404,6 @@ func (t *traceLocation) Set(value string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// flushSyncWriter is the interface satisfied by logging destinations.
|
||||
type flushSyncWriter interface {
|
||||
Flush() error
|
||||
Sync() error
|
||||
io.Writer
|
||||
}
|
||||
|
||||
var logging loggingT
|
||||
var commandLine flag.FlagSet
|
||||
|
||||
@@ -469,7 +479,7 @@ type settings struct {
|
||||
// Access to all of the following fields must be protected via a mutex.
|
||||
|
||||
// file holds writer for each of the log types.
|
||||
file [severity.NumSeverity]flushSyncWriter
|
||||
file [severity.NumSeverity]io.Writer
|
||||
// flushInterval is the interval for periodic flushing. If zero,
|
||||
// the global default will be used.
|
||||
flushInterval time.Duration
|
||||
@@ -814,32 +824,12 @@ func (l *loggingT) printS(err error, s severity.Severity, depth int, msg string,
|
||||
buffer.PutBuffer(b)
|
||||
}
|
||||
|
||||
// redirectBuffer is used to set an alternate destination for the logs
|
||||
type redirectBuffer struct {
|
||||
w io.Writer
|
||||
}
|
||||
|
||||
func (rb *redirectBuffer) Sync() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rb *redirectBuffer) Flush() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rb *redirectBuffer) Write(bytes []byte) (n int, err error) {
|
||||
return rb.w.Write(bytes)
|
||||
}
|
||||
|
||||
// SetOutput sets the output destination for all severities
|
||||
func SetOutput(w io.Writer) {
|
||||
logging.mu.Lock()
|
||||
defer logging.mu.Unlock()
|
||||
for s := severity.FatalLog; s >= severity.InfoLog; s-- {
|
||||
rb := &redirectBuffer{
|
||||
w: w,
|
||||
}
|
||||
logging.file[s] = rb
|
||||
logging.file[s] = w
|
||||
}
|
||||
}
|
||||
|
||||
@@ -851,10 +841,7 @@ func SetOutputBySeverity(name string, w io.Writer) {
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("SetOutputBySeverity(%q): unrecognized severity name", name))
|
||||
}
|
||||
rb := &redirectBuffer{
|
||||
w: w,
|
||||
}
|
||||
logging.file[sev] = rb
|
||||
logging.file[sev] = w
|
||||
}
|
||||
|
||||
// LogToStderr sets whether to log exclusively to stderr, bypassing outputs
|
||||
@@ -994,7 +981,8 @@ func (l *loggingT) exit(err error) {
|
||||
logExitFunc(err)
|
||||
return
|
||||
}
|
||||
l.flushAll()
|
||||
needToSync := l.flushAll()
|
||||
l.syncAll(needToSync)
|
||||
OsExit(2)
|
||||
}
|
||||
|
||||
@@ -1011,10 +999,6 @@ type syncBuffer struct {
|
||||
maxbytes uint64 // The max number of bytes this syncBuffer.file can hold before cleaning up.
|
||||
}
|
||||
|
||||
func (sb *syncBuffer) Sync() error {
|
||||
return sb.file.Sync()
|
||||
}
|
||||
|
||||
// CalculateMaxSize returns the real max size in bytes after considering the default max size and the flag options.
|
||||
func CalculateMaxSize() uint64 {
|
||||
if logging.logFile != "" {
|
||||
@@ -1206,24 +1190,45 @@ func StartFlushDaemon(interval time.Duration) {
|
||||
// lockAndFlushAll is like flushAll but locks l.mu first.
|
||||
func (l *loggingT) lockAndFlushAll() {
|
||||
l.mu.Lock()
|
||||
l.flushAll()
|
||||
needToSync := l.flushAll()
|
||||
l.mu.Unlock()
|
||||
// Some environments are slow when syncing and holding the lock might cause contention.
|
||||
l.syncAll(needToSync)
|
||||
}
|
||||
|
||||
// flushAll flushes all the logs and attempts to "sync" their data to disk.
|
||||
// flushAll flushes all the logs
|
||||
// l.mu is held.
|
||||
func (l *loggingT) flushAll() {
|
||||
//
|
||||
// The result is the number of files which need to be synced and the pointers to them.
|
||||
func (l *loggingT) flushAll() fileArray {
|
||||
var needToSync fileArray
|
||||
|
||||
// Flush from fatal down, in case there's trouble flushing.
|
||||
for s := severity.FatalLog; s >= severity.InfoLog; s-- {
|
||||
file := l.file[s]
|
||||
if file != nil {
|
||||
_ = file.Flush() // ignore error
|
||||
_ = file.Sync() // ignore error
|
||||
if sb, ok := file.(*syncBuffer); ok && sb.file != nil {
|
||||
_ = sb.Flush() // ignore error
|
||||
needToSync.files[needToSync.num] = sb.file
|
||||
needToSync.num++
|
||||
}
|
||||
}
|
||||
if logging.loggerOptions.flush != nil {
|
||||
logging.loggerOptions.flush()
|
||||
}
|
||||
return needToSync
|
||||
}
|
||||
|
||||
type fileArray struct {
|
||||
num int
|
||||
files [severity.NumSeverity]*os.File
|
||||
}
|
||||
|
||||
// syncAll attempts to "sync" their data to disk.
|
||||
func (l *loggingT) syncAll(needToSync fileArray) {
|
||||
// Flush from fatal down, in case there's trouble flushing.
|
||||
for i := 0; i < needToSync.num; i++ {
|
||||
_ = needToSync.files[i].Sync() // ignore error
|
||||
}
|
||||
}
|
||||
|
||||
// CopyStandardLogTo arranges for messages written to the Go "log" package's
|
||||
|
10
vendor/k8s.io/klog/v2/klogr_slog.go
generated
vendored
10
vendor/k8s.io/klog/v2/klogr_slog.go
generated
vendored
@@ -25,7 +25,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/go-logr/logr/slogr"
|
||||
"github.com/go-logr/logr"
|
||||
|
||||
"k8s.io/klog/v2/internal/buffer"
|
||||
"k8s.io/klog/v2/internal/serialize"
|
||||
@@ -35,7 +35,7 @@ import (
|
||||
|
||||
func (l *klogger) Handle(ctx context.Context, record slog.Record) error {
|
||||
if logging.logger != nil {
|
||||
if slogSink, ok := logging.logger.GetSink().(slogr.SlogSink); ok {
|
||||
if slogSink, ok := logging.logger.GetSink().(logr.SlogSink); ok {
|
||||
// Let that logger do the work.
|
||||
return slogSink.Handle(ctx, record)
|
||||
}
|
||||
@@ -77,13 +77,13 @@ func slogOutput(file string, line int, now time.Time, err error, s severity.Seve
|
||||
buffer.PutBuffer(b)
|
||||
}
|
||||
|
||||
func (l *klogger) WithAttrs(attrs []slog.Attr) slogr.SlogSink {
|
||||
func (l *klogger) WithAttrs(attrs []slog.Attr) logr.SlogSink {
|
||||
clone := *l
|
||||
clone.values = serialize.WithValues(l.values, sloghandler.Attrs2KVList(l.groups, attrs))
|
||||
return &clone
|
||||
}
|
||||
|
||||
func (l *klogger) WithGroup(name string) slogr.SlogSink {
|
||||
func (l *klogger) WithGroup(name string) logr.SlogSink {
|
||||
clone := *l
|
||||
if clone.groups != "" {
|
||||
clone.groups += "." + name
|
||||
@@ -93,4 +93,4 @@ func (l *klogger) WithGroup(name string) slogr.SlogSink {
|
||||
return &clone
|
||||
}
|
||||
|
||||
var _ slogr.SlogSink = &klogger{}
|
||||
var _ logr.SlogSink = &klogger{}
|
||||
|
34
vendor/k8s.io/klog/v2/safeptr.go
generated
vendored
Normal file
34
vendor/k8s.io/klog/v2/safeptr.go
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
/*
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
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 klog
|
||||
|
||||
// SafePtr is a function that takes a pointer of any type (T) as an argument.
|
||||
// If the provided pointer is not nil, it returns the same pointer. If it is nil, it returns nil instead.
|
||||
//
|
||||
// This function is particularly useful to prevent nil pointer dereferencing when:
|
||||
//
|
||||
// - The type implements interfaces that are called by the logger, such as `fmt.Stringer`.
|
||||
// - And these interface implementations do not perform nil checks themselves.
|
||||
func SafePtr[T any](p *T) any {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
return p
|
||||
}
|
Reference in New Issue
Block a user