- Notifications
You must be signed in to change notification settings - Fork928
feat: add--version
flag tocoder templates pull
, default to active version#10153
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
feat: add--version
flag tocoder templates pull
, default to active version#10153
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Current dependencies on/for this PR: This comment was auto-generated byGraphite. |
var latestVersion codersdk.TemplateVersion | ||
{ | ||
// Determine the latest template version and compare with the | ||
// active version. If they aren't the same, warn the user. | ||
versions, err := client.TemplateVersionsByTemplate(ctx, codersdk.TemplateVersionsByTemplateRequest{ | ||
TemplateID: template.ID, | ||
}) | ||
if err != nil { | ||
return xerrors.Errorf("template versions by template: %w", err) | ||
} | ||
if len(versions) == 0 { | ||
return xerrors.Errorf("no template versions for template %q", templateName) | ||
} | ||
// Sort the slice from newest to oldest template. | ||
sort.SliceStable(versions, func(i, j int) bool { | ||
return versions[i].CreatedAt.After(versions[j].CreatedAt) | ||
}) | ||
if len(versions) == 0 { | ||
return xerrors.Errorf("no template versions for template %q", templateName) | ||
latestVersion = versions[0] | ||
} |
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.
You should move this into the switch when you pick latest
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 need to know the latest version for the warning when the version isn't specified.
Fixes#9837