Skip to content

Commit

Permalink
Print formatted output string in rule management CLI (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
arekkas authored Nov 24, 2017
1 parent 95abec8 commit b14c74e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/helper_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func checkResponse(response *swagger.APIResponse, err error, expectedStatusCode int) {
must(err, "Could not validate token: %s", err)
must(err, "A network error occurred: %s", err)

if response.StatusCode != expectedStatusCode {
fmt.Printf("Command failed because status code %d was expeceted but code %d was received", expectedStatusCode, response.StatusCode)
Expand Down
6 changes: 4 additions & 2 deletions cmd/rules_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package cmd
import (
"net/http"

"fmt"

"github.com/ory/oathkeeper/sdk/go/oathkeepersdk"
"github.com/spf13/cobra"
)
Expand All @@ -24,9 +26,9 @@ var getCmd = &cobra.Command{
}

client := oathkeepersdk.NewSDK(endpoint)
rules, response, err := client.GetRule(args[0])
rule, response, err := client.GetRule(args[0])
checkResponse(response, err, http.StatusOK)
formatResponse(rules)
fmt.Println(formatResponse(rule))
},
}

Expand Down
4 changes: 3 additions & 1 deletion cmd/rules_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package cmd
import (
"net/http"

"fmt"

"github.com/ory/oathkeeper/sdk/go/oathkeepersdk"
"github.com/spf13/cobra"
)
Expand All @@ -24,7 +26,7 @@ var listCmd = &cobra.Command{
client := oathkeepersdk.NewSDK(endpoint)
rules, response, err := client.ListRules()
checkResponse(response, err, http.StatusOK)
formatResponse(rules)
fmt.Println(formatResponse(rules))
},
}

Expand Down

0 comments on commit b14c74e

Please sign in to comment.