Skip to content

Commit 1a0460a

Browse files
authored
Merge pull request #1 from Keyfactor/root_of_trust
feat(util): Base implementation of `root of trust`
2 parents b1a4f1f + 3ce630e commit 1a0460a

File tree

16 files changed

+2782
-210
lines changed

16 files changed

+2782
-210
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ jobs:
3838
env:
3939
# GitHub sets the GITHUB_TOKEN secret automatically.
4040
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41-
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
41+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
42+
GPG_TTY: $(tty)

.goreleaser.yml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ archives:
3333
- format: zip
3434
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
3535
checksum:
36-
extra_files: []
36+
extra_files:
37+
- glob: 'integration-manifest.json'
38+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
3739
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
3840
algorithm: sha256
3941
signs:
@@ -49,8 +51,35 @@ signs:
4951
- "--detach-sign"
5052
- "${artifact}"
5153
release:
52-
extra_files: []
54+
extra_files:
55+
- glob: 'integration-manifest.json'
56+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
5357
# If you want to manually examine the release before its live, uncomment this line:
54-
draft: true
58+
# draft: true
5559
changelog:
56-
skip: true
60+
sort: asc
61+
use: github
62+
filters:
63+
exclude:
64+
- '^test:'
65+
- '^chore'
66+
- 'merge conflict'
67+
- Merge pull request
68+
- Merge remote-tracking branch
69+
- Merge branch
70+
- go mod tidy
71+
groups:
72+
- title: Dependency updates
73+
regexp: "^.*(feat|fix)\\(deps\\)*:+.*$"
74+
order: 300
75+
- title: 'New Features'
76+
regexp: "^.*feat[(\\w)]*:+.*$"
77+
order: 100
78+
- title: 'Bug fixes'
79+
regexp: "^.*fix[(\\w)]*:+.*$"
80+
order: 200
81+
- title: 'Documentation updates'
82+
regexp: "^.*docs[(\\w)]*:+.*$"
83+
order: 400
84+
- title: Other work
85+
order: 9999

GNUmakefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ NAMESPACE=keyfactor
66
WEBSITE_REPO=https://github.com/Keyfactor/kfutil
77
NAME=kfutil
88
BINARY=${NAME}
9-
VERSION=0.0.2
9+
VERSION=v0.0.4
1010
OS_ARCH := $(shell go env GOOS)_$(shell go env GOARCH)
1111
BASEDIR := ${HOME}/go/bin
1212
INSTALLDIR := ${BASEDIR}
@@ -35,7 +35,8 @@ install:
3535
rm -rf ${INSTALLDIR}/${BINARY}
3636
mkdir -p ${INSTALLDIR}
3737
chmod oug+x ${BINARY}
38-
mv ${BINARY} ${INSTALLDIR}
38+
cp ${BINARY} ${INSTALLDIR}
39+
mv ${BINARY} /usr/local/bin/${BINARY}
3940

4041

4142
test:
@@ -46,8 +47,8 @@ fmt:
4647
gofmt -w $(GOFMT_FILES)
4748

4849
prerelease:
49-
git tag -d $(VERSION)
50-
git push origin :$(VERSION)
50+
git tag -d $(VERSION) || true
51+
git push origin :$(VERSION) || true
5152
git tag $(VERSION)
5253
git push origin $(VERSION)
5354

cmd/containers.go

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
3+
*/
4+
package cmd
5+
6+
import (
7+
"fmt"
8+
9+
"github.com/spf13/cobra"
10+
)
11+
12+
// containersCmd represents the containers command
13+
var containersCmd = &cobra.Command{
14+
Use: "containers",
15+
Short: "Keyfactor CertificateStoreContainer API and utilities.",
16+
Long: `A collections of APIs and utilities for interacting with Keyfactor certificate store containers.`,
17+
Run: func(cmd *cobra.Command, args []string) {
18+
fmt.Println("containers called")
19+
},
20+
}
21+
22+
var containersCreateCmd = &cobra.Command{
23+
Use: "create",
24+
Short: "Create certificate store container.",
25+
Long: `Create certificate store container.`,
26+
Run: func(cmd *cobra.Command, args []string) {
27+
fmt.Println("containers create called")
28+
},
29+
}
30+
31+
var containersGetCmd = &cobra.Command{
32+
Use: "get",
33+
Short: "Get certificate store container by ID or name.",
34+
Long: `Get certificate store container by ID or name.`,
35+
Run: func(cmd *cobra.Command, args []string) {
36+
fmt.Println("containers get called")
37+
},
38+
}
39+
40+
var containersUpdateCmd = &cobra.Command{
41+
Use: "update",
42+
Short: "Update certificate store container by ID or name.",
43+
Long: `Update certificate store container by ID or name.`,
44+
Run: func(cmd *cobra.Command, args []string) {
45+
fmt.Println("containers update called")
46+
},
47+
}
48+
49+
var containersDeleteCmd = &cobra.Command{
50+
Use: "delete",
51+
Short: "Delete certificate store container by ID or name.",
52+
Long: `Delete certificate store container by ID or name.`,
53+
Run: func(cmd *cobra.Command, args []string) {
54+
fmt.Println("containers delete called")
55+
},
56+
}
57+
58+
var containersListCmd = &cobra.Command{
59+
Use: "list",
60+
Short: "List certificate store containers.",
61+
Long: `List certificate store containers.`,
62+
Run: func(cmd *cobra.Command, args []string) {
63+
fmt.Println("containers list called")
64+
},
65+
}
66+
67+
func init() {
68+
rootCmd.AddCommand(containersCmd)
69+
// LIST containers command
70+
containersCmd.AddCommand(containersListCmd)
71+
// GET containers command
72+
containersCmd.AddCommand(containersGetCmd)
73+
// CREATE containers command
74+
containersCmd.AddCommand(containersCreateCmd)
75+
// UPDATE containers command
76+
containersCmd.AddCommand(containersUpdateCmd)
77+
// DELETE containers command
78+
containersCmd.AddCommand(containersDeleteCmd)
79+
// Utility functions
80+
}

cmd/orchs.go

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
3+
4+
*/
5+
package cmd
6+
7+
import (
8+
"encoding/json"
9+
"fmt"
10+
"io/ioutil"
11+
"log"
12+
13+
"github.com/spf13/cobra"
14+
)
15+
16+
// orchsCmd represents the orchs command
17+
var orchsCmd = &cobra.Command{
18+
Use: "orchs",
19+
Short: "Keyfactor agents APIs and utilities.",
20+
Long: `A collections of APIs and utilities for interacting with Keyfactor orchestrators.`,
21+
}
22+
23+
var getOrchestratorCmd = &cobra.Command{
24+
Use: "get",
25+
Short: "Get orchestrator by ID or machine/host name.",
26+
Long: `Get orchestrator by ID or machine/host name.`,
27+
Run: func(cmd *cobra.Command, args []string) {
28+
fmt.Println("orchestrator get called")
29+
},
30+
}
31+
32+
var approveOrchestratorCmd = &cobra.Command{
33+
Use: "approve",
34+
Short: "Approve orchestrator by ID or machine/host name.",
35+
Long: `Approve orchestrator by ID or machine/host name.`,
36+
Run: func(cmd *cobra.Command, args []string) {
37+
fmt.Println("orchestrator approve called")
38+
},
39+
}
40+
41+
var disapproveOrchestratorCmd = &cobra.Command{
42+
Use: "disapprove",
43+
Short: "Disapprove orchestrator by ID or machine/host name.",
44+
Long: `Disapprove orchestrator by ID or machine/host name.`,
45+
Run: func(cmd *cobra.Command, args []string) {
46+
fmt.Println("orchestrator disapprove called")
47+
},
48+
}
49+
50+
var resetOrchestratorCmd = &cobra.Command{
51+
Use: "reset",
52+
Short: "Reset orchestrator by ID or machine/host name.",
53+
Long: `Reset orchestrator by ID or machine/host name.`,
54+
Run: func(cmd *cobra.Command, args []string) {
55+
fmt.Println("orchestrator reset called")
56+
},
57+
}
58+
59+
var getLogsOrchestratorCmd = &cobra.Command{
60+
Use: "logs",
61+
Short: "Get orchestrator logs by ID or machine/host name.",
62+
Long: `Get orchestrator logs by ID or machine/host name.`,
63+
Run: func(cmd *cobra.Command, args []string) {
64+
fmt.Println("orchestrator logs called")
65+
},
66+
}
67+
68+
var listOrchestratorsCmd = &cobra.Command{
69+
Use: "list",
70+
Short: "List orchestrators.",
71+
Long: `Returns a JSON list of Keyfactor orchestrators.`,
72+
Run: func(cmd *cobra.Command, args []string) {
73+
log.SetOutput(ioutil.Discard)
74+
kfClient, _ := initClient()
75+
agents, err := kfClient.GetAgentList()
76+
if err != nil {
77+
log.Printf("Error: %s", err)
78+
}
79+
output, jErr := json.Marshal(agents)
80+
if jErr != nil {
81+
log.Printf("Error: %s", jErr)
82+
}
83+
fmt.Printf("%s", output)
84+
},
85+
}
86+
87+
func init() {
88+
rootCmd.AddCommand(orchsCmd)
89+
90+
// LIST orchestrators command
91+
orchsCmd.AddCommand(listOrchestratorsCmd)
92+
// GET orchestrator command
93+
orchsCmd.AddCommand(getOrchestratorCmd)
94+
// CREATE orchestrator command TODO: API NOT SUPPORTED
95+
//orchsCmd.AddCommand(createOrchestratorCmd)
96+
// UPDATE orchestrator command TODO: API NOT SUPPORTED
97+
//orchsCmd.AddCommand(updateOrchestratorCmd)
98+
// DELETE orchestrator command TODO: API NOT SUPPORTED
99+
//orchsCmd.AddCommand(deleteOrchestratorCmd)
100+
// APPROVE orchestrator command
101+
orchsCmd.AddCommand(approveOrchestratorCmd)
102+
// DISAPPROVE orchestrator command
103+
orchsCmd.AddCommand(disapproveOrchestratorCmd)
104+
// RESET orchestrator command
105+
orchsCmd.AddCommand(resetOrchestratorCmd)
106+
// GET orchestrator logs command
107+
orchsCmd.AddCommand(getLogsOrchestratorCmd)
108+
// SET orchestrator auth certificate reenrollment command TODO: Not implemented
109+
//orchsCmd.AddCommand(setOrchestratorAuthCertReenrollCmd)
110+
// Utility commands
111+
//orchsCmd.AddCommand(downloadOrchestrator) TODO: Not implemented
112+
}

cmd/root.go

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,35 @@ package cmd
77
import (
88
"os"
99

10+
"github.com/Keyfactor/keyfactor-go-client/api"
1011
"github.com/spf13/cobra"
12+
"log"
1113
)
1214

15+
func initClient() (*api.Client, error) {
16+
var clientAuth api.AuthConfig
17+
clientAuth.Username = os.Getenv("KEYFACTOR_USERNAME")
18+
log.Printf("[DEBUG] Username: %s", clientAuth.Username)
19+
clientAuth.Password = os.Getenv("KEYFACTOR_PASSWORD")
20+
log.Printf("[DEBUG] Password: %s", clientAuth.Password)
21+
clientAuth.Domain = os.Getenv("KEYFACTOR_DOMAIN")
22+
log.Printf("[DEBUG] Domain: %s", clientAuth.Domain)
23+
clientAuth.Hostname = os.Getenv("KEYFACTOR_HOSTNAME")
24+
log.Printf("[DEBUG] Hostname: %s", clientAuth.Hostname)
25+
26+
c, err := api.NewKeyfactorClient(&clientAuth)
27+
28+
if err != nil {
29+
log.Fatalf("Error creating Keyfactor client: %s", err)
30+
}
31+
return c, err
32+
}
33+
1334
// rootCmd represents the base command when called without any subcommands
1435
var rootCmd = &cobra.Command{
1536
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.`,
37+
Short: "Keyfactor CLI utilities",
38+
Long: `A CLI wrapper around the Keyfactor Platform API.`,
2339
// Uncomment the following line if your bare application
2440
// has an action associated with it:
2541
// Run: func(cmd *cobra.Command, args []string) { },

0 commit comments

Comments
 (0)