cmd/composer: move currentArch helper to common package

The helper function might be useful also in different parts of the project.
This commit is contained in:
Ondřej Budai 2020-02-24 14:04:08 +01:00 committed by Tom Gundersen
parent 740fb77d64
commit 80f0888896
2 changed files with 19 additions and 16 deletions

View file

@ -8,8 +8,8 @@ import (
"io/ioutil"
"log"
"os"
"runtime"
"github.com/osbuild/osbuild-composer/internal/common"
"github.com/osbuild/osbuild-composer/internal/distro"
"github.com/osbuild/osbuild-composer/internal/jobqueue"
"github.com/osbuild/osbuild-composer/internal/rpmmd"
@ -19,20 +19,6 @@ import (
"github.com/coreos/go-systemd/activation"
)
func currentArch() string {
if runtime.GOARCH == "amd64" {
return "x86_64"
} else if runtime.GOARCH == "arm64" {
return "aarch64"
} else if runtime.GOARCH == "ppc64le" {
return "ppc64le"
} else if runtime.GOARCH == "s390x" {
return "s390x"
} else {
panic("unsupported architecture")
}
}
type connectionConfig struct {
CACertFile string
ServerKeyFile string
@ -103,7 +89,7 @@ func main() {
store := store.New(&stateDir, distribution, *distros)
jobAPI := jobqueue.New(logger, store)
weldrAPI := weldr.New(rpm, currentArch(), distribution, logger, store)
weldrAPI := weldr.New(rpm, common.CurrentArch(), distribution, logger, store)
go jobAPI.Serve(jobListener)

View file

@ -0,0 +1,17 @@
package common
import "runtime"
func CurrentArch() string {
if runtime.GOARCH == "amd64" {
return "x86_64"
} else if runtime.GOARCH == "arm64" {
return "aarch64"
} else if runtime.GOARCH == "ppc64le" {
return "ppc64le"
} else if runtime.GOARCH == "s390x" {
return "s390x"
} else {
panic("unsupported architecture")
}
}