From 05f6268765f94c920bcdd8baf5917c5e01ad10cb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 13 May 2026 14:26:47 +0000 Subject: [PATCH 1/2] Initial plan From cfc6ea4949aa6e80dda765c96e83d8de21fd0f18 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 13 May 2026 14:32:12 +0000 Subject: [PATCH 2/2] feat: include CLI version in User-Agent header Agent-Logs-Url: https://github.com/mia-platform/miactl/sessions/39f75b65-2f8e-4927-9c1c-d7720fed3fea Co-authored-by: ThisIsDemetrio <5429953+ThisIsDemetrio@users.noreply.github.com> --- Makefile | 2 +- internal/clioptions/clioptions.go | 5 +++++ internal/cmd/version.go | 9 ++------- internal/version/version.go | 22 ++++++++++++++++++++++ 4 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 internal/version/version.go diff --git a/Makefile b/Makefile index 56abc8af..25fd0278 100644 --- a/Makefile +++ b/Makefile @@ -84,7 +84,7 @@ GIT_REV:= $(shell git rev-parse --short HEAD 2>/dev/null) VERSION:= $(shell git describe --tags --exact-match 2>/dev/null || (echo $(GIT_REV) | cut -c1-12)) endif # insert here the go module where to add the version metadata -VERSION_MODULE_NAME:= github.com/mia-platform/miactl/internal/cmd +VERSION_MODULE_NAME:= github.com/mia-platform/miactl/internal/version # supported platforms for container creation, these are a subset of the supported # platforms of the base image. diff --git a/internal/clioptions/clioptions.go b/internal/clioptions/clioptions.go index 53516a88..86503ef5 100644 --- a/internal/clioptions/clioptions.go +++ b/internal/clioptions/clioptions.go @@ -24,6 +24,7 @@ import ( "github.com/mia-platform/miactl/internal/cliconfig" "github.com/mia-platform/miactl/internal/client" "github.com/mia-platform/miactl/internal/logger" + "github.com/mia-platform/miactl/internal/version" "github.com/spf13/cobra" "github.com/spf13/pflag" @@ -363,6 +364,10 @@ func defaultUserAgent() string { command = filepath.Base(osCommand) } + if version.Version != "" { + command = fmt.Sprintf("%s@%s", command, version.Version) + } + os := runtime.GOOS arch := runtime.GOARCH return fmt.Sprintf("%s (%s/%s)", command, os, arch) diff --git a/internal/cmd/version.go b/internal/cmd/version.go index 6aebe964..08fa5a41 100644 --- a/internal/cmd/version.go +++ b/internal/cmd/version.go @@ -25,16 +25,11 @@ import ( "github.com/spf13/cobra" "github.com/mia-platform/miactl/internal/clioptions" + "github.com/mia-platform/miactl/internal/version" ) -// Version is dynamically set by the ci or overridden by the Makefile. -var Version = "" - -// BuildDate is dynamically set at build time by the cli or overridden in the Makefile. -var BuildDate = "" // YYYY-MM-DD - func VersionCmd(_ *clioptions.CLIOptions) *cobra.Command { - versionOutput := versionFormat(Version, BuildDate) + versionOutput := versionFormat(version.Version, version.BuildDate) // Version subcommand cmd := &cobra.Command{ Use: "version", diff --git a/internal/version/version.go b/internal/version/version.go new file mode 100644 index 00000000..ee2f0256 --- /dev/null +++ b/internal/version/version.go @@ -0,0 +1,22 @@ +// Copyright Mia srl +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package version + +// Version is dynamically set by the ci or overridden by the Makefile. +var Version = "" + +// BuildDate is dynamically set at build time by the cli or overridden in the Makefile. +var BuildDate = "" // YYYY-MM-DD