Tim Hockin
812d5fff40
Remove old gengo detritus
2024-02-29 22:07:39 -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
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
4627a15ac0
Get rid of vendor baggage in go-to-proto
2024-02-29 22:07:07 -08:00
Tim Hockin
dd4e456875
codegen:proto: Use revised API to gengo parser
2024-02-29 22:07:03 -08:00
Tim Hockin
4b55936ab0
Remove defunct trim-path-prefix
2024-02-29 22:07:02 -08:00
Tim Hockin
2348e94908
Conversion: Better logging
2024-02-29 22:07:01 -08:00
Tim Hockin
e84adf611f
Remove references to "GO111MODULE"
2024-02-29 22:06:55 -08:00
Tim Hockin
d772f7719d
Remove defunct references to "vendor"
2024-02-29 22:06:52 -08:00
Tim Hockin
7f5982e708
code-generator: Remove now unused helper function
2024-02-29 22:06:51 -08:00
Tim Hockin
10c32b3e2f
Get rid of most references to GOPATH
2024-02-29 22:06:51 -08:00
Tim Hockin
91efe7e571
Fix import-boss wrt gengo/v2
2024-02-29 22:06:40 -08:00
Tim Hockin
c8b61bb98b
Fix register-gen wrt gengo/v2
2024-02-29 22:06:39 -08:00
Tim Hockin
f772410082
Make code-gen subprojects 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
b961b39efa
Fix client-gen wrt gengo/v2
2024-02-29 22:06:35 -08:00
Tim Hockin
5ddd6772a4
Fix applyconfiguration-gen wrt gengo/v2
2024-02-29 22:06:33 -08:00
Tim Hockin
0aa98ee8e3
Fix informer-gen wrt 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
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