Skip to content

Dynamic Api for ownerReferences #1783

Answered by mhutter
mhutter asked this question in Q&A
Discussion options

You must be logged in to vote

Ah, I figured it out:

First, since the only thing that prompted me to use that DynamicType = () bound in the first place was determining the object's kind, so I moved that to a separate trait:

trait GetKind {
    fn kind(&self) -> String;
}

impl GetKind for Pod {
    fn kind(&self) -> String {
        <Pod as Resource>::kind(&()).to_string()
    }
}

impl GetKind for DynamicObject {
    fn kind(&self) -> String {
        self.types.as_ref().unwrap().kind.clone()
    }
}

I tried making it more generic but got conflicting implementations, so I just implemented it for concrete types I knew I was gonna need.

Next, generic resources can be queried using Discovery and DynamicObject:

async fn o…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by mhutter
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants