Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nkvuong committed Mar 29, 2023
1 parent 6cb5d5a commit 15f67ba
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions permissions/resource_permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func urlPathForObjectID(objectID string) string {
// permissions when POSTing permissions changes through the REST API, to avoid accidentally
// revoking the calling user's ability to manage the current object.
func (a PermissionsAPI) shouldExplicitlyGrantCallingUserManagePermissions(objectID string) bool {
for _, prefix := range [...]string{"/registered-models/", "/clusters/", "/queries/"} {
for _, prefix := range [...]string{"/registered-models/", "/clusters/", "/queries/", "/sql/warehouses"} {
if strings.HasPrefix(objectID, prefix) {
return true
}
Expand Down Expand Up @@ -174,21 +174,6 @@ func (a PermissionsAPI) Update(objectID string, objectACL AccessControlChangeLis
PermissionLevel: "CAN_MANAGE",
})
}
w, err := a.client.WorkspaceClient()
if err != nil {
return err
}
if strings.HasPrefix(objectID, "/sql/warehouses") {
warehouse, err := w.Warehouses.GetById(a.context, strings.ReplaceAll(objectID, "/sql/warehouses/", ""))
if err != nil {
return err
}
// add CAN_MANAGE permission for creator
objectACL.AccessControlList = append(objectACL.AccessControlList, AccessControlChange{
UserName: warehouse.CreatorName,
PermissionLevel: "CAN_MANAGE",
})
}
if strings.HasPrefix(objectID, "/jobs") || strings.HasPrefix(objectID, "/pipelines") {
owners := 0
for _, acl := range objectACL.AccessControlList {
Expand Down Expand Up @@ -231,11 +216,11 @@ func (a PermissionsAPI) Delete(objectID string) error {
return err
}
if strings.HasPrefix(objectID, "/jobs") {
job_id, err := strconv.ParseInt(strings.ReplaceAll(objectID, "/jobs/", ""), 10, 0)
jobId, err := strconv.ParseInt(strings.ReplaceAll(objectID, "/jobs/", ""), 10, 0)
if err != nil {
return err
}
job, err := w.Jobs.GetByJobId(a.context, job_id)
job, err := w.Jobs.GetByJobId(a.context, jobId)
if err != nil {
return err
}
Expand Down

0 comments on commit 15f67ba

Please sign in to comment.