mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
chore: include all templates in cli template list (#13841)
* chore: cli template list includes all templates Shows all accessible templates from all organizations
This commit is contained in:
@ -11,7 +11,6 @@ import (
|
||||
)
|
||||
|
||||
func (r *RootCmd) templateList() *serpent.Command {
|
||||
orgContext := NewOrganizationContext()
|
||||
formatter := cliui.NewOutputFormatter(
|
||||
cliui.TableFormat([]templateTableRow{}, []string{"name", "organization name", "last updated", "used by"}),
|
||||
cliui.JSONFormat(),
|
||||
@ -26,17 +25,13 @@ func (r *RootCmd) templateList() *serpent.Command {
|
||||
r.InitClient(client),
|
||||
),
|
||||
Handler: func(inv *serpent.Invocation) error {
|
||||
organization, err := orgContext.Selected(inv, client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
templates, err := client.TemplatesByOrganization(inv.Context(), organization.ID)
|
||||
templates, err := client.Templates(inv.Context(), codersdk.TemplateFilter{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(templates) == 0 {
|
||||
_, _ = fmt.Fprintf(inv.Stderr, "%s No templates found in %s! Create one:\n\n", Caret, color.HiWhiteString(organization.Name))
|
||||
_, _ = fmt.Fprintf(inv.Stderr, "%s No templates found! Create one:\n\n", Caret)
|
||||
_, _ = fmt.Fprintln(inv.Stderr, color.HiMagentaString(" $ coder templates push <directory>\n"))
|
||||
return nil
|
||||
}
|
||||
@ -53,6 +48,5 @@ func (r *RootCmd) templateList() *serpent.Command {
|
||||
}
|
||||
|
||||
formatter.AttachOptions(&cmd.Options)
|
||||
orgContext.AttachOptions(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
Reference in New Issue
Block a user