Skip to content

Commit baea4cc

Browse files
committed
Remove warning on drop permission for non-existed role for hasura.
1 parent 8d89719 commit baea4cc

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

hasura/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ func (api *API) DropSelectPermissions(ctx context.Context, table, source string,
220220
"source": source,
221221
},
222222
}
223+
223224
return api.post(ctx, "/v1/metadata", nil, req, nil)
224225
}
225226

hasura/error.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ func (e APIError) Error() string {
3232
func (e APIError) AlreadyExists() bool {
3333
return e.Code == "already-exists"
3434
}
35+
36+
// PermissionDenied -
37+
func (e APIError) PermissionDenied() bool {
38+
return e.Code == "permission-denied"
39+
}

hasura/hasura.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ func Create(ctx context.Context, args GenerateArgs) error {
128128
}
129129
}
130130
if err := api.DropSelectPermissions(ctx, args.Views[i], args.Config.Source.Name, args.Config.UnauthorizedRole); err != nil {
131-
log.Warn().Err(err).Msg("")
131+
if e, ok := err.(APIError); !ok || !e.PermissionDenied() {
132+
log.Warn().Err(err).Msg("")
133+
}
132134
}
133135
if err := api.CreateSelectPermissions(ctx, args.Views[i], args.Config.Source.Name, args.Config.UnauthorizedRole, Permission{
134136
Limit: args.Config.RowsLimit,

0 commit comments

Comments
 (0)