Commit Graph

121431 Commits

Author SHA1 Message Date
Tim Hockin
00e09374b6
Make update-codegen avoid sub-workspaces 2024-02-29 22:10:39 -08:00
Tim Hockin
21715e6bbd
Fix up go.mod files after reviews
Because of how the previous 100+ commits were done, so changes snuck
thru that properly belong in earlier commits but it's not really
possible to do that without a lot of effort.

We agreed it was OK to "spackle" these cracks with a final commit.
2024-02-29 22:07:45 -08:00
Tim Hockin
78f82b972f
Sort publishing/rules.yaml
Needed because defaulter-gen tests end up depending on apimachinery.
2024-02-29 22:07:44 -08:00
Tim Hockin
ac5664086b
Use path instead of filepath for pkg-paths 2024-02-29 22:07:44 -08:00
Tim Hockin
70d803c1ff
Make make fail better with bad inputs
Ultimately, we're hitting places where bash is just hard to get right.

Instead of:

```
$ make WHAT=nonexist
stat /home/thockin/src/kubernetes/nonexist: directory not found
!!! [0228 12:07:12] Call tree:
!!! [0228 12:07:12]  1: /home/thockin/src/kubernetes/hack/lib/golang.sh:930 kube::golang::normalize_go_targets(...)
!!! [0228 12:07:12]  2: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
+++ [0228 12:07:12] Building go targets for linux/amd64
     (non-static)
no Go files in /home/thockin/src/kubernetes
!!! [0228 12:07:12] Call tree:
!!! [0228 12:07:12]  1: /home/thockin/src/kubernetes/hack/lib/golang.sh:820 kube::golang::build_some_binaries(...)
!!! [0228 12:07:12]  2: /home/thockin/src/kubernetes/hack/lib/golang.sh:974 kube::golang::build_binaries_for_platform(...)
!!! [0228 12:07:12]  3: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [0228 12:07:12] Call tree:
!!! [0228 12:07:12]  1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [0228 12:07:12] Call tree:
!!! [0228 12:07:12]  1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
make: *** [Makefile:95: all] Error 1
```

We now get:

```
$ make WHAT=nonexist
+++ [0228 12:33:49] Building go targets for linux/amd64
    ./nonexist (non-static)
stat /home/thockin/src/kubernetes/nonexist: directory not found
!!! [0228 12:33:49] Call tree:
!!! [0228 12:33:49]  1: /home/thockin/src/kubernetes/hack/lib/golang.sh:823 kube::golang::build_some_binaries(...)
!!! [0228 12:33:49]  2: /home/thockin/src/kubernetes/hack/lib/golang.sh:976 kube::golang::build_binaries_for_platform(...)
!!! [0228 12:33:49]  3: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [0228 12:33:49] Call tree:
!!! [0228 12:33:49]  1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [0228 12:33:49] Call tree:
!!! [0228 12:33:49]  1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
make: *** [Makefile:95: all] Error 1

$ make test WHAT=nonexist
+++ [0228 12:33:53] Set GOMAXPROCS automatically to 6
+++ [0228 12:33:53] Running tests without code coverage and with -race
stat /home/thockin/src/kubernetes/nonexist: directory not found
make: *** [Makefile:190: test] Error 1
```
2024-02-29 22:07:43 -08:00
Tim Hockin
81ba0f3b44
Make golang::setup-env turn on workspaces
Both GO111MODULE and GOWORK default to on, so this just unsets them.  We
could set them to explicit values but this seems equivalent and cleaner.
2024-02-29 22:07:42 -08:00
Tim Hockin
2e2ae029c3
Fix instrumentation tests
1) Fail if we can't read critical env vars
2) Don't rely on KUBE_ROOT env var when `go list` works
3) Don't rely on GOOS env var when `go env` works
4) Don't quietly ignore "can't read" errors

Once we stop ignoring errors, some tests fail for real (and should
always have failed).

The "Imported k8s.io/staging constant" test seems to not be allowed at
all anymore.  Han said to nix it and he'd look async.

Oversall this test is dodgy.  You REALLY can't glue strings together and
expect valid Go module paths.  We should consider a deeper rework.
2024-02-29 22:07:41 -08:00
Tim Hockin
706c88863f
Use go 1.22 for KMS mock 2024-02-29 22:07:40 -08:00
Tim Hockin
812d5fff40
Remove old gengo detritus 2024-02-29 22:07:39 -08:00
Tim Hockin
16c26b22cb
Run latest openapi generation 2024-02-29 22:07:38 -08:00
Tim Hockin
d6cf98f8ac
Remove errant +required with no validation code 2024-02-29 22:07:37 -08:00
Tim Hockin
1a4450f6ff
Get rid of code-generator/cmd/openapi-gen
It's an exact duplicate of k8s.io/kube-openapi/cmd/openapi-gen.
2024-02-29 22:07:37 -08:00
Tim Hockin
067a328284
Move import-boss: k/code-generator/cmd -> k/k/cmd 2024-02-29 22:07:36 -08:00
Tim Hockin
7776496309
EOL code-generator/generate-groups scripts
There's no easy way to make it work in the new model.  Callers add flags
to the commandline like:

```
"${CODEGEN_PKG}/generate-internal-groups.sh" "client,conversion,deepcopy,defaulter,informer,lister,openapi" \
  k8s.io/code-generator/examples/apiserver \
  k8s.io/code-generator/examples/apiserver/apis \
  k8s.io/code-generator/examples/apiserver/apis \
  "example:v1 example2:v1 example3.io:v1" \
  --output-base "${SCRIPT_DIR}/../../../.." \
  --go-header-file "${SCRIPT_DIR}/boilerplate.go.txt"
```

To support this we would need to parse these flags in these scripts and
try to adapt them to the new CLI tool interfaces.  Not impossible, but
seeing as we deprecated these a few releases ago AND that we have other
breaking changes to the tools, let's just rip this bandaid off?
2024-02-29 22:07:35 -08:00
Tim Hockin
9cf189f4e0
Fix lint found by golangci-lint 2024-02-29 22:07:34 -08:00
Tim Hockin
14321ef959
Move doc-generation funcs into only caller 2024-02-29 22:07:33 -08:00
Tim Hockin
8288c06b2b
Make hack scripts use go install and assume PATH
Now that they all call setup_env, we don't need find-binary (I think).
That was originally meant to hide the diff between docker and local
builds but all these tools do local builds anyway.
2024-02-29 22:07:32 -08:00
Tim Hockin
ea3696dbcf
Remove legacy references to './output' 2024-02-29 22:07:31 -08:00
Tim Hockin
242b4e27c0
No need to check nil iterating gengo Inputs 2024-02-29 22:07:31 -08:00
Tim Hockin
7a084b3352
Renamed gengo SourcePath -> Dir 2024-02-29 22:07:30 -08:00
Tim Hockin
96b91f364a
Renamed gengo Builder -> Parser 2024-02-29 22:07:29 -08:00
Tim Hockin
cb86010d20
Gengo utils moved 2024-02-29 22:07:28 -08:00
Tim Hockin
236ce54aa8
The gengo "args" package is gone 2024-02-29 22:07:27 -08:00
Tim Hockin
b40e4d7e70
Get rid of gengo CustomArgs 2024-02-29 22:07:26 -08:00
Tim Hockin
86d2ecbf9a
Move gengo/examples/defaulter -> code_generator
This includes tests, which all pass.  Also fixes a bunch of lint.
2024-02-29 22:07:25 -08:00
Tim Hockin
cb7f0593ae
Move gengo/examples/deepcopy -> code_generator
Merge comments in main.go and fix a bunch of pre-existing lint errors.
2024-02-29 22:07:24 -08:00
Tim Hockin
01a1865934
Fix lint in code-generator/cmd/...
Later commits touch code around here, which triggers verify.  This
commit JUST fixes lint.
2024-02-29 22:07:24 -08:00
Tim Hockin
b68340e5b6
Get rid of gengo InputDirs flag 2024-02-29 22:07:23 -08:00
Tim Hockin
299b045307
codegen: Remove most uses of InputDirs
This clears the path to getting rid of it completely.
2024-02-29 22:07:22 -08:00
Tim Hockin
e78dc86288
Move import-boss to k/k, retool to not use gengo
* Moved code and tests out of gengo -> code_generator
* Reworked it to use packages.Load
* Reworked tests (still not comprehensive but pretty good?)
* Dropped test support from gengo (support for tests in
  x/tools/go/packages is pretty hostile to gengo, and nobody used it)
2024-02-29 22:07:21 -08:00
Tim Hockin
08ce6a0f14
Get rid of gengo WithoutDefaultFlagParsing 2024-02-29 22:07:20 -08:00
Tim Hockin
5b2d4384c7
codegen: Make import-boss do it's own flags 2024-02-29 22:07:19 -08:00
Tim Hockin
1fed36b984
codegen: Minor: fix wrong comments 2024-02-29 22:07:18 -08:00
Tim Hockin
6420e64662
Move go-header-file flag to each tool
Also remove the build-tag flag (unused, untested).

This changes some output comments (less redundant).
2024-02-29 22:07:17 -08:00
Tim Hockin
3a77592b2c
Remove gengo verify-only - unused and untested
All of our own tools emit into a tmp tree and then diff that.
2024-02-29 22:07:17 -08:00
Tim Hockin
d0dd72b01e
Move OutputFileBase flag to each tool 2024-02-29 22:07:16 -08:00
Tim Hockin
26a1a13b80
Rename output-package -> output-pkg
To parallel "output-dir".
2024-02-29 22:07:15 -08:00
Tim Hockin
6a375b8f4c
Move the OutputBase flag to each tool
...and rename to --output-dir
2024-02-29 22:07:14 -08:00
Tim Hockin
875566f997
Type-assert gengo CustomArgs blindly
If it does fail, it is catastophic.  Don't bother trying to handle it.
2024-02-29 22:07:13 -08:00
Tim Hockin
0ff7dd1943
Rename gengo DefaultGen -> GolangGenerator 2024-02-29 22:07:12 -08:00
Tim Hockin
2ac119bea9
Rename gengo Target.SourcePath() -> Dir() 2024-02-29 22:07:11 -08:00
Tim Hockin
fcd6c19c24
Rename gengo generator.Package -> Target 2024-02-29 22:07:10 -08:00
Tim Hockin
d2c7401910
Drop generator.Packages type 2024-02-29 22:07:10 -08:00
Tim Hockin
b2832697d5
Rename DefaultPackage to SimplePackage 2024-02-29 22:07:09 -08:00
Tim Hockin
bd31265d23
Make update-vendor log the go env 2024-02-29 22:07:08 -08:00
Tim Hockin
4627a15ac0
Get rid of vendor baggage in go-to-proto 2024-02-29 22:07:07 -08:00
Tim Hockin
4320631265
codegen: Don't need to pass --logtostderr
All the tools already set it internally
2024-02-29 22:07:06 -08:00
Tim Hockin
2c0da11c0a
Make verify-shellcheck take optional args 2024-02-29 22:07:05 -08:00
Tim Hockin
19b37f046f
Rename update-generated-* dockerized
Now they don't start with "update" and confuse dumb scripts which try to
run all the updates.
2024-02-29 22:07:04 -08:00
Tim Hockin
94b709c0e2
codegen: Use single-dash for '-v' 2024-02-29 22:07:04 -08:00