Skip to content

Commit 02ef83f

Browse files
committedOct 5, 2024·
fix: Use chart archive modifed time for OCI push
Signed-off-by: George Jenkins <gvjenkins@gmail.com>
1 parent 145d12f commit 02ef83f

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed
 

‎pkg/pusher/ocipusher.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ func (pusher *OCIPusher) push(chartRef, href string) error {
9090
path.Join(strings.TrimPrefix(href, fmt.Sprintf("%s://", registry.OCIScheme)), meta.Metadata.Name),
9191
meta.Metadata.Version)
9292

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

9697
_, err = client.Push(chartBytes, ref, pushOpts...)
9798
return err

‎pkg/time/ctime/ctime.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,9 @@ import (
2121
)
2222

2323
func Created(fi os.FileInfo) time.Time {
24-
return created(fi)
24+
return modified(fi)
25+
}
26+
27+
func Modified(fi os.FileInfo) time.Time {
28+
return modified(fi)
2529
}

‎pkg/time/ctime/ctime_linux.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import (
2323
"time"
2424
)
2525

26-
func created(fi os.FileInfo) time.Time {
26+
func modified(fi os.FileInfo) time.Time {
2727
st := fi.Sys().(*syscall.Stat_t)
2828
//nolint
29-
return time.Unix(int64(st.Ctim.Sec), int64(st.Ctim.Nsec))
29+
return time.Unix(int64(st.Mtim.Sec), int64(st.Mtim.Nsec))
3030
}

‎pkg/time/ctime/ctime_other.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ import (
2222
"time"
2323
)
2424

25-
func created(fi os.FileInfo) time.Time {
25+
func modified(fi os.FileInfo) time.Time {
2626
return fi.ModTime()
2727
}

0 commit comments

Comments
 (0)
Please sign in to comment.