Add network get-config command

This commit is contained in:
Brian Picciano 2024-11-12 18:18:47 +01:00
parent 6809445832
commit 070524f686
3 changed files with 15 additions and 10 deletions

View File

@ -106,6 +106,19 @@ var subCmdNetworkList = subCmd{
}), }),
} }
var subCmdNetworkGetConfig = subCmd{
name: "get-config",
descr: "Displays the currently active configuration for a joined network",
do: doWithOutput(func(ctx subCmdCtx) (any, error) {
ctx, err := ctx.withParsedFlags()
if err != nil {
return nil, fmt.Errorf("parsing flags: %w", err)
}
return newDaemonRPCClient().GetConfig(ctx)
}),
}
var subCmdNetwork = subCmd{ var subCmdNetwork = subCmd{
name: "network", name: "network",
descr: "Sub-commands related to network membership", descr: "Sub-commands related to network membership",
@ -115,6 +128,7 @@ var subCmdNetwork = subCmd{
subCmdNetworkCreate, subCmdNetworkCreate,
subCmdNetworkJoin, subCmdNetworkJoin,
subCmdNetworkList, subCmdNetworkList,
subCmdNetworkGetConfig,
) )
}, },
} }

View File

@ -55,10 +55,6 @@ type ConfigStorageAllocation struct {
S3APIPort int `yaml:"s3_api_port"` S3APIPort int `yaml:"s3_api_port"`
RPCPort int `yaml:"rpc_port"` RPCPort int `yaml:"rpc_port"`
AdminPort int `yaml:"admin_port"` AdminPort int `yaml:"admin_port"`
// Zone is a secret option which makes it easier to test garage bugs, but
// which we don't want users to otherwise know about.
Zone string `yaml:"zone"`
} }
// Annotate implements the mctx.Annotator interface. // Annotate implements the mctx.Annotator interface.

View File

@ -103,15 +103,10 @@ func garageApplyLayout(
id := daecommon.BootstrapGarageHostForAlloc(currHost, alloc).ID id := daecommon.BootstrapGarageHostForAlloc(currHost, alloc).ID
roleIDs[id] = struct{}{} roleIDs[id] = struct{}{}
zone := string(hostName)
if alloc.Zone != "" {
zone = alloc.Zone
}
roles[i] = garage.Role{ roles[i] = garage.Role{
ID: id, ID: id,
Capacity: alloc.Capacity * 1_000_000_000, Capacity: alloc.Capacity * 1_000_000_000,
Zone: zone, Zone: string(hostName),
Tags: []string{}, Tags: []string{},
} }
} }