Skip to content

Commit

Permalink
Simplify installation with go install
Browse files Browse the repository at this point in the history
Currently the main file of the binary is in a package named `cmd`. That
complicates installation using `go install`. To simplify that this patch
moves it to a `metamodel` package, so that it will be possible to
install like this:

```
$ go install github.com/openshift-online/ocm-api-metamodel/cmd/[email protected]
```

Signed-off-by: Juan Hernandez <[email protected]>
  • Loading branch information
jhernand committed Jan 6, 2022
1 parent 2c08182 commit 243864a
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
env["GOARCH"] = goarch
# Build the binary:
args = ["make", "cmds"]
args = ["make", "binary"]
subprocess.run(check=True, env=env, args=args)
# Copy the generated binary to the assets directory:
Expand Down
16 changes: 7 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,22 @@
# limitations under the License.
#

# Disable CGO so that we always generate static binaries:
export CGO_ENABLED=0

# Details of the version of 'antlr' to use:
antlr_version:=4.9.3
antlr_url:=https://www.antlr.org/download/antlr-$(antlr_version)-complete.jar
antlr_sum:=afcd40946d3de4d81e28d7c88d467289e0587285d27adb172aecc5494a17df36

# Explicitly enable Go modules so that compilation will work correctly even when
# the project directory is inside the directory indicated by the 'GOPATH'
# environment variable:
export GO111MODULE=on

# Version of the OpenAPI verification tool:
openapi_generator_version:=3.3.4
openapi_generator_url:=https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/$(openapi_generator_version)/openapi-generator-cli-$(openapi_generator_version).jar
openapi_generator_sum:=24cb04939110cffcdd7062d2f50c6f61159dc3e0ca3b8aecbae6ade53ad3dc8c

.PHONY: cmds
cmds: generate
go build -o metamodel ./cmd
.PHONY: binary
binary: generate
go build ./cmd/metamodel

.PHONY: generate
generate: antlr
Expand Down Expand Up @@ -65,7 +63,7 @@ unit_tests:
ginkgo -r pkg

.PHONY: golang_tests
go_tests: cmds
go_tests: binary
rm -rf tests/go/generated
./metamodel generate go \
--model=tests/model \
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions cmd/generate/cmd.go → cmd/metamodel/generate/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package generate
import (
"github.com/spf13/cobra"

"github.com/openshift-online/ocm-api-metamodel/cmd/generate/docs"
"github.com/openshift-online/ocm-api-metamodel/cmd/generate/golang"
"github.com/openshift-online/ocm-api-metamodel/cmd/generate/openapi"
"github.com/openshift-online/ocm-api-metamodel/cmd/metamodel/generate/docs"
"github.com/openshift-online/ocm-api-metamodel/cmd/metamodel/generate/golang"
"github.com/openshift-online/ocm-api-metamodel/cmd/metamodel/generate/openapi"
)

// Cmd is the definition of the command:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions cmd/main.go → cmd/metamodel/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/openshift-online/ocm-api-metamodel/cmd/check"
"github.com/openshift-online/ocm-api-metamodel/cmd/generate"
"github.com/openshift-online/ocm-api-metamodel/cmd/version"
"github.com/openshift-online/ocm-api-metamodel/cmd/metamodel/check"
"github.com/openshift-online/ocm-api-metamodel/cmd/metamodel/generate"
"github.com/openshift-online/ocm-api-metamodel/cmd/metamodel/version"
)

// Root command:
Expand Down
File renamed without changes.

0 comments on commit 243864a

Please sign in to comment.