Updated required params

This commit is contained in:
Carlos Salguero
2022-04-05 12:42:06 -03:00
parent e5cb95130d
commit 9837bbdd2e
2 changed files with 7 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"fmt"
"strings"
"text/template"
"time"
@@ -31,7 +32,7 @@ type cmdlineArgs struct {
AllCollections bool `name:"all-collections" xor:"colls" help:"Check in all collections in the selected databases."`
Collections []string `name:"collections" xor:"colls" help:"Comma separated list of collections to check"`
URI string `name:"mongodb.uri" help:"Connection URI"`
URI string `name:"mongodb.uri" required:"" placeholder:"mongodb://host:port/admindb?options" help:"Connection URI"`
JSON bool `name:"json" help:"Show output as JSON"`
}
@@ -66,6 +67,10 @@ func main() {
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()
if !strings.HasPrefix(args.URI, "mongodb") && !strings.HasPrefix(args.URI, "mongodb+srv") {
args.URI = "mongodb://" + args.URI
}
client, err := mongo.Connect(ctx, options.Client().ApplyURI(args.URI))
if err != nil {
log.Fatalf("Cannot connect to the database: %q", err)

View File

@@ -4,7 +4,7 @@ package templates
// When $i == 0 (first element) {{ if $i }} returns false (0)
var Unused = `
Unused indexes
Unused indexes since last restart
{{ range . }}
{{ .Spec.Namespace }}, index '{{ .Name }}' with fields { {{- range $i, $val := .Key }}{{if $i}}, {{end}}{{ $val.Key }}:{{ $val.Value }} }{{ end }}{{ end}}
`