Skip to content

Commit

Permalink
Remove telegrapher/vrb for log
Browse files Browse the repository at this point in the history
  • Loading branch information
telegrapher committed Jan 22, 2021
1 parent ed64021 commit 5cc7a0d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ Temporary Items
*.yml

dist/
imscli
/imscli
8 changes: 4 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
package cmd

import (
"os"
"io/ioutil"
"log"

"github.com/adobe/imscli/ims"
"github.com/spf13/cobra"
"github.com/telegrapher/vrb"
)

func RootCmd(version string) *cobra.Command {
Expand All @@ -29,8 +29,8 @@ func RootCmd(version string) *cobra.Command {
Long: `imscli is a CLI tool to automate and troubleshoot Adobe's authentication and authorization service IMS.`,
Version: version,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if verbose {
vrb.Init(os.Stderr)
if !verbose {
log.SetOutput(ioutil.Discard)
}
// This call of the initParams will load all env vars, config file and flags.
return initParams(cmd, imsConfig, configFile)
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ require (
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4
github.com/spf13/cobra v1.1.0
github.com/spf13/viper v1.7.1
github.com/telegrapher/vrb v0.1.0
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/telegrapher/vrb v0.1.0 h1:hfguwiwC6SiqRfvlOcQMtHu6bq9zDrNy2zSqYRDWuS8=
github.com/telegrapher/vrb v0.1.0/go.mod h1:i0ygzN6L6mRDCeJoswlKDY5Hkdx6pckcyslJuThu1yE=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
Expand Down
14 changes: 7 additions & 7 deletions ims/authz_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package ims
import (
"context"
"fmt"
"log"
"net"
"net/http"
"os"
Expand All @@ -21,7 +22,6 @@ import (
"github.com/adobe/ims-go/ims"
"github.com/adobe/ims-go/login"
"github.com/pkg/browser"
"github.com/telegrapher/vrb"
)

const port = 8888
Expand All @@ -47,7 +47,7 @@ func (i Config) validateAuthorizeUserConfig() error {
case i.Organization == "":
return fmt.Errorf("missing organization parameter")
default:
vrb.Println("all needed parameters verified not empty")
log.Println("all needed parameters verified not empty")
}

return nil
Expand Down Expand Up @@ -98,7 +98,7 @@ func (i Config) AuthorizeUser() (string, error) {
return "", fmt.Errorf("unable to listen at port %d", port)
}

vrb.Println("Local server successfully launched and contacted.")
log.Println("Local server successfully launched and contacted.")

localUrl := fmt.Sprintf("http://localhost:%d/", port)

Expand All @@ -116,9 +116,9 @@ func (i Config) AuthorizeUser() (string, error) {

select {
case serr = <-server.Error():
vrb.Println("The IMS HTTP handler returned a message.")
log.Println("The IMS HTTP handler returned a message.")
case resp = <-server.Response():
vrb.Println("The IMS HTTP handler returned a message.")
log.Println("The IMS HTTP handler returned a message.")
case <-time.After(time.Minute * 5):
fmt.Fprintf(os.Stderr, "Timeout reached waiting for the user to finish the authentication ...\n")
serr = fmt.Errorf("user timed out")
Expand All @@ -127,12 +127,12 @@ func (i Config) AuthorizeUser() (string, error) {
if err = server.Shutdown(context.Background()); err != nil {
return "", fmt.Errorf("error shutting down the local server: %v", err)
}
vrb.Println("Local server shut down ...")
log.Println("Local server shut down ...")

if serr != nil {
return "", fmt.Errorf("error negotiating the authorization code: %v", serr)
}
vrb.Println("No error from Authorization Code handler, server is successfully shut down.")
log.Println("No error from Authorization Code handler, server is successfully shut down.")

return resp.AccessToken, nil
}
4 changes: 2 additions & 2 deletions ims/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ package ims

import (
"fmt"
"log"

"github.com/adobe/ims-go/ims"
"github.com/telegrapher/vrb"
)

func (i Config) validateGetProfileConfig() error {
Expand All @@ -24,7 +24,7 @@ func (i Config) validateGetProfileConfig() error {
case i.URL == "":
return fmt.Errorf("missing IMS base URL parameter")
default:
vrb.Println("all needed parameters verified not empty")
log.Println("all needed parameters verified not empty")
}
return nil
}
Expand Down

0 comments on commit 5cc7a0d

Please sign in to comment.