Working with packages and allowed IPs.

giredorectl now able to interact with giredored about:

* Setting package data. There is no such thing as "create" or "update",
just set.

* Deleting package data.

* Setting allowed IP addresses. This is the only authorization method
ATM, more may come in future.
This commit is contained in:
2019-10-07 18:21:26 +05:00
parent 83a8694061
commit 6ce7747dd5
24 changed files with 725 additions and 47 deletions

View File

@@ -22,6 +22,58 @@ func main() {
clientv1.Initialize()
clientv1.GetConfiguration(options)
return 0
}),
).
WithCommand(
cli.NewCommand("set", "sets configuration value").
WithCommand(
cli.NewCommand("allowedips", "sets list of allowed IPs for interacting with configuration API").
WithArg(cli.NewArg("allowed_ips_list", "list of allowed IP addresses delimited by comma. Subnets are also fine.")).
WithAction(func(args []string, options map[string]string) int {
logger.Initialize()
clientv1.Initialize()
clientv1.SetAllowedIPs(args, options)
return 0
}),
),
)
packages := cli.NewCommand("packages", "work with packages giredore will serve").
WithShortcut("pkg").
WithCommand(
cli.NewCommand("get", "gets and prints out list of packages that is served by giredore").
WithArg(cli.NewArg("pkgnames", "one or more packages to get info about, delimited with comma, e.g. '/path/pkg1,/path/pkg2'. Say 'all' here to get info about all known packages.")).
WithAction(func(args []string, options map[string]string) int {
logger.Initialize()
clientv1.Initialize()
clientv1.GetPackages(args, options)
return 0
}),
).
WithCommand(
cli.NewCommand("set", "creates or updates package data").
WithArg(cli.NewArg("description", "optional package description that will be shown on package serving page")).
WithArg(cli.NewArg("origpath", "original path of package without domain, e.g. '/group/pkg' instead of 'github.com/group/pkg'")).
WithArg(cli.NewArg("realpath", "real path for package sources, e.g. 'github.com/group/pkg.git'")).
WithArg(cli.NewArg("vcs", "VCS used for package sources getting. See https://github.com/golang/tools/blob/master/go/vcs/vcs.go for list of supported VCS.")).
WithAction(func(args []string, options map[string]string) int {
logger.Initialize()
clientv1.Initialize()
clientv1.SetPackage(args, options)
return 0
}),
).
WithCommand(
cli.NewCommand("delete", "deletes package data").
WithArg(cli.NewArg("origpath", "original path of package without domain, e.g. '/group/pkg' instead of 'github.com/group/pkg'")).
WithAction(func(args []string, options map[string]string) int {
logger.Initialize()
clientv1.Initialize()
clientv1.DeletePackage(args, options)
return 0
}),
)
@@ -30,7 +82,8 @@ func main() {
WithOption(
cli.NewOption("server", "giredore server address"),
).
WithCommand(config)
WithCommand(config).
WithCommand(packages)
os.Exit(app.Run(os.Args, os.Stdout))
}

View File

@@ -33,6 +33,7 @@ func main() {
go func() {
<-signalHandler
httpserver.Shutdown()
configuration.Shutdown()
shutdownDone <- true
}()