mirror of
https://github.com/containers/skopeo.git
synced 2025-09-23 02:48:26 +00:00
4
Makefile
4
Makefile
@@ -81,10 +81,8 @@ endif
|
|||||||
CONTAINER_GOSRC = /src/github.com/containers/skopeo
|
CONTAINER_GOSRC = /src/github.com/containers/skopeo
|
||||||
CONTAINER_RUN ?= $(CONTAINER_CMD) --security-opt label=disable -v $(CURDIR):$(CONTAINER_GOSRC) -w $(CONTAINER_GOSRC) $(SKOPEO_CIDEV_CONTAINER_FQIN)
|
CONTAINER_RUN ?= $(CONTAINER_CMD) --security-opt label=disable -v $(CURDIR):$(CONTAINER_GOSRC) -w $(CONTAINER_GOSRC) $(SKOPEO_CIDEV_CONTAINER_FQIN)
|
||||||
|
|
||||||
GIT_COMMIT := $(shell GIT_CEILING_DIRECTORIES=$$(cd ..; pwd) git rev-parse HEAD 2> /dev/null || true)
|
|
||||||
|
|
||||||
EXTRA_LDFLAGS ?=
|
EXTRA_LDFLAGS ?=
|
||||||
SKOPEO_LDFLAGS := -ldflags '-X main.gitCommit=${GIT_COMMIT} $(EXTRA_LDFLAGS)'
|
SKOPEO_LDFLAGS := -ldflags '$(EXTRA_LDFLAGS)'
|
||||||
|
|
||||||
MANPAGES_MD = $(wildcard docs/*.md)
|
MANPAGES_MD = $(wildcard docs/*.md)
|
||||||
MANPAGES ?= $(MANPAGES_MD:%.md=%)
|
MANPAGES ?= $(MANPAGES_MD:%.md=%)
|
||||||
|
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -15,10 +16,6 @@ import (
|
|||||||
"go.podman.io/storage/pkg/reexec"
|
"go.podman.io/storage/pkg/reexec"
|
||||||
)
|
)
|
||||||
|
|
||||||
// gitCommit will be the hash that the binary was built from
|
|
||||||
// and will be populated by the Makefile
|
|
||||||
var gitCommit = ""
|
|
||||||
|
|
||||||
var defaultUserAgent = "skopeo/" + version.Version
|
var defaultUserAgent = "skopeo/" + version.Version
|
||||||
|
|
||||||
type globalOptions struct {
|
type globalOptions struct {
|
||||||
@@ -70,8 +67,10 @@ func createApp() (*cobra.Command, *globalOptions) {
|
|||||||
// (skopeo --tls-verify inspect) (causes a warning) and (skopeo inspect --tls-verify) (no warning).
|
// (skopeo --tls-verify inspect) (causes a warning) and (skopeo inspect --tls-verify) (no warning).
|
||||||
TraverseChildren: true,
|
TraverseChildren: true,
|
||||||
}
|
}
|
||||||
if gitCommit != "" {
|
// We don’t use debug.ReadBuildInfo to automate version.Version, because that would not work well for builds from
|
||||||
rootCommand.Version = fmt.Sprintf("%s commit: %s", version.Version, gitCommit)
|
// a released tarball (e.g. RPM builds).
|
||||||
|
if commit := gitCommit(); commit != "" {
|
||||||
|
rootCommand.Version = fmt.Sprintf("%s commit: %s", version.Version, commit)
|
||||||
} else {
|
} else {
|
||||||
rootCommand.Version = version.Version
|
rootCommand.Version = version.Version
|
||||||
}
|
}
|
||||||
@@ -112,6 +111,20 @@ func createApp() (*cobra.Command, *globalOptions) {
|
|||||||
return rootCommand, &opts
|
return rootCommand, &opts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gitCommit returns the git commit for this codebase, if we are built from a git repo; "" otherwise.
|
||||||
|
func gitCommit() string {
|
||||||
|
bi, ok := debug.ReadBuildInfo()
|
||||||
|
if !ok {
|
||||||
|
logrus.Fatal("runtime.ReadBuildInfo failed")
|
||||||
|
}
|
||||||
|
for _, e := range bi.Settings {
|
||||||
|
if e.Key == "vcs.revision" {
|
||||||
|
return e.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// before is run by the cli package for any command, before running the command-specific handler.
|
// before is run by the cli package for any command, before running the command-specific handler.
|
||||||
func (opts *globalOptions) before(cmd *cobra.Command, args []string) error {
|
func (opts *globalOptions) before(cmd *cobra.Command, args []string) error {
|
||||||
if opts.debug {
|
if opts.debug {
|
||||||
|
2
go.mod
2
go.mod
@@ -1,7 +1,7 @@
|
|||||||
module github.com/containers/skopeo
|
module github.com/containers/skopeo
|
||||||
|
|
||||||
// Minimum required golang version
|
// Minimum required golang version
|
||||||
go 1.23.3
|
go 1.24.0
|
||||||
|
|
||||||
// Warning: Ensure the "go" and "toolchain" versions match exactly to prevent unwanted auto-updates
|
// Warning: Ensure the "go" and "toolchain" versions match exactly to prevent unwanted auto-updates
|
||||||
|
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
@@ -29,9 +30,8 @@ type signingSuite struct {
|
|||||||
var _ = suite.SetupAllSuite(&signingSuite{})
|
var _ = suite.SetupAllSuite(&signingSuite{})
|
||||||
|
|
||||||
func findFingerprint(lineBytes []byte) (string, error) {
|
func findFingerprint(lineBytes []byte) (string, error) {
|
||||||
lines := string(lineBytes)
|
for line := range bytes.SplitSeq(lineBytes, []byte{'\n'}) {
|
||||||
for _, line := range strings.Split(lines, "\n") {
|
fields := strings.Split(string(line), ":")
|
||||||
fields := strings.Split(line, ":")
|
|
||||||
if len(fields) >= 10 && fields[0] == "fpr" {
|
if len(fields) >= 10 && fields[0] == "fpr" {
|
||||||
return fields[9], nil
|
return fields[9], nil
|
||||||
}
|
}
|
||||||
|
@@ -381,7 +381,7 @@ quay.io:
|
|||||||
// get the number of tags
|
// get the number of tags
|
||||||
re := regexp.MustCompile(`^ +- +[^:/ ]+`)
|
re := regexp.MustCompile(`^ +- +[^:/ ]+`)
|
||||||
var nTags int
|
var nTags int
|
||||||
for _, l := range strings.Split(yamlConfig, "\n") {
|
for l := range strings.SplitSeq(yamlConfig, "\n") {
|
||||||
if re.MatchString(l) {
|
if re.MatchString(l) {
|
||||||
nTags++
|
nTags++
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user