mirror of
https://github.com/genuinetools/reg.git
synced 2024-09-28 11:46:20 -04:00
server: provide asset-path argument (#111)
This allows to install the assets into /usr/share/reg for packaging
This commit is contained in:
parent
bde58ebc52
commit
dad52d251d
2 changed files with 15 additions and 10 deletions
|
@ -224,6 +224,7 @@ Flags:
|
||||||
-u, --username username for the registry (default: <none>)
|
-u, --username username for the registry (default: <none>)
|
||||||
--cert path to ssl cert (default: <none>)
|
--cert path to ssl cert (default: <none>)
|
||||||
--clair url to clair instance (default: <none>)
|
--clair url to clair instance (default: <none>)
|
||||||
|
--asset-path Path to assets and templates (default: <none>)
|
||||||
-d enable debug logging (default: false)
|
-d enable debug logging (default: false)
|
||||||
-k, --insecure do not verify tls certificates (default: false)
|
-k, --insecure do not verify tls certificates (default: false)
|
||||||
-f, --force-non-ssl force allow use of non-ssl (default: false)
|
-f, --force-non-ssl force allow use of non-ssl (default: false)
|
||||||
|
|
24
server.go
24
server.go
|
@ -36,6 +36,7 @@ func (cmd *serverCommand) Register(fs *flag.FlagSet) {
|
||||||
fs.StringVar(&cmd.cert, "cert", "", "path to ssl cert")
|
fs.StringVar(&cmd.cert, "cert", "", "path to ssl cert")
|
||||||
fs.StringVar(&cmd.key, "key", "", "path to ssl key")
|
fs.StringVar(&cmd.key, "key", "", "path to ssl key")
|
||||||
fs.StringVar(&cmd.port, "port", "8080", "port for server to run on")
|
fs.StringVar(&cmd.port, "port", "8080", "port for server to run on")
|
||||||
|
fs.StringVar(&cmd.assetPath, "asset-path", "", "Path to assets and templates")
|
||||||
|
|
||||||
fs.BoolVar(&cmd.once, "once", false, "generate an output once and then exit")
|
fs.BoolVar(&cmd.once, "once", false, "generate an output once and then exit")
|
||||||
}
|
}
|
||||||
|
@ -47,9 +48,10 @@ type serverCommand struct {
|
||||||
|
|
||||||
once bool
|
once bool
|
||||||
|
|
||||||
cert string
|
cert string
|
||||||
key string
|
key string
|
||||||
port string
|
port string
|
||||||
|
assetPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cmd *serverCommand) Run(ctx context.Context, args []string) error {
|
func (cmd *serverCommand) Run(ctx context.Context, args []string) error {
|
||||||
|
@ -77,15 +79,17 @@ func (cmd *serverCommand) Run(ctx context.Context, args []string) error {
|
||||||
} else {
|
} else {
|
||||||
rc.cl = nil
|
rc.cl = nil
|
||||||
}
|
}
|
||||||
|
// Get the path to the asset directory.
|
||||||
// Get the path to the static directory.
|
assetDir := cmd.assetPath
|
||||||
wd, err := os.Getwd()
|
if len(cmd.assetPath) <= 0 {
|
||||||
if err != nil {
|
assetDir, err = os.Getwd()
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
staticDir := filepath.Join(wd, "static")
|
|
||||||
templateDir := filepath.Join(staticDir, "../templates")
|
|
||||||
|
|
||||||
|
staticDir := filepath.Join(assetDir, "static")
|
||||||
|
templateDir := filepath.Join(assetDir, "templates")
|
||||||
// Make sure all the paths exist.
|
// Make sure all the paths exist.
|
||||||
tmplPaths := []string{
|
tmplPaths := []string{
|
||||||
staticDir,
|
staticDir,
|
||||||
|
|
Loading…
Reference in a new issue