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

Backport of [NET-9839] fix: add shared version submodule (#4091) into release/1.3.x #4097

Merged
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
3 changes: 3 additions & 0 deletions .changelog/4091.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
cni: fix incorrect release version due to unstable submodule pinning
```
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,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 }} .
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
3 changes: 3 additions & 0 deletions cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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.3.0-rc1
github.com/hashicorp/go-hclog v1.5.0
github.com/hashicorp/hcp-sdk-go v0.62.1-0.20230913154003-cf69c0370c54
Expand Down
2 changes: 1 addition & 1 deletion cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion control-plane/api-gateway/binding/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion control-plane/api-gateway/common/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
29 changes: 22 additions & 7 deletions control-plane/build-support/functions/10-util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -636,6 +638,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}/g" "${cfile}"
sed_i ${SED_EXT} -e "s/(appVersion:[[:space:]]*)[^\"]*/\1${full_consul_version}/g" "${cfile}"
Expand Down Expand Up @@ -689,13 +709,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

Expand Down
3 changes: 3 additions & 0 deletions control-plane/cni/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +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/version v0.0.0
github.com/hashicorp/consul/sdk v0.13.1
github.com/hashicorp/go-hclog v1.2.2
github.com/stretchr/testify v1.8.4
Expand Down
8 changes: 5 additions & 3 deletions control-plane/cni/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +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"
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"
Expand Down Expand Up @@ -110,7 +111,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)
}

Expand Down Expand Up @@ -246,7 +247,8 @@ func cmdCheck(_ *skel.CmdArgs) error {

func main() {
c := &Command{}
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"))
}

// skipTrafficRedirection looks for annotations on the pod and determines if it should skip traffic redirection.
Expand Down
2 changes: 1 addition & 1 deletion control-plane/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion control-plane/connect-inject/webhook/mesh_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion control-plane/connect-inject/webhook/mesh_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion control-plane/connect-inject/webhookv2/mesh_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion control-plane/consul/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion control-plane/consul/consul_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
3 changes: 3 additions & 0 deletions control-plane/go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,6 +12,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-20230825213844-4ea04860c5ed
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.10.1-0.20240122160221-1c7e9443cbcd
github.com/hashicorp/consul/proto-public v0.5.1
Expand Down
2 changes: 1 addition & 1 deletion control-plane/helper/go-discover/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion control-plane/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion control-plane/subcommand/connect-init/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion control-plane/subcommand/mesh-init/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
30 changes: 0 additions & 30 deletions control-plane/version/fips_build.go

This file was deleted.

15 changes: 0 additions & 15 deletions control-plane/version/non_fips_build.go

This file was deleted.

58 changes: 0 additions & 58 deletions control-plane/version/version.go

This file was deleted.

File renamed without changes.
3 changes: 3 additions & 0 deletions version/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/hashicorp/consul-k8s/version

go 1.20
File renamed without changes.
File renamed without changes.
Loading