mirror of
https://github.com/void-linux/void-packages.git
synced 2025-06-05 06:33:50 +02:00
NetAuth: add completions and manpages, build nsutil
This commit is contained in:
parent
b9248135cc
commit
be2f23848b
3 changed files with 134 additions and 0 deletions
36
srcpkgs/NetAuth/patches/cli-generate.patch
Normal file
36
srcpkgs/NetAuth/patches/cli-generate.patch
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
From cb7cfa5bc0530e43fdbc227783187a141d857139 Mon Sep 17 00:00:00 2001
|
||||||
|
From: classabbyamp <dev@placeviolette.net>
|
||||||
|
Date: Sat, 24 Sep 2022 17:40:11 -0400
|
||||||
|
Subject: [PATCH] internal/ctl/system-ctl: don't run initialize(), rename to
|
||||||
|
system-cli
|
||||||
|
|
||||||
|
the default initialize() is not necessary when generating completions
|
||||||
|
and docs, so we can override it with an empty function.
|
||||||
|
|
||||||
|
Also, the file was renamed to `system-cli` to put it more inline with
|
||||||
|
other files' naming conventions.
|
||||||
|
---
|
||||||
|
internal/ctl/{system-ctl.go => system-cli.go} | 3 +++
|
||||||
|
1 file changed, 3 insertions(+)
|
||||||
|
rename internal/ctl/{system-ctl.go => system-cli.go} (68%)
|
||||||
|
|
||||||
|
diff --git a/internal/ctl/system-ctl.go b/internal/ctl/system-cli.go
|
||||||
|
similarity index 68%
|
||||||
|
rename from internal/ctl/system-ctl.go
|
||||||
|
rename to internal/ctl/system-cli.go
|
||||||
|
index 3dbd9d3..0a42d05 100644
|
||||||
|
--- a/internal/ctl/system-ctl.go
|
||||||
|
+++ b/internal/ctl/system-cli.go
|
||||||
|
@@ -8,9 +8,12 @@ var (
|
||||||
|
cliCmd = &cobra.Command{
|
||||||
|
Use: "cli",
|
||||||
|
Short: "Extra utilities for the CLI",
|
||||||
|
+ PersistentPreRun: cli_initialize,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
systemCmd.AddCommand(cliCmd)
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+func cli_initialize(*cobra.Command, []string) {}
|
87
srcpkgs/NetAuth/patches/config-loading.patch
Normal file
87
srcpkgs/NetAuth/patches/config-loading.patch
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
From 1df568cd25d6ccac79e56451406e021ead49c0c4 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Michael Aldridge <aldridge.mac@gmail.com>
|
||||||
|
Date: Wed, 31 Aug 2022 16:44:40 -0500
|
||||||
|
Subject: [PATCH] pkg/netauth: Handle config loading in library layer
|
||||||
|
|
||||||
|
---
|
||||||
|
cmd/netauth/main.go | 7 -------
|
||||||
|
internal/ctl/root.go | 9 ---------
|
||||||
|
pkg/netauth/netauth.go | 13 +++++++++++++
|
||||||
|
3 files changed, 13 insertions(+), 16 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/cmd/netauth/main.go b/cmd/netauth/main.go
|
||||||
|
index d66dd8a..7695cd5 100644
|
||||||
|
--- a/cmd/netauth/main.go
|
||||||
|
+++ b/cmd/netauth/main.go
|
||||||
|
@@ -4,7 +4,6 @@ import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/hashicorp/go-hclog"
|
||||||
|
- "github.com/spf13/viper"
|
||||||
|
|
||||||
|
"github.com/netauth/netauth/internal/ctl"
|
||||||
|
|
||||||
|
@@ -22,12 +21,6 @@ var (
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
- // This runs here so we can reset the defaults that are set
|
||||||
|
- // during various init() methods.
|
||||||
|
- viper.SetDefault("token.cache", "fs")
|
||||||
|
- viper.SetDefault("token.keyprovider", "fs")
|
||||||
|
- viper.SetDefault("token.backend", "jwt-rsa")
|
||||||
|
-
|
||||||
|
level, set := os.LookupEnv("NETAUTH_LOGLEVEL")
|
||||||
|
if !set {
|
||||||
|
appLogger = hclog.NewNullLogger()
|
||||||
|
diff --git a/internal/ctl/root.go b/internal/ctl/root.go
|
||||||
|
index faf35b0..b20c0d2 100644
|
||||||
|
--- a/internal/ctl/root.go
|
||||||
|
+++ b/internal/ctl/root.go
|
||||||
|
@@ -61,15 +61,6 @@ func onInit() {
|
||||||
|
viper.BindPFlags(pflag.CommandLine)
|
||||||
|
if cfg != "" {
|
||||||
|
viper.SetConfigFile(cfg)
|
||||||
|
- } else {
|
||||||
|
- viper.SetConfigName("config")
|
||||||
|
- viper.AddConfigPath(".")
|
||||||
|
- viper.AddConfigPath("$HOME/.netauth")
|
||||||
|
- viper.AddConfigPath("/etc/netauth/")
|
||||||
|
- }
|
||||||
|
- if err := viper.ReadInConfig(); err != nil {
|
||||||
|
- fmt.Println("Error reading config:", err)
|
||||||
|
- os.Exit(1)
|
||||||
|
}
|
||||||
|
viper.Set("client.ServiceName", "netauth")
|
||||||
|
|
||||||
|
diff --git a/pkg/netauth/netauth.go b/pkg/netauth/netauth.go
|
||||||
|
index 831d64f..77a203c 100644
|
||||||
|
--- a/pkg/netauth/netauth.go
|
||||||
|
+++ b/pkg/netauth/netauth.go
|
||||||
|
@@ -17,6 +17,14 @@ import (
|
||||||
|
func init() {
|
||||||
|
viper.SetDefault("core.port", 1729)
|
||||||
|
viper.SetDefault("tls.certificate", "keys/tls.pem")
|
||||||
|
+ viper.SetDefault("token.cache", "fs")
|
||||||
|
+ viper.SetDefault("token.keyprovider", "fs")
|
||||||
|
+ viper.SetDefault("token.backend", "jwt-rsa")
|
||||||
|
+
|
||||||
|
+ viper.SetConfigName("config")
|
||||||
|
+ viper.AddConfigPath(".")
|
||||||
|
+ viper.AddConfigPath("$HOME/.netauth")
|
||||||
|
+ viper.AddConfigPath("/etc/netauth/")
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewWithLog uses the specified logger to contruct a NetAuth client.
|
||||||
|
@@ -24,6 +32,11 @@ func init() {
|
||||||
|
// handler that is provided should have the correct name and be
|
||||||
|
// parented to the correct point on the log tree.
|
||||||
|
func NewWithLog(l hclog.Logger) (*Client, error) {
|
||||||
|
+ if err := viper.ReadInConfig(); err != nil {
|
||||||
|
+ fmt.Println("Error reading config:", err)
|
||||||
|
+ os.Exit(1)
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if viper.GetString("core.conf") == "" {
|
||||||
|
viper.Set("core.conf", filepath.Dir(viper.ConfigFileUsed()))
|
||||||
|
l.Debug("Config relative load path set", "path", viper.GetString("core.conf"))
|
|
@ -4,8 +4,10 @@ version=0.6.1
|
||||||
revision=1
|
revision=1
|
||||||
wrksrc=netauth-$version
|
wrksrc=netauth-$version
|
||||||
build_style="go"
|
build_style="go"
|
||||||
|
build_helper="qemu"
|
||||||
go_import_path="github.com/netauth/netauth"
|
go_import_path="github.com/netauth/netauth"
|
||||||
go_package="${go_import_path}/cmd/netauth
|
go_package="${go_import_path}/cmd/netauth
|
||||||
|
${go_import_path}/cmd/nsutil
|
||||||
${go_import_path}/cmd/netauthd"
|
${go_import_path}/cmd/netauthd"
|
||||||
short_desc="Network authentication and identity system"
|
short_desc="Network authentication and identity system"
|
||||||
maintainer="Michael Aldridge <maldridge@netauth.org>"
|
maintainer="Michael Aldridge <maldridge@netauth.org>"
|
||||||
|
@ -15,6 +17,15 @@ distfiles="https://github.com/NetAuth/NetAuth/archive/v$version.tar.gz"
|
||||||
checksum=cf84b2e63b7a59ec6e415ead1a94994b040b30fee2b27e482073371cfb0fb444
|
checksum=cf84b2e63b7a59ec6e415ead1a94994b040b30fee2b27e482073371cfb0fb444
|
||||||
|
|
||||||
post_install() {
|
post_install() {
|
||||||
|
for sh in bash zsh; do
|
||||||
|
vtargetrun ${DESTDIR}/usr/bin/netauth system cli ${sh} netauth.${sh}
|
||||||
|
vcompletion netauth.${sh} ${sh} netauth
|
||||||
|
done
|
||||||
|
mkdir manpages
|
||||||
|
vtargetrun ${DESTDIR}/usr/bin/netauth system cli man manpages
|
||||||
|
for p in manpages/*; do
|
||||||
|
vman "${p}"
|
||||||
|
done
|
||||||
vlicense LICENSE
|
vlicense LICENSE
|
||||||
vsv netauthd
|
vsv netauthd
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue