Skip to content

Commit

Permalink
feat: map strings to UUIDs (#809) (#840)
Browse files Browse the repository at this point in the history
With this change Keto now maps strings to UUIDv5 on the storage layer. This change allows unlimited strings to be used while maintaining good performance. Further, it reduces the likeliness of database hot-spots.
The migration that applies this mapping might take some time, so please confirm that your migration strategy works for you.

BREAKING CHANGE: `keto namespace migrate ...` commands were removed. To migrate from v0.6.0-alpha.1, please first migrate the legacy namespaces using v0.8.0-alpha.2
BREAKING CHANGE: The protobuf API was bumped to `v1alpha2`. Please upgrade your client dependency to that version. `v1alpha1` is still supported for now, but might be dropped soon.
BREAKING CHANGE: Some payload keys are now (not) required anymore. The generated SDKs will likely have breaking changes.

Co-authored-by: Patrik <zepatrik@users.noreply.github.com>
Co-authored-by: hperl <34397+hperl@users.noreply.github.com>
  • Loading branch information
zepatrik and hperl committed Jul 27, 2022
1 parent d1cb2ae commit add6577
Show file tree
Hide file tree
Showing 154 changed files with 6,211 additions and 5,336 deletions.
74 changes: 0 additions & 74 deletions .bin/formula-pins/protobuf@3.19.rb

This file was deleted.

6 changes: 4 additions & 2 deletions Makefile
Expand Up @@ -11,8 +11,7 @@ GO_DEPENDENCIES = golang.org/x/tools/cmd/goimports \
google.golang.org/grpc/cmd/protoc-gen-go-grpc \
github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc

BREW_DEPENDENCIES = protobuf@3.19 \
go-swagger@0.29.0 \
BREW_DEPENDENCIES = go-swagger@0.29.0 \
grype@0.40.1 \
cli@0.1.35 \
yq@4 \
Expand All @@ -31,6 +30,9 @@ define make-brew-dependency
endef
$(foreach dep, $(BREW_DEPENDENCIES), $(eval $(call make-brew-dependency,$(dep))))

tools/protobuf: tools/brew Makefile
HOMEBREW_NO_AUTO_UPDATE=1 brew install protobuf@3.19

node_modules: package.json package-lock.json Makefile
npm ci

Expand Down
10 changes: 5 additions & 5 deletions cmd/expand/root.go
Expand Up @@ -3,6 +3,8 @@ package expand
import (
"fmt"

"github.com/ory/keto/ketoapi"

rts "github.com/ory/keto/proto/ory/keto/relation_tuples/v1alpha2"

"github.com/ory/x/flagx"
Expand All @@ -11,7 +13,6 @@ import (
"github.com/spf13/cobra"

"github.com/ory/keto/cmd/client"
"github.com/ory/keto/internal/expand"
)

const FlagMaxDepth = "max-depth"
Expand Down Expand Up @@ -44,10 +45,9 @@ func NewExpandCmd() *cobra.Command {
return cmdx.FailSilently(cmd)
}

tree, err := expand.TreeFromProto(resp.Tree)
if err != nil {
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "Error building the tree: %s\n", err.Error())
return cmdx.FailSilently(cmd)
var tree *ketoapi.ExpandTree
if resp.Tree != nil {
tree = (&ketoapi.ExpandTree{}).FromProto(resp.Tree)
}

cmdx.PrintJSONAble(cmd, tree)
Expand Down
7 changes: 4 additions & 3 deletions cmd/migrate/migrate_test.go
Expand Up @@ -38,11 +38,9 @@ func TestMigrate(t *testing.T) {
nspaces := []*namespace.Namespace{
{
Name: "default",
ID: 0,
},
{
Name: "other",
ID: 1,
},
}

Expand Down Expand Up @@ -160,7 +158,10 @@ func TestUpAndDown(t *testing.T) {
for _, dsn := range dbx.GetDSNs(t, debugOnDisk) {
dsn := dsn
t.Run("dsn="+dsn.Name, func(t *testing.T) {
cf := dbx.ConfigFile(t, map[string]interface{}{config.KeyDSN: dsn.Conn})
cf := dbx.ConfigFile(t, map[string]interface{}{
config.KeyDSN: dsn.Conn,
config.KeyNamespaces: []*namespace.Namespace{},
})

t.Log(cmd.ExecNoErr(t, "up", "-c", cf, "--"+FlagYes))
t.Log(cmd.ExecNoErr(t, "down", "0", "-c", cf, "--"+FlagYes))
Expand Down
115 changes: 0 additions & 115 deletions cmd/namespace/migrate_legacy.go

This file was deleted.

Binary file removed cmd/namespace/migrate_legacy_snapshot.sqlite
Binary file not shown.
94 changes: 0 additions & 94 deletions cmd/namespace/migrate_legacy_test.go

This file was deleted.

4 changes: 2 additions & 2 deletions cmd/namespace/root.go
Expand Up @@ -24,10 +24,10 @@ func NewMigrateCmd() *cobra.Command {
}
}

func RegisterCommandsRecursive(parent *cobra.Command, opts []ketoctx.Option) {
func RegisterCommandsRecursive(parent *cobra.Command, _ []ketoctx.Option) {
rootCmd := NewNamespaceCmd()
migrateCmd := NewMigrateCmd()
migrateCmd.AddCommand(NewMigrateUpCmd(), NewMigrateDownCmd(), NewMigrateStatusCmd(), NewMigrateLegacyCmd(opts))
migrateCmd.AddCommand(NewMigrateUpCmd(), NewMigrateDownCmd(), NewMigrateStatusCmd())

rootCmd.AddCommand(migrateCmd, NewValidateCmd())

Expand Down

0 comments on commit add6577

Please sign in to comment.