Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cmd/cloudx/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"testing"
"time"

"github.com/ory/cli/cmd"

"github.com/pquerna/otp/totp"
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/ory/cli/cmd/cloudx"
"github.com/ory/cli/cmd/cloudx/client"
"github.com/ory/cli/cmd/cloudx/testhelpers"
cloud "github.com/ory/client-go"
Expand All @@ -23,9 +23,9 @@ func TestAuthenticator(t *testing.T) {
configDir := testhelpers.NewConfigDir(t)

t.Run("errors without config and --quiet flag", func(t *testing.T) {
cmd := cloudx.NewRootCommand(new(cobra.Command), "", "")
cmd.SetArgs([]string{"auth", "--" + client.ConfigFlag, configDir, "--quiet"})
require.Error(t, cmd.Execute())
c := cmd.NewRootCmd()
c.SetArgs([]string{"auth", "--" + client.ConfigFlag, configDir, "--quiet"})
require.Error(t, c.Execute())
})

password := testhelpers.FakePassword()
Expand Down
9 changes: 6 additions & 3 deletions cmd/cloudx/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ func NewCreateCmd() *cobra.Command {
Use: "create",
Short: "Create Ory Cloud resources",
}
cmd.AddCommand(project.NewCreateProjectCmd())
cmd.AddCommand(oauth2.NewCreateOAuth2Client(cmd))
cmd.AddCommand(relationtuples.NewCreateCmd())
cmd.AddCommand(
project.NewCreateProjectCmd(),
oauth2.NewCreateOAuth2Client(),
relationtuples.NewCreateCmd(),
oauth2.NewCreateJWK(),
)

client.RegisterConfigFlag(cmd.PersistentFlags())
client.RegisterYesFlag(cmd.PersistentFlags())
Expand Down
12 changes: 8 additions & 4 deletions cmd/cloudx/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ import (
"github.com/ory/x/cmdx"
)

func NewDeleteCmd(parent *cobra.Command) *cobra.Command {
func NewDeleteCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "delete",
Short: "Delete resources",
}

cmd.AddCommand(identity.NewDeleteIdentityCmd(parent))
cmd.AddCommand(oauth2.NewDeleteOAuth2Cmd(parent))
cmd.AddCommand(relationtuples.NewDeleteCmd())
cmd.AddCommand(
identity.NewDeleteIdentityCmd(),
oauth2.NewDeleteOAuth2Client(),
oauth2.NewDeleteJWKs(),
oauth2.NewDeleteAccessTokens(),
relationtuples.NewDeleteCmd(),
)

client.RegisterConfigFlag(cmd.PersistentFlags())
client.RegisterYesFlag(cmd.PersistentFlags())
Expand Down
7 changes: 4 additions & 3 deletions cmd/cloudx/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/ory/x/cmdx"
)

func NewGetCmd(parent *cobra.Command) *cobra.Command {
func NewGetCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "get",
Short: "Get a resource",
Expand All @@ -22,8 +22,9 @@ func NewGetCmd(parent *cobra.Command) *cobra.Command {
project.NewGetKratosConfigCmd(),
project.NewGetKetoConfigCmd(),
project.NewGetOAuth2ConfigCmd(),
identity.NewGetIdentityCmd(parent),
oauth2.NewGetOAuth2Client(parent),
identity.NewGetIdentityCmd(),
oauth2.NewGetOAuth2Client(),
oauth2.NewGetJWK(),
)

client.RegisterConfigFlag(cmd.PersistentFlags())
Expand Down
4 changes: 2 additions & 2 deletions cmd/cloudx/identity/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/ory/x/cmdx"
)

func NewDeleteIdentityCmd(parent *cobra.Command) *cobra.Command {
cmd := identities.NewDeleteIdentityCmd(parent)
func NewDeleteIdentityCmd() *cobra.Command {
cmd := identities.NewDeleteIdentityCmd()
client.RegisterProjectFlag(cmd.Flags())
cmdx.RegisterFormatFlags(cmd.Flags())
return cmd
Expand Down
4 changes: 2 additions & 2 deletions cmd/cloudx/identity/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/ory/x/cmdx"
)

func NewGetIdentityCmd(parent *cobra.Command) *cobra.Command {
cmd := identities.NewGetIdentityCmd(parent)
func NewGetIdentityCmd() *cobra.Command {
cmd := identities.NewGetIdentityCmd()
client.RegisterProjectFlag(cmd.Flags())
cmdx.RegisterFormatFlags(cmd.Flags())
return cmd
Expand Down
4 changes: 2 additions & 2 deletions cmd/cloudx/identity/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/ory/kratos/cmd/identities"
)

func NewImportIdentityCmd(parent *cobra.Command) *cobra.Command {
cmd := identities.NewImportIdentitiesCmd(parent)
func NewImportIdentityCmd() *cobra.Command {
cmd := identities.NewImportIdentitiesCmd()
client.RegisterProjectFlag(cmd.Flags())
return cmd
}
4 changes: 2 additions & 2 deletions cmd/cloudx/identity/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/ory/kratos/cmd/identities"
)

func NewListIdentityCmd(parent *cobra.Command) *cobra.Command {
cmd := identities.NewListIdentitiesCmd(parent)
func NewListIdentityCmd() *cobra.Command {
cmd := identities.NewListIdentitiesCmd()
client.RegisterProjectFlag(cmd.Flags())
return cmd
}
9 changes: 6 additions & 3 deletions cmd/cloudx/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ import (
"github.com/ory/x/cmdx"
)

func NewImportCmd(parent *cobra.Command) *cobra.Command {
func NewImportCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "import",
Short: "Import resources",
}

cmd.AddCommand(identity.NewImportIdentityCmd(parent))
cmd.AddCommand(oauth2.NewImportOAuth2Cmd(parent))
cmd.AddCommand(
identity.NewImportIdentityCmd(),
oauth2.NewImportOAuth2Client(),
oauth2.NewImportJWK(),
)

client.RegisterConfigFlag(cmd.PersistentFlags())
client.RegisterYesFlag(cmd.PersistentFlags())
Expand Down
20 changes: 20 additions & 0 deletions cmd/cloudx/introspect.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cloudx

import (
"github.com/spf13/cobra"

"github.com/ory/cli/cmd/cloudx/oauth2"
"github.com/ory/x/cmdx"
)

func NewIntrospectCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "introspect",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the more general verb describe also make sense here? I'd imagine that describe would fit more objects than introspect, if we want to follow the kubectl model. But I don't know the semantics for sure.

Short: "Introspect resources",
}
cmd.AddCommand(oauth2.NewIntrospectToken())

cmdx.RegisterHTTPClientFlags(cmd.PersistentFlags())
cmdx.RegisterFormatFlags(cmd.PersistentFlags())
return cmd
}
14 changes: 8 additions & 6 deletions cmd/cloudx/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,28 @@ package cloudx
import (
"github.com/spf13/cobra"

"github.com/ory/cli/cmd/cloudx/identity"
"github.com/ory/cli/cmd/cloudx/oauth2"
"github.com/ory/cli/cmd/cloudx/relationtuples"

"github.com/ory/cli/cmd/cloudx/client"
"github.com/ory/cli/cmd/cloudx/identity"
"github.com/ory/cli/cmd/cloudx/project"
"github.com/ory/x/cmdx"
)

func NewListCmd(parent *cobra.Command) *cobra.Command {
func NewListCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Aliases: []string{"ls"},
Short: "List resources",
}

cmd.AddCommand(project.NewListProjectsCmd())
cmd.AddCommand(identity.NewListIdentityCmd(parent))
cmd.AddCommand(oauth2.NewListOAuth2Cmd(parent))
cmd.AddCommand(relationtuples.NewListCmd())
cmd.AddCommand(
project.NewListProjectsCmd(),
identity.NewListIdentityCmd(),
oauth2.NewListOAuth2Clients(),
relationtuples.NewListCmd(),
)

client.RegisterConfigFlag(cmd.PersistentFlags())
client.RegisterYesFlag(cmd.PersistentFlags())
Expand Down
31 changes: 31 additions & 0 deletions cmd/cloudx/oauth2/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package oauth2

import (
"github.com/spf13/cobra"

hydra "github.com/ory/hydra/cmd"
)

func NewCreateOAuth2Client() *cobra.Command {
return wrapHydraCmd(hydra.NewCreateClientsCommand)
}

func NewDeleteOAuth2Client() *cobra.Command {
return wrapHydraCmd(hydra.NewDeleteClientCmd)
}

func NewGetOAuth2Client() *cobra.Command {
return wrapHydraCmd(hydra.NewGetClientsCmd)
}

func NewImportOAuth2Client() *cobra.Command {
return wrapHydraCmd(hydra.NewImportClientCmd)
}

func NewListOAuth2Clients() *cobra.Command {
return wrapHydraCmd(hydra.NewListClientsCmd)
}

func NewUpdateOAuth2Client() *cobra.Command {
return wrapHydraCmd(hydra.NewUpdateClientCmd)
}
Loading