mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
init corrosion admin client in machine
This commit is contained in:
@@ -44,6 +44,7 @@ type Config struct {
|
|||||||
CorrosionDir string
|
CorrosionDir string
|
||||||
CorrosionAPIListenAddr netip.AddrPort
|
CorrosionAPIListenAddr netip.AddrPort
|
||||||
CorrosionAPIAddr netip.AddrPort
|
CorrosionAPIAddr netip.AddrPort
|
||||||
|
CorrosionAdminSockPath string
|
||||||
CorrosionService corroservice.Service
|
CorrosionService corroservice.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,6 +73,9 @@ func (c *Config) SetDefaults() *Config {
|
|||||||
cfg.CorrosionAPIAddr = netip.AddrPortFrom(
|
cfg.CorrosionAPIAddr = netip.AddrPortFrom(
|
||||||
netip.AddrFrom4([4]byte{127, 0, 0, 1}), corroservice.DefaultAPIPort)
|
netip.AddrFrom4([4]byte{127, 0, 0, 1}), corroservice.DefaultAPIPort)
|
||||||
}
|
}
|
||||||
|
if cfg.CorrosionAdminSockPath == "" {
|
||||||
|
cfg.CorrosionAdminSockPath = filepath.Join(cfg.CorrosionDir, "admin.sock")
|
||||||
|
}
|
||||||
if cfg.CorrosionService == nil {
|
if cfg.CorrosionService == nil {
|
||||||
cfg.CorrosionService = corroservice.DefaultSystemdService(cfg.CorrosionDir)
|
cfg.CorrosionService = corroservice.DefaultSystemdService(cfg.CorrosionDir)
|
||||||
}
|
}
|
||||||
@@ -138,7 +142,11 @@ func NewMachine(config *Config) (*Machine, error) {
|
|||||||
return nil, fmt.Errorf("create corrosion API client: %w", err)
|
return nil, fmt.Errorf("create corrosion API client: %w", err)
|
||||||
}
|
}
|
||||||
corroStore := store.New(corro)
|
corroStore := store.New(corro)
|
||||||
c := cluster.NewCluster(corroStore)
|
corroAdmin, err := corrosion.NewAdminClient(config.CorrosionAdminSockPath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("create corrosion admin client: %w", err)
|
||||||
|
}
|
||||||
|
c := cluster.NewCluster(corroStore, corroAdmin)
|
||||||
|
|
||||||
// Init a gRPC Docker server that proxies requests to the local Docker daemon.
|
// Init a gRPC Docker server that proxies requests to the local Docker daemon.
|
||||||
dockerCli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
|
dockerCli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
|
||||||
|
|||||||
Reference in New Issue
Block a user