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 public psuedo role to resource grant #524

Merged
merged 1 commit into from
Mar 28, 2024
Merged

Conversation

bobbyiliev
Copy link
Contributor

It looks like that we used to be generating the following:

GRANT USAGE ON CLUSTER "example_cluster" TO "PUBLIC";
ERROR:  unknown role 'PUBLIC'

This PR checks if the role is PUBLIC and if so, it does not quote it.

@bobbyiliev bobbyiliev requested a review from a team as a code owner March 27, 2024 19:10
@bobbyiliev bobbyiliev requested review from SangJunBak, benesch and a team and removed request for a team March 27, 2024 19:10
Comment on lines 133 to 140
func (b *MaterializeRole) QualifiedName() string {
// If role name is PUBLIC, it should not be quoted as it is a pseudo-role
if b.name == "PUBLIC" {
return b.name
}
return QualifiedName(b.name)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is essentially the main change, the rest is just tests.

Copy link

@SangJunBak SangJunBak left a comment

Choose a reason for hiding this comment

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

LGTM

pp := `WHERE mz_clusters.id = 'u1'`
testhelpers.MockClusterScan(mock, pp)

if err := grantClusterCreate(context.TODO(), d, db); err != nil {

Choose a reason for hiding this comment

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

Out of curiosity, what does context.TODO() do here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Jun 🙌

The context.TODO() returns a non-nil, empty Context. It is just used as a placeholder.

Copy link
Member

@benesch benesch left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@bobbyiliev bobbyiliev merged commit b5895c0 into main Mar 28, 2024
6 checks passed
@bobbyiliev bobbyiliev deleted the Add-PUBLIC-psuedo-role branch March 28, 2024 08:50
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