Skip to content

Commit

Permalink
chore: removed golint and updated golangci-linta
Browse files Browse the repository at this point in the history
  • Loading branch information
bnormington committed Nov 30, 2024
1 parent d0ccf24 commit 9c34770
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 45 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: lint
on: [ push, pull_request ]
on: [push, pull_request]
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v6
with:
version: v1.38
version: v1.62
45 changes: 43 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ run:
timeout: 2m

output:
format: tab
formats:
- format: tab

issues:
max-issues-per-linter: 0
Expand All @@ -16,6 +17,46 @@ linters:
- gocritic
- gocyclo
- gofmt
- golint
- misspell
- unconvert

linters-settings:
depguard:
rules:
main:
files:
- $all
allow:
- $gostd # Allow all Go standard library imports
- github.com/a8m/djson
- github.com/AlecAivazis/survey/v2
- github.com/aws/aws-sdk-go-v2/aws
- github.com/aws/aws-sdk-go-v2/config
- github.com/aws/aws-sdk-go-v2/feature/s3/manager
- github.com/aws/aws-sdk-go-v2/service/s3
- github.com/aws/aws-sdk-go-v2/service/secretsmanager
- github.com/aws/aws-sdk-go-v2/service/secretsmanager/types
- github.com/clok/avtool/v3
- github.com/clok/cdocs
- github.com/clok/kemba
- github.com/cyberark/summon/pkg/secretsyml
- github.com/GoodwayGroup/gwsm/cmd
- github.com/GoodwayGroup/gwsm/env
- github.com/GoodwayGroup/gwsm/info
- github.com/GoodwayGroup/gwsm/kube
- github.com/GoodwayGroup/gwsm/s3
- github.com/GoodwayGroup/gwsm/sm
- github.com/jedib0t/go-pretty/v6/table
- github.com/logrusorgru/aurora/v3
- github.com/manifoldco/promptui
- github.com/r3labs/diff/v2
- github.com/sergi/go-diff/diffmatchpatch
- github.com/TylerBrock/colorjson
- github.com/urfave/cli/v2
- k8s.io/api/core/v1
- k8s.io/apimachinery/pkg/apis/meta/v1
- k8s.io/client-go/kubernetes
- k8s.io/client-go/kubernetes/scheme
- k8s.io/client-go/rest
- k8s.io/client-go/tools/clientcmd
- k8s.io/client-go/tools/remotecommand
10 changes: 6 additions & 4 deletions cmd/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package cmd

import (
"fmt"
"os"
"sort"
"strings"

"github.com/GoodwayGroup/gwsm/env"
"github.com/clok/kemba"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/urfave/cli/v2"
"os"
"sort"
"strings"
)

// Print the resulting environment for a set of local ConfigMap and Summon secrets.yml file.
Expand All @@ -26,7 +27,8 @@ func ViewLocalEnv(c *cli.Context) error {
t.SetTitle("From ConfigMap")
} else {
l := kemba.PickColor(group)
t.SetTitle(fmt.Sprintf("From secret: %s", l.Sprintf(group)))
gp := l.Sprintf(group)
t.SetTitle(fmt.Sprintf("From secret: %s", gp))
}
t.AppendHeader(table.Row{"Key", "Value"})

Expand Down
12 changes: 7 additions & 5 deletions kube/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ package kube

import (
"bytes"
"github.com/clok/kemba"
"context"
"io"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
"net/url"
"strings"

"k8s.io/api/core/v1"
"github.com/clok/kemba"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"

v1 "k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes/scheme"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/remotecommand"
Expand Down Expand Up @@ -89,7 +91,7 @@ func execute(method string, url *url.URL, config *restclient.Config, stdin io.Re
if err != nil {
return err
}
return exec.Stream(remotecommand.StreamOptions{
return exec.StreamWithContext(context.Background(), remotecommand.StreamOptions{
Stdin: stdin,
Stdout: stdout,
Stderr: stderr,
Expand Down
9 changes: 5 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package main

import (
"fmt"
"github.com/GoodwayGroup/gwsm/cmd"
"github.com/GoodwayGroup/gwsm/info"
"github.com/clok/cdocs"
"github.com/urfave/cli/v2"
"log"
"os"
"runtime"
"time"

"github.com/GoodwayGroup/gwsm/cmd"
"github.com/GoodwayGroup/gwsm/info"
"github.com/clok/cdocs"
"github.com/urfave/cli/v2"
)

var version string
Expand Down
11 changes: 5 additions & 6 deletions s3/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package s3
import (
"context"
"errors"
"os"
"strings"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/feature/s3/manager"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/clok/kemba"
"github.com/urfave/cli/v2"
"log"
"os"
"strings"
)

var (
Expand All @@ -32,8 +32,7 @@ func Get(src string, dest string) error {

cfg, err := config.LoadDefaultConfig(context.TODO())
if err != nil {
log.Fatal(err)
return err
return cli.Exit(err, 2)
}

// Create an Amazon S3 service client
Expand Down
38 changes: 17 additions & 21 deletions sm/main.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package sm

import (
"encoding/json"
"fmt"
"context"
"log"
"encoding/json"
"errors"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/secretsmanager"
"github.com/aws/aws-sdk-go-v2/service/secretsmanager/types"
"log"
"strings"
)

Expand Down Expand Up @@ -59,11 +59,11 @@ func RetrieveSecret(variableName string) (secretBytes []byte, err error) {

// Get secret value
input := &secretsmanager.GetSecretValueInput{
SecretId: aws.String(secretName),
}
SecretId: aws.String(secretName),
}

resp, err := svc.GetSecretValue(context.TODO(), input)
if err != nil {
if err != nil {
return nil, err
}

Expand Down Expand Up @@ -94,20 +94,20 @@ func ListSecrets() (secrets []types.SecretListEntry, err error) {
svc := secretsmanager.NewFromConfig(cfg)

// Get all secret names
paginator := secretsmanager.NewListSecretsPaginator(svc, &secretsmanager.ListSecretsInput{
MaxResults: aws.Int32(100),
})
paginator := secretsmanager.NewListSecretsPaginator(svc, &secretsmanager.ListSecretsInput{
MaxResults: aws.Int32(100),
})

for paginator.HasMorePages() {
page, err := paginator.NextPage(context.TODO())
if err != nil {
return nil, fmt.Errorf("failed to retrieve secrets: %w", err)
}
for paginator.HasMorePages() {
page, err := paginator.NextPage(context.TODO())
if err != nil {
return nil, fmt.Errorf("failed to retrieve secrets: %w", err)
}

secrets = append(secrets, page.SecretList...)
}
secrets = append(secrets, page.SecretList...)
}

return secrets, nil
return secrets, nil
}

// GetSecret will retrieve a specific secret by Name (id)
Expand All @@ -119,7 +119,6 @@ func GetSecret(id string) (secret *secretsmanager.GetSecretValueOutput, err erro
}
svc := secretsmanager.NewFromConfig(cfg)


secret, err = svc.GetSecretValue(context.TODO(), &secretsmanager.GetSecretValueInput{
SecretId: aws.String(id),
})
Expand Down Expand Up @@ -161,7 +160,6 @@ func PutSecretString(id string, data string) (secret *secretsmanager.PutSecretVa
}
svc := secretsmanager.NewFromConfig(cfg)


secret, err = svc.PutSecretValue(context.TODO(), &secretsmanager.PutSecretValueInput{
SecretString: aws.String(data),
SecretId: aws.String(id),
Expand Down Expand Up @@ -204,7 +202,6 @@ func CreateSecretString(id string, data string, description string, tagsCSV stri
}
svc := secretsmanager.NewFromConfig(cfg)


input := secretsmanager.CreateSecretInput{
SecretString: aws.String(data),
Name: aws.String(id),
Expand Down Expand Up @@ -244,7 +241,6 @@ func CreateSecretBinary(id string, data []byte, description string, tagsCSV stri
}
svc := secretsmanager.NewFromConfig(cfg)


input := secretsmanager.CreateSecretInput{
SecretBinary: data,
Name: aws.String(id),
Expand Down

0 comments on commit 9c34770

Please sign in to comment.