Skip to content

Commit

Permalink
OCM-6840 | fix: Add json output of the external auth
Browse files Browse the repository at this point in the history
Signed-off-by: Maggie Chen <magchen@redhat.com>
  • Loading branch information
chenz4027 committed Mar 20, 2024
1 parent 897b1c3 commit 1ba8c13
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions cmd/describe/externalauthprovider/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ func runWithRuntime(r *rosa.Runtime, cmd *cobra.Command, argv []string) error {
return fmt.Errorf("external authentication provider '%s' not found", externalAuthId)
}

if output.HasFlag() {
err = output.Print(externalAuthConfig)
if err != nil {
r.Reporter.Errorf("%v", err)
os.Exit(1)
}
os.Exit(0)
}

externalAuthConfigList := describeExternalAuthProviders(r, cluster, clusterKey, externalAuthConfig)

fmt.Print(externalAuthConfigList)
Expand Down
4 changes: 3 additions & 1 deletion cmd/list/externalauthprovider/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ func runWithRuntime(r *rosa.Runtime, cmd *cobra.Command) error {
if output.HasFlag() {
err = output.Print(externalAuthProviders)
if err != nil {
return fmt.Errorf("%v", err)
r.Reporter.Errorf("%s", err)
os.Exit(1)
}
os.Exit(0)
}

if len(externalAuthProviders) == 0 {
Expand Down
8 changes: 8 additions & 0 deletions pkg/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ func Print(resource interface{}) error {
if dnsdomains, ok := resource.([]*cmv1.DNSDomain); ok {
cmv1.MarshalDNSDomainList(dnsdomains, &b)
}
case "[]*v1.ExternalAuth":
if externalAuths, ok := resource.([]*cmv1.ExternalAuth); ok {
cmv1.MarshalExternalAuthList(externalAuths, &b)
}
case "*v1.ExternalAuth":
if externalAuth, ok := resource.(*cmv1.ExternalAuth); ok {
cmv1.MarshalExternalAuth(externalAuth, &b)
}
case "[]*v1.IdentityProvider":
if idps, ok := resource.([]*cmv1.IdentityProvider); ok {
cmv1.MarshalIdentityProviderList(idps, &b)
Expand Down

0 comments on commit 1ba8c13

Please sign in to comment.