diff --git a/cmd/osbuild-composer/main.go b/cmd/osbuild-composer/main.go index abc5ee745..d622aee32 100644 --- a/cmd/osbuild-composer/main.go +++ b/cmd/osbuild-composer/main.go @@ -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) diff --git a/internal/common/helpers.go b/internal/common/helpers.go new file mode 100644 index 000000000..81075224f --- /dev/null +++ b/internal/common/helpers.go @@ -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") + } +}