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
5 changes: 1 addition & 4 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,9 @@ linters:
rules:
- linters:
- gosec
- prealloc
- unparam
path: test
- linters:
- staticcheck
text: "ST1003" # A lot of "Api" instead of "API" names
path: pkg/reconciler/testing/v1/apiserversource.go
- linters:
- staticcheck
text: "ST1001" # Prohibit dot imports
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ require (
go.uber.org/atomic v1.10.0
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.28.0
golang.org/x/net v0.58.0
golang.org/x/sync v0.22.0
k8s.io/api v0.35.7
k8s.io/apiextensions-apiserver v0.35.7
Expand Down Expand Up @@ -135,6 +134,7 @@ require (
go.yaml.in/yaml/v3 v3.0.5 // indirect
golang.org/x/crypto v0.55.0 // indirect
golang.org/x/mod v0.39.0 // indirect
golang.org/x/net v0.58.0 // indirect
golang.org/x/oauth2 v0.36.0 // indirect
golang.org/x/sys v0.47.0 // indirect
golang.org/x/term v0.45.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion pkg/adapter/mtping/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func GetNoShutDownAfterValue() int {
if str != "" {
second, err := strconv.Atoi(str)
if err != nil || second < 0 || second > 59 {
log.Printf("%s environment value is invalid. It must be a integer between 0 and 59. (got %s)", EnvNoShutdownAfter, str)
log.Printf("%s environment value is invalid. It must be a integer between 0 and 59. (got %s)", EnvNoShutdownAfter, str) //nolint:gosec // value is operator-controlled env var, not user input
} else {
return second
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/feature/api_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func walk(value reflect.Value, paths ...string) reflect.Value {
return newVal
}
return walk(value.FieldByName(paths[0]), paths[1:]...)
case reflect.Ptr:
case reflect.Pointer:
return walk(reflect.Indirect(value), paths...)
default:
return reflect.Zero(value.Type())
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/messaging/v1/in_memory_channel_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ limitations under the License.
package v1

import (
"context"
"fmt"
"testing"

"knative.dev/pkg/system"

"golang.org/x/net/context"
authenticationv1 "k8s.io/api/authentication/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"knative.dev/pkg/apis"
Expand Down
2 changes: 1 addition & 1 deletion pkg/channel/fanout/fanout_event_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func createEventReceiverFunction(f *FanoutEventHandler) func(context.Context, ch

parentSpan := trace.SpanFromContext(ctx)

go func(e event.Event, h nethttp.Header, s trace.Span) {
go func(e event.Event, h nethttp.Header, s trace.Span) { //nolint:gosec // intentional async dispatch, must outlive the request-scoped context
// Run async dispatch with background context.
ctx = trace.ContextWithSpan(context.Background(), s)
// Any returned error is already logged in f.dispatch().
Expand Down
2 changes: 1 addition & 1 deletion pkg/eventingtls/eventingtls.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func loadCertPool(config ClientConfig) (*x509.CertPool, error) {
return nil
}

b, err := os.ReadFile(path)
b, err := os.ReadFile(path) //nolint:gosec // fixed platform-managed trust-bundle mount path
if err != nil {
return fmt.Errorf("failed to read file %q: %w", path, err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/graph/lineage.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

func (g *Graph) Lineage() []*Vertex {
sources := g.Sources()
lineagePaths := make(Vertices, len(sources))
lineagePaths := make(Vertices, 0, len(sources))
for _, s := range sources {
lineagePaths = append(lineagePaths, s.Lineage(EmptyEventType(), TransformFunctionContext{}))
}
Expand Down
17 changes: 9 additions & 8 deletions pkg/reconciler/eventtransform/resources_jsonata.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,14 +652,15 @@ func jsonataCertificate(ctx context.Context, transform *eventing.EventTransform)
// container, combining the transform file path, config watcher env vars, and
// OTEL tracing env vars.
func jsonataContainerEnvVars(cw *reconcilersource.ConfigWatcher) []corev1.EnvVar {
envVars := []corev1.EnvVar{
{
Name: "JSONATA_TRANSFORM_FILE_NAME",
Value: filepath.Join(JsonataExpressionPath, JsonataExpressionDataKey),
},
}
envVars = append(envVars, cw.ToEnvVars()...)
envVars = append(envVars, otelTracingEnvVars(cw)...)
cwEnvVars := cw.ToEnvVars()
otelEnvVars := otelTracingEnvVars(cw)
envVars := make([]corev1.EnvVar, 0, 1+len(cwEnvVars)+len(otelEnvVars))
envVars = append(envVars, corev1.EnvVar{
Name: "JSONATA_TRANSFORM_FILE_NAME",
Value: filepath.Join(JsonataExpressionPath, JsonataExpressionDataKey),
})
envVars = append(envVars, cwEnvVars...)
envVars = append(envVars, otelEnvVars...)
return envVars
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/integration/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func GenerateEnvVarsFromStruct(prefix string, s interface{}) []corev1.EnvVar {

// Use reflection to inspect the struct fields
v := reflect.ValueOf(s)
if v.Kind() == reflect.Ptr {
if v.Kind() == reflect.Pointer {
v = v.Elem()
}

Expand Down Expand Up @@ -67,7 +67,7 @@ func GenerateEnvVarsFromStruct(prefix string, s interface{}) []corev1.EnvVar {
envVarName = fmt.Sprintf("%s_%s", prefix, strings.ToUpper(tagName))
}

if field.Kind() == reflect.Ptr {
if field.Kind() == reflect.Pointer {
if field.IsNil() {
continue
}
Expand Down
13 changes: 7 additions & 6 deletions pkg/reconciler/pingsource/resources/receive_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,32 @@ type Args struct {

// MakeReceiveAdapterEnvVar generates the environment variables for the pingsources
func MakeReceiveAdapterEnvVar(args Args) []corev1.EnvVar {
envs := []corev1.EnvVar{{
envs := make([]corev1.EnvVar, 0, 5+len(args.ConfigEnvVars))
envs = append(envs, corev1.EnvVar{
Name: adapter.EnvConfigNamespace,
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.namespace",
},
},
}, {
}, corev1.EnvVar{
// Needed by leader elector.
Name: system.NamespaceEnvKey,
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.namespace",
},
},
}, {
}, corev1.EnvVar{
Name: adapter.EnvConfigLeaderElectionConfig,
Value: args.LeConfig,
}, {
}, corev1.EnvVar{
Name: mtping.EnvNoShutdownAfter,
Value: strconv.Itoa(args.NoShutdownAfter),
}, {
}, corev1.EnvVar{
Name: adapter.EnvSinkTimeout,
Value: strconv.Itoa(args.SinkTimeout),
}}
})

return append(envs, args.ConfigEnvVars...)
}
1 change: 1 addition & 0 deletions pkg/reconciler/source/crd/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func (r *Reconciler) reconcileController(ctx context.Context, crd *v1.CustomReso
}

// Source Duck controller context
//nolint:gosec // TODO: cancel is stored in runningController for cleanup on CRD deletion, which is not yet implemented (goroutine leak on CRD removal)
sdctx, cancel := context.WithCancel(r.ogctx)
// Source Duck controller instantiation
sd := sdc(sdctx, r.ogcmw)
Expand Down
10 changes: 5 additions & 5 deletions test/lib/recordevents/event_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type EventInfo struct {
func (ei *EventInfo) String() string {
var sb strings.Builder
sb.WriteString("-- EventInfo --\n")
sb.WriteString(fmt.Sprintf("--- Kind: %v ---\n", ei.Kind))
fmt.Fprintf(&sb, "--- Kind: %v ---\n", ei.Kind)
if ei.Event != nil {
sb.WriteString("--- Event ---\n")
sb.WriteString(ei.Event.String())
Expand All @@ -90,12 +90,12 @@ func (ei *EventInfo) String() string {
sb.WriteRune('\n')
}
if ei.StatusCode != 0 {
sb.WriteString(fmt.Sprintf("--- Status Code: %d ---\n", ei.StatusCode))
fmt.Fprintf(&sb, "--- Status Code: %d ---\n", ei.StatusCode)
}
sb.WriteString("--- Origin: '" + ei.Origin + "' ---\n")
sb.WriteString("--- Observer: '" + ei.Observer + "' ---\n")
sb.WriteString("--- Time: " + ei.Time.String() + " ---\n")
sb.WriteString(fmt.Sprintf("--- Sequence: %d ---\n", ei.Sequence))
fmt.Fprintf(&sb, "--- Sequence: %d ---\n", ei.Sequence)
sb.WriteString("--------------------\n")
return sb.String()
}
Expand All @@ -112,8 +112,8 @@ type SearchedInfo struct {
// Pretty print the SearchedInfor for error messages
func (s *SearchedInfo) String() string {
var sb strings.Builder
sb.WriteString(fmt.Sprintf("%d events seen, last %d events (total events seen %d, events ignored %d):\n",
s.TotalEvent, len(s.LastNEvent), s.storeEventsSeen, s.storeEventsNotMine))
fmt.Fprintf(&sb, "%d events seen, last %d events (total events seen %d, events ignored %d):\n",
s.TotalEvent, len(s.LastNEvent), s.storeEventsSeen, s.storeEventsNotMine)
for _, ei := range s.LastNEvent {
sb.WriteString(ei.String())
sb.WriteRune('\n')
Expand Down
118 changes: 0 additions & 118 deletions vendor/golang.org/x/net/context/context.go

This file was deleted.

1 change: 0 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,6 @@ golang.org/x/mod/module
golang.org/x/mod/semver
# golang.org/x/net v0.58.0
## explicit; go 1.25.0
golang.org/x/net/context
golang.org/x/net/http/httpguts
golang.org/x/net/http2
golang.org/x/net/http2/h2c
Expand Down
Loading