mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-15 09:01:31 +00:00
refactor: move base zone bootstrap to DNS domain
This commit is contained in:
@@ -852,7 +852,7 @@ var northstarStartCmd = &cobra.Command{
|
||||
baseDirOverride: viper.GetString("base-dir"),
|
||||
}, northstarStartDependencies{
|
||||
loadConfig: loadRequiredClusterConfig,
|
||||
bootstrapBaseZone: northstar.BootstrapBaseZone,
|
||||
bootstrapBaseZone: dns.BootstrapBaseZone,
|
||||
newService: func(cfg *northstar.Config) (northstarStarter, error) {
|
||||
return service.New("northstar", cfg)
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package northstar
|
||||
package dns
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
|
||||
nsconfig "github.com/mulgadc/northstar/pkg/config"
|
||||
"github.com/mulgadc/spinifex/spinifex/bootstrap/config"
|
||||
"github.com/mulgadc/spinifex/spinifex/domains/dns"
|
||||
)
|
||||
|
||||
// baseZoneTXT is the marker TXT record seeded at the apex of the base zone.
|
||||
@@ -77,7 +76,7 @@ func BootstrapBaseZone(configPath string, cluster *config.ClusterConfig) error {
|
||||
SecretKey: sysCreds.SecretKey,
|
||||
}
|
||||
|
||||
nameservers := dns.NameserverSeeds(cluster)
|
||||
nameservers := NameserverSeeds(cluster)
|
||||
slog.Info("northstar bootstrap: ensuring base zone",
|
||||
"domain", domain, "nameservers", len(nameservers), "multi_node", len(nameservers) > 1)
|
||||
|
||||
+1
-40
@@ -1,4 +1,4 @@
|
||||
package northstar
|
||||
package dns
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
@@ -20,44 +19,6 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// fakeS3 is a minimal mutable path-style S3 endpoint (HEAD/PUT/GET) for the
|
||||
// bootstrap happy-path test.
|
||||
func fakeS3(t *testing.T, bucket string) (endpoint string, objects map[string]string) {
|
||||
t.Helper()
|
||||
var mu sync.Mutex
|
||||
objects = map[string]string{}
|
||||
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
key := strings.TrimPrefix(r.URL.Path, "/"+bucket+"/")
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
switch r.Method {
|
||||
case http.MethodHead:
|
||||
if _, ok := objects[key]; ok {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
} else {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
}
|
||||
case http.MethodPut:
|
||||
body, _ := io.ReadAll(r.Body)
|
||||
objects[key] = string(body)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
case http.MethodGet:
|
||||
body, ok := objects[key]
|
||||
if !ok {
|
||||
http.Error(w, "not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Length", strconv.Itoa(len(body)))
|
||||
_, _ = w.Write([]byte(body))
|
||||
default:
|
||||
http.Error(w, "unsupported", http.StatusMethodNotAllowed)
|
||||
}
|
||||
}))
|
||||
t.Cleanup(srv.Close)
|
||||
return srv.URL, objects
|
||||
}
|
||||
|
||||
func TestBootstrapBaseZone(t *testing.T) {
|
||||
endpoint, objects := fakeS3(t, "northstar")
|
||||
|
||||
Reference in New Issue
Block a user