func DescribeDeployment(remote config.Remote, id string) (prettycli.Output, error) { c := DefaultAgentClientFactory.New(remote) desc, err := c.DescribeDeployment(id) if err != nil { return prettycli.PlainOutput{}, err } do := prettycli.DetailOutput{ Details: map[string]string{ "Name": desc.Name, "ID": strconv.Itoa(desc.ID), "Redeployable": strconv.FormatBool(desc.Redeployable), }, Order: []string{"ID", "Name", "Redeployable"}, } lo := prettycli.ListOutput{Labels: []string{"ID", "State"}} for _, s := range desc.Status.Services { lo.AddRow(map[string]string{ "ID": s.ID, "State": s.ActualState, }) } co := prettycli.CombinedOutput{} co.AddOutput("", do) co.AddOutput("Services", lo) return &co, nil }
func DescribeRemote(c config.Config, name string) (prettycli.Output, error) { r, err := c.Get(name) if err != nil { return prettycli.PlainOutput{}, err } isActive := "false" if c.Active() != nil && c.Active().Name == r.Name { isActive = "true" } client := DefaultAgentClientFactory.New(r) metadata, err := client.GetMetadata() if err != nil { return prettycli.PlainOutput{}, err } adapterMetadataBytes, err := json.Marshal(metadata.Adapter) if err != nil { return prettycli.PlainOutput{}, err } adapterMetadata := struct { Version string Type string IsHealthy bool }{} if err := json.Unmarshal(adapterMetadataBytes, &adapterMetadata); err != nil { return prettycli.PlainOutput{}, err } do := prettycli.DetailOutput{ Details: map[string]string{ "Name": r.Name, "Active": isActive, "Endpoint": r.Endpoint, "Agent Version": metadata.Agent.Version, "Adapter Version": adapterMetadata.Version, "Adapter Type": adapterMetadata.Type, "Adapter Is Healthy": strconv.FormatBool(adapterMetadata.IsHealthy), }, Order: []string{"Name", "Active", "Endpoint"}, } lo, err := ListDeployments(r) if err != nil { return prettycli.PlainOutput{}, err } co := prettycli.CombinedOutput{} co.AddOutput("", do) co.AddOutput("Deployments", lo) return &co, nil }