Add names to init output (#428)
This commit is contained in:
1 parent
7fcbffbe88
commit
41a3c66ea1
5 files changed
+121
-95
No files matched your search
@@ -7,20 +7,24 @@ import (
|
||||
)
|
||||
|
||||
type AuthMethodInfo struct {
|
||||
AuthMethodId string `json:"auth_method_id"`
|
||||
LoginName string `json:"login_name"`
|
||||
Password string `json:"password"`
|
||||
ScopeId string `json:"scope_id"`
|
||||
UserId string `json:"user_id"`
|
||||
AuthMethodId string `json:"auth_method_id"`
|
||||
AuthMethodName string `json:"auth_method_name"`
|
||||
LoginName string `json:"login_name"`
|
||||
Password string `json:"password"`
|
||||
ScopeId string `json:"scope_id"`
|
||||
UserId string `json:"user_id"`
|
||||
UserName string `json:"user_name"`
|
||||
}
|
||||
|
||||
func generateInitialAuthMethodTableOutput(in *AuthMethodInfo) string {
|
||||
nonAttributeMap := map[string]interface{}{
|
||||
"Scope ID": in.ScopeId,
|
||||
"Auth Method ID": in.AuthMethodId,
|
||||
"Login Name": in.LoginName,
|
||||
"Password": in.Password,
|
||||
"User ID": in.UserId,
|
||||
"Scope ID": in.ScopeId,
|
||||
"Auth Method ID": in.AuthMethodId,
|
||||
"Auth Method Name": in.AuthMethodName,
|
||||
"Login Name": in.LoginName,
|
||||
"Password": in.Password,
|
||||
"User ID": in.UserId,
|
||||
"User Name": in.UserName,
|
||||
}
|
||||
|
||||
maxLength := 0
|
||||
@@ -42,12 +46,14 @@ func generateInitialAuthMethodTableOutput(in *AuthMethodInfo) string {
|
||||
type ScopeInfo struct {
|
||||
ScopeId string `json:"scope_id"`
|
||||
Type string `json:"type"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func generateInitialScopeTableOutput(in *ScopeInfo) string {
|
||||
nonAttributeMap := map[string]interface{}{
|
||||
"Scope ID": in.ScopeId,
|
||||
"Type": in.Type,
|
||||
"Name": in.Name,
|
||||
}
|
||||
|
||||
maxLength := 0
|
||||
@@ -67,20 +73,26 @@ func generateInitialScopeTableOutput(in *ScopeInfo) string {
|
||||
}
|
||||
|
||||
type HostInfo struct {
|
||||
HostCatalogId string `json:"host_catalog_id"`
|
||||
HostSetId string `json:"host_set_id"`
|
||||
HostId string `json:"host_id"`
|
||||
Type string `json:"type"`
|
||||
ScopeId string `json:"scope_id"`
|
||||
HostCatalogId string `json:"host_catalog_id"`
|
||||
HostSetId string `json:"host_set_id"`
|
||||
HostId string `json:"host_id"`
|
||||
Type string `json:"type"`
|
||||
ScopeId string `json:"scope_id"`
|
||||
HostCatalogName string `json:"host_catalog_name"`
|
||||
HostSetName string `json:"host_set_name"`
|
||||
HostName string `json:"host_name"`
|
||||
}
|
||||
|
||||
func generateInitialHostResourcesTableOutput(in *HostInfo) string {
|
||||
nonAttributeMap := map[string]interface{}{
|
||||
"Host Catalog ID": in.HostCatalogId,
|
||||
"Host Set ID": in.HostSetId,
|
||||
"Host ID": in.HostId,
|
||||
"Type": in.Type,
|
||||
"Scope ID": in.ScopeId,
|
||||
"Host Catalog ID": in.HostCatalogId,
|
||||
"Host Catalog Name": in.HostCatalogName,
|
||||
"Host Set ID": in.HostSetId,
|
||||
"Host Set Name": in.HostSetName,
|
||||
"Host ID": in.HostId,
|
||||
"Host Name": in.HostName,
|
||||
"Type": in.Type,
|
||||
"Scope ID": in.ScopeId,
|
||||
}
|
||||
|
||||
maxLength := 0
|
||||
@@ -106,6 +118,7 @@ type TargetInfo struct {
|
||||
SessionConnectionLimit int32 `json:"session_connection_limit"`
|
||||
Type string `json:"type"`
|
||||
ScopeId string `json:"scope_id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func generateInitialTargetTableOutput(in *TargetInfo) string {
|
||||
@@ -116,6 +129,7 @@ func generateInitialTargetTableOutput(in *TargetInfo) string {
|
||||
"Session Connection Limit": in.SessionConnectionLimit,
|
||||
"Type": in.Type,
|
||||
"Scope ID": in.ScopeId,
|
||||
"Name": in.Name,
|
||||
}
|
||||
|
||||
maxLength := 0
|
||||
|
||||
@@ -303,17 +303,20 @@ func (c *InitCommand) Run(args []string) (retCode int) {
|
||||
|
||||
// Use an easy name, at least
|
||||
c.srv.DevLoginName = "admin"
|
||||
if err := c.srv.CreateInitialAuthMethod(c.Context); err != nil {
|
||||
am, user, err := c.srv.CreateInitialAuthMethod(c.Context)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error creating initial auth method and user: %w", err).Error())
|
||||
return 1
|
||||
}
|
||||
|
||||
authMethodInfo := &AuthMethodInfo{
|
||||
AuthMethodId: c.srv.DevAuthMethodId,
|
||||
LoginName: c.srv.DevLoginName,
|
||||
Password: c.srv.DevPassword,
|
||||
ScopeId: scope.Global.String(),
|
||||
UserId: c.srv.DevUserId,
|
||||
AuthMethodId: c.srv.DevAuthMethodId,
|
||||
AuthMethodName: am.Name,
|
||||
LoginName: c.srv.DevLoginName,
|
||||
Password: c.srv.DevPassword,
|
||||
ScopeId: scope.Global.String(),
|
||||
UserId: c.srv.DevUserId,
|
||||
UserName: user.Name,
|
||||
}
|
||||
switch base.Format(c.UI) {
|
||||
case "table":
|
||||
@@ -326,7 +329,8 @@ func (c *InitCommand) Run(args []string) (retCode int) {
|
||||
return 0
|
||||
}
|
||||
|
||||
if err := c.srv.CreateInitialScopes(c.Context); err != nil {
|
||||
orgScope, projScope, err := c.srv.CreateInitialScopes(c.Context)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error creating initial scopes: %w", err).Error())
|
||||
return 1
|
||||
}
|
||||
@@ -334,6 +338,7 @@ func (c *InitCommand) Run(args []string) (retCode int) {
|
||||
orgScopeInfo := &ScopeInfo{
|
||||
ScopeId: c.srv.DevOrgId,
|
||||
Type: scope.Org.String(),
|
||||
Name: orgScope.Name,
|
||||
}
|
||||
switch base.Format(c.UI) {
|
||||
case "table":
|
||||
@@ -345,6 +350,7 @@ func (c *InitCommand) Run(args []string) (retCode int) {
|
||||
projScopeInfo := &ScopeInfo{
|
||||
ScopeId: c.srv.DevProjectId,
|
||||
Type: scope.Project.String(),
|
||||
Name: projScope.Name,
|
||||
}
|
||||
switch base.Format(c.UI) {
|
||||
case "table":
|
||||
@@ -357,17 +363,21 @@ func (c *InitCommand) Run(args []string) (retCode int) {
|
||||
return 0
|
||||
}
|
||||
|
||||
if err := c.srv.CreateInitialHostResources(c.Context); err != nil {
|
||||
hc, hs, h, err := c.srv.CreateInitialHostResources(c.Context)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Errorf("Error creating initial host resources: %w", err).Error())
|
||||
return 1
|
||||
}
|
||||
|
||||
hostInfo := &HostInfo{
|
||||
HostCatalogId: c.srv.DevHostCatalogId,
|
||||
HostSetId: c.srv.DevHostSetId,
|
||||
HostId: c.srv.DevHostId,
|
||||
Type: "static",
|
||||
ScopeId: c.srv.DevProjectId,
|
||||
HostCatalogId: c.srv.DevHostCatalogId,
|
||||
HostCatalogName: hc.GetName(),
|
||||
HostSetId: c.srv.DevHostSetId,
|
||||
HostSetName: hs.GetName(),
|
||||
HostId: c.srv.DevHostId,
|
||||
HostName: h.GetName(),
|
||||
Type: "static",
|
||||
ScopeId: c.srv.DevProjectId,
|
||||
}
|
||||
switch base.Format(c.UI) {
|
||||
case "table":
|
||||
@@ -393,6 +403,7 @@ func (c *InitCommand) Run(args []string) (retCode int) {
|
||||
SessionConnectionLimit: t.GetSessionConnectionLimit(),
|
||||
Type: "tcp",
|
||||
ScopeId: c.srv.DevProjectId,
|
||||
Name: t.GetName(),
|
||||
}
|
||||
switch base.Format(c.UI) {
|
||||
case "table":
|
||||
|
||||
Reference in new issue
Block a user