Compare commits
No commits in common. "277de43a0212e8efc901d0e2d2d390bad63842f9" and "c799dc78382c5ee5b6a110036158ffc1b8a48396" have entirely different histories.
277de43a02
...
c799dc7838
11 changed files with 72 additions and 311 deletions
21
README.md
21
README.md
|
|
@ -207,12 +207,14 @@ On the other hand, profiles are simply objects that contain data used to populat
|
||||||
type Profile struct {
|
type Profile struct {
|
||||||
ID string `json:"id"` // profile ID
|
ID string `json:"id"` // profile ID
|
||||||
Description string `json:"description,omitempty"` // profile description
|
Description string `json:"description,omitempty"` // profile description
|
||||||
Tags []string `json:"tags,omitempty"` // tags used for filtering (not implemented yet)
|
Tags []string `json:"tags,omitempty"` // tags used for ...
|
||||||
|
Paths []string `json:"paths,omitempty"` // paths to download
|
||||||
|
Plugins []string `json:"plugins,omitempty"` // plugins to run
|
||||||
Data map[string]any `json:"data,omitempty"` // include render data
|
Data map[string]any `json:"data,omitempty"` // include render data
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Profiles can be created using JSON and only require an `id` with optional `data`. See the example in `$MAKESHIFT_ROOT/profiles/default.json`.
|
Profiles can be created using JSON. See the example in `$MAKESHIFT_ROOT/profiles/default.json`.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
|
@ -233,9 +235,12 @@ Profiles can be created using JSON and only require an `id` with optional `data`
|
||||||
|
|
||||||
There are some features still missing that will be added later.
|
There are some features still missing that will be added later.
|
||||||
|
|
||||||
1. Running `makeshift` locally with profiles and plugins
|
1. Uploading files and directories
|
||||||
2. Plugin to add user data for one-time use without creating a profile
|
2. Uploading new profiles and plugins
|
||||||
3. Optionally build plugins directly into the main driver
|
3. Running `makeshift` locally with profiles and plugins
|
||||||
4. Protected routes that require authentication
|
4. Plugin to add user data for one-time use without creating a profile
|
||||||
5. Configuration file for persistent runs
|
5. Optionally build plugins directly into the main driver
|
||||||
6. `Dockerfile` and `docker-compose.yml` files to build containers
|
6. Protected routes that require authentication
|
||||||
|
7. Configuration file for persistent runs
|
||||||
|
8. `Dockerfile` and `docker-compose.yml` files to build containers
|
||||||
|
9. Including certs with requests
|
||||||
0
bin/compile-plugins.sh
Executable file → Normal file
0
bin/compile-plugins.sh
Executable file → Normal file
|
|
@ -24,29 +24,17 @@ var deleteCmd = &cobra.Command{
|
||||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||||
setenv(cmd, "host", "MAKESHIFT_HOST")
|
setenv(cmd, "host", "MAKESHIFT_HOST")
|
||||||
setenv(cmd, "path", "MAKESHIFT_PATH")
|
setenv(cmd, "path", "MAKESHIFT_PATH")
|
||||||
setenv(cmd, "cacert", "MAKESHIFT_CACERT")
|
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var (
|
var (
|
||||||
host, _ = cmd.Flags().GetString("host")
|
host, _ = cmd.Flags().GetString("host")
|
||||||
paths, _ = cmd.Flags().GetStringSlice("path")
|
paths, _ = cmd.Flags().GetStringSlice("path")
|
||||||
cacertPath, _ = cmd.Flags().GetString("cacert")
|
|
||||||
|
|
||||||
c = client.New(host)
|
c = client.New(host)
|
||||||
res *http.Response
|
res *http.Response
|
||||||
query string
|
query string
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
log.Debug().
|
|
||||||
Str("host", host).
|
|
||||||
Str("cacert", cacertPath).
|
|
||||||
Send()
|
|
||||||
|
|
||||||
if cacertPath != "" {
|
|
||||||
c.LoadCertificateFromPath(cacertPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, path := range paths {
|
for _, path := range paths {
|
||||||
if path == "" {
|
if path == "" {
|
||||||
log.Warn().Msg("skipping empty path")
|
log.Warn().Msg("skipping empty path")
|
||||||
|
|
@ -74,7 +62,6 @@ var deleteProfilesCmd = &cobra.Command{
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var (
|
var (
|
||||||
host, _ = cmd.Flags().GetString("host")
|
host, _ = cmd.Flags().GetString("host")
|
||||||
cacertPath, _ = cmd.Flags().GetString("cacert")
|
|
||||||
|
|
||||||
c = client.New(host)
|
c = client.New(host)
|
||||||
res *http.Response
|
res *http.Response
|
||||||
|
|
@ -82,14 +69,6 @@ var deleteProfilesCmd = &cobra.Command{
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
log.Debug().
|
|
||||||
Str("host", host).
|
|
||||||
Str("cacert", cacertPath).
|
|
||||||
Send()
|
|
||||||
|
|
||||||
if cacertPath != "" {
|
|
||||||
c.LoadCertificateFromPath(cacertPath)
|
|
||||||
}
|
|
||||||
for _, profileID := range args {
|
for _, profileID := range args {
|
||||||
if profileID == "default" {
|
if profileID == "default" {
|
||||||
log.Warn().Msg("cannot delete the default profile")
|
log.Warn().Msg("cannot delete the default profile")
|
||||||
|
|
@ -117,7 +96,6 @@ var deletePluginsCmd = &cobra.Command{
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var (
|
var (
|
||||||
host, _ = cmd.Flags().GetString("host")
|
host, _ = cmd.Flags().GetString("host")
|
||||||
cacertPath, _ = cmd.Flags().GetString("cacert")
|
|
||||||
|
|
||||||
c = client.New(host)
|
c = client.New(host)
|
||||||
res *http.Response
|
res *http.Response
|
||||||
|
|
@ -125,15 +103,6 @@ var deletePluginsCmd = &cobra.Command{
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
log.Debug().
|
|
||||||
Str("host", host).
|
|
||||||
Str("cacert", cacertPath).
|
|
||||||
Send()
|
|
||||||
|
|
||||||
if cacertPath != "" {
|
|
||||||
c.LoadCertificateFromPath(cacertPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, pluginName := range args {
|
for _, pluginName := range args {
|
||||||
query = fmt.Sprintf("/plugins/%s", pluginName)
|
query = fmt.Sprintf("/plugins/%s", pluginName)
|
||||||
res, _, err = c.MakeRequest(client.HTTPEnvelope{
|
res, _, err = c.MakeRequest(client.HTTPEnvelope{
|
||||||
|
|
@ -147,7 +116,6 @@ var deletePluginsCmd = &cobra.Command{
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
deleteCmd.PersistentFlags().String("host", "http://localhost:5050", "Set the makeshift server host (can be set with MAKESHIFT_HOST)")
|
deleteCmd.PersistentFlags().String("host", "http://localhost:5050", "Set the makeshift server host (can be set with MAKESHIFT_HOST)")
|
||||||
deleteCmd.PersistentFlags().String("cacert", "", "Set the CA certificate path to load")
|
|
||||||
deleteCmd.Flags().StringSliceP("path", "p", []string{}, "Set the paths to delete files and directories")
|
deleteCmd.Flags().StringSliceP("path", "p", []string{}, "Set the paths to delete files and directories")
|
||||||
deleteCmd.AddCommand(deleteProfilesCmd, deletePluginsCmd)
|
deleteCmd.AddCommand(deleteProfilesCmd, deletePluginsCmd)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,14 +37,12 @@ var downloadCmd = cobra.Command{
|
||||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||||
setenv(cmd, "host", "MAKESHIFT_HOST")
|
setenv(cmd, "host", "MAKESHIFT_HOST")
|
||||||
setenv(cmd, "path", "MAKESHIFT_PATH")
|
setenv(cmd, "path", "MAKESHIFT_PATH")
|
||||||
setenv(cmd, "cacert", "MAKESHIFT_CACERT")
|
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var (
|
var (
|
||||||
host, _ = cmd.Flags().GetString("host")
|
host, _ = cmd.Flags().GetString("host")
|
||||||
path, _ = cmd.Flags().GetString("path")
|
path, _ = cmd.Flags().GetString("path")
|
||||||
outputPath, _ = cmd.Flags().GetString("output")
|
outputPath, _ = cmd.Flags().GetString("output")
|
||||||
cacertPath, _ = cmd.Flags().GetString("cacert")
|
|
||||||
pluginNames, _ = cmd.Flags().GetStringSlice("plugins")
|
pluginNames, _ = cmd.Flags().GetStringSlice("plugins")
|
||||||
profileIDs, _ = cmd.Flags().GetStringSlice("profiles")
|
profileIDs, _ = cmd.Flags().GetStringSlice("profiles")
|
||||||
extract, _ = cmd.Flags().GetBool("extract")
|
extract, _ = cmd.Flags().GetBool("extract")
|
||||||
|
|
@ -74,10 +72,6 @@ var downloadCmd = cobra.Command{
|
||||||
Strs("plugins", pluginNames).
|
Strs("plugins", pluginNames).
|
||||||
Send()
|
Send()
|
||||||
|
|
||||||
if cacertPath != "" {
|
|
||||||
c.LoadCertificateFromPath(cacertPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
res, body, err = c.MakeRequest(client.HTTPEnvelope{
|
res, body, err = c.MakeRequest(client.HTTPEnvelope{
|
||||||
Path: query,
|
Path: query,
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
|
|
@ -169,7 +163,6 @@ var downloadProfileCmd = &cobra.Command{
|
||||||
var (
|
var (
|
||||||
host, _ = cmd.Flags().GetString("host")
|
host, _ = cmd.Flags().GetString("host")
|
||||||
outputPath, _ = cmd.Flags().GetString("output")
|
outputPath, _ = cmd.Flags().GetString("output")
|
||||||
cacertPath, _ = cmd.Flags().GetString("cacert")
|
|
||||||
|
|
||||||
c = client.New(host)
|
c = client.New(host)
|
||||||
res *http.Response
|
res *http.Response
|
||||||
|
|
@ -183,10 +176,6 @@ var downloadProfileCmd = &cobra.Command{
|
||||||
Str("output", outputPath).
|
Str("output", outputPath).
|
||||||
Send()
|
Send()
|
||||||
|
|
||||||
if cacertPath != "" {
|
|
||||||
c.LoadCertificateFromPath(cacertPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, profileID := range args {
|
for _, profileID := range args {
|
||||||
query = fmt.Sprintf("/profiles/%s", profileID)
|
query = fmt.Sprintf("/profiles/%s", profileID)
|
||||||
res, body, err = c.MakeRequest(client.HTTPEnvelope{
|
res, body, err = c.MakeRequest(client.HTTPEnvelope{
|
||||||
|
|
@ -230,7 +219,6 @@ var downloadPluginCmd = &cobra.Command{
|
||||||
var (
|
var (
|
||||||
host, _ = cmd.Flags().GetString("host")
|
host, _ = cmd.Flags().GetString("host")
|
||||||
outputPath, _ = cmd.Flags().GetString("output")
|
outputPath, _ = cmd.Flags().GetString("output")
|
||||||
cacertPath, _ = cmd.Flags().GetString("cacert")
|
|
||||||
|
|
||||||
c = client.New(host)
|
c = client.New(host)
|
||||||
res *http.Response
|
res *http.Response
|
||||||
|
|
@ -244,10 +232,6 @@ var downloadPluginCmd = &cobra.Command{
|
||||||
Str("output", outputPath).
|
Str("output", outputPath).
|
||||||
Send()
|
Send()
|
||||||
|
|
||||||
if cacertPath != "" {
|
|
||||||
c.LoadCertificateFromPath(cacertPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, pluginName := range args {
|
for _, pluginName := range args {
|
||||||
query = fmt.Sprintf("/plugins/%s/raw", pluginName)
|
query = fmt.Sprintf("/plugins/%s/raw", pluginName)
|
||||||
res, body, err = c.MakeRequest(client.HTTPEnvelope{
|
res, body, err = c.MakeRequest(client.HTTPEnvelope{
|
||||||
|
|
@ -283,7 +267,6 @@ var downloadPluginCmd = &cobra.Command{
|
||||||
func init() {
|
func init() {
|
||||||
downloadCmd.PersistentFlags().String("host", "http://localhost:5050", "Set the makeshift remote host (can be set with MAKESHIFT_HOST)")
|
downloadCmd.PersistentFlags().String("host", "http://localhost:5050", "Set the makeshift remote host (can be set with MAKESHIFT_HOST)")
|
||||||
downloadCmd.PersistentFlags().StringP("output", "o", "", "Set the output path to write files")
|
downloadCmd.PersistentFlags().StringP("output", "o", "", "Set the output path to write files")
|
||||||
downloadCmd.PersistentFlags().String("cacert", "", "Set the CA certificate path to load")
|
|
||||||
downloadCmd.Flags().StringP("path", "p", ".", "Set the path to list files (can be set with MAKESHIFT_PATH)")
|
downloadCmd.Flags().StringP("path", "p", ".", "Set the path to list files (can be set with MAKESHIFT_PATH)")
|
||||||
downloadCmd.Flags().StringSlice("profiles", []string{}, "Set the profile(s) to use to populate data store")
|
downloadCmd.Flags().StringSlice("profiles", []string{}, "Set the profile(s) to use to populate data store")
|
||||||
downloadCmd.Flags().StringSlice("plugins", []string{}, "Set the plugin(s) to run before downloading files")
|
downloadCmd.Flags().StringSlice("plugins", []string{}, "Set the plugin(s) to run before downloading files")
|
||||||
|
|
|
||||||
39
cmd/list.go
39
cmd/list.go
|
|
@ -24,16 +24,14 @@ var listCmd = &cobra.Command{
|
||||||
`,
|
`,
|
||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
Short: "List all files in a remote data directory",
|
Short: "List all files in a remote data directory",
|
||||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
setenv(cmd, "host", "MAKESHIFT_HOST")
|
setenv(cmd, "host", "MAKESHIFT_HOST")
|
||||||
setenv(cmd, "path", "MAKESHIFT_PATH")
|
setenv(cmd, "path", "MAKESHIFT_PATH")
|
||||||
setenv(cmd, "cacert", "MAKESHIFT_CACERT")
|
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var (
|
var (
|
||||||
host, _ = cmd.Flags().GetString("host")
|
host, _ = cmd.Flags().GetString("host")
|
||||||
path, _ = cmd.Flags().GetString("path")
|
path, _ = cmd.Flags().GetString("path")
|
||||||
cacertPath, _ = cmd.Flags().GetString("cacert")
|
|
||||||
|
|
||||||
c = client.New(host)
|
c = client.New(host)
|
||||||
body []byte
|
body []byte
|
||||||
|
|
@ -44,13 +42,8 @@ var listCmd = &cobra.Command{
|
||||||
log.Debug().
|
log.Debug().
|
||||||
Str("host", host).
|
Str("host", host).
|
||||||
Str("path", path).
|
Str("path", path).
|
||||||
Str("cacert", cacertPath).
|
|
||||||
Send()
|
Send()
|
||||||
|
|
||||||
if cacertPath != "" {
|
|
||||||
c.LoadCertificateFromPath(cacertPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
// make request to /list endpoint
|
// make request to /list endpoint
|
||||||
_, body, err = c.MakeRequest(client.HTTPEnvelope{
|
_, body, err = c.MakeRequest(client.HTTPEnvelope{
|
||||||
Path: fmt.Sprintf("/list/%s", path),
|
Path: fmt.Sprintf("/list/%s", path),
|
||||||
|
|
@ -88,7 +81,6 @@ var listPluginsCmd = &cobra.Command{
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var (
|
var (
|
||||||
host, _ = cmd.Flags().GetString("host")
|
host, _ = cmd.Flags().GetString("host")
|
||||||
cacertPath, _ = cmd.Flags().GetString("cacert")
|
|
||||||
|
|
||||||
c = client.New(host)
|
c = client.New(host)
|
||||||
res *http.Response
|
res *http.Response
|
||||||
|
|
@ -98,15 +90,6 @@ var listPluginsCmd = &cobra.Command{
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
log.Debug().
|
|
||||||
Str("host", host).
|
|
||||||
Str("cacert", cacertPath).
|
|
||||||
Send()
|
|
||||||
|
|
||||||
if cacertPath != "" {
|
|
||||||
c.LoadCertificateFromPath(cacertPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
// make request to /list endpoint
|
// make request to /list endpoint
|
||||||
res, body, err = c.MakeRequest(client.HTTPEnvelope{
|
res, body, err = c.MakeRequest(client.HTTPEnvelope{
|
||||||
|
|
@ -139,18 +122,10 @@ var listPluginsCmd = &cobra.Command{
|
||||||
|
|
||||||
var listProfilesCmd = &cobra.Command{
|
var listProfilesCmd = &cobra.Command{
|
||||||
Use: "profiles",
|
Use: "profiles",
|
||||||
Example: `
|
|
||||||
# list all profiles
|
|
||||||
makeshift list profiles
|
|
||||||
|
|
||||||
# live individual profiles
|
|
||||||
makeshift list profiles default custom
|
|
||||||
`,
|
|
||||||
Short: "Show all available profiles",
|
Short: "Show all available profiles",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var (
|
var (
|
||||||
host, _ = cmd.Flags().GetString("host")
|
host, _ = cmd.Flags().GetString("host")
|
||||||
cacertPath, _ = cmd.Flags().GetString("cacert")
|
|
||||||
|
|
||||||
c = client.New(host)
|
c = client.New(host)
|
||||||
res *http.Response
|
res *http.Response
|
||||||
|
|
@ -160,15 +135,6 @@ var listProfilesCmd = &cobra.Command{
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
log.Debug().
|
|
||||||
Str("host", host).
|
|
||||||
Str("cacert", cacertPath).
|
|
||||||
Send()
|
|
||||||
|
|
||||||
if cacertPath != "" {
|
|
||||||
c.LoadCertificateFromPath(cacertPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
// make request to /list endpoint
|
// make request to /list endpoint
|
||||||
res, body, err = c.MakeRequest(client.HTTPEnvelope{
|
res, body, err = c.MakeRequest(client.HTTPEnvelope{
|
||||||
|
|
@ -188,7 +154,7 @@ var listProfilesCmd = &cobra.Command{
|
||||||
// make request to /list endpoint
|
// make request to /list endpoint
|
||||||
query = fmt.Sprintf("/profiles/%s", profileID)
|
query = fmt.Sprintf("/profiles/%s", profileID)
|
||||||
res, body, err = c.MakeRequest(client.HTTPEnvelope{
|
res, body, err = c.MakeRequest(client.HTTPEnvelope{
|
||||||
Path: query,
|
Path: fmt.Sprintf(query),
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
})
|
})
|
||||||
handleResponseError(res, host, query, err)
|
handleResponseError(res, host, query, err)
|
||||||
|
|
@ -208,7 +174,6 @@ var listProfilesCmd = &cobra.Command{
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
listCmd.PersistentFlags().String("host", "http://localhost:5050", "Set the configurator remote host (can be set with MAKESHIFT_HOST)")
|
listCmd.PersistentFlags().String("host", "http://localhost:5050", "Set the configurator remote host (can be set with MAKESHIFT_HOST)")
|
||||||
listCmd.PersistentFlags().String("cacert", "", "Set the CA certificate path to load")
|
|
||||||
listCmd.Flags().StringP("path", "p", ".", "Set the path to list files (can be set with MAKESHIFT_PATH)")
|
listCmd.Flags().StringP("path", "p", ".", "Set the path to list files (can be set with MAKESHIFT_PATH)")
|
||||||
|
|
||||||
listCmd.AddCommand(listPluginsCmd, listProfilesCmd)
|
listCmd.AddCommand(listPluginsCmd, listProfilesCmd)
|
||||||
|
|
|
||||||
12
cmd/serve.go
12
cmd/serve.go
|
|
@ -23,15 +23,11 @@ var serveCmd = &cobra.Command{
|
||||||
setenv(cmd, "host", "MAKESHIFT_HOST")
|
setenv(cmd, "host", "MAKESHIFT_HOST")
|
||||||
setenv(cmd, "root", "MAKESHIFT_ROOT")
|
setenv(cmd, "root", "MAKESHIFT_ROOT")
|
||||||
setenv(cmd, "timeout", "MAKESHIFT_TIMEOUT")
|
setenv(cmd, "timeout", "MAKESHIFT_TIMEOUT")
|
||||||
setenv(cmd, "cacert", "MAKESHIFT_CACERT")
|
|
||||||
setenv(cmd, "keyfile", "MAKESHIFT_KEYFILE")
|
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var (
|
var (
|
||||||
host, _ = cmd.Flags().GetString("host")
|
host, _ = cmd.Flags().GetString("host")
|
||||||
rootPath, _ = cmd.Flags().GetString("root")
|
rootPath, _ = cmd.Flags().GetString("root")
|
||||||
cacertPath, _ = cmd.Flags().GetString("cacert")
|
|
||||||
keyfile, _ = cmd.Flags().GetString("keyfile")
|
|
||||||
timeout, _ = cmd.Flags().GetInt("timeout")
|
timeout, _ = cmd.Flags().GetInt("timeout")
|
||||||
|
|
||||||
parsed *url.URL
|
parsed *url.URL
|
||||||
|
|
@ -51,8 +47,6 @@ var serveCmd = &cobra.Command{
|
||||||
server = service.New()
|
server = service.New()
|
||||||
server.Addr = parsed.Host
|
server.Addr = parsed.Host
|
||||||
server.RootPath = rootPath
|
server.RootPath = rootPath
|
||||||
server.CACertFile = cacertPath
|
|
||||||
server.CACertKeyfile = keyfile
|
|
||||||
server.Timeout = time.Duration(timeout) * time.Second
|
server.Timeout = time.Duration(timeout) * time.Second
|
||||||
|
|
||||||
// show some debugging information
|
// show some debugging information
|
||||||
|
|
@ -60,8 +54,6 @@ var serveCmd = &cobra.Command{
|
||||||
Str("host", parsed.Host).
|
Str("host", parsed.Host).
|
||||||
Any("paths", map[string]string{
|
Any("paths", map[string]string{
|
||||||
"root": rootPath,
|
"root": rootPath,
|
||||||
"cacert": cacertPath,
|
|
||||||
"keyfile": keyfile,
|
|
||||||
"data": server.PathForData(),
|
"data": server.PathForData(),
|
||||||
"profiles": server.PathForProfiles(),
|
"profiles": server.PathForProfiles(),
|
||||||
"plugins": server.PathForPlugins(),
|
"plugins": server.PathForPlugins(),
|
||||||
|
|
@ -92,10 +84,6 @@ func init() {
|
||||||
serveCmd.Flags().String("host", "localhost:5050", "Set the configurator server host (can be set with MAKESHIFT_HOST)")
|
serveCmd.Flags().String("host", "localhost:5050", "Set the configurator server host (can be set with MAKESHIFT_HOST)")
|
||||||
serveCmd.Flags().String("root", "./", "Set the root path to serve files (can be set with MAKESHIFT_ROOT)")
|
serveCmd.Flags().String("root", "./", "Set the root path to serve files (can be set with MAKESHIFT_ROOT)")
|
||||||
serveCmd.Flags().IntP("timeout", "t", 60, "Set the timeout in seconds for requests (can be set with MAKESHIFT_TIMEOUT)")
|
serveCmd.Flags().IntP("timeout", "t", 60, "Set the timeout in seconds for requests (can be set with MAKESHIFT_TIMEOUT)")
|
||||||
serveCmd.Flags().String("cacert", "", "Set the CA certificate path to load (can be set with MAKESHIFT_CACERT)")
|
|
||||||
serveCmd.Flags().String("keyfile", "", "Set the CA key file to use (can be set with MAKESHIFT_KEYFILE)")
|
|
||||||
|
|
||||||
serveCmd.MarkFlagsRequiredTogether("cacert", "keyfile")
|
|
||||||
|
|
||||||
rootCmd.AddCommand(serveCmd)
|
rootCmd.AddCommand(serveCmd)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
160
cmd/upload.go
160
cmd/upload.go
|
|
@ -4,8 +4,6 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
|
||||||
"maps"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -43,13 +41,11 @@ var uploadCmd = &cobra.Command{
|
||||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||||
setenv(cmd, "host", "MAKESHIFT_HOST")
|
setenv(cmd, "host", "MAKESHIFT_HOST")
|
||||||
setenv(cmd, "path", "MAKESHIFT_PATH")
|
setenv(cmd, "path", "MAKESHIFT_PATH")
|
||||||
setenv(cmd, "cacert", "MAKESHIFT_CACERT")
|
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var (
|
var (
|
||||||
host, _ = cmd.Flags().GetString("host")
|
host, _ = cmd.Flags().GetString("host")
|
||||||
path, _ = cmd.Flags().GetString("path")
|
path, _ = cmd.Flags().GetString("path")
|
||||||
cacertPath, _ = cmd.Flags().GetString("cacert")
|
|
||||||
dataArgs, _ = cmd.Flags().GetStringArray("data")
|
dataArgs, _ = cmd.Flags().GetStringArray("data")
|
||||||
|
|
||||||
inputData = processFiles(dataArgs)
|
inputData = processFiles(dataArgs)
|
||||||
|
|
@ -59,21 +55,8 @@ var uploadCmd = &cobra.Command{
|
||||||
query string
|
query string
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
log.Debug().
|
|
||||||
Str("host", host).
|
|
||||||
Str("path", path).
|
|
||||||
Str("query", query).
|
|
||||||
Str("cacert", cacertPath).
|
|
||||||
Any("input", inputData).
|
|
||||||
Send()
|
|
||||||
|
|
||||||
if cacertPath != "" {
|
|
||||||
c.LoadCertificateFromPath(cacertPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
for inputPath, contents := range inputData {
|
for inputPath, contents := range inputData {
|
||||||
log.Debug().Str("path", path).Int("size", len(contents)).Send()
|
log.Info().Str("path", path).Int("size", len(contents)).Send()
|
||||||
if useDirectoryPath {
|
if useDirectoryPath {
|
||||||
query = path + "/" + filepath.Clean(inputPath)
|
query = path + "/" + filepath.Clean(inputPath)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -111,7 +94,6 @@ var uploadProfilesCmd = &cobra.Command{
|
||||||
var (
|
var (
|
||||||
host, _ = cmd.Flags().GetString("host")
|
host, _ = cmd.Flags().GetString("host")
|
||||||
dataArgs, _ = cmd.Flags().GetStringArray("data")
|
dataArgs, _ = cmd.Flags().GetStringArray("data")
|
||||||
cacertPath, _ = cmd.Flags().GetString("cacert")
|
|
||||||
profiles = processProfiles(dataArgs)
|
profiles = processProfiles(dataArgs)
|
||||||
|
|
||||||
c = client.New(host)
|
c = client.New(host)
|
||||||
|
|
@ -121,16 +103,6 @@ var uploadProfilesCmd = &cobra.Command{
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
log.Debug().
|
|
||||||
Str("host", host).
|
|
||||||
Str("query", query).
|
|
||||||
Str("cacert", cacertPath).
|
|
||||||
Send()
|
|
||||||
|
|
||||||
if cacertPath != "" {
|
|
||||||
c.LoadCertificateFromPath(cacertPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
// load files from args
|
// load files from args
|
||||||
for i, path := range args {
|
for i, path := range args {
|
||||||
body, err = os.ReadFile(path)
|
body, err = os.ReadFile(path)
|
||||||
|
|
@ -190,7 +162,6 @@ var uploadPluginsCmd = &cobra.Command{
|
||||||
var (
|
var (
|
||||||
host, _ = cmd.Flags().GetString("host")
|
host, _ = cmd.Flags().GetString("host")
|
||||||
dataArgs, _ = cmd.Flags().GetStringArray("data")
|
dataArgs, _ = cmd.Flags().GetStringArray("data")
|
||||||
cacertPath, _ = cmd.Flags().GetString("cacert")
|
|
||||||
|
|
||||||
plugins = processFiles(dataArgs)
|
plugins = processFiles(dataArgs)
|
||||||
c = client.New(host)
|
c = client.New(host)
|
||||||
|
|
@ -201,16 +172,6 @@ var uploadPluginsCmd = &cobra.Command{
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
log.Debug().
|
|
||||||
Str("host", host).
|
|
||||||
Str("query", query).
|
|
||||||
Str("cacert", cacertPath).
|
|
||||||
Send()
|
|
||||||
|
|
||||||
if cacertPath != "" {
|
|
||||||
c.LoadCertificateFromPath(cacertPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
// load files from args
|
// load files from args
|
||||||
for i, path := range args {
|
for i, path := range args {
|
||||||
body, err = os.ReadFile(path)
|
body, err = os.ReadFile(path)
|
||||||
|
|
@ -247,8 +208,6 @@ var uploadPluginsCmd = &cobra.Command{
|
||||||
func init() {
|
func init() {
|
||||||
uploadCmd.PersistentFlags().String("host", "http://localhost:5050", "Set the makeshift remote host (can be set with MAKESHIFT_HOST)")
|
uploadCmd.PersistentFlags().String("host", "http://localhost:5050", "Set the makeshift remote host (can be set with MAKESHIFT_HOST)")
|
||||||
uploadCmd.PersistentFlags().StringArrayP("data", "d", []string{}, "Set the data to send to specified host (prepend @ for files)")
|
uploadCmd.PersistentFlags().StringArrayP("data", "d", []string{}, "Set the data to send to specified host (prepend @ for files)")
|
||||||
uploadCmd.PersistentFlags().String("cacert", "", "Set the CA certificate path to load")
|
|
||||||
|
|
||||||
uploadCmd.Flags().StringP("path", "p", ".", "Set the path to list files (can be set with MAKESHIFT_PATH)")
|
uploadCmd.Flags().StringP("path", "p", ".", "Set the path to list files (can be set with MAKESHIFT_PATH)")
|
||||||
|
|
||||||
uploadProfilesCmd.Flags().VarP(&inputFormat, "format", "F", "Set the input format for profile")
|
uploadProfilesCmd.Flags().VarP(&inputFormat, "format", "F", "Set the input format for profile")
|
||||||
|
|
@ -261,27 +220,31 @@ func processFiles(args []string) map[string][]byte {
|
||||||
// load data either from file or directly from args
|
// load data either from file or directly from args
|
||||||
var collection = make(map[string][]byte, len(args))
|
var collection = make(map[string][]byte, len(args))
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
// skip empty string args
|
// if arg is empty string, then skip and continue
|
||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
// determine if we're reading from file to load contents
|
// determine if we're reading from file to load contents
|
||||||
if strings.HasPrefix(arg, "@") {
|
if strings.HasPrefix(arg, "@") {
|
||||||
var path string = strings.TrimLeft(arg, "@")
|
var (
|
||||||
|
path string = strings.TrimLeft(arg, "@")
|
||||||
// process sub-directories recursively
|
contents []byte
|
||||||
newCollection, err := processDir(path)
|
err error
|
||||||
|
)
|
||||||
|
contents, err = os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn().
|
log.Error().Err(err).Str("path", path).Msg("failed to read file")
|
||||||
Err(err).
|
continue
|
||||||
Str("path", path).
|
|
||||||
Msg("failed to process directory at path")
|
|
||||||
}
|
}
|
||||||
log.Trace().
|
|
||||||
Str("path", path).
|
|
||||||
Msg("new collection added at path")
|
|
||||||
maps.Copy(collection, newCollection)
|
|
||||||
|
|
||||||
|
// skip empty files
|
||||||
|
if len(contents) == 0 {
|
||||||
|
log.Warn().Str("path", path).Msg("file is empty")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// add loaded data to collection of all data
|
||||||
|
collection[path] = contents
|
||||||
} else {
|
} else {
|
||||||
log.Warn().Msg("only files can be uploaded (add @ before the path with '--data' flag)")
|
log.Warn().Msg("only files can be uploaded (add @ before the path)")
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -312,28 +275,20 @@ func processProfiles(args []string) []*makeshift.Profile {
|
||||||
)
|
)
|
||||||
contents, err = os.ReadFile(path)
|
contents, err = os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().Err(err).Str("path", path).Msg("failed to read file")
|
||||||
Err(err).
|
|
||||||
Str("path", path).
|
|
||||||
Msg("failed to read file")
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip empty files
|
// skip empty files
|
||||||
if len(contents) == 0 {
|
if len(contents) == 0 {
|
||||||
log.Warn().
|
log.Warn().Str("path", path).Msg("file is empty")
|
||||||
Str("path", path).
|
|
||||||
Msg("file is empty")
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert/validate input data
|
// convert/validate input data
|
||||||
data, err = parseProfile(contents, format.DataFormatFromFileExt(path, inputFormat))
|
data, err = parseProfile(contents, format.DataFormatFromFileExt(path, inputFormat))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().Err(err).Str("path", path).Msg("failed to validate input from file")
|
||||||
Err(err).
|
|
||||||
Str("path", path).
|
|
||||||
Msg("failed to validate input from file")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add loaded data to collection of all data
|
// add loaded data to collection of all data
|
||||||
|
|
@ -351,9 +306,7 @@ func processProfiles(args []string) []*makeshift.Profile {
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(input, &data)
|
err = json.Unmarshal(input, &data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().Err(err).Msgf("failed to unmarshal input for argument %d", i)
|
||||||
Err(err).
|
|
||||||
Msgf("failed to unmarshal input for argument %d", i)
|
|
||||||
}
|
}
|
||||||
return []*makeshift.Profile{data}
|
return []*makeshift.Profile{data}
|
||||||
}
|
}
|
||||||
|
|
@ -362,73 +315,6 @@ func processProfiles(args []string) []*makeshift.Profile {
|
||||||
return collection
|
return collection
|
||||||
}
|
}
|
||||||
|
|
||||||
func processDir(path string) (map[string][]byte, error) {
|
|
||||||
var (
|
|
||||||
collection = map[string][]byte{}
|
|
||||||
fileInfo os.FileInfo
|
|
||||||
contents []byte
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
// determine if path is directory
|
|
||||||
if fileInfo, err = os.Stat(path); err == nil {
|
|
||||||
if fileInfo.IsDir() {
|
|
||||||
filepath.WalkDir(path, func(path string, d fs.DirEntry, err error) error {
|
|
||||||
if !d.IsDir() {
|
|
||||||
contents, err = os.ReadFile(path)
|
|
||||||
if err != nil {
|
|
||||||
log.Error().Err(err).Str("path", path).Msg("failed to read file")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// skip empty files
|
|
||||||
if len(contents) == 0 {
|
|
||||||
log.Warn().Str("path", path).Msg("file is empty")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debug().
|
|
||||||
Str("path", path).
|
|
||||||
Msg("file added to collection")
|
|
||||||
|
|
||||||
// add loaded data to collection of all data
|
|
||||||
collection[path] = contents
|
|
||||||
} else {
|
|
||||||
// process sub-directories recursively
|
|
||||||
newCollection, err := processDir(path)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to process directory at path '%s': %v", path, err)
|
|
||||||
}
|
|
||||||
log.Trace().
|
|
||||||
Str("path", path).
|
|
||||||
Msg("new collection added from nested directory")
|
|
||||||
maps.Copy(collection, newCollection)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
contents, err = os.ReadFile(path)
|
|
||||||
if err != nil {
|
|
||||||
return collection, fmt.Errorf("failed to read file at path '%s': %v", path, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// skip empty files
|
|
||||||
if len(contents) == 0 {
|
|
||||||
return collection, fmt.Errorf("file is empty")
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debug().
|
|
||||||
Str("path", path).
|
|
||||||
Msg("file added to collection")
|
|
||||||
|
|
||||||
// add loaded data to collection of all data
|
|
||||||
collection[path] = contents
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return nil, fmt.Errorf("failed to stat file: %v", err)
|
|
||||||
}
|
|
||||||
return collection, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func parseProfile(contents []byte, dataFormat format.DataFormat) (*makeshift.Profile, error) {
|
func parseProfile(contents []byte, dataFormat format.DataFormat) (*makeshift.Profile, error) {
|
||||||
var (
|
var (
|
||||||
data *makeshift.Profile
|
data *makeshift.Profile
|
||||||
|
|
|
||||||
|
|
@ -133,18 +133,10 @@ func addToArchive(tw *tar.Writer, filename string, hooks []makeshift.Hook) error
|
||||||
}
|
}
|
||||||
hook.Data.Set("file", contents)
|
hook.Data.Set("file", contents)
|
||||||
|
|
||||||
err = hook.Init()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
err = hook.Run()
|
err = hook.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = hook.Cleanup()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// create temporary file to use to add to archive
|
// create temporary file to use to add to archive
|
||||||
hook = hooks[len(hooks)-1]
|
hook = hooks[len(hooks)-1]
|
||||||
|
|
|
||||||
|
|
@ -29,18 +29,10 @@ type Hook struct {
|
||||||
Plugin Plugin
|
Plugin Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Hook) Init() error {
|
|
||||||
return h.Plugin.Init()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Hook) Run() error {
|
func (h *Hook) Run() error {
|
||||||
return h.Plugin.Run(h.Data, h.Args)
|
return h.Plugin.Run(h.Data, h.Args)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Hook) Cleanup() error {
|
|
||||||
return h.Plugin.Cleanup()
|
|
||||||
}
|
|
||||||
|
|
||||||
func PluginToMap(p Plugin) map[string]any {
|
func PluginToMap(p Plugin) map[string]any {
|
||||||
return map[string]any{
|
return map[string]any{
|
||||||
"name": p.Name(),
|
"name": p.Name(),
|
||||||
|
|
|
||||||
|
|
@ -142,14 +142,6 @@ func (s *Service) Download() http.HandlerFunc {
|
||||||
"version": hook.Plugin.Version(),
|
"version": hook.Plugin.Version(),
|
||||||
},
|
},
|
||||||
}).Send()
|
}).Send()
|
||||||
err = hook.Init()
|
|
||||||
if err != nil {
|
|
||||||
log.Error().
|
|
||||||
Err(err).
|
|
||||||
Str("plugin", hook.Plugin.Name()).
|
|
||||||
Msg("failed to initialize plugin")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
err = hook.Run()
|
err = hook.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().
|
||||||
|
|
@ -158,14 +150,6 @@ func (s *Service) Download() http.HandlerFunc {
|
||||||
Msg("failed to run plugin")
|
Msg("failed to run plugin")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
err = hook.Cleanup()
|
|
||||||
if err != nil {
|
|
||||||
log.Error().
|
|
||||||
Err(err).
|
|
||||||
Str("plugin", hook.Plugin.Name()).
|
|
||||||
Msg("failed to cleanup plugin")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// take the contents from the last hook and update files
|
// take the contents from the last hook and update files
|
||||||
|
|
@ -206,9 +190,7 @@ func (s *Service) Upload() http.HandlerFunc {
|
||||||
)
|
)
|
||||||
|
|
||||||
// show what we're uploading
|
// show what we're uploading
|
||||||
log.Debug().
|
log.Debug().Str("path", path).Msg("Service.Upload()")
|
||||||
Str("path", path).
|
|
||||||
Msg("Service.Upload()")
|
|
||||||
|
|
||||||
// take the provided path and store the file contents
|
// take the provided path and store the file contents
|
||||||
dirpath = filepath.Dir(path)
|
dirpath = filepath.Dir(path)
|
||||||
|
|
@ -314,7 +296,7 @@ func (s *Service) loadProfiles(profileIDs []string, store storage.KVStore, errs
|
||||||
profile *makeshift.Profile
|
profile *makeshift.Profile
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
if i > s.ProfilesMaxCount {
|
if i > DEFAULT_PROFILES_MAX_COUNT {
|
||||||
log.Warn().Msg("max profiles count reached...stopping")
|
log.Warn().Msg("max profiles count reached...stopping")
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
|
@ -347,7 +329,7 @@ func (s *Service) loadPlugins(pluginNames []string, store storage.KVStore, args
|
||||||
plugin makeshift.Plugin
|
plugin makeshift.Plugin
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
if i > s.PluginsMaxCount {
|
if i > DEFAULT_PLUGINS_MAX_COUNT {
|
||||||
log.Warn().Msg("max plugins count reached or exceeded...stopping")
|
log.Warn().Msg("max plugins count reached or exceeded...stopping")
|
||||||
return hooks, errs
|
return hooks, errs
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,7 @@ import (
|
||||||
type Service struct {
|
type Service struct {
|
||||||
Addr string
|
Addr string
|
||||||
RootPath string `yaml:"root,omitempty"`
|
RootPath string `yaml:"root,omitempty"`
|
||||||
CACertFile string `yaml:"cacert,omitempty"`
|
Environment map[string]string
|
||||||
CACertKeyfile string `yaml:"keyfile,omitempty"`
|
|
||||||
|
|
||||||
// max counts
|
// max counts
|
||||||
PluginsMaxCount int
|
PluginsMaxCount int
|
||||||
|
|
@ -35,6 +34,11 @@ func New() *Service {
|
||||||
return &Service{
|
return &Service{
|
||||||
Addr: ":5050",
|
Addr: ":5050",
|
||||||
RootPath: "./",
|
RootPath: "./",
|
||||||
|
Environment: map[string]string{
|
||||||
|
"MAKESHIFT_HOST": "",
|
||||||
|
"MAKESHIFT_ROOT": "",
|
||||||
|
"ACCESS_TOKEN": "",
|
||||||
|
},
|
||||||
PluginsMaxCount: DEFAULT_PLUGINS_MAX_COUNT,
|
PluginsMaxCount: DEFAULT_PLUGINS_MAX_COUNT,
|
||||||
ProfilesMaxCount: DEFAULT_PROFILES_MAX_COUNT,
|
ProfilesMaxCount: DEFAULT_PROFILES_MAX_COUNT,
|
||||||
Timeout: DEFAULT_TIMEOUT_IN_SECS,
|
Timeout: DEFAULT_TIMEOUT_IN_SECS,
|
||||||
|
|
@ -117,12 +121,8 @@ func (s *Service) Serve() error {
|
||||||
|
|
||||||
// always available public routes go here
|
// always available public routes go here
|
||||||
router.HandleFunc("/status", s.GetStatus)
|
router.HandleFunc("/status", s.GetStatus)
|
||||||
if s.CACertFile != "" && s.CACertKeyfile != "" {
|
|
||||||
return http.ListenAndServeTLS(s.Addr, s.CACertFile, s.CACertKeyfile, router)
|
|
||||||
} else {
|
|
||||||
return http.ListenAndServe(s.Addr, router)
|
return http.ListenAndServe(s.Addr, router)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) requireAuth() bool {
|
func (s *Service) requireAuth() bool {
|
||||||
return false
|
return false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue