diff --git a/.changelog/4091.txt b/.changelog/4091.txt new file mode 100644 index 0000000000..dc67979da8 --- /dev/null +++ b/.changelog/4091.txt @@ -0,0 +1,3 @@ +```release-note:bug +cni: fix incorrect release version due to unstable submodule pinning +``` diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7e451bb854..99038bef56 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -140,7 +140,7 @@ jobs: export GIT_COMMIT=$(git rev-parse --short HEAD) export GIT_DIRTY=$(test -n "$(git status --porcelain)" && echo "+CHANGES") - export GIT_IMPORT=github.com/hashicorp/consul-k8s/${{ matrix.component }}/version + export GIT_IMPORT=github.com/hashicorp/consul-k8s/version export GOLDFLAGS="-X ${GIT_IMPORT}.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X ${GIT_IMPORT}.GitDescribe=${{ needs.get-product-version.outputs.product-version }}" ${{ matrix.env }} go build -o dist/${{ matrix.bin_name }} -ldflags "${GOLDFLAGS}" -tags=${{ matrix.gotags }} . diff --git a/Makefile b/Makefile index 408512c4be..5458bffd53 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = $(shell ./control-plane/build-support/scripts/version.sh control-plane/version/version.go) +VERSION = $(shell ./control-plane/build-support/scripts/version.sh version/version.go) GOLANG_VERSION?=$(shell head -n 1 .go-version) CONSUL_IMAGE_VERSION = $(shell ./control-plane/build-support/scripts/consul-version.sh charts/consul/values.yaml) CONSUL_ENTERPRISE_IMAGE_VERSION = $(shell ./control-plane/build-support/scripts/consul-enterprise-version.sh charts/consul/values.yaml) diff --git a/acceptance/go.mod b/acceptance/go.mod index 2e20d1600b..1cac90636e 100644 --- a/acceptance/go.mod +++ b/acceptance/go.mod @@ -5,6 +5,7 @@ go 1.21.1 toolchain go1.22.0 require ( + github.com/go-logr/logr v1.2.4 github.com/google/uuid v1.3.0 github.com/gruntwork-io/terratest v0.46.7 github.com/hashicorp/consul-k8s/control-plane v0.0.0-20240226161840-f3842c41cb2b @@ -48,9 +49,7 @@ require ( github.com/ghodss/yaml v1.0.0 // indirect github.com/go-errors/errors v1.4.2 // indirect github.com/go-jose/go-jose/v3 v3.0.3 // indirect - github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-logr/zapr v1.2.4 // indirect github.com/go-openapi/analysis v0.21.4 // indirect github.com/go-openapi/errors v0.20.3 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect @@ -122,8 +121,6 @@ require ( go.opentelemetry.io/otel/metric v1.19.0 // indirect go.opentelemetry.io/otel/sdk v1.19.0 // indirect go.opentelemetry.io/otel/trace v1.19.0 // indirect - go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.25.0 // indirect golang.org/x/crypto v0.22.0 // indirect golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect golang.org/x/mod v0.14.0 // indirect diff --git a/acceptance/go.sum b/acceptance/go.sum index ae73cc24a5..e2ebe425ee 100644 --- a/acceptance/go.sum +++ b/acceptance/go.sum @@ -20,9 +20,6 @@ github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/aws/aws-sdk-go v1.44.262 h1:gyXpcJptWoNkK+DiAiaBltlreoWKQXjAIh6FRh60F+I= github.com/aws/aws-sdk-go v1.44.262/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= -github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -464,14 +461,8 @@ go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1 go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo= go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= -go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -488,7 +479,6 @@ golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= 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/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -591,7 +581,6 @@ golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= @@ -600,7 +589,6 @@ golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -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.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= diff --git a/cli/commands.go b/cli/commands.go index 513bd6d9d7..2c2e797673 100644 --- a/cli/commands.go +++ b/cli/commands.go @@ -23,7 +23,7 @@ import ( cmdversion "github.com/hashicorp/consul-k8s/cli/cmd/version" "github.com/hashicorp/consul-k8s/cli/common" "github.com/hashicorp/consul-k8s/cli/common/terminal" - "github.com/hashicorp/consul-k8s/cli/version" + "github.com/hashicorp/consul-k8s/version" "github.com/hashicorp/go-hclog" "github.com/mitchellh/cli" ) diff --git a/cli/go.mod b/cli/go.mod index ac05e5aaef..2429e34b6d 100644 --- a/cli/go.mod +++ b/cli/go.mod @@ -4,12 +4,15 @@ go 1.21 toolchain go1.21.4 +replace github.com/hashicorp/consul-k8s/version => ../version + require ( github.com/bgentry/speakeasy v0.1.0 github.com/cenkalti/backoff v2.2.1+incompatible github.com/fatih/color v1.16.0 github.com/google/go-cmp v0.6.0 github.com/hashicorp/consul-k8s/charts v0.0.0-00010101000000-000000000000 + github.com/hashicorp/consul-k8s/version v0.0.0 github.com/hashicorp/consul/troubleshoot v0.6.1 github.com/hashicorp/go-hclog v1.5.0 github.com/hashicorp/hcp-sdk-go v0.62.1-0.20230913154003-cf69c0370c54 diff --git a/cli/main.go b/cli/main.go index 133e2a28a8..86c2caecc3 100644 --- a/cli/main.go +++ b/cli/main.go @@ -9,7 +9,7 @@ import ( "os/signal" "syscall" - "github.com/hashicorp/consul-k8s/cli/version" + "github.com/hashicorp/consul-k8s/version" "github.com/hashicorp/go-hclog" "github.com/mitchellh/cli" ) diff --git a/control-plane/api-gateway/binding/validation.go b/control-plane/api-gateway/binding/validation.go index ea9208f150..02ca210294 100644 --- a/control-plane/api-gateway/binding/validation.go +++ b/control-plane/api-gateway/binding/validation.go @@ -22,7 +22,7 @@ import ( "github.com/hashicorp/consul-k8s/control-plane/api-gateway/common" "github.com/hashicorp/consul-k8s/control-plane/api/v1alpha1" - "github.com/hashicorp/consul-k8s/control-plane/version" + "github.com/hashicorp/consul-k8s/version" ) var ( diff --git a/control-plane/api-gateway/common/secrets.go b/control-plane/api-gateway/common/secrets.go index 1b7d8dec33..cf05349ace 100644 --- a/control-plane/api-gateway/common/secrets.go +++ b/control-plane/api-gateway/common/secrets.go @@ -13,7 +13,7 @@ import ( "github.com/miekg/dns" corev1 "k8s.io/api/core/v1" - "github.com/hashicorp/consul-k8s/control-plane/version" + "github.com/hashicorp/consul-k8s/version" ) var ( diff --git a/control-plane/build-support/functions/10-util.sh b/control-plane/build-support/functions/10-util.sh index 00cbf9d3fa..3f0a140f9c 100644 --- a/control-plane/build-support/functions/10-util.sh +++ b/control-plane/build-support/functions/10-util.sh @@ -621,11 +621,13 @@ function update_version_helm { local version="$2" local prerelease="$3" local full_version="$2" + local full_version_k8s_for_chart_version="$2" local full_consul_version="$5" local full_consul_dataplane_version="$7" local consul_dataplane_base_path="$8" if ! test -z "$3" && test "$3" != "dev"; then full_version="$2-$3" + full_version_k8s_for_chart_version="$2-$3" full_consul_version="$5-$3" full_consul_dataplane_version="$7-$3" elif test "$3" == "dev"; then @@ -637,6 +639,24 @@ function update_version_helm { full_consul_dataplane_version="${7%.*}-$3" fi + # validate script versions + if test -z "$full_version"; then + err "ERROR: full_version is empty" + return 1 + fi + if test -z "$full_version_k8s_for_chart_version"; then + err "ERROR: full_version_k8s_for_chart_version is empty" + return 1 + fi + if test -z "$full_consul_version"; then + err "ERROR: full_consul_version is empty" + return 1 + fi + if test -z "$full_consul_dataplane_version"; then + err "ERROR: full_consul_dataplane_version is empty" + return 1 + fi + sed_i ${SED_EXT} -e "s/(imageK8S:.*\/consul-k8s-control-plane:)[^\"]*/imageK8S: $4${full_version}/g" "${vfile}" sed_i ${SED_EXT} -e "s/(version:[[:space:]]*)[^\"]*/\1${full_version_k8s_for_chart_version}/g" "${cfile}" sed_i ${SED_EXT} -e "s/(appVersion:[[:space:]]*)[^\"]*/\1${full_consul_version}/g" "${cfile}" @@ -690,13 +710,8 @@ function set_version { local consul_vers="$6" local consul_dataplane_vers="$8" - status_stage "==> Updating control-plane version/version.go with version info: ${vers} "$4"" - if ! update_version "${sdir}/control-plane/version/version.go" "${vers}" "$4"; then - return 1 - fi - - status_stage "==> Updating cli version/version.go with version info: ${vers} "$4"" - if ! update_version "${sdir}/cli/version/version.go" "${vers}" "$4"; then + status_stage "==> Updating version/version.go with version info: ${vers} "$4"" + if ! update_version "${sdir}/version/version.go" "${vers}" "$4"; then return 1 fi diff --git a/control-plane/cni/go.mod b/control-plane/cni/go.mod index 46c81524f2..e27eb9ab3f 100644 --- a/control-plane/cni/go.mod +++ b/control-plane/cni/go.mod @@ -1,9 +1,11 @@ module github.com/hashicorp/consul-k8s/control-plane/cni +replace github.com/hashicorp/consul-k8s/version => ../../version + require ( github.com/containernetworking/cni v1.1.2 github.com/containernetworking/plugins v1.2.0 - github.com/hashicorp/consul-k8s/control-plane v0.0.0-20240326170414-f12a82a84667 + github.com/hashicorp/consul-k8s/version v0.0.0 github.com/hashicorp/consul/sdk v0.16.1 github.com/hashicorp/go-hclog v1.5.0 github.com/stretchr/testify v1.8.4 diff --git a/control-plane/cni/go.sum b/control-plane/cni/go.sum index 1d3d58e0b9..25d890cdd4 100644 --- a/control-plane/cni/go.sum +++ b/control-plane/cni/go.sum @@ -59,8 +59,6 @@ github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hashicorp/consul-k8s/control-plane v0.0.0-20240326170414-f12a82a84667 h1:5pYrzowjHkDl81CdYWZm78LTf0pujXqVWPUXic37DrA= -github.com/hashicorp/consul-k8s/control-plane v0.0.0-20240326170414-f12a82a84667/go.mod h1:7V8Rj0bFQ6l33EdNT6fys6Ga/3np0vMV/S/zv5rPuRs= github.com/hashicorp/consul/sdk v0.16.1 h1:V8TxTnImoPD5cj0U9Spl0TUxcytjcbbJeADFF07KdHg= github.com/hashicorp/consul/sdk v0.16.1/go.mod h1:fSXvwxB2hmh1FMZCNl6PwX0Q/1wdWtHJcZ7Ea5tns0s= github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= diff --git a/control-plane/cni/main.go b/control-plane/cni/main.go index 0f9a32b265..86cc211f71 100644 --- a/control-plane/cni/main.go +++ b/control-plane/cni/main.go @@ -13,8 +13,8 @@ import ( "github.com/containernetworking/cni/pkg/skel" "github.com/containernetworking/cni/pkg/types" current "github.com/containernetworking/cni/pkg/types/100" - "github.com/containernetworking/cni/pkg/version" - cpv "github.com/hashicorp/consul-k8s/control-plane/version" + cniv "github.com/containernetworking/cni/pkg/version" + "github.com/hashicorp/consul-k8s/version" "github.com/hashicorp/consul/sdk/iptables" "github.com/hashicorp/go-hclog" corev1 "k8s.io/api/core/v1" @@ -114,7 +114,7 @@ func parseConfig(stdin []byte) (*PluginConf, error) { // The previous result is passed from the previously run plugin to our plugin. We do not // do anything with the result but instead just pass it on when our plugin is finished. - if err := version.ParsePrevResult(&cfg.NetConf); err != nil { + if err := cniv.ParsePrevResult(&cfg.NetConf); err != nil { return nil, fmt.Errorf("could not parse prevResult: %w", err) } @@ -264,8 +264,8 @@ func cmdCheck(_ *skel.CmdArgs) error { func main() { c := &Command{} - bv.BuildVersion = cpv.GetHumanVersion() - skel.PluginMain(c.cmdAdd, cmdCheck, cmdDel, version.All, bv.BuildString("consul-cni")) + bv.BuildVersion = version.GetHumanVersion() + skel.PluginMain(c.cmdAdd, cmdCheck, cmdDel, cniv.All, bv.BuildString("consul-cni")) } // createK8sClient configures the command's Kubernetes API client if it doesn't diff --git a/control-plane/commands.go b/control-plane/commands.go index 01f5163bc3..16dbc670f7 100644 --- a/control-plane/commands.go +++ b/control-plane/commands.go @@ -27,7 +27,7 @@ import ( cmdTLSInit "github.com/hashicorp/consul-k8s/control-plane/subcommand/tls-init" cmdVersion "github.com/hashicorp/consul-k8s/control-plane/subcommand/version" webhookCertManager "github.com/hashicorp/consul-k8s/control-plane/subcommand/webhook-cert-manager" - "github.com/hashicorp/consul-k8s/control-plane/version" + "github.com/hashicorp/consul-k8s/version" ) // Commands is the mapping of all available consul-k8s commands. diff --git a/control-plane/connect-inject/webhook/mesh_webhook.go b/control-plane/connect-inject/webhook/mesh_webhook.go index beee510b92..f568b3a907 100644 --- a/control-plane/connect-inject/webhook/mesh_webhook.go +++ b/control-plane/connect-inject/webhook/mesh_webhook.go @@ -31,7 +31,7 @@ import ( "github.com/hashicorp/consul-k8s/control-plane/connect-inject/metrics" "github.com/hashicorp/consul-k8s/control-plane/consul" "github.com/hashicorp/consul-k8s/control-plane/namespaces" - "github.com/hashicorp/consul-k8s/control-plane/version" + "github.com/hashicorp/consul-k8s/version" ) const ( diff --git a/control-plane/connect-inject/webhook/mesh_webhook_test.go b/control-plane/connect-inject/webhook/mesh_webhook_test.go index 846fd05219..a880f029c4 100644 --- a/control-plane/connect-inject/webhook/mesh_webhook_test.go +++ b/control-plane/connect-inject/webhook/mesh_webhook_test.go @@ -30,7 +30,7 @@ import ( "github.com/hashicorp/consul-k8s/control-plane/connect-inject/metrics" "github.com/hashicorp/consul-k8s/control-plane/consul" "github.com/hashicorp/consul-k8s/control-plane/namespaces" - "github.com/hashicorp/consul-k8s/control-plane/version" + "github.com/hashicorp/consul-k8s/version" ) func TestHandlerHandle(t *testing.T) { diff --git a/control-plane/connect-inject/webhookv2/mesh_webhook.go b/control-plane/connect-inject/webhookv2/mesh_webhook.go index fc54c3ece2..9676243fef 100644 --- a/control-plane/connect-inject/webhookv2/mesh_webhook.go +++ b/control-plane/connect-inject/webhookv2/mesh_webhook.go @@ -31,7 +31,7 @@ import ( "github.com/hashicorp/consul-k8s/control-plane/connect-inject/metrics" "github.com/hashicorp/consul-k8s/control-plane/consul" "github.com/hashicorp/consul-k8s/control-plane/namespaces" - "github.com/hashicorp/consul-k8s/control-plane/version" + "github.com/hashicorp/consul-k8s/version" ) const ( diff --git a/control-plane/connect-inject/webhookv2/mesh_webhook_test.go b/control-plane/connect-inject/webhookv2/mesh_webhook_test.go index faea725efe..9158449cd3 100644 --- a/control-plane/connect-inject/webhookv2/mesh_webhook_test.go +++ b/control-plane/connect-inject/webhookv2/mesh_webhook_test.go @@ -30,7 +30,7 @@ import ( "github.com/hashicorp/consul-k8s/control-plane/connect-inject/metrics" "github.com/hashicorp/consul-k8s/control-plane/consul" "github.com/hashicorp/consul-k8s/control-plane/namespaces" - "github.com/hashicorp/consul-k8s/control-plane/version" + "github.com/hashicorp/consul-k8s/version" ) func TestHandlerHandle(t *testing.T) { diff --git a/control-plane/consul/consul.go b/control-plane/consul/consul.go index 8dea334607..72a930c8fa 100644 --- a/control-plane/consul/consul.go +++ b/control-plane/consul/consul.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/consul-server-connection-manager/discovery" capi "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul-k8s/control-plane/version" + "github.com/hashicorp/consul-k8s/version" ) //go:generate mockery --name ServerConnectionManager --inpkg diff --git a/control-plane/consul/consul_test.go b/control-plane/consul/consul_test.go index 04afe08033..5f721d59fd 100644 --- a/control-plane/consul/consul_test.go +++ b/control-plane/consul/consul_test.go @@ -9,7 +9,7 @@ import ( "net/http/httptest" "testing" - "github.com/hashicorp/consul-k8s/control-plane/version" + "github.com/hashicorp/consul-k8s/version" capi "github.com/hashicorp/consul/api" "github.com/stretchr/testify/require" ) diff --git a/control-plane/go.mod b/control-plane/go.mod index db29e90540..160bc748fc 100644 --- a/control-plane/go.mod +++ b/control-plane/go.mod @@ -1,5 +1,7 @@ module github.com/hashicorp/consul-k8s/control-plane +replace github.com/hashicorp/consul-k8s/version => ../version + require ( github.com/cenkalti/backoff v2.2.1+incompatible github.com/containernetworking/cni v1.1.2 @@ -11,6 +13,7 @@ require ( github.com/google/go-cmp v0.5.9 github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/hashicorp/consul-k8s/control-plane/cni v0.0.0-20240226161840-f3842c41cb2b + github.com/hashicorp/consul-k8s/version v0.0.0 github.com/hashicorp/consul-server-connection-manager v0.1.6 github.com/hashicorp/consul/api v1.29.1 github.com/hashicorp/consul/proto-public v0.6.1 diff --git a/control-plane/helper/go-discover/discover.go b/control-plane/helper/go-discover/discover.go index 140586634a..6bd56b3364 100644 --- a/control-plane/helper/go-discover/discover.go +++ b/control-plane/helper/go-discover/discover.go @@ -7,7 +7,7 @@ import ( "fmt" "strings" - "github.com/hashicorp/consul-k8s/control-plane/version" + "github.com/hashicorp/consul-k8s/version" "github.com/hashicorp/go-discover" discoverk8s "github.com/hashicorp/go-discover/provider/k8s" "github.com/hashicorp/go-hclog" diff --git a/control-plane/main.go b/control-plane/main.go index 64ccd5d43a..659485ac43 100644 --- a/control-plane/main.go +++ b/control-plane/main.go @@ -9,7 +9,7 @@ import ( "github.com/mitchellh/cli" - "github.com/hashicorp/consul-k8s/control-plane/version" + "github.com/hashicorp/consul-k8s/version" ) func main() { diff --git a/control-plane/subcommand/connect-init/command.go b/control-plane/subcommand/connect-init/command.go index 2d245797dc..6751ffaa3e 100644 --- a/control-plane/subcommand/connect-init/command.go +++ b/control-plane/subcommand/connect-init/command.go @@ -29,7 +29,7 @@ import ( "github.com/hashicorp/consul-k8s/control-plane/namespaces" "github.com/hashicorp/consul-k8s/control-plane/subcommand/common" "github.com/hashicorp/consul-k8s/control-plane/subcommand/flags" - "github.com/hashicorp/consul-k8s/control-plane/version" + "github.com/hashicorp/consul-k8s/version" ) const ( diff --git a/control-plane/subcommand/mesh-init/command.go b/control-plane/subcommand/mesh-init/command.go index ea03577848..5b74607a65 100644 --- a/control-plane/subcommand/mesh-init/command.go +++ b/control-plane/subcommand/mesh-init/command.go @@ -28,7 +28,7 @@ import ( "github.com/hashicorp/consul-k8s/control-plane/consul" "github.com/hashicorp/consul-k8s/control-plane/subcommand/common" "github.com/hashicorp/consul-k8s/control-plane/subcommand/flags" - "github.com/hashicorp/consul-k8s/control-plane/version" + "github.com/hashicorp/consul-k8s/version" ) const ( diff --git a/control-plane/version/fips_build.go b/control-plane/version/fips_build.go deleted file mode 100644 index 63e0e68883..0000000000 --- a/control-plane/version/fips_build.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -//go:build fips - -package version - -// This validates during compilation that we are being built with a FIPS enabled go toolchain -import ( - _ "crypto/tls/fipsonly" - "runtime" - "strings" -) - -// IsFIPS returns true if consul-k8s is operating in FIPS-140-2 mode. -func IsFIPS() bool { - return true -} - -func GetFIPSInfo() string { - str := "Enabled" - // Try to get the crypto module name - gover := strings.Split(runtime.Version(), "X:") - if len(gover) >= 2 { - gover_last := gover[len(gover)-1] - // Able to find crypto module name; add that to status string. - str = "FIPS 140-2 Enabled, crypto module " + gover_last - } - return str -} diff --git a/control-plane/version/non_fips_build.go b/control-plane/version/non_fips_build.go deleted file mode 100644 index ce99575d2c..0000000000 --- a/control-plane/version/non_fips_build.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -//go:build !fips - -package version - -// IsFIPS returns true if consul-k8s is operating in FIPS-140-2 mode. -func IsFIPS() bool { - return false -} - -func GetFIPSInfo() string { - return "" -} diff --git a/control-plane/version/version.go b/control-plane/version/version.go deleted file mode 100644 index e5d773c66d..0000000000 --- a/control-plane/version/version.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package version - -import ( - "fmt" - "strings" -) - -var ( - // The git commit that was compiled. These will be filled in by the compiler. - GitCommit string - GitDescribe string - - // The main version number that is being run at the moment. - // - // Version must conform to the format expected by - // github.com/hashicorp/go-version for tests to work. - Version = "1.6.0" - - // A pre-release marker for the version. If this is "" (empty string) - // then it means that it is a final release. Otherwise, this is a pre-release - // such as "dev" (in development), "beta", "rc1", etc. - VersionPrerelease = "dev" -) - -// GetHumanVersion composes the parts of the version in a way that's suitable -// for displaying to humans. -func GetHumanVersion() string { - version := Version - if GitDescribe != "" { - version = GitDescribe - } - version = fmt.Sprintf("v%s", version) - - release := VersionPrerelease - if GitDescribe == "" && release == "" { - release = "dev" - } - - if IsFIPS() { - version += "+fips1402" - } - - if release != "" { - if !strings.Contains(version, "-"+release) { - // if we tagged a prerelease version then the release is in the version already - version += fmt.Sprintf("-%s", release) - } - if GitCommit != "" { - version += fmt.Sprintf(" (%s)", GitCommit) - } - } - - // Strip off any single quotes added by the git information. - return strings.Replace(version, "'", "", -1) -} diff --git a/cli/version/fips_build.go b/version/fips_build.go similarity index 100% rename from cli/version/fips_build.go rename to version/fips_build.go diff --git a/version/go.mod b/version/go.mod new file mode 100644 index 0000000000..b3772ec6bd --- /dev/null +++ b/version/go.mod @@ -0,0 +1,3 @@ +module github.com/hashicorp/consul-k8s/version + +go 1.20 diff --git a/cli/version/non_fips_build.go b/version/non_fips_build.go similarity index 100% rename from cli/version/non_fips_build.go rename to version/non_fips_build.go diff --git a/cli/version/version.go b/version/version.go similarity index 100% rename from cli/version/version.go rename to version/version.go