- Notifications
You must be signed in to change notification settings - Fork1k
feat: Implement parameters list + more template list columns#2359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
- Allow more columns on template list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
someone with more Go experience should review but 👍 from the FE. BTW, if you mergemain
in again, that chromatic CI check should clear up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This looks really useful!
"github.com/google/uuid" | ||
"golang.org/x/xerrors" | ||
"github.com/spf13/cobra" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
nit: imports
funcdisplayParameters(filterColumns []string,params...codersdk.Parameter)string { | ||
tableWriter:=cliui.Table() | ||
header:= table.Row{"id","scope","scope id","name","source scheme","destination scheme","created at","updated at"} | ||
tableWriter.AppendHeader(header) | ||
tableWriter.SetColumnConfigs(cliui.FilterTableColumns(header,filterColumns)) | ||
tableWriter.SortBy([]table.SortBy{{ | ||
Name:"name", | ||
}}) | ||
for_,param:=rangeparams { | ||
tableWriter.AppendRow(table.Row{ | ||
param.ID.String(), | ||
param.Scope, | ||
param.ScopeID.String(), | ||
param.Name, | ||
param.SourceScheme, | ||
param.DestinationScheme, | ||
param.CreatedAt, | ||
param.UpdatedAt, | ||
}) | ||
} | ||
returntableWriter.Render() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I like this approach of abstracting the presentation logic from the command logic; makes it more re-usable later.
funcdisplayTemplates(filterColumns []string,templates...codersdk.Template)string { | ||
tableWriter:=cliui.Table() | ||
header:= table.Row{ | ||
"Name","Created At","Last Updated","Organization ID","Provisioner", | ||
"Active Version ID","Used By","Max TTL","Min Autostart"} | ||
tableWriter.AppendHeader(header) | ||
tableWriter.SetColumnConfigs(cliui.FilterTableColumns(header,filterColumns)) | ||
tableWriter.SortBy([]table.SortBy{{ | ||
Name:"name", | ||
}}) | ||
for_,template:=rangetemplates { | ||
suffix:="" | ||
iftemplate.WorkspaceOwnerCount!=1 { | ||
suffix="s" | ||
} | ||
tableWriter.AppendRow(table.Row{ | ||
template.Name, | ||
template.CreatedAt.Format("January 2, 2006"), | ||
template.UpdatedAt.Format("January 2, 2006"), | ||
template.OrganizationID.String(), | ||
template.Provisioner, | ||
template.ActiveVersionID.String(), | ||
cliui.Styles.Fuschia.Render(fmt.Sprintf("%d developer%s",template.WorkspaceOwnerCount,suffix)), | ||
(time.Duration(template.MaxTTLMillis)*time.Millisecond).String(), | ||
(time.Duration(template.MinAutostartIntervalMillis)*time.Millisecond).String(), | ||
}) | ||
} | ||
returntableWriter.Render() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
👍
Uh oh!
There was an error while loading.Please reload this page.
I am using this for debugging, figured I'd throw it in a quick branch.
What this does
Adds a way to list parameter values for a scope. Really helpful for debugging the param things I am messing with.I hide the cmd by default right now, as it lists theparameter_values, notparameter_schemes.. I think the cli should somehow distinguish the two, but don't know at the moment.
No actual values are returned from the cli, just the name + meta data.
I also added more columns templates list if they specify the columns. I needed this for debugging too.
Param list (hidden by default)
Template columns