mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
* first cut at pre-sort command that works on ndjson * finish pre_sort command for CSV and JSON and add test * try fixing golangci-lint * remove some dumb lint checks * more linter disabling * take .golangci.yml from previous repo * go fmt (facepalm) * remove ioutil to fix lint
34 lines
794 B
Go
34 lines
794 B
Go
// Copyright 2022 Molecula Corp. (DBA FeatureBase).
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
package ctl
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
|
|
"github.com/featurebasedb/featurebase/v3/logger"
|
|
"github.com/gorilla/securecookie"
|
|
)
|
|
|
|
// Keygen represents a command for generating a cryptographic key.
|
|
type KeygenCommand struct {
|
|
stdout io.Writer
|
|
logDest logger.Logger
|
|
KeyLength int
|
|
}
|
|
|
|
// NewKeygen returns a new instance of Keygen.
|
|
func NewKeygenCommand(logdest logger.Logger) *KeygenCommand {
|
|
return &KeygenCommand{
|
|
stdout: os.Stdout,
|
|
logDest: logdest,
|
|
}
|
|
}
|
|
|
|
// Run keygen to obtain key to use for authentication .
|
|
func (kg *KeygenCommand) Run(_ context.Context) error {
|
|
fmt.Fprintf(kg.stdout, "secret-key = \"%+x\"\n", securecookie.GenerateRandomKey(kg.KeyLength))
|
|
return nil
|
|
}
|