add flag to specify alternative filepath to secret
For the hyp client to be able to support multiple servers, each with their own secret, this capability is requried.
This commit is contained in:
parent
ead7578544
commit
3ae568639e
@ -31,8 +31,14 @@ Example usage:
|
|||||||
`,
|
`,
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
// load secret and generate ports using secret and current time
|
// load secret and generate ports using secret and current time
|
||||||
secretBytes, err := os.ReadFile("hyp.secret")
|
secretFilePath, err := cmd.Flags().GetString("secret")
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("failed to parse command flag 'secret': %w", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
secretBytes, err := os.ReadFile(secretFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to read file 'hyp.secret': %v", err)
|
log.Fatalf("failed to read file 'hyp.secret': %v", err)
|
||||||
}
|
}
|
||||||
@ -56,4 +62,6 @@ Example usage:
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(knockCmd)
|
rootCmd.AddCommand(knockCmd)
|
||||||
|
|
||||||
|
knockCmd.PersistentFlags().String("secret", "hyp.secret", "Path to the file containing the hyp secret.")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user