Skip to content

Commit e30963b

Browse files
committed
image build: rename goArchToArchitectureLabel
The function is used for more than just getting architecture labels now. Signed-off-by: Adam Cmiel <acmiel@redhat.com>
1 parent 6367112 commit e30963b

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

pkg/commands/build.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ func findPrefetchResources(prefetchDir string) (*prefetchResources, error) {
767767
resources.envFile = envfiles[0]
768768
}
769769

770-
currentArch := goArchToArchitectureLabel(runtime.GOARCH)
770+
currentArch := goArchToRpmArch(runtime.GOARCH)
771771

772772
reposD := filepath.Join(prefetchDir, "output", "deps", "rpm", currentArch, "repos.d")
773773
if _, err := os.Lstat(reposD); err == nil {
@@ -873,7 +873,7 @@ func (c *Build) copyPrefetchDir() (string, error) {
873873

874874
l.Logger.Debugf("Copying prefetch resources to %s", prefetchDirCopy)
875875

876-
currentArch := goArchToArchitectureLabel(runtime.GOARCH)
876+
currentArch := goArchToRpmArch(runtime.GOARCH)
877877
// Clean the filepaths, we do string comparisons below
878878
prefetchDir = filepath.Clean(prefetchDir)
879879
prefetchDirCopy = filepath.Clean(prefetchDirCopy)
@@ -1335,7 +1335,7 @@ func (c *Build) processLabelsAndAnnotations() error {
13351335
if c.Params.AddLegacyLabels {
13361336
defaultLabels = append(defaultLabels, "build-date="+buildTimeStr)
13371337

1338-
arch := goArchToArchitectureLabel(runtime.GOARCH)
1338+
arch := goArchToRpmArch(runtime.GOARCH)
13391339
defaultLabels = append(defaultLabels, "architecture="+arch)
13401340

13411341
if c.Params.ImageSource != "" {
@@ -1406,11 +1406,8 @@ func parseAnnotationsFile(filePath string) ([]string, error) {
14061406
return annotationStrings, nil
14071407
}
14081408

1409-
// Convert Go's GOARCH value to the value used for the 'architecture' label.
1410-
//
1411-
// Historically, the 'architecture' label used the RPM architecture names rather
1412-
// than the GOARCH names. Keep that the same.
1413-
func goArchToArchitectureLabel(goarch string) string {
1409+
// Convert a supported GOARCH value to the corresponding RPM architecture name.
1410+
func goArchToRpmArch(goarch string) string {
14141411
switch goarch {
14151412
case "amd64":
14161413
return "x86_64"

pkg/commands/build_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ func Test_goArchToArchitectureLabel(t *testing.T) {
11451145
}
11461146

11471147
for _, tc := range tests {
1148-
result := goArchToArchitectureLabel(tc.goarch)
1148+
result := goArchToRpmArch(tc.goarch)
11491149
g.Expect(result).To(Equal(tc.expected), "goArchToUname(%s) should return %s", tc.goarch, tc.expected)
11501150
}
11511151
}
@@ -1249,7 +1249,7 @@ func Test_Build_processLabelsAndAnnotations(t *testing.T) {
12491249
err := c.processLabelsAndAnnotations()
12501250
g.Expect(err).ToNot(HaveOccurred())
12511251

1252-
arch := goArchToArchitectureLabel(runtime.GOARCH)
1252+
arch := goArchToRpmArch(runtime.GOARCH)
12531253
g.Expect(c.mergedLabels).To(Equal([]string{
12541254
"org.opencontainers.image.created=2026-01-01T00:00:00Z",
12551255
"org.opencontainers.image.source=https://github.com/org/repo",
@@ -1950,7 +1950,7 @@ func Test_Build_copyPrefetchDir(t *testing.T) {
19501950
t.Run("filters RPM dirs by architecture", func(t *testing.T) {
19511951
g := NewWithT(t)
19521952

1953-
currentArch := goArchToArchitectureLabel(runtime.GOARCH)
1953+
currentArch := goArchToRpmArch(runtime.GOARCH)
19541954
otherArch := "s390x"
19551955

19561956
srcDir := t.TempDir()

0 commit comments

Comments
 (0)