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

Print formatted output string in rule management CLI #35

Merged
merged 1 commit into from
Nov 24, 2017
Merged
Show file tree
Hide file tree
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
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