Tim Hockin
f772410082
Make code-gen subprojects work on gengo/v2
2024-02-29 22:06:38 -08:00
Tim Hockin
251b22a7f8
Make update-codegen protobuf work on gengo/v2
2024-02-29 22:06:38 -08:00
Tim Hockin
b0a70dec4a
Fix go-to-protobuf wrt gengo/v2
...
There's some very fishy-smelling logic in here, but this commit is
trying to be as focused as possible.
The *.pb.go diffs are the "name" encoded in the descriptor. The
descriptor blobs can be decoded by this program (thanks StackOverflow!):
```
package main
import (
"bytes"
"compress/gzip"
"encoding/json"
"fmt"
"os"
"io/ioutil"
proto "github.com/golang/protobuf/proto"
dpb "github.com/golang/protobuf/protoc-gen-go/descriptor"
)
func main() {
m := map[string][]byte{
"before": blobv1,
"after": blobv2,
}
arg := os.Args[1]
dump(m[arg])
}
func dump(bytes []byte) {
fd, err := decodeFileDesc(bytes)
if err != nil {
panic(err)
}
b, err := json.MarshalIndent(fd, "", " ")
if err != nil {
panic(err)
}
fmt.Println(string(b))
}
// decompress does gzip decompression.
func decompress(b []byte) ([]byte, error) {
r, err := gzip.NewReader(bytes.NewReader(b))
if err != nil {
return nil, fmt.Errorf("bad gzipped descriptor: %v", err)
}
out, err := ioutil.ReadAll(r)
if err != nil {
return nil, fmt.Errorf("bad gzipped descriptor: %v", err)
}
return out, nil
}
func decodeFileDesc(enc []byte) (*dpb.FileDescriptorProto, error) {
raw, err := decompress(enc)
if err != nil {
return nil, fmt.Errorf("failed to decompress enc: %v", err)
}
fd := new(dpb.FileDescriptorProto)
if err := proto.Unmarshal(raw, fd); err != nil {
return nil, fmt.Errorf("bad descriptor: %v", err)
}
return fd, nil
}
var blobv1 = []byte{
// insert proto "before" blob here
}
var blobv2 = []byte{
// insert proto "after" blob here
}
```
Running this with "before" and "after" args, and diffing the output
yields something like:
```diff
--- /tmp/a 2023-12-23 23:57:04.748090836 -0800
+++ /tmp/b 2023-12-23 23:57:11.000040973 -0800
@@ -1,5 +1,5 @@
{
- "name": "k8s.io/kubernetes/vendor/k8s.io/api/admission/v1/generated.proto",
+ "name": "k8s.io/api/admission/v1/generated.proto",
"package": "k8s.io.api.admission.v1",
"dependency": [
"github.com/gogo/protobuf/gogoproto/gogo.proto",
```
2024-02-29 22:06:37 -08:00
Tim Hockin
7506048d3f
Make update-codegen client work on gengo/v2
2024-02-29 22:06:36 -08:00
Tim Hockin
b961b39efa
Fix client-gen wrt gengo/v2
2024-02-29 22:06:35 -08:00
Tim Hockin
130a9f8426
Make update-codegen applyconfig work on gengo/v2
2024-02-29 22:06:34 -08:00
Tim Hockin
5ddd6772a4
Fix applyconfiguration-gen wrt gengo/v2
2024-02-29 22:06:33 -08:00
Tim Hockin
9c62235266
Make update-codegen informer work on gengo/v2
2024-02-29 22:06:32 -08:00
Tim Hockin
0aa98ee8e3
Fix informer-gen wrt gengo/v2
2024-02-29 22:06:31 -08:00
Tim Hockin
46665fa76a
Make update-codegen lister work on gengo/v2
2024-02-29 22:06:31 -08:00
Tim Hockin
b82527b6fb
Fix lister-gen wrt gengo/v2
2024-02-29 22:06:30 -08:00
Tim Hockin
1965f56f59
Make update-codegen openapi work on gengo/v2
2024-02-29 22:06:29 -08:00
Tim Hockin
5475797f43
Make update-codegen conversion work on gengo/v2
2024-02-29 22:06:28 -08:00
Tim Hockin
ed35118664
Fix conversion-gen wrt gengo/v2
2024-02-29 22:06:27 -08:00
Tim Hockin
1e96f4e50a
Make update-codegen prerelease work on gengo/v2
2024-02-29 22:06:26 -08:00
Tim Hockin
fd2ca0a344
Fix prerelease-lifecycle-gen wrt gengo/v2
2024-02-29 22:06:25 -08:00
Tim Hockin
b5b8c9d869
Make update-codegen swagger work on gengo/v2
2024-02-29 22:06:25 -08:00
Tim Hockin
8420278c7f
Make update-codegen defaulter work on gengo/v2
2024-02-29 22:06:24 -08:00
Tim Hockin
1fb4e824ba
Make update-codegen deepcopy work on gengo/v2
2024-02-29 22:06:23 -08:00
Tim Hockin
d5e8e9c29c
Change update-codegen.sh to use new setup_env
...
This breaks all the generators, which will be fixed subsequently.
2024-02-29 22:06:22 -08:00
Tim Hockin
db590ecd89
Fix scripts to avoid testdata
2024-02-29 22:06:21 -08:00
Tim Hockin
514dd0e1f6
Convert all gengo references to gengo/v2
...
TO REPEAT:
git ls-files ':!:vendor/k8s.io/gengo' ':!:gengo-v2' ':(glob)**/*.go' \
| xargs grep -l 'k8s.io/gengo/' \
| while read F; do \
sed -i 's|k8s.io/gengo/\([^v]\)|k8s.io/gengo/v2/\1|' $F
done
2024-02-29 22:06:20 -08:00
Tim Hockin
6f2f3735e0
Re-vendor latest kube-openapi and gengo/v2
...
./hack/pin-dependency.sh k8s.io/kube-openapi latest
./hack/pin-dependency.sh k8s.io/gengo/v2 latest
./hack/update-vendor.sh
2024-02-29 22:06:19 -08:00
Tim Hockin
b3dd724174
Remove dep on set-gen: gone in gengo/v2
2024-02-29 22:06:18 -08:00
Tim Hockin
487cd02711
Change verify-generated to new setup_env
2024-02-29 22:06:18 -08:00
Tim Hockin
c79e5abec4
Change test-e2e-node to use new setup_env
2024-02-29 22:06:17 -08:00
Tim Hockin
7a7dff1eeb
Change verify-imports to use new setup_env
...
Also clean up the tool a bit and drop vendor as an explicit thing to
be handled.
2024-02-29 22:06:16 -08:00
Tim Hockin
3be358ecc1
Make verify-conformance-requirements use new setup_env
2024-02-29 22:06:15 -08:00
Tim Hockin
08622aa685
Make verify-no-vendor-cycles use new setup_env
2024-02-29 22:06:14 -08:00
Tim Hockin
854037d5b5
Change update-generated-api-compatibility-data test to new setup_env
2024-02-29 22:06:13 -08:00
Tim Hockin
25b97dae82
Change ipamperf test to new setup_env
2024-02-29 22:06:12 -08:00
Tim Hockin
238b33de3b
Change test/instrumentation/update-* to new setup_env
2024-02-29 22:06:12 -08:00
Tim Hockin
cbc887a1d6
Change verify-govulncheck to new setup_env
2024-02-29 22:06:11 -08:00
Tim Hockin
024f4e9c09
Change verify-generated-docs to new setup_env
2024-02-29 22:06:10 -08:00
Tim Hockin
35aa5b3c69
Change verify-fieldname-docs to new setup_env
2024-02-29 22:06:09 -08:00
Tim Hockin
0d30f918fa
Change verify-description to new setup_env
2024-02-29 22:06:08 -08:00
Tim Hockin
bad67dc973
Fix golangci-lint for workspaces
2024-02-29 22:06:07 -08:00
Tim Hockin
3163fc4f69
Change update-golangci-lint-config to new setup_env
2024-02-29 22:06:06 -08:00
Tim Hockin
714f8a0855
Change verify-yamlfmt to new setup_env
2024-02-29 22:06:06 -08:00
Tim Hockin
3dc447708b
Change verify-gofmt to new setup_env
2024-02-29 22:06:05 -08:00
Tim Hockin
d785f13c05
Change verify-licenses to new setup_env
2024-02-29 22:06:04 -08:00
Tim Hockin
974276e4a0
Change update-openapi-spec to new setup_env
2024-02-29 22:06:03 -08:00
Tim Hockin
2ee339b023
Simplify verify-cli-conventions; use new setup_env
2024-02-29 22:06:02 -08:00
Tim Hockin
2924b90d75
Change verify-api-groups.sh to s/vendor/staging/
...
I'm really not sure what this particular file check is doing, but that's
for tomorrow.
2024-02-29 22:06:01 -08:00
Tim Hockin
b725fd20c2
Fix update/verify-mocks.sh
...
There appears to be a bug in `go generate` for workspaces which will be
fixed in the 1.22.1 release.
2024-02-29 22:06:00 -08:00
Tim Hockin
58ab5eea89
Remove some references to GOPATH
2024-02-29 22:05:59 -08:00
Tim Hockin
5f490b4fe8
Clarify, document KUBE_OUTPUT_* variables
2024-02-29 22:05:42 -08:00
Tim Hockin
f47e0cb779
Rename KUBE_OUTPUT_BINPATH -> KUBE_OUTPUT_BIN
...
"...PATH" doesn't add anything and confuses it with KUBE_OUTPUT_SUBPATH.
2024-02-29 00:22:14 -08:00
Tim Hockin
aaf6fc07d8
Make build scripts use Go import paths
...
This helps 2 things:
1) output is cleaner
2) whether a build is static or non-static depends on string matching,
which is easier after this
If you specify a `...` pattern, this will preserve it, which breaks the
static/non-static matching but really, can we just agree that `make` is
for binaries? It works for other things but so does `go build`.
Example:
```
$ make WHAT="cmd/kubectl/ ./staging/src/k8s.io/api/... ./test/e2e/e2e.test ./test/e2e/e2e.test ./cmd/kubectl/ "
go version go1.21.4 linux/amd64
+++ [1208 22:24:43] Building go targets for linux/amd64
k8s.io/api/... (non-static)
k8s.io/kubernetes/cmd/kubectl (static)
k8s.io/kubernetes/test/e2e/e2e.test (test)
```
2024-02-29 00:22:13 -08:00
Tim Hockin
f3c8e92def
Clean up test.sh and get rid of GOPATH
...
Result: `make test` works:
```
$ #### BUILD ####
$ make WHAT="./cmd/kubectl/ ./staging/src/k8s.io/api"
+++ [1211 11:20:46] Building go targets for linux/amd64
./cmd/kubectl/ (non-static)
./staging/src/k8s.io/api (non-static)
$ #### TEST ####
$ make test WHAT=./pkg/proxy/iptables/
+++ [1211 11:22:31] Set GOMAXPROCS automatically to 6
+++ [1211 11:22:31] Running tests without code coverage and with -race
ok k8s.io/kubernetes/pkg/proxy/iptables 9.517s
$ make test WHAT=pkg/proxy/iptables/
+++ [1211 11:22:53] Set GOMAXPROCS automatically to 6
+++ [1211 11:22:53] Running tests without code coverage and with -race
ok k8s.io/kubernetes/pkg/proxy/iptables (cached)
$ make test WHAT=k8s.io/kubernetes/pkg/proxy/iptables/
+++ [1211 11:23:09] Set GOMAXPROCS automatically to 6
+++ [1211 11:23:09] Running tests without code coverage and with -race
ok k8s.io/kubernetes/pkg/proxy/iptables (cached)
$ make test WHAT=./staging/src/k8s.io/api
+++ [1211 11:23:24] Set GOMAXPROCS automatically to 6
+++ [1211 11:23:24] Running tests without code coverage and with -race
ok k8s.io/api 21.981s
$ make test WHAT=staging/src/k8s.io/api
+++ [1211 11:23:54] Set GOMAXPROCS automatically to 6
+++ [1211 11:23:54] Running tests without code coverage and with -race
ok k8s.io/api (cached)
$ make test WHAT=k8s.io/api
+++ [1211 11:24:06] Set GOMAXPROCS automatically to 6
+++ [1211 11:24:06] Running tests without code coverage and with -race
ok k8s.io/api (cached)
```
2024-02-29 00:22:13 -08:00