Replies: 2 comments 1 reply
-
This sounds like a Controller::new(github_repository_api, cfg)
.watches_stream(account_stream, mapper) where |
Beta Was this translation helpful? Give feedback.
-
Maybe I tell more about the use case. Teams have x AWS accounts and y GitHub repositories. Every time a team create a new repository, OIDC must be configured for all team accounts. If a team creates a new account, for all team repositories OIDC must be configured. I came up with: Controller::new(github_repository_api.clone(), Config::default())
.watches_stream(
account_stream,
map_aws_account_to_github_repositories(github_repository_api.clone()),
)
async fn query(api: Api<GitHubRepository>, aws_account: AwsAccount) -> Vec<GitHubRepository> {
let labels = format!("team={}", aws_account.labels().get("team").unwrap());
let list_params = ListParams::default().labels(&labels);
api.list(&list_params).await.unwrap().items
}
fn map_aws_account_to_github_repositories(
api: Api<GitHubRepository>,
) -> impl Fn(AwsAccount) -> Vec<ObjectRef<GitHubRepository>> {
move |aws_account| {
futures::executor::block_on(async { query(api.clone(), aws_account.clone()).await })
.iter()
.map(|repository| ObjectRef::from_obj(repository))
.collect::<Vec<_>>()
}
} But I think my concept is wrong.
|
Beta Was this translation helpful? Give feedback.
-
I have 2 CRDs,
AwsAccount
andGitHubRepository
.The
GitHubRepository
controller must do something for everyAwsAccount
that it is related to it via a label calledteam
. (that's the easy part)But when a team gets a new
AwsAccount
, theGitHubRepository
controller must do something for this new account.I thought the
reconcile_on
is just a trigger, but it sends aAwsAccount
object ref.What is the recommended way to do this? Can I make a query inside the
map_ok
function to get a list of relatedGitHubRepository
s? Or do I need 2 separateGitHubRepository
controllers?Beta Was this translation helpful? Give feedback.
All reactions