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

Add volumecontext package for accessing volume context from CSI #340

Merged
merged 2 commits into from
Jan 14, 2025

Conversation

unexge
Copy link
Contributor

@unexge unexge commented Jan 14, 2025

Splitted out of #328.

This might not make sense since it's moved out of its original context, but the original motivation was that these constants was spread out to different packages and that was causing circular dependencies.

For example, if you need to use VolumeCtxBucketName in pkg/driver/node/mounter package, you'd need to import pkg/driver/node package which would cause a circular dependency as pkg/driver/node imports pkg/driver/node/mounter. In situations like that, it's best to extract common things into a leaf package that doesn't import anything, which is what this PR does with pkg/driver/node/volumecontext package.

It also makes finding these volume context keys easier by placing them into a singular place.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

muddyfish
muddyfish previously approved these changes Jan 14, 2025
@@ -96,7 +89,7 @@ func (c *CredentialProvider) Provide(ctx context.Context, volumeID string, volum
return nil, status.Error(codes.InvalidArgument, "Missing volume context")
}

authenticationSource := volumeContext[VolumeCtxAuthenticationSource]
authenticationSource := volumeContext[volumecontext.AuthenticationSource]
Copy link
Contributor

Choose a reason for hiding this comment

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

Not blocking: The only difference here being capitalisation makes this more challenging to read at first glance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can rename variables to volumeCtx, to have similar naming convention to built-in context package and ctx variable used widely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed with 5da88fc

This is to have same naming convention with built-in `context` package
and `ctx` variable name used widely.

Updated with `sg --pattern 'volumeContext' --rewrite 'volumeCtx' --lang go`.

Signed-off-by: Burak Varlı <[email protected]>
@unexge unexge merged commit 8c65618 into main Jan 14, 2025
23 of 24 checks passed
@unexge unexge deleted the unexge/add-volumectx-package branch January 14, 2025 19:08
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.

2 participants