Skip to content

Commit

Permalink
Merge branch '30_versioning'
Browse files Browse the repository at this point in the history
  • Loading branch information
aztechian committed Aug 27, 2019
2 parents 62e7d4e + 4e6f6a9 commit 0a47f9c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
PROJECT_NAME := "bridgr"
PKG := "$(PROJECT_NAME)"
CMD := "cmd/bridgr/main.go"
VERSION := $(shell git describe --always --long --dirty)
GO_FILES := $(shell find . -name '*.go' | grep -v _test.go)

.PHONY: all coverage lint test race x2unit xunit clean generate download
Expand Down Expand Up @@ -57,10 +58,10 @@ generate: $(GO_FILES)
@GOOS="" go generate ./...

$(PROJECT_NAME): generate $(GO_FILES)
@go build -tags dist -i -v -o $@ $(CMD)
@go build -tags dist -i -v -o $@ -ldflags="-X main.version=${VERSION}" $(CMD)

$(PROJECT_NAME)-%: generate $(GO_FILES)
@go build -tags dist -i -v -o $@ $(CMD)
@go build -tags dist -i -v -o $@ -ldflags="-X main.version=${VERSION}" $(CMD)
@echo "Created executable $@"

%.sha256:
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ To only run one of the repository types, simply give that type after any configu

Additional command line options include:

| Option | Meaning |
| ------ | --------------------------------------------- |
| -v | Verbose Output |
| -n | Dry-run. Only do setup, don't fetch artifacts |
| -c | Specify an alternate configuration file |
| Option | Meaning |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------- |
| -v / --verbose | Verbose Output |
| |
| -n / --dry-run | Dry-run. Only do setup, don't fetch artifacts |
| -c / --config | Specify an alternate configuration file |
| --version | Print the version of Bridgr and exit. The output of stderr can be redirected to /dev/null to get just the version string. |

## Development setup

Expand Down Expand Up @@ -94,6 +96,8 @@ Potential library for creating iso9660 (ISO) files [https://github.com/kdomanski

## Release History

- 1.1.0
- Add PyPi support
- 1.0.0
- Intial release of Bridgr with support for Yum, Files, and Docker artifacts
- 0.0.1
Expand Down
20 changes: 14 additions & 6 deletions cmd/bridgr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import (
"flag"
"fmt"
"io"
"log"
"os"
"strings"
)

var (
version = "development"
verbosePtr = flag.Bool("verbose", false, "Verbose logging (debug)")
versionPtr = flag.Bool("version", false, "Print version and exit")
configPtr = flag.String("config", "bridge.yml", "The config file for Bridgr (default is bridge.yml)")
dryrunPtr = flag.Bool("dry-run", false, "Dry-run only. Do not actually download content")
)
Expand All @@ -28,13 +29,20 @@ func main() {
flag.Parse()
bridgr.Verbose = *verbosePtr

if *versionPtr {
fmt.Fprintln(os.Stderr, "Bridgr - (C) 2019 Ian Martin, MIT License. See https://github.com/aztechian/bridgr")
fmt.Printf("%s\n", version)
fmt.Fprintln(os.Stderr, "")
os.Exit(0)
}

if *dryrunPtr {
log.Println("Dry-Run requested, will not download artifacts.")
bridgr.Println("Dry-Run requested, will not download artifacts.")
}

configFile, err := openConfig()
if err != nil {
log.Printf("Unable to open bridgr config \"%s\": %s", *configPtr, err)
bridgr.Printf("Unable to open bridgr config \"%s\": %s", *configPtr, err)
if configFile != nil {
configFile.Close()
}
Expand All @@ -50,7 +58,7 @@ func main() {
bridgr.Debugf("Running workers for subcommands: %+v\n", flag.Args())
err = processWorkers(workerList, flag.Args())
if err != nil {
log.Print(err)
bridgr.Print(err)
os.Exit(255)
}
os.Exit(0)
Expand Down Expand Up @@ -91,15 +99,15 @@ func initWorkers(conf *config.BridgrConf) []workers.Worker {
}

func doWorker(w workers.Worker) {
log.Printf("Processing %s...", w.Name())
bridgr.Printf("Processing %s...", w.Name())
var err error
if *dryrunPtr {
err = w.Setup()
} else {
err = w.Run()
}
if err != nil {
log.Printf("Error processing %s: %s", w.Name(), err)
bridgr.Printf("Error processing %s: %s", w.Name(), err)
}
}

Expand Down

0 comments on commit 0a47f9c

Please sign in to comment.