...
1COLOR_OK=\\x1b[0;32m
2COLOR_NONE=\x1b[0m
3COLOR_ERROR=\x1b[31;01m
4COLOR_WARNING=\x1b[33;05m
5COLOR_OKTA=\x1B[34;01m
6GOFMT := gofumpt
7GOIMPORTS := goimports
8
9help:
10 @echo "$(COLOR_OK)Okta SDK for Golang$(COLOR_NONE)"
11 @echo ""
12 @echo "$(COLOR_WARNING)Usage:$(COLOR_NONE)"
13 @echo "$(COLOR_OK) make [command]$(COLOR_NONE)"
14 @echo ""
15 @echo "$(COLOR_WARNING)Available commands:$(COLOR_NONE)"
16 @echo "$(COLOR_OK) build Clean and build the Okta Golang SDK generated files$(COLOR_NONE)"
17 @echo "$(COLOR_OK) clean-files Deletes all generated files$(COLOR_NONE)"
18 @echo "$(COLOR_OK) generate-files Generates files based around spec$(COLOR_NONE)"
19 @echo "$(COLOR_OK) pull-spec Pull down the most recent released version of the spec$(COLOR_NONE)"
20 @echo "$(COLOR_WARNING)test$(COLOR_NONE)"
21 @echo "$(COLOR_OK) test:all Run all tests$(COLOR_NONE)"
22 @echo "$(COLOR_OK) test:integration Run only integration tests$(COLOR_NONE)"
23 @echo "$(COLOR_OK) test:unit Run only unit tests$(COLOR_NONE)"
24
25build:
26 @echo "$(COLOR_OKTA)Building SDK...$(COLOR_NONE)"
27 make clean-files
28 make generate-files
29 make test:all
30
31clean-files:
32 @echo "$(COLOR_OKTA)Cleaning Up Old Generated Files...$(COLOR_NONE)"
33 cd openapi && yarn cleanFiles
34
35generate-files:
36 @echo "$(COLOR_OKTA)Generating SDK Files...$(COLOR_NONE)"
37 cd openapi && yarn generator
38 @echo "$(COLOR_OK)Running goimports and gofumpt on generated files...$(COLOR_NONE)"
39 @make import
40 @make fmt
41 @echo "$(COLOR_OKTA)Done!$(COLOR_NONE)"
42
43pull-spec:
44 @echo "$(COLOR_OKTA)Pulling in latest spec...$(COLOR_NONE)"
45 cd openapi && npm install
46# Overwrite the spec.json file from npm if a git branch is specified by env variable.
47ifneq ($(origin OPENAPI_SPEC_BRANCH),undefined)
48 rm -f openapi/spec.json
49 git clone --branch $(OPENAPI_SPEC_BRANCH) https://github.com/okta/okta-management-openapi-spec spec-raw
50 cp spec-raw/dist/spec.json openapi/spec.json
51 cp spec-raw/dist/spec.json openapi/node_modules/@okta/openapi/dist/spec.json
52 rm -fr spec-raw
53endif
54
55test:
56 make test:all
57
58test\:all:
59 @echo "$(COLOR_OKTA)Running all tests...$(COLOR_NONE)"
60 @make test:unit
61 @make test:integration
62
63test\:integration:
64 @echo "$(COLOR_OKTA)Running integration tests...$(COLOR_NONE)"
65 go test -failfast -race ./tests/integration -test.v
66
67test\:unit:
68 @echo "$(COLOR_OK)Running unit tests...$(COLOR_NONE)"
69 go test -failfast -race ./tests/unit ./okta/query -test.v
70
71test\:integration\:all:
72 @echo "$(COLOR_OKTA)Running integration tests...$(COLOR_NONE)"
73 go test -race ./tests/integration -test.v
74
75test\:unit\:all:
76 @echo "$(COLOR_OK)Running unit tests...$(COLOR_NONE)"
77 go test -race ./tests/unit ./okta/query -test.v
78
79.PHONY: fmt
80fmt: check-fmt # Format the code
81 @$(GOFMT) -l -w $$(find . -name '*.go' |grep -v vendor) > /dev/null
82
83check-fmt:
84 @which $(GOFMT) > /dev/null || GO111MODULE=on go install mvdan.cc/gofumpt@latest
85
86.PHONY: import
87import: check-goimports
88 @$(GOIMPORTS) -w $$(find . -path ./vendor -prune -o -name '*.go' -print) > /dev/null
89
90check-goimports:
91 @which $(GOIMPORTS) > /dev/null || GO111MODULE=on go install golang.org/x/tools/cmd/goimports@latest
92
93v3-test:
94 go test -failfast -race ./okta/v3 -test.v
95
96v3-generate:
97 npx @openapitools/openapi-generator-cli generate -c ./.generator/config.yaml -i .generator/okta-management-APIs-oasv3-enum-inheritance.yaml
View as plain text