Skip to content

Commit

Permalink
tidy up, refactor to local vars
Browse files Browse the repository at this point in the history
  • Loading branch information
pgalbavy committed Feb 28, 2022
1 parent 432b49e commit ef07d74
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
6 changes: 1 addition & 5 deletions cmd/geneos/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
* Help highlight typos rather than skip them
* Command line verbosity control - PARTIAL
* TLS support
* create basic cert/key sets
* create real certs/keys based on CA files
* output cacert file on stdout for sharing
* manage permissions / system folders
* sensible/valid naming for csr fields
* Docker / Compose file build from selection of components
* check capabilities and not just setuid/root user
* Run REST commands against gateways
Expand All @@ -24,6 +20,6 @@
* command line options different
* standalone collection agent
* centralised config
* web dashboard - mostly done, better port numbers and ssl to do
* web dashboard - mostly done, better port numbers and tls to do
* FIX2 netprobe
* modularise component types, make future addins easier - PARTIAL
22 changes: 14 additions & 8 deletions cmd/geneos/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,37 @@ func init() {
ParseFlags: flagsTLS,
ParseArgs: TLSArgs,
CommandLine: "geneos tls [init|import|new|renew|ls] ...",
Summary: `TLS operations subcommand`,
Description: `TLS operations subcommand. The following subcommands are supported:
Summary: `TLS operations`,
Description: `TLS operations. The following subcommands are supported:
geneos tls init
initialise the TLS environment, creating root and intermediate CAs and certificates for all instances
geneos tls import file [file...]
import certificate and private key used to sign instance certificates
geneos tls new [TYPE] [NAME]
create a new certificate for matching instances
geneos tls renew [TYPE] [NAME]
renew certificates for matching instances
geneos tls ls [TYPE] [NAME]
list certificates for matcing instances, including the root and intermediate CA certs.
same options as for the main 'ls' command
`}

TLSFlags = flag.NewFlagSet("tls", flag.ExitOnError)
// support the same flags as "ls" for lists
TLSFlags.BoolVar(&listJSON, "j", false, "Output JSON")
TLSFlags.BoolVar(&listJSONIndent, "i", false, "Indent / pretty print JSON")
TLSFlags.BoolVar(&listCSV, "c", false, "Output CSV")
TLSFlags.BoolVar(&tLSlistJSON, "j", false, "Output JSON")
TLSFlags.BoolVar(&tLSlistJSONIndent, "i", false, "Indent / pretty print JSON")
TLSFlags.BoolVar(&tLSlistCSV, "c", false, "Output CSV")
TLSFlags.BoolVar(&helpFlag, "h", false, helpUsage)
}

var TLSFlags *flag.FlagSet
var tLSlistJSON, tLSlistJSONIndent bool
var tLSlistCSV bool

const rootCAFile = "rootCA"
const intermediateFile = "geneos"
Expand Down Expand Up @@ -118,9 +124,9 @@ func listCertsCommand(ct ComponentType, args []string, params []string) (err err
}

switch {
case listJSON:
case tLSlistJSON:
jsonEncoder = json.NewEncoder(log.Writer())
if listJSONIndent {
if tLSlistJSONIndent {
jsonEncoder.SetIndent("", " ")
}
jsonEncoder.Encode(lsCertType{
Expand All @@ -144,7 +150,7 @@ func listCertsCommand(ct ComponentType, args []string, params []string) (err err
nil,
})
err = loopCommand(lsInstanceCertJSON, ct, args, params)
case listCSV:
case tLSlistCSV:
csvWriter = csv.NewWriter(log.Writer())
csvWriter.Write([]string{
"Type",
Expand Down

0 comments on commit ef07d74

Please sign in to comment.