Skip to content

Commit

Permalink
fix linting issues #39
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Jul 24, 2022
1 parent a205b5f commit 26e8e54
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 29 deletions.
3 changes: 1 addition & 2 deletions apiclient/clifile.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ func GetPreferences() (err error) {
return err
}

PrettyPrint(output)
return nil
return PrettyPrint(output)
}

//WritePreferencesFile
Expand Down
2 changes: 1 addition & 1 deletion apiclient/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func generateAccessToken(privateKey string) (string, error) {

if err != nil {
clilog.Error.Println("error in response: ", err)
return "", fmt.Errorf("error in response: ", err)
return "", fmt.Errorf("error in response: %v", err)
} else if resp.StatusCode > 399 {
clilog.Error.Printf("status code %d, error in response: %s\n", resp.StatusCode, string(respBody))
return "", fmt.Errorf("status code %d, error in response: %s\n", resp.StatusCode, string(respBody))
Expand Down
4 changes: 2 additions & 2 deletions bundlegen/generateapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func GenerateAPIProxyDefFromOAS(name string,
targets.NewTargetEndpoint(u.Scheme+"://"+u.Hostname(), oasGoogleAcessTokenScopeLiteral, oasGoogleIdTokenAudLiteral, oasGoogleIdTokenAudRef)
} else { //an explicit target url is set
if _, err = url.Parse(targetUrl); err != nil {
return fmt.Errorf("Invalid target url: ", err)
return fmt.Errorf("Invalid target url: %v", err)
}
targets.NewTargetEndpoint(targetUrl, oasGoogleAcessTokenScopeLiteral, oasGoogleIdTokenAudLiteral, oasGoogleIdTokenAudRef)
}
Expand Down Expand Up @@ -335,7 +335,7 @@ func GenerateAPIProxyDefFromGQL(name string,
targets.NewTargetEndpoint("https://api.example.com", "", "", "")
} else { //an explicit target url is set
if _, err = url.Parse(targetUrl); err != nil {
return fmt.Errorf("Invalid target url: ", err)
return fmt.Errorf("Invalid target url: %v", err)
}
targets.NewTargetEndpoint(targetUrl, "", "", "")
}
Expand Down
4 changes: 4 additions & 0 deletions client/developers/developers.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ func GetDeveloperId(email string) (developerId string, err error) {
u, _ := url.Parse(apiclient.BaseURL)
u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "developers", url.QueryEscape(email)) //since developer emails can have +
respBody, err := apiclient.HttpClient(apiclient.GetPrintOutput(), u.String())
if err != nil {
return "", err
}

apiclient.SetPrintOutput(true)
err = json.Unmarshal(respBody, &developerMap)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions client/operations/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ type OperationCompleteState string

const (
Success OperationCompleteState = "Success"
Failed = "Failed"
Both = "Both"
Failed OperationCompleteState = "Failed"
Both OperationCompleteState = "Both"
)

//Get
Expand Down
3 changes: 1 addition & 2 deletions cmd/apis/depwaitapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ var DepWaitCmd = &cobra.Command{
Short: "Deploys a revision of an existing API proxy and waits for deployment status",
Long: "Deploys a revision of an existing API proxy to an environment and waits for deployment status",
Args: func(cmd *cobra.Command, args []string) (err error) {
apiclient.SetApigeeOrg(org)
apiclient.SetApigeeEnv(env)
return nil
return apiclient.SetApigeeOrg(org)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
if revision == -1 {
Expand Down
4 changes: 3 additions & 1 deletion cmd/env/crtarchive.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ var CreateArchiveCmd = &cobra.Command{

if folder != "" {
zipfile = name + ".zip"
proxybundle.GenerateArchiveBundle(folder, zipfile)
if err = proxybundle.GenerateArchiveBundle(folder, zipfile); err != nil {
return err
}
}

respBody, err := env.CreateArchive(name, zipfile)
Expand Down
2 changes: 1 addition & 1 deletion cmd/iam/iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var Cmd = &cobra.Command{
}

var name, projectID, roleType string
var generateName, wid bool
var generateName bool

var roles = []string{"mart", "analytics", "all", "logger", "connect", "cassandra", "watcher",
"sync", "admin", "api-admin", "env-admin", "dev-admin", "readonly-admin"}
Expand Down
4 changes: 2 additions & 2 deletions cmd/org/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var ExportCmd = &cobra.Command{
return err
}

fmt.Println("\tExporting KV Map names for org %s", org)
fmt.Printf("\tExporting KV Map names for org %s\n", org)
if respBody, err = kvm.List(""); err != nil {
return err
}
Expand Down Expand Up @@ -158,7 +158,7 @@ var ExportCmd = &cobra.Command{
return err
}

fmt.Println("\tExporting KV Map names for environment %s...", environment)
fmt.Printf("\tExporting KV Map names for environment %s...\n", environment)
if respBody, err = kvm.List(""); err != nil {
return err
}
Expand Down
8 changes: 6 additions & 2 deletions cmd/org/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ var ImportCmd = &cobra.Command{
return err
}
if orgKVMFileList[kvmName] != "" {
kvm.ImportEntries("", kvmName, conn, orgKVMFileList[kvmName])
if err = kvm.ImportEntries("", kvmName, conn, orgKVMFileList[kvmName]); err != nil {
return err
}
}
}
}
Expand Down Expand Up @@ -157,7 +159,9 @@ var ImportCmd = &cobra.Command{
return err
}
if envKVMFileList[kvmName] != "" {
kvm.ImportEntries("", kvmName, conn, envKVMFileList[kvmName])
if err = kvm.ImportEntries("", kvmName, conn, envKVMFileList[kvmName]); err != nil {
return err
}
}
}
}
Expand Down
13 changes: 2 additions & 11 deletions cmd/overrides/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package overrides

import (
"encoding/json"
"fmt"

"github.com/apigee/apigeecli/apiclient"
Expand All @@ -40,8 +39,9 @@ var ApplyCmd = &cobra.Command{
if err = readOverrides(overridesFile); err != nil {
return err
}

apiclient.SetProjectID(getOrg())
apiclient.SetApigeeOrg(getOrg())
_ = apiclient.SetApigeeOrg(getOrg())
apiclient.SetPrintOutput(false)

//check if the org exists
Expand Down Expand Up @@ -115,12 +115,3 @@ func getDomainName(index int) []string {
domainNames = append(domainNames, domainName)
return domainNames
}

func getSyncIdentityCount(response []byte) (count int, err error) {
syncResponse := make(map[string]interface{})
err = json.Unmarshal(response, &syncResponse)
if err != nil {
return 0, err
}
return len(syncResponse["identities"].([]interface{})), nil
}
2 changes: 1 addition & 1 deletion cmd/overrides/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var DeleteCmd = &cobra.Command{
return err
}
apiclient.SetProjectID(getOrg())
apiclient.SetApigeeOrg(getOrg())
_ = apiclient.SetApigeeOrg(getOrg())
apiclient.SetPrintOutput(false)

//delete environments
Expand Down
2 changes: 0 additions & 2 deletions cmd/overrides/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ var Cmd = &cobra.Command{
Long: "Manage Apigee hybrid through overrides",
}

var org string

func init() {
Cmd.AddCommand(ApplyCmd)
Cmd.AddCommand(DeleteCmd)
Expand Down

0 comments on commit 26e8e54

Please sign in to comment.