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

Add BuildOrigin field to podman info #24781

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ GOFLAGS ?= -trimpath
LDFLAGS_PODMAN ?= \
$(if $(GIT_COMMIT),-X $(LIBPOD)/define.gitCommit=$(GIT_COMMIT),) \
$(if $(BUILD_INFO),-X $(LIBPOD)/define.buildInfo=$(BUILD_INFO),) \
$(if $(BUILD_ORIGIN),-X $(LIBPOD)/define.buildOrigin=$(BUILD_ORIGIN),) \
-X $(LIBPOD)/config._installPrefix=$(PREFIX) \
-X $(LIBPOD)/config._etcDir=$(ETCDIR) \
-X $(PROJECT)/v5/pkg/systemd/quadlet._binDir=$(BINDIR) \
Expand Down
14 changes: 8 additions & 6 deletions cmd/podman/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package main
import "github.com/containers/podman/v5/libpod/define"

type clientInfo struct {
OSArch string `json:"OS"`
Provider string `json:"provider"`
Version string `json:"version"`
OSArch string `json:"OS"`
Provider string `json:"provider"`
Version string `json:"version"`
BuildOrigin string `json:"buildOrigin,omitempty" yaml:",omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has this a yaml tag as only field?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We yaml marshall these on output, and buildOrigin is the only omitempty field we need. For consistency's sake, I can add it to all the fields.

}

func getClientInfo() (*clientInfo, error) {
Expand All @@ -18,8 +19,9 @@ func getClientInfo() (*clientInfo, error) {
return nil, err
}
return &clientInfo{
OSArch: vinfo.OsArch,
Provider: p,
Version: vinfo.Version,
OSArch: vinfo.OsArch,
Provider: p,
Version: vinfo.Version,
BuildOrigin: vinfo.BuildOrigin,
}, nil
}
2 changes: 2 additions & 0 deletions cmd/podman/system/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ API Version:\t{{.APIVersion}}
Go Version:\t{{.GoVersion}}
{{if .GitCommit -}}Git Commit:\t{{.GitCommit}}\n{{end -}}
Built:\t{{.BuiltTime}}
{{if .BuildOrigin -}}Build Origin:\t{{.BuildOrigin}}\n{{end -}}
OS/Arch:\t{{.OsArch}}
{{- end}}

Expand All @@ -108,6 +109,7 @@ API Version:\t{{.APIVersion}}
Go Version:\t{{.GoVersion}}
{{if .GitCommit -}}Git Commit:\t{{.GitCommit}}\n{{end -}}
Built:\t{{.BuiltTime}}
{{if .BuildOrigin -}}Built Origin:\t{{.BuildOrigin}}\n{{end -}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built intentional, or should it be Build?

OS/Arch:\t{{.OsArch}}
{{- end}}{{- end}}
`
3 changes: 2 additions & 1 deletion contrib/pkginstaller/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ PRODUCTSIGN_IDENTITY=${PRODUCTSIGN_IDENTITY:-mock}
NO_CODESIGN=${NO_CODESIGN:-0}
HELPER_BINARIES_DIR="/opt/podman/bin"
MACHINE_POLICY_JSON_DIR="/opt/podman/config"
BUILD_ORIGIN="pkginstaller"

tmpBin="contrib/pkginstaller/tmp-bin"

Expand Down Expand Up @@ -42,7 +43,7 @@ function build_podman() {
}

function build_podman_arch(){
make -B GOARCH="$1" podman-remote HELPER_BINARIES_DIR="${HELPER_BINARIES_DIR}"
make -B GOARCH="$1" podman-remote HELPER_BINARIES_DIR="${HELPER_BINARIES_DIR}" BUILD_ORIGIN="${BUILD_ORIGIN}"
make -B GOARCH="$1" podman-mac-helper
mkdir -p "${tmpBin}"
cp bin/darwin/podman "${tmpBin}/podman-$1"
Expand Down
37 changes: 21 additions & 16 deletions libpod/define/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,22 @@ var (
// 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
type Version struct {
APIVersion string
Version string
GoVersion string
GitCommit string
BuiltTime string
Built int64
OsArch string
Os string
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
Expand All @@ -43,13 +47,14 @@ func GetVersion() (Version, error) {
}
}
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,
OsArch: runtime.GOOS + "/" + runtime.GOARCH,
Os: runtime.GOOS,
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
}
Loading