feat(cmd): Create target using address on boundary dev / database init

Creates a target using an address for boundary dev and when first
init-ing boundary (boundary database init).

It also makes this newly created target the default one
(ttcp_1234567890). The target using host sources is now a secondary
target (ttcp_0987654321).
This commit is contained in:
Hugo Vieira committed 2023-01-09 15:39:55 +00:00
1 parent 1d3930a711
commit f85da3ee2b
9 files changed
+236 -90

No files matched your search

+27 -11
View File
@@ -426,26 +426,42 @@ func (c *InitCommand) Run(args []string) (retCode int) {
}
c.DevTargetSessionConnectionLimit = -1
t, err := c.CreateInitialTarget(c.Context)
ta, err := c.CreateInitialTargetWithAddress(c.Context)
if err != nil {
c.UI.Error(fmt.Errorf("Error creating initial target: %w", err).Error())
return base.CommandCliError
}
taInfo := &TargetInfo{
TargetId: ta.GetPublicId(),
DefaultPort: ta.GetDefaultPort(),
SessionMaxSeconds: ta.GetSessionMaxSeconds(),
SessionConnectionLimit: ta.GetSessionConnectionLimit(),
Type: string(ta.GetType()),
ScopeId: ta.GetProjectId(),
Name: ta.GetName(),
}
targetInfo := &TargetInfo{
TargetId: c.DevTargetId,
DefaultPort: t.GetDefaultPort(),
SessionMaxSeconds: t.GetSessionMaxSeconds(),
SessionConnectionLimit: t.GetSessionConnectionLimit(),
Type: "tcp",
ScopeId: c.DevProjectId,
Name: t.GetName(),
ths, err := c.CreateInitialTargetWithHostSources(c.Context)
if err != nil {
c.UI.Error(fmt.Errorf("Error creating initial secondary target: %w", err).Error())
return base.CommandCliError
}
thsInfo := &TargetInfo{
TargetId: ths.GetPublicId(),
DefaultPort: ths.GetDefaultPort(),
SessionMaxSeconds: ths.GetSessionMaxSeconds(),
SessionConnectionLimit: ths.GetSessionConnectionLimit(),
Type: string(ths.GetType()),
ScopeId: ths.GetProjectId(),
Name: ths.GetName(),
}
switch base.Format(c.UI) {
case "table":
c.UI.Output(generateInitialTargetTableOutput(targetInfo))
c.UI.Output(generateInitialTargetTableOutput(taInfo))
c.UI.Output(generateInitialTargetTableOutput(thsInfo))
case "json":
jsonMap["target"] = targetInfo
jsonMap["target"] = taInfo
jsonMap["target_secondary"] = thsInfo
}
return base.CommandSuccess