Some checks failed
CI / Run lints and checks (push) Failing after 47s
CI / Run tests (push) Failing after 1s
CI / Run race tests (push) Failing after 5s
CI / Build CLI docs (push) Has been skipped
CI / Run buf actions (push) Failing after 5s
CodeQL / Analyze (go) (push) Failing after 3s
CodeQL / Analyze (javascript) (push) Failing after 2s
Docker Image Scanners / scanners (push) Failing after 3s
Format / format (push) Failing after 3s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Draft newsletter (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
// Copyright © 2023 Ory Corp
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package relationtuple
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
rts "github.com/ory/keto/gen/go/ory/keto/relation_tuples/v1alpha2"
|
|
)
|
|
|
|
const FlagFile = "file"
|
|
|
|
func NewCreateCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "create <subject_namespace>:<subject_id> <relation> <object_namespace>:<object_id>",
|
|
Short: "Create relationship tuples from inline arguments or JSON files and folders",
|
|
Long: `Create relationship tuples from inline arguments or JSON files and folders.
|
|
Inline example:
|
|
keto relation-tuple create User:alice owner Doc:readme
|
|
|
|
From file or folder:
|
|
keto relation-tuple create -f relationships1.json -f relationships2.json
|
|
keto relation-tuple create -f relationships-dir1 -f relationships-dir2
|
|
|
|
If a directory is provided, all JSON files inside it are processed.
|
|
Use '-' as filename to read from STD_IN:
|
|
keto relation-tuple create -f -`,
|
|
Args: cobra.ArbitraryArgs,
|
|
RunE: transactTuples(rts.RelationTupleDelta_ACTION_INSERT),
|
|
}
|
|
|
|
registerFileFlag(cmd.Flags())
|
|
registerPackageFlags(cmd.Flags())
|
|
|
|
return cmd
|
|
}
|