stackabletech / operator-rs

A simple wrapper/framework around kube-rs to make implementing Operators/Controllers easier
Apache License 2.0
112 stars 11 forks source link

feat(stackable-versioned): Adjust generated module and container names #797

Closed Techassi closed 1 month ago

Techassi commented 2 months ago

Description

Tracked by https://github.com/stackabletech/issues/issues/507, follow-up of #764 and #793

# Reviewer
- [ ] Code contains useful comments
- [ ] (Integration-)Test cases added
- [ ] Documentation added or updated
- [ ] Changelog updated
- [ ] Cargo.toml only contains references to git tags (not specific commits or branches)
Techassi commented 2 months ago

Seems like we currently cannot use the heck crate for case conversions: https://github.com/withoutboats/heck/issues/58.

Techassi commented 2 months ago

The generated code now looks like this:

#[versioned(
    version(name = "v1alpha1"),
    version(name = "v1beta1"),
    version(name = "v1"),
    version(name = "v2"),
    version(name = "v3")
)]
struct Foo {
    /// My docs
    #[versioned(
        added(since = "v1alpha1"),
        renamed(since = "v1beta1", from = "jjj"),
        deprecated(since = "v2", note = "not empty")
    )]
    deprecated_bar: usize,
    baz: bool,
}

// Produces ...

#[automatically_derived]
pub mod foo {
    pub struct V1Alpha1 {
        pub jjj: usize,
        pub baz: bool,
    }
    pub struct V1Beta1 {
        pub bar: usize,
        pub baz: bool,
    }
    pub struct V1 {
        pub bar: usize,
        pub baz: bool,
    }
    pub struct V2 {
        #[deprecated = "not empty"]
        pub deprecated_bar: usize,
        pub baz: bool,
    }
    pub struct V3 {
        // Missing deprecated attribute will be fixed
        pub deprecated_bar: usize,
        pub baz: bool,
    }
}
pub type Foo = foo::V3;
sbernauer commented 2 months ago

I guess we should also take https://github.com/stackabletech/operator-rs/pull/793#issuecomment-2129232150 into consideration

Techassi commented 2 months ago

Putting this PR on hold for now, as some more discussion is happening over at #793.

Techassi commented 1 month ago

A decision in #793 was reached. We will stick with the current naming scheme and thus this PR will be closed.