2022-03-22 13:17:50 -06:00
|
|
|
package cli
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/spf13/cobra"
|
2022-04-11 18:54:30 -05:00
|
|
|
"golang.org/x/xerrors"
|
|
|
|
|
|
|
|
|
|
"github.com/coder/coder/cli/cliui"
|
2022-03-22 13:17:50 -06:00
|
|
|
)
|
|
|
|
|
|
2022-05-02 11:08:52 -05:00
|
|
|
func show() *cobra.Command {
|
2022-03-22 13:17:50 -06:00
|
|
|
return &cobra.Command{
|
2022-05-09 17:42:02 -05:00
|
|
|
Annotations: workspaceCommand,
|
2022-07-25 16:56:20 +03:00
|
|
|
Use: "show <workspace>",
|
2022-09-19 11:36:18 -05:00
|
|
|
Short: "Display details of a workspace's resources and agents",
|
2022-05-09 17:42:02 -05:00
|
|
|
Args: cobra.ExactArgs(1),
|
2022-03-22 13:17:50 -06:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2022-08-23 13:55:39 -07:00
|
|
|
client, err := CreateClient(cmd)
|
2022-04-11 18:54:30 -05:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
2022-08-31 16:33:50 +01:00
|
|
|
buildInfo, err := client.BuildInfo(cmd.Context())
|
|
|
|
|
if err != nil {
|
|
|
|
|
return xerrors.Errorf("get server version: %w", err)
|
|
|
|
|
}
|
2022-06-03 14:36:08 -05:00
|
|
|
workspace, err := namedWorkspace(cmd, client, args[0])
|
2022-04-11 18:54:30 -05:00
|
|
|
if err != nil {
|
|
|
|
|
return xerrors.Errorf("get workspace: %w", err)
|
|
|
|
|
}
|
2022-10-03 17:01:13 -04:00
|
|
|
return cliui.WorkspaceResources(cmd.OutOrStdout(), workspace.LatestBuild.Resources, cliui.WorkspaceResourcesOptions{
|
2022-04-11 18:54:30 -05:00
|
|
|
WorkspaceName: workspace.Name,
|
2022-08-31 16:33:50 +01:00
|
|
|
ServerVersion: buildInfo.Version,
|
2022-04-11 18:54:30 -05:00
|
|
|
})
|
2022-03-22 13:17:50 -06:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|