-
Notifications
You must be signed in to change notification settings - Fork 6
automation and filedescriptorset usage #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d121f44
add a service generator for build.rs sanity
clux 9a31740
move scripts into something that tracks script dependencies
clux 80289eb
attempts to make servicegenerator work
clux 1350ff7
drop servicegenerater and use fds to inject into files
clux 36d8889
Use `jq` to patch `swagger.json`
kazk fdea2e9
Add `fd` to build dependencies list
kazk 6c85ca6
force build.rs to rebuild all on just build for now
clux 159d347
some attempts at a rudimentary matching with api-resources
clux 61baaa4
move build.rs into a codegen crate
clux e9815c3
Add `spec`, `status`, `condition` for new traits
kazk c19076f
Add `metadata` type
kazk 0fdf919
Add `subresources`
kazk a932174
Merge subresources into parent
kazk 955920a
Transform to map of proto path to resource infos
kazk 582b9f1
Sort resources by key
kazk 89a574f
Use more consistent formatting and add comments
kazk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/target | ||
Cargo.lock | ||
protos.fds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,6 @@ | ||
[package] | ||
name = "k8s-pb" | ||
version = "0.1.0" | ||
license = "Apache-2.0" | ||
edition = "2018" | ||
|
||
[dependencies] | ||
bytes = "1.0.1" | ||
prost = "0.8.0" | ||
prost-types = "0.8" | ||
|
||
[build-dependencies] | ||
prost-build = "0.8.0" | ||
[workspace] | ||
default-members = ["k8s-pb"] | ||
members = [ | ||
"k8s-pb-codegen", | ||
"k8s-pb" | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
VERSION := "1.22.0" | ||
|
||
default: | ||
@just --list | ||
|
||
# Download protos schemas from upstream | ||
protos-dl: | ||
#!/usr/bin/env bash | ||
set -exuo pipefail | ||
rm -rf protos && mkdir protos && cd protos | ||
for x in api apimachinery apiextensions-apiserver kube-aggregator metrics; do | ||
mkdir ./$x -p | ||
curl -sSL https://github.com/kubernetes/$x/archive/refs/tags/kubernetes-{{VERSION}}.tar.gz | tar xzf - -C ./$x/ --strip-components=1 | ||
fd -e proto -x sh -c "mkdir -p k8s.io/'{//}'; mv '{}' k8s.io/'{}'" ';' . ./$x | ||
rm -rf ./$x | ||
done | ||
|
||
# Patch protos schemas to fix import paths | ||
protos-patch: | ||
#!/usr/bin/env bash | ||
set -exuo pipefail | ||
fd -e proto -x sd 'k8s\.io\.(.+);' '$1;' {} | ||
fd -e proto -x sd 'import "k8s\.io/(.+)";' 'import "$1";' {} | ||
mv protos/k8s.io/* protos/ | ||
rmdir protos/k8s.io/ | ||
|
||
# Generate protos path list for prost | ||
protos-list: | ||
fd -e proto | sort > protos.list | ||
|
||
# Download and generate all protos dependent files | ||
protos: protos-dl protos-patch protos-list | ||
|
||
# Download swagger | ||
swagger-dl: | ||
#!/usr/bin/env bash | ||
set -exuo pipefail | ||
curl -sSL -o k8s-pb-codegen/openapi/swagger.json \ | ||
https://raw.githubusercontent.com/kubernetes/kubernetes/v{{VERSION}}/api/openapi-spec/swagger.json | ||
|
||
# Patch swagger schema for upstream bugs | ||
swagger-patch: | ||
#!/usr/bin/env bash | ||
set -exuo pipefail | ||
cd k8s-pb-codegen/openapi | ||
jq -f patches/patch-nonexistent-gvk.jq < swagger.json > swagger-patched.json | ||
mv swagger-patched.json swagger.json | ||
|
||
# Transform swagger schema into api-resources.json | ||
swagger-transform: | ||
#!/usr/bin/env bash | ||
set -exuo pipefail | ||
cd k8s-pb-codegen/openapi | ||
jq -f list-resources.jq < swagger.json > api-resources.json | ||
|
||
# Download and generate all swagger dependent files | ||
swagger: swagger-dl swagger-patch swagger-transform | ||
|
||
# Build a FileDescriptorSet for custom code generation | ||
codegen-fds: | ||
#!/usr/bin/env bash | ||
set -exuo pipefail | ||
shopt -s globstar | ||
cd k8s-pb-codegen | ||
protoc \ | ||
--include_imports \ | ||
--include_source_info \ | ||
--descriptor_set_out=protos.fds \ | ||
--proto_path=./protos \ | ||
./protos/**/*.proto | ||
|
||
# Generate the library code from completed swagger and protos | ||
codegen: codegen-fds | ||
#!/usr/bin/env bash | ||
set -exuo pipefail | ||
rm -rf out/ && mkdir out | ||
cd k8s-pb-codegen && cargo run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[package] | ||
name = "k8s-pb-codegen" | ||
version = "0.1.0" | ||
edition = "2018" | ||
license = "Apache-2.0" | ||
|
||
[[bin]] | ||
name = "pbcodegen" | ||
path = "pbcodegen.rs" | ||
|
||
[lib] | ||
name = "pbcodegen" | ||
path = "src/lib.rs" | ||
|
||
[dependencies] | ||
bytes = "1.0.1" | ||
prost = "0.8.0" | ||
prost-build = "0.8.0" | ||
prost-types = "0.8.0" | ||
serde_json = "1.0.67" | ||
serde = { version = "1.0.130", features = ["derive"] } | ||
log = "0.4.14" | ||
anyhow = "1.0.44" | ||
env_logger = "0.9.0" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.