mirror of
https://github.com/postmannen/ctrl.git
synced 2024-12-14 12:37:31 +00:00
added reading of user nkey into configuration
This commit is contained in:
parent
36874c6b98
commit
47a0c47e15
1 changed files with 23 additions and 0 deletions
|
@ -3,6 +3,7 @@ package steward
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -59,6 +60,8 @@ type Configuration struct {
|
|||
RootCAPath string
|
||||
// Full path to the NKEY's seed file
|
||||
NkeySeedFile string
|
||||
// NkeyPublicKey
|
||||
NkeyPublicKey string
|
||||
// The host and port to expose the data folder
|
||||
ExposeDataFolder string
|
||||
// Timeout for error messages
|
||||
|
@ -604,6 +607,26 @@ func (c *Configuration) CheckFlags() error {
|
|||
|
||||
}
|
||||
|
||||
// Get the nkey user file content.
|
||||
if c.NkeySeedFile != "" {
|
||||
userFileDir := filepath.Dir(c.NkeySeedFile)
|
||||
userFile := filepath.Join(userFileDir, "user.txt")
|
||||
|
||||
uFh, err := os.Open(userFile)
|
||||
if err != nil {
|
||||
log.Printf("error: unable to open %v file: %v\n", userFile, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
userFileContent, err := io.ReadAll(uFh)
|
||||
if err != nil {
|
||||
log.Printf("error: unable to read %v file: %v\n", userFile, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
c.NkeyPublicKey = string(userFileContent)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue