mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Merge branch 'main' into manpage
This commit is contained in:
commit
5e0687139e
6 changed files with 88 additions and 4 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1,4 +1,6 @@
|
||||||
magellan
|
magellan
|
||||||
emulator/rf-emulator
|
emulator/rf-emulator
|
||||||
**/*.db
|
**/*.db
|
||||||
dist/*
|
**.tar.gz
|
||||||
|
**.tar.zst
|
||||||
|
**.part
|
||||||
|
|
|
||||||
10
Makefile
10
Makefile
|
|
@ -12,6 +12,12 @@ ifndef VERSION
|
||||||
$(error VERSION is not set. Please review and copy config.env.default to config.env and try again)
|
$(error VERSION is not set. Please review and copy config.env.default to config.env and try again)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifndef BUILD
|
||||||
|
$(error BUILD is not set. Please review and copy config.env.default to config.env and try again)
|
||||||
|
endif
|
||||||
|
|
||||||
|
LDFLAGS="-s -X=$(GIT)main.commit=$(BUILD) -X=$(GIT)main.version=$(VERSION) -X=$(GIT)main.date=$(shell date +%Y-%m-%d:%H:%M:%S)"
|
||||||
|
|
||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
GOPATH ?= $(shell echo $${GOPATH:-~/go})
|
GOPATH ?= $(shell echo $${GOPATH:-~/go})
|
||||||
|
|
||||||
|
|
@ -55,8 +61,8 @@ release: ## goreleaser build
|
||||||
$(GOPATH)/bin/goreleaser build --clean --single-target --snapshot
|
$(GOPATH)/bin/goreleaser build --clean --single-target --snapshot
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: ## goreleaser build
|
build: ## go build
|
||||||
go build --tags=all
|
go build -v --tags=all -ldflags=$(LDFLAGS) -o $(NAME) main.go
|
||||||
|
|
||||||
.PHONY: docker
|
.PHONY: docker
|
||||||
container: ## docker build
|
container: ## docker build
|
||||||
|
|
|
||||||
40
cmd/version.go
Normal file
40
cmd/version.go
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
version string
|
||||||
|
commit string
|
||||||
|
date string
|
||||||
|
output string
|
||||||
|
)
|
||||||
|
|
||||||
|
var versionCmd = &cobra.Command{
|
||||||
|
Use: "version",
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
if cmd.Flag("commit").Value.String() == "true" {
|
||||||
|
output = commit
|
||||||
|
if date != "" {
|
||||||
|
output += " built @ " + date
|
||||||
|
}
|
||||||
|
fmt.Println(output)
|
||||||
|
} else {
|
||||||
|
fmt.Println(version)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
versionCmd.Flags().Bool("commit", false, "show the version commit")
|
||||||
|
rootCmd.AddCommand(versionCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetVersionInfo(buildVersion string, buildCommit string, buildDate string) {
|
||||||
|
version = buildVersion
|
||||||
|
commit = buildCommit
|
||||||
|
date = buildDate
|
||||||
|
}
|
||||||
|
|
@ -2,4 +2,4 @@
|
||||||
|
|
||||||
NAME=magellan
|
NAME=magellan
|
||||||
VERSION=$(shell git describe --tags --abbrev=0)
|
VERSION=$(shell git describe --tags --abbrev=0)
|
||||||
|
BUILD=$(shell git rev-parse --short HEAD)
|
||||||
|
|
|
||||||
29
dist/archlinux/PKGBUILD
vendored
Normal file
29
dist/archlinux/PKGBUILD
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Maintainer: David J. Allen <allend@lanl.gov>
|
||||||
|
pkgname=magellan
|
||||||
|
pkgver=v0.1.5
|
||||||
|
pkgrel=1
|
||||||
|
pkgdesc="Redfish-based BMC discovery tool written in Go"
|
||||||
|
arch=("x86_64")
|
||||||
|
url="https://github.com/OpenCHAMI/magellan"
|
||||||
|
license=('MIT')
|
||||||
|
groups=("openchami")
|
||||||
|
provides=('magellan')
|
||||||
|
conflicts=('magellan')
|
||||||
|
source_x86_64=("${url}/releases/download/${pkgver}/${pkgname}_Linux_x86_64.tar.gz")
|
||||||
|
sha256sums_x86_64=('1bb028d592d5389b519362e6aa7021f27443f0b36471e09ee7f47ab5cb6d4d7f')
|
||||||
|
|
||||||
|
# Please refer to the 'USING VCS SOURCES' section of the PKGBUILD man page for
|
||||||
|
# a description of each element in the source array.
|
||||||
|
|
||||||
|
pkgver() {
|
||||||
|
cd "$srcdir" || exit
|
||||||
|
printf "%s" "$(git describe --tags --abbrev=0)"
|
||||||
|
}
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd "$srcdir/" || exit
|
||||||
|
|
||||||
|
# install the binary to /usr/bin
|
||||||
|
mkdir -p "${pkgdir}/usr/bin"
|
||||||
|
install -m755 magellan "${pkgdir}/usr/bin/magellan"
|
||||||
|
}
|
||||||
7
main.go
7
main.go
|
|
@ -4,6 +4,13 @@ import (
|
||||||
"github.com/OpenCHAMI/magellan/cmd"
|
"github.com/OpenCHAMI/magellan/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
version string
|
||||||
|
commit string
|
||||||
|
date string
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
cmd.SetVersionInfo(version, commit, date)
|
||||||
cmd.Execute()
|
cmd.Execute()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue