Skip to content
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

Set status explicitly in the kube tag #34

Merged
merged 1 commit into from
Feb 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Set status explicitly in the kube tag
Without this, the status data won't be accessible through the generated struct

fixes #4

Signed-off-by: Flavio Percoco <flaper87@gmail.com>
  • Loading branch information
flaper87 committed Feb 16, 2022
commit 3ad785733edc0fecb329b9d89aaac82711f78365
19 changes: 12 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{anyhow, Result};
use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1::{
CustomResourceDefinition, CustomResourceDefinitionVersion,
CustomResourceDefinition, CustomResourceDefinitionVersion, CustomResourceSubresources,
};
use kopium::{analyze, OutputStruct};
use kube::{api, core::Version, Api, Client, ResourceExt};
Expand Down Expand Up @@ -134,12 +134,12 @@ impl Kopium {
.schema
.as_ref()
.and_then(|schema| schema.open_api_v3_schema.clone());
let version = version.name.clone();
let version_name = version.name.clone();

let kind = crd.spec.names.kind;
let plural = crd.spec.names.plural;
let group = crd.spec.group;
let scope = crd.spec.scope;
let kind = &crd.spec.names.kind;
let plural = &crd.spec.names.plural;
let group = &crd.spec.group;
let scope = &crd.spec.scope;

if let Some(schema) = data {
let mut structs = vec![];
Expand All @@ -159,11 +159,16 @@ impl Kopium {
self.print_derives();
println!(
r#"#[kube(group = "{}", version = "{}", kind = "{}", plural = "{}")]"#,
group, version, kind, plural
group, version_name, kind, plural
);
if scope == "Namespaced" {
println!(r#"#[kube(namespaced)]"#);
}

if let Some(CustomResourceSubresources { status: Some(_), .. }) = version.subresources
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah that is a nice pattern match 👍

{
println!(r#"#[kube(status = "{}Status")]"#, kind);
}
// don't support grabbing original schema atm so disable schemas:
// (we coerce IntToString to String anyway so it wont match anyway)
println!(r#"#[kube(schema = "disabled")]"#);
Expand Down