Skip to content

Commit

Permalink
fix: Avoid copying mutex/lock (#250)
Browse files Browse the repository at this point in the history
Use the example from upstream Kubernetes to avoid copying mutexes.
  • Loading branch information
rquitales authored Nov 1, 2022
1 parent 59b6c42 commit 3a38243
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/declared/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"k8s.io/kube-openapi/pkg/schemaconv"
"k8s.io/kube-openapi/pkg/util/proto"
"k8s.io/kubectl/pkg/util/openapi"
"sigs.k8s.io/structured-merge-diff/v4/schema"
"sigs.k8s.io/structured-merge-diff/v4/typed"
)

Expand Down Expand Up @@ -105,7 +106,8 @@ func typedParser(doc *openapiv2.Document) (*typed.Parser, error) {
if err != nil {
return nil, fmt.Errorf("converting models to schema: %w", err)
}
// This fails the copylocks lint check, but this is exactly how the API server
// does it so I'm not sure what else to do.
return &typed.Parser{Schema: *typeSchema}, nil //nolint:govet

// We need to copy into a new schema.Schema to avoid copylock issue.
// See https://github.com/kubernetes/kubernetes/pull/109212/files
return &typed.Parser{Schema: schema.Schema{Types: typeSchema.Types}}, nil
}

0 comments on commit 3a38243

Please sign in to comment.