Skip to content
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: actions triggers create #42

Merged
merged 31 commits into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4f132b1
wip working
turcottedanny Jan 25, 2021
162ada0
working output as json
turcottedanny Jan 25, 2021
ea465b6
Improve logging
turcottedanny Jan 26, 2021
62f503f
update go-auth0
turcottedanny Jan 26, 2021
3c1e85d
typos
turcottedanny Jan 26, 2021
b596505
Merge branch 'main' into A0CLI-17-test-action
turcottedanny Jan 26, 2021
8186ffa
cleanup
turcottedanny Jan 26, 2021
1287704
wip list bindings
turcottedanny Jan 26, 2021
18264ed
update vendor
turcottedanny Jan 26, 2021
a41b4cc
working reorder bindings prototype
turcottedanny Jan 26, 2021
36ce917
vendor
turcottedanny Jan 26, 2021
983b0f7
fix
turcottedanny Jan 26, 2021
6d586c4
review fixes
turcottedanny Jan 26, 2021
c02865f
update vendor
turcottedanny Jan 26, 2021
befdcd6
Merge branch 'main' into A0CLI-17-test-action
turcottedanny Jan 26, 2021
b0ab9ff
implement new struct
turcottedanny Jan 26, 2021
4aec6ac
wip list bindings
turcottedanny Jan 26, 2021
9477879
update vendor
turcottedanny Jan 26, 2021
01ba881
implement new api
turcottedanny Jan 26, 2021
13c3fb9
Merge branch 'A0CLI-29-actions-triggers-show' of github.com:auth0/aut…
turcottedanny Jan 26, 2021
183b337
working reorder bindings prototype
turcottedanny Jan 26, 2021
57f8e54
vendor
turcottedanny Jan 26, 2021
5b4af1e
fix
turcottedanny Jan 26, 2021
8516d94
implement new api
turcottedanny Jan 26, 2021
321827c
Merge branch 'A0CLI-30-actions-triggers-reorder' of github.com:auth0/…
turcottedanny Jan 26, 2021
1d0fb07
wip
turcottedanny Jan 26, 2021
1c8a37b
feat: create a binding
turcottedanny Jan 26, 2021
8fe805c
fixes display_name
turcottedanny Jan 26, 2021
9ebfdab
Merge branch 'main' into A0CLI-34-actions-triggers-add
turcottedanny Jan 26, 2021
902eeb5
fix syntax
turcottedanny Jan 26, 2021
6bc36da
Merge branch 'main' into A0CLI-34-actions-triggers-add
turcottedanny Jan 26, 2021
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ require (

// replace gopkg.in/auth0.v5 => ../auth0

replace gopkg.in/auth0.v5 => github.com/go-auth0/auth0 v1.3.1-0.20210126044025-c2f94c36f593
replace gopkg.in/auth0.v5 => github.com/go-auth0/auth0 v1.3.1-0.20210126164439-7451a183abbd
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-auth0/auth0 v1.3.1-0.20210126044025-c2f94c36f593 h1:Ty0FV0S+59z1ioKa6uM0WW9i39HgZM46oAtFh++rUHQ=
github.com/go-auth0/auth0 v1.3.1-0.20210126044025-c2f94c36f593/go.mod h1:pbIRmwBulkHNKKsUGGvhyIOI2itMhz2OfwtPaFXBSSQ=
github.com/go-auth0/auth0 v1.3.1-0.20210126164439-7451a183abbd h1:O1ZCQlPODGWJNDT0qH6SpGdFEcEBWz7dd/mHFw6Kh10=
github.com/go-auth0/auth0 v1.3.1-0.20210126164439-7451a183abbd/go.mod h1:QQ9fgGj2Wpza15+Ho3mM6amMeKfhzHo2cixcOqdkoKk=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
Expand Down Expand Up @@ -187,6 +189,8 @@ github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1f
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag=
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8=
Expand Down
3 changes: 2 additions & 1 deletion internal/auth0/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type ActionVersionAPI interface {
}

type ActionBindingAPI interface {
Create(triggerID management.TriggerID, action *management.Action) (ab *management.ActionBinding, err error)
List(triggerID management.TriggerID, opts ...management.RequestOption) (c *management.ActionBindingList, err error)
Update(triggerID management.TriggerID, v *management.ActionBindingList) error
Update(triggerID management.TriggerID, v []*management.ActionBinding) (list *management.ActionBindingList, err error)
}
72 changes: 68 additions & 4 deletions internal/cli/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func triggersCmd(cli *cli) *cobra.Command {
cmd.SetUsageTemplate(resourceUsageTemplate())
cmd.AddCommand(showTriggerCmd(cli))
cmd.AddCommand(reorderTriggerCmd(cli))
cmd.AddCommand(createTriggerCmd(cli))

return cmd
}
Expand Down Expand Up @@ -197,8 +198,7 @@ func showTriggerCmd(cli *cli) *cobra.Command {
triggerID := management.TriggerID(trigger)

var list *management.ActionBindingList
err := ansi.Spinner("Loading actions", func() error {
var err error
err := ansi.Spinner("Loading actions", func() (err error) {
list, err = cli.api.ActionBinding.List(triggerID)
return err
})
Expand Down Expand Up @@ -238,8 +238,14 @@ func reorderTriggerCmd(cli *cli) *cobra.Command {
return err
}

err = ansi.Spinner("Loading actions", func() error {
return cli.api.ActionBinding.Update(triggerID, list)
err = ansi.Spinner("Reordoring actions", func() (err error) {
if _, err = cli.api.ActionBinding.Update(triggerID, list.Bindings); err != nil {
return err
}

list, err = cli.api.ActionBinding.List(triggerID)

return err
})

if err != nil {
Expand All @@ -256,3 +262,61 @@ func reorderTriggerCmd(cli *cli) *cobra.Command {

return cmd
}

func createTriggerCmd(cli *cli) *cobra.Command {
var trigger string
var actionId string

cmd := &cobra.Command{
Use: "create",
Short: "Bind an action to a trigger",
Long: `$ auth0 actions triggers create --trigger <post-login> --name <action_id>`,
RunE: func(cmd *cobra.Command, args []string) error {
if err := validators.TriggerID(trigger); err != nil {
return err
}

triggerID := management.TriggerID(trigger)

var binding *management.ActionBinding
var list *management.ActionBindingList

err := ansi.Spinner("Adding action", func() (err error) {
var action *management.Action
if action, err = cli.api.Action.Read(actionId); err != nil {
return err
}

if binding, err = cli.api.ActionBinding.Create(triggerID, action); err != nil {
return err
}

if list, err = cli.api.ActionBinding.List(triggerID); err != nil {
return err
}

bindings := append(list.Bindings, binding)

if _, err = cli.api.ActionBinding.Update(triggerID, bindings); err != nil {
return err
}

list, err = cli.api.ActionBinding.List(triggerID)

return err
})

if err != nil {
return err
}

cli.renderer.ActionTriggersList(list.Bindings)
return nil
},
}

cmd.Flags().StringVarP(&trigger, "trigger", "t", string(management.PostLogin), "Trigger type for action.")
cmd.Flags().StringVar(&actionId, "name", "", "Action ID to to test")

return cmd
}
73 changes: 73 additions & 0 deletions vendor/github.com/mitchellh/mapstructure/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions vendor/github.com/mitchellh/mapstructure/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions vendor/github.com/mitchellh/mapstructure/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading