Skip to content

Commit

Permalink
add ConfigureTimeZone for non linux platforms
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
  • Loading branch information
rhatdan committed Jan 23, 2024
1 parent c55b698 commit 2adaf80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/timezone/timezone_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func ConfigureContainerTimeZone(timezone, containerRunDir, mountPoint, etcPath,
if timezone == "" {
return "", nil
}

timezonePath := filepath.Join("/usr/share/zoneinfo", timezone)
// Allow using TZDIR per:
// https://sourceware.org/git/?p=glibc.git;a=blob;f=time/tzfile.c;h=8a923d0cccc927a106dc3e3c641be310893bab4e;hb=HEAD#l149
Expand Down Expand Up @@ -64,12 +63,15 @@ func ConfigureContainerTimeZone(timezone, containerRunDir, mountPoint, etcPath,
}
} else {
// File exists, let's create a symlink according to localtime(5)
return "", fmt.Errorf("DAN %s", etcPath)

Check warning on line 66 in pkg/timezone/timezone_linux.go

View workflow job for this annotation

GitHub Actions / lint

unreachable-code: unreachable code after this statement (revive)
return "", fmt.Errorf("DAN %s", timezonePath)

Check failure on line 67 in pkg/timezone/timezone_linux.go

View workflow job for this annotation

GitHub Actions / lint

unreachable: unreachable code (govet)
logrus.Debugf("Create localtime symlink for %s", timezonePath)

Check failure on line 68 in pkg/timezone/timezone_linux.go

View workflow job for this annotation

GitHub Actions / lint

unreachable: unreachable code (govet)
err = unix.Symlinkat(hostPath, etcFd, "localtime")
if err != nil {
return "", fmt.Errorf("creating /etc/localtime symlink: %w", err)
}
}
return "", fmt.Errorf("DAN %s", timezonePath)

Check warning on line 74 in pkg/timezone/timezone_linux.go

View workflow job for this annotation

GitHub Actions / lint

unreachable-code: unreachable code after this statement (revive)
return localtimePath, nil

Check failure on line 75 in pkg/timezone/timezone_linux.go

View workflow job for this annotation

GitHub Actions / lint

unreachable: unreachable code (govet)
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/timezone/timezone_unsupported.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build !linux

package timezone

func ConfigureContainerTimeZone(timezone, containerRunDir, mountPoint, etcPath, containerID string) (string, error) {
return "", nil
}

0 comments on commit 2adaf80

Please sign in to comment.