Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #435 from kazk/refactor-derive-with-darling
Refactor kube-derive using darling
- Loading branch information
Showing
10 changed files
with
386 additions
and
472 deletions.
There are no files selected for viewing
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 contains 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,10 @@ | ||
// Test that `kube-derive` outputs helpful error messages. | ||
// If you make a change, remove `tests/ui/*.stderr` and run `cargo test`. | ||
// Then copy the files that appear under `wip/` if it's what you expected. | ||
// Alternatively, run `TRYBUILD=overwrite cargo test`. | ||
// See https://github.com/dtolnay/trybuild | ||
#[test] | ||
fn test_failures() { | ||
let t = trybuild::TestCases::new(); | ||
t.compile_fail("tests/ui/*.rs"); | ||
} |
This file contains 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,10 @@ | ||
use kube_derive::CustomResource; | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(CustomResource, Serialize, Deserialize, Debug, Clone, JsonSchema)] | ||
enum FooSpec { | ||
Foo, | ||
} | ||
|
||
fn main() {} |
This file contains 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,5 @@ | ||
error: Enums or Unions can not #[derive(CustomResource)] | ||
--> $DIR/enum_fails.rs:6:6 | ||
| | ||
6 | enum FooSpec { | ||
| ^^^^^^^ |
This file contains 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,11 @@ | ||
use kube_derive::CustomResource; | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(CustomResource, Serialize, Deserialize, Debug, Clone, JsonSchema)] | ||
#[kube(group = "clux.dev", version = "v1", kind = "Foo", shortnames = "foo")] | ||
struct FooSpec { | ||
foo: String, | ||
} | ||
|
||
fn main() {} |
This file contains 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,5 @@ | ||
error: Unknown field: `shortnames`. Did you mean `shortname`? | ||
--> $DIR/fail_with_suggestion.rs:6:58 | ||
| | ||
6 | #[kube(group = "clux.dev", version = "v1", kind = "Foo", shortnames = "foo")] | ||
| ^^^^^^^^^^ |
This file contains 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,10 @@ | ||
use kube_derive::CustomResource; | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(CustomResource, Serialize, Deserialize, Debug, Clone, JsonSchema)] | ||
struct FooSpec { | ||
foo: String, | ||
} | ||
|
||
fn main() {} |
This file contains 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,23 @@ | ||
error: Missing field `group` | ||
--> $DIR/missing_required.rs:5:10 | ||
| | ||
5 | #[derive(CustomResource, Serialize, Deserialize, Debug, Clone, JsonSchema)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: Missing field `version` | ||
--> $DIR/missing_required.rs:5:10 | ||
| | ||
5 | #[derive(CustomResource, Serialize, Deserialize, Debug, Clone, JsonSchema)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: Missing field `kind` | ||
--> $DIR/missing_required.rs:5:10 | ||
| | ||
5 | #[derive(CustomResource, Serialize, Deserialize, Debug, Clone, JsonSchema)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) |