-
Notifications
You must be signed in to change notification settings - Fork 6
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
Move codegen to a separate crate and use improved transform #5
Conversation
Signed-off-by: clux <[email protected]>
Signed-off-by: kazk <[email protected]>
Signed-off-by: kazk <[email protected]>
Signed-off-by: kazk <[email protected]>
// TODO `Option<Vec<Subresource>>` | ||
/// Any subresources. | ||
pub subresources: Vec<Subresource>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if !subresources.empty()
vs if let Some(subresources)
. Can change empty array to null
in transform.jq
later if we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, vector probably is fine here 👍
fs::read_to_string(&path).with_context(|| format!("read {}", path.as_ref().display())) | ||
} | ||
|
||
fn main() -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the file to the standard location.
@@ -0,0 +1,48 @@ | |||
pub mod api { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the file that was left in src/lib.rs
and commented out the include!
s.
for m in f.message_type { | ||
if let Some(name) = m.name { | ||
let path = format!("{}.{}", pkg, name); | ||
if let Some(resource) = resources.get(&path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's much easier to load resource info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah that is a lot easier!
Basically a copy of `list-resources.jq` without `verbs` as a map. Should be easier to use for codegen. Signed-off-by: kazk <[email protected]>
Signed-off-by: kazk <[email protected]>
Signed-off-by: kazk <[email protected]>
Signed-off-by: kazk <[email protected]>
@clux Decided to push to a new branch just in case I messed something up while rebasing. This is #1 cleaned up + loading the new
transformed.json
in codegen. Should be much easier for us to work from here.With the new
transform.jq
, Pod looks like this:apiVersion
metadata
type forMetadata
traitspec
type forHasSpec
traitstatus
type forHasStatus
traitcondition
type forHasConditions
traitnamespaced
is true if resource can be namespaced. It can still haveall
verbs likelist
.