Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Jul 27, 2019
1 parent 1371caf commit bd0005e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
11 changes: 6 additions & 5 deletions cmd/apis/crtapi/crtapi.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package crtapis

import (
"github.com/spf13/cobra"
"github.com/srinandan/apigeecli/cmd/shared"
"net/url"
"path"

"github.com/spf13/cobra"
"github.com/srinandan/apigeecli/cmd/shared"
)

var Cmd = &cobra.Command{
Expand All @@ -21,11 +22,11 @@ var Cmd = &cobra.Command{
q.Set("action", "import")
u.RawQuery = q.Encode()
err := shared.ReadBundle(name)
if err == nil {
return shared.PostHttpOctet(u.String(), proxy)
} else {
if err != nil {
return err
}

return shared.PostHttpOctet(u.String(), proxy)
} else {
proxyName := "{\"name\":\"" + name + "\"}"
return shared.HttpClient(u.String(), proxyName)
Expand Down
8 changes: 4 additions & 4 deletions cmd/shared/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ func generateJWT() (string, error) {

func GenerateAccessToken() (string, error) {

const token_endpoint = "https://www.googleapis.com/oauth2/v4/token"
const grant_type = "urn:ietf:params:oauth:grant-type:jwt-bearer"
const tokenEndpoint = "https://www.googleapis.com/oauth2/v4/token"
const grantType = "urn:ietf:params:oauth:grant-type:jwt-bearer"

token, err := generateJWT()

Expand All @@ -308,11 +308,11 @@ func GenerateAccessToken() (string, error) {
}

form := url.Values{}
form.Add("grant_type", grant_type)
form.Add("grant_type", grantType)
form.Add("assertion", token)

client := &http.Client{}
req, err := http.NewRequest("POST", token_endpoint, strings.NewReader(form.Encode()))
req, err := http.NewRequest("POST", tokenEndpoint, strings.NewReader(form.Encode()))
if err != nil {
Error.Fatalln("Error in client:\n", err)
return "", err
Expand Down
11 changes: 6 additions & 5 deletions cmd/sharedflows/crtsf/crtsf.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package crtsf

import (
"github.com/srinandan/apigeecli/cmd/shared"
"github.com/spf13/cobra"
"net/url"
"path"

"github.com/spf13/cobra"
"github.com/srinandan/apigeecli/cmd/shared"
)

var Cmd = &cobra.Command{
Expand All @@ -21,11 +22,11 @@ var Cmd = &cobra.Command{
q.Set("action", "import")
u.RawQuery = q.Encode()
err := shared.ReadBundle(name)
if err == nil {
return shared.PostHttpOctet(u.String(), proxy)
} else {
if err != nil {
return err
}

return shared.PostHttpOctet(u.String(), proxy)
} else {
proxyName := "{\"name\":\"" + name + "\"}"
return shared.HttpClient(u.String(), proxyName)
Expand Down
6 changes: 3 additions & 3 deletions cmd/sync/setsync/setsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ var Cmd = &cobra.Command{
Short: "Set identity with access to control plane resources",
Long: "Set identity with access to control plane resources",
Args: func(cmd *cobra.Command, args []string) error {
if strings.Contains(identity, ".iam.gserviceaccount.com") {
return nil
} else {
if !strings.Contains(identity, ".iam.gserviceaccount.com") {
return fmt.Errorf("identity[0] must have .iam.gserviceaccount.com suffix and should not be a Google managed service account: %s", identity)
}

return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
u, _ := url.Parse(shared.BaseURL)
Expand Down
7 changes: 4 additions & 3 deletions cmd/token/gettk/gettk.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gettk

import (
"fmt"

"github.com/spf13/cobra"
"github.com/srinandan/apigeecli/cmd/shared"
)
Expand All @@ -11,11 +12,11 @@ var Cmd = &cobra.Command{
Short: "Generate a new access token",
Long: "Generate a new access token",
Args: func(cmd *cobra.Command, args []string) error {
if shared.RootArgs.ServiceAccount != "" {
return nil
} else {
if shared.RootArgs.ServiceAccount == "" {
return fmt.Errorf("Service account cannot be empty")
}

return nil
},

RunE: func(cmd *cobra.Command, args []string) error {
Expand Down

0 comments on commit bd0005e

Please sign in to comment.