diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml index afa0c1ba80..6782a3e4d7 100644 --- a/.github/workflows/go-tests.yml +++ b/.github/workflows/go-tests.yml @@ -96,29 +96,28 @@ jobs: - name: Notify Slack if: ${{ failure() }} run: .github/scripts/notify_slack.sh - # Temporarily changing until the situation with license headers in the generated code can be worked out - # check-generated-deep-copy: - # needs: - # - setup - # runs-on: ${{ fromJSON(needs.setup.outputs.compute-large) }} - # steps: - # - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - # # NOTE: This step is specifically needed for ENT. It allows us to access the required private HashiCorp repos. - # - name: Setup Git - # if: ${{ endsWith(github.repository, '-enterprise') }} - # run: git config --global url."https://${{ secrets.ELEVATED_GITHUB_TOKEN }}:@github.com".insteadOf "https://github.com" - # - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 - # with: - # go-version-file: 'go.mod' - # - run: make --always-make deep-copy - # - run: | - # if ! git diff --exit-code; then - # echo "Generated code was not updated correctly" - # exit 1 - # fi - # - name: Notify Slack - # if: ${{ failure() }} - # run: .github/scripts/notify_slack.sh + check-codegen: + needs: + - setup + runs-on: ${{ fromJSON(needs.setup.outputs.compute-large) }} + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + # NOTE: This step is specifically needed for ENT. It allows us to access the required private HashiCorp repos. + - name: Setup Git + if: ${{ endsWith(github.repository, '-enterprise') }} + run: git config --global url."https://${{ secrets.ELEVATED_GITHUB_TOKEN }}:@github.com".insteadOf "https://github.com" + - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 + with: + go-version-file: 'go.mod' + - run: make --always-make codegen + - run: | + if ! git diff --exit-code; then + echo "Generated code was not updated correctly" + exit 1 + fi + - name: Notify Slack + if: ${{ failure() }} + run: .github/scripts/notify_slack.sh lint-enums: needs: @@ -486,8 +485,7 @@ jobs: needs: - conditional-skip - setup - # Reenable later - #- check-generated-deep-copy + - check-codegen - check-generated-protobuf - check-go-mod - lint-consul-retry diff --git a/Makefile b/Makefile index a94d2d247a..73d381cff5 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,7 @@ MOG_VERSION='v0.4.0' PROTOC_GO_INJECT_TAG_VERSION='v1.3.0' PROTOC_GEN_GO_BINARY_VERSION="v0.1.0" DEEP_COPY_VERSION='bc3f5aa5735d8a54961580a3a24422c308c831c2' +COPYWRITE_TOOL_VERSION='v0.16.4' MOCKED_PB_DIRS= pbdns @@ -427,12 +428,13 @@ lint-tools: ## Install tools for linting codegen-tools: ## Install tools for codegen @$(SHELL) $(CURDIR)/build-support/scripts/devtools.sh -codegen -.PHONY: deep-copy -deep-copy: codegen-tools ## Deep copy +.PHONY: codegen +codegen: codegen-tools ## Deep copy @$(SHELL) $(CURDIR)/agent/structs/deep-copy.sh @$(SHELL) $(CURDIR)/agent/proxycfg/deep-copy.sh @$(SHELL) $(CURDIR)/agent/consul/state/deep-copy.sh @$(SHELL) $(CURDIR)/agent/config/deep-copy.sh + copywrite headers print-% : ; @echo $($*) ## utility to echo a makefile variable (i.e. 'make print-GOPATH') diff --git a/agent/config/config.deepcopy.go b/agent/config/config.deepcopy.go index 9e6b3e06ff..2a5ebfce27 100644 --- a/agent/config/config.deepcopy.go +++ b/agent/config/config.deepcopy.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + // generated by deep-copy -pointer-receiver -o ./config.deepcopy.go -type RuntimeConfig ./; DO NOT EDIT. package config diff --git a/agent/proxycfg-sources/catalog/config_source_oss.go b/agent/proxycfg-sources/catalog/config_source_oss.go index 21ddede882..1d2da03b42 100644 --- a/agent/proxycfg-sources/catalog/config_source_oss.go +++ b/agent/proxycfg-sources/catalog/config_source_oss.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + //go:build !consulent // +build !consulent diff --git a/agent/proxycfg/config_snapshot_glue.go b/agent/proxycfg/config_snapshot_glue.go index 7d1c1d9770..6355e0595e 100644 --- a/agent/proxycfg/config_snapshot_glue.go +++ b/agent/proxycfg/config_snapshot_glue.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + package proxycfg import ( diff --git a/agent/proxycfg/config_snapshot_glue_test.go b/agent/proxycfg/config_snapshot_glue_test.go index 6ff20714eb..ed7a9afc1f 100644 --- a/agent/proxycfg/config_snapshot_glue_test.go +++ b/agent/proxycfg/config_snapshot_glue_test.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + package proxycfg import ( diff --git a/build-support/scripts/devtools.sh b/build-support/scripts/devtools.sh index edf4b83eae..6c14e99427 100755 --- a/build-support/scripts/devtools.sh +++ b/build-support/scripts/devtools.sh @@ -149,14 +149,30 @@ function lint_install { } function codegen_install { - local deep_copy_version - deep_copy_version="$(make --no-print-directory print-DEEP_COPY_VERSION)" + deepcopy_install + copywrite_install +} + +function deepcopy_install { + local deep_copy_version + deep_copy_version="$(make --no-print-directory print-DEEP_COPY_VERSION)" + + install_versioned_tool \ + 'deep-copy' \ + 'github.com/globusdigital/deep-copy' \ + "${deep_copy_version}" \ + 'github.com/globusdigital/deep-copy' +} + +function copywrite_install { + local copywrite_version + copywrite_version="$(make --no-print-directory print-COPYWRITE_TOOL_VERSION)" install_versioned_tool \ - 'deep-copy' \ - 'github.com/globusdigital/deep-copy' \ - "${deep_copy_version}" \ - 'github.com/globusdigital/deep-copy' + 'copywrite' \ + 'github.com/hashicorp/copywrite' \ + "${copywrite_version}" \ + 'github.com/hashicorp/copywrite' } function tools_install { @@ -164,6 +180,7 @@ function tools_install { lint_install proto_tools_install codegen_install + copywrite_install return 0 } diff --git a/command/resource/testdata/demo.hcl b/command/resource/testdata/demo.hcl index 473cab6089..35e72aba31 100644 --- a/command/resource/testdata/demo.hcl +++ b/command/resource/testdata/demo.hcl @@ -1,3 +1,6 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: BUSL-1.1 + ID { Type = gvk("demo.v2.Artist") Name = "korn" diff --git a/command/resource/testdata/invalid.hcl b/command/resource/testdata/invalid.hcl index edac039dca..04c08e9212 100644 --- a/command/resource/testdata/invalid.hcl +++ b/command/resource/testdata/invalid.hcl @@ -1,3 +1,6 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: BUSL-1.1 + ID { Type = gvk("demo.v2.Artist") Name = "korn" diff --git a/command/resource/testdata/invalid_type.hcl b/command/resource/testdata/invalid_type.hcl index b24e5699cf..b3b87ae245 100644 --- a/command/resource/testdata/invalid_type.hcl +++ b/command/resource/testdata/invalid_type.hcl @@ -1,3 +1,6 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: BUSL-1.1 + D { Type = gvk("demo.v2.Artist") Tenancy { diff --git a/command/resource/testdata/nested_data.hcl b/command/resource/testdata/nested_data.hcl index c0993e4d5b..2353cccadd 100644 --- a/command/resource/testdata/nested_data.hcl +++ b/command/resource/testdata/nested_data.hcl @@ -1,3 +1,6 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: BUSL-1.1 + ID { Type = gvk("mesh.v1alpha1.Upstreams") Name = "api" diff --git a/internal/mesh/internal/cache/sidecarproxycache/destinations_cache.go b/internal/mesh/internal/cache/sidecarproxycache/destinations_cache.go index e2b04e0aa4..cd73bdfec8 100644 --- a/internal/mesh/internal/cache/sidecarproxycache/destinations_cache.go +++ b/internal/mesh/internal/cache/sidecarproxycache/destinations_cache.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + package sidecarproxycache import ( diff --git a/internal/mesh/internal/cache/sidecarproxycache/destinations_cache_test.go b/internal/mesh/internal/cache/sidecarproxycache/destinations_cache_test.go index 529a498b43..0483af6fd9 100644 --- a/internal/mesh/internal/cache/sidecarproxycache/destinations_cache_test.go +++ b/internal/mesh/internal/cache/sidecarproxycache/destinations_cache_test.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + package sidecarproxycache import ( diff --git a/internal/mesh/internal/controllers/xds/proxy_tracker_watch.go b/internal/mesh/internal/controllers/xds/proxy_tracker_watch.go index 419a200a91..cf21dc0f7f 100644 --- a/internal/mesh/internal/controllers/xds/proxy_tracker_watch.go +++ b/internal/mesh/internal/controllers/xds/proxy_tracker_watch.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + package xds import ( diff --git a/internal/mesh/proxy-snapshot/proxy_snapshot.go b/internal/mesh/proxy-snapshot/proxy_snapshot.go index 40763f568c..e1c972c08a 100644 --- a/internal/mesh/proxy-snapshot/proxy_snapshot.go +++ b/internal/mesh/proxy-snapshot/proxy_snapshot.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + package proxysnapshot import "github.com/hashicorp/consul/acl" diff --git a/internal/mesh/proxy-tracker/proxy_state_exports.go b/internal/mesh/proxy-tracker/proxy_state_exports.go index 59c4e1070f..ca8a6594a4 100644 --- a/internal/mesh/proxy-tracker/proxy_state_exports.go +++ b/internal/mesh/proxy-tracker/proxy_state_exports.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + package proxytracker import ( diff --git a/logging/logfile_bsd.go b/logging/logfile_bsd.go index d81d065be1..3c5be0a370 100644 --- a/logging/logfile_bsd.go +++ b/logging/logfile_bsd.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + //go:build darwin || freebsd || netbsd || openbsd // +build darwin freebsd netbsd openbsd diff --git a/logging/logfile_linux.go b/logging/logfile_linux.go index 6cdacfe80e..e852d392bc 100644 --- a/logging/logfile_linux.go +++ b/logging/logfile_linux.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + //go:build dragonfly || linux // +build dragonfly linux diff --git a/logging/logfile_solaris.go b/logging/logfile_solaris.go index b64610cc38..3d99ab3477 100644 --- a/logging/logfile_solaris.go +++ b/logging/logfile_solaris.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + //go:build solaris // +build solaris diff --git a/logging/logfile_windows.go b/logging/logfile_windows.go index 688a8351cd..d60f8d2a99 100644 --- a/logging/logfile_windows.go +++ b/logging/logfile_windows.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + package logging import ( diff --git a/test-integ/go.mod b/test-integ/go.mod index 2049ba1316..9557119b87 100644 --- a/test-integ/go.mod +++ b/test-integ/go.mod @@ -90,7 +90,7 @@ require ( github.com/googleapis/gax-go/v2 v2.11.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect - github.com/hashicorp/consul v0.0.0-00010101000000-000000000000 // indirect + github.com/hashicorp/consul v1.16.1 // indirect github.com/hashicorp/consul-awsauth v0.0.0-20220713182709-05ac1c5c2706 // indirect github.com/hashicorp/consul-net-rpc v0.0.0-20221205195236-156cfab66a69 // indirect github.com/hashicorp/consul/envoyextensions v0.4.1 // indirect @@ -204,7 +204,7 @@ require ( go.opentelemetry.io/proto/otlp v0.19.0 // indirect go.uber.org/atomic v1.9.0 // indirect golang.org/x/crypto v0.12.0 // indirect - golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b // indirect + golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.14.0 // indirect golang.org/x/oauth2 v0.8.0 // indirect @@ -213,7 +213,7 @@ require ( golang.org/x/term v0.11.0 // indirect golang.org/x/text v0.12.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.11.1 // indirect + golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect google.golang.org/api v0.126.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230726155614-23370e0ffb3e // indirect diff --git a/test-integ/go.sum b/test-integ/go.sum index 1a7c67d76a..0cc1e0467d 100644 --- a/test-integ/go.sum +++ b/test-integ/go.sum @@ -853,8 +853,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b h1:r+vk0EmXNmekl0S0BascoeeoHk/L7wmaW2QF90K+kYI= -golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ= +golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1126,8 +1126,8 @@ golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.11.1 h1:ojD5zOW8+7dOGzdnNgersm8aPfcDjhMp12UfG93NIMc= -golang.org/x/tools v0.11.1/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= +golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 h1:Vve/L0v7CXXuxUmaMGIEK/dEeq7uiqb5qBgQrZzIE7E= +golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=