Skip to content

Commit cac5f3d

Browse files
committed
Initial version
1 parent 99dcea3 commit cac5f3d

31 files changed

+2354
-0
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
custom: https://paypal.me/grepplabs?locale.x=en_GB

.github/workflows/tests.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up Go
17+
uses: actions/setup-go@v5
18+
with:
19+
go-version: '1.21'
20+
check-latest: true
21+
- run: go version
22+
- name: Vendor
23+
run: go mod vendor
24+
- name: Build
25+
run: go build -v ./...
26+
- name: Vet
27+
run: go vet ./...
28+
- name: Test
29+
run: go test -count=1 -v ./...
30+
- name: golangci-lint
31+
uses: golangci/golangci-lint-action@v4
32+
with:
33+
version: v1.56.2
34+
skip-pkg-cache: true
35+
skip-build-cache: true

.golangci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# options for analysis running
2+
run:
3+
# exit code when at least one issue was found, default is 1
4+
issues-exit-code: 1
5+
6+
# which dirs to skip: they won't be analyzed;
7+
# can use regexp here: generated.*, regexp is applied on full path;
8+
# default value is empty list, but next dirs are always skipped independently
9+
# from this option's value:
10+
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
11+
skip-dirs:
12+
- vendor
13+
14+
linters:
15+
enable:
16+
- errcheck
17+
- goconst
18+
- godot
19+
- gofmt
20+
- goimports
21+
- gosimple
22+
- govet
23+
- ineffassign
24+
- staticcheck
25+
- typecheck
26+
- unparam
27+
- unused
28+
- exportloopref
29+
30+
issues:
31+
exclude-rules:
32+
- path: _test\.go
33+
linters:
34+
- unparam

Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.DEFAULT_GOAL := help
2+
3+
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
4+
5+
default: help
6+
7+
.PHONY: help
8+
help:
9+
@grep -E '^[a-zA-Z%_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
10+
11+
.PHONY: test
12+
test: ## Test
13+
GO111MODULE=on go test -count=1 -mod=vendor -v ./...
14+
15+
.PHONY: fmt
16+
fmt: ## Go format
17+
go fmt ./...
18+
19+
.PHONY: vet
20+
vet: ## Go vet
21+
go vet ./...
22+
23+
.PHONY: lint
24+
lint: ## Lint
25+
@golangci-lint run
26+
27+
.PHONY: deps
28+
deps: ## Get dependencies
29+
GO111MODULE=on go get ./...
30+
31+
.PHONY: vendor
32+
vendor: ## Go vendor
33+
GO111MODULE=on go mod vendor
34+
35+
.PHONY: tidy
36+
tidy: ## Go tidy
37+
GO111MODULE=on go mod tidy
38+

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# cert-source
2+
3+
[![Release](https://img.shields.io/github/v/release/grepplabs/cert-source?sort=semver)](https://github.com/grepplabs/cert-source/releases)
4+
![Build](https://github.com/grepplabs/cert-source/workflows/tests/badge.svg)
5+
6+
## Overview
7+
8+
The cert-source is a library designed to help with loading of TLS certificates and to streamline the process of
9+
certificate rotation.

config/config.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package config
2+
3+
import (
4+
"time"
5+
)
6+
7+
type TLSServerConfig struct {
8+
Enable bool `help:"Enable server-side TLS."`
9+
Refresh time.Duration `default:"0s" help:"Interval for refreshing server TLS certificates."`
10+
File TLSServerFiles `embed:"" prefix:"file."`
11+
}
12+
13+
type TLSServerFiles struct {
14+
Key string `placeholder:"FILE" help:"Path to the server TLS key file."`
15+
Cert string `placeholder:"FILE" help:"Path to the server TLS certificate file."`
16+
ClientCAs string `placeholder:"FILE" name:"client-ca" help:"Optional path to server client CA file for client verification."`
17+
ClientCLR string `placeholder:"FILE" name:"client-clr" help:"TLS X509 CLR signed be the client CA. If no revocation list is specified, only client CA is verified."`
18+
}
19+
20+
type TLSClientConfig struct {
21+
Enable bool `help:"Enable client-side TLS."`
22+
Refresh time.Duration `default:"0s" help:"Interval for refreshing client TLS certificates."`
23+
InsecureSkipVerify bool `help:"Skip TLS verification on client side."`
24+
File TLSClientFiles `embed:"" prefix:"file."`
25+
}
26+
27+
type TLSClientFiles struct {
28+
Key string `placeholder:"FILE" help:"Optional path to client TLS key file."`
29+
Cert string `placeholder:"FILE" help:"Optional path to client TLS certificate file."`
30+
RootCAs string `placeholder:"FILE" name:"root-ca" help:"Optional path to client root CAs for server verification."`
31+
}

go.mod

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
module github.com/grepplabs/cert-source
22

33
go 1.21
4+
5+
require github.com/stretchr/testify v1.8.4
6+
7+
require (
8+
github.com/davecgh/go-spew v1.1.1 // indirect
9+
github.com/pmezard/go-difflib v1.0.0 // indirect
10+
gopkg.in/yaml.v3 v3.0.1 // indirect
11+
)

go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
6+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
7+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
8+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
9+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
10+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)