mirror of
https://github.com/containers/podman.git
synced 2025-06-21 09:28:09 +08:00
Merge pull request #9580 from rhatdan/timestamp
Fix support for podman build --timestamp
This commit is contained in:
@ -509,6 +509,11 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
|
||||
TransientMounts: flags.Volumes,
|
||||
}
|
||||
|
||||
if c.Flag("timestamp").Changed {
|
||||
timestamp := time.Unix(flags.Timestamp, 0).UTC()
|
||||
opts.Timestamp = ×tamp
|
||||
}
|
||||
|
||||
return &entities.BuildOptions{BuildOptions: opts}, nil
|
||||
}
|
||||
|
||||
|
@ -104,6 +104,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
||||
Squash bool `schema:"squash"`
|
||||
Tag []string `schema:"t"`
|
||||
Target string `schema:"target"`
|
||||
Timestamp int64 `schema:"timestamp"`
|
||||
}{
|
||||
Dockerfile: "Dockerfile",
|
||||
Registry: "docker.io",
|
||||
@ -318,6 +319,11 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
||||
Target: query.Target,
|
||||
}
|
||||
|
||||
if _, found := r.URL.Query()["timestamp"]; found {
|
||||
ts := time.Unix(query.Timestamp, 0)
|
||||
buildOptions.Timestamp = &ts
|
||||
}
|
||||
|
||||
runCtx, cancel := context.WithCancel(context.Background())
|
||||
var imageID string
|
||||
go func() {
|
||||
|
@ -185,6 +185,12 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
|
||||
if options.Squash {
|
||||
params.Set("squash", "1")
|
||||
}
|
||||
|
||||
if options.Timestamp != nil {
|
||||
t := *options.Timestamp
|
||||
params.Set("timestamp", strconv.FormatInt(t.Unix(), 10))
|
||||
}
|
||||
|
||||
var (
|
||||
headers map[string]string
|
||||
err error
|
||||
|
@ -532,4 +532,20 @@ RUN grep CapEff /proc/self/status`
|
||||
// Then
|
||||
Expect(session.ExitCode()).To(Equal(125))
|
||||
})
|
||||
|
||||
It("podman build --timestamp flag", func() {
|
||||
containerfile := `FROM quay.io/libpod/alpine:latest
|
||||
RUN echo hello`
|
||||
|
||||
containerfilePath := filepath.Join(podmanTest.TempDir, "Containerfile")
|
||||
err := ioutil.WriteFile(containerfilePath, []byte(containerfile), 0755)
|
||||
Expect(err).To(BeNil())
|
||||
session := podmanTest.Podman([]string{"build", "-t", "test", "--timestamp", "0", "--file", containerfilePath, podmanTest.TempDir})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
|
||||
inspect := podmanTest.Podman([]string{"image", "inspect", "--format", "{{ .Created }}", "test"})
|
||||
inspect.WaitWithDefaultTimeout()
|
||||
Expect(inspect.OutputToString()).To(Equal("1970-01-01 00:00:00 +0000 UTC"))
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user