Skip to content

Commit

Permalink
Rename executable to masonry
Browse files Browse the repository at this point in the history
- Create a new compliance-masonry executable for legacy uses
- New masonry.go is now the primary program naming
- Fixes opencontrol#177
  • Loading branch information
redhatrises committed Jun 8, 2018
1 parent 553bce0 commit f4728e7
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 19 deletions.
5 changes: 4 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ jobs:
- checkout

- run:
name: Build the program
name: Build the compliance-masonry program
command: go build cmd/compliance-masonry/compliance-masonry.go
- run:
name: Build the masonry program
command: go build cmd/masonry/masonry.go
- run:
name: Run tests
command: ./.circleci/coverage.sh
Expand Down
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ GOFMT ?= gofmt
GOLINT ?= golint
EPOCH_TEST_COMMIT ?= 1cc5a27
PROJECT := github.com/opencontrol/compliance-masonry
PROGNAME ?= compliance-masonry
PROGNAME ?= masonry
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g")
PREFIX ?= ${DESTDIR}/usr/local
BINDIR ?= ${PREFIX}/bin
DATAROOTDIR ?= ${PREFIX}/share/compliance-masonry
DATAROOTDIR ?= ${PREFIX}/share/masonry

BASHINSTALLDIR=${PREFIX}/share/bash-completion/completions

Expand All @@ -36,10 +36,12 @@ DEBUGFLAGS ?= -gcflags="-N -l"
endif

build:
$(GO) build \
$(DEBUGFLAGS) \
$(GO) build $(DEBUGFLAGS) \
-o $(BUILD_DIR)/$(PROGNAME) \
cmd/compliance-masonry/compliance-masonry.go
cmd/masonry/masonry.go
$(GO) build $(DEBUGFLAGS) \
-o $(BUILD_DIR)/compliance-masonry \
cmd/compliance-masonry/compliance-masonry.go

all: build

Expand All @@ -48,9 +50,12 @@ platforms:
GOOS="`echo $$platform | cut -d"/" -f1`"; \
GOARCH="`echo $$platform | cut -d"/" -f2`"; \
output_name="$(BUILD_DIR)/$$GOOS-$$GOARCH/$(PROGNAME)"; \
legacy_name="$(BUILD_DIR)/$$GOOS-$$GOARCH/compliance-masonry"; \
[ $$GOOS = "windows" ] && output_name="$$output_name.exe"; \
[ $$GOOS = "windows" ] && legacy_name="$$legacy_name.exe"; \
echo "Building $(PROGNAME) version $(VERSION) for $$GOOS on $$GOARCH"; \
GOOS=$$GOOS GOARCH=$$GOARCH $(GO) build -o $$output_name cmd/compliance-masonry/compliance-masonry.go; \
GOOS=$$GOOS GOARCH=$$GOARCH $(GO) build -o $$output_name cmd/masonry/masonry.go; \
GOOS=$$GOOS GOARCH=$$GOARCH $(GO) build -o $$legacy_name cmd/compliance-masonry/compliance-masonry.go; \
[ -d $(BUILD_DIR)/$$GOOS-$$GOARCH/ ] && cp {LICENSE.md,README.md} $(BUILD_DIR)/$$GOOS-$$GOARCH/; \
done

Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ install:
set PATH=%PATH%;%GOPATH%\bin
build_script:
- cmd: go build cmd/compliance-masonry/compliance-masonry.go
- cmd: go build cmd/masonry/masonry.go
test_script:
- cmd: FOR /F %%A IN ('glide novendor') DO go test -v %%A || exit /b 1
35 changes: 30 additions & 5 deletions cmd/compliance-masonry/compliance-masonry.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
package main

import (
"fmt"
"log"
"os"

"github.com/opencontrol/compliance-masonry/pkg/cmd/masonry"
"os/exec"
"path/filepath"
"runtime"
)

func main() {
if err := masonry.Run(); err != nil {
os.Exit(1)
var binary string
var cmd *exec.Cmd

if runtime.GOOS == "windows" {
binary = "masonry.exe"
} else {
binary = "masonry"
}

prog, err := filepath.Abs(filepath.Join(binary))
if err != nil {
log.Fatal(err)
}

args := os.Args
if len(args) > 1 {
cmd = exec.Command(prog, args[1:]...)
} else {
cmd = exec.Command(prog)
}

output, err := cmd.CombinedOutput()
if err != nil {
//do nothing
}
os.Exit(0)
fmt.Printf("%s\n", output)
}
14 changes: 14 additions & 0 deletions cmd/masonry/masonry.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import (
"os"

"github.com/opencontrol/compliance-masonry/pkg/cmd/masonry"
)

func main() {
if err := masonry.Run(); err != nil {
os.Exit(1)
}
os.Exit(0)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"
)

func TestComplianceMasonryGo(t *testing.T) {
func TestMasonryGo(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "ComplianceMasonryGo Suite")
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

var usage = `
Usage:
compliance-masonry [flags]
compliance-masonry [command]
masonry [flags]
masonry [command]
Available Commands:
diff Compliance Diff Gap Analysis
Expand All @@ -18,7 +18,7 @@ Available Commands:
help Help about any command
Flags:
-h, --help help for compliance-masonry
-h, --help help for masonry
--verbose Run with verbosity
-v, --version Print the version
`
Expand Down
2 changes: 1 addition & 1 deletion examples/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func cleanupOpencontrolWorkspace() {
}

func Masonry(args ...string) *Session {
path, err := Build("github.com/opencontrol/compliance-masonry/cmd/compliance-masonry")
path, err := Build("github.com/opencontrol/compliance-masonry/cmd/masonry")
Expect(err).NotTo(HaveOccurred())
return createCommand(path, args...)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/masonry/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var Version bool
// Add new commands/subcommands for new verbs in this function
func NewMasonryCommand(in io.Reader, out, err io.Writer) *cobra.Command {
cmds := &cobra.Command{
Use: "compliance-masonry",
Use: "masonry",
Short: "OpenControl CLI Tool",
Long: `Compliance Masonry is a command-line interface (CLI) that
allows users to construct certification documentation using
Expand Down
2 changes: 1 addition & 1 deletion pkg/tests/test_masonry.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
// Masonry is used to launch tests on the CLI
func Masonry(args ...string) *gexec.Session {
RegisterFailHandler(Fail)
path, err := gexec.Build("github.com/opencontrol/compliance-masonry/cmd/compliance-masonry")
path, err := gexec.Build("github.com/opencontrol/compliance-masonry/cmd/masonry")
Expect(err).NotTo(HaveOccurred())
cmd := exec.Command(path, args...)
stdin, err := cmd.StdinPipe()
Expand Down

0 comments on commit f4728e7

Please sign in to comment.