-
Notifications
You must be signed in to change notification settings - Fork 35
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
feat: schema generator #31
Conversation
remove slug from actions and namepaces
add namespaceId to roles and actions
internal/authz/spicedb/spicedb.go
Outdated
|
||
func (p *Policy) AddPolicy(schema string) error { | ||
request := &pb.WriteSchemaRequest{Schema: schema} | ||
_, err := p.client.WriteSchema(context.Background(), request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets pass ctx ?
return transformedPolicies, nil | ||
} | ||
|
||
func (s Store) CreatePolicy(ctx context.Context, policyToCreate model.Policy) ([]model.Policy, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets try for txn in near future
return s.fetchNamespacePolicies(ctx, newPolicy.NamespaceID) | ||
} | ||
|
||
func (s Store) UpdatePolicy(ctx context.Context, id string, toUpdate model.Policy) ([]model.Policy, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets try for txn in near future
store/postgres/policy.go
Outdated
func (s Store) fetchNamespacePolicies(ctx context.Context, namespaceId string) ([]model.Policy, error) { | ||
var fetchedPolicies []Policy | ||
|
||
query := fmt.Sprintf("%s %s", listPolicyQuery, fmt.Sprintf("WHERE p.namespace_id='%s'", namespaceId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WHERE p.namespace_id='%s'
-> WHERE p.namespace_id='$1'
store/postgres/roles.go
Outdated
getRoleQuery = `SELECT id, name, types, namespace, metadata, created_at, updated_at from roles where id=$1;` | ||
listRolesQuery = `SELECT id, name, types, namespace, metadata, created_at, updated_at from roles;` | ||
updateRoleQuery = `UPDATE roles SET name = $2, types = $3, namespace = $4, metadata = $5, updated_at = now() where id = $1;` | ||
createRoleQuery = `INSERT into roles(id, name, types, namespace_id, namespac, metadata) values($1, $2, $3, $4, $4, $5) RETURNING id, name, types, namespace_id, metadata, created_at, updated_at;` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets fix the typo
func (s Store) fetchNamespacePolicies(ctx context.Context, namespaceId string) ([]model.Policy, error) { | ||
var fetchedPolicies []Policy | ||
|
||
query := fmt.Sprintf("%s %s", listPolicyQuery, "WHERE p.namespace_id='$1'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pgx does it - '$1'
-> $1
No description provided.