Skip to content

Commit

Permalink
Merge pull request helm#13376 from helm/fix_oci_push_timestamp
Browse files Browse the repository at this point in the history
fix: Use chart archive modifed time for OCI push
  • Loading branch information
sabre1041 authored Oct 27, 2024
2 parents 5ae91e1 + f5fcae8 commit 717529a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions pkg/pusher/ocipusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ func (pusher *OCIPusher) push(chartRef, href string) error {
path.Join(strings.TrimPrefix(href, fmt.Sprintf("%s://", registry.OCIScheme)), meta.Metadata.Name),
meta.Metadata.Version)

chartCreationTime := ctime.Created(stat)
pushOpts = append(pushOpts, registry.PushOptCreationTime(chartCreationTime.Format(time.RFC3339)))
// The time the chart was "created" is semantically the time the chart archive file was last written(modified)
chartArchiveFileCreatedTime := ctime.Modified(stat)
pushOpts = append(pushOpts, registry.PushOptCreationTime(chartArchiveFileCreatedTime.Format(time.RFC3339)))

_, err = client.Push(chartBytes, ref, pushOpts...)
return err
Expand Down
6 changes: 5 additions & 1 deletion pkg/time/ctime/ctime.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ import (
)

func Created(fi os.FileInfo) time.Time {
return created(fi)
return modified(fi)
}

func Modified(fi os.FileInfo) time.Time {
return modified(fi)
}
4 changes: 2 additions & 2 deletions pkg/time/ctime/ctime_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"time"
)

func created(fi os.FileInfo) time.Time {
func modified(fi os.FileInfo) time.Time {
st := fi.Sys().(*syscall.Stat_t)
//nolint
return time.Unix(int64(st.Ctim.Sec), int64(st.Ctim.Nsec))
return time.Unix(int64(st.Mtim.Sec), int64(st.Mtim.Nsec))
}
2 changes: 1 addition & 1 deletion pkg/time/ctime/ctime_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ import (
"time"
)

func created(fi os.FileInfo) time.Time {
func modified(fi os.FileInfo) time.Time {
return fi.ModTime()
}

0 comments on commit 717529a

Please sign in to comment.