Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ jobs:
env:
# GitHub sets the GITHUB_TOKEN secret automatically.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GPG_TTY: $(tty)
37 changes: 33 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ archives:
- format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
checksum:
extra_files: []
extra_files:
- glob: 'integration-manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256
signs:
Expand All @@ -49,8 +51,35 @@ signs:
- "--detach-sign"
- "${artifact}"
release:
extra_files: []
extra_files:
- glob: 'integration-manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
# If you want to manually examine the release before its live, uncomment this line:
draft: true
# draft: true
changelog:
skip: true
sort: asc
use: github
filters:
exclude:
- '^test:'
- '^chore'
- 'merge conflict'
- Merge pull request
- Merge remote-tracking branch
- Merge branch
- go mod tidy
groups:
- title: Dependency updates
regexp: "^.*(feat|fix)\\(deps\\)*:+.*$"
order: 300
- title: 'New Features'
regexp: "^.*feat[(\\w)]*:+.*$"
order: 100
- title: 'Bug fixes'
regexp: "^.*fix[(\\w)]*:+.*$"
order: 200
- title: 'Documentation updates'
regexp: "^.*docs[(\\w)]*:+.*$"
order: 400
- title: Other work
order: 9999
9 changes: 5 additions & 4 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ NAMESPACE=keyfactor
WEBSITE_REPO=https://github.com/Keyfactor/kfutil
NAME=kfutil
BINARY=${NAME}
VERSION=0.0.2
VERSION=v0.0.4
OS_ARCH := $(shell go env GOOS)_$(shell go env GOARCH)
BASEDIR := ${HOME}/go/bin
INSTALLDIR := ${BASEDIR}
Expand Down Expand Up @@ -35,7 +35,8 @@ install:
rm -rf ${INSTALLDIR}/${BINARY}
mkdir -p ${INSTALLDIR}
chmod oug+x ${BINARY}
mv ${BINARY} ${INSTALLDIR}
cp ${BINARY} ${INSTALLDIR}
mv ${BINARY} /usr/local/bin/${BINARY}


test:
Expand All @@ -46,8 +47,8 @@ fmt:
gofmt -w $(GOFMT_FILES)

prerelease:
git tag -d $(VERSION)
git push origin :$(VERSION)
git tag -d $(VERSION) || true
git push origin :$(VERSION) || true
git tag $(VERSION)
git push origin $(VERSION)

Expand Down
80 changes: 80 additions & 0 deletions cmd/containers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// containersCmd represents the containers command
var containersCmd = &cobra.Command{
Use: "containers",
Short: "Keyfactor CertificateStoreContainer API and utilities.",
Long: `A collections of APIs and utilities for interacting with Keyfactor certificate store containers.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("containers called")
},
}

var containersCreateCmd = &cobra.Command{
Use: "create",
Short: "Create certificate store container.",
Long: `Create certificate store container.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("containers create called")
},
}

var containersGetCmd = &cobra.Command{
Use: "get",
Short: "Get certificate store container by ID or name.",
Long: `Get certificate store container by ID or name.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("containers get called")
},
}

var containersUpdateCmd = &cobra.Command{
Use: "update",
Short: "Update certificate store container by ID or name.",
Long: `Update certificate store container by ID or name.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("containers update called")
},
}

var containersDeleteCmd = &cobra.Command{
Use: "delete",
Short: "Delete certificate store container by ID or name.",
Long: `Delete certificate store container by ID or name.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("containers delete called")
},
}

var containersListCmd = &cobra.Command{
Use: "list",
Short: "List certificate store containers.",
Long: `List certificate store containers.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("containers list called")
},
}

func init() {
rootCmd.AddCommand(containersCmd)
// LIST containers command
containersCmd.AddCommand(containersListCmd)
// GET containers command
containersCmd.AddCommand(containersGetCmd)
// CREATE containers command
containersCmd.AddCommand(containersCreateCmd)
// UPDATE containers command
containersCmd.AddCommand(containersUpdateCmd)
// DELETE containers command
containersCmd.AddCommand(containersDeleteCmd)
// Utility functions
}
112 changes: 112 additions & 0 deletions cmd/orchs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>

*/
package cmd

import (
"encoding/json"
"fmt"
"io/ioutil"
"log"

"github.com/spf13/cobra"
)

// orchsCmd represents the orchs command
var orchsCmd = &cobra.Command{
Use: "orchs",
Short: "Keyfactor agents APIs and utilities.",
Long: `A collections of APIs and utilities for interacting with Keyfactor orchestrators.`,
}

var getOrchestratorCmd = &cobra.Command{
Use: "get",
Short: "Get orchestrator by ID or machine/host name.",
Long: `Get orchestrator by ID or machine/host name.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("orchestrator get called")
},
}

var approveOrchestratorCmd = &cobra.Command{
Use: "approve",
Short: "Approve orchestrator by ID or machine/host name.",
Long: `Approve orchestrator by ID or machine/host name.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("orchestrator approve called")
},
}

var disapproveOrchestratorCmd = &cobra.Command{
Use: "disapprove",
Short: "Disapprove orchestrator by ID or machine/host name.",
Long: `Disapprove orchestrator by ID or machine/host name.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("orchestrator disapprove called")
},
}

var resetOrchestratorCmd = &cobra.Command{
Use: "reset",
Short: "Reset orchestrator by ID or machine/host name.",
Long: `Reset orchestrator by ID or machine/host name.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("orchestrator reset called")
},
}

var getLogsOrchestratorCmd = &cobra.Command{
Use: "logs",
Short: "Get orchestrator logs by ID or machine/host name.",
Long: `Get orchestrator logs by ID or machine/host name.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("orchestrator logs called")
},
}

var listOrchestratorsCmd = &cobra.Command{
Use: "list",
Short: "List orchestrators.",
Long: `Returns a JSON list of Keyfactor orchestrators.`,
Run: func(cmd *cobra.Command, args []string) {
log.SetOutput(ioutil.Discard)
kfClient, _ := initClient()
agents, err := kfClient.GetAgentList()
if err != nil {
log.Printf("Error: %s", err)
}
output, jErr := json.Marshal(agents)
if jErr != nil {
log.Printf("Error: %s", jErr)
}
fmt.Printf("%s", output)
},
}

func init() {
rootCmd.AddCommand(orchsCmd)

// LIST orchestrators command
orchsCmd.AddCommand(listOrchestratorsCmd)
// GET orchestrator command
orchsCmd.AddCommand(getOrchestratorCmd)
// CREATE orchestrator command TODO: API NOT SUPPORTED
//orchsCmd.AddCommand(createOrchestratorCmd)
// UPDATE orchestrator command TODO: API NOT SUPPORTED
//orchsCmd.AddCommand(updateOrchestratorCmd)
// DELETE orchestrator command TODO: API NOT SUPPORTED
//orchsCmd.AddCommand(deleteOrchestratorCmd)
// APPROVE orchestrator command
orchsCmd.AddCommand(approveOrchestratorCmd)
// DISAPPROVE orchestrator command
orchsCmd.AddCommand(disapproveOrchestratorCmd)
// RESET orchestrator command
orchsCmd.AddCommand(resetOrchestratorCmd)
// GET orchestrator logs command
orchsCmd.AddCommand(getLogsOrchestratorCmd)
// SET orchestrator auth certificate reenrollment command TODO: Not implemented
//orchsCmd.AddCommand(setOrchestratorAuthCertReenrollCmd)
// Utility commands
//orchsCmd.AddCommand(downloadOrchestrator) TODO: Not implemented
}
30 changes: 23 additions & 7 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,35 @@ package cmd
import (
"os"

"github.com/Keyfactor/keyfactor-go-client/api"
"github.com/spf13/cobra"
"log"
)

func initClient() (*api.Client, error) {
var clientAuth api.AuthConfig
clientAuth.Username = os.Getenv("KEYFACTOR_USERNAME")
log.Printf("[DEBUG] Username: %s", clientAuth.Username)
clientAuth.Password = os.Getenv("KEYFACTOR_PASSWORD")
log.Printf("[DEBUG] Password: %s", clientAuth.Password)
clientAuth.Domain = os.Getenv("KEYFACTOR_DOMAIN")
log.Printf("[DEBUG] Domain: %s", clientAuth.Domain)
clientAuth.Hostname = os.Getenv("KEYFACTOR_HOSTNAME")
log.Printf("[DEBUG] Hostname: %s", clientAuth.Hostname)

c, err := api.NewKeyfactorClient(&clientAuth)

if err != nil {
log.Fatalf("Error creating Keyfactor client: %s", err)
}
return c, err
}

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "kfutil",
Short: "A brief description of your application",
Long: `A longer description that spans multiple lines and likely contains
examples and usage of using your application. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Short: "Keyfactor CLI utilities",
Long: `A CLI wrapper around the Keyfactor Platform API.`,
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
Expand Down
Loading