-
Notifications
You must be signed in to change notification settings - Fork 72
/
Makefile
112 lines (88 loc) · 4.47 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
.DEFAULT_GOAL := binary
SHELL = bash
# see internal/build.go on build configurations
RHOAS_VERSION ?= "dev"
REPOSITORY_OWNER ?= "redhat-developer"
REPOSITORY_NAME ?= "app-services-cli"
CONSTANTS_URL ?= "https://console.redhat.com/apps/application-services/service-constants.json"
SSO_REDIRECT_PATH ?= "sso-redhat-callback"
BUILD_SOURCE ?= "local"
# see pkg/cmdutil/constants.go
DEFAULT_PAGE_NUMBER ?= "1"
DEFAULT_PAGE_SIZE ?= "10"
GO_LDFLAGS := -X github.com/redhat-developer/app-services-cli/internal/build.Version=$(RHOAS_VERSION) $(GO_LDFLAGS)
GO_LDFLAGS := -X github.com/redhat-developer/app-services-cli/internal/build.RepositoryOwner=$(REPOSITORY_OWNER) $(GO_LDFLAGS)
GO_LDFLAGS := -X github.com/redhat-developer/app-services-cli/internal/build.RepositoryName=$(REPOSITORY_NAME) $(GO_LDFLAGS)
GO_LDFLAGS := -X github.com/redhat-developer/app-services-cli/internal/build.DynamicConfigURL=$(CONSTANTS_URL) $(GO_LDFLAGS)
GO_LDFLAGS := -X github.com/redhat-developer/app-services-cli/internal/build.DefaultPageSize=$(DEFAULT_PAGE_SIZE) $(GO_LDFLAGS)
GO_LDFLAGS := -X github.com/redhat-developer/app-services-cli/internal/build.DefaultPageNumber=$(DEFAULT_PAGE_NUMBER) $(GO_LDFLAGS)
GO_LDFLAGS := -X github.com/redhat-developer/app-services-cli/internal/build.SSORedirectPath=$(SSO_REDIRECT_PATH) $(GO_LDFLAGS)
GO_LDFLAGS := -X github.com/redhat-developer/app-services-cli/internal/build.BuildSource=$(BUILD_SOURCE) $(GO_LDFLAGS)
BUILDFLAGS :=
ifdef DEBUG
BUILDFLAGS := -gcflags "all=-N -l" $(BUILDFLAGS)
endif
# The details of the application:
binary:=rhoas
# Enable Go modules:
export GO111MODULE=on
# Requires golangci-lint to be installed @ $(go env GOPATH)/bin/golangci-lint
# https://golangci-lint.run/usage/install/
lint: lint-lang ## Lint Go files for errors
golangci-lint run cmd/... pkg/... internal/...
generate: ## Scan code for generate comments and run generators
go generate ./...
# Build binaries
# NOTE it may be necessary to use CGO_ENABLED=0 for backwards compatibility with centos7 if not using centos7
binary: ## Compile the rhoas binary into the local project directory
go build $(BUILDFLAGS) -ldflags "${GO_LDFLAGS}" -o ${binary} ./cmd/rhoas
.PHONY: binary
install: ## Compile and install rhoas and add it to the PAth
go install -trimpath $(BUILDFLAGS) -ldflags "${GO_LDFLAGS}" ./cmd/rhoas
.PHONY: install
test: ## Run unit tests
go test ./pkg/... ./internal/...
.PHONY: test
start-mock-api: ## Start the mock rhoas server
npm install -g @rhoas/api-mock
asapi --pre-seed
.PHONY: start-mock-api
format: ## Clean up code and dependencies
@go mod tidy
@gofmt -w `find . -type f -name '*.go' ! -path './vendor/*'`
.PHONY: format
check-docs: generate-docs ## Check whether reference documentation needs to be generated
./scripts/check-docs.sh
.PHONY: check-docs
generate-docs: ## Generate command-line reference documentation
rm -rf ./docs/commands/*.md
go run ./cmd/rhoas docs --dir ./docs/commands --file-format md
.PHONY: generate-docs
generate-downstream-docs: ## Generate command-line reference documentation in adoc format
rm -rf ./docs/commands/*
go run ./cmd/rhoas docs --dir ./dist --file-format adoc
.PHONY: generate-downstream-docs
check-vendor:
./scripts/check-vendor.sh
.PHONY: check-vendor
I18N_LINTER_DEF := $(shell command -v app-services-go-linter 2> /dev/null)
lint-lang: ## Lint i18n files
ifndef I18N_LINTER_DEF # check if the linter is installed, install it if not
go install github.com/redhat-developer/app-services-go-linter/cmd/app-services-go-linter@latest
endif
app-services-go-linter -path ./pkg/core/localize/locales ./...
.PHONY: lint-lang
# Check http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.PHONY: help
update-sdk:
go get github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/kafkamgmt@latest
go get github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/serviceaccountmgmt@latest
go get github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/connectormgmt@latest
go get github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/accountmgmt@latest
go get github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/kafkainstance@latest
go get github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/registryinstance@latest
go get github.com/redhat-developer/app-services-sdk-core/app-services-sdk-go/registrymgmt@latest
go mod tidy
go mod vendor