Skip to content

Commit

Permalink
🧹 Replace archived packages (#1490)
Browse files Browse the repository at this point in the history
For background on the mapstructure, see here for more details: mondoohq/cnquery#4851

Signed-off-by: Christian Zunker <[email protected]>
  • Loading branch information
czunker authored Nov 25, 2024
1 parent a73b2c0 commit 707e9ac
Show file tree
Hide file tree
Showing 21 changed files with 35 additions and 26 deletions.
10 changes: 10 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ linters:
disable-all: true
enable:
- gofmt
- depguard
# deactivated for now since its slow in github actions
# - govet

Expand All @@ -28,3 +29,12 @@ linters-settings:
- structtag
- lostcancel
disable-all: true

depguard:
rules:
denied-packages:
deny:
- pkg: "github.com/pkg/errors"
desc: "no longer maintained; use github.com/cockroachdb/errors instead"
- pkg: "github.com/mitchellh/mapstructure"
desc: "no longer maintained; use github.com/go-viper/mapstructure/v2 instead"
2 changes: 1 addition & 1 deletion apps/cnspec/cmd/backgroundjob/checkin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"context"
"net/http"

"github.com/pkg/errors"
"github.com/cockroachdb/errors"
"go.mondoo.com/cnquery/v11"
"go.mondoo.com/cnquery/v11/providers-sdk/v1/sysinfo"
"go.mondoo.com/cnquery/v11/providers-sdk/v1/upstream"
Expand Down
2 changes: 1 addition & 1 deletion apps/cnspec/cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"os/exec"
"runtime"

"github.com/pkg/errors"
"github.com/cockroachdb/errors"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"go.mondoo.com/cnquery/v11/cli/config"
Expand Down
2 changes: 1 addition & 1 deletion cli/reporter/junit.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"fmt"
"strconv"

mapstructure "github.com/go-viper/mapstructure/v2"
"github.com/jstemmer/go-junit-report/v2/junit"
"github.com/mitchellh/mapstructure"
"go.mondoo.com/cnquery/v11/explorer"
"go.mondoo.com/cnquery/v11/providers-sdk/v1/inventory"
"go.mondoo.com/cnquery/v11/providers-sdk/v1/upstream/mvd"
Expand Down
2 changes: 1 addition & 1 deletion cli/reporter/render_advisory_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strconv"
"strings"

"github.com/mitchellh/mapstructure"
mapstructure "github.com/go-viper/mapstructure/v2"
"github.com/muesli/termenv"
"github.com/rs/zerolog/log"
"go.mondoo.com/cnquery/v11/cli/printer"
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/aws/aws-sdk-go-v2/config v1.28.5
github.com/aws/aws-sdk-go-v2/service/s3 v1.68.0
github.com/cockroachdb/errors v1.11.3
github.com/go-viper/mapstructure/v2 v2.2.1
github.com/google/go-cmdtest v0.4.0
github.com/google/uuid v1.6.0
github.com/hashicorp/go-multierror v1.1.1
Expand All @@ -22,13 +23,11 @@ require (
github.com/hashicorp/terraform-json v0.23.0
github.com/jstemmer/go-junit-report/v2 v2.1.0
github.com/mattn/go-isatty v0.0.20
github.com/mitchellh/mapstructure v1.5.0
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6
github.com/muesli/reflow v0.3.0
github.com/muesli/termenv v0.15.2
github.com/olekukonko/tablewriter v0.0.5
github.com/owenrumney/go-sarif/v2 v2.3.3
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.33.0
github.com/segmentio/fasthash v1.0.3
github.com/segmentio/ksuid v1.0.4
Expand Down Expand Up @@ -167,7 +166,6 @@ require (
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
Expand Down Expand Up @@ -231,6 +229,7 @@ require (
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/buildkit v0.17.1 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
Expand All @@ -246,6 +245,7 @@ require (
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/sftp v1.13.7 // indirect
github.com/pkg/term v1.2.0-beta.2 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
Expand Down
8 changes: 4 additions & 4 deletions internal/onboarding/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import (

"github.com/Masterminds/semver"
"github.com/abiosoft/colima/util/terminal"
"github.com/cockroachdb/errors"
"github.com/hashicorp/go-version"
"github.com/hashicorp/hc-install/product"
"github.com/hashicorp/hc-install/releases"
"github.com/hashicorp/terraform-exec/tfexec"
tfjson "github.com/hashicorp/terraform-json"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"go.mondoo.com/cnquery/v11/cli/components"
"go.mondoo.com/cnquery/v11/cli/theme"
Expand All @@ -45,7 +45,7 @@ func WriteHCL(hcl string, location string, identifier string) (string, error) {
if os.IsNotExist(err) {
directory := filepath.FromSlash(dirname)
if _, err := os.Stat(directory); os.IsNotExist(err) {
err = os.MkdirAll(directory, 0700)
err = os.MkdirAll(directory, 0o700)
if err != nil {
return "", err
}
Expand All @@ -54,7 +54,7 @@ func WriteHCL(hcl string, location string, identifier string) (string, error) {

// Create HCL file
outputLocation := filepath.FromSlash(fmt.Sprintf("%s/main.tf", dirname))
err = os.WriteFile(filepath.FromSlash(outputLocation), []byte(hcl), 0700)
err = os.WriteFile(filepath.FromSlash(outputLocation), []byte(hcl), 0o700)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -225,7 +225,6 @@ func newTf(workingDir string, execPath string) (*tfexec.Terraform, error) {
}

func TerraformInit(tf *tfexec.Terraform) error {

vw := terminal.NewVerboseWriter(10)
tf.SetStdout(vw)
tf.SetStderr(vw)
Expand Down Expand Up @@ -271,6 +270,7 @@ func processTfPlanChangesSummary(tf *tfexec.Terraform) (*TfPlanChangesSummary, e

return parseTfPlanOutput(plan), nil
}

func parseTfPlanOutput(plan *tfjson.Plan) *TfPlanChangesSummary {
// Build output of changes
resourceCreate := 0
Expand Down
2 changes: 1 addition & 1 deletion policy/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"sort"
"strings"

"github.com/pkg/errors"
"github.com/cockroachdb/errors"
"github.com/rs/zerolog/log"
"go.mondoo.com/cnquery/v11"
"go.mondoo.com/cnquery/v11/checksums"
Expand Down
2 changes: 1 addition & 1 deletion policy/bundle_file_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"path/filepath"
"strings"

"github.com/pkg/errors"
"github.com/cockroachdb/errors"
"github.com/rs/zerolog/log"
)

Expand Down
2 changes: 1 addition & 1 deletion policy/bundle_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"context"
"strings"

"github.com/cockroachdb/errors"
"github.com/hashicorp/go-version"
"github.com/pkg/errors"
"go.mondoo.com/cnquery/v11/explorer"
"go.mondoo.com/cnquery/v11/llx"
"go.mondoo.com/cnquery/v11/mqlc"
Expand Down
2 changes: 1 addition & 1 deletion policy/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"context"
"sort"

"github.com/pkg/errors"
"github.com/cockroachdb/errors"
"github.com/rs/zerolog/log"
"go.mondoo.com/cnquery/v11/checksums"
"go.mondoo.com/cnquery/v11/mrn"
Expand Down
2 changes: 1 addition & 1 deletion policy/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"os"
"path"

"github.com/pkg/errors"
"github.com/cockroachdb/errors"
"github.com/rs/zerolog/log"
"go.mondoo.com/cnquery/v11/explorer"
"go.mondoo.com/cnquery/v11/logger"
Expand Down
2 changes: 1 addition & 1 deletion policy/mquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package policy
import (
"sort"

"github.com/pkg/errors"
"github.com/cockroachdb/errors"
"go.mondoo.com/cnquery/v11/checksums"
"go.mondoo.com/cnquery/v11/explorer"
"go.mondoo.com/cnquery/v11/mqlc"
Expand Down
2 changes: 1 addition & 1 deletion policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"
"time"

"github.com/pkg/errors"
"github.com/cockroachdb/errors"
"github.com/rs/zerolog/log"
"go.mondoo.com/cnquery/v11/checksums"
"go.mondoo.com/cnquery/v11/explorer"
Expand Down
2 changes: 1 addition & 1 deletion policy/resolved_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package policy

import (
"github.com/pkg/errors"
"github.com/cockroachdb/errors"
"go.mondoo.com/cnquery/v11/explorer"
"go.mondoo.com/cnquery/v11/llx"
"go.mondoo.com/cnquery/v11/types"
Expand Down
3 changes: 1 addition & 2 deletions policy/resolved_policy_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"
"time"

"github.com/pkg/errors"
"github.com/cockroachdb/errors"
"github.com/rs/zerolog/log"
"go.mondoo.com/cnquery/v11/explorer"
"go.mondoo.com/cnquery/v11/llx"
Expand Down Expand Up @@ -115,7 +115,6 @@ func buildResolvedPolicy(ctx context.Context, bundleMrn string, bundle *Bundle,
if err := walk(edgeNode); err != nil {
return err
}

} else {
log.Debug().Str("from", node.getId()).Str("to", edge).Msg("edge not found")
}
Expand Down
2 changes: 1 addition & 1 deletion policy/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"sort"
"time"

"github.com/pkg/errors"
"github.com/cockroachdb/errors"
"github.com/rs/zerolog/log"
"github.com/segmentio/fasthash/fnv1a"
"go.mondoo.com/cnquery/v11/checksums"
Expand Down
2 changes: 1 addition & 1 deletion policy/risk_factor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"encoding/json"
"strconv"

"github.com/pkg/errors"
"github.com/cockroachdb/errors"
"github.com/rs/zerolog/log"
"go.mondoo.com/cnquery/v11/checksums"
"go.mondoo.com/cnquery/v11/mqlc"
Expand Down
2 changes: 1 addition & 1 deletion policy/scan/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"io"
"net/http"

"github.com/pkg/errors"
"github.com/cockroachdb/errors"
"go.mondoo.com/cnquery/v11/mqlc"
"go.mondoo.com/cnspec/v11"
"go.mondoo.com/cnspec/v11/policy"
Expand Down
2 changes: 1 addition & 1 deletion policy/scan/local_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"sync"
"time"

"github.com/pkg/errors"
"github.com/cockroachdb/errors"
"github.com/rs/zerolog/log"
"github.com/segmentio/ksuid"
"go.mondoo.com/cnquery/v11"
Expand Down
2 changes: 1 addition & 1 deletion policy/score_calculator.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"math"
"strconv"

"github.com/pkg/errors"
"github.com/cockroachdb/errors"
"go.mondoo.com/cnquery/v11/explorer"
"google.golang.org/protobuf/proto"
)
Expand Down

0 comments on commit 707e9ac

Please sign in to comment.