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

build: Adopt go.work and remove submodule replace statements #21657

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 4 additions & 1 deletion .github/workflows/reusable-check-go-mod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ jobs:
- run: make go-mod-tidy
- run: |
if [[ -n $(git status -s) ]]; then
echo "Git directory has changes"
echo "Git directory has changes after running 'make go-mod-tidy'."
echo "This means go.mod/go.sum have entries that have not been cleaned up, or go.mod and go.work are out of sync."
echo
echo "Run 'make go-mod-tidy' locally, then review and commit changes to resolve."
git status -s
exit 1
fi
4 changes: 3 additions & 1 deletion .github/workflows/security-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ jobs:

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
path: consul

- name: Set up Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
Expand All @@ -71,7 +73,7 @@ jobs:
id: scan
uses: ./security-scanner
with:
repository: "$PWD"
repository: "$PWD/consul"
# See scan.hcl at repository root for config.

- name: SARIF Output
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ override.tf.json
# Ignore CLI configuration files
.terraformrc
terraform.rc
/go.work
/go.work.sum
.docker

# Avoid accidental commits of consul-k8s submodule used by some dev environments
Expand Down
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ issues:
text: 'SA1019:'
path: "(agent/grpc-external|agent/grpc-internal)"

# Allow usage of deprecated grpc DialContext and WithBlock until we've migrated from it.
- linters: [ staticcheck ]
text: '(Dial|DialContext) is deprecated: use NewClient instead'
- linters: [ staticcheck ]
text: 'WithBlock is deprecated: this DialOption is not supported by NewClient'

# An argument that always receives the same value is often not a problem.
- linters: [unparam]
text: "always receives"
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,13 @@ linux: ## Linux builds a linux binary compatible with the source platform
@mkdir -p ./pkg/bin/linux_$(GOARCH)
CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) go build -o ./pkg/bin/linux_$(GOARCH) -ldflags "$(GOLDFLAGS)" -tags "$(GOTAGS)"

.PHONY: go-work-sync
go-work-sync:
@echo "--> Running go work sync (.)"
@go work sync

.PHONY: go-mod-tidy
go-mod-tidy: $(foreach mod,$(GO_MODULES),go-mod-tidy/$(mod)) ## Run go mod tidy in every module
go-mod-tidy: go-work-sync $(foreach mod,$(GO_MODULES),go-mod-tidy/$(mod)) ## Run go mod tidy in every module

.PHONY: mod-tidy/%
go-mod-tidy/%:
Expand Down
8 changes: 4 additions & 4 deletions agent/grpc-middleware/testutil/testservice/simple.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions agent/hcp/telemetry/otel_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

goMetrics "github.com/armon/go-metrics"
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/aggregation"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
metricpb "go.opentelemetry.io/proto/otlp/metrics/v1"
)
Expand Down Expand Up @@ -54,18 +53,18 @@ func (e *otelExporter) Temporality(_ metric.InstrumentKind) metricdata.Temporali
// Aggregation returns the Aggregation to use for an instrument kind.
// The default implementation provided by the OTEL Metrics SDK library DefaultAggregationSelector panics.
// This custom version replicates that logic, but removes the panic.
func (e *otelExporter) Aggregation(kind metric.InstrumentKind) aggregation.Aggregation {
func (e *otelExporter) Aggregation(kind metric.InstrumentKind) metric.Aggregation {
switch kind {
case metric.InstrumentKindObservableGauge:
return aggregation.LastValue{}
return metric.AggregationLastValue{}
case metric.InstrumentKindHistogram:
return aggregation.ExplicitBucketHistogram{
return metric.AggregationExplicitBucketHistogram{
Boundaries: []float64{0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000},
NoMinMax: false,
}
}
// for metric.InstrumentKindCounter and others, default to sum.
return aggregation.Sum{}
return metric.AggregationSum{}
}

// Export serializes and transmits metric data to a receiver.
Expand Down
9 changes: 4 additions & 5 deletions agent/hcp/telemetry/otel_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/armon/go-metrics"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/aggregation"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
"go.opentelemetry.io/otel/sdk/resource"
metricpb "go.opentelemetry.io/proto/otlp/metrics/v1"
Expand Down Expand Up @@ -50,19 +49,19 @@ func TestAggregation(t *testing.T) {
t.Parallel()
for name, test := range map[string]struct {
kind metric.InstrumentKind
expAgg aggregation.Aggregation
expAgg metric.Aggregation
}{
"gauge": {
kind: metric.InstrumentKindObservableGauge,
expAgg: aggregation.LastValue{},
expAgg: metric.AggregationLastValue{},
},
"counter": {
kind: metric.InstrumentKindCounter,
expAgg: aggregation.Sum{},
expAgg: metric.AggregationSum{},
},
"histogram": {
kind: metric.InstrumentKindHistogram,
expAgg: aggregation.ExplicitBucketHistogram{Boundaries: []float64{0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000}, NoMinMax: false},
expAgg: metric.AggregationExplicitBucketHistogram{Boundaries: []float64{0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000}, NoMinMax: false},
},
} {
test := test
Expand Down
28 changes: 16 additions & 12 deletions api/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/hashicorp/consul/api

go 1.19
go 1.22

replace github.com/hashicorp/consul/sdk => ../sdk
toolchain go1.22.6

retract (
v1.29.5 // cut from incorrect branch
Expand All @@ -12,41 +12,45 @@ retract (
)

require (
github.com/google/go-cmp v0.5.9
github.com/google/go-cmp v0.6.0
github.com/hashicorp/consul/sdk v0.16.1
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/go-hclog v1.5.0
github.com/hashicorp/go-hclog v1.6.3
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-rootcerts v1.0.2
github.com/hashicorp/go-uuid v1.0.3
github.com/hashicorp/serf v0.10.1
github.com/mitchellh/mapstructure v1.5.0
github.com/stretchr/testify v1.8.4
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
)

require (
github.com/armon/go-metrics v0.4.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-msgpack v0.5.5 // indirect
github.com/hashicorp/go-sockaddr v1.0.2 // indirect
github.com/hashicorp/go-version v1.2.1 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/memberlist v0.5.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/miekg/dns v1.1.41 // indirect
github.com/miekg/dns v1.1.50 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect
github.com/stretchr/objx v0.5.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sync v0.2.0 // indirect
golang.org/x/sys v0.19.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/tools v0.22.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading