mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-08-21 15:57:54 +00:00
Replace deprecated swagger:alias with swagger:model for ImagePullStatus and ArtifactPullStatus. Add explicit swagger:model annotations with unique names to Podman types that collide with vendor types (DriverData, PruneReport, RootFS, Secret, ThrottleDevice, WeightDevice, Version) to resolve colliding model name warnings from go-swagger. The types from libpod/define use a Libpod prefix, matching LibpodInfo which already does that. Apart from the prefix the names are the ones go-swagger derives on its own, so the annotations mostly just make the naming explicit so the tool stops warning about it. This does not close #29199 entirely. The two remaining name collisions (Mount and Summary) are each between two vendored types, so they cannot be controlled from the Podman side, and the dropped-ref-sibling warnings are a separate problem. Related: #29199 Signed-off-by: Satwik Sai Prakash Sahoo <sahoospsatwik@gmail.com>
61 lines
1.5 KiB
Go
61 lines
1.5 KiB
Go
package define
|
|
|
|
import (
|
|
"runtime"
|
|
"strconv"
|
|
"time"
|
|
|
|
"go.podman.io/podman/v6/version"
|
|
)
|
|
|
|
// Overwritten at build time
|
|
var (
|
|
// GitCommit is the commit that the binary is being built from.
|
|
// It will be populated by the Makefile.
|
|
gitCommit string
|
|
// BuildInfo is the time at which the binary was built
|
|
// It will be populated by the Makefile.
|
|
buildInfo string
|
|
// BuildOrigin is the packager of the binary.
|
|
// It will be populated at build-time.
|
|
buildOrigin string
|
|
)
|
|
|
|
// Version is an output struct for API
|
|
//
|
|
// swagger:model LibpodVersion
|
|
type Version struct {
|
|
APIVersion string
|
|
Version string
|
|
GoVersion string
|
|
GitCommit string
|
|
BuiltTime string
|
|
Built int64
|
|
BuildOrigin string `json:",omitempty" yaml:",omitempty"`
|
|
OsArch string
|
|
Os string
|
|
}
|
|
|
|
// GetVersion returns a VersionOutput struct for API and podman
|
|
func GetVersion() (Version, error) {
|
|
var err error
|
|
var buildTime int64
|
|
if buildInfo != "" {
|
|
// Converts unix time from string to int64
|
|
buildTime, err = strconv.ParseInt(buildInfo, 10, 64)
|
|
if err != nil {
|
|
return Version{}, err
|
|
}
|
|
}
|
|
return Version{
|
|
APIVersion: version.APIVersion[version.Libpod][version.CurrentAPI].String(),
|
|
Version: version.Version.String(),
|
|
GoVersion: runtime.Version(),
|
|
GitCommit: gitCommit,
|
|
BuiltTime: time.Unix(buildTime, 0).Format(time.ANSIC),
|
|
Built: buildTime,
|
|
BuildOrigin: buildOrigin,
|
|
OsArch: runtime.GOOS + "/" + runtime.GOARCH,
|
|
Os: runtime.GOOS,
|
|
}, nil
|
|
}
|