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

Serviceaccount token synchronization #139

Merged

Conversation

galal-hussein
Copy link
Collaborator

@galal-hussein galal-hussein commented Nov 6, 2024

k3k-kubelet/provider/provider.go Show resolved Hide resolved
k3k-kubelet/provider/provider.go Show resolved Hide resolved
k3k-kubelet/provider/token.go Outdated Show resolved Hide resolved
Signed-off-by: galal-hussein <[email protected]>
Signed-off-by: galal-hussein <[email protected]>
@galal-hussein galal-hussein force-pushed the service_account_token_sync branch from 5f4fd2e to f728c73 Compare November 7, 2024 16:18
k3k-kubelet/main.go Outdated Show resolved Hide resolved
Signed-off-by: galal-hussein <[email protected]>
Comment on lines 263 to +275
if volume.ConfigMap != nil {
if err := p.syncConfigmap(ctx, podNamespace, volume.ConfigMap.Name); err != nil {
if volume.ConfigMap.Optional != nil {
optional = *volume.ConfigMap.Optional
}
if err := p.syncConfigmap(ctx, podNamespace, volume.ConfigMap.Name, optional); err != nil {
return fmt.Errorf("unable to sync configmap volume %s: %w", volume.Name, err)
}
volume.ConfigMap.Name = p.Translater.TranslateName(podNamespace, volume.ConfigMap.Name)
} else if volume.Secret != nil {
if err := p.syncSecret(ctx, podNamespace, volume.Secret.SecretName); err != nil {
if volume.Secret.Optional != nil {
optional = *volume.Secret.Optional
}
if err := p.syncSecret(ctx, podNamespace, volume.Secret.SecretName, optional); err != nil {
Copy link
Collaborator

@enrichman enrichman Nov 7, 2024

Choose a reason for hiding this comment

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

Imho the code will look more readable changing the structure to have less branches, and passing the struct to the syncXXX funcs. Something like:

if volume.ConfigMap != nil {
	if err := p.syncConfigmap(ctx, podNamespace, *volume.ConfigMap); err != nil {
		return fmt.Errorf("unable to sync configmap volume %s: %w", volume.Name, err)
	}
	volume.ConfigMap.Name = p.Translater.TranslateName(podNamespace, volume.ConfigMap.Name)
	continue
}

if volume.Secret != nil {
	// same
}

What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that makes sense, fixing and testing now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hmmm, I think why Michael didnt want to do that in the first place, simply because there are 2 types of volumes , there is simple configmap and projection configmap, which are two different types, thats why he only sent the names and not the whole object, that said Michael wanted to make the syncer more generic anyway, so I think we can merge for now and for future iteration we can conver the whole syncer to a more generic functions to accept any type of object

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I've just realized that. :/

Kinda annoying but I agree, thanks anyway! 👍

@galal-hussein galal-hussein merged commit bc25c1c into rancher:main Nov 7, 2024
1 check passed
briandowns pushed a commit to briandowns/k3k that referenced this pull request Dec 4, 2024
* Serviceaccount token sync

Signed-off-by: galal-hussein <[email protected]>

* fixes

Signed-off-by: galal-hussein <[email protected]>

* fixing typo

Signed-off-by: galal-hussein <[email protected]>

---------

Signed-off-by: galal-hussein <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants