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

apps show: use key value list #124

Merged
merged 1 commit into from
Mar 5, 2021
Merged
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
33 changes: 32 additions & 1 deletion internal/display/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type applicationView struct {
ClientSecret string
Callbacks []string
revealSecret bool

raw interface{}
}

func (v *applicationView) AsTableHeader() []string {
Expand Down Expand Up @@ -51,6 +53,32 @@ func (v *applicationView) AsTableRow() []string {
}
}

func (v *applicationView) KeyValues() [][]string {
callbacks := strings.Join(v.Callbacks, ", ")

if v.revealSecret {
return [][]string{
[]string{"NAME", v.Name},
[]string{"TYPE", v.Type},
[]string{"CLIENT ID", ansi.Faint(v.ClientID)},
[]string{"CLIENT SECRET", ansi.Italic(v.ClientSecret)},
[]string{"CALLBACKS", callbacks},
}

}

return [][]string{
[]string{"NAME", v.Name},
[]string{"TYPE", v.Type},
[]string{"CLIENT ID", ansi.Faint(v.ClientID)},
[]string{"CALLBACKS", callbacks},
}
}

func (v *applicationView) Object() interface{} {
return v.raw
}

// applicationListView is a slimmed down view of a client for displaying
// larger numbers of applications
type applicationListView struct {
Expand Down Expand Up @@ -113,9 +141,10 @@ func (r *Renderer) ApplicationShow(client *management.Client, revealSecrets bool
ClientID: auth0.StringValue(client.ClientID),
ClientSecret: auth0.StringValue(client.ClientSecret),
Callbacks: callbacksFor(client.Callbacks),
raw: client,
}

r.Results([]View{v})
r.Result(v)
}

func (r *Renderer) ApplicationCreate(client *management.Client, revealSecrets bool) {
Expand All @@ -128,6 +157,7 @@ func (r *Renderer) ApplicationCreate(client *management.Client, revealSecrets bo
ClientID: auth0.StringValue(client.ClientID),
ClientSecret: auth0.StringValue(client.ClientSecret),
Callbacks: callbacksFor(client.Callbacks),
raw: client,
}

r.Results([]View{v})
Expand All @@ -145,6 +175,7 @@ func (r *Renderer) ApplicationUpdate(client *management.Client, revealSecrets bo
ClientID: auth0.StringValue(client.ClientID),
ClientSecret: auth0.StringValue(client.ClientSecret),
Callbacks: callbacksFor(client.Callbacks),
raw: client,
}

r.Results([]View{v})
Expand Down