Skip to content

Commit

Permalink
Merge pull request #289 from redhatrises/go_standards
Browse files Browse the repository at this point in the history
Update file structure to closer match GO standards
  • Loading branch information
shawndwells authored Jun 6, 2018
2 parents 8be8db8 + c0508fb commit 3ef42d3
Show file tree
Hide file tree
Showing 157 changed files with 173 additions and 175 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

- run:
name: Build the program
command: go build
command: go build cmd/compliance-masonry/compliance-masonry.go cmd/compliance-masonry/diff.go
- run:
name: Run tests
command: ./.circleci/coverage.sh
Expand Down
2 changes: 1 addition & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ ratings:
paths:
- "**.go"
exclude_paths:
- fixtures/
- test/
- vendor/
9 changes: 4 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
circleci/
.circleci/
docs/
exampleplugin/
fixtures/
examples/
test/
.codeclimate.yml
.git
.gitignore
.goxc.json
appveyor.yml
circle.yml
CONTRIBUTING.md
release.sh
release.sh
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.goxc.local.json
/compliance-masonry
*.swp
*.out
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ install:
set PATH=%PATH%;%GOPATH%\bin
build_script:
- cmd: go build
- cmd: go build cmd/compliance-masonry/compliance-masonry.go cmd/compliance-masonry/diff.go
test_script:
- cmd: FOR /F %%A IN ('glide novendor') DO go test -v %%A || exit /b 1
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"path/filepath"

"github.com/codegangsta/cli"
"github.com/opencontrol/compliance-masonry/commands/docs"
"github.com/opencontrol/compliance-masonry/commands/docs/gitbook"
"github.com/opencontrol/compliance-masonry/commands/get"
"github.com/opencontrol/compliance-masonry/pkg/cli/docs"
"github.com/opencontrol/compliance-masonry/pkg/cli/docs/gitbook"
"github.com/opencontrol/compliance-masonry/pkg/cli/get"
"github.com/opencontrol/compliance-masonry/tools/constants"
"github.com/opencontrol/compliance-masonry/tools/fs"
"github.com/opencontrol/compliance-masonry/version"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var _ = Describe("Masonry CLI", func() {
output := Masonry(
"docs", "gitbook", "LATO",
"-e", exportTempDir,
"-o", filepath.Join("fixtures", "opencontrol_fixtures"),
"-o", filepath.Join("..", "..", "test", "fixtures", "opencontrol_fixtures"),
"-m", "sdfds").Wait(1 * time.Second)
Eventually(output.Out.Contents).Should(ContainSubstring("Warning: markdown directory does not exist\n"))
Eventually(output.Out.Contents).Should(ContainSubstring("New Gitbook Documentation Created\n"))
Expand All @@ -73,8 +73,8 @@ var _ = Describe("Masonry CLI", func() {
output := Masonry(
"docs", "gitbook", "LATO",
"-e", exportTempDir,
"-o", filepath.Join("fixtures", "opencontrol_fixtures_with_markdown"),
"-m", filepath.Join("fixtures", "opencontrol_fixtures_with_markdown", "markdowns")).Wait(1 * time.Second)
"-o", filepath.Join("..", "..", "test", "fixtures", "opencontrol_fixtures_with_markdown"),
"-m", filepath.Join("..", "..", "test", "fixtures", "opencontrol_fixtures_with_markdown", "markdowns")).Wait(1 * time.Second)
Eventually(output.Out.Contents).ShouldNot(ContainSubstring("Warning: markdown directory does not exist\n"))
Eventually(output.Out.Contents).Should(ContainSubstring("New Gitbook Documentation Created\n"))
})
Expand All @@ -101,15 +101,15 @@ var _ = Describe("Masonry CLI", func() {
It("should print the number of missing controls", func() {
output := Masonry(
"diff", "LATO",
"-o", filepath.Join("fixtures", "opencontrol_fixtures")).Wait(1 * time.Second)
"-o", filepath.Join("..", "..", "test", "fixtures", "opencontrol_fixtures")).Wait(1 * time.Second)
Eventually(output.Out.Contents).Should(ContainSubstring("Number of missing controls:"))
})
})
})
})

func Masonry(args ...string) *Session {
path, err := Build("github.com/opencontrol/compliance-masonry")
path, err := Build("github.com/opencontrol/compliance-masonry/cmd/compliance-masonry")
Expect(err).NotTo(HaveOccurred())
cmd := exec.Command(path, args...)
stdin, err := cmd.StdinPipe()
Expand Down
2 changes: 1 addition & 1 deletion diff.go → cmd/compliance-masonry/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"
"github.com/codegangsta/cli"
"github.com/opencontrol/compliance-masonry/commands/diff"
"github.com/opencontrol/compliance-masonry/pkg/cli/diff"
"github.com/tg/gosortmap"
)

Expand Down
2 changes: 1 addition & 1 deletion diff_test.go → cmd/compliance-masonry/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var _ = Describe("Diff", func() {
}
})
It("should return return the number a missing controls when given a certification", func() {
err := app.Run([]string{app.Name, "diff", "LATO", "-o", filepath.Join("fixtures", "opencontrol_fixtures")})
err := app.Run([]string{app.Name, "diff", "LATO", "-o", filepath.Join("..", "..", "test", "fixtures", "opencontrol_fixtures")})
assert.Nil(GinkgoT(), err)
assert.Contains(GinkgoT(), buffer.String(), "Number of missing controls:")
})
Expand Down
4 changes: 2 additions & 2 deletions exampleplugin/example.go → examples/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package main

import (
"fmt"
"github.com/opencontrol/compliance-masonry/lib"
"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/opencontrol/compliance-masonry/pkg/lib"
"github.com/opencontrol/compliance-masonry/pkg/lib/common"
"io"
"os"
)
Expand Down
12 changes: 6 additions & 6 deletions exampleplugin/example_test.go → examples/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gbytes"
. "github.com/onsi/gomega/gexec"
"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/opencontrol/compliance-masonry/lib/common/mocks"
"github.com/opencontrol/compliance-masonry/pkg/lib/common"
"github.com/opencontrol/compliance-masonry/pkg/lib/common/mocks"
"github.com/stretchr/testify/assert"
"os"
"os/exec"
Expand Down Expand Up @@ -48,8 +48,8 @@ var _ = Describe("Exampleplugin", func() {
Describe("run", func() {
Context("When running it on data in a workspace", func() {
It("should find the data and print it out to standard out", func() {
wsPath := filepath.Join("..", "fixtures", "opencontrol_fixtures")
certPath := filepath.Join("..", "..", "fixtures", "opencontrol_fixtures", "certifications", "LATO.yaml")
wsPath := filepath.Join("..", "test", "fixtures", "opencontrol_fixtures")
certPath := filepath.Join("..", "..", "test", "fixtures", "opencontrol_fixtures", "certifications", "LATO.yaml")
buffer := NewBuffer()
run(wsPath, certPath, buffer)
Expect(buffer).To(Say("partial"))
Expand Down Expand Up @@ -84,12 +84,12 @@ func cleanupOpencontrolWorkspace() {
}

func Masonry(args ...string) *Session {
path, err := Build("github.com/opencontrol/compliance-masonry")
path, err := Build("github.com/opencontrol/compliance-masonry/cmd/compliance-masonry")
Expect(err).NotTo(HaveOccurred())
return createCommand(path, args...)
}
func Plugin(args ...string) *Session {
path, err := Build("github.com/opencontrol/compliance-masonry/exampleplugin")
path, err := Build("github.com/opencontrol/compliance-masonry/examples")
Expect(err).NotTo(HaveOccurred())
return createCommand(path, args...)
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions commands/diff/inventory.go → pkg/cli/diff/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package diff

import (
"fmt"
"github.com/opencontrol/compliance-masonry/lib"
"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/opencontrol/compliance-masonry/pkg/lib"
"github.com/opencontrol/compliance-masonry/pkg/lib/common"
"github.com/opencontrol/compliance-masonry/tools/certifications"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package diff_test

import (
. "github.com/opencontrol/compliance-masonry/commands/diff"
. "github.com/opencontrol/compliance-masonry/pkg/cli/diff"

"errors"
. "github.com/onsi/ginkgo"
Expand Down Expand Up @@ -39,7 +39,7 @@ var _ = Describe("Inventory", func() {
Context("When there are controls specified in the certification but some controls have been documented", func() {
It("should return a subset of the full list of controls", func() {
config := Config{
OpencontrolDir: filepath.Join(workingDir, "..", "..", "fixtures", "opencontrol_fixtures"),
OpencontrolDir: filepath.Join(workingDir, "..", "..", "..", "test", "fixtures", "opencontrol_fixtures"),
Certification: "LATO",
}
i, err := ComputeGapAnalysis(config)
Expand All @@ -50,7 +50,7 @@ var _ = Describe("Inventory", func() {
Context("When there are controls specified in the certification and we have documented them", func() {
It("should return no missing controls", func() {
config := Config{
OpencontrolDir: filepath.Join(workingDir, "..", "..", "fixtures", "opencontrol_fixtures_complete"),
OpencontrolDir: filepath.Join(workingDir, "..", "..", "..", "test", "fixtures", "opencontrol_fixtures_complete"),
Certification: "LATO",
}
i, err := ComputeGapAnalysis(config)
Expand Down
2 changes: 1 addition & 1 deletion commands/docs/docs.go → pkg/cli/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package docs
import (
"os"

"github.com/opencontrol/compliance-masonry/commands/docs/gitbook"
"github.com/opencontrol/compliance-masonry/pkg/cli/docs/gitbook"
"github.com/opencontrol/compliance-masonry/tools/certifications"
)

Expand Down
File renamed without changes.
20 changes: 10 additions & 10 deletions commands/docs/docs_test.go → pkg/cli/docs/docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"os"
"path/filepath"

. "github.com/opencontrol/compliance-masonry/commands/docs"
"github.com/opencontrol/compliance-masonry/commands/docs/gitbook"
. "github.com/opencontrol/compliance-masonry/pkg/cli/docs"
"github.com/opencontrol/compliance-masonry/pkg/cli/docs/gitbook"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
Expand All @@ -27,7 +27,7 @@ var _ = Describe("Doc Tests", func() {
Entry(
"Check that the gitbook is correctly exported given the fixtures",
gitbook.Config{
OpencontrolDir: filepath.Join("..", "..", "fixtures", "opencontrol_fixtures"),
OpencontrolDir: filepath.Join("..", "..", "..", "test", "fixtures", "opencontrol_fixtures"),
Certification: "LATO",
MarkdownPath: "",
},
Expand All @@ -49,9 +49,9 @@ var _ = Describe("Doc Tests", func() {
Entry(
"Check that gitbook is created with markdowns",
gitbook.Config{
OpencontrolDir: filepath.Join("..", "..", "fixtures", "opencontrol_fixtures_with_markdown"),
OpencontrolDir: filepath.Join("..", "..", "..", "test", "fixtures", "opencontrol_fixtures_with_markdown"),
Certification: "LATO",
MarkdownPath: filepath.Join("..", "..", "fixtures", "opencontrol_fixtures_with_markdown", "markdowns"),
MarkdownPath: filepath.Join("..", "..", "..", "test", "fixtures", "opencontrol_fixtures_with_markdown", "markdowns"),
},
"",
nil,
Expand All @@ -60,20 +60,20 @@ var _ = Describe("Doc Tests", func() {
Entry(
"Check that thre is an error returned when the certification does not exist",
gitbook.Config{
OpencontrolDir: filepath.Join("..", "..", "fixtures", "opencontrol_fixtures_with_markdown"),
OpencontrolDir: filepath.Join("..", "..", "..", "test", "fixtures", "opencontrol_fixtures_with_markdown"),
Certification: "LAT",
MarkdownPath: filepath.Join("..", "..", "fixtures", "opencontrol_fixtures_with_markdown", "markdowns"),
MarkdownPath: filepath.Join("..", "..", "..", "test", "fixtures", "opencontrol_fixtures_with_markdown", "markdowns"),
},
"",
[]error{fmt.Errorf("Error: `%s` does not exist\nUse one of the following:\nLATO", filepath.Join("..", "..", "fixtures", "opencontrol_fixtures_with_markdown", "certifications", "LAT.yaml"))},
[]error{fmt.Errorf("Error: `%s` does not exist\nUse one of the following:\nLATO", filepath.Join("..", "..", "..", "test", "fixtures", "opencontrol_fixtures_with_markdown", "certifications", "LAT.yaml"))},
),

Entry(
"Check that error is returned when certification argument is not present",
gitbook.Config{
OpencontrolDir: filepath.Join("..", "..", "fixtures", "opencontrol_fixtures_with_markdown"),
OpencontrolDir: filepath.Join("..", "..", "..", "test", "fixtures", "opencontrol_fixtures_with_markdown"),
Certification: "",
MarkdownPath: filepath.Join("..", "..", "fixtures", "opencontrol_fixtures_with_markdown", "markdowns/"),
MarkdownPath: filepath.Join("..", "..", "..", "test", "fixtures", "opencontrol_fixtures_with_markdown", "markdowns/"),
},
"",
[]error{errors.New("Error: Missing Certification Argument")},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"path/filepath"
"strings"

"github.com/opencontrol/compliance-masonry/lib"
"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/opencontrol/compliance-masonry/pkg/lib"
"github.com/opencontrol/compliance-masonry/pkg/lib/common"
"github.com/opencontrol/compliance-masonry/tools/fs"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io/ioutil"
"path/filepath"

"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/opencontrol/compliance-masonry/pkg/lib/common"
)

func (openControl *OpenControlGitBook) getResponsibleRole(text string, component common.Component) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"testing"

"github.com/opencontrol/compliance-masonry/lib"
"github.com/opencontrol/compliance-masonry/pkg/lib"
"github.com/opencontrol/compliance-masonry/tools/fs"
)

Expand All @@ -24,8 +24,8 @@ type exportControlTest struct {
var exportControlTests = []exportControlTest{
// Check that a control is exported correctly
{
filepath.Join("..", "..", "..", "fixtures", "opencontrol_fixtures"),
filepath.Join("..", "..", "..", "fixtures", "opencontrol_fixtures", "certifications", "LATO.yaml"),
filepath.Join("..", "..", "..", "..", "test", "fixtures", "opencontrol_fixtures"),
filepath.Join("..", "..", "..", "..", "test", "fixtures", "opencontrol_fixtures", "certifications", "LATO.yaml"),
"NIST-800-53",
"CM-2",
"NIST-800-53-CM-2.md",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"testing"

"github.com/blang/semver"
"github.com/opencontrol/compliance-masonry/lib/common"
v2 "github.com/opencontrol/compliance-masonry/lib/components/versions/2_0_0"
"github.com/opencontrol/compliance-masonry/pkg/lib/common"
v2 "github.com/opencontrol/compliance-masonry/pkg/lib/components/versions/2_0_0"
)

type componentExportTest struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package gitbook

import (
"fmt"
"github.com/opencontrol/compliance-masonry/lib/common"
"github.com/opencontrol/compliance-masonry/pkg/lib/common"
"io/ioutil"
"path/filepath"
"strings"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"testing"

"github.com/opencontrol/compliance-masonry/lib"
"github.com/opencontrol/compliance-masonry/pkg/lib"
"github.com/opencontrol/compliance-masonry/tools/fs"
)

Expand All @@ -29,10 +29,10 @@ type buildStandardsSummariesTest struct {
var buildComponentsSummariesTests = []buildComponentsSummariesTest{
// Check that the component summary is correctly exported
{
filepath.Join("..", "..", "..", "fixtures", "opencontrol_fixtures"),
filepath.Join("..", "..", "..", "fixtures", "opencontrol_fixtures", "certifications", "LATO.yaml"),
filepath.Join("..", "..", "..", "..", "test", "fixtures", "opencontrol_fixtures"),
filepath.Join("..", "..", "..", "..", "test", "fixtures", "opencontrol_fixtures", "certifications", "LATO.yaml"),
"",
filepath.Join("..", "..", "..", "fixtures", "exports_fixtures", "gitbook_exports", "components_readme.md"),
filepath.Join("..", "..", "..", "..", "test", "fixtures", "exports_fixtures", "gitbook_exports", "components_readme.md"),
},
}

Expand Down Expand Up @@ -61,11 +61,11 @@ func TestBuildComponentsSummaries(t *testing.T) {
var buildStandardsSummariesTests = []buildStandardsSummariesTest{
// Check that a standards summary is correctly exported
{
filepath.Join("..", "..", "..", "fixtures", "opencontrol_fixtures"),
filepath.Join("..", "..", "..", "fixtures", "opencontrol_fixtures", "certifications", "LATO.yaml"),
filepath.Join("..", "..", "..", "..", "test", "fixtures", "opencontrol_fixtures"),
filepath.Join("..", "..", "..", "..", "test", "fixtures", "opencontrol_fixtures", "certifications", "LATO.yaml"),
"",
filepath.Join("..", "..", "..", "fixtures", "exports_fixtures", "gitbook_exports", "standards_readme.md"),
filepath.Join("..", "..", "..", "fixtures", "exports_fixtures", "gitbook_exports", "standards"),
filepath.Join("..", "..", "..", "..", "test", "fixtures", "exports_fixtures", "gitbook_exports", "standards_readme.md"),
filepath.Join("..", "..", "..", "..", "test", "fixtures", "exports_fixtures", "gitbook_exports", "standards"),
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ func TestReplaceParentheses(t *testing.T) {
var buildGitbookTests = []buildGitbookTest{
// Check that the gitbook is correctly exported given the fixtures
{
filepath.Join("..", "..", "..", "fixtures", "opencontrol_fixtures"),
filepath.Join("..", "..", "..", "fixtures", "opencontrol_fixtures", "certifications", "LATO.yaml"),
filepath.Join("..", "..", "..", "..", "test", "fixtures", "opencontrol_fixtures"),
filepath.Join("..", "..", "..", "..", "test", "fixtures", "opencontrol_fixtures", "certifications", "LATO.yaml"),
"",
filepath.Join("..", "..", "..", "fixtures", "exports_fixtures", "complete_export"),
filepath.Join("..", "..", "..", "..", "test", "fixtures", "exports_fixtures", "complete_export"),
},
// Check that the gitbook is correctly exported given the fixtures with markdowns
{
filepath.Join("..", "..", "..", "fixtures", "opencontrol_fixtures_with_markdown"),
filepath.Join("..", "..", "..", "fixtures", "opencontrol_fixtures_with_markdown", "certifications", "LATO.yaml"),
filepath.Join("..", "..", "..", "fixtures", "opencontrol_fixtures_with_markdown", "markdowns"),
filepath.Join("..", "..", "..", "fixtures", "exports_fixtures", "complete_export_with_markdown"),
filepath.Join("..", "..", "..", "..", "test", "fixtures", "opencontrol_fixtures_with_markdown"),
filepath.Join("..", "..", "..", "..", "test", "fixtures", "opencontrol_fixtures_with_markdown", "certifications", "LATO.yaml"),
filepath.Join("..", "..", "..", "..", "test", "fixtures", "opencontrol_fixtures_with_markdown", "markdowns"),
filepath.Join("..", "..", "..", "..", "test", "fixtures", "exports_fixtures", "complete_export_with_markdown"),
},
}

Expand Down
Loading

0 comments on commit 3ef42d3

Please sign in to comment.