Skip to content

Commit b6b3e5a

Browse files
committed
add essentials
1 parent bb225b0 commit b6b3e5a

File tree

18 files changed

+806
-2
lines changed

18 files changed

+806
-2
lines changed

.github/FUNDING.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
github: [greenpau]
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: Ask a question!
3+
about: There are no stupid questions! It is this project's documentation that needs improvement. Show ❤️️, give 🌟
4+
title: 'question: CHANGE_ME'
5+
labels: ['need triage', 'question']
6+
assignees: 'greenpau'
7+
8+
---
9+
10+
> A clear and concise description of what you want to accomplish.
11+
12+
CHANGE_ME

.github/ISSUE_TEMPLATE/break-fix.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: Things are not working!
3+
about: You think you are doing the right thing, but it is not working as expected.
4+
title: 'breakfix: CHANGE_ME'
5+
labels: ['need triage', 'breakfix']
6+
assignees: 'greenpau'
7+
8+
---
9+
10+
**Describe the issue**
11+
12+
A clear and concise description of what the issue is.
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: Feature Request
3+
about: You understand that some functionality/feature is not available and you want it added.
4+
title: 'feature: CHANGE_ME'
5+
labels: ['need triage', 'feature']
6+
assignees: 'greenpau'
7+
8+
---
9+
10+
> A clear and concise description of what you want the system to do.
11+
12+
CHANGE_ME

.github/workflows/main.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
name: build
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
core:
14+
strategy:
15+
matrix:
16+
go-version: [1.15.x, 1.16.x]
17+
platform: [ubuntu-latest]
18+
name: Build
19+
runs-on: ${{ matrix.platform }}
20+
env:
21+
GOBIN: /home/runner/.local/bin
22+
steps:
23+
- name: Install Go
24+
uses: actions/setup-go@v1
25+
with:
26+
go-version: ${{ matrix.go-version }}
27+
id: go
28+
- name: Check out code into the Go module directory
29+
uses: actions/checkout@v2
30+
- name: Install Go modules
31+
run: |
32+
mkdir -p .coverage
33+
- name: Run tests
34+
run: |
35+
go test -v -coverprofile=.coverage/coverage.out ./*.go
36+
go tool cover -html=.coverage/coverage.out -o .coverage/coverage.html
37+
go test -covermode=count -coverprofile=.coverage/coverage.out ./*.go
38+
go tool cover -func=.coverage/coverage.out | grep -v 100
39+
- name: Upload coverage report
40+
uses: actions/upload-artifact@v1
41+
with:
42+
name: Test Coverage Report
43+
path: .coverage/coverage.html

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
vendor/**
2+
bin/**
3+
.coverage/**
4+
.doc/**
5+
*TODO*
6+
123*
7+
.tmp/**
8+
19
# Binaries for programs and plugins
210
*.exe
311
*.exe~

Makefile

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
.PHONY: test ctest covdir coverage docs linter qtest clean dep release license envvar
2+
APP_VERSION:=$(shell cat VERSION | head -1)
3+
GIT_COMMIT:=$(shell git describe --dirty --always)
4+
GIT_BRANCH:=$(shell git rev-parse --abbrev-ref HEAD -- | head -1)
5+
BUILD_USER:=$(shell whoami)
6+
BUILD_DATE:=$(shell date +"%Y-%m-%d")
7+
VERBOSE:=-v
8+
ifdef TEST
9+
TEST:="-run ${TEST}"
10+
endif
11+
12+
all: envvar build
13+
@echo "$@: complete"
14+
15+
envvar:
16+
@echo "Version: $(APP_VERSION), Branch: $(GIT_BRANCH), Revision: $(GIT_COMMIT)"
17+
@echo "Build on $(BUILD_DATE) by $(BUILD_USER)"
18+
19+
build:
20+
@mkdir -p bin/
21+
@rm -rf ./bin/*
22+
@CGO_ENABLED=0 go build -o ./bin/aaasfcli $(VERBOSE) \
23+
-ldflags="-w -s \
24+
-X main.appVersion=$(APP_VERSION) \
25+
-X main.gitBranch=$(GIT_BRANCH) \
26+
-X main.gitCommit=$(GIT_COMMIT) \
27+
-X main.buildUser=$(BUILD_USER) \
28+
-X main.buildDate=$(BUILD_DATE)" \
29+
-gcflags="all=-trimpath=$(GOPATH)/src" \
30+
-asmflags="all=-trimpath $(GOPATH)/src" \
31+
cmd/aaasfcli/*.go
32+
@./bin/aaasfcli --version
33+
@./bin/aaasfcli --help
34+
@echo "$@: complete"
35+
36+
linter:
37+
@echo "Running lint checks"
38+
@golint -set_exit_status ./...
39+
@echo "$@: complete"
40+
41+
gtest:
42+
@go test $(VERBOSE) -coverprofile=.coverage/coverage.out ./...
43+
@echo "$@: complete"
44+
45+
test: envvar covdir linter gtest coverage
46+
@echo "$@: complete"
47+
48+
ctest: covdir linter
49+
@richgo version || go get -u github.com/kyoh86/richgo
50+
@time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./...
51+
@echo "$@: complete"
52+
53+
covdir:
54+
@echo "Creating .coverage/ directory"
55+
@mkdir -p .coverage
56+
@echo "$@: complete"
57+
58+
coverage:
59+
@#go tool cover -help
60+
@go tool cover -html=.coverage/coverage.out -o .coverage/coverage.html
61+
@go test -covermode=count -coverprofile=.coverage/coverage.out ./...
62+
@go tool cover -func=.coverage/coverage.out | grep -v "100.0"
63+
@echo "$@: complete"
64+
65+
docs:
66+
@mkdir -p .doc
67+
@go doc -all > .doc/index.txt
68+
@cat .doc/index.txt
69+
@echo "$@: complete"
70+
71+
clean:
72+
@rm -rf .doc
73+
@rm -rf .coverage
74+
@rm -rf bin/
75+
@echo "$@: complete"
76+
77+
qtest:
78+
@echo "Perform quick tests ..."
79+
@time richgo test -v -coverprofile=.coverage/coverage.out internal/tag/*.go
80+
@go tool cover -html=.coverage/coverage.out -o .coverage/coverage.html
81+
@go tool cover -func=.coverage/coverage.out | grep -v "100.0"
82+
@echo "$@: complete"
83+
84+
dep:
85+
@echo "Making dependencies check ..."
86+
@golint || go get -u golang.org/x/lint/golint
87+
@go get -u github.com/kyoh86/richgo
88+
@versioned || go get -u github.com/greenpau/versioned/cmd/versioned
89+
@echo "$@: complete"
90+
91+
license:
92+
@versioned || go get -u github.com/greenpau/versioned/cmd/versioned
93+
@for f in `find ./ -type f -name '*.go'`; do versioned -addlicense -copyright="Paul Greenberg [email protected]" -year=2022 -filepath=$$f; done
94+
@echo "$@: complete"
95+
96+
release:
97+
@echo "Making release"
98+
@go mod tidy
99+
@go mod verify
100+
@if [ $(GIT_BRANCH) != "main" ]; then echo "cannot release to non-main branch $(GIT_BRANCH)" && false; fi
101+
@git diff-index --quiet HEAD -- || ( echo "git directory is dirty, commit changes first" && false )
102+
@versioned -patch
103+
@echo "Patched version"
104+
@git add VERSION
105+
@versioned -sync cmd/aaasfcli/main.go
106+
@git add cmd/aaasfcli/main.go
107+
@git commit -m "released v`cat VERSION | head -1`"
108+
@git tag -a v`cat VERSION | head -1` -m "v`cat VERSION | head -1`"
109+
@git push
110+
@git push --tags

OWNERS

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
reviewers:
3+
- greenpau
4+
5+
approvers:
6+
- greenpau
7+
8+
features:
9+
- comments
10+
- reviewers
11+
- aliases
12+
- branches

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# aaasf
2-
Authentication, Authorization, and Accounting (AAA) Security Functions (SF)
1+
# Authentication, Authorization, and Accounting (AAA) Security Functions (SF)
2+
3+
This code base contains the functions implementing AAA.

VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

cmd/aaasfcli/main.go

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"github.com/urfave/cli/v2"
6+
"os"
7+
8+
"github.com/greenpau/versioned"
9+
)
10+
11+
var (
12+
app *versioned.PackageManager
13+
appVersion string
14+
gitBranch string
15+
gitCommit string
16+
buildUser string
17+
buildDate string
18+
sh *cli.App
19+
)
20+
21+
func init() {
22+
app = versioned.NewPackageManager("aaasfcli")
23+
app.Description = "AAA SF management client"
24+
app.Documentation = "https://github.com/greenpau/aaasf/"
25+
app.SetVersion(appVersion, "1.0.0")
26+
app.SetGitBranch(gitBranch, "")
27+
app.SetGitCommit(gitCommit, "")
28+
app.SetBuildUser(buildUser, "")
29+
app.SetBuildDate(buildDate, "")
30+
31+
cli.VersionPrinter = func(c *cli.Context) {
32+
fmt.Fprintf(os.Stdout, "%s\n", app.Banner())
33+
}
34+
35+
sh = cli.NewApp()
36+
sh.Name = app.Name
37+
sh.Version = app.Version
38+
sh.Usage = app.Description
39+
sh.Description = app.Documentation
40+
sh.HideHelp = false
41+
sh.HideVersion = false
42+
sh.Flags = append(sh.Flags, &cli.StringFlag{
43+
Name: "config",
44+
Aliases: []string{"c"},
45+
Usage: "Sets path to configuration from `CONFIG_PATH` (default: ~/.config/aaasfcli/config.json)",
46+
EnvVars: []string{"AUTHDBCTL_CONFIG_PATH"},
47+
})
48+
}
49+
50+
func main() {
51+
sh.Run(os.Args)
52+
}

go.mod

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module github.com/greenpau/aaasf
2+
3+
go 1.16
4+
5+
require (
6+
github.com/google/go-cmp v0.5.6 // indirect
7+
github.com/greenpau/versioned v1.0.27 // indirect
8+
github.com/iancoleman/strcase v0.2.0 // indirect
9+
github.com/urfave/cli/v2 v2.3.0 // indirect
10+
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce // indirect
11+
)

go.sum

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
2+
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
3+
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
4+
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
5+
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
6+
github.com/greenpau/versioned v1.0.27 h1:aFJ16tzsUkbc6WT7DRia60S0VrgWzBNuul3h0RXFKxM=
7+
github.com/greenpau/versioned v1.0.27/go.mod h1:rtFCvaWWNbMH4CJnje/xicgmrM63j++rUh5juSu0k/A=
8+
github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=
9+
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
10+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
11+
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
12+
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
13+
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
14+
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
15+
github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
16+
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
17+
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce h1:Roh6XWxHFKrPgC/EQhVubSAGQ6Ozk6IdxHSzt1mR0EI=
18+
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
19+
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
20+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
21+
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
22+
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
23+
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
24+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
25+
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
26+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
27+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
28+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
29+
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

0 commit comments

Comments
 (0)