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:
parent
740fb77d64
commit
80f0888896
2 changed files with 19 additions and 16 deletions
|
|
@ -8,8 +8,8 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
|
||||||
|
|
||||||
|
"github.com/osbuild/osbuild-composer/internal/common"
|
||||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||||
"github.com/osbuild/osbuild-composer/internal/jobqueue"
|
"github.com/osbuild/osbuild-composer/internal/jobqueue"
|
||||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||||
|
|
@ -19,20 +19,6 @@ import (
|
||||||
"github.com/coreos/go-systemd/activation"
|
"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 {
|
type connectionConfig struct {
|
||||||
CACertFile string
|
CACertFile string
|
||||||
ServerKeyFile string
|
ServerKeyFile string
|
||||||
|
|
@ -103,7 +89,7 @@ func main() {
|
||||||
store := store.New(&stateDir, distribution, *distros)
|
store := store.New(&stateDir, distribution, *distros)
|
||||||
|
|
||||||
jobAPI := jobqueue.New(logger, store)
|
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)
|
go jobAPI.Serve(jobListener)
|
||||||
|
|
||||||
|
|
|
||||||
17
internal/common/helpers.go
Normal file
17
internal/common/helpers.go
Normal 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")
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue