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

fix linting issues #40

Merged
merged 2 commits into from
Jul 29, 2022
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
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
2 changes: 1 addition & 1 deletion client/datacollectors/datacollectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func List() (respBody []byte, err error) {
//Import
func Import(filePath string) (err error) {

dCollectors := dcollectors{}
var dCollectors dcollectors

if dCollectors, err = readDataCollectorsFile(filePath); err != nil {
return err
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
2 changes: 1 addition & 1 deletion client/envgroups/envgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func getArrayStr(str []string) string {
//Import
func Import(filePath string) (err error) {

environmentGroups := environmentgroups{}
var environmentGroups environmentgroups

if environmentGroups, err = readEnvGroupsFile(filePath); err != nil {
return err
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