Skip to content

Commit 55cec3a

Browse files
committed
feat: Initial commit
0 parents  commit 55cec3a

File tree

14 files changed

+575
-0
lines changed

14 files changed

+575
-0
lines changed

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# See GitHub's documentation for more information on this file:
2+
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates
3+
version: 2
4+
updates:
5+
- package-ecosystem: "github-actions"
6+
directory: "/"
7+
schedule:
8+
interval: "daily"
9+
- package-ecosystem: "gomod"
10+
directory: "/"
11+
schedule:
12+
interval: "daily"

.github/images/kf_logo.png

3.52 KB
Loading
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Starter Workflow
2+
on: workflow_dispatch
3+
4+
jobs:
5+
catalog-update-check:
6+
runs-on: windows-latest
7+
outputs:
8+
upd_cat: ${{ steps.read-json.outputs.prop }}
9+
steps:
10+
- uses: actions/checkout@v3
11+
- name: Read json
12+
id: read-json
13+
shell: pwsh
14+
run: |
15+
$json = Get-Content integration-manifest.json | ConvertFrom-Json
16+
echo "::set-output name=prop::$(echo $json.update_catalog)"
17+
18+
#call-create-github-release-workflow:
19+
# uses: Keyfactor/actions/.github/workflows/github-release.yml@main
20+
21+
#call-dotnet-build-and-release-workflow:
22+
# needs: [call-create-github-release-workflow]
23+
# uses: Keyfactor/actions/.github/workflows/dotnet-build-and-release.yml@main
24+
# with:
25+
# release_version: ${{ needs.call-create-github-release-workflow.outputs.release_version }}
26+
# release_url: ${{ needs.call-create-github-release-workflow.outputs.release_url }}
27+
# release_dir: SslStoreCaProxy/bin/Release
28+
# secrets:
29+
# token: ${{ secrets.PRIVATE_PACKAGE_ACCESS }}
30+
31+
call-generate-readme-workflow:
32+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
33+
uses: Keyfactor/actions/.github/workflows/generate-readme.yml@main
34+
35+
call-update-catalog-workflow:
36+
needs: catalog-update-check
37+
if: needs.catalog-update-check.outputs.upd_cat == 'True' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
38+
uses: Keyfactor/actions/.github/workflows/update-catalog.yml@main
39+
secrets:
40+
token: ${{ secrets.SDK_SYNC_PAT }}
41+

.github/workflows/release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Terraform Provider release workflow.
2+
name: Release
3+
4+
# This GitHub action creates a release when a tag that matches the pattern
5+
# "v*" (e.g. v0.1.0) is created.
6+
on:
7+
push:
8+
tags:
9+
- 'v*'
10+
11+
# Releases need permissions to read and write the repository contents.
12+
# GitHub considers creating releases and uploading assets as writing contents.
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
goreleaser:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
with:
22+
# Allow goreleaser to access older tag information.
23+
fetch-depth: 0
24+
- uses: actions/setup-go@v3
25+
with:
26+
go-version-file: 'go.mod'
27+
cache: true
28+
- name: Import GPG key
29+
uses: crazy-max/ghaction-import-gpg@v5
30+
id: import_gpg
31+
with:
32+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
33+
passphrase: ${{ secrets.PASSPHRASE }}
34+
- name: Run GoReleaser
35+
uses: goreleaser/goreleaser-action@v3
36+
with:
37+
args: release --rm-dist
38+
env:
39+
# GitHub sets the GITHUB_TOKEN secret automatically.
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
### Go template
2+
# Binaries for programs and plugins
3+
.idea
4+
*.exe
5+
*.exe~
6+
*.dll
7+
*.so
8+
*.dylib
9+
10+
# Test binary, built with `go test -c`
11+
*.test
12+
13+
# Output of the go coverage tool, specifically when used with LiteIDE
14+
*.out
15+
16+
# Dependency directories (remove the comment below to include it)
17+
vendor/
18+
19+
.env
20+
21+
*.csv

GNUmakefile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
PROVIDER_DIR := $(PWD)
2+
TEST?=$$(go list ./... | grep -v 'vendor')
3+
HOSTNAME=keyfactor.com
4+
GOFMT_FILES := $$(find $(PROVIDER_DIR) -name '*.go' |grep -v vendor)
5+
NAMESPACE=keyfactor
6+
WEBSITE_REPO=https://github.com/Keyfactor/kfutil
7+
NAME=kfutil
8+
BINARY=${NAME}
9+
VERSION=0.0.1
10+
OS_ARCH := $(shell go env GOOS)_$(shell go env GOARCH)
11+
BASEDIR := ${HOME}/go/bin
12+
INSTALLDIR := ${BASEDIR}
13+
14+
default: build
15+
16+
build: fmt
17+
go install
18+
19+
release:
20+
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64
21+
GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386
22+
GOOS=freebsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_freebsd_amd64
23+
GOOS=freebsd GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_freebsd_arm
24+
GOOS=linux GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_linux_386
25+
GOOS=linux GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_linux_amd64
26+
GOOS=linux GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_linux_arm
27+
GOOS=openbsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_openbsd_386
28+
GOOS=openbsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_openbsd_amd64
29+
GOOS=solaris GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_solaris_amd64
30+
GOOS=windows GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_windows_386
31+
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64
32+
33+
install:
34+
go build -o ${BINARY}
35+
rm -rf ${INSTALLDIR}/${BINARY}
36+
mkdir -p ${INSTALLDIR}
37+
chmod oug+x ${BINARY}
38+
mv ${BINARY} ${INSTALLDIR}
39+
40+
41+
test:
42+
go test -i $(TEST) || exit 1
43+
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
44+
45+
fmt:
46+
gofmt -w $(GOFMT_FILES)
47+
48+
.PHONY: build release install test fmt

LICENSE

Whitespace-only changes.

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Keyfactor Util
2+
General go-lang CLI utility for the Keyfactor API.
3+
4+
## Quickstart
5+
```bash
6+
make install
7+
kfutil --help
8+
````
9+
10+
## Commands
11+
12+
### Bulk operations
13+
14+
#### Bulk create cert stores
15+
`# TODO: Not implemented`
16+
This will attempt to process a CSV input file of certificate stores to create. The template can be generated by running: `kfutil generate-template --type bulk-certstore` command.
17+
```bash
18+
kfutil bulk create certstores --file <path to csv file>
19+
```
20+
21+
#### Bulk create cert store types
22+
`# TODO: Not implemented`
23+
This will attempt to process a CSV input file of certificate store types to create. The template can be generated by running: `kfutil generate-template --type bulk-certstore-types` command.
24+
```bash
25+
kfutil bulk create certstores --file <path to csv file>
26+
```
27+
28+
### Root of Trust
29+
30+
#### Generate Certificate List Template
31+
This will write the file `certs_template.csv` to the current directory.
32+
```bash
33+
kfutil stores generate-template-rot --type certs
34+
```
35+
36+
#### Generate Certificate Store List Template
37+
This will write the file `certs_template.csv` to the current directory.
38+
```bash
39+
kfutil stores generate-template-rot --type stores
40+
```
41+
42+
#### Run Root of Trust Check
43+
This will read the file `certs.csv` from the current directory or the absolute path, and generate a report of the certificate stores that contain the specified certificates.
44+
```bash
45+
kfutil stores rot --stores stores.csv --certs certs.csv
46+
```
47+
48+
### Development
49+
This CLI developed using [cobra](https://umarcor.github.io/cobra/)
50+
#### Adding a new command
51+
```bash
52+
cobra-cli add <my-new-command>
53+
```
54+
alternatively you can specify the parent command
55+
```bash
56+
cobra-cli add <my-new-command> -p '<parent>Cmd'
57+
```

cmd/root.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
3+
4+
*/
5+
package cmd
6+
7+
import (
8+
"os"
9+
10+
"github.com/spf13/cobra"
11+
)
12+
13+
// rootCmd represents the base command when called without any subcommands
14+
var rootCmd = &cobra.Command{
15+
Use: "kfutil",
16+
Short: "A brief description of your application",
17+
Long: `A longer description that spans multiple lines and likely contains
18+
examples and usage of using your application. For example:
19+
20+
Cobra is a CLI library for Go that empowers applications.
21+
This application is a tool to generate the needed files
22+
to quickly create a Cobra application.`,
23+
// Uncomment the following line if your bare application
24+
// has an action associated with it:
25+
// Run: func(cmd *cobra.Command, args []string) { },
26+
}
27+
28+
// Execute adds all child commands to the root command and sets flags appropriately.
29+
// This is called by main.main(). It only needs to happen once to the rootCmd.
30+
func Execute() {
31+
err := rootCmd.Execute()
32+
if err != nil {
33+
os.Exit(1)
34+
}
35+
}
36+
37+
func init() {
38+
// Here you will define your flags and configuration settings.
39+
// Cobra supports persistent flags, which, if defined here,
40+
// will be global for your application.
41+
42+
// rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.kfutil.yaml)")
43+
44+
// Cobra also supports local flags, which will only run
45+
// when this action is called directly.
46+
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
47+
}
48+
49+
func boolToPointer(b bool) *bool {
50+
return &b
51+
}
52+
53+
func intToPointer(i int) *int {
54+
if i == 0 {
55+
return nil
56+
}
57+
return &i
58+
}
59+
60+
func stringToPointer(s string) *string {
61+
if s == "" {
62+
return nil
63+
}
64+
return &s
65+
}

0 commit comments

Comments
 (0)