-
Notifications
You must be signed in to change notification settings - Fork 55
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: include Callbacks on clients create and list #25
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
package display | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/auth0/auth0-cli/internal/ansi" | ||
"gopkg.in/auth0.v5" | ||
"gopkg.in/auth0.v5/management" | ||
|
@@ -11,22 +14,34 @@ type clientView struct { | |
Type string | ||
ClientID string | ||
ClientSecret string | ||
Callbacks []string | ||
revealSecret bool | ||
} | ||
|
||
func (v *clientView) AsTableHeader() []string { | ||
if v.revealSecret { | ||
return []string{"Name", "Type", "ClientID", "Client Secret"} | ||
return []string{"Name", "Type", "ClientID", "Client Secret", "Callbacks"} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a refactor here regarding how the columns are included/excluded will be needed at some point (probably not for the PoC) |
||
} | ||
return []string{"Name", "Type", "ClientID"} | ||
return []string{"Name", "Type", "ClientID", "Callbacks"} | ||
cyx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
} | ||
|
||
func (v *clientView) AsTableRow() []string { | ||
if v.revealSecret { | ||
return []string{v.Name, v.Type, ansi.Faint(v.ClientID), ansi.Italic(v.ClientSecret)} | ||
return []string{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, potential combinations are going to make this hard to maintain |
||
v.Name, | ||
v.Type, | ||
ansi.Faint(v.ClientID), | ||
ansi.Italic(v.ClientSecret), | ||
strings.Join(v.Callbacks, ", "), | ||
} | ||
} | ||
return []string{ | ||
v.Name, | ||
v.Type, | ||
ansi.Faint(v.ClientID), | ||
strings.Join(v.Callbacks, ", "), | ||
} | ||
return []string{v.Name, v.Type, ansi.Faint(v.ClientID)} | ||
|
||
} | ||
|
||
|
@@ -42,6 +57,7 @@ func (r *Renderer) ClientList(clients []*management.Client) { | |
Type: appTypeFor(c.AppType), | ||
ClientID: auth0.StringValue(c.ClientID), | ||
ClientSecret: auth0.StringValue(c.ClientSecret), | ||
Callbacks: callbacksFor(c.Callbacks), | ||
}) | ||
} | ||
|
||
|
@@ -59,6 +75,7 @@ func (r *Renderer) ClientCreate(client *management.Client, revealSecrets bool) { | |
Type: appTypeFor(client.AppType), | ||
ClientID: auth0.StringValue(client.ClientID), | ||
ClientSecret: auth0.StringValue(client.ClientSecret), | ||
Callbacks: callbacksFor(client.Callbacks), | ||
} | ||
|
||
r.Results([]View{v}) | ||
|
@@ -88,3 +105,11 @@ func appTypeFor(v *string) string { | |
return *v | ||
} | ||
} | ||
|
||
func callbacksFor(s []interface{}) []string { | ||
res := make([]string, len(s)) | ||
for i, v := range s { | ||
res[i] = fmt.Sprintf("%s", v) | ||
} | ||
return res | ||
} | ||
Comment on lines
+109
to
+115
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a simpler way to convert from []interface{} -> []string ? |
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.
I wonder if there is a 1-liner to convert from []string to []interface{} 🤔
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.
Nah there's none :) It's the reason the
generics
troll gets fueled :)