feat: import Sea vHost single-server testing release
This commit is contained in:
commit
248badd33e
441 files changed
+63221
No files matched your search
@@ -0,0 +1,43 @@
|
||||
package isolation
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sea-vhost/internal/schedulerbridge"
|
||||
)
|
||||
|
||||
type SchedulerBridge interface {
|
||||
ConfigureSchedulerBridge(context.Context, schedulerbridge.Config) error
|
||||
}
|
||||
|
||||
func (c *Client) ConfigureSchedulerBridge(ctx context.Context, v schedulerbridge.Config) error {
|
||||
return c.request(ctx, "/v1/scheduler/configure", v, nil)
|
||||
}
|
||||
func (Mock) ConfigureSchedulerBridge(context.Context, schedulerbridge.Config) error { return nil }
|
||||
func (a Agent) configureSchedulerBridge(w http.ResponseWriter, r *http.Request) {
|
||||
var v schedulerbridge.Config
|
||||
d := json.NewDecoder(r.Body)
|
||||
d.DisallowUnknownFields()
|
||||
if d.Decode(&v) != nil || d.Decode(&struct{}{}) != io.EOF || v.Validate() != nil {
|
||||
http.Error(w, "invalid scheduler identity", 400)
|
||||
return
|
||||
}
|
||||
if e := ensurePhysicalDirectory(filepath.Dir(schedulerbridge.ConfigPath), 0700); e != nil {
|
||||
http.Error(w, "scheduler directory unavailable", 422)
|
||||
return
|
||||
}
|
||||
raw, _ := json.Marshal(v)
|
||||
if e := writePrivateFile(schedulerbridge.ConfigPath, raw); e != nil {
|
||||
http.Error(w, "cannot save scheduler identity", 422)
|
||||
return
|
||||
}
|
||||
if e := os.Chmod(schedulerbridge.ConfigPath, 0600); e != nil {
|
||||
http.Error(w, "cannot secure scheduler identity", 422)
|
||||
return
|
||||
}
|
||||
w.WriteHeader(200)
|
||||
}
|
||||
Reference in new issue
Block a user