resolver: Use self-built image
This commit updates the resolver component to use an image that is built locally.
This commit is contained in:
parent
dceff860e4
commit
2881a5f65c
71 changed files with 195 additions and 111 deletions
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
|
||||
"github.com/FAU-CDI/wisski-distillery/core"
|
||||
"github.com/FAU-CDI/wisski-distillery/distillery"
|
||||
"github.com/FAU-CDI/wisski-distillery/embed"
|
||||
cfg "github.com/FAU-CDI/wisski-distillery/internal/config"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/fsx"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/hostname"
|
||||
|
|
@ -123,7 +123,7 @@ func (bs bootstrap) Run(context wisski_distillery.Context) error {
|
|||
return errBootstrapWriteConfig.WithMessageF(err)
|
||||
}
|
||||
|
||||
if err := distillery.InstallTemplate(envPath, filepath.Join("resources", "templates", "bootstrap", "env"), map[string]string{
|
||||
if err := embed.InstallTemplate(envPath, filepath.Join("resources", "templates", "bootstrap", "env"), map[string]string{
|
||||
"DEPLOY_ROOT": root,
|
||||
"DEFAULT_DOMAIN": domain,
|
||||
"SELF_OVERRIDES_FILE": overridesPath,
|
||||
|
|
@ -146,12 +146,12 @@ func (bs bootstrap) Run(context wisski_distillery.Context) error {
|
|||
if err := logging.LogOperation(func() error {
|
||||
|
||||
context.Println(overridesPath)
|
||||
if err := distillery.InstallTemplate(overridesPath, filepath.Join("resources", "templates", "bootstrap", "overrides.json"), map[string]string{}); err != nil {
|
||||
if err := embed.InstallTemplate(overridesPath, filepath.Join("resources", "templates", "bootstrap", "overrides.json"), map[string]string{}); err != nil {
|
||||
return errBootstrapCreateFile.WithMessageF(err)
|
||||
}
|
||||
|
||||
context.Println(authorizedKeysFile)
|
||||
if err := distillery.InstallTemplate(authorizedKeysFile, filepath.Join("resources", "templates", "bootstrap", "global_authorized_keys"), map[string]string{}); err != nil {
|
||||
if err := embed.InstallTemplate(authorizedKeysFile, filepath.Join("resources", "templates", "bootstrap", "global_authorized_keys"), map[string]string{}); err != nil {
|
||||
return errBootstrapCreateFile.WithMessageF(err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
|
||||
"github.com/FAU-CDI/wisski-distillery/core"
|
||||
"github.com/tkw1536/goprogram/exit"
|
||||
)
|
||||
|
||||
// DisServer is the 'dis_server' command
|
||||
var DisServer wisski_distillery.Command = disServer{}
|
||||
|
||||
type disServer struct {
|
||||
Prefix string `short:"p" long:"prefix" description:"prefix to listen under"`
|
||||
Bind string `short:"b" long:"bind" description:"address to listen on" default:"127.0.0.1:8888"`
|
||||
}
|
||||
|
||||
func (disServer) Description() wisski_distillery.Description {
|
||||
return wisski_distillery.Description{
|
||||
Requirements: core.Requirements{
|
||||
NeedsDistillery: true,
|
||||
},
|
||||
Command: "dis_server",
|
||||
Description: "Starts a server with information about this distillery",
|
||||
}
|
||||
}
|
||||
|
||||
var errServerListen = exit.Error{
|
||||
ExitCode: exit.ExitGeneric,
|
||||
Message: "Unable to listen",
|
||||
}
|
||||
|
||||
func (s disServer) Run(context wisski_distillery.Context) error {
|
||||
server := context.Environment.Server()
|
||||
|
||||
context.Printf("Listening on %s\n", s.Bind)
|
||||
err := http.ListenAndServe(s.Bind, http.StripPrefix(s.Prefix, server))
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
return errServerListen.Wrap(err)
|
||||
}
|
||||
68
cmd/servers.go
Normal file
68
cmd/servers.go
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
|
||||
"github.com/FAU-CDI/wisski-distillery/core"
|
||||
"github.com/tkw1536/goprogram/exit"
|
||||
)
|
||||
|
||||
// ResolverServer is the 'resolver_server' command
|
||||
var ResolverServer wisski_distillery.Command = server{
|
||||
Desc: wisski_distillery.Description{
|
||||
Requirements: core.Requirements{
|
||||
NeedsDistillery: true,
|
||||
},
|
||||
Command: "resolver_server",
|
||||
Description: "Starts a global resolver server",
|
||||
},
|
||||
Server: func(context wisski_distillery.Context) (http.Handler, error) {
|
||||
return context.Environment.Resolver().Server(context.IOStream)
|
||||
},
|
||||
}
|
||||
|
||||
// DisServer is the 'dis_server' command
|
||||
var DisServer wisski_distillery.Command = server{
|
||||
Desc: wisski_distillery.Description{
|
||||
Requirements: core.Requirements{
|
||||
NeedsDistillery: true,
|
||||
},
|
||||
Command: "dis_server",
|
||||
Description: "Starts a server with information about this distillery",
|
||||
},
|
||||
Server: func(context wisski_distillery.Context) (http.Handler, error) {
|
||||
return context.Environment.Server(), nil
|
||||
},
|
||||
}
|
||||
|
||||
type server struct {
|
||||
Prefix string `short:"p" long:"prefix" description:"prefix to listen under"`
|
||||
Bind string `short:"b" long:"bind" description:"address to listen on" default:"127.0.0.1:8888"`
|
||||
|
||||
Desc wisski_distillery.Description
|
||||
Server func(context wisski_distillery.Context) (http.Handler, error)
|
||||
}
|
||||
|
||||
func (s server) Description() wisski_distillery.Description {
|
||||
return s.Desc
|
||||
}
|
||||
|
||||
var errServerListen = exit.Error{
|
||||
ExitCode: exit.ExitGeneric,
|
||||
Message: "Unable to listen",
|
||||
}
|
||||
|
||||
func (s server) Run(context wisski_distillery.Context) error {
|
||||
handler, err := s.Server(context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
context.Printf("Listening on %s\n", s.Bind)
|
||||
err = http.ListenAndServe(s.Bind, http.StripPrefix(s.Prefix, handler))
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
return errServerListen.Wrap(err)
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
wisski_distillery "github.com/FAU-CDI/wisski-distillery"
|
||||
"github.com/FAU-CDI/wisski-distillery/core"
|
||||
"github.com/FAU-CDI/wisski-distillery/distillery"
|
||||
"github.com/FAU-CDI/wisski-distillery/embed"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/execx"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/logging"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/stack"
|
||||
|
|
@ -143,7 +143,7 @@ func (si systemupdate) Run(context wisski_distillery.Context) error {
|
|||
}
|
||||
|
||||
if err := logging.LogOperation(func() error {
|
||||
return distillery.InstallResource(dis.RuntimeDir(), filepath.Join("resources", "runtime"), func(dst, src string) {
|
||||
return embed.InstallResource(dis.RuntimeDir(), filepath.Join("resources", "runtime"), func(dst, src string) {
|
||||
context.Printf("[copy] %s\n", dst)
|
||||
})
|
||||
}, context.IOStream, "Unpacking Runtime Components"); err != nil {
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ func init() {
|
|||
|
||||
// servers
|
||||
wdcli.Register(cmd.DisServer)
|
||||
wdcli.Register(cmd.ResolverServer)
|
||||
}
|
||||
|
||||
// an error when no arguments are provided.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue